update makefile.msvc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
diff --git a/makefile.msvc b/makefile.msvc
index 6e89506..68a7088 100644
--- a/makefile.msvc
+++ b/makefile.msvc
@@ -1,12 +1,26 @@
-#MSVC Makefile
+# MAKEFILE for MS Windows (nmake + Windows SDK)
#
-#Tom St Denis
+# BEWARE: variable OBJECTS is updated via ./updatemakes.sh
-LTM_CFLAGS = /Ox /nologo /I. /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /W3 $(CFLAGS)
+### USAGE:
+# Open a command prompt with WinSDK variables set and start:
+#
+# nmake -f makefile.msvc all
+# test.exe
+# nmake -f makefile.msvc PREFIX=c:\devel\libtom install
+
+#The following can be overridden from command line e.g. make -f makefile.msvc CC=gcc ARFLAGS=rcs
+PREFIX = c:\devel
+CFLAGS = /Ox
+
+#Compilation flags
+LTM_CFLAGS = /nologo /I./ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /W3 $(CFLAGS)
+LTM_LDFLAGS = advapi32.lib
-default: library
+#Libraries to be created (this makefile builds only static libraries)
+LIBMAIN_S =tommath.lib
-#START_INS
+#List of objects to compile (all goes to tommath.lib)
OBJECTS=bn_error.obj bn_fast_mp_invmod.obj bn_fast_mp_montgomery_reduce.obj bn_fast_s_mp_mul_digs.obj \
bn_fast_s_mp_mul_high_digs.obj bn_fast_s_mp_sqr.obj bn_mp_2expt.obj bn_mp_abs.obj bn_mp_add.obj bn_mp_add_d.obj \
bn_mp_addmod.obj bn_mp_and.obj bn_mp_clamp.obj bn_mp_clear.obj bn_mp_clear_multi.obj bn_mp_cmp.obj bn_mp_cmp_d.obj \
@@ -33,12 +47,43 @@ bn_mp_to_unsigned_bin_n.obj bn_mp_toom_mul.obj bn_mp_toom_sqr.obj bn_mp_toradix.
bn_mp_unsigned_bin_size.obj bn_mp_xor.obj bn_mp_zero.obj bn_prime_tab.obj bn_reverse.obj bn_s_mp_add.obj \
bn_s_mp_exptmod.obj bn_s_mp_mul_digs.obj bn_s_mp_mul_high_digs.obj bn_s_mp_sqr.obj bn_s_mp_sub.obj bncore.obj
-#END_INS
+HEADERS_PUB=tommath.h tommath_class.h tommath_superclass.h
-HEADERS=tommath.h tommath_class.h tommath_private.h tommath_superclass.h
+HEADERS=tommath_private.h $(HEADERS_PUB)
-library: $(OBJECTS)
- lib /out:tommath.lib $(OBJECTS)
+#The default rule for make builds the tommath.lib library (static)
+default: $(LIBMAIN_S)
+
+#Dependencies on *.h
+$(OBJECTS): $(HEADERS)
.c.obj:
$(CC) $(LTM_CFLAGS) /c $< /Fo$@
+
+#Create tomcrypt.lib
+$(LIBMAIN_S): $(OBJECTS)
+ lib /out:$(LIBMAIN_S) $(OBJECTS)
+
+#Build test suite
+test.exe: $(LIBMAIN_S) demo/demo.c
+ cl $(LTM_CFLAGS) $(TOBJECTS) $(LIBMAIN_S) $(LTM_LDFLAGS) demo/demo.c /DLTM_DEMO_TEST_VS_MTEST=0 /Fe$@
+ @echo NOTICE: start the tests by launching test.exe
+
+all: $(LIBMAIN_S) test.exe
+
+test: test.exe
+
+clean:
+ @-cmd /c del /Q /S *.OBJ *.LIB *.EXE *.DLL 2>nul
+
+#Install the library + headers
+install: $(LIBMAIN_S)
+ 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 tommath*.h "$(PREFIX)\include"
+
+# ref: $Format:%D$
+# git commit: $Format:%H$
+# commit time: $Format:%ai$