Rev 5432 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
660 | texou | 1 | # Makefile for BLFS Book generation. |
2 | # By Tushar Teredesai <tushar@linuxfromscratch.org> |
||
3 | # 2004-01-31 |
||
2473 | myou72 | 4 | # $LastChangedBy: randy $ |
5 | # $Date: 2012-08-22 18:33:50 +0200 (mer. 22 août 2012) $ |
||
493 | gleu | 6 | |
660 | texou | 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 = |
||
4369 | myou72 | 13 | PDF_OUTPUT = BLFS-BOOK.pdf |
660 | texou | 14 | NOCHUNKS_OUTPUT = BLFS-BOOK.html |
1540 | jmengual | 15 | SHELL = /bin/bash |
493 | gleu | 16 | |
660 | texou | 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 | |||
22 | ifdef V |
||
23 | Q = |
||
24 | else |
||
25 | Q = @ |
||
26 | endif |
||
27 | |||
28 | blfs: html wget-list |
||
4369 | myou72 | 29 | all: blfs nochunks pdf |
30 | #all: blfs nochunks |
||
660 | texou | 31 | world: all blfs-patch-list dump-commands test-links |
32 | |||
33 | html: $(BASEDIR)/index.html |
||
34 | $(BASEDIR)/index.html: $(RENDERTMP)/blfs-html.xml |
||
35 | @echo "Generating chunked XHTML files..." |
||
36 | $(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \ |
||
37 | -stringparam rootid "$(ROOT_ID)" -stringparam base.dir $(BASEDIR)/ \ |
||
38 | stylesheets/blfs-chunked.xsl $(RENDERTMP)/blfs-html.xml |
||
39 | |||
40 | @echo "Copying CSS code and images..." |
||
41 | $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \ |
||
42 | mkdir -p $(BASEDIR)/stylesheets; \ |
||
493 | gleu | 43 | fi; |
660 | texou | 44 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets |
45 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \ |
||
46 | mkdir -p $(BASEDIR)/images; \ |
||
493 | gleu | 47 | fi; |
660 | texou | 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 |
||
493 | gleu | 51 | |
660 | texou | 52 | @echo "Running Tidy and obfuscate.sh on chunked XHTML..." |
53 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \ |
||
54 | tidy -config tidy.conf $$filename; \ |
||
55 | true; \ |
||
56 | bash obfuscate.sh $$filename; \ |
||
57 | sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \ |
||
58 | done; |
||
540 | gleu | 59 | |
4146 | myou72 | 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 \ |
||
64 | --output $(RENDERTMP)/blfs-pdf.xml stylesheets/lfs-xsl/profile.xsl \ |
||
65 | $(RENDERTMP)/blfs-full.xml |
||
493 | gleu | 66 | |
4146 | myou72 | 67 | $(RENDERTMP)/blfs-pdf.fo: $(RENDERTMP)/blfs-pdf.xml |
68 | @echo "Generating FO file..." |
||
69 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \ |
||
660 | texou | 70 | --output $(RENDERTMP)/blfs-pdf.fo stylesheets/blfs-pdf.xsl \ |
71 | $(RENDERTMP)/blfs-pdf.xml |
||
4146 | myou72 | 72 | $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/blfs-pdf.fo |
493 | gleu | 73 | |
4146 | myou72 | 74 | $(BASEDIR)/$(PDF_OUTPUT): $(RENDERTMP)/blfs-pdf.fo |
75 | @echo "Generating PDF file..." |
||
76 | $(Q)if [ ! -e $(BASEDIR) ]; then \ |
||
660 | texou | 77 | mkdir -p $(BASEDIR); \ |
78 | fi; |
||
4146 | myou72 | 79 | $(Q)fop $(RENDERTMP)/blfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT) |
493 | gleu | 80 | |
660 | texou | 81 | nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT) |
82 | $(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/blfs-html.xml |
||
83 | @echo "Generating non-chunked XHTML file..." |
||
84 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \ |
||
85 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \ |
||
86 | stylesheets/blfs-nochunks.xsl $(RENDERTMP)/blfs-html.xml |
||
87 | |||
88 | @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..." |
||
89 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true |
||
90 | $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT) |
||
91 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \ |
||
92 | $(BASEDIR)/$(NOCHUNKS_OUTPUT) |
||
93 | |||
94 | tmpdir: $(RENDERTMP) |
||
95 | $(RENDERTMP): |
||
96 | @echo "Creating $(RENDERTMP)" |
||
97 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP) |
||
98 | |||
99 | clean: |
||
100 | @echo "Cleaning $(RENDERTMP)" |
||
2473 | myou72 | 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 |
||
660 | texou | 104 | $(Q)rm -f $(RENDERTMP)/blfs-{patch-list,patches} |
105 | $(Q)rmdir $(RENDERTMP) 2>/dev/null || : |
||
106 | |||
107 | validxml: $(RENDERTMP)/blfs-full.xml |
||
108 | $(RENDERTMP)/blfs-full.xml: general.ent $(ALLXML) $(ALLXSL) |
||
109 | @echo "Validating the book..." |
||
110 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP) |
||
111 | $(Q)xmllint --nonet --noent --xinclude --postvalid \ |
||
112 | -o $(RENDERTMP)/blfs-full.xml index.xml |
||
113 | |||
114 | profile-html: $(RENDERTMP)/blfs-html.xml |
||
115 | $(RENDERTMP)/blfs-html.xml: $(RENDERTMP)/blfs-full.xml |
||
116 | @echo "Generating profiled XML for XHTML..." |
||
117 | $(Q)xsltproc --nonet --stringparam profile.condition html \ |
||
118 | --output $(RENDERTMP)/blfs-html.xml stylesheets/lfs-xsl/profile.xsl \ |
||
119 | $(RENDERTMP)/blfs-full.xml |
||
120 | |||
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 \ |
||
129 | stylesheets/patcheslist.xsl $(RENDERTMP)/blfs-full.xml |
||
130 | |||
131 | wget-list: $(BASEDIR)/wget-list |
||
132 | $(BASEDIR)/wget-list: $(RENDERTMP)/blfs-full.xml |
||
133 | @echo "Generating wget list..." |
||
134 | $(Q)mkdir -p $(BASEDIR) |
||
135 | $(Q)xsltproc --nonet --output $(BASEDIR)/wget-list \ |
||
136 | stylesheets/wget-list.xsl $(RENDERTMP)/blfs-full.xml |
||
137 | |||
138 | test-links: $(BASEDIR)/test-links |
||
139 | $(BASEDIR)/test-links: $(RENDERTMP)/blfs-full.xml |
||
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 \ |
||
144 | $(RENDERTMP)/blfs-full.xml |
||
145 | |||
146 | @echo "Checking URLs, first pass..." |
||
147 | $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls |
||
148 | $(Q)for URL in `cat $(BASEDIR)/test-links`; do \ |
||
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 |
||
154 | |||
155 | @echo "Checking URLs, second pass..." |
||
156 | $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \ |
||
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 |
||
5432 | myou72 | 162 | |
163 | test-all-links: $(BASEDIR)/test-all-links |
||
164 | $(BASEDIR)/test-all-links: $(RENDERTMP)/blfs-full.xml |
||
165 | @echo "Generating test-all-links file..." |
||
166 | $(Q)mkdir -p $(BASEDIR) |
||
167 | $(Q)xsltproc --nonet \ |
||
168 | --output $(BASEDIR)/test-all-links stylesheets/list_url.xsl \ |
||
169 | $(RENDERTMP)/blfs-full.xml |
||
660 | texou | 170 | |
5432 | myou72 | 171 | @echo "Checking URLs, first pass..." |
172 | $(Q)rm -f $(BASEDIR)/{good,bad,true_bad,broken}_urls |
||
173 | $(Q)for URL in `uniq $(BASEDIR)/test-all-links`; do \ |
||
174 | wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \ |
||
175 | if test $$? -ne 0 ; then echo $$URL >> $(BASEDIR)/bad_urls ; \ |
||
176 | else echo $$URL >> $(BASEDIR)/good_urls 2>&1; \ |
||
177 | fi; \ |
||
178 | done |
||
179 | |||
180 | @echo "Checking URLs, second pass..." |
||
181 | $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \ |
||
182 | wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \ |
||
183 | if test $$? -ne 0 ; then echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \ |
||
184 | else echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \ |
||
185 | fi; \ |
||
186 | done |
||
187 | |||
188 | @echo "Generating broken_urls file ..." |
||
189 | $(Q)for URL in `cat $(BASEDIR)/true_bad_urls`; do \ |
||
190 | grep -r "$$URL" * >> $(BASEDIR)/broken_urls ; \ |
||
191 | done |
||
192 | |||
193 | $(Q)sed -i $(BASEDIR)/broken_urls -e "/^tmp/d" -e "/xml~/d" |
||
194 | |||
195 | |||
660 | texou | 196 | dump-commands: $(DUMPDIR) |
197 | $(DUMPDIR): $(RENDERTMP)/blfs-full.xml |
||
198 | @echo "Dumping book commands..." |
||
199 | $(Q)xsltproc --output $(DUMPDIR)/ \ |
||
200 | stylesheets/dump-commands.xsl $(RENDERTMP)/blfs-full.xml |
||
201 | $(Q)touch $(DUMPDIR) |
||
202 | |||
493 | gleu | 203 | validate: |
660 | texou | 204 | @echo "Validating the book..." |
205 | $(Q)xmllint --noout --nonet --xinclude --postvalid index.xml |
||
540 | gleu | 206 | |
2473 | myou72 | 207 | .PHONY: blfs all world html nochunks tmpdir clean validxml \ |
660 | texou | 208 | profile-html wget-list test-links dump-commands validate |
2473 | myou72 | 209 | |
210 | #.PHONY: blfs all world html pdf nochunks tmpdir clean validxml \ |
||
211 | profile-html wget-list test-links dump-commands validate |