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
RevLine 
[19599c63]1# Makefile for BLFS Book generation.
2# By Tushar Teredesai <tushar@linuxfromscratch.org>
3# 2004-01-31
[35d9770]4
[19599c63]5# Adjust these to suit your installation
[efe19ba]6RENDERTMP ?= $(HOME)/tmp
7CHUNK_QUIET = 1
8ROOT_ID =
9SHELL = /bin/bash
[35d9770]10
[6328b89]11ALLXML := $(filter-out $(RENDERTMP)/%, \
12 $(wildcard *.xml */*.xml */*/*.xml */*/*/*.xml */*/*/*/*.xml))
13ALLXSL := $(filter-out $(RENDERTMP)/%, \
14 $(wildcard *.xsl */*.xsl */*/*.xsl */*/*/*.xsl */*/*/*/*.xsl))
15
[35d9770]16ifdef V
17 Q =
18else
19 Q = @
20endif
21
[efe19ba]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
[f852e706]36 BLFSHTML ?= blfs-html.xml
37 BLFSHTML2 ?= blfs-html2.xml
38 BLFSFULL ?= blfs-full.xml
[efe19ba]39else
40 BASEDIR ?= $(HOME)/public_html/blfs-systemd
41 NOCHUNKS_OUTPUT ?= blfs-sysd-book.html
42 DUMPDIR ?= ~/blfs-sysd-commands
[f852e706]43 BLFSHTML ?= blfs-systemd-html.xml
44 BLFSHTML2 ?= blfs-systemd-html2.xml
45 BLFSFULL ?= blfs-systemd-full.xml
46
[efe19ba]47endif
48
49
[575bba80]50blfs: html wget-list
[efe19ba]51
[820b6d7]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
[f5ee8c2]98all: blfs nochunks
[575bba80]99world: all blfs-patch-list dump-commands test-links
100
101html: $(BASEDIR)/index.html
[17c9da8]102$(BASEDIR)/index.html: $(RENDERTMP)/$(BLFSHTML) version
[35d9770]103 @echo "Generating chunked XHTML files..."
[efe19ba]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 \
[f852e706]109 $(RENDERTMP)/$(BLFSHTML)
[35d9770]110
111 @echo "Copying CSS code and images..."
112 $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
[efe19ba]113 mkdir -p $(BASEDIR)/stylesheets; \
114 fi;
115
[35d9770]116 $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
[efe19ba]117
[35d9770]118 $(Q)if [ ! -e $(BASEDIR)/images ]; then \
[efe19ba]119 mkdir -p $(BASEDIR)/images; \
120 fi;
[35d9770]121 $(Q)cp images/*.png $(BASEDIR)/images
[efe19ba]122
[869909a]123 $(Q)cd $(BASEDIR)/; sed -e "s@../images@images@g" \
[efe19ba]124 -i *.html
[4a02298]125
[5d463a51]126 @echo "Running Tidy and obfuscate.sh on chunked XHTML..."
[efe19ba]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;
[6d3005f]133
[575bba80]134nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
[17c9da8]135$(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/$(BLFSHTML) version
[5d463a51]136 @echo "Generating non-chunked XHTML file..."
[efe19ba]137 $(Q)xsltproc --nonet \
138 --stringparam rootid "$(ROOT_ID)" \
139 --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
140 stylesheets/blfs-nochunks.xsl \
[f852e706]141 $(RENDERTMP)/$(BLFSHTML)
[35d9770]142
[5d463a51]143 @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
[35d9770]144 $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
[7ba7636]145 $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
[efe19ba]146 $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
[35d9770]147
[575bba80]148tmpdir: $(RENDERTMP)
149$(RENDERTMP):
150 @echo "Creating $(RENDERTMP)"
[adf0149]151 $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
[575bba80]152
153clean:
154 @echo "Cleaning $(RENDERTMP)"
[f852e706]155 $(Q)rm -f $(RENDERTMP)/blfs*
[8e2f3658]156
[f852e706]157validate: $(RENDERTMP)/$(BLFSFULL)
[17c9da8]158$(RENDERTMP)/$(BLFSFULL): general.ent packages.ent $(ALLXML) $(ALLXSL) version
[575bba80]159 $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
[efe19ba]160
161 @echo "Adjusting for revision $(REV)..."
162 $(Q)xsltproc --nonet \
163 --xinclude \
[f852e706]164 --output $(RENDERTMP)/$(BLFSHTML2) \
[efe19ba]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 \
[f852e706]173 --output $(RENDERTMP)/$(BLFSFULL) \
174 $(RENDERTMP)/$(BLFSHTML2)
[35d9770]175
[f852e706]176profile-html: $(RENDERTMP)/$(BLFSHTML)
[17c9da8]177$(RENDERTMP)/$(BLFSHTML): $(RENDERTMP)/$(BLFSFULL) version
[35d9770]178 @echo "Generating profiled XML for XHTML..."
[efe19ba]179 $(Q)xsltproc --nonet \
180 --stringparam profile.condition html \
[f852e706]181 --output $(RENDERTMP)/$(BLFSHTML) \
[efe19ba]182 stylesheets/lfs-xsl/profile.xsl \
[f852e706]183 $(RENDERTMP)/$(BLFSFULL)
[35d9770]184
[0238e7e]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
[17c9da8]190blfs-patches.sh: $(RENDERTMP)/$(BLFSFULL) version
[0238e7e]191 @echo "Generating blfs patch script..."
[efe19ba]192 $(Q)xsltproc --nonet \
193 --output blfs-patches.sh \
194 stylesheets/patcheslist.xsl \
[f852e706]195 $(RENDERTMP)/$(BLFSFULL)
[35d9770]196
[575bba80]197wget-list: $(BASEDIR)/wget-list
[17c9da8]198$(BASEDIR)/wget-list: $(RENDERTMP)/$(BLFSFULL) version
[efe19ba]199 @echo "Generating wget list for $(REV) at $(BASEDIR)/wget-list ..."
[35d9770]200 $(Q)mkdir -p $(BASEDIR)
[efe19ba]201 $(Q)xsltproc --nonet \
202 --output $(BASEDIR)/wget-list \
203 stylesheets/wget-list.xsl \
[f852e706]204 $(RENDERTMP)/$(BLFSFULL)
[35d9770]205
[cb55412]206test-links: $(BASEDIR)/test-links
[17c9da8]207$(BASEDIR)/test-links: $(RENDERTMP)/$(BLFSFULL) version
[35d9770]208 @echo "Generating test-links file..."
209 $(Q)mkdir -p $(BASEDIR)
[efe19ba]210 $(Q)xsltproc --nonet \
211 --stringparam list_mode full \
212 --output $(BASEDIR)/test-links \
213 stylesheets/wget-list.xsl \
[f852e706]214 $(RENDERTMP)/$(BLFSFULL)
[35d9770]215
[cdd254a]216 @echo "Checking URLs, first pass..."
[35d9770]217 $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
[efe19ba]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
[35d9770]226
[cdd254a]227 @echo "Checking URLs, second pass..."
[efe19ba]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
[7818e780]236
[6d3005f]237bootscripts:
238 @VERSION=`grep "bootscripts-version " general.ent | cut -d\" -f2`; \
[efe19ba]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; \
[6d3005f]246 fi
247
[f852e706]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
[575bba80]258dump-commands: $(DUMPDIR)
[17c9da8]259$(DUMPDIR): $(RENDERTMP)/$(BLFSFULL) version
[35d9770]260 @echo "Dumping book commands..."
[efe19ba]261 $(Q)xsltproc --output $(DUMPDIR)/ \
262 stylesheets/dump-commands.xsl \
[f852e706]263 $(RENDERTMP)/$(BLFSFULL)
[575bba80]264 $(Q)touch $(DUMPDIR)
[35d9770]265
[efe19ba]266.PHONY: blfs all world html nochunks tmpdir clean \
267 validate profile-html blfs-patch-list wget-list test-links \
[17c9da8]268 dump-commands bootscripts systemd-units version
[6d3005f]269
[17c9da8]270version:
271 $(Q)./git-version.sh
Note: See TracBrowser for help on using the repository browser.