comparison 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
comparison
equal deleted inserted replaced
7:56a7ed833d0a 8:58a3312a1c59
1 INSTALL := install 1 INSTALL := install
2 INSTALL.exec := $(INSTALL) -D -m 0755 2 INSTALL.exec := $(INSTALL) -D -m 0755
3 INSTALL.data := $(INSTALL) -D -m 0644 3 INSTALL.data := $(INSTALL) -D -m 0644
4 SED := sed 4 SED := sed
5 MSGFMT := msgfmt
6 INTLTOOL_UPDATE := intltool-update
7 INTLTOOL_MERGE := intltool-merge
5 8
6 DESTDIR ?= 9 DESTDIR ?=
7 prefix ?= /usr/local 10 prefix ?= /usr/local
8 bindir ?= $(prefix)/bin 11 bindir ?= $(prefix)/bin
12 datadir ?= $(prefix)/share
13 localedir ?= $(datadir)/locale
9 sysconfdir ?= /etc 14 sysconfdir ?= /etc
10 xdgautostartdir ?= $(sysconfdir)/xdg/autostart 15 xdgautostartdir ?= $(sysconfdir)/xdg/autostart
11 16
12 PACKAGE = pk-update-icon 17 PACKAGE = pk-update-icon
13 VERSION = 0.1 18 VERSION = 0.1
14 OBJS = main.o notify.o packagekit.o 19 OBJS = main.o notify.o packagekit.o
15 AUTOSTART_FILE = $(PACKAGE).desktop 20 AUTOSTART_FILE = $(PACKAGE).desktop
21 MOFILES := $(patsubst %.po,%.mo,$(wildcard po/*.po))
22 POTFILE = po/$(PACKAGE).pot
16 CPPFLAGS := $(shell pkg-config --cflags gtk+-2.0 libnotify packagekit-glib2) \ 23 CPPFLAGS := $(shell pkg-config --cflags gtk+-2.0 libnotify packagekit-glib2) \
17 -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE 24 -DI_KNOW_THE_PACKAGEKIT_GLIB2_API_IS_SUBJECT_TO_CHANGE \
25 -DPACKAGE="\"$(PACKAGE)\"" \
26 -DLOCALEDIR="\"$(localedir)\""
18 LDLIBS := $(shell pkg-config --libs gtk+-2.0 libnotify packagekit-glib2) 27 LDLIBS := $(shell pkg-config --libs gtk+-2.0 libnotify packagekit-glib2)
19 28
20 .DEFAULT_TARGET = all 29 .DEFAULT_TARGET = all
21 30
22 .PHONY: all clean install 31 .PHONY: all clean install
23 32
24 all: $(PACKAGE) 33 all: $(PACKAGE) $(MOFILES) $(AUTOSTART_FILE)
25 34
26 $(PACKAGE): $(OBJS) 35 $(PACKAGE): $(OBJS)
27 $(LINK.o) $^ $(LDLIBS) -o $@ 36 $(LINK.o) $^ $(LDLIBS) -o $@
37
38 $(POTFILE): po/POTFILES.in
39 cd po/ && $(INTLTOOL_UPDATE) --pot --gettext-package="$(PACKAGE)"
40
41 pot: $(POTFILE)
42
43 update-po: $(POTFILE)
44 cd po/ && for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \
45 $(INTLTOOL_UPDATE) --dist --gettext-package="$(PACKAGE)" \
46 $${lang}; \
47 done
28 48
29 %.o: %.c 49 %.o: %.c
30 $(COMPILE.c) -MD -o $@ $< 50 $(COMPILE.c) -MD -o $@ $<
31 @cp $*.d $*.P; \ 51 @cp $*.d $*.P; \
32 $(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ 52 $(SED) -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
33 -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \ 53 -e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $*.P; \
34 rm -f $*.d 54 rm -f $*.d
35 55
56 %.desktop: %.desktop.in $(MOFILES)
57 $(INTLTOOL_MERGE) --desktop-style --utf8 po $< $@
58
59 %.mo: %.po
60 $(MSGFMT) -o $@ $<
61
36 install: 62 install:
37 $(INSTALL.exec) $(PACKAGE) $(DESTDIR)$(bindir)/$(PACKAGE) 63 $(INSTALL.exec) $(PACKAGE) $(DESTDIR)$(bindir)/$(PACKAGE)
38 $(INSTALL.data) $(AUTOSTART_FILE) \ 64 $(INSTALL.data) $(AUTOSTART_FILE) \
39 $(DESTDIR)$(xdgautostartdir)/$(AUTOSTART_FILE) 65 $(DESTDIR)$(xdgautostartdir)/$(AUTOSTART_FILE)
66 for lang in $(patsubst po/%.mo,%,$(MOFILES)); do \
67 $(INSTALL.data) po/$${lang}.mo \
68 $(DESTDIR)$(LOCALEDIR)/$${lang}/$(PACKAGE).mo; \
69 done
40 70
41 clean: 71 clean:
42 -rm -f $(PACKAGE) $(OBJS) 72 rm -f $(PACKAGE) $(OBJS) $(POTFILE) $(MOFILES) $(AUTOSTART_FILE)
43 73
44 -include $(patsubst %.o,%.P,$(OBJS)) 74 -include $(patsubst %.o,%.P,$(OBJS))