Makefile.m32 11 KB

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