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