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