From 1ee20123f68f914398eb5cd7406dc4ff420b59a1 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 13 Aug 2018 12:03:54 +0900 Subject: [PATCH] fix mk.bat and mklib.bat and update readme.md for windows --- mk.bat | 17 ++++++++++++++--- mklib.bat | 32 +++++++++++++++++++++----------- readme.md | 15 ++++++++++----- 3 files changed, 45 insertions(+), 19 deletions(-) diff --git a/mk.bat b/mk.bat index b2e88ab..19eb841 100644 --- a/mk.bat +++ b/mk.bat @@ -1,9 +1,20 @@ @echo off call setvar.bat -set SRC=%1 +if "%1"=="-s" ( + echo use static lib + set CFLAGS=%CFLAGS% /DMCLBN_DONT_EXPORT +) else if "%1"=="-d" ( + echo use dynamic lib +) else ( + echo "mk (-s|-d) " + goto exit +) +set SRC=%2 set EXE=%SRC:.cpp=.exe% set EXE=%EXE:.c=.exe% set EXE=%EXE:test\=bin\% set EXE=%EXE:sample\=bin\% -echo cl %CFLAGS% %1 %2 %3 /Fe:%EXE% /link %LDFLAGS% -cl %CFLAGS% %1 %2 %3 /Fe:%EXE% /link %LDFLAGS% +echo cl %CFLAGS% %2 /Fe:%EXE% /link %LDFLAGS% +cl %CFLAGS% %2 /Fe:%EXE% /link %LDFLAGS% + +:exit diff --git a/mklib.bat b/mklib.bat index ac1b17d..1f9ad4f 100644 --- a/mklib.bat +++ b/mklib.bat @@ -1,5 +1,10 @@ @echo off call setvar.bat +if "%1"=="dll" ( + echo make dynamic library DLL +) else ( + echo make static library LIB +) rem nasm -f win64 -D_WIN64 src\asm\low_x86-64.asm rem lib /OUT:lib\mcl.lib /nodefaultlib fp.obj src\asm\low_x86-64.obj @@ -8,17 +13,22 @@ echo cl /c %CFLAGS% src\fp.cpp /Foobj\fp.obj echo lib /nologo /OUT:lib\mcl.lib /nodefaultlib obj\fp.obj lib /nologo /OUT:lib\mcl.lib /nodefaultlib obj\fp.obj -echo cl /c %CFLAGS% src\bn_c256.cpp /Foobj\bn_c256.obj - cl /c %CFLAGS% src\bn_c256.cpp /Foobj\bn_c256.obj -echo link /nologo /DLL /OUT:bin\mclbn256.dll obj\bn_c256.obj obj\fp.obj %LDFLAGS% /implib:lib\mclbn256.lib - link /nologo /DLL /OUT:bin\mclbn256.dll obj\bn_c256.obj obj\fp.obj %LDFLAGS% /implib:lib\mclbn256.lib +if "%1"=="dll" ( + echo cl /c %CFLAGS% src\she_c256.cpp /Foobj\she_c256.obj + cl /c %CFLAGS% src\she_c256.cpp /Foobj\she_c256.obj /DMCLBN_NO_AUTOLINK + echo link /nologo /DLL /OUT:bin\mclbn256.dll obj\she_c256.obj obj\fp.obj %LDFLAGS% /implib:lib\mclshe256.lib + link /nologo /DLL /OUT:bin\mclbn256.dll obj\she_c256.obj obj\fp.obj %LDFLAGS% /implib:lib\mclshe256.lib -echo cl /c %CFLAGS% src\bn_c384.cpp /Foobj\bn_c384.obj - cl /c %CFLAGS% src\bn_c384.cpp /Foobj\bn_c384.obj -echo link /nologo /DLL /OUT:bin\mclbn384.dll obj\bn_c384.obj obj\fp.obj %LDFLAGS% /implib:lib\mclbn384.lib + echo cl /c %CFLAGS% src\bn_c384.cpp /Foobj\bn_c384.obj + cl /c %CFLAGS% src\bn_c384.cpp /Foobj\bn_c384.obj /DMCLBN_NO_AUTOLINK + echo link /nologo /DLL /OUT:bin\mclbn384.dll obj\bn_c384.obj obj\fp.obj %LDFLAGS% /implib:lib\mclbn384.lib link /nologo /DLL /OUT:bin\mclbn384.dll obj\bn_c384.obj obj\fp.obj %LDFLAGS% /implib:lib\mclbn384.lib +) else ( + echo cl /c %CFLAGS% src\bn_c256.cpp /Foobj\bn_c256.obj + cl /c %CFLAGS% src\bn_c256.cpp /Foobj\bn_c256.obj + lib /nologo /OUT:lib\mclbn256.lib /nodefaultlib obj\bn_c256.obj lib\mcl.lib -echo cl /c %CFLAGS% src\she_c256.cpp /Foobj\she_c256.obj - cl /c %CFLAGS% src\she_c256.cpp /Foobj\she_c256.obj -echo link /nologo /DLL /OUT:bin\mclbn256.dll obj\she_c256.obj obj\fp.obj %LDFLAGS% /implib:lib\mclshe256.lib - link /nologo /DLL /OUT:bin\mclbn256.dll obj\she_c256.obj obj\fp.obj %LDFLAGS% /implib:lib\mclshe256.lib + echo cl /c %CFLAGS% src\bn_c384.cpp /Foobj\bn_c384.obj + cl /c %CFLAGS% src\bn_c384.cpp /Foobj\bn_c384.obj + lib /nologo /OUT:lib\mclbn384.lib /nodefaultlib obj\bn_c384.obj lib\mcl.lib +) diff --git a/readme.md b/readme.md index 531d4c2..6db805d 100644 --- a/readme.md +++ b/readme.md @@ -114,14 +114,19 @@ make ARCH=x86 CFLAGS_USER="-I /include" LDFLAGS_USER="-L /lib -Wl, ``` ## Build for 64-bit Windows -1) make library +1) make static library and use it + ``` -mklib.bat +mklib +mk -s test\bn_c256_test.cpp +bin\bn_c256_test.exe ``` -2) make exe binary of sample\pairing.cpp +2) make dynamic library and use it + ``` -mk sample\pairing.cpp -bin/bn_test.exe +mklib dll +mk -d test\bn_c256_test.cpp +bin\bn_c256_test.exe ``` open mcl.sln and build or if you have msbuild.exe