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