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