blob: f0460aa0c9cf0f8a1d653c86bf5e3ce29d0373c8 [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\
151 $(XML_INTDIR)/list.o\
152 $(XML_INTDIR)/nanoftp.o\
153 $(XML_INTDIR)/nanohttp.o\
154 $(XML_INTDIR)/parser.o\
155 $(XML_INTDIR)/parserInternals.o\
Igor Zlatkovicf3bffaf2003-02-08 17:53:46 +0000156 $(XML_INTDIR)/relaxng.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000157 $(XML_INTDIR)/SAX.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000158 $(XML_INTDIR)/SAX2.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000159 $(XML_INTDIR)/threads.o\
160 $(XML_INTDIR)/tree.o\
161 $(XML_INTDIR)/uri.o\
162 $(XML_INTDIR)/valid.o\
163 $(XML_INTDIR)/xinclude.o\
164 $(XML_INTDIR)/xlink.o\
165 $(XML_INTDIR)/xmlIO.o\
166 $(XML_INTDIR)/xmlmemory.o\
Igor Zlatkovic3f752e22002-12-16 18:45:29 +0000167 $(XML_INTDIR)/xmlreader.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000168 $(XML_INTDIR)/xmlregexp.o\
169 $(XML_INTDIR)/xmlschemas.o\
170 $(XML_INTDIR)/xmlschemastypes.o\
171 $(XML_INTDIR)/xmlunicode.o\
172 $(XML_INTDIR)/xpath.o\
173 $(XML_INTDIR)/xpointer.o
174
175XML_SRCS = $(subst .o,.c,$(subst $(XML_INTDIR)/,$(XML_SRCDIR)/,$(XML_OBJS)))
176
177# Static libxml object files.
178XML_OBJS_A = $(XML_INTDIR_A)/c14n.o\
179 $(XML_INTDIR_A)/catalog.o\
180 $(XML_INTDIR_A)/debugXML.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000181 $(XML_INTDIR_A)/dict.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000182 $(XML_INTDIR_A)/DOCBparser.o\
183 $(XML_INTDIR_A)/encoding.o\
184 $(XML_INTDIR_A)/entities.o\
185 $(XML_INTDIR_A)/error.o\
186 $(XML_INTDIR_A)/globals.o\
187 $(XML_INTDIR_A)/hash.o\
188 $(XML_INTDIR_A)/HTMLparser.o\
189 $(XML_INTDIR_A)/HTMLtree.o\
190 $(XML_INTDIR_A)/list.o\
191 $(XML_INTDIR_A)/nanoftp.o\
192 $(XML_INTDIR_A)/nanohttp.o\
193 $(XML_INTDIR_A)/parser.o\
194 $(XML_INTDIR_A)/parserInternals.o\
Igor Zlatkovicf3bffaf2003-02-08 17:53:46 +0000195 $(XML_INTDIR_A)/relaxng.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000196 $(XML_INTDIR_A)/SAX.o\
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000197 $(XML_INTDIR_A)/SAX2.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000198 $(XML_INTDIR_A)/threads.o\
199 $(XML_INTDIR_A)/tree.o\
200 $(XML_INTDIR_A)/uri.o\
201 $(XML_INTDIR_A)/valid.o\
202 $(XML_INTDIR_A)/xinclude.o\
203 $(XML_INTDIR_A)/xlink.o\
204 $(XML_INTDIR_A)/xmlIO.o\
205 $(XML_INTDIR_A)/xmlmemory.o\
Igor Zlatkovic3f752e22002-12-16 18:45:29 +0000206 $(XML_INTDIR_A)/xmlreader.o\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000207 $(XML_INTDIR_A)/xmlregexp.o\
208 $(XML_INTDIR_A)/xmlschemas.o\
209 $(XML_INTDIR_A)/xmlschemastypes.o\
210 $(XML_INTDIR_A)/xmlunicode.o\
211 $(XML_INTDIR_A)/xpath.o\
212 $(XML_INTDIR_A)/xpointer.o
213
214XML_SRCS_A = $(subst .o,.c,$(subst $(XML_INTDIR_A)/,$(XML_SRCDIR)/,$(XML_OBJS_A)))
215
216# Xmllint and friends executables.
217UTILS = $(BINDIR)/xmllint.exe\
218 $(BINDIR)/xmlcatalog.exe\
219 $(BINDIR)/testAutomata.exe\
220 $(BINDIR)/testC14N.exe\
221 $(BINDIR)/testDocbook.exe\
222 $(BINDIR)/testHTML.exe\
Igor Zlatkovic3f752e22002-12-16 18:45:29 +0000223 $(BINDIR)/testReader.exe\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000224 $(BINDIR)/testRegexp.exe\
Igor Zlatkovicf3bffaf2003-02-08 17:53:46 +0000225 $(BINDIR)/testRelax.exe\
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000226 $(BINDIR)/testSAX.exe\
227 $(BINDIR)/testSchemas.exe\
228 $(BINDIR)/testURI.exe\
229 $(BINDIR)/testXPath.exe
230ifeq ($(WITH_THREADS),yes)
231UTILS += $(BINDIR)/testThreadsWin32.exe
232endif
233ifeq ($(WITH_THREADS),ctls)
234UTILS += $(BINDIR)/testThreadsWin32.exe
235endif
236ifeq ($(WITH_THREADS),native)
237UTILS += $(BINDIR)/testThreadsWin32.exe
238endif
239ifeq ($(WITH_THREADS),posix)
240UTILS += $(BINDIR)/testThreads.exe
241endif
242
243all : dep libxml libxmla utils
244
245libxml : $(BINDIR)/$(XML_SO)
246
247libxmla : $(BINDIR)/$(XML_A)
248
249utils : $(UTILS)
250
251clean :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000252 cmd.exe /C if exist $(XML_INTDIR) rmdir /S /Q $(XML_INTDIR)
253 cmd.exe /C if exist $(XML_INTDIR_A) rmdir /S /Q $(XML_INTDIR_A)
254 cmd.exe /C if exist $(UTILS_INTDIR) rmdir /S /Q $(UTILS_INTDIR)
255 cmd.exe /C if exist $(BINDIR) rmdir /S /Q $(BINDIR)
256 cmd.exe /C if exist depends.mingw del depends.mingw
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000257
258distclean : clean
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000259 cmd.exe /C if exist config.* del config.*
260 cmd.exe /C if exist Makefile del Makefile
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000261
262rebuild : clean all
263
264install : all
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000265 cmd.exe /C if not exist $(INCPREFIX)\libxml mkdir $(INCPREFIX)\libxml
266 cmd.exe /C if not exist $(BINPREFIX) mkdir $(BINPREFIX)
267 cmd.exe /C if not exist $(LIBPREFIX) mkdir $(LIBPREFIX)
268 cmd.exe /C copy $(XML_SRCDIR)\include\libxml\*.h $(INCPREFIX)\libxml
269 cmd.exe /C copy $(BINDIR)\$(XML_SO) $(SOPREFIX)
270 cmd.exe /C copy $(BINDIR)\$(XML_A) $(LIBPREFIX)
271 cmd.exe /C copy $(BINDIR)\$(XML_IMP) $(LIBPREFIX)
272 cmd.exe /C copy $(BINDIR)\*.exe $(BINPREFIX)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000273
274# This is a target for me, to make a binary distribution. Not for the public use,
275# keep your hands off :-)
276BDVERSION = $(LIBXML_MAJOR_VERSION).$(LIBXML_MINOR_VERSION).$(LIBXML_MICRO_VERSION)
277BDPREFIX = $(XML_BASENAME)-$(BDVERSION).win32
278bindist : all
279 $(MAKE) PREFIX=$(BDPREFIX) BINPREFIX=$(BDPREFIX)/util install
280 cscript //NoLogo configure.js genreadme $(XML_BASENAME) $(BDVERSION) $(BDPREFIX)\readme.txt
281
282
283# Creates the dependency file
284dep :
285 $(CC) $(CFLAGS) -M $(XML_SRCS) > depends.mingw
286
287
288# Makes the output directory.
289$(BINDIR) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000290 cmd.exe /C if not exist $(BINDIR) mkdir $(BINDIR)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000291
292
293# Makes the libxml intermediate directory.
294$(XML_INTDIR) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000295 cmd.exe /C if not exist $(XML_INTDIR) mkdir $(XML_INTDIR)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000296
297# Makes the static libxml intermediate directory.
298$(XML_INTDIR_A) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000299 cmd.exe /C if not exist $(XML_INTDIR_A) mkdir $(XML_INTDIR_A)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000300
301# An implicit rule for libxml compilation.
302$(XML_INTDIR)/%.o : $(XML_SRCDIR)/%.c
303 $(CC) $(CFLAGS) -o $@ -c $<
304
305# An implicit rule for static libxml compilation.
306$(XML_INTDIR_A)/%.o : $(XML_SRCDIR)/%.c
307 $(CC) $(CFLAGS) -DLIBXML_STATIC -o $@ -c $<
308
309
310# Compiles libxml source. Uses the implicit rule for commands.
311$(XML_OBJS) : $(XML_INTDIR)
312
313# Compiles static libxml source. Uses the implicit rule for commands.
314$(XML_OBJS_A) : $(XML_INTDIR_A)
315
316# Creates the libxml shared object.
317XMLSO_LDFLAGS = $(LDFLAGS) -shared -Wl,--dll -Wl,--out-implib,$(BINDIR)/$(XML_IMP)
318$(BINDIR)/$(XML_SO) : $(BINDIR) $(XML_OBJS)
319 $(LD) $(XMLSO_LDFLAGS) -o $(BINDIR)/$(XML_SO) $(XML_OBJS) $(LIBS)
320
321# Creates the libxml archive.
322$(BINDIR)/$(XML_A) : $(BINDIR) $(XML_OBJS_A)
323 $(AR) $(ARFLAGS) $(BINDIR)\$(XML_A) $(XML_OBJS_A)
324
325
326# Makes the utils intermediate directory.
327$(UTILS_INTDIR) :
Igor Zlatkovic1bab92d2003-08-28 10:24:40 +0000328 cmd.exe /C if not exist $(UTILS_INTDIR) mkdir $(UTILS_INTDIR)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000329
330# An implicit rule for xmllint and friends.
331ifeq ($(STATIC),1)
332$(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
333 $(CC) -DLIBXML_STATIC $(CFLAGS) -o $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -c $<
Igor Zlatkovic002372e2002-11-22 18:07:37 +0000334 $(LD) $(LDFLAGS) -o $@ $(subst .c,.o,$(UTILS_INTDIR)/$(<F)) -l$(XML_BASENAME) $(LIBS)
Igor Zlatkovicbd1a3062002-11-14 17:43:24 +0000335else
336$(BINDIR)/%.exe : $(UTILS_SRCDIR)/%.c
337 $(CC) $(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 +0000339endif
340
341# Builds xmllint and friends. Uses the implicit rule for commands.
342$(UTILS) : $(UTILS_INTDIR) $(BINDIR) libxml libxmla
343
344# Source dependencies
345#-include depends.mingw
346