1 | BASEDIR = ~/lfs-book
|
---|
2 | DUMPDIR = ~/lfs-commands
|
---|
3 | RENDERTMP = $(HOME)/tmp
|
---|
4 | CHUNK_QUIET = 1
|
---|
5 | ROOT_ID =
|
---|
6 | PDF_OUTPUT = LFS-BOOK.pdf
|
---|
7 | NOCHUNKS_OUTPUT = LFS-BOOK.html
|
---|
8 | SHELL = /bin/bash
|
---|
9 |
|
---|
10 | ifdef V
|
---|
11 | Q =
|
---|
12 | else
|
---|
13 | Q = @
|
---|
14 | endif
|
---|
15 |
|
---|
16 | lfs: validate profile-html
|
---|
17 | @echo "Generating chunked XHTML files..."
|
---|
18 | $(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
|
---|
19 | -stringparam rootid "$(ROOT_ID)" -stringparam base.dir $(BASEDIR)/ \
|
---|
20 | stylesheets/lfs-chunked.xsl $(RENDERTMP)/lfs-html.xml
|
---|
21 |
|
---|
22 | @echo "Copying CSS code and images..."
|
---|
23 | $(Q)if [ ! -e $(BASEDIR)/stylesheets ]; then \
|
---|
24 | mkdir -p $(BASEDIR)/stylesheets; \
|
---|
25 | fi;
|
---|
26 | $(Q)cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
|
---|
27 | $(Q)if [ ! -e $(BASEDIR)/images ]; then \
|
---|
28 | mkdir -p $(BASEDIR)/images; \
|
---|
29 | fi;
|
---|
30 | $(Q)cp images/*.png $(BASEDIR)/images
|
---|
31 | $(Q)cd $(BASEDIR)/; sed -i -e "s@../stylesheets@stylesheets@g" *.html
|
---|
32 | $(Q)cd $(BASEDIR)/; sed -i -e "s@../images@images@g" *.html
|
---|
33 |
|
---|
34 | @echo "Running Tidy and obfuscate.sh..."
|
---|
35 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
---|
36 | tidy -config tidy.conf $$filename; \
|
---|
37 | true; \
|
---|
38 | /bin/bash obfuscate.sh $$filename; \
|
---|
39 | sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
---|
40 | done;
|
---|
41 |
|
---|
42 | $(Q)$(MAKE) $(BASEDIR)/wget-list $(BASEDIR)/md5sums
|
---|
43 |
|
---|
44 | pdf: validate
|
---|
45 | @echo "Generating profiled XML for PDF..."
|
---|
46 | $(Q)xsltproc --nonet --stringparam profile.condition pdf \
|
---|
47 | --output $(RENDERTMP)/lfs-pdf.xml stylesheets/lfs-xsl/profile.xsl \
|
---|
48 | $(RENDERTMP)/lfs-full.xml
|
---|
49 |
|
---|
50 | @echo "Generating FO file..."
|
---|
51 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
52 | --output $(RENDERTMP)/lfs-pdf.fo stylesheets/lfs-pdf.xsl \
|
---|
53 | $(RENDERTMP)/lfs-pdf.xml
|
---|
54 | $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/lfs-pdf.fo
|
---|
55 | $(Q)bash pdf-fixups.sh $(RENDERTMP)/lfs-pdf.fo
|
---|
56 |
|
---|
57 | @echo "Generating PDF file..."
|
---|
58 | $(Q)if [ ! -e $(BASEDIR) ]; then \
|
---|
59 | mkdir -p $(BASEDIR); \
|
---|
60 | fi;
|
---|
61 | $(Q)fop -q $(RENDERTMP)/lfs-pdf.fo $(BASEDIR)/$(PDF_OUTPUT) 2>fop.log
|
---|
62 | @echo "$(BASEDIR)/$(PDF_OUTPUT) created"
|
---|
63 | @echo "fop.log created"
|
---|
64 |
|
---|
65 | nochunks: validate profile-html
|
---|
66 | @echo "Generating non chunked XHTML file..."
|
---|
67 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
68 | --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
|
---|
69 | stylesheets/lfs-nochunks.xsl $(RENDERTMP)/lfs-html.xml
|
---|
70 |
|
---|
71 | @echo "Running Tidy..."
|
---|
72 | $(Q)tidy -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
|
---|
73 | @echo "Running obfuscate.sh..."
|
---|
74 | $(Q)bash obfuscate.sh $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
75 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
76 | $(Q)sed -i -e "s@../wget-list@wget-list@" $(BASEDIR)/$(NOCHUNKS_OUTPUT)
|
---|
77 | $(Q)$(MAKE) $(BASEDIR)/wget-list $(BASEDIR)/md5sums
|
---|
78 |
|
---|
79 | tmpdir:
|
---|
80 | @echo "Creating and cleaning $(RENDERTMP)"
|
---|
81 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
82 | $(Q)rm -f $(RENDERTMP)/lfs-{full,html,pdf}.xml
|
---|
83 | $(Q)rm -f $(RENDERTMP)/lfs-pdf.fo
|
---|
84 |
|
---|
85 | validate: tmpdir
|
---|
86 | @echo "Processing bootscripts..."
|
---|
87 | $(Q)bash process-scripts.sh
|
---|
88 | @echo "Validating the book..."
|
---|
89 | $(Q)xmllint --nonet --noent --xinclude --postvalid \
|
---|
90 | -o $(RENDERTMP)/lfs-full.xml index.xml
|
---|
91 | $(Q)rm -f appendices/*.script
|
---|
92 | $(Q)./aux-file-data.sh $(RENDERTMP)/lfs-full.xml
|
---|
93 | @echo "Validation complete."
|
---|
94 |
|
---|
95 | profile-html: validate
|
---|
96 | @echo "Generating profiled XML for XHTML..."
|
---|
97 | $(Q)xsltproc --nonet --stringparam profile.condition html \
|
---|
98 | --output $(RENDERTMP)/lfs-html.xml stylesheets/lfs-xsl/profile.xsl \
|
---|
99 | $(RENDERTMP)/lfs-full.xml
|
---|
100 |
|
---|
101 | wget-list: $(BASEDIR)/wget-list
|
---|
102 | $(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml packages.ent patches.ent
|
---|
103 | @echo "Generating wget list..."
|
---|
104 | $(Q)mkdir -p $(BASEDIR)
|
---|
105 | $(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/wget-list \
|
---|
106 | stylesheets/wget-list.xsl chapter03/chapter03.xml
|
---|
107 |
|
---|
108 | md5sums: $(BASEDIR)/md5sums
|
---|
109 | $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml packages.ent patches.ent
|
---|
110 | @echo "Generating md5sum file..."
|
---|
111 | $(Q)mkdir -p $(BASEDIR)
|
---|
112 | $(Q)xsltproc --xinclude --nonet --output $(BASEDIR)/md5sums \
|
---|
113 | stylesheets/md5sum.xsl chapter03/chapter03.xml
|
---|
114 | $(Q)sed -i -e \
|
---|
115 | "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.bz2 | cut -d' ' -f1)/" \
|
---|
116 | $(BASEDIR)/md5sums
|
---|
117 |
|
---|
118 | dump-commands: validate
|
---|
119 | @echo "Dumping book commands..."
|
---|
120 | $(Q)xsltproc --output $(DUMPDIR)/ \
|
---|
121 | stylesheets/dump-commands.xsl $(RENDERTMP)/lfs-full.xml
|
---|
122 |
|
---|
123 |
|
---|
124 | all: lfs nochunks pdf dump-commands
|
---|
125 |
|
---|
126 | .PHONY : all dump-commands lfs nochunks pdf profile-html tmpdir validate
|
---|
127 |
|
---|