ignore errors of the RM command; seems that the del command fails on W2K when the...
[platform/upstream/curl.git] / lib / Makefile.m32
1 #############################################################
2 # $Id$
3 #
4 ## Makefile for building libcurl.a with MingW32 (GCC-3.2) and
5 ## optionally OpenSSL (0.9.8), libssh2 (0.17), zlib (1.2.3)
6 ##
7 ## Usage:
8 ## mingw32-make -f Makefile.m32 [SSL=1] [SSH2=1] [ZLIB=1] [SSPI=1] [IPV6=1] [DYN=1]
9 ##
10 ## Comments to: Troy Engel <tengel@sonic.net> or
11 ##              Joern Hartroth <hartroth@acm.org>
12
13 ifndef OPENSSL_PATH
14 OPENSSL_PATH = ../../openssl-0.9.8e
15 endif
16 ifndef LIBSSH2_PATH
17 LIBSSH2_PATH = ../../libssh2-0.16
18 endif
19 ifndef ZLIB_PATH
20 ZLIB_PATH = ../../zlib-1.2.3
21 endif
22
23 ARES_LIB = ../ares
24
25 CC = gcc
26 AR = ar
27 # comment LDFLAGS below to keep debug info
28 LDFLAGS = -s
29 RANLIB = ranlib
30 RC = windres
31 RCFLAGS = --include-dir=../include -DCURLDEBUG=0 -O COFF -i
32 RM = del /q /f
33 STRIP = strip -g
34
35 ########################################################
36 ## Nothing more to do below this line!
37
38 INCLUDES = -I. -I../include
39 CFLAGS = -g -O2 -DBUILDING_LIBCURL
40 ifdef ARES
41   INCLUDES += -I$(ARES_LIB)
42   CFLAGS += -DUSE_ARES
43   DLL_LIBS += -L$(ARES_LIB) -lcares
44   libcurl_dll_DEPENDENCIES = $(ARES_LIB)/libcares.a
45 endif
46 ifdef SSH2
47   INCLUDES += -I"$(LIBSSH2_PATH)/include" -I"$(LIBSSH2_PATH)/win32"
48   CFLAGS += -DUSE_LIBSSH2 -DHAVE_LIBSSH2_H
49   DLL_LIBS += -L$(LIBSSH2_PATH)/win32 -lssh2
50 endif
51 ifdef SSL
52   INCLUDES += -I"$(OPENSSL_PATH)/outinc" -I"$(OPENSSL_PATH)/outinc/openssl"
53   CFLAGS += -DUSE_SSLEAY -DUSE_OPENSSL -DHAVE_OPENSSL_ENGINE_H -DHAVE_OPENSSL_PKCS12_H \
54             -DHAVE_ENGINE_LOAD_BUILTIN_ENGINES -DOPENSSL_NO_KRB5 \
55             -DCURL_WANTS_CA_BUNDLE_ENV
56   DLL_LIBS += -L$(OPENSSL_PATH)/out -leay32 -lssl32
57 endif
58 ifdef ZLIB
59   INCLUDES += -I"$(ZLIB_PATH)"
60   CFLAGS += -DHAVE_LIBZ -DHAVE_ZLIB_H
61   DLL_LIBS += -L$(ZLIB_PATH) -lz
62 endif
63 ifdef SSPI
64   CFLAGS += -DUSE_WINDOWS_SSPI
65 endif
66 ifdef IPV6
67   CFLAGS += -DENABLE_IPV6
68 endif
69 DLL_LIBS += -lws2_32 -lwinmm -lwldap32
70 COMPILE = $(CC) $(INCLUDES) $(CFLAGS)
71
72 # Makefile.inc provides the CSOURCES and HHEADERS defines
73 include Makefile.inc
74
75 libcurl_dll_LIBRARY = libcurl.dll
76 libcurl_dll_a_LIBRARY = libcurldll.a
77 libcurl_a_LIBRARY = libcurl.a
78
79 libcurl_a_OBJECTS := $(patsubst %.c,%.o,$(strip $(CSOURCES)))
80 libcurl_a_DEPENDENCIES := $(strip $(CSOURCES) $(HHEADERS))
81
82 RESOURCE = libcurl.res
83
84 .SUFFIXES: .rc .res
85
86 all: $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY)
87
88 $(libcurl_a_LIBRARY): $(libcurl_a_OBJECTS) $(libcurl_a_DEPENDENCIES)
89         -$(RM) $@
90         $(AR) cru $@ $(libcurl_a_OBJECTS)
91         $(RANLIB) $@
92         $(STRIP) $@
93
94 # remove the last line above to keep debug info
95
96 $(libcurl_dll_LIBRARY): $(libcurl_a_OBJECTS) $(RESOURCE) $(libcurl_dll_DEPENDENCIES)
97         -$(RM) $@
98         $(CC) $(LDFLAGS) -shared -Wl,--out-implib,$(libcurl_dll_a_LIBRARY) \
99           -o $@ $(libcurl_a_OBJECTS) $(RESOURCE) $(DLL_LIBS)
100
101 .c.o:
102         $(COMPILE) -c $<
103
104 .rc.res:
105         $(RC) $(RCFLAGS) $< -o $@
106
107 clean:
108         -$(RM) $(libcurl_a_OBJECTS) $(RESOURCE)
109
110 distrib: clean
111         -$(RM) $(libcurl_a_LIBRARY) $(libcurl_dll_LIBRARY) $(libcurl_dll_a_LIBRARY)
112
113 $(ARES_LIB)/libcares.a:
114         $(MAKE) -C $(ARES_LIB) -f Makefile.m32
115
116