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 curl.exe 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 libmetalink package.
54 ifndef LIBMETALINK_PATH
55 LIBMETALINK_PATH = ../../libmetalink-0.1.3
57 # Edit the path below to point to the base of your libexpat package.
59 LIBEXPAT_PATH = ../../expat-2.1.0
61 # Edit the path below to point to the base of your libxml2 package.
63 LIBXML2_PATH = ../../libxml2-2.9.2
65 # Edit the path below to point to the base of your libidn package.
67 LIBIDN_PATH = ../../libidn-1.32
69 # Edit the path below to point to the base of your MS IDN package.
70 # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
71 # https://www.microsoft.com/en-us/download/details.aspx?id=734
73 WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
75 # Edit the path below to point to the base of your Novell LDAP NDK.
77 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
79 # Edit the path below to point to the base of your nghttp2 package.
81 NGHTTP2_PATH = ../../nghttp2-1.0.0
86 # Edit the path below to point to the base of your c-ares package.
88 LIBCARES_PATH = $(PROOT)/ares
91 CC = $(CROSSPREFIX)gcc
92 CFLAGS = $(CURL_CFLAG_EXTRAS) -g -O2 -Wall
93 CFLAGS += -fno-strict-aliasing
94 # comment LDFLAGS below to keep debug info
95 LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_EXE) -s
97 RC = $(CROSSPREFIX)windres
98 RCFLAGS = --include-dir=$(PROOT)/include -O COFF
99 STRIP = $(CROSSPREFIX)strip -g
101 # We may need these someday
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)
171 ifneq ($(findstring -winssl,$(CFG)),-winssl)
176 ifeq ($(findstring -ssl,$(CFG)),-ssl)
179 ifeq ($(findstring -zlib,$(CFG)),-zlib)
182 ifeq ($(findstring -idn,$(CFG)),-idn)
185 ifeq ($(findstring -winidn,$(CFG)),-winidn)
188 ifeq ($(findstring -sspi,$(CFG)),-sspi)
191 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
194 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
197 ifeq ($(findstring -metalink,$(CFG)),-metalink)
200 ifeq ($(findstring -winssl,$(CFG)),-winssl)
204 ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
208 INCLUDES = -I. -I../include -I../lib
211 curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
212 curl_LDADD = -L$(PROOT)/lib -lcurldll
214 curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
215 curl_LDADD = -L$(PROOT)/lib -lcurl
216 CFLAGS += -DCURL_STATICLIB
220 CFLAGS += -DUSE_SYNC_DNS
224 curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
226 CFLAGS += -DUSE_ARES -DCARES_STATICLIB
227 curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
231 CFLAGS += -DUSE_LIBRTMP
232 curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
235 CFLAGS += -DUSE_NGHTTP2
236 curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
239 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
240 curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
243 curl_LDADD += -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 OPENSSL_LIBS = -lssl -lcrypto
261 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
262 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
264 OPENSSL_LIBS = -lssl32 -leay32
267 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
268 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
272 OPENSSL_LIBS += -lgdi32 -lcrypt32
274 INCLUDES += -I"$(OPENSSL_INCLUDE)"
275 CFLAGS += -DUSE_OPENSSL
276 curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
279 INCLUDES += -I"$(ZLIB_PATH)"
280 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
281 curl_LDADD += -L"$(ZLIB_PATH)" -lz
284 CFLAGS += -DUSE_LIBIDN
285 curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
288 CFLAGS += -DUSE_WIN32_IDN
289 curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
293 INCLUDES += -I"$(LIBMETALINK_PATH)/include"
294 CFLAGS += -DUSE_METALINK
295 curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink
297 ifeq ($(findstring libexpat_metalink_parser.o,$(shell $(AR) t "$(LIBMETALINK_PATH)/lib/libmetalink.a")),libexpat_metalink_parser.o)
298 curl_LDADD += -L"$(LIBEXPAT_PATH)/lib" -lexpat
300 curl_LDADD += -L"$(LIBXML2_PATH)/lib" -lxml2
305 CFLAGS += -DUSE_WINDOWS_SSPI
307 CFLAGS += -DUSE_SCHANNEL
311 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
314 CFLAGS += -DHAVE_LDAP_SSL
316 ifdef USE_LDAP_NOVELL
317 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
318 curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
320 ifdef USE_LDAP_OPENLDAP
321 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
322 curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
324 ifndef USE_LDAP_NOVELL
325 ifndef USE_LDAP_OPENLDAP
326 curl_LDADD += -lwldap32
329 curl_LDADD += -lws2_32
331 # Makefile.inc provides the CSOURCES and HHEADERS defines
334 curl_PROGRAMS = curl.exe
335 curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
336 curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES))))
338 curl_OBJECTS += $(curlx_OBJECTS)
339 vpath %.c $(PROOT)/lib
345 all: $(curl_PROGRAMS)
347 curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES)
349 $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD)
351 # We don't have nroff normally under win32
352 # tool_hugehelp.c: $(PROOT)/docs/MANUAL $(PROOT)/docs/curl.1 mkhelp.pl
353 # @$(call DEL, tool_hugehelp.c)
354 # $(NROFF) -man $(PROOT)/docs/curl.1 | $(PERL) mkhelp.pl $(PROOT)/docs/MANUAL > tool_hugehelp.c
358 @$(call COPY, $@.cvs, $@)
361 $(CC) $(INCLUDES) $(CFLAGS) -c $<
364 $(RC) $(RCFLAGS) -i $< -o $@
367 ifeq "$(wildcard tool_hugehelp.c.cvs)" "tool_hugehelp.c.cvs"
368 @$(call DEL, tool_hugehelp.c)
370 @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE))
372 distclean vclean: clean
373 @$(call DEL, $(curl_PROGRAMS))