source: BOOK/Makefile@ eef46e9

Last change on this file since eef46e9 was eef46e9, checked in by Joe Ciccone <jciccone@…>, 14 years ago

Add a custom schema for CLFS as well as an intermediate target in
the Makefile that validate against this schema and then docbooks
standard schema.

  • Property mode set to 100644
File size: 7.8 KB
Line 
1TOP := $(PWD)
2RENDERDIR := $(TOP)/../render
3
4VALIDATEDIR := $(RENDERDIR)/validate
5PROFILEDIR := $(RENDERDIR)/profile
6
7HTMLDIR := $(RENDERDIR)/html
8NOCHUNKDIR := $(RENDERDIR)/nochunk
9
10FODIR := $(RENDERDIR)/fo
11PDFDIR := $(RENDERDIR)/pdf
12
13TROUBLEDIR := $(RENDERDIR)/trouble
14DUMPDIR := $(RENDERDIR)/commands
15DLLISTDIR := $(RENDERDIR)/download-list
16
17CHUNK_QUIET := 1
18ROOT_ID :=
19
20ARCHS := x86 x86_64 x86_64-64 \
21 sparc sparc64 sparc64-64 \
22 mips mips64 mips64-64 \
23 ppc ppc64 \
24 alpha
25
26ifdef V
27 Q =
28else
29 Q = @
30endif
31
32.PHONY: clfs lfs
33clfs lfs: html
34
35.PHONY: tidy tidy-f tidy-d
36ifeq ($(shell which tidy >/dev/null 2>&1 && echo yes),yes)
37tidy:
38 @$(MAKE) --no-print-directory tidy-d TIDY_DIR=$(HTMLDIR)
39
40tidy-f:
41 @echo "Running tidy on F:$(shell basename $(TIDY_FILE))"
42 @$(TOP)/tidy.sh "$(TIDY_FILE)"
43
44tidy-d:
45 @echo "Running tidy on D:$(shell basename $(TIDY_DIR))"
46 @$(TOP)/tidy.sh "$(TIDY_DIR)"
47else
48tidy tidy-f tidy-d:
49 @echo "Tidy is not installed on this system"
50endif
51
52.PHONY: titlepage
53titlepage:
54 @echo "Rendering the top-level index..."
55 $(Q)xsltproc --nonet --output $(HTMLDIR)/index.html \
56 $(PWD)/stylesheets/top-index.xsl \
57 $(PWD)/index.xml
58 @$(MAKE) --no-print-directory tidy-f TIDY_FILE=$(HTMLDIR)/index.html
59
60ARCHS_VD_XML := $(ARCHS:%=%-validate_dump-xml)
61.PHONY: $(ARCHS_VD_XML)
62$(ARCHS_VD_XML): override arch = $(@:%-validate_dump-xml=%)
63$(ARCHS_VD_XML):
64 @echo "Validating $(arch) against the CLFS Schema..."
65 $(Q)mkdir -p $(VALIDATEDIR)
66 $(Q)xmllint --nonet --noent --xinclude \
67 --relaxng $(TOP)/schema/clfs/0.1/rng/clfs.rng \
68 -o $(VALIDATEDIR)/$(arch)-full.xml \
69 $(PWD)/$(arch)-index.xml \
70 2>&1 | grep -v " validates$$"; \
71 if test $${?} -ne 0; then true; else false; fi
72
73ARCHS_P_XML := $(ARCHS:%=%-profiled-xml)
74.PHONY: $(ARCHS_P_XML)
75$(ARCHS_P_XML): override arch = $(@:%-profiled-xml=%)
76$(ARCHS_P_XML):
77 @$(MAKE) --no-print-directory $(arch)-validate_dump-xml
78 @echo "Profiling $(arch) for rendering..."
79 $(Q)mkdir -p $(PROFILEDIR)
80 $(Q)xsltproc --nonet --stringparam profile.condition html \
81 --output $(PROFILEDIR)/$(arch)-html.xml \
82 $(PWD)/stylesheets/lfs-xsl/profile.xsl \
83 $(VALIDATEDIR)/$(arch)-full.xml
84
85ARCHS_VDB_XML := $(ARCHS:%=%-validate_db-xml)
86.PHONY: $(ARCHS_VDB_XML)
87$(ARCHS_VDB_XML): override arch = $(@:%-validate_db-xml=%)
88$(ARCHS_VDB_XML):
89 @echo "Validating $(arch) against the DocBook Schema..."
90 $(Q)xmllint --noout --nonet \
91 --relaxng $(TOP)/schema/docbook/4.5/rng/docbook.rng \
92 $(VALIDATEDIR)/$(arch)-full.xml \
93 2>&1 | grep -v " validates$$"; \
94 if test $${?} -ne 0; then true; else false; fi
95
96ARCHS_HTML := $(ARCHS:%=%-html)
97.PHONY: html render $(ARCHS_HTML)
98html render: $(ARCHS_HTML) titlepage
99$(ARCHS_HTML): override arch = $(@:%-html=%)
100$(ARCHS_HTML):
101 @$(MAKE) --no-print-directory $(arch)-profiled-xml
102 @$(MAKE) --no-print-directory $(arch)-validate_db-xml
103
104 @echo "Rendering chunked XHTML of $(arch)..."
105 $(Q)mkdir -p $(HTMLDIR)/$(arch)
106 $(Q)xsltproc --nonet -stringparam chunk.quietly $(CHUNK_QUIET) \
107 -stringparam rootid "$(ROOT_ID)" \
108 -stringparam base.dir $(HTMLDIR)/$(arch)/ \
109 $(PWD)/stylesheets/clfs-chunked.xsl \
110 $(PROFILEDIR)/$(arch)-html.xml
111
112 @echo "Copying CSS code and images for $(arch)..."
113 $(Q)mkdir -p $(HTMLDIR)/$(arch)/stylesheets
114 $(Q)cp $(PWD)/stylesheets/lfs-xsl/*.css $(HTMLDIR)/$(arch)/stylesheets
115 $(Q)sed -i -e "s@../stylesheets@stylesheets@g" $(HTMLDIR)/$(arch)/*.html
116 $(Q)mkdir -p $(HTMLDIR)/$(arch)/images
117 $(Q)cp $(PWD)/images/*.png $(HTMLDIR)/$(arch)/images
118 $(Q)sed -i -e "s@../images@images@g" $(HTMLDIR)/$(arch)/*.html
119
120 @$(MAKE) --no-print-directory tidy-d TIDY_DIR=$(HTMLDIR)/$(arch)
121
122ARCHS_NOCHUNKS := $(ARCHS:%=%-nochunks)
123.PHONY: nochunks $(ARCHS_NOCHUNKS)
124nochunks: $(ARCHS_NOCHUNKS)
125$(ARCHS_NOCHUNKS): override arch = $(@:%-nochunks=%)
126$(ARCHS_NOCHUNKS):
127 @$(MAKE) --no-print-directory $(arch)-profiled-xml
128 @$(MAKE) --no-print-directory $(arch)-validate_db-xml
129
130 @echo "Rendering Single File HTML of $(arch)..."
131 $(Q)mkdir -p $(NOCHUNKDIR)
132 $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
133 --output $(NOCHUNKDIR)/CLFS-$(arch).html \
134 $(PWD)/stylesheets/clfs-nochunks.xsl \
135 $(PROFILEDIR)/$(arch)-html.xml
136
137 @$(MAKE) --no-print-directory tidy-f TIDY_FILE=$(NOCHUNKDIR)/CLFS-$(arch).html
138
139ARCHS_FO := $(ARCHS:%=%-fo)
140.PHONY: fo $(ARCHS_FO)
141fo: $(ARCHS_FO)
142$(ARCHS_FO): override arch = $(@:%-fo=%)
143$(ARCHS_FO):
144 @$(MAKE) --no-print-directory $(arch)-profiled-xml
145 @$(MAKE) --no-print-directory $(arch)-validate_db-xml
146
147 @echo "Generating FO file of $(arch)..."
148 @mkdir -p $(FODIR)
149 $(Q)xsltproc --nonet -stringparam rootid "$(ROOT_ID)" \
150 --output $(FODIR)/$(arch).fo \
151 $(PWD)/stylesheets/clfs-pdf.xsl \
152 $(PROFILEDIR)/$(arch)-html.xml
153 $(Q)sed -i -e 's/span="inherit"/span="all"/' $(FODIR)/$(arch).fo
154
155ARCHS_PDF := $(ARCHS:%=%-pdf)
156.PHONY: pdf $(ARCHS_PDF)
157pdf: $(ARCHS_PDF)
158$(ARCHS_PDF): override arch = $(@:%-pdf=%)
159$(ARCHS_PDF):
160 @$(MAKE) --no-print-directory $(arch)-fo
161
162 @echo "Rendering PDF of $(arch)..."
163 $(Q)mkdir -p $(PDFDIR)
164 $(Q)fop $(FODIR)/$(arch).fo $(PDFDIR)/CLFS-$(arch).pdf
165
166ARCHS_VALIDATE := $(ARCHS:%=%-validate)
167.PHONY: validate $(ARCHS_VALIDATE)
168validate: $(ARCHS_VALIDATE)
169$(ARCHS_VALIDATE): override arch = $(@:%-validate=%)
170$(ARCHS_VALIDATE):
171 @echo "Validating $(arch) against the CLFS Schema..."
172 $(Q)xmllint --xinclude --noout --nonet \
173 --relaxng $(TOP)/schema/clfs/0.1/rng/clfs.rng \
174 $(PWD)/$(arch)-index.xml \
175 2>&1 | grep -v " validates$$"; \
176 if test $${?} -ne 0; then true; else false; fi
177
178ARCHS_TROUBLE := $(ARCHS:%=%-trouble)
179.PHONY: trouble $(ARCHS_TROUBLE)
180trouble: $(ARCHS_TROUBLE)
181$(ARCHS_TROUBLE): override arch = $(@:%-trouble=%)
182$(ARCHS_TROUBLE):
183 @echo "Troubleshooting $(arch)..."
184 @mkdir -p $(TROUBLEDIR)
185 $(Q)xmllint --xinclude --nonet \
186 --relaxng $(TOP)/schema/clfs/0.1/rng/clfs.rng \
187 -o $(TROUBLEDIR)/dump-$(arch) \
188 $(PWD)/$(arch)-index.xml \
189 2>&1 | grep -v " validates$$"; \
190 if test $${?} -ne 0; then true; else false; fi
191 $(Q)xmllint --xinclude --noout --nonet \
192 --relaxng $(TOP)/schema/clfs/0.1/rng/clfs.rng \
193 $(TROUBLEDIR)/dump-$(arch) \
194 2>&1 | grep -v " validates$$"; \
195 if test $${?} -ne 0; then true; else false; fi
196 @echo "You can now look at $(TROUBLEDIR)/dump-$(arch) to see the errors"
197
198ARCHS_DUMP := $(ARCHS:%=%-dump)
199.PHONY: dump-commands $(ARCHS_DUMP)
200dump-commands: $(ARCHS_DUMP)
201$(ARCHS_DUMP): override arch = $(@:%-dump=%)
202$(ARCHS_DUMP):
203 @echo "Extracting commands from $(arch)..."
204 $(Q)mkdir -p $(DUMPDIR)/$(arch)
205 $(Q)xsltproc --xinclude --nonet \
206 --output $(DUMPDIR)/$(arch)/ \
207 $(PWD)/stylesheets/dump-commands.xsl \
208 $(PWD)/$(arch)-index.xml
209
210ARCHS_DLLIST := $(ARCHS:%=%-dllist)
211.PHONY: download-list $(ARCHS_DLLIST)
212download-list: $(ARCHS_DLLIST)
213$(ARCHS_DLLIST): override arch = $(@:%-dllist=%)
214$(ARCHS_DLLIST):
215 @echo "Creating download list for $(arch)..."
216 $(Q)mkdir -p $(DLLISTDIR)
217 $(Q)xsltproc --xinclude --nonet \
218 --output $(DLLISTDIR)/$(arch).list \
219 $(PWD)/stylesheets/wget.xsl \
220 $(PWD)/$(arch)-index.xml
221
222FG_GREEN := $(shell echo -e '\e[0;32m')
223FG_BLUE := $(shell echo -e '\e[0;34m')
224FG_DEFAULT := $(shell echo -e '\e[0;0m')
225help:
226 @echo "Output: $(RENDERDIR)"
227 @echo
228 @echo "HTML Targets"
229 @echo " $(FG_GREEN)clfs lfs tidy html render titlepage $(FG_BLUE)$(ARCHS_HTML)$(FG_DEFAULT)"
230 @echo
231 @echo "NoChunks Targets"
232 @echo " $(FG_GREEN)nochunks tidy $(FG_BLUE)$(ARCHS_NOCHUNKS)$(FG_DEFAULT)"
233 @echo
234 @echo "FO Targets"
235 @echo " $(FG_GREEN)fo $(FG_BLUE)$(ARCHS_FO)$(FG_DEFAULT)"
236 @echo
237 @echo "PDF Targets"
238 @echo " $(FG_GREEN)pdf $(FG_BLUE)$(ARCHS_PDF)$(FG_DEFAULT)"
239 @echo
240 @echo "Validate Targets"
241 @echo " $(FG_GREEN)validate $(FG_BLUE)$(ARCHS_VALIDATE)$(FG_DEFAULT)"
242 @echo
243 @echo "Trouble Targets"
244 @echo " $(FG_GREEN)trouble $(FG_BLUE)$(ARCHS_TROUBLE)$(FG_DEFAULT)"
245 @echo
246 @echo "Dump-Commands Targets"
247 @echo " $(FG_GREEN)dump-commands $(FG_BLUE)$(ARCHS_DUMP)$(FG_DEFAULT)"
248 @echo
249 @echo "Download-List Targets"
250 @echo " $(FG_GREEN)download-list $(FG_BLUE)$(ARCHS_DLLIST)$(FG_DEFAULT)"
Note: See TracBrowser for help on using the repository browser.