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