driconf: Fix gen_xmlpool.py script to allow running from any directory
[mesa.git] / src / mesa / drivers / dri / common / xmlpool / Makefile
1 # Convenient makefile for managing translations.
2
3 # Prerequisites:
4 # - GNU gettext
5 # - Python
6
7 # Adding new translations
8 # -----------------------
9
10 # To start working on a new translation edit the POS=... line
11 # below. If you want to add for example a french translation, add
12 # fr.po.
13
14 # Then run "make po" to generate a fresh .po file from translatable
15 # strings in t_options.h. Now you can edit the new .po file (fr.po in
16 # the example above) to translate the strings. Please make sure that
17 # your editor encodes the file in UTF-8.
18
19 # Updating existing translations
20 # ------------------------------
21
22 # Run "make po" to update .po files with new translatable strings from
23 # t_options.h. Now you can edit the .po files you're interested
24 # in. Please make sure that your editor encodes the file in UTF-8.
25
26 # Updating options.h
27 # ------------------
28
29 # Finally run "make" to generate options.h from t_options.h with all
30 # translations. Now you can rebuild the drivers. Any common options
31 # used by the drivers will have option descriptions with the latest
32 # translations.
33
34 # Publishing translations
35 # -----------------------
36
37 # To get your translation(s) into Mesa CVS, please send me your
38 # <lang>.po file.
39
40 # More information:
41 # - info gettext
42
43 # The set of supported languages. Add languages as needed.
44 POS=de.po es.po nl.po fr.po sv.po
45
46 #
47 # Don't change anything below, unless you know what you're doing.
48 #
49 LANGS=$(POS:%.po=%)
50 MOS=$(POS:%.po=%/LC_MESSAGES/options.mo)
51 POT=xmlpool.pot
52
53 .PHONY: all clean pot po mo
54
55 all: options.h
56
57 # Only intermediate files are cleaned up. options.h is not deleted because
58 # it's in CVS.
59 clean:
60 -rm -f $(POT) *~
61 -rm -rf $(LANGS)
62
63 # Default target options.h
64 options.h: LOCALEDIR := .
65 options.h: t_options.h mo
66 $(PYTHON2) $(PYTHON_FLAGS) gen_xmlpool.py t_options.h $(LOCALEDIR) $(LANGS) > options.h
67
68 # Update .mo files from the corresponding .po files.
69 mo:
70 @for mo in $(MOS); do \
71 lang=$${mo%%/*}; \
72 echo "Updating $$mo from $$lang.po."; \
73 mkdir -p $${mo%/*}; \
74 msgfmt -o $$mo $$lang.po; \
75 done
76
77 # Use this target to create or update .po files with new messages in
78 # driconf.py.
79 po: $(POS)
80
81 pot: $(POT)
82
83 # Extract message catalog from driconf.py.
84 $(POT): t_options.h
85 xgettext -L C --from-code utf-8 -o $(POT) t_options.h
86
87 # Create or update a .po file for a specific language.
88 %.po: $(POT)
89 @if [ -f $@ ]; then \
90 echo "Merging new strings from $(POT) into $@."; \
91 mv $@ $@~; \
92 msgmerge -o $@ $@~ $(POT); \
93 else \
94 echo "Initializing $@ from $(POT)."; \
95 msginit -i $(POT) -o $@~ --locale=$*; \
96 sed -e 's/charset=.*\\n/charset=UTF-8\\n/' $@~ > $@; \
97 fi