Makefile.m32 10 KB

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