Rename the tidy target to clean-editor-files so it can't be confused with the dok...
[privoxy.git] / GNUmakefile.in
index 40e4cd5..19b3dcd 100644 (file)
@@ -1,8 +1,8 @@
 # Note:  Makefile is built automatically from Makefile.in
 #
-# $Id: GNUmakefile.in,v 1.195 2011/01/22 12:33:11 fabiankeil Exp $
+# $Id: GNUmakefile.in,v 1.201 2011/08/31 13:36:35 fabiankeil Exp $
 #
-# Written by and Copyright (C) 2001-2010 members of the
+# Written by and Copyright (C) 2001-2011 members of the
 # Privoxy team. http://www.privoxy.org/
 #
 # Based on the Internet Junkbuster originally written
@@ -142,6 +142,7 @@ PERL       = perl
 DOC_DIR    = doc/source
 DOC_TMP    = $(DOC_DIR)/tmp
 DOC_STATUS = @DOC_STATUS@
+TIDY       = tidy -modify -indent -clean -wrap 78
 
 # Program to do LF->CRLF
 #
@@ -274,8 +275,7 @@ PID_DEST check_doc install-strip uninstall GROUP_T
 # Strip master copy comments from default.action:
 #############################################################################
 default.action: default.action.master
-       $(GREP) -v '^#MASTER#' $< > $@
-
+       $(GREP) -v '^#MASTER#' default.action.master > $@
 #############################################################################
 # Win32 config files
 #############################################################################
@@ -456,13 +456,14 @@ dok-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 ./$(MAN_PAGE) | $(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
+       echo MAN2HTML is $(MAN2HTML)
+       @if [ $(MAN2HTML) != "false" ]; then \
+               $(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 ./$(MAN_PAGE) | $(MAN2HTML) -bare >> doc/webserver/man-page/privoxy-man-page.html; \
+               $(ECHO) "</body></html>" >> doc/webserver/man-page/privoxy-man-page.html; \
+       else \
+               $(MAKE) groff2html; \
+       fi;
 
 # Build man page from sgml. This requires the SGMLSpm perl module.
 # See CPAN, or your favorite perl repository. This is the preferred 
@@ -481,20 +482,17 @@ man: dok-release
 # For those with man2html ala RH7s.
 man2html:
        mkdir -p doc/webserver/man-page
-ifneq ($(MAN2HTML),false)
-       $(MAN2HTML) $(MAN_PAGE) |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
-       $(PERL) -pi.bak -e "s/\['a\]/\&aacute;/g;s/\['e\]/\&eacute;/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
-
+       @if [ $(MAN2HTML) != "false" ]; then \
+               $(MAN2HTML) $(MAN_PAGE) |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; \
+               $(PERL) -pi.bak -e 's/(<A.*),(">)/$$1$$2/g' tmp.html; \
+               $(PERL) -pi.bak -e 's,\.">,">,g' tmp.html; \
+               $(PERL) -pi.bak -e "s/\['a\]/\&aacute;/g;s/\['e\]/\&eacute;/g" tmp.html; \
+               $(SED) -e 's/\a//g' tmp.html > doc/webserver/man-page/privoxy-man-page.html && $(RM) tmp.*; \
+       else \
+               $(MAKE) groff2html; \
+       fi;
 
 # Otherwise we get plain groff conversion.
 groff2html:
@@ -549,19 +547,18 @@ dok-release:
      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
+       @if [ $(CODE_STATUS) = "stable" ]; then \
+               $(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; \
+       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; \
+       fi;
+       $(RM) -r doc/source/*bak doc/source/*/*bak;
 
 # Create release announcement in text and html, with short and long versions.
 # This is a standalone target, and must be invoked directly.
@@ -610,7 +607,7 @@ config-file-alt:
 # moves dokumentation to webserver
 #
 #############################################################################
-webserver: tidy
+webserver: clean-editor-files
        @$(ECHO) -------------------------------------------------------
        @$(ECHO) You will need to "create" a SF shell first:
        @$(ECHO)    ssh -t SF-USER-ID,ijbswa@shell.sourceforge.net create
@@ -635,7 +632,7 @@ webserver: tidy
        @$(SSH) shell.sourceforge.net 'chmod -R 775 /home/groups/i/ij/ijbswa/htdocs 2>/dev/null; true'
        @$(SSH) shell.sourceforge.net 'find /home/groups/i/ij/ijbswa/htdocs/ -type f | xargs chmod 664 2>/dev/null; true'
 
-web-actions: tidy
+web-actions: clean-editor-files
        @$(ECHO) Uploading 
        @cd doc/webserver/actions; \
           upload=`find . -type f -a -not \( -path "*/CVS*" -o -path "*/results*" \)`; \
@@ -661,6 +658,22 @@ dok-get:
        $(WGET) http://www.privoxy.org/docs/$(DOC_FILE) ;\
        $(TAR) -zxvf $(DOC_FILE)
 
+#############################################################################
+#
+# Try to clean up the generated HTML files.
+#
+# The files are a such a mess that some of them require two tidy runs
+# in row as the first abort prematurely. The vanilla tidy output renders
+# poorly as it contains a bit too much white-space, so we additionally run
+# the files through perl to fix this again.
+#
+#############################################################################
+dok-tidy:
+       for html_file in `find doc/webserver -name "*.html"`; do \
+               $(TIDY) $$html_file || $(TIDY) $$html_file; \
+               $(PERL) -i\'\' -e 's@^\s*<br>\s*$$@@; s@ +$$@@;' -n -p $$html_file; \
+       done
+
 
 #############################################################################
 # Source file dependencies
@@ -733,12 +746,12 @@ clean:
        $(RM) a.out $(OBJS) $(W32_FILES) $(W32_INIS) $(PROGRAM) default.action \
                `find . -name TAGS -o -name tags | $(GREP) -v .git` config.base config.tmp
 
-tidy:
+clean-editor-files:
        $(RM) `find . -name "*~"`
        $(RM) `find . -name "#*#"` # Emacs backup files
        $(RM) `find . -name ".\#*"`
 
-clobber: tidy
+clobber: clean-editor-files
        $(RM) GNUmakefile configure config.h.in config.h config.cache config.status config.log logfile \
               privoxy.log core *.tar.gz *.tar privoxy-cl.spec doc/source/ldp.dsl config.new
        $(RM) -r autom4te.cache