source: Makefile@ 751ceda

11.1 11.2 11.3 12.0 12.1 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts lazarus lxqt plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition trunk xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since 751ceda was 50836740, checked in by Xi Ruoyao <xry111@…>, 3 years ago

merge conditional XML from LFS

There was some consistency issues in URLs to LFS. For example, in
systemd revision the URL to LFS "General Network Configuration" points
to the sysv book, this can be really troubling to new readers.

Instead of fixing them one by one, merge conditional XML developed by
Pierre from LFS.

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