source: Makefile@ d4919db

12.1 ken/TL2024 lazarus plabs/newcss rahul/power-profiles-daemon trunk xry111/llvm18
Last change on this file since d4919db was 1df87ee, checked in by Pierre Labastie <pierre.labastie@…>, 4 months ago

Output the book in utf-8 encoding

Also fix doctype being removed by tidy in longindex by removing a wrong
attribute (xmlns:xlink) in a div element in the index.

  • Property mode set to 100644
File size: 10.6 KB
Line 
1# vim:ts=3
2# Makefile for BLFS Book generation.
3# By Tushar Teredesai <tushar@linuxfromscratch.org>
4# 2004-01-31
5
6# Adjust these to suit your installation
7RENDERTMP ?= $(HOME)/tmp
8CHUNK_QUIET = 1
9ROOT_ID =
10SHELL = /bin/bash
11
12ALLXML := $(filter-out $(RENDERTMP)/%, \
13 $(wildcard *.xml */*.xml */*/*.xml */*/*/*.xml */*/*/*/*.xml))
14ALLXSL := $(filter-out $(RENDERTMP)/%, \
15 $(wildcard *.xsl */*.xsl */*/*.xsl */*/*/*.xsl */*/*/*/*.xsl))
16
17ifdef V
18 Q =
19else
20 Q = @
21endif
22
23ifndef REV
24 REV = sysv
25endif
26
27ifneq ($(REV), sysv)
28 ifneq ($(REV), systemd)
29 $(error REV must be 'sysv' (default) or 'systemd'.)
30 endif
31endif
32
33ifeq ($(REV), sysv)
34 BASEDIR ?= $(HOME)/public_html/blfs-book
35 NOCHUNKS_OUTPUT ?= blfs-book.html
36 DUMPDIR ?= ~/blfs-commands
37 BLFSHTML ?= blfs-html.xml
38 BLFSHTML2 ?= blfs-html2.xml
39 BLFSFULL ?= blfs-full.xml
40else
41 BASEDIR ?= $(HOME)/public_html/blfs-systemd
42 NOCHUNKS_OUTPUT ?= blfs-sysd-book.html
43 DUMPDIR ?= ~/blfs-sysd-commands
44 BLFSHTML ?= blfs-systemd-html.xml
45 BLFSHTML2 ?= blfs-systemd-html2.xml
46 BLFSFULL ?= blfs-systemd-full.xml
47
48endif
49
50
51blfs: html wget-list
52
53help:
54 @echo ""
55 @echo "make <parameters> <targets>"
56 @echo ""
57 @echo "Parameters:"
58 @echo " REV=<rev> Build variation of book"
59 @echo " Valid values for REV are:"
60 @echo " * sysv - Build book for SysV"
61 @echo " * systemd - Build book for systemd"
62 @echo " Defaults to 'sysv'"
63 @echo ""
64 @echo " BASEDIR=<dir> Put the output in directory <dir>."
65 @echo " Defaults to"
66 @echo " 'HOME/public_html/blfs-book' if REV=sysv (or unset)"
67 @echo " or to"
68 @echo " 'HOME/public_html/blfs-book-systemd' if REV=systemd"
69 @echo ""
70 @echo " V=<val> If <val> is a non-empty value, all"
71 @echo " steps to produce the output is shown."
72 @echo " Default is unset."
73 @echo ""
74 @echo "Targets:"
75 @echo " help Show this help text."
76 @echo ""
77 @echo " blfs Builds targets 'html' and 'wget-list'."
78 @echo ""
79 @echo " html Builds the HTML pages of the book."
80 @echo ""
81 @echo " wget-list Produces a list of all packages to download."
82 @echo " Output is BASEDIR/wget-list"
83 @echo ""
84 @echo " nochunks Builds the book as a one-pager. The output"
85 @echo " is a large single HTML page containing the"
86 @echo " whole book."
87 @echo ""
88 @echo " Parameter NOCHUNKS_OUTPUT=<filename> controls"
89 @echo " the name of the HTML file."
90 @echo ""
91 @echo " validate Runs validation checks on the XML files."
92 @echo ""
93 @echo " test-links Runs validation checks on URLs in the book."
94 @echo " Produces a file named BASEDIR/bad_urls containing"
95 @echo " URLS which are invalid and a BASEDIR/good_urls"
96 @echo " containing all valid URLs."
97 @echo ""
98
99all: blfs nochunks
100world: all blfs-patch-list dump-commands test-links
101
102html: $(BASEDIR)/index.html
103$(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML) version
104 @echo "Generating chunked XHTML files..."
105 $(Q)xsltproc --nonet \
106 --stringparam chunk.quietly $(CHUNK_QUIET) \
107 --stringparam rootid "$(ROOT_ID)" \
108 --stringparam base.dir $(BASEDIR)/ \
109 stylesheets/blfs-chunked.xsl \
110 $(RENDERTMP)/$(BLFSHTML)
111 $(Q)sed -i 's/xmlns:xlink.*xlink"//' $(BASEDIR)/longindex.html
112
113 @echo "Copying CSS code and images..."
114 $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
115 mkdir -p $(BASEDIR)/stylesheets; \
116 fi;
117
118 $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
119 $(Q)sed -i 's|../stylesheet|stylesheet|' $(BASEDIR)/index.html
120
121 $(Q)if [ ! -e $(BASEDIR)/images ]; then \
122 mkdir -p $(BASEDIR)/images; \
123 fi;
124 $(Q)cp images/*.png $(BASEDIR)/images
125
126 $(Q)cd $(BASEDIR)/; sed -e "s@../images@images@g" \
127 -i *.html
128
129 @echo "Running Tidy and obfuscate.sh on chunked XHTML..."
130 $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
131 tidy -config tidy.conf $$filename; \
132 true; \
133 bash obfuscate.sh $$filename; \
134 sed -i -e "1,20s@text/html@application/xhtml+xml@g" $$filename; \
135 done;
136
137nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
138$(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML) version
139 @echo "Generating non-chunked XHTML file..."
140 $(Q)xsltproc --nonet \
141 --stringparam rootid "$(ROOT_ID)" \
142 --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
143 stylesheets/blfs-nochunks.xsl \
144 $(RENDERTMP)/$(BLFSHTML)
145 $(Q)sed -i 's/xmlns:xlink.*xlink"//' $(BASEDIR)/$(NOCHUNKS_OUTPUT)
146
147 @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
148 $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
149 $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
150 $(Q)sed -i -e "1,20s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
151
152tmpdir: $(RENDERTMP)
153$(RENDERTMP):
154 @echo "Creating $(RENDERTMP)"
155 $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
156
157clean:
158 @echo "Cleaning $(RENDERTMP)"
159 $(Q)rm -f $(RENDERTMP)/blfs*
160
161validate: $(RENDERTMP)/$(BLFSFULL)
162$(RENDERTMP)/$(BLFSFULL): general.ent packages.ent $(ALLXML) $(ALLXSL) version
163 $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
164
165 @echo "Adjusting for revision $(REV)..."
166 $(Q)xsltproc --nonet \
167 --xinclude \
168 --output $(RENDERTMP)/$(BLFSHTML2) \
169 --stringparam profile.revision $(REV) \
170 stylesheets/lfs-xsl/profile.xsl \
171 index.xml
172
173 @echo "Validating the book..."
174 $(Q)xmllint --nonet \
175 --noent \
176 --postvalid \
177 --output $(RENDERTMP)/$(BLFSFULL) \
178 $(RENDERTMP)/$(BLFSHTML2)
179
180profile-html: $(RENDERTMP)/$(BLFSHTML)
181$(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL) version
182 @echo "Generating profiled XML for XHTML..."
183 $(Q)xsltproc --nonet \
184 --stringparam profile.condition html \
185 --output $(RENDERTMP)/$(BLFSHTML) \
186 stylesheets/lfs-xsl/profile.xsl \
187 $(RENDERTMP)/$(BLFSFULL)
188
189blfs-patch-list: blfs-patches.sh
190 @echo "Generating blfs patch list..."
191 $(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
192 blfs-patches.sh > blfs-patch-list
193
194blfs-patches.sh: $(RENDERTMP)/$(BLFSFULL) version
195 @echo "Generating blfs patch script..."
196 $(Q)xsltproc --nonet \
197 --output blfs-patches.sh \
198 stylesheets/patcheslist.xsl \
199 $(RENDERTMP)/$(BLFSFULL)
200
201wget-list: $(BASEDIR)/wget-list
202$(BASEDIR)/wget-list: $(RENDERTMP)/$(BLFSFULL) version
203 @echo "Generating wget list for $(REV) at $(BASEDIR)/wget-list ..."
204 $(Q)mkdir -p $(BASEDIR)
205 $(Q)xsltproc --nonet \
206 --output $(BASEDIR)/wget-list \
207 stylesheets/wget-list.xsl \
208 $(RENDERTMP)/$(BLFSFULL)
209
210test-links: $(BASEDIR)/test-links
211$(BASEDIR)/test-links: $(RENDERTMP)/$(BLFSFULL) version
212 @echo "Generating test-links file..."
213 $(Q)mkdir -p $(BASEDIR)
214 $(Q)xsltproc --nonet \
215 --stringparam list_mode full \
216 --output $(BASEDIR)/test-links \
217 stylesheets/wget-list.xsl \
218 $(RENDERTMP)/$(BLFSFULL)
219
220 @echo "Checking URLs, first pass..."
221 $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
222 $(Q)for URL in `cat $(BASEDIR)/test-links`; do \
223 wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
224 if test $$? -ne 0 ; then \
225 echo $$URL >> $(BASEDIR)/bad_urls ; \
226 else \
227 echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
228 fi; \
229 done
230
231 @echo "Checking URLs, second pass..."
232 $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
233 wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
234 if test $$? -ne 0 ; then \
235 echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
236 else \
237 echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
238 fi; \
239 done
240
241bootscripts:
242 @VERSION=`grep "bootscripts-version " general.ent | cut -d\" -f2`; \
243 BOOTSCRIPTS="blfs-bootscripts-$$VERSION"; \
244 if [ ! -e $$BOOTSCRIPTS.tar.xz ]; then \
245 rm -rf $(RENDERTMP)/$$BOOTSCRIPTS; \
246 mkdir $(RENDERTMP)/$$BOOTSCRIPTS; \
247 cp -a ../bootscripts/* $(RENDERTMP)/$$BOOTSCRIPTS; \
248 rm -rf ../bootscripts/archive; \
249 tar -cJhf $$BOOTSCRIPTS.tar.xz -C $(RENDERTMP) $$BOOTSCRIPTS; \
250 fi
251
252systemd-units:
253 @VERSION=`grep "systemd-units-version " general.ent | cut -d\" -f2`; \
254 UNITS="blfs-systemd-units-$$VERSION"; \
255 if [ ! -e $$UNITS.tar.xz ]; then \
256 rm -rf $(RENDERTMP)/$$UNITS; \
257 mkdir $(RENDERTMP)/$$UNITS; \
258 cp -a ../systemd-units/* $(RENDERTMP)/$$UNITS; \
259 tar -cJhf $$UNITS.tar.xz -C $(RENDERTMP) $$UNITS; \
260 fi
261
262test-options:
263 $(Q)xsltproc --xinclude --nonet stylesheets/test-options.xsl index.xml
264
265dump-commands: $(DUMPDIR)
266$(DUMPDIR): $(RENDERTMP)/$(BLFSFULL) version
267 @echo "Dumping book commands..."
268 $(Q)xsltproc --output $(DUMPDIR)/ \
269 stylesheets/dump-commands.xsl \
270 $(RENDERTMP)/$(BLFSFULL)
271 $(Q)touch $(DUMPDIR)
272
273.PHONY: blfs all world html nochunks tmpdir clean \
274 validate profile-html blfs-patch-list wget-list test-links \
275 dump-commands bootscripts systemd-units version test-options
276
277version:
278 $(Q)./git-version.sh $(REV)
Note: See TracBrowser for help on using the repository browser.