From 8a937bd354001a190dbe66538aacb353e7c99341 Mon Sep 17 00:00:00 2001 From: Reinhard Tartler Date: Tue, 9 Nov 2010 17:28:58 +0100 Subject: Import upstream version 0.11~rc8~r2714 --- docs/Makefile | 160 +++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 107 insertions(+), 53 deletions(-) (limited to 'docs/Makefile') diff --git a/docs/Makefile b/docs/Makefile index f337fd86..c4a63671 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,8 +1,71 @@ +# Process DocBook to HTML +# This makefile is a bit obfuscated so that it works correctly on both +# BSD and GNU make. Some parts apply to one version of make and not the +# other; these are marked by comments. -# Process DocBook to HTML +# The "all" target shouldn't be up here, but the trickery below defines +# what looks like a rule to GNU make, and so we need to define the actual +# default target before it. + +all: docs -DBPROC=xsltproc +DBPROC_COMMAND = xsltproc +MKDIR_COMMAND = mkdir +CP_COMMAND = cp +PERL_COMMAND = perl +RM_COMMAND = rm -f +TAR_COMMAND = tar +GZIP_COMMAND = gzip -f +GENERATE_SCRIPT = tools/generate_except_xml.pl + +DBPROC = $(DBPROC_COMMAND) +MKDIR = $(MKDIR_COMMAND) +CP = $(CP_COMMAND) +GENERATE = $(PERL_COMMAND) $(GENERATE_SCRIPT) +RM_QUIET = $(RM_COMMAND) +TAR = $(TAR_COMMAND) +GZIP = $(GZIP_COMMAND) +PROGRESS = @ true + +# use a GNU make "define" command, that looks like a harmless dummy rule +# to BSD make, to hide parts of the Makefile from GNU make. +define IGNORED_BY_GNU_MAKE: +.if 0 +endef + + # seen by GNU make, not by BSD make + ifeq ($(V),) + DBPROC = @ echo " [XLSTPROC]" $^ && $(DBPROC_COMMAND) 2>/dev/null + GENERATE = @ echo " [GENERATE]" $@ && $(PERL_COMMAND) $(GENERATE_SCRIPT) + TAR = @ echo " [TAR] " $@ && $(TAR_COMMAND) + GZIP = @ echo " [GZIP] " $< && $(GZIP_COMMAND) + RM_QUIET = @ $(RM_COMMAND) + PROGRESS = @ echo + endif + +define IGNORED_BY_GNU_MAKE: +.endif + +.ifndef V + # seen by BSD make, not by GNU make + DBPROC = @ echo " [XSLTPROC]" $(.ALLSRC) && $(DBPROC_COMMAND) 2>/dev/null + GENERATE = @ echo " [GENERATE]" $(.TARGET) && $(PERL_COMMAND) $(GENERATE_SCRIPT) + TAR = @ echo " [TAR] " $(.TARGET) && $(TAR_COMMAND) + GZIP = @ echo " [GZIP] " $(.TARGET:.gz=) && $(GZIP_COMMAND) + RM_QUIET = @ $(RM_COMMAND) + PROGRESS = @ echo +.endif + +# neither .endif nor endef can be followed by a colon; each creates +# warnings or errors in one or other version of make. we need some +# magic to make them both work. Luckily, .endfor ignores the colon. + +.for DUMMY in $(NO_SUCH_VARIABLE) +endef +.endfor : + +PROGRESS_RM = $(PROGRESS) " [RM] " DOCBOOK_DIR = docbook HTML_DIR = htmlguide @@ -15,8 +78,6 @@ MANXSL = $(DOCBOOK_DIR)/bb-man.xsl VPATH = $(DOCBOOK_DIR) .SUFFIXES: .html .xml .gz .1 .5 .8 -all: docs - docs: instguide adminguide manpages @mkdir -p $(HTML_DIR)/images @cp $(DOCBOOK_DIR)/html/images/*.png $(HTML_DIR)/images/. @@ -25,36 +86,23 @@ docs: instguide adminguide manpages adminguide: $(DOCBOOK_DIR)/ExceptionCodes.xml $(HTML_DIR)/adminguide/index.html -# all sources ($>) is exactly the right args for xsltproc +# $^ gives all sources on GNU make, and nothing on BSD make +# $> gives all sources on BSD make, and nothing on GNU make $(HTML_DIR)/adminguide/index.html: $(BOOKXSL) $(DOCBOOK_DIR)/adminguide.xml - $(DBPROC) -o $(HTML_DIR)/adminguide/ $> + $(DBPROC) -o $(HTML_DIR)/adminguide/ $^ $> instguide: $(HTML_DIR)/instguide/index.html $(HTML_DIR)/instguide/index.html: $(BOOKXSL) $(DOCBOOK_DIR)/instguide.xml - $(DBPROC) -o $(HTML_DIR)/instguide/ $> + $(DBPROC) -o $(HTML_DIR)/instguide/ $^ $> -# $< is empty on BSD make when making this rule, $> has all sources -# $< has the target on GNU make, $> is empty +# On BSD make, $> contains all sources and $^ is empty +# On GNU make, $^ contains all sources and $> is empty $(DOCBOOK_DIR)/ExceptionCodes.xml: ../ExceptionCodes.txt - perl tools/generate_except_xml.pl $< $> $@ + $(GENERATE) $> $^ $@ manpages: man-dirs man-nroff man-html -xslt: $(MANXSL) - -$(MANXSL): $(MANXSL).tmpl - @if [ -f /usr/local/share/xsl/docbook/manpages/docbook.xsl ]; then \ - DOCBOOK=file:///usr/local/share/xsl/docbook/manpages/docbook.xsl; \ - elif [ -f /opt/local/share/xsl/docbook-xsl/manpages/docbook.xsl ]; then \ - DOCBOOK=file:///opt/local/share/xsl/docbook-xsl/manpages/docbook.xsl; \ - elif [ -f /usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl ]; then \ - DOCBOOK=file:///usr/share/sgml/docbook/xsl-stylesheets/manpages/docbook.xsl; \ - else \ - DOCBOOK=http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl; \ - fi; \ - sed -e "s,%%DOCBOOK%%,$${DOCBOOK}," $(MANXSL).tmpl > $(MANXSL) - man-dirs: man/.there $(HTML_DIR)/man-html/.there $(HTML_DIR)/man-html/.there: @@ -80,50 +128,56 @@ HTML_FILES = $(HTML_FILES_2:%=$(HTML_DIR)/man-html/%) man-html: $(HTML_FILES) +# $^ gives all sources on GNU make, and nothing on BSD make + +# GNU make +$(HTML_DIR)/man-html/%.html: $(NOCHUNKBOOKXSL) $(DOCBOOK_DIR)/%.xml + $(DBPROC) -o $@ $^ + # GNU make -$(HTML_DIR)/man-html/%.html: $(DOCBOOK_DIR)/%.xml $(NOCHUNKBOOKXSL) - $(DBPROC) -o $@ $(NOCHUNKBOOKXSL) $< +$(MAN_DIR)/%.8: $(MANXSL) $(DOCBOOK_DIR)/%.xml + $(DBPROC) -o $@ $^ -# Before running xsltproc to generate manual pages, we need to check -# that $(MANXSL) has been built. We don't want to add it to dependencies, -# because that would cause # the man pages to try to be rebuilt even if -# they already exist if the date of the xslt file changes, and that -# requires xsltproc, which negates the point of precompiling them for -# distribution users. +# GNU make +$(MAN_DIR)/%.8.gz: $(MAN_DIR)/%.8 + $(GZIP) $< # GNU make -$(MAN_DIR)/%.8.gz: $(DOCBOOK_DIR)/%.xml - $(MAKE) xslt - $(DBPROC) -o $(@:.gz=) $(MANXSL) $< - gzip $(@:.gz=) +$(MAN_DIR)/%.5: $(MANXSL) $(DOCBOOK_DIR)/%.xml $(MANXSL) + $(DBPROC) -o $@ $^ # GNU make -$(MAN_DIR)/%.5.gz: $(DOCBOOK_DIR)/%.xml - $(MAKE) xslt - $(DBPROC) -o $(@:.gz=) $(MANXSL) $< - gzip $(@:.gz=) +$(MAN_DIR)/%.5.gz: $(MAN_DIR)/%.5 + $(GZIP) $< # BSD make: the final colon (:) is required to make the .for and .endfor # lines valid in GNU make. It creates (different) dummy rules in GNU and # BSD make. Both dummy rules are harmless. .for MAN_PAGE in $(NROFF_PAGES) : -$(MAN_DIR)/$(MAN_PAGE).gz: $(DOCBOOK_DIR)/$(MAN_PAGE:R).xml - $(MAKE) xslt - $(DBPROC) -o $(.TARGET:.gz=) $(MANXSL) $> - gzip $(@:.gz=) +$(MAN_DIR)/$(MAN_PAGE).gz: $(MANXSL) $(DOCBOOK_DIR)/$(MAN_PAGE:R).xml + $(DBPROC) -o $(.TARGET:.gz=) $(.ALLSRC) + $(GZIP) $(.TARGET:.gz=) -$(HTML_DIR)/man-html/$(MAN_PAGE:R).html: $(DOCBOOK_DIR)/$(MAN_PAGE:R).xml - $(DBPROC) -o $@ $(NOCHUNKBOOKXSL) $> +$(HTML_DIR)/man-html/$(MAN_PAGE:R).html: $(NOCHUNKBOOKXSL) \ +$(DOCBOOK_DIR)/$(MAN_PAGE:R).xml + $(DBPROC) -o $(.TARGET) $(.ALLSRC) .endfor : -dockit: clean docs - tar zcf documentation-kit-0.10.tar.gz $(HTML_DIR)/ +dockit: clean docs documentation-kit-0.10.tar.gz + +documentation-kit-0.10.tar.gz: + $(TAR) zcf documentation-kit-0.10.tar.gz $(HTML_DIR)/ clean: - rm -f $(HTML_FILES) - rm -f $(NROFF_FILES) - rm -f $(DOCBOOK_DIR)/ExceptionCodes.xml - rm -f documentation-kit-0.10.tar.gz - rm -f $(MANXSL) + $(PROGRESS_RM) "$(HTML_DIR)/man-html/*.html" + $(RM_QUIET) $(HTML_FILES) + + $(PROGRESS_RM) "$(MAN_DIR)/*.[58].gz" + $(RM_QUIET) $(NROFF_FILES) + $(PROGRESS_RM) "$(DOCBOOK_DIR)/ExceptionCodes.xml" + $(RM_QUIET) $(DOCBOOK_DIR)/ExceptionCodes.xml + + $(PROGRESS_RM) "documentation-kit-0.10.tar.gz" + $(RM_QUIET) documentation-kit-0.10.tar.gz -- cgit v1.2.3