diff Makefile @ 8:58a3312a1c59

add internationalization support add German translation --HG-- rename : pk-update-icon.desktop => pk-update-icon.desktop.in
author Guido Berhoerster <guido@berhoerster.name>
date Tue, 11 Oct 2011 17:07:49 +0200
parents 56a7ed833d0a
children 0e50d3652326
line wrap: on
line diff
--- a/Makefile	Tue Oct 11 17:07:49 2011 +0200
+++ b/Makefile	Tue Oct 11 17:07:49 2011 +0200
@@ -2,10 +2,15 @@
 INSTALL.exec :=	$(INSTALL) -D -m 0755
 INSTALL.data :=	$(INSTALL) -D -m 0644
 SED :=		sed
+MSGFMT :=	msgfmt
+INTLTOOL_UPDATE :=	intltool-update
+INTLTOOL_MERGE :=	intltool-merge
 
 DESTDIR ?=
 prefix ?=	/usr/local
 bindir ?=	$(prefix)/bin
+datadir ?=	$(prefix)/share
+localedir ?=	$(datadir)/locale
 sysconfdir ?=	/etc
 xdgautostartdir ?=	$(sysconfdir)/xdg/autostart
 
@@ -13,19 +18,34 @@
 VERSION =	0.1
 OBJS =		main.o notify.o packagekit.o
 AUTOSTART_FILE =	$(PACKAGE).desktop
+MOFILES :=	$(patsubst %.po,%.mo,$(wildcard po/*.po))
+POTFILE =	po/$(PACKAGE).pot
 CPPFLAGS :=	$(shell pkg-config --cflags gtk+-2.0 libnotify packagekit-glib2) \
-		-DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE
+		-DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE \
+		-DPACKAGE="\"$(PACKAGE)\"" \
+		-DLOCALEDIR="\"$(localedir)\""
 LDLIBS :=	$(shell pkg-config --libs gtk+-2.0 libnotify packagekit-glib2)
 
 .DEFAULT_TARGET = all
 
 .PHONY: all clean install
 
-all: $(PACKAGE)
+all: $(PACKAGE) $(MOFILES) $(AUTOSTART_FILE)
 
 $(PACKAGE): $(OBJS)
 	$(LINK.o) $^ $(LDLIBS) -o $@
 
+$(POTFILE): po/POTFILES.in
+	cd po/ && $(INTLTOOL_UPDATE) --pot --gettext-package="$(PACKAGE)"
+
+pot: $(POTFILE)
+
+update-po: $(POTFILE)
+	cd po/ && for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \
+		$(INTLTOOL_UPDATE) --dist --gettext-package="$(PACKAGE)" \
+				   $${lang}; \
+	done
+
 %.o: %.c
 	$(COMPILE.c) -MD -o $@ $<
 	@cp $*.d $*.P; \
@@ -33,12 +53,22 @@
 	       -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
 	rm -f $*.d
 
+%.desktop: %.desktop.in $(MOFILES)
+	$(INTLTOOL_MERGE) --desktop-style --utf8 po $< $@
+
+%.mo: %.po
+	$(MSGFMT) -o $@ $<
+
 install:
 	$(INSTALL.exec) $(PACKAGE) $(DESTDIR)$(bindir)/$(PACKAGE)
 	$(INSTALL.data) $(AUTOSTART_FILE) \
 			$(DESTDIR)$(xdgautostartdir)/$(AUTOSTART_FILE)
+	for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \
+		$(INSTALL.data) po/$${lang}.mo \
+			$(DESTDIR)$(LOCALEDIR)/$${lang}/$(PACKAGE).mo; \
+	done
 
 clean:
-	-rm -f $(PACKAGE) $(OBJS)
+	rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(AUTOSTART_FILE)
 
 -include $(patsubst %.o,%.P,$(OBJS))