Lucas Eckels | 9bd90e6 | 2012-08-06 15:07:02 -0700 | [diff] [blame^] | 1 | ######################################################################### |
| 2 | # |
| 3 | ## Makefile for building curl examples with MingW32 |
| 4 | ## and optionally OpenSSL (0.9.8), libssh2 (0.18), zlib (1.2.3) |
| 5 | ## |
| 6 | ## Usage: |
| 7 | ## mingw32-make -f Makefile.m32 [SSL=1] [SSH2=1] [ZLIB=1] [SSPI=1] [IPV6=1] [DYN=1] |
| 8 | ## |
| 9 | ## Hint: you can also set environment vars to control the build, f.e.: |
| 10 | ## set ZLIB_PATH=c:/zlib-1.2.3 |
| 11 | ## set ZLIB=1 |
| 12 | ## |
| 13 | ######################################################################### |
| 14 | |
| 15 | # Edit the path below to point to the base of your Zlib sources. |
| 16 | ifndef ZLIB_PATH |
| 17 | ZLIB_PATH = ../../zlib-1.2.3 |
| 18 | endif |
| 19 | # Edit the path below to point to the base of your OpenSSL package. |
| 20 | ifndef OPENSSL_PATH |
| 21 | OPENSSL_PATH = ../../openssl-0.9.8k |
| 22 | endif |
| 23 | # Edit the path below to point to the base of your LibSSH2 package. |
| 24 | ifndef LIBSSH2_PATH |
| 25 | LIBSSH2_PATH = ../../libssh2-1.2 |
| 26 | endif |
| 27 | # Edit the path below to point to the base of your Novell LDAP NDK. |
| 28 | ifndef LDAP_SDK |
| 29 | LDAP_SDK = c:/novell/ndk/cldapsdk/win32 |
| 30 | endif |
| 31 | |
| 32 | PROOT = ../.. |
| 33 | ARES_LIB = $(PROOT)/ares |
| 34 | |
| 35 | SSL = 1 |
| 36 | ZLIB = 1 |
| 37 | |
| 38 | CC = gcc |
| 39 | CFLAGS = -g -O2 -Wall |
| 40 | # comment LDFLAGS below to keep debug info |
| 41 | LDFLAGS = -s |
| 42 | RC = windres |
| 43 | RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i |
| 44 | RM = del /q /f > NUL 2>&1 |
| 45 | CP = copy |
| 46 | |
| 47 | ######################################################## |
| 48 | ## Nothing more to do below this line! |
| 49 | |
| 50 | INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib |
| 51 | LINK = $(CC) $(LDFLAGS) -o $@ |
| 52 | |
| 53 | ifdef DYN |
| 54 | curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll |
| 55 | curl_LDADD = -L$(PROOT)/lib -lcurldll |
| 56 | else |
| 57 | curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a |
| 58 | curl_LDADD = -L$(PROOT)/lib -lcurl |
| 59 | CFLAGS += -DCURL_STATICLIB |
| 60 | endif |
| 61 | ifdef ARES |
| 62 | ifndef DYN |
| 63 | curl_DEPENDENCIES += $(ARES_LIB)/libcares.a |
| 64 | endif |
| 65 | CFLAGS += -DUSE_ARES |
| 66 | curl_LDADD += -L$(ARES_LIB) -lcares |
| 67 | endif |
| 68 | ifdef SSH2 |
| 69 | CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H |
| 70 | curl_LDADD += -L$(LIBSSH2_PATH)/win32 -lssh2 |
| 71 | endif |
| 72 | ifdef SSL |
| 73 | INCLUDES += -I"$(OPENSSL_PATH)/outinc" |
| 74 | CFLAGS += -DUSE_SSLEAY -DHAVE_OPENSSL_ENGINE_H |
| 75 | ifdef DYN |
| 76 | curl_LDADD += -L$(OPENSSL_PATH)/out -leay32 -lssl32 |
| 77 | else |
| 78 | curl_LDADD += -L$(OPENSSL_PATH)/out -lssl -lcrypto -lgdi32 |
| 79 | endif |
| 80 | endif |
| 81 | ifdef ZLIB |
| 82 | INCLUDES += -I"$(ZLIB_PATH)" |
| 83 | CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H |
| 84 | curl_LDADD += -L$(ZLIB_PATH) -lz |
| 85 | endif |
| 86 | ifdef SSPI |
| 87 | CFLAGS += -DUSE_WINDOWS_SSPI |
| 88 | endif |
| 89 | ifdef IPV6 |
| 90 | CFLAGS += -DENABLE_IPV6 |
| 91 | endif |
| 92 | ifdef LDAPS |
| 93 | CFLAGS += -DHAVE_LDAP_SSL |
| 94 | endif |
| 95 | ifdef USE_LDAP_NOVELL |
| 96 | CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK |
| 97 | curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx |
| 98 | endif |
| 99 | ifdef USE_LDAP_OPENLDAP |
| 100 | CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK |
| 101 | curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber |
| 102 | endif |
| 103 | ifndef USE_LDAP_NOVELL |
| 104 | ifndef USE_LDAP_OPENLDAP |
| 105 | curl_LDADD += -lwldap32 |
| 106 | endif |
| 107 | endif |
| 108 | curl_LDADD += -lws2_32 |
| 109 | COMPILE = $(CC) $(INCLUDES) $(CFLAGS) |
| 110 | |
| 111 | # Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines |
| 112 | include Makefile.inc |
| 113 | |
| 114 | example_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS))) |
| 115 | |
| 116 | .SUFFIXES: .rc .res .o .exe |
| 117 | |
| 118 | |
| 119 | all: $(example_PROGRAMS) |
| 120 | |
| 121 | .o.exe: $(curl_DEPENDENCIES) |
| 122 | $(LINK) $< $(curl_LDADD) |
| 123 | |
| 124 | .c.o: |
| 125 | $(COMPILE) -c $< |
| 126 | |
| 127 | .rc.res: |
| 128 | $(RC) $(RCFLAGS) $< -o $@ |
| 129 | |
| 130 | clean: |
| 131 | $(RM) $(example_PROGRAMS) |
| 132 | |
| 133 | |