Makefile.m32 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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.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 libcurl.a with MingW (GCC-3.2 or later or LLVM/Clang)
  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 libidn2 package.
  61. ifndef LIBIDN2_PATH
  62. LIBIDN2_PATH = ../../libidn2-2.0.3
  63. endif
  64. # Edit the path below to point to the base of your MS IDN package.
  65. # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
  66. # https://www.microsoft.com/en-us/download/details.aspx?id=734
  67. ifndef WINIDN_PATH
  68. WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
  69. endif
  70. # Edit the path below to point to the base of your Novell LDAP NDK.
  71. ifndef LDAP_SDK
  72. LDAP_SDK = c:/novell/ndk/cldapsdk/win32
  73. endif
  74. # Edit the path below to point to the base of your nghttp2 package.
  75. ifndef NGHTTP2_PATH
  76. NGHTTP2_PATH = ../../nghttp2-1.0.0
  77. endif
  78. # Edit the path below to point to the base of your nghttp3 package.
  79. ifndef NGHTTP3_PATH
  80. NGHTTP3_PATH = ../../nghttp3-1.0.0
  81. endif
  82. # Edit the path below to point to the base of your ngtcp2 package.
  83. ifndef NGTCP2_PATH
  84. NGTCP2_PATH = ../../ngtcp2-1.0.0
  85. endif
  86. PROOT = ..
  87. # Edit the path below to point to the base of your c-ares package.
  88. ifndef LIBCARES_PATH
  89. LIBCARES_PATH = $(PROOT)/ares
  90. endif
  91. ifeq ($(CURL_CC),)
  92. CURL_CC := $(CROSSPREFIX)gcc
  93. endif
  94. ifeq ($(CURL_AR),)
  95. CURL_AR := $(CROSSPREFIX)ar
  96. endif
  97. ifeq ($(CURL_RANLIB),)
  98. CURL_RANLIB := $(CROSSPREFIX)ranlib
  99. endif
  100. CC = $(CURL_CC)
  101. CFLAGS = $(CURL_CFLAG_EXTRAS) -g -O2 -Wall -W
  102. CFLAGS += -fno-strict-aliasing
  103. # comment LDFLAGS below to keep debug info
  104. LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_DLL) -s
  105. AR = $(CURL_AR)
  106. RANLIB = $(CURL_RANLIB)
  107. RC = $(CROSSPREFIX)windres
  108. RCFLAGS = --include-dir=$(PROOT)/include -DDEBUGBUILD=0 -O coff
  109. STRIP = $(CROSSPREFIX)strip -g
  110. # Set environment var ARCH to your architecture to override autodetection.
  111. ifndef ARCH
  112. ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
  113. ARCH = w64
  114. else
  115. ARCH = w32
  116. endif
  117. endif
  118. ifeq ($(ARCH),w64)
  119. CFLAGS += -m64 -D_AMD64_
  120. LDFLAGS += -m64
  121. RCFLAGS += -F pe-x86-64
  122. else
  123. CFLAGS += -m32
  124. LDFLAGS += -m32
  125. RCFLAGS += -F pe-i386
  126. endif
  127. # Platform-dependent helper tool macros
  128. ifeq ($(findstring /sh,$(SHELL)),/sh)
  129. DEL = rm -f $1
  130. RMDIR = rm -fr $1
  131. MKDIR = mkdir -p $1
  132. COPY = -cp -afv $1 $2
  133. #COPYR = -cp -afr $1/* $2
  134. COPYR = -rsync -aC $1/* $2
  135. TOUCH = touch $1
  136. CAT = cat
  137. ECHONL = echo ""
  138. DL = '
  139. else
  140. ifeq "$(OS)" "Windows_NT"
  141. DEL = -del 2>NUL /q /f $(subst /,\,$1)
  142. RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
  143. else
  144. DEL = -del 2>NUL $(subst /,\,$1)
  145. RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
  146. endif
  147. MKDIR = -md 2>NUL $(subst /,\,$1)
  148. COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
  149. COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
  150. TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
  151. CAT = type
  152. ECHONL = $(ComSpec) /c echo.
  153. endif
  154. ########################################################
  155. ## Nothing more to do below this line!
  156. ifeq ($(findstring -dyn,$(CFG)),-dyn)
  157. DYN = 1
  158. endif
  159. ifeq ($(findstring -ares,$(CFG)),-ares)
  160. ARES = 1
  161. endif
  162. ifeq ($(findstring -sync,$(CFG)),-sync)
  163. SYNC = 1
  164. endif
  165. ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
  166. RTMP = 1
  167. SSL = 1
  168. ZLIB = 1
  169. endif
  170. ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
  171. SSH2 = 1
  172. SSL = 1
  173. ZLIB = 1
  174. endif
  175. ifeq ($(findstring -ssl,$(CFG)),-ssl)
  176. SSL = 1
  177. endif
  178. ifeq ($(findstring -srp,$(CFG)),-srp)
  179. SRP = 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 -winssl,$(CFG)),-winssl)
  206. WINSSL = 1
  207. SSPI = 1
  208. endif
  209. ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
  210. NGHTTP2 = 1
  211. endif
  212. ifeq ($(findstring -nghttp3,$(CFG)),-nghttp3)
  213. NGHTTP3 = 1
  214. endif
  215. ifeq ($(findstring -ngtcp2,$(CFG)),-ngtcp2)
  216. NGTCP2 = 1
  217. endif
  218. ifeq ($(findstring -unicode,$(CFG)),-unicode)
  219. UNICODE = 1
  220. endif
  221. INCLUDES = -I. -I../include
  222. CFLAGS += -DBUILDING_LIBCURL
  223. ifdef SSL
  224. ifdef WINSSL
  225. CFLAGS += -DCURL_WITH_MULTI_SSL
  226. endif
  227. endif
  228. ifdef UNICODE
  229. CFLAGS += -DUNICODE -D_UNICODE
  230. endif
  231. ifdef SYNC
  232. CFLAGS += -DUSE_SYNC_DNS
  233. else
  234. ifdef ARES
  235. INCLUDES += -I"$(LIBCARES_PATH)"
  236. CFLAGS += -DUSE_ARES -DCARES_STATICLIB
  237. DLL_LIBS += -L"$(LIBCARES_PATH)" -lcares
  238. libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a
  239. endif
  240. endif
  241. ifdef RTMP
  242. INCLUDES += -I"$(LIBRTMP_PATH)"
  243. CFLAGS += -DUSE_LIBRTMP
  244. DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
  245. endif
  246. ifdef NGHTTP2
  247. INCLUDES += -I"$(NGHTTP2_PATH)/include"
  248. CFLAGS += -DUSE_NGHTTP2
  249. DLL_LIBS += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
  250. endif
  251. ifdef SSH2
  252. INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
  253. CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
  254. DLL_LIBS += -L"$(LIBSSH2_PATH)/win32" -lssh2
  255. ifdef WINSSL
  256. ifndef DYN
  257. DLL_LIBS += -lbcrypt -lcrypt32
  258. endif
  259. endif
  260. endif
  261. ifdef SSL
  262. ifdef NGHTTP3
  263. INCLUDES += -I"$(NGHTTP3_PATH)/include"
  264. CFLAGS += -DUSE_NGHTTP3
  265. DLL_LIBS += -L"$(NGHTTP3_PATH)/lib" -lnghttp3
  266. ifdef NGTCP2
  267. INCLUDES += -I"$(NGTCP2_PATH)/include"
  268. CFLAGS += -DUSE_NGTCP2
  269. DLL_LIBS += -L"$(NGTCP2_PATH)/lib" -lngtcp2 -lngtcp2_crypto_openssl
  270. endif
  271. endif
  272. ifndef OPENSSL_INCLUDE
  273. ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
  274. OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
  275. endif
  276. ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
  277. OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
  278. endif
  279. endif
  280. ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
  281. $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
  282. endif
  283. ifndef OPENSSL_LIBPATH
  284. ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
  285. OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
  286. OPENSSL_LIBS = -leay32 -lssl32
  287. endif
  288. ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
  289. OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
  290. OPENSSL_LIBS = -lcrypto -lssl
  291. endif
  292. endif
  293. ifndef DYN
  294. OPENSSL_LIBS += -lgdi32 -lcrypt32
  295. endif
  296. INCLUDES += -I"$(OPENSSL_INCLUDE)"
  297. CFLAGS += -DUSE_OPENSSL -DHAVE_OPENSSL_PKCS12_H \
  298. -DOPENSSL_NO_KRB5
  299. DLL_LIBS += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
  300. ifdef SRP
  301. ifeq "$(wildcard $(OPENSSL_INCLUDE)/openssl/srp.h)" "$(OPENSSL_INCLUDE)/openssl/srp.h"
  302. CFLAGS += -DHAVE_OPENSSL_SRP -DUSE_TLS_SRP
  303. endif
  304. endif
  305. endif
  306. ifdef WINSSL
  307. CFLAGS += -DUSE_SCHANNEL
  308. DLL_LIBS += -lcrypt32
  309. endif
  310. ifdef ZLIB
  311. INCLUDES += -I"$(ZLIB_PATH)"
  312. CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
  313. DLL_LIBS += -L"$(ZLIB_PATH)" -lz
  314. endif
  315. ifdef ZSTD
  316. INCLUDES += -I"$(ZSTD_PATH)/include"
  317. CFLAGS += -DHAVE_ZSTD
  318. DLL_LIBS += -L"$(ZSTD_PATH)/lib"
  319. ifdef ZSTD_LIBS
  320. DLL_LIBS += $(ZSTD_LIBS)
  321. else
  322. DLL_LIBS += -lzstd
  323. endif
  324. endif
  325. ifdef BROTLI
  326. INCLUDES += -I"$(BROTLI_PATH)/include"
  327. CFLAGS += -DHAVE_BROTLI
  328. DLL_LIBS += -L"$(BROTLI_PATH)/lib"
  329. ifdef BROTLI_LIBS
  330. DLL_LIBS += $(BROTLI_LIBS)
  331. else
  332. DLL_LIBS += -lbrotlidec
  333. endif
  334. endif
  335. ifdef IDN2
  336. INCLUDES += -I"$(LIBIDN2_PATH)/include"
  337. CFLAGS += -DUSE_LIBIDN2
  338. DLL_LIBS += -L"$(LIBIDN2_PATH)/lib" -lidn2
  339. else
  340. ifdef WINIDN
  341. CFLAGS += -DUSE_WIN32_IDN
  342. CFLAGS += -DWANT_IDN_PROTOTYPES
  343. DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz
  344. endif
  345. endif
  346. ifdef SSPI
  347. CFLAGS += -DUSE_WINDOWS_SSPI
  348. endif
  349. ifdef SPNEGO
  350. CFLAGS += -DHAVE_SPNEGO
  351. endif
  352. ifdef IPV6
  353. CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
  354. endif
  355. ifdef LDAPS
  356. CFLAGS += -DHAVE_LDAP_SSL
  357. endif
  358. ifdef USE_LDAP_NOVELL
  359. INCLUDES += -I"$(LDAP_SDK)/inc"
  360. CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
  361. DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
  362. endif
  363. ifdef USE_LDAP_OPENLDAP
  364. INCLUDES += -I"$(LDAP_SDK)/include"
  365. CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
  366. DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
  367. endif
  368. ifndef USE_LDAP_NOVELL
  369. ifndef USE_LDAP_OPENLDAP
  370. DLL_LIBS += -lwldap32
  371. endif
  372. endif
  373. DLL_LIBS += -lws2_32
  374. # Makefile.inc provides the CSOURCES and HHEADERS defines
  375. include Makefile.inc
  376. ifeq ($(CURL_DLL_A_SUFFIX),)
  377. CURL_DLL_A_SUFFIX := dll
  378. endif
  379. libcurl_dll_LIBRARY = libcurl$(CURL_DLL_SUFFIX).dll
  380. libcurl_dll_a_LIBRARY = libcurl$(CURL_DLL_A_SUFFIX).a
  381. libcurl_a_LIBRARY = libcurl.a
  382. libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
  383. libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
  384. RESOURCE = libcurl.res
  385. all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
  386. $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
  387. @$(call DEL, $@)
  388. $(AR) cru $@ $(libcurl_a_OBJECTS)
  389. $(RANLIB) $@
  390. $(STRIP) $@
  391. # remove the last line above to keep debug info
  392. $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
  393. @$(call DEL, $@)
  394. $(CC) $(LDFLAGS) -shared -o $@ \
  395. -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY) \
  396. $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
  397. %.o: %.c
  398. $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
  399. %.res: %.rc
  400. $(RC) $(RCFLAGS) -i $< -o $@
  401. clean:
  402. @$(call DEL, $(libcurl_a_OBJECTS) $(RESOURCE))
  403. distclean vclean: clean
  404. @$(call DEL, $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY))
  405. $(LIBCARES_PATH)/libcares.a:
  406. $(MAKE) -C $(LIBCARES_PATH) -f Makefile.m32