Revert "Imported Upstream version 7.44.0"
[platform/upstream/curl.git] / lib / Makefile.m32
1 ###########################################################################
2 #
3 ## Makefile for building libcurl.a 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-sspi-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 libidn package.
32 ifndef LIBIDN_PATH
33 LIBIDN_PATH = ../../libidn-1.18
34 endif
35 # Edit the path below to point to the base of your MS IDN package.
36 # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
37 # http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815
38 ifndef WINIDN_PATH
39 WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
40 endif
41 # Edit the path below to point to the base of your Novell LDAP NDK.
42 ifndef LDAP_SDK
43 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
44 endif
45 # Edit the path below to point to the base of your nghttp2 package.
46 ifndef NGHTTP2_PATH
47 NGHTTP2_PATH = ../../nghttp2-0.6.7
48 endif
49
50 PROOT = ..
51
52 # Edit the path below to point to the base of your c-ares package.
53 ifndef LIBCARES_PATH
54 LIBCARES_PATH = $(PROOT)/ares
55 endif
56
57 CC      = $(CROSSPREFIX)gcc
58 CFLAGS  = -g -O2 -Wall
59 CFLAGS  += -fno-strict-aliasing
60 # comment LDFLAGS below to keep debug info
61 LDFLAGS = -s
62 AR      = $(CROSSPREFIX)ar
63 RANLIB  = $(CROSSPREFIX)ranlib
64 RC      = $(CROSSPREFIX)windres
65 RCFLAGS = --include-dir=$(PROOT)/include -DDEBUGBUILD=0 -O COFF
66 STRIP   = $(CROSSPREFIX)strip -g
67
68 # Set environment var ARCH to your architecture to override autodetection.
69 ifndef ARCH
70 ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
71 ARCH    = w64
72 else
73 ARCH    = w32
74 endif
75 endif
76
77 ifeq ($(ARCH),w64)
78 CFLAGS  += -D_AMD64_
79 RCFLAGS += -F pe-x86-64
80 else
81 CFLAGS  += -m32
82 RCFLAGS += -F pe-i386
83 endif
84
85 # Platform-dependent helper tool macros
86 ifeq ($(findstring /sh,$(SHELL)),/sh)
87 DEL     = rm -f $1
88 RMDIR   = rm -fr $1
89 MKDIR   = mkdir -p $1
90 COPY    = -cp -afv $1 $2
91 #COPYR  = -cp -afr $1/* $2
92 COPYR   = -rsync -aC $1/* $2
93 TOUCH   = touch $1
94 CAT     = cat
95 ECHONL  = echo ""
96 DL      = '
97 else
98 ifeq "$(OS)" "Windows_NT"
99 DEL     = -del 2>NUL /q /f $(subst /,\,$1)
100 RMDIR   = -rd 2>NUL /q /s $(subst /,\,$1)
101 else
102 DEL     = -del 2>NUL $(subst /,\,$1)
103 RMDIR   = -deltree 2>NUL /y $(subst /,\,$1)
104 endif
105 MKDIR   = -md 2>NUL $(subst /,\,$1)
106 COPY    = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
107 COPYR   = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
108 TOUCH   = copy 2>&1>NUL /b $(subst /,\,$1) +,,
109 CAT     = type
110 ECHONL  = $(ComSpec) /c echo.
111 endif
112
113 ########################################################
114 ## Nothing more to do below this line!
115
116 ifeq ($(findstring -dyn,$(CFG)),-dyn)
117 DYN = 1
118 endif
119 ifeq ($(findstring -ares,$(CFG)),-ares)
120 ARES = 1
121 endif
122 ifeq ($(findstring -sync,$(CFG)),-sync)
123 SYNC = 1
124 endif
125 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
126 RTMP = 1
127 SSL = 1
128 ZLIB = 1
129 endif
130 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
131 SSH2 = 1
132 SSL = 1
133 ZLIB = 1
134 endif
135 ifeq ($(findstring -ssl,$(CFG)),-ssl)
136 SSL = 1
137 endif
138 ifeq ($(findstring -srp,$(CFG)),-srp)
139 SRP = 1
140 endif
141 ifeq ($(findstring -zlib,$(CFG)),-zlib)
142 ZLIB = 1
143 endif
144 ifeq ($(findstring -idn,$(CFG)),-idn)
145 IDN = 1
146 endif
147 ifeq ($(findstring -winidn,$(CFG)),-winidn)
148 WINIDN = 1
149 endif
150 ifeq ($(findstring -sspi,$(CFG)),-sspi)
151 SSPI = 1
152 endif
153 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
154 LDAPS = 1
155 endif
156 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
157 IPV6 = 1
158 endif
159 ifeq ($(findstring -winssl,$(CFG)),-winssl)
160 WINSSL = 1
161 SSPI = 1
162 endif
163 ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
164 NGHTTP2 = 1
165 endif
166
167 INCLUDES = -I. -I../include
168 CFLAGS += -DBUILDING_LIBCURL
169
170 ifdef SYNC
171   CFLAGS += -DUSE_SYNC_DNS
172 else
173   ifdef ARES
174     INCLUDES += -I"$(LIBCARES_PATH)"
175     CFLAGS += -DUSE_ARES -DCARES_STATICLIB
176     DLL_LIBS += -L"$(LIBCARES_PATH)" -lcares
177     libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a
178   endif
179 endif
180 ifdef RTMP
181   INCLUDES += -I"$(LIBRTMP_PATH)"
182   CFLAGS += -DUSE_LIBRTMP
183   DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
184 endif
185 ifdef NGHTTP2
186   INCLUDES += -I"$(NGHTTP2_PATH)/include"
187   CFLAGS += -DUSE_NGHTTP2
188   DLL_LIBS += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
189 endif
190 ifdef SSH2
191   INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
192   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
193   DLL_LIBS += -L"$(LIBSSH2_PATH)/win32" -lssh2
194 endif
195 ifdef SSL
196   ifndef OPENSSL_INCLUDE
197     ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
198       OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
199     endif
200     ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
201       OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
202     endif
203   endif
204   ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
205   $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
206   endif
207   ifndef OPENSSL_LIBPATH
208     ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
209       OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
210       OPENSSL_LIBS = -leay32 -lssl32
211     endif
212     ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
213       OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
214       OPENSSL_LIBS = -lcrypto -lssl
215     endif
216   endif
217   INCLUDES += -I"$(OPENSSL_INCLUDE)"
218   CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \
219             -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 \
220             -DCURL_WANTS_CA_BUNDLE_ENV
221   DLL_LIBS += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
222   ifdef SRP
223     ifeq "$(wildcard $(OPENSSL_INCLUDE)/openssl/srp.h)" "$(OPENSSL_INCLUDE)/openssl/srp.h"
224       CFLAGS += -DHAVE_SSLEAY_SRP -DUSE_TLS_SRP
225     endif
226   endif
227 endif
228 ifdef ZLIB
229   INCLUDES += -I"$(ZLIB_PATH)"
230   CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
231   DLL_LIBS += -L"$(ZLIB_PATH)" -lz
232 endif
233 ifdef IDN
234   INCLUDES += -I"$(LIBIDN_PATH)/include"
235   CFLAGS += -DUSE_LIBIDN
236   DLL_LIBS += -L"$(LIBIDN_PATH)/lib" -lidn
237 else
238 ifdef WINIDN
239   CFLAGS += -DUSE_WIN32_IDN
240   CFLAGS += -DWANT_IDN_PROTOTYPES
241   DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz
242 endif
243 endif
244 ifdef SSPI
245   CFLAGS += -DUSE_WINDOWS_SSPI
246   ifdef WINSSL
247     CFLAGS += -DUSE_SCHANNEL
248   endif
249 endif
250 ifdef SPNEGO
251   CFLAGS += -DHAVE_SPNEGO
252 endif
253 ifdef IPV6
254   CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
255 endif
256 ifdef LDAPS
257   CFLAGS += -DHAVE_LDAP_SSL
258 endif
259 ifdef USE_LDAP_NOVELL
260   INCLUDES += -I"$(LDAP_SDK)/inc"
261   CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
262   DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
263 endif
264 ifdef USE_LDAP_OPENLDAP
265   INCLUDES += -I"$(LDAP_SDK)/include"
266   CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
267   DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
268 endif
269 ifndef USE_LDAP_NOVELL
270 ifndef USE_LDAP_OPENLDAP
271   DLL_LIBS += -lwldap32
272 endif
273 endif
274 DLL_LIBS += -lws2_32
275
276 # Makefile.inc provides the CSOURCES and HHEADERS defines
277 include Makefile.inc
278
279 libcurl_dll_LIBRARY = libcurl.dll
280 libcurl_dll_a_LIBRARY = libcurldll.a
281 libcurl_a_LIBRARY = libcurl.a
282
283 libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
284 libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
285
286 RESOURCE = libcurl.res
287
288
289 all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
290
291 $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
292         @$(call DEL, $@)
293         $(AR) cru $@ $(libcurl_a_OBJECTS)
294         $(RANLIB) $@
295         $(STRIP) $@
296
297 # remove the last line above to keep debug info
298
299 $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
300         @$(call DEL, $@)
301         $(CC) $(LDFLAGS) -shared -o $@ \
302           -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY) \
303           $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
304
305 %.o: %.c $(PROOT)/include/curl/curlbuild.h
306         $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
307
308 %.res: %.rc
309         $(RC) $(RCFLAGS) -i $< -o $@
310
311 clean:
312 ifeq "$(wildcard $(PROOT)/include/curl/curlbuild.h.dist)" "$(PROOT)/include/curl/curlbuild.h.dist"
313         @$(call DEL, $(PROOT)/include/curl/curlbuild.h)
314 endif
315         @$(call DEL, $(libcurl_a_OBJECTS) $(RESOURCE))
316
317 distclean vclean: clean
318         @$(call DEL, $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY))
319
320 $(PROOT)/include/curl/curlbuild.h:
321         @echo Creating $@
322         @$(call COPY, $@.dist, $@)
323
324 $(LIBCARES_PATH)/libcares.a:
325         $(MAKE) -C $(LIBCARES_PATH) -f Makefile.m32
326
327