Makefile.m32 11 KB

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