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