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