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