[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
|
---|
[1d36178d] | 6 | BASEDIR ?= $(HOME)/public_html/blfs-book-xsl
|
---|
| 7 | DUMPDIR ?= $(HOME)/blfs-commands
|
---|
[c41b38f] | 8 | RENDERTMP ?= /tmp
|
---|
[f3e7a94] | 9 | CHUNK_QUIET = 1
|
---|
| 10 | ROOT_ID =
|
---|
| 11 | NOCHUNKS_OUTPUT = BLFS-BOOK.html
|
---|
[c41b38f] | 12 | SHELL = /bin/sh
|
---|
[35d9770] | 13 |
|
---|
[6328b89] | 14 | ALLXML := $(filter-out $(RENDERTMP)/%, \
|
---|
| 15 | $(wildcard *.xml */*.xml */*/*.xml */*/*/*.xml */*/*/*/*.xml))
|
---|
| 16 | ALLXSL := $(filter-out $(RENDERTMP)/%, \
|
---|
| 17 | $(wildcard *.xsl */*.xsl */*/*.xsl */*/*/*.xsl */*/*/*/*.xsl))
|
---|
| 18 |
|
---|
[35d9770] | 19 | ifdef V
|
---|
| 20 | Q =
|
---|
| 21 | else
|
---|
| 22 | Q = @
|
---|
| 23 | endif
|
---|
| 24 |
|
---|
[575bba80] | 25 | blfs: html wget-list
|
---|
[f5ee8c2] | 26 | all: blfs nochunks
|
---|
[575bba80] | 27 | world: all blfs-patch-list dump-commands test-links
|
---|
| 28 |
|
---|
| 29 | html: $(BASEDIR)/index.html
|
---|
| 30 | $(BASEDIR)/index.html: $(RENDERTMP)/blfs-html.xml
|
---|
[35d9770] | 31 | @echo "Generating chunked XHTML files..."
|
---|
| 32 | $(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
|
---|
[f3e7a94] | 33 | -stringparam rootid "$(ROOT_ID)" -stringparam base.dir $(BASEDIR)/ \
|
---|
[adf0149] | 34 | stylesheets/blfs-chunked.xsl $(RENDERTMP)/blfs-html.xml
|
---|
[35d9770] | 35 |
|
---|
| 36 | @echo "Copying CSS code and images..."
|
---|
| 37 | $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
---|
[527966e] | 38 | mkdir -p $(BASEDIR)/stylesheets; \
|
---|
[eff3826] | 39 | fi;
|
---|
[35d9770] | 40 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
---|
| 41 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
---|
[527966e] | 42 | mkdir -p $(BASEDIR)/images; \
|
---|
[eff3826] | 43 | fi;
|
---|
[35d9770] | 44 | $(Q)cp images/*.png $(BASEDIR)/images
|
---|
| 45 | $(Q)cd $(BASEDIR)/; sed -i -e "s@../stylesheets@stylesheets@g" *.html
|
---|
| 46 | $(Q)cd $(BASEDIR)/; sed -i -e "s@../images@images@g" *.html
|
---|
[4a02298] | 47 |
|
---|
[5d463a51] | 48 | @echo "Running Tidy and obfuscate.sh on chunked XHTML..."
|
---|
[35d9770] | 49 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
---|
[4a02298] | 50 | tidy -config tidy.conf $$filename; \
|
---|
| 51 | true; \
|
---|
[c41b38f] | 52 | sh obfuscate.sh $$filename; \
|
---|
[4a02298] | 53 | sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
---|
| 54 | done;
|
---|
[eff3826] | 55 |
|
---|
[575bba80] | 56 | nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
| 57 | $(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/blfs-html.xml
|
---|
[5d463a51] | 58 | @echo "Generating non-chunked XHTML file..."
|
---|
[adf9e23] | 59 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
[32797f8] | 60 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
---|
[adf0149] | 61 | stylesheets/blfs-nochunks.xsl $(RENDERTMP)/blfs-html.xml
|
---|
[35d9770] | 62 |
|
---|
[5d463a51] | 63 | @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
|
---|
[35d9770] | 64 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
---|
[7ba7636] | 65 | $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
[5d463a51] | 66 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \
|
---|
[35d9770] | 67 | $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
| 68 |
|
---|
[575bba80] | 69 | tmpdir: $(RENDERTMP)
|
---|
| 70 | $(RENDERTMP):
|
---|
| 71 | @echo "Creating $(RENDERTMP)"
|
---|
[adf0149] | 72 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
[575bba80] | 73 |
|
---|
| 74 | clean:
|
---|
| 75 | @echo "Cleaning $(RENDERTMP)"
|
---|
[f5ee8c2] | 76 | $(Q)rm -f $(RENDERTMP)/blfs-{full,html}.xml
|
---|
[adf0149] | 77 | $(Q)rm -f $(RENDERTMP)/blfs-{patch-list,patches}
|
---|
[73fb1e74] | 78 | $(Q)rmdir $(RENDERTMP) 2>/dev/null || :
|
---|
[8e2f3658] | 79 |
|
---|
[575bba80] | 80 | validxml: $(RENDERTMP)/blfs-full.xml
|
---|
[6328b89] | 81 | $(RENDERTMP)/blfs-full.xml: general.ent $(ALLXML) $(ALLXSL)
|
---|
[35d9770] | 82 | @echo "Validating the book..."
|
---|
[575bba80] | 83 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
[35d9770] | 84 | $(Q)xmllint --nonet --noent --xinclude --postvalid \
|
---|
[2182f2c] | 85 | -o $(RENDERTMP)/blfs-full.xml index.xml
|
---|
[35d9770] | 86 |
|
---|
[575bba80] | 87 | profile-html: $(RENDERTMP)/blfs-html.xml
|
---|
| 88 | $(RENDERTMP)/blfs-html.xml: $(RENDERTMP)/blfs-full.xml
|
---|
[35d9770] | 89 | @echo "Generating profiled XML for XHTML..."
|
---|
| 90 | $(Q)xsltproc --nonet --stringparam profile.condition html \
|
---|
[adf0149] | 91 | --output $(RENDERTMP)/blfs-html.xml stylesheets/lfs-xsl/profile.xsl \
|
---|
| 92 | $(RENDERTMP)/blfs-full.xml
|
---|
[35d9770] | 93 |
|
---|
[0238e7e] | 94 | blfs-patch-list: blfs-patches.sh
|
---|
| 95 | @echo "Generating blfs patch list..."
|
---|
| 96 | $(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
|
---|
| 97 | blfs-patches.sh > blfs-patch-list
|
---|
| 98 |
|
---|
| 99 | blfs-patches.sh: $(RENDERTMP)/blfs-full.xml
|
---|
| 100 | @echo "Generating blfs patch script..."
|
---|
| 101 | $(Q)xsltproc --nonet --output blfs-patches.sh \
|
---|
[adf0149] | 102 | stylesheets/patcheslist.xsl $(RENDERTMP)/blfs-full.xml
|
---|
[35d9770] | 103 |
|
---|
[575bba80] | 104 | wget-list: $(BASEDIR)/wget-list
|
---|
| 105 | $(BASEDIR)/wget-list: $(RENDERTMP)/blfs-full.xml
|
---|
[35d9770] | 106 | @echo "Generating wget list..."
|
---|
| 107 | $(Q)mkdir -p $(BASEDIR)
|
---|
| 108 | $(Q)xsltproc --nonet --output $(BASEDIR)/wget-list \
|
---|
[adf0149] | 109 | stylesheets/wget-list.xsl $(RENDERTMP)/blfs-full.xml
|
---|
[35d9770] | 110 |
|
---|
[cb55412] | 111 | test-links: $(BASEDIR)/test-links
|
---|
[575bba80] | 112 | $(BASEDIR)/test-links: $(RENDERTMP)/blfs-full.xml
|
---|
[35d9770] | 113 | @echo "Generating test-links file..."
|
---|
| 114 | $(Q)mkdir -p $(BASEDIR)
|
---|
| 115 | $(Q)xsltproc --nonet --stringparam list_mode full \
|
---|
| 116 | --output $(BASEDIR)/test-links stylesheets/wget-list.xsl \
|
---|
[adf0149] | 117 | $(RENDERTMP)/blfs-full.xml
|
---|
[35d9770] | 118 |
|
---|
[cdd254a] | 119 | @echo "Checking URLs, first pass..."
|
---|
[35d9770] | 120 | $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
|
---|
| 121 | $(Q)for URL in `cat $(BASEDIR)/test-links`; do \
|
---|
[7818e780] | 122 | wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
|
---|
| 123 | if test $$? -ne 0 ; then echo $$URL >> $(BASEDIR)/bad_urls ; \
|
---|
| 124 | else echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
|
---|
| 125 | fi; \
|
---|
| 126 | done
|
---|
[35d9770] | 127 |
|
---|
[cdd254a] | 128 | @echo "Checking URLs, second pass..."
|
---|
[35d9770] | 129 | $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
|
---|
[7818e780] | 130 | wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
|
---|
| 131 | if test $$? -ne 0 ; then echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
|
---|
| 132 | else echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
|
---|
| 133 | fi; \
|
---|
| 134 | done
|
---|
| 135 |
|
---|
[575bba80] | 136 | dump-commands: $(DUMPDIR)
|
---|
| 137 | $(DUMPDIR): $(RENDERTMP)/blfs-full.xml
|
---|
[35d9770] | 138 | @echo "Dumping book commands..."
|
---|
| 139 | $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
[adf0149] | 140 | stylesheets/dump-commands.xsl $(RENDERTMP)/blfs-full.xml
|
---|
[575bba80] | 141 | $(Q)touch $(DUMPDIR)
|
---|
[35d9770] | 142 |
|
---|
| 143 | validate:
|
---|
| 144 | @echo "Validating the book..."
|
---|
| 145 | $(Q)xmllint --noout --nonet --xinclude --postvalid index.xml
|
---|
| 146 |
|
---|
[f5ee8c2] | 147 | .PHONY: blfs all world html nochunks tmpdir clean validxml \
|
---|
[575bba80] | 148 | profile-html wget-list test-links dump-commands validate
|
---|