[patch] build and install translations (and manpage)

Benjamin Pineau benjamin_pineau at zouh.org
Thu May 24 05:10:55 PDT 2007


Hi,

The attached patch modifiy the Makefiles to build (from sources .po to
binaries .mo, with msgfmt) and installs (in
/usr/share/locale/*/LC_MESSAGES/powerpot.mo) the translations files in po/. 
It also gzip and install the manpage.

Notes :
- The patch create a new po/Makefile file, so it must be applied with "patch
  -p0" (without "-p0" everything ends up in main ./Makefile), and be svn added.
- The install path LOCALESDIR is an overridable make variable, but for now only
  the default path will work (/usr/share/locale/ is hardcoded in powertop.c).

-------------- next part --------------
 
Index: Makefile
===================================================================
--- Makefile	(r??vision 76)
+++ Makefile	(copie de travail)
@@ -1,14 +1,25 @@
 BINDIR=/usr/bin
+LOCALESDIR=/usr/share/locale
+MANDIR=/usr/share/man/man1
 WARNFLAGS=-Wall
 CFLAGS?=-O2 -g ${WARNFLAGS}
 CC?=gcc
 
 powertop: powertop.c config.c process.c misctips.c bluetooth.c display.c Makefile powertop.h
 	$(CC) ${CFLAGS}  powertop.c config.c process.c misctips.c bluetooth.c display.c -lncurses -o powertop
+	@(cd po/ && $(MAKE))
 
-install: powertop
+powertop.1.gz: powertop.1
+	gzip -c $< > $@
+
+install: powertop powertop.1.gz
 	mkdir -p ${DESTDIR}${BINDIR}
 	cp powertop ${DESTDIR}${BINDIR}
-	
+	mkdir -p ${DESTDIR}${MANDIR}
+	cp powertop.1.gz ${DESTDIR}${MANDIR}
+	@(cd po/ && env LOCALESDIR=$(LOCALESDIR) DESTDIR=$(DESTDIR) $(MAKE) $@)
+
 clean:
-	rm -f *~ powertop
+	rm -f *~ powertop powertop.1.gz
+	@(cd po/ && $(MAKE) $@)
+

Index: po/Makefile
===================================================================
--- po/Makefile	(r??vision 0)
+++ po/Makefile	(r??vision 0)
@@ -0,0 +1,20 @@
+SRC=$(wildcard *.po)
+OBJ= $(SRC:.po=.mo)
+INST= $(SRC:.po=.inst)
+
+translations: $(OBJ)
+	
+%.mo: %.po
+	- at msgfmt -o $@ -v $<
+
+clean:
+	rm -f *.mo
+
+# hack to automate installation dynamicaly, without previous knowledge of 
+# the po/mo file list (we fool make by pretending the need for .inst files).
+install: $(OBJ) $(INST)
+
+%.inst: %.mo
+	mkdir -p $(DESTDIR)$(LOCALESDIR)/$*/LC_MESSAGES/
+	cp -f $< $(DESTDIR)$(LOCALESDIR)/$*/LC_MESSAGES/powertop.mo
+


More information about the Power mailing list