Browse Source

tuning makefile.msvc+mingw

Karel Miko 8 years ago
parent
commit
7ed5a832b0
3 changed files with 80 additions and 46 deletions
  1. 1 1
      helper.pl
  2. 10 10
      makefile.mingw
  3. 69 35
      makefile.msvc

+ 1 - 1
helper.pl

@@ -262,7 +262,7 @@ sub process_makefiles {
   # update OBJECTS + HEADERS in makefile*
   # update OBJECTS + HEADERS in makefile*
   for my $m (qw/ makefile makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) {
   for my $m (qw/ makefile makefile.shared makefile.unix makefile.mingw makefile.msvc makefile.include /) {
     my $old = read_file($m);
     my $old = read_file($m);
-    my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_to, @ver_version)
+    my $new = $m eq 'makefile.msvc' ? patch_makefile($old, $var_obj, $var_h, $var_tobj, @ver_version)
                                     : patch_makefile($old, $var_o, $var_h, $var_to, @ver_version);
                                     : patch_makefile($old, $var_o, $var_h, $var_to, @ver_version);
     if ($old ne $new) {
     if ($old ne $new) {
       write_file($m, $new) if $write;
       write_file($m, $new) if $write;

+ 10 - 10
makefile.mingw

@@ -7,13 +7,11 @@
 #
 #
 # gmake -f makefile.mingw all
 # gmake -f makefile.mingw all
 # test.exe
 # test.exe
-# gmake -f makefile.mingw install
+# gmake -f makefile.mingw DESTDIR=c:\devel\libtom install
 #
 #
 #OR:
 #OR:
 #
 #
 # gmake -f makefile.mingw CFLAGS="-O3 -DUSE_LTM -DLTM_DESC -Ic:/path/to/libtommath" EXTRALIBS="-Lc:/path/to/libtommath -ltommath" all
 # 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
 #
 #
 
 
 #The following can be overridden from command line e.g. make -f makefile.mingw CC=gcc ARFLAGS=rcs
 #The following can be overridden from command line e.g. make -f makefile.mingw CC=gcc ARFLAGS=rcs
@@ -254,24 +252,26 @@ $(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS)
 	$(STRIP) -S $(LIBMAIN_D)
 	$(STRIP) -S $(LIBMAIN_D)
 
 
 #Demo tools/utilities
 #Demo tools/utilities
-hashsum: demos/hashsum.o $(LIBMAIN_S)
+hashsum.exe: demos/hashsum.o $(LIBMAIN_S)
 	$(CC) $? $(LTC_LDFLAGS) -o $@
 	$(CC) $? $(LTC_LDFLAGS) -o $@
-crypt: demos/crypt.o $(LIBMAIN_S)
+ltcrypt.exe: demos/ltcrypt.o $(LIBMAIN_S)
 	$(CC) $? $(LTC_LDFLAGS) -o $@
 	$(CC) $? $(LTC_LDFLAGS) -o $@
-small: demos/small.o $(LIBMAIN_S)
+small.exe: demos/small.o $(LIBMAIN_S)
 	$(CC) $? $(LTC_LDFLAGS) -o $@
 	$(CC) $? $(LTC_LDFLAGS) -o $@
-tv_gen: demos/tv_gen.o $(LIBMAIN_S)
+tv_gen.exe: demos/tv_gen.o $(LIBMAIN_S)
 	$(CC) $? $(LTC_LDFLAGS) -o $@
 	$(CC) $? $(LTC_LDFLAGS) -o $@
 
 
 #Tests + timing tests
 #Tests + timing tests
-timing: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S)
+timing.exe: demos/timing.o $(LIBTEST_S) $(LIBMAIN_S)
 	$(CC) $? $(LTC_LDFLAGS) -o $@
 	$(CC) $? $(LTC_LDFLAGS) -o $@
 	@echo NOTICE: start the tests by: timing.exe
 	@echo NOTICE: start the tests by: timing.exe
-test: demos/test.o $(LIBMAIN_S) $(LIBTEST_S)
+test.exe: demos/test.o $(LIBMAIN_S) $(LIBTEST_S)
 	$(CC) $? $(LTC_LDFLAGS) -o $@
 	$(CC) $? $(LTC_LDFLAGS) -o $@
 	@echo NOTICE: start the tests by: test.exe
 	@echo NOTICE: start the tests by: test.exe
 
 
-all: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) hashsum crypt small tv_gen timing test
+all: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D) $(LIBTEST_S) hashsum.exe ltcrypt.exe small.exe tv_gen.exe timing.exe test.exe
+
+test: test.exe
 
 
 clean:
 clean:
 	@cmd /c del /Q /S *.o *.a *.exe *.dll 2>nul
 	@cmd /c del /Q /S *.o *.a *.exe *.dll 2>nul

+ 69 - 35
makefile.msvc

@@ -1,14 +1,33 @@
+# MAKEFILE for MS Windows (nmake + Windows SDK)
 #
 #
-# open a command prompt with WinSDK variables set
-# and start: nmake -f makefile.msvc
+# BEWARE: variables OBJECTS, TOBJECTS, HEADERS, VERSION are updated via ./updatemakes.sh
+
+### USAGE:
+# Open a command prompt with WinSDK variables set and start:
+#
+# nmake -f makefile.msvc all
+# test.exe
+# nmake -f makefile.msvc DESTDIR=c:\devel\libtom install
+#
+#OR:
 #
 #
+# nmake -f makefile.msvc CFLAGS="/DUSE_LTM /DLTM_DESC /Ic:\path\to\libtommath" EXTRALIBS="c:\path\to\libtommath\tommath.lib" all
+#
+
+#The following can be overridden from command line e.g. make -f makefile.msvc CC=gcc ARFLAGS=rcs
+DESTDIR   = c:\devel
+CFLAGS    = /Ox /DUSE_LTM /DLTM_DESC /I../libtommath
+EXTRALIBS = ../libtommath/tommath.lib
 
 
-EXTRALIBS=../libtommath/tommath.lib
-EXTRAINCLUDE=../libtommath
+#Compilation flags
+LTC_CFLAGS  = $(CFLAGS) /nologo /Isrc/headers/ /Itestprof/ /D_CRT_SECURE_NO_WARNINGS /DLTC_SOURCE /W3
+LTC_LDFLAGS = advapi32.lib $(EXTRALIBS)
 
 
-CFLAGS = /nologo /Isrc/headers/ /I$(EXTRAINCLUDE) /Itestprof/ /Ox /D_CRT_SECURE_NO_WARNINGS /DUSE_LTM /DLTM_DESC /DLTC_SOURCE /DLTC_NO_PROTOTYPES /W3 $(CF)
+#Libraries to be created
+LIBMAIN_S =tomcrypt.lib
+LIBTEST_S =tomcrypt_prof.lib
 
 
-# List of objects to compile (all goes to libtomcrypt.lib)
+#List of objects to compile (all goes to tomcrypt.lib)
 OBJECTS=src/ciphers/aes/aes.obj src/ciphers/aes/aes_enc.obj src/ciphers/anubis.obj src/ciphers/blowfish.obj \
 OBJECTS=src/ciphers/aes/aes.obj src/ciphers/aes/aes_enc.obj src/ciphers/anubis.obj src/ciphers/blowfish.obj \
 src/ciphers/camellia.obj src/ciphers/cast5.obj src/ciphers/des.obj src/ciphers/kasumi.obj src/ciphers/khazad.obj \
 src/ciphers/camellia.obj src/ciphers/cast5.obj src/ciphers/des.obj src/ciphers/kasumi.obj src/ciphers/khazad.obj \
 src/ciphers/kseed.obj src/ciphers/multi2.obj src/ciphers/noekeon.obj src/ciphers/rc2.obj src/ciphers/rc5.obj \
 src/ciphers/kseed.obj src/ciphers/multi2.obj src/ciphers/noekeon.obj src/ciphers/rc2.obj src/ciphers/rc5.obj \
@@ -160,51 +179,66 @@ src/stream/chacha/chacha_keystream.obj src/stream/chacha/chacha_setup.obj src/st
 src/stream/rc4/rc4.obj src/stream/rc4/rc4_test.obj src/stream/sober128/sober128.obj \
 src/stream/rc4/rc4.obj src/stream/rc4/rc4_test.obj src/stream/sober128/sober128.obj \
 src/stream/sober128/sober128_test.obj
 src/stream/sober128/sober128_test.obj
 
 
-# List of test objects to compile (all goes to libtomcrypt_prof.lib)
-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/misc_test.o testprof/modes_test.o testprof/multi_test.o testprof/no_prng.o \
-testprof/pkcs_1_eme_test.o testprof/pkcs_1_emsa_test.o testprof/pkcs_1_oaep_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
+#List of test objects to compile (all goes to tomcrypt_prof.lib)
+TOBJECTS=testprof/base64_test.obj testprof/cipher_hash_test.obj testprof/der_tests.obj testprof/dh_test.obj \
+testprof/dsa_test.obj testprof/ecc_test.obj testprof/file_test.obj testprof/katja_test.obj testprof/mac_test.obj \
+testprof/misc_test.obj testprof/modes_test.obj testprof/multi_test.obj testprof/no_prng.obj \
+testprof/pkcs_1_eme_test.obj testprof/pkcs_1_emsa_test.obj testprof/pkcs_1_oaep_test.obj \
+testprof/pkcs_1_pss_test.obj testprof/pkcs_1_test.obj testprof/rotate_test.obj testprof/rsa_test.obj \
+testprof/store_test.obj testprof/test_driver.obj testprof/x86_prof.obj
 
 
-# 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
 
 
-default: library
-
 .c.obj:
 .c.obj:
-	$(CC) $(CFLAGS) /c $< /Fo$@
+	$(CC) $(LTC_CFLAGS) /c $< /Fo$@
+
+#The default rule for make builds the tomcrypt.lib library (static)
+default: $(LIBMAIN_S)
 
 
 #ciphers come in two flavours... enc+dec and enc
 #ciphers come in two flavours... enc+dec and enc
 src/ciphers/aes/aes_enc.obj: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
 src/ciphers/aes/aes_enc.obj: src/ciphers/aes/aes.c src/ciphers/aes/aes_tab.c
-	$(CC) $(CFLAGS) /DENCRYPT_ONLY /c src/ciphers/aes/aes.c /Fosrc/ciphers/aes/aes_enc.obj
+	$(CC) $(LTC_CFLAGS) /DENCRYPT_ONLY /c src/ciphers/aes/aes.c /Fosrc/ciphers/aes/aes_enc.obj
 
 
-library: $(OBJECTS) $(TOBJECTS)
-	lib /out:tomcrypt.lib $(OBJECTS)
-	lib /out:tomcrypt_prof.lib $(TOBJECTS)
+$(LIBMAIN_S): $(OBJECTS)
+	lib /out:$(LIBMAIN_S) $(OBJECTS)
 
 
-tv_gen: demos/tv_gen.c library
-	cl $(CFLAGS) demos/tv_gen.c tomcrypt.lib advapi32.lib $(EXTRALIBS)
+$(LIBTEST_S): $(TOBJECTS)
+	lib /out:$(LIBTEST_S) $(TOBJECTS)
 
 
-hashsum: demos/hashsum.c library
-	cl $(CFLAGS) demos/hashsum.c tomcrypt.lib advapi32.lib $(EXTRALIBS)
+tv_gen.exe: demos/tv_gen.c $(LIBMAIN_S)
+	cl $(LTC_CFLAGS) demos/tv_gen.c $(LIBMAIN_S) $(LTC_LDFLAGS)
 
 
-test: demos/test.c library
-	cl $(CFLAGS) demos/test.c tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS)
+hashsum.exe: demos/hashsum.c $(LIBMAIN_S)
+	cl $(LTC_CFLAGS) demos/hashsum.c $(LIBMAIN_S) $(LTC_LDFLAGS)
 
 
-timing: demos/timing.c library
-	cl $(CFLAGS) demos/timing.c tomcrypt_prof.lib tomcrypt.lib advapi32.lib $(EXTRALIBS)
+ltcrypt.exe: demos/ltcrypt.c $(LIBMAIN_S)
+	cl $(LTC_CFLAGS) demos/ltcrypt.c $(LIBMAIN_S) $(LTC_LDFLAGS)
 
 
-all_test: test tv_gen hashsum timing
+small.exe: demos/small.c $(LIBMAIN_S)
+	cl $(LTC_CFLAGS) demos/small.c $(LIBMAIN_S) $(LTC_LDFLAGS)
 
 
-clean:
-	cmd /c del /Q /S *.OBJ *.LIB *.EXE
+test.exe: demos/test.c $(LIBMAIN_S) $(LIBTEST_S)
+	cl $(LTC_CFLAGS) demos/test.c $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS)
+
+timing.exe: demos/timing.c $(LIBMAIN_S) $(LIBTEST_S)
+	cl $(LTC_CFLAGS) demos/timing.c $(LIBTEST_S) $(LIBMAIN_S) $(LTC_LDFLAGS)
 
 
-# $Source$
-# $Revision$
-# $Date$
+all: $(LIBMAIN_S) $(LIBTEST_S) hashsum.exe ltcrypt.exe small.exe tv_gen.exe timing.exe test.exe
+
+test: test.exe
+
+clean:
+	@cmd /c del /Q /S *.OBJ *.LIB *.EXE *.DLL 2>nul
+
+install: $(LIBMAIN_S) $(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 hashsum.exe "$(DESTDIR)\bin"
+	copy /Y $(LIBMAIN_S) "$(DESTDIR)\lib"
+	copy /Y src\headers\tomcrypt*.h "$(DESTDIR)\include"