source: Makefile@ 17c9da8

trunk
Last change on this file since 17c9da8 was 17c9da8, checked in by Xi Ruoyao <xry111@…>, 4 months ago

generate version info from git

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