1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1999 - 2015, 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 libcurl.a with MingW (GCC-3.2 or later)
26 ## and optionally OpenSSL (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4)
28 ## Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
29 ## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
31 ## Hint: you can also set environment vars to control the build, f.e.:
32 ## set ZLIB_PATH=c:/zlib-1.2.8
35 ###########################################################################
37 # Edit the path below to point to the base of your Zlib sources.
39 ZLIB_PATH = ../../zlib-1.2.8
41 # Edit the path below to point to the base of your OpenSSL package.
43 OPENSSL_PATH = ../../openssl-1.0.2a
45 # Edit the path below to point to the base of your LibSSH2 package.
47 LIBSSH2_PATH = ../../libssh2-1.5.0
49 # Edit the path below to point to the base of your librtmp package.
51 LIBRTMP_PATH = ../../librtmp-2.4
53 # Edit the path below to point to the base of your libidn package.
55 LIBIDN_PATH = ../../libidn-1.32
57 # Edit the path below to point to the base of your MS IDN package.
58 # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
59 # https://www.microsoft.com/en-us/download/details.aspx?id=734
61 WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
63 # Edit the path below to point to the base of your Novell LDAP NDK.
65 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
67 # Edit the path below to point to the base of your nghttp2 package.
69 NGHTTP2_PATH = ../../nghttp2-1.0.0
74 # Edit the path below to point to the base of your c-ares package.
76 LIBCARES_PATH = $(PROOT)/ares
79 CC = $(CROSSPREFIX)gcc
80 CFLAGS = $(CURL_CFLAG_EXTRAS) -g -O2 -Wall
81 CFLAGS += -fno-strict-aliasing
82 # comment LDFLAGS below to keep debug info
83 LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_DLL) -s
85 RANLIB = $(CROSSPREFIX)ranlib
86 RC = $(CROSSPREFIX)windres
87 RCFLAGS = --include-dir=$(PROOT)/include -DDEBUGBUILD=0 -O COFF
88 STRIP = $(CROSSPREFIX)strip -g
90 # Set environment var ARCH to your architecture to override autodetection.
92 ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
100 CFLAGS += -m64 -D_AMD64_
102 RCFLAGS += -F pe-x86-64
106 RCFLAGS += -F pe-i386
109 # Platform-dependent helper tool macros
110 ifeq ($(findstring /sh,$(SHELL)),/sh)
114 COPY = -cp -afv $1 $2
115 #COPYR = -cp -afr $1/* $2
116 COPYR = -rsync -aC $1/* $2
122 ifeq "$(OS)" "Windows_NT"
123 DEL = -del 2>NUL /q /f $(subst /,\,$1)
124 RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
126 DEL = -del 2>NUL $(subst /,\,$1)
127 RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
129 MKDIR = -md 2>NUL $(subst /,\,$1)
130 COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
131 COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
132 TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
134 ECHONL = $(ComSpec) /c echo.
137 ########################################################
138 ## Nothing more to do below this line!
140 ifeq ($(findstring -dyn,$(CFG)),-dyn)
143 ifeq ($(findstring -ares,$(CFG)),-ares)
146 ifeq ($(findstring -sync,$(CFG)),-sync)
149 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
154 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
156 ifneq ($(findstring -winssl,$(CFG)),-winssl)
161 ifeq ($(findstring -ssl,$(CFG)),-ssl)
164 ifeq ($(findstring -srp,$(CFG)),-srp)
167 ifeq ($(findstring -zlib,$(CFG)),-zlib)
170 ifeq ($(findstring -idn,$(CFG)),-idn)
173 ifeq ($(findstring -winidn,$(CFG)),-winidn)
176 ifeq ($(findstring -sspi,$(CFG)),-sspi)
179 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
182 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
185 ifeq ($(findstring -winssl,$(CFG)),-winssl)
189 ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
193 INCLUDES = -I. -I../include
194 CFLAGS += -DBUILDING_LIBCURL
197 CFLAGS += -DUSE_SYNC_DNS
200 INCLUDES += -I"$(LIBCARES_PATH)"
201 CFLAGS += -DUSE_ARES -DCARES_STATICLIB
202 DLL_LIBS += -L"$(LIBCARES_PATH)" -lcares
203 libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a
207 INCLUDES += -I"$(LIBRTMP_PATH)"
208 CFLAGS += -DUSE_LIBRTMP
209 DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
212 INCLUDES += -I"$(NGHTTP2_PATH)/include"
213 CFLAGS += -DUSE_NGHTTP2
214 DLL_LIBS += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
217 INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
218 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
219 DLL_LIBS += -L"$(LIBSSH2_PATH)/win32" -lssh2
222 DLL_LIBS += -lbcrypt -lcrypt32
227 ifndef OPENSSL_INCLUDE
228 ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
229 OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
231 ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
232 OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
235 ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
236 $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
238 ifndef OPENSSL_LIBPATH
239 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
240 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
241 OPENSSL_LIBS = -leay32 -lssl32
243 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
244 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
245 OPENSSL_LIBS = -lcrypto -lssl
249 OPENSSL_LIBS += -lgdi32 -lcrypt32
251 INCLUDES += -I"$(OPENSSL_INCLUDE)"
252 CFLAGS += -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \
253 -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 \
254 -DCURL_WANTS_CA_BUNDLE_ENV
255 DLL_LIBS += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
257 ifeq "$(wildcard $(OPENSSL_INCLUDE)/openssl/srp.h)" "$(OPENSSL_INCLUDE)/openssl/srp.h"
258 CFLAGS += -DHAVE_OPENSSL_SRP -DUSE_TLS_SRP
263 INCLUDES += -I"$(ZLIB_PATH)"
264 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
265 DLL_LIBS += -L"$(ZLIB_PATH)" -lz
268 INCLUDES += -I"$(LIBIDN_PATH)/include"
269 CFLAGS += -DUSE_LIBIDN
270 DLL_LIBS += -L"$(LIBIDN_PATH)/lib" -lidn
273 CFLAGS += -DUSE_WIN32_IDN
274 CFLAGS += -DWANT_IDN_PROTOTYPES
275 DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz
279 CFLAGS += -DUSE_WINDOWS_SSPI
281 CFLAGS += -DUSE_SCHANNEL
285 CFLAGS += -DHAVE_SPNEGO
288 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
291 CFLAGS += -DHAVE_LDAP_SSL
293 ifdef USE_LDAP_NOVELL
294 INCLUDES += -I"$(LDAP_SDK)/inc"
295 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
296 DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
298 ifdef USE_LDAP_OPENLDAP
299 INCLUDES += -I"$(LDAP_SDK)/include"
300 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
301 DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
303 ifndef USE_LDAP_NOVELL
304 ifndef USE_LDAP_OPENLDAP
305 DLL_LIBS += -lwldap32
310 # Makefile.inc provides the CSOURCES and HHEADERS defines
313 libcurl_dll_LIBRARY = libcurl.dll
314 libcurl_dll_a_LIBRARY = libcurldll.a
315 libcurl_a_LIBRARY = libcurl.a
317 libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
318 libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
320 RESOURCE = libcurl.res
323 all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
325 $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
327 $(AR) cru $@ $(libcurl_a_OBJECTS)
331 # remove the last line above to keep debug info
333 $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
335 $(CC) $(LDFLAGS) -shared -o $@ \
336 -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY) \
337 $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
339 %.o: %.c $(PROOT)/include/curl/curlbuild.h
340 $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
343 $(RC) $(RCFLAGS) -i $< -o $@
346 ifeq "$(wildcard $(PROOT)/include/curl/curlbuild.h.dist)" "$(PROOT)/include/curl/curlbuild.h.dist"
347 @$(call DEL, $(PROOT)/include/curl/curlbuild.h)
349 @$(call DEL, $(libcurl_a_OBJECTS) $(RESOURCE))
351 distclean vclean: clean
352 @$(call DEL, $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY))
354 $(PROOT)/include/curl/curlbuild.h:
356 @$(call COPY, $@.dist, $@)
358 $(LIBCARES_PATH)/libcares.a:
359 $(MAKE) -C $(LIBCARES_PATH) -f Makefile.m32