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