1 ###########################################################################
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)
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.7
13 ###########################################################################
15 # Edit the path below to point to the base of your Zlib sources.
17 ZLIB_PATH = ../../zlib-1.2.7
19 # Edit the path below to point to the base of your OpenSSL package.
21 OPENSSL_PATH = ../../openssl-0.9.8x
23 # Edit the path below to point to the base of your LibSSH2 package.
25 LIBSSH2_PATH = ../../libssh2-1.4.2
27 # Edit the path below to point to the base of your librtmp package.
29 LIBRTMP_PATH = ../../librtmp-2.3
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
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.0
43 # Edit the path below to point to the base of your libidn package.
45 LIBIDN_PATH = ../../libidn-1.18
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
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
60 # Edit the path below to point to the base of your c-ares package.
62 LIBCARES_PATH = $(PROOT)/ares
65 # Edit the var below to set to your architecture or set environment var.
70 CC = $(CROSSPREFIX)gcc
72 CFLAGS += -fno-strict-aliasing
76 # comment LDFLAGS below to keep debug info
79 RC = $(CROSSPREFIX)windres
80 RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i
82 # We may need these someday
86 # Platform-dependent helper tool macros
87 ifeq ($(findstring /sh,$(SHELL)),/sh)
92 #COPYR = -cp -afr $1/* $2
93 COPYR = -rsync -aC $1/* $2
99 ifeq "$(OS)" "Windows_NT"
100 DEL = -del 2>NUL /q /f $(subst /,\,$1)
101 RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
103 DEL = -del 2>NUL $(subst /,\,$1)
104 RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
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) +,,
111 ECHONL = $(ComSpec) /c echo.
114 ########################################################
115 ## Nothing more to do below this line!
117 ifeq ($(findstring -dyn,$(CFG)),-dyn)
120 ifeq ($(findstring -ares,$(CFG)),-ares)
123 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
128 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
133 ifeq ($(findstring -ssl,$(CFG)),-ssl)
136 ifeq ($(findstring -zlib,$(CFG)),-zlib)
139 ifeq ($(findstring -idn,$(CFG)),-idn)
142 ifeq ($(findstring -winidn,$(CFG)),-winidn)
145 ifeq ($(findstring -sspi,$(CFG)),-sspi)
148 ifeq ($(findstring -spnego,$(CFG)),-spnego)
151 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
154 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
157 ifeq ($(findstring -metalink,$(CFG)),-metalink)
160 ifeq ($(findstring -winssl,$(CFG)),-winssl)
165 INCLUDES = -I. -I../include -I../lib
168 curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
169 curl_LDADD = -L$(PROOT)/lib -lcurldll
171 curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
172 curl_LDADD = -L$(PROOT)/lib -lcurl
173 CFLAGS += -DCURL_STATICLIB
178 curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
181 curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
184 CFLAGS += -DUSE_LIBRTMP
185 curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
188 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
189 curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
192 ifndef OPENSSL_INCLUDE
193 ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
194 OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
196 ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
197 OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
200 ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
201 $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
203 ifndef OPENSSL_LIBPATH
204 OPENSSL_LIBS = -lssl -lcrypto
205 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
206 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
208 OPENSSL_LIBS = -lssl32 -leay32
211 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
212 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
216 OPENSSL_LIBS += -lgdi32 -lcrypt32
218 INCLUDES += -I"$(OPENSSL_INCLUDE)"
219 CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL
220 curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
223 INCLUDES += -I"$(ZLIB_PATH)"
224 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
225 curl_LDADD += -L"$(ZLIB_PATH)" -lz
228 CFLAGS += -DUSE_LIBIDN
229 curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
232 CFLAGS += -DUSE_WIN32_IDN
233 curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
237 INCLUDES += -I"$(LIBMETALINK_PATH)/include"
238 CFLAGS += -DUSE_METALINK
239 curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink
241 ifeq ($(findstring libexpat_metalink_parser.o,$(shell $(AR) t "$(LIBMETALINK_PATH)/lib/libmetalink.a")),libexpat_metalink_parser.o)
242 curl_LDADD += -L"$(LIBEXPAT_PATH)/lib" -lexpat
244 curl_LDADD += -L"$(LIBXML2_PATH)/lib" -lxml2
249 CFLAGS += -DUSE_WINDOWS_SSPI
251 CFLAGS += -DUSE_SCHANNEL
255 CFLAGS += -DHAVE_SPNEGO
258 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
261 CFLAGS += -DHAVE_LDAP_SSL
263 ifdef USE_LDAP_NOVELL
264 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
265 curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
267 ifdef USE_LDAP_OPENLDAP
268 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
269 curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
271 ifndef USE_LDAP_NOVELL
272 ifndef USE_LDAP_OPENLDAP
273 curl_LDADD += -lwldap32
276 curl_LDADD += -lws2_32
278 # Makefile.inc provides the CSOURCES and HHEADERS defines
281 curl_PROGRAMS = curl.exe
282 curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
283 curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_ONES))))
285 curl_OBJECTS += $(curlx_OBJECTS)
286 vpath %.c $(PROOT)/lib
292 all: $(curl_PROGRAMS)
294 curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES)
296 $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD)
298 # We don't have nroff normally under win32
299 # tool_hugehelp.c: $(PROOT)/docs/MANUAL $(PROOT)/docs/curl.1 mkhelp.pl
300 # @$(call DEL, tool_hugehelp.c)
301 # $(NROFF) -man $(PROOT)/docs/curl.1 | $(PERL) mkhelp.pl $(PROOT)/docs/MANUAL > tool_hugehelp.c
305 @$(call COPY, $@.cvs, $@)
308 $(CC) $(INCLUDES) $(CFLAGS) -c $<
311 $(RC) $(RCFLAGS) $< -o $@
314 ifeq "$(wildcard tool_hugehelp.c.cvs)" "tool_hugehelp.c.cvs"
315 @$(call DEL, tool_hugehelp.c)
317 @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE))
319 distclean vclean: clean
320 @$(call DEL, $(curl_PROGRAMS))