1 # makefile for TomsFastMath, a fast ISO C bignum library. -- Tom St Denis
2 # SPDX-License-Identifier: Unlicense
9 LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC)
11 INSTALL_CMD = $(LT) --mode=install install
12 UNINSTALL_CMD = $(LT) --mode=uninstall rm
15 include makefile_include.mk
18 OBJECTS=src/addsub/fp_add.o src/addsub/fp_add_d.o src/addsub/fp_addmod.o src/addsub/fp_cmp.o \
19 src/addsub/fp_cmp_d.o src/addsub/fp_cmp_mag.o src/addsub/fp_sub.o src/addsub/fp_sub_d.o \
20 src/addsub/fp_submod.o src/addsub/s_fp_add.o src/addsub/s_fp_sub.o src/bin/fp_radix_size.o \
21 src/bin/fp_read_radix.o src/bin/fp_read_signed_bin.o src/bin/fp_read_unsigned_bin.o \
22 src/bin/fp_reverse.o src/bin/fp_s_rmap.o src/bin/fp_signed_bin_size.o src/bin/fp_to_signed_bin.o \
23 src/bin/fp_to_unsigned_bin.o src/bin/fp_toradix.o src/bin/fp_toradix_n.o src/bin/fp_unsigned_bin_size.o \
24 src/bit/fp_cnt_lsb.o src/bit/fp_count_bits.o src/bit/fp_div_2.o src/bit/fp_div_2d.o src/bit/fp_lshd.o \
25 src/bit/fp_mod_2d.o src/bit/fp_rshd.o src/divide/fp_div.o src/divide/fp_div_d.o src/divide/fp_mod.o \
26 src/divide/fp_mod_d.o src/exptmod/fp_2expt.o src/exptmod/fp_exptmod.o src/misc/fp_ident.o \
27 src/misc/fp_rand.o src/misc/fp_set.o src/mont/fp_montgomery_calc_normalization.o \
28 src/mont/fp_montgomery_reduce.o src/mont/fp_montgomery_setup.o src/mul/fp_mul.o src/mul/fp_mul_2.o \
29 src/mul/fp_mul_2d.o src/mul/fp_mul_comba.o src/mul/fp_mul_comba_12.o src/mul/fp_mul_comba_17.o \
30 src/mul/fp_mul_comba_20.o src/mul/fp_mul_comba_24.o src/mul/fp_mul_comba_28.o src/mul/fp_mul_comba_3.o \
31 src/mul/fp_mul_comba_32.o src/mul/fp_mul_comba_4.o src/mul/fp_mul_comba_48.o src/mul/fp_mul_comba_6.o \
32 src/mul/fp_mul_comba_64.o src/mul/fp_mul_comba_7.o src/mul/fp_mul_comba_8.o src/mul/fp_mul_comba_9.o \
33 src/mul/fp_mul_comba_small_set.o src/mul/fp_mul_d.o src/mul/fp_mulmod.o src/numtheory/fp_gcd.o \
34 src/numtheory/fp_invmod.o src/numtheory/fp_isprime.o src/numtheory/fp_isprime_ex.o \
35 src/numtheory/fp_lcm.o src/numtheory/fp_prime_miller_rabin.o src/numtheory/fp_prime_random_ex.o \
36 src/sqr/fp_sqr.o src/sqr/fp_sqr_comba.o src/sqr/fp_sqr_comba_12.o src/sqr/fp_sqr_comba_17.o \
37 src/sqr/fp_sqr_comba_20.o src/sqr/fp_sqr_comba_24.o src/sqr/fp_sqr_comba_28.o src/sqr/fp_sqr_comba_3.o \
38 src/sqr/fp_sqr_comba_32.o src/sqr/fp_sqr_comba_4.o src/sqr/fp_sqr_comba_48.o src/sqr/fp_sqr_comba_6.o \
39 src/sqr/fp_sqr_comba_64.o src/sqr/fp_sqr_comba_7.o src/sqr/fp_sqr_comba_8.o src/sqr/fp_sqr_comba_9.o \
40 src/sqr/fp_sqr_comba_generic.o src/sqr/fp_sqr_comba_small_set.o src/sqr/fp_sqrmod.o
42 LOBJECTS = $(OBJECTS:.o=.lo)
44 HEADERS_PUB=src/headers/tfm.h
45 HEADERS=src/headers/tfm_private.h $(HEADERS_PUB)
50 $(OBJECTS): $(HEADERS)
53 $(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -o $@ -c $<
55 $(LIBNAME): $(OBJECTS)
56 $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(LDFLAGS) $(LOBJECTS) -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION_LIB)
58 install: .common_install
59 sed -e 's,^prefix=.*,prefix=$(PREFIX),' -e 's,^Version:.*,Version: $(VERSION_PC),' -e 's,@CMAKE_INSTALL_LIBDIR@,lib,' \
60 -e 's,@CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@,include/tomsfastmath,' tomsfastmath.pc.in > tomsfastmath.pc
61 install -d $(DESTDIR)$(LIBPATH)/pkgconfig
62 install -m 644 tomsfastmath.pc $(DESTDIR)$(LIBPATH)/pkgconfig/
64 uninstall: .common_uninstall
65 rm $(DESTDIR)$(LIBPATH)/pkgconfig/tomsfastmath.pc
68 test: $(LIBNAME) demo/test.o
69 $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o test demo/test.o $(LIBNAME)
71 test_standalone: CFLAGS+=-DTFM_DEMO_TEST_VS_MTEST=0
73 .PHONY: test_standalone
74 test_standalone: $(LIBNAME) demo/test.o
75 $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o test demo/test.o $(LIBNAME)
77 stest: $(LIBNAME) demo/stest.o
78 $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o stest demo/stest.o $(LIBNAME)
81 timing: $(LIBNAME) demo/timing.o
82 $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o timing demo/timing.o $(LIBNAME)