+# developer manual
+dok-devel:
+ $(RM) doc/webserver/developer-manual/*.html
+ $(RM) -r doc/source/developer-manual
+ mkdir -p doc/text doc/source/developer-manual
+ cd doc/source/developer-manual && $(DB) ../developer-manual.sgml && cd .. && cp developer-manual/*.html ../webserver/developer-manual/
+ cd doc/source && $(DB) -V nochunks developer-manual.sgml > tmp.html && $(WDUMP) tmp.html > ../text/developer-manual.txt && $(RM) -r tmp.html developer-manual
+
+# user manual
+dok-user:
+ $(RM) doc/webserver/user-manual/*.html
+ $(RM) -r doc/source/user-manual/
+ mkdir -p doc/text doc/source/user-manual
+ cd doc/source/user-manual && $(DB) -iuser-man ../user-manual.sgml && cd .. && cp user-manual/*.html ../webserver/user-manual/
+ @#FIXME: temp fix so same stylesheet gets in more than one place so it works \
+ @# for all doc set-ups, including the 'user manual' config option in local \
+ @#system where it MUST be in same directory as html.
+ $(PERL) -pi.bak -e 's/<\/head/\n<LINK REL=\"STYLESHEET\" TYPE=\"text\/css\" HREF=\"p_doc.css\">\n<\/head/i' doc/webserver/user-manual/*html
+ cd doc/source && $(DB) -iuser-man -V nochunks user-manual.sgml > tmp.html && $(WDUMP) tmp.html > ../text/user-manual.txt && $(RM) -r tmp.html user-manual
+
+# faq
+dok-faq:
+ $(RM) doc/webserver/faq/*.html
+ $(RM) -r doc/source/faq
+ mkdir -p doc/text doc/source/faq
+ cd doc/source/faq && $(DB) ../faq.sgml && cd .. && cp faq/*.html ../webserver/faq/
+ cd doc/source && $(DB) -V nochunks faq.sgml > tmp.html && $(WDUMP) tmp.html > ../text/faq.txt && $(RM) -r tmp.html faq
+
+# man page, one variation. Try to use the next target, just 'make man'.
+dok-man:
+ $(RM) doc/man/* doc/webserver/man-page/*.html
+ifneq ($(MAN2HTML),false)
+ $(ECHO) "<html><head><title>Privoxy Man page</title><link rel=\"stylesheet\" type=\"text/css\" href=\"../p_web.css\"></head><body><H2>NAME</H2>" > doc/webserver/man-page/privoxy-man-page.html
+ man ./privoxy.1 | $(MAN2HTML) -bare >> doc/webserver/man-page/privoxy-man-page.html
+ $(ECHO) "</body></html>" >> doc/webserver/man-page/privoxy-man-page.html
+else
+ $(MAKE) groff2html
+endif
+
+# Build man page from sgml. This requires the SGMLSpm perl module.
+# See CPAN, or your favorite perl repository. This is the preferred
+# target for man page generation!
+man: dok-release
+ mkdir -p doc/source/temp && cd doc/source/temp && $(RM) * ;\
+ nsgmls ../privoxy-man-page.sgml | sgmlspl ../../../utils/docbook2man/docbook2man-spec.pl &&\
+ perl -pi.bak -e 's/ <URL:.*>//; s/\[ /\[/g' privoxy.1 ;\
+ $(DB) ../privoxy-man-page.sgml && $(MV) -f privoxy.1 ../../../privoxy.1
+
+# For those with man2html ala RH7s.
+man2html:
+ mkdir -p doc/webserver/man-page
+ifneq ($(MAN2HTML),false)
+ $(MAN2HTML) privoxy.1 |grep -v "^Content-type" > tmp.html
+ $(PERL) -pi.bak -e 's/<A .*Contents<\/A>//; s/<A .*man2html<\/A>/man2html/' tmp.html
+ $(PERL) -pi.bak -e 's/(<\/HEAD>)/<LINK REL=\"STYLESHEET\" TYPE=\"text\/css\" HREF=\"..\/p_doc.css\"><\/HEAD>/' tmp.html
+# Twice because my version of man2html is pulling in commas and periods in URLs.
+ $(PERL) -pi.bak -e 's/(<A.*),(">)/$$1$$2/g' tmp.html
+ $(PERL) -pi.bak -e 's,\.">,">,g' tmp.html
+# Get rid of spurious \a from conversion. (How to do this with perl?)
+ $(SED) -e 's/\a//g' tmp.html > doc/webserver/man-page/privoxy-man-page.html && $(RM) tmp.*
+else
+ $(MAKE) groff2html
+endif
+
+
+# Otherwise we get plain groff conversion.
+groff2html:
+ $(G2H_CMD) ./privoxy.1 | $(SED) -e 's@</head>@<link REL="STYLESHEET" TYPE="text/css" HREF="../p_doc.css"></head>@' > doc/webserver/man-page/privoxy-man-page.html
+
+
+# readme page and INSTALL file
+dok-readme: dok-release
+ cd doc/source && $(DB)-notoc -V nochunks readme.sgml > tmp.html &&\
+ $(WDUMP) tmp.html > ../../README ;\
+ $(DB)-notoc -V nochunks install.sgml > tmp.html &&\
+ $(WDUMP) tmp.html > ../../INSTALL ;\
+ $(RM) tmp.*
+
+# index.sgml is used to create both the Home Page, and a local index
+# for documentation, etc.
+#
+# index.html for webserver:
+dok-webserver:
+ cd doc/source/webserver && $(DB)-notoc -ip-homepage -V nochunks index.sgml > ../../webserver/index.html
+ $(PERL) -pi.bak -e 's/..\/p_doc.css/p_doc.css/;\
+ s/<\/HEAD/\n<meta name=\"description\" content=\"Privoxy helps consumers reduce unwanted junk email and protect their privacy from direct marketing companies.\"><\/HEAD/;\
+ s/<\/HEAD/\n<meta name="MSSmartTagsPreventParsing" content="TRUE"><\/HEAD/;\
+ s/\.\d\. //;\
+ s/__copy/©/'\
+ doc/webserver/index.html && $(RM) doc/webserver/*.bak
+
+# privoxy-index.html for local documentation:
+dok-index:
+ cd doc/source/webserver && $(DB)-notoc -ip-index -V nochunks index.sgml > ../../webserver/privoxy-index.html
+ $(PERL) -pi.bak -e 's/..\/p_doc.css/p_doc.css/;\
+ s/<\/HEAD/\n<meta name=\"description\" content=\"Privoxy helps consumers reduce unwanted junk email and protect their privacy from direct marketing companies.\"><\/HEAD/;\
+ s/<\/HEAD/\n<meta name="MSSmartTagsPreventParsing" content="TRUE"><\/HEAD/;\
+ s/\.\d\. //;\
+ s/__copy/©/' \
+ doc/webserver/privoxy-index.html && $(RM) doc/webserver/*.bak
+
+# Main documentation target.
+dok: dok-release dok-devel dok-user dok-faq dok-readme dok-webserver dok-authors dok-index
+ @$(ECHO) Documentation created.
+
+#
+# an alternative to the above dok. disabled man page creation for the moment
+#
+redhat-dok: dok-release dok-devel dok-user dok-faq redhat-readme dok-webserver dok-authors
+ @$(ECHO) Documentation created.
+
+## Make README
+redhat-readme:
+ cd doc/source && $(DB)-notoc -V nochunks readme.sgml > tmp.html && $(WDUMP) \
+ tmp.html > ../../README && $(RM) -r tmp.html
+
+## Make AUTHORS file
+dok-authors:
+ cd doc/source && $(DB) -V nochunks authors.sgml > tmp.html && $(WDUMP) \
+ tmp.html > ../../AUTHORS && $(RM) tmp.html
+
+# Set doc entities for VERSION and CODE_STATUS in sgml docs. Toggle content
+# exceptions accordingly. This needs to go before any doc building (doh).
+dok-release:
+ @$(ECHO) Setting doc version and status to $(VERSION), $(CODE_STATUS)
+ @$(PERL) -pi.bak -e 's/<!entity +p-version.*>/<!entity p-version "$(VERSION)">/;\
+ s/<!entity +p-status.*>/<!entity p-status "$(CODE_STATUS)">/' \
+ doc/source/*sgml doc/source/*/*sgml
+ $(RM) -r doc/source/*bak doc/source/*/*bak
+ifeq ($(CODE_STATUS),stable)
+ @$(ECHO) Setting docs to stable $(VERSION)
+ @$(PERL) -pi.bak -e 's/<!entity +% +p-stable.*>/<!entity % p-stable "INCLUDE">/;\
+ s/<!entity +% +p-not-stable.*>/<!entity % p-not-stable "IGNORE">/' \
+ doc/source/*sgml doc/source/*/*sgml
+ $(RM) -r doc/source/*bak doc/source/*/*bak
+else
+ @$(ECHO) Setting docs to not stable $(VERSION)
+ @$(PERL) -pi.bak -e 's/<!entity +% +p-stable.*>/<!entity % p-stable "IGNORE">/;\
+ s/<!entity +% +p-not-stable.*>/<!entity % p-not-stable "INCLUDE">/' \
+ doc/source/*sgml doc/source/*/*sgml
+ $(RM) -r doc/source/*bak doc/source/*/*bak
+endif
+
+# Generate single page html. Used only for creating pdf docs (ATM).
+# Currently using: See http://www.easysw.com/htmldoc/pdf-o-matic.php.
+# If using this generator, remember U-M has a couple of graphics in
+# a parallel directory.
+#
+dok-shtml: dok-release
+ mkdir -p doc/source/temp # this directory not in cvs
+ cd doc/source && $(DB) -iuser-man -V nochunks user-manual.sgml > temp/privoxy-user-manual.html
+ cd doc/source && $(DB) -V nochunks developer-manual.sgml > temp/privoxy-developer-manual.html
+ cd doc/source && $(DB) -V nochunks faq.sgml > temp/privoxy-faq.html
+# one could use html2ps and ps2pdf. well, that does not work. htmlps produces incorrect output.
+
+# Make pdf docs from single page html. Requires htmldoc, see
+# (http://www.easysw.com/htmldoc/). Note: 1.8.20 has a TOC bug.
+# PDF docs are uploaded to webserver as zip archive.
+dok-pdf: dok-shtml
+ @$(ECHO) -n "starting htmldoc version: ";
+ if htmldoc --version ; then : ; \
+ else $(ECHO) "WARNING: could not get htmldoc version" ; fi
+ cd utils/ldp_print && $(RM) *html *bak *jpg *tmp *pdf *zip
+ cp -f doc/source/temp/*html doc/webserver/user-manual/*jpg utils/ldp_print
+ cd utils/ldp_print ;\
+ $(PERL) -pi.bak -e 's/\.\.\/images\///; s/(<\/?)SUB/$$1small/i;\
+ s/\.\.\/user-manual\/index\.html/privoxy-user-manual.pdf/;\
+ s/\.\.\/developer-manual\/index\.html/privoxy-developer-manual.pdf/;\
+ s/\.\.\/faq\/index\.html/privoxy-faq.pdf/' *.html ;\
+ for i in developer-manual user-manual faq; do \
+ ./ldp_print privoxy-$$i.html ;\
+ $(ECHO) DONE: privoxy-$$i.pdf ;\
+ done ;\
+ $(MV) *.pdf ../../doc/pdf ;\
+ $(RM) -r *html *bak *jpg *pdf *zip ../../doc/source/temp
+
+# Create release announcement in text and html, with short and long versions.
+# This is a standalone target, and must be invoked directly.
+# announce: dok-release
+# mkdir -p $(DOC_TMP)
+# cd $(DOC_TMP) && cp -f ../announce.sgml . && $(DB) -iannounce-big announce.sgml &&\
+# mv -f index.html announce.html && $(WDUMP) announce.html > announce.txt
+# cd $(DOC_TMP) && $(DB) announce.sgml &&\
+# mv -f index.html announce-mini.html && $(WDUMP) announce-mini.html > announce-mini.txt &&\
+# mv -f *html *txt ../../..
+# rm -fr $(DOC_TMP)
+
+# The main Privoxy config file, generated from sgml sources.
+# NOTE: This will require some hand editing. The new file is outputted
+# as config.new so that problem sections can be compared to previous
+# version. This is hardcored to w3m for html/text conversion. Also,
+# requires the shell util 'fmt'.
+config-file: dok-release
+ cd doc/source && $(DB)-notoc -iconfig-file -V nochunks config.sgml > __tmp.html &&\
+ w3m -dump __tmp.html |fmt -w 70 > ../../config.new && $(RM) -r __tmp.*
+ $(PERL) -pi.bak -e 's/^1\. \@\@TITLE\@\@/ /i;\
+ /^\d\.\d\.\s+/ && tr/[a-z]/[A-Z]/;\
+ $$header_len=0 unless $$hit_header;\
+ if ($$hit_header) {\
+ print "# ";\
+ for ($$i=1; $$i < $$header_len; $$i++) {print "=";}\
+ print "\n";\
+ };\
+ $$hit_header=0;\
+ $$hit_header=1 if m/^(\d\.)(\d\.)(\d\.)?\s/ && s/^(\d\.)//;\
+ $$header_len = length($$_);\
+ s/^/# /; /^# #{12,}/ && s/^# #/####/;\
+ s/^.*$$// if $$hit_option;\
+ $$hit_option=0;\
+ s/^\n//; s/^#\s*-{20,}//; s/ *$$//;\
+ $$hit_option=1 if s/^#\s+@@//;' config.new
+ $(RM) *.bak
+ @$(ECHO) "****************************************************"
+ @$(ECHO) "The output file is config.new."
+ @$(ECHO) "Now -- you need to hand edit the results!!!"
+ @$(ECHO) "In particular, check the Debug levels, the"
+ @$(ECHO) "permit-access, forward & socks examples and the"
+ @$(ECHO) "various user-manual examples, which all"
+ @$(ECHO) "probably got hammered."
+ @$(ECHO) "****************************************************"
+
+# config file, alternate verison using lynx (perl stuff unfinished). Lynx
+# does not do so good a job.
+config-file-alt:
+ cd doc/source && $(ECHO) -e ".h2 JUSTIFY\\nJUSTIFY:FALSE" > __tmp.lynx_cfg &&\
+ $(DB)-notoc -iconfig-file -V nochunks config.sgml > __tmp.html &&\
+ lynx -cfg=__tmp.lynx_cfg -width=78 -dump __tmp.html > ../../config.new && $(RM) -r __tmp.*
+ $(PERL) -pi -e 's/^( )//;\
+ s/:$\/:\n/' config.new