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. 36ifndef ZLIB_PATH 37ZLIB_PATH = ../../../zlib-1.2.8 38endif 39# Edit the path below to point to the base of your OpenSSL package. 40ifndef OPENSSL_PATH 41OPENSSL_PATH = ../../../openssl-0.9.8y 42endif 43# Edit the path below to point to the base of your LibSSH2 package. 44ifndef LIBSSH2_PATH 45LIBSSH2_PATH = ../../../libssh2-1.4.3 46endif 47# Edit the path below to point to the base of your librtmp package. 48ifndef LIBRTMP_PATH 49LIBRTMP_PATH = ../../../librtmp-2.3 50endif 51# Edit the path below to point to the base of your libidn package. 52ifndef LIBIDN_PATH 53LIBIDN_PATH = ../../../libidn-1.18 54endif 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 58ifndef WINIDN_PATH 59WINIDN_PATH = ../../../Microsoft IDN Mitigation APIs 60endif 61# Edit the path below to point to the base of your Novell LDAP NDK. 62ifndef LDAP_SDK 63LDAP_SDK = c:/novell/ndk/cldapsdk/win32 64endif 65 66PROOT = ../.. 67 68# Edit the path below to point to the base of your c-ares package. 69ifndef LIBCARES_PATH 70LIBCARES_PATH = $(PROOT)/ares 71endif 72 73# Edit the var below to set to your architecture or set environment var. 74ifndef ARCH 75ARCH = w32 76endif 77 78CC = $(CROSSPREFIX)gcc 79CFLAGS = -g -O2 -Wall 80CFLAGS += -fno-strict-aliasing 81ifeq ($(ARCH),w64) 82CFLAGS += -D_AMD64_ 83endif 84# comment LDFLAGS below to keep debug info 85LDFLAGS = -s 86RC = $(CROSSPREFIX)windres 87RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i 88 89# Platform-dependent helper tool macros 90ifeq ($(findstring /sh,$(SHELL)),/sh) 91DEL = rm -f $1 92RMDIR = rm -fr $1 93MKDIR = mkdir -p $1 94COPY = -cp -afv $1 $2 95#COPYR = -cp -afr $1/* $2 96COPYR = -rsync -aC $1/* $2 97TOUCH = touch $1 98CAT = cat 99ECHONL = echo "" 100DL = ' 101else 102ifeq "$(OS)" "Windows_NT" 103DEL = -del 2>NUL /q /f $(subst /,\,$1) 104RMDIR = -rd 2>NUL /q /s $(subst /,\,$1) 105else 106DEL = -del 2>NUL $(subst /,\,$1) 107RMDIR = -deltree 2>NUL /y $(subst /,\,$1) 108endif 109MKDIR = -md 2>NUL $(subst /,\,$1) 110COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2) 111COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2) 112TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,, 113CAT = type 114ECHONL = $(ComSpec) /c echo. 115endif 116 117######################################################## 118## Nothing more to do below this line! 119 120ifeq ($(findstring -dyn,$(CFG)),-dyn) 121DYN = 1 122endif 123ifeq ($(findstring -ares,$(CFG)),-ares) 124ARES = 1 125endif 126ifeq ($(findstring -rtmp,$(CFG)),-rtmp) 127RTMP = 1 128SSL = 1 129ZLIB = 1 130endif 131ifeq ($(findstring -ssh2,$(CFG)),-ssh2) 132SSH2 = 1 133SSL = 1 134ZLIB = 1 135endif 136ifeq ($(findstring -ssl,$(CFG)),-ssl) 137SSL = 1 138endif 139ifeq ($(findstring -zlib,$(CFG)),-zlib) 140ZLIB = 1 141endif 142ifeq ($(findstring -idn,$(CFG)),-idn) 143IDN = 1 144endif 145ifeq ($(findstring -winidn,$(CFG)),-winidn) 146WINIDN = 1 147endif 148ifeq ($(findstring -sspi,$(CFG)),-sspi) 149SSPI = 1 150endif 151ifeq ($(findstring -spnego,$(CFG)),-spnego) 152SPNEGO = 1 153endif 154ifeq ($(findstring -ldaps,$(CFG)),-ldaps) 155LDAPS = 1 156endif 157ifeq ($(findstring -ipv6,$(CFG)),-ipv6) 158IPV6 = 1 159endif 160ifeq ($(findstring -metalink,$(CFG)),-metalink) 161METALINK = 1 162endif 163ifeq ($(findstring -winssl,$(CFG)),-winssl) 164SCHANNEL = 1 165SSPI = 1 166endif 167 168INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib 169 170ifdef DYN 171 curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll 172 curl_LDADD = -L$(PROOT)/lib -lcurldll 173else 174 curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a 175 curl_LDADD = -L$(PROOT)/lib -lcurl 176 CFLAGS += -DCURL_STATICLIB 177 LDFLAGS += -static 178endif 179ifdef ARES 180 ifndef DYN 181 curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a 182 endif 183 CFLAGS += -DUSE_ARES 184 curl_LDADD += -L"$(LIBCARES_PATH)" -lcares 185endif 186ifdef RTMP 187 CFLAGS += -DUSE_LIBRTMP 188 curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm 189endif 190ifdef SSH2 191 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H 192 curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2 193endif 194ifdef SSL 195 ifndef OPENSSL_LIBPATH 196 OPENSSL_LIBS = -lssl -lcrypto 197 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out" 198 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out 199 ifdef DYN 200 OPENSSL_LIBS = -lssl32 -leay32 201 endif 202 endif 203 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib" 204 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib 205 endif 206 endif 207 ifndef DYN 208 OPENSSL_LIBS += -lgdi32 -lcrypt32 209 endif 210 CFLAGS += -DUSE_SSLEAY 211 curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS) 212endif 213ifdef ZLIB 214 INCLUDES += -I"$(ZLIB_PATH)" 215 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H 216 curl_LDADD += -L"$(ZLIB_PATH)" -lz 217endif 218ifdef IDN 219 CFLAGS += -DUSE_LIBIDN 220 curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn 221else 222ifdef WINIDN 223 CFLAGS += -DUSE_WIN32_IDN 224 curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz 225endif 226endif 227ifdef SSPI 228 CFLAGS += -DUSE_WINDOWS_SSPI 229 ifdef SCHANNEL 230 CFLAGS += -DUSE_SCHANNEL 231 endif 232endif 233ifdef SPNEGO 234 CFLAGS += -DHAVE_SPNEGO 235endif 236ifdef IPV6 237 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501 238endif 239ifdef LDAPS 240 CFLAGS += -DHAVE_LDAP_SSL 241endif 242ifdef USE_LDAP_NOVELL 243 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK 244 curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx 245endif 246ifdef USE_LDAP_OPENLDAP 247 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK 248 curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber 249endif 250ifndef USE_LDAP_NOVELL 251ifndef USE_LDAP_OPENLDAP 252 curl_LDADD += -lwldap32 253endif 254endif 255curl_LDADD += -lws2_32 256 257# Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines 258include Makefile.inc 259 260check_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS))) 261check_PROGRAMS += ftpuploadresume.exe synctime.exe 262 263.PRECIOUS: %.o 264 265 266all: $(check_PROGRAMS) 267 268%.exe: %.o $(curl_DEPENDENCIES) 269 $(CC) $(LDFLAGS) -o $@ $< $(curl_LDADD) 270 271%.o: %.c 272 $(CC) $(INCLUDES) $(CFLAGS) -c $< 273 274%.res: %.rc 275 $(RC) $(RCFLAGS) $< -o $@ 276 277clean: 278 @$(call DEL, $(check_PROGRAMS:.exe=.o)) 279 280distclean vclean: clean 281 @$(call DEL, $(check_PROGRAMS)) 282 283