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