summaryrefslogtreecommitdiff
path: root/makefiles/gmake
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2009-03-18 11:11:31 +0100
committerAndreas Baumann <abaumann@yahoo.com>2009-03-18 11:11:31 +0100
commit6ce34263d161c066e3f3347cb83626b13753818b (patch)
tree36332ab49fcedc870efba1d7002832a1fbafccde /makefiles/gmake
parent3404f2ca1994cf219992cc0e1c2a6e77068c1f5f (diff)
downloadwolfbones-6ce34263d161c066e3f3347cb83626b13753818b.tar.gz
wolfbones-6ce34263d161c066e3f3347cb83626b13753818b.tar.bz2
started to add PostgreSQL-like gettext support
Diffstat (limited to 'makefiles/gmake')
-rw-r--r--makefiles/gmake/clean.mk2
-rw-r--r--makefiles/gmake/help.mk3
-rw-r--r--makefiles/gmake/i18n.mk101
-rw-r--r--makefiles/gmake/install.mk2
-rw-r--r--makefiles/gmake/sub.mk1
5 files changed, 108 insertions, 1 deletions
diff --git a/makefiles/gmake/clean.mk b/makefiles/gmake/clean.mk
index 95b7d0a..3c7a8a9 100644
--- a/makefiles/gmake/clean.mk
+++ b/makefiles/gmake/clean.mk
@@ -18,7 +18,7 @@ clean_recursive:
@test -z "$(SUBDIRS)" || ( set -e; for d in $(SUBDIRS)""; do \
(set -e; $(MAKE) -C $$d clean || exit 1); done)
-clean: clean_recursive local_clean
+clean: clean_recursive clean_po local_clean
-@rm -f *.bak 2>/dev/null
-@rm -f *~ 2>/dev/null
-@rm -f *.d port/*.d 2>/dev/null
diff --git a/makefiles/gmake/help.mk b/makefiles/gmake/help.mk
index 60b2e94..aaf311a 100644
--- a/makefiles/gmake/help.mk
+++ b/makefiles/gmake/help.mk
@@ -9,3 +9,6 @@ make distclean clean up all generated artifacts
make install install (set 'DESTDIR' and 'prefix' at will)
make dist[-Z|-gz|-bz2] create tarball containing all sources
make help show this very help page
+make init-po create initial version of the gettext files
+make update-po update the gettext files after changes
+make check-po check sanity of gettext files
diff --git a/makefiles/gmake/i18n.mk b/makefiles/gmake/i18n.mk
new file mode 100644
index 0000000..46dd829
--- /dev/null
+++ b/makefiles/gmake/i18n.mk
@@ -0,0 +1,101 @@
+# handle localization stuff (gettext)
+# (this follows roughly the way Postgresql handles NLS)
+#
+# requires:
+# - CATALOG_NAME: name of the catalog (name of the library or program)
+# will be installed as $(CATALOG_NAME).po in the localedir
+# - GETTEXT_LANGUAGES: list of languages supported
+# - GETTEXT_FILES: list of source files that contain message strings
+# - GETTEXT_TRIGGERS: (optional) list of functions/macros that contain
+# translatable strings
+#
+# provides:
+# - target: init-po
+# - target: update-po
+# - taget: check-po
+
+MSGFMT=msgfmt
+MSGMERGE=msgmerge
+XGETTEXT=xgettext
+
+.PHONY: init-po update-po
+
+PO_FILES = $(addprefix po/, $(addsuffix .po, $(GETTEXT_LANGUAGES)))
+MO_FILES = $(addprefix po/, $(addsuffix .mo, $(GETTEXT_LANGUAGES)))
+
+%.mo : %.po
+ $(MSGFMT) -c -o $@ $<
+
+all-po: $(MO_FILES)
+
+init-po: po/$(CATALOG_NAME).pot
+
+po/$(CATALOG_NAME).pot: $(GETTEXT_FILES)
+ $(XGETTEXT) -n -F -d $(CATALOG_NAME) -o $@ \
+ $(addprefix -k, $(GETTEXT_TRIGGERS)) --flag=_:1:pass-c-format \
+ -d $(CATALOG_NAME) -n -F $(GETTEXT_FILES)
+
+clean_po:
+ echo "Removing po files.."
+
+# TODO: sort out below
+
+# initial creation of the translation table:
+# msginit -l de_CH -o test_gettext_de_CH.po -i test_gettext.pot
+#
+# merge the changes into the translation tables keeping existing
+# translations
+# msgmerge -s -U test_gettext_de_CH.po test_gettext.pot
+#
+# compile message files into binary format:
+# msgfmt -c -v -o test_gettext_de.mo test_gettext_de.po
+
+# a potfile is a set of files, we can't just do this!
+#%.pot: %.c
+# xgettext -k_ --flag=_:1:pass-c-format -d test_gettext -s -o $@ $<
+# touch $@
+
+#test_gettext_de.po: test_gettext.pot
+# msgmerge -s -U $@ -i $<
+# touch $@
+
+#test_gettext_de_CH.po: test_gettext.pot
+# msgmerge -s -U $@ -i $<
+# touch $@
+
+# TODO: big cleanup for GCC compilation flags
+# in older gcc (before 4.2.1) we can't switch off warnings selectivly with a
+# prage. So gettext misses a format attribute which results in a warning
+# test_gettext.c:81: warning: format not a string literal, argument types not checked
+# (Solaris 8, NetBSD)
+# on Solaris 10 we get a system header conflict if we don't specify -std=c99
+#test_gettext.o : test_gettext.c
+# $(CC) -c -g -o $@ $(PLATFORM_COMPILE_FLAGS) $(INCLUDE_DIRS) $<
+
+# LANG setting differs from platform to platform a little bit :-(
+#ifeq "$(PLATFORM)" "LINUX"
+#TEST_LANG = de_CH
+#endif
+#ifeq "$(PLATFORM)" "FREEBSD"
+#TEST_LANG = de_CH.ISO8859-1
+#endif
+#ifeq "$(PLATFORM)" "OPENBSD"
+#TEST_LANG = de_CH.ISO8859-1
+#endif
+#ifeq "$(PLATFORM)" "SUNOS"
+#TEST_LANG = de_CH.iso_8859_1
+#endif
+#ifeq "$(PLATFORM)" "CYGWIN"
+#TEST_LANG = de
+#endif
+#ifeq "$(PLATFORM)" "NETBSD"
+#TEST_LANG = de
+#endif
+
+#local_test: test_gettext_de.mo test_gettext_de_CH.mo
+# @echo "Testing gettext.."
+# @mkdir -p locale/de_CH/LC_MESSAGES
+# @mkdir -p locale/de/LC_MESSAGES
+# @cp test_gettext_de.mo locale/de_CH/LC_MESSAGES/test_gettext.mo
+# @cp test_gettext_de.mo locale/de/LC_MESSAGES/test_gettext.mo
+# @LANG=$(TEST_LANG) ./test_gettext >/dev/null 2>&1
diff --git a/makefiles/gmake/install.mk b/makefiles/gmake/install.mk
index 8a5c3be..4f1e1e5 100644
--- a/makefiles/gmake/install.mk
+++ b/makefiles/gmake/install.mk
@@ -18,6 +18,8 @@ sbindir=$(execdir)/sbin
libdir=$(execdir)/lib
sysconfdir=$(execdir)/etc
includedir=$(execdir)/include
+datadir=$(execdir)/share
+localedir=$(datadir)/locale
.PHONY: install_recursive install local_install
diff --git a/makefiles/gmake/sub.mk b/makefiles/gmake/sub.mk
index 764d274..89c6bbb 100644
--- a/makefiles/gmake/sub.mk
+++ b/makefiles/gmake/sub.mk
@@ -24,3 +24,4 @@ test: $(OBJS) $(TEST_OBJS) $(CPPOBJS) $(BIN_OBJS) $(BINS) $(CPP_BINS) $(TEST_BIN
-include $(TOPDIR)/makefiles/gmake/depend.mk
-include $(TOPDIR)/makefiles/gmake/clean.mk
-include $(TOPDIR)/makefiles/gmake/install.mk
+-include $(TOPDIR)/makefiles/gmake/i18n.mk