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