1 | TOP := $(PWD)
|
---|
2 |
|
---|
3 | WORKDIR := $(TOP)/render-output
|
---|
4 |
|
---|
5 | BASEDIR := $(WORKDIR)/cross-lfs-book
|
---|
6 | DUMPDIR := $(WORKDIR)/cross-lfs-commands
|
---|
7 | DLLISTDIR := $(WORKDIR)/cross-lfs-dllist
|
---|
8 | RENDERTMP := $(WORKDIR)/tmp
|
---|
9 | CHUNK_QUIET := 1
|
---|
10 | ROOT_ID :=
|
---|
11 |
|
---|
12 | S := -
|
---|
13 |
|
---|
14 | ARCHS := x86 x86_64 x86_64-64 sparc sparc64 sparc64-64 mips mips64 mips64-64 \
|
---|
15 | ppc ppc64 alpha
|
---|
16 |
|
---|
17 | ARCHS_VD_XML := $(ARCHS:%=%-validate_dump-xml)
|
---|
18 | ARCHS_P_XML := $(ARCHS:%=%-profiled-xml)
|
---|
19 |
|
---|
20 | ARCHS_HTML := $(ARCHS:%=%$(S)html)
|
---|
21 | ARCHS_NOCHUNKS := $(ARCHS:%=%$(S)nochunks)
|
---|
22 | ARCHS_PDF := $(ARCHS:%=%$(S)pdf)
|
---|
23 | ARCHS_VALIDATE := $(ARCHS:%=%$(S)validate)
|
---|
24 | ARCHS_TROUBLE := $(ARCHS:%=%$(S)trouble)
|
---|
25 | ARCHS_DUMP := $(ARCHS:%=%$(S)dump)
|
---|
26 | ARCHS_DLLIST := $(ARCHS:%=%$(S)dllist)
|
---|
27 |
|
---|
28 | ifdef V
|
---|
29 | Q =
|
---|
30 | else
|
---|
31 | Q = @
|
---|
32 | endif
|
---|
33 |
|
---|
34 | .PHONY: lfs tidy render titlepage $(ARCHS_HTML) nochunks $(ARCHS_NOCHUNKS) pdf \
|
---|
35 | $(ARCHS_PDF) validate $(ARCHS_VALIDATE) trouble $(ARCHS_TROUBLE) \
|
---|
36 | dump-commands $(ARCHS_DUMP) download-list $(ARCHS_DLLIST) tmpdir
|
---|
37 |
|
---|
38 | lfs: tmpdir render tidy
|
---|
39 |
|
---|
40 | tmpdir:
|
---|
41 | @echo "Creating and cleaning $(RENDERTMP)"
|
---|
42 | $(Q)[ -d $(RENDERTMP) ] || mkdir -p $(RENDERTMP)
|
---|
43 | $(Q)rm -f $(RENDERTMP)/*-{full,html,pdf}.xml
|
---|
44 | $(Q)rm -f $(RENDERTMP)/*.fo
|
---|
45 |
|
---|
46 | ifeq ($(shell which tidy >/dev/null 2>&1 && echo yes),yes)
|
---|
47 | tidy:
|
---|
48 | @echo "Running tidy on the created HTML"
|
---|
49 | $(Q)for filename in `find $(BASEDIR) -name "*.html"`; do \
|
---|
50 | tidy -config $(PWD)/tidy.conf $$filename; \
|
---|
51 | true; \
|
---|
52 | bash $(PWD)/obfuscate.sh $$filename; \
|
---|
53 | sed -i -e "s@text/html@application/xhtml+xml@g" $$filename; \
|
---|
54 | done;
|
---|
55 | else
|
---|
56 | tidy:
|
---|
57 | @echo "Tidy is not installed on this system"
|
---|
58 | endif
|
---|
59 |
|
---|
60 | render: $(ARCHS_HTML) titlepage
|
---|
61 |
|
---|
62 | titlepage:
|
---|
63 | $(Q)xsltproc --nonet --output $(BASEDIR)/index.html \
|
---|
64 | $(PWD)/stylesheets/top-index.xsl $(PWD)/index.xml
|
---|
65 |
|
---|
66 | $(ARCHS_VD_XML): override validate_dump_xml_arch = $(@:%-validate_dump-xml=%)
|
---|
67 | $(ARCHS_VD_XML):
|
---|
68 | @echo "Validating $(validate_dump_xml_arch) book..."
|
---|
69 | $(Q)xmllint --nonet --noent --xinclude --postvalid \
|
---|
70 | -o $(RENDERTMP)/$(validate_dump_xml_arch)-full.xml $(PWD)/$(validate_dump_xml_arch)-index.xml
|
---|
71 |
|
---|
72 | $(ARCHS_P_XML): override profiled_xml_arch = $(@:%-profiled-xml=%)
|
---|
73 | $(ARCHS_P_XML):
|
---|
74 | @$(MAKE) --no-print-directory $(profiled_xml_arch)-validate_dump-xml
|
---|
75 |
|
---|
76 | @echo "Generating profiled $(profiled_xml_arch) book for XHTML..."
|
---|
77 | $(Q)xsltproc --nonet --stringparam profile.condition html \
|
---|
78 | --output $(RENDERTMP)/$(profiled_xml_arch)-html.xml \
|
---|
79 | $(PWD)/stylesheets/lfs-xsl/profile.xsl $(RENDERTMP)/$(profiled_xml_arch)-full.xml
|
---|
80 |
|
---|
81 | $(ARCHS_HTML): override html_arch = $(@:%$(S)html=%)
|
---|
82 | $(ARCHS_HTML):
|
---|
83 | @$(MAKE) --no-print-directory $(html_arch)-profiled-xml
|
---|
84 |
|
---|
85 | @echo "Rendering chunked XHTML of $(html_arch)..."
|
---|
86 | $(Q)mkdir -p $(BASEDIR)/$(html_arch)
|
---|
87 | $(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
|
---|
88 | -stringparam rootid "$(ROOT_ID)" \
|
---|
89 | -stringparam base.dir $(BASEDIR)/$(html_arch)/ \
|
---|
90 | $(PWD)/stylesheets/clfs-chunked.xsl $(RENDERTMP)/$(html_arch)-html.xml
|
---|
91 |
|
---|
92 | @echo "Copying CSS code and images..."
|
---|
93 | $(Q)mkdir -p $(BASEDIR)/$(html_arch)/stylesheets
|
---|
94 | $(Q)cp $(PWD)/stylesheets/lfs-xsl/*.css $(BASEDIR)/$(html_arch)/stylesheets
|
---|
95 | $(Q)sed -i -e "s@../stylesheets@stylesheets@g" $(BASEDIR)/$(html_arch)/*.html
|
---|
96 | $(Q)mkdir -p $(BASEDIR)/$(html_arch)/images
|
---|
97 | $(Q)cp $(PWD)/images/*.png $(BASEDIR)/$(html_arch)/images
|
---|
98 | $(Q)sed -i -e "s@../images@images@g" $(BASEDIR)/$(html_arch)/*.html
|
---|
99 |
|
---|
100 | nochunks: tmpdir $(ARCHS_NOCHUNKS) tidy
|
---|
101 |
|
---|
102 | $(ARCHS_NOCHUNKS): override nochunk_arch = $(@:%$(S)nochunks=%)
|
---|
103 | $(ARCHS_NOCHUNKS):
|
---|
104 | @$(MAKE) --no-print-directory $(nochunk_arch)-profiled-xml
|
---|
105 |
|
---|
106 | @echo "Rendering Single File HTML of $(nochunk_arch)..."
|
---|
107 | $(Q)mkdir -p $(BASEDIR)
|
---|
108 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
109 | --output $(BASEDIR)/CLFS-$(nochunk_arch).html \
|
---|
110 | $(PWD)/stylesheets/clfs-nochunks.xsl $(RENDERTMP)/$(nochunk_arch)-html.xml
|
---|
111 |
|
---|
112 | @echo "Running Tidy..."
|
---|
113 | $(Q)tidy -config $(PWD)/tidy.conf $(BASEDIR)/CLFS-$(nochunk_arch).html || true
|
---|
114 | @echo "Running obfuscate.sh..."
|
---|
115 | $(Q)bash $(PWD)/obfuscate.sh $(BASEDIR)/CLFS-$(nochunk_arch).html
|
---|
116 | $(Q)sed -i -e "s@text/html@application/xhtml+xml@g" \
|
---|
117 | $(BASEDIR)/CLFS-$(nochunk_arch).html
|
---|
118 |
|
---|
119 | pdf: tmpdir $(ARCHS_PDF)
|
---|
120 |
|
---|
121 | $(ARCHS_PDF): override pdf_arch = $(@:%$(S)pdf=%)
|
---|
122 | $(ARCHS_PDF):
|
---|
123 | @$(MAKE) --no-print-directory $(pdf_arch)-profiled-xml
|
---|
124 |
|
---|
125 | @echo "Generating FO file of $(pdf_arch)..."
|
---|
126 | $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
|
---|
127 | --output $(RENDERTMP)/$(pdf_arch).fo $(PWD)/stylesheets/clfs-pdf.xsl \
|
---|
128 | $(RENDERTMP)/$(pdf_arch)-pdf.xml
|
---|
129 | $(Q)sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/$(pdf_arch).fo
|
---|
130 |
|
---|
131 | @echo "Rendering PDF of $(pdf_arch)..."
|
---|
132 | $(Q)mkdir -p $(BASEDIR)
|
---|
133 | $(Q)fop $(RENDERTMP)/$(pdf_arch).fo $(BASEDIR)/CLFS-$(pdf_arch).pdf
|
---|
134 |
|
---|
135 | validate: $(ARCHS_VALIDATE)
|
---|
136 |
|
---|
137 | $(ARCHS_VALIDATE): override validate_arch = $(@:%$(S)validate=%)
|
---|
138 | $(ARCHS_VALIDATE):
|
---|
139 | @echo "Validating $(validate_arch)..."
|
---|
140 | $(Q)xmllint --xinclude --noout --nonet --postvalid $(PWD)/$(validate_arch)-index.xml
|
---|
141 |
|
---|
142 | trouble: tmpdir $(ARCHS_TROUBLE)
|
---|
143 |
|
---|
144 | $(ARCHS_TROUBLE): override trouble_arch = $(@:%$(S)trouble=%)
|
---|
145 | $(ARCHS_TROUBLE):
|
---|
146 | @echo "Troubleshooting $(trouble_arch)..."
|
---|
147 | $(Q)xmllint --xinclude --nonet --postvalid \
|
---|
148 | -o $(RENDERTMP)/dump-$(trouble_arch) $(PWD)/$(trouble_arch)-index.xml
|
---|
149 | $(Q)xmllint --xinclude --noout --nonet --valid $(RENDERTMP)/dump-$(trouble_arch)
|
---|
150 | @echo "You can now look at $(RENDERTMP)/dump-$(trouble_arch) to see the errors"
|
---|
151 |
|
---|
152 | dump-commands: $(ARCHS_DUMP)
|
---|
153 |
|
---|
154 | $(ARCHS_DUMP): override dump_arch = $(@:%$(S)dump=%)
|
---|
155 | $(ARCHS_DUMP):
|
---|
156 | @echo "Extracting commands from $(dump_arch)..."
|
---|
157 | $(Q)mkdir -p $(DUMPDIR)/$(dump_arch)
|
---|
158 | $(Q)xsltproc --xinclude --nonet --output $(DUMPDIR)/$(dump_arch)/ \
|
---|
159 | $(PWD)/stylesheets/dump-commands.xsl $(PWD)/$(dump_arch)-index.xml
|
---|
160 |
|
---|
161 | download-list: $(ARCHS_DLLIST)
|
---|
162 |
|
---|
163 | $(ARCHS_DLLIST): override dllist_arch = $(@:%$(S)dllist=%)
|
---|
164 | $(ARCHS_DLLIST):
|
---|
165 | @echo "Creating download list for $(dllist_arch)..."
|
---|
166 | $(Q)mkdir -p $(DLLISTDIR)
|
---|
167 | $(Q)xsltproc --xinclude --nonet --output $(DLLISTDIR)/$(dllist_arch)/dl.list \
|
---|
168 | $(PWD)/stylesheets/wget.xsl $(PWD)/$(dllist_arch)-index.xml
|
---|
169 |
|
---|
170 | help:
|
---|
171 | @echo "Output: $(WORKDIR)"
|
---|
172 | @echo
|
---|
173 | @echo "HTML Targets"
|
---|
174 | @echo -e " \e[0;32mlfs tidy render titlepage \e[0;34m$(ARCHS_HTML)\e[0;0m"
|
---|
175 | @echo
|
---|
176 | @echo "NoChunks Targets"
|
---|
177 | @echo -e " \e[0;32mnochunks tidy \e[0;34m$(ARCHS_NOCHUNKS)\e[0;0m"
|
---|
178 | @echo
|
---|
179 | @echo "PDF Targets"
|
---|
180 | @echo -e " \e[0;32mpdf \e[0;34m$(ARCHS_PDF)\e[0;0m"
|
---|
181 | @echo
|
---|
182 | @echo "Validate Targets"
|
---|
183 | @echo -e " \e[0;32mvalidate \e[0;34m$(ARCHS_VALIDATE)\e[0;0m"
|
---|
184 | @echo
|
---|
185 | @echo "Trouble Targets"
|
---|
186 | @echo -e " \e[0;32mtrouble \e[0;34m$(ARCHS_TROUBLE)\e[0;0m"
|
---|
187 | @echo
|
---|
188 | @echo "Dump-Commands Targets"
|
---|
189 | @echo -e " \e[0;32mdump-commands \e[0;34m$(ARCHS_DUMP)\e[0;0m"
|
---|
190 | @echo
|
---|
191 | @echo "Download-List Targets"
|
---|
192 | @echo -e " \e[0;32mdownload-list \e[0;34m$(ARCHS_DLLIST)\e[0;0m"
|
---|