Makefile.m32 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. #***************************************************************************
  2. # _ _ ____ _
  3. # Project ___| | | | _ \| |
  4. # / __| | | | |_) | |
  5. # | (__| |_| | _ <| |___
  6. # \___|\___/|_| \_\_____|
  7. #
  8. # Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
  9. #
  10. # This software is licensed as described in the file COPYING, which
  11. # you should have received as part of this distribution. The terms
  12. # are also available at http://curl.haxx.se/docs/copyright.html.
  13. #
  14. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  15. # copies of the Software, and permit persons to whom the Software is
  16. # furnished to do so, under the terms of the COPYING file.
  17. #
  18. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  19. # KIND, either express or implied.
  20. #
  21. ###########################################################################
  22. #
  23. ## Makefile for building curl examples with MingW (GCC-3.2 or later)
  24. ## and optionally OpenSSL (0.9.8), libssh2 (1.3), zlib (1.2.5), librtmp (2.3)
  25. ##
  26. ## Usage: mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
  27. ## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-spi-winidn
  28. ##
  29. ## Hint: you can also set environment vars to control the build, f.e.:
  30. ## set ZLIB_PATH=c:/zlib-1.2.8
  31. ## set ZLIB=1
  32. #
  33. ###########################################################################
  34. # Edit the path below to point to the base of your Zlib sources.
  35. ifndef ZLIB_PATH
  36. ZLIB_PATH = ../../../zlib-1.2.8
  37. endif
  38. # Edit the path below to point to the base of your OpenSSL package.
  39. ifndef OPENSSL_PATH
  40. OPENSSL_PATH = ../../../openssl-0.9.8y
  41. endif
  42. # Edit the path below to point to the base of your LibSSH2 package.
  43. ifndef LIBSSH2_PATH
  44. LIBSSH2_PATH = ../../../libssh2-1.4.3
  45. endif
  46. # Edit the path below to point to the base of your librtmp package.
  47. ifndef LIBRTMP_PATH
  48. LIBRTMP_PATH = ../../../librtmp-2.3
  49. endif
  50. # Edit the path below to point to the base of your libidn package.
  51. ifndef LIBIDN_PATH
  52. LIBIDN_PATH = ../../../libidn-1.18
  53. endif
  54. # Edit the path below to point to the base of your MS IDN package.
  55. # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
  56. # http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815
  57. ifndef WINIDN_PATH
  58. WINIDN_PATH = ../../../Microsoft IDN Mitigation APIs
  59. endif
  60. # Edit the path below to point to the base of your Novell LDAP NDK.
  61. ifndef LDAP_SDK
  62. LDAP_SDK = c:/novell/ndk/cldapsdk/win32
  63. endif
  64. PROOT = ../..
  65. # Edit the path below to point to the base of your c-ares package.
  66. ifndef LIBCARES_PATH
  67. LIBCARES_PATH = $(PROOT)/ares
  68. endif
  69. # Edit the var below to set to your architecture or set environment var.
  70. ifndef ARCH
  71. ARCH = w32
  72. endif
  73. CC = $(CROSSPREFIX)gcc
  74. CFLAGS = -g -O2 -Wall
  75. CFLAGS += -fno-strict-aliasing
  76. ifeq ($(ARCH),w64)
  77. CFLAGS += -D_AMD64_
  78. endif
  79. # comment LDFLAGS below to keep debug info
  80. LDFLAGS = -s
  81. RC = $(CROSSPREFIX)windres
  82. RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i
  83. # Platform-dependent helper tool macros
  84. ifeq ($(findstring /sh,$(SHELL)),/sh)
  85. DEL = rm -f $1
  86. RMDIR = rm -fr $1
  87. MKDIR = mkdir -p $1
  88. COPY = -cp -afv $1 $2
  89. #COPYR = -cp -afr $1/* $2
  90. COPYR = -rsync -aC $1/* $2
  91. TOUCH = touch $1
  92. CAT = cat
  93. ECHONL = echo ""
  94. DL = '
  95. else
  96. ifeq "$(OS)" "Windows_NT"
  97. DEL = -del 2>NUL /q /f $(subst /,\,$1)
  98. RMDIR = -rd 2>NUL /q /s $(subst /,\,$1)
  99. else
  100. DEL = -del 2>NUL $(subst /,\,$1)
  101. RMDIR = -deltree 2>NUL /y $(subst /,\,$1)
  102. endif
  103. MKDIR = -md 2>NUL $(subst /,\,$1)
  104. COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
  105. COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
  106. TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,,
  107. CAT = type
  108. ECHONL = $(ComSpec) /c echo.
  109. endif
  110. ########################################################
  111. ## Nothing more to do below this line!
  112. ifeq ($(findstring -dyn,$(CFG)),-dyn)
  113. DYN = 1
  114. endif
  115. ifeq ($(findstring -ares,$(CFG)),-ares)
  116. ARES = 1
  117. endif
  118. ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
  119. RTMP = 1
  120. SSL = 1
  121. ZLIB = 1
  122. endif
  123. ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
  124. SSH2 = 1
  125. SSL = 1
  126. ZLIB = 1
  127. endif
  128. ifeq ($(findstring -ssl,$(CFG)),-ssl)
  129. SSL = 1
  130. endif
  131. ifeq ($(findstring -zlib,$(CFG)),-zlib)
  132. ZLIB = 1
  133. endif
  134. ifeq ($(findstring -idn,$(CFG)),-idn)
  135. IDN = 1
  136. endif
  137. ifeq ($(findstring -winidn,$(CFG)),-winidn)
  138. WINIDN = 1
  139. endif
  140. ifeq ($(findstring -sspi,$(CFG)),-sspi)
  141. SSPI = 1
  142. endif
  143. ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
  144. LDAPS = 1
  145. endif
  146. ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
  147. IPV6 = 1
  148. endif
  149. ifeq ($(findstring -metalink,$(CFG)),-metalink)
  150. METALINK = 1
  151. endif
  152. ifeq ($(findstring -winssl,$(CFG)),-winssl)
  153. SCHANNEL = 1
  154. SSPI = 1
  155. endif
  156. INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib
  157. ifdef DYN
  158. curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
  159. curl_LDADD = -L$(PROOT)/lib -lcurldll
  160. else
  161. curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
  162. curl_LDADD = -L$(PROOT)/lib -lcurl
  163. CFLAGS += -DCURL_STATICLIB
  164. LDFLAGS += -static
  165. endif
  166. ifdef ARES
  167. ifndef DYN
  168. curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
  169. endif
  170. CFLAGS += -DUSE_ARES
  171. curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
  172. endif
  173. ifdef RTMP
  174. CFLAGS += -DUSE_LIBRTMP
  175. curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
  176. endif
  177. ifdef SSH2
  178. CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
  179. curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
  180. endif
  181. ifdef SSL
  182. ifndef OPENSSL_LIBPATH
  183. OPENSSL_LIBS = -lssl -lcrypto
  184. ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
  185. OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
  186. ifdef DYN
  187. OPENSSL_LIBS = -lssl32 -leay32
  188. endif
  189. endif
  190. ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
  191. OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
  192. endif
  193. endif
  194. ifndef DYN
  195. OPENSSL_LIBS += -lgdi32 -lcrypt32
  196. endif
  197. CFLAGS += -DUSE_SSLEAY
  198. curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
  199. endif
  200. ifdef ZLIB
  201. INCLUDES += -I"$(ZLIB_PATH)"
  202. CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
  203. curl_LDADD += -L"$(ZLIB_PATH)" -lz
  204. endif
  205. ifdef IDN
  206. CFLAGS += -DUSE_LIBIDN
  207. curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
  208. else
  209. ifdef WINIDN
  210. CFLAGS += -DUSE_WIN32_IDN
  211. curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
  212. endif
  213. endif
  214. ifdef SSPI
  215. CFLAGS += -DUSE_WINDOWS_SSPI
  216. ifdef SCHANNEL
  217. CFLAGS += -DUSE_SCHANNEL
  218. endif
  219. endif
  220. ifdef IPV6
  221. CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
  222. endif
  223. ifdef LDAPS
  224. CFLAGS += -DHAVE_LDAP_SSL
  225. endif
  226. ifdef USE_LDAP_NOVELL
  227. CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
  228. curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
  229. endif
  230. ifdef USE_LDAP_OPENLDAP
  231. CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
  232. curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
  233. endif
  234. ifndef USE_LDAP_NOVELL
  235. ifndef USE_LDAP_OPENLDAP
  236. curl_LDADD += -lwldap32
  237. endif
  238. endif
  239. curl_LDADD += -lws2_32
  240. # Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines
  241. include Makefile.inc
  242. check_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
  243. check_PROGRAMS += ftpuploadresume.exe synctime.exe
  244. .PRECIOUS: %.o
  245. all: $(check_PROGRAMS)
  246. %.exe: %.o $(curl_DEPENDENCIES)
  247. $(CC) $(LDFLAGS) -o $@ $< $(curl_LDADD)
  248. %.o: %.c
  249. $(CC) $(INCLUDES) $(CFLAGS) -c $<
  250. %.res: %.rc
  251. $(RC) $(RCFLAGS) $< -o $@
  252. clean:
  253. @$(call DEL, $(check_PROGRAMS:.exe=.o))
  254. distclean vclean: clean
  255. @$(call DEL, $(check_PROGRAMS))