1!IF "$(MODE)"=="static"
2TARGET = $(LIB_NAME_STATIC)
3AS_DLL = false
4CFGSET=true
5!ELSEIF "$(MODE)"=="dll"
6TARGET = $(LIB_NAME_DLL)
7AS_DLL = true
8CFGSET=true
9!ELSE
10!MESSAGE Invalid mode: $(MODE)
11
12#######################
13# Usage
14#
15
16!MESSAGE Usage: nmake /f Makefile.vc mode=<static or dll> <options>
17!MESSAGE where <options> is one or many of:
18!MESSAGE   VC=<6,7,8,9,10,11,12,14>     - VC versions
19!MESSAGE   WITH_DEVEL=<path>            - Paths for the development files (SSL, zlib, etc.)
20!MESSAGE                                  Defaults to sibbling directory deps: ../deps
21!MESSAGE                                  Libraries can be fetched at http://pecl2.php.net/downloads/php-windows-builds/
22!MESSAGE                                  Uncompress them into the deps folder.
23!MESSAGE   WITH_SSL=<dll or static>     - Enable OpenSSL support, DLL or static
24!MESSAGE   WITH_CARES=<dll or static>   - Enable c-ares support, DLL or static
25!MESSAGE   WITH_ZLIB=<dll or static>    - Enable zlib support, DLL or static
26!MESSAGE   WITH_SSH2=<dll or static>    - Enable libSSH2 support, DLL or static
27!MESSAGE   ENABLE_IDN=<yes or no>       - Enable use of Windows IDN APIs, defaults to yes
28!MESSAGE                                  Requires Windows Vista or later, or installation from:
29!MESSAGE                                  https://www.microsoft.com/en-us/download/details.aspx?id=734
30!MESSAGE   ENABLE_IPV6=<yes or no>      - Enable IPv6, defaults to yes
31!MESSAGE   ENABLE_SSPI=<yes or no>      - Enable SSPI support, defaults to yes
32!MESSAGE   ENABLE_WINSSL=<yes or no>    - Enable native Windows SSL support, defaults to yes
33!MESSAGE   GEN_PDB=<yes or no>          - Generate Program Database (debug symbols for release build)
34!MESSAGE   DEBUG=<yes or no>            - Debug builds
35!MESSAGE   MACHINE=<x86 or x64>         - Target architecture (default x64 on AMD64, x86 on others)
36!ERROR please choose a valid mode
37
38!ENDIF
39
40!INCLUDE "../lib/Makefile.inc"
41LIBCURL_OBJS=$(CSOURCES:.c=.obj)
42
43!INCLUDE "../src/Makefile.inc"
44
45# tool_hugehelp has a special rule
46CURL_OBJS=$(CURL_CFILES:tool_hugehelp.c=)
47
48CURL_OBJS=$(CURL_OBJS:.c=.obj)
49
50
51# backwards compatible check for USE_SSPI
52!IFDEF USE_SSPI
53ENABLE_SSPI = $(USE_SSPI)
54!ENDIF
55
56# default options
57!IFNDEF MACHINE
58!IF "$(PROCESSOR_ARCHITECTURE)"=="AMD64"
59MACHINE = x64
60!ELSE
61MACHINE = x86
62!ENDIF
63!ENDIF
64
65!IFNDEF ENABLE_IDN
66USE_IDN = true
67!ELSEIF "$(ENABLE_IDN)"=="yes"
68USE_IDN = true
69!ELSEIF "$(ENABLE_IDN)"=="no"
70USE_IDN = false
71!ENDIF
72
73!IFNDEF ENABLE_IPV6
74USE_IPV6 = true
75!ELSEIF "$(ENABLE_IPV6)"=="yes"
76USE_IPV6 = true
77!ELSEIF "$(ENABLE_IPV6)"=="no"
78USE_IPV6 = false
79!ENDIF
80
81!IFNDEF ENABLE_SSPI
82USE_SSPI = true
83!ELSEIF "$(ENABLE_SSPI)"=="yes"
84USE_SSPI = true
85!ELSEIF "$(ENABLE_SSPI)"=="no"
86USE_SSPI = false
87!ENDIF
88
89!IFNDEF ENABLE_WINSSL
90!IFDEF WITH_SSL
91USE_WINSSL = false
92!ELSE
93USE_WINSSL = $(USE_SSPI)
94!ENDIF
95!ELSEIF "$(ENABLE_WINSSL)"=="yes"
96USE_WINSSL = true
97!ELSEIF "$(ENABLE_WINSSL)"=="no"
98USE_WINSSL = false
99!ENDIF
100
101CONFIG_NAME_LIB = libcurl
102
103!IF "$(WITH_SSL)"=="dll"
104USE_SSL = true
105SSL     = dll
106!ELSEIF "$(WITH_SSL)"=="static"
107USE_SSL = true
108SSL     = static
109!ENDIF
110
111!IF "$(WITH_CARES)"=="dll"
112USE_CARES = true
113CARES     = dll
114!ELSEIF "$(WITH_CARES)"=="static"
115USE_CARES = true
116CARES     = static
117!ENDIF
118
119!IF "$(WITH_ZLIB)"=="dll"
120USE_ZLIB = true
121ZLIB     = dll
122!ELSEIF "$(WITH_ZLIB)"=="static"
123USE_ZLIB = true
124ZLIB     = static
125!ENDIF
126
127!IF "$(WITH_SSH2)"=="dll"
128USE_SSH2 = true
129SSH2     = dll
130!ELSEIF "$(WITH_SSH2)"=="static"
131USE_SSH2 = true
132SSH2     = static
133!ENDIF
134
135CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-vc$(VC)-$(MACHINE)
136
137!IF "$(DEBUG)"=="yes"
138CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-debug
139!ELSE
140CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-release
141!ENDIF
142
143!IF "$(AS_DLL)"=="true"
144CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-dll
145!ELSE
146CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-static
147!ENDIF
148
149!IF "$(USE_SSL)"=="true"
150CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-ssl-$(SSL)
151!ENDIF
152
153!IF "$(USE_CARES)"=="true"
154CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-cares-$(CARES)
155!ENDIF
156
157!IF "$(USE_ZLIB)"=="true"
158CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-zlib-$(ZLIB)
159!ENDIF
160
161!IF "$(USE_SSH2)"=="true"
162CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-ssh2-$(SSH2)
163!ENDIF
164
165!IF "$(USE_IPV6)"=="true"
166CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-ipv6
167!ENDIF
168
169!IF "$(USE_SSPI)"=="true"
170CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-sspi
171!ENDIF
172
173!IF "$(USE_WINSSL)"=="true"
174CONFIG_NAME_LIB = $(CONFIG_NAME_LIB)-winssl
175!ENDIF
176
177!MESSAGE configuration name: $(CONFIG_NAME_LIB)
178
179BUILD_DIR=../builds/$(CONFIG_NAME_LIB)
180LIBCURL_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-lib
181CURL_DIROBJ = ..\builds\$(CONFIG_NAME_LIB)-obj-curl
182DIRDIST = ..\builds\$(CONFIG_NAME_LIB)\
183
184$(MODE):
185	@IF NOT EXIST ..\include\curl\curlbuild.h ( \
186	   CALL ..\buildconf.bat \
187	)
188	@SET DIROBJ=$(LIBCURL_DIROBJ)
189	@SET MACRO_NAME=LIBCURL_OBJS
190	@SET OUTFILE=LIBCURL_OBJS.inc
191	@gen_resp_file.bat $(LIBCURL_OBJS)
192
193	@SET DIROBJ=$(CURL_DIROBJ)
194	@SET MACRO_NAME=CURL_OBJS
195	@SET OUTFILE=CURL_OBJS.inc
196	@gen_resp_file.bat $(CURL_OBJS)
197
198	@SET CONFIG_NAME_LIB=$(CONFIG_NAME_LIB)
199	@SET MACHINE=$(MACHINE)
200	@SET USE_IDN=$(USE_IDN)
201	@SET USE_IPV6=$(USE_IPV6)
202	@SET USE_SSPI=$(USE_SSPI)
203	@SET USE_WINSSL=$(USE_WINSSL)
204	@$(MAKE) /NOLOGO /F MakefileBuild.vc
205
206copy_from_lib:
207	echo copying .c...
208	FOR %%i IN ($(CURLX_CFILES:/=\)) DO copy %%i ..\src\
209