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 | else
|
---|
39 | BASEDIR ?= $(HOME)/public_html/blfs-systemd
|
---|
40 | NOCHUNKS_OUTPUT ?= blfs-sysd-book.html
|
---|
41 | DUMPDIR ?= ~/blfs-sysd-commands
|
---|
42 | endif
|
---|
43 |
|
---|
44 |
|
---|
45 | blfs: html wget-list
|
---|
46 |
|
---|
47 | all: blfs nochunks
|
---|
48 | world: all blfs-patch-list dump-commands test-links
|
---|
49 |
|
---|
50 | html: $(BASEDIR)/index.html
|
---|
51 | $(BASEDIR)/index.html: $(RENDERTMP)/blfs-html.xml
|
---|
52 | @echo "Generating chunked XHTML files..."
|
---|
53 | $(Q)xsltproc --nonet \
|
---|
54 | --stringparam chunk.quietly $(CHUNK_QUIET) \
|
---|
55 | --stringparam rootid "$(ROOT_ID)" \
|
---|
56 | --stringparam base.dir $(BASEDIR)/ \
|
---|
57 | stylesheets/blfs-chunked.xsl \
|
---|
58 | $(RENDERTMP)/blfs-html.xml
|
---|
59 |
|
---|
60 | @echo "Copying CSS code and images..."
|
---|
61 | $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
---|
62 | mkdir -p $(BASEDIR)/stylesheets; \
|
---|
63 | fi;
|
---|
64 |
|
---|
65 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
---|
66 |
|
---|
67 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
---|
68 | mkdir -p $(BASEDIR)/images; \
|
---|
69 | fi;
|
---|
70 | $(Q)cp images/*.png $(BASEDIR)/images
|
---|
71 |
|
---|
72 | $(Q)cd $(BASEDIR)/; sed -e "s@../stylesheets@stylesheets@g" \
|
---|
73 | -e "s@../images@images@g" \
|
---|
74 | -i *.html
|
---|
75 |
|
---|
76 | @echo "Running Tidy and obfuscate.sh on chunked XHTML..."
|
---|
77 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
---|
78 | tidy -config tidy.conf $$filename; \
|
---|
79 | true; \
|
---|
80 | bash obfuscate.sh $$filename; \
|
---|
81 | sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
---|
82 | done;
|
---|
83 |
|
---|
84 | nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
85 | $(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/blfs-html.xml
|
---|
86 | @echo "Generating non-chunked XHTML file..."
|
---|
87 | $(Q)xsltproc --nonet \
|
---|
88 | --stringparam rootid "$(ROOT_ID)" \
|
---|
89 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
---|
90 | stylesheets/blfs-nochunks.xsl \
|
---|
91 | $(RENDERTMP)/blfs-html.xml
|
---|
92 |
|
---|
93 | @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
|
---|
94 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
---|
95 | $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
96 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
97 |
|
---|
98 | tmpdir: $(RENDERTMP)
|
---|
99 | $(RENDERTMP):
|
---|
100 | @echo "Creating $(RENDERTMP)"
|
---|
101 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
102 |
|
---|
103 | clean:
|
---|
104 | @echo "Cleaning $(RENDERTMP)"
|
---|
105 | $(Q)rm -f $(RENDERTMP)/blfs-{full,html}.xml
|
---|
106 | $(Q)rm -f $(RENDERTMP)/blfs-{patch-list,patches}
|
---|
107 |
|
---|
108 | validate: $(RENDERTMP)/blfs-full.xml
|
---|
109 | $(RENDERTMP)/blfs-full.xml: general.ent $(ALLXML) $(ALLXSL)
|
---|
110 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
111 |
|
---|
112 | @echo "Adjusting for revision $(REV)..."
|
---|
113 | $(Q)xsltproc --nonet \
|
---|
114 | --xinclude \
|
---|
115 | --output $(RENDERTMP)/blfs-html2.xml \
|
---|
116 | --stringparam profile.revision $(REV) \
|
---|
117 | stylesheets/lfs-xsl/profile.xsl \
|
---|
118 | index.xml
|
---|
119 |
|
---|
120 | @echo "Validating the book..."
|
---|
121 | $(Q)xmllint --nonet \
|
---|
122 | --noent \
|
---|
123 | --postvalid \
|
---|
124 | --output $(RENDERTMP)/blfs-full.xml \
|
---|
125 | $(RENDERTMP)/blfs-html2.xml
|
---|
126 |
|
---|
127 | profile-html: $(RENDERTMP)/blfs-html.xml
|
---|
128 | $(RENDERTMP)/blfs-html.xml: $(RENDERTMP)/blfs-full.xml
|
---|
129 | @echo "Generating profiled XML for XHTML..."
|
---|
130 | $(Q)xsltproc --nonet \
|
---|
131 | --stringparam profile.condition html \
|
---|
132 | --output $(RENDERTMP)/blfs-html.xml \
|
---|
133 | stylesheets/lfs-xsl/profile.xsl \
|
---|
134 | $(RENDERTMP)/blfs-full.xml
|
---|
135 |
|
---|
136 | blfs-patch-list: blfs-patches.sh
|
---|
137 | @echo "Generating blfs patch list..."
|
---|
138 | $(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
|
---|
139 | blfs-patches.sh > blfs-patch-list
|
---|
140 |
|
---|
141 | blfs-patches.sh: $(RENDERTMP)/blfs-full.xml
|
---|
142 | @echo "Generating blfs patch script..."
|
---|
143 | $(Q)xsltproc --nonet \
|
---|
144 | --output blfs-patches.sh \
|
---|
145 | stylesheets/patcheslist.xsl \
|
---|
146 | $(RENDERTMP)/blfs-full.xml
|
---|
147 |
|
---|
148 | wget-list: $(BASEDIR)/wget-list
|
---|
149 | $(BASEDIR)/wget-list: $(RENDERTMP)/blfs-full.xml
|
---|
150 | @echo "Generating wget list for $(REV) at $(BASEDIR)/wget-list ..."
|
---|
151 | $(Q)mkdir -p $(BASEDIR)
|
---|
152 | $(Q)xsltproc --nonet \
|
---|
153 | --output $(BASEDIR)/wget-list \
|
---|
154 | stylesheets/wget-list.xsl \
|
---|
155 | $(RENDERTMP)/blfs-full.xml
|
---|
156 |
|
---|
157 | test-links: $(BASEDIR)/test-links
|
---|
158 | $(BASEDIR)/test-links: $(RENDERTMP)/blfs-full.xml
|
---|
159 | @echo "Generating test-links file..."
|
---|
160 | $(Q)mkdir -p $(BASEDIR)
|
---|
161 | $(Q)xsltproc --nonet \
|
---|
162 | --stringparam list_mode full \
|
---|
163 | --output $(BASEDIR)/test-links \
|
---|
164 | stylesheets/wget-list.xsl \
|
---|
165 | $(RENDERTMP)/blfs-full.xml
|
---|
166 |
|
---|
167 | @echo "Checking URLs, first pass..."
|
---|
168 | $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
|
---|
169 | $(Q)for URL in `cat $(BASEDIR)/test-links`; do \
|
---|
170 | wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
|
---|
171 | if test $$? -ne 0 ; then \
|
---|
172 | echo $$URL >> $(BASEDIR)/bad_urls ; \
|
---|
173 | else \
|
---|
174 | echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
|
---|
175 | fi; \
|
---|
176 | done
|
---|
177 |
|
---|
178 | @echo "Checking URLs, second pass..."
|
---|
179 | $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
|
---|
180 | wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
|
---|
181 | if test $$? -ne 0 ; then \
|
---|
182 | echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
|
---|
183 | else \
|
---|
184 | echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
|
---|
185 | fi; \
|
---|
186 | done
|
---|
187 |
|
---|
188 | bootscripts:
|
---|
189 | @VERSION=`grep "bootscripts-version " general.ent | cut -d\" -f2`; \
|
---|
190 | BOOTSCRIPTS="blfs-bootscripts-$$VERSION"; \
|
---|
191 | if [ ! -e $$BOOTSCRIPTS.tar.xz ]; then \
|
---|
192 | rm -rf $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
193 | mkdir $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
194 | cp -a ../bootscripts/* $(RENDERTMP)/$$BOOTSCRIPTS; \
|
---|
195 | rm -rf ../bootscripts/archive; \
|
---|
196 | tar -cJhf $$BOOTSCRIPTS.tar.xz -C $(RENDERTMP) $$BOOTSCRIPTS; \
|
---|
197 | fi
|
---|
198 |
|
---|
199 | dump-commands: $(DUMPDIR)
|
---|
200 | $(DUMPDIR): $(RENDERTMP)/blfs-full.xml
|
---|
201 | @echo "Dumping book commands..."
|
---|
202 | $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
203 | stylesheets/dump-commands.xsl \
|
---|
204 | $(RENDERTMP)/blfs-full.xml
|
---|
205 | $(Q)touch $(DUMPDIR)
|
---|
206 |
|
---|
207 | .PHONY: blfs all world html nochunks tmpdir clean \
|
---|
208 | validate profile-html blfs-patch-list wget-list test-links \
|
---|
209 | dump-commands bootscripts
|
---|
210 |
|
---|
211 |
|
---|