Makefile.m32 11 KB

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