1 ###########################################################################
3 ## Makefile for building curl.exe with MingW (GCC-3.2 or later)
4 ## and optionally OpenSSL (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4)
6 ## Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
7 ## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-spi-winidn
9 ## Hint: you can also set environment vars to control the build, f.e.:
10 ## set ZLIB_PATH=c:/zlib-1.2.8
13 ###########################################################################
15 # Edit the path below to point to the base of your Zlib sources.
17 ZLIB_PATH = ../../zlib-1.2.8
19 # Edit the path below to point to the base of your OpenSSL package.
21 OPENSSL_PATH = ../../openssl-1.0.2a
23 # Edit the path below to point to the base of your LibSSH2 package.
25 LIBSSH2_PATH = ../../libssh2-1.5.0
27 # Edit the path below to point to the base of your librtmp package.
29 LIBRTMP_PATH = ../../librtmp-2.4
31 # Edit the path below to point to the base of your libmetalink package.
32 ifndef LIBMETALINK_PATH
33 LIBMETALINK_PATH = ../../libmetalink-0.1.3
35 # Edit the path below to point to the base of your libexpat package.
37 LIBEXPAT_PATH = ../../expat-2.1.0
39 # Edit the path below to point to the base of your libxml2 package.
41 LIBXML2_PATH = ../../libxml2-2.9.2
43 # Edit the path below to point to the base of your libidn package.
45 LIBIDN_PATH = ../../libidn-1.32
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 # https://www.microsoft.com/en-us/download/details.aspx?id=734
51 WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
53 # Edit the path below to point to the base of your Novell LDAP NDK.
55 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
57 # Edit the path below to point to the base of your nghttp2 package.
59 NGHTTP2_PATH = ../../nghttp2-1.0.0
64 # Edit the path below to point to the base of your c-ares package.
66 LIBCARES_PATH = $(PROOT)/ares
69 CC = $(CROSSPREFIX)gcc
71 CFLAGS += -fno-strict-aliasing
72 # comment LDFLAGS below to keep debug info
75 RC = $(CROSSPREFIX)windres
76 RCFLAGS = --include-dir=$(PROOT)/include -O COFF
77 STRIP = $(CROSSPREFIX)strip -g
79 # We may need these someday
83 # Set environment var ARCH to your architecture to override autodetection.
85 ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
93 CFLAGS += -m64 -D_AMD64_
95 RCFLAGS += -F pe-x86-64
102 # Platform-dependent helper tool macros
103 ifeq ($(findstring /sh,$(SHELL)),/sh)
107 COPY = -cp -afv $1 $2
108 #COPYR = -cp -afr $1/* $2
109 COPYR = -rsync -aC $1/* $2
115 ifeq "$(OS)" "Windows_NT"
116 DEL = -del 2>NUL /q /f $(subst /,\,$1)
117 RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
119 DEL = -del 2>NUL $(subst /,\,$1)
120 RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
122 MKDIR = -md 2>NUL $(subst /,\,$1)
123 COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
124 COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
125 TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
127 ECHONL = $(ComSpec) /c echo.
130 ########################################################
131 ## Nothing more to do below this line!
133 ifeq ($(findstring -dyn,$(CFG)),-dyn)
136 ifeq ($(findstring -ares,$(CFG)),-ares)
139 ifeq ($(findstring -sync,$(CFG)),-sync)
142 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
147 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
152 ifeq ($(findstring -ssl,$(CFG)),-ssl)
155 ifeq ($(findstring -zlib,$(CFG)),-zlib)
158 ifeq ($(findstring -idn,$(CFG)),-idn)
161 ifeq ($(findstring -winidn,$(CFG)),-winidn)
164 ifeq ($(findstring -sspi,$(CFG)),-sspi)
167 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
170 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
173 ifeq ($(findstring -metalink,$(CFG)),-metalink)
176 ifeq ($(findstring -winssl,$(CFG)),-winssl)
180 ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
184 INCLUDES = -I. -I../include -I../lib
187 curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
188 curl_LDADD = -L$(PROOT)/lib -lcurldll
190 curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
191 curl_LDADD = -L$(PROOT)/lib -lcurl
192 CFLAGS += -DCURL_STATICLIB
196 CFLAGS += -DUSE_SYNC_DNS
200 curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
202 CFLAGS += -DUSE_ARES -DCARES_STATICLIB
203 curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
207 CFLAGS += -DUSE_LIBRTMP
208 curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
211 CFLAGS += -DUSE_NGHTTP2
212 curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
215 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
216 curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
219 ifndef OPENSSL_INCLUDE
220 ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
221 OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
223 ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
224 OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
227 ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
228 $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
230 ifndef OPENSSL_LIBPATH
231 OPENSSL_LIBS = -lssl -lcrypto
232 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
233 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
235 OPENSSL_LIBS = -lssl32 -leay32
238 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
239 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
243 OPENSSL_LIBS += -lgdi32 -lcrypt32
245 INCLUDES += -I"$(OPENSSL_INCLUDE)"
246 CFLAGS += -DUSE_OPENSSL
247 curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
250 INCLUDES += -I"$(ZLIB_PATH)"
251 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
252 curl_LDADD += -L"$(ZLIB_PATH)" -lz
255 CFLAGS += -DUSE_LIBIDN
256 curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
259 CFLAGS += -DUSE_WIN32_IDN
260 curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
264 INCLUDES += -I"$(LIBMETALINK_PATH)/include"
265 CFLAGS += -DUSE_METALINK
266 curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink
268 ifeq ($(findstring libexpat_metalink_parser.o,$(shell $(AR) t "$(LIBMETALINK_PATH)/lib/libmetalink.a")),libexpat_metalink_parser.o)
269 curl_LDADD += -L"$(LIBEXPAT_PATH)/lib" -lexpat
271 curl_LDADD += -L"$(LIBXML2_PATH)/lib" -lxml2
276 CFLAGS += -DUSE_WINDOWS_SSPI
278 CFLAGS += -DUSE_SCHANNEL
282 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
285 CFLAGS += -DHAVE_LDAP_SSL
287 ifdef USE_LDAP_NOVELL
288 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
289 curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
291 ifdef USE_LDAP_OPENLDAP
292 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
293 curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
295 ifndef USE_LDAP_NOVELL
296 ifndef USE_LDAP_OPENLDAP
297 curl_LDADD += -lwldap32
300 curl_LDADD += -lws2_32
302 # Makefile.inc provides the CSOURCES and HHEADERS defines
305 curl_PROGRAMS = curl.exe
306 curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
307 curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES))))
309 curl_OBJECTS += $(curlx_OBJECTS)
310 vpath %.c $(PROOT)/lib
316 all: $(curl_PROGRAMS)
318 curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES)
320 $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD)
322 # We don't have nroff normally under win32
323 # tool_hugehelp.c: $(PROOT)/docs/MANUAL $(PROOT)/docs/curl.1 mkhelp.pl
324 # @$(call DEL, tool_hugehelp.c)
325 # $(NROFF) -man $(PROOT)/docs/curl.1 | $(PERL) mkhelp.pl $(PROOT)/docs/MANUAL > tool_hugehelp.c
329 @$(call COPY, $@.cvs, $@)
332 $(CC) $(INCLUDES) $(CFLAGS) -c $<
335 $(RC) $(RCFLAGS) -i $< -o $@
338 ifeq "$(wildcard tool_hugehelp.c.cvs)" "tool_hugehelp.c.cvs"
339 @$(call DEL, tool_hugehelp.c)
341 @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE))
343 distclean vclean: clean
344 @$(call DEL, $(curl_PROGRAMS))