Makefile.m32 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2015, 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. ## Makefile for building curl examples with MingW (GCC-3.2 or later)
  24. ## and optionally OpenSSL (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4)
  25. ##
  26. ## Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
  27. ## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-spi-winidn
  28. ##
  29. ## Hint: you can also set environment vars to control the build, f.e.:
  30. ## set ZLIB_PATH=c:/zlib-1.2.8
  31. ## set ZLIB=1
  32. #
  33. ###########################################################################
  34. # Edit the path below to point to the base of your Zlib sources.
  35. ifndef ZLIB_PATH
  36. ZLIB_PATH = ../../../zlib-1.2.8
  37. endif
  38. # Edit the path below to point to the base of your OpenSSL package.
  39. ifndef OPENSSL_PATH
  40. OPENSSL_PATH = ../../../openssl-1.0.2a
  41. endif
  42. # Edit the path below to point to the base of your LibSSH2 package.
  43. ifndef LIBSSH2_PATH
  44. LIBSSH2_PATH = ../../../libssh2-1.5.0
  45. endif
  46. # Edit the path below to point to the base of your librtmp package.
  47. ifndef LIBRTMP_PATH
  48. LIBRTMP_PATH = ../../../librtmp-2.4
  49. endif
  50. # Edit the path below to point to the base of your libidn package.
  51. ifndef LIBIDN_PATH
  52. LIBIDN_PATH = ../../../libidn-1.32
  53. endif
  54. # Edit the path below to point to the base of your MS IDN package.
  55. # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
  56. # https://www.microsoft.com/en-us/download/details.aspx?id=734
  57. ifndef WINIDN_PATH
  58. WINIDN_PATH = ../../../Microsoft IDN Mitigation APIs
  59. endif
  60. # Edit the path below to point to the base of your Novell LDAP NDK.
  61. ifndef LDAP_SDK
  62. LDAP_SDK = c:/novell/ndk/cldapsdk/win32
  63. endif
  64. # Edit the path below to point to the base of your nghttp2 package.
  65. ifndef NGHTTP2_PATH
  66. NGHTTP2_PATH = ../../../nghttp2-1.0.0
  67. endif
  68. PROOT = ../..
  69. # Edit the path below to point to the base of your c-ares package.
  70. ifndef LIBCARES_PATH
  71. LIBCARES_PATH = $(PROOT)/ares
  72. endif
  73. # Edit the var below to set to your architecture or set environment var.
  74. ifndef ARCH
  75. ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
  76. ARCH = w64
  77. else
  78. ARCH = w32
  79. endif
  80. endif
  81. CC = $(CROSSPREFIX)gcc
  82. CFLAGS = -g -O2 -Wall
  83. CFLAGS += -fno-strict-aliasing
  84. ifeq ($(ARCH),w64)
  85. CFLAGS += -m64 -D_AMD64_
  86. LDFLAGS += -m64
  87. RCFLAGS += -F pe-x86-64
  88. else
  89. CFLAGS += -m32
  90. LDFLAGS += -m32
  91. RCFLAGS += -F pe-i386
  92. endif
  93. # comment LDFLAGS below to keep debug info
  94. LDFLAGS = -s
  95. RC = $(CROSSPREFIX)windres
  96. RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i
  97. # Platform-dependent helper tool macros
  98. ifeq ($(findstring /sh,$(SHELL)),/sh)
  99. DEL = rm -f $1
  100. RMDIR = rm -fr $1
  101. MKDIR = mkdir -p $1
  102. COPY = -cp -afv $1 $2
  103. #COPYR = -cp -afr $1/* $2
  104. COPYR = -rsync -aC $1/* $2
  105. TOUCH = touch $1
  106. CAT = cat
  107. ECHONL = echo ""
  108. DL = '
  109. else
  110. ifeq "$(OS)" "Windows_NT"
  111. DEL = -del 2>NUL /q /f $(subst /,\,$1)
  112. RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
  113. else
  114. DEL = -del 2>NUL $(subst /,\,$1)
  115. RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
  116. endif
  117. MKDIR = -md 2>NUL $(subst /,\,$1)
  118. COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
  119. COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
  120. TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
  121. CAT = type
  122. ECHONL = $(ComSpec) /c echo.
  123. endif
  124. ########################################################
  125. ## Nothing more to do below this line!
  126. ifeq ($(findstring -dyn,$(CFG)),-dyn)
  127. DYN = 1
  128. endif
  129. ifeq ($(findstring -ares,$(CFG)),-ares)
  130. ARES = 1
  131. endif
  132. ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
  133. RTMP = 1
  134. SSL = 1
  135. ZLIB = 1
  136. endif
  137. ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
  138. SSH2 = 1
  139. SSL = 1
  140. ZLIB = 1
  141. endif
  142. ifeq ($(findstring -ssl,$(CFG)),-ssl)
  143. SSL = 1
  144. endif
  145. ifeq ($(findstring -zlib,$(CFG)),-zlib)
  146. ZLIB = 1
  147. endif
  148. ifeq ($(findstring -idn,$(CFG)),-idn)
  149. IDN = 1
  150. endif
  151. ifeq ($(findstring -winidn,$(CFG)),-winidn)
  152. WINIDN = 1
  153. endif
  154. ifeq ($(findstring -sspi,$(CFG)),-sspi)
  155. SSPI = 1
  156. endif
  157. ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
  158. LDAPS = 1
  159. endif
  160. ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
  161. IPV6 = 1
  162. endif
  163. ifeq ($(findstring -metalink,$(CFG)),-metalink)
  164. METALINK = 1
  165. endif
  166. ifeq ($(findstring -winssl,$(CFG)),-winssl)
  167. WINSSL = 1
  168. SSPI = 1
  169. endif
  170. ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
  171. NGHTTP2 = 1
  172. endif
  173. INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib
  174. ifdef DYN
  175. curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
  176. curl_LDADD = -L$(PROOT)/lib -lcurldll
  177. else
  178. curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
  179. curl_LDADD = -L$(PROOT)/lib -lcurl
  180. CFLAGS += -DCURL_STATICLIB
  181. LDFLAGS += -static
  182. endif
  183. ifdef ARES
  184. ifndef DYN
  185. curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
  186. endif
  187. CFLAGS += -DUSE_ARES
  188. curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
  189. endif
  190. ifdef RTMP
  191. CFLAGS += -DUSE_LIBRTMP
  192. curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
  193. endif
  194. ifdef NGHTTP2
  195. CFLAGS += -DUSE_NGHTTP2
  196. curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
  197. endif
  198. ifdef SSH2
  199. CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
  200. curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
  201. endif
  202. ifdef SSL
  203. ifndef OPENSSL_LIBPATH
  204. OPENSSL_LIBS = -lssl -lcrypto
  205. ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
  206. OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
  207. ifdef DYN
  208. OPENSSL_LIBS = -lssl32 -leay32
  209. endif
  210. endif
  211. ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
  212. OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
  213. endif
  214. endif
  215. ifndef DYN
  216. OPENSSL_LIBS += -lgdi32 -lcrypt32
  217. endif
  218. CFLAGS += -DUSE_OPENSSL
  219. curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
  220. endif
  221. ifdef ZLIB
  222. INCLUDES += -I"$(ZLIB_PATH)"
  223. CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
  224. curl_LDADD += -L"$(ZLIB_PATH)" -lz
  225. endif
  226. ifdef IDN
  227. CFLAGS += -DUSE_LIBIDN
  228. curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
  229. else
  230. ifdef WINIDN
  231. CFLAGS += -DUSE_WIN32_IDN
  232. curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
  233. endif
  234. endif
  235. ifdef SSPI
  236. CFLAGS += -DUSE_WINDOWS_SSPI
  237. ifdef WINSSL
  238. CFLAGS += -DUSE_SCHANNEL
  239. endif
  240. endif
  241. ifdef IPV6
  242. CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
  243. endif
  244. ifdef LDAPS
  245. CFLAGS += -DHAVE_LDAP_SSL
  246. endif
  247. ifdef USE_LDAP_NOVELL
  248. CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
  249. curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
  250. endif
  251. ifdef USE_LDAP_OPENLDAP
  252. CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
  253. curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
  254. endif
  255. ifndef USE_LDAP_NOVELL
  256. ifndef USE_LDAP_OPENLDAP
  257. curl_LDADD += -lwldap32
  258. endif
  259. endif
  260. curl_LDADD += -lws2_32
  261. # Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines
  262. include Makefile.inc
  263. check_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
  264. check_PROGRAMS += ftpuploadresume.exe synctime.exe
  265. .PRECIOUS: %.o
  266. all: $(check_PROGRAMS)
  267. %.exe: %.o $(curl_DEPENDENCIES)
  268. $(CC) $(LDFLAGS) -o $@ $< $(curl_LDADD)
  269. %.o: %.c
  270. $(CC) $(INCLUDES) $(CFLAGS) -c $<
  271. %.res: %.rc
  272. $(RC) $(RCFLAGS) $< -o $@
  273. clean:
  274. @$(call DEL, $(check_PROGRAMS:.exe=.o))
  275. distclean vclean: clean
  276. @$(call DEL, $(check_PROGRAMS))