1include $(top_srcdir)/doc/files.am
2include $(top_srcdir)/build/makefiles/sphinx-build.am
3
4CLEANFILES =
5
6EXTRA_DIST +=					\
7	$(po_files)
8
9if DOCUMENT_AVAILABLE
10EXTRA_DIST +=					\
11	$(mo_files)
12endif
13
14if DOCUMENT_BUILDABLE
15BUILT_SOURCES +=				\
16	mo-build-stamp
17CLEANFILES +=					\
18	pot-build-stamp				\
19	edit-po-build-stamp			\
20	mo-build-stamp
21endif
22
23SUFFIXES += .pot .po .mo .edit
24
25.PHONY: gettext update build
26
27.pot.edit:
28	if test -f $*.po; then			\
29	  msgmerge				\
30	    --quiet				\
31	    --sort-by-file			\
32	    --output-file=$@.tmp		\
33	    $*.po				\
34	    $<;					\
35	else					\
36	  msginit				\
37	    --input=$<				\
38	    --output-file=$@.tmp		\
39	    --locale=$(LOCALE)			\
40	    --no-translator;			\
41	fi
42	(echo "# -*- po -*-";					\
43	 GREP_OPTIONS= grep -v '^# -\*- po -\*-' $@.tmp |	\
44	 GREP_OPTIONS= grep -v '^"POT-Creation-Date:') > $@
45	rm $@.tmp
46
47.edit.po:
48	msgcat --no-location --output $@ $<
49
50.po.mo:
51	msgfmt -o $@ $<
52
53if DOCUMENT_BUILDABLE
54update: edit-po-build-stamp
55build: mo-build-stamp
56else
57update:
58build:
59endif
60
61html: build
62
63gettext:
64	rm *.pot || true
65	$(SPHINX_BUILD_COMMAND) -d doctrees -b gettext $(ALLSPHINXOPTS) .
66	xgettext --language Python --output conf.pot \
67	  $(top_srcdir)/doc/source/conf.py
68
69pot-build-stamp: $(absolute_source_files)
70	$(MAKE) gettext
71	@touch $@
72
73edit-po-build-stamp: pot-build-stamp
74	$(MAKE) $(edit_po_files)
75	@touch $@
76
77mo_build_stamp_dependencies = edit-po-build-stamp
78if DOCUMENT_BUILDABLE
79mo_build_stamp_dependencies += $(edit_po_files)
80endif
81
82mo-build-stamp: $(mo_build_stamp_dependencies)
83	$(MAKE) $(mo_files)
84	@touch $@
85