re-work makefile.mingw in the same style as makefile.unix

This commit is contained in:
Karel Miko 2017-05-03 07:36:05 +02:00 committed by Steffen Jaeckel
parent c225f22a23
commit f544418d56

View File

@ -1,38 +1,42 @@
# MAKEFILE for MS Windows (mingw + gcc + gmake)
# #
# open a command prompt with gcc + gmake in PATH # BEWARE: variables OBJECTS, TOBJECTS, HEADERS, VERSION are updated via ./updatemakes.sh
# and start: gmake -f makefile.mingw
### USAGE:
# Open a command prompt with gcc + gmake in PATH and start:
#
# gmake -f makefile.mingw all
# test.exe
# gmake -f makefile.mingw install
#
#OR:
#
# gmake -f makefile.mingw CFLAGS="-O3 -DUSE_LTM -DLTM_DESC -Ic:/path/to/libtommath" EXTRALIBS="-Lc:/path/to/libtommath -ltommath" all
# test.exe
# gmake -f makefile.mingw DESTDIR=c:\devel\libtom install
# #
EXTRALIBS=../libtommath/libtommath.a #The following can be overridden from command line e.g. make -f makefile.mingw CC=gcc ARFLAGS=rcs
EXTRAINCLUDE=../libtommath DESTDIR = c:\mingw
CC = gcc
AR = ar
ARFLAGS = r
RANLIB = ranlib
STRIP = strip
CFLAGS = -O2 -DUSE_LTM -DLTM_DESC -I../libtommath
EXTRALIBS = -L../libtommath -ltommath
CFLAGS = -Wall -Wextra -c -I./src/headers -I$(EXTRAINCLUDE) -I./testprof -DUSE_LTM -DLTM_DESC -DLTC_SOURCE -DLTC_NO_PROTOTYPES -O2 ${CFLAGS_OPTS} #Compilation flags
LTC_CFLAGS = $(CFLAGS) -Isrc/headers -Itestprof -DLTC_SOURCE
LTC_LDFLAGS = $(LDFLAGS) $(EXTRALIBS)
# Compiler and Linker Names #Libraries to be created
CC=gcc LIBMAIN_S =libtomcrypt.a
LD=ld LIBMAIN_I =libtomcrypt.dll.a
AR=ar LIBMAIN_D =libtomcrypt.dll
ARFLAGS=rc LIBTEST_S =libtomcrypt_prof.a
RANLIB=ranlib
LIBNAME=libtomcrypt.a #List of objects to compile (all goes to libtomcrypt.a)
LIBTEST=libtomcrypt_prof.a
HASH=hashsum
CRYPT=encrypt
SMALL=small
PROF=x86_prof
TV=tv_gen
TIMING=timing
TEST=test
#LIBPATH-The directory for libtomcrypt to be installed to.
#INCPATH-The directory to install the header files for libtomcrypt.
INSTPREFIX=c:\devel-libtom
LIBPATH=$(INSTPREFIX)\lib
INCPATH=$(INSTPREFIX)\include
# List of objects to compile (all goes to libtomcrypt.a)
OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \ OBJECTS=src/ciphers/aes/aes.o src/ciphers/aes/aes_enc.o src/ciphers/anubis.o src/ciphers/blowfish.o \
src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \ src/ciphers/camellia.o src/ciphers/cast5.o src/ciphers/des.o src/ciphers/kasumi.o src/ciphers/khazad.o \
src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \ src/ciphers/kseed.o src/ciphers/multi2.o src/ciphers/noekeon.o src/ciphers/rc2.o src/ciphers/rc5.o \
@ -184,7 +188,7 @@ src/stream/chacha/chacha_keystream.o src/stream/chacha/chacha_setup.o src/stream
src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \ src/stream/rc4/rc4.o src/stream/rc4/rc4_test.o src/stream/sober128/sober128.o \
src/stream/sober128/sober128_test.o src/stream/sober128/sober128_test.o
# List of test objects to compile (all goes to libtomcrypt_prof.a) #List of test objects to compile (all goes to libtomcrypt_prof.a)
TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \ TOBJECTS=testprof/base64_test.o testprof/cipher_hash_test.o testprof/der_tests.o testprof/dh_test.o \
testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \ testprof/dsa_test.o testprof/ecc_test.o testprof/file_test.o testprof/katja_test.o testprof/mac_test.o \
testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \ testprof/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \
@ -192,29 +196,24 @@ testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_test
testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \ testprof/pkcs_1_pss_test.o testprof/pkcs_1_test.o testprof/rotate_test.o testprof/rsa_test.o \
testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o testprof/store_test.o testprof/test_driver.o testprof/x86_prof.o
# The following headers will be installed by "make install" #The following headers will be installed by "make install"
HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \ HEADERS=src/headers/tomcrypt.h src/headers/tomcrypt_argchk.h src/headers/tomcrypt_cfg.h \
src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \ src/headers/tomcrypt_cipher.h src/headers/tomcrypt_custom.h src/headers/tomcrypt_hash.h \
src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \ src/headers/tomcrypt_mac.h src/headers/tomcrypt_macros.h src/headers/tomcrypt_math.h \
src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \ src/headers/tomcrypt_misc.h src/headers/tomcrypt_pk.h src/headers/tomcrypt_pkcs.h \
src/headers/tomcrypt_prng.h src/headers/tomcrypt_prng.h
TESTOBJECTS=demos/test.o .c.o:
HASHOBJECTS=demos/hashsum.o $(CC) $(LTC_CFLAGS) -c $< -o $@
CRYPTOBJECTS=demos/encrypt.o
SMALLOBJECTS=demos/small.o
TVS=demos/tv_gen.o
TIMINGS=demos/timing.o
TESTS=demos/test.o
#The default rule for make builds the libtomcrypt library. #The default rule for make builds the libtomcrypt.a library (static)
default:library default: $(LIBMAIN_S)
#ciphers come in two flavours... enc+dec and enc #SPECIAL: AES comes in two flavours - enc+dec and enc-only
src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c src/ciphers/aes/aes_enc.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
$(CC) $(CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o $(CC) $(LTC_CFLAGS) -DENCRYPT_ONLY -c src/ciphers/aes/aes.c -o src/ciphers/aes/aes_enc.o
#These are the rules to make certain object files. #SPECIAL: these are the rules to make certain object files
src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c src/ciphers/aes/aes.o: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c src/ciphers/twofish/twofish.o: src/ciphers/twofish/twofish.c src/ciphers/twofish/twofish_tab.c
src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c src/hashes/whirl/whirl.o: src/hashes/whirl/whirl.c src/hashes/whirl/whirltab.c
@ -223,58 +222,53 @@ src/hashes/sha2/sha512_224.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_22
src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c src/hashes/sha2/sha512_256.o: src/hashes/sha2/sha512.c src/hashes/sha2/sha512_256.c
src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c src/hashes/sha2/sha256.o: src/hashes/sha2/sha256.c src/hashes/sha2/sha224.c
#This rule makes the libtomcrypt library.
library: $(LIBNAME)
#Dependencies on *.h #Dependencies on *.h
$(OBJECTS): $(HEADERS) $(OBJECTS): $(HEADERS)
$(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h $(TOBJECTS): $(HEADERS) testprof/tomcrypt_test.h
$(LIBTEST): $(TOBJECTS) #Create libtomcrypt_prof.a
$(LIBTEST_S): $(TOBJECTS)
$(AR) $(ARFLAGS) $@ $(TOBJECTS) $(AR) $(ARFLAGS) $@ $(TOBJECTS)
$(RANLIB) $@ $(RANLIB) $@
%.o: %.c #Create libtomcrypt.a
${CC} ${CFLAGS} -c $< -o $@ $(LIBMAIN_S): $(OBJECTS)
$(LIBNAME): $(OBJECTS)
$(AR) $(ARFLAGS) $@ $(OBJECTS) $(AR) $(ARFLAGS) $@ $(OBJECTS)
$(RANLIB) $@ $(RANLIB) $@
#This rule makes the hash program included with libtomcrypt #Create DLL + import library libtomcrypt.dll.a
hashsum: library $(HASHOBJECTS) $(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS)
$(CC) $(HASHOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(HASH) $(WARN) $(CC) -s -shared -o $(LIBMAIN_D) $^ -Wl,--enable-auto-import,--export-all -Wl,--out-implib=$(LIBMAIN_I) $(LTC_LDFLAGS)
$(STRIP) -S $(LIBMAIN_D)
#makes the crypt program #Demo tools/utilities
crypt: library $(CRYPTOBJECTS) hashsum: demos/hashsum.o $(LIBMAIN_S)
$(CC) $(CRYPTOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(CRYPT) $(WARN) $(CC) demos/hashsum.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
crypt: demos/crypt.o $(LIBMAIN_S)
$(CC) demos/crypt.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
small: demos/small.o $(LIBMAIN_S)
$(CC) demos/small.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
tv_gen: demos/tv_gen.o $(LIBMAIN_S)
$(CC) demos/tv_gen.o $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
#makes the small program #Tests + timing tests
small: library $(SMALLOBJECTS) timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S)
$(CC) $(SMALLOBJECTS) $(LIBNAME) $(EXTRALIBS) -o $(SMALL) $(WARN) $(CC) demos/timing.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
@echo NOTICE: start the tests by: timing.exe
test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S)
$(CC) demos/test.o $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS) -o $@
@echo NOTICE: start the tests by: test.exe
tv_gen: library $(TVS) all: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) hashsum crypt small tv_gen timing test
$(CC) $(LDFLAGS) $(TVS) $(LIBNAME) $(EXTRALIBS) -o $(TV)
timing: library $(LIBTEST) $(TIMINGS)
$(CC) $(LDFLAGS) $(TIMINGS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TIMING)
.PHONY: test
test: library $(LIBTEST) $(TESTS)
$(CC) $(LDFLAGS) $(TESTS) $(LIBTEST) $(LIBNAME) $(EXTRALIBS) -o $(TEST)
all_test: test tv_gen hashsum crypt small timing
install: library
cmd /c if not exist "$(LIBPATH)" mkdir "$(LIBPATH)"
cmd /c if not exist "$(INCPATH)" mkdir "$(INCPATH)"
copy /Y $(LIBNAME) "$(LIBPATH)"
copy /Y src\headers\tomcrypt*.h "$(INCPATH)"
install_test: $(LIBTEST)
cmd /c if not exist "$(LIBPATH)" mkdir "$(LIBPATH)"
copy /Y testprof\$(LIBTEST) "$(LIBPATH)"
clean: clean:
cmd /c del /Q /S *.o *.a *.exe @cmd /c del /Q /S *.o *.a *.exe *.dll 2>nul
$(MAKE) -C testprof -f makefile.mingw clean
install: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S)
cmd /c if not exist "$(DESTDIR)\bin" mkdir "$(DESTDIR)\bin"
cmd /c if not exist "$(DESTDIR)\lib" mkdir "$(DESTDIR)\lib"
cmd /c if not exist "$(DESTDIR)\include" mkdir "$(DESTDIR)\include"
copy /Y $(LIBMAIN_S) "$(DESTDIR)\lib"
copy /Y $(LIBMAIN_I) "$(DESTDIR)\lib"
copy /Y $(LIBMAIN_D) "$(DESTDIR)\bin"
copy /Y src\headers\tomcrypt*.h "$(DESTDIR)\include"