tizen 2.3.1 release
[external/curl.git] / docs / examples / Makefile.m32
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
9 #
10 # This software is licensed as described in the file COPYING, which
11 # you should have received as part of this distribution. The terms
12 # are also available at http://curl.haxx.se/docs/copyright.html.
13 #
14 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 # copies of the Software, and permit persons to whom the Software is
16 # furnished to do so, under the terms of the COPYING file.
17 #
18 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 # KIND, either express or implied.
20 #
21 ###########################################################################
22 #
23 ## Makefile for building curl examples with MingW (GCC-3.2 or later)
24 ## and optionally OpenSSL (0.9.8), libssh2 (1.3), zlib (1.2.5), librtmp (2.3)
25 ##
26 ## Usage:   mingw32-make -f Makefile.m32 CFG=-feature1[-feature2][-feature3][...]
27 ## Example: mingw32-make -f Makefile.m32 CFG=-zlib-ssl-spi-winidn
28 ##
29 ## Hint: you can also set environment vars to control the build, f.e.:
30 ## set ZLIB_PATH=c:/zlib-1.2.8
31 ## set ZLIB=1
32 #
33 ###########################################################################
34
35 # Edit the path below to point to the base of your Zlib sources.
36 ifndef ZLIB_PATH
37 ZLIB_PATH = ../../../zlib-1.2.8
38 endif
39 # Edit the path below to point to the base of your OpenSSL package.
40 ifndef OPENSSL_PATH
41 OPENSSL_PATH = ../../../openssl-0.9.8zc
42 endif
43 # Edit the path below to point to the base of your LibSSH2 package.
44 ifndef LIBSSH2_PATH
45 LIBSSH2_PATH = ../../../libssh2-1.4.3
46 endif
47 # Edit the path below to point to the base of your librtmp package.
48 ifndef LIBRTMP_PATH
49 LIBRTMP_PATH = ../../../librtmp-2.3
50 endif
51 # Edit the path below to point to the base of your libidn package.
52 ifndef LIBIDN_PATH
53 LIBIDN_PATH = ../../../libidn-1.18
54 endif
55 # Edit the path below to point to the base of your MS IDN package.
56 # Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1
57 # http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815
58 ifndef WINIDN_PATH
59 WINIDN_PATH = ../../../Microsoft IDN Mitigation APIs
60 endif
61 # Edit the path below to point to the base of your Novell LDAP NDK.
62 ifndef LDAP_SDK
63 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
64 endif
65
66 PROOT = ../..
67
68 # Edit the path below to point to the base of your c-ares package.
69 ifndef LIBCARES_PATH
70 LIBCARES_PATH = $(PROOT)/ares
71 endif
72
73 # Edit the var below to set to your architecture or set environment var.
74 ifndef ARCH
75 ARCH = w32
76 endif
77
78 CC      = $(CROSSPREFIX)gcc
79 CFLAGS  = -g -O2 -Wall
80 CFLAGS  += -fno-strict-aliasing
81 ifeq ($(ARCH),w64)
82 CFLAGS  += -D_AMD64_
83 endif
84 # comment LDFLAGS below to keep debug info
85 LDFLAGS = -s
86 RC      = $(CROSSPREFIX)windres
87 RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i
88
89 # Platform-dependent helper tool macros
90 ifeq ($(findstring /sh,$(SHELL)),/sh)
91 DEL     = rm -f $1
92 RMDIR   = rm -fr $1
93 MKDIR   = mkdir -p $1
94 COPY    = -cp -afv $1 $2
95 #COPYR  = -cp -afr $1/* $2
96 COPYR   = -rsync -aC $1/* $2
97 TOUCH   = touch $1
98 CAT     = cat
99 ECHONL  = echo ""
100 DL      = '
101 else
102 ifeq "$(OS)" "Windows_NT"
103 DEL     = -del 2>NUL /q /f $(subst /,\,$1)
104 RMDIR   = -rd 2>NUL /q /s $(subst /,\,$1)
105 else
106 DEL     = -del 2>NUL $(subst /,\,$1)
107 RMDIR   = -deltree 2>NUL /y $(subst /,\,$1)
108 endif
109 MKDIR   = -md 2>NUL $(subst /,\,$1)
110 COPY    = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
111 COPYR   = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
112 TOUCH   = copy 2>&1>NUL /b $(subst /,\,$1) +,,
113 CAT     = type
114 ECHONL  = $(ComSpec) /c echo.
115 endif
116
117 ########################################################
118 ## Nothing more to do below this line!
119
120 ifeq ($(findstring -dyn,$(CFG)),-dyn)
121 DYN = 1
122 endif
123 ifeq ($(findstring -ares,$(CFG)),-ares)
124 ARES = 1
125 endif
126 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
127 RTMP = 1
128 SSL = 1
129 ZLIB = 1
130 endif
131 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
132 SSH2 = 1
133 SSL = 1
134 ZLIB = 1
135 endif
136 ifeq ($(findstring -ssl,$(CFG)),-ssl)
137 SSL = 1
138 endif
139 ifeq ($(findstring -zlib,$(CFG)),-zlib)
140 ZLIB = 1
141 endif
142 ifeq ($(findstring -idn,$(CFG)),-idn)
143 IDN = 1
144 endif
145 ifeq ($(findstring -winidn,$(CFG)),-winidn)
146 WINIDN = 1
147 endif
148 ifeq ($(findstring -sspi,$(CFG)),-sspi)
149 SSPI = 1
150 endif
151 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
152 LDAPS = 1
153 endif
154 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
155 IPV6 = 1
156 endif
157 ifeq ($(findstring -metalink,$(CFG)),-metalink)
158 METALINK = 1
159 endif
160 ifeq ($(findstring -winssl,$(CFG)),-winssl)
161 SCHANNEL = 1
162 SSPI = 1
163 endif
164
165 INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib
166
167 ifdef DYN
168   curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
169   curl_LDADD = -L$(PROOT)/lib -lcurldll
170 else
171   curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
172   curl_LDADD = -L$(PROOT)/lib -lcurl
173   CFLAGS += -DCURL_STATICLIB
174   LDFLAGS += -static
175 endif
176 ifdef ARES
177   ifndef DYN
178     curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
179   endif
180   CFLAGS += -DUSE_ARES
181   curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
182 endif
183 ifdef RTMP
184   CFLAGS += -DUSE_LIBRTMP
185   curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
186 endif
187 ifdef SSH2
188   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
189   curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
190 endif
191 ifdef SSL
192   ifndef OPENSSL_LIBPATH
193     OPENSSL_LIBS = -lssl -lcrypto
194     ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
195       OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
196       ifdef DYN
197         OPENSSL_LIBS = -lssl32 -leay32
198       endif
199     endif
200     ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
201       OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
202     endif
203   endif
204   ifndef DYN
205     OPENSSL_LIBS += -lgdi32 -lcrypt32
206   endif
207   CFLAGS += -DUSE_SSLEAY
208   curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
209 endif
210 ifdef ZLIB
211   INCLUDES += -I"$(ZLIB_PATH)"
212   CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
213   curl_LDADD += -L"$(ZLIB_PATH)" -lz
214 endif
215 ifdef IDN
216   CFLAGS += -DUSE_LIBIDN
217   curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
218 else
219 ifdef WINIDN
220   CFLAGS += -DUSE_WIN32_IDN
221   curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
222 endif
223 endif
224 ifdef SSPI
225   CFLAGS += -DUSE_WINDOWS_SSPI
226   ifdef SCHANNEL
227     CFLAGS += -DUSE_SCHANNEL
228   endif
229 endif
230 ifdef IPV6
231   CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
232 endif
233 ifdef LDAPS
234   CFLAGS += -DHAVE_LDAP_SSL
235 endif
236 ifdef USE_LDAP_NOVELL
237   CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
238   curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
239 endif
240 ifdef USE_LDAP_OPENLDAP
241   CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
242   curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
243 endif
244 ifndef USE_LDAP_NOVELL
245 ifndef USE_LDAP_OPENLDAP
246   curl_LDADD += -lwldap32
247 endif
248 endif
249 curl_LDADD += -lws2_32
250
251 # Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines
252 include Makefile.inc
253
254 check_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
255 check_PROGRAMS += ftpuploadresume.exe synctime.exe
256
257 .PRECIOUS: %.o
258
259
260 all: $(check_PROGRAMS)
261
262 %.exe: %.o $(curl_DEPENDENCIES)
263         $(CC) $(LDFLAGS) -o $@ $< $(curl_LDADD)
264
265 %.o: %.c
266         $(CC) $(INCLUDES) $(CFLAGS) -c $<
267
268 %.res: %.rc
269         $(RC) $(RCFLAGS) $< -o $@
270
271 clean:
272         @$(call DEL, $(check_PROGRAMS:.exe=.o))
273
274 distclean vclean: clean
275         @$(call DEL, $(check_PROGRAMS))
276