blob: 15750d01f73a0b7226761e87a71cfd25c325d036 [file] [log] [blame]
Lucas Eckels9bd90e62012-08-06 15:07:02 -07001#########################################################################
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.
16ifndef ZLIB_PATH
17ZLIB_PATH = ../../zlib-1.2.3
18endif
19# Edit the path below to point to the base of your OpenSSL package.
20ifndef OPENSSL_PATH
21OPENSSL_PATH = ../../openssl-0.9.8k
22endif
23# Edit the path below to point to the base of your LibSSH2 package.
24ifndef LIBSSH2_PATH
25LIBSSH2_PATH = ../../libssh2-1.2
26endif
27# Edit the path below to point to the base of your Novell LDAP NDK.
28ifndef LDAP_SDK
29LDAP_SDK = c:/novell/ndk/cldapsdk/win32
30endif
31
32PROOT = ../..
33ARES_LIB = $(PROOT)/ares
34
35SSL = 1
36ZLIB = 1
37
38CC = gcc
39CFLAGS = -g -O2 -Wall
40# comment LDFLAGS below to keep debug info
41LDFLAGS = -s
42RC = windres
43RCFLAGS = --include-dir=$(PROOT)/include -O COFF -i
44RM = del /q /f > NUL 2>&1
45CP = copy
46
47########################################################
48## Nothing more to do below this line!
49
50INCLUDES = -I. -I$(PROOT) -I$(PROOT)/include -I$(PROOT)/lib
51LINK = $(CC) $(LDFLAGS) -o $@
52
53ifdef DYN
54 curl_DEPENDENCIES = $(PROOT)/lib/libcurldll.a $(PROOT)/lib/libcurl.dll
55 curl_LDADD = -L$(PROOT)/lib -lcurldll
56else
57 curl_DEPENDENCIES = $(PROOT)/lib/libcurl.a
58 curl_LDADD = -L$(PROOT)/lib -lcurl
59 CFLAGS += -DCURL_STATICLIB
60endif
61ifdef ARES
62 ifndef DYN
63 curl_DEPENDENCIES += $(ARES_LIB)/libcares.a
64 endif
65 CFLAGS += -DUSE_ARES
66 curl_LDADD += -L$(ARES_LIB) -lcares
67endif
68ifdef SSH2
69 CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
70 curl_LDADD += -L$(LIBSSH2_PATH)/win32 -lssh2
71endif
72ifdef 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
80endif
81ifdef ZLIB
82 INCLUDES += -I"$(ZLIB_PATH)"
83 CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
84 curl_LDADD += -L$(ZLIB_PATH) -lz
85endif
86ifdef SSPI
87 CFLAGS += -DUSE_WINDOWS_SSPI
88endif
89ifdef IPV6
90 CFLAGS += -DENABLE_IPV6
91endif
92ifdef LDAPS
93 CFLAGS += -DHAVE_LDAP_SSL
94endif
95ifdef USE_LDAP_NOVELL
96 CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
97 curl_LDADD += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
98endif
99ifdef USE_LDAP_OPENLDAP
100 CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
101 curl_LDADD += -L"$(LDAP_SDK)/lib" -lldap -llber
102endif
103ifndef USE_LDAP_NOVELL
104ifndef USE_LDAP_OPENLDAP
105curl_LDADD += -lwldap32
106endif
107endif
108curl_LDADD += -lws2_32
109COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
110
111# Makefile.inc provides the check_PROGRAMS and COMPLICATED_EXAMPLES defines
112include Makefile.inc
113
114example_PROGRAMS := $(patsubst %,%.exe,$(strip $(check_PROGRAMS)))
115
116.SUFFIXES: .rc .res .o .exe
117
118
119all: $(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
130clean:
131 $(RM) $(example_PROGRAMS)
132
133