100 lines
4.3 KiB
Plaintext
100 lines
4.3 KiB
Plaintext
# MAKEFILE for MS Windows (mingw + gcc + gmake)
|
|
#
|
|
# BEWARE: variable OBJECTS is updated via helper.pl
|
|
|
|
### USAGE:
|
|
# Open a command prompt with gcc + gmake in PATH and start:
|
|
#
|
|
# gmake -f makefile.mingw all
|
|
# test.exe
|
|
# gmake -f makefile.mingw PREFIX=c:\devel\libtom install
|
|
|
|
#The following can be overridden from command line e.g. make -f makefile.mingw CC=gcc ARFLAGS=rcs
|
|
PREFIX = c:\mingw
|
|
CC = gcc
|
|
AR = ar
|
|
ARFLAGS = rcs
|
|
STRIP = strip
|
|
CFLAGS = -O2
|
|
LDFLAGS =
|
|
|
|
#Compilation flags
|
|
LTM_CFLAGS = -I. $(CFLAGS)
|
|
LTM_LDFLAGS = $(LDFLAGS) -static-libgcc
|
|
|
|
#Libraries to be created
|
|
LIBMAIN_S =libtommath.a
|
|
LIBMAIN_I =libtommath.dll.a
|
|
LIBMAIN_D =libtommath.dll
|
|
|
|
#List of objects to compile (all goes to libtommath.a)
|
|
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 \
|
|
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 \
|
|
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 \
|
|
mp_error_to_string.o mp_exch.o mp_expt_u32.o mp_exptmod.o mp_exteuclid.o mp_fread.o mp_from_sbin.o \
|
|
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_ll.o \
|
|
mp_get_mag_u32.o mp_get_mag_u64.o mp_get_mag_ul.o mp_get_mag_ull.o mp_grow.o mp_init.o mp_init_copy.o \
|
|
mp_init_i32.o mp_init_i64.o mp_init_l.o mp_init_ll.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 mp_init_ull.o mp_invmod.o mp_is_square.o mp_kronecker.o mp_lcm.o \
|
|
mp_log_u32.o mp_lshd.o mp_mod.o mp_mod_2d.o mp_montgomery_calc_normalization.o mp_montgomery_reduce.o \
|
|
mp_montgomery_setup.o mp_mul.o mp_mul_2.o 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 mp_prime_frobenius_underwood.o mp_prime_is_prime.o \
|
|
mp_prime_miller_rabin.o mp_prime_next_prime.o mp_prime_rabin_miller_trials.o mp_prime_rand.o \
|
|
mp_prime_strong_lucas_selfridge.o mp_radix_size.o mp_rand.o mp_read_radix.o mp_reduce.o mp_reduce_2k.o \
|
|
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 \
|
|
mp_reduce_setup.o mp_root_u32.o mp_rshd.o mp_sbin_size.o mp_set.o mp_set_double.o mp_set_i32.o mp_set_i64.o \
|
|
mp_set_l.o mp_set_ll.o mp_set_u32.o mp_set_u64.o mp_set_ul.o mp_set_ull.o mp_shrink.o mp_signed_rsh.o \
|
|
mp_sqrmod.o mp_sqrt.o 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 mp_unpack.o mp_xor.o mp_zero.o s_mp_add.o s_mp_copy_digs.o s_mp_div_3.o \
|
|
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_get_bit.o \
|
|
s_mp_invmod.o s_mp_invmod_odd.o s_mp_log.o s_mp_log_d.o s_mp_log_pow2.o 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 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 s_mp_radix_map.o s_mp_rand_jenkins.o \
|
|
s_mp_rand_platform.o s_mp_sqr.o s_mp_sqr_comba.o s_mp_sqr_karatsuba.o s_mp_sqr_toom.o s_mp_sub.o \
|
|
s_mp_zero_buf.o s_mp_zero_digs.o
|
|
|
|
HEADERS_PUB=tommath.h
|
|
HEADERS=tommath_private.h tommath_class.h tommath_superclass.h tommath_cutoffs.h $(HEADERS_PUB)
|
|
|
|
#The default rule for make builds the libtommath.a library (static)
|
|
default: $(LIBMAIN_S)
|
|
|
|
#Dependencies on *.h
|
|
$(OBJECTS): $(HEADERS)
|
|
|
|
.c.o:
|
|
$(CC) $(LTM_CFLAGS) -c $< -o $@
|
|
|
|
#Create libtommath.a
|
|
$(LIBMAIN_S): $(OBJECTS)
|
|
$(AR) $(ARFLAGS) $@ $(OBJECTS)
|
|
|
|
#Create DLL + import library libtommath.dll.a
|
|
$(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS)
|
|
$(CC) -s -shared -o $(LIBMAIN_D) $^ tommath.def -Wl,--out-implib=$(LIBMAIN_I) $(LTM_LDFLAGS)
|
|
$(STRIP) -S $(LIBMAIN_D)
|
|
|
|
#Build test suite
|
|
test.exe: demo/shared.o demo/test.o $(LIBMAIN_S)
|
|
$(CC) $(LTM_CFLAGS) $(LTM_LDFLAGS) $^ -o $@
|
|
@echo NOTICE: start the tests by launching test.exe
|
|
|
|
all: $(LIBMAIN_S) test.exe
|
|
|
|
tune: $(LIBNAME_S)
|
|
$(MAKE) -C etc tune
|
|
$(MAKE)
|
|
|
|
clean:
|
|
@-cmd /c del /Q /S *.o *.a *.exe *.dll 2>nul
|
|
|
|
#Install the library + headers
|
|
install: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D)
|
|
cmd /c if not exist "$(PREFIX)\bin" mkdir "$(PREFIX)\bin"
|
|
cmd /c if not exist "$(PREFIX)\lib" mkdir "$(PREFIX)\lib"
|
|
cmd /c if not exist "$(PREFIX)\include" mkdir "$(PREFIX)\include"
|
|
copy /Y $(LIBMAIN_S) "$(PREFIX)\lib"
|
|
copy /Y $(LIBMAIN_I) "$(PREFIX)\lib"
|
|
copy /Y $(LIBMAIN_D) "$(PREFIX)\bin"
|
|
copy /Y tommath*.h "$(PREFIX)\include"
|