2
0

Makefile.m32 8.0 KB

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