schannel: remove version number and identify its use with 'schannel' literal
[platform/upstream/curl.git] / lib / Makefile.m32
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
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 libidn package.
32 ifndef LIBIDN_PATH
33 LIBIDN_PATH = ../../libidn-1.18
34 endif
35 # Edit the path below to point to the base of your MS IDN package.
36 # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
37 # http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815
38 ifndef WINIDN_PATH
39 WINIDN_PATH = ../../Microsoft IDN Mitigation APIs
40 endif
41 # Edit the path below to point to the base of your Novell LDAP NDK.
42 ifndef LDAP_SDK
43 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
44 endif
45
46 PROOT = ..
47
48 # Edit the path below to point to the base of your c-ares package.
49 ifndef LIBCARES_PATH
50 LIBCARES_PATH = $(PROOT)/ares
51 endif
52
53 # Edit the var below to set to your architecture or set environment var.
54 ifndef ARCH
55 ARCH = w32
56 endif
57
58 CC = gcc
59 CFLAGS = -g -O2 -Wall
60 CFLAGS += -fno-strict-aliasing
61 ifeq ($(ARCH),w64)
62 CFLAGS += -D_AMD64_
63 endif
64 # comment LDFLAGS below to keep debug info
65 LDFLAGS = -s
66 AR = ar
67 RANLIB = ranlib
68 RC = windres
69 RCFLAGS = --include-dir=$(PROOT)/include -DDEBUGBUILD=0 -O COFF -i
70 STRIP = strip -g
71
72 RM = del /q /f 2>NUL
73 CP = copy
74
75 ########################################################
76 ## Nothing more to do below this line!
77
78 ifeq ($(findstring -dyn,$(CFG)),-dyn)
79 DYN = 1
80 endif
81 ifeq ($(findstring -ares,$(CFG)),-ares)
82 ARES = 1
83 endif
84 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
85 RTMP = 1
86 SSL = 1
87 ZLIB = 1
88 endif
89 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
90 SSH2 = 1
91 SSL = 1
92 ZLIB = 1
93 endif
94 ifeq ($(findstring -ssl,$(CFG)),-ssl)
95 SSL = 1
96 endif
97 ifeq ($(findstring -zlib,$(CFG)),-zlib)
98 ZLIB = 1
99 endif
100 ifeq ($(findstring -idn,$(CFG)),-idn)
101 IDN = 1
102 endif
103 ifeq ($(findstring -winidn,$(CFG)),-winidn)
104 WINIDN = 1
105 endif
106 ifeq ($(findstring -sspi,$(CFG)),-sspi)
107 SSPI = 1
108 endif
109 ifeq ($(findstring -spnego,$(CFG)),-spnego)
110 SPNEGO = 1
111 endif
112 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
113 LDAPS = 1
114 endif
115 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
116 IPV6 = 1
117 endif
118 ifeq ($(findstring -schannel,$(CFG)),-schannel)
119 SCHANNEL = 1
120 SSPI = 1
121 endif
122
123 INCLUDES = -I. -I../include
124 CFLAGS += -DBUILDING_LIBCURL
125
126 ifdef ARES
127   INCLUDES += -I"$(LIBCARES_PATH)"
128   CFLAGS += -DUSE_ARES
129   DLL_LIBS += -L"$(LIBCARES_PATH)" -lcares
130   libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a
131 endif
132 ifdef RTMP
133   INCLUDES += -I"$(LIBRTMP_PATH)"
134   CFLAGS += -DUSE_LIBRTMP
135   DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
136 endif
137 ifdef SSH2
138   INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
139   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
140   DLL_LIBS += -L"$(LIBSSH2_PATH)/win32" -lssh2
141 endif
142 ifdef SSL
143   ifndef OPENSSL_INCLUDE
144     ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc"
145       OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc
146     endif
147     ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include"
148       OPENSSL_INCLUDE = $(OPENSSL_PATH)/include
149     endif
150   endif
151   ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h"
152   $(error Invalid path to OpenSSL package: $(OPENSSL_PATH))
153   endif
154   ifndef OPENSSL_LIBPATH
155     ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
156       OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
157       OPENSSL_LIBS = -leay32 -lssl32
158     endif
159     ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
160       OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
161       OPENSSL_LIBS = -lcrypto -lssl
162     endif
163   endif
164   INCLUDES += -I"$(OPENSSL_INCLUDE)"
165   CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \
166             -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 \
167             -DCURL_WANTS_CA_BUNDLE_ENV
168   DLL_LIBS += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
169 endif
170 ifdef ZLIB
171   INCLUDES += -I"$(ZLIB_PATH)"
172   CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
173   DLL_LIBS += -L"$(ZLIB_PATH)" -lz
174 endif
175 ifdef IDN
176   INCLUDES += -I"$(LIBIDN_PATH)/include"
177   CFLAGS += -DUSE_LIBIDN
178   DLL_LIBS += -L"$(LIBIDN_PATH)/lib" -lidn
179 else
180 ifdef WINIDN
181   CFLAGS += -DUSE_WIN32_IDN
182   CFLAGS += -DWANT_IDN_PROTOTYPES
183   DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz
184 endif
185 endif
186 ifdef SSPI
187   CFLAGS += -DUSE_WINDOWS_SSPI
188 ifdef SCHANNEL
189   CFLAGS += -DUSE_SCHANNEL
190 endif
191 endif
192 ifdef SPNEGO
193   CFLAGS += -DHAVE_SPNEGO
194 endif
195 ifdef IPV6
196   CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
197 endif
198 ifdef LDAPS
199   CFLAGS += -DHAVE_LDAP_SSL
200 endif
201 ifdef USE_LDAP_NOVELL
202   INCLUDES += -I"$(LDAP_SDK)/inc"
203   CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
204   DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
205 endif
206 ifdef USE_LDAP_OPENLDAP
207   INCLUDES += -I"$(LDAP_SDK)/include"
208   CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
209   DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
210 endif
211 ifndef USE_LDAP_NOVELL
212 ifndef USE_LDAP_OPENLDAP
213   DLL_LIBS += -lwldap32
214 endif
215 endif
216 DLL_LIBS += -lws2_32
217
218 # Makefile.inc provides the CSOURCES and HHEADERS defines
219 include Makefile.inc
220
221 libcurl_dll_LIBRARY = libcurl.dll
222 libcurl_dll_a_LIBRARY = libcurldll.a
223 libcurl_a_LIBRARY = libcurl.a
224
225 libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
226 libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
227
228 RESOURCE = libcurl.res
229
230
231 all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
232
233 $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
234         -$(RM) $@
235         $(AR) cru $@ $(libcurl_a_OBJECTS)
236         $(RANLIB) $@
237         $(STRIP) $@
238
239 # remove the last line above to keep debug info
240
241 $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
242         -$(RM) $@
243         $(CC) $(LDFLAGS) -shared -Wl,--out-implib,$(libcurl_dll_a_LIBRARY) \
244           -o $@ $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
245
246 %.o: %.c $(PROOT)/include/curl/curlbuild.h
247         $(CC) $(INCLUDES) $(CFLAGS) -c $<
248
249 %.res: %.rc
250         $(RC) $(RCFLAGS) $< -o $@
251
252 clean:
253 ifeq "$(wildcard $(PROOT)/include/curl/curlbuild.h.dist)" "$(PROOT)/include/curl/curlbuild.h.dist"
254         -$(RM) $(subst /,\,$(PROOT)/include/curl/curlbuild.h)
255 endif
256         -$(RM) $(libcurl_a_OBJECTS) $(RESOURCE)
257
258 distclean vclean: clean
259         -$(RM) $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_a_LIBRARY)
260
261 $(LIBCARES_PATH)/libcares.a:
262         $(MAKE) -C $(LIBCARES_PATH) -f Makefile.m32
263
264 $(PROOT)/include/curl/curlbuild.h:
265         @echo Creating $@
266         @$(CP) $(subst /,\,$@).dist $(subst /,\,$@)
267