source: Makefile

trunk
Last change on this file was b6dd23c7, checked in by Pierre Labastie <pierre.labastie@…>, 3 months ago

Makefile: improvements in xsltproc commands

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