Makefile.m32 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2018, 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 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)
  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 libmetalink package.
  57. ifndef LIBMETALINK_PATH
  58. LIBMETALINK_PATH = ../../../libmetalink-0.1.3
  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 libidn2 package.
  69. ifndef LIBIDN2_PATH
  70. LIBIDN2_PATH = ../../../libidn2-2.0.3
  71. endif
  72. # Edit the path below to point to the base of your MS IDN package.
  73. # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
  74. # https://www.microsoft.com/en-us/download/details.aspx?id=734
  75. ifndef WINIDN_PATH
  76. WINIDN_PATH = ../../../Microsoft IDN Mitigation APIs
  77. endif
  78. # Edit the path below to point to the base of your Novell LDAP NDK.
  79. ifndef LDAP_SDK
  80. LDAP_SDK = c:/novell/ndk/cldapsdk/win32
  81. endif
  82. # Edit the path below to point to the base of your nghttp2 package.
  83. ifndef NGHTTP2_PATH
  84. NGHTTP2_PATH = ../../../nghttp2-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. CC = $(CURL_CC)
  98. CFLAGS = $(CURL_CFLAG_EXTRAS) -g -O2 -Wall -W
  99. CFLAGS += -fno-strict-aliasing
  100. # comment LDFLAGS below to keep debug info
  101. LDFLAGS = $(CURL_LDFLAG_EXTRAS) $(CURL_LDFLAG_EXTRAS_EXE) -s
  102. RC = $(CROSSPREFIX)windres
  103. RCFLAGS = --include-dir=$(PROOT)/include -O COFF
  104. # Set environment var ARCH to your architecture to override autodetection.
  105. ifndef ARCH
  106. ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
  107. ARCH = w64
  108. else
  109. ARCH = w32
  110. endif
  111. endif
  112. ifeq ($(ARCH),w64)
  113. CFLAGS += -m64 -D_AMD64_
  114. LDFLAGS += -m64
  115. RCFLAGS += -F pe-x86-64
  116. else
  117. CFLAGS += -m32
  118. LDFLAGS += -m32
  119. RCFLAGS += -F pe-i386
  120. endif
  121. # Platform-dependent helper tool macros
  122. ifeq ($(findstring /sh,$(SHELL)),/sh)
  123. DEL = rm -f $1
  124. RMDIR = rm -fr $1
  125. MKDIR = mkdir -p $1
  126. COPY = -cp -afv $1 $2
  127. #COPYR = -cp -afr $1/* $2
  128. COPYR = -rsync -aC $1/* $2
  129. TOUCH = touch $1
  130. CAT = cat
  131. ECHONL = echo ""
  132. DL = '
  133. else
  134. ifeq "$(OS)" "Windows_NT"
  135. DEL = -del 2>NUL /q /f $(subst /,\,$1)
  136. RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
  137. else
  138. DEL = -del 2>NUL $(subst /,\,$1)
  139. RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
  140. endif
  141. MKDIR = -md 2>NUL $(subst /,\,$1)
  142. COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
  143. COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
  144. TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
  145. CAT = type
  146. ECHONL = $(ComSpec) /c echo.
  147. endif
  148. ########################################################
  149. ## Nothing more to do below this line!
  150. ifeq ($(findstring -dyn,$(CFG)),-dyn)
  151. DYN = 1
  152. endif
  153. ifeq ($(findstring -ares,$(CFG)),-ares)
  154. ARES = 1
  155. endif
  156. ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
  157. RTMP = 1
  158. SSL = 1
  159. ZLIB = 1
  160. endif
  161. ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
  162. SSH2 = 1
  163. SSL = 1
  164. ZLIB = 1
  165. endif
  166. ifeq ($(findstring -ssl,$(CFG)),-ssl)
  167. SSL = 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 -metalink,$(CFG)),-metalink)
  191. METALINK = 1
  192. endif
  193. ifeq ($(findstring -winssl,$(CFG)),-winssl)
  194. WINSSL = 1
  195. SSPI = 1
  196. endif
  197. ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
  198. NGHTTP2 = 1
  199. endif
  200. INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib
  201. ifdef DYN
  202. curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
  203. curl_LDADD = -L$(PROOT)/lib -lcurldll
  204. else
  205. curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
  206. curl_LDADD = -L$(PROOT)/lib -lcurl
  207. CFLAGS += -DCURL_STATICLIB
  208. LDFLAGS += -static
  209. endif
  210. ifdef ARES
  211. ifndef DYN
  212. curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
  213. endif
  214. CFLAGS += -DUSE_ARES
  215. curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
  216. endif
  217. ifdef RTMP
  218. CFLAGS += -DUSE_LIBRTMP
  219. curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
  220. endif
  221. ifdef NGHTTP2
  222. CFLAGS += -DUSE_NGHTTP2
  223. curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
  224. endif
  225. ifdef SSH2
  226. CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
  227. curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
  228. ifdef WINSSL
  229. ifndef DYN
  230. curl_LDADD += -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. OPENSSL_LIBS = -lssl -lcrypto
  248. ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
  249. OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
  250. ifdef DYN
  251. OPENSSL_LIBS = -lssl32 -leay32
  252. endif
  253. endif
  254. ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
  255. OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
  256. endif
  257. endif
  258. ifndef DYN
  259. OPENSSL_LIBS += -lgdi32 -lcrypt32
  260. endif
  261. INCLUDES += -I"$(OPENSSL_INCLUDE)"
  262. CFLAGS += -DUSE_OPENSSL
  263. curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
  264. endif
  265. ifdef WINSSL
  266. CFLAGS += -DUSE_SCHANNEL
  267. curl_LDADD += -lcrypt32
  268. endif
  269. ifdef ZLIB
  270. INCLUDES += -I"$(ZLIB_PATH)"
  271. CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
  272. curl_LDADD += -L"$(ZLIB_PATH)" -lz
  273. endif
  274. ifdef BROTLI
  275. INCLUDES += -I"$(BROTLI_PATH)/include"
  276. CFLAGS += -DHAVE_BROTLI
  277. curl_LDADD += -L"$(BROTLI_PATH)/lib"
  278. ifdef BROTLI_LIBS
  279. curl_LDADD += $(BROTLI_LIBS)
  280. else
  281. curl_LDADD += -lbrotlidec
  282. endif
  283. endif
  284. ifdef IDN2
  285. CFLAGS += -DUSE_LIBIDN2
  286. curl_LDADD += -L"$(LIBIDN2_PATH)/lib" -lidn2
  287. else
  288. ifdef WINIDN
  289. CFLAGS += -DUSE_WIN32_IDN
  290. curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
  291. endif
  292. endif
  293. ifdef METALINK
  294. INCLUDES += -I"$(LIBMETALINK_PATH)/include"
  295. CFLAGS += -DUSE_METALINK
  296. curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink
  297. ifndef DYN
  298. ifeq ($(findstring libexpat_metalink_parser.o,$(shell $(AR) t "$(LIBMETALINK_PATH)/lib/libmetalink.a")),libexpat_metalink_parser.o)
  299. curl_LDADD += -L"$(LIBEXPAT_PATH)/lib" -lexpat
  300. else
  301. curl_LDADD += -L"$(LIBXML2_PATH)/lib" -lxml2
  302. endif
  303. endif
  304. endif
  305. ifdef SSPI
  306. CFLAGS += -DUSE_WINDOWS_SSPI
  307. endif
  308. ifdef IPV6
  309. CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
  310. endif
  311. ifdef LDAPS
  312. CFLAGS += -DHAVE_LDAP_SSL
  313. endif
  314. ifdef USE_LDAP_NOVELL
  315. CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
  316. curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
  317. endif
  318. ifdef USE_LDAP_OPENLDAP
  319. CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
  320. curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
  321. endif
  322. ifndef USE_LDAP_NOVELL
  323. ifndef USE_LDAP_OPENLDAP
  324. curl_LDADD += -lwldap32
  325. endif
  326. endif
  327. curl_LDADD += -lws2_32
  328. # Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines
  329. include Makefile.inc
  330. check_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
  331. check_PROGRAMS += ftpuploadresume.exe synctime.exe
  332. .PRECIOUS: %.o
  333. all: $(check_PROGRAMS)
  334. %.exe: %.o $(curl_DEPENDENCIES)
  335. $(CC) $(LDFLAGS) -o $@ $< $(curl_LDADD)
  336. %.o: %.c
  337. $(CC) $(INCLUDES) $(CFLAGS) -c $<
  338. %.res: %.rc
  339. $(RC) $(RCFLAGS) -i $< -o $@
  340. clean:
  341. @$(call DEL, $(check_PROGRAMS:.exe=.o))
  342. distclean vclean: clean
  343. @$(call DEL, $(check_PROGRAMS))