nmake /f Makefile.vc mode=<static or dll> <options>\r
\r
where <options> is one or many of:\r
- VC=<6,7,8,9,10,11,12,14,15> - VC versions\r
- WITH_DEVEL=<path> - Paths for the development files (SSL, zlib, etc.)\r
- Defaults to sibbling directory deps: ../deps\r
- Libraries can be fetched at http://windows.php.net/downloads/php-sdk/deps/\r
- Uncompress them into the deps folder.\r
- WITH_SSL=<dll or static> - Enable OpenSSL support, DLL or static\r
- WITH_NGHTTP2=<dll or static> - Enable HTTP/2 support, DLL or static\r
- WITH_MBEDTLS=<dll or static> - Enable mbedTLS support, DLL or static\r
- WITH_CARES=<dll or static> - Enable c-ares support, DLL or static\r
- WITH_ZLIB=<dll or static> - Enable zlib support, DLL or static\r
- WITH_SSH2=<dll or static> - Enable libSSH2 support, DLL or static\r
- ENABLE_SSPI=<yes or no> - Enable SSPI support, defaults to yes\r
- ENABLE_IPV6=<yes or no> - Enable IPv6, defaults to yes\r
- ENABLE_IDN=<yes or no> - Enable use of Windows IDN APIs, defaults to yes\r
- Requires Windows Vista or later, or installation from:\r
- https://www.microsoft.com/downloads/details.aspx?FamilyID=AD6158D7-DDBA-416A-9109-07607425A815\r
- ENABLE_WINSSL=<yes or no> - Enable native Windows SSL support, defaults to yes\r
- GEN_PDB=<yes or no> - Generate Program Database (debug symbols for release build)\r
- DEBUG=<yes or no> - Debug builds\r
- MACHINE=<x86 or x64> - Target architecture (default is x86)\r
+ VC=<6,7,8,9,10,11,12,14,15> - VC versions\r
+ WITH_DEVEL=<path> - Paths for the development files (SSL, zlib, etc.)\r
+ Defaults to sibbling directory deps: ../deps\r
+ Libraries can be fetched at http://windows.php.net/downloads/php-sdk/deps/\r
+ Uncompress them into the deps folder.\r
+ WITH_SSL=<dll or static> - Enable OpenSSL support, DLL or static\r
+ WITH_NGHTTP2=<dll or static> - Enable HTTP/2 support, DLL or static\r
+ WITH_MBEDTLS=<dll or static> - Enable mbedTLS support, DLL or static\r
+ WITH_CARES=<dll or static> - Enable c-ares support, DLL or static\r
+ WITH_ZLIB=<dll or static> - Enable zlib support, DLL or static\r
+ WITH_SSH2=<dll or static> - Enable libSSH2 support, DLL or static\r
+ ENABLE_SSPI=<yes or no> - Enable SSPI support, defaults to yes\r
+ ENABLE_IPV6=<yes or no> - Enable IPv6, defaults to yes\r
+ ENABLE_IDN=<yes or no> - Enable use of Windows IDN APIs, defaults to yes\r
+ Requires Windows Vista or later\r
+ ENABLE_WINSSL=<yes or no> - Enable native Windows SSL support, defaults to yes\r
+ GEN_PDB=<yes or no> - Generate Program Database (debug symbols for release build)\r
+ DEBUG=<yes or no> - Debug builds\r
+ MACHINE=<x86 or x64> - Target architecture (default is x86)\r
+ CARES_PATH=<path to cares> - Custom path for c-ares\r
+ MBEDTLS_PATH=<path to mbedTLS> - Custom path for mbedTLS\r
+ NGHTTP2_PATH=<path to HTTP/2> - Custom path for nghttp2\r
+ SSH2_PATH=<path to libSSH2> - Custom path for libSSH2\r
+ SSL_PATH=<path to OpenSSL> - Custom path for OpenSSL\r
+ ZLIB_PATH=<path to zlib> - Custom path for zlib\r
+\r
\r
Static linking of Microsoft's C RunTime (CRT):\r
==============================================\r
!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
\r
LFLAGS = /nologo /machine:$(MACHINE)\r
LNKDLL = link.exe /DLL\r
-LNKLIB = link.exe /lib\r
+# Use lib.exe instead of link.exe as link.exe /lib has the following bad habits:\r
+# - optimizing options like /opt:ref raises warnings (at least in Visual Studio 2015)\r
+# - all (including Windows) dependencies are aggregated (as static parts) \r
+# - link.exe /lib is not documented (anymore) at MSDN\r
+# Instead of id: just create an archive, that contains all objects\r
+LNKLIB = lib.exe\r
\r
CFLAGS_PDB = /Zi\r
LFLAGS_PDB = /incremental:no /opt:ref,icf /DEBUG\r
PDB_NAME_DLL_DEBUG = $(BASE_NAME_DEBUG).pdb\r
\r
# CURL Command section\r
-PROGRAM_NAME = curl.exe\r
-CURL_CFLAGS = /I../lib /I../include /nologo /W4 /EHsc /DWIN32 /FD /c\r
-CURL_LFLAGS = /nologo /out:$(DIRDIST)\bin\$(PROGRAM_NAME) /subsystem:console /machine:$(MACHINE)\r
+PROGRAM_NAME = curl.exe\r
+CURL_CFLAGS = /I../lib /I../include /nologo /W4 /EHsc /DWIN32 /FD /c\r
+CURL_LFLAGS = /out:$(DIRDIST)\bin\$(PROGRAM_NAME) /subsystem:console $(LFLAGS)\r
CURL_RESFLAGS = /i../include\r
\r
#############################################################\r
CURL_SRC_DIR = ..\src\r
\r
!IFNDEF WITH_DEVEL\r
-WITH_DEVEL = ../../deps\r
+WITH_DEVEL = ../../deps\r
!ENDIF\r
-DEVEL_INCLUDE = $(WITH_DEVEL)/include\r
-DEVEL_LIB = $(WITH_DEVEL)/lib\r
-DEVEL_BIN = $(WITH_DEVEL)/bin\r
+DEVEL_INCLUDE= $(WITH_DEVEL)/include\r
+DEVEL_LIB = $(WITH_DEVEL)/lib\r
\r
-CFLAGS = $(CFLAGS) /I"$(DEVEL_INCLUDE)"\r
-LFLAGS = $(LFLAGS) "/LIBPATH:$(DEVEL_LIB)"\r
+!IF EXISTS("$(DEVEL_INCLUDE)")\r
+CFLAGS = $(CFLAGS) /I"$(DEVEL_INCLUDE)"\r
+!ENDIF\r
+!IF EXISTS("$(DEVEL_LIB)")\r
+LFLAGS = $(LFLAGS) "/LIBPATH:$(DEVEL_LIB)"\r
+!ENDIF\r
\r
+!IFDEF SSL_PATH\r
+SSL_INC_DIR = $(SSL_PATH)\include\r
+SSL_LIB_DIR = $(SSL_PATH)\lib\r
+SSL_LFLAGS = $(SSL_LFLAGS) "/LIBPATH:$(SSL_LIB_DIR)"\r
+!ELSE\r
+SSL_INC_DIR=$(DEVEL_INCLUDE)\openssl\r
+SSL_LIB_DIR=$(DEVEL_LIB)\r
+!ENDIF\r
\r
-!IF "$(WITH_SSL)"=="dll"\r
-!IF EXISTS("$(DEVEL_LIB)\libssl.lib")\r
+!IF "$(WITH_SSL)"=="dll" || "$(WITH_SSL)"=="static"\r
+!IF EXISTS("$(SSL_LIB_DIR)\libssl.lib")\r
SSL_LIBS = libssl.lib libcrypto.lib\r
!ELSE\r
SSL_LIBS = libeay32.lib ssleay32.lib\r
!ENDIF\r
USE_SSL = true\r
-SSL = dll\r
-!ELSEIF "$(WITH_SSL)"=="static"\r
-!IF EXISTS("$(DEVEL_LIB)\libssl.lib")\r
-SSL_LIBS = libssl.lib libcrypto.lib gdi32.lib user32.lib crypt32.lib\r
-!ELSE\r
-SSL_LIBS = libeay32.lib ssleay32.lib gdi32.lib user32.lib crypt32.lib\r
+SSL = $(WITH_SSL)\r
+!IF "$(WITH_SSL)"=="static"\r
+WIN_LIBS = $(WIN_LIBS) gdi32.lib user32.lib crypt32.lib\r
!ENDIF\r
-USE_SSL = true\r
-SSL = static\r
!ENDIF\r
\r
!IFDEF USE_SSL\r
-SSL_CFLAGS = /DUSE_OPENSSL /I"$(DEVEL_INCLUDE)/openssl"\r
-!IF EXISTS("$(DEVEL_INCLUDE)\openssl\is_boringssl.h")\r
+SSL_CFLAGS = /DUSE_OPENSSL /I"$(SSL_INC_DIR)"\r
+!IF EXISTS("$(SSL_INC_DIR)\is_boringssl.h")\r
SSL_CFLAGS = $(SSL_CFLAGS) /DHAVE_BORINGSSL\r
!ENDIF\r
!ENDIF\r
\r
+\r
+!IFDEF NGHTTP2_PATH\r
+NGHTTP2_INC_DIR = $(NGHTTP2_PATH)\include\r
+NGHTTP2_LIB_DIR = $(NGHTTP2_PATH)\lib\r
+NGHTTP2_LFLAGS = $(NGHTTP2_LFLAGS) "/LIBPATH:$(NGHTTP2_LIB_DIR)"\r
+!ELSE\r
+NGHTTP2_INC_DIR = $(DEVEL_INCLUDE)\r
+NGHTTP2_LIB_DIR = $(DEVEL_LIB)\r
+!ENDIF\r
+\r
!IF "$(WITH_NGHTTP2)"=="dll"\r
-NGHTTP2_CFLAGS = /DUSE_NGHTTP2\r
+NGHTTP2_CFLAGS = /DUSE_NGHTTP2 /I"$(NGHTTP2_INC_DIR)"\r
NGHTTP2_LIBS = nghttp2.lib\r
!ELSEIF "$(WITH_NGHTTP2)"=="static"\r
-NGHTTP2_CFLAGS = /DUSE_NGHTTP2 /DNGHTTP2_STATICLIB\r
+NGHTTP2_CFLAGS = /DUSE_NGHTTP2 /DNGHTTP2_STATICLIB /I"$(NGHTTP2_INC_DIR)"\r
NGHTTP2_LIBS = nghttp2_static.lib\r
!ENDIF\r
\r
+\r
+!IFDEF MBEDTLS_PATH\r
+MBEDTLS_INC_DIR = $(MBEDTLS_PATH)\include\r
+MBEDTLS_LIB_DIR = $(MBEDTLS_PATH)\lib\r
+MBEDTLS_LFLAGS = $(MBEDTLS_LFLAGS) "/LIBPATH:$(MBEDTLS_LIB_DIR)"\r
+!ELSE\r
+MBEDTLS_INC_DIR = $(DEVEL_INCLUDE)\r
+MBEDTLS_LIB_DIR = $(DEVEL_LIB)\r
+!ENDIF\r
+\r
!IF "$(WITH_MBEDTLS)"=="dll" || "$(WITH_MBEDTLS)"=="static"\r
USE_MBEDTLS = true\r
MBEDTLS = $(WITH_MBEDTLS)\r
-MBEDTLS_CFLAGS = /DUSE_MBEDTLS\r
+MBEDTLS_CFLAGS = /DUSE_MBEDTLS /I"$(MBEDTLS_INC_DIR)"\r
MBEDTLS_LIBS = mbedtls.lib mbedcrypto.lib mbedx509.lib\r
!ENDIF\r
\r
\r
+!IFDEF CARES_PATH\r
+CARES_INC_DIR = $(CARES_PATH)\include\r
+CARES_LIB_DIR = $(CARES_PATH)\lib\r
+CARES_LFLAGS = $(CARES_LFLAGS) "/LIBPATH:$(CARES_LIB_DIR)"\r
+!ELSE\r
+CARES_INC_DIR = $(DEVEL_INCLUDE)/cares\r
+CARES_LIB_DIR = $(DEVEL_LIB)\r
+!ENDIF\r
+\r
!IF "$(WITH_CARES)"=="dll"\r
!IF "$(DEBUG)"=="yes"\r
CARES_LIBS = caresd.lib\r
!ENDIF\r
\r
!IFDEF USE_CARES\r
-CARES_CFLAGS = /DUSE_ARES /I"$(DEVEL_INCLUDE)/cares"\r
+CARES_CFLAGS = /DUSE_ARES /I"$(CARES_INC_DIR)"\r
+!ENDIF\r
+\r
+\r
+!IFDEF ZLIB_PATH\r
+ZLIB_INC_DIR = $(ZLIB_PATH)\include\r
+ZLIB_LIB_DIR = $(ZLIB_PATH)\lib\r
+ZLIB_LFLAGS = $(ZLIB_LFLAGS) "/LIBPATH:$(ZLIB_LIB_DIR)"\r
+!ELSE\r
+ZLIB_INC_DIR = $(DEVEL_INCLUDE)\r
+ZLIB_LIB_DIR = $(DEVEL_LIB)\r
!ENDIF\r
\r
# Depending on how zlib is built the libraries have different names, we \r
# try to handle them all. \r
!IF "$(WITH_ZLIB)"=="dll"\r
-!IF EXISTS("$(DEVEL_LIB)\zlibwapi.lib")\r
+!IF EXISTS("$(ZLIB_LIB_DIR)\zlibwapi.lib")\r
ZLIB_LIBS = zlibwapi.lib\r
-!ELSEIF EXISTS("$(DEVEL_LIB)\zdll.lib")\r
+!ELSEIF EXISTS("$(ZLIB_LIB_DIR)\zdll.lib")\r
ZLIB_LIBS = zdll.lib\r
!ELSE\r
ZLIB_LIBS = zlib.lib\r
USE_ZLIB = true\r
ZLIB = dll\r
!ELSEIF "$(WITH_ZLIB)"=="static"\r
-!IF EXISTS("$(DEVEL_LIB)\zlibstat.lib")\r
+!IF EXISTS("$(ZLIB_LIB_DIR)\zlibstat.lib")\r
ZLIB_LIBS = zlibstat.lib\r
-!ELSEIF EXISTS("$(DEVEL_LIB)\zlib.lib")\r
+!ELSEIF EXISTS("$(ZLIB_LIB_DIR)\zlib.lib")\r
ZLIB_LIBS = zlib.lib\r
!ELSE\r
ZLIB_LIBS = zlib_a.lib\r
!ENDIF\r
\r
!IFDEF USE_ZLIB\r
-ZLIB_CFLAGS = /DHAVE_ZLIB_H /DHAVE_ZLIB /DHAVE_LIBZ\r
+ZLIB_CFLAGS = /DHAVE_ZLIB_H /DHAVE_ZLIB /DHAVE_LIBZ /I"$(ZLIB_INC_DIR)"\r
!ENDIF\r
\r
\r
+!IFDEF SSH2_PATH\r
+SSH2_INC_DIR= $(SSH2_PATH)\include\r
+SSH2_LIB_DIR= $(SSH2_PATH)\lib\r
+SSH2_LFLAGS = $(SSH2_LFLAGS) "/LIBPATH:$(SSH2_LIB_DIR)"\r
+!ELSE\r
+SSH2_LIB_DIR= $(DEVEL_LIB)\r
+SSH2_INC_DIR= $(DEVEL_INCLUDE)/libssh2\r
+!ENDIF\r
+\r
!IF "$(WITH_SSH2)"=="dll"\r
SSH2_LIBS = libssh2.lib\r
USE_SSH2 = true\r
SSH2 = dll\r
!ELSEIF "$(WITH_SSH2)"=="static"\r
-SSH2_LIBS = libssh2_a.lib user32.lib\r
+# libssh2 NMakefile on Windows at default creates a static library without _a suffix\r
+!IF EXISTS("$(SSH2_LIB_DIR)\libssh2.lib")\r
+SSH2_LIBS = libssh2.lib\r
+!ELSE\r
+SSH2_LIBS = libssh2_a.lib\r
+!ENDIF\r
+WIN_LIBS = $(WIN_LIBS) user32.lib\r
USE_SSH2 = true\r
SSH2 = static\r
!ENDIF\r
\r
!IFDEF USE_SSH2\r
SSH2_CFLAGS = /DHAVE_LIBSSH2 /DHAVE_LIBSSH2_H /DLIBSSH2_WIN32 /DLIBSSH2_LIBRARY /DUSE_LIBSSH2\r
-SSH2_CFLAGS = $(SSH2_CFLAGS) /I$(WITH_DEVEL)/include/libssh2\r
+SSH2_CFLAGS = $(SSH2_CFLAGS) /I$(SSH2_INC_DIR)\r
!ENDIF\r
\r
\r
\r
!IF "$(AS_DLL)" == "true"\r
\r
-LNK = $(LNKDLL) $(WIN_LIBS) /out:$(LIB_DIROBJ)\$(TARGET)\r
+LNK = $(LNKDLL) $(LFLAGS) $(WIN_LIBS) /out:$(LIB_DIROBJ)\$(TARGET)\r
!IF "$(DEBUG)"=="yes"\r
TARGET = $(LIB_NAME_DLL_DEBUG)\r
LNK = $(LNK) /DEBUG /IMPLIB:$(LIB_DIROBJ)\$(LIB_NAME_IMP_DEBUG)\r
TARGET = $(LIB_NAME_STATIC)\r
PDB = $(PDB_NAME_STATIC)\r
!ENDIF\r
-LNK = $(LNKLIB) $(WIN_LIBS) /out:$(LIB_DIROBJ)\$(TARGET)\r
+LNK = $(LNKLIB) /out:$(LIB_DIROBJ)\$(TARGET)\r
CURL_CC = $(CURL_CC) $(CFLAGS_LIBCURL_STATIC)\r
\r
# AS_DLL\r
#\r
CURL_LINK = link.exe /incremental:no /libpath:"$(DIRDIST)\lib"\r
\r
-#!IF "$(CFG)" == "release-ssh2-ssl-dll-zlib"\r
-#TARGET = $(LIB_NAME_STATIC)\r
-#LNK = $(LNKLIB) $(WINLIBS) $(SSLLIBS) $(ZLIBLIBS) $(SSH2LIBS) $(SSL_LFLAGS) $(ZLIB_LFLAGS) $(LFLAGSSSH) /out:$(LIB_DIROBJ)\$(TARGET)\r
-#CC = $(CCNODBG) $(RTLIB) $(SSL_CFLAGS) $(ZLIB_CFLAGS) $(CFLAGSLIB) $(SSH2_CFLAGS)\r
-#CFGSET = TRUE\r
-#!ENDIF\r
-\r
-#######################\r
-# Only the clean target can be used if a config was not provided.\r
-#\r
!IF "$(CFGSET)" != "FALSE"\r
# A mode was provided, so the library can be built.\r
#\r
@echo GenPDB: $(GEN_PDB)\r
@echo Debug: $(DEBUG)\r
@echo Machine: $(MACHINE)\r
- $(LNK) $(LFLAGS) $(LIB_OBJS)\r
+ $(LNK) $(LIB_OBJS)\r
@echo Copying libs...\r
@if exist $(LIB_DIROBJ)\$(LIB_NAME_DLL) copy $(LIB_DIROBJ)\$(LIB_NAME_DLL) $(DIRDIST)\bin\ /y >nul 2<&1\r
@if exist $(LIB_DIROBJ)\$(LIB_NAME_STATIC) copy $(LIB_DIROBJ)\$(LIB_NAME_STATIC) $(DIRDIST)\lib\ /y >nul 2<&1\r