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