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