Merge pull request #578 from PX4/fix_mp_prime_strong_lucas_lefridge_compilation
[libtommath.git] / makefile.unix
blob58642098dcac1ae6c5e398a79cf706802ebc6537
1 # MAKEFILE that is intended to be compatible with any kind of make (GNU make, BSD make, ...)
2 # works on: Linux, *BSD, Cygwin, AIX, HP-UX and hopefully other UNIX systems
4 # Please do not use here neither any special make syntax nor any unusual tools/utilities!
6 # using ICC compiler:
7 # make -f makefile.unix CC=icc CFLAGS="-O3 -xP -ip"
9 # using Borland C++Builder:
10 # make -f makefile.unix CC=bcc32
12 #The following can be overridden from command line e.g. "make -f makefile.unix CC=gcc ARFLAGS=rcs"
13 DESTDIR   =
14 PREFIX    = /usr/local
15 LIBPATH   = $(PREFIX)/lib
16 INCPATH   = $(PREFIX)/include
17 CC        = cc
18 AR        = ar
19 ARFLAGS   = rcs
20 CFLAGS    = -O2
21 LDFLAGS   =
23 VERSION   = 1.3.0
25 #Compilation flags
26 LTM_CFLAGS  = -I. $(CFLAGS)
27 LTM_LDFLAGS = $(LDFLAGS)
29 #Library to be created (this makefile builds only static library)
30 LIBMAIN_S = libtommath.a
32 OBJECTS=mp_2expt.o mp_abs.o mp_add.o mp_add_d.o mp_addmod.o mp_and.o mp_clamp.o mp_clear.o mp_clear_multi.o \
33 mp_cmp.o mp_cmp_d.o mp_cmp_mag.o mp_cnt_lsb.o mp_complement.o mp_copy.o mp_count_bits.o mp_cutoffs.o \
34 mp_div.o mp_div_2.o mp_div_2d.o mp_div_d.o mp_dr_is_modulus.o mp_dr_reduce.o mp_dr_setup.o \
35 mp_error_to_string.o mp_exch.o mp_expt_n.o mp_exptmod.o mp_exteuclid.o mp_fread.o mp_from_sbin.o \
36 mp_from_ubin.o mp_fwrite.o mp_gcd.o mp_get_double.o mp_get_i32.o mp_get_i64.o mp_get_l.o mp_get_mag_u32.o \
37 mp_get_mag_u64.o mp_get_mag_ul.o mp_grow.o mp_hash.o mp_init.o mp_init_copy.o mp_init_i32.o mp_init_i64.o \
38 mp_init_l.o mp_init_multi.o mp_init_set.o mp_init_size.o mp_init_u32.o mp_init_u64.o mp_init_ul.o \
39 mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o mp_log.o mp_log_n.o mp_lshd.o mp_mod.o mp_mod_2d.o \
40 mp_montgomery_calc_normalization.o mp_montgomery_reduce.o mp_montgomery_setup.o mp_mul.o mp_mul_2.o \
41 mp_mul_2d.o mp_mul_d.o mp_mulmod.o mp_neg.o mp_or.o mp_pack.o mp_pack_count.o mp_prime_fermat.o \
42 mp_prime_frobenius_underwood.o mp_prime_is_prime.o mp_prime_miller_rabin.o mp_prime_next_prime.o \
43 mp_prime_rabin_miller_trials.o mp_prime_rand.o mp_prime_strong_lucas_selfridge.o mp_radix_size.o \
44 mp_radix_size_overestimate.o mp_rand.o mp_rand_source.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o \
45 mp_reduce_2k_l.o mp_reduce_2k_setup.o mp_reduce_2k_setup_l.o mp_reduce_is_2k.o mp_reduce_is_2k_l.o \
46 mp_reduce_setup.o mp_root_n.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o \
47 mp_set_l.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_shrink.o mp_signed_rsh.o mp_sqrmod.o mp_sqrt.o \
48 mp_sqrtmod_prime.o mp_sub.o mp_sub_d.o mp_submod.o mp_to_radix.o mp_to_sbin.o mp_to_ubin.o mp_ubin_size.o \
49 mp_unpack.o mp_warray_free.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o \
50 s_mp_div_recursive.o s_mp_div_school.o s_mp_div_small.o s_mp_exptmod.o s_mp_exptmod_fast.o s_mp_fp_log.o \
51 s_mp_fp_log_d.o s_mp_get_bit.o s_mp_invmod.o s_mp_invmod_odd.o s_mp_log_2expt.o \
52 s_mp_montgomery_reduce_comba.o s_mp_mul.o s_mp_mul_balance.o s_mp_mul_comba.o s_mp_mul_high.o \
53 s_mp_mul_high_comba.o s_mp_mul_karatsuba.o s_mp_mul_toom.o s_mp_prime_is_divisible.o s_mp_prime_tab.o \
54 s_mp_radix_map.o s_mp_radix_size_overestimate.o s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o \
55 s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o s_mp_warray.o s_mp_warray_get.o s_mp_warray_put.o \
56 s_mp_zero_buf.o s_mp_zero_digs.o
59 HEADERS_PUB=tommath.h
60 HEADERS=tommath_private.h tommath_class.h tommath_superclass.h tommath_cutoffs.h $(HEADERS_PUB)
62 #The default rule for make builds the libtommath.a library (static)
63 default: $(LIBMAIN_S)
65 #Dependencies on *.h
66 $(OBJECTS): $(HEADERS)
68 #This is necessary for compatibility with BSD make (namely on OpenBSD)
69 .SUFFIXES: .o .c
70 .c.o:
71         $(CC) $(LTM_CFLAGS) -c $< -o $@
73 #Create libtommath.a
74 $(LIBMAIN_S): $(OBJECTS)
75         $(AR) $(ARFLAGS) $@ $(OBJECTS)
77 #Build test_standalone suite
78 test: demo/shared.o demo/test.o $(LIBMAIN_S)
79         $(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -o $@
80         @echo "NOTICE: start the tests by: ./test"
82 all: $(LIBMAIN_S) test
84 tune: $(LIBMAIN_S)
85         $(MAKE) -C etc tune
86         $(MAKE)
88 #NOTE: this makefile works also on cygwin, thus we need to delete *.exe
89 clean:
90         -@rm -f $(OBJECTS) $(LIBMAIN_S)
91         -@rm -f demo/main.o demo/opponent.o demo/test.o test test.exe
93 #Install the library + headers
94 install: $(LIBMAIN_S)
95         @mkdir -p $(DESTDIR)$(INCPATH) $(DESTDIR)$(LIBPATH)/pkgconfig
96         @cp $(LIBMAIN_S) $(DESTDIR)$(LIBPATH)/
97         @cp $(HEADERS_PUB) $(DESTDIR)$(INCPATH)/
98         @sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION),' libtommath.pc.in > $(DESTDIR)$(LIBPATH)/pkgconfig/libtommath.pc