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.8 11## set ZLIB=1 12# 13########################################################################### 14 15# Edit the path below to point to the base of your Zlib sources. 16ifndef ZLIB_PATH 17ZLIB_PATH = ../../zlib-1.2.8 18endif 19# Edit the path below to point to the base of your OpenSSL package. 20ifndef OPENSSL_PATH 21OPENSSL_PATH = ../../openssl-0.9.8y 22endif 23# Edit the path below to point to the base of your LibSSH2 package. 24ifndef LIBSSH2_PATH 25LIBSSH2_PATH = ../../libssh2-1.4.3 26endif 27# Edit the path below to point to the base of your librtmp package. 28ifndef LIBRTMP_PATH 29LIBRTMP_PATH = ../../librtmp-2.3 30endif 31# Edit the path below to point to the base of your libmetalink package. 32ifndef LIBMETALINK_PATH 33LIBMETALINK_PATH = ../../libmetalink-0.1.2 34endif 35# Edit the path below to point to the base of your libexpat package. 36ifndef LIBEXPAT_PATH 37LIBEXPAT_PATH = ../../expat-2.1.0 38endif 39# Edit the path below to point to the base of your libxml2 package. 40ifndef LIBXML2_PATH 41LIBXML2_PATH = ../../libxml2-2.9.0 42endif 43# Edit the path below to point to the base of your libidn package. 44ifndef LIBIDN_PATH 45LIBIDN_PATH = ../../libidn-1.18 46endif 47# Edit the path below to point to the base of your MS IDN package. 48# Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1 49# http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815 50ifndef WINIDN_PATH 51WINIDN_PATH = ../../Microsoft IDN Mitigation APIs 52endif 53# Edit the path below to point to the base of your Novell LDAP NDK. 54ifndef LDAP_SDK 55LDAP_SDK = c:/novell/ndk/cldapsdk/win32 56endif 57 58PROOT = .. 59 60# Edit the path below to point to the base of your c-ares package. 61ifndef LIBCARES_PATH 62LIBCARES_PATH = $(PROOT)/ares 63endif 64 65# Edit the var below to set to your architecture or set environment var. 66ifndef ARCH 67ARCH = w32 68endif 69 70CC = $(CROSSPREFIX)gcc 71CFLAGS = -g -O2 -Wall 72CFLAGS += -fno-strict-aliasing 73ifeq ($(ARCH),w64) 74CFLAGS += -D_AMD64_ 75endif 76# comment LDFLAGS below to keep debug info 77LDFLAGS = -s 78AR = $(CROSSPREFIX)ar 79RC = $(CROSSPREFIX)windres 80RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i 81 82# We may need these someday 83# PERL = perl 84# NROFF = nroff 85 86# Platform-dependent helper tool macros 87ifeq ($(findstring /sh,$(SHELL)),/sh) 88DEL = rm -f $1 89RMDIR = rm -fr $1 90MKDIR = mkdir -p $1 91COPY = -cp -afv $1 $2 92#COPYR = -cp -afr $1/* $2 93COPYR = -rsync -aC $1/* $2 94TOUCH = touch $1 95CAT = cat 96ECHONL = echo "" 97DL = ' 98else 99ifeq "$(OS)" "Windows_NT" 100DEL = -del 2>NUL /q /f $(subst /,\,$1) 101RMDIR = -rd 2>NUL /q /s $(subst /,\,$1) 102else 103DEL = -del 2>NUL $(subst /,\,$1) 104RMDIR = -deltree 2>NUL /y $(subst /,\,$1) 105endif 106MKDIR = -md 2>NUL $(subst /,\,$1) 107COPY = -copy 2>NUL /y $(subst /,\,$1) $(subst /,\,$2) 108COPYR = -xcopy 2>NUL /q /y /e $(subst /,\,$1) $(subst /,\,$2) 109TOUCH = copy 2>&1>NUL /b $(subst /,\,$1) +,, 110CAT = type 111ECHONL = $(ComSpec) /c echo. 112endif 113 114######################################################## 115## Nothing more to do below this line! 116 117ifeq ($(findstring -dyn,$(CFG)),-dyn) 118DYN = 1 119endif 120ifeq ($(findstring -ares,$(CFG)),-ares) 121ARES = 1 122endif 123ifeq ($(findstring -sync,$(CFG)),-sync) 124SYNC = 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) 164WINSSL = 1 165SSPI = 1 166endif 167 168INCLUDES = -I. -I../include -I../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 SYNC 180 CFLAGS += -DUSE_SYNC_DNS 181else 182 ifdef ARES 183 ifndef DYN 184 curl_DEPENDENCIES += $(LIBCARES_PATH)/libcares.a 185 endif 186 CFLAGS += -DUSE_ARES -DCARES_STATICLIB 187 curl_LDADD += -L"$(LIBCARES_PATH)" -lcares 188 endif 189endif 190ifdef RTMP 191 CFLAGS += -DUSE_LIBRTMP 192 curl_LDADD += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm 193endif 194ifdef SSH2 195 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H 196 curl_LDADD += -L"$(LIBSSH2_PATH)/win32" -lssh2 197endif 198ifdef SSL 199 ifndef OPENSSL_INCLUDE 200 ifeq "$(wildcard $(OPENSSL_PATH)/outinc)" "$(OPENSSL_PATH)/outinc" 201 OPENSSL_INCLUDE = $(OPENSSL_PATH)/outinc 202 endif 203 ifeq "$(wildcard $(OPENSSL_PATH)/include)" "$(OPENSSL_PATH)/include" 204 OPENSSL_INCLUDE = $(OPENSSL_PATH)/include 205 endif 206 endif 207 ifneq "$(wildcard $(OPENSSL_INCLUDE)/openssl/opensslv.h)" "$(OPENSSL_INCLUDE)/openssl/opensslv.h" 208 $(error Invalid path to OpenSSL package: $(OPENSSL_PATH)) 209 endif 210 ifndef OPENSSL_LIBPATH 211 OPENSSL_LIBS = -lssl -lcrypto 212 ifeq "$(wildcard $(OPENSSL_PATH)/out)" "$(OPENSSL_PATH)/out" 213 OPENSSL_LIBPATH = $(OPENSSL_PATH)/out 214 ifdef DYN 215 OPENSSL_LIBS = -lssl32 -leay32 216 endif 217 endif 218 ifeq "$(wildcard $(OPENSSL_PATH)/lib)" "$(OPENSSL_PATH)/lib" 219 OPENSSL_LIBPATH = $(OPENSSL_PATH)/lib 220 endif 221 endif 222 ifndef DYN 223 OPENSSL_LIBS += -lgdi32 -lcrypt32 224 endif 225 INCLUDES += -I"$(OPENSSL_INCLUDE)" 226 CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL 227 curl_LDADD += -L"$(OPENSSL_LIBPATH)" $(OPENSSL_LIBS) 228endif 229ifdef ZLIB 230 INCLUDES += -I"$(ZLIB_PATH)" 231 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H 232 curl_LDADD += -L"$(ZLIB_PATH)" -lz 233endif 234ifdef IDN 235 CFLAGS += -DUSE_LIBIDN 236 curl_LDADD += -L"$(LIBIDN_PATH)/lib" -lidn 237else 238ifdef WINIDN 239 CFLAGS += -DUSE_WIN32_IDN 240 curl_LDADD += -L"$(WINIDN_PATH)" -lnormaliz 241endif 242endif 243ifdef METALINK 244 INCLUDES += -I"$(LIBMETALINK_PATH)/include" 245 CFLAGS += -DUSE_METALINK 246 curl_LDADD += -L"$(LIBMETALINK_PATH)/lib" -lmetalink 247 ifndef DYN 248 ifeq ($(findstring libexpat_metalink_parser.o,$(shell $(AR) t "$(LIBMETALINK_PATH)/lib/libmetalink.a")),libexpat_metalink_parser.o) 249 curl_LDADD += -L"$(LIBEXPAT_PATH)/lib" -lexpat 250 else 251 curl_LDADD += -L"$(LIBXML2_PATH)/lib" -lxml2 252 endif 253 endif 254endif 255ifdef SSPI 256 CFLAGS += -DUSE_WINDOWS_SSPI 257 ifdef WINSSL 258 CFLAGS += -DUSE_SCHANNEL 259 endif 260endif 261ifdef SPNEGO 262 CFLAGS += -DHAVE_SPNEGO 263endif 264ifdef IPV6 265 CFLAGS += -DENABLE_IPV6 -D_WIN32_WINNT=0x0501 266endif 267ifdef LDAPS 268 CFLAGS += -DHAVE_LDAP_SSL 269endif 270ifdef USE_LDAP_NOVELL 271 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK 272 curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx 273endif 274ifdef USE_LDAP_OPENLDAP 275 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK 276 curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber 277endif 278ifndef USE_LDAP_NOVELL 279ifndef USE_LDAP_OPENLDAP 280curl_LDADD += -lwldap32 281endif 282endif 283curl_LDADD += -lws2_32 284 285# Makefile.inc provides the CSOURCES and HHEADERS defines 286include Makefile.inc 287 288curl_PROGRAMS = curl.exe 289curl_OBJECTS := $(patsubst %.c,%.o,$(strip $(CURL_CFILES))) 290curlx_OBJECTS := $(patsubst %.c,%.o,$(notdir $(strip $(CURLX_CFILES)))) 291ifdef DYN 292curl_OBJECTS += $(curlx_OBJECTS) 293vpath %.c $(PROOT)/lib 294endif 295 296RESOURCE = curl.res 297 298 299all: $(curl_PROGRAMS) 300 301curl.exe: $(RESOURCE) $(curl_OBJECTS) $(curl_DEPENDENCIES) 302 $(call DEL, $@) 303 $(CC) $(LDFLAGS) -o $@ $< $(curl_OBJECTS) $(curl_LDADD) 304 305# We don't have nroff normally under win32 306# tool_hugehelp.c: $(PROOT)/docs/MANUAL $(PROOT)/docs/curl.1 mkhelp.pl 307# @$(call DEL, tool_hugehelp.c) 308# $(NROFF) -man $(PROOT)/docs/curl.1 | $(PERL) mkhelp.pl $(PROOT)/docs/MANUAL > tool_hugehelp.c 309 310tool_hugehelp.c: 311 @echo Creating $@ 312 @$(call COPY, $@.cvs, $@) 313 314%.o: %.c 315 $(CC) $(INCLUDES) $(CFLAGS) -c $< 316 317%.res: %.rc 318 $(RC) $(RCFLAGS) $< -o $@ 319 320clean: 321ifeq "$(wildcard tool_hugehelp.c.cvs)" "tool_hugehelp.c.cvs" 322 @$(call DEL, tool_hugehelp.c) 323endif 324 @$(call DEL, $(curl_OBJECTS) $(curlx_OBJECTS) $(RESOURCE)) 325 326distclean vclean: clean 327 @$(call DEL, $(curl_PROGRAMS)) 328 329