1212#The following can be overridden from command line e.g. make -f makefile.msvc CC=gcc ARFLAGS=rcs
1313PREFIX = c:\devel
1414CFLAGS = /Ox
15+ LDFLAGS =
1516
1617#Compilation flags
1718LTM_CFLAGS = /nologo /I./ /D_CRT_SECURE_NO_WARNINGS /D_CRT_NONSTDC_NO_DEPRECATE /D__STDC_WANT_SECURE_LIB__=1 /D_CRT_HAS_CXX17=0 /Wall /wd4146 /wd4127 /wd4668 /wd4710 /wd4711 /wd4820 /wd5045 /WX $(CFLAGS)
18- LTM_LDFLAGS = advapi32.lib
19+ LTM_LDFLAGS = $(LDFLAGS) advapi32.lib
1920
20- #Libraries to be created (this makefile builds only static libraries)
21- LIBMAIN_S =tommath.lib
21+ #Libraries to be created
22+ LIBMAIN_S = tommath.lib
23+ LIBMAIN_I = tommath.dll.lib
24+ LIBMAIN_D = tommath.dll
2225
2326#List of objects to compile (all goes to tommath.lib)
2427OBJECTS=mp_2expt.obj mp_abs.obj mp_add.obj mp_add_d.obj mp_addmod.obj mp_and.obj mp_clamp.obj mp_clear.obj mp_clear_multi.obj \
@@ -62,12 +65,16 @@ $(OBJECTS): $(HEADERS)
6265$(LIBMAIN_S): $(OBJECTS)
6366 lib /out:$(LIBMAIN_S) $(OBJECTS)
6467
68+ #Create DLL + import library tommath.dll.lib
69+ $(LIBMAIN_D) $(LIBMAIN_I): $(OBJECTS) tommath.def
70+ link /dll /out:$(LIBMAIN_D) /implib:$(LIBMAIN_I) /def:tommath.def $(LTM_LDFLAGS) $(OBJECTS)
71+
6572#Build test suite
6673test.exe: $(LIBMAIN_S) demo/shared.obj demo/test.obj
6774 cl $(LTM_CFLAGS) $(TOBJECTS) $(LIBMAIN_S) $(LTM_LDFLAGS) demo/shared.c demo/test.c /Fe$@
6875 @echo NOTICE: start the tests by launching test.exe
6976
70- all: $(LIBMAIN_S) test.exe
77+ all: $(LIBMAIN_S) test.exe $(LIBMAIN_D)
7178
7279tune: $(LIBMAIN_S)
7380 $(MAKE) -C etc tune
@@ -77,9 +84,11 @@ clean:
7784 @-cmd /c del /Q /S *.OBJ *.LIB *.EXE *.DLL 2>nul
7885
7986#Install the library + headers
80- install: $(LIBMAIN_S)
87+ install: $(LIBMAIN_S) $(LIBMAIN_I) $(LIBMAIN_D)
8188 cmd /c if not exist "$(PREFIX)\bin" mkdir "$(PREFIX)\bin"
8289 cmd /c if not exist "$(PREFIX)\lib" mkdir "$(PREFIX)\lib"
8390 cmd /c if not exist "$(PREFIX)\include" mkdir "$(PREFIX)\include"
8491 copy /Y $(LIBMAIN_S) "$(PREFIX)\lib"
92+ copy /Y $(LIBMAIN_I) "$(PREFIX)\lib"
93+ copy /Y $(LIBMAIN_D) "$(PREFIX)\bin"
8594 copy /Y tommath*.h "$(PREFIX)\include"
0 commit comments