Merge my gettext branch (gettext support in build system for GRUB utilities)

This commit is contained in:
Robert Millan 2009-11-17 20:23:06 +00:00
commit 769ae37bfd
18 changed files with 330 additions and 18 deletions

View File

@ -2,6 +2,7 @@
10_*
30_os-prober
40_custom
aclocal.m4
autom4te.cache
build_env.mk
.bzrignore
@ -48,6 +49,8 @@ Makefile
*.mod
mod-*.c
*.pf2
po/*.mo
po/grub.pot
stamp-h
stamp-h1
stamp-h.in

View File

@ -1,3 +1,67 @@
2009-11-17 Robert Millan <rmh.grub@aybabtu.com>
* INSTALL: Document Automake is needed for bootstrap.
* po/ca.po: Fix PO-Revision-Date and Language-Team fields.
* util/grub.d/10_kfreebsd.in (bindir): New variable.
Add gettext initialization.
(kfreebsd_entry): Make menuentry output translatable.
2009-11-17 Robert Millan <rmh.grub@aybabtu.com>
* Makefile.in (XGETTEXT, MSGMERGE, MSGFMT): New variables.
(po/$(PACKAGE).pot): Replace `xgettext' with `$(XGETTEXT)'.
(po/*.po): Replace `msgmerge' with `$(MSGMERGE)'.
(po/%.mo): Replace `msgfmt' with `$(MSGFMT)'.
(LINGUAS): Auto-generate using `po/LINGUAS'.
* po/LINGUAS: New file.
2009-11-17 Robert Millan <rmh.grub@aybabtu.com>
* configure.ac: Call AM_GNU_GETTEXT() (defines localedir, among
other things).
* Makefile.in (CPPFLAGS): Add `-DLOCALEDIR=\"$(localedir)\"'.
* util/i386/pc/grub-mkimage.c (main): Issue setlocale() and
bindtextdomain() calls for gettext initialization.
2009-11-17 Robert Millan <rmh.grub@aybabtu.com>
* gnulib/progname.c: New file (imported from Gnulib).
* gnulib/progname.h: Likewise.
* conf/i386-pc.rmk (grub_mkimage_SOURCES): Add `gnulib/progname.c'.
* util/i386/pc/grub-mkimage.c: Include `"progname.h"'.
(usage): Replace `progname' with `program_name'.
(main): Use set_program_name() for program name initialization.
2009-11-17 Robert Millan <rmh.grub@aybabtu.com>
* conf/common.rmk (grub_mkisofs_CFLAGS): Move `-I$(srcdir)/gnulib'
from here ...
* Makefile.in (CPPFLAGS): ... to here.
2009-11-16 Robert Millan <rmh.grub@aybabtu.com>
* aclocal.m4: Move from here ...
* acinclude.m4: ... to here.
* autogen.sh: Add call to `aclocal'.
* configure.ac: Add AM_INIT_AUTOMAKE() after AC_INIT() call.
2009-11-16 Robert Millan <rmh.grub@aybabtu.com>
* Makefile.in (CLEANFILES): Add `po/*.mo'.
(LINGUAS): New variable.
(all-local): Add `$(foreach lang, $(LINGUAS), po/$(lang).mo)'.
(install-local): Install MO files.
(po/$(PACKAGE).pot, po/*.po, po/%.mo): New rules.
* include/grub/i18n.h: New file.
* po/POTFILES: New file.
* po/ca.po: New file.
* util/grub.d/10_linux.in (bindir): New variable.
Add gettext initialization.
(linux_entry): Make menuentry output translatable.
* util/i386/pc/grub-mkimage.c: Include `<grub/i18n.h>'.
(usage): Make --help output translatable.
(main): Initialize gettext.
2009-11-17 Robert Millan <rmh.grub@aybabtu.com>
* import_gcry.py: New file (written by Vladimir with minor

View File

@ -23,6 +23,7 @@ need the following.
* Ruby 1.6 or later
* Python 2.5.2 or later
* Autoconf 2.59d or later
* Automake 1.10.1 or later
Configuring the GRUB
====================

View File

@ -41,6 +41,13 @@ includedir = @includedir@
pkgdatadir = $(datadir)/`echo @PACKAGE_TARNAME@ | sed '$(transform)'`
pkglibdir = $(libdir)/`echo @PACKAGE_TARNAME@/$(target_cpu)-$(platform) | sed '$(transform)'`
XGETTEXT = @XGETTEXT@
MSGMERGE = @MSGMERGE@
MSGFMT = @MSGFMT@
LINGUAS = $(shell tr '\n' ' ' < $(srcdir)/po/LINGUAS)
PACKAGE = @PACKAGE@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
@ -67,8 +74,8 @@ CC = @CC@
CFLAGS = @CFLAGS@
ASFLAGS = @ASFLAGS@
LDFLAGS = @LDFLAGS@
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/include -Wall -W \
-DGRUB_LIBDIR=\"$(pkglibdir)\"
CPPFLAGS = @CPPFLAGS@ -I$(builddir) -I$(builddir)/include -I$(srcdir)/gnulib -I$(srcdir)/include -Wall -W \
-DGRUB_LIBDIR=\"$(pkglibdir)\" -DLOCALEDIR=\"$(localedir)\"
TARGET_CC = @TARGET_CC@
TARGET_CFLAGS = @TARGET_CFLAGS@
TARGET_ASFLAGS = @TARGET_ASFLAGS@
@ -153,7 +160,7 @@ include $(srcdir)/conf/$(target_cpu)-$(platform).mk
### General targets.
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA)
CLEANFILES += $(pkglib_DATA) $(pkgdata_DATA) po/*.mo
pkglib_DATA += moddep.lst command.lst fs.lst partmap.lst parttool.lst handler.lst
moddep.lst: $(DEFSYMFILES) $(UNDSYMFILES) genmoddep.awk
cat $(DEFSYMFILES) /dev/null \
@ -237,7 +244,7 @@ build_env.mk: Makefile
) > $@
pkglib_BUILDDIR += config.h grub_script.tab.h
all-local: $(PROGRAMS) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES)
all-local: $(PROGRAMS) $(PKGLIB) $(PKGDATA) $(SCRIPTS) $(INFOS) $(MKFILES) $(foreach lang, $(LINGUAS), po/$(lang).mo)
install: install-local
@ -301,6 +308,13 @@ install-local: all
dest="`echo $$file | sed 's,.*/,,'`"; \
$(INSTALL_DATA) $$dir$$file $(DESTDIR)$(libdir)/grub/$$dest; \
done
$(foreach lang, $(LINGUAS), \
$(SHELL) $(mkinstalldirs) $(DESTDIR)/$(datadir)/locale/$(lang)/LC_MESSAGES
@list='po/$(lang).mo'; \
for file in $$list; do \
if test -f "$$file"; then dir=; else dir="$(srcdir)/"; fi; \
$(INSTALL_DATA) $$dir$$file $(DESTDIR)/$(datadir)/locale/$(lang)/LC_MESSAGES/$(PACKAGE).mo; \
done)
$(SHELL) $(mkinstalldirs) $(DESTDIR)$(infodir)
@list='$(info_INFOS)'; \
for file in $$list; do \
@ -455,6 +469,16 @@ gensymlist.sh: gensymlist.sh.in config.status
genkernsyms.sh: genkernsyms.sh.in config.status
$(SHELL) ./config.status
po/$(PACKAGE).pot: po/POTFILES
$(XGETTEXT) --from-code=utf-8 --keyword=_ -f $< -o $@
po/*.po: po/$(PACKAGE).pot
$(MSGMERGE) -U $@ po/$(PACKAGE).pot
po/%.mo: po/%.po
$(MKDIR_P) $$(dirname $@)
$(MSGFMT) -c --statistics -o $@ $^
.PHONY: all install install-strip uninstall clean mostlyclean distclean
.PHONY: maintainer-clean info dvi dist check

View File

@ -2,6 +2,7 @@
set -e
aclocal
autoconf
autoheader

View File

@ -39,7 +39,7 @@ grub_mkisofs_SOURCES = util/mkisofs/eltorito.c \
gnulib/fnmatch.c gnulib/getopt1.c gnulib/getopt.c \
gnulib/error.c
grub_mkisofs_CFLAGS = -D_FILE_OFFSET_BITS=64 \
-I$(srcdir)/util/mkisofs/include -I$(srcdir)/gnulib \
-I$(srcdir)/util/mkisofs/include \
-Wno-all -Werror
# For grub-fstest.

View File

@ -87,7 +87,7 @@ sbin_UTILITIES += grub-emu
endif
# For grub-mkimage.
grub_mkimage_SOURCES = util/i386/pc/grub-mkimage.c util/misc.c \
grub_mkimage_SOURCES = gnulib/progname.c util/i386/pc/grub-mkimage.c util/misc.c \
util/resolve.c lib/LzmaEnc.c lib/LzFind.c
grub_mkimage_CFLAGS = -DGRUB_KERNEL_MACHINE_LINK_ADDR=$(GRUB_KERNEL_MACHINE_LINK_ADDR)
util/i386/pc/grub-mkimage.c_DEPENDENCIES = Makefile

View File

@ -32,6 +32,8 @@ dnl type.
AC_INIT([GRUB],[1.97],[bug-grub@gnu.org])
AM_INIT_AUTOMAKE()
AM_GNU_GETTEXT()
AC_PREREQ(2.59d)
AC_CONFIG_SRCDIR([include/grub/dl.h])
AC_CONFIG_HEADER([config.h])

78
gnulib/progname.c Normal file
View File

@ -0,0 +1,78 @@
/* Program name management.
Copyright (C) 2001-2003, 2005-2009 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
/* Specification. */
#undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */
#include "progname.h"
#include <errno.h> /* get program_invocation_name declaration */
#include <string.h>
/* String containing name the program is called with.
To be initialized by main(). */
const char *program_name = NULL;
/* Set program_name, based on argv[0]. */
void
set_program_name (const char *argv0)
{
/* libtool creates a temporary executable whose name is sometimes prefixed
with "lt-" (depends on the platform). It also makes argv[0] absolute.
But the name of the temporary executable is a detail that should not be
visible to the end user and to the test suite.
Remove this "<dirname>/.libs/" or "<dirname>/.libs/lt-" prefix here. */
const char *slash;
const char *base;
slash = strrchr (argv0, '/');
base = (slash != NULL ? slash + 1 : argv0);
if (base - argv0 >= 7 && strncmp (base - 7, "/.libs/", 7) == 0)
{
argv0 = base;
if (strncmp (base, "lt-", 3) == 0)
{
argv0 = base + 3;
/* On glibc systems, remove the "lt-" prefix from the variable
program_invocation_short_name. */
#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME
program_invocation_short_name = (char *) argv0;
#endif
}
}
/* But don't strip off a leading <dirname>/ in general, because when the user
runs
/some/hidden/place/bin/cp foo foo
he should get the error message
/some/hidden/place/bin/cp: `foo' and `foo' are the same file
not
cp: `foo' and `foo' are the same file
*/
program_name = argv0;
/* On glibc systems, the error() function comes from libc and uses the
variable program_invocation_name, not program_name. So set this variable
as well. */
#if HAVE_DECL_PROGRAM_INVOCATION_NAME
program_invocation_name = (char *) argv0;
#endif
}

60
gnulib/progname.h Normal file
View File

@ -0,0 +1,60 @@
/* Program name management.
Copyright (C) 2001-2004, 2006 Free Software Foundation, Inc.
Written by Bruno Haible <haible@clisp.cons.org>, 2001.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifndef _PROGNAME_H
#define _PROGNAME_H
/* Programs using this file should do the following in main():
set_program_name (argv[0]);
*/
#ifdef __cplusplus
extern "C" {
#endif
/* String containing name the program is called with. */
extern const char *program_name;
/* Set program_name, based on argv[0]. */
extern void set_program_name (const char *argv0);
#if ENABLE_RELOCATABLE
/* Set program_name, based on argv[0], and original installation prefix and
directory, for relocatability. */
extern void set_program_name_and_installdir (const char *argv0,
const char *orig_installprefix,
const char *orig_installdir);
#undef set_program_name
#define set_program_name(ARG0) \
set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR)
/* Return the full pathname of the current executable, based on the earlier
call to set_program_name_and_installdir. Return NULL if unknown. */
extern char *get_full_program_name (void);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _PROGNAME_H */

30
include/grub/i18n.h Normal file
View File

@ -0,0 +1,30 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2009 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GRUB_I18N_H
#define GRUB_I18N_H 1
#ifdef GRUB_UTIL
# include <locale.h>
# include <libintl.h>
# define _(str) gettext(str)
#else
# define _(str) str
#endif
#endif /* GRUB_I18N_H */

1
po/LINGUAS Normal file
View File

@ -0,0 +1 @@
ca

2
po/POTFILES Normal file
View File

@ -0,0 +1,2 @@
# List of files which contain translatable strings.
util/i386/pc/grub-mkimage.c

20
po/ca.po Normal file
View File

@ -0,0 +1,20 @@
# Copyright (C) 2009 Free Software Foundation, Inc
# This file is distributed under the same license as the GNU GRUB package.
# Robert Millan <rmh.grub@aybabtu.com>, 2009.
#
msgid ""
msgstr ""
"Project-Id-Version: GNU GRUB\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2009-11-16 00:05+0100\n"
"PO-Revision-Date: 2009-11-17 12:26+0100\n"
"Last-Translator: Robert Millan <rmh.grub@aybabtu.com>\n"
"Language-Team: None <no-team-yet@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: util/i386/pc/grub-mkimage.c:322
#, c-format
msgid "Try ``%s --help'' for more information.\n"
msgstr "Proveu «%s --help» per a obtenir més informació.\n"

View File

@ -18,9 +18,14 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
. ${bindir}/gettext.sh
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@LOCALEDIR@
case "${GRUB_DISTRIBUTOR}" in
Debian) OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" ;;
*) OS="FreeBSD" ;;
@ -28,9 +33,12 @@ esac
kfreebsd_entry ()
{
cat << EOF
menuentry "$1" {
EOF
os="$1"
version="$2"
recovery="$3" # not used yet
args="$4" # not used yet
title="$(gettext "%s, with kFreeBSD %s")"
printf "menuentry \"${title}\" {" ${os} ${version}
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi
@ -100,7 +108,7 @@ while [ "x$list" != "x" ] ; do
acpi_ko_rel_dirname=`make_system_path_relative_to_its_root $acpi_ko_dirname`
fi
kfreebsd_entry "${OS}, kFreeBSD ${version}"
kfreebsd_entry "${OS}" "${version}"
list=`echo $list | tr ' ' '\n' | grep -vx $kfreebsd | tr '\n' ' '`
done

View File

@ -18,9 +18,14 @@
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
. ${libdir}/grub/grub-mkconfig_lib
. ${bindir}/gettext.sh
export TEXTDOMAIN=@PACKAGE@
export TEXTDOMAINDIR=@LOCALEDIR@
if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then
OS=GNU/Linux
else
@ -44,15 +49,22 @@ fi
linux_entry ()
{
cat << EOF
menuentry "$1" {
EOF
os="$1"
version="$2"
recovery="$3"
args="$4"
if ${recovery} ; then
title="$(gettext "%s, with Linux %s (recovery mode)")"
else
title="$(gettext "%s, with Linux %s")"
fi
printf "menuentry \"${title}\" {" ${os} ${version}
if [ -z "${prepare_boot_cache}" ]; then
prepare_boot_cache="$(prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/")"
fi
printf '%s\n' "${prepare_boot_cache}"
cat << EOF
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro $2
linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}
EOF
if test -n "${initrd}" ; then
cat << EOF
@ -95,10 +107,10 @@ while [ "x$list" != "x" ] ; do
linux_root_device_thisversion=${GRUB_DEVICE}
fi
linux_entry "${OS}, with Linux ${version}" \
linux_entry "${OS}" "${version}" false \
"${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then
linux_entry "${OS}, with Linux ${version} (recovery mode)" \
linux_entry "${OS}" "${version}" true \
"single ${GRUB_CMDLINE_LINUX}"
fi

View File

@ -22,6 +22,7 @@
#include <grub/machine/boot.h>
#include <grub/machine/kernel.h>
#include <grub/machine/memory.h>
#include <grub/i18n.h>
#include <grub/kernel.h>
#include <grub/disk.h>
#include <grub/util/misc.h>
@ -36,6 +37,8 @@
#define _GNU_SOURCE 1
#include <getopt.h>
#include "progname.h"
#ifdef ENABLE_LZMA
#include <grub/lib/LzmaEnc.h>
@ -315,7 +318,7 @@ static void
usage (int status)
{
if (status)
fprintf (stderr, "Try ``grub-mkimage --help'' for more information.\n");
fprintf (stderr, _("Try ``%s --help'' for more information.\n"), program_name);
else
printf ("\
Usage: grub-mkimage [OPTION]... [MODULES]\n\
@ -347,7 +350,10 @@ main (int argc, char *argv[])
char *config = NULL;
FILE *fp = stdout;
progname = "grub-mkimage";
set_program_name (argv[0]);
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
while (1)
{