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 | BASEDIR = $(HOME)/public_html/blfs-book-xsl
|
---|
9 | DUMPDIR = $(HOME)/blfs-commands
|
---|
10 | RENDERTMP = $(HOME)/tmp
|
---|
11 | CHUNK_QUIET = 1
|
---|
12 | ROOT_ID =
|
---|
13 | PDF_OUTPUT = BLFS-BOOK.pdf
|
---|
14 | NOCHUNKS_OUTPUT = BLFS-BOOK.html
|
---|
15 |
|
---|
16 | ifdef V
|
---|
17 | Q =
|
---|
18 | else
|
---|
19 | Q = @
|
---|
20 | endif
|
---|
21 |
|
---|
22 | blfs: validxml profile-html
|
---|
23 | @echo "Generating chunked XHTML files..."
|
---|
24 | $(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
|
---|
25 | -stringparam rootid "$(ROOT_ID)" -stringparam base.dir $(BASEDIR)/ \
|
---|
26 | stylesheets/blfs-chunked.xsl $(RENDERTMP)/blfs-html.xml
|
---|
27 |
|
---|
28 | @echo "Copying CSS code and images..."
|
---|
29 | $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
---|
30 | mkdir -p $(BASEDIR)/stylesheets; \
|
---|
31 | fi;
|
---|
32 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
---|
33 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
---|
34 | mkdir -p $(BASEDIR)/images; \
|
---|
35 | fi;
|
---|
36 | $(Q)cp images/*.png $(BASEDIR)/images
|
---|
37 | $(Q)cd $(BASEDIR)/; sed -i -e "s@../stylesheets@stylesheets@g" *.html
|
---|
38 | $(Q)cd $(BASEDIR)/; sed -i -e "s@../images@images@g" *.html
|
---|
39 |
|
---|
40 | @echo "Running Tidy and obfuscate.sh..."
|
---|
41 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
---|
42 | tidy -config tidy.conf $$filename; \
|
---|
43 | true; \
|
---|
44 | sh obfuscate.sh $$filename; \
|
---|
45 | sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
---|
46 | done;
|
---|
47 |
|
---|
48 | $(Q)$(MAKE) wget-list
|
---|
49 |
|
---|
50 | pdf: validxml
|
---|
51 | @echo "Generating profiled XML for PDF..."
|
---|
52 | $(Q)xsltproc --nonet --stringparam profile.condition pdf \
|
---|
53 | --output $(RENDERTMP)/blfs-pdf.xml stylesheets/lfs-xsl/profile.xsl \
|
---|
54 | $(RENDERTMP)/blfs-full.xml
|
---|
55 |
|
---|
56 | @echo "Generating FO file..."
|
---|
57 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
58 | --output $(RENDERTMP)/blfs-pdf.fo stylesheets/blfs-pdf.xsl $(RENDERTMP)/blfs-pdf.xml
|
---|
59 | $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/blfs-pdf.fo
|
---|
60 |
|
---|
61 | @echo "Generating PDF file..."
|
---|
62 | $(Q)if [ ! -e $(BASEDIR) ]; then \
|
---|
63 | mkdir -p $(BASEDIR); \
|
---|
64 | fi;
|
---|
65 | $(Q)fop $(RENDERTMP)/blfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT)
|
---|
66 |
|
---|
67 | nochunks: validxml profile-html
|
---|
68 | @echo "Generating non chunked XHTML file..."
|
---|
69 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
70 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
---|
71 | stylesheets/blfs-nochunks.xsl $(RENDERTMP)/blfs-html.xml
|
---|
72 |
|
---|
73 | @echo "Running Tidy..."
|
---|
74 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
---|
75 | @echo "Running obfuscate.sh..."
|
---|
76 | $(Q)sh obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
77 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \
|
---|
78 | $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
79 |
|
---|
80 | tmpdir:
|
---|
81 | @echo "Creating and cleaning $(RENDERTMP)"
|
---|
82 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
83 | $(Q)rm -f $(RENDERTMP)/blfs-{full,html,pdf}.xml
|
---|
84 | $(Q)rm -f $(RENDERTMP)/blfs-pdf.fo
|
---|
85 | $(Q)rm -f $(RENDERTMP)/blfs-{patch-list,patches}
|
---|
86 |
|
---|
87 | validxml: tmpdir
|
---|
88 | @echo "Validating the book..."
|
---|
89 | $(Q)xmllint --nonet --noent --xinclude --postvalid \
|
---|
90 | -o $(RENDERTMP)/blfs-full.xml index.xml
|
---|
91 |
|
---|
92 | profile-html: validxml
|
---|
93 | @echo "Generating profiled XML for XHTML..."
|
---|
94 | $(Q)xsltproc --nonet --stringparam profile.condition html \
|
---|
95 | --output $(RENDERTMP)/blfs-html.xml stylesheets/lfs-xsl/profile.xsl \
|
---|
96 | $(RENDERTMP)/blfs-full.xml
|
---|
97 |
|
---|
98 | blfs-patch-list: validxml
|
---|
99 | @echo "Generating blfs-patch-list..."
|
---|
100 | $(Q)xsltproc --nonet --output $(RENDERTMP)/blfs-patch-list \
|
---|
101 | stylesheets/patcheslist.xsl $(RENDERTMP)/blfs-full.xml
|
---|
102 | $(Q)sed -e "s|^.*/||" $(RENDERTMP)/blfs-patch-list > $(RENDERTMP)/blfs-patches
|
---|
103 | $(Q)sort $(RENDERTMP)/blfs-patches > blfs-patch-list
|
---|
104 |
|
---|
105 | wget-list:
|
---|
106 | @echo "Generating wget list..."
|
---|
107 | $(Q)[ -f $(RENDERTMP)/blfs-full.xml ] || $(MAKE) validxml
|
---|
108 | $(Q)mkdir -p $(BASEDIR)
|
---|
109 | $(Q)xsltproc --nonet --output $(BASEDIR)/wget-list \
|
---|
110 | stylesheets/wget-list.xsl $(RENDERTMP)/blfs-full.xml
|
---|
111 |
|
---|
112 | test-links: validxml
|
---|
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: validxml
|
---|
137 | @echo "Dumping book commands..."
|
---|
138 | $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
139 | stylesheets/dump-commands.xsl $(RENDERTMP)/blfs-full.xml
|
---|
140 |
|
---|
141 | validate:
|
---|
142 | @echo "Validating the book..."
|
---|
143 | $(Q)xmllint --noout --nonet --xinclude --postvalid index.xml
|
---|
144 |
|
---|
145 | all: blfs nochunks pdf
|
---|
146 |
|
---|
147 | world: all blfs-patch-list dump-commands test-links
|
---|
148 |
|
---|
149 | .PHONY : all blfs blfs-patch-list dump-commands nochunks pdf profile-html \
|
---|
150 | test-links tmpdir validate validxml wget-list world
|
---|