Makefile.m32 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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.8y
  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.4
  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. # Edit the var below to set to your architecture or set environment var.
  54. ifndef ARCH
  55. ARCH = w32
  56. endif
  57. CC = $(CROSSPREFIX)gcc
  58. CFLAGS = -g -O2 -Wall
  59. CFLAGS += -fno-strict-aliasing
  60. ifeq ($(ARCH),w64)
  61. CFLAGS += -D_AMD64_
  62. endif
  63. # comment LDFLAGS below to keep debug info
  64. LDFLAGS = -s
  65. AR = $(CROSSPREFIX)ar
  66. RANLIB = $(CROSSPREFIX)ranlib
  67. RC = $(CROSSPREFIX)windres
  68. RCFLAGS = --include-dir=$(PROOT)/include -DDEBUGBUILD=0 -O COFF -i
  69. STRIP = $(CROSSPREFIX)strip -g
  70. # Platform-dependent helper tool macros
  71. ifeq ($(findstring /sh,$(SHELL)),/sh)
  72. DEL = rm -f $1
  73. RMDIR = rm -fr $1
  74. MKDIR = mkdir -p $1
  75. COPY = -cp -afv $1 $2
  76. #COPYR = -cp -afr $1/* $2
  77. COPYR = -rsync -aC $1/* $2
  78. TOUCH = touch $1
  79. CAT = cat
  80. ECHONL = echo ""
  81. DL = '
  82. else
  83. ifeq "$(OS)" "Windows_NT"
  84. DEL = -del 2>NUL /q /f $(subst /,\,$1)
  85. RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
  86. else
  87. DEL = -del 2>NUL $(subst /,\,$1)
  88. RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
  89. endif
  90. MKDIR = -md 2>NUL $(subst /,\,$1)
  91. COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
  92. COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
  93. TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
  94. CAT = type
  95. ECHONL = $(ComSpec) /c echo.
  96. endif
  97. ########################################################
  98. ## Nothing more to do below this line!
  99. ifeq ($(findstring -dyn,$(CFG)),-dyn)
  100. DYN = 1
  101. endif
  102. ifeq ($(findstring -ares,$(CFG)),-ares)
  103. ARES = 1
  104. endif
  105. ifeq ($(findstring -sync,$(CFG)),-sync)
  106. SYNC = 1
  107. endif
  108. ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
  109. RTMP = 1
  110. SSL = 1
  111. ZLIB = 1
  112. endif
  113. ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
  114. SSH2 = 1
  115. SSL = 1
  116. ZLIB = 1
  117. endif
  118. ifeq ($(findstring -ssl,$(CFG)),-ssl)
  119. SSL = 1
  120. endif
  121. ifeq ($(findstring -srp,$(CFG)),-srp)
  122. SRP = 1
  123. endif
  124. ifeq ($(findstring -zlib,$(CFG)),-zlib)
  125. ZLIB = 1
  126. endif
  127. ifeq ($(findstring -idn,$(CFG)),-idn)
  128. IDN = 1
  129. endif
  130. ifeq ($(findstring -winidn,$(CFG)),-winidn)
  131. WINIDN = 1
  132. endif
  133. ifeq ($(findstring -sspi,$(CFG)),-sspi)
  134. SSPI = 1
  135. endif
  136. ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
  137. LDAPS = 1
  138. endif
  139. ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
  140. IPV6 = 1
  141. endif
  142. ifeq ($(findstring -winssl,$(CFG)),-winssl)
  143. WINSSL = 1
  144. SSPI = 1
  145. endif
  146. ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
  147. NGHTTP2 = 1
  148. endif
  149. INCLUDES = -I. -I../include
  150. CFLAGS += -DBUILDING_LIBCURL
  151. ifdef SYNC
  152. CFLAGS += -DUSE_SYNC_DNS
  153. else
  154. ifdef ARES
  155. INCLUDES += -I"$(LIBCARES_PATH)"
  156. CFLAGS += -DUSE_ARES -DCARES_STATICLIB
  157. DLL_LIBS += -L"$(LIBCARES_PATH)" -lcares
  158. libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a
  159. endif
  160. endif
  161. ifdef RTMP
  162. INCLUDES += -I"$(LIBRTMP_PATH)"
  163. CFLAGS += -DUSE_LIBRTMP
  164. DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
  165. endif
  166. ifdef NGHTTP2
  167. INCLUDES += -I"$(NGHTTP2_PATH)/include"
  168. CFLAGS += -DUSE_NGHTTP2
  169. DLL_LIBS += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
  170. endif
  171. ifdef SSH2
  172. INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
  173. CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
  174. DLL_LIBS += -L"$(LIBSSH2_PATH)/win32" -lssh2
  175. endif
  176. ifdef SSL
  177. ifndef OPENSSL_INCLUDE
  178. ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
  179. OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
  180. endif
  181. ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
  182. OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
  183. endif
  184. endif
  185. ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
  186. $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
  187. endif
  188. ifndef OPENSSL_LIBPATH
  189. ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
  190. OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
  191. OPENSSL_LIBS = -leay32 -lssl32
  192. endif
  193. ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
  194. OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
  195. OPENSSL_LIBS = -lcrypto -lssl
  196. endif
  197. endif
  198. INCLUDES += -I"$(OPENSSL_INCLUDE)"
  199. CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \
  200. -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 \
  201. -DCURL_WANTS_CA_BUNDLE_ENV
  202. DLL_LIBS += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
  203. ifdef SRP
  204. ifeq "$(wildcard $(OPENSSL_INCLUDE)/openssl/srp.h)" "$(OPENSSL_INCLUDE)/openssl/srp.h"
  205. CFLAGS += -DHAVE_SSLEAY_SRP -DUSE_TLS_SRP
  206. endif
  207. endif
  208. endif
  209. ifdef ZLIB
  210. INCLUDES += -I"$(ZLIB_PATH)"
  211. CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
  212. DLL_LIBS += -L"$(ZLIB_PATH)" -lz
  213. endif
  214. ifdef IDN
  215. INCLUDES += -I"$(LIBIDN_PATH)/include"
  216. CFLAGS += -DUSE_LIBIDN
  217. DLL_LIBS += -L"$(LIBIDN_PATH)/lib" -lidn
  218. else
  219. ifdef WINIDN
  220. CFLAGS += -DUSE_WIN32_IDN
  221. CFLAGS += -DWANT_IDN_PROTOTYPES
  222. DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz
  223. endif
  224. endif
  225. ifdef SSPI
  226. CFLAGS += -DUSE_WINDOWS_SSPI
  227. ifdef WINSSL
  228. CFLAGS += -DUSE_SCHANNEL
  229. endif
  230. endif
  231. ifdef SPNEGO
  232. CFLAGS += -DHAVE_SPNEGO
  233. endif
  234. ifdef IPV6
  235. CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
  236. endif
  237. ifdef LDAPS
  238. CFLAGS += -DHAVE_LDAP_SSL
  239. endif
  240. ifdef USE_LDAP_NOVELL
  241. INCLUDES += -I"$(LDAP_SDK)/inc"
  242. CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
  243. DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
  244. endif
  245. ifdef USE_LDAP_OPENLDAP
  246. INCLUDES += -I"$(LDAP_SDK)/include"
  247. CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
  248. DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
  249. endif
  250. ifndef USE_LDAP_NOVELL
  251. ifndef USE_LDAP_OPENLDAP
  252. DLL_LIBS += -lwldap32
  253. endif
  254. endif
  255. DLL_LIBS += -lws2_32
  256. # Makefile.inc provides the CSOURCES and HHEADERS defines
  257. include Makefile.inc
  258. libcurl_dll_LIBRARY = libcurl.dll
  259. libcurl_dll_a_LIBRARY = libcurldll.a
  260. libcurl_a_LIBRARY = libcurl.a
  261. libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
  262. libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
  263. RESOURCE = libcurl.res
  264. all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
  265. $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
  266. @$(call DEL, $@)
  267. $(AR) cru $@ $(libcurl_a_OBJECTS)
  268. $(RANLIB) $@
  269. $(STRIP) $@
  270. # remove the last line above to keep debug info
  271. $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
  272. @$(call DEL, $@)
  273. $(CC) $(LDFLAGS) -shared -o $@ \
  274. -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY) \
  275. $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
  276. %.o: %.c $(PROOT)/include/curl/curlbuild.h
  277. $(CC) $(INCLUDES) $(CFLAGS) -c $< -o $@
  278. %.res: %.rc
  279. $(RC) $(RCFLAGS) $< -o $@
  280. clean:
  281. ifeq "$(wildcard $(PROOT)/include/curl/curlbuild.h.dist)" "$(PROOT)/include/curl/curlbuild.h.dist"
  282. @$(call DEL, $(PROOT)/include/curl/curlbuild.h)
  283. endif
  284. @$(call DEL, $(libcurl_a_OBJECTS) $(RESOURCE))
  285. distclean vclean: clean
  286. @$(call DEL, $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY))
  287. $(PROOT)/include/curl/curlbuild.h:
  288. @echo Creating $@
  289. @$(call COPY, $@.dist, $@)
  290. $(LIBCARES_PATH)/libcares.a:
  291. $(MAKE) -C $(LIBCARES_PATH) -f Makefile.m32