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