1 | # Makefile for BLFS Book generation.
|
---|
2 | # By Tushar Teredesai <tushar@linuxfromscratch.org>
|
---|
3 | # 2004-01-31
|
---|
4 | # $LastChangedBy$
|
---|
5 | # $Date$
|
---|
6 |
|
---|
7 | # Adjust these to suit your installation
|
---|
8 | BASEDIR ?= $(HOME)/public_html/blfs-book-xsl
|
---|
9 | DUMPDIR ?= $(HOME)/blfs-commands
|
---|
10 | RENDERTMP ?= tmp
|
---|
11 | CHUNK_QUIET = 1
|
---|
12 | ROOT_ID =
|
---|
13 | PDF_OUTPUT = BLFS-BOOK.pdf
|
---|
14 | NOCHUNKS_OUTPUT = BLFS-BOOK.html
|
---|
15 |
|
---|
16 | ifdef V
|
---|
17 | Q =
|
---|
18 | else
|
---|
19 | Q = @
|
---|
20 | endif
|
---|
21 |
|
---|
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
|
---|
28 | @echo "Generating chunked XHTML files..."
|
---|
29 | $(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
|
---|
30 | -stringparam rootid "$(ROOT_ID)" -stringparam base.dir $(BASEDIR)/ \
|
---|
31 | stylesheets/blfs-chunked.xsl $(RENDERTMP)/blfs-html.xml
|
---|
32 |
|
---|
33 | @echo "Copying CSS code and images..."
|
---|
34 | $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
---|
35 | mkdir -p $(BASEDIR)/stylesheets; \
|
---|
36 | fi;
|
---|
37 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
---|
38 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
---|
39 | mkdir -p $(BASEDIR)/images; \
|
---|
40 | fi;
|
---|
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
|
---|
44 |
|
---|
45 | @echo "Running Tidy and obfuscate.sh on chunked XHTML..."
|
---|
46 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
---|
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;
|
---|
52 |
|
---|
53 | pdf: $(BASEDIR)/$(PDF_OUTPUT)
|
---|
54 | $(RENDERTMP)/blfs-pdf.xml: $(RENDERTMP)/blfs-full.xml
|
---|
55 | @echo "Generating profiled XML for PDF..."
|
---|
56 | $(Q)xsltproc --nonet --stringparam profile.condition pdf \
|
---|
57 | --output $(RENDERTMP)/blfs-pdf.xml stylesheets/lfs-xsl/profile.xsl \
|
---|
58 | $(RENDERTMP)/blfs-full.xml
|
---|
59 |
|
---|
60 | $(RENDERTMP)/blfs-pdf.fo: $(RENDERTMP)/blfs-full.xml
|
---|
61 | @echo "Generating FO file..."
|
---|
62 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
63 | --output $(RENDERTMP)/blfs-pdf.fo stylesheets/blfs-pdf.xsl \
|
---|
64 | $(RENDERTMP)/blfs-pdf.xml
|
---|
65 | $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/blfs-pdf.fo
|
---|
66 |
|
---|
67 | $(BASEDIR)/$(PDF_OUTPUT): $(RENDERTMP)/blfs-pdf.fo
|
---|
68 | @echo "Generating PDF file..."
|
---|
69 | $(Q)if [ ! -e $(BASEDIR) ]; then \
|
---|
70 | mkdir -p $(BASEDIR); \
|
---|
71 | fi;
|
---|
72 | $(Q)fop $(RENDERTMP)/blfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT)
|
---|
73 |
|
---|
74 | nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
75 | $(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/blfs-html.xml
|
---|
76 | @echo "Generating non-chunked XHTML file..."
|
---|
77 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
78 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
---|
79 | stylesheets/blfs-nochunks.xsl $(RENDERTMP)/blfs-html.xml
|
---|
80 |
|
---|
81 | @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
|
---|
82 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
---|
83 | $(Q)sh obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
84 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \
|
---|
85 | $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
86 |
|
---|
87 | tmpdir: $(RENDERTMP)
|
---|
88 | $(RENDERTMP):
|
---|
89 | @echo "Creating $(RENDERTMP)"
|
---|
90 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
91 |
|
---|
92 | clean:
|
---|
93 | @echo "Cleaning $(RENDERTMP)"
|
---|
94 | $(Q)rm -f $(RENDERTMP)/blfs-{full,html,pdf}.xml
|
---|
95 | $(Q)rm -f $(RENDERTMP)/blfs-pdf.fo
|
---|
96 | $(Q)rm -f $(RENDERTMP)/blfs-{patch-list,patches}
|
---|
97 | $(Q)rmdir $(RENDERTMP) 2>/dev/null || :
|
---|
98 |
|
---|
99 | validxml: $(RENDERTMP)/blfs-full.xml
|
---|
100 | $(RENDERTMP)/blfs-full.xml: index.xml general.ent
|
---|
101 | @echo "Validating the book..."
|
---|
102 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
103 | $(Q)xmllint --nonet --noent --xinclude --postvalid \
|
---|
104 | -o $(RENDERTMP)/blfs-full.xml index.xml
|
---|
105 |
|
---|
106 | profile-html: $(RENDERTMP)/blfs-html.xml
|
---|
107 | $(RENDERTMP)/blfs-html.xml: $(RENDERTMP)/blfs-full.xml
|
---|
108 | @echo "Generating profiled XML for XHTML..."
|
---|
109 | $(Q)xsltproc --nonet --stringparam profile.condition html \
|
---|
110 | --output $(RENDERTMP)/blfs-html.xml stylesheets/lfs-xsl/profile.xsl \
|
---|
111 | $(RENDERTMP)/blfs-full.xml
|
---|
112 |
|
---|
113 | blfs-patch-list: blfs-patches.sh
|
---|
114 | @echo "Generating blfs patch list..."
|
---|
115 | $(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
|
---|
116 | blfs-patches.sh > blfs-patch-list
|
---|
117 |
|
---|
118 | blfs-patches.sh: $(RENDERTMP)/blfs-full.xml
|
---|
119 | @echo "Generating blfs patch script..."
|
---|
120 | $(Q)xsltproc --nonet --output blfs-patches.sh \
|
---|
121 | stylesheets/patcheslist.xsl $(RENDERTMP)/blfs-full.xml
|
---|
122 |
|
---|
123 | wget-list: $(BASEDIR)/wget-list
|
---|
124 | $(BASEDIR)/wget-list: $(RENDERTMP)/blfs-full.xml
|
---|
125 | @echo "Generating wget list..."
|
---|
126 | $(Q)mkdir -p $(BASEDIR)
|
---|
127 | $(Q)xsltproc --nonet --output $(BASEDIR)/wget-list \
|
---|
128 | stylesheets/wget-list.xsl $(RENDERTMP)/blfs-full.xml
|
---|
129 |
|
---|
130 | test-links: $(RENDERTMP)/blfs-full.xml
|
---|
131 | $(BASEDIR)/test-links: $(RENDERTMP)/blfs-full.xml
|
---|
132 | @echo "Generating test-links file..."
|
---|
133 | $(Q)mkdir -p $(BASEDIR)
|
---|
134 | $(Q)xsltproc --nonet --stringparam list_mode full \
|
---|
135 | --output $(BASEDIR)/test-links stylesheets/wget-list.xsl \
|
---|
136 | $(RENDERTMP)/blfs-full.xml
|
---|
137 |
|
---|
138 | @echo "Checking URLs, first pass..."
|
---|
139 | $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
|
---|
140 | $(Q)for URL in `cat $(BASEDIR)/test-links`; do \
|
---|
141 | wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
|
---|
142 | if test $$? -ne 0 ; then echo $$URL >> $(BASEDIR)/bad_urls ; \
|
---|
143 | else echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
|
---|
144 | fi; \
|
---|
145 | done
|
---|
146 |
|
---|
147 | @echo "Checking URLs, second pass..."
|
---|
148 | $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
|
---|
149 | wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
|
---|
150 | if test $$? -ne 0 ; then echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
|
---|
151 | else echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
|
---|
152 | fi; \
|
---|
153 | done
|
---|
154 |
|
---|
155 | dump-commands: $(DUMPDIR)
|
---|
156 | $(DUMPDIR): $(RENDERTMP)/blfs-full.xml
|
---|
157 | @echo "Dumping book commands..."
|
---|
158 | $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
159 | stylesheets/dump-commands.xsl $(RENDERTMP)/blfs-full.xml
|
---|
160 | $(Q)touch $(DUMPDIR)
|
---|
161 |
|
---|
162 | validate:
|
---|
163 | @echo "Validating the book..."
|
---|
164 | $(Q)xmllint --noout --nonet --xinclude --postvalid index.xml
|
---|
165 |
|
---|
166 | .PHONY: blfs all world html pdf nochunks tmpdir clean validxml \
|
---|
167 | profile-html wget-list test-links dump-commands validate
|
---|