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