summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--winbuild/BUILD.WINDOWS.txt46
-rw-r--r--winbuild/Makefile.vc45
-rw-r--r--winbuild/MakefileBuild.vc147
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=<static or dll> <options>
where <options> is one or many of:
- VC=<6,7,8,9,10,11,12,14,15> - VC versions
- WITH_DEVEL=<path> - 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=<dll or static> - Enable OpenSSL support, DLL or static
- WITH_NGHTTP2=<dll or static> - Enable HTTP/2 support, DLL or static
- WITH_MBEDTLS=<dll or static> - Enable mbedTLS support, DLL or static
- WITH_CARES=<dll or static> - Enable c-ares support, DLL or static
- WITH_ZLIB=<dll or static> - Enable zlib support, DLL or static
- WITH_SSH2=<dll or static> - Enable libSSH2 support, DLL or static
- ENABLE_SSPI=<yes or no> - Enable SSPI support, defaults to yes
- ENABLE_IPV6=<yes or no> - Enable IPv6, defaults to yes
- ENABLE_IDN=<yes or no> - 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=<yes or no> - Enable native Windows SSL support, defaults to yes
- GEN_PDB=<yes or no> - Generate Program Database (debug symbols for release build)
- DEBUG=<yes or no> - Debug builds
- MACHINE=<x86 or x64> - Target architecture (default is x86)
+ VC=<6,7,8,9,10,11,12,14,15> - VC versions
+ WITH_DEVEL=<path> - 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=<dll or static> - Enable OpenSSL support, DLL or static
+ WITH_NGHTTP2=<dll or static> - Enable HTTP/2 support, DLL or static
+ WITH_MBEDTLS=<dll or static> - Enable mbedTLS support, DLL or static
+ WITH_CARES=<dll or static> - Enable c-ares support, DLL or static
+ WITH_ZLIB=<dll or static> - Enable zlib support, DLL or static
+ WITH_SSH2=<dll or static> - Enable libSSH2 support, DLL or static
+ ENABLE_SSPI=<yes or no> - Enable SSPI support, defaults to yes
+ ENABLE_IPV6=<yes or no> - Enable IPv6, defaults to yes
+ ENABLE_IDN=<yes or no> - Enable use of Windows IDN APIs, defaults to yes
+ Requires Windows Vista or later
+ ENABLE_WINSSL=<yes or no> - Enable native Windows SSL support, defaults to yes
+ GEN_PDB=<yes or no> - Generate Program Database (debug symbols for release build)
+ DEBUG=<yes or no> - Debug builds
+ MACHINE=<x86 or x64> - Target architecture (default is x86)
+ CARES_PATH=<path to cares> - Custom path for c-ares
+ MBEDTLS_PATH=<path to mbedTLS> - Custom path for mbedTLS
+ NGHTTP2_PATH=<path to HTTP/2> - Custom path for nghttp2
+ SSH2_PATH=<path to libSSH2> - Custom path for libSSH2
+ SSL_PATH=<path to OpenSSL> - Custom path for OpenSSL
+ ZLIB_PATH=<path to zlib> - 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=<static or dll> <options>
!MESSAGE where <options> is one or many of:
-!MESSAGE VC=<6,7,8,9,10,11,12,14,15> - VC versions
-!MESSAGE WITH_DEVEL=<path> - 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=<dll or static> - Enable OpenSSL support, DLL or static
-!MESSAGE WITH_NGHTTP2=<dll or static> - Enable HTTP/2 support, DLL or static
-!MESSAGE WITH_CARES=<dll or static> - Enable c-ares support, DLL or static
-!MESSAGE WITH_ZLIB=<dll or static> - Enable zlib support, DLL or static
-!MESSAGE WITH_SSH2=<dll or static> - Enable libSSH2 support, DLL or static
-!MESSAGE WITH_MBEDTLS=<dll or static> - Enable mbedTLS support, DLL or static
-!MESSAGE ENABLE_IDN=<yes or no> - 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=<yes or no> - Enable IPv6, defaults to yes
-!MESSAGE ENABLE_SSPI=<yes or no> - Enable SSPI support, defaults to yes
-!MESSAGE ENABLE_WINSSL=<yes or no> - Enable native Windows SSL support, defaults to yes
-!MESSAGE GEN_PDB=<yes or no> - Generate Program Database (debug symbols for release build)
-!MESSAGE DEBUG=<yes or no> - Debug builds
-!MESSAGE MACHINE=<x86 or x64> - 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=<path> - 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=<dll or static> - Enable OpenSSL support, DLL or static
+!MESSAGE WITH_NGHTTP2=<dll or static> - Enable HTTP/2 support, DLL or static
+!MESSAGE WITH_CARES=<dll or static> - Enable c-ares support, DLL or static
+!MESSAGE WITH_ZLIB=<dll or static> - Enable zlib support, DLL or static
+!MESSAGE WITH_SSH2=<dll or static> - Enable libSSH2 support, DLL or static
+!MESSAGE WITH_MBEDTLS=<dll or static> - Enable mbedTLS support, DLL or static
+!MESSAGE ENABLE_IDN=<yes or no> - Enable use of Windows IDN APIs, defaults to yes
+!MESSAGE Requires Windows Vista or later
+!MESSAGE ENABLE_IPV6=<yes or no> - Enable IPv6, defaults to yes
+!MESSAGE ENABLE_SSPI=<yes or no> - Enable SSPI support, defaults to yes
+!MESSAGE ENABLE_WINSSL=<yes or no> - Enable native Windows SSL support, defaults to yes
+!MESSAGE GEN_PDB=<yes or no> - Generate Program Database (debug symbols for release build)
+!MESSAGE DEBUG=<yes or no> - Debug builds
+!MESSAGE MACHINE=<x86 or x64> - Target architecture (default x64 on AMD64, x86 on others)
+!MESSAGE CARES_PATH=<path to cares> - Custom path for c-ares
+!MESSAGE MBEDTLS_PATH=<path to mbedTLS> - Custom path for mbedTLS
+!MESSAGE NGHTTP2_PATH=<path to HTTP/2> - Custom path for nghttp2
+!MESSAGE SSH2_PATH=<path to libSSH2> - Custom path for libSSH2
+!MESSAGE SSL_PATH=<path to OpenSSL> - Custom path for OpenSSL
+!MESSAGE ZLIB_PATH=<path to zlib> - 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