OSDN Git Service

[lfsja-git] r11.1-69 対応。
[lfsbookja/lfsja-git.git] / src / Makefile.am
1 ##
2 ## This is part of LFSbookja package.
3 ##
4 SUBDIRS=appendices chapter01 chapter02 chapter03 chapter04 chapter05 \
5         chapter06 chapter07 chapter08 chapter09 chapter10 chapter11 \
6         part3intro prologue stylesheets udev-lfs
7 EXTRA_DIST = general.ch index.ch packages.ch patches.ch pdf-fixups.ch \
8         tidy.ch make-aux-files.ch aux-file-data.ch
9 BOOKdir = @abs_bookdir@
10 srcdir = @srcdir@
11 srcs = general.ent index.xml packages.ent patches.ent pdf-fixups.sh \
12         process-scripts.sh aux-file-data.sh tidy.conf make-aux-files.sh \
13         git-version.sh conditional.ent
14 DISTCLEANFILES = $(srcs)
15
16 GITVER=@GITVER@
17 BASEDIR=@BASEDIR@
18 DUMPDIR=@DUMPDIR@
19 ROOT_ID =
20 RENDERTMP = tmp
21 CHUNK_QUIET = 1
22 NOCHUNKS_NAME = @NOCHUNKS_NAME@
23 NOCHUNKS_OUTPUT = @NOCHUNKS_OUTPUT@
24 PDF_OUTPUT = @PDF_OUTPUT@
25 URLTOP = http\:\/\/lfsbookja.osdn.jp\/git-ja
26
27 #ALLXML := $(filter-out $(RENDERTMP)/%, \
28 #       $(wildcard ./*.xml ./*/*.xml))
29 ALLXML=$(shell find . -type d -name $(RENDERTMP) -prune -o -type f -name '*.xml' -print)
30
31 REV=@revspec@
32
33 all: ctie $(srcs) stylesheets _bootscripts scripts udev-lfs book
34
35 ctie:
36         @$(MAKE) -C $(top_builddir)/$@ $@ >/dev/null
37
38 general.ent: $(BOOKdir)/general.ent $(srcdir)/general.ch
39         $(top_builddir)/$(CTIE) -m $@ $^ >/dev/null
40 index.xml: $(BOOKdir)/index.xml $(srcdir)/index.ch
41         $(top_builddir)/$(CTIE) -m $@ $^ >/dev/null
42 packages.ent: $(BOOKdir)/packages.ent $(srcdir)/packages.ch
43         $(top_builddir)/$(CTIE) -m $@ $^ >/dev/null
44 patches.ent: $(BOOKdir)/patches.ent $(srcdir)/patches.ch
45         $(top_builddir)/$(CTIE) -m $@ $^ >/dev/null
46 tidy.conf: $(BOOKdir)/tidy.conf $(srcdir)/tidy.ch
47         $(top_builddir)/$(CTIE) -m $@ $^ >/dev/null
48
49 .PHONY: scripts
50 scripts: process-scripts.sh aux-file-data.sh make-aux-files.sh pdf-fixups.sh git-version.sh
51
52 process-scripts.sh: $(BOOKdir)/process-scripts.sh
53         cp -p $^ $@
54 aux-file-data.sh: $(BOOKdir)/aux-file-data.sh $(srcdir)/aux-file-data.ch
55         $(top_builddir)/$(CTIE) -m $@ $^ >/dev/null
56         chmod +x $@
57 #       sed -i '/.\/make-aux-files.sh/d' $@
58 make-aux-files.sh: $(BOOKdir)/make-aux-files.sh $(srcdir)/make-aux-files.ch
59         $(top_builddir)/$(CTIE) -m $@ $^ >/dev/null
60         chmod +x $@
61 pdf-fixups.sh: $(BOOKdir)/pdf-fixups.sh $(srcdir)/pdf-fixups.ch
62         $(top_builddir)/$(CTIE) -m $@ $^ >/dev/null
63 git-version.sh: $(BOOKdir)/git-version.sh
64         sed -e "s|version\.ent|$(abs_builddir)/version\.ent|g" \
65             -e "/^full_date/afull_date=\"\$$year/\$$month_digit/\$$day\"" $^ > $@
66 conditional.ent: $(BOOKdir)/conditional.ent
67         cp -p $^ $@
68
69 stylesheets:
70         $(MKDIR_P) stylesheets
71         cp -R $(BOOKdir)/stylesheets/* stylesheets
72
73 _bootscripts: $(ALLXML)
74         $(MKDIR_P) bootscripts
75         cp -pR $(BOOKdir)/bootscripts/* bootscripts
76
77 udev-lfs:
78         $(MKDIR_P) udev-lfs
79 #       cp -R $(BOOKdir)/udev-lfs/* udev-lfs
80
81 book: validate profile-html
82         @echo "Generating chunked XHTML files at $(BASEDIR)/ ..."
83         $(XSLTPROC) --nonet                          \
84           --stringparam chunk.quietly $(CHUNK_QUIET) \
85           --stringparam rootid "$(ROOT_ID)"          \
86           --stringparam base.dir $(BASEDIR)/         \
87           stylesheets/lfs-chunked.xsl                \
88           $(RENDERTMP)/lfs-html.xml
89
90         @echo "Copying CSS code and images..."
91         $(MKDIR_P) $(BASEDIR)/stylesheets
92         cp stylesheets/lfs-xsl/*.css $(BASEDIR)/stylesheets
93         sed -i 's|../stylesheet|stylesheet|' $(BASEDIR)/index.html
94
95         $(MKDIR_P) $(BASEDIR)/images
96         cp -p $(BOOKdir)/images/*.png $(BASEDIR)/images
97
98         @echo "Running Tidy and obfuscate.sh..."
99         for filename in `find $(BASEDIR) -name "*.html"`; do \
100          $(TIDY) -config tidy.conf $$filename;           \
101          true;                                        \
102          ${SHELL} $(BOOKdir)/obfuscate.sh $$filename;           \
103          sed -e "s@text/html@application/xhtml+xml@g" \
104              -i $$filename;                           \
105         done;
106
107         $(MAKE) --no-print-directory $(BASEDIR)/wget-list $(BASEDIR)/md5sums
108
109 @TXT@nochunks: validate profile-html
110 @TXT@   @echo "Generating non chunked XHTML file..."
111 @TXT@   $(XSLTPROC) --nonet                                 \
112 @TXT@                -stringparam rootid "$(ROOT_ID)"       \
113 @TXT@                --output $(BASEDIR)/$(NOCHUNKS_OUTPUT) \
114 @TXT@                stylesheets/lfs-nochunks.xsl           \
115 @TXT@                $(RENDERTMP)/lfs-full.xml
116 @TXT@#                $(RENDERTMP)/lfs-html2.xml
117
118 @TXT@   @echo "Running Tidy..."
119 @TXT@   $(TIDY) -config tidy.conf $(BASEDIR)/$(NOCHUNKS_OUTPUT) || true
120 @TXT@   @echo "Running obfuscate.sh..."
121 @TXT@   ${SHELL} $(BOOKdir)/obfuscate.sh                 $(BASEDIR)/$(NOCHUNKS_OUTPUT)
122 @TXT@   sed -i -e "s@text/html@application/xhtml+xml@g"  $(BASEDIR)/$(NOCHUNKS_OUTPUT)
123 @TXT@   sed -i -e "s@../wget-list@wget-list@"            $(BASEDIR)/$(NOCHUNKS_OUTPUT)
124 @TXT@   sed -i -e "s@../md5sums@md5sums@"                $(BASEDIR)/$(NOCHUNKS_OUTPUT)
125 @TXT@   make $(BASEDIR)/wget-list $(BASEDIR)/md5sums
126
127 @TXT@txt: nochunks
128 @TXT@   $(LYNX) -assume_charset=utf-8 -display_charset=utf-8 -width=44 -dump $(BASEDIR)/$(NOCHUNKS_OUTPUT) > ../$(NOCHUNKS_NAME).txt
129 @TXT@   sed -i -e "s@file\:///[A-Za-z/\-]+\.html@$(URLTOP)/$(NOCHUNKS_NAME)-nochunks.html@g" \
130 @TXT@          -e "s@file\://$(abs_top_builddir)@$(URLTOP)@g" ../$(NOCHUNKS_NAME).txt
131
132 @PDF@@TAKAO@pdf: validate userconfig.xml
133 @PDF@@TAKAO@    @echo "Generating profiled XML for PDF..."
134 @PDF@@TAKAO@    $(XSLTPROC) --nonet --stringparam profile.condition pdf \
135 @PDF@@TAKAO@    --output $(RENDERTMP)/lfs-pdf.xml stylesheets/lfs-xsl/profile.xsl \
136 @PDF@@TAKAO@    $(RENDERTMP)/lfs-full.xml
137 @PDF@@TAKAO@
138 @PDF@@TAKAO@    @echo "Generating FO file..."
139 @PDF@@TAKAO@    $(XSLTPROC) --nonet -stringparam rootid "$(ROOT_ID)" \
140 @PDF@@TAKAO@    --output $(RENDERTMP)/lfs-pdf.fo stylesheets/lfs-pdf.xsl \
141 @PDF@@TAKAO@    $(RENDERTMP)/lfs-pdf.xml
142 @PDF@@TAKAO@    sed -i -e 's/span="inherit"/span="all"/' $(RENDERTMP)/lfs-pdf.fo
143 @PDF@@TAKAO@    sed -i -e 's|\.\./wget-list|wget-list|g' -e 's|\.\./md5sums|md5sums|g' $(RENDERTMP)/lfs-pdf.fo
144 @PDF@@TAKAO@    bash pdf-fixups.sh $(RENDERTMP)/lfs-pdf.fo
145 @PDF@@TAKAO@
146 @PDF@@TAKAO@    @echo "Generating PDF file..."
147 @PDF@@TAKAO@    cp -R $(BASEDIR)/images .;
148 @PDF@@TAKAO@    $(FOP) -c userconfig.xml $(RENDERTMP)/lfs-pdf.fo ./$(PDF_OUTPUT)
149 @PDF@@TAKAO@
150 @PDF@@TAKAO@    @echo "Copying images to destination..."
151 @PDF@@TAKAO@    $(Q)mkdir -p $(BASEDIR)/images
152 @PDF@@TAKAO@    $(Q)cp images/*.png $(BASEDIR)/images
153
154 @PDF@@TAKAO@userconfig.xml: $(srcdir)/userconfig.xml.in
155
156 tmpdir: $(ALLXML)
157         @echo "Creating and cleaning $(RENDERTMP)"
158         [ -d $(RENDERTMP) ] || $(MKDIR_P) $(RENDERTMP)
159         rm -f $(RENDERTMP)/lfs-{full,html,pdf}.xml
160         rm -f $(RENDERTMP)/lfs-pdf.fo
161
162 validate: tmpdir version $(ALLXML)
163         @echo "Processing bootscripts..."
164         bash process-scripts.sh
165
166         @echo "Adjusting for revision $(REV)..."
167         $(XSLTPROC) --nonet                           \
168                 --xinclude                            \
169                 --output $(RENDERTMP)/lfs-html2.xml   \
170                 --stringparam profile.revision $(REV) \
171                 stylesheets/lfs-xsl/profile.xsl       \
172                 index.xml
173
174         @echo "Validating the book..."
175         $(XMLLINT) --nonet                  \
176                --noent                      \
177                --postvalid                  \
178                -o $(RENDERTMP)/lfs-full.xml \
179                $(RENDERTMP)/lfs-html2.xml
180
181         rm -f appendices/*.script
182         ./aux-file-data.sh $(RENDERTMP)/lfs-full.xml $(BOOKdir)
183         @echo "Validation complete."
184
185 maketar:
186         @echo "Making tarballs..."
187         sh make-aux-files.sh $(BOOKdir)
188
189 profile-html: validate $(ALLXML)
190         @echo "Generating profiled XML for XHTML..."
191         $(XSLTPROC) --nonet --stringparam profile.condition html \
192           --output $(RENDERTMP)/lfs-html.xml stylesheets/lfs-xsl/profile.xsl \
193           $(RENDERTMP)/lfs-full.xml
194
195 wget-list: $(BASEDIR)/wget-list
196 $(BASEDIR)/wget-list: stylesheets/wget-list.xsl chapter03/chapter03.xml \
197                       packages.ent patches.ent general.ent
198         @echo "Generating consolidated wget list at $(BASEDIR)/wget-list ..."
199         $(MKDIR_P) $(BASEDIR)
200 #       $(XSLTPROC) --nonet --xinclude                     \
201 #                --stringparam profile.revision $(REV)      \
202 #                --output $(RENDERTMP)/sysd-wget.xml        \
203 #                $(BOOKdir)/stylesheets/lfs-xsl/profile.xsl \
204 #                ./chapter03/chapter03.xml
205         $(XSLTPROC) --xinclude --nonet                     \
206                 --output $(BASEDIR)/wget-list              \
207                      $(BOOKdir)/stylesheets/wget-list.xsl  \
208                 ./chapter03/chapter03.xml
209
210 md5sums: $(BASEDIR)/md5sums
211 $(BASEDIR)/md5sums: stylesheets/wget-list.xsl chapter03/chapter03.xml packages.ent patches.ent $(srcdir)/general.ch
212         @echo "Generating consolidated md5sum file at $(BASEDIR)/md5sums ..."
213         $(MKDIR_P) $(BASEDIR)
214         $(XSLTPROC) --nonet --xinclude                \
215                 --stringparam profile.revision $(REV) \
216                 --output $(RENDERTMP)/sysv-md5sum.xml \
217                 stylesheets/lfs-xsl/profile.xsl       \
218                 chapter03/chapter03.xml
219         $(XSLTPROC) --xinclude --nonet      \
220                 --output $(BASEDIR)/md5sums \
221                 stylesheets/md5sum.xsl      \
222                 $(RENDERTMP)/sysv-md5sum.xml
223         sed -i -e \
224            "s/BOOTSCRIPTS-MD5SUM/$(shell md5sum lfs-bootscripts*.tar.xz | cut -d' ' -f1)/" \
225            $(BASEDIR)/md5sums
226
227 version:
228         (cd $(BOOKdir) && sh $(abs_builddir)/git-version.sh $(REV))
229
230 #dump-commands: validate
231 #       @echo "Dumping book commands..."
232 #       $(XSLTPROC) --output $(DUMPDIR)/ \
233 #          stylesheets/dump-commands.xsl $(RENDERTMP)/lfs-full.xml
234
235
236 #all: lfs nochunks pdf dump-commands
237
238 .PHONY : all lfs nochunks pdf profile-html tmpdir validate md5sums wget-list version