1 | # Makefile for BLFS Book generation.
|
---|
2 | # By Tushar Teredesai <tushar@linuxfromscratch.org>
|
---|
3 | # 2004-01-31
|
---|
4 | # $LastChangedBy$
|
---|
5 | # $Date$
|
---|
6 |
|
---|
7 | # Adjust these to suit your installation
|
---|
8 | RENDERTMP ?= $(HOME)/tmp
|
---|
9 | CHUNK_QUIET = 1
|
---|
10 | ROOT_ID =
|
---|
11 | SHELL = /bin/bash
|
---|
12 |
|
---|
13 | ALLXML := $(filter-out $(RENDERTMP)/%, \
|
---|
14 | $(wildcard *.xml */*.xml */*/*.xml */*/*/*.xml */*/*/*/*.xml))
|
---|
15 | ALLXSL := $(filter-out $(RENDERTMP)/%, \
|
---|
16 | $(wildcard *.xsl */*.xsl */*/*.xsl */*/*/*.xsl */*/*/*/*.xsl))
|
---|
17 |
|
---|
18 | ifdef V
|
---|
19 | Q =
|
---|
20 | else
|
---|
21 | Q = @
|
---|
22 | endif
|
---|
23 |
|
---|
24 | ifndef REV
|
---|
25 | REV = sysv
|
---|
26 | endif
|
---|
27 |
|
---|
28 | ifneq ($(REV), sysv)
|
---|
29 | ifneq ($(REV), systemd)
|
---|
30 | $(error REV must be 'sysv' (default) or 'systemd'.)
|
---|
31 | endif
|
---|
32 | endif
|
---|
33 |
|
---|
34 | ifeq ($(REV), sysv)
|
---|
35 | BASEDIR ?= $(HOME)/public_html/blfs-book
|
---|
36 | NOCHUNKS_OUTPUT ?= blfs-book.html
|
---|
37 | DUMPDIR ?= ~/blfs-commands
|
---|
38 | BLFSHTML ?= blfs-html.xml
|
---|
39 | BLFSHTML2 ?= blfs-html2.xml
|
---|
40 | BLFSFULL ?= blfs-full.xml
|
---|
41 | else
|
---|
42 | BASEDIR ?= $(HOME)/public_html/blfs-systemd
|
---|
43 | NOCHUNKS_OUTPUT ?= blfs-sysd-book.html
|
---|
44 | DUMPDIR ?= ~/blfs-sysd-commands
|
---|
45 | BLFSHTML ?= blfs-systemd-html.xml
|
---|
46 | BLFSHTML2 ?= blfs-systemd-html2.xml
|
---|
47 | BLFSFULL ?= blfs-systemd-full.xml
|
---|
48 |
|
---|
49 | endif
|
---|
50 |
|
---|
51 |
|
---|
52 | blfs: html wget-list
|
---|
53 |
|
---|
54 | all: blfs nochunks
|
---|
55 | world: all blfs-patch-list dump-commands test-links
|
---|
56 |
|
---|
57 | html: $(BASEDIR)/index.html
|
---|
58 | $(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML)
|
---|
59 | @echo "Generating chunked XHTML files..."
|
---|
60 | $(Q)xsltproc --nonet \
|
---|
61 | --stringparam chunk.quietly $(CHUNK_QUIET) \
|
---|
62 | --stringparam rootid "$(ROOT_ID)" \
|
---|
63 | --stringparam base.dir $(BASEDIR)/ \
|
---|
64 | stylesheets/blfs-chunked.xsl \
|
---|
65 | $(RENDERTMP)/$(BLFSHTML)
|
---|
66 |
|
---|
67 | @echo "Copying CSS code and images..."
|
---|
68 | $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
---|
69 | mkdir -p $(BASEDIR)/stylesheets; \
|
---|
70 | fi;
|
---|
71 |
|
---|
72 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
---|
73 |
|
---|
74 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
---|
75 | mkdir -p $(BASEDIR)/images; \
|
---|
76 | fi;
|
---|
77 | $(Q)cp images/*.png $(BASEDIR)/images
|
---|
78 |
|
---|
79 | $(Q)cd $(BASEDIR)/; sed -e "s@../stylesheets@stylesheets@g" \
|
---|
80 | -e "s@../images@images@g" \
|
---|
81 | -i *.html
|
---|
82 |
|
---|
83 | @echo "Running Tidy and obfuscate.sh on chunked XHTML..."
|
---|
84 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
---|
85 | tidy -config tidy.conf $$filename; \
|
---|
86 | true; \
|
---|
87 | bash obfuscate.sh $$filename; \
|
---|
88 | sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
---|
89 | done;
|
---|
90 |
|
---|
91 | nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
92 | $(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML)
|
---|
93 | @echo "Generating non-chunked XHTML file..."
|
---|
94 | $(Q)xsltproc --nonet \
|
---|
95 | --stringparam rootid "$(ROOT_ID)" \
|
---|
96 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
---|
97 | stylesheets/blfs-nochunks.xsl \
|
---|
98 | $(RENDERTMP)/$(BLFSHTML)
|
---|
99 |
|
---|
100 | @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
|
---|
101 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
---|
102 | $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
103 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
104 |
|
---|
105 | tmpdir: $(RENDERTMP)
|
---|
106 | $(RENDERTMP):
|
---|
107 | @echo "Creating $(RENDERTMP)"
|
---|
108 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
109 |
|
---|
110 | clean:
|
---|
111 | @echo "Cleaning $(RENDERTMP)"
|
---|
112 | $(Q)rm -f $(RENDERTMP)/blfs*
|
---|
113 |
|
---|
114 | validate: $(RENDERTMP)/$(BLFSFULL)
|
---|
115 | $(RENDERTMP)/$(BLFSFULL): general.ent $(ALLXML) $(ALLXSL)
|
---|
116 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
117 |
|
---|
118 | @echo "Adjusting for revision $(REV)..."
|
---|
119 | $(Q)xsltproc --nonet \
|
---|
120 | --xinclude \
|
---|
121 | --output $(RENDERTMP)/$(BLFSHTML2) \
|
---|
122 | --stringparam profile.revision $(REV) \
|
---|
123 | stylesheets/lfs-xsl/profile.xsl \
|
---|
124 | index.xml
|
---|
125 |
|
---|
126 | @echo "Validating the book..."
|
---|
127 | $(Q)xmllint --nonet \
|
---|
128 | --noent \
|
---|
129 | --postvalid \
|
---|
130 | --output $(RENDERTMP)/$(BLFSFULL) \
|
---|
131 | $(RENDERTMP)/$(BLFSHTML2)
|
---|
132 |
|
---|
133 | profile-html: $(RENDERTMP)/$(BLFSHTML)
|
---|
134 | $(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL)
|
---|
135 | @echo "Generating profiled XML for XHTML..."
|
---|
136 | $(Q)xsltproc --nonet \
|
---|
137 | --stringparam profile.condition html \
|
---|
138 | --output $(RENDERTMP)/$(BLFSHTML) \
|
---|
139 | stylesheets/lfs-xsl/profile.xsl \
|
---|
140 | $(RENDERTMP)/$(BLFSFULL)
|
---|
141 |
|
---|
142 | blfs-patch-list: blfs-patches.sh
|
---|
143 | @echo "Generating blfs patch list..."
|
---|
144 | $(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
|
---|
145 | blfs-patches.sh > blfs-patch-list
|
---|
146 |
|
---|
147 | blfs-patches.sh: $(RENDERTMP)/$(BLFSFULL)
|
---|
148 | @echo "Generating blfs patch script..."
|
---|
149 | $(Q)xsltproc --nonet \
|
---|
150 | --output blfs-patches.sh \
|
---|
151 | stylesheets/patcheslist.xsl \
|
---|
152 | $(RENDERTMP)/$(BLFSFULL)
|
---|
153 |
|
---|
154 | wget-list: $(BASEDIR)/wget-list
|
---|
155 | $(BASEDIR)/wget-list: $(RENDERTMP)/$(BLFSFULL)
|
---|
156 | @echo "Generating wget list for $(REV) at $(BASEDIR)/wget-list ..."
|
---|
157 | $(Q)mkdir -p $(BASEDIR)
|
---|
158 | $(Q)xsltproc --nonet \
|
---|
159 | --output $(BASEDIR)/wget-list \
|
---|
160 | stylesheets/wget-list.xsl \
|
---|
161 | $(RENDERTMP)/$(BLFSFULL)
|
---|
162 |
|
---|
163 | test-links: $(BASEDIR)/test-links
|
---|
164 | $(BASEDIR)/test-links: $(RENDERTMP)/$(BLFSFULL)
|
---|
165 | @echo "Generating test-links file..."
|
---|
166 | $(Q)mkdir -p $(BASEDIR)
|
---|
167 | $(Q)xsltproc --nonet \
|
---|
168 | --stringparam list_mode full \
|
---|
169 | --output $(BASEDIR)/test-links \
|
---|
170 | stylesheets/wget-list.xsl \
|
---|
171 | $(RENDERTMP)/$(BLFSFULL)
|
---|
172 |
|
---|
173 | @echo "Checking URLs, first pass..."
|
---|
174 | $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
|
---|
175 | $(Q)for URL in `cat $(BASEDIR)/test-links`; do \
|
---|
176 | wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
|
---|
177 | if test $$? -ne 0 ; then \
|
---|
178 | echo $$URL >> $(BASEDIR)/bad_urls ; \
|
---|
179 | else \
|
---|
180 | echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
|
---|
181 | fi; \
|
---|
182 | done
|
---|
183 |
|
---|
184 | @echo "Checking URLs, second pass..."
|
---|
185 | $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
|
---|
186 | wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
|
---|
187 | if test $$? -ne 0 ; then \
|
---|
188 | echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
|
---|
189 | else \
|
---|
190 | echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
|
---|
191 | fi; \
|
---|
192 | done
|
---|
193 |
|
---|
194 | bootscripts:
|
---|
195 | @VERSION=`grep "bootscripts-version " general.ent | cut -d\" -f2`; \
|
---|
196 | BOOTSCRIPTS="blfs-bootscripts-$$VERSION"; \
|
---|
197 | if [ ! -e $$BOOTSCRIPTS.tar.xz ]; then \
|
---|
198 | rm -rf $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
199 | mkdir $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
200 | cp -a ../bootscripts/* $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
201 | rm -rf ../bootscripts/archive; \
|
---|
202 | tar -cJhf $$BOOTSCRIPTS.tar.xz -C $(RENDERTMP) $$BOOTSCRIPTS; \
|
---|
203 | fi
|
---|
204 |
|
---|
205 | systemd-units:
|
---|
206 | @VERSION=`grep "systemd-units-version " general.ent | cut -d\" -f2`; \
|
---|
207 | UNITS="blfs-systemd-units-$$VERSION"; \
|
---|
208 | if [ ! -e $$UNITS.tar.xz ]; then \
|
---|
209 | rm -rf $(RENDERTMP)/$$UNITS; \
|
---|
210 | mkdir $(RENDERTMP)/$$UNITS; \
|
---|
211 | cp -a ../systemd-units/* $(RENDERTMP)/$$UNITS; \
|
---|
212 | tar -cJhf $$UNITS.tar.xz -C $(RENDERTMP) $$UNITS; \
|
---|
213 | fi
|
---|
214 |
|
---|
215 | dump-commands: $(DUMPDIR)
|
---|
216 | $(DUMPDIR): $(RENDERTMP)/$(BLFSFULL)
|
---|
217 | @echo "Dumping book commands..."
|
---|
218 | $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
219 | stylesheets/dump-commands.xsl \
|
---|
220 | $(RENDERTMP)/$(BLFSFULL)
|
---|
221 | $(Q)touch $(DUMPDIR)
|
---|
222 |
|
---|
223 | .PHONY: blfs all world html nochunks tmpdir clean \
|
---|
224 | validate profile-html blfs-patch-list wget-list test-links \
|
---|
225 | dump-commands bootscripts systemd-units
|
---|
226 |
|
---|
227 |
|
---|