2
0

Makefile.m32 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. 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 -sync,$(CFG)),-sync)
  102. SYNC = 1
  103. endif
  104. ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
  105. RTMP = 1
  106. SSL = 1
  107. ZLIB = 1
  108. endif
  109. ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
  110. SSH2 = 1
  111. SSL = 1
  112. ZLIB = 1
  113. endif
  114. ifeq ($(findstring -ssl,$(CFG)),-ssl)
  115. SSL = 1
  116. endif
  117. ifeq ($(findstring -srp,$(CFG)),-srp)
  118. SRP = 1
  119. endif
  120. ifeq ($(findstring -zlib,$(CFG)),-zlib)
  121. ZLIB = 1
  122. endif
  123. ifeq ($(findstring -idn,$(CFG)),-idn)
  124. IDN = 1
  125. endif
  126. ifeq ($(findstring -winidn,$(CFG)),-winidn)
  127. WINIDN = 1
  128. endif
  129. ifeq ($(findstring -sspi,$(CFG)),-sspi)
  130. SSPI = 1
  131. endif
  132. ifeq ($(findstring -spnego,$(CFG)),-spnego)
  133. SPNEGO = 1
  134. endif
  135. ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
  136. LDAPS = 1
  137. endif
  138. ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
  139. IPV6 = 1
  140. endif
  141. ifeq ($(findstring -winssl,$(CFG)),-winssl)
  142. WINSSL = 1
  143. SSPI = 1
  144. endif
  145. INCLUDES = -I. -I../include
  146. CFLAGS += -DBUILDING_LIBCURL
  147. ifdef SYNC
  148. CFLAGS += -DUSE_SYNC_DNS
  149. else
  150. ifdef ARES
  151. INCLUDES += -I"$(LIBCARES_PATH)"
  152. CFLAGS += -DUSE_ARES -DCARES_STATICLIB
  153. DLL_LIBS += -L"$(LIBCARES_PATH)" -lcares
  154. libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a
  155. endif
  156. endif
  157. ifdef RTMP
  158. INCLUDES += -I"$(LIBRTMP_PATH)"
  159. CFLAGS += -DUSE_LIBRTMP
  160. DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
  161. endif
  162. ifdef SSH2
  163. INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
  164. CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
  165. DLL_LIBS += -L"$(LIBSSH2_PATH)/win32" -lssh2
  166. endif
  167. ifdef SSL
  168. ifndef OPENSSL_INCLUDE
  169. ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
  170. OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
  171. endif
  172. ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
  173. OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
  174. endif
  175. endif
  176. ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
  177. $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
  178. endif
  179. ifndef OPENSSL_LIBPATH
  180. ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
  181. OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
  182. OPENSSL_LIBS = -leay32 -lssl32
  183. endif
  184. ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
  185. OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
  186. OPENSSL_LIBS = -lcrypto -lssl
  187. endif
  188. endif
  189. INCLUDES += -I"$(OPENSSL_INCLUDE)"
  190. CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \
  191. -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 \
  192. -DCURL_WANTS_CA_BUNDLE_ENV
  193. DLL_LIBS += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
  194. ifdef SRP
  195. ifeq "$(wildcard $(OPENSSL_INCLUDE)/openssl/srp.h)" "$(OPENSSL_INCLUDE)/openssl/srp.h"
  196. CFLAGS += -DHAVE_SSLEAY_SRP -DUSE_TLS_SRP
  197. endif
  198. endif
  199. endif
  200. ifdef ZLIB
  201. INCLUDES += -I"$(ZLIB_PATH)"
  202. CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
  203. DLL_LIBS += -L"$(ZLIB_PATH)" -lz
  204. endif
  205. ifdef IDN
  206. INCLUDES += -I"$(LIBIDN_PATH)/include"
  207. CFLAGS += -DUSE_LIBIDN
  208. DLL_LIBS += -L"$(LIBIDN_PATH)/lib" -lidn
  209. else
  210. ifdef WINIDN
  211. CFLAGS += -DUSE_WIN32_IDN
  212. CFLAGS += -DWANT_IDN_PROTOTYPES
  213. DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz
  214. endif
  215. endif
  216. ifdef SSPI
  217. CFLAGS += -DUSE_WINDOWS_SSPI
  218. ifdef WINSSL
  219. CFLAGS += -DUSE_SCHANNEL
  220. endif
  221. endif
  222. ifdef SPNEGO
  223. CFLAGS += -DHAVE_SPNEGO
  224. endif
  225. ifdef IPV6
  226. CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
  227. endif
  228. ifdef LDAPS
  229. CFLAGS += -DHAVE_LDAP_SSL
  230. endif
  231. ifdef USE_LDAP_NOVELL
  232. INCLUDES += -I"$(LDAP_SDK)/inc"
  233. CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
  234. DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
  235. endif
  236. ifdef USE_LDAP_OPENLDAP
  237. INCLUDES += -I"$(LDAP_SDK)/include"
  238. CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
  239. DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
  240. endif
  241. ifndef USE_LDAP_NOVELL
  242. ifndef USE_LDAP_OPENLDAP
  243. DLL_LIBS += -lwldap32
  244. endif
  245. endif
  246. DLL_LIBS += -lws2_32
  247. # Makefile.inc provides the CSOURCES and HHEADERS defines
  248. include Makefile.inc
  249. libcurl_dll_LIBRARY = libcurl.dll
  250. libcurl_dll_a_LIBRARY = libcurldll.a
  251. libcurl_a_LIBRARY = libcurl.a
  252. libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
  253. libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
  254. RESOURCE = libcurl.res
  255. all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
  256. $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
  257. @$(call DEL, $@)
  258. $(AR) cru $@ $(libcurl_a_OBJECTS)
  259. $(RANLIB) $@
  260. $(STRIP) $@
  261. # remove the last line above to keep debug info
  262. $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
  263. @$(call DEL, $@)
  264. $(CC) $(LDFLAGS) -shared -o $@ \
  265. -Wl,--output-def,$(@:.dll=.def),--out-implib,$(libcurl_dll_a_LIBRARY) \
  266. $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
  267. %.o: %.c $(PROOT)/include/curl/curlbuild.h
  268. $(CC) $(INCLUDES) $(CFLAGS) -c $<
  269. %.res: %.rc
  270. $(RC) $(RCFLAGS) $< -o $@
  271. clean:
  272. ifeq "$(wildcard $(PROOT)/include/curl/curlbuild.h.dist)" "$(PROOT)/include/curl/curlbuild.h.dist"
  273. @$(call DEL, $(PROOT)/include/curl/curlbuild.h)
  274. endif
  275. @$(call DEL, $(libcurl_a_OBJECTS) $(RESOURCE))
  276. distclean vclean: clean
  277. @$(call DEL, $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_LIBRARY:.dll=.def) $(libcurl_dll_a_LIBRARY))
  278. $(PROOT)/include/curl/curlbuild.h:
  279. @echo Creating $@
  280. @$(call COPY, $@.dist, $@)
  281. $(LIBCARES_PATH)/libcares.a:
  282. $(MAKE) -C $(LIBCARES_PATH) -f Makefile.m32