1# Makefile - for tidy - HTML parser and pretty printer 2# 3# CVS Info : 4# 5# $Author$ 6# $Date$ 7# $Revision$ 8# 9# Copyright (c) 1998-2005 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=/usr/local 62devinst_prefix=/usr/local 63 64bininst = ${runinst_prefix}/bin 65libinst = ${devinst_prefix}/lib 66incinst = ${devinst_prefix}/include/$(PROJECT) 67maninst = ${devinst_prefix}/man 68 69ifdef TIDY_APPLE_CHANGES 70maninst = ${devinst_prefix}/share/man 71endif 72 73# Internal variables. - No spaces allowed: libtool chokes on spaces in directory names. 74TOPDIR = ../.. 75INCDIR = ${TOPDIR}/include 76APPDIR = ${TOPDIR}/console 77SRCDIR = ${TOPDIR}/src 78OBJDIR = ./obj 79LIBDIR = ${TOPDIR}/lib 80BINDIR = ${TOPDIR}/bin 81DOCDIR = ${TOPDIR}/htmldoc 82 83# Note about shared library and exported symbols: 84# With gcc, one can control the exported symbols by either using 85# "-fvisibility=hidden -DTIDY_EXPORT='__attribute__((visibility("default")))'" 86# or using a linker map (see GNU ld "--version-script"). 87 88# Lookup based on hash table can be disabled with 89# "-DELEMENT_HASH_LOOKUP=0 -DATTRIBUTE_HASH_LOOKUP=0" 90 91# CFLAGS etc.. 92# For optimised builds, flags such as "-O2" should be added and -D_DEBUG=1 93# disabled. 94ifdef TIDY_APPLE_CHANGES 95CC = $(shell xcrun -find -sdk $(SDKROOT) cc) 96CFLAGS+= -g -Wall -Wno-switch -Wno-parentheses -I $(INCDIR) \ 97 -fvisibility=hidden -DTIDY_EXPORT='__attribute__((visibility("default")))' 98else 99CC= cc 100CFLAGS= -g -Wall -Wno-switch -Wno-parentheses -I $(INCDIR) 101endif 102# flags only supported with gcc 3.x 103# CFLAGS += -Wunused-parameter 104 105OTHERCFLAGS= 106ifndef TIDY_APPLE_CHANGES 107OTHERCFLAGS+= -D_DEBUG=1 108OTHERCFLAGS+= -DSUPPORT_POSIX_MAPPED_FILES 109endif 110# OTHERCFLAGS+= -fvisibility=hidden -DTIDY_EXPORT='__attribute__((visibility("default")))' 111# OTHERCFLAGS+= -DSUPPORT_ACCESSIBILITY_CHECKS=1 -DSUPPORT_UTF16_ENCODINGS=1 -DSUPPORT_ASIAN_ENCODINGS=1 112ifdef SUPPORT_UTF16_ENCODINGS 113CFLAGS += -DSUPPORT_UTF16_ENCODINGS=$(SUPPORT_UTF16_ENCODINGS) 114endif 115ifdef SUPPORT_ASIAN_ENCODINGS 116CFLAGS += -DSUPPORT_ASIAN_ENCODINGS=$(SUPPORT_ASIAN_ENCODINGS) 117endif 118ifdef SUPPORT_ACCESSIBILITY_CHECKS 119CFLAGS += -DSUPPORT_ACCESSIBILITY_CHECKS=$(SUPPORT_ACCESSIBILITY_CHECKS) 120endif 121 122DEBUGFLAGS=-g 123ifdef DMALLOC 124DEBUGFLAGS += -DDMALLOC 125endif 126 127LIBS= 128DEBUGLIBS=-ldmalloc 129 130# Tidy lib related variables 131TIDY_MAJOR = 1 132TIDY_MINOR = 0 133 134# This will come from autoconf again 135LIBPREFIX = lib 136LIBSUFFIX = .a 137OBJSUF = .o 138 139LIBRARY = $(LIBDIR)/$(LIBPREFIX)$(PROJECT)$(LIBSUFFIX) 140AR ?= ar 141 142XSLTPROC = xsltproc 143 144EXES = $(BINDIR)/$(PROJECT) $(BINDIR)/tab2space 145 146DOCS = $(DOCDIR)/quickref.html $(DOCDIR)/tidy.1 147 148CONFIGXML = $(DOCDIR)/tidy-config.xml 149HELPXML = $(DOCDIR)/tidy-help.xml 150 151OBJFILES=\ 152 $(OBJDIR)/access$(OBJSUF) $(OBJDIR)/attrs$(OBJSUF) $(OBJDIR)/istack$(OBJSUF) \ 153 $(OBJDIR)/parser$(OBJSUF) $(OBJDIR)/tags$(OBJSUF) $(OBJDIR)/entities$(OBJSUF) \ 154 $(OBJDIR)/lexer$(OBJSUF) $(OBJDIR)/pprint$(OBJSUF) $(OBJDIR)/clean$(OBJSUF) \ 155 $(OBJDIR)/localize$(OBJSUF) $(OBJDIR)/config$(OBJSUF) $(OBJDIR)/alloc$(OBJSUF) \ 156 $(OBJDIR)/attrask$(OBJSUF) $(OBJDIR)/attrdict$(OBJSUF) $(OBJDIR)/attrget$(OBJSUF) \ 157 $(OBJDIR)/buffio$(OBJSUF) $(OBJDIR)/fileio$(OBJSUF) $(OBJDIR)/streamio$(OBJSUF) \ 158 $(OBJDIR)/tagask$(OBJSUF) $(OBJDIR)/tmbstr$(OBJSUF) $(OBJDIR)/utf8$(OBJSUF) \ 159 $(OBJDIR)/tidylib$(OBJSUF) $(OBJDIR)/mappedio$(OBJSUF) 160 161CFILES= \ 162 $(SRCDIR)/access.c $(SRCDIR)/attrs.c $(SRCDIR)/istack.c \ 163 $(SRCDIR)/parser.c $(SRCDIR)/tags.c $(SRCDIR)/entities.c \ 164 $(SRCDIR)/lexer.c $(SRCDIR)/pprint.c $(SRCDIR)/clean.c \ 165 $(SRCDIR)/localize.c $(SRCDIR)/config.c $(SRCDIR)/alloc.c \ 166 $(SRCDIR)/attrask.c $(SRCDIR)/attrdict.c $(SRCDIR)/attrget.c \ 167 $(SRCDIR)/buffio.c $(SRCDIR)/fileio.c $(SRCDIR)/streamio.c \ 168 $(SRCDIR)/tagask.c $(SRCDIR)/tmbstr.c $(SRCDIR)/utf8.c \ 169 $(SRCDIR)/tidylib.c $(SRCDIR)/mappedio.c 170 171HFILES= $(INCDIR)/platform.h $(INCDIR)/tidy.h $(INCDIR)/tidyenum.h \ 172 $(INCDIR)/buffio.h 173 174LIBHFILES= \ 175 $(SRCDIR)/access.h $(SRCDIR)/attrs.h $(SRCDIR)/attrdict.h \ 176 $(SRCDIR)/clean.h $(SRCDIR)/config.h $(SRCDIR)/entities.h \ 177 $(SRCDIR)/fileio.h $(SRCDIR)/forward.h $(SRCDIR)/lexer.h \ 178 $(SRCDIR)/mappedio.h $(SRCDIR)/message.h $(SRCDIR)/parser.h \ 179 $(SRCDIR)/pprint.h $(SRCDIR)/streamio.h $(SRCDIR)/tags.h \ 180 $(SRCDIR)/tmbstr.h $(SRCDIR)/utf8.h $(SRCDIR)/tidy-int.h \ 181 $(SRCDIR)/version.h 182 183ifdef TIDY_APPLE_CHANGES 184LIBS=-lc 185endif 186 187all: $(LIBRARY) $(EXES) 188 189doc: $(DOCS) 190 191$(LIBRARY): $(OBJFILES) 192 if [ ! -d $(LIBDIR) ]; then mkdir $(LIBDIR); fi 193 $(AR) -r $@ $(OBJFILES) 194ifdef RANLIB 195 $(RANLIB) $@ 196endif 197 198$(OBJDIR)/%$(OBJSUF): $(SRCDIR)/%.c $(HFILES) $(LIBHFILES) Makefile 199 if [ ! -d $(OBJDIR) ]; then mkdir $(OBJDIR); fi 200 $(CC) $(CFLAGS) $(OTHERCFLAGS) -o $@ -c $< 201 202$(BINDIR)/$(PROJECT): $(APPDIR)/tidy.c $(HFILES) $(LIBRARY) 203 if [ ! -d $(BINDIR) ]; then mkdir $(BINDIR); fi 204 $(CC) $(CFLAGS) $(OTHERCFLAGS) -o $@ $(APPDIR)/tidy.c -I$(INCDIR) -L$(LIBDIR) -l$(PROJECT) 205 206$(BINDIR)/tab2space: $(APPDIR)/tab2space.c 207 if [ ! -d $(BINDIR) ]; then mkdir $(BINDIR); fi 208 $(CC) $(CFLAGS) $(OTHERCFLAGS) -o $@ $(APPDIR)/tab2space.c $(LIBS) 209 210$(HELPXML): $(BINDIR)/$(PROJECT) 211 $(BINDIR)/$(PROJECT) -xml-help > $@ 212 213$(CONFIGXML): $(BINDIR)/$(PROJECT) 214 $(BINDIR)/$(PROJECT) -xml-config > $@ 215 216$(DOCDIR)/quickref.html: $(DOCDIR)/quickref-html.xsl $(CONFIGXML) 217 $(XSLTPROC) -o $@ $(DOCDIR)/quickref-html.xsl $(CONFIGXML) 218 219$(DOCDIR)/tidy.1: $(DOCDIR)/tidy1.xsl $(HELPXML) $(CONFIGXML) 220 $(XSLTPROC) -o $@ $(DOCDIR)/tidy1.xsl $(HELPXML) 221 222debug: 223 @$(MAKE) CFLAGS='$(CFLAGS) $(DEBUGFLAGS)' LIBS='$(LIBS) $(DEBUGLIBS)' all 224 225clean: 226 rm -f $(OBJFILES) $(EXES) $(LIBRARY) $(DOCS) $(HELPXML) $(CONFIGXML) $(OBJDIR)/*.lo 227 if [ -d $(OBJDIR)/.libs ]; then rmdir $(OBJDIR)/.libs; fi 228 if [ -d $(LIBDIR)/.libs ]; then rmdir $(LIBDIR)/.libs; fi 229 if [ "$(OBJDIR)" != "$(TOPDIR)" -a -d $(OBJDIR) ]; then rmdir $(OBJDIR); fi 230 if [ "$(LIBDIR)" != "$(TOPDIR)" -a -d $(LIBDIR) ]; then rmdir $(LIBDIR); fi 231 if [ "$(BINDIR)" != "$(TOPDIR)" -a -d $(BINDIR) ]; then rmdir $(BINDIR); fi 232 233installhdrs: $(HFILES) 234 if [ ! -d "$(incinst)" ]; then mkdir -p "$(incinst)"; fi 235 install -m 0444 $(HFILES) "$(incinst)/" 236 237installib: $(LIBRARY) 238 if [ ! -d "$(libinst)" ]; then mkdir -p "$(libinst)"; fi 239 cp -f $(LIBRARY) "$(libinst)/" 240 241installexes: $(EXES) 242 if [ ! -d "$(bininst)" ]; then mkdir -p "$(bininst)"; fi 243 cp -f $(EXES) "$(bininst)/" 244 245installmanpage: $(DOCDIR)/tidy.1 246 if [ ! -d "$(maninst)/man1" ]; then mkdir -p "$(maninst)/man1"; fi; 247 cp -f $(DOCDIR)/tidy.1 "$(maninst)/man1/tidy.1"; 248 249ifdef TIDY_APPLE_CHANGES 250installmanpage_apple: 251 if [ -f "$(TOPDIR)/htmldoc/man_page.txt" ] ; then \ 252 if [ ! -d "$(maninst)/man1" ]; then mkdir -p "$(maninst)/man1"; fi; \ 253 cp -f $(TOPDIR)/htmldoc/man_page.txt "$(maninst)/man1/tidy.1"; \ 254 cp -f $(TOPDIR)/htmldoc/tab2space_man_page.txt "$(maninst)/man1/tab2space.1"; \ 255 fi 256endif 257 258install: installhdrs installib installexes installmanpage 259