1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1999 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
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.
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.
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
21 #***************************************************************************
23 ###########################################################################
25 ## Makefile for building curl.exe with MingW (GCC-3.2 or later or LLVM/Clang)
26 ## and optionally OpenSSL (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4),
29 ## Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
30 ## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
32 ## Hint: you can also set environment vars to control the build, f.e.:
33 ## set ZLIB_PATH=c:/zlib-1.2.8
36 ###########################################################################
38 # Edit the path below to point to the base of your Zlib sources.
40 ZLIB_PATH = ../../zlib-1.2.8
42 # Edit the path below to point to the base of your Brotli sources.
44 BROTLI_PATH = ../../brotli-1.0.1
46 # Edit the path below to point to the base of your OpenSSL package.
48 OPENSSL_PATH = ../../openssl-1.0.2a
50 # Edit the path below to point to the base of your LibSSH2 package.
52 LIBSSH2_PATH = ../../libssh2-1.5.0
54 # Edit the path below to point to the base of your librtmp package.
56 LIBRTMP_PATH = ../../librtmp-2.4
58 # Edit the path below to point to the base of your libmetalink package.
59 ifndef LIBMETALINK_PATH
60 LIBMETALINK_PATH = ../../libmetalink-0.1.3
62 # Edit the path below to point to the base of your libexpat package.
64 LIBEXPAT_PATH = ../../expat-2.1.0
66 # Edit the path below to point to the base of your libxml2 package.
68 LIBXML2_PATH = ../../libxml2-2.9.2
70 # Edit the path below to point to the base of your libidn2 package.
72 LIBIDN2_PATH = ../../libidn2-2.0.3
74 # Edit the path below to point to the base of your MS IDN package.
75 # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
76 # https://www.microsoft.com/en-us/download/details.aspx?id=734
78 WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
80 # Edit the path below to point to the base of your Novell LDAP NDK.
82 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
84 # Edit the path below to point to the base of your nghttp2 package.
86 NGHTTP2_PATH = ../../nghttp2-1.0.0
91 # Edit the path below to point to the base of your c-ares package.
93 LIBCARES_PATH = $(PROOT)/ares
97 CURL_CC := $(CROSSPREFIX)gcc
100 CURL_AR := $(CROSSPREFIX)ar
104 CFLAGS = $(CURL_CFLAG_EXTRAS) -g -O2 -Wall -W
105 CFLAGS += -fno-strict-aliasing
106 # comment LDFLAGS below to keep debug info
107 LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_EXE) -s
109 RC = $(CROSSPREFIX)windres
110 RCFLAGS = --include-dir=$(PROOT)/include -O COFF
111 STRIP = $(CROSSPREFIX)strip -g
113 # We may need these someday
117 # Set environment var ARCH to your architecture to override autodetection.
119 ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
127 CFLAGS += -m64 -D_AMD64_
129 RCFLAGS += -F pe-x86-64
133 RCFLAGS += -F pe-i386
136 # Platform-dependent helper tool macros
137 ifeq ($(findstring /sh,$(SHELL)),/sh)
141 COPY = -cp -afv $1 $2
142 #COPYR = -cp -afr $1/* $2
143 COPYR = -rsync -aC $1/* $2
149 ifeq "$(OS)" "Windows_NT"
150 DEL = -del 2>NUL /q /f $(subst /,\,$1)
151 RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
153 DEL = -del 2>NUL $(subst /,\,$1)
154 RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
156 MKDIR = -md 2>NUL $(subst /,\,$1)
157 COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
158 COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
159 TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
161 ECHONL = $(ComSpec) /c echo.
164 ########################################################
165 ## Nothing more to do below this line!
167 ifeq ($(findstring -dyn,$(CFG)),-dyn)
170 ifeq ($(findstring -ares,$(CFG)),-ares)
173 ifeq ($(findstring -sync,$(CFG)),-sync)
176 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
181 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
186 ifeq ($(findstring -ssl,$(CFG)),-ssl)
189 ifeq ($(findstring -zlib,$(CFG)),-zlib)
192 ifeq ($(findstring -brotli,$(CFG)),-brotli)
195 ifeq ($(findstring -idn2,$(CFG)),-idn2)
198 ifeq ($(findstring -winidn,$(CFG)),-winidn)
201 ifeq ($(findstring -sspi,$(CFG)),-sspi)
204 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
207 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
210 ifeq ($(findstring -metalink,$(CFG)),-metalink)
213 ifeq ($(findstring -winssl,$(CFG)),-winssl)
217 ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
221 INCLUDES = -I. -I../include -I../lib
224 CFLAGS += -DCURL_WITH_MULTI_SSL
229 curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
230 curl_LDADD = -L$(PROOT)/lib -lcurldll
232 curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
233 curl_LDADD = -L$(PROOT)/lib -lcurl
234 CFLAGS += -DCURL_STATICLIB
238 CFLAGS += -DUSE_SYNC_DNS
242 curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
244 CFLAGS += -DUSE_ARES -DCARES_STATICLIB
245 curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
249 CFLAGS += -DUSE_LIBRTMP
250 curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
253 CFLAGS += -DUSE_NGHTTP2
254 curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
257 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
258 curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
261 curl_LDADD += -lbcrypt -lcrypt32
266 ifndef OPENSSL_INCLUDE
267 ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
268 OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
270 ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
271 OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
274 ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
275 $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
277 ifndef OPENSSL_LIBPATH
278 OPENSSL_LIBS = -lssl -lcrypto
279 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
280 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
282 OPENSSL_LIBS = -lssl32 -leay32
285 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
286 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
290 OPENSSL_LIBS += -lgdi32 -lcrypt32
292 INCLUDES += -I"$(OPENSSL_INCLUDE)"
293 CFLAGS += -DUSE_OPENSSL
294 curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
297 CFLAGS += -DUSE_SCHANNEL
298 curl_LDADD += -lcrypt32
301 INCLUDES += -I"$(ZLIB_PATH)"
302 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
303 curl_LDADD += -L"$(ZLIB_PATH)" -lz
306 INCLUDES += -I"$(BROTLI_PATH)/include"
307 CFLAGS += -DHAVE_BROTLI
308 curl_LDADD += -L"$(BROTLI_PATH)/lib"
310 curl_LDADD += $(BROTLI_LIBS)
312 curl_LDADD += -lbrotlidec
316 CFLAGS += -DUSE_LIBIDN2
317 curl_LDADD += -L"$(LIBIDN2_PATH)/lib" -lidn2
320 CFLAGS += -DUSE_WIN32_IDN
321 curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
325 INCLUDES += -I"$(LIBMETALINK_PATH)/include"
326 CFLAGS += -DUSE_METALINK
327 curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink
329 ifeq ($(findstring libexpat_metalink_parser.o,$(shell $(AR) t "$(LIBMETALINK_PATH)/lib/libmetalink.a")),libexpat_metalink_parser.o)
330 curl_LDADD += -L"$(LIBEXPAT_PATH)/lib" -lexpat
332 curl_LDADD += -L"$(LIBXML2_PATH)/lib" -lxml2
337 CFLAGS += -DUSE_WINDOWS_SSPI
340 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
343 CFLAGS += -DHAVE_LDAP_SSL
345 ifdef USE_LDAP_NOVELL
346 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
347 curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
349 ifdef USE_LDAP_OPENLDAP
350 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
351 curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
353 ifndef USE_LDAP_NOVELL
354 ifndef USE_LDAP_OPENLDAP
355 curl_LDADD += -lwldap32
358 curl_LDADD += -lws2_32
360 # Makefile.inc provides the CSOURCES and HHEADERS defines
363 curl_PROGRAMS = curl.exe
364 curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
365 curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES))))
367 curl_OBJECTS += $(curlx_OBJECTS)
368 vpath %.c $(PROOT)/lib
374 all: $(curl_PROGRAMS)
376 curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES)
378 $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD)
380 # We don't have nroff normally under win32
381 # tool_hugehelp.c: $(PROOT)/docs/MANUAL $(PROOT)/docs/curl.1 mkhelp.pl
382 # @$(call DEL, tool_hugehelp.c)
383 # $(NROFF) -man $(PROOT)/docs/curl.1 | $(PERL) mkhelp.pl $(PROOT)/docs/MANUAL > tool_hugehelp.c
387 @$(call COPY, $@.cvs, $@)
390 $(CC) $(INCLUDES) $(CFLAGS) -c $<
393 $(RC) $(RCFLAGS) -i $< -o $@
396 ifeq "$(wildcard tool_hugehelp.c.cvs)" "tool_hugehelp.c.cvs"
397 @$(call DEL, tool_hugehelp.c)
399 @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE))
401 distclean vclean: clean
402 @$(call DEL, $(curl_PROGRAMS))