Makefile.m32 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2021, 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. #***************************************************************************
  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 libexpat package.
  61. ifndef LIBEXPAT_PATH
  62. LIBEXPAT_PATH = ../../../expat-2.1.0
  63. endif
  64. # Edit the path below to point to the base of your libxml2 package.
  65. ifndef LIBXML2_PATH
  66. LIBXML2_PATH = ../../../libxml2-2.9.2
  67. endif
  68. # Edit the path below to point to the base of your libgsasl package.
  69. ifndef LIBGSASL_PATH
  70. LIBGSASL_PATH = ../../../libgsasl-1.10.0
  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. ZLIB = 1
  171. endif
  172. ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
  173. SSH2 = 1
  174. ZLIB = 1
  175. endif
  176. ifeq ($(findstring -ssl,$(CFG)),-ssl)
  177. SSL = 1
  178. endif
  179. ifeq ($(findstring -zlib,$(CFG)),-zlib)
  180. ZLIB = 1
  181. endif
  182. ifeq ($(findstring -zstd,$(CFG)),-zstd)
  183. ZSTD = 1
  184. endif
  185. ifeq ($(findstring -brotli,$(CFG)),-brotli)
  186. BROTLI = 1
  187. endif
  188. ifeq ($(findstring -gsasl,$(CFG)),-gsasl)
  189. GSASL = 1
  190. endif
  191. ifeq ($(findstring -idn2,$(CFG)),-idn2)
  192. IDN2 = 1
  193. endif
  194. ifeq ($(findstring -winidn,$(CFG)),-winidn)
  195. WINIDN = 1
  196. endif
  197. ifeq ($(findstring -sspi,$(CFG)),-sspi)
  198. SSPI = 1
  199. endif
  200. ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
  201. LDAPS = 1
  202. endif
  203. ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
  204. IPV6 = 1
  205. endif
  206. ifeq ($(findstring -winssl,$(CFG)),-winssl)
  207. WINSSL = 1
  208. SSPI = 1
  209. endif
  210. ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
  211. NGHTTP2 = 1
  212. endif
  213. ifeq ($(findstring -nghttp3,$(CFG)),-nghttp3)
  214. NGHTTP3 = 1
  215. endif
  216. ifeq ($(findstring -ngtcp2,$(CFG)),-ngtcp2)
  217. NGTCP2 = 1
  218. endif
  219. # SSH2 and RTMP require an SSL library; assume OpenSSL if none specified
  220. ifneq ($(SSH2)$(RTMP),)
  221. ifeq ($(SSL)$(WINSSL),)
  222. SSL = 1
  223. endif
  224. endif
  225. INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib
  226. ifdef DYN
  227. curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
  228. curl_LDADD = -L$(PROOT)/lib -lcurldll
  229. else
  230. curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
  231. curl_LDADD = -L$(PROOT)/lib -lcurl
  232. CFLAGS += -DCURL_STATICLIB
  233. LDFLAGS += -static
  234. endif
  235. ifdef ARES
  236. ifndef DYN
  237. curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
  238. endif
  239. CFLAGS += -DUSE_ARES
  240. curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
  241. endif
  242. ifdef RTMP
  243. CFLAGS += -DUSE_LIBRTMP
  244. curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
  245. endif
  246. ifdef NGHTTP2
  247. CFLAGS += -DUSE_NGHTTP2
  248. curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
  249. endif
  250. ifdef SSH2
  251. CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
  252. curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
  253. ifdef WINSSL
  254. ifndef DYN
  255. curl_LDADD += -lbcrypt -lcrypt32
  256. endif
  257. endif
  258. endif
  259. ifdef SSL
  260. ifdef NGHTTP3
  261. CFLAGS += -DUSE_NGHTTP3
  262. curl_LDADD += -L"$(NGHTTP3_PATH)/lib" -lnghttp3
  263. ifdef NGTCP2
  264. CFLAGS += -DUSE_NGTCP2
  265. curl_LDADD += -L"$(NGTCP2_PATH)/lib" -lngtcp2 -lngtcp2_crypto_openssl
  266. endif
  267. endif
  268. ifndef OPENSSL_INCLUDE
  269. ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
  270. OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
  271. endif
  272. ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
  273. OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
  274. endif
  275. endif
  276. ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
  277. $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
  278. endif
  279. ifndef OPENSSL_LIBPATH
  280. OPENSSL_LIBS = -lssl -lcrypto
  281. ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
  282. OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
  283. ifdef DYN
  284. OPENSSL_LIBS = -lssl32 -leay32
  285. endif
  286. endif
  287. ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
  288. OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
  289. endif
  290. endif
  291. ifndef DYN
  292. OPENSSL_LIBS += -lgdi32 -lcrypt32
  293. endif
  294. INCLUDES += -I"$(OPENSSL_INCLUDE)"
  295. CFLAGS += -DUSE_OPENSSL
  296. curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
  297. endif
  298. ifdef WINSSL
  299. CFLAGS += -DUSE_SCHANNEL
  300. curl_LDADD += -lcrypt32
  301. endif
  302. ifdef ZLIB
  303. INCLUDES += -I"$(ZLIB_PATH)"
  304. CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
  305. curl_LDADD += -L"$(ZLIB_PATH)" -lz
  306. endif
  307. ifdef ZSTD
  308. INCLUDES += -I"$(ZSTD_PATH)/include"
  309. CFLAGS += -DHAVE_ZSTD
  310. curl_LDADD += -L"$(ZSTD_PATH)/lib"
  311. ifdef ZSTD_LIBS
  312. curl_LDADD += $(ZSTD_LIBS)
  313. else
  314. curl_LDADD += -lzstd
  315. endif
  316. endif
  317. ifdef BROTLI
  318. INCLUDES += -I"$(BROTLI_PATH)/include"
  319. CFLAGS += -DHAVE_BROTLI
  320. curl_LDADD += -L"$(BROTLI_PATH)/lib"
  321. ifdef BROTLI_LIBS
  322. curl_LDADD += $(BROTLI_LIBS)
  323. else
  324. curl_LDADD += -lbrotlidec
  325. endif
  326. endif
  327. ifdef GSASL
  328. CFLAGS += -DUSE_GSASL
  329. curl_LDADD += -L"$(LIBGSASL_PATH)/lib" -lgsasl
  330. endif
  331. ifdef IDN2
  332. CFLAGS += -DUSE_LIBIDN2
  333. curl_LDADD += -L"$(LIBIDN2_PATH)/lib" -lidn2
  334. else
  335. ifdef WINIDN
  336. CFLAGS += -DUSE_WIN32_IDN
  337. curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
  338. endif
  339. endif
  340. ifdef SSPI
  341. CFLAGS += -DUSE_WINDOWS_SSPI
  342. endif
  343. ifdef IPV6
  344. CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
  345. endif
  346. ifdef LDAPS
  347. CFLAGS += -DHAVE_LDAP_SSL
  348. endif
  349. ifdef USE_LDAP_NOVELL
  350. CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
  351. curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
  352. endif
  353. ifdef USE_LDAP_OPENLDAP
  354. CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
  355. curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
  356. endif
  357. ifndef USE_LDAP_NOVELL
  358. ifndef USE_LDAP_OPENLDAP
  359. curl_LDADD += -lwldap32
  360. endif
  361. endif
  362. curl_LDADD += -lws2_32
  363. # Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines
  364. include Makefile.inc
  365. check_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
  366. check_PROGRAMS += ftpuploadresume.exe synctime.exe
  367. .PRECIOUS: %.o
  368. all: $(check_PROGRAMS)
  369. %.exe: %.o $(curl_DEPENDENCIES)
  370. $(CC) $(LDFLAGS) -o $@ $< $(curl_LDADD)
  371. %.o: %.c
  372. $(CC) $(INCLUDES) $(CFLAGS) -c $<
  373. %.res: %.rc
  374. $(RC) $(RCFLAGS) -i $< -o $@
  375. clean:
  376. @$(call DEL, $(check_PROGRAMS:.exe=.o))
  377. distclean vclean: clean
  378. @$(call DEL, $(check_PROGRAMS))