File: Makefile

package info (click to toggle)
grass 8.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 277,040 kB
  • sloc: ansic: 460,798; python: 227,732; cpp: 42,026; sh: 11,262; makefile: 7,007; xml: 3,637; sql: 968; lex: 520; javascript: 484; yacc: 450; asm: 387; perl: 157; sed: 25; objc: 6; ruby: 4
file content (112 lines) | stat: -rw-r--r-- 4,285 bytes parent folder | download | duplicates (2)
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
# written by Markus Neteler
# tcl stuff by Cedric Shock
# wxpython by Martin Landa

MODULE_TOPDIR = ..
include $(MODULE_TOPDIR)/include/Make/Other.make

default:
	@if [ "$(HAVE_NLS)" != "" ] ; then \
		echo "Creating translations (= 'make mo')" >&2 ; \
		$(MAKE) mo ; \
		echo "Creating translation statistics (= 'make statistics')" >&2 ; \
		$(MAKE) statistics ; \
	else \
		echo "NLS disabled." ; \
	fi

all:
	@echo 'Usage:'
	@echo '   make pot        create grass.pot (containing original messages)'
	@echo '   make update-po  merge new messages into existing *.po files'
	@echo '   make mo         create the *.mo files'
	@echo '   make verify     verify the *.po files'

# Directory for installing tcl .msg files:
PO_DIR = po

#distinguish between library messages and modules:
LIBDOMAIN = grasslibs
MODDOMAIN = grassmods
WXPYDOMAIN = grasswxpy
DOMAINS = $(LIBDOMAIN) $(MODDOMAIN) $(WXPYDOMAIN)

LIB_POTFILES = find ../lib \( -name "*.c" -o -name "*.py" \) | xargs grep -l "_(\"\|n_(\""
MOD_POTFILES = find ../ \( -name "*.c" -o -name "*.cpp" \) | grep -v '../lib' | xargs grep -l "_(\"\|n_(\""
WXPY_POTFILES = find ../gui/wxpython -name '*.py' | xargs grep -l "_(\"\|n_(\""
#For Python script module messages
MOD_PYFILES = find ../scripts -name '*.py' | xargs grep -l "_(\"\|n_(\""

define po_stats
GISBASE="$(RUN_GISBASE)" $(PYTHON) ./grass_po_stats.py
endef

#The xgettext utility is used to automate the creation of
#portable message files (.po)
pot:
	if [ ! -f ../gui/wxpython/menustrings.py ] ; then \
		echo "Build GRASS before running 'make pot'" >&2 ; \
		exit 1 ; \
	fi
	@rm -f ./templates/*.pot
	@echo "Generating $(LIBDOMAIN)..."
	xgettext --from-code=utf-8 --keyword=_ --keyword=n_:1,2 -cGTC -o ./templates/$(LIBDOMAIN).pot `$(LIB_POTFILES)`
	@echo "Generating $(MODDOMAIN)..."
	xgettext --from-code=utf-8 --keyword=_ --keyword=n_:1,2 -cGTC -o ./templates/$(MODDOMAIN).pot `$(MOD_POTFILES)`
	xgettext --from-code=utf-8 -j --keyword=_ --keyword=n_:1,2 -cGTC -o ./templates/$(MODDOMAIN).pot `$(MOD_PYFILES)`
	@echo "Generating $(WXPYDOMAIN)..."
	xgettext --from-code=utf-8 --keyword=_ --keyword=n_:1,2 -cGTC -o ./templates/$(WXPYDOMAIN).pot `$(WXPY_POTFILES)`

#merge already existing translations with new messages in POT template file, deduplicate it and create new po files:
update-po:
	@for i in $(DOMAINS) ; do \
		if [ "`ls ./po/$$i\_*.po 2>/dev/null`" = "" ] ; then \
		 echo "No $$i.po file found in ./po/ directory. Will create new po files from template." ; \
		 cp ./templates/$$i.pot ./po/$$i.po ; \
		 echo "Created ./po/$$i.po - Rename to ./po/$$i\_LANG.po (with LANG: de, ru, ...)" ; \
		 echo "Then you can translate the messages in this file (e.g with kbabel)" ; \
		fi ;\
	done
	@cd ./po/ ; for po in `ls *_*.po 2>/dev/null` ; do \
		suffix=`echo $$po | cut -d'_' -f2-`; \
		lingua=`basename $$suffix .po`; \
		prefix=`echo $$po | cut -d'_' -f1`; \
		if msgmerge -o $$prefix\_$$suffix.new $$prefix\_$$suffix ../templates/$$prefix.pot; then\
		  msguniq --use-first $$prefix\_$$suffix.new > $$prefix\_$$suffix; \
		  rm -f $$prefix\_$$suffix.new; \
		  echo "Merged new messages into $$prefix\_$$suffix" ; \
		else \
		    echo "Merging failed"; \
		fi \
		done
	@echo "Be careful with git commits as .po file updates must be synchronized with the individual translators."

verify:
	@cd ./po/ ; for po in `ls *_*.po 2>/dev/null` ; do \
		echo "----- $$po:" ; \
		msgfmt -c $$po; \
	done
	@rm -f po/messages.mo
	@echo "Note: In case of translations errors to be fixed, edit the respective translation on transifex (and not in git)"

statistics:
	$(call po_stats)

define dom_rule
$(1)_FILES := $$(patsubst po/grass$(1)_%.po,$$(MO_DIR)/%/LC_MESSAGES/grass$(1).mo,$$(wildcard po/grass$(1)_*.po))
$$(MO_DIR)/%/LC_MESSAGES/grass$(1).mo: po/grass$(1)_%.po
	@ [ -d $$(MO_DIR)/$$*/LC_MESSAGES ] || $(MKDIR) $$(MO_DIR)/$$*/LC_MESSAGES
	msgfmt --statistics -o $$@ $$<
endef
$(foreach domain,libs mods wxpy,$(eval $(call dom_rule,$(domain))))

$(MSG_DIR)/%.msg: po/grasstcl_%.po
	@ [ -d $(MSG_DIR) ] || $(MKDIR) $(MSG_DIR)
	msgfmt --statistics --tcl -l $* -d $(MSG_DIR)/ $<

MSGFILES := $(patsubst po/grasstcl_%.po,$(MSG_DIR)/%.msg,$(wildcard po/grasstcl_*.po))

#create binary messages files
mo: $(libs_FILES) $(mods_FILES) $(wxpy_FILES) $(MSGFILES)

.PHONY: mo