summaryrefslogtreecommitdiff
path: root/po4a/Makefile
blob: d3663e54ff742897ae3f9b2a9ede1f5bf5cb6346 (plain)
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
# dgit document translation machinery
#
# Translators: there is no need to look at this file.  It contains
# complicated machinery which you do not need to understand :-).
# See po/README instead.

# Copyright (C)2018 Ian Jackson
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# ----- devel docs (translators, pleaee ignore all this) -----
#
# We use po4a for everything.
#
# po4a is nicely automatic for all the po handling, and the config
# file makes nice documentation, but it really really likes to dirty
# the tree.  And we want to automatically list the documents and the
# translation languages which it doesn't make easy.
#
# The approach I have chosen is as follows:
#
# po4a.cfg
#
#   This is autogenerated.  But also, we invite translators to add
#   their own language to it.  The resulting merge
#   conflict/discrepancy will be just an alphabetical ordering
#   discrepancy, since our generation script scans the available po
#   files.
#
#   Generation is done by a shell script, ./list-documents.
#
#   make targets:  po4a.cfg           # many others imply this
#                  po4a.cfg.check     # fails if out of date
#
# *.pot, *.po
#
#   As far as translators are concerned, generated and maintained by
#   po4a and committed to git.  As for the developers, we update this
#   occasionally just by running po4a.
#
#   make targets:  default           } mean
#                  pofiles           }  the same
#
# Translations for translators:
#
#   make targets:  preview.LANG
#                  translated
#
# Translated document source-language files (eg, translated pod):
#
#   Like with normal po things, the tools don't like to generate
#   output without updating (dirtying) the .po files.  But with po4a
#   this is really hard to avoid.  So we use a linkfarming technique.
#
#   make targets:  translated-only
#
# Translated output files (roff format, from pod2man):
#
#   We have sort of lost the usual make rule information by now
#   about targets and what to build.  Only po4a knows which
#   translated files are supposed to exist.  So we have a shell
#   script which reuses the top-level Makefile to run pod2man
#   where appropriate, and generate a further even-more-output-ish
#   tree.
#
#   make targets:  install
#
# Check:
#
#   make targets:  check
#                  pairwise-pocheck.check


default: pofiles

include ../i18n-common.make
PO4A ?= po4a

all update: translated

check: po4a.cfg.check pairwise-pocheck.check

pofiles: po4a.cfg
	$(PO4A) --no-translations $<

translated: po4a.cfg
	$(PO4A) $<

po4a.cfg: list-documents
	./$< $o

po4a.cfg.check: list-documents
	./$< >$@.tmp
	diff po4a.cfg $@.tmp

pairwise-pocheck.check:
	./pairwise-pocheck

t = ../.po4a.translated-only
p = ../po4a

translated-only: po4a.cfg pairwise-pocheck.check
	rm -rf $t && mkdir $t
	cd $t && ln -s $p/*.po $p/*.pot $p/po4a.cfg .
	cd $t && $(PO4A) po4a.cfg
	! test -d $t/translated || \
	cp -al --remove-destination $t/translated .

.po4a.%.cfg: po4a.cfg Makefile
	$S perl -p -e 's{^(\[po4a_langs\]).*}{$$1 $*};' \
		-e 's{:translated/man}{:.$*.translated/man}' \
		$< $o

.PRECIOUS: .po4a.%.cfg

pairwise-pocheck.%.check:
	./pairwise-pocheck $*

preview.%: .po4a.%.cfg pairwise-pocheck.%.check
	$S $(PO4A) $<
	$S ./install-documents >/dev/null .$*.translated $@
	@ echo '# runes to preview the various final tranlated manpages:'
	$S find $@ -type f -printf 'man -l %p\n'

# We can't really use timestamps to drive po4a
.PHONY: preview.% translated

install: translated-only
	./install-documents translated $(DESTDIR)