blob: 2da5294ed54786098d1ea788ad2daaf2429d2658 [file] [log] [blame]
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -07001#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
Lucas Eckels9bd90e62012-08-06 15:07:02 -07007#
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -07008# Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
9#
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 http://curl.haxx.se/docs/copyright.html.
13#
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.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21###########################################################################
22#
23## Makefile for building curl examples with MingW (GCC-3.2 or later)
24## and optionally OpenSSL (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4)
Lucas Eckels9bd90e62012-08-06 15:07:02 -070025##
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070026## Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
27## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-spi-winidn
Lucas Eckels9bd90e62012-08-06 15:07:02 -070028##
29## Hint: you can also set environment vars to control the build, f.e.:
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070030## set ZLIB_PATH=c:/zlib-1.2.8
Lucas Eckels9bd90e62012-08-06 15:07:02 -070031## set ZLIB=1
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070032#
33###########################################################################
Lucas Eckels9bd90e62012-08-06 15:07:02 -070034
35# Edit the path below to point to the base of your Zlib sources.
36ifndef ZLIB_PATH
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070037ZLIB_PATH = ../../../zlib-1.2.8
Lucas Eckels9bd90e62012-08-06 15:07:02 -070038endif
39# Edit the path below to point to the base of your OpenSSL package.
40ifndef OPENSSL_PATH
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070041OPENSSL_PATH = ../../../openssl-1.0.2a
Lucas Eckels9bd90e62012-08-06 15:07:02 -070042endif
43# Edit the path below to point to the base of your LibSSH2 package.
44ifndef LIBSSH2_PATH
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070045LIBSSH2_PATH = ../../../libssh2-1.5.0
46endif
47# Edit the path below to point to the base of your librtmp package.
48ifndef LIBRTMP_PATH
49LIBRTMP_PATH = ../../../librtmp-2.4
50endif
51# Edit the path below to point to the base of your libidn package.
52ifndef LIBIDN_PATH
53LIBIDN_PATH = ../../../libidn-1.30
54endif
55# Edit the path below to point to the base of your MS IDN package.
56# Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
57# https://www.microsoft.com/en-us/download/details.aspx?id=734
58ifndef WINIDN_PATH
59WINIDN_PATH = ../../../Microsoft IDN Mitigation APIs
Lucas Eckels9bd90e62012-08-06 15:07:02 -070060endif
61# Edit the path below to point to the base of your Novell LDAP NDK.
62ifndef LDAP_SDK
63LDAP_SDK = c:/novell/ndk/cldapsdk/win32
64endif
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070065# Edit the path below to point to the base of your nghttp2 package.
66ifndef NGHTTP2_PATH
67NGHTTP2_PATH = ../../../nghttp2-1.0.0
68endif
Lucas Eckels9bd90e62012-08-06 15:07:02 -070069
70PROOT = ../..
Lucas Eckels9bd90e62012-08-06 15:07:02 -070071
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070072# Edit the path below to point to the base of your c-ares package.
73ifndef LIBCARES_PATH
74LIBCARES_PATH = $(PROOT)/ares
75endif
Lucas Eckels9bd90e62012-08-06 15:07:02 -070076
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070077# Edit the var below to set to your architecture or set environment var.
78ifndef ARCH
79ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
80ARCH = w64
81else
82ARCH = w32
83endif
84endif
85
86CC = $(CROSSPREFIX)gcc
87CFLAGS = -g -O2 -Wall
88CFLAGS += -fno-strict-aliasing
89ifeq ($(ARCH),w64)
90CFLAGS += -m64 -D_AMD64_
91LDFLAGS += -m64
92RCFLAGS += -F pe-x86-64
93else
94CFLAGS += -m32
95LDFLAGS += -m32
96RCFLAGS += -F pe-i386
97endif
Lucas Eckels9bd90e62012-08-06 15:07:02 -070098# comment LDFLAGS below to keep debug info
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -070099LDFLAGS = -s
100RC = $(CROSSPREFIX)windres
101RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i
102
103# Platform-dependent helper tool macros
104ifeq ($(findstring /sh,$(SHELL)),/sh)
105DEL = rm -f $1
106RMDIR = rm -fr $1
107MKDIR = mkdir -p $1
108COPY = -cp -afv $1 $2
109#COPYR = -cp -afr $1/* $2
110COPYR = -rsync -aC $1/* $2
111TOUCH = touch $1
112CAT = cat
113ECHONL = echo ""
114DL = '
115else
116ifeq "$(OS)" "Windows_NT"
117DEL = -del 2>NUL /q /f $(subst /,\,$1)
118RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
119else
120DEL = -del 2>NUL $(subst /,\,$1)
121RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
122endif
123MKDIR = -md 2>NUL $(subst /,\,$1)
124COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
125COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
126TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
127CAT = type
128ECHONL = $(ComSpec) /c echo.
129endif
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700130
131########################################################
132## Nothing more to do below this line!
133
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700134ifeq ($(findstring -dyn,$(CFG)),-dyn)
135DYN = 1
136endif
137ifeq ($(findstring -ares,$(CFG)),-ares)
138ARES = 1
139endif
140ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
141RTMP = 1
142SSL = 1
143ZLIB = 1
144endif
145ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
146SSH2 = 1
147SSL = 1
148ZLIB = 1
149endif
150ifeq ($(findstring -ssl,$(CFG)),-ssl)
151SSL = 1
152endif
153ifeq ($(findstring -zlib,$(CFG)),-zlib)
154ZLIB = 1
155endif
156ifeq ($(findstring -idn,$(CFG)),-idn)
157IDN = 1
158endif
159ifeq ($(findstring -winidn,$(CFG)),-winidn)
160WINIDN = 1
161endif
162ifeq ($(findstring -sspi,$(CFG)),-sspi)
163SSPI = 1
164endif
165ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
166LDAPS = 1
167endif
168ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
169IPV6 = 1
170endif
171ifeq ($(findstring -metalink,$(CFG)),-metalink)
172METALINK = 1
173endif
174ifeq ($(findstring -winssl,$(CFG)),-winssl)
175WINSSL = 1
176SSPI = 1
177endif
178ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
179NGHTTP2 = 1
180endif
181
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700182INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700183
184ifdef DYN
185 curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
186 curl_LDADD = -L$(PROOT)/lib -lcurldll
187else
188 curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
189 curl_LDADD = -L$(PROOT)/lib -lcurl
190 CFLAGS += -DCURL_STATICLIB
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700191 LDFLAGS += -static
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700192endif
193ifdef ARES
194 ifndef DYN
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700195 curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700196 endif
197 CFLAGS += -DUSE_ARES
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700198 curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
199endif
200ifdef RTMP
201 CFLAGS += -DUSE_LIBRTMP
202 curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
203endif
204ifdef NGHTTP2
205 CFLAGS += -DUSE_NGHTTP2
206 curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700207endif
208ifdef SSH2
209 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700210 curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700211endif
212ifdef SSL
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700213 ifndef OPENSSL_LIBPATH
214 OPENSSL_LIBS = -lssl -lcrypto
215 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
216 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
217 ifdef DYN
218 OPENSSL_LIBS = -lssl32 -leay32
219 endif
220 endif
221 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
222 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
223 endif
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700224 endif
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700225 ifndef DYN
226 OPENSSL_LIBS += -lgdi32 -lcrypt32
227 endif
228 CFLAGS += -DUSE_OPENSSL
229 curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700230endif
231ifdef ZLIB
232 INCLUDES += -I"$(ZLIB_PATH)"
233 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700234 curl_LDADD += -L"$(ZLIB_PATH)" -lz
235endif
236ifdef IDN
237 CFLAGS += -DUSE_LIBIDN
238 curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
239else
240ifdef WINIDN
241 CFLAGS += -DUSE_WIN32_IDN
242 curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
243endif
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700244endif
245ifdef SSPI
246 CFLAGS += -DUSE_WINDOWS_SSPI
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700247 ifdef WINSSL
248 CFLAGS += -DUSE_SCHANNEL
249 endif
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700250endif
251ifdef IPV6
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700252 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700253endif
254ifdef LDAPS
255 CFLAGS += -DHAVE_LDAP_SSL
256endif
257ifdef USE_LDAP_NOVELL
258 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
259 curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
260endif
261ifdef USE_LDAP_OPENLDAP
262 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
263 curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
264endif
265ifndef USE_LDAP_NOVELL
266ifndef USE_LDAP_OPENLDAP
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700267 curl_LDADD += -lwldap32
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700268endif
269endif
270curl_LDADD += -lws2_32
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700271
272# Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines
273include Makefile.inc
274
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700275check_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
276check_PROGRAMS += ftpuploadresume.exe synctime.exe
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700277
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700278.PRECIOUS: %.o
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700279
280
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700281all: $(check_PROGRAMS)
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700282
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700283%.exe: %.o $(curl_DEPENDENCIES)
284 $(CC) $(LDFLAGS) -o $@ $< $(curl_LDADD)
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700285
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700286%.o: %.c
287 $(CC) $(INCLUDES) $(CFLAGS) -c $<
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700288
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700289%.res: %.rc
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700290 $(RC) $(RCFLAGS) $< -o $@
291
292clean:
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700293 @$(call DEL, $(check_PROGRAMS:.exe=.o))
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700294
Bertrand SIMONNETe6cd7382015-07-01 15:39:44 -0700295distclean vclean: clean
296 @$(call DEL, $(check_PROGRAMS))
Lucas Eckels9bd90e62012-08-06 15:07:02 -0700297