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 | SHELL = /bin/bash
|
---|
16 |
|
---|
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
|
---|
29 | #all: blfs nochunks pdf
|
---|
30 | all: blfs nochunks
|
---|
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; \
|
---|
43 | fi;
|
---|
44 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
---|
45 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
---|
46 | mkdir -p $(BASEDIR)/images; \
|
---|
47 | fi;
|
---|
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
|
---|
51 |
|
---|
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;
|
---|
59 |
|
---|
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
|
---|
66 |
|
---|
67 | #$(RENDERTMP)/blfs-pdf.fo: $(RENDERTMP)/blfs-pdf.xml
|
---|
68 | # @echo "Generating FO file..."
|
---|
69 | # $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
70 | --output $(RENDERTMP)/blfs-pdf.fo stylesheets/blfs-pdf.xsl \
|
---|
71 | $(RENDERTMP)/blfs-pdf.xml
|
---|
72 | # $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/blfs-pdf.fo
|
---|
73 |
|
---|
74 | #$(BASEDIR)/$(PDF_OUTPUT): $(RENDERTMP)/blfs-pdf.fo
|
---|
75 | # @echo "Generating PDF file..."
|
---|
76 | # $(Q)if [ ! -e $(BASEDIR) ]; then \
|
---|
77 | mkdir -p $(BASEDIR); \
|
---|
78 | fi;
|
---|
79 | # $(Q)fop $(RENDERTMP)/blfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT)
|
---|
80 |
|
---|
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)"
|
---|
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
|
---|
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
|
---|
162 |
|
---|
163 | bootscripts:
|
---|
164 | @VERSION=`grep "bootscripts-version " general.ent | cut -d\" -f2`; \
|
---|
165 | BOOTSCRIPTS="blfs-bootscripts-$$VERSION"; \
|
---|
166 | if [ ! -e $$BOOTSCRIPTS.tar.xz ]; then \
|
---|
167 | rm -rf $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
168 | mkdir $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
169 | cp -a ../bootscripts/* $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
170 | rm -rf ../bootscripts/archive; \
|
---|
171 | tar -cJhf $$BOOTSCRIPTS.tar.xz -C $(RENDERTMP) $$BOOTSCRIPTS; \
|
---|
172 | fi
|
---|
173 |
|
---|
174 | dump-commands: $(DUMPDIR)
|
---|
175 | $(DUMPDIR): $(RENDERTMP)/blfs-full.xml
|
---|
176 | @echo "Dumping book commands..."
|
---|
177 | $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
178 | stylesheets/dump-commands.xsl $(RENDERTMP)/blfs-full.xml
|
---|
179 | $(Q)touch $(DUMPDIR)
|
---|
180 |
|
---|
181 | validate:
|
---|
182 | @echo "Validating the book..."
|
---|
183 | $(Q)xmllint --noout --nonet --xinclude --postvalid index.xml
|
---|
184 |
|
---|
185 | .PHONY: blfs all world html nochunks tmpdir clean validxml \
|
---|
186 | profile-html wget-list test-links dump-commands validate \
|
---|
187 | bootscripts
|
---|
188 |
|
---|
189 | #.PHONY: blfs all world html pdf nochunks tmpdir clean validxml \
|
---|
190 | profile-html wget-list test-links dump-commands validate
|
---|