blob: c5abb9f25436393e945602ea7f19753882a814f5 [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\
141 $(XML_INTDIR)/debugXML.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000142 $(XML_INTDIR)/dict.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000143 $(XML_INTDIR)/DOCBparser.o\
144 $(XML_INTDIR)/encoding.o\
145 $(XML_INTDIR)/entities.o\
146 $(XML_INTDIR)/error.o\
147 $(XML_INTDIR)/globals.o\
148 $(XML_INTDIR)/hash.o\
149 $(XML_INTDIR)/HTMLparser.o\
150 $(XML_INTDIR)/HTMLtree.o\
Daniel Veillard141310a2003-10-06 08:47:56 +0000151 $(XML_INTDIR)/legacy.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000152 $(XML_INTDIR)/list.o\
153 $(XML_INTDIR)/nanoftp.o\
154 $(XML_INTDIR)/nanohttp.o\
155 $(XML_INTDIR)/parser.o\
156 $(XML_INTDIR)/parserInternals.o\
Igor Zlatkovicf3bffaf2003-02-08 17:53:46 +0000157 $(XML_INTDIR)/relaxng.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000158 $(XML_INTDIR)/SAX.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000159 $(XML_INTDIR)/SAX2.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000160 $(XML_INTDIR)/threads.o\
161 $(XML_INTDIR)/tree.o\
162 $(XML_INTDIR)/uri.o\
163 $(XML_INTDIR)/valid.o\
164 $(XML_INTDIR)/xinclude.o\
165 $(XML_INTDIR)/xlink.o\
166 $(XML_INTDIR)/xmlIO.o\
167 $(XML_INTDIR)/xmlmemory.o\
Igor Zlatkovic3f752e22002-12-16 18:45:29 +0000168 $(XML_INTDIR)/xmlreader.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000169 $(XML_INTDIR)/xmlregexp.o\
170 $(XML_INTDIR)/xmlschemas.o\
171 $(XML_INTDIR)/xmlschemastypes.o\
172 $(XML_INTDIR)/xmlunicode.o\
173 $(XML_INTDIR)/xpath.o\
174 $(XML_INTDIR)/xpointer.o
175
176XML_SRCS = $(subst .o,.c,$(subst $(XML_INTDIR)/,$(XML_SRCDIR)/,$(XML_OBJS)))
177
178# Static libxml object files.
179XML_OBJS_A = $(XML_INTDIR_A)/c14n.o\
180 $(XML_INTDIR_A)/catalog.o\
181 $(XML_INTDIR_A)/debugXML.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000182 $(XML_INTDIR_A)/dict.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000183 $(XML_INTDIR_A)/DOCBparser.o\
184 $(XML_INTDIR_A)/encoding.o\
185 $(XML_INTDIR_A)/entities.o\
186 $(XML_INTDIR_A)/error.o\
187 $(XML_INTDIR_A)/globals.o\
188 $(XML_INTDIR_A)/hash.o\
189 $(XML_INTDIR_A)/HTMLparser.o\
190 $(XML_INTDIR_A)/HTMLtree.o\
Daniel Veillard141310a2003-10-06 08:47:56 +0000191 $(XML_INTDIR_A)/legacy.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000192 $(XML_INTDIR_A)/list.o\
193 $(XML_INTDIR_A)/nanoftp.o\
194 $(XML_INTDIR_A)/nanohttp.o\
195 $(XML_INTDIR_A)/parser.o\
196 $(XML_INTDIR_A)/parserInternals.o\
Igor Zlatkovicf3bffaf2003-02-08 17:53:46 +0000197 $(XML_INTDIR_A)/relaxng.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000198 $(XML_INTDIR_A)/SAX.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000199 $(XML_INTDIR_A)/SAX2.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000200 $(XML_INTDIR_A)/threads.o\
201 $(XML_INTDIR_A)/tree.o\
202 $(XML_INTDIR_A)/uri.o\
203 $(XML_INTDIR_A)/valid.o\
204 $(XML_INTDIR_A)/xinclude.o\
205 $(XML_INTDIR_A)/xlink.o\
206 $(XML_INTDIR_A)/xmlIO.o\
207 $(XML_INTDIR_A)/xmlmemory.o\
Igor Zlatkovic3f752e22002-12-16 18:45:29 +0000208 $(XML_INTDIR_A)/xmlreader.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000209 $(XML_INTDIR_A)/xmlregexp.o\
210 $(XML_INTDIR_A)/xmlschemas.o\
211 $(XML_INTDIR_A)/xmlschemastypes.o\
212 $(XML_INTDIR_A)/xmlunicode.o\
213 $(XML_INTDIR_A)/xpath.o\
214 $(XML_INTDIR_A)/xpointer.o
215
216XML_SRCS_A = $(subst .o,.c,$(subst $(XML_INTDIR_A)/,$(XML_SRCDIR)/,$(XML_OBJS_A)))
217
218# Xmllint and friends executables.
219UTILS = $(BINDIR)/xmllint.exe\
220 $(BINDIR)/xmlcatalog.exe\
221 $(BINDIR)/testAutomata.exe\
222 $(BINDIR)/testC14N.exe\
223 $(BINDIR)/testDocbook.exe\
224 $(BINDIR)/testHTML.exe\
Igor Zlatkovic3f752e22002-12-16 18:45:29 +0000225 $(BINDIR)/testReader.exe\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000226 $(BINDIR)/testRegexp.exe\
Igor Zlatkovicf3bffaf2003-02-08 17:53:46 +0000227 $(BINDIR)/testRelax.exe\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000228 $(BINDIR)/testSAX.exe\
229 $(BINDIR)/testSchemas.exe\
230 $(BINDIR)/testURI.exe\
231 $(BINDIR)/testXPath.exe
232ifeq ($(WITH_THREADS),yes)
233UTILS += $(BINDIR)/testThreadsWin32.exe
234endif
235ifeq ($(WITH_THREADS),ctls)
236UTILS += $(BINDIR)/testThreadsWin32.exe
237endif
238ifeq ($(WITH_THREADS),native)
239UTILS += $(BINDIR)/testThreadsWin32.exe
240endif
241ifeq ($(WITH_THREADS),posix)
242UTILS += $(BINDIR)/testThreads.exe
243endif
244
245all : dep libxml libxmla utils
246
247libxml : $(BINDIR)/$(XML_SO)
248
249libxmla : $(BINDIR)/$(XML_A)
250
251utils : $(UTILS)
252
253clean :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000254 cmd.exe /C if exist $(XML_INTDIR) rmdir /S /Q $(XML_INTDIR)
255 cmd.exe /C if exist $(XML_INTDIR_A) rmdir /S /Q $(XML_INTDIR_A)
256 cmd.exe /C if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)
257 cmd.exe /C if exist $(BINDIR) rmdir /S /Q $(BINDIR)
258 cmd.exe /C if exist depends.mingw del depends.mingw
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000259
260distclean : clean
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000261 cmd.exe /C if exist config.* del config.*
262 cmd.exe /C if exist Makefile del Makefile
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000263
264rebuild : clean all
265
266install : all
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000267 cmd.exe /C if not exist $(INCPREFIX)\libxml mkdir $(INCPREFIX)\libxml
268 cmd.exe /C if not exist $(BINPREFIX) mkdir $(BINPREFIX)
269 cmd.exe /C if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)
270 cmd.exe /C copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml
271 cmd.exe /C copy $(BINDIR)\$(XML_SO) $(SOPREFIX)
272 cmd.exe /C copy $(BINDIR)\$(XML_A) $(LIBPREFIX)
273 cmd.exe /C copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)
274 cmd.exe /C copy $(BINDIR)\*.exe $(BINPREFIX)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000275
276# This is a target for me, to make a binary distribution. Not for the public use,
277# keep your hands off :-)
278BDVERSION = $(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION).$(LIBXML_MICRO_VERSION)
279BDPREFIX = $(XML_BASENAME)-$(BDVERSION).win32
280bindist : all
281 $(MAKE) PREFIX=$(BDPREFIX) BINPREFIX=$(BDPREFIX)/util install
282 cscript //NoLogo configure.js genreadme $(XML_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt
283
284
285# Creates the dependency file
286dep :
287 $(CC) $(CFLAGS) -M $(XML_SRCS) > depends.mingw
288
289
290# Makes the output directory.
291$(BINDIR) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000292 cmd.exe /C if not exist $(BINDIR) mkdir $(BINDIR)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000293
294
295# Makes the libxml intermediate directory.
296$(XML_INTDIR) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000297 cmd.exe /C if not exist $(XML_INTDIR) mkdir $(XML_INTDIR)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000298
299# Makes the static libxml intermediate directory.
300$(XML_INTDIR_A) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000301 cmd.exe /C if not exist $(XML_INTDIR_A) mkdir $(XML_INTDIR_A)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000302
303# An implicit rule for libxml compilation.
304$(XML_INTDIR)/%.o : $(XML_SRCDIR)/%.c
305 $(CC) $(CFLAGS) -o $@ -c $<
306
307# An implicit rule for static libxml compilation.
308$(XML_INTDIR_A)/%.o : $(XML_SRCDIR)/%.c
309 $(CC) $(CFLAGS) -DLIBXML_STATIC -o $@ -c $<
310
311
312# Compiles libxml source. Uses the implicit rule for commands.
313$(XML_OBJS) : $(XML_INTDIR)
314
315# Compiles static libxml source. Uses the implicit rule for commands.
316$(XML_OBJS_A) : $(XML_INTDIR_A)
317
318# Creates the libxml shared object.
319XMLSO_LDFLAGS = $(LDFLAGS) -shared -Wl,--dll -Wl,--out-implib,$(BINDIR)/$(XML_IMP)
320$(BINDIR)/$(XML_SO) : $(BINDIR) $(XML_OBJS)
321 $(LD) $(XMLSO_LDFLAGS) -o $(BINDIR)/$(XML_SO) $(XML_OBJS) $(LIBS)
322
323# Creates the libxml archive.
324$(BINDIR)/$(XML_A) : $(BINDIR) $(XML_OBJS_A)
325 $(AR) $(ARFLAGS) $(BINDIR)\$(XML_A) $(XML_OBJS_A)
326
327
328# Makes the utils intermediate directory.
329$(UTILS_INTDIR) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000330 cmd.exe /C if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000331
332# An implicit rule for xmllint and friends.
333ifeq ($(STATIC),1)
334$(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
335 $(CC) -DLIBXML_STATIC $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $<
Igor Zlatkovic002372e2002-11-22 18:07:37 +0000336 $(LD) $(LDFLAGS) -o $@ $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -l$(XML_BASENAME) $(LIBS)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000337else
338$(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
339 $(CC) $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $<
Igor Zlatkovic002372e2002-11-22 18:07:37 +0000340 $(LD) $(LDFLAGS) -o $@ $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -l$(XML_BASENAME) $(LIBS)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000341endif
342
343# Builds xmllint and friends. Uses the implicit rule for commands.
344$(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxml libxmla
345
346# Source dependencies
347#-include depends.mingw
348