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 |
|
---|
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 | true; \
|
---|
57 | /bin/bash obfuscate.sh $$filename; \
|
---|
58 | sed -e "s@text/html@application/xhtml+xml@g" \
|
---|
59 | -e "s/\xa9/\©/ " \
|
---|
60 | -i $$filename; \
|
---|
61 | done;
|
---|
62 |
|
---|
63 | $(Q)$(MAKE) --no-print-directory wget-list md5sums
|
---|
64 |
|
---|
65 | pdf: validate
|
---|
66 | @echo "Generating profiled XML for PDF..."
|
---|
67 | $(Q)xsltproc --nonet \
|
---|
68 | --stringparam profile.condition pdf \
|
---|
69 | --output $(RENDERTMP)/lfs-pdf.xml \
|
---|
70 | stylesheets/lfs-xsl/profile.xsl \
|
---|
71 | $(RENDERTMP)/lfs-full.xml
|
---|
72 |
|
---|
73 | @echo "Generating FO file..."
|
---|
74 | $(Q)xsltproc --nonet \
|
---|
75 | --stringparam rootid "$(ROOT_ID)" \
|
---|
76 | --output $(RENDERTMP)/lfs-pdf.fo \
|
---|
77 | stylesheets/lfs-pdf.xsl \
|
---|
78 | $(RENDERTMP)/lfs-pdf.xml
|
---|
79 |
|
---|
80 | $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/lfs-pdf.fo
|
---|
81 | $(Q)bash pdf-fixups.sh $(RENDERTMP)/lfs-pdf.fo
|
---|
82 |
|
---|
83 | @echo "Generating PDF file..."
|
---|
84 | $(Q)mkdir -p $(RENDERTMP)/images
|
---|
85 | $(Q)cp images/*.png $(RENDERTMP)/images
|
---|
86 |
|
---|
87 | $(Q)mkdir -p $(BASEDIR)
|
---|
88 |
|
---|
89 | $(Q)fop -q $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT) 2>fop.log
|
---|
90 | @echo "$(BASEDIR)/$(PDF_OUTPUT) created"
|
---|
91 | @echo "fop.log created"
|
---|
92 |
|
---|
93 | nochunks: validate profile-html
|
---|
94 | @echo "Generating non chunked XHTML file..."
|
---|
95 | $(Q)xsltproc --nonet \
|
---|
96 | --stringparam rootid "$(ROOT_ID)" \
|
---|
97 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
---|
98 | stylesheets/lfs-nochunks.xsl \
|
---|
99 | $(RENDERTMP)/lfs-html.xml
|
---|
100 | # $(RENDERTMP)/lfs-html2.xml
|
---|
101 |
|
---|
102 | @echo "Running Tidy..."
|
---|
103 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
---|
104 |
|
---|
105 | @echo "Running obfuscate.sh..."
|
---|
106 | $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
107 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
108 | $(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
109 | $(Q)sed -i -e "s@../md5sums@md5sums@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
110 | $(Q)sed -i -e "s@\xa9@\©@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
111 |
|
---|
112 | @echo "Output at $(BASEDIR)/$(NOCHUNKS_OUTPUT)"
|
---|
113 |
|
---|
114 | tmpdir:
|
---|
115 | @echo "Creating and cleaning $(RENDERTMP)"
|
---|
116 | $(Q)mkdir -p $(RENDERTMP)
|
---|
117 | $(Q)rm -f $(RENDERTMP)/lfs*.xml
|
---|
118 | $(Q)rm -f $(RENDERTMP)/*wget*
|
---|
119 | $(Q)rm -f $(RENDERTMP)/*md5sum*
|
---|
120 | $(Q)rm -f $(RENDERTMP)/*pdf.fo
|
---|
121 |
|
---|
122 | validate: tmpdir version
|
---|
123 | @echo "Processing bootscripts..."
|
---|
124 | $(Q)bash process-scripts.sh
|
---|
125 |
|
---|
126 | @echo "Adjusting for revision $(REV)..."
|
---|
127 | $(Q)xsltproc --nonet \
|
---|
128 | --xinclude \
|
---|
129 | --output $(RENDERTMP)/lfs-html2.xml \
|
---|
130 | --stringparam profile.revision $(REV) \
|
---|
131 | stylesheets/lfs-xsl/profile.xsl \
|
---|
132 | index.xml
|
---|
133 |
|
---|
134 | @echo "Validating the book..."
|
---|
135 | $(Q)xmllint --nonet \
|
---|
136 | --noent \
|
---|
137 | --postvalid \
|
---|
138 | -o $(RENDERTMP)/lfs-full.xml \
|
---|
139 | $(RENDERTMP)/lfs-html2.xml
|
---|
140 |
|
---|
141 | $(Q)rm -f appendices/*.script
|
---|
142 | $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
|
---|
143 | @echo "Validation complete."
|
---|
144 |
|
---|
145 | profile-html:
|
---|
146 | @echo "Generating profiled XML for XHTML..."
|
---|
147 | $(Q)xsltproc --nonet \
|
---|
148 | --stringparam profile.condition html \
|
---|
149 | --output $(RENDERTMP)/lfs-html.xml \
|
---|
150 | stylesheets/lfs-xsl/profile.xsl \
|
---|
151 | $(RENDERTMP)/lfs-full.xml
|
---|
152 |
|
---|
153 | wget-list: $(BASEDIR)/wget-list
|
---|
154 | $(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml \
|
---|
155 | packages.ent patches.ent general.ent
|
---|
156 | @echo "Generating consolidated wget list at $(BASEDIR)/wget-list ..."
|
---|
157 | $(Q)mkdir -p $(BASEDIR)
|
---|
158 |
|
---|
159 | # $(Q)xsltproc --nonet --xinclude \
|
---|
160 | # --stringparam profile.revision $(REV) \
|
---|
161 | # --output $(RENDERTMP)/sysd-wget.xml \
|
---|
162 | # stylesheets/lfs-xsl/profile.xsl \
|
---|
163 | # chapter03/chapter03.xml
|
---|
164 |
|
---|
165 | $(Q)xsltproc --xinclude --nonet \
|
---|
166 | --output $(BASEDIR)/wget-list \
|
---|
167 | stylesheets/wget-list.xsl \
|
---|
168 | chapter03/chapter03.xml
|
---|
169 |
|
---|
170 | md5sums: $(BASEDIR)/md5sums
|
---|
171 | $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \
|
---|
172 | packages.ent patches.ent
|
---|
173 | @echo "Generating consolidated md5sum file at $(BASEDIR)/md5sums ..."
|
---|
174 | $(Q)mkdir -p $(BASEDIR)
|
---|
175 |
|
---|
176 | $(Q)xsltproc --nonet --xinclude \
|
---|
177 | --stringparam profile.revision $(REV) \
|
---|
178 | --output $(RENDERTMP)/sysv-md5sum.xml \
|
---|
179 | stylesheets/lfs-xsl/profile.xsl \
|
---|
180 | chapter03/chapter03.xml
|
---|
181 |
|
---|
182 | $(Q)xsltproc --xinclude --nonet \
|
---|
183 | --output $(BASEDIR)/md5sums \
|
---|
184 | stylesheets/md5sum.xsl \
|
---|
185 | $(RENDERTMP)/sysv-md5sum.xml
|
---|
186 | $(Q)sed -i -e \
|
---|
187 | "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.xz | cut -d' ' -f1)/" \
|
---|
188 | $(BASEDIR)/md5sums
|
---|
189 |
|
---|
190 | version:
|
---|
191 | $(Q)./git-version.sh
|
---|
192 |
|
---|
193 | #dump-commands: validate
|
---|
194 | # @echo "Dumping book commands..."
|
---|
195 | # $(Q)xsltproc --nonet \
|
---|
196 | # --output $(RENDERTMP)/lfs-html.xml \
|
---|
197 | # --stringparam profile.revision $(REV) \
|
---|
198 | # stylesheets/lfs-xsl/profile.xsl \
|
---|
199 | # $(RENDERTMP)/lfs-full.xml
|
---|
200 |
|
---|
201 | # $(Q)rm -rf $(DUMPDIR)
|
---|
202 |
|
---|
203 | # $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
204 | # stylesheets/dump-commands.xsl \
|
---|
205 | # $(RENDERTMP)/lfs-html.xml
|
---|
206 | # @echo "Dumping book commands complete in $(DUMPDIR)"
|
---|
207 |
|
---|
208 | all: book nochunks pdf # dump-commands
|
---|
209 |
|
---|
210 | .PHONY : all book dump-commands nochunks pdf profile-html tmpdir validate md5sums wget-list version
|
---|
211 |
|
---|