1 ###########################################################################
3 ## Makefile for building libcurl.a 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-sspi-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 libidn package.
33 LIBIDN_PATH = ../../libidn-1.18
35 # Edit the path below to point to the base of your MS IDN package.
36 # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
37 # http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815
39 WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
41 # Edit the path below to point to the base of your Novell LDAP NDK.
43 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
48 # Edit the path below to point to the base of your c-ares package.
50 LIBCARES_PATH = $(PROOT)/ares
53 # Edit the var below to set to your architecture or set environment var.
60 CFLAGS += -fno-strict-aliasing
64 # comment LDFLAGS below to keep debug info
69 RCFLAGS = --include-dir=$(PROOT)/include -DDEBUGBUILD=0 -O COFF -i
75 ########################################################
76 ## Nothing more to do below this line!
78 ifeq ($(findstring -dyn,$(CFG)),-dyn)
81 ifeq ($(findstring -ares,$(CFG)),-ares)
84 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
89 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
94 ifeq ($(findstring -ssl,$(CFG)),-ssl)
97 ifeq ($(findstring -zlib,$(CFG)),-zlib)
100 ifeq ($(findstring -idn,$(CFG)),-idn)
103 ifeq ($(findstring -winidn,$(CFG)),-winidn)
106 ifeq ($(findstring -sspi,$(CFG)),-sspi)
109 ifeq ($(findstring -spnego,$(CFG)),-spnego)
112 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
115 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
118 ifeq ($(findstring -schannel,$(CFG)),-schannel)
123 INCLUDES = -I. -I../include
124 CFLAGS += -DBUILDING_LIBCURL
127 INCLUDES += -I"$(LIBCARES_PATH)"
129 DLL_LIBS += -L"$(LIBCARES_PATH)" -lcares
130 libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a
133 INCLUDES += -I"$(LIBRTMP_PATH)"
134 CFLAGS += -DUSE_LIBRTMP
135 DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
138 INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
139 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
140 DLL_LIBS += -L"$(LIBSSH2_PATH)/win32" -lssh2
143 ifndef OPENSSL_INCLUDE
144 ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
145 OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
147 ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
148 OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
151 ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
152 $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
154 ifndef OPENSSL_LIBPATH
155 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
156 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
157 OPENSSL_LIBS = -leay32 -lssl32
159 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
160 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
161 OPENSSL_LIBS = -lcrypto -lssl
164 INCLUDES += -I"$(OPENSSL_INCLUDE)"
165 CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \
166 -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 \
167 -DCURL_WANTS_CA_BUNDLE_ENV
168 DLL_LIBS += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
171 INCLUDES += -I"$(ZLIB_PATH)"
172 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
173 DLL_LIBS += -L"$(ZLIB_PATH)" -lz
176 INCLUDES += -I"$(LIBIDN_PATH)/include"
177 CFLAGS += -DUSE_LIBIDN
178 DLL_LIBS += -L"$(LIBIDN_PATH)/lib" -lidn
181 CFLAGS += -DUSE_WIN32_IDN
182 CFLAGS += -DWANT_IDN_PROTOTYPES
183 DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz
187 CFLAGS += -DUSE_WINDOWS_SSPI
189 CFLAGS += -DUSE_SCHANNEL
193 CFLAGS += -DHAVE_SPNEGO
196 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
199 CFLAGS += -DHAVE_LDAP_SSL
201 ifdef USE_LDAP_NOVELL
202 INCLUDES += -I"$(LDAP_SDK)/inc"
203 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
204 DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
206 ifdef USE_LDAP_OPENLDAP
207 INCLUDES += -I"$(LDAP_SDK)/include"
208 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
209 DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
211 ifndef USE_LDAP_NOVELL
212 ifndef USE_LDAP_OPENLDAP
213 DLL_LIBS += -lwldap32
218 # Makefile.inc provides the CSOURCES and HHEADERS defines
221 libcurl_dll_LIBRARY = libcurl.dll
222 libcurl_dll_a_LIBRARY = libcurldll.a
223 libcurl_a_LIBRARY = libcurl.a
225 libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
226 libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
228 RESOURCE = libcurl.res
231 all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
233 $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
235 $(AR) cru $@ $(libcurl_a_OBJECTS)
239 # remove the last line above to keep debug info
241 $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
243 $(CC) $(LDFLAGS) -shared -Wl,--out-implib,$(libcurl_dll_a_LIBRARY) \
244 -o $@ $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
246 %.o: %.c $(PROOT)/include/curl/curlbuild.h
247 $(CC) $(INCLUDES) $(CFLAGS) -c $<
250 $(RC) $(RCFLAGS) $< -o $@
253 ifeq "$(wildcard $(PROOT)/include/curl/curlbuild.h.dist)" "$(PROOT)/include/curl/curlbuild.h.dist"
254 -$(RM) $(subst /,\,$(PROOT)/include/curl/curlbuild.h)
256 -$(RM) $(libcurl_a_OBJECTS) $(RESOURCE)
258 distclean vclean: clean
259 -$(RM) $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_a_LIBRARY)
261 $(LIBCARES_PATH)/libcares.a:
262 $(MAKE) -C $(LIBCARES_PATH) -f Makefile.m32
264 $(PROOT)/include/curl/curlbuild.h:
266 @$(CP) $(subst /,\,$@).dist $(subst /,\,$@)