source: Makefile@ 8ba840f

12.1 12.1-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/loongarch xry111/loongarch-12.1 xry111/mips64el xry111/update-glibc
Last change on this file since 8ba840f was 8ba840f, checked in by Xi Ruoyao <xry111@…>, 5 months ago

Makefile: Unify two sed for removing bogus xmlns:xlink, and link to upstream bug report

Nasty bug :(.

  • Property mode set to 100644
File size: 7.7 KB
Line 
1# vim:ts=3
2#BASEDIR = ~/lfs-book
3#SYSDDIR = ~/lfs-systemd
4#DUMPDIR = ~/lfs-commands
5RENDERTMP = $(HOME)/tmp
6CHUNK_QUIET = 1
7ROOT_ID =
8SHELL = /bin/bash
9
10ifdef V
11 Q =
12else
13 Q = @
14endif
15
16ifndef REV
17 REV = sysv
18endif
19
20ifneq ($(REV), sysv)
21 ifneq ($(REV), systemd)
22 $(error REV must be 'sysv' (default) or 'systemd'.)
23 endif
24endif
25
26ifeq ($(REV), sysv)
27 BASEDIR ?= ~/public_html/lfs-book
28 PDF_OUTPUT ?= LFS-BOOK.pdf
29 NOCHUNKS_OUTPUT ?= LFS-BOOK.html
30 DUMPDIR ?= ~/lfs-commands
31else
32 BASEDIR ?= ~/public_html/lfs-systemd
33 PDF_OUTPUT ?= LFS-SYSD-BOOK.pdf
34 NOCHUNKS_OUTPUT ?= LFS-SYSD-BOOK.html
35 DUMPDIR ?= ~/lfs-sysd-commands
36endif
37
38# https://github.com/docbook/xslt10-stylesheets/issues/239
39SED_XMLNS_XLINK = sed -i 's/xmlns:xlink.*xlink"//'
40
41book: validate profile-html
42 @echo "Generating chunked XHTML files at $(BASEDIR)/ ..."
43 $(Q)xsltproc --nonet \
44 --stringparam chunk.quietly $(CHUNK_QUIET) \
45 --stringparam rootid "$(ROOT_ID)" \
46 --stringparam base.dir $(BASEDIR)/ \
47 stylesheets/lfs-chunked.xsl \
48 $(RENDERTMP)/lfs-html.xml
49
50 @echo "Copying CSS code and images..."
51 $(Q)mkdir -p $(BASEDIR)/stylesheets
52 $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
53 $(Q)sed -i 's|../stylesheet|stylesheet|' $(BASEDIR)/index.html
54 $(Q)$(SED_XMLNS_XLINK) $(BASEDIR)/longindex.html
55
56 $(Q)mkdir -p $(BASEDIR)/images
57 $(Q)cp images/*.png $(BASEDIR)/images
58
59 @echo "Running Tidy and obfuscate.sh..."
60 $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
61 tidy -config tidy.conf $$filename; \
62 true; \
63 /bin/bash obfuscate.sh $$filename; \
64 sed -e "s@text/html@application/xhtml+xml@g" \
65 -i $$filename; \
66 done;
67
68 $(Q)$(MAKE) --no-print-directory wget-list md5sums
69
70pdf: validate
71 @echo "Generating profiled XML for PDF..."
72 $(Q)xsltproc --nonet \
73 --stringparam profile.condition pdf \
74 --output $(RENDERTMP)/lfs-pdf.xml \
75 stylesheets/lfs-xsl/profile.xsl \
76 $(RENDERTMP)/lfs-full.xml
77
78 @echo "Generating FO file..."
79 $(Q)xsltproc --nonet \
80 --stringparam rootid "$(ROOT_ID)" \
81 --output $(RENDERTMP)/lfs-pdf.fo \
82 stylesheets/lfs-pdf.xsl \
83 $(RENDERTMP)/lfs-pdf.xml
84
85 $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/lfs-pdf.fo
86 $(Q)bash pdf-fixups.sh $(RENDERTMP)/lfs-pdf.fo
87
88 @echo "Generating PDF file..."
89 $(Q)mkdir -p $(RENDERTMP)/images
90 $(Q)cp images/*.png $(RENDERTMP)/images
91
92 $(Q)mkdir -p $(BASEDIR)
93
94 $(Q)fop -q $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT) 2>fop.log
95 @echo "$(BASEDIR)/$(PDF_OUTPUT) created"
96 @echo "fop.log created"
97
98nochunks: validate profile-html
99 @echo "Generating non chunked XHTML file..."
100 $(Q)xsltproc --nonet \
101 --stringparam rootid "$(ROOT_ID)" \
102 --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
103 stylesheets/lfs-nochunks.xsl \
104 $(RENDERTMP)/lfs-html.xml
105# $(RENDERTMP)/lfs-html2.xml
106
107 $(Q)$(SED_XMLNS_XLINK) $(BASEDIR)/$(NOCHUNKS_OUTPUT)
108 @echo "Running Tidy..."
109 $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
110
111 @echo "Running obfuscate.sh..."
112 $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
113 $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
114 $(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
115 $(Q)sed -i -e "s@../md5sums@md5sums@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
116
117 @echo "Output at $(BASEDIR)/$(NOCHUNKS_OUTPUT)"
118
119tmpdir:
120 @echo "Creating and cleaning $(RENDERTMP)"
121 $(Q)mkdir -p $(RENDERTMP)
122 $(Q)rm -f $(RENDERTMP)/lfs*.xml
123 $(Q)rm -f $(RENDERTMP)/*wget*
124 $(Q)rm -f $(RENDERTMP)/*md5sum*
125 $(Q)rm -f $(RENDERTMP)/*pdf.fo
126
127validate: tmpdir version
128 @echo "Processing bootscripts..."
129 $(Q)bash process-scripts.sh
130
131 @echo "Adjusting for revision $(REV)..."
132 $(Q)xsltproc --nonet \
133 --xinclude \
134 --output $(RENDERTMP)/lfs-html2.xml \
135 --stringparam profile.revision $(REV) \
136 stylesheets/lfs-xsl/profile.xsl \
137 index.xml
138
139 @echo "Validating the book..."
140 $(Q)xmllint --nonet \
141 --noent \
142 --postvalid \
143 -o $(RENDERTMP)/lfs-full.xml \
144 $(RENDERTMP)/lfs-html2.xml
145
146 $(Q)rm -f appendices/*.script
147 $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
148 @echo "Validation complete."
149
150profile-html:
151 @echo "Generating profiled XML for XHTML..."
152 $(Q)xsltproc --nonet \
153 --stringparam profile.condition html \
154 --output $(RENDERTMP)/lfs-html.xml \
155 stylesheets/lfs-xsl/profile.xsl \
156 $(RENDERTMP)/lfs-full.xml
157
158wget-list: $(BASEDIR)/wget-list $(BASEDIR)/wget-list-$(REV)
159$(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml \
160 packages.ent patches.ent general.ent
161 @echo "Generating consolidated wget list at $(BASEDIR)/wget-list ..."
162 $(Q)mkdir -p $(BASEDIR)
163 $(Q)xsltproc --xinclude --nonet \
164 --output $(BASEDIR)/wget-list \
165 stylesheets/wget-list.xsl \
166 chapter03/chapter03.xml
167
168$(BASEDIR)/wget-list-$(REV): stylesheets/wget-list.xsl \
169 chapter03/chapter03.xml \
170 packages.ent patches.ent general.ent
171 $(Q)xsltproc --nonet --xinclude \
172 --stringparam profile.revision $(REV) \
173 --output $(RENDERTMP)/wget-list.xml \
174 stylesheets/lfs-xsl/profile.xsl \
175 chapter03/chapter03.xml
176 $(Q)xsltproc --xinclude --nonet \
177 --output $(BASEDIR)/wget-list-$(REV) \
178 stylesheets/wget-list.xsl \
179 $(RENDERTMP)/wget-list.xml
180
181md5sums: $(BASEDIR)/md5sums
182$(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \
183 packages.ent patches.ent
184 @echo "Generating consolidated md5sum file at $(BASEDIR)/md5sums ..."
185 $(Q)mkdir -p $(BASEDIR)
186
187 $(Q)xsltproc --nonet --xinclude \
188 --stringparam profile.revision $(REV) \
189 --output $(RENDERTMP)/md5sum.xml \
190 stylesheets/lfs-xsl/profile.xsl \
191 chapter03/chapter03.xml
192
193 $(Q)xsltproc --xinclude --nonet \
194 --output $(BASEDIR)/md5sums \
195 stylesheets/md5sum.xsl \
196 $(RENDERTMP)/md5sum.xml
197 $(Q)sed -i -e \
198 "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.xz | cut -d' ' -f1)/" \
199 $(BASEDIR)/md5sums
200
201version:
202 $(Q)./git-version.sh $(REV)
203
204dump-commands: validate
205 @echo "Dumping book commands..."
206
207 $(Q)rm -rf $(DUMPDIR)
208
209 $(Q)xsltproc --output $(DUMPDIR)/ \
210 stylesheets/dump-commands.xsl \
211 $(RENDERTMP)/lfs-full.xml
212 @echo "Dumping book commands complete in $(DUMPDIR)"
213
214all: book nochunks pdf dump-commands
215
216dist:
217 $(Q)DIST=/tmp/LFS-RELEASE ./git-version.sh $(REV)
218 $(Q)rm -f lfs-$$(</tmp/LFS-RELEASE).tar.xz
219 $(Q)tar cJf lfs-$$(</tmp/LFS-RELEASE).tar.xz \
220 $(shell git ls-tree HEAD . --name-only) version.ent \
221 -C /tmp LFS-RELEASE \
222 --transform "s,^,lfs-$$(</tmp/LFS-RELEASE)/,"
223 $(Q)echo "Generated XML tarball lfs-$$(</tmp/LFS-RELEASE).tar.xz"
224
225.PHONY : all book dump-commands nochunks pdf profile-html tmpdir validate md5sums wget-list version dist
226
Note: See TracBrowser for help on using the repository browser.