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.0.3
35 # Edit the path below to point to the base of your libidn package.
37 LIBIDN_PATH = ../../libidn-1.18
39 # Edit the path below to point to the base of your MS IDN package.
40 # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
41 # http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815
43 WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
45 # Edit the path below to point to the base of your Novell LDAP NDK.
47 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
52 # Edit the path below to point to the base of your c-ares package.
54 LIBCARES_PATH = $(PROOT)/ares
57 # Edit the var below to set to your architecture or set environment var.
62 CC = $(CROSSPREFIX)gcc
64 CFLAGS += -fno-strict-aliasing
68 # comment LDFLAGS below to keep debug info
70 RC = $(CROSSPREFIX)windres
71 RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i
73 # We may need these someday
77 # Platform-dependent helper tool macros
78 ifeq ($(findstring /sh,$(SHELL)),/sh)
83 #COPYR = -cp -afr $1/* $2
84 COPYR = -rsync -aC $1/* $2
90 ifeq "$(OS)" "Windows_NT"
91 DEL = -del 2>NUL /q /f $(subst /,\,$1)
92 RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
94 DEL = -del 2>NUL $(subst /,\,$1)
95 RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
97 MKDIR = -md 2>NUL $(subst /,\,$1)
98 COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
99 COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
100 TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
102 ECHONL = $(ComSpec) /c echo.
105 ########################################################
106 ## Nothing more to do below this line!
108 ifeq ($(findstring -dyn,$(CFG)),-dyn)
111 ifeq ($(findstring -ares,$(CFG)),-ares)
114 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
119 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
124 ifeq ($(findstring -ssl,$(CFG)),-ssl)
127 ifeq ($(findstring -zlib,$(CFG)),-zlib)
130 ifeq ($(findstring -idn,$(CFG)),-idn)
133 ifeq ($(findstring -winidn,$(CFG)),-winidn)
136 ifeq ($(findstring -sspi,$(CFG)),-sspi)
139 ifeq ($(findstring -spnego,$(CFG)),-spnego)
142 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
145 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
148 ifeq ($(findstring -metalink,$(CFG)),-metalink)
151 ifeq ($(findstring -winssl,$(CFG)),-winssl)
156 INCLUDES = -I. -I../include -I../lib
159 curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
160 curl_LDADD = -L$(PROOT)/lib -lcurldll
162 curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
163 curl_LDADD = -L$(PROOT)/lib -lcurl
164 CFLAGS += -DCURL_STATICLIB
169 curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
172 curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
175 CFLAGS += -DUSE_LIBRTMP
176 curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
179 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
180 curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
183 ifndef OPENSSL_LIBPATH
184 OPENSSL_LIBS = -lssl -lcrypto
185 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
186 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
188 OPENSSL_LIBS = -lssl32 -leay32
191 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
192 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
196 OPENSSL_LIBS += -lgdi32 -lcrypt32
198 CFLAGS += -DUSE_SSLEAY
199 curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
202 INCLUDES += -I"$(ZLIB_PATH)"
203 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
204 curl_LDADD += -L"$(ZLIB_PATH)" -lz
207 CFLAGS += -DUSE_LIBIDN
208 curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
211 CFLAGS += -DUSE_WIN32_IDN
212 curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
216 INCLUDES += -I"$(LIBMETALINK_PATH)/include"
217 CFLAGS += -DUSE_METALINK
218 curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink
221 CFLAGS += -DUSE_WINDOWS_SSPI
223 CFLAGS += -DUSE_SCHANNEL
227 CFLAGS += -DHAVE_SPNEGO
230 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
233 CFLAGS += -DHAVE_LDAP_SSL
235 ifdef USE_LDAP_NOVELL
236 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
237 curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
239 ifdef USE_LDAP_OPENLDAP
240 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
241 curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
243 ifndef USE_LDAP_NOVELL
244 ifndef USE_LDAP_OPENLDAP
245 curl_LDADD += -lwldap32
248 curl_LDADD += -lws2_32
250 # Makefile.inc provides the CSOURCES and HHEADERS defines
253 curl_PROGRAMS = curl.exe
254 curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
255 curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_ONES))))
257 curl_OBJECTS += $(curlx_OBJECTS)
258 vpath %.c $(PROOT)/lib
264 all: $(curl_PROGRAMS)
266 curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES)
268 $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD)
270 # We don't have nroff normally under win32
271 # hugehelp.c: $(PROOT)/README.curl $(PROOT)/curl.1 mkhelp.pl
273 # $(NROFF) -man $(PROOT)/curl.1 | $(PERL) mkhelp.pl $(PROOT)/README.curl > hugehelp.c
277 @$(call COPY, $@.cvs, $@)
280 $(CC) $(INCLUDES) $(CFLAGS) -c $<
283 $(RC) $(RCFLAGS) $< -o $@
286 ifeq "$(wildcard hugehelp.c.cvs)" "hugehelp.c.cvs"
287 @$(call DEL, hugehelp.c)
289 @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE))
291 distclean vclean: clean
292 @$(call DEL, $(curl_PROGRAMS))