1: #***************************************************************************
2: # _ _ ____ _
3: # Project ___| | | | _ \| |
4: # / __| | | | |_) | |
5: # | (__| |_| | _ <| |___
6: # \___|\___/|_| \_\_____|
7: #
8: # Copyright (C) 1999 - 2020, 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 https://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: ###########################################################################
24: #
25: ## Makefile for building curl.exe 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),
27: ## brotli (1.0.1)
28: ##
29: ## Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
30: ## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-sspi-winidn
31: ##
32: ## Hint: you can also set environment vars to control the build, f.e.:
33: ## set ZLIB_PATH=c:/zlib-1.2.8
34: ## set ZLIB=1
35: #
36: ###########################################################################
37:
38: # Edit the path below to point to the base of your Zlib sources.
39: ifndef ZLIB_PATH
40: ZLIB_PATH = ../../zlib-1.2.8
41: endif
42: # Edit the path below to point to the base of your Brotli sources.
43: ifndef BROTLI_PATH
44: BROTLI_PATH = ../../brotli-1.0.1
45: endif
46: # Edit the path below to point to the base of your OpenSSL package.
47: ifndef OPENSSL_PATH
48: OPENSSL_PATH = ../../openssl-1.0.2a
49: endif
50: # Edit the path below to point to the base of your LibSSH2 package.
51: ifndef LIBSSH2_PATH
52: LIBSSH2_PATH = ../../libssh2-1.5.0
53: endif
54: # Edit the path below to point to the base of your librtmp package.
55: ifndef LIBRTMP_PATH
56: LIBRTMP_PATH = ../../librtmp-2.4
57: endif
58: # Edit the path below to point to the base of your libmetalink package.
59: ifndef LIBMETALINK_PATH
60: LIBMETALINK_PATH = ../../libmetalink-0.1.3
61: endif
62: # Edit the path below to point to the base of your libexpat package.
63: ifndef LIBEXPAT_PATH
64: LIBEXPAT_PATH = ../../expat-2.1.0
65: endif
66: # Edit the path below to point to the base of your libxml2 package.
67: ifndef LIBXML2_PATH
68: LIBXML2_PATH = ../../libxml2-2.9.2
69: endif
70: # Edit the path below to point to the base of your libidn2 package.
71: ifndef LIBIDN2_PATH
72: LIBIDN2_PATH = ../../libidn2-2.0.3
73: endif
74: # Edit the path below to point to the base of your MS IDN package.
75: # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
76: # https://www.microsoft.com/en-us/download/details.aspx?id=734
77: ifndef WINIDN_PATH
78: WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
79: endif
80: # Edit the path below to point to the base of your Novell LDAP NDK.
81: ifndef LDAP_SDK
82: LDAP_SDK = c:/novell/ndk/cldapsdk/win32
83: endif
84: # Edit the path below to point to the base of your nghttp2 package.
85: ifndef NGHTTP2_PATH
86: NGHTTP2_PATH = ../../nghttp2-1.0.0
87: endif
88:
89: PROOT = ..
90:
91: # Edit the path below to point to the base of your c-ares package.
92: ifndef LIBCARES_PATH
93: LIBCARES_PATH = $(PROOT)/ares
94: endif
95:
96: ifeq ($(CURL_CC),)
97: CURL_CC := $(CROSSPREFIX)gcc
98: endif
99: ifeq ($(CURL_AR),)
100: CURL_AR := $(CROSSPREFIX)ar
101: endif
102:
103: CC = $(CURL_CC)
104: CFLAGS = $(CURL_CFLAG_EXTRAS) -g -O2 -Wall -W
105: CFLAGS += -fno-strict-aliasing
106: # comment LDFLAGS below to keep debug info
107: LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_EXE) -s
108: AR = $(CURL_AR)
109: RC = $(CROSSPREFIX)windres
110: RCFLAGS = --include-dir=$(PROOT)/include -O coff -DCURL_EMBED_MANIFEST
111: STRIP = $(CROSSPREFIX)strip -g
112:
113: # We may need these someday
114: # PERL = perl
115: # NROFF = nroff
116:
117: # Set environment var ARCH to your architecture to override autodetection.
118: ifndef ARCH
119: ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
120: ARCH = w64
121: else
122: ARCH = w32
123: endif
124: endif
125:
126: ifeq ($(ARCH),w64)
127: CFLAGS += -m64 -D_AMD64_
128: LDFLAGS += -m64
129: RCFLAGS += -F pe-x86-64
130: else
131: CFLAGS += -m32
132: LDFLAGS += -m32
133: RCFLAGS += -F pe-i386
134: endif
135:
136: # Platform-dependent helper tool macros
137: ifeq ($(findstring /sh,$(SHELL)),/sh)
138: DEL = rm -f $1
139: RMDIR = rm -fr $1
140: MKDIR = mkdir -p $1
141: COPY = -cp -afv $1 $2
142: #COPYR = -cp -afr $1/* $2
143: COPYR = -rsync -aC $1/* $2
144: TOUCH = touch $1
145: CAT = cat
146: ECHONL = echo ""
147: DL = '
148: else
149: ifeq "$(OS)" "Windows_NT"
150: DEL = -del 2>NUL /q /f $(subst /,\,$1)
151: RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
152: else
153: DEL = -del 2>NUL $(subst /,\,$1)
154: RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
155: endif
156: MKDIR = -md 2>NUL $(subst /,\,$1)
157: COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
158: COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
159: TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
160: CAT = type
161: ECHONL = $(ComSpec) /c echo.
162: endif
163:
164: ########################################################
165: ## Nothing more to do below this line!
166:
167: ifeq ($(findstring -dyn,$(CFG)),-dyn)
168: DYN = 1
169: endif
170: ifeq ($(findstring -ares,$(CFG)),-ares)
171: ARES = 1
172: endif
173: ifeq ($(findstring -sync,$(CFG)),-sync)
174: SYNC = 1
175: endif
176: ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
177: RTMP = 1
178: SSL = 1
179: ZLIB = 1
180: endif
181: ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
182: SSH2 = 1
183: SSL = 1
184: ZLIB = 1
185: endif
186: ifeq ($(findstring -ssl,$(CFG)),-ssl)
187: SSL = 1
188: endif
189: ifeq ($(findstring -zlib,$(CFG)),-zlib)
190: ZLIB = 1
191: endif
192: ifeq ($(findstring -brotli,$(CFG)),-brotli)
193: BROTLI = 1
194: endif
195: ifeq ($(findstring -idn2,$(CFG)),-idn2)
196: IDN2 = 1
197: endif
198: ifeq ($(findstring -winidn,$(CFG)),-winidn)
199: WINIDN = 1
200: endif
201: ifeq ($(findstring -sspi,$(CFG)),-sspi)
202: SSPI = 1
203: endif
204: ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
205: LDAPS = 1
206: endif
207: ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
208: IPV6 = 1
209: endif
210: ifeq ($(findstring -metalink,$(CFG)),-metalink)
211: METALINK = 1
212: endif
213: ifeq ($(findstring -winssl,$(CFG)),-winssl)
214: WINSSL = 1
215: SSPI = 1
216: endif
217: ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
218: NGHTTP2 = 1
219: endif
220:
221: INCLUDES = -I. -I../include -I../lib
222: ifdef SSL
223: ifdef WINSSL
224: CFLAGS += -DCURL_WITH_MULTI_SSL
225: endif
226: endif
227:
228: ifdef DYN
229: curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
230: curl_LDADD = -L$(PROOT)/lib -lcurldll
231: else
232: curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
233: curl_LDADD = -L$(PROOT)/lib -lcurl
234: CFLAGS += -DCURL_STATICLIB
235: LDFLAGS += -static
236: endif
237: ifdef SYNC
238: CFLAGS += -DUSE_SYNC_DNS
239: else
240: ifdef ARES
241: ifndef DYN
242: curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
243: endif
244: CFLAGS += -DUSE_ARES -DCARES_STATICLIB
245: curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
246: endif
247: endif
248: ifdef RTMP
249: CFLAGS += -DUSE_LIBRTMP
250: curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
251: endif
252: ifdef NGHTTP2
253: CFLAGS += -DUSE_NGHTTP2
254: curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
255: endif
256: ifdef SSH2
257: CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
258: curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
259: ifdef WINSSL
260: ifndef DYN
261: curl_LDADD += -lbcrypt -lcrypt32
262: endif
263: endif
264: endif
265: ifdef SSL
266: ifndef OPENSSL_INCLUDE
267: ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
268: OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
269: endif
270: ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
271: OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
272: endif
273: endif
274: ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
275: $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
276: endif
277: ifndef OPENSSL_LIBPATH
278: OPENSSL_LIBS = -lssl -lcrypto
279: ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
280: OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
281: ifdef DYN
282: OPENSSL_LIBS = -lssl32 -leay32
283: endif
284: endif
285: ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
286: OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
287: endif
288: endif
289: ifndef DYN
290: OPENSSL_LIBS += -lgdi32 -lcrypt32
291: endif
292: INCLUDES += -I"$(OPENSSL_INCLUDE)"
293: CFLAGS += -DUSE_OPENSSL
294: curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
295: endif
296: ifdef WINSSL
297: CFLAGS += -DUSE_SCHANNEL
298: curl_LDADD += -lcrypt32
299: endif
300: ifdef ZLIB
301: INCLUDES += -I"$(ZLIB_PATH)"
302: CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
303: curl_LDADD += -L"$(ZLIB_PATH)" -lz
304: endif
305: ifdef BROTLI
306: INCLUDES += -I"$(BROTLI_PATH)/include"
307: CFLAGS += -DHAVE_BROTLI
308: curl_LDADD += -L"$(BROTLI_PATH)/lib"
309: ifdef BROTLI_LIBS
310: curl_LDADD += $(BROTLI_LIBS)
311: else
312: curl_LDADD += -lbrotlidec
313: endif
314: endif
315: ifdef IDN2
316: CFLAGS += -DUSE_LIBIDN2
317: curl_LDADD += -L"$(LIBIDN2_PATH)/lib" -lidn2
318: else
319: ifdef WINIDN
320: CFLAGS += -DUSE_WIN32_IDN
321: curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
322: endif
323: endif
324: ifdef METALINK
325: INCLUDES += -I"$(LIBMETALINK_PATH)/include"
326: CFLAGS += -DUSE_METALINK
327: curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink
328: ifndef DYN
329: ifeq ($(findstring libexpat_metalink_parser.o,$(shell $(AR) t "$(LIBMETALINK_PATH)/lib/libmetalink.a")),libexpat_metalink_parser.o)
330: curl_LDADD += -L"$(LIBEXPAT_PATH)/lib" -lexpat
331: else
332: curl_LDADD += -L"$(LIBXML2_PATH)/lib" -lxml2
333: endif
334: endif
335: endif
336: ifdef SSPI
337: CFLAGS += -DUSE_WINDOWS_SSPI
338: endif
339: ifdef IPV6
340: CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
341: endif
342: ifdef LDAPS
343: CFLAGS += -DHAVE_LDAP_SSL
344: endif
345: ifdef USE_LDAP_NOVELL
346: CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
347: curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
348: endif
349: ifdef USE_LDAP_OPENLDAP
350: CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
351: curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
352: endif
353: ifndef USE_LDAP_NOVELL
354: ifndef USE_LDAP_OPENLDAP
355: curl_LDADD += -lwldap32
356: endif
357: endif
358: curl_LDADD += -lws2_32
359:
360: # Makefile.inc provides the CSOURCES and HHEADERS defines
361: include Makefile.inc
362:
363: curl_PROGRAMS = curl.exe
364: curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
365: curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES))))
366: ifdef DYN
367: curl_OBJECTS += $(curlx_OBJECTS)
368: vpath %.c $(PROOT)/lib
369: endif
370:
371: RESOURCE = curl.res
372:
373:
374: all: $(curl_PROGRAMS)
375:
376: curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES)
377: $(call DEL, $@)
378: $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD)
379:
380: # We don't have nroff normally under win32
381: # tool_hugehelp.c: $(PROOT)/docs/MANUAL $(PROOT)/docs/curl.1 mkhelp.pl
382: # @$(call DEL, tool_hugehelp.c)
383: # $(NROFF) -man $(PROOT)/docs/curl.1 | $(PERL) mkhelp.pl $(PROOT)/docs/MANUAL > tool_hugehelp.c
384:
385: tool_hugehelp.c:
386: @echo Creating $@
387: @$(call COPY, $@.cvs, $@)
388:
389: %.o: %.c
390: $(CC) $(INCLUDES) $(CFLAGS) -c $<
391:
392: %.res: %.rc
393: $(RC) $(RCFLAGS) -i $< -o $@
394:
395: clean:
396: ifeq "$(wildcard tool_hugehelp.c.cvs)" "tool_hugehelp.c.cvs"
397: @$(call DEL, tool_hugehelp.c)
398: endif
399: @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE))
400:
401: distclean vclean: clean
402: @$(call DEL, $(curl_PROGRAMS))
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>