1######################################################################### 2# 3## Makefile for building libcurl.a with MingW32 (GCC-3.2 or later) 4## and optionally OpenSSL (0.9.8), libssh2 (1.2), 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-sspi-winidn 8## 9## Hint: you can also set environment vars to control the build, f.e.: 10## set ZLIB_PATH=c:/zlib-1.2.5 11## set ZLIB=1 12## 13## Comments to: Troy Engel <tengel@sonic.net> or 14## Joern Hartroth <hartroth@acm.org> 15######################################################################### 16 17# Edit the path below to point to the base of your Zlib sources. 18ifndef ZLIB_PATH 19ZLIB_PATH = ../../zlib-1.2.5 20endif 21# Edit the path below to point to the base of your OpenSSL package. 22ifndef OPENSSL_PATH 23OPENSSL_PATH = ../../openssl-0.9.8r 24endif 25# Edit the path below to point to the base of your LibSSH2 package. 26ifndef LIBSSH2_PATH 27LIBSSH2_PATH = ../../libssh2-1.2.8 28endif 29# Edit the path below to point to the base of your librtmp package. 30ifndef LIBRTMP_PATH 31LIBRTMP_PATH = ../../librtmp-2.3 32endif 33# Edit the path below to point to the base of your libidn package. 34ifndef LIBIDN_PATH 35LIBIDN_PATH = ../../libidn-1.18 36endif 37# Edit the path below to point to the base of your MS idndlpackage. 38# Microsoft Internationalized Domain Names (IDN) Mitigation APIs 1.1 39# http://www.microsoft.com/downloads/en/details.aspx?FamilyID=ad6158d7-ddba-416a-9109-07607425a815 40ifndef WINIDN_PATH 41WINIDN_PATH = ../../Microsoft IDN Mitigation APIs 42endif 43# Edit the path below to point to the base of your Novell LDAP NDK. 44ifndef LDAP_SDK 45LDAP_SDK = c:/novell/ndk/cldapsdk/win32 46endif 47 48# Edit the path below to point to the base of your c-ares package. 49ifndef LIBCARES_PATH 50LIBCARES_PATH = ../ares 51endif 52 53CC = gcc 54CFLAGS = -g -O2 -Wall 55# comment LDFLAGS below to keep debug info 56LDFLAGS = -s 57AR = ar 58RANLIB = ranlib 59RC = windres 60RCFLAGS = --include-dir=../include -DDEBUGBUILD=0 -O COFF -i 61RM = del /q /f 2>NUL 62STRIP = strip -g 63 64######################################################## 65## Nothing more to do below this line! 66 67ifeq ($(findstring -dyn,$(CFG)),-dyn) 68DYN = 1 69endif 70ifeq ($(findstring -ares,$(CFG)),-ares) 71ARES = 1 72endif 73ifeq ($(findstring -rtmp,$(CFG)),-rtmp) 74RTMP = 1 75SSL = 1 76ZLIB = 1 77endif 78ifeq ($(findstring -ssh2,$(CFG)),-ssh2) 79SSH2 = 1 80SSL = 1 81ZLIB = 1 82endif 83ifeq ($(findstring -ssl,$(CFG)),-ssl) 84SSL = 1 85endif 86ifeq ($(findstring -zlib,$(CFG)),-zlib) 87ZLIB = 1 88endif 89ifeq ($(findstring -idn,$(CFG)),-idn) 90IDN = 1 91endif 92ifeq ($(findstring -winidn,$(CFG)),-winidn) 93WINIDN = 1 94endif 95ifeq ($(findstring -sspi,$(CFG)),-sspi) 96SSPI = 1 97endif 98ifeq ($(findstring -ldaps,$(CFG)),-ldaps) 99LDAPS = 1 100endif 101ifeq ($(findstring -ipv6,$(CFG)),-ipv6) 102IPV6 = 1 103endif 104 105INCLUDES = -I. -I../include 106CFLAGS += -DBUILDING_LIBCURL 107ifdef ARES 108 INCLUDES += -I$(LIBCARES_PATH) 109 CFLAGS += -DUSE_ARES 110 DLL_LIBS += -L$(LIBCARES_PATH) -lcares 111 libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a 112endif 113ifdef RTMP 114 INCLUDES += -I"$(LIBRTMP_PATH)" 115 CFLAGS += -DUSE_LIBRTMP 116 DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm 117endif 118ifdef SSH2 119 INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32" 120 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H 121 DLL_LIBS += -L$(LIBSSH2_PATH)/win32 -lssh2 122endif 123ifdef SSL 124 INCLUDES += -I"$(OPENSSL_PATH)/outinc" -I"$(OPENSSL_PATH)/outinc/openssl" 125 CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \ 126 -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 \ 127 -DCURL_WANTS_CA_BUNDLE_ENV 128 DLL_LIBS += -L$(OPENSSL_PATH)/out -leay32 -lssl32 129endif 130ifdef ZLIB 131 INCLUDES += -I"$(ZLIB_PATH)" 132 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H 133 DLL_LIBS += -L$(ZLIB_PATH) -lz 134endif 135ifdef IDN 136 INCLUDES += -I"$(LIBIDN_PATH)/include" 137 CFLAGS += -DUSE_LIBIDN 138 DLL_LIBS += -L$(LIBIDN_PATH)/lib -lidn 139else 140ifdef WINIDN 141 INCLUDES += -I"$(WINIDN_PATH)/include" 142 CFLAGS += -DHAVE_NORMALIZATION_H 143 CFLAGS += -DUSE_WIN32_IDN 144 DLL_LIBS += -L"$(WINIDN_PATH)" -lnormaliz 145endif 146endif 147ifdef SSPI 148 CFLAGS += -DUSE_WINDOWS_SSPI 149endif 150ifdef IPV6 151 CFLAGS += -DENABLE_IPV6 152endif 153ifdef LDAPS 154 CFLAGS += -DHAVE_LDAP_SSL 155endif 156ifdef USE_LDAP_NOVELL 157 INCLUDES += -I"$(LDAP_SDK)/inc" 158 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK 159 DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx 160endif 161ifdef USE_LDAP_OPENLDAP 162 INCLUDES += -I"$(LDAP_SDK)/include" 163 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK 164 DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber 165endif 166ifndef USE_LDAP_NOVELL 167ifndef USE_LDAP_OPENLDAP 168DLL_LIBS += -lwldap32 169endif 170endif 171DLL_LIBS += -lws2_32 172COMPILE = $(CC) $(INCLUDES) $(CFLAGS) 173 174# Makefile.inc provides the CSOURCES and HHEADERS defines 175include Makefile.inc 176 177libcurl_dll_LIBRARY = libcurl.dll 178libcurl_dll_a_LIBRARY = libcurldll.a 179libcurl_a_LIBRARY = libcurl.a 180 181libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES))) 182libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS)) 183 184RESOURCE = libcurl.res 185 186.SUFFIXES: .rc .res 187 188all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) 189 190$(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES) 191 -$(RM) $@ 192 $(AR) cru $@ $(libcurl_a_OBJECTS) 193 $(RANLIB) $@ 194 $(STRIP) $@ 195 196# remove the last line above to keep debug info 197 198$(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES) 199 -$(RM) $@ 200 $(CC) $(LDFLAGS) -shared -Wl,--out-implib,$(libcurl_dll_a_LIBRARY) \ 201 -o $@ $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS) 202 203.c.o: 204 $(COMPILE) -c $< 205 206.rc.res: 207 $(RC) $(RCFLAGS) $< -o $@ 208 209clean: 210 -$(RM) $(libcurl_a_OBJECTS) $(RESOURCE) 211 212distclean vclean: clean 213 -$(RM) $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_a_LIBRARY) 214 215FORCE: ; 216 217$(LIBCARES_PATH)/libcares.a: 218 $(MAKE) -C $(LIBCARES_PATH) -f Makefile.m32 219 220