1 #***************************************************************************
3 # Project ___| | | | _ \| |
5 # | (__| |_| | _ <| |___
6 # \___|\___/|_| \_\_____|
8 # Copyright (C) 1999 - 2017, 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 or LLVM/Clang)
26 ## and optionally OpenSSL (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4),
29 ## Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
30 ## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
32 ## Hint: you can also set environment vars to control the build, f.e.:
33 ## set ZLIB_PATH=c:/zlib-1.2.8
36 ###########################################################################
38 # Edit the path below to point to the base of your Zlib sources.
40 ZLIB_PATH = ../../zlib-1.2.8
42 # Edit the path below to point to the base of your Brotli sources.
44 BROTLI_PATH = ../../brotli-1.0.1
46 # Edit the path below to point to the base of your OpenSSL package.
48 OPENSSL_PATH = ../../openssl-1.0.2a
50 # Edit the path below to point to the base of your LibSSH2 package.
52 LIBSSH2_PATH = ../../libssh2-1.5.0
54 # Edit the path below to point to the base of your librtmp package.
56 LIBRTMP_PATH = ../../librtmp-2.4
58 # Edit the path below to point to the base of your libidn2 package.
60 LIBIDN2_PATH = ../../libidn2-2.0.3
62 # Edit the path below to point to the base of your MS IDN package.
63 # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
64 # https://www.microsoft.com/en-us/download/details.aspx?id=734
66 WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
68 # Edit the path below to point to the base of your Novell LDAP NDK.
70 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
72 # Edit the path below to point to the base of your nghttp2 package.
74 NGHTTP2_PATH = ../../nghttp2-1.0.0
79 # Edit the path below to point to the base of your c-ares package.
81 LIBCARES_PATH = $(PROOT)/ares
85 CURL_CC := $(CROSSPREFIX)gcc
88 CURL_AR := $(CROSSPREFIX)ar
90 ifeq ($(CURL_RANLIB),)
91 CURL_RANLIB := $(CROSSPREFIX)ranlib
95 CFLAGS = $(CURL_CFLAG_EXTRAS) -g -O2 -Wall -W
96 CFLAGS += -fno-strict-aliasing
97 # comment LDFLAGS below to keep debug info
98 LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_DLL) -s
100 RANLIB = $(CURL_RANLIB)
101 RC = $(CROSSPREFIX)windres
102 RCFLAGS = --include-dir=$(PROOT)/include -DDEBUGBUILD=0 -O COFF
103 STRIP = $(CROSSPREFIX)strip -g
105 # Set environment var ARCH to your architecture to override autodetection.
107 ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
115 CFLAGS += -m64 -D_AMD64_
117 RCFLAGS += -F pe-x86-64
121 RCFLAGS += -F pe-i386
124 # Platform-dependent helper tool macros
125 ifeq ($(findstring /sh,$(SHELL)),/sh)
129 COPY = -cp -afv $1 $2
130 #COPYR = -cp -afr $1/* $2
131 COPYR = -rsync -aC $1/* $2
137 ifeq "$(OS)" "Windows_NT"
138 DEL = -del 2>NUL /q /f $(subst /,\,$1)
139 RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
141 DEL = -del 2>NUL $(subst /,\,$1)
142 RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
144 MKDIR = -md 2>NUL $(subst /,\,$1)
145 COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
146 COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
147 TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
149 ECHONL = $(ComSpec) /c echo.
152 ########################################################
153 ## Nothing more to do below this line!
155 ifeq ($(findstring -dyn,$(CFG)),-dyn)
158 ifeq ($(findstring -ares,$(CFG)),-ares)
161 ifeq ($(findstring -sync,$(CFG)),-sync)
164 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
169 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
174 ifeq ($(findstring -ssl,$(CFG)),-ssl)
177 ifeq ($(findstring -srp,$(CFG)),-srp)
180 ifeq ($(findstring -zlib,$(CFG)),-zlib)
183 ifeq ($(findstring -brotli,$(CFG)),-brotli)
186 ifeq ($(findstring -idn2,$(CFG)),-idn2)
189 ifeq ($(findstring -winidn,$(CFG)),-winidn)
192 ifeq ($(findstring -sspi,$(CFG)),-sspi)
195 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
198 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
201 ifeq ($(findstring -winssl,$(CFG)),-winssl)
205 ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
209 INCLUDES = -I. -I../include
210 CFLAGS += -DBUILDING_LIBCURL
213 CFLAGS += -DCURL_WITH_MULTI_SSL
218 CFLAGS += -DUSE_SYNC_DNS
221 INCLUDES += -I"$(LIBCARES_PATH)"
222 CFLAGS += -DUSE_ARES -DCARES_STATICLIB
223 DLL_LIBS += -L"$(LIBCARES_PATH)" -lcares
224 libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a
228 INCLUDES += -I"$(LIBRTMP_PATH)"
229 CFLAGS += -DUSE_LIBRTMP
230 DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
233 INCLUDES += -I"$(NGHTTP2_PATH)/include"
234 CFLAGS += -DUSE_NGHTTP2
235 DLL_LIBS += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
238 INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
239 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
240 DLL_LIBS += -L"$(LIBSSH2_PATH)/win32" -lssh2
243 DLL_LIBS += -lbcrypt -lcrypt32
248 ifndef OPENSSL_INCLUDE
249 ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
250 OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
252 ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
253 OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
256 ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
257 $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
259 ifndef OPENSSL_LIBPATH
260 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
261 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
262 OPENSSL_LIBS = -leay32 -lssl32
264 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
265 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
266 OPENSSL_LIBS = -lcrypto -lssl
270 OPENSSL_LIBS += -lgdi32 -lcrypt32
272 INCLUDES += -I"$(OPENSSL_INCLUDE)"
273 CFLAGS += -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \
274 -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5
275 DLL_LIBS += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
277 ifeq "$(wildcard $(OPENSSL_INCLUDE)/openssl/srp.h)" "$(OPENSSL_INCLUDE)/openssl/srp.h"
278 CFLAGS += -DHAVE_OPENSSL_SRP -DUSE_TLS_SRP
283 CFLAGS += -DUSE_SCHANNEL
284 DLL_LIBS += -lcrypt32
287 INCLUDES += -I"$(ZLIB_PATH)"
288 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
289 DLL_LIBS += -L"$(ZLIB_PATH)" -lz
292 INCLUDES += -I"$(BROTLI_PATH)/include"
293 CFLAGS += -DHAVE_BROTLI
294 DLL_LIBS += -L"$(BROTLI_PATH)/lib"
296 DLL_LIBS += $(BROTLI_LIBS)
298 DLL_LIBS += -lbrotlidec
302 INCLUDES += -I"$(LIBIDN2_PATH)/include"
303 CFLAGS += -DUSE_LIBIDN2
304 DLL_LIBS += -L"$(LIBIDN2_PATH)/lib" -lidn2
307 CFLAGS += -DUSE_WIN32_IDN
308 CFLAGS += -DWANT_IDN_PROTOTYPES
309 DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz
313 CFLAGS += -DUSE_WINDOWS_SSPI
316 CFLAGS += -DHAVE_SPNEGO
319 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
322 CFLAGS += -DHAVE_LDAP_SSL
324 ifdef USE_LDAP_NOVELL
325 INCLUDES += -I"$(LDAP_SDK)/inc"
326 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
327 DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
329 ifdef USE_LDAP_OPENLDAP
330 INCLUDES += -I"$(LDAP_SDK)/include"
331 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
332 DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
334 ifndef USE_LDAP_NOVELL
335 ifndef USE_LDAP_OPENLDAP
336 DLL_LIBS += -lwldap32
341 # Makefile.inc provides the CSOURCES and HHEADERS defines
344 ifeq ($(CURL_DLL_A_SUFFIX),)
345 CURL_DLL_A_SUFFIX := dll
348 libcurl_dll_LIBRARY = libcurl$(CURL_DLL_SUFFIX).dll
349 libcurl_dll_a_LIBRARY = libcurl$(CURL_DLL_A_SUFFIX).a
350 libcurl_a_LIBRARY = libcurl.a
352 libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
353 libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
355 RESOURCE = libcurl.res
358 all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
360 $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
362 $(AR) cru $@ $(libcurl_a_OBJECTS)
366 # remove the last line above to keep debug info
368 $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
370 $(CC) $(LDFLAGS) -shared -o $@ \
371 -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY) \
372 $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
375 $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
378 $(RC) $(RCFLAGS) -i $< -o $@
381 @$(call DEL, $(libcurl_a_OBJECTS) $(RESOURCE))
383 distclean vclean: clean
384 @$(call DEL, $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY))
386 $(LIBCARES_PATH)/libcares.a:
387 $(MAKE) -C $(LIBCARES_PATH) -f Makefile.m32