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