| 1 | # Process DocBook to HTML |
|---|
| 2 | |
|---|
| 3 | # This makefile is a bit obfuscated so that it works correctly on both |
|---|
| 4 | # BSD and GNU make. Some parts apply to one version of make and not the |
|---|
| 5 | # other; these are marked by comments. |
|---|
| 6 | |
|---|
| 7 | # The "all" target shouldn't be up here, but the trickery below defines |
|---|
| 8 | # what looks like a rule to GNU make, and so we need to define the actual |
|---|
| 9 | # default target before it. |
|---|
| 10 | |
|---|
| 11 | all: docs |
|---|
| 12 | |
|---|
| 13 | DBPROC_COMMAND = xsltproc |
|---|
| 14 | MKDIR_COMMAND = mkdir |
|---|
| 15 | CP_COMMAND = cp |
|---|
| 16 | PERL_COMMAND = perl |
|---|
| 17 | RM_COMMAND = rm -f |
|---|
| 18 | TAR_COMMAND = tar |
|---|
| 19 | GZIP_COMMAND = gzip -f |
|---|
| 20 | GENERATE_SCRIPT = tools/generate_except_xml.pl |
|---|
| 21 | |
|---|
| 22 | DBPROC = $(DBPROC_COMMAND) |
|---|
| 23 | MKDIR = $(MKDIR_COMMAND) |
|---|
| 24 | CP = $(CP_COMMAND) |
|---|
| 25 | GENERATE = $(PERL_COMMAND) $(GENERATE_SCRIPT) |
|---|
| 26 | RM_QUIET = $(RM_COMMAND) |
|---|
| 27 | TAR = $(TAR_COMMAND) |
|---|
| 28 | GZIP = $(GZIP_COMMAND) |
|---|
| 29 | PROGRESS = @ true |
|---|
| 30 | |
|---|
| 31 | # use a GNU make "define" command, that looks like a harmless dummy rule |
|---|
| 32 | # to BSD make, to hide parts of the Makefile from GNU make. |
|---|
| 33 | define IGNORED_BY_GNU_MAKE: |
|---|
| 34 | .if 0 |
|---|
| 35 | endef |
|---|
| 36 | |
|---|
| 37 | # seen by GNU make, not by BSD make |
|---|
| 38 | ifeq ($(V),) |
|---|
| 39 | DBPROC = @ echo " [XLSTPROC]" $^ && $(DBPROC_COMMAND) 2>/dev/null |
|---|
| 40 | GENERATE = @ echo " [GENERATE]" $@ && $(PERL_COMMAND) $(GENERATE_SCRIPT) |
|---|
| 41 | TAR = @ echo " [TAR] " $@ && $(TAR_COMMAND) |
|---|
| 42 | GZIP = @ echo " [GZIP] " $< && $(GZIP_COMMAND) |
|---|
| 43 | RM_QUIET = @ $(RM_COMMAND) |
|---|
| 44 | PROGRESS = @ echo |
|---|
| 45 | endif |
|---|
| 46 | |
|---|
| 47 | define IGNORED_BY_GNU_MAKE: |
|---|
| 48 | .endif |
|---|
| 49 | |
|---|
| 50 | .ifndef V |
|---|
| 51 | # seen by BSD make, not by GNU make |
|---|
| 52 | DBPROC = @ echo " [XSLTPROC]" $(.ALLSRC) && $(DBPROC_COMMAND) 2>/dev/null |
|---|
| 53 | GENERATE = @ echo " [GENERATE]" $(.TARGET) && $(PERL_COMMAND) $(GENERATE_SCRIPT) |
|---|
| 54 | TAR = @ echo " [TAR] " $(.TARGET) && $(TAR_COMMAND) |
|---|
| 55 | GZIP = @ echo " [GZIP] " $(.TARGET:.gz=) && $(GZIP_COMMAND) |
|---|
| 56 | RM_QUIET = @ $(RM_COMMAND) |
|---|
| 57 | PROGRESS = @ echo |
|---|
| 58 | .endif |
|---|
| 59 | |
|---|
| 60 | # neither .endif nor endef can be followed by a colon; each creates |
|---|
| 61 | # warnings or errors in one or other version of make. we need some |
|---|
| 62 | # magic to make them both work. Luckily, .endfor ignores the colon. |
|---|
| 63 | |
|---|
| 64 | .for DUMMY in $(NO_SUCH_VARIABLE) |
|---|
| 65 | endef |
|---|
| 66 | .endfor : |
|---|
| 67 | |
|---|
| 68 | PROGRESS_RM = $(PROGRESS) " [RM] " |
|---|
| 69 | |
|---|
| 70 | DOCBOOK_DIR = docbook |
|---|
| 71 | HTML_DIR = htmlguide |
|---|
| 72 | MAN_DIR = man |
|---|
| 73 | |
|---|
| 74 | BOOKXSL = $(DOCBOOK_DIR)/bb-book.xsl |
|---|
| 75 | NOCHUNKBOOKXSL = $(DOCBOOK_DIR)/bb-nochunk-book.xsl |
|---|
| 76 | MANXSL = $(DOCBOOK_DIR)/bb-man.xsl |
|---|
| 77 | |
|---|
| 78 | VPATH = $(DOCBOOK_DIR) |
|---|
| 79 | .SUFFIXES: .html .xml .gz .1 .5 .8 |
|---|
| 80 | |
|---|
| 81 | docs: instguide adminguide manpages |
|---|
| 82 | @mkdir -p $(HTML_DIR)/images |
|---|
| 83 | @cp $(DOCBOOK_DIR)/html/images/*.png $(HTML_DIR)/images/. |
|---|
| 84 | @cp $(DOCBOOK_DIR)/html/*.css $(HTML_DIR)/. |
|---|
| 85 | @cp $(DOCBOOK_DIR)/html/*.ico $(HTML_DIR)/. |
|---|
| 86 | |
|---|
| 87 | adminguide: $(DOCBOOK_DIR)/ExceptionCodes.xml $(HTML_DIR)/adminguide/index.html |
|---|
| 88 | |
|---|
| 89 | # $^ gives all sources on GNU make, and nothing on BSD make |
|---|
| 90 | # $> gives all sources on BSD make, and nothing on GNU make |
|---|
| 91 | $(HTML_DIR)/adminguide/index.html: $(BOOKXSL) $(DOCBOOK_DIR)/adminguide.xml |
|---|
| 92 | $(DBPROC) -o $(HTML_DIR)/adminguide/ $^ $> |
|---|
| 93 | |
|---|
| 94 | instguide: $(HTML_DIR)/instguide/index.html |
|---|
| 95 | |
|---|
| 96 | $(HTML_DIR)/instguide/index.html: $(BOOKXSL) $(DOCBOOK_DIR)/instguide.xml |
|---|
| 97 | $(DBPROC) -o $(HTML_DIR)/instguide/ $^ $> |
|---|
| 98 | |
|---|
| 99 | # On BSD make, $> contains all sources and $^ is empty |
|---|
| 100 | # On GNU make, $^ contains all sources and $> is empty |
|---|
| 101 | $(DOCBOOK_DIR)/ExceptionCodes.xml: ../ExceptionCodes.txt |
|---|
| 102 | $(GENERATE) $> $^ $@ |
|---|
| 103 | |
|---|
| 104 | manpages: man-dirs man-nroff man-html |
|---|
| 105 | |
|---|
| 106 | man-dirs: man/.there $(HTML_DIR)/man-html/.there |
|---|
| 107 | |
|---|
| 108 | $(HTML_DIR)/man-html/.there: |
|---|
| 109 | mkdir -p $(HTML_DIR)/man-html |
|---|
| 110 | touch $(HTML_DIR)/man-html/.there |
|---|
| 111 | |
|---|
| 112 | man/.there: |
|---|
| 113 | mkdir -p man |
|---|
| 114 | touch man/.there |
|---|
| 115 | |
|---|
| 116 | NROFF_PAGES = bbackupd.8 bbackupd-config.8 bbackupctl.8 bbackupquery.8 \ |
|---|
| 117 | bbstored.8 bbstored-config.8 bbstoreaccounts.8 bbstored-certs.8 \ |
|---|
| 118 | raidfile-config.8 \ |
|---|
| 119 | bbackupd.conf.5 bbstored.conf.5 raidfile.conf.5 |
|---|
| 120 | |
|---|
| 121 | NROFF_FILES = $(NROFF_PAGES:%=$(MAN_DIR)/%.gz) |
|---|
| 122 | |
|---|
| 123 | man-nroff: $(NROFF_FILES) |
|---|
| 124 | |
|---|
| 125 | HTML_FILES_1 = $(NROFF_PAGES:%.5=%.html) |
|---|
| 126 | HTML_FILES_2 = $(HTML_FILES_1:%.8=%.html) |
|---|
| 127 | HTML_FILES = $(HTML_FILES_2:%=$(HTML_DIR)/man-html/%) |
|---|
| 128 | |
|---|
| 129 | man-html: $(HTML_FILES) |
|---|
| 130 | |
|---|
| 131 | # $^ gives all sources on GNU make, and nothing on BSD make |
|---|
| 132 | |
|---|
| 133 | # GNU make |
|---|
| 134 | $(HTML_DIR)/man-html/%.html: $(NOCHUNKBOOKXSL) $(DOCBOOK_DIR)/%.xml |
|---|
| 135 | $(DBPROC) -o $@ $^ |
|---|
| 136 | |
|---|
| 137 | # GNU make |
|---|
| 138 | $(MAN_DIR)/%.8: $(MANXSL) $(DOCBOOK_DIR)/%.xml |
|---|
| 139 | $(DBPROC) -o $@ $^ |
|---|
| 140 | |
|---|
| 141 | # GNU make |
|---|
| 142 | $(MAN_DIR)/%.8.gz: $(MAN_DIR)/%.8 |
|---|
| 143 | $(GZIP) $< |
|---|
| 144 | |
|---|
| 145 | # GNU make |
|---|
| 146 | $(MAN_DIR)/%.5: $(MANXSL) $(DOCBOOK_DIR)/%.xml $(MANXSL) |
|---|
| 147 | $(DBPROC) -o $@ $^ |
|---|
| 148 | |
|---|
| 149 | # GNU make |
|---|
| 150 | $(MAN_DIR)/%.5.gz: $(MAN_DIR)/%.5 |
|---|
| 151 | $(GZIP) $< |
|---|
| 152 | |
|---|
| 153 | # BSD make: the final colon (:) is required to make the .for and .endfor |
|---|
| 154 | # lines valid in GNU make. It creates (different) dummy rules in GNU and |
|---|
| 155 | # BSD make. Both dummy rules are harmless. |
|---|
| 156 | |
|---|
| 157 | .for MAN_PAGE in $(NROFF_PAGES) : |
|---|
| 158 | $(MAN_DIR)/$(MAN_PAGE).gz: $(MANXSL) $(DOCBOOK_DIR)/$(MAN_PAGE:R).xml |
|---|
| 159 | $(DBPROC) -o $(.TARGET:.gz=) $(.ALLSRC) |
|---|
| 160 | $(GZIP) $(.TARGET:.gz=) |
|---|
| 161 | |
|---|
| 162 | $(HTML_DIR)/man-html/$(MAN_PAGE:R).html: $(NOCHUNKBOOKXSL) \ |
|---|
| 163 | $(DOCBOOK_DIR)/$(MAN_PAGE:R).xml |
|---|
| 164 | $(DBPROC) -o $(.TARGET) $(.ALLSRC) |
|---|
| 165 | .endfor : |
|---|
| 166 | |
|---|
| 167 | dockit: clean docs documentation-kit-0.10.tar.gz |
|---|
| 168 | |
|---|
| 169 | documentation-kit-0.10.tar.gz: |
|---|
| 170 | $(TAR) zcf documentation-kit-0.10.tar.gz $(HTML_DIR)/ |
|---|
| 171 | |
|---|
| 172 | clean: |
|---|
| 173 | $(PROGRESS_RM) "$(HTML_DIR)/man-html/*.html" |
|---|
| 174 | $(RM_QUIET) $(HTML_FILES) |
|---|
| 175 | |
|---|
| 176 | $(PROGRESS_RM) "$(MAN_DIR)/*.[58].gz" |
|---|
| 177 | $(RM_QUIET) $(NROFF_FILES) |
|---|
| 178 | |
|---|
| 179 | $(PROGRESS_RM) "$(DOCBOOK_DIR)/ExceptionCodes.xml" |
|---|
| 180 | $(RM_QUIET) $(DOCBOOK_DIR)/ExceptionCodes.xml |
|---|
| 181 | |
|---|
| 182 | $(PROGRESS_RM) "documentation-kit-0.10.tar.gz" |
|---|
| 183 | $(RM_QUIET) documentation-kit-0.10.tar.gz |
|---|