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