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