-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
143 lines (112 loc) · 4.68 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
LANG=en_US.UTF-8
SHELL := /bin/bash
default: html
LFS_EN = lfs-en
MLANG = zh_CN
include $(MLANG)/lang.mk
EXCLUDE_XML = $(LFS_EN)/stylesheets/lfs-xsl/lfs-l10n.xml \
$(LFS_EN)/chapter01/changelog.xml \
$(LFS_EN)/appendices/creat-comm.xml \
$(LFS_EN)/appendices/mit-lic.xml \
$(wildcard $(LFS_EN)/chapter10/kernel/*.xml)
CMD_FIND_XML = find $(LFS_EN) -type f -name '*.xml'
XML_FILES = $(filter-out $(EXCLUDE_XML), $(wildcard $(shell $(CMD_FIND_XML))))
POT_DIRS = $(sort $(patsubst $(LFS_EN)/%, pot/%, $(dir $(XML_FILES))))
PO_FILES = $(patsubst $(LFS_EN)/%.xml, $(MLANG)/%.po, $(XML_FILES))
MKPO4ACFG = ./mkpo4acfg.py $(MLANG)
$(MLANG)/book: ; mkdir -pv $@
-include local.mk
$(PO_FILES) &: $(XML_FILES) mkpo4acfg.py
mkdir -pv $(POT_DIRS)
$(MKPO4ACFG) $(XML_FILES) > po4a.cfg
po4a --no-translations po4a.cfg
$(MLANG)/chapter01/changelog.po: $(LFS_EN)/chapter01/changelog.xml \
changelogtranslator.py \
templatetranslator.py
mkdir -pv pot/chapter01
$(MKPO4ACFG) $(LFS_EN)/chapter01/changelog.xml > po4a-changelog.cfg
po4a --no-translations po4a-changelog.cfg
./changelogtranslator.py $(MLANG)
# Run again. polib does not agree with po4a on line wrappings
# in the .po file, so we need to settle it down.
po4a --no-translations --force po4a-changelog.cfg
MXML_FILES = $(patsubst $(LFS_EN)/%.xml, $(MLANG)/book/%.xml, $(XML_FILES))
EN_BOOK_FILES = $(shell find $(LFS_EN) -type f \
-not -path "$(LFS_EN)/.git" \
-not -path "$(LFS_EN)/conditional.ent" \
-not -path "*.tar.xz")
BOOK_FILES = $(patsubst $(LFS_EN)/%, %, $(EN_BOOK_FILES))
MBOOK_FILES = $(patsubst %, $(MLANG)/book/%, $(BOOK_FILES))
.PHONY: html booksrc nochunks pdf pofiles
pofiles: $(PO_FILES) $(MLANG)/chapter01/changelog.po
html: booksrc
rm -rf $(MLANG)/book/render # without this tidy may be stupidly slow
tmpdir=$$(mktemp -d); \
make -j1 -C $(MLANG)/book REV=$(REV) BASEDIR=render RENDERTMP=$$tmpdir; \
rm -rf $$tmpdir
nochunks: booksrc
rm -rf $(MLANG)/book/nochunks
tmpdir=$$(mktemp -d); \
make -j1 -C $(MLANG)/book REV=$(REV) BASEDIR=nochunks RENDERTMP=$$tmpdir nochunks; \
rm -rf $$tmpdir
pdf: booksrc
rm -rf $(MLANG)/book/pdf
tmpdir=$$(mktemp -d); \
make -j1 -C $(MLANG)/book REV=$(REV) BASEDIR=pdf RENDERTMP=$$tmpdir pdf; \
rm -rf $$tmpdir
booksrc: $(MBOOK_FILES) $(ORIG_FILES) $(MLANG)/book/version.ent
# $(MLANG)/book is not a git repo, so we need to generate the version info
# now and silence git-version.sh. lang.mk SHALL contain the recipe to
# localize git-version.sh.
#
# The content of version.ent does not depend on REV, so just say "sysv"
# here.
.PHONY: version
version: $(MLANG)/book/git-version.sh
cd $(<D); rm LFS-RELEASE; \
DIST=./LFS-RELEASE GIT_DIR=$(PWD)/$(LFS_EN)/.git ./$(<F) sysv
rm -fv $(MLANG)/book/conditional.ent
$(MLANG)/book/version.ent: version; true
$(MXML_FILES) &: $(XML_FILES) $(PO_FILES) mkpo4acfg.py po4a_issue295.sh
mkdir -pv $(POT_DIRS)
$(MKPO4ACFG) $(XML_FILES) > po4a.cfg
po4a po4a.cfg
sed -e 's|<book>|<book lang="$(M_DOCBOOK_LANG)">|' -i $(MLANG)/book/index.xml
cd $(MLANG)/book; $(PWD)/po4a_issue295.sh
$(MLANG)/book/chapter01/changelog.xml: $(LFS_EN)/chapter01/changelog.xml \
$(MLANG)/chapter01/changelog.po
mkdir -pv pot/chapter01
$(MKPO4ACFG) $(LFS_EN)/chapter01/changelog.xml > po4a-changelog.cfg
po4a po4a-changelog.cfg
$(MLANG)/book/%: $(LFS_EN)/%
mkdir -pv "$(@D)"
cp -v $< $@
# The following targets are used for checking any unintentionally command
# changes.
KNOWN_DIFF = chapter09/*-symlinks \
chapter09/*-network \
chapter09/*-console \
chapter09/*-locale \
chapter10/*-fstab
cmd/en/sysv/stamp: $(EN_BOOK_FILES)
make -C $(LFS_EN) DUMPDIR="$(PWD)/$(@D)" REV=sysv dump-commands
cd $(@D); rm -f $(KNOWN_DIFF)
touch $@
cmd/en/systemd/stamp: $(EN_BOOK_FILES)
make -C $(LFS_EN) DUMPDIR="$(PWD)/$(@D)" REV=systemd dump-commands
cd $(@D); rm -f $(KNOWN_DIFF)
touch $@
cmd/$(MLANG)/sysv/stamp: $(MBOOK_FILES)
make -C $(MLANG)/book DUMPDIR="$(PWD)/$(@D)" REV=sysv dump-commands
cd $(@D); rm -f $(KNOWN_DIFF)
touch $@
cmd/$(MLANG)/systemd/stamp: $(MBOOK_FILES)
make -C $(MLANG)/book DUMPDIR="$(PWD)/$(@D)" REV=systemd dump-commands
cd $(@D); rm -f $(KNOWN_DIFF)
touch $@
.PHONY: check-cmd check-cmd-sysv check-cmd-systemd
check-cmd-sysv: cmd/en/sysv/stamp cmd/$(MLANG)/sysv/stamp
diff $(^D) -Naur
check-cmd-systemd: cmd/en/systemd/stamp cmd/$(MLANG)/systemd/stamp
diff $(^D) -Naur
check-cmd: check-cmd-sysv check-cmd-systemd