Git init
[external/curl.git] / lib / Makefile.m32
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)
5 ##
6 ## Usage:
7 ## mingw32-make -f Makefile.m32 [SSL=1] [SSH2=1] [ZLIB=1] [IDN=1] [SSPI=1] [IPV6=1] [LDAPS=1] [RTMP=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.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.
18 ifndef ZLIB_PATH
19 ZLIB_PATH = ../../zlib-1.2.5
20 endif
21 # Edit the path below to point to the base of your OpenSSL package.
22 ifndef OPENSSL_PATH
23 OPENSSL_PATH = ../../openssl-0.9.8q
24 endif
25 # Edit the path below to point to the base of your LibSSH2 package.
26 ifndef LIBSSH2_PATH
27 LIBSSH2_PATH = ../../libssh2-1.2.7
28 endif
29 # Edit the path below to point to the base of your libidn package.
30 ifndef LIBIDN_PATH
31 LIBIDN_PATH = ../../libidn-1.18
32 endif
33 # Edit the path below to point to the base of your librtmp package.
34 ifndef LIBRTMP_PATH
35 LIBRTMP_PATH = ../../librtmp-2.3
36 endif
37 # Edit the path below to point to the base of your Novell LDAP NDK.
38 ifndef LDAP_SDK
39 LDAP_SDK = c:/novell/ndk/cldapsdk/win32
40 endif
41
42 # Edit the path below to point to the base of your c-ares package.
43 ifndef LIBCARES_PATH
44 LIBCARES_PATH = ../ares
45 endif
46
47 CC = gcc
48 AR = ar
49 # comment LDFLAGS below to keep debug info
50 LDFLAGS = -s
51 RANLIB = ranlib
52 RC = windres
53 RCFLAGS = --include-dir=../include -DDEBUGBUILD=0 -O COFF -i
54 RM = del /q /f 2>NUL
55 STRIP = strip -g
56
57 ########################################################
58 ## Nothing more to do below this line!
59
60 INCLUDES = -I. -I../include
61 CFLAGS = -g -O2 -DBUILDING_LIBCURL
62 ifdef ARES
63   INCLUDES += -I$(LIBCARES_PATH)
64   CFLAGS += -DUSE_ARES
65   DLL_LIBS += -L$(LIBCARES_PATH) -lcares
66   libcurl_dll_DEPENDENCIES = $(LIBCARES_PATH)/libcares.a
67 endif
68 ifdef RTMP
69   INCLUDES += -I"$(LIBRTMP_PATH)"
70   CFLAGS += -DUSE_LIBRTMP
71   DLL_LIBS += -L"$(LIBRTMP_PATH)/librtmp" -lrtmp -lwinmm
72 endif
73 ifdef SSH2
74   INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
75   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
76   DLL_LIBS += -L$(LIBSSH2_PATH)/win32 -lssh2
77 endif
78 ifdef SSL
79   INCLUDES += -I"$(OPENSSL_PATH)/outinc" -I"$(OPENSSL_PATH)/outinc/openssl"
80   CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \
81             -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 \
82             -DCURL_WANTS_CA_BUNDLE_ENV
83   DLL_LIBS += -L$(OPENSSL_PATH)/out -leay32 -lssl32
84 endif
85 ifdef ZLIB
86   INCLUDES += -I"$(ZLIB_PATH)"
87   CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
88   DLL_LIBS += -L$(ZLIB_PATH) -lz
89 endif
90 ifdef IDN
91   INCLUDES += -I"$(LIBIDN_PATH)/include"
92   CFLAGS += -DUSE_LIBIDN
93   DLL_LIBS += -L$(LIBIDN_PATH)/lib -lidn
94 endif
95 ifdef SSPI
96   CFLAGS += -DUSE_WINDOWS_SSPI
97 endif
98 ifdef IPV6
99   CFLAGS += -DENABLE_IPV6
100 endif
101 ifdef LDAPS
102   CFLAGS += -DHAVE_LDAP_SSL
103 endif
104 ifdef USE_LDAP_NOVELL
105   INCLUDES += -I"$(LDAP_SDK)/inc"
106   CFLAGS += -DCURL_HAS_NOVELL_LDAPSDK
107   DLL_LIBS += -L"$(LDAP_SDK)/lib/mscvc" -lldapsdk -lldapssl -lldapx
108 endif
109 ifdef USE_LDAP_OPENLDAP
110   INCLUDES += -I"$(LDAP_SDK)/include"
111   CFLAGS += -DCURL_HAS_OPENLDAP_LDAPSDK
112   DLL_LIBS += -L"$(LDAP_SDK)/lib" -lldap -llber
113 endif
114 ifndef USE_LDAP_NOVELL
115 ifndef USE_LDAP_OPENLDAP
116 DLL_LIBS += -lwldap32
117 endif
118 endif
119 DLL_LIBS += -lws2_32
120 COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
121
122 # Makefile.inc provides the CSOURCES and HHEADERS defines
123 include Makefile.inc
124
125 libcurl_dll_LIBRARY = libcurl.dll
126 libcurl_dll_a_LIBRARY = libcurldll.a
127 libcurl_a_LIBRARY = libcurl.a
128
129 libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
130 libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
131
132 RESOURCE = libcurl.res
133
134 .SUFFIXES: .rc .res
135
136 all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
137
138 $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
139         -$(RM) $@
140         $(AR) cru $@ $(libcurl_a_OBJECTS)
141         $(RANLIB) $@
142         $(STRIP) $@
143
144 # remove the last line above to keep debug info
145
146 $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
147         -$(RM) $@
148         $(CC) $(LDFLAGS) -shared -Wl,--out-implib,$(libcurl_dll_a_LIBRARY) \
149           -o $@ $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
150
151 .c.o:
152         $(COMPILE) -c $<
153
154 .rc.res:
155         $(RC) $(RCFLAGS) $< -o $@
156
157 clean:
158         -$(RM) $(libcurl_a_OBJECTS) $(RESOURCE)
159
160 distclean vclean: clean
161         -$(RM) $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_a_LIBRARY)
162
163 FORCE: ;
164
165 $(LIBCARES_PATH)/libcares.a:
166         $(MAKE) -C $(LIBCARES_PATH) -f Makefile.m32
167