1# Makefile - for tidy - HTML parser and pretty printer
2#
3#  CVS Info :
4#
5#     $Author: arnaud02 $
6#     $Date: 2008/03/22 21:13:38 $
7#     $Revision: 1.37 $
8#
9#  Copyright (c) 1998-2008 World Wide Web Consortium
10#  (Massachusetts Institute of Technology, European Research
11#  Consortium for Informatics and Mathematics, Keio University).
12#  All Rights Reserved.
13#
14#  Contributing Author(s):
15#
16#     Dave Raggett <dsr@w3.org>
17#     Terry Teague <terry_teague@users.sourceforge.net>
18#     Pradeep Padala<ppadala@users.sourceforge.net>
19#
20#  The contributing author(s) would like to thank all those who
21#  helped with testing, bug fixes, and patience.  This wouldn't
22#  have been possible without all of you.
23#
24#  COPYRIGHT NOTICE:
25#
26#  This software and documentation is provided "as is," and
27#  the copyright holders and contributing author(s) make no
28#  representations or warranties, express or implied, including
29#  but not limited to, warranties of merchantability or fitness
30#  for any particular purpose or that the use of the software or
31#  documentation will not infringe any third party patents,
32#  copyrights, trademarks or other rights.
33#
34#  The copyright holders and contributing author(s) will not be
35#  liable for any direct, indirect, special or consequential damages
36#  arising out of any use of the software or documentation, even if
37#  advised of the possibility of such damage.
38#
39#  Permission is hereby granted to use, copy, modify, and distribute
40#  this source code, or portions hereof, documentation and executables,
41#  for any purpose, without fee, subject to the following restrictions:
42#
43#  1. The origin of this source code must not be misrepresented.
44#  2. Altered versions must be plainly marked as such and must
45#     not be misrepresented as being the original source.
46#  3. This Copyright notice may not be removed or altered from any
47#     source or altered source distribution.
48#
49#  The copyright holders and contributing author(s) specifically
50#  permit, without fee, and encourage the use of this source code
51#  as a component for supporting the Hypertext Markup Language in
52#  commercial products. If you use this source code in a product,
53#  acknowledgment is not required but would be appreciated.
54#
55
56SHELL=/bin/sh
57
58PROJECT=tidy
59
60# Installation variables.  Spaces OK, only dir create and file copy operations.
61runinst_prefix=${PREFIX}
62devinst_prefix=${PREFIX}
63
64bininst = ${runinst_prefix}/bin
65libinst = ${devinst_prefix}/lib
66incinst = ${devinst_prefix}/include/$(PROJECT)
67maninst = ${devinst_prefix}/man
68
69# Internal variables. - No spaces allowed: libtool chokes on spaces in directory names.
70TOPDIR = .
71INCDIR = ${TOPDIR}/include
72APPDIR = ${TOPDIR}/console
73SRCDIR = ${TOPDIR}/src
74OBJDIR = ./obj
75LIBDIR = ${TOPDIR}/lib
76BINDIR = ${TOPDIR}/bin
77DOCDIR = ${TOPDIR}/htmldoc
78
79# Note about shared library and exported symbols:
80# With gcc, one can control the exported symbols by either using
81# "-fvisibility=hidden -DTIDY_EXPORT='__attribute__((visibility("default")))'"
82# or using a linker map (see GNU ld "--version-script").
83
84# Lookup based on hash table can be disabled with
85# "-DELEMENT_HASH_LOOKUP=0 -DATTRIBUTE_HASH_LOOKUP=0"
86
87# Memory mapped i/o can be disabled with -DSUPPORT_POSIX_MAPPED_FILES=0
88#
89
90# CFLAGS etc..
91# For optimised builds, flags such as "-O2" should be added and -D_DEBUG=1
92# disabled.
93#CC= gcc
94CFLAGS+= -pedantic -Wall -I $(INCDIR) -fPIC
95# flags only supported with gcc 3.x
96CFLAGS += -Wunused-parameter
97
98OTHERCFLAGS=
99OTHERCFLAGS+= -D_DEBUG=1
100# OTHERCFLAGS+= -fvisibility=hidden -DTIDY_EXPORT='__attribute__((visibility("default")))'
101ifdef SUPPORT_UTF16_ENCODINGS
102CFLAGS += -DSUPPORT_UTF16_ENCODINGS=$(SUPPORT_UTF16_ENCODINGS)
103endif
104ifdef SUPPORT_ASIAN_ENCODINGS
105CFLAGS += -DSUPPORT_ASIAN_ENCODINGS=$(SUPPORT_ASIAN_ENCODINGS)
106endif
107ifdef SUPPORT_ACCESSIBILITY_CHECKS
108CFLAGS += -DSUPPORT_ACCESSIBILITY_CHECKS=$(SUPPORT_ACCESSIBILITY_CHECKS)
109endif
110
111DEBUGFLAGS=-g
112ifdef DMALLOC
113DEBUGFLAGS += -DDMALLOC
114endif
115
116LIBS=
117DEBUGLIBS=-ldmalloc
118
119# Tidy lib related variables
120TIDY_MAJOR = 1
121TIDY_MINOR = 0
122
123# This will come from autoconf again
124LIBPREFIX = lib
125LIBSUFFIX = .a
126OBJSUF = .o
127
128LIBRARY = $(LIBDIR)/$(LIBPREFIX)$(PROJECT)$(LIBSUFFIX)
129AR=ar -r
130
131XSLTPROC = xsltproc
132
133EXES = $(BINDIR)/$(PROJECT) $(BINDIR)/tab2space
134
135DOCS = $(DOCDIR)/quickref.html $(DOCDIR)/tidy.1
136
137CONFIGXML = $(DOCDIR)/tidy-config.xml
138HELPXML = $(DOCDIR)/tidy-help.xml
139
140OBJFILES=\
141        $(OBJDIR)/access$(OBJSUF)     $(OBJDIR)/attrs$(OBJSUF)      $(OBJDIR)/istack$(OBJSUF) \
142        $(OBJDIR)/parser$(OBJSUF)     $(OBJDIR)/tags$(OBJSUF)       $(OBJDIR)/entities$(OBJSUF) \
143        $(OBJDIR)/lexer$(OBJSUF)      $(OBJDIR)/pprint$(OBJSUF)     $(OBJDIR)/clean$(OBJSUF) \
144        $(OBJDIR)/localize$(OBJSUF)   $(OBJDIR)/config$(OBJSUF)     $(OBJDIR)/alloc$(OBJSUF) \
145        $(OBJDIR)/attrask$(OBJSUF)    $(OBJDIR)/attrdict$(OBJSUF)   $(OBJDIR)/attrget$(OBJSUF) \
146        $(OBJDIR)/buffio$(OBJSUF)     $(OBJDIR)/fileio$(OBJSUF)     $(OBJDIR)/streamio$(OBJSUF) \
147        $(OBJDIR)/tagask$(OBJSUF)     $(OBJDIR)/tmbstr$(OBJSUF)     $(OBJDIR)/utf8$(OBJSUF) \
148        $(OBJDIR)/tidylib$(OBJSUF)    $(OBJDIR)/mappedio$(OBJSUF)
149
150CFILES= \
151        $(SRCDIR)/access.c       $(SRCDIR)/attrs.c        $(SRCDIR)/istack.c \
152        $(SRCDIR)/parser.c       $(SRCDIR)/tags.c         $(SRCDIR)/entities.c \
153        $(SRCDIR)/lexer.c        $(SRCDIR)/pprint.c       $(SRCDIR)/clean.c \
154        $(SRCDIR)/localize.c     $(SRCDIR)/config.c       $(SRCDIR)/alloc.c \
155        $(SRCDIR)/attrask.c      $(SRCDIR)/attrdict.c     $(SRCDIR)/attrget.c \
156        $(SRCDIR)/buffio.c       $(SRCDIR)/fileio.c       $(SRCDIR)/streamio.c \
157        $(SRCDIR)/tagask.c       $(SRCDIR)/tmbstr.c       $(SRCDIR)/utf8.c \
158        $(SRCDIR)/tidylib.c      $(SRCDIR)/mappedio.c
159
160HFILES= $(INCDIR)/platform.h     $(INCDIR)/tidy.h         $(INCDIR)/tidyenum.h \
161        $(INCDIR)/buffio.h
162
163LIBHFILES= \
164        $(SRCDIR)/access.h       $(SRCDIR)/attrs.h        $(SRCDIR)/attrdict.h \
165        $(SRCDIR)/clean.h        $(SRCDIR)/config.h       $(SRCDIR)/entities.h \
166        $(SRCDIR)/fileio.h       $(SRCDIR)/forward.h      $(SRCDIR)/lexer.h \
167        $(SRCDIR)/mappedio.h     $(SRCDIR)/message.h      $(SRCDIR)/parser.h \
168        $(SRCDIR)/pprint.h       $(SRCDIR)/streamio.h     $(SRCDIR)/tags.h \
169        $(SRCDIR)/tmbstr.h       $(SRCDIR)/utf8.h         $(SRCDIR)/tidy-int.h \
170        $(SRCDIR)/version.h
171
172
173
174all:    $(LIBRARY) $(EXES)
175
176doc:    $(DOCS)
177
178$(LIBRARY): $(OBJFILES)
179	if [ ! -d $(LIBDIR) ]; then mkdir $(LIBDIR); fi
180	$(AR) $@ $(OBJFILES)
181ifdef RANLIB
182	$(RANLIB) $@
183endif
184
185$(OBJDIR)/%$(OBJSUF):	$(SRCDIR)/%.c $(HFILES) $(LIBHFILES) Makefile
186	if [ ! -d $(OBJDIR) ]; then mkdir $(OBJDIR); fi
187	$(CC) $(CFLAGS) $(OTHERCFLAGS) -o $@ -c $<
188
189$(BINDIR)/$(PROJECT):	$(APPDIR)/tidy.c $(HFILES) $(LIBRARY)
190	if [ ! -d $(BINDIR) ]; then mkdir $(BINDIR); fi
191	$(CC) $(CFLAGS) $(OTHERCFLAGS) -o $@ $(APPDIR)/tidy.c -I$(INCDIR) $(LIBRARY)
192
193$(BINDIR)/tab2space: $(APPDIR)/tab2space.c
194	if [ ! -d $(BINDIR) ]; then mkdir $(BINDIR); fi
195	$(CC) $(CFLAGS) $(OTHERCFLAGS) -o $@ $(APPDIR)/tab2space.c $(LIBS)
196
197$(HELPXML): $(BINDIR)/$(PROJECT)
198	$(BINDIR)/$(PROJECT) -xml-help > $@
199
200$(CONFIGXML): $(BINDIR)/$(PROJECT)
201	$(BINDIR)/$(PROJECT) -xml-config > $@
202
203$(DOCDIR)/quickref.html: $(DOCDIR)/quickref-html.xsl $(CONFIGXML)
204	$(XSLTPROC) -o $@ $(DOCDIR)/quickref-html.xsl $(CONFIGXML)
205
206$(DOCDIR)/tidy.1: $(DOCDIR)/tidy1.xsl $(HELPXML) $(CONFIGXML)
207	$(XSLTPROC) -o $@ $(DOCDIR)/tidy1.xsl $(HELPXML)
208
209debug:
210	@$(MAKE) CFLAGS='$(CFLAGS) $(DEBUGFLAGS)' LIBS='$(LIBS) $(DEBUGLIBS)' all
211
212clean:
213	rm -f $(OBJFILES) $(EXES) $(LIBRARY) $(DOCS) $(HELPXML) $(CONFIGXML) $(OBJDIR)/*.lo
214	if [ -d $(OBJDIR)/.libs ]; then rmdir $(OBJDIR)/.libs; fi
215	if [ -d $(LIBDIR)/.libs ]; then rmdir $(LIBDIR)/.libs; fi
216	if [ "$(OBJDIR)" != "$(TOPDIR)" -a -d $(OBJDIR) ]; then rmdir $(OBJDIR); fi
217	if [ "$(LIBDIR)" != "$(TOPDIR)" -a -d $(LIBDIR) ]; then rmdir $(LIBDIR); fi
218	if [ "$(BINDIR)" != "$(TOPDIR)" -a -d $(BINDIR) ]; then rmdir $(BINDIR); fi
219
220installhdrs: $(HFILES)
221	if [ ! -d "$(incinst)" ]; then mkdir -p "$(incinst)"; fi
222	cp -f $(HFILES) "$(incinst)/"
223
224installib: $(LIBRARY)
225	if [ ! -d "$(libinst)" ]; then mkdir -p "$(libinst)"; fi
226	cp -f $(LIBRARY) "$(libinst)/"
227
228installexes: $(EXES)
229	if [ ! -d "$(bininst)" ]; then mkdir -p "$(bininst)"; fi
230	cp -f $(EXES) "$(bininst)/"
231
232installmanpage: $(DOCDIR)/tidy.1
233	if [ ! -d "$(maninst)/man1" ]; then mkdir -p "$(maninst)/man1"; fi;
234	cp -f $(DOCDIR)/tidy.1 "$(maninst)/man1/tidy.1";
235
236install: installhdrs installib installexes installmanpage
237