Revert "Imported Upstream version 7.44.0"
[platform/upstream/curl.git] / src / Makefile.m32
1 ###########################################################################
2 #
3 ## Makefile for building curl.exe with MingW (GCC-3.2 or later)
4 ## and optionally OpenSSL (0.9.8), libssh2 (1.3), zlib (1.2.5), librtmp (2.3)
5 ##
6 ## Usage:   mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
7 ## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-spi-winidn
8 ##
9 ## Hint: you can also set environment vars to control the build, f.e.:
10 ## set ZLIB_PATH=c:/zlib-1.2.8
11 ## set ZLIB=1
12 #
13 ###########################################################################
14
15 # Edit the path below to point to the base of your Zlib sources.
16 ifndef ZLIB_PATH
17 ZLIB_PATH = ../../zlib-1.2.8
18 endif
19 # Edit the path below to point to the base of your OpenSSL package.
20 ifndef OPENSSL_PATH
21 OPENSSL_PATH = ../../openssl-0.9.8zc
22 endif
23 # Edit the path below to point to the base of your LibSSH2 package.
24 ifndef LIBSSH2_PATH
25 LIBSSH2_PATH = ../../libssh2-1.4.3
26 endif
27 # Edit the path below to point to the base of your librtmp package.
28 ifndef LIBRTMP_PATH
29 LIBRTMP_PATH = ../../librtmp-2.3
30 endif
31 # Edit the path below to point to the base of your libmetalink package.
32 ifndef LIBMETALINK_PATH
33 LIBMETALINK_PATH = ../../libmetalink-0.1.2
34 endif
35 # Edit the path below to point to the base of your libexpat package.
36 ifndef LIBEXPAT_PATH
37 LIBEXPAT_PATH = ../../expat-2.1.0
38 endif
39 # Edit the path below to point to the base of your libxml2 package.
40 ifndef LIBXML2_PATH
41 LIBXML2_PATH = ../../libxml2-2.9.0
42 endif
43 # Edit the path below to point to the base of your libidn package.
44 ifndef LIBIDN_PATH
45 LIBIDN_PATH = ../../libidn-1.18
46 endif
47 # Edit the path below to point to the base of your MS IDN package.
48 # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
49 # http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815
50 ifndef WINIDN_PATH
51 WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
52 endif
53 # Edit the path below to point to the base of your Novell LDAP NDK.
54 ifndef LDAP_SDK
55 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
56 endif
57 # Edit the path below to point to the base of your nghttp2 package.
58 ifndef NGHTTP2_PATH
59 NGHTTP2_PATH = ../../nghttp2-0.6.7
60 endif
61
62 PROOT = ..
63
64 # Edit the path below to point to the base of your c-ares package.
65 ifndef LIBCARES_PATH
66 LIBCARES_PATH = $(PROOT)/ares
67 endif
68
69 CC      = $(CROSSPREFIX)gcc
70 CFLAGS  = -g -O2 -Wall
71 CFLAGS  += -fno-strict-aliasing
72 # comment LDFLAGS below to keep debug info
73 LDFLAGS = -s
74 AR      = $(CROSSPREFIX)ar
75 RC      = $(CROSSPREFIX)windres
76 RCFLAGS = --include-dir=$(PROOT)/include -O COFF
77 STRIP   = $(CROSSPREFIX)strip -g
78
79 # We may need these someday
80 # PERL = perl
81 # NROFF = nroff
82
83 # Set environment var ARCH to your architecture to override autodetection.
84 ifndef ARCH
85 ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
86 ARCH    = w64
87 else
88 ARCH    = w32
89 endif
90 endif
91
92 ifeq ($(ARCH),w64)
93 CFLAGS  += -D_AMD64_
94 RCFLAGS += -F pe-x86-64
95 else
96 CFLAGS  += -m32
97 RCFLAGS += -F pe-i386
98 endif
99
100 # Platform-dependent helper tool macros
101 ifeq ($(findstring /sh,$(SHELL)),/sh)
102 DEL     = rm -f $1
103 RMDIR   = rm -fr $1
104 MKDIR   = mkdir -p $1
105 COPY    = -cp -afv $1 $2
106 #COPYR  = -cp -afr $1/* $2
107 COPYR   = -rsync -aC $1/* $2
108 TOUCH   = touch $1
109 CAT     = cat
110 ECHONL  = echo ""
111 DL      = '
112 else
113 ifeq "$(OS)" "Windows_NT"
114 DEL     = -del 2>NUL /q /f $(subst /,\,$1)
115 RMDIR   = -rd 2>NUL /q /s $(subst /,\,$1)
116 else
117 DEL     = -del 2>NUL $(subst /,\,$1)
118 RMDIR   = -deltree 2>NUL /y $(subst /,\,$1)
119 endif
120 MKDIR   = -md 2>NUL $(subst /,\,$1)
121 COPY    = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
122 COPYR   = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
123 TOUCH   = copy 2>&1>NUL /b $(subst /,\,$1) +,,
124 CAT     = type
125 ECHONL  = $(ComSpec) /c echo.
126 endif
127
128 ########################################################
129 ## Nothing more to do below this line!
130
131 ifeq ($(findstring -dyn,$(CFG)),-dyn)
132 DYN = 1
133 endif
134 ifeq ($(findstring -ares,$(CFG)),-ares)
135 ARES = 1
136 endif
137 ifeq ($(findstring -sync,$(CFG)),-sync)
138 SYNC = 1
139 endif
140 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
141 RTMP = 1
142 SSL = 1
143 ZLIB = 1
144 endif
145 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
146 SSH2 = 1
147 SSL = 1
148 ZLIB = 1
149 endif
150 ifeq ($(findstring -ssl,$(CFG)),-ssl)
151 SSL = 1
152 endif
153 ifeq ($(findstring -zlib,$(CFG)),-zlib)
154 ZLIB = 1
155 endif
156 ifeq ($(findstring -idn,$(CFG)),-idn)
157 IDN = 1
158 endif
159 ifeq ($(findstring -winidn,$(CFG)),-winidn)
160 WINIDN = 1
161 endif
162 ifeq ($(findstring -sspi,$(CFG)),-sspi)
163 SSPI = 1
164 endif
165 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
166 LDAPS = 1
167 endif
168 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
169 IPV6 = 1
170 endif
171 ifeq ($(findstring -metalink,$(CFG)),-metalink)
172 METALINK = 1
173 endif
174 ifeq ($(findstring -winssl,$(CFG)),-winssl)
175 WINSSL = 1
176 SSPI = 1
177 endif
178 ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
179 NGHTTP2 = 1
180 endif
181
182 INCLUDES = -I. -I../include -I../lib
183
184 ifdef DYN
185   curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
186   curl_LDADD = -L$(PROOT)/lib -lcurldll
187 else
188   curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
189   curl_LDADD = -L$(PROOT)/lib -lcurl
190   CFLAGS += -DCURL_STATICLIB
191   LDFLAGS += -static
192 endif
193 ifdef SYNC
194   CFLAGS += -DUSE_SYNC_DNS
195 else
196   ifdef ARES
197     ifndef DYN
198       curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
199     endif
200     CFLAGS += -DUSE_ARES -DCARES_STATICLIB
201     curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
202   endif
203 endif
204 ifdef RTMP
205   CFLAGS += -DUSE_LIBRTMP
206   curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
207 endif
208 ifdef NGHTTP2
209   CFLAGS += -DUSE_NGHTTP2
210   curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
211 endif
212 ifdef SSH2
213   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
214   curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
215 endif
216 ifdef SSL
217   ifndef OPENSSL_INCLUDE
218     ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
219       OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
220     endif
221     ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
222       OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
223     endif
224   endif
225   ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
226   $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
227   endif
228   ifndef OPENSSL_LIBPATH
229     OPENSSL_LIBS = -lssl -lcrypto
230     ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
231       OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
232       ifdef DYN
233         OPENSSL_LIBS = -lssl32 -leay32
234       endif
235     endif
236     ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
237       OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
238     endif
239   endif
240   ifndef DYN
241     OPENSSL_LIBS += -lgdi32 -lcrypt32
242   endif
243   INCLUDES += -I"$(OPENSSL_INCLUDE)"
244   CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL
245   curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
246 endif
247 ifdef ZLIB
248   INCLUDES += -I"$(ZLIB_PATH)"
249   CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
250   curl_LDADD += -L"$(ZLIB_PATH)" -lz
251 endif
252 ifdef IDN
253   CFLAGS += -DUSE_LIBIDN
254   curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
255 else
256 ifdef WINIDN
257   CFLAGS += -DUSE_WIN32_IDN
258   curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
259 endif
260 endif
261 ifdef METALINK
262   INCLUDES += -I"$(LIBMETALINK_PATH)/include"
263   CFLAGS += -DUSE_METALINK
264   curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink
265   ifndef DYN
266     ifeq ($(findstring libexpat_metalink_parser.o,$(shell $(AR) t "$(LIBMETALINK_PATH)/lib/libmetalink.a")),libexpat_metalink_parser.o)
267       curl_LDADD += -L"$(LIBEXPAT_PATH)/lib" -lexpat
268     else
269       curl_LDADD += -L"$(LIBXML2_PATH)/lib" -lxml2
270     endif
271   endif
272 endif
273 ifdef SSPI
274   CFLAGS += -DUSE_WINDOWS_SSPI
275   ifdef WINSSL
276     CFLAGS += -DUSE_SCHANNEL
277   endif
278 endif
279 ifdef IPV6
280   CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
281 endif
282 ifdef LDAPS
283   CFLAGS += -DHAVE_LDAP_SSL
284 endif
285 ifdef USE_LDAP_NOVELL
286   CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
287   curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
288 endif
289 ifdef USE_LDAP_OPENLDAP
290   CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
291   curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
292 endif
293 ifndef USE_LDAP_NOVELL
294 ifndef USE_LDAP_OPENLDAP
295 curl_LDADD += -lwldap32
296 endif
297 endif
298 curl_LDADD += -lws2_32
299
300 # Makefile.inc provides the CSOURCES and HHEADERS defines
301 include Makefile.inc
302
303 curl_PROGRAMS = curl.exe
304 curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
305 curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES))))
306 ifdef DYN
307 curl_OBJECTS += $(curlx_OBJECTS)
308 vpath %.c $(PROOT)/lib
309 endif
310
311 RESOURCE = curl.res
312
313
314 all: $(curl_PROGRAMS)
315
316 curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES)
317         $(call DEL, $@)
318         $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD)
319
320 # We don't have nroff normally under win32
321 # tool_hugehelp.c: $(PROOT)/docs/MANUAL $(PROOT)/docs/curl.1 mkhelp.pl
322 #       @$(call DEL, tool_hugehelp.c)
323 #       $(NROFF) -man $(PROOT)/docs/curl.1 | $(PERL) mkhelp.pl $(PROOT)/docs/MANUAL > tool_hugehelp.c
324
325 tool_hugehelp.c:
326         @echo Creating $@
327         @$(call COPY, $@.cvs, $@)
328
329 %.o: %.c
330         $(CC) $(INCLUDES) $(CFLAGS) -c $<
331
332 %.res: %.rc
333         $(RC) $(RCFLAGS) -i $< -o $@
334
335 clean:
336 ifeq "$(wildcard tool_hugehelp.c.cvs)" "tool_hugehelp.c.cvs"
337         @$(call DEL, tool_hugehelp.c)
338 endif
339         @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE))
340
341 distclean vclean: clean
342         @$(call DEL, $(curl_PROGRAMS))
343