source: Makefile

trunk
Last change on this file was 820b6d7, checked in by Thomas Trepl (Moody) <thomas@…>, 3 weeks ago

Add an initial version of a 'help' target

  • Property mode set to 100644
File size: 10.3 KB
Line 
1# Makefile for BLFS Book generation.
2# By Tushar Teredesai <tushar@linuxfromscratch.org>
3# 2004-01-31
4
5# Adjust these to suit your installation
6RENDERTMP ?= $(HOME)/tmp
7CHUNK_QUIET = 1
8ROOT_ID =
9SHELL = /bin/bash
10
11ALLXML := $(filter-out $(RENDERTMP)/%, \
12 $(wildcard *.xml */*.xml */*/*.xml */*/*/*.xml */*/*/*/*.xml))
13ALLXSL := $(filter-out $(RENDERTMP)/%, \
14 $(wildcard *.xsl */*.xsl */*/*.xsl */*/*/*.xsl */*/*/*/*.xsl))
15
16ifdef V
17 Q =
18else
19 Q = @
20endif
21
22ifndef REV
23 REV = sysv
24endif
25
26ifneq ($(REV), sysv)
27 ifneq ($(REV), systemd)
28 $(error REV must be 'sysv' (default) or 'systemd'.)
29 endif
30endif
31
32ifeq ($(REV), sysv)
33 BASEDIR ?= $(HOME)/public_html/blfs-book
34 NOCHUNKS_OUTPUT ?= blfs-book.html
35 DUMPDIR ?= ~/blfs-commands
36 BLFSHTML ?= blfs-html.xml
37 BLFSHTML2 ?= blfs-html2.xml
38 BLFSFULL ?= blfs-full.xml
39else
40 BASEDIR ?= $(HOME)/public_html/blfs-systemd
41 NOCHUNKS_OUTPUT ?= blfs-sysd-book.html
42 DUMPDIR ?= ~/blfs-sysd-commands
43 BLFSHTML ?= blfs-systemd-html.xml
44 BLFSHTML2 ?= blfs-systemd-html2.xml
45 BLFSFULL ?= blfs-systemd-full.xml
46
47endif
48
49
50blfs: html wget-list
51
52help:
53 @echo ""
54 @echo "make <parameters> <targets>"
55 @echo ""
56 @echo "Parameters:"
57 @echo " REV=<rev> Build variation of book"
58 @echo " Valid values for REV are:"
59 @echo " * sysv - Build book for SysV"
60 @echo " * systemd - Build book for systemd"
61 @echo " Defaults to 'sysv'"
62 @echo ""
63 @echo " BASEDIR=<dir> Put the output in directory <dir>."
64 @echo " Defaults to"
65 @echo " 'HOME/public_html/blfs-book' if REV=sysv (or unset)"
66 @echo " or to"
67 @echo " 'HOME/public_html/blfs-book-systemd' if REV=systemd"
68 @echo ""
69 @echo " V=<val> If <val> is a non-empty value, all"
70 @echo " steps to produce the output is shown."
71 @echo " Default is unset."
72 @echo ""
73 @echo "Targets:"
74 @echo " help Show this help text."
75 @echo ""
76 @echo " blfs Builds targets 'html' and 'wget-list'."
77 @echo ""
78 @echo " html Builds the HTML pages of the book."
79 @echo ""
80 @echo " wget-list Produces a list of all packages to download."
81 @echo " Output is BASEDIR/wget-list"
82 @echo ""
83 @echo " nochunks Builds the book as a one-pager. The output"
84 @echo " is a large single HTML page containing the"
85 @echo " whole book."
86 @echo ""
87 @echo " Parameter NOCHUNKS_OUTPUT=<filename> controls"
88 @echo " the name of the HTML file."
89 @echo ""
90 @echo " validate Runs validation checks on the XML files."
91 @echo ""
92 @echo " test-links Runs validation checks on URLs in the book."
93 @echo " Produces a file named BASEDIR/bad_urls containing"
94 @echo " URLS which are invalid and a BASEDIR/good_urls"
95 @echo " containing all valid URLs."
96 @echo ""
97
98all: blfs nochunks
99world: all blfs-patch-list dump-commands test-links
100
101html: $(BASEDIR)/index.html
102$(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML) version
103 @echo "Generating chunked XHTML files..."
104 $(Q)xsltproc --nonet \
105 --stringparam chunk.quietly $(CHUNK_QUIET) \
106 --stringparam rootid "$(ROOT_ID)" \
107 --stringparam base.dir $(BASEDIR)/ \
108 stylesheets/blfs-chunked.xsl \
109 $(RENDERTMP)/$(BLFSHTML)
110
111 @echo "Copying CSS code and images..."
112 $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
113 mkdir -p $(BASEDIR)/stylesheets; \
114 fi;
115
116 $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
117
118 $(Q)if [ ! -e $(BASEDIR)/images ]; then \
119 mkdir -p $(BASEDIR)/images; \
120 fi;
121 $(Q)cp images/*.png $(BASEDIR)/images
122
123 $(Q)cd $(BASEDIR)/; sed -e "s@../images@images@g" \
124 -i *.html
125
126 @echo "Running Tidy and obfuscate.sh on chunked XHTML..."
127 $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
128 tidy -config tidy.conf $$filename; \
129 true; \
130 bash obfuscate.sh $$filename; \
131 sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
132 done;
133
134nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
135$(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML) version
136 @echo "Generating non-chunked XHTML file..."
137 $(Q)xsltproc --nonet \
138 --stringparam rootid "$(ROOT_ID)" \
139 --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
140 stylesheets/blfs-nochunks.xsl \
141 $(RENDERTMP)/$(BLFSHTML)
142
143 @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
144 $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
145 $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
146 $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
147
148tmpdir: $(RENDERTMP)
149$(RENDERTMP):
150 @echo "Creating $(RENDERTMP)"
151 $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
152
153clean:
154 @echo "Cleaning $(RENDERTMP)"
155 $(Q)rm -f $(RENDERTMP)/blfs*
156
157validate: $(RENDERTMP)/$(BLFSFULL)
158$(RENDERTMP)/$(BLFSFULL): general.ent packages.ent $(ALLXML) $(ALLXSL) version
159 $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
160
161 @echo "Adjusting for revision $(REV)..."
162 $(Q)xsltproc --nonet \
163 --xinclude \
164 --output $(RENDERTMP)/$(BLFSHTML2) \
165 --stringparam profile.revision $(REV) \
166 stylesheets/lfs-xsl/profile.xsl \
167 index.xml
168
169 @echo "Validating the book..."
170 $(Q)xmllint --nonet \
171 --noent \
172 --postvalid \
173 --output $(RENDERTMP)/$(BLFSFULL) \
174 $(RENDERTMP)/$(BLFSHTML2)
175
176profile-html: $(RENDERTMP)/$(BLFSHTML)
177$(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL) version
178 @echo "Generating profiled XML for XHTML..."
179 $(Q)xsltproc --nonet \
180 --stringparam profile.condition html \
181 --output $(RENDERTMP)/$(BLFSHTML) \
182 stylesheets/lfs-xsl/profile.xsl \
183 $(RENDERTMP)/$(BLFSFULL)
184
185blfs-patch-list: blfs-patches.sh
186 @echo "Generating blfs patch list..."
187 $(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
188 blfs-patches.sh > blfs-patch-list
189
190blfs-patches.sh: $(RENDERTMP)/$(BLFSFULL) version
191 @echo "Generating blfs patch script..."
192 $(Q)xsltproc --nonet \
193 --output blfs-patches.sh \
194 stylesheets/patcheslist.xsl \
195 $(RENDERTMP)/$(BLFSFULL)
196
197wget-list: $(BASEDIR)/wget-list
198$(BASEDIR)/wget-list: $(RENDERTMP)/$(BLFSFULL) version
199 @echo "Generating wget list for $(REV) at $(BASEDIR)/wget-list ..."
200 $(Q)mkdir -p $(BASEDIR)
201 $(Q)xsltproc --nonet \
202 --output $(BASEDIR)/wget-list \
203 stylesheets/wget-list.xsl \
204 $(RENDERTMP)/$(BLFSFULL)
205
206test-links: $(BASEDIR)/test-links
207$(BASEDIR)/test-links: $(RENDERTMP)/$(BLFSFULL) version
208 @echo "Generating test-links file..."
209 $(Q)mkdir -p $(BASEDIR)
210 $(Q)xsltproc --nonet \
211 --stringparam list_mode full \
212 --output $(BASEDIR)/test-links \
213 stylesheets/wget-list.xsl \
214 $(RENDERTMP)/$(BLFSFULL)
215
216 @echo "Checking URLs, first pass..."
217 $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
218 $(Q)for URL in `cat $(BASEDIR)/test-links`; do \
219 wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
220 if test $$? -ne 0 ; then \
221 echo $$URL >> $(BASEDIR)/bad_urls ; \
222 else \
223 echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
224 fi; \
225 done
226
227 @echo "Checking URLs, second pass..."
228 $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
229 wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
230 if test $$? -ne 0 ; then \
231 echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
232 else \
233 echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
234 fi; \
235 done
236
237bootscripts:
238 @VERSION=`grep "bootscripts-version " general.ent | cut -d\" -f2`; \
239 BOOTSCRIPTS="blfs-bootscripts-$$VERSION"; \
240 if [ ! -e $$BOOTSCRIPTS.tar.xz ]; then \
241 rm -rf $(RENDERTMP)/$$BOOTSCRIPTS; \
242 mkdir $(RENDERTMP)/$$BOOTSCRIPTS; \
243 cp -a ../bootscripts/* $(RENDERTMP)/$$BOOTSCRIPTS; \
244 rm -rf ../bootscripts/archive; \
245 tar -cJhf $$BOOTSCRIPTS.tar.xz -C $(RENDERTMP) $$BOOTSCRIPTS; \
246 fi
247
248systemd-units:
249 @VERSION=`grep "systemd-units-version " general.ent | cut -d\" -f2`; \
250 UNITS="blfs-systemd-units-$$VERSION"; \
251 if [ ! -e $$UNITS.tar.xz ]; then \
252 rm -rf $(RENDERTMP)/$$UNITS; \
253 mkdir $(RENDERTMP)/$$UNITS; \
254 cp -a ../systemd-units/* $(RENDERTMP)/$$UNITS; \
255 tar -cJhf $$UNITS.tar.xz -C $(RENDERTMP) $$UNITS; \
256 fi
257
258dump-commands: $(DUMPDIR)
259$(DUMPDIR): $(RENDERTMP)/$(BLFSFULL) version
260 @echo "Dumping book commands..."
261 $(Q)xsltproc --output $(DUMPDIR)/ \
262 stylesheets/dump-commands.xsl \
263 $(RENDERTMP)/$(BLFSFULL)
264 $(Q)touch $(DUMPDIR)
265
266.PHONY: blfs all world html nochunks tmpdir clean \
267 validate profile-html blfs-patch-list wget-list test-links \
268 dump-commands bootscripts systemd-units version
269
270version:
271 $(Q)./git-version.sh
Note: See TracBrowser for help on using the repository browser.