Try to detect OpenSSL build type automatically.
[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 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 RC = windres
67 RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i
68
69 RM = del /q /f 2>NUL
70 CP = copy
71
72 # We may need these someday
73 # PERL = perl
74 # NROFF = nroff
75
76 ########################################################
77 ## Nothing more to do below this line!
78
79 ifeq ($(findstring -dyn,$(CFG)),-dyn)
80 DYN = 1
81 endif
82 ifeq ($(findstring -ares,$(CFG)),-ares)
83 ARES = 1
84 endif
85 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
86 RTMP = 1
87 SSL = 1
88 ZLIB = 1
89 endif
90 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
91 SSH2 = 1
92 SSL = 1
93 ZLIB = 1
94 endif
95 ifeq ($(findstring -ssl,$(CFG)),-ssl)
96 SSL = 1
97 endif
98 ifeq ($(findstring -zlib,$(CFG)),-zlib)
99 ZLIB = 1
100 endif
101 ifeq ($(findstring -idn,$(CFG)),-idn)
102 IDN = 1
103 endif
104 ifeq ($(findstring -winidn,$(CFG)),-winidn)
105 WINIDN = 1
106 endif
107 ifeq ($(findstring -sspi,$(CFG)),-sspi)
108 SSPI = 1
109 endif
110 ifeq ($(findstring -spnego,$(CFG)),-spnego)
111 SPNEGO = 1
112 endif
113 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
114 LDAPS = 1
115 endif
116 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
117 IPV6 = 1
118 endif
119
120 INCLUDES = -I. -I.. -I../include -I../lib
121
122 ifdef DYN
123   curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
124   curl_LDADD = -L$(PROOT)/lib -lcurldll
125 else
126   curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
127   curl_LDADD = -L$(PROOT)/lib -lcurl
128   CFLAGS += -DCURL_STATICLIB
129 endif
130 ifdef ARES
131   ifndef DYN
132     curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
133   endif
134   CFLAGS += -DUSE_ARES
135   curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
136 endif
137 ifdef RTMP
138   CFLAGS += -DUSE_LIBRTMP
139   curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
140 endif
141 ifdef SSH2
142   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
143   curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
144 endif
145 ifdef SSL
146   ifndef OPENSSL_LIBPATH
147     ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
148       OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
149       OPENSSL_LIBS = -leay32 -lssl32
150     endif
151     ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
152       OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
153       OPENSSL_LIBS = -lcrypto -lssl
154     endif
155   endif
156   CFLAGS += -DUSE_SSLEAY -DHAVE_OPENSSL_ENGINE_H
157   curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
158 endif
159 ifdef ZLIB
160   INCLUDES += -I"$(ZLIB_PATH)"
161   CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
162   curl_LDADD += -L"$(ZLIB_PATH)" -lz
163 endif
164 ifdef IDN
165   CFLAGS += -DUSE_LIBIDN
166   curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
167 else
168 ifdef WINIDN
169   CFLAGS += -DUSE_WIN32_IDN
170   curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
171 endif
172 endif
173 ifdef SSPI
174   CFLAGS += -DUSE_WINDOWS_SSPI
175 endif
176 ifdef SPNEGO
177   CFLAGS += -DHAVE_SPNEGO
178 endif
179 ifdef IPV6
180   CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
181 endif
182 ifdef LDAPS
183   CFLAGS += -DHAVE_LDAP_SSL
184 endif
185 ifdef USE_LDAP_NOVELL
186   CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
187   curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
188 endif
189 ifdef USE_LDAP_OPENLDAP
190   CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
191   curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
192 endif
193 ifndef USE_LDAP_NOVELL
194 ifndef USE_LDAP_OPENLDAP
195 curl_LDADD += -lwldap32
196 endif
197 endif
198 curl_LDADD += -lws2_32
199
200 # Makefile.inc provides the CSOURCES and HHEADERS defines
201 include Makefile.inc
202
203 curl_PROGRAMS = curl.exe
204 curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES)))
205 curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_ONES))))
206 ifdef DYN
207 curl_OBJECTS += $(curlx_OBJECTS)
208 vpath %.c $(PROOT)/lib
209 endif
210
211 RESOURCE = curl.res
212
213
214 all: $(curl_PROGRAMS)
215
216 curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES)
217         -$(RM) $@
218         $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD)
219
220 # We don't have nroff normally under win32
221 # hugehelp.c: $(PROOT)/README.curl $(PROOT)/curl.1 mkhelp.pl
222 #       -$(RM) hugehelp.c
223 #       $(NROFF) -man $(PROOT)/curl.1 | $(PERL) mkhelp.pl $(PROOT)/README.curl > hugehelp.c
224
225 hugehelp.c:
226         @echo Creating $@
227         @$(CP) hugehelp.c.cvs $@
228
229 %.o: %.c
230         $(CC) $(INCLUDES) $(CFLAGS) -c $<
231
232 %.res: %.rc
233         $(RC) $(RCFLAGS) $< -o $@
234
235 clean:
236 ifeq "$(wildcard hugehelp.c.cvs)" "hugehelp.c.cvs"
237         -$(RM) hugehelp.c
238 endif
239         -$(RM) $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE)
240
241 distclean vclean: clean
242         -$(RM) $(curl_PROGRAMS)
243