added libidn build.
[platform/upstream/curl.git] / lib / Makefile.m32
1 #########################################################################
2 # $Id$
3 #
4 ## Makefile for building libcurl.a with MingW32 (GCC-3.2)
5 ## and optionally OpenSSL (0.9.8), libssh2 (0.18), zlib (1.2.3)
6 ##
7 ## Usage:
8 ## mingw32-make -f Makefile.m32 [SSL=1] [SSH2=1] [ZLIB=1] [IDN=1] [SSPI=1] [IPV6=1] [DYN=1]
9 ##
10 ## Hint: you can also set environment vars to control the build, f.e.:
11 ## set ZLIB_PATH=c:/zlib-1.2.3
12 ## set ZLIB=1
13 ##
14 ## Comments to: Troy Engel <tengel@sonic.net> or
15 ##              Joern Hartroth <hartroth@acm.org>
16 #########################################################################
17
18 # Edit the path below to point to the base of your Zlib sources.
19 ifndef ZLIB_PATH
20 ZLIB_PATH = ../../zlib-1.2.3
21 endif
22 # Edit the path below to point to the base of your OpenSSL package.
23 ifndef OPENSSL_PATH
24 OPENSSL_PATH = ../../openssl-0.9.8g
25 endif
26 # Edit the path below to point to the base of your LibSSH2 package.
27 ifndef LIBSSH2_PATH
28 LIBSSH2_PATH = ../../libssh2-0.18
29 endif
30 # Edit the path below to point to the base of your libidn package.
31 ifndef LIBIDN_PATH
32 LIBIDN_PATH = ../../libidn-1.9
33 endif
34 # Edit the path below to point to the base of your Novell LDAP NDK.
35 ifndef LDAP_SDK
36 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
37 endif
38
39 ARES_LIB = ../ares
40
41 CC = gcc
42 AR = ar
43 # comment LDFLAGS below to keep debug info
44 LDFLAGS = -s
45 RANLIB = ranlib
46 RC = windres
47 RCFLAGS = --include-dir=../include -DCURLDEBUG=0 -O COFF -i
48 RM = del /q /f > NUL 2>&1
49 STRIP = strip -g
50
51 ########################################################
52 ## Nothing more to do below this line!
53
54 INCLUDES = -I. -I../include
55 CFLAGS = -g -O2 -DBUILDING_LIBCURL
56 ifdef ARES
57   INCLUDES += -I$(ARES_LIB)
58   CFLAGS += -DUSE_ARES
59   DLL_LIBS += -L$(ARES_LIB) -lcares
60   libcurl_dll_DEPENDENCIES = $(ARES_LIB)/libcares.a
61 endif
62 ifdef SSH2
63   INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
64   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
65   DLL_LIBS += -L$(LIBSSH2_PATH)/win32 -lssh2
66 endif
67 ifdef SSL
68   INCLUDES += -I"$(OPENSSL_PATH)/outinc" -I"$(OPENSSL_PATH)/outinc/openssl"
69   CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \
70             -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 \
71             -DCURL_WANTS_CA_BUNDLE_ENV
72   DLL_LIBS += -L$(OPENSSL_PATH)/out -leay32 -lssl32
73 endif
74 ifdef ZLIB
75   INCLUDES += -I"$(ZLIB_PATH)"
76   CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
77   DLL_LIBS += -L$(ZLIB_PATH) -lz
78 endif
79 ifdef IDN
80   INCLUDES += -I"$(LIBIDN_PATH)/include"
81   CFLAGS += -DUSE_LIBIDN
82   DLL_LIBS += -L$(LIBIDN_PATH)/lib -lidn
83 endif
84 ifdef SSPI
85   CFLAGS += -DUSE_WINDOWS_SSPI
86 endif
87 ifdef IPV6
88   CFLAGS += -DENABLE_IPV6
89 endif
90 ifdef LDAPS
91   CFLAGS += -DHAVE_LDAP_SSL
92 endif
93 ifdef USE_LDAP_NOVELL
94   INCLUDES += -I"$(LDAP_SDK)/inc"
95   CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
96   DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
97 endif
98 ifdef USE_LDAP_OPENLDAP
99   INCLUDES += -I"$(LDAP_SDK)/include"
100   CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
101   DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
102 endif
103 ifndef USE_LDAP_NOVELL
104 ifndef USE_LDAP_OPENLDAP
105 DLL_LIBS += -lwldap32
106 endif
107 endif
108 DLL_LIBS += -lws2_32
109 COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
110
111 # Makefile.inc provides the CSOURCES and HHEADERS defines
112 include Makefile.inc
113
114 libcurl_dll_LIBRARY = libcurl.dll
115 libcurl_dll_a_LIBRARY = libcurldll.a
116 libcurl_a_LIBRARY = libcurl.a
117
118 libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
119 libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
120
121 RESOURCE = libcurl.res
122
123 .SUFFIXES: .rc .res
124
125 all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
126
127 $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
128         -$(RM) $@
129         $(AR) cru $@ $(libcurl_a_OBJECTS)
130         $(RANLIB) $@
131         $(STRIP) $@
132
133 # remove the last line above to keep debug info
134
135 $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
136         -$(RM) $@
137         $(CC) $(LDFLAGS) -shared -Wl,--out-implib,$(libcurl_dll_a_LIBRARY) \
138           -o $@ $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
139
140 .c.o:
141         $(COMPILE) -c $<
142
143 .rc.res:
144         $(RC) $(RCFLAGS) $< -o $@
145
146 clean:
147         -$(RM) $(libcurl_a_OBJECTS) $(RESOURCE)
148
149 distrib: clean
150         -$(RM) $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_a_LIBRARY)
151
152 FORCE: ;
153
154 $(ARES_LIB)/libcares.a:
155         $(MAKE) -C $(ARES_LIB) -f Makefile.m32
156
157