OSDN Git Service

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