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