PROJECT(LIB_TOMMATH)

INCLUDE_DIRECTORIES(${LIB_TOMMATH_SOURCE_DIR})

SET(LIB_TOMMATH_SRC
  ${LIB_TOMMATH_SOURCE_DIR}/
  ${LIB_TOMMATH_SOURCE_DIR}/bncore.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_init.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_clear.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_exch.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_grow.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_shrink.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_clamp.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_zero.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_set.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_set_int.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_init_size.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_copy.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_init_copy.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_abs.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_neg.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_cmp_mag.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_cmp.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_cmp_d.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_rshd.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_lshd.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_mod_2d.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_div_2d.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_mul_2d.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_div_2.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_mul_2.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_s_mp_add.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_s_mp_sub.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_fast_s_mp_mul_digs.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_s_mp_mul_digs.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_fast_s_mp_mul_high_digs.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_s_mp_mul_high_digs.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_fast_s_mp_sqr.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_s_mp_sqr.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_add.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_sub.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_karatsuba_mul.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_mul.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_karatsuba_sqr.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_sqr.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_div.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_mod.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_add_d.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_sub_d.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_mul_d.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_div_d.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_mod_d.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_expt_d.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_addmod.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_submod.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_mulmod.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_sqrmod.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_gcd.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_lcm.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_fast_mp_invmod.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_invmod.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_reduce.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_montgomery_setup.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_fast_mp_montgomery_reduce.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_montgomery_reduce.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_exptmod_fast.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_exptmod.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_2expt.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_n_root.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_jacobi.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_reverse.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_count_bits.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_read_unsigned_bin.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_read_signed_bin.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_to_unsigned_bin.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_to_signed_bin.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_unsigned_bin_size.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_signed_bin_size.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_xor.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_and.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_or.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_rand.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_montgomery_calc_normalization.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_prime_is_divisible.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_prime_tab.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_prime_fermat.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_prime_miller_rabin.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_prime_is_prime.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_prime_next_prime.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_dr_reduce.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_dr_is_modulus.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_dr_setup.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_reduce_setup.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_toom_mul.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_toom_sqr.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_div_3.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_s_mp_exptmod.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_reduce_2k.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_reduce_is_2k.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_reduce_2k_setup.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_reduce_2k_l.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_reduce_is_2k_l.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_reduce_2k_setup_l.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_radix_smap.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_read_radix.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_toradix.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_radix_size.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_fread.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_fwrite.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_cnt_lsb.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_error.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_init_multi.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_clear_multi.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_exteuclid.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_toradix_n.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_prime_random_ex.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_get_int.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_sqrt.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_is_square.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_init_set.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_init_set_int.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_invmod_slow.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_prime_rabin_miller_trials.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_to_signed_bin_n.c
  ${LIB_TOMMATH_SOURCE_DIR}/bn_mp_to_unsigned_bin_n.c
)

ADD_LIBRARY(lib_tommath EXCLUDE_FROM_ALL SHARED ${LIB_TOMMATH_SRC})
SET_TARGET_PROPERTIES(lib_tommath PROPERTIES
    OUTPUT_NAME tommath
    COMPILE_FLAGS "-fPIC") #necessary so that the lib can be used linked in a static code or a shared library

