# $Id: Makefile,v 1.42 2003/09/26 13:51:40 hxml Exp $ HXMLDIR = . GHCFLAGS = -Wall -O GHCINCLUDE = -i$(HXMLDIR)/hparser:$(HXMLDIR)/hdom:$(HXMLDIR)/hvalidator:$(HXMLDIR)/hxpath:$(HXMLDIR)/parsec:$(HXMLDIR)/http:$(HXMLDIR)/popen GHCINCLUDEHUNIT = $(GHCINCLUDE):$(HXMLDIR)/hunit GHCPACKAGES = -package lang -package net -package util GHC = ghc $(GHCFLAGS) $(GHCINCLUDE) GHCHUNIT = ghc $(GHCFLAGS) $(GHCINCLUDEHUNIT) PROGS = HXmlParser RunTestCases Profiling HXPath ParseExample FilterExample HUnitExample TreeVisualisation PROFILING_INPUT = xhtml.xml GHOSTVIEW = kghostview SOFTWARE = HXmlToolbox VERSION = 3.01 VERSIONTAG = hxml-3-01 # use: make tagVersion for creating cvs tag SOFTVERS = $(SOFTWARE)-$(VERSION) PUBDATE := $(shell date +%Y-%m-%d) # -------------------------------------------------- all : HXmlParser ParseExample RunTestCases HXPath FilterExample HUnitExample TreeVisualisation force : rm -f $(PROGS) $(MAKE) all # -------------------------------------------------- # # Example Applications # # Command line well-formedness checker and validator HXmlParser : examples/HXmlParser.hs $(GHC) --make $(GHCPACKAGES) -o $@ $< # Minimal Application ParseExample : examples/ParseExample.hs $(GHC) --make $(GHCPACKAGES) -o $@ $< # Application for running the W3C Validation test suite # RunTestCases : examples/RunTestCases.hs $(GHC) --make $(GHCPACKAGES) -o $@ $< # XPath Extractor # HXPath : examples/HXPath.hs $(GHC) --make $(GHCPACKAGES) -o $@ $< # Filter example for extracting and editing # FilterExample : examples/FilterExample.hs $(GHC) --make $(GHCPACKAGES) -o $@ $< # HUnit tests and examples # HUnitExample : examples/HUnitExample.hs $(GHCHUNIT) --make $(GHCPACKAGES) -o $@ $< ; \ # Tree visualisation with SVG # TreeVisualisation : examples/TreeVisualisation.hs $(GHC) --make $(GHCPACKAGES) -o $@ $< # -------------------------------------------------- # # simple test cases test : $(MAKE) test0 test1 test2 test3 test4 test5 xptest hunit EX1 = examples/example1.xml EXi = examples/invalid.xml EX2 = examples/xhtml/xhtml.xml EX3 = examples/namespace0.xml EX3a = examples/namespace1.xml EX4 = examples/lousy.html test0 : HXmlParser ParseExample @echo "===> run the minimal parser example" ./ParseExample $(EX1) @echo @echo "===> run a few simple test cases with the validating parser" @echo "===> see all command line options" ./HXmlParser --help @echo @echo "===> a 1. simple valid document" ./HXmlParser $(EX1) @echo @echo "===> the dom tree of the same document (without any redundant whitespace)" ./HXmlParser --show-tree --no-whitespace $(EX1) @echo @echo "===> the next test case contains validation erors, it must fail" ./HXmlParser --verbose $(EXi) || true @echo @echo "===> same source, but only wellformed check" ./HXmlParser --no-validation $(EXi) || true @echo @echo "===> only validation, no output of an XHTML source" ./HXmlParser --verbose --no-output $(EX2) @echo test1 : HXmlParser @echo "===> the source of a very simple valid document" ; echo ; sleep 2 cat $(EX1) @sleep 2 ; echo ; echo "===> parser will emit UTF-8" ; echo ; sleep 2 ./HXmlParser --output-encoding=UTF-8 $(EX1) @echo @sleep 2 ; echo ; echo "===> once again with ISO-8859-1 (latin1) output" ; echo ; sleep 2 ./HXmlParser --output-encoding=ISO-8859-1 $(EX1) @echo @sleep 2 ; echo ; echo "===> once again with US-ASCII output" ; echo ; sleep 2 ./HXmlParser --output-encoding=US-ASCII $(EX1) @echo @sleep 2 ; echo ; echo "===> once again with hdom tree output" ; echo ; sleep 2 ./HXmlParser --show-tree --output-encoding=ISO-8859-1 $(EX1) @echo @sleep 2 ; echo ; echo "===> once again, but without any markup" ; echo ; sleep 2 ./HXmlParser --show-text --output-encoding=ISO-8859-1 $(EX1) @echo test2 : HXmlParser @echo "===> the source of a xhtml document" ; echo ; sleep 2 cat $(EX2) @echo "that document has" `cat $(EX2) | wc -l` "lines" @sleep 2 ; echo ; echo "===> parser will validate this document and try to indent the output" ; echo ; sleep 2 ./HXmlParser --indent $(EX2) @sleep 2 ; echo ; echo "===> once again, but remove all markup" ; echo ; sleep 2 ./HXmlParser --show-text --no-whitespace $(EX2) @sleep 2 ; echo ; echo "===> once again with hdom tree output" ; echo ; sleep 2 ./HXmlParser --show-tree --no-whitespace $(EX2) test3 : HXmlParser @echo "===> namespace processing examples" ; echo ; sleep 2 @echo "===> namespace propagation test" ; echo ; sleep 2 ./HXmlParser --verbose --check-namespaces --indent --output-encoding=ISO-8859-1 $(EX3) @echo @echo ; sleep 2 ; echo "===> namespace propagation test: tree output with attached namespaces" ; echo ; sleep 2 ./HXmlParser --verbose --check-namespaces --no-whitespace --show-tree --output-encoding=ISO-8859-1 $(EX3) @echo @echo ; sleep 2 ; echo "===> namespace validation test: this test produces namespace errors" ; echo ; sleep 2 ./HXmlParser --verbose --no-validation --check-namespaces --indent --output-encoding=ISO-8859-1 $(EX3a) || true @echo test4 : HXmlParser @echo "===> HTML parsing examples" ; echo ; sleep 2 @echo "===> the source of a lousy html document" ; echo ; sleep 2 cat $(EX4) @sleep 2 ; echo ; echo "===> parser accept this document and try to build a document tree" ; echo ; sleep 2 ./HXmlParser --indent --preserve-comment --html $(EX4) @echo test5 : FilterExample @echo "===> Filter examples" ; echo ; sleep 2 @sleep 2 ; echo ; echo "===> the filter parses a document and selects or modifies parts of it" ; echo ; sleep 2 ./FilterExample --help @echo @sleep 2 ; echo ; echo "===> extract all a tags with a href attribute" ; echo ; sleep 2 ./FilterExample --html --no-warnings --filter=all-a-tags-with-href-attr $(EX4) @echo @sleep 2 ; echo ; echo "===> extract all href attribute values for a tags" ; echo ; sleep 2 ./FilterExample --html --no-warnings --filter=all-href-values-of-a-tags $(EX4) @echo @sleep 2 ; echo ; echo "===> change all src attribute values of img tags to absolut uris" ; echo ; sleep 2 ./FilterExample --html --no-warnings --filter=change-img-src-to-abs-uri $(EX4) @echo @sleep 2 ; echo ; echo "===> select all text" ; echo ; sleep 2 ./FilterExample --html --no-warnings --filter=all-text $(EX4) @echo @sleep 2 ; echo ; echo "===> select all text within body, but remove whitespace" ; echo ; sleep 2 ./FilterExample --html --no-warnings --filter=all-body-text-without-whitespace $(EX4) @echo xptest : HXPath @echo "===> XPath extraction examples" ; echo ; sleep 2 @echo "===> extract all text from the XHTML document" ; echo ; sleep 2 ./HXPath --no-validation "/html/body/descendant-or-self::text()" $(EX2) @echo @echo "===> extract the 42. paragraph from the XHTML document" ; echo ; sleep 2 ./HXPath --no-validation "/descendant::p[position()=42]" $(EX2) @echo @echo "===> extract the text of all top level h1 tags from the XHTML document" ; echo ; sleep 2 ./HXPath --indent --no-validation "/child::html/child::body/child::h1/descendant-or-self::text()" $(EX2) @echo @echo "===> extract all href attributes from a tags from the XHTML document" ; echo ; sleep 2 ./HXPath --indent --no-validation "/descendant::a/attribute::href" $(EX2) @echo hunit : HUnitExample @echo "===> run HUnit examples" ; echo ; sleep 2 cd examples ; ../HUnitExample ; \ # -------------------------------------------------- # # w3c test cases date := $(shell date +%Y-%m-%d.%H.%M.%S) testSuite = . w3c : RunTestCases RunTestCases -h RunTestCases -v --only-err $(testSuite)/xml-test-suite/xmlconf/xmlconf.xml 2> w3c.err | tee w3c.out cp w3c.err w3c.err.$(date) cp w3c.out w3c.out.$(date) # -------------------------------------------------- # Utility for testing the XML parser whith the W3C XML Test Suites OldRunTestCases : hvalidator/RunTestCases.hs $(GHC) --make $(GHCPACKAGES) -o $@ $< # -------------------------------------------------- # Utility for GHC profiling of the XML parser Profiling : hvalidator/Profiling.hs $(GHC) --make $(GHCPACKAGES) -prof -ignore-scc -o $@ $< # Time and allocation profiling - Generate profiling information in XML format runprofiling1 : ./Profiling --source $(PROFILING_INPUT) +RTS -px ghcprof Profiling.prof # Time and allocation profiling - Generate profiling information in text format runprofiling2 : ./Profiling --source $(PROFILING_INPUT) +RTS -p less Profiling.prof # Heap profiling - Break down the graph by the cost-centre stack which produced the data. runprofiling3 : ./Profiling --source $(PROFILING_INPUT) +RTS -hc hp2ps -c -m20 Profiling.hp $(GHOSTVIEW) Profiling.ps # Heap profiling - Break down the graph by retainer set. runprofiling4 : ./Profiling --source $(PROFILING_INPUT) +RTS -hr hp2ps -c -m20 Profiling.hp $(GHOSTVIEW) Profiling.ps cleanprofiling : rm -f Profiling.* \ GHCbarchart.tcl \ ghcprof.log # -------------------------------------------------- # Build a tarball and webpage directory for distribution examples_src := $(shell find examples -name '*.hs' -o -name '*.xml' -o -name '.ghci' -o -name '*.dtd' -o -name '*.ent' -o -name '*.html' -o -name '*.html.svg' -o -name '*.html.jpg') hdom_src := $(shell find hdom -name '*.hs') hparser_src := $(shell find hparser -maxdepth 1 -name '*.hs') hvalidator_src := $(shell find hvalidator -name '*.hs') hxpath_src := $(shell find hxpath -name '*.hs') parsec_src := $(shell find parsec -name '*.hs') http_src := $(shell find http -name '*.hs') popen_src := $(shell find popen -name '*.hs') hunit_src := $(shell find hunit -name '*.hs' -o -name '*.lhs' -o -name '*.html' -o -name 'License' -o -name 'README') all_src = $(examples_src) $(hdom_src) $(hparser_src) $(hvalidator_src) $(hxpath_src) $(parsec_src) $(http_src) $(hunit_src) $(popen_src) # -------------------------------------------------- # # haddoc documentation examples_doc := $(shell find examples -name HXmlParser.hs) hvalidator_doc := $(shell find hvalidator -name '*.hs' -a -not -name RunTestCases.hs -a -not -name Profiling.hs) hxpath_doc := $(shell find hxpath -name '*.hs' -a -not -name XPathExample.hs) src_doc := $(hdom_src) $(hparser_src) $(hvalidator_doc) $(hxpath_doc) $(examples_doc) hdoc : doc/hdoc/index.html doc/hdoc/index.html : $(src_doc) [ -d doc/hdoc ] || mkdir -p doc/hdoc haddock -h \ -o doc/hdoc \ -t "Haskell Xml Toolbox $(VERSION)" \ $(src_doc) cleanhdoc : rm -Rf doc/hdoc # -------------------------------------------------- thesis: @echo "thesis not remade, command '$(MAKE) -C doc/hvalidator all' not executed" # Create tarball for distribution tarball : cleantarball hdoc thesis vtree mkdir -p $(SOFTVERS) tar cvf - $(all_src) | ( cd $(SOFTVERS) ; tar xf - ) mkdir -p $(SOFTVERS)/doc/hdoc cp doc/hdoc/* $(SOFTVERS)/doc/hdoc mkdir $(SOFTVERS)/doc/thesis cp -r doc/hvalidator/thesis $(SOFTVERS)/doc cp doc/hvalidator/thesis.ps $(SOFTVERS)/doc || true mkdir -p $(SOFTVERS)/doc/hxpath cp doc/hxpath/*.pdf $(SOFTVERS)/doc/hxpath || true cp LICENSE Makefile README $(SOFTVERS) tar -zcvf $(SOFTVERS).tar.gz $(SOFTVERS) rm -rf $(SOFTVERS) cleantarball : rm -f $(SOFTVERS).tar.gz rm -rf $(SOFTVERS) # Create webpage directory for distribution WEBHOME = ../../../HXmlToolbox webpage : tarball [ ! -d $(WEBHOME) ] || echo "please clean $(WEBHOME) first: make cleanwebpage" mkdir -p $(WEBHOME) cp -r doc/hdoc $(WEBHOME)/hdoc cp -r doc/hvalidator/thesis $(WEBHOME)/thesis cp -f doc/hvalidator/thesis.ps doc/hvalidator/thesis.pdf $(WEBHOME) || true [ -d $(WEBHOME)/hxpath ] || mkdir -p $(WEBHOME)/hxpath cp -f doc/hxpath/diplomarbeit.pdf $(WEBHOME)/hxpath [ -d $(WEBHOME)/examples ] || mkdir -p $(WEBHOME)/examples cp -f examples/*.html.jpg $(WEBHOME)/examples cp -f examples/FilterExample.hs examples/HUnitExample.hs examples/TreeVisualisation.hs $(WEBHOME)/examples cat doc/index.html \ | sed 's/%DISTFILE%/$(SOFTVERS)/g' \ | sed 's/%SOFTWARE%/$(SOFTWARE)/g' \ | sed 's/%VERSION%/$(VERSION)/g' \ | sed 's/%PUBDATE%/$(PUBDATE)/g' > $(WEBHOME)/index.html mv $(SOFTVERS).tar.gz $(WEBHOME) ( echo "AddType text/html .html" \ ; echo "allow from all" \ ) > $(WEBHOME)/.htaccess cleanwebpage : rm -rf $(WEBHOME) # -------------------------------------------------- # Clean all clean : cleanhdoc cleanprofiling cleantarball cleanvt rm -f $(PROGS) \ $(HXMLDIR)/examples/*.o \ $(HXMLDIR)/examples/*.hi \ $(HXMLDIR)/hdom/*.o \ $(HXMLDIR)/hdom/*.hi \ $(HXMLDIR)/hparser/*.o \ $(HXMLDIR)/hparser/*.hi \ $(HXMLDIR)/hvalidator/*.o \ $(HXMLDIR)/hvalidator/*.hi \ $(HXMLDIR)/hxpath/*.o \ $(HXMLDIR)/hxpath/*.hi \ $(HXMLDIR)/parsec/*.o \ $(HXMLDIR)/parsec/*.hi \ $(HXMLDIR)/http/*.o \ $(HXMLDIR)/http/*.hi \ $(HXMLDIR)/popen/*.o \ $(HXMLDIR)/popen/*.hi \ $(HXMLDIR)/hunit/*.o \ $(HXMLDIR)/hunit/*.hi \ # -------------------------------------------------- # Tree Visualisation Examples proxy := $(shell if [ `hostname` = "si" ] ; then echo -n "--proxy=www-cache.fh-wedel.de:3128" ; else echo -n ; fi) HTV = TreeVisualisation -t1 --curl --encoding=ISO-8859-1 --html --no-warnings --removeWhiteSpace XTV = TreeVisualisation -t1 --curl --no-validation --no-warnings --removeWhiteSpace cleanvt : rm -f \ examples/index.html.jpg \ examples/www.fh-wedel.de.index.html.jpg \ examples/www.w3.org.index.html.jpg \ examples/www.haskell.org.index.html.jpg \ examples/index.html.svg \ examples/www.fh-wedel.de.index.html.svg \ examples/www.w3.org.index.html.svg \ examples/www.haskell.org.index.html.svg vtree : TreeVisualisation \ examples/index.html.jpg \ examples/www.fh-wedel.de.index.html.jpg \ examples/www.w3.org.index.html.jpg \ examples/www.haskell.org.index.html.jpg examples/index.html.svg : doc/index.html @echo "get Haskell XML Toolbox homepage" $(HTV) --width=800 --height=400 \ doc/index.html > examples/index.html.svg examples/www.fh-wedel.de.index.html.svg : @echo "get FH Wedel homepage" $(HTV) --horizontalTree --horizontalLines --width=600 --height=800 --border 30 \ http://www.fh-wedel.de/ > examples/www.fh-wedel.de.index.html.svg examples/www.w3.org.index.html.svg : @echo "get www.w3.org" $(XTV) --centricTree --withAttr --width=1000 --height=1000 $(proxy) \ http://www.w3.org/ > examples/www.w3.org.index.html.svg examples/www.haskell.org.index.html.svg : @echo "get www.haskell.org" $(HTV) --horizontalLines --withAttr --width=600 --height=400 $(proxy) \ http://www.haskell.org/ > examples/www.haskell.org.index.html.svg %.jpg : %.svg svgtoraster -m image/jpeg -q 0.7 `pwd`/$< %.png : %.svg svgtoraster -m image/png `pwd`/$< # -------------------------------------------------- # tagVersion : cvs tag $(VERSIONTAG) . # -------------------------------------------------- # end Makefile