2
0

Makefile.m32 8.6 KB

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