1# Tell BSD make(1) to not remake the .1in and .htmlin files. 2SUFFIXES= .1 .1in .htmlin .html 3 4# requires: 5# xmllint (libxml2) 6# xmlto (cyberelk.net) 7# nsgmls (opensp) 8 9# what to build 10man_MANS = bogofilter.1 bogoutil.1 bogoupgrade.1 bogolexer.1 bogotune.1 \ 11 bf_copy.1 bf_tar.1 bf_compact.1 12 13html_MANS = bogofilter.html bogoutil.html bogoupgrade.html \ 14 bogolexer.html bogotune.html \ 15 bf_copy.html bf_tar.html bf_compact.html 16 17all: $(man_MANS) $(html_MANS) 18 19CLEANFILES = $(man_MANS) $(html_MANS) 20 21HTML_DOCS = bogofilter-faq.html bogofilter-faq-fr.html bogofilter-faq-it.html bogotune-faq.html 22XHTML_DOCS= bogofilter-faq-bg.xhtml 23 24# what to distribute 25EXTRA_DIST = \ 26 bogofilter.xml bogofilter.1in bogofilter.htmlin \ 27 bogolexer.xml bogolexer.1in bogolexer.htmlin \ 28 bogotune.xml bogotune.1in bogotune.htmlin \ 29 bogoupgrade.xml bogoupgrade.1in bogoupgrade.htmlin \ 30 bogoutil.xml bogoutil.1in bogoutil.htmlin \ 31 bf_compact.xml bf_compact.1in bf_compact.htmlin \ 32 bf_copy.xml bf_copy.1in bf_copy.htmlin \ 33 bf_tar.xml bf_tar.1in bf_tar.htmlin \ 34 $(HTML_DOCS) \ 35 $(XHTML_DOCS) \ 36 bogofilter-tuning.HOWTO.html \ 37 bogofilter-SA-2002-01 bogofilter-SA-2004-01 \ 38 bogofilter-SA-2005-01 bogofilter-SA-2005-02 \ 39 bogofilter-SA-2010-01 \ 40 bogofilter-SA-2012-01 \ 41 integrating-with-postfix \ 42 integrating-with-qmail \ 43 programmer/OS2/configure.os2 \ 44 programmer/README.freebsd programmer/README.hp-ux \ 45 programmer/README.RISC-OS programmer/README.memory-checking \ 46 programmer/README.osx \ 47 programmer/RISC-OS/src/Makefile \ 48 programmer/RISC-OS/gsl/Makefile \ 49 README.db README.sqlite \ 50 README.validation 51 52# bogofilter.cf.example 53# strlcat.3 strlcpy.3 54 55.1in.1: 56 sed -e "s|[@]sysconfdir@|$(sysconfdir)|g" \ 57 -e "s|[@]bindir@|$(bindir)|g" <$< >$@ \ 58 || { rm -f $@ ; exit 1 ; } 59 60# same as .1in.1: above, but POSIX doesn't allow two targets on one line. 61.htmlin.html: 62 sed -e "s|[@]sysconfdir@|$(sysconfdir)|g" \ 63 -e "s|[@]bindir@|$(bindir)|g" <$< >$@ \ 64 || { rm -f $@ ; exit 1 ; } 65 66if ENABLE_XMLTO 67dist-hook: 68 @if [ ! -f catalog ] ; then \ 69 echo ; echo "Warning: 'catalog' file not present; see 'README.validation'". ; echo ; else \ 70 case "$(MFLAGS)" in *s*) : ;; *) echo >&2 "validating $(HTML_DOCS)" ;; esac ; \ 71 ( set -e ; for i in $(HTML_DOCS) ; do $(NSGMLS) -s $(srcdir)/$$i \ 72 || { echo >&2 "ERROR: $$i does not validate." ; exit 1 ; } ; done ) ; \ 73 fi 74 75# Use Perl to fix up br0ken 0xa0 characters that the XML DocBook style 76# sheets emit instead of "\ " for roff or " " for HTML, 77# respectively. 78.xml.htmlin: 79 $(XMLLINT) --noout --postvalid $< 80 if test -f $(srcdir)/$@ && test $(srcdir)/$@ -nt $< ; then \ 81 cp $(srcdir)/$@ . ; else \ 82 if xmlto html-nochunks $< ; then f=$@ ; mv $${f%%in} $@ ; else rm -f $@ ; exit 1 ; fi ; \ 83 perl -pl -e "s|\xA0| |g" -i $@ || { rm -f $@ ; exit 1 ; } \ 84 fi 85 86.xml.1in: 87 $(XMLLINT) --noout --postvalid $< 88 if test -f $(srcdir)/$@ && test $(srcdir)/$@ -nt $< ; then \ 89 cp $(srcdir)/$@ . ; else \ 90 if xmlto man $< ; then f=$@ ; mv $${f%in} $@ ; else rm -f $@ ; exit 1 ; fi ; \ 91 perl -pl -e "s|\xA0|\\ |g" -i $@ || { rm -f $@ ; exit 1 ; } \ 92 fi 93else 94dist-hook: 95 true 96 97.xml.1in: 98 @echo 1>&2 99 @echo 1>&2 "You need xmlto to build bogofilter documentation." 100 @echo 1>&2 101 @exit 1 102 103.xml.htmlin: 104 @echo 1>&2 105 @echo 1>&2 "You need xmlto to build bogofilter documentation." 106 @echo 1>&2 107 @exit 1 108endif 109 110.PHONY: check checkx 111checkx: 112 @if echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> <head><title /> </head><body /> </html>' | $(XMLLINT) --noout --nonet --postvalid - 2>/dev/null ; then \ 113 set +e ; fail=0 ; for i in $(XHTML_DOCS) ; do if $(XMLLINT) --noout --postvalid $(srcdir)/$$i ; then echo PASS: $$i ; else echo FAIL: $$i: ; fail=1 ; fi ; done ; \ 114 if test "$$fail" = 1 ; then echo >&2 "*** XHTML document invalid ***" ; false ; fi ; \ 115 else echo >&2 "*** Not validating XHTML, XHTML 1.1 DTD not or improperly installed ***" ; fi 116 117check: checkx 118 @if echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><HTML><HEAD><TITLE></TITLE></HEAD><BODY><P></P></BODY></HTML>' | $(NSGMLS) -s 2>/dev/null; then \ 119 set +e ; fail=0 ; for i in $(HTML_DOCS) ; do if $(NSGMLS) -s $(srcdir)/$$i ; then echo PASS: $$i ; else echo FAIL: $$i: ; fail=1 ; fi ; done ; \ 120 else echo >&2 "*** Not validating HTML, nsgmls/HTML DTDs improperly installed ***" ; fi ; \ 121 if test "$$fail" = "1" ; then echo >&2 "*** HTML document invalid ***" ; false ; fi 122