From 7921659450c0a479b5fc675e11dded78a2bffb5a Mon Sep 17 00:00:00 2001 From: kdekker Date: Mon, 9 Apr 2018 11:19:51 +0200 Subject: winbuild: Support custom devel paths for each dependency - Support custom devel paths for c-ares, mbedTLS, nghttp2, libSSH2, OpenSSL and zlib. Respectively: CARES_PATH, MBEDTLS_PATH, NGHTTP2_PATH, SSH2_PATH, SSL_PATH and ZLIB_PATH. - Use lib.exe for making the static library instead of link.exe /lib. The latter is undocumented and could cause problems as noted in the comments. - Remove a dangling URL that no longer worked. (I was not able to find the IDN download at MSDN/microsoft.com, so it seems to be removed.) - Remove custom override for release-ssh2-ssl-dll-zlib configuration. Nobody knows why it was there and as far as we can see is unnecessary. Closes https://github.com/curl/curl/pull/2474 --- winbuild/BUILD.WINDOWS.txt | 46 ++++++++------ winbuild/Makefile.vc | 45 ++++++++------ winbuild/MakefileBuild.vc | 147 +++++++++++++++++++++++++++++++-------------- 3 files changed, 152 insertions(+), 86 deletions(-) diff --git a/winbuild/BUILD.WINDOWS.txt b/winbuild/BUILD.WINDOWS.txt index 26092867c..33252f8e5 100644 --- a/winbuild/BUILD.WINDOWS.txt +++ b/winbuild/BUILD.WINDOWS.txt @@ -75,26 +75,32 @@ a directory named using the options given to the nmake call. nmake /f Makefile.vc mode= where is one or many of: - VC=<6,7,8,9,10,11,12,14,15> - VC versions - WITH_DEVEL= - Paths for the development files (SSL, zlib, etc.) - Defaults to sibbling directory deps: ../deps - Libraries can be fetched at http://windows.php.net/downloads/php-sdk/deps/ - Uncompress them into the deps folder. - WITH_SSL= - Enable OpenSSL support, DLL or static - WITH_NGHTTP2= - Enable HTTP/2 support, DLL or static - WITH_MBEDTLS= - Enable mbedTLS support, DLL or static - WITH_CARES= - Enable c-ares support, DLL or static - WITH_ZLIB= - Enable zlib support, DLL or static - WITH_SSH2= - Enable libSSH2 support, DLL or static - ENABLE_SSPI= - Enable SSPI support, defaults to yes - ENABLE_IPV6= - Enable IPv6, defaults to yes - ENABLE_IDN= - Enable use of Windows IDN APIs, defaults to yes - Requires Windows Vista or later, or installation from: - https://www.microsoft.com/downloads/details.aspx?FamilyID=AD6158D7-DDBA-416A-9109-07607425A815 - ENABLE_WINSSL= - Enable native Windows SSL support, defaults to yes - GEN_PDB= - Generate Program Database (debug symbols for release build) - DEBUG= - Debug builds - MACHINE= - Target architecture (default is x86) + VC=<6,7,8,9,10,11,12,14,15> - VC versions + WITH_DEVEL= - Paths for the development files (SSL, zlib, etc.) + Defaults to sibbling directory deps: ../deps + Libraries can be fetched at http://windows.php.net/downloads/php-sdk/deps/ + Uncompress them into the deps folder. + WITH_SSL= - Enable OpenSSL support, DLL or static + WITH_NGHTTP2= - Enable HTTP/2 support, DLL or static + WITH_MBEDTLS= - Enable mbedTLS support, DLL or static + WITH_CARES= - Enable c-ares support, DLL or static + WITH_ZLIB= - Enable zlib support, DLL or static + WITH_SSH2= - Enable libSSH2 support, DLL or static + ENABLE_SSPI= - Enable SSPI support, defaults to yes + ENABLE_IPV6= - Enable IPv6, defaults to yes + ENABLE_IDN= - Enable use of Windows IDN APIs, defaults to yes + Requires Windows Vista or later + ENABLE_WINSSL= - Enable native Windows SSL support, defaults to yes + GEN_PDB= - Generate Program Database (debug symbols for release build) + DEBUG= - Debug builds + MACHINE= - Target architecture (default is x86) + CARES_PATH= - Custom path for c-ares + MBEDTLS_PATH= - Custom path for mbedTLS + NGHTTP2_PATH= - Custom path for nghttp2 + SSH2_PATH= - Custom path for libSSH2 + SSL_PATH= - Custom path for OpenSSL + ZLIB_PATH= - Custom path for zlib + Static linking of Microsoft's C RunTime (CRT): ============================================== diff --git a/winbuild/Makefile.vc b/winbuild/Makefile.vc index b3d0e4607..a874b77f8 100644 --- a/winbuild/Makefile.vc +++ b/winbuild/Makefile.vc @@ -37,26 +37,31 @@ CFGSET=true !MESSAGE Usage: nmake /f Makefile.vc mode= !MESSAGE where is one or many of: -!MESSAGE VC=<6,7,8,9,10,11,12,14,15> - VC versions -!MESSAGE WITH_DEVEL= - Paths for the development files (SSL, zlib, etc.) -!MESSAGE Defaults to sibbling directory deps: ../deps -!MESSAGE Libraries can be fetched at http://pecl2.php.net/downloads/php-windows-builds/ -!MESSAGE Uncompress them into the deps folder. -!MESSAGE WITH_SSL= - Enable OpenSSL support, DLL or static -!MESSAGE WITH_NGHTTP2= - Enable HTTP/2 support, DLL or static -!MESSAGE WITH_CARES= - Enable c-ares support, DLL or static -!MESSAGE WITH_ZLIB= - Enable zlib support, DLL or static -!MESSAGE WITH_SSH2= - Enable libSSH2 support, DLL or static -!MESSAGE WITH_MBEDTLS= - Enable mbedTLS support, DLL or static -!MESSAGE ENABLE_IDN= - Enable use of Windows IDN APIs, defaults to yes -!MESSAGE Requires Windows Vista or later, or installation from: -!MESSAGE https://www.microsoft.com/en-us/download/details.aspx?id=734 -!MESSAGE ENABLE_IPV6= - Enable IPv6, defaults to yes -!MESSAGE ENABLE_SSPI= - Enable SSPI support, defaults to yes -!MESSAGE ENABLE_WINSSL= - Enable native Windows SSL support, defaults to yes -!MESSAGE GEN_PDB= - Generate Program Database (debug symbols for release build) -!MESSAGE DEBUG= - Debug builds -!MESSAGE MACHINE= - Target architecture (default x64 on AMD64, x86 on others) +!MESSAGE VC=<6,7,8,9,10,11,12,14,15> - VC versions +!MESSAGE WITH_DEVEL= - Paths for the development files (SSL, zlib, etc.) +!MESSAGE Defaults to sibbling directory deps: ../deps +!MESSAGE Libraries can be fetched at http://pecl2.php.net/downloads/php-windows-builds/ +!MESSAGE Uncompress them into the deps folder. +!MESSAGE WITH_SSL= - Enable OpenSSL support, DLL or static +!MESSAGE WITH_NGHTTP2= - Enable HTTP/2 support, DLL or static +!MESSAGE WITH_CARES= - Enable c-ares support, DLL or static +!MESSAGE WITH_ZLIB= - Enable zlib support, DLL or static +!MESSAGE WITH_SSH2= - Enable libSSH2 support, DLL or static +!MESSAGE WITH_MBEDTLS= - Enable mbedTLS support, DLL or static +!MESSAGE ENABLE_IDN= - Enable use of Windows IDN APIs, defaults to yes +!MESSAGE Requires Windows Vista or later +!MESSAGE ENABLE_IPV6= - Enable IPv6, defaults to yes +!MESSAGE ENABLE_SSPI= - Enable SSPI support, defaults to yes +!MESSAGE ENABLE_WINSSL= - Enable native Windows SSL support, defaults to yes +!MESSAGE GEN_PDB= - Generate Program Database (debug symbols for release build) +!MESSAGE DEBUG= - Debug builds +!MESSAGE MACHINE= - Target architecture (default x64 on AMD64, x86 on others) +!MESSAGE CARES_PATH= - Custom path for c-ares +!MESSAGE MBEDTLS_PATH= - Custom path for mbedTLS +!MESSAGE NGHTTP2_PATH= - Custom path for nghttp2 +!MESSAGE SSH2_PATH= - Custom path for libSSH2 +!MESSAGE SSL_PATH= - Custom path for OpenSSL +!MESSAGE ZLIB_PATH= - Custom path for zlib !ERROR please choose a valid mode !ENDIF diff --git a/winbuild/MakefileBuild.vc b/winbuild/MakefileBuild.vc index 9e6810340..5f994cb30 100644 --- a/winbuild/MakefileBuild.vc +++ b/winbuild/MakefileBuild.vc @@ -70,7 +70,12 @@ CFLAGS = /I. /I ../lib /I../include /nologo /W4 /wd4127 /EHsc /DWIN32 /FD / LFLAGS = /nologo /machine:$(MACHINE) LNKDLL = link.exe /DLL -LNKLIB = link.exe /lib +# Use lib.exe instead of link.exe as link.exe /lib has the following bad habits: +# - optimizing options like /opt:ref raises warnings (at least in Visual Studio 2015) +# - all (including Windows) dependencies are aggregated (as static parts) +# - link.exe /lib is not documented (anymore) at MSDN +# Instead of id: just create an archive, that contains all objects +LNKLIB = lib.exe CFLAGS_PDB = /Zi LFLAGS_PDB = /incremental:no /opt:ref,icf /DEBUG @@ -97,9 +102,9 @@ PDB_NAME_DLL = $(BASE_NAME).pdb PDB_NAME_DLL_DEBUG = $(BASE_NAME_DEBUG).pdb # CURL Command section -PROGRAM_NAME = curl.exe -CURL_CFLAGS = /I../lib /I../include /nologo /W4 /EHsc /DWIN32 /FD /c -CURL_LFLAGS = /nologo /out:$(DIRDIST)\bin\$(PROGRAM_NAME) /subsystem:console /machine:$(MACHINE) +PROGRAM_NAME = curl.exe +CURL_CFLAGS = /I../lib /I../include /nologo /W4 /EHsc /DWIN32 /FD /c +CURL_LFLAGS = /out:$(DIRDIST)\bin\$(PROGRAM_NAME) /subsystem:console $(LFLAGS) CURL_RESFLAGS = /i../include ############################################################# @@ -108,57 +113,92 @@ LIBCURL_SRC_DIR = ..\lib CURL_SRC_DIR = ..\src !IFNDEF WITH_DEVEL -WITH_DEVEL = ../../deps +WITH_DEVEL = ../../deps !ENDIF -DEVEL_INCLUDE = $(WITH_DEVEL)/include -DEVEL_LIB = $(WITH_DEVEL)/lib -DEVEL_BIN = $(WITH_DEVEL)/bin +DEVEL_INCLUDE= $(WITH_DEVEL)/include +DEVEL_LIB = $(WITH_DEVEL)/lib -CFLAGS = $(CFLAGS) /I"$(DEVEL_INCLUDE)" -LFLAGS = $(LFLAGS) "/LIBPATH:$(DEVEL_LIB)" +!IF EXISTS("$(DEVEL_INCLUDE)") +CFLAGS = $(CFLAGS) /I"$(DEVEL_INCLUDE)" +!ENDIF +!IF EXISTS("$(DEVEL_LIB)") +LFLAGS = $(LFLAGS) "/LIBPATH:$(DEVEL_LIB)" +!ENDIF +!IFDEF SSL_PATH +SSL_INC_DIR = $(SSL_PATH)\include +SSL_LIB_DIR = $(SSL_PATH)\lib +SSL_LFLAGS = $(SSL_LFLAGS) "/LIBPATH:$(SSL_LIB_DIR)" +!ELSE +SSL_INC_DIR=$(DEVEL_INCLUDE)\openssl +SSL_LIB_DIR=$(DEVEL_LIB) +!ENDIF -!IF "$(WITH_SSL)"=="dll" -!IF EXISTS("$(DEVEL_LIB)\libssl.lib") +!IF "$(WITH_SSL)"=="dll" || "$(WITH_SSL)"=="static" +!IF EXISTS("$(SSL_LIB_DIR)\libssl.lib") SSL_LIBS = libssl.lib libcrypto.lib !ELSE SSL_LIBS = libeay32.lib ssleay32.lib !ENDIF USE_SSL = true -SSL = dll -!ELSEIF "$(WITH_SSL)"=="static" -!IF EXISTS("$(DEVEL_LIB)\libssl.lib") -SSL_LIBS = libssl.lib libcrypto.lib gdi32.lib user32.lib crypt32.lib -!ELSE -SSL_LIBS = libeay32.lib ssleay32.lib gdi32.lib user32.lib crypt32.lib +SSL = $(WITH_SSL) +!IF "$(WITH_SSL)"=="static" +WIN_LIBS = $(WIN_LIBS) gdi32.lib user32.lib crypt32.lib !ENDIF -USE_SSL = true -SSL = static !ENDIF !IFDEF USE_SSL -SSL_CFLAGS = /DUSE_OPENSSL /I"$(DEVEL_INCLUDE)/openssl" -!IF EXISTS("$(DEVEL_INCLUDE)\openssl\is_boringssl.h") +SSL_CFLAGS = /DUSE_OPENSSL /I"$(SSL_INC_DIR)" +!IF EXISTS("$(SSL_INC_DIR)\is_boringssl.h") SSL_CFLAGS = $(SSL_CFLAGS) /DHAVE_BORINGSSL !ENDIF !ENDIF + +!IFDEF NGHTTP2_PATH +NGHTTP2_INC_DIR = $(NGHTTP2_PATH)\include +NGHTTP2_LIB_DIR = $(NGHTTP2_PATH)\lib +NGHTTP2_LFLAGS = $(NGHTTP2_LFLAGS) "/LIBPATH:$(NGHTTP2_LIB_DIR)" +!ELSE +NGHTTP2_INC_DIR = $(DEVEL_INCLUDE) +NGHTTP2_LIB_DIR = $(DEVEL_LIB) +!ENDIF + !IF "$(WITH_NGHTTP2)"=="dll" -NGHTTP2_CFLAGS = /DUSE_NGHTTP2 +NGHTTP2_CFLAGS = /DUSE_NGHTTP2 /I"$(NGHTTP2_INC_DIR)" NGHTTP2_LIBS = nghttp2.lib !ELSEIF "$(WITH_NGHTTP2)"=="static" -NGHTTP2_CFLAGS = /DUSE_NGHTTP2 /DNGHTTP2_STATICLIB +NGHTTP2_CFLAGS = /DUSE_NGHTTP2 /DNGHTTP2_STATICLIB /I"$(NGHTTP2_INC_DIR)" NGHTTP2_LIBS = nghttp2_static.lib !ENDIF + +!IFDEF MBEDTLS_PATH +MBEDTLS_INC_DIR = $(MBEDTLS_PATH)\include +MBEDTLS_LIB_DIR = $(MBEDTLS_PATH)\lib +MBEDTLS_LFLAGS = $(MBEDTLS_LFLAGS) "/LIBPATH:$(MBEDTLS_LIB_DIR)" +!ELSE +MBEDTLS_INC_DIR = $(DEVEL_INCLUDE) +MBEDTLS_LIB_DIR = $(DEVEL_LIB) +!ENDIF + !IF "$(WITH_MBEDTLS)"=="dll" || "$(WITH_MBEDTLS)"=="static" USE_MBEDTLS = true MBEDTLS = $(WITH_MBEDTLS) -MBEDTLS_CFLAGS = /DUSE_MBEDTLS +MBEDTLS_CFLAGS = /DUSE_MBEDTLS /I"$(MBEDTLS_INC_DIR)" MBEDTLS_LIBS = mbedtls.lib mbedcrypto.lib mbedx509.lib !ENDIF +!IFDEF CARES_PATH +CARES_INC_DIR = $(CARES_PATH)\include +CARES_LIB_DIR = $(CARES_PATH)\lib +CARES_LFLAGS = $(CARES_LFLAGS) "/LIBPATH:$(CARES_LIB_DIR)" +!ELSE +CARES_INC_DIR = $(DEVEL_INCLUDE)/cares +CARES_LIB_DIR = $(DEVEL_LIB) +!ENDIF + !IF "$(WITH_CARES)"=="dll" !IF "$(DEBUG)"=="yes" CARES_LIBS = caresd.lib @@ -178,15 +218,25 @@ CARES = static !ENDIF !IFDEF USE_CARES -CARES_CFLAGS = /DUSE_ARES /I"$(DEVEL_INCLUDE)/cares" +CARES_CFLAGS = /DUSE_ARES /I"$(CARES_INC_DIR)" +!ENDIF + + +!IFDEF ZLIB_PATH +ZLIB_INC_DIR = $(ZLIB_PATH)\include +ZLIB_LIB_DIR = $(ZLIB_PATH)\lib +ZLIB_LFLAGS = $(ZLIB_LFLAGS) "/LIBPATH:$(ZLIB_LIB_DIR)" +!ELSE +ZLIB_INC_DIR = $(DEVEL_INCLUDE) +ZLIB_LIB_DIR = $(DEVEL_LIB) !ENDIF # Depending on how zlib is built the libraries have different names, we # try to handle them all. !IF "$(WITH_ZLIB)"=="dll" -!IF EXISTS("$(DEVEL_LIB)\zlibwapi.lib") +!IF EXISTS("$(ZLIB_LIB_DIR)\zlibwapi.lib") ZLIB_LIBS = zlibwapi.lib -!ELSEIF EXISTS("$(DEVEL_LIB)\zdll.lib") +!ELSEIF EXISTS("$(ZLIB_LIB_DIR)\zdll.lib") ZLIB_LIBS = zdll.lib !ELSE ZLIB_LIBS = zlib.lib @@ -194,9 +244,9 @@ ZLIB_LIBS = zlib.lib USE_ZLIB = true ZLIB = dll !ELSEIF "$(WITH_ZLIB)"=="static" -!IF EXISTS("$(DEVEL_LIB)\zlibstat.lib") +!IF EXISTS("$(ZLIB_LIB_DIR)\zlibstat.lib") ZLIB_LIBS = zlibstat.lib -!ELSEIF EXISTS("$(DEVEL_LIB)\zlib.lib") +!ELSEIF EXISTS("$(ZLIB_LIB_DIR)\zlib.lib") ZLIB_LIBS = zlib.lib !ELSE ZLIB_LIBS = zlib_a.lib @@ -206,23 +256,38 @@ ZLIB = static !ENDIF !IFDEF USE_ZLIB -ZLIB_CFLAGS = /DHAVE_ZLIB_H /DHAVE_ZLIB /DHAVE_LIBZ +ZLIB_CFLAGS = /DHAVE_ZLIB_H /DHAVE_ZLIB /DHAVE_LIBZ /I"$(ZLIB_INC_DIR)" !ENDIF +!IFDEF SSH2_PATH +SSH2_INC_DIR= $(SSH2_PATH)\include +SSH2_LIB_DIR= $(SSH2_PATH)\lib +SSH2_LFLAGS = $(SSH2_LFLAGS) "/LIBPATH:$(SSH2_LIB_DIR)" +!ELSE +SSH2_LIB_DIR= $(DEVEL_LIB) +SSH2_INC_DIR= $(DEVEL_INCLUDE)/libssh2 +!ENDIF + !IF "$(WITH_SSH2)"=="dll" SSH2_LIBS = libssh2.lib USE_SSH2 = true SSH2 = dll !ELSEIF "$(WITH_SSH2)"=="static" -SSH2_LIBS = libssh2_a.lib user32.lib +# libssh2 NMakefile on Windows at default creates a static library without _a suffix +!IF EXISTS("$(SSH2_LIB_DIR)\libssh2.lib") +SSH2_LIBS = libssh2.lib +!ELSE +SSH2_LIBS = libssh2_a.lib +!ENDIF +WIN_LIBS = $(WIN_LIBS) user32.lib USE_SSH2 = true SSH2 = static !ENDIF !IFDEF USE_SSH2 SSH2_CFLAGS = /DHAVE_LIBSSH2 /DHAVE_LIBSSH2_H /DLIBSSH2_WIN32 /DLIBSSH2_LIBRARY /DUSE_LIBSSH2 -SSH2_CFLAGS = $(SSH2_CFLAGS) /I$(WITH_DEVEL)/include/libssh2 +SSH2_CFLAGS = $(SSH2_CFLAGS) /I$(SSH2_INC_DIR) !ENDIF @@ -330,7 +395,7 @@ CURL_RC_FLAGS = /i../include /dDEBUGBUILD=0 /Fo $@ $(CURL_SRC_DIR)\curl.rc !IF "$(AS_DLL)" == "true" -LNK = $(LNKDLL) $(WIN_LIBS) /out:$(LIB_DIROBJ)\$(TARGET) +LNK = $(LNKDLL) $(LFLAGS) $(WIN_LIBS) /out:$(LIB_DIROBJ)\$(TARGET) !IF "$(DEBUG)"=="yes" TARGET = $(LIB_NAME_DLL_DEBUG) LNK = $(LNK) /DEBUG /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG) @@ -354,7 +419,7 @@ PDB = $(PDB_NAME_STATIC_DEBUG) TARGET = $(LIB_NAME_STATIC) PDB = $(PDB_NAME_STATIC) !ENDIF -LNK = $(LNKLIB) $(WIN_LIBS) /out:$(LIB_DIROBJ)\$(TARGET) +LNK = $(LNKLIB) /out:$(LIB_DIROBJ)\$(TARGET) CURL_CC = $(CURL_CC) $(CFLAGS_LIBCURL_STATIC) # AS_DLL @@ -416,16 +481,6 @@ DIRDIST = ..\builds\$(CONFIG_NAME_LIB)\ # CURL_LINK = link.exe /incremental:no /libpath:"$(DIRDIST)\lib" -#!IF "$(CFG)" == "release-ssh2-ssl-dll-zlib" -#TARGET = $(LIB_NAME_STATIC) -#LNK = $(LNKLIB) $(WINLIBS) $(SSLLIBS) $(ZLIBLIBS) $(SSH2LIBS) $(SSL_LFLAGS) $(ZLIB_LFLAGS) $(LFLAGSSSH) /out:$(LIB_DIROBJ)\$(TARGET) -#CC = $(CCNODBG) $(RTLIB) $(SSL_CFLAGS) $(ZLIB_CFLAGS) $(CFLAGSLIB) $(SSH2_CFLAGS) -#CFGSET = TRUE -#!ENDIF - -####################### -# Only the clean target can be used if a config was not provided. -# !IF "$(CFGSET)" != "FALSE" # A mode was provided, so the library can be built. # @@ -462,7 +517,7 @@ $(TARGET): $(LIB_OBJS) $(LIB_DIROBJ) $(DISTDIR) @echo GenPDB: $(GEN_PDB) @echo Debug: $(DEBUG) @echo Machine: $(MACHINE) - $(LNK) $(LFLAGS) $(LIB_OBJS) + $(LNK) $(LIB_OBJS) @echo Copying libs... @if exist $(LIB_DIROBJ)\$(LIB_NAME_DLL) copy $(LIB_DIROBJ)\$(LIB_NAME_DLL) $(DIRDIST)\bin\ /y >nul 2<&1 @if exist $(LIB_DIROBJ)\$(LIB_NAME_STATIC) copy $(LIB_DIROBJ)\$(LIB_NAME_STATIC) $(DIRDIST)\lib\ /y >nul 2<&1 -- cgit v1.2.1