Makefile.m32 9.8 KB

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