1################################################################
2# Process this file with top-level configure script to produce Makefile
3#
4# Copyright 2000 Clark Cooper
5#
6#  This file is part of EXPAT.
7#
8#  EXPAT is free software; you can redistribute it and/or modify it
9#  under the terms of the License (based on the MIT/X license) contained
10#  in the file COPYING that comes with this distribution.
11#
12# EXPAT IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
15# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
16# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
17# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18# SOFTWARE OR THE USE OR OTHER DEALINGS IN EXPAT.
19#
20
21SHELL = /bin/sh
22
23srcdir = .
24top_srcdir = .
25
26
27prefix = /usr/local
28exec_prefix = ${prefix}
29
30bindir = ${exec_prefix}/bin
31libdir = ${exec_prefix}/lib
32includedir = ${prefix}/include
33man1dir = ${prefix}/share/man/man1
34pkgconfigdir = $(libdir)/pkgconfig
35
36top_builddir = .
37
38
39INSTALL = /usr/bin/install -c
40INSTALL_PROGRAM = ${INSTALL}
41INSTALL_DATA = ${INSTALL} -m 644
42mkinstalldirs = $(SHELL) $(top_srcdir)/conftools/mkinstalldirs
43
44MANFILE = $(srcdir)/doc/xmlwf.1
45APIHEADER = $(srcdir)/lib/expat.h $(srcdir)/lib/expat_external.h
46LIBRARY = libexpat.la
47
48DESTDIR = $(INSTALL_ROOT)
49
50default:  buildlib xmlwf/xmlwf
51
52buildlib: $(LIBRARY) expat.pc
53
54all: $(LIBRARY) expat.pc xmlwf/xmlwf examples/elements examples/outline
55
56clean:
57	cd lib && rm -f $(LIBRARY) *.o *.lo && rm -rf .libs _libs
58	cd xmlwf && rm -f xmlwf *.o *.lo && rm -rf .libs _libs
59	cd examples && rm -f elements outline *.o *.lo && rm -rf .libs _libs
60	cd tests && rm -rf .libs runtests runtests.o runtestspp runtestspp.o
61	cd tests && rm -f chardata.o minicheck.o
62	rm -rf .libs libexpat.la
63	rm -f examples/core tests/core xmlwf/core
64
65clobber: clean
66
67distclean: clean
68	rm -f expat_config.h config.status config.log config.cache libtool
69	rm -f Makefile expat.pc
70
71extraclean: distclean
72	rm -f expat_config.h.in configure
73	rm -f aclocal.m4 m4/*
74	rm -f conftools/ltmain.sh conftools/install-sh conftools/config.guess conftools/config.sub
75
76check: tests/runtests tests/runtestspp
77	tests/runtests
78	tests/runtestspp
79
80install: xmlwf/xmlwf installlib
81	$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir)
82	$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) xmlwf/xmlwf $(DESTDIR)$(bindir)/xmlwf
83	$(INSTALL_DATA) $(MANFILE) $(DESTDIR)$(man1dir)
84
85installlib: $(LIBRARY) $(APIHEADER) expat.pc
86	$(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(includedir) $(DESTDIR)$(pkgconfigdir)
87	$(LIBTOOL) --mode=install $(INSTALL) $(LIBRARY) $(DESTDIR)$(libdir)/$(LIBRARY)
88	for FN in $(APIHEADER) ; do $(INSTALL_DATA) $$FN $(DESTDIR)$(includedir) ; done
89	$(INSTALL_DATA) expat.pc $(DESTDIR)$(pkgconfigdir)/expat.pc
90
91uninstall: uninstalllib
92	$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bindir)/xmlwf
93	rm -f $(DESTDIR)$(man1dir)/xmlwf.1
94
95uninstalllib:
96	$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(LIBRARY)
97	rm -f $(DESTDIR)$(includedir)/expat.h
98	rm -f $(DESTDIR)$(includedir)/expat_external.h
99	rm -f $(DESTDIR)$(pkgconfigdir)/expat.pc
100
101# for VPATH builds (invoked by configure)
102mkdir-init:
103	@for d in lib xmlwf examples tests ; do \
104		(mkdir $$d 2> /dev/null || test 1) ; \
105	done
106
107CC = gcc -std=gnu99
108CXX = g++
109LIBTOOL = $(SHELL) $(top_builddir)/libtool
110
111INCLUDES = -I$(srcdir)/lib -I.
112LDFLAGS = 
113CPPFLAGS =  -DHAVE_EXPAT_CONFIG_H
114CFLAGS = -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions
115CXXFLAGS = -g -O2 -Wall -fexceptions
116VSNFLAG = -version-info 7:0:6
117
118### autoconf this?
119LTFLAGS = --silent
120
121COMPILE = $(CC) $(INCLUDES) $(CFLAGS) $(DEFS) $(CPPFLAGS)
122CXXCOMPILE = $(CXX) $(INCLUDES) $(CXXFLAGS) $(DEFS) $(CPPFLAGS)
123LTCOMPILE = $(LIBTOOL) $(LTFLAGS) --mode=compile $(COMPILE)
124LINK_LIB = $(LIBTOOL) $(LTFLAGS) --mode=link $(COMPILE) -no-undefined $(VSNFLAG) -rpath $(libdir) $(LDFLAGS) -o $@
125LINK_EXE = $(LIBTOOL) $(LTFLAGS) --mode=link $(COMPILE) $(LDFLAGS) -o $@
126LINK_CXX_EXE = $(LIBTOOL) $(LTFLAGS) --mode=link $(CXXCOMPILE) $(LDFLAGS) -o $@
127
128LIB_OBJS = lib/xmlparse.lo lib/xmltok.lo lib/xmlrole.lo
129$(LIBRARY): $(LIB_OBJS)
130	$(LINK_LIB) $(LIB_OBJS)
131
132expat.pc: $(top_builddir)/config.status
133	cd $(top_builddir) && $(SHELL) ./config.status $@
134
135lib/xmlparse.lo: lib/xmlparse.c lib/expat.h lib/xmlrole.h lib/xmltok.h \
136	$(top_builddir)/expat_config.h lib/expat_external.h lib/internal.h
137
138lib/xmlrole.lo: lib/xmlrole.c lib/ascii.h lib/xmlrole.h \
139	$(top_builddir)/expat_config.h lib/expat_external.h lib/internal.h
140
141lib/xmltok.lo: lib/xmltok.c lib/xmltok_impl.c lib/xmltok_ns.c \
142	lib/ascii.h lib/asciitab.h lib/iasciitab.h lib/latin1tab.h \
143	lib/nametab.h lib/utf8tab.h lib/xmltok.h lib/xmltok_impl.h \
144	$(top_builddir)/expat_config.h lib/expat_external.h lib/internal.h
145
146
147XMLWF_OBJS = xmlwf/xmlwf.o xmlwf/xmlfile.o xmlwf/codepage.o xmlwf/unixfilemap.o
148xmlwf/xmlwf.o: xmlwf/xmlwf.c
149xmlwf/xmlfile.o: xmlwf/xmlfile.c
150xmlwf/codepage.o: xmlwf/codepage.c
151xmlwf/unixfilemap.o: xmlwf/unixfilemap.c
152xmlwf/xmlwf: $(XMLWF_OBJS) $(LIBRARY)
153	$(LINK_EXE) $(XMLWF_OBJS) $(LIBRARY)
154
155examples/elements.o: examples/elements.c
156examples/elements: examples/elements.o $(LIBRARY)
157	$(LINK_EXE) $< $(LIBRARY)
158
159examples/outline.o: examples/outline.c
160examples/outline: examples/outline.o $(LIBRARY)
161	$(LINK_EXE) $< $(LIBRARY)
162
163tests/chardata.o: tests/chardata.c tests/chardata.h
164tests/minicheck.o: tests/minicheck.c tests/minicheck.h
165tests/runtests.o: tests/runtests.c tests/chardata.h
166tests/runtests: tests/runtests.o tests/chardata.o tests/minicheck.o $(LIBRARY)
167	$(LINK_EXE) tests/runtests.o tests/chardata.o tests/minicheck.o $(LIBRARY)
168tests/runtestspp.o: tests/runtestspp.cpp tests/runtests.c tests/chardata.h
169tests/runtestspp: tests/runtestspp.o tests/chardata.o tests/minicheck.o $(LIBRARY)
170	$(LINK_CXX_EXE) tests/runtestspp.o tests/chardata.o tests/minicheck.o $(LIBRARY)
171
172tests/benchmark/benchmark.o: tests/benchmark/benchmark.c
173tests/benchmark/benchmark: tests/benchmark/benchmark.o $(LIBRARY)
174	$(LINK_EXE) tests/benchmark/benchmark.o $(LIBRARY)
175
176run-benchmark: tests/benchmark/benchmark
177	tests/benchmark/benchmark -n $(top_srcdir)/../testdata/largefiles/recset.xml 65535 3
178
179tests/xmlts.zip:
180	wget --output-document=tests/xmlts.zip \
181		http://www.w3.org/XML/Test/xmlts20080827.zip
182
183tests/XML-Test-Suite: tests/xmlts.zip
184	cd tests && unzip -q xmlts.zip
185
186run-xmltest: xmlwf/xmlwf tests/XML-Test-Suite
187	tests/xmltest.sh
188
189.SUFFIXES: .c .cpp .lo .o
190
191.cpp.o:
192	$(CXXCOMPILE) -o $@ -c $<
193.c.o:
194	$(COMPILE) -o $@ -c $<
195.c.lo:
196	$(LTCOMPILE) -o $@ -c $<
197
198.PHONY: buildlib all \
199	clean distclean extraclean maintainer-clean \
200	dist distdir \
201	install uninstall
202