Imported Upstream version 7.48.0
[platform/upstream/curl.git] / docs / examples / Makefile.m32
1 #***************************************************************************
2 #                                  _   _ ____  _
3 #  Project                     ___| | | |  _ \| |
4 #                             / __| | | | |_) | |
5 #                            | (__| |_| |  _ <| |___
6 #                             \___|\___/|_| \_\_____|
7 #
8 # Copyright (C) 1998 - 2015, 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 https://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 (1.0.2a), libssh2 (1.5), zlib (1.2.8), librtmp (2.4)
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-1.0.2a
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.5.0
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.4
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.32
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 # https://www.microsoft.com/en-us/download/details.aspx?id=734
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 # Edit the path below to point to the base of your nghttp2 package.
66 ifndef NGHTTP2_PATH
67 NGHTTP2_PATH = ../../../nghttp2-1.0.0
68 endif
69
70 PROOT = ../..
71
72 # Edit the path below to point to the base of your c-ares package.
73 ifndef LIBCARES_PATH
74 LIBCARES_PATH = $(PROOT)/ares
75 endif
76
77 # Edit the var below to set to your architecture or set environment var.
78 ifndef ARCH
79 ifeq ($(findstring x86_64,$(shell $(CC) -dumpmachine)),x86_64)
80 ARCH    = w64
81 else
82 ARCH    = w32
83 endif
84 endif
85
86 CC      = $(CROSSPREFIX)gcc
87 CFLAGS  = -g -O2 -Wall
88 CFLAGS  += -fno-strict-aliasing
89 ifeq ($(ARCH),w64)
90 CFLAGS  += -m64 -D_AMD64_
91 LDFLAGS += -m64
92 RCFLAGS += -F pe-x86-64
93 else
94 CFLAGS  += -m32
95 LDFLAGS += -m32
96 RCFLAGS += -F pe-i386
97 endif
98 # comment LDFLAGS below to keep debug info
99 LDFLAGS = -s
100 RC      = $(CROSSPREFIX)windres
101 RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i
102
103 # Platform-dependent helper tool macros
104 ifeq ($(findstring /sh,$(SHELL)),/sh)
105 DEL     = rm -f $1
106 RMDIR   = rm -fr $1
107 MKDIR   = mkdir -p $1
108 COPY    = -cp -afv $1 $2
109 #COPYR  = -cp -afr $1/* $2
110 COPYR   = -rsync -aC $1/* $2
111 TOUCH   = touch $1
112 CAT     = cat
113 ECHONL  = echo ""
114 DL      = '
115 else
116 ifeq "$(OS)" "Windows_NT"
117 DEL     = -del 2>NUL /q /f $(subst /,\,$1)
118 RMDIR   = -rd 2>NUL /q /s $(subst /,\,$1)
119 else
120 DEL     = -del 2>NUL $(subst /,\,$1)
121 RMDIR   = -deltree 2>NUL /y $(subst /,\,$1)
122 endif
123 MKDIR   = -md 2>NUL $(subst /,\,$1)
124 COPY    = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2)
125 COPYR   = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2)
126 TOUCH   = copy 2>&1>NUL /b $(subst /,\,$1) +,,
127 CAT     = type
128 ECHONL  = $(ComSpec) /c echo.
129 endif
130
131 ########################################################
132 ## Nothing more to do below this line!
133
134 ifeq ($(findstring -dyn,$(CFG)),-dyn)
135 DYN = 1
136 endif
137 ifeq ($(findstring -ares,$(CFG)),-ares)
138 ARES = 1
139 endif
140 ifeq ($(findstring -rtmp,$(CFG)),-rtmp)
141 RTMP = 1
142 SSL = 1
143 ZLIB = 1
144 endif
145 ifeq ($(findstring -ssh2,$(CFG)),-ssh2)
146 SSH2 = 1
147 SSL = 1
148 ZLIB = 1
149 endif
150 ifeq ($(findstring -ssl,$(CFG)),-ssl)
151 SSL = 1
152 endif
153 ifeq ($(findstring -zlib,$(CFG)),-zlib)
154 ZLIB = 1
155 endif
156 ifeq ($(findstring -idn,$(CFG)),-idn)
157 IDN = 1
158 endif
159 ifeq ($(findstring -winidn,$(CFG)),-winidn)
160 WINIDN = 1
161 endif
162 ifeq ($(findstring -sspi,$(CFG)),-sspi)
163 SSPI = 1
164 endif
165 ifeq ($(findstring -ldaps,$(CFG)),-ldaps)
166 LDAPS = 1
167 endif
168 ifeq ($(findstring -ipv6,$(CFG)),-ipv6)
169 IPV6 = 1
170 endif
171 ifeq ($(findstring -metalink,$(CFG)),-metalink)
172 METALINK = 1
173 endif
174 ifeq ($(findstring -winssl,$(CFG)),-winssl)
175 WINSSL = 1
176 SSPI = 1
177 endif
178 ifeq ($(findstring -nghttp2,$(CFG)),-nghttp2)
179 NGHTTP2 = 1
180 endif
181
182 INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib
183
184 ifdef DYN
185   curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
186   curl_LDADD = -L$(PROOT)/lib -lcurldll
187 else
188   curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
189   curl_LDADD = -L$(PROOT)/lib -lcurl
190   CFLAGS += -DCURL_STATICLIB
191   LDFLAGS += -static
192 endif
193 ifdef ARES
194   ifndef DYN
195     curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a
196   endif
197   CFLAGS += -DUSE_ARES
198   curl_LDADD += -L"$(LIBCARES_PATH)" -lcares
199 endif
200 ifdef RTMP
201   CFLAGS += -DUSE_LIBRTMP
202   curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
203 endif
204 ifdef NGHTTP2
205   CFLAGS += -DUSE_NGHTTP2
206   curl_LDADD += -L"$(NGHTTP2_PATH)/lib" -lnghttp2
207 endif
208 ifdef SSH2
209   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
210   curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2
211 endif
212 ifdef SSL
213   ifndef OPENSSL_LIBPATH
214     OPENSSL_LIBS = -lssl -lcrypto
215     ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out"
216       OPENSSL_LIBPATH = $(OPENSSL_PATH)/out
217       ifdef DYN
218         OPENSSL_LIBS = -lssl32 -leay32
219       endif
220     endif
221     ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib"
222       OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib
223     endif
224   endif
225   ifndef DYN
226     OPENSSL_LIBS += -lgdi32 -lcrypt32
227   endif
228   CFLAGS += -DUSE_OPENSSL
229   curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS)
230 endif
231 ifdef ZLIB
232   INCLUDES += -I"$(ZLIB_PATH)"
233   CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
234   curl_LDADD += -L"$(ZLIB_PATH)" -lz
235 endif
236 ifdef IDN
237   CFLAGS += -DUSE_LIBIDN
238   curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn
239 else
240 ifdef WINIDN
241   CFLAGS += -DUSE_WIN32_IDN
242   curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz
243 endif
244 endif
245 ifdef SSPI
246   CFLAGS += -DUSE_WINDOWS_SSPI
247   ifdef WINSSL
248     CFLAGS += -DUSE_SCHANNEL
249   endif
250 endif
251 ifdef IPV6
252   CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501
253 endif
254 ifdef LDAPS
255   CFLAGS += -DHAVE_LDAP_SSL
256 endif
257 ifdef USE_LDAP_NOVELL
258   CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
259   curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
260 endif
261 ifdef USE_LDAP_OPENLDAP
262   CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
263   curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
264 endif
265 ifndef USE_LDAP_NOVELL
266 ifndef USE_LDAP_OPENLDAP
267   curl_LDADD += -lwldap32
268 endif
269 endif
270 curl_LDADD += -lws2_32
271
272 # Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines
273 include Makefile.inc
274
275 check_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
276 check_PROGRAMS += ftpuploadresume.exe synctime.exe
277
278 .PRECIOUS: %.o
279
280
281 all: $(check_PROGRAMS)
282
283 %.exe: %.o $(curl_DEPENDENCIES)
284         $(CC) $(LDFLAGS) -o $@ $< $(curl_LDADD)
285
286 %.o: %.c
287         $(CC) $(INCLUDES) $(CFLAGS) -c $<
288
289 %.res: %.rc
290         $(RC) $(RCFLAGS) $< -o $@
291
292 clean:
293         @$(call DEL, $(check_PROGRAMS:.exe=.o))
294
295 distclean vclean: clean
296         @$(call DEL, $(check_PROGRAMS))
297