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