Add libelf to dependencies section
[linux_from_scratch.git] / Makefile
blobf237346a15d7a6ebcf74d7f8f93c32547f8b19db
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
9 ifdef V
10 Q =
11 else
12 Q = @
13 endif
15 ifndef REV
16 REV = sysv
17 endif
19 ifneq ($(REV), sysv)
20 ifneq ($(REV), systemd)
21 $(error REV must be 'sysv' (default) or 'systemd'.)
22 endif
23 endif
25 ifeq ($(REV), sysv)
26 BASEDIR ?= ~/lfs-book
27 PDF_OUTPUT ?= LFS-BOOK.pdf
28 NOCHUNKS_OUTPUT ?= LFS-BOOK.html
29 DUMPDIR ?= ~/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
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
46 @echo "Copying CSS code and images..."
47 $(Q)mkdir -p $(BASEDIR)/stylesheets
48 $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
49 $(Q)pushd $(BASEDIR)/ > /dev/null; \
50 sed -i -e "s@../stylesheets@stylesheets@g" *.html; \
51 popd > /dev/null
53 $(Q)mkdir -p $(BASEDIR)/images
54 $(Q)cp images/*.png $(BASEDIR)/images
56 @echo "Running Tidy and obfuscate.sh..."
57 $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
58 tidy -config tidy.conf $$filename; \
59 true; \
60 /bin/bash obfuscate.sh $$filename; \
61 sed -e "s@text/html@application/xhtml+xml@g" \
62 -e "s/\xa9/\©/ " \
63 -i $$filename; \
64 done;
66 $(Q)$(MAKE) --no-print-directory wget-list md5sums
68 pdf: validate
69 @echo "Generating profiled XML for PDF..."
70 $(Q)xsltproc --nonet \
71 --stringparam profile.condition pdf \
72 --output $(RENDERTMP)/lfs-pdf.xml \
73 stylesheets/lfs-xsl/profile.xsl \
74 $(RENDERTMP)/lfs-full.xml
76 @echo "Generating FO file..."
77 $(Q)xsltproc --nonet \
78 --stringparam rootid "$(ROOT_ID)" \
79 --output $(RENDERTMP)/lfs-pdf.fo \
80 stylesheets/lfs-pdf.xsl \
81 $(RENDERTMP)/lfs-pdf.xml
83 $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/lfs-pdf.fo
84 $(Q)bash pdf-fixups.sh $(RENDERTMP)/lfs-pdf.fo
86 @echo "Generating PDF file..."
87 $(Q)mkdir -p $(RENDERTMP)/images
88 $(Q)cp images/*.png $(RENDERTMP)/images
90 $(Q)mkdir -p $(BASEDIR)
92 $(Q)fop -q $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT) 2>fop.log
93 @echo "$(BASEDIR)/$(PDF_OUTPUT) created"
94 @echo "fop.log created"
96 nochunks: validate profile-html
97 @echo "Generating non chunked XHTML file..."
98 $(Q)xsltproc --nonet \
99 --stringparam rootid "$(ROOT_ID)" \
100 --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
101 stylesheets/lfs-nochunks.xsl \
102 $(RENDERTMP)/lfs-html2.xml
104 @echo "Running Tidy..."
105 $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
107 @echo "Running obfuscate.sh..."
108 $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
109 $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
110 $(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
111 $(Q)sed -i -e "s@../md5sums@md5sums@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
112 $(Q)sed -i -e "s@\xa9@\©@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
114 @echo "Output at $(BASEDIR)/$(NOCHUNKS_OUTPUT)"
116 tmpdir:
117 @echo "Creating and cleaning $(RENDERTMP)"
118 $(Q)mkdir -p $(RENDERTMP)
119 $(Q)rm -f $(RENDERTMP)/lfs*.xml
120 $(Q)rm -f $(RENDERTMP)/*wget*
121 $(Q)rm -f $(RENDERTMP)/*md5sum*
122 $(Q)rm -f $(RENDERTMP)/*pdf.fo
124 validate: tmpdir
125 @echo "Processing bootscripts..."
126 $(Q)bash process-scripts.sh
128 @echo "Adjusting for revision $(REV)..."
129 $(Q)xsltproc --nonet \
130 --xinclude \
131 --output $(RENDERTMP)/lfs-html2.xml \
132 --stringparam profile.revision $(REV) \
133 stylesheets/lfs-xsl/profile.xsl \
134 index.xml
136 @echo "Validating the book..."
137 $(Q)xmllint --nonet \
138 --noent \
139 --postvalid \
140 -o $(RENDERTMP)/lfs-full.xml \
141 $(RENDERTMP)/lfs-html2.xml
143 $(Q)rm -f appendices/*.script
144 $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
145 @echo "Validation complete."
147 profile-html:
148 @echo "Generating profiled XML for XHTML..."
149 $(Q)xsltproc --nonet \
150 --stringparam profile.condition html \
151 --output $(RENDERTMP)/lfs-html.xml \
152 stylesheets/lfs-xsl/profile.xsl \
153 $(RENDERTMP)/lfs-full.xml
155 wget-list: $(BASEDIR)/wget-list
156 $(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml \
157 packages.ent patches.ent
158 @echo "Generating consolidated wget list at $(BASEDIR)/wget-list ..."
159 $(Q)mkdir -p $(BASEDIR)
161 # $(Q)xsltproc --nonet --xinclude \
162 # --stringparam profile.revision $(REV) \
163 # --output $(RENDERTMP)/sysd-wget.xml \
164 # stylesheets/lfs-xsl/profile.xsl \
165 # chapter03/chapter03.xml
167 $(Q)xsltproc --xinclude --nonet \
168 --output $(BASEDIR)/wget-list \
169 stylesheets/wget-list.xsl \
170 chapter03/chapter03.xml
172 md5sums: $(BASEDIR)/md5sums
173 $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml \
174 packages.ent patches.ent
175 @echo "Generating consolidated md5sum file at $(BASEDIR)/md5sums ..."
176 $(Q)mkdir -p $(BASEDIR)
178 $(Q)xsltproc --nonet --xinclude \
179 --stringparam profile.revision $(REV) \
180 --output $(RENDERTMP)/sysv-md5sum.xml \
181 stylesheets/lfs-xsl/profile.xsl \
182 chapter03/chapter03.xml
184 $(Q)xsltproc --xinclude --nonet \
185 --output $(BASEDIR)/md5sums \
186 stylesheets/md5sum.xsl \
187 $(RENDERTMP)/sysv-md5sum.xml
188 $(Q)sed -i -e \
189 "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.bz2 | cut -d' ' -f1)/" \
190 $(BASEDIR)/md5sums
192 dump-commands: validate
193 @echo "Dumping book commands..."
194 # $(Q)xsltproc --nonet \
195 # --output $(RENDERTMP)/lfs-html.xml \
196 # --stringparam profile.revision $(REV) \
197 # stylesheets/lfs-xsl/profile.xsl \
198 # $(RENDERTMP)/lfs-full.xml
200 $(Q)rm -rf $(DUMPDIR)
202 $(Q)xsltproc --output $(DUMPDIR)/ \
203 stylesheets/dump-commands.xsl \
204 $(RENDERTMP)/lfs-html.xml
205 @echo "Dumping book commands complete in $(DUMPDIR)"
207 all: book nochunks pdf dump-commands
209 .PHONY : all book dump-commands nochunks pdf profile-html tmpdir validate md5sums wget-list