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