[19599c63] | 1 | # Makefile for BLFS Book generation.
|
---|
| 2 | # By Tushar Teredesai <tushar@linuxfromscratch.org>
|
---|
| 3 | # 2004-01-31
|
---|
[35d9770] | 4 |
|
---|
[19599c63] | 5 | # Adjust these to suit your installation
|
---|
[efe19ba] | 6 | RENDERTMP ?= $(HOME)/tmp
|
---|
| 7 | CHUNK_QUIET = 1
|
---|
| 8 | ROOT_ID =
|
---|
| 9 | SHELL = /bin/bash
|
---|
[35d9770] | 10 |
|
---|
[6328b89] | 11 | ALLXML := $(filter-out $(RENDERTMP)/%, \
|
---|
| 12 | $(wildcard *.xml */*.xml */*/*.xml */*/*/*.xml */*/*/*/*.xml))
|
---|
| 13 | ALLXSL := $(filter-out $(RENDERTMP)/%, \
|
---|
| 14 | $(wildcard *.xsl */*.xsl */*/*.xsl */*/*/*.xsl */*/*/*/*.xsl))
|
---|
| 15 |
|
---|
[35d9770] | 16 | ifdef V
|
---|
| 17 | Q =
|
---|
| 18 | else
|
---|
| 19 | Q = @
|
---|
| 20 | endif
|
---|
| 21 |
|
---|
[efe19ba] | 22 | ifndef REV
|
---|
| 23 | REV = sysv
|
---|
| 24 | endif
|
---|
| 25 |
|
---|
| 26 | ifneq ($(REV), sysv)
|
---|
| 27 | ifneq ($(REV), systemd)
|
---|
| 28 | $(error REV must be 'sysv' (default) or 'systemd'.)
|
---|
| 29 | endif
|
---|
| 30 | endif
|
---|
| 31 |
|
---|
| 32 | ifeq ($(REV), sysv)
|
---|
| 33 | BASEDIR ?= $(HOME)/public_html/blfs-book
|
---|
| 34 | NOCHUNKS_OUTPUT ?= blfs-book.html
|
---|
| 35 | DUMPDIR ?= ~/blfs-commands
|
---|
[f852e706] | 36 | BLFSHTML ?= blfs-html.xml
|
---|
| 37 | BLFSHTML2 ?= blfs-html2.xml
|
---|
| 38 | BLFSFULL ?= blfs-full.xml
|
---|
[efe19ba] | 39 | else
|
---|
| 40 | BASEDIR ?= $(HOME)/public_html/blfs-systemd
|
---|
| 41 | NOCHUNKS_OUTPUT ?= blfs-sysd-book.html
|
---|
| 42 | DUMPDIR ?= ~/blfs-sysd-commands
|
---|
[f852e706] | 43 | BLFSHTML ?= blfs-systemd-html.xml
|
---|
| 44 | BLFSHTML2 ?= blfs-systemd-html2.xml
|
---|
| 45 | BLFSFULL ?= blfs-systemd-full.xml
|
---|
| 46 |
|
---|
[efe19ba] | 47 | endif
|
---|
| 48 |
|
---|
| 49 |
|
---|
[575bba80] | 50 | blfs: html wget-list
|
---|
[efe19ba] | 51 |
|
---|
[f5ee8c2] | 52 | all: blfs nochunks
|
---|
[575bba80] | 53 | world: all blfs-patch-list dump-commands test-links
|
---|
| 54 |
|
---|
| 55 | html: $(BASEDIR)/index.html
|
---|
[17c9da8] | 56 | $(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML) version
|
---|
[35d9770] | 57 | @echo "Generating chunked XHTML files..."
|
---|
[efe19ba] | 58 | $(Q)xsltproc --nonet \
|
---|
| 59 | --stringparam chunk.quietly $(CHUNK_QUIET) \
|
---|
| 60 | --stringparam rootid "$(ROOT_ID)" \
|
---|
| 61 | --stringparam base.dir $(BASEDIR)/ \
|
---|
| 62 | stylesheets/blfs-chunked.xsl \
|
---|
[f852e706] | 63 | $(RENDERTMP)/$(BLFSHTML)
|
---|
[35d9770] | 64 |
|
---|
| 65 | @echo "Copying CSS code and images..."
|
---|
| 66 | $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
---|
[efe19ba] | 67 | mkdir -p $(BASEDIR)/stylesheets; \
|
---|
| 68 | fi;
|
---|
| 69 |
|
---|
[35d9770] | 70 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
---|
[efe19ba] | 71 |
|
---|
[35d9770] | 72 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
---|
[efe19ba] | 73 | mkdir -p $(BASEDIR)/images; \
|
---|
| 74 | fi;
|
---|
[35d9770] | 75 | $(Q)cp images/*.png $(BASEDIR)/images
|
---|
[efe19ba] | 76 |
|
---|
[869909a] | 77 | $(Q)cd $(BASEDIR)/; sed -e "s@../images@images@g" \
|
---|
[efe19ba] | 78 | -i *.html
|
---|
[4a02298] | 79 |
|
---|
[5d463a51] | 80 | @echo "Running Tidy and obfuscate.sh on chunked XHTML..."
|
---|
[efe19ba] | 81 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
---|
| 82 | tidy -config tidy.conf $$filename; \
|
---|
| 83 | true; \
|
---|
| 84 | bash obfuscate.sh $$filename; \
|
---|
| 85 | sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
---|
| 86 | done;
|
---|
[6d3005f] | 87 |
|
---|
[575bba80] | 88 | nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
[17c9da8] | 89 | $(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML) version
|
---|
[5d463a51] | 90 | @echo "Generating non-chunked XHTML file..."
|
---|
[efe19ba] | 91 | $(Q)xsltproc --nonet \
|
---|
| 92 | --stringparam rootid "$(ROOT_ID)" \
|
---|
| 93 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
---|
| 94 | stylesheets/blfs-nochunks.xsl \
|
---|
[f852e706] | 95 | $(RENDERTMP)/$(BLFSHTML)
|
---|
[35d9770] | 96 |
|
---|
[5d463a51] | 97 | @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
|
---|
[35d9770] | 98 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
---|
[7ba7636] | 99 | $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
[efe19ba] | 100 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
[35d9770] | 101 |
|
---|
[575bba80] | 102 | tmpdir: $(RENDERTMP)
|
---|
| 103 | $(RENDERTMP):
|
---|
| 104 | @echo "Creating $(RENDERTMP)"
|
---|
[adf0149] | 105 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
[575bba80] | 106 |
|
---|
| 107 | clean:
|
---|
| 108 | @echo "Cleaning $(RENDERTMP)"
|
---|
[f852e706] | 109 | $(Q)rm -f $(RENDERTMP)/blfs*
|
---|
[8e2f3658] | 110 |
|
---|
[f852e706] | 111 | validate: $(RENDERTMP)/$(BLFSFULL)
|
---|
[17c9da8] | 112 | $(RENDERTMP)/$(BLFSFULL): general.ent packages.ent $(ALLXML) $(ALLXSL) version
|
---|
[575bba80] | 113 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
[efe19ba] | 114 |
|
---|
| 115 | @echo "Adjusting for revision $(REV)..."
|
---|
| 116 | $(Q)xsltproc --nonet \
|
---|
| 117 | --xinclude \
|
---|
[f852e706] | 118 | --output $(RENDERTMP)/$(BLFSHTML2) \
|
---|
[efe19ba] | 119 | --stringparam profile.revision $(REV) \
|
---|
| 120 | stylesheets/lfs-xsl/profile.xsl \
|
---|
| 121 | index.xml
|
---|
| 122 |
|
---|
| 123 | @echo "Validating the book..."
|
---|
| 124 | $(Q)xmllint --nonet \
|
---|
| 125 | --noent \
|
---|
| 126 | --postvalid \
|
---|
[f852e706] | 127 | --output $(RENDERTMP)/$(BLFSFULL) \
|
---|
| 128 | $(RENDERTMP)/$(BLFSHTML2)
|
---|
[35d9770] | 129 |
|
---|
[f852e706] | 130 | profile-html: $(RENDERTMP)/$(BLFSHTML)
|
---|
[17c9da8] | 131 | $(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL) version
|
---|
[35d9770] | 132 | @echo "Generating profiled XML for XHTML..."
|
---|
[efe19ba] | 133 | $(Q)xsltproc --nonet \
|
---|
| 134 | --stringparam profile.condition html \
|
---|
[f852e706] | 135 | --output $(RENDERTMP)/$(BLFSHTML) \
|
---|
[efe19ba] | 136 | stylesheets/lfs-xsl/profile.xsl \
|
---|
[f852e706] | 137 | $(RENDERTMP)/$(BLFSFULL)
|
---|
[35d9770] | 138 |
|
---|
[0238e7e] | 139 | blfs-patch-list: blfs-patches.sh
|
---|
| 140 | @echo "Generating blfs patch list..."
|
---|
| 141 | $(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
|
---|
| 142 | blfs-patches.sh > blfs-patch-list
|
---|
| 143 |
|
---|
[17c9da8] | 144 | blfs-patches.sh: $(RENDERTMP)/$(BLFSFULL) version
|
---|
[0238e7e] | 145 | @echo "Generating blfs patch script..."
|
---|
[efe19ba] | 146 | $(Q)xsltproc --nonet \
|
---|
| 147 | --output blfs-patches.sh \
|
---|
| 148 | stylesheets/patcheslist.xsl \
|
---|
[f852e706] | 149 | $(RENDERTMP)/$(BLFSFULL)
|
---|
[35d9770] | 150 |
|
---|
[575bba80] | 151 | wget-list: $(BASEDIR)/wget-list
|
---|
[17c9da8] | 152 | $(BASEDIR)/wget-list: $(RENDERTMP)/$(BLFSFULL) version
|
---|
[efe19ba] | 153 | @echo "Generating wget list for $(REV) at $(BASEDIR)/wget-list ..."
|
---|
[35d9770] | 154 | $(Q)mkdir -p $(BASEDIR)
|
---|
[efe19ba] | 155 | $(Q)xsltproc --nonet \
|
---|
| 156 | --output $(BASEDIR)/wget-list \
|
---|
| 157 | stylesheets/wget-list.xsl \
|
---|
[f852e706] | 158 | $(RENDERTMP)/$(BLFSFULL)
|
---|
[35d9770] | 159 |
|
---|
[cb55412] | 160 | test-links: $(BASEDIR)/test-links
|
---|
[17c9da8] | 161 | $(BASEDIR)/test-links: $(RENDERTMP)/$(BLFSFULL) version
|
---|
[35d9770] | 162 | @echo "Generating test-links file..."
|
---|
| 163 | $(Q)mkdir -p $(BASEDIR)
|
---|
[efe19ba] | 164 | $(Q)xsltproc --nonet \
|
---|
| 165 | --stringparam list_mode full \
|
---|
| 166 | --output $(BASEDIR)/test-links \
|
---|
| 167 | stylesheets/wget-list.xsl \
|
---|
[f852e706] | 168 | $(RENDERTMP)/$(BLFSFULL)
|
---|
[35d9770] | 169 |
|
---|
[cdd254a] | 170 | @echo "Checking URLs, first pass..."
|
---|
[35d9770] | 171 | $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
|
---|
[efe19ba] | 172 | $(Q)for URL in `cat $(BASEDIR)/test-links`; do \
|
---|
| 173 | wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
|
---|
| 174 | if test $$? -ne 0 ; then \
|
---|
| 175 | echo $$URL >> $(BASEDIR)/bad_urls ; \
|
---|
| 176 | else \
|
---|
| 177 | echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
|
---|
| 178 | fi; \
|
---|
| 179 | done
|
---|
[35d9770] | 180 |
|
---|
[cdd254a] | 181 | @echo "Checking URLs, second pass..."
|
---|
[efe19ba] | 182 | $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
|
---|
| 183 | wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
|
---|
| 184 | if test $$? -ne 0 ; then \
|
---|
| 185 | echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
|
---|
| 186 | else \
|
---|
| 187 | echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
|
---|
| 188 | fi; \
|
---|
| 189 | done
|
---|
[7818e780] | 190 |
|
---|
[6d3005f] | 191 | bootscripts:
|
---|
| 192 | @VERSION=`grep "bootscripts-version " general.ent | cut -d\" -f2`; \
|
---|
[efe19ba] | 193 | BOOTSCRIPTS="blfs-bootscripts-$$VERSION"; \
|
---|
| 194 | if [ ! -e $$BOOTSCRIPTS.tar.xz ]; then \
|
---|
| 195 | rm -rf $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
| 196 | mkdir $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
| 197 | cp -a ../bootscripts/* $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
| 198 | rm -rf ../bootscripts/archive; \
|
---|
| 199 | tar -cJhf $$BOOTSCRIPTS.tar.xz -C $(RENDERTMP) $$BOOTSCRIPTS; \
|
---|
[6d3005f] | 200 | fi
|
---|
| 201 |
|
---|
[f852e706] | 202 | systemd-units:
|
---|
| 203 | @VERSION=`grep "systemd-units-version " general.ent | cut -d\" -f2`; \
|
---|
| 204 | UNITS="blfs-systemd-units-$$VERSION"; \
|
---|
| 205 | if [ ! -e $$UNITS.tar.xz ]; then \
|
---|
| 206 | rm -rf $(RENDERTMP)/$$UNITS; \
|
---|
| 207 | mkdir $(RENDERTMP)/$$UNITS; \
|
---|
| 208 | cp -a ../systemd-units/* $(RENDERTMP)/$$UNITS; \
|
---|
| 209 | tar -cJhf $$UNITS.tar.xz -C $(RENDERTMP) $$UNITS; \
|
---|
| 210 | fi
|
---|
| 211 |
|
---|
[575bba80] | 212 | dump-commands: $(DUMPDIR)
|
---|
[17c9da8] | 213 | $(DUMPDIR): $(RENDERTMP)/$(BLFSFULL) version
|
---|
[35d9770] | 214 | @echo "Dumping book commands..."
|
---|
[efe19ba] | 215 | $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
| 216 | stylesheets/dump-commands.xsl \
|
---|
[f852e706] | 217 | $(RENDERTMP)/$(BLFSFULL)
|
---|
[575bba80] | 218 | $(Q)touch $(DUMPDIR)
|
---|
[35d9770] | 219 |
|
---|
[efe19ba] | 220 | .PHONY: blfs all world html nochunks tmpdir clean \
|
---|
| 221 | validate profile-html blfs-patch-list wget-list test-links \
|
---|
[17c9da8] | 222 | dump-commands bootscripts systemd-units version
|
---|
[6d3005f] | 223 |
|
---|
[17c9da8] | 224 | version:
|
---|
| 225 | $(Q)./git-version.sh
|
---|