chiark / gitweb /
changelog: document last change
[sgt-puzzles.git] / Makefile.doc
1 all: puzzles.hlp puzzles.txt HACKING
2
3 preprocessed.but: puzzles.but
4         sed 's/PREFIX-/$(BINPREFIX)/g' puzzles.but > preprocessed.but
5
6 puzzles.hlp puzzles.txt: preprocessed.but
7         halibut --winhelp=puzzles.hlp --text=puzzles.txt preprocessed.but
8
9 HACKING: devel.but
10         halibut --text=HACKING devel.but
11
12 chm: puzzles.hhp
13 puzzles.hhp: puzzles.but chm.but
14         halibut --html puzzles.but chm.but
15
16 TRANSLATIONS := $(patsubst po/%.po,%,$(wildcard po/*.po))
17 LANGUAGES := en $(TRANSLATIONS)
18
19 update-po:
20 # Please tell me there is an easier way to preserve the POT file header.
21         test -f po/puzzles-doc.pot
22         po4a-gettextize -f halibut -m puzzles.but --package-name puzzles \
23                 -p po/puzzles-doc.tmp1.pot
24         awk -F: '{ print ""; \
25                    print "#: " $$1 ".R"; \
26                    print "msgid \"" $$4 "\""; \
27                    print "msgstr \"\""; }' \
28                 < gamedesc.txt >> po/puzzles-doc.tmp1.pot
29         xgettext -j -cTranslator: --package-name puzzles \
30                 -o po/puzzles-doc.tmp1.pot mkmanpages.pl
31         sed -i '1,/^#$$/d' po/puzzles-doc.tmp1.pot
32         cat po/puzzles-doc.pot.head po/puzzles-doc.tmp1.pot \
33                 > po/puzzles-doc.tmp2.pot
34         diff -q -I Project-Id-Version: -I POT-Creation-Date: \
35                 po/puzzles-doc.pot po/puzzles-doc.tmp2.pot || \
36                 mv po/puzzles-doc.tmp2.pot po/puzzles-doc.pot
37         rm -f po/puzzles-doc.tmp*.pot
38         for lang in $(TRANSLATIONS); do \
39                 msgmerge --previous -U po/$$lang.po po/puzzles-doc.pot || exit; \
40         done
41 .PHONY: update-po
42
43 doc/puzzles.but.%: puzzles.but po/%.po
44         mkdir -p doc
45         po4a-translate -k 0 -f halibut -m puzzles.but -p po/$*.po -l $@
46 .PRECIOUS: $(addprefix doc/puzzles.but.,$(TRANSLATIONS))
47
48 doc/preprocessed.but.%: doc/puzzles.but.%
49         sed 's/PREFIX-/$(BINPREFIX)/g' $< > $@
50
51 doc/puzzles.txt.%: doc/preprocessed.but.%
52         halibut --text=$@ --input-charset=UTF-8 $<
53 all: $(addprefix doc/puzzles.txt.,$(TRANSLATIONS))
54
55 doc/man-en-stamp: preprocessed.but
56         mkdir -p doc
57         rm -rf doc/man-en
58         mkdir doc/man-en
59         perl mkmanpages.pl en
60         touch $@
61 doc/man-%-stamp: doc/preprocessed.but.%
62         mkdir -p doc
63         rm -rf doc/man-$*
64         mkdir doc/man-$*
65         perl mkmanpages.pl $*
66         touch $@
67 man: $(patsubst %,doc/man-%-stamp,$(LANGUAGES))
68
69 doc/html-en-stamp: preprocessed.but
70         mkdir -p doc
71         rm -rf doc/html-en
72         mkdir doc/html-en
73         cd doc/html-en && halibut --html ../../preprocessed.but
74         touch $@
75 doc/html-%-stamp: doc/preprocessed.but.%
76         mkdir -p doc
77         rm -rf doc/html-$*
78         mkdir doc/html-$*
79         cd doc/html-$* && halibut --html --input-charset=UTF-8 ../preprocessed.but.$*
80         touch $@
81 html: $(patsubst %,doc/html-%-stamp,$(LANGUAGES))
82
83 .PHONY: man html
84 all: man html
85
86 clean:
87         rm -f puzzles.hlp puzzles.txt preprocessed.but HACKING *.html *.hh[pck]
88         rm -f puzzles.cnt
89         rm -rf doc