Skip to content

Commit 3ba0496

Browse files
madebrsjaeckel
authored andcommitted
enable building dll's using makefile.msvc
1 parent c18817c commit 3ba0496

File tree

4 files changed

+45
-5
lines changed

4 files changed

+45
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
*.gcda
66
*.gcno
77
*.gcov
8+
*.dll
9+
*.exp
10+
*.pdb
811
*.lib
912
*.tmp
1013
[Dd]ebug/

makefile.msvc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,16 @@
1212
#The following can be overridden from command line e.g. make -f makefile.msvc CC=gcc ARFLAGS=rcs
1313
PREFIX = c:\devel
1414
CFLAGS = /Ox
15+
LDFLAGS =
1516

1617
#Compilation flags
1718
LTM_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)
2427
OBJECTS=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
6673
test.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

7279
tune: $(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"

s_mp_rand_platform.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ static mp_err s_read_arc4random(void *p, size_t n)
1414
arc4random_buf(p, n);
1515
return MP_OKAY;
1616
}
17+
#else
18+
static mp_err s_read_arc4random(void *p, size_t n)
19+
{
20+
(void)p;
21+
(void)n;
22+
return MP_ERR;
23+
}
1724
#endif
1825

1926
#if defined(_WIN32)
@@ -72,6 +79,15 @@ static mp_err s_read_getrandom(void *p, size_t n)
7279
#endif
7380
#endif
7481

82+
#ifndef S_READ_GETRANDOM_C
83+
static mp_err s_read_getrandom(void *p, size_t n)
84+
{
85+
(void)p;
86+
(void)n;
87+
return MP_ERR;
88+
}
89+
#endif
90+
7591
/* We assume all platforms besides windows provide "/dev/urandom".
7692
* In case yours doesn't, define MP_NO_DEV_URANDOM at compile-time.
7793
*/
@@ -110,6 +126,13 @@ static mp_err s_read_urandom(void *p, size_t n)
110126
close(fd);
111127
return MP_OKAY;
112128
}
129+
#else
130+
static mp_err s_read_urandom(void *p, size_t n)
131+
{
132+
(void)p;
133+
(void)n;
134+
return MP_ERR;
135+
}
113136
#endif
114137

115138
mp_err s_read_arc4random(void *p, size_t n);

tommath.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ EXPORTS
8989
mp_radix_size
9090
mp_radix_size_overestimate
9191
mp_rand
92+
mp_rand_source
9293
mp_read_radix
9394
mp_reduce
9495
mp_reduce_2k
@@ -124,3 +125,7 @@ EXPORTS
124125
mp_unpack
125126
mp_xor
126127
mp_zero
128+
MP_MUL_KARATSUBA_CUTOFF
129+
MP_SQR_KARATSUBA_CUTOFF
130+
MP_MUL_TOOM_CUTOFF
131+
MP_SQR_TOOM_CUTOFF

0 commit comments

Comments
 (0)