[a2f7a1c] | 1 | # vim:ts=3
|
---|
[19599c63] | 2 | # Makefile for BLFS Book generation.
|
---|
| 3 | # By Tushar Teredesai <tushar@linuxfromscratch.org>
|
---|
| 4 | # 2004-01-31
|
---|
[35d9770] | 5 |
|
---|
[19599c63] | 6 | # Adjust these to suit your installation
|
---|
[efe19ba] | 7 | RENDERTMP ?= $(HOME)/tmp
|
---|
| 8 | CHUNK_QUIET = 1
|
---|
| 9 | ROOT_ID =
|
---|
| 10 | SHELL = /bin/bash
|
---|
[35d9770] | 11 |
|
---|
[51bec49] | 12 | ALLXML := $(filter-out $(RENDERTMP)/%, \
|
---|
[e3047fd] | 13 | $(wildcard *.xml */*.xml */*/*.xml */*/*/*.xml */*/*/*/*.xml))
|
---|
[51bec49] | 14 | ALLXSL := $(filter-out $(RENDERTMP)/%, \
|
---|
[e3047fd] | 15 | $(wildcard *.xsl */*.xsl */*/*.xsl */*/*/*.xsl */*/*/*/*.xsl))
|
---|
[3c265f56] | 16 |
|
---|
[35d9770] | 17 | ifdef V
|
---|
| 18 | Q =
|
---|
| 19 | else
|
---|
| 20 | Q = @
|
---|
| 21 | endif
|
---|
| 22 |
|
---|
[efe19ba] | 23 | ifndef REV
|
---|
| 24 | REV = sysv
|
---|
| 25 | endif
|
---|
| 26 |
|
---|
| 27 | ifneq ($(REV), sysv)
|
---|
| 28 | ifneq ($(REV), systemd)
|
---|
| 29 | $(error REV must be 'sysv' (default) or 'systemd'.)
|
---|
| 30 | endif
|
---|
| 31 | endif
|
---|
| 32 |
|
---|
| 33 | ifeq ($(REV), sysv)
|
---|
| 34 | BASEDIR ?= $(HOME)/public_html/blfs-book
|
---|
| 35 | NOCHUNKS_OUTPUT ?= blfs-book.html
|
---|
| 36 | DUMPDIR ?= ~/blfs-commands
|
---|
[f852e706] | 37 | BLFSHTML ?= blfs-html.xml
|
---|
| 38 | BLFSHTML2 ?= blfs-html2.xml
|
---|
| 39 | BLFSFULL ?= blfs-full.xml
|
---|
[efe19ba] | 40 | else
|
---|
| 41 | BASEDIR ?= $(HOME)/public_html/blfs-systemd
|
---|
| 42 | NOCHUNKS_OUTPUT ?= blfs-sysd-book.html
|
---|
| 43 | DUMPDIR ?= ~/blfs-sysd-commands
|
---|
[f852e706] | 44 | BLFSHTML ?= blfs-systemd-html.xml
|
---|
| 45 | BLFSHTML2 ?= blfs-systemd-html2.xml
|
---|
| 46 | BLFSFULL ?= blfs-systemd-full.xml
|
---|
| 47 |
|
---|
[efe19ba] | 48 | endif
|
---|
| 49 |
|
---|
[575bba80] | 50 | blfs: html wget-list
|
---|
[efe19ba] | 51 |
|
---|
[820b6d7] | 52 | help:
|
---|
| 53 | @echo ""
|
---|
| 54 | @echo "make <parameters> <targets>"
|
---|
| 55 | @echo ""
|
---|
| 56 | @echo "Parameters:"
|
---|
| 57 | @echo " REV=<rev> Build variation of book"
|
---|
| 58 | @echo " Valid values for REV are:"
|
---|
| 59 | @echo " * sysv - Build book for SysV"
|
---|
| 60 | @echo " * systemd - Build book for systemd"
|
---|
| 61 | @echo " Defaults to 'sysv'"
|
---|
| 62 | @echo ""
|
---|
| 63 | @echo " BASEDIR=<dir> Put the output in directory <dir>."
|
---|
| 64 | @echo " Defaults to"
|
---|
| 65 | @echo " 'HOME/public_html/blfs-book' if REV=sysv (or unset)"
|
---|
| 66 | @echo " or to"
|
---|
| 67 | @echo " 'HOME/public_html/blfs-book-systemd' if REV=systemd"
|
---|
| 68 | @echo ""
|
---|
| 69 | @echo " V=<val> If <val> is a non-empty value, all"
|
---|
| 70 | @echo " steps to produce the output is shown."
|
---|
| 71 | @echo " Default is unset."
|
---|
| 72 | @echo ""
|
---|
| 73 | @echo "Targets:"
|
---|
| 74 | @echo " help Show this help text."
|
---|
| 75 | @echo ""
|
---|
| 76 | @echo " blfs Builds targets 'html' and 'wget-list'."
|
---|
| 77 | @echo ""
|
---|
| 78 | @echo " html Builds the HTML pages of the book."
|
---|
| 79 | @echo ""
|
---|
| 80 | @echo " wget-list Produces a list of all packages to download."
|
---|
| 81 | @echo " Output is BASEDIR/wget-list"
|
---|
| 82 | @echo ""
|
---|
| 83 | @echo " nochunks Builds the book as a one-pager. The output"
|
---|
| 84 | @echo " is a large single HTML page containing the"
|
---|
| 85 | @echo " whole book."
|
---|
| 86 | @echo ""
|
---|
| 87 | @echo " Parameter NOCHUNKS_OUTPUT=<filename> controls"
|
---|
| 88 | @echo " the name of the HTML file."
|
---|
| 89 | @echo ""
|
---|
| 90 | @echo " validate Runs validation checks on the XML files."
|
---|
| 91 | @echo ""
|
---|
| 92 | @echo " test-links Runs validation checks on URLs in the book."
|
---|
| 93 | @echo " Produces a file named BASEDIR/bad_urls containing"
|
---|
| 94 | @echo " URLS which are invalid and a BASEDIR/good_urls"
|
---|
| 95 | @echo " containing all valid URLs."
|
---|
| 96 | @echo ""
|
---|
| 97 |
|
---|
[f5ee8c2] | 98 | all: blfs nochunks
|
---|
[575bba80] | 99 | world: all blfs-patch-list dump-commands test-links
|
---|
| 100 |
|
---|
| 101 | html: $(BASEDIR)/index.html
|
---|
[e3047fd] | 102 | $(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML) version
|
---|
[35d9770] | 103 | @echo "Generating chunked XHTML files..."
|
---|
[efe19ba] | 104 | $(Q)xsltproc --nonet \
|
---|
| 105 | --stringparam chunk.quietly $(CHUNK_QUIET) \
|
---|
| 106 | --stringparam rootid "$(ROOT_ID)" \
|
---|
| 107 | --stringparam base.dir $(BASEDIR)/ \
|
---|
| 108 | stylesheets/blfs-chunked.xsl \
|
---|
[f852e706] | 109 | $(RENDERTMP)/$(BLFSHTML)
|
---|
[35d9770] | 110 |
|
---|
| 111 | @echo "Copying CSS code and images..."
|
---|
| 112 | $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
---|
[efe19ba] | 113 | mkdir -p $(BASEDIR)/stylesheets; \
|
---|
| 114 | fi;
|
---|
| 115 |
|
---|
[35d9770] | 116 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
---|
[8ed58ee] | 117 | $(Q)sed -i 's|../stylesheet|stylesheet|' $(BASEDIR)/index.html
|
---|
[efe19ba] | 118 |
|
---|
[35d9770] | 119 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
---|
[efe19ba] | 120 | mkdir -p $(BASEDIR)/images; \
|
---|
| 121 | fi;
|
---|
[35d9770] | 122 | $(Q)cp images/*.png $(BASEDIR)/images
|
---|
[efe19ba] | 123 |
|
---|
[869909a] | 124 | $(Q)cd $(BASEDIR)/; sed -e "s@../images@images@g" \
|
---|
[efe19ba] | 125 | -i *.html
|
---|
[4a02298] | 126 |
|
---|
[5d463a51] | 127 | @echo "Running Tidy and obfuscate.sh on chunked XHTML..."
|
---|
[efe19ba] | 128 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
---|
| 129 | tidy -config tidy.conf $$filename; \
|
---|
| 130 | true; \
|
---|
| 131 | bash obfuscate.sh $$filename; \
|
---|
[28909b72] | 132 | sed -i -e "1,20s@text/html@application/xhtml+xml@g" $$filename; \
|
---|
[efe19ba] | 133 | done;
|
---|
[6d3005f] | 134 |
|
---|
[575bba80] | 135 | nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
[e3047fd] | 136 | $(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML) version
|
---|
[5d463a51] | 137 | @echo "Generating non-chunked XHTML file..."
|
---|
[efe19ba] | 138 | $(Q)xsltproc --nonet \
|
---|
| 139 | --stringparam rootid "$(ROOT_ID)" \
|
---|
| 140 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
---|
| 141 | stylesheets/blfs-nochunks.xsl \
|
---|
[f852e706] | 142 | $(RENDERTMP)/$(BLFSHTML)
|
---|
[35d9770] | 143 |
|
---|
[5d463a51] | 144 | @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
|
---|
[35d9770] | 145 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
---|
[7ba7636] | 146 | $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
[28909b72] | 147 | $(Q)sed -i -e "1,20s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
[35d9770] | 148 |
|
---|
[575bba80] | 149 | tmpdir: $(RENDERTMP)
|
---|
| 150 | $(RENDERTMP):
|
---|
| 151 | @echo "Creating $(RENDERTMP)"
|
---|
[adf0149] | 152 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
[575bba80] | 153 |
|
---|
| 154 | clean:
|
---|
| 155 | @echo "Cleaning $(RENDERTMP)"
|
---|
[f852e706] | 156 | $(Q)rm -f $(RENDERTMP)/blfs*
|
---|
[8e2f3658] | 157 |
|
---|
[f852e706] | 158 | validate: $(RENDERTMP)/$(BLFSFULL)
|
---|
[e3047fd] | 159 | $(RENDERTMP)/$(BLFSFULL): general.ent packages.ent $(ALLXML) $(ALLXSL) version
|
---|
[575bba80] | 160 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
[efe19ba] | 161 |
|
---|
| 162 | @echo "Adjusting for revision $(REV)..."
|
---|
| 163 | $(Q)xsltproc --nonet \
|
---|
| 164 | --xinclude \
|
---|
[a2f7a1c] | 165 | --output $(RENDERTMP)/$(BLFSHTML2) \
|
---|
[efe19ba] | 166 | --stringparam profile.revision $(REV) \
|
---|
| 167 | stylesheets/lfs-xsl/profile.xsl \
|
---|
| 168 | index.xml
|
---|
| 169 |
|
---|
| 170 | @echo "Validating the book..."
|
---|
| 171 | $(Q)xmllint --nonet \
|
---|
| 172 | --noent \
|
---|
| 173 | --postvalid \
|
---|
[a2f7a1c] | 174 | --output $(RENDERTMP)/$(BLFSFULL) \
|
---|
[f852e706] | 175 | $(RENDERTMP)/$(BLFSHTML2)
|
---|
[35d9770] | 176 |
|
---|
[f852e706] | 177 | profile-html: $(RENDERTMP)/$(BLFSHTML)
|
---|
[e3047fd] | 178 | $(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL) version
|
---|
[35d9770] | 179 | @echo "Generating profiled XML for XHTML..."
|
---|
[efe19ba] | 180 | $(Q)xsltproc --nonet \
|
---|
| 181 | --stringparam profile.condition html \
|
---|
[a2f7a1c] | 182 | --output $(RENDERTMP)/$(BLFSHTML) \
|
---|
[efe19ba] | 183 | stylesheets/lfs-xsl/profile.xsl \
|
---|
[f852e706] | 184 | $(RENDERTMP)/$(BLFSFULL)
|
---|
[35d9770] | 185 |
|
---|
[0238e7e] | 186 | blfs-patch-list: blfs-patches.sh
|
---|
| 187 | @echo "Generating blfs patch list..."
|
---|
| 188 | $(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
|
---|
| 189 | blfs-patches.sh > blfs-patch-list
|
---|
| 190 |
|
---|
[e3047fd] | 191 | blfs-patches.sh: $(RENDERTMP)/$(BLFSFULL) version
|
---|
[0238e7e] | 192 | @echo "Generating blfs patch script..."
|
---|
[efe19ba] | 193 | $(Q)xsltproc --nonet \
|
---|
| 194 | --output blfs-patches.sh \
|
---|
| 195 | stylesheets/patcheslist.xsl \
|
---|
[f852e706] | 196 | $(RENDERTMP)/$(BLFSFULL)
|
---|
[35d9770] | 197 |
|
---|
[575bba80] | 198 | wget-list: $(BASEDIR)/wget-list
|
---|
[e3047fd] | 199 | $(BASEDIR)/wget-list: $(RENDERTMP)/$(BLFSFULL) version
|
---|
[efe19ba] | 200 | @echo "Generating wget list for $(REV) at $(BASEDIR)/wget-list ..."
|
---|
[35d9770] | 201 | $(Q)mkdir -p $(BASEDIR)
|
---|
[efe19ba] | 202 | $(Q)xsltproc --nonet \
|
---|
| 203 | --output $(BASEDIR)/wget-list \
|
---|
| 204 | stylesheets/wget-list.xsl \
|
---|
[f852e706] | 205 | $(RENDERTMP)/$(BLFSFULL)
|
---|
[35d9770] | 206 |
|
---|
[cb55412] | 207 | test-links: $(BASEDIR)/test-links
|
---|
[e3047fd] | 208 | $(BASEDIR)/test-links: $(RENDERTMP)/$(BLFSFULL) version
|
---|
[35d9770] | 209 | @echo "Generating test-links file..."
|
---|
| 210 | $(Q)mkdir -p $(BASEDIR)
|
---|
[efe19ba] | 211 | $(Q)xsltproc --nonet \
|
---|
| 212 | --stringparam list_mode full \
|
---|
| 213 | --output $(BASEDIR)/test-links \
|
---|
| 214 | stylesheets/wget-list.xsl \
|
---|
[f852e706] | 215 | $(RENDERTMP)/$(BLFSFULL)
|
---|
[35d9770] | 216 |
|
---|
[cdd254a] | 217 | @echo "Checking URLs, first pass..."
|
---|
[35d9770] | 218 | $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
|
---|
[efe19ba] | 219 | $(Q)for URL in `cat $(BASEDIR)/test-links`; do \
|
---|
| 220 | wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
|
---|
| 221 | if test $$? -ne 0 ; then \
|
---|
| 222 | echo $$URL >> $(BASEDIR)/bad_urls ; \
|
---|
| 223 | else \
|
---|
| 224 | echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
|
---|
| 225 | fi; \
|
---|
| 226 | done
|
---|
[35d9770] | 227 |
|
---|
[cdd254a] | 228 | @echo "Checking URLs, second pass..."
|
---|
[efe19ba] | 229 | $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
|
---|
| 230 | wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
|
---|
| 231 | if test $$? -ne 0 ; then \
|
---|
| 232 | echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
|
---|
| 233 | else \
|
---|
| 234 | echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
|
---|
| 235 | fi; \
|
---|
| 236 | done
|
---|
[7818e780] | 237 |
|
---|
[6d3005f] | 238 | bootscripts:
|
---|
| 239 | @VERSION=`grep "bootscripts-version " general.ent | cut -d\" -f2`; \
|
---|
[efe19ba] | 240 | BOOTSCRIPTS="blfs-bootscripts-$$VERSION"; \
|
---|
| 241 | if [ ! -e $$BOOTSCRIPTS.tar.xz ]; then \
|
---|
| 242 | rm -rf $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
| 243 | mkdir $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
| 244 | cp -a ../bootscripts/* $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
| 245 | rm -rf ../bootscripts/archive; \
|
---|
| 246 | tar -cJhf $$BOOTSCRIPTS.tar.xz -C $(RENDERTMP) $$BOOTSCRIPTS; \
|
---|
[6d3005f] | 247 | fi
|
---|
| 248 |
|
---|
[f852e706] | 249 | systemd-units:
|
---|
| 250 | @VERSION=`grep "systemd-units-version " general.ent | cut -d\" -f2`; \
|
---|
[a2f7a1c] | 251 | UNITS="blfs-systemd-units-$$VERSION"; \
|
---|
| 252 | if [ ! -e $$UNITS.tar.xz ]; then \
|
---|
| 253 | rm -rf $(RENDERTMP)/$$UNITS; \
|
---|
| 254 | mkdir $(RENDERTMP)/$$UNITS; \
|
---|
| 255 | cp -a ../systemd-units/* $(RENDERTMP)/$$UNITS; \
|
---|
| 256 | tar -cJhf $$UNITS.tar.xz -C $(RENDERTMP) $$UNITS; \
|
---|
[f852e706] | 257 | fi
|
---|
| 258 |
|
---|
[99eb823a] | 259 | test-options:
|
---|
| 260 | $(Q)xsltproc --xinclude --nonet stylesheets/test-options.xsl index.xml
|
---|
| 261 |
|
---|
[575bba80] | 262 | dump-commands: $(DUMPDIR)
|
---|
[e3047fd] | 263 | $(DUMPDIR): $(RENDERTMP)/$(BLFSFULL) version
|
---|
[35d9770] | 264 | @echo "Dumping book commands..."
|
---|
[efe19ba] | 265 | $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
| 266 | stylesheets/dump-commands.xsl \
|
---|
[f852e706] | 267 | $(RENDERTMP)/$(BLFSFULL)
|
---|
[575bba80] | 268 | $(Q)touch $(DUMPDIR)
|
---|
[35d9770] | 269 |
|
---|
[e3047fd] | 270 | .PHONY: blfs all world html nochunks tmpdir clean \
|
---|
| 271 | validate profile-html blfs-patch-list wget-list test-links \
|
---|
[99eb823a] | 272 | dump-commands bootscripts systemd-units version test-options
|
---|
[05d5b11] | 273 |
|
---|
[e3047fd] | 274 | version:
|
---|
| 275 | $(Q)./git-version.sh $(REV)
|
---|