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
|
---|
6 | BASEDIR ?= $(HOME)/public_html/blfs-book-xsl
|
---|
7 | DUMPDIR ?= $(HOME)/blfs-commands
|
---|
8 | RENDERTMP ?= /tmp
|
---|
9 | CHUNK_QUIET = 1
|
---|
10 | ROOT_ID =
|
---|
11 | NOCHUNKS_OUTPUT = BLFS-BOOK.html
|
---|
12 | SHELL = /bin/sh
|
---|
13 |
|
---|
14 | ALLXML := $(filter-out $(RENDERTMP)/%, \
|
---|
15 | $(wildcard *.xml */*.xml */*/*.xml */*/*/*.xml */*/*/*/*.xml))
|
---|
16 | ALLXSL := $(filter-out $(RENDERTMP)/%, \
|
---|
17 | $(wildcard *.xsl */*.xsl */*/*.xsl */*/*/*.xsl */*/*/*/*.xsl))
|
---|
18 |
|
---|
19 | ifdef V
|
---|
20 | Q =
|
---|
21 | else
|
---|
22 | Q = @
|
---|
23 | endif
|
---|
24 |
|
---|
25 | blfs: html wget-list
|
---|
26 | all: blfs nochunks
|
---|
27 | world: all blfs-patch-list dump-commands test-links
|
---|
28 |
|
---|
29 | html: $(BASEDIR)/index.html
|
---|
30 | $(BASEDIR)/index.html: $(RENDERTMP)/blfs-html.xml
|
---|
31 | @echo "Generating chunked XHTML files..."
|
---|
32 | $(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
|
---|
33 | -stringparam rootid "$(ROOT_ID)" -stringparam base.dir $(BASEDIR)/ \
|
---|
34 | stylesheets/blfs-chunked.xsl $(RENDERTMP)/blfs-html.xml
|
---|
35 |
|
---|
36 | @echo "Copying CSS code and images..."
|
---|
37 | $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
---|
38 | mkdir -p $(BASEDIR)/stylesheets; \
|
---|
39 | fi;
|
---|
40 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
---|
41 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
---|
42 | mkdir -p $(BASEDIR)/images; \
|
---|
43 | fi;
|
---|
44 | $(Q)cp images/*.png $(BASEDIR)/images
|
---|
45 | $(Q)cd $(BASEDIR)/; sed -i -e "s@../stylesheets@stylesheets@g" *.html
|
---|
46 | $(Q)cd $(BASEDIR)/; sed -i -e "s@../images@images@g" *.html
|
---|
47 |
|
---|
48 | @echo "Running Tidy and obfuscate.sh on chunked XHTML..."
|
---|
49 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
---|
50 | tidy -config tidy.conf $$filename; \
|
---|
51 | true; \
|
---|
52 | sh obfuscate.sh $$filename; \
|
---|
53 | sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
---|
54 | done;
|
---|
55 |
|
---|
56 | nochunks: $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
57 | $(BASEDIR)/$(NOCHUNKS_OUTPUT): $(RENDERTMP)/blfs-html.xml
|
---|
58 | @echo "Generating non-chunked XHTML file..."
|
---|
59 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
60 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
---|
61 | stylesheets/blfs-nochunks.xsl $(RENDERTMP)/blfs-html.xml
|
---|
62 |
|
---|
63 | @echo "Running Tidy and obfuscate.sh on non-chunked XHTML..."
|
---|
64 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
---|
65 | $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
66 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \
|
---|
67 | $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
68 |
|
---|
69 | tmpdir: $(RENDERTMP)
|
---|
70 | $(RENDERTMP):
|
---|
71 | @echo "Creating $(RENDERTMP)"
|
---|
72 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
73 |
|
---|
74 | clean:
|
---|
75 | @echo "Cleaning $(RENDERTMP)"
|
---|
76 | $(Q)rm -f $(RENDERTMP)/blfs-{full,html}.xml
|
---|
77 | $(Q)rm -f $(RENDERTMP)/blfs-{patch-list,patches}
|
---|
78 | $(Q)rmdir $(RENDERTMP) 2>/dev/null || :
|
---|
79 |
|
---|
80 | validxml: $(RENDERTMP)/blfs-full.xml
|
---|
81 | $(RENDERTMP)/blfs-full.xml: general.ent $(ALLXML) $(ALLXSL)
|
---|
82 | @echo "Validating the book..."
|
---|
83 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
84 | $(Q)xmllint --nonet --noent --xinclude --postvalid \
|
---|
85 | -o $(RENDERTMP)/blfs-full.xml index.xml
|
---|
86 |
|
---|
87 | profile-html: $(RENDERTMP)/blfs-html.xml
|
---|
88 | $(RENDERTMP)/blfs-html.xml: $(RENDERTMP)/blfs-full.xml
|
---|
89 | @echo "Generating profiled XML for XHTML..."
|
---|
90 | $(Q)xsltproc --nonet --stringparam profile.condition html \
|
---|
91 | --output $(RENDERTMP)/blfs-html.xml stylesheets/lfs-xsl/profile.xsl \
|
---|
92 | $(RENDERTMP)/blfs-full.xml
|
---|
93 |
|
---|
94 | blfs-patch-list: blfs-patches.sh
|
---|
95 | @echo "Generating blfs patch list..."
|
---|
96 | $(Q)awk '{if ($$1 == "copy") {sub(/.*\//, "", $$2); print $$2}}' \
|
---|
97 | blfs-patches.sh > blfs-patch-list
|
---|
98 |
|
---|
99 | blfs-patches.sh: $(RENDERTMP)/blfs-full.xml
|
---|
100 | @echo "Generating blfs patch script..."
|
---|
101 | $(Q)xsltproc --nonet --output blfs-patches.sh \
|
---|
102 | stylesheets/patcheslist.xsl $(RENDERTMP)/blfs-full.xml
|
---|
103 |
|
---|
104 | wget-list: $(BASEDIR)/wget-list
|
---|
105 | $(BASEDIR)/wget-list: $(RENDERTMP)/blfs-full.xml
|
---|
106 | @echo "Generating wget list..."
|
---|
107 | $(Q)mkdir -p $(BASEDIR)
|
---|
108 | $(Q)xsltproc --nonet --output $(BASEDIR)/wget-list \
|
---|
109 | stylesheets/wget-list.xsl $(RENDERTMP)/blfs-full.xml
|
---|
110 |
|
---|
111 | test-links: $(BASEDIR)/test-links
|
---|
112 | $(BASEDIR)/test-links: $(RENDERTMP)/blfs-full.xml
|
---|
113 | @echo "Generating test-links file..."
|
---|
114 | $(Q)mkdir -p $(BASEDIR)
|
---|
115 | $(Q)xsltproc --nonet --stringparam list_mode full \
|
---|
116 | --output $(BASEDIR)/test-links stylesheets/wget-list.xsl \
|
---|
117 | $(RENDERTMP)/blfs-full.xml
|
---|
118 |
|
---|
119 | @echo "Checking URLs, first pass..."
|
---|
120 | $(Q)rm -f $(BASEDIR)/{good,bad,true_bad}_urls
|
---|
121 | $(Q)for URL in `cat $(BASEDIR)/test-links`; do \
|
---|
122 | wget --spider --tries=2 --timeout=60 $$URL >>/dev/null 2>&1; \
|
---|
123 | if test $$? -ne 0 ; then echo $$URL >> $(BASEDIR)/bad_urls ; \
|
---|
124 | else echo $$URL >> $(BASEDIR)/good_urls 2>&1; \
|
---|
125 | fi; \
|
---|
126 | done
|
---|
127 |
|
---|
128 | @echo "Checking URLs, second pass..."
|
---|
129 | $(Q)for URL2 in `cat $(BASEDIR)/bad_urls`; do \
|
---|
130 | wget --spider --tries=2 --timeout=60 $$URL2 >>/dev/null 2>&1; \
|
---|
131 | if test $$? -ne 0 ; then echo $$URL2 >> $(BASEDIR)/true_bad_urls ; \
|
---|
132 | else echo $$URL2 >> $(BASEDIR)/good_urls 2>&1; \
|
---|
133 | fi; \
|
---|
134 | done
|
---|
135 |
|
---|
136 | dump-commands: $(DUMPDIR)
|
---|
137 | $(DUMPDIR): $(RENDERTMP)/blfs-full.xml
|
---|
138 | @echo "Dumping book commands..."
|
---|
139 | $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
140 | stylesheets/dump-commands.xsl $(RENDERTMP)/blfs-full.xml
|
---|
141 | $(Q)touch $(DUMPDIR)
|
---|
142 |
|
---|
143 | validate:
|
---|
144 | @echo "Validating the book..."
|
---|
145 | $(Q)xmllint --noout --nonet --xinclude --postvalid index.xml
|
---|
146 |
|
---|
147 | .PHONY: blfs all world html nochunks tmpdir clean validxml \
|
---|
148 | profile-html wget-list test-links dump-commands validate
|
---|