Makefile.m32 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. ###########################################################################
  2. #
  3. ## Makefile for building curl.exe 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-spi-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 libmetalink package.
  31. ifndef LIBMETALINK_PATH
  32. LIBMETALINK_PATH = ../../libmetalink-0.1.2
  33. endif
  34. # Edit the path below to point to the base of your libexpat package.
  35. ifndef LIBEXPAT_PATH
  36. LIBEXPAT_PATH = ../../expat-2.1.0
  37. endif
  38. # Edit the path below to point to the base of your libxml2 package.
  39. ifndef LIBXML2_PATH
  40. LIBXML2_PATH = ../../libxml2-2.9.0
  41. endif
  42. # Edit the path below to point to the base of your libidn package.
  43. ifndef LIBIDN_PATH
  44. LIBIDN_PATH = ../../libidn-1.18
  45. endif
  46. # Edit the path below to point to the base of your MS IDN package.
  47. # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
  48. # http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815
  49. ifndef WINIDN_PATH
  50. WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
  51. endif
  52. # Edit the path below to point to the base of your Novell LDAP NDK.
  53. ifndef LDAP_SDK
  54. LDAP_SDK = c:/novell/ndk/cldapsdk/win32
  55. endif
  56. PROOT = ..
  57. # Edit the path below to point to the base of your c-ares package.
  58. ifndef LIBCARES_PATH
  59. LIBCARES_PATH = $(PROOT)/ares
  60. endif
  61. # Edit the var below to set to your architecture or set environment var.
  62. ifndef ARCH
  63. ARCH = w32
  64. endif
  65. CC = $(CROSSPREFIX)gcc
  66. CFLAGS = -g -O2 -Wall
  67. CFLAGS += -fno-strict-aliasing
  68. ifeq ($(ARCH),w64)
  69. CFLAGS += -D_AMD64_
  70. endif
  71. # comment LDFLAGS below to keep debug info
  72. LDFLAGS = -s
  73. AR = $(CROSSPREFIX)ar
  74. RC = $(CROSSPREFIX)windres
  75. RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i
  76. # We may need these someday
  77. # PERL = perl
  78. # NROFF = nroff
  79. # Platform-dependent helper tool macros
  80. ifeq ($(findstring /sh,$(SHELL)),/sh)
  81. DEL = rm -f $1
  82. RMDIR = rm -fr $1
  83. MKDIR = mkdir -p $1
  84. COPY = -cp -afv $1 $2
  85. #COPYR = -cp -afr $1/* $2
  86. COPYR = -rsync -aC $1/* $2
  87. TOUCH = touch $1
  88. CAT = cat
  89. ECHONL = echo ""
  90. DL = '
  91. else
  92. ifeq "$(OS)" "Windows_NT"
  93. DEL = -del 2>NUL /q /f $(subst /,\,$1)
  94. RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
  95. else
  96. DEL = -del 2>NUL $(subst /,\,$1)
  97. RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
  98. endif
  99. MKDIR = -md 2>NUL $(subst /,\,$1)
  100. COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
  101. COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
  102. TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
  103. CAT = type
  104. ECHONL = $(ComSpec) /c echo.
  105. endif
  106. ########################################################
  107. ## Nothing more to do below this line!
  108. ifeq ($(findstring -dyn,$(CFG)),-dyn)
  109. DYN = 1
  110. endif
  111. ifeq ($(findstring -ares,$(CFG)),-ares)
  112. ARES = 1
  113. endif
  114. ifeq ($(findstring -sync,$(CFG)),-sync)
  115. SYNC = 1
  116. endif
  117. ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
  118. RTMP = 1
  119. SSL = 1
  120. ZLIB = 1
  121. endif
  122. ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
  123. SSH2 = 1
  124. SSL = 1
  125. ZLIB = 1
  126. endif
  127. ifeq ($(findstring -ssl,$(CFG)),-ssl)
  128. SSL = 1
  129. endif
  130. ifeq ($(findstring -zlib,$(CFG)),-zlib)
  131. ZLIB = 1
  132. endif
  133. ifeq ($(findstring -idn,$(CFG)),-idn)
  134. IDN = 1
  135. endif
  136. ifeq ($(findstring -winidn,$(CFG)),-winidn)
  137. WINIDN = 1
  138. endif
  139. ifeq ($(findstring -sspi,$(CFG)),-sspi)
  140. SSPI = 1
  141. endif
  142. ifeq ($(findstring -spnego,$(CFG)),-spnego)
  143. SPNEGO = 1
  144. endif
  145. ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
  146. LDAPS = 1
  147. endif
  148. ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
  149. IPV6 = 1
  150. endif
  151. ifeq ($(findstring -metalink,$(CFG)),-metalink)
  152. METALINK = 1
  153. endif
  154. ifeq ($(findstring -winssl,$(CFG)),-winssl)
  155. WINSSL = 1
  156. SSPI = 1
  157. endif
  158. INCLUDES = -I. -I../include -I../lib
  159. ifdef DYN
  160. curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
  161. curl_LDADD = -L$(PROOT)/lib -lcurldll
  162. else
  163. curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
  164. curl_LDADD = -L$(PROOT)/lib -lcurl
  165. CFLAGS += -DCURL_STATICLIB
  166. LDFLAGS += -static
  167. endif
  168. ifdef SYNC
  169. CFLAGS += -DUSE_SYNC_DNS
  170. else
  171. ifdef ARES
  172. ifndef DYN
  173. curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
  174. endif
  175. CFLAGS += -DUSE_ARES -DCARES_STATICLIB
  176. curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
  177. endif
  178. endif
  179. ifdef RTMP
  180. CFLAGS += -DUSE_LIBRTMP
  181. curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
  182. endif
  183. ifdef SSH2
  184. CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
  185. curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
  186. endif
  187. ifdef SSL
  188. ifndef OPENSSL_INCLUDE
  189. ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
  190. OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
  191. endif
  192. ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
  193. OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
  194. endif
  195. endif
  196. ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
  197. $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
  198. endif
  199. ifndef OPENSSL_LIBPATH
  200. OPENSSL_LIBS = -lssl -lcrypto
  201. ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
  202. OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
  203. ifdef DYN
  204. OPENSSL_LIBS = -lssl32 -leay32
  205. endif
  206. endif
  207. ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
  208. OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
  209. endif
  210. endif
  211. ifndef DYN
  212. OPENSSL_LIBS += -lgdi32 -lcrypt32
  213. endif
  214. INCLUDES += -I"$(OPENSSL_INCLUDE)"
  215. CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL
  216. curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
  217. endif
  218. ifdef ZLIB
  219. INCLUDES += -I"$(ZLIB_PATH)"
  220. CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
  221. curl_LDADD += -L"$(ZLIB_PATH)" -lz
  222. endif
  223. ifdef IDN
  224. CFLAGS += -DUSE_LIBIDN
  225. curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
  226. else
  227. ifdef WINIDN
  228. CFLAGS += -DUSE_WIN32_IDN
  229. curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
  230. endif
  231. endif
  232. ifdef METALINK
  233. INCLUDES += -I"$(LIBMETALINK_PATH)/include"
  234. CFLAGS += -DUSE_METALINK
  235. curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink
  236. ifndef DYN
  237. ifeq ($(findstring libexpat_metalink_parser.o,$(shell $(AR) t "$(LIBMETALINK_PATH)/lib/libmetalink.a")),libexpat_metalink_parser.o)
  238. curl_LDADD += -L"$(LIBEXPAT_PATH)/lib" -lexpat
  239. else
  240. curl_LDADD += -L"$(LIBXML2_PATH)/lib" -lxml2
  241. endif
  242. endif
  243. endif
  244. ifdef SSPI
  245. CFLAGS += -DUSE_WINDOWS_SSPI
  246. ifdef WINSSL
  247. CFLAGS += -DUSE_SCHANNEL
  248. endif
  249. endif
  250. ifdef SPNEGO
  251. CFLAGS += -DHAVE_SPNEGO
  252. endif
  253. ifdef IPV6
  254. CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
  255. endif
  256. ifdef LDAPS
  257. CFLAGS += -DHAVE_LDAP_SSL
  258. endif
  259. ifdef USE_LDAP_NOVELL
  260. CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
  261. curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
  262. endif
  263. ifdef USE_LDAP_OPENLDAP
  264. CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
  265. curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
  266. endif
  267. ifndef USE_LDAP_NOVELL
  268. ifndef USE_LDAP_OPENLDAP
  269. curl_LDADD += -lwldap32
  270. endif
  271. endif
  272. curl_LDADD += -lws2_32
  273. # Makefile.inc provides the CSOURCES and HHEADERS defines
  274. include Makefile.inc
  275. curl_PROGRAMS = curl.exe
  276. curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
  277. curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES))))
  278. ifdef DYN
  279. curl_OBJECTS += $(curlx_OBJECTS)
  280. vpath %.c $(PROOT)/lib
  281. endif
  282. RESOURCE = curl.res
  283. all: $(curl_PROGRAMS)
  284. curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES)
  285. $(call DEL, $@)
  286. $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD)
  287. # We don't have nroff normally under win32
  288. # tool_hugehelp.c: $(PROOT)/docs/MANUAL $(PROOT)/docs/curl.1 mkhelp.pl
  289. # @$(call DEL, tool_hugehelp.c)
  290. # $(NROFF) -man $(PROOT)/docs/curl.1 | $(PERL) mkhelp.pl $(PROOT)/docs/MANUAL > tool_hugehelp.c
  291. tool_hugehelp.c:
  292. @echo Creating $@
  293. @$(call COPY, $@.cvs, $@)
  294. %.o: %.c
  295. $(CC) $(INCLUDES) $(CFLAGS) -c $<
  296. %.res: %.rc
  297. $(RC) $(RCFLAGS) $< -o $@
  298. clean:
  299. ifeq "$(wildcard tool_hugehelp.c.cvs)" "tool_hugehelp.c.cvs"
  300. @$(call DEL, tool_hugehelp.c)
  301. endif
  302. @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE))
  303. distclean vclean: clean
  304. @$(call DEL, $(curl_PROGRAMS))