blob: 5edaae5739911afa28907eba34f317a6a52521e6 [file] [log] [blame]
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +00001# Makefile for libxml2, specific for Windows, GCC (mingw) and GNU make.
2#
3# Take a look at the beginning and modify the variables to suit your
4# environment. Having done that, you can do a
5#
6# nmake [all] to build the libxml and the accompanying utilities.
7# nmake clean to remove all compiler output files and return to a
8# clean state.
9# nmake rebuild to rebuild everything from scratch. This basically does
10# a 'nmake clean' and then a 'nmake all'.
11# nmake install to install the library and its header files.
12#
Daniel Veillardbeb70bd2002-12-18 14:53:54 +000013# November 2002, Igor Zlatkovic <igor@zlatkovic.com>
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +000014
15AUTOCONF = .\config.mingw
16
17# If you cannot run the configuration script, which would take the burden of
18# editing this file from your back, then remove the following line...
19include $(AUTOCONF)
20# ...and enable the following lines and adapt them to your environment.
21#XML_SRCDIR = ..
22#UTILS_SRCDIR = ..
23#BINDIR = binaries
24#LIBXML_MAJOR_VERSION = 0 # set this to the right value.
25#LIBXML_MINOR_VERSION = 0 # set this to the right value.
26#LIBXML_MICRO_VERSION = 0 # set this to the right value.
27#WITH_TRIO = 0
28#WITH_THREADS = 0
29#WITH_FTP = 1
30#WITH_HTTP = 1
31#WITH_HTML = 1
32#WITH_C14N = 1
33#WITH_CATALOG = 1
34#WITH_DOCB = 1
35#WITH_XPATH = 1
36#WITH_XPTR = 1
37#WITH_XINCLUDE = 1
38#WITH_ICONV = 1
39#WITH_ZLIB = 0
40#WITH_DEBUG = 1
41#WITH_MEM_DEBUG = 0
42#WITH_SCHEMAS = 1
43#DEBUG = 0
44#STATIC = 0
45#PREFIX = . # set this to the right value.
46#BINPREFIX = $(PREFIX)\bin
47#INCPREFIX = $(PREFIX)\include
48#LIBPREFIX = $(PREFIX)\lib
49#SOPREFIX = $(PREFIX)\lib
50#INCLUDE += ;$(INCPREFIX)
51#LIB += ;$(LIBPREFIX)
52
53
54# There should never be a need to modify anything below this line.
55# ----------------------------------------------------------------
56
57
58# Names of various input and output components.
59XML_NAME = xml2
60XML_BASENAME = lib$(XML_NAME)
61XML_SO = $(XML_BASENAME).dll
62XML_IMP = $(XML_BASENAME).lib
63XML_A = $(XML_BASENAME).a
64
65# Place where we let the compiler put its intermediate trash.
66XML_INTDIR = $(XML_BASENAME).int
67XML_INTDIR_A = $(XML_BASENAME)_a.int
68UTILS_INTDIR = utils.int
69
70# The preprocessor and its options.
71CPP = gcc.exe -E
72CPPFLAGS += -I$(XML_SRCDIR)/include
73ifeq ($(WITH_THREADS),1)
74CPPFLAGS += -D_REENTRANT
75endif
76
77# The compiler and its options.
78CC = gcc.exe
79CFLAGS += -DWIN32 -D_WINDOWS -D_MBCS
80CFLAGS += -I$(XML_SRCDIR) -I$(XML_SRCDIR)/include -I$(INCPREFIX)
81ifneq ($(WITH_THREADS),no)
82CFLAGS += -D_REENTRANT
83endif
84ifeq ($(WITH_THREADS),yes)
85CFLAGS += -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS
86endif
87ifeq ($(WITH_THREADS),ctls)
88CFLAGS += -DHAVE_WIN32_THREADS -DHAVE_COMPILER_TLS
89endif
90ifeq ($(WITH_THREADS),native)
91CFLAGS += -DHAVE_WIN32_THREADS
92endif
93ifeq ($(WITH_THREADS),posix)
94CFLAGS += -DHAVE_PTHREAD_H
95endif
96ifeq ($(WITH_ZLIB),1)
97CFLAGS += -DHAVE_ZLIB_H
98endif
99
100# The linker and its options.
101LD = gcc.exe
102LDFLAGS += -Wl,--major-image-version,$(LIBXML_MAJOR_VERSION)
103LDFLAGS += -Wl,--minor-image-version,$(LIBXML_MINOR_VERSION)
104LDFLAGS += -Wl,-L,$(BINDIR) -Wl,-L,$(LIBPREFIX)
105LIBS =
106ifeq ($(WITH_FTP),1)
107CFLAGS += -D_WINSOCKAPI_
108LIBS += -lwsock32
109endif
110ifeq ($(WITH_HTTP),1)
111CFLAGS += -D_WINSOCKAPI_
112LIBS += -lwsock32
113endif
114ifeq ($(WITH_ICONV),1)
115LIBS += -liconv
116endif
117ifeq ($(WITH_ZLIB),1)
118LIBS += -lzlib
119endif
120ifeq ($(WITH_THREADS),posix)
121LIBS += -lpthreadGC
122endif
123
124# The archiver and its options.
125AR = ar.exe
126ARFLAGS = -r
127
128# Optimisation and debug symbols.
129ifeq ($(DEBUG),1)
130CFLAGS += -D_DEBUG -g
131LDFLAGS +=
132else
133CFLAGS += -DNDEBUG -O2
134LDFLAGS +=
135endif
136
137
138# Libxml object files.
139XML_OBJS = $(XML_INTDIR)/c14n.o\
140 $(XML_INTDIR)/catalog.o\
Daniel Veillard1e5e4382003-10-21 19:15:44 +0000141 $(XML_INTDIR)/chvalid.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000142 $(XML_INTDIR)/debugXML.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000143 $(XML_INTDIR)/dict.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000144 $(XML_INTDIR)/DOCBparser.o\
145 $(XML_INTDIR)/encoding.o\
146 $(XML_INTDIR)/entities.o\
147 $(XML_INTDIR)/error.o\
148 $(XML_INTDIR)/globals.o\
149 $(XML_INTDIR)/hash.o\
150 $(XML_INTDIR)/HTMLparser.o\
151 $(XML_INTDIR)/HTMLtree.o\
Daniel Veillard141310a2003-10-06 08:47:56 +0000152 $(XML_INTDIR)/legacy.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000153 $(XML_INTDIR)/list.o\
154 $(XML_INTDIR)/nanoftp.o\
155 $(XML_INTDIR)/nanohttp.o\
156 $(XML_INTDIR)/parser.o\
157 $(XML_INTDIR)/parserInternals.o\
Igor Zlatkovicf3bffaf2003-02-08 17:53:46 +0000158 $(XML_INTDIR)/relaxng.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000159 $(XML_INTDIR)/SAX.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000160 $(XML_INTDIR)/SAX2.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000161 $(XML_INTDIR)/threads.o\
162 $(XML_INTDIR)/tree.o\
163 $(XML_INTDIR)/uri.o\
164 $(XML_INTDIR)/valid.o\
165 $(XML_INTDIR)/xinclude.o\
166 $(XML_INTDIR)/xlink.o\
167 $(XML_INTDIR)/xmlIO.o\
168 $(XML_INTDIR)/xmlmemory.o\
Igor Zlatkovic3f752e22002-12-16 18:45:29 +0000169 $(XML_INTDIR)/xmlreader.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000170 $(XML_INTDIR)/xmlregexp.o\
171 $(XML_INTDIR)/xmlschemas.o\
172 $(XML_INTDIR)/xmlschemastypes.o\
173 $(XML_INTDIR)/xmlunicode.o\
174 $(XML_INTDIR)/xpath.o\
175 $(XML_INTDIR)/xpointer.o
176
177XML_SRCS = $(subst .o,.c,$(subst $(XML_INTDIR)/,$(XML_SRCDIR)/,$(XML_OBJS)))
178
179# Static libxml object files.
180XML_OBJS_A = $(XML_INTDIR_A)/c14n.o\
181 $(XML_INTDIR_A)/catalog.o\
Daniel Veillard1e5e4382003-10-21 19:15:44 +0000182 $(XML_INTDIR_A)/chvalid.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000183 $(XML_INTDIR_A)/debugXML.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000184 $(XML_INTDIR_A)/dict.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000185 $(XML_INTDIR_A)/DOCBparser.o\
186 $(XML_INTDIR_A)/encoding.o\
187 $(XML_INTDIR_A)/entities.o\
188 $(XML_INTDIR_A)/error.o\
189 $(XML_INTDIR_A)/globals.o\
190 $(XML_INTDIR_A)/hash.o\
191 $(XML_INTDIR_A)/HTMLparser.o\
192 $(XML_INTDIR_A)/HTMLtree.o\
Daniel Veillard141310a2003-10-06 08:47:56 +0000193 $(XML_INTDIR_A)/legacy.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000194 $(XML_INTDIR_A)/list.o\
195 $(XML_INTDIR_A)/nanoftp.o\
196 $(XML_INTDIR_A)/nanohttp.o\
197 $(XML_INTDIR_A)/parser.o\
198 $(XML_INTDIR_A)/parserInternals.o\
Igor Zlatkovicf3bffaf2003-02-08 17:53:46 +0000199 $(XML_INTDIR_A)/relaxng.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000200 $(XML_INTDIR_A)/SAX.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000201 $(XML_INTDIR_A)/SAX2.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000202 $(XML_INTDIR_A)/threads.o\
203 $(XML_INTDIR_A)/tree.o\
204 $(XML_INTDIR_A)/uri.o\
205 $(XML_INTDIR_A)/valid.o\
206 $(XML_INTDIR_A)/xinclude.o\
207 $(XML_INTDIR_A)/xlink.o\
208 $(XML_INTDIR_A)/xmlIO.o\
209 $(XML_INTDIR_A)/xmlmemory.o\
Igor Zlatkovic3f752e22002-12-16 18:45:29 +0000210 $(XML_INTDIR_A)/xmlreader.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000211 $(XML_INTDIR_A)/xmlregexp.o\
212 $(XML_INTDIR_A)/xmlschemas.o\
213 $(XML_INTDIR_A)/xmlschemastypes.o\
214 $(XML_INTDIR_A)/xmlunicode.o\
215 $(XML_INTDIR_A)/xpath.o\
216 $(XML_INTDIR_A)/xpointer.o
217
218XML_SRCS_A = $(subst .o,.c,$(subst $(XML_INTDIR_A)/,$(XML_SRCDIR)/,$(XML_OBJS_A)))
219
220# Xmllint and friends executables.
221UTILS = $(BINDIR)/xmllint.exe\
222 $(BINDIR)/xmlcatalog.exe\
223 $(BINDIR)/testAutomata.exe\
224 $(BINDIR)/testC14N.exe\
225 $(BINDIR)/testDocbook.exe\
226 $(BINDIR)/testHTML.exe\
Igor Zlatkovic3f752e22002-12-16 18:45:29 +0000227 $(BINDIR)/testReader.exe\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000228 $(BINDIR)/testRegexp.exe\
Igor Zlatkovicf3bffaf2003-02-08 17:53:46 +0000229 $(BINDIR)/testRelax.exe\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000230 $(BINDIR)/testSAX.exe\
231 $(BINDIR)/testSchemas.exe\
232 $(BINDIR)/testURI.exe\
233 $(BINDIR)/testXPath.exe
234ifeq ($(WITH_THREADS),yes)
235UTILS += $(BINDIR)/testThreadsWin32.exe
236endif
237ifeq ($(WITH_THREADS),ctls)
238UTILS += $(BINDIR)/testThreadsWin32.exe
239endif
240ifeq ($(WITH_THREADS),native)
241UTILS += $(BINDIR)/testThreadsWin32.exe
242endif
243ifeq ($(WITH_THREADS),posix)
244UTILS += $(BINDIR)/testThreads.exe
245endif
246
247all : dep libxml libxmla utils
248
249libxml : $(BINDIR)/$(XML_SO)
250
251libxmla : $(BINDIR)/$(XML_A)
252
253utils : $(UTILS)
254
255clean :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000256 cmd.exe /C if exist $(XML_INTDIR) rmdir /S /Q $(XML_INTDIR)
257 cmd.exe /C if exist $(XML_INTDIR_A) rmdir /S /Q $(XML_INTDIR_A)
258 cmd.exe /C if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)
259 cmd.exe /C if exist $(BINDIR) rmdir /S /Q $(BINDIR)
260 cmd.exe /C if exist depends.mingw del depends.mingw
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000261
262distclean : clean
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000263 cmd.exe /C if exist config.* del config.*
264 cmd.exe /C if exist Makefile del Makefile
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000265
266rebuild : clean all
267
268install : all
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000269 cmd.exe /C if not exist $(INCPREFIX)\libxml mkdir $(INCPREFIX)\libxml
270 cmd.exe /C if not exist $(BINPREFIX) mkdir $(BINPREFIX)
271 cmd.exe /C if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)
272 cmd.exe /C copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml
273 cmd.exe /C copy $(BINDIR)\$(XML_SO) $(SOPREFIX)
274 cmd.exe /C copy $(BINDIR)\$(XML_A) $(LIBPREFIX)
275 cmd.exe /C copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)
276 cmd.exe /C copy $(BINDIR)\*.exe $(BINPREFIX)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000277
278# This is a target for me, to make a binary distribution. Not for the public use,
279# keep your hands off :-)
280BDVERSION = $(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION).$(LIBXML_MICRO_VERSION)
281BDPREFIX = $(XML_BASENAME)-$(BDVERSION).win32
282bindist : all
283 $(MAKE) PREFIX=$(BDPREFIX) BINPREFIX=$(BDPREFIX)/util install
284 cscript //NoLogo configure.js genreadme $(XML_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt
285
286
287# Creates the dependency file
288dep :
289 $(CC) $(CFLAGS) -M $(XML_SRCS) > depends.mingw
290
291
292# Makes the output directory.
293$(BINDIR) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000294 cmd.exe /C if not exist $(BINDIR) mkdir $(BINDIR)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000295
296
297# Makes the libxml intermediate directory.
298$(XML_INTDIR) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000299 cmd.exe /C if not exist $(XML_INTDIR) mkdir $(XML_INTDIR)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000300
301# Makes the static libxml intermediate directory.
302$(XML_INTDIR_A) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000303 cmd.exe /C if not exist $(XML_INTDIR_A) mkdir $(XML_INTDIR_A)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000304
305# An implicit rule for libxml compilation.
306$(XML_INTDIR)/%.o : $(XML_SRCDIR)/%.c
307 $(CC) $(CFLAGS) -o $@ -c $<
308
309# An implicit rule for static libxml compilation.
310$(XML_INTDIR_A)/%.o : $(XML_SRCDIR)/%.c
311 $(CC) $(CFLAGS) -DLIBXML_STATIC -o $@ -c $<
312
313
314# Compiles libxml source. Uses the implicit rule for commands.
315$(XML_OBJS) : $(XML_INTDIR)
316
317# Compiles static libxml source. Uses the implicit rule for commands.
318$(XML_OBJS_A) : $(XML_INTDIR_A)
319
320# Creates the libxml shared object.
321XMLSO_LDFLAGS = $(LDFLAGS) -shared -Wl,--dll -Wl,--out-implib,$(BINDIR)/$(XML_IMP)
322$(BINDIR)/$(XML_SO) : $(BINDIR) $(XML_OBJS)
323 $(LD) $(XMLSO_LDFLAGS) -o $(BINDIR)/$(XML_SO) $(XML_OBJS) $(LIBS)
324
325# Creates the libxml archive.
326$(BINDIR)/$(XML_A) : $(BINDIR) $(XML_OBJS_A)
327 $(AR) $(ARFLAGS) $(BINDIR)\$(XML_A) $(XML_OBJS_A)
328
329
330# Makes the utils intermediate directory.
331$(UTILS_INTDIR) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000332 cmd.exe /C if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000333
334# An implicit rule for xmllint and friends.
335ifeq ($(STATIC),1)
336$(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
337 $(CC) -DLIBXML_STATIC $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $<
Igor Zlatkovic002372e2002-11-22 18:07:37 +0000338 $(LD) $(LDFLAGS) -o $@ $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -l$(XML_BASENAME) $(LIBS)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000339else
340$(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
341 $(CC) $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $<
Igor Zlatkovic002372e2002-11-22 18:07:37 +0000342 $(LD) $(LDFLAGS) -o $@ $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -l$(XML_BASENAME) $(LIBS)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000343endif
344
345# Builds xmllint and friends. Uses the implicit rule for commands.
346$(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxml libxmla
347
348# Source dependencies
349#-include depends.mingw
350