From: Bruno Haible Date: Mon, 17 Mar 2003 09:38:55 +0000 (+0000) Subject: Support for relocatable installation. X-Git-Tag: v0.12~148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e71d76e1cdca1bcdbb9c0dbbeb49e8921a6289ba;p=thirdparty%2Fgettext.git Support for relocatable installation. --- diff --git a/ChangeLog b/ChangeLog index 3831e262a..a71aeb06e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * config/config.libpath: New file. + * config/install-reloc: New file. + * config/reloc-ldflags: New file. + * Makefile.am (EXTRA_DIST): Add them. + * config/compile: New file, from automake-1.7.2. + * INSTALL: Document --enable-relocatable and --with-libintl-prefix. + 2003-02-27 Bruno Haible * configure.ac: Include AC_CANONICAL_HOST, AC_ARG_ENABLE, AC_ARG_WITH, diff --git a/INSTALL b/INSTALL index 863ccc31e..3c7993200 100644 --- a/INSTALL +++ b/INSTALL @@ -104,6 +104,39 @@ you can set and what kinds of files go in them. with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. +Relocatable Installation +======================== + + By default, `make install' will install a package with hardwired +file names, and the package will not work correctly when copied or +moved to a different location in the filesystem. + + Some packages pay attention to the `--enable-relocatable' option to +`configure'. This option makes the entire installed package +relocatable. This means, it can be moved or copied to a different +location on the filesystem. It is possible to make symlinks to the +installed and moved programs, and invoke them through the symlink. It +is possible to do the same thing with a hard link _only_ if the hard +linked file is in the same directory as the real program. + + For reliability it is best to give together with --enable-relocatable +a `--prefix' option pointing to an otherwise unused (and never used +again) directory, for example, `--prefix=/tmp/inst$$'. This is +recommended because on some OSes the executables remember the location +of shared libraries (and prefer them over LD_LIBRARY_PATH !), therefore +such an executable will look for its shared libraries first in the +original installation directory and only then in the current +installation directory. + + Installation with `--enable-relocatable' will not work for setuid / +setgid executables. (This is because such an executable kills its +LD_LIBRARY_PATH variable when it is launched.) + + The runtime penalty and size penalty are nearly zero on Linux 2.2 or +newer (just one system call more when an executable is launched), and +small on other systems (the wrapper program just sets an environment +variable and execs the real program). + Optional Features ================= @@ -121,7 +154,13 @@ you can use the `configure' options `--x-includes=DIR' and For packages that use the GNU libiconv library, you can use the `configure' option `--with-libiconv-prefix' to specify the prefix you -used while installing libiconv. +used while installing GNU libiconv. This option is not necessary if +that other prefix is the same as the one now specified through --prefix. + + For packages that use the GNU libintl library, you can use the +`configure' option `--with-libintl-prefix' to specify the prefix you +used while installing GNU gettext-runtime. This option is not necessary if +that other prefix is the same as the one now specified through --prefix. Particular Systems ================== diff --git a/Makefile.am b/Makefile.am index 22367901f..8865d4928 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,6 +23,7 @@ SUBDIRS = autoconf-lib-link gettext-runtime gettext-tools EXTRA_DIST = \ version.sh PACKAGING README.gemtext ChangeLog.0 \ + config/config.libpath config/reloc-ldflags config/install-reloc \ config/m4/fixautomake.m4 \ config/m4/libtool.m4 diff --git a/autoconf-lib-link/ChangeLog b/autoconf-lib-link/ChangeLog index d5cd0cbd6..2141a2f95 100644 --- a/autoconf-lib-link/ChangeLog +++ b/autoconf-lib-link/ChangeLog @@ -1,3 +1,8 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * INSTALL: Document --enable-relocatable and --with-libintl-prefix. + 2003-02-22 Bruno Haible * Makefile.am (ps, pdf): Remove rules, redundant with automake 1.7.2. diff --git a/autoconf-lib-link/INSTALL b/autoconf-lib-link/INSTALL index 863ccc31e..3c7993200 100644 --- a/autoconf-lib-link/INSTALL +++ b/autoconf-lib-link/INSTALL @@ -104,6 +104,39 @@ you can set and what kinds of files go in them. with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. +Relocatable Installation +======================== + + By default, `make install' will install a package with hardwired +file names, and the package will not work correctly when copied or +moved to a different location in the filesystem. + + Some packages pay attention to the `--enable-relocatable' option to +`configure'. This option makes the entire installed package +relocatable. This means, it can be moved or copied to a different +location on the filesystem. It is possible to make symlinks to the +installed and moved programs, and invoke them through the symlink. It +is possible to do the same thing with a hard link _only_ if the hard +linked file is in the same directory as the real program. + + For reliability it is best to give together with --enable-relocatable +a `--prefix' option pointing to an otherwise unused (and never used +again) directory, for example, `--prefix=/tmp/inst$$'. This is +recommended because on some OSes the executables remember the location +of shared libraries (and prefer them over LD_LIBRARY_PATH !), therefore +such an executable will look for its shared libraries first in the +original installation directory and only then in the current +installation directory. + + Installation with `--enable-relocatable' will not work for setuid / +setgid executables. (This is because such an executable kills its +LD_LIBRARY_PATH variable when it is launched.) + + The runtime penalty and size penalty are nearly zero on Linux 2.2 or +newer (just one system call more when an executable is launched), and +small on other systems (the wrapper program just sets an environment +variable and execs the real program). + Optional Features ================= @@ -121,7 +154,13 @@ you can use the `configure' options `--x-includes=DIR' and For packages that use the GNU libiconv library, you can use the `configure' option `--with-libiconv-prefix' to specify the prefix you -used while installing libiconv. +used while installing GNU libiconv. This option is not necessary if +that other prefix is the same as the one now specified through --prefix. + + For packages that use the GNU libintl library, you can use the +`configure' option `--with-libintl-prefix' to specify the prefix you +used while installing GNU gettext-runtime. This option is not necessary if +that other prefix is the same as the one now specified through --prefix. Particular Systems ================== diff --git a/gettext-runtime/ChangeLog b/gettext-runtime/ChangeLog index a28ea74ec..30214489d 100644 --- a/gettext-runtime/ChangeLog +++ b/gettext-runtime/ChangeLog @@ -1,3 +1,11 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * configure.ac: Invoke AC_RELOCATABLE, gt_STDBOOL_H, gl_FUNC_ALLOCA, + AC_REPLACE_FUNCS([memmove]), gt_FUNC_SETENV, gl_FUNC_STRERROR, + gl_PATHMAX, gl_XREADLINK, gl_CANONICALIZE. + * INSTALL: Document --enable-relocatable and --with-libintl-prefix. + 2003-02-22 Bruno Haible * Makefile.am (ps, pdf): Remove rules, redundant with automake 1.7.2. diff --git a/gettext-runtime/INSTALL b/gettext-runtime/INSTALL index 863ccc31e..3c7993200 100644 --- a/gettext-runtime/INSTALL +++ b/gettext-runtime/INSTALL @@ -104,6 +104,39 @@ you can set and what kinds of files go in them. with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. +Relocatable Installation +======================== + + By default, `make install' will install a package with hardwired +file names, and the package will not work correctly when copied or +moved to a different location in the filesystem. + + Some packages pay attention to the `--enable-relocatable' option to +`configure'. This option makes the entire installed package +relocatable. This means, it can be moved or copied to a different +location on the filesystem. It is possible to make symlinks to the +installed and moved programs, and invoke them through the symlink. It +is possible to do the same thing with a hard link _only_ if the hard +linked file is in the same directory as the real program. + + For reliability it is best to give together with --enable-relocatable +a `--prefix' option pointing to an otherwise unused (and never used +again) directory, for example, `--prefix=/tmp/inst$$'. This is +recommended because on some OSes the executables remember the location +of shared libraries (and prefer them over LD_LIBRARY_PATH !), therefore +such an executable will look for its shared libraries first in the +original installation directory and only then in the current +installation directory. + + Installation with `--enable-relocatable' will not work for setuid / +setgid executables. (This is because such an executable kills its +LD_LIBRARY_PATH variable when it is launched.) + + The runtime penalty and size penalty are nearly zero on Linux 2.2 or +newer (just one system call more when an executable is launched), and +small on other systems (the wrapper program just sets an environment +variable and execs the real program). + Optional Features ================= @@ -121,7 +154,13 @@ you can use the `configure' options `--x-includes=DIR' and For packages that use the GNU libiconv library, you can use the `configure' option `--with-libiconv-prefix' to specify the prefix you -used while installing libiconv. +used while installing GNU libiconv. This option is not necessary if +that other prefix is the same as the one now specified through --prefix. + + For packages that use the GNU libintl library, you can use the +`configure' option `--with-libintl-prefix' to specify the prefix you +used while installing GNU gettext-runtime. This option is not necessary if +that other prefix is the same as the one now specified through --prefix. Particular Systems ================== diff --git a/gettext-runtime/configure.ac b/gettext-runtime/configure.ac index f09aa5fc1..5db424212 100644 --- a/gettext-runtime/configure.ac +++ b/gettext-runtime/configure.ac @@ -53,20 +53,30 @@ dnl Check for build configuration. AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL +AC_RELOCATABLE + AC_DEFINE(_GNU_SOURCE, 1, [Make sure we see all GNU extensions.]) dnl Checks for libraries. dnl Checks for header files. AC_CHECK_HEADERS(string.h) +gt_STDBOOL_H dnl Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T dnl Checks for library functions. +gl_FUNC_ALLOCA AC_FUNC_VPRINTF AC_CHECK_FUNCS([setlocale strerror]) +AC_REPLACE_FUNCS([memmove]) +gt_FUNC_SETENV +gl_FUNC_STRERROR gt_FUNC_ERROR_AT_LINE +gl_PATHMAX +gl_XREADLINK +gl_CANONICALIZE dnl These are the only lines required to internationalize the package. dnl (OK, not quite, the AC_CONFIG_FILES has also some parts.) diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog index 49ed8a0be..cc86b4147 100644 --- a/gettext-runtime/intl/ChangeLog +++ b/gettext-runtime/intl/ChangeLog @@ -1,3 +1,20 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * relocatable.h: New file. + * relocatable.c: New file. + * libgnuintl.h (libintl_set_relocation_prefix): New declaration. + * localealias.c: Include relocatable.h. + (read_alias_file): Relocate LOCALE_ALIAS_PATH element. + * localcharset.c: Include relocatable.h. + (get_charset_aliases): Relocate LIBDIR value. + * Makefile.in (DEFS): Define also ENABLE_RELOCATABLE, IN_LIBRARY, + INSTALLDIR, NO_XMALLOC, set_relocation_prefix, relocate. + (HEADERS): Add relocatable.h. + (SOURCES): Add relocatable.c. + (OBJECTS): Add relocatable.$lo. + (relocatable.$lo): New rule. + 2003-02-28 Bruno Haible * Makefile.in (mkinstalldirs): Simplify. Prepending "$(top_builddir)/" diff --git a/gettext-runtime/intl/Makefile.in b/gettext-runtime/intl/Makefile.in index b6b048548..ce49f05fd 100644 --- a/gettext-runtime/intl/Makefile.in +++ b/gettext-runtime/intl/Makefile.in @@ -51,7 +51,10 @@ YACC = @INTLBISON@ -y -d YFLAGS = --name-prefix=__gettext DEFS = -DLOCALEDIR=\"$(localedir)\" -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ --DLIBDIR=\"$(libdir)\" -DIN_LIBINTL @DEFS@ +-DLIBDIR=\"$(libdir)\" -DIN_LIBINTL \ +-DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DINSTALLDIR=\"$(libdir)\" -DNO_XMALLOC \ +-Dset_relocation_prefix=libintl_set_relocation_prefix \ +-Drelocate=libintl_relocate @DEFS@ CPPFLAGS = @CPPFLAGS@ CFLAGS = @CFLAGS@ LDFLAGS = @LDFLAGS@ @@ -66,6 +69,7 @@ HEADERS = \ plural-exp.h \ eval-plural.h \ localcharset.h \ + relocatable.h \ os2compat.h \ libgnuintl.h SOURCES = \ @@ -86,6 +90,7 @@ SOURCES = \ plural.y \ plural-exp.c \ localcharset.c \ + relocatable.c \ localename.c \ log.c \ osdep.c \ @@ -109,6 +114,7 @@ OBJECTS = \ plural.$lo \ plural-exp.$lo \ localcharset.$lo \ + relocatable.$lo \ localename.$lo \ log.$lo \ osdep.$lo \ @@ -193,6 +199,8 @@ plural-exp.lo: $(srcdir)/plural-exp.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/plural-exp.c localcharset.lo: $(srcdir)/localcharset.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localcharset.c +relocatable.lo: $(srcdir)/relocatable.c + $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/relocatable.c localename.lo: $(srcdir)/localename.c $(LIBTOOL) --mode=compile $(COMPILE) $(srcdir)/localename.c log.lo: $(srcdir)/log.c @@ -392,6 +400,7 @@ dcigettext.$lo: $(srcdir)/hash-string.h explodename.$lo l10nflist.$lo: $(srcdir)/loadinfo.h dcigettext.$lo loadmsgcat.$lo plural.$lo plural-exp.$lo: $(srcdir)/plural-exp.h dcigettext.$lo: $(srcdir)/eval-plural.h +localealias.$lo localcharset.$lo relocatable.$lo: $(srcdir)/relocatable.h tags: TAGS diff --git a/gettext-runtime/intl/libgnuintl.h b/gettext-runtime/intl/libgnuintl.h index 3ae78abed..4123c44ad 100644 --- a/gettext-runtime/intl/libgnuintl.h +++ b/gettext-runtime/intl/libgnuintl.h @@ -1,5 +1,5 @@ /* Message catalogs for internationalization. - Copyright (C) 1995-1997, 2000-2002 Free Software Foundation, Inc. + Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -289,6 +289,18 @@ extern char *bind_textdomain_codeset _INTL_PARAMS ((const char *__domainname, #endif +/* Support for relocatable packages. */ + +/* Sets the original and the current installation prefix of the package. + Relocation simply replaces a pathname starting with the original prefix + by the corresponding pathname with the current prefix instead. Both + prefixes should be directory names without trailing slash (i.e. use "" + instead of "/"). */ +#define libintl_set_relocation_prefix libintl_set_relocation_prefix +extern void libintl_set_relocation_prefix (const char *orig_prefix, + const char *curr_prefix); + + #ifdef __cplusplus } #endif diff --git a/gettext-runtime/intl/localcharset.c b/gettext-runtime/intl/localcharset.c index 6676e8b50..998882470 100644 --- a/gettext-runtime/intl/localcharset.c +++ b/gettext-runtime/intl/localcharset.c @@ -67,6 +67,12 @@ # include #endif +#if ENABLE_RELOCATABLE +# include "relocatable.h" +#else +# define relocate(pathname) (pathname) +#endif + #if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__ /* Win32, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') @@ -110,7 +116,7 @@ get_charset_aliases () { #if !defined WIN32 FILE *fp; - const char *dir = LIBDIR; + const char *dir = relocate (LIBDIR); const char *base = "charset.alias"; char *file_name; diff --git a/gettext-runtime/intl/localealias.c b/gettext-runtime/intl/localealias.c index 785540307..12ad821e6 100644 --- a/gettext-runtime/intl/localealias.c +++ b/gettext-runtime/intl/localealias.c @@ -1,5 +1,5 @@ /* Handle aliases for locale names. - Copyright (C) 1995-1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published @@ -57,6 +57,12 @@ char *alloca (); #include "gettextP.h" +#if ENABLE_RELOCATABLE +# include "relocatable.h" +#else +# define relocate(pathname) (pathname) +#endif + /* @@ end of prolog @@ */ #ifdef _LIBC @@ -222,7 +228,7 @@ read_alias_file (fname, fname_len) memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile); #endif - fp = fopen (full_fname, "r"); + fp = fopen (relocate (full_fname), "r"); freea (full_fname); if (fp == NULL) return 0; diff --git a/gettext-runtime/lib/ChangeLog b/gettext-runtime/lib/ChangeLog index f9fdce9a6..f2b8b074f 100644 --- a/gettext-runtime/lib/ChangeLog +++ b/gettext-runtime/lib/ChangeLog @@ -1,3 +1,32 @@ +2003-02-28 Bruno Haible + + Cleanup and support for relocatable installation. + * basename.h: Remove file, replaced with the copy in + ../../gettext-tools/lib. + * basename.c: Likewise. + * error.h: Likewise. + * error.c: Likewise. + * exit.h: Likewise. + * getopt.h: Likewise. + * getopt.c: Likewise. + * getopt1.c: Likewise. + * xmalloc.h: Likewise. + * xmalloc.c: Likewise. + * alloca.c: New file, trivial link to ../../gettext-tools/lib. + * canonicalize.c: New file, trivial link to ../../gettext-tools/lib. + * memmove.c: New file, trivial link to ../../gettext-tools/lib. + * relocatable.c: New file, trivial link to ../../gettext-tools/lib. + * setenv.c: New file, trivial link to ../../gettext-tools/lib. + * strerror.c: New file, trivial link to ../../gettext-tools/lib. + * unsetenv.c: New file, trivial link to ../../gettext-tools/lib. + * Makefile.am (libgrt_a_SOURCES): Add pathmax.h, progname.h, + progname.c, xstrdup.c, xreadlink.h, xreadlink.c. Use references to + ../../gettext-tools/lib. + (LIBADD_SOURCE): New variable. + (EXTRA_DIST, MOSTLYCLEANFILES): New variable. + (stdbool.h): New rule. + (alloca.h): New rule. + 2003-02-12 Bruno Haible Extracted from gettext package. diff --git a/gettext-runtime/lib/Makefile.am b/gettext-runtime/lib/Makefile.am index 35fc8bec8..3b65b08ff 100644 --- a/gettext-runtime/lib/Makefile.am +++ b/gettext-runtime/lib/Makefile.am @@ -18,20 +18,67 @@ ## Process this file with automake to produce Makefile.in. AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies +EXTRA_DIST = +MOSTLYCLEANFILES = noinst_LIBRARIES = libgrt.a # Sources that are compiled on all platforms. libgrt_a_SOURCES = \ - basename.h basename.c \ - error.h error.c \ - exit.h \ - getopt.h getopt.c getopt1.c \ - xmalloc.h xmalloc.c + ../../gettext-tools/lib/basename.h ../../gettext-tools/lib/basename.c \ + ../../gettext-tools/lib/error.h ../../gettext-tools/lib/error.c \ + ../../gettext-tools/lib/exit.h \ + ../../gettext-tools/lib/getopt.h ../../gettext-tools/lib/getopt.c ../../gettext-tools/lib/getopt1.c \ + ../../gettext-tools/lib/pathmax.h \ + ../../gettext-tools/lib/progname.h ../../gettext-tools/lib/progname.c \ + ../../gettext-tools/lib/xmalloc.h ../../gettext-tools/lib/xmalloc.c ../../gettext-tools/lib/xstrdup.c \ + ../../gettext-tools/lib/xreadlink.h ../../gettext-tools/lib/xreadlink.c + +# Sources that are compiled only on platforms that lack the functions. + +LIBADD_SOURCE = \ + alloca.c \ + ../../gettext-tools/lib/canonicalize.h canonicalize.c \ + memmove.c \ + ../../gettext-tools/lib/relocatable.h relocatable.c \ + ../../gettext-tools/lib/setenv.h setenv.c unsetenv.c \ + strerror.c + +# How to build libgrt.a. + +libgrt_a_LIBADD = @ALLOCA@ @LIBOBJS@ INCLUDES = \ -I. -I$(srcdir) \ -I.. \ -I../intl -I$(srcdir)/../intl \ -I../../gettext-tools/lib -I$(srcdir)/../../gettext-tools/lib + +# List of files to be distributed. + +EXTRA_DIST += $(LIBADD_SOURCE) + + +# >>> gnulib module stdbool. +EXTRA_DIST += ../../gettext-tools/lib/stdbool.h.in + +# The following is needed in order to create an when the system +# doesn't have one that works. +all-local $(libgettextlib_la_OBJECTS): @STDBOOL_H@ +stdbool.h: ../../gettext-tools/lib/stdbool.h.in + sed -e 's/@''HAVE__BOOL''@/@HAVE__BOOL@/g' < $(srcdir)/../../gettext-tools/lib/stdbool.h.in > stdbool.h +MOSTLYCLEANFILES += stdbool.h +# <<< gnulib module stdbool. + + +# >>> gnulib module alloca. +EXTRA_DIST += ../../gettext-tools/lib/alloca_.h + +# The following is needed in order to create an when the system +# doesn't have one that works with the given compiler. +all-local $(libgettextlib_la_OBJECTS): @ALLOCA_H@ +alloca.h: ../../gettext-tools/lib/alloca_.h + cp $(srcdir)/../../gettext-tools/lib/alloca_.h alloca.h +MOSTLYCLEANFILES += alloca.h +# <<< gnulib module alloca. diff --git a/gettext-runtime/libasprintf/INSTALL b/gettext-runtime/libasprintf/INSTALL index 863ccc31e..3c7993200 100644 --- a/gettext-runtime/libasprintf/INSTALL +++ b/gettext-runtime/libasprintf/INSTALL @@ -104,6 +104,39 @@ you can set and what kinds of files go in them. with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. +Relocatable Installation +======================== + + By default, `make install' will install a package with hardwired +file names, and the package will not work correctly when copied or +moved to a different location in the filesystem. + + Some packages pay attention to the `--enable-relocatable' option to +`configure'. This option makes the entire installed package +relocatable. This means, it can be moved or copied to a different +location on the filesystem. It is possible to make symlinks to the +installed and moved programs, and invoke them through the symlink. It +is possible to do the same thing with a hard link _only_ if the hard +linked file is in the same directory as the real program. + + For reliability it is best to give together with --enable-relocatable +a `--prefix' option pointing to an otherwise unused (and never used +again) directory, for example, `--prefix=/tmp/inst$$'. This is +recommended because on some OSes the executables remember the location +of shared libraries (and prefer them over LD_LIBRARY_PATH !), therefore +such an executable will look for its shared libraries first in the +original installation directory and only then in the current +installation directory. + + Installation with `--enable-relocatable' will not work for setuid / +setgid executables. (This is because such an executable kills its +LD_LIBRARY_PATH variable when it is launched.) + + The runtime penalty and size penalty are nearly zero on Linux 2.2 or +newer (just one system call more when an executable is launched), and +small on other systems (the wrapper program just sets an environment +variable and execs the real program). + Optional Features ================= @@ -121,7 +154,13 @@ you can use the `configure' options `--x-includes=DIR' and For packages that use the GNU libiconv library, you can use the `configure' option `--with-libiconv-prefix' to specify the prefix you -used while installing libiconv. +used while installing GNU libiconv. This option is not necessary if +that other prefix is the same as the one now specified through --prefix. + + For packages that use the GNU libintl library, you can use the +`configure' option `--with-libintl-prefix' to specify the prefix you +used while installing GNU gettext-runtime. This option is not necessary if +that other prefix is the same as the one now specified through --prefix. Particular Systems ================== diff --git a/gettext-runtime/po/ChangeLog b/gettext-runtime/po/ChangeLog index 169018120..d64dc4010 100644 --- a/gettext-runtime/po/ChangeLog +++ b/gettext-runtime/po/ChangeLog @@ -1,3 +1,7 @@ +2003-02-28 Bruno Haible + + * POTFILES.in: Use references to ../gettext-tools/lib. + 2003-02-28 Bruno Haible * Makefile.in.in (mkinstalldirs): Simplify. Prepending diff --git a/gettext-runtime/src/ChangeLog b/gettext-runtime/src/ChangeLog index f9fdce9a6..8458099e1 100644 --- a/gettext-runtime/src/ChangeLog +++ b/gettext-runtime/src/ChangeLog @@ -1,3 +1,19 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * gettext.c: Include progname.h, relocatable.h. + (program_name): Remove variable. + (main): Use set_program_name. Relocate LOCALEDIR value. Update + copyright year. + * ngettext.c: Include progname.h, relocatable.h. + (program_name): Remove variable. + (main): Use set_program_name. Relocate LOCALEDIR value. Update + copyright year. + * Makefile.am (gettext_CFLAGS, ngettext_CFLAGS): New variables. + (gettext_LDFLAGS, ngettext_LDFLAGS): New variables. + (RELOCATABLE_LIBRARY_PATH, RELOCATABLE_SRC_DIR, RELOCATABLE_BUILD_DIR, + RELOCATABLE_CONFIG_H_DIR): New variables. + 2003-02-12 Bruno Haible Extracted from gettext package. diff --git a/gettext-runtime/src/Makefile.am b/gettext-runtime/src/Makefile.am index df5ae47ca..2383e7164 100644 --- a/gettext-runtime/src/Makefile.am +++ b/gettext-runtime/src/Makefile.am @@ -37,3 +37,18 @@ ngettext_SOURCES = ngettext.c # Link dependencies. LDADD = ../lib/libgrt.a @LTLIBINTL@ + +# Specify installation directory, for --enable-relocatable. +gettext_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +ngettext_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +if RELOCATABLE_VIA_LD +gettext_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +ngettext_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +endif + +# Support for relocatability. +RELOCATABLE_LIBRARY_PATH = $(libdir) +RELOCATABLE_SRC_DIR = $(top_srcdir)/../gettext-tools/lib +RELOCATABLE_BUILD_DIR = ../lib +RELOCATABLE_CONFIG_H_DIR = .. +@SET_RELOCATABLE@ diff --git a/gettext-runtime/src/gettext.c b/gettext-runtime/src/gettext.c index 78ea862b4..b39daa508 100644 --- a/gettext-runtime/src/gettext.c +++ b/gettext-runtime/src/gettext.c @@ -1,5 +1,5 @@ /* gettext - retrieve text string from message catalog and print it. - Copyright (C) 1995-1997, 2000-2002 Free Software Foundation, Inc. + Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc. Written by Ulrich Drepper , May 1995. This program is free software; you can redistribute it and/or modify @@ -27,6 +27,8 @@ #include #include "error.h" +#include "progname.h" +#include "relocatable.h" #include "basename.h" #include "xmalloc.h" #include "exit.h" @@ -42,9 +44,6 @@ int add_newline; message catalog. */ int do_expand; -/* Name the program is called with. */ -const char *program_name; - /* Long options. */ static const struct option long_options[] = { @@ -79,9 +78,7 @@ main (int argc, char *argv[]) do_expand = 0; /* Set program name for message texts. */ - program_name = argv[0]; - if (strncmp (program_name, "lt-", 3) == 0) - program_name += 3; + set_program_name (argv[0]); #ifdef HAVE_SETLOCALE /* Set locale via LC_ALL. */ @@ -89,7 +86,7 @@ main (int argc, char *argv[]) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Parse command line options. */ @@ -133,7 +130,7 @@ main (int argc, char *argv[]) This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ "), - "1995-1997, 2000-2002"); + "1995-1997, 2000-2003"); printf (_("Written by %s.\n"), "Ulrich Drepper"); exit (EXIT_SUCCESS); } diff --git a/gettext-runtime/src/ngettext.c b/gettext-runtime/src/ngettext.c index 989e0ff66..654a34740 100644 --- a/gettext-runtime/src/ngettext.c +++ b/gettext-runtime/src/ngettext.c @@ -1,5 +1,5 @@ /* ngettext - retrieve plural form string from message catalog and print it. - Copyright (C) 1995-1997, 2000-2002 Free Software Foundation, Inc. + Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc. 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 @@ -27,6 +27,8 @@ #include #include "error.h" +#include "progname.h" +#include "relocatable.h" #include "basename.h" #include "xmalloc.h" #include "exit.h" @@ -39,9 +41,6 @@ message catalog. */ int do_expand; -/* Name the program is called with. */ -const char *program_name; - /* Long options. */ static const struct option long_options[] = { @@ -76,9 +75,7 @@ main (int argc, char *argv[]) do_expand = 0; /* Set program name for message texts. */ - program_name = argv[0]; - if (strncmp (program_name, "lt-", 3) == 0) - program_name += 3; + set_program_name (argv[0]); #ifdef HAVE_SETLOCALE /* Set locale via LC_ALL. */ @@ -86,7 +83,7 @@ main (int argc, char *argv[]) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Parse command line options. */ @@ -124,7 +121,7 @@ main (int argc, char *argv[]) This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ "), - "1995-1997, 2000-2002"); + "1995-1997, 2000-2003"); printf (_("Written by %s.\n"), "Ulrich Drepper"); exit (EXIT_SUCCESS); } diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog index 98f1cfb90..9caf58674 100644 --- a/gettext-tools/ChangeLog +++ b/gettext-tools/ChangeLog @@ -1,3 +1,10 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * configure.ac: Invoke AC_RELOCATABLE, AC_REPLACE_FUNCS([memmove]), + gl_FUNC_STRERROR, gl_XREADLINK, gl_CANONICALIZE. + * INSTALL: Document --enable-relocatable and --with-libintl-prefix. + 2003-02-28 Bruno Haible * configure.ac: Invoke gl_PATHMAX. diff --git a/gettext-tools/INSTALL b/gettext-tools/INSTALL index 863ccc31e..3c7993200 100644 --- a/gettext-tools/INSTALL +++ b/gettext-tools/INSTALL @@ -104,6 +104,39 @@ you can set and what kinds of files go in them. with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. +Relocatable Installation +======================== + + By default, `make install' will install a package with hardwired +file names, and the package will not work correctly when copied or +moved to a different location in the filesystem. + + Some packages pay attention to the `--enable-relocatable' option to +`configure'. This option makes the entire installed package +relocatable. This means, it can be moved or copied to a different +location on the filesystem. It is possible to make symlinks to the +installed and moved programs, and invoke them through the symlink. It +is possible to do the same thing with a hard link _only_ if the hard +linked file is in the same directory as the real program. + + For reliability it is best to give together with --enable-relocatable +a `--prefix' option pointing to an otherwise unused (and never used +again) directory, for example, `--prefix=/tmp/inst$$'. This is +recommended because on some OSes the executables remember the location +of shared libraries (and prefer them over LD_LIBRARY_PATH !), therefore +such an executable will look for its shared libraries first in the +original installation directory and only then in the current +installation directory. + + Installation with `--enable-relocatable' will not work for setuid / +setgid executables. (This is because such an executable kills its +LD_LIBRARY_PATH variable when it is launched.) + + The runtime penalty and size penalty are nearly zero on Linux 2.2 or +newer (just one system call more when an executable is launched), and +small on other systems (the wrapper program just sets an environment +variable and execs the real program). + Optional Features ================= @@ -121,7 +154,13 @@ you can use the `configure' options `--x-includes=DIR' and For packages that use the GNU libiconv library, you can use the `configure' option `--with-libiconv-prefix' to specify the prefix you -used while installing libiconv. +used while installing GNU libiconv. This option is not necessary if +that other prefix is the same as the one now specified through --prefix. + + For packages that use the GNU libintl library, you can use the +`configure' option `--with-libintl-prefix' to specify the prefix you +used while installing GNU gettext-runtime. This option is not necessary if +that other prefix is the same as the one now specified through --prefix. Particular Systems ================== diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac index 88fd70173..e978beeb3 100644 --- a/gettext-tools/configure.ac +++ b/gettext-tools/configure.ac @@ -70,6 +70,8 @@ dnl Check for build configuration. AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL +AC_RELOCATABLE + AC_DEFINE(_GNU_SOURCE, 1, [Make sure we see all GNU extensions.]) dnl Checks for libraries. @@ -94,7 +96,7 @@ gl_FUNC_ALLOCA AC_FUNC_VPRINTF AC_CHECK_FUNCS([getcwd posix_spawn putc_unlocked raise select strerror \ strtoul uname utime utimes]) -AC_REPLACE_FUNCS([memset stpcpy strcspn \ +AC_REPLACE_FUNCS([memmove memset stpcpy strcspn \ strcasecmp strncasecmp strpbrk strstr vasprintf]) AM_FUNC_GETLINE if test $am_cv_func_working_getline != yes; then @@ -110,8 +112,11 @@ gt_FUNC_MKDTEMP gt_SIGNALBLOCKING gt_SIGINFO gt_FUNC_SETENV +gl_FUNC_STRERROR gt_FUNC_ERROR_AT_LINE gl_PATHMAX +gl_XREADLINK +gl_CANONICALIZE gt_SETLOCALE gt_PREREQ_HOSTNAME diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index 36d6c0097..3ada6c0fb 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,3 +1,36 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * canonicalize.h: New file. + * canonicalize.c: New file, from glibc 2.3.1 with modifications. + * relocatable.h: New file. + * relocatable.c: New file. + * relocwrapper.c: New file. + * strerror.c: New file, from gnulib with modifications. + * xreadlink.h: New file, from gnulib with modifications. + * xreadlink.c: New file, from gnulib with modifications. + * progname.h (set_program_name_and_installdir): New declaration. + (set_program_name) [ENABLE_RELOCATABLE]: Define as macro. + (get_full_program_name): New declaration. + * progname.c: Include xreadlink.h, canonicalize.h, relocatable.h. + (executable_fd): New variable. + (maybe_executable): New function. + (find_executable): New function. + (executable_fullname): New variable. + (prepare_relocate): New function. + (set_program_name_and_installdir): New function. + (get_full_program_name): New function. + * localcharset.c: Include relocatable.h. + (get_charset_aliases): Relocate LIBDIR value. + * xmalloc.h (xalloc_die): New declaration. + * xmalloc.c (xalloc_die): New function. + (fixup_null_alloc): Use it. + * Makefile.am (libgettextlib_la_SOURCES): Add xreadlink.h, xreadlink.c. + (LIBADD_SOURCE): Add canonicalize.h, canonicalize.c, memmove.c, + relocatable.h, relocatable.c, strerror.c. + (UNUSED_SOURCE): Remove memmove.c. + (EXTRA_DIST): Add relocwrapper.c. + 2003-02-28 Bruno Haible * localcharset.h: Change copyright to LGPL. Enclose declaration in diff --git a/gettext-tools/lib/Makefile.am b/gettext-tools/lib/Makefile.am index efceef1f7..594053358 100644 --- a/gettext-tools/lib/Makefile.am +++ b/gettext-tools/lib/Makefile.am @@ -67,20 +67,25 @@ libgettextlib_la_SOURCES = \ wait-process.h wait-process.c \ xerror.h xerror.c \ xmalloc.h xmalloc.c xstrdup.c \ + xreadlink.h xreadlink.c \ xsetenv.h xsetenv.c # Sources that are compiled only on platforms that lack the functions. LIBADD_SOURCE = \ alloca.c \ + canonicalize.h canonicalize.c \ getline.h getline.c \ + memmove.c \ memset.c \ mkdtemp.h mkdtemp.c \ pfnmatch.h pfnmatch.c \ + relocatable.h relocatable.c \ setenv.h setenv.c unsetenv.c \ stpcpy.h stpcpy.c \ strcase.h strcasecmp.c strncasecmp.c \ strcspn.c \ + strerror.c \ strpbrk.h strpbrk.c \ strstr.h strstr.c \ strtol.c \ @@ -89,7 +94,6 @@ LIBADD_SOURCE = \ # Unused sources. UNUSED_SOURCE = \ - memmove.c \ xgetcwd.h xgetcwd.c # How to build libgettextlib.la. @@ -117,7 +121,7 @@ gettextsrc_DATA = gettext.h noinst_HEADERS = gettext.h EXTRA_DIST += \ - $(LIBADD_SOURCE) $(UNUSED_SOURCE) \ + $(LIBADD_SOURCE) $(UNUSED_SOURCE) relocwrapper.c \ gen-lbrkprop.c 3level.h Combining.txt \ ChangeLog.0 diff --git a/gettext-tools/lib/localcharset.c b/gettext-tools/lib/localcharset.c index 6676e8b50..998882470 100644 --- a/gettext-tools/lib/localcharset.c +++ b/gettext-tools/lib/localcharset.c @@ -67,6 +67,12 @@ # include #endif +#if ENABLE_RELOCATABLE +# include "relocatable.h" +#else +# define relocate(pathname) (pathname) +#endif + #if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__ /* Win32, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') @@ -110,7 +116,7 @@ get_charset_aliases () { #if !defined WIN32 FILE *fp; - const char *dir = LIBDIR; + const char *dir = relocate (LIBDIR); const char *base = "charset.alias"; char *file_name; diff --git a/gettext-tools/lib/progname.c b/gettext-tools/lib/progname.c index 98e1a6013..11bf92ebe 100644 --- a/gettext-tools/lib/progname.c +++ b/gettext-tools/lib/progname.c @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -24,8 +24,37 @@ /* Specification. */ #include "progname.h" +#include #include +#include #include +#include +#if HAVE_UNISTD_H +# include +#endif +#include + +#if defined _WIN32 || defined __WIN32__ +# undef WIN32 /* avoid warning on mingw32 */ +# define WIN32 +#endif + +#ifdef WIN32 +# define WIN32_LEAN_AND_MEAN +# include +#endif + +#include "xreadlink.h" +#include "canonicalize.h" +#include "relocatable.h" + +#ifdef NO_XMALLOC +# define xmalloc malloc +#else +# include "xmalloc.h" +#endif + +#undef set_program_name /* String containing name the program is called with. @@ -54,6 +83,220 @@ set_program_name (const char *argv0) program_name = argv0; } + +#if ENABLE_RELOCATABLE + +#ifdef __linux__ +/* File descriptor of the executable. + (Only used to verify that we find the correct executable.) */ +static int executable_fd = -1; +#endif + +/* Tests whether a given pathname may belong to the executable. */ +static bool +maybe_executable (const char *filename) +{ + if (access (filename, X_OK) < 0) + return false; + +#ifdef __linux__ + if (executable_fd >= 0) + { + /* If we already have an executable_fd, check that filename points to + the same inode. */ + struct stat statexe; + struct stat statfile; + + if (fstat (executable_fd, &statexe) >= 0) + { + if (stat (filename, &statfile) < 0) + return false; + if (!(statfile.st_dev + && statfile.st_dev == statexe.st_dev + && statfile.st_ino == statexe.st_ino)) + return false; + } + } +#endif + + return true; +} + +/* Determine the full pathname of the current executable, freshly allocated. + Return NULL if unknown. + Guaranteed to work on Linux and Woe32. Likely to work on the other + Unixes (maybe except BeOS), under most conditions. */ +static char * +find_executable (const char *argv0) +{ +#ifdef WIN32 + char buf[1024]; + int length = GetModuleFileName (NULL, buf, sizeof (buf)); + if (length < 0) + return NULL; + if (!IS_PATH_WITH_DIR (location)) + /* Shouldn't happen. */ + return NULL; + return xstrdup (buf); +#else /* Unix */ +#ifdef __linux__ + /* The executable is accessible as /proc//exe. In newer Linux + versions, also as /proc/self/exe. Linux >= 2.1 provides a symlink + to the true pathname; older Linux versions give only device and ino, + enclosed in brackets, which we cannot use here. */ + { + char *link; + + link = xreadlink ("/proc/self/exe"); + if (link != NULL && link[0] != '[') + return link; + if (executable_fd < 0) + executable_fd = open ("/proc/self/exe", O_RDONLY, 0); + + { + char buf[6+10+5]; + sprintf (buf, "/proc/%d/exe", getpid ()); + link = xreadlink (buf); + if (link != NULL && link[0] != '[') + return link; + if (executable_fd < 0) + executable_fd = open (buf, O_RDONLY, 0); + } + } +#endif + /* Guess the executable's full path. We assume the executable has been + called via execlp() or execvp() with properly set up argv[0]. The + login(1) convention to add a '-' prefix to argv[0] is not supported. */ + { + bool has_slash = false; + { + const char *p; + for (p = argv0; *p; p++) + if (*p == '/') + { + has_slash = true; + break; + } + } + if (!has_slash) + { + /* exec searches paths without slashes in the directory list given + by $PATH. */ + const char *path = getenv ("PATH"); + + if (path != NULL) + { + const char *p; + const char *p_next; + + for (p = path; *p; p = p_next) + { + const char *q; + size_t p_len; + char *concat_name; + + for (q = p; *q; q++) + if (*q == ':') + break; + p_len = q - p; + p_next = (*q == '\0' ? q : q + 1); + + /* We have a path item at p, of length p_len. + Now concatenate the path item and argv0. */ + concat_name = (char *) xmalloc (p_len + strlen (argv0) + 2); +#ifdef NO_XMALLOC + if (concat_name == NULL) + return NULL; +#endif + if (p_len == 0) + /* An empty PATH element designates the current directory. */ + strcpy (concat_name, argv0); + else + { + memcpy (concat_name, p, p_len); + concat_name[p_len] = '/'; + strcpy (concat_name + p_len + 1, argv0); + } + if (maybe_executable (concat_name)) + return canonicalize_file_name (concat_name); + free (concat_name); + } + } + /* Not found in the PATH, assume the current directory. */ + } + /* exec treats paths containing slashes as relative to the current + directory. */ + if (maybe_executable (argv0)) + return canonicalize_file_name (argv0); + } + /* No way to find the executable. */ + return NULL; +#endif +} + +/* Full pathname of executable, or NULL. */ +static char *executable_fullname; + +static void +prepare_relocate (const char *orig_installprefix, const char *orig_installdir, + const char *argv0) +{ + const char *curr_prefix; + + /* Determine the full pathname of the current executable. */ + executable_fullname = find_executable (argv0); + + /* Determine the current installation prefix from it. */ + curr_prefix = compute_curr_prefix (orig_installprefix, orig_installdir, + executable_fullname); + if (curr_prefix != NULL) + /* Now pass this prefix to all copies of the relocate.c source file. */ + set_relocation_prefix (orig_installprefix, curr_prefix); +} + +/* Set program_name, based on argv[0], and original installation prefix and + directory, for relocatability. */ +void +set_program_name_and_installdir (const char *argv0, + const char *orig_installprefix, + const char *orig_installdir) +{ + const char *argv0_stripped = argv0; + + /* Relocatable programs are renamed to .bin by install-reloc. Remove + this suffix here. */ + { + size_t argv0_len = strlen (argv0); + if (argv0_len > 4 && memcmp (argv0 + argv0_len - 4, ".bin", 4) == 0) + { + char *shorter = (char *) xmalloc (argv0_len - 4 + 1); +#ifdef NO_XMALLOC + if (shorter != NULL) +#endif + { + memcpy (shorter, argv0, argv0_len - 4); + shorter[argv0_len - 4] = '\0'; + argv0_stripped = shorter; + } + } + } + + set_program_name (argv0_stripped); + + prepare_relocate (orig_installprefix, orig_installdir, argv0); +} + +/* Return the full pathname of the current executable, based on the earlier + call to set_program_name_and_installdir. Return NULL if unknown. */ +char * +get_full_program_name () +{ + return executable_fullname; +} + +#endif + + /* Indicates whether errors and warnings get prefixed with program_name. Default is true. */ bool error_with_progname = true; diff --git a/gettext-tools/lib/progname.h b/gettext-tools/lib/progname.h index 0b50bfe38..13d87cd00 100644 --- a/gettext-tools/lib/progname.h +++ b/gettext-tools/lib/progname.h @@ -1,5 +1,5 @@ /* Program name management. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -35,6 +35,22 @@ 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); +#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 + /* Indicates whether errors and warnings get prefixed with program_name. Default is true. A reason to omit the prefix is for better interoperability with Emacs' diff --git a/gettext-tools/lib/xmalloc.c b/gettext-tools/lib/xmalloc.c index ed757d2a9..0f6577989 100644 --- a/gettext-tools/lib/xmalloc.c +++ b/gettext-tools/lib/xmalloc.c @@ -1,5 +1,5 @@ /* xmalloc.c -- malloc with out of memory checking - Copyright (C) 1990-1996, 2000-2002 Free Software Foundation, Inc. + Copyright (C) 1990-1996, 2000-2003 Free Software Foundation, Inc. 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 @@ -35,6 +35,16 @@ The caller may set it to some other value. */ int xmalloc_exit_failure = EXIT_FAILURE; +void +xalloc_die () +{ + error (xmalloc_exit_failure, 0, _("memory exhausted")); + /* The `noreturn' cannot be given to error, since it may return if + its first argument is 0. To help compilers understand the + xalloc_die does terminate, call exit. */ + exit (EXIT_FAILURE); +} + static void * fixup_null_alloc (size_t n) { @@ -44,7 +54,7 @@ fixup_null_alloc (size_t n) if (n == 0) p = malloc ((size_t) 1); if (p == NULL) - error (xmalloc_exit_failure, 0, _("memory exhausted")); + xalloc_die (); return p; } diff --git a/gettext-tools/lib/xmalloc.h b/gettext-tools/lib/xmalloc.h index c5b47ece3..aa85e1f5f 100644 --- a/gettext-tools/lib/xmalloc.h +++ b/gettext-tools/lib/xmalloc.h @@ -1,5 +1,5 @@ /* malloc with out of memory checking. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -34,6 +34,16 @@ extern void *xcalloc (size_t nmemb, size_t size); with error checking. If PTR is NULL, run xmalloc. */ extern void *xrealloc (void *ptr, size_t size); +/* This function is always triggered when memory is exhausted. It is + in charge of honoring the three previous items. This is the + function to call when one wants the program to die because of a + memory allocation failure. */ +extern void xalloc_die (void) +#if (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)) && !__STRICT_ANSI__ + __attribute__ ((__noreturn__)) +#endif + ; + /* Defined in xstrdup.c. */ diff --git a/gettext-tools/m4/ChangeLog b/gettext-tools/m4/ChangeLog index dac5395a9..ed46eb478 100644 --- a/gettext-tools/m4/ChangeLog +++ b/gettext-tools/m4/ChangeLog @@ -1,3 +1,12 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * canonicalize.m4: New file. + * relocatable.m4: New file. + * strerror.m4: New file. + * xreadlink.m4: New file. + * Makefile.am (EXTRA_DIST): Add them. + 2003-02-28 Bruno Haible * pathmax.m4: New file, from gnulib. diff --git a/gettext-tools/m4/Makefile.am b/gettext-tools/m4/Makefile.am index 274f0b234..7ae063254 100644 --- a/gettext-tools/m4/Makefile.am +++ b/gettext-tools/m4/Makefile.am @@ -27,6 +27,7 @@ aclocal_DATA = \ EXTRA_DIST = README ChangeLog.0 \ alloca.m4 \ backupfile.m4 \ +canonicalize.m4 \ error.m4 \ flex.m4 \ fnmatch.m4 \ @@ -41,11 +42,14 @@ mbswidth.m4 \ mkdtemp.m4 \ onceonly.m4 \ pathmax.m4 \ +relocatable.m4 \ setenv.m4 \ setlocale.m4 \ siginfo.m4 \ signalblocking.m4 \ ssize_t.m4 \ stdbool.m4 \ +strerror.m4 \ tmpdir.m4 \ -unionwait.m4 +unionwait.m4 \ +xreadlink.m4 diff --git a/gettext-tools/misc/ChangeLog b/gettext-tools/misc/ChangeLog index a23254511..a5a9ea9cc 100644 --- a/gettext-tools/misc/ChangeLog +++ b/gettext-tools/misc/ChangeLog @@ -1,3 +1,9 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * autopoint.in: Relocate $gettext_dir. + * gettextize.in: Relocate $gettext_dir. + 2003-02-16 Bruno Haible * gettextize.in: Create po/Makevars.template from installed diff --git a/gettext-tools/misc/autopoint.in b/gettext-tools/misc/autopoint.in index d22f14e5a..7b7a13d44 100644 --- a/gettext-tools/misc/autopoint.in +++ b/gettext-tools/misc/autopoint.in @@ -1,6 +1,6 @@ #! /bin/sh # -# Copyright (C) 2002 Free Software Foundation, Inc. +# Copyright (C) 2002-2003 Free Software Foundation, Inc. # # 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 @@ -25,6 +25,90 @@ progname=$0 package=@PACKAGE@ version=@VERSION@ +# Set variables +# - gettext_dir directory where the sources are stored. +prefix="@prefix@" +gettext_dir="@datadir@/gettext" + +# Support for relocatability. +func_find_curr_installdir () +{ + # Determine curr_installdir, even taking into account symlinks. + curr_executable="$0" + case "$curr_executable" in + */* | *\\*) ;; + *) # Need to look in the PATH. + if test "${PATH_SEPARATOR+set}" != set; then + { echo "#! /bin/sh"; echo "exit 0"; } > /tmp/conf$$.sh + chmod +x /tmp/conf$$.sh + if (PATH="/nonexistent;/tmp"; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f /tmp/conf$$.sh + fi + save_IFS="$IFS"; IFS="$PATH_SEPARATOR" + for dir in $PATH; do + IFS="$save_IFS" + test -z "$dir" && dir=. + for exec_ext in ''; do + if test -f "$dir/$curr_executable$exec_ext"; then + curr_executable="$dir/$curr_executable$exec_ext" + break 2 + fi + done + done + IFS="$save_IFS" + ;; + esac + # Make absolute. + case "$curr_executable" in + /* | ?:/* | ?:\\*) ;; + *) curr_executable=`pwd`/"$curr_executable" ;; + esac + # Resolve symlinks. + while : ; do + lsline=`LC_ALL=C ls -l "$curr_executable"` + case "$lsline" in + *" -> "*) + curr_executable=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'`/`echo "$lsline" | sed -n -e 's,^.* -> \(.*\),\1,p'` ;; + *) break ;; + esac + done + curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'` + # Canonicalize. + curr_installdir=`cd "$curr_installdir" && pwd` +} +func_find_prefixes () +{ + # Compute the original/current installation prefixes by stripping the + # trailing directories off the original/current installation directories. + orig_installprefix="$orig_installdir" + curr_installprefix="$curr_installdir" + while true; do + orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` + curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` + if test -z "$orig_last" || test -z "$curr_last"; then + break + fi + if test "$orig_last" != "$curr_last"; then + break + fi + orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'` + curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'` + done +} +if test "@RELOCATABLE@" = yes; then + exec_prefix="@exec_prefix@" + bindir="@bindir@" + orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables + func_find_curr_installdir # determine curr_installdir + func_find_prefixes + # Relocate the directory variables that we use. + gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'` +fi + # func_usage # outputs to stdout the --help usage message. func_usage () @@ -212,11 +296,6 @@ fi omitintl=`cat "$configure_in" | grep '^AM_GNU_GETTEXT' | sed -n -e 's/^AM_GNU_GETTEXT(\([^(),]*\).*$/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q` omitintl=`if test 'external' = "$omitintl"; then echo yes; fi` -# Set variables -# - gettext_dir directory where the sources are stored. -prefix="@prefix@" -gettext_dir="@datadir@/gettext" - # Set up a temporary CVS repository and a temporary checkout directory. # We need the temporary CVS repository because any checkout needs write # access to the CVSROOT/history file, so it cannot be under $gettext_dir. diff --git a/gettext-tools/misc/gettextize.in b/gettext-tools/misc/gettextize.in index 46059a9f2..94f51f076 100644 --- a/gettext-tools/misc/gettextize.in +++ b/gettext-tools/misc/gettextize.in @@ -25,6 +25,90 @@ progname=$0 package=@PACKAGE@ version=@VERSION@ +# Set variables +# - gettext_dir directory where the sources are stored. +prefix="@prefix@" +gettext_dir="@datadir@/gettext" + +# Support for relocatability. +func_find_curr_installdir () +{ + # Determine curr_installdir, even taking into account symlinks. + curr_executable="$0" + case "$curr_executable" in + */* | *\\*) ;; + *) # Need to look in the PATH. + if test "${PATH_SEPARATOR+set}" != set; then + { echo "#! /bin/sh"; echo "exit 0"; } > /tmp/conf$$.sh + chmod +x /tmp/conf$$.sh + if (PATH="/nonexistent;/tmp"; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f /tmp/conf$$.sh + fi + save_IFS="$IFS"; IFS="$PATH_SEPARATOR" + for dir in $PATH; do + IFS="$save_IFS" + test -z "$dir" && dir=. + for exec_ext in ''; do + if test -f "$dir/$curr_executable$exec_ext"; then + curr_executable="$dir/$curr_executable$exec_ext" + break 2 + fi + done + done + IFS="$save_IFS" + ;; + esac + # Make absolute. + case "$curr_executable" in + /* | ?:/* | ?:\\*) ;; + *) curr_executable=`pwd`/"$curr_executable" ;; + esac + # Resolve symlinks. + while : ; do + lsline=`LC_ALL=C ls -l "$curr_executable"` + case "$lsline" in + *" -> "*) + curr_executable=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'`/`echo "$lsline" | sed -n -e 's,^.* -> \(.*\),\1,p'` ;; + *) break ;; + esac + done + curr_installdir=`echo "$curr_executable" | sed -e 's,/[^/]*$,,'` + # Canonicalize. + curr_installdir=`cd "$curr_installdir" && pwd` +} +func_find_prefixes () +{ + # Compute the original/current installation prefixes by stripping the + # trailing directories off the original/current installation directories. + orig_installprefix="$orig_installdir" + curr_installprefix="$curr_installdir" + while true; do + orig_last=`echo "$orig_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` + curr_last=`echo "$curr_installprefix" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` + if test -z "$orig_last" || test -z "$curr_last"; then + break + fi + if test "$orig_last" != "$curr_last"; then + break + fi + orig_installprefix=`echo "$orig_installprefix" | sed -e 's,/[^/]*$,,'` + curr_installprefix=`echo "$curr_installprefix" | sed -e 's,/[^/]*$,,'` + done +} +if test "@RELOCATABLE@" = yes; then + exec_prefix="@exec_prefix@" + bindir="@bindir@" + orig_installdir="$bindir" # see Makefile.am's *_SCRIPTS variables + func_find_curr_installdir # determine curr_installdir + func_find_prefixes + # Relocate the directory variables that we use. + gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'` +fi + # func_usage # outputs to stdout the --help usage message. func_usage () @@ -139,11 +223,6 @@ func_fatal_error () # The current directory is now $srcdir. -# Set variable -# - gettext_dir directory where the sources are stored. -prefix="@prefix@" -gettext_dir="@datadir@/gettext" - # Check integrity of package: A configure.in/ac must be present. Sets variable # - configure_in name of configure.in/ac file. test -f configure.in || test -f configure.ac || diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index f76f461f2..7babeb529 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,67 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * msgattrib.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msgcat.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msgcmp.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msgcomm.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msgconv.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msgen.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msgexec.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msgfilter.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msgfmt.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msggrep.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msginit.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + (project_id, project_id_version, get_user_email): Relocate LIBDIR + value. + (language_team_address): Relocate LIBDIR and PROJECTSDIR values. + * msgmerge.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msgunfmt.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * msguniq.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * xgettext.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. + * read-java.c: Include relocatable.h. + (msgdomain_read_java): Relocate GETTEXTJEXEDIR value. + * read-tcl.c: Include relocatable.h. + (msgdomain_read_tcl): Relocate GETTEXTDATADIR value. + * hostname.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. Update copyright year. + * urlget.c: Include relocatable.h. + (main): Relocate LOCALEDIR value. Update copyright year. + (fetch): Relocate GETTEXTJEXEDIR value. + * user-email.in: Relocate $libdir. + * Makefile.am (aliaspath): New variable. + (DEFS): Define LOCALE_ALIAS_PATH. + (msginit_SOURCES): Add .../localealias.c. + (msginit_LDADD): Remove .../localealias.lo. + (msgcmp_CFLAGS, msgfmt_CFLAGS, msgmerge_CFLAGS, msgunfmt_CFLAGS, + xgettext_CFLAGS, msgattrib_CFLAGS, msgcat_CFLAGS, msgcomm_CFLAGS, + msgconv_CFLAGS, msgen_CFLAGS, msgexec_CFLAGS, msgfilter_CFLAGS, + msggrep_CFLAGS, msginit_CFLAGS, msguniq_CFLAGS, hostname_CFLAGS, + urlget_CFLAGS): New variables. + (msgcmp_LDFLAGS, msgfmt_LDFLAGS, msgmerge_LDFLAGS, msgunfmt_LDFLAGS, + xgettext_LDFLAGS, msgattrib_LDFLAGS, msgcat_LDFLAGS, msgcomm_LDFLAGS, + msgconv_LDFLAGS, msgen_LDFLAGS, msgexec_LDFLAGS, msgfilter_LDFLAGS, + msggrep_LDFLAGS, msginit_LDFLAGS, msguniq_LDFLAGS, hostname_LDFLAGS, + urlget_LDFLAGS): New variables. + (install-exec-java-yes): Don't ignore INSTALL_PROGRAM_ENV. + (RELOCATABLE_LIBRARY_PATH, RELOCATABLE_SRC_DIR, RELOCATABLE_BUILD_DIR, + RELOCATABLE_CONFIG_H_DIR): New variables. + 2003-03-13 Bruno Haible * msggrep.c (main): On Solaris, prefer /usr/xpg4/bin/grep to diff --git a/gettext-tools/src/Makefile.am b/gettext-tools/src/Makefile.am index 14c73c09a..1a3beeed5 100644 --- a/gettext-tools/src/Makefile.am +++ b/gettext-tools/src/Makefile.am @@ -46,6 +46,7 @@ x-rst.h x-glade.h EXTRA_DIST += FILES project-id ChangeLog.0 localedir = $(datadir)/locale +aliaspath = $(localedir) jardir = $(datadir)/gettext pkgdatadir = $(datadir)/gettext projectsdir = $(pkgdatadir)/projects @@ -59,6 +60,7 @@ INCLUDES = \ -I../intl -I$(top_srcdir)/../gettext-runtime/intl DEFS = \ -DLOCALEDIR=\"$(localedir)\" \ + -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \ -DUSEJEXE=$(USEJEXE) \ -DGETTEXTJEXEDIR=\"$(pkglibdir)\" \ -DGETTEXTJAR=\"$(jardir)/gettext.jar\" \ @@ -125,7 +127,7 @@ msgen_SOURCES = msgen.c msgexec_SOURCES = msgexec.c msgfilter_SOURCES = msgfilter.c msggrep_SOURCES = msggrep.c -msginit_SOURCES = msginit.c +msginit_SOURCES = msginit.c ../../gettext-runtime/intl/localealias.c msguniq_SOURCES = msguniq.c hostname_SOURCES = hostname.c urlget_SOURCES = urlget.c @@ -168,11 +170,47 @@ msgen_LDADD = libgettextsrc.la msgexec_LDADD = libgettextsrc.la msgfilter_LDADD = libgettextsrc.la msggrep_LDADD = libgettextsrc.la -msginit_LDADD = ../intl/localealias.@INTL_LIBTOOL_SUFFIX_PREFIX@o \ - ../intl/localename.@INTL_LIBTOOL_SUFFIX_PREFIX@o \ +msginit_LDADD = ../intl/localename.@INTL_LIBTOOL_SUFFIX_PREFIX@o \ libgettextsrc.la msguniq_LDADD = libgettextsrc.la +# Specify installation directory, for --enable-relocatable. +msgcmp_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msgfmt_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msgmerge_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msgunfmt_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +xgettext_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msgattrib_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msgcat_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msgcomm_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msgconv_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msgen_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msgexec_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msgfilter_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msggrep_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msginit_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +msguniq_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +hostname_CFLAGS = -DINSTALLDIR=\"$(pkglibdir)\" +urlget_CFLAGS = -DINSTALLDIR=\"$(pkglibdir)\" +if RELOCATABLE_VIA_LD +msgcmp_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msgfmt_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msgmerge_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msgunfmt_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +xgettext_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msgattrib_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msgcat_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msgcomm_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msgconv_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msgen_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msgexec_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msgfilter_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msggrep_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msginit_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +msguniq_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +hostname_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(pkglibdir)` +urlget_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(pkglibdir)` +endif # Special rules for bison and flex generated files. @@ -246,8 +284,8 @@ CLEANFILES += gnu.gettext.DumpResource$(EXEEXT) gnu.gettext.GetURL$(EXEEXT) \ install-exec-local: install-exec-java-@BUILDJAVAEXE@ install-exec-java-yes: all-java-yes $(mkinstalldirs) $(DESTDIR)$(pkglibdir) - $(INSTALL_PROGRAM) gnu.gettext.DumpResource$(EXEEXT) $(DESTDIR)$(pkglibdir)/gnu.gettext.DumpResource$(EXEEXT) - $(INSTALL_PROGRAM) gnu.gettext.GetURL$(EXEEXT) $(DESTDIR)$(pkglibdir)/gnu.gettext.GetURL$(EXEEXT) + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) gnu.gettext.DumpResource$(EXEEXT) $(DESTDIR)$(pkglibdir)/gnu.gettext.DumpResource$(EXEEXT) + $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) gnu.gettext.GetURL$(EXEEXT) $(DESTDIR)$(pkglibdir)/gnu.gettext.GetURL$(EXEEXT) install-exec-java-no: install-data-local: install-data-java-@BUILDJAVAEXE@ @@ -291,3 +329,11 @@ installdirs-tcl: uninstall-local: uninstall-tcl uninstall-tcl: $(RM) $(DESTDIR)$(pkgdatadir)/msgunfmt.tcl + + +# Support for relocatability. +RELOCATABLE_LIBRARY_PATH = $(libdir) +RELOCATABLE_SRC_DIR = $(top_srcdir)/lib +RELOCATABLE_BUILD_DIR = ../lib +RELOCATABLE_CONFIG_H_DIR = .. +@SET_RELOCATABLE@ diff --git a/gettext-tools/src/hostname.c b/gettext-tools/src/hostname.c index 0bcbe413c..32fae9cdf 100644 --- a/gettext-tools/src/hostname.c +++ b/gettext-tools/src/hostname.c @@ -1,5 +1,5 @@ /* Display hostname in various forms. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -79,6 +79,7 @@ #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "xmalloc.h" #include "exit.h" @@ -128,7 +129,7 @@ main (int argc, char *argv[]) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ @@ -172,7 +173,7 @@ main (int argc, char *argv[]) This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ "), - "2001"); + "2001-2003"); printf (_("Written by %s.\n"), "Bruno Haible"); exit (EXIT_SUCCESS); } diff --git a/gettext-tools/src/msgattrib.c b/gettext-tools/src/msgattrib.c index 36d2284e3..fac9ae793 100644 --- a/gettext-tools/src/msgattrib.c +++ b/gettext-tools/src/msgattrib.c @@ -30,6 +30,7 @@ #include "dir-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "read-po.h" @@ -138,7 +139,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ diff --git a/gettext-tools/src/msgcat.c b/gettext-tools/src/msgcat.c index 7109b21f9..a949f562b 100644 --- a/gettext-tools/src/msgcat.c +++ b/gettext-tools/src/msgcat.c @@ -32,6 +32,7 @@ #include "file-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "read-po.h" @@ -109,7 +110,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ diff --git a/gettext-tools/src/msgcmp.c b/gettext-tools/src/msgcmp.c index c47f46b91..9d60745b6 100644 --- a/gettext-tools/src/msgcmp.c +++ b/gettext-tools/src/msgcmp.c @@ -30,6 +30,7 @@ #include "dir-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "exit.h" @@ -84,7 +85,7 @@ main (int argc, char *argv[]) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); do_help = false; diff --git a/gettext-tools/src/msgcomm.c b/gettext-tools/src/msgcomm.c index 021278f8a..2f1d799ed 100644 --- a/gettext-tools/src/msgcomm.c +++ b/gettext-tools/src/msgcomm.c @@ -32,6 +32,7 @@ #include "file-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "read-po.h" @@ -112,7 +113,7 @@ main (int argc, char *argv[]) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ diff --git a/gettext-tools/src/msgconv.c b/gettext-tools/src/msgconv.c index 76d3e6f84..e843eb3a0 100644 --- a/gettext-tools/src/msgconv.c +++ b/gettext-tools/src/msgconv.c @@ -30,6 +30,7 @@ #include "dir-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "read-po.h" @@ -101,7 +102,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ diff --git a/gettext-tools/src/msgen.c b/gettext-tools/src/msgen.c index 04da10409..ac66ebb48 100644 --- a/gettext-tools/src/msgen.c +++ b/gettext-tools/src/msgen.c @@ -30,6 +30,7 @@ #include "dir-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "read-po.h" @@ -95,7 +96,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ diff --git a/gettext-tools/src/msgexec.c b/gettext-tools/src/msgexec.c index 1e1f5d90b..4840ee4d3 100644 --- a/gettext-tools/src/msgexec.c +++ b/gettext-tools/src/msgexec.c @@ -37,6 +37,7 @@ #include "error.h" #include "xerror.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "read-po.h" @@ -109,7 +110,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ diff --git a/gettext-tools/src/msgfilter.c b/gettext-tools/src/msgfilter.c index 96fda4b1f..11e5f5724 100644 --- a/gettext-tools/src/msgfilter.c +++ b/gettext-tools/src/msgfilter.c @@ -44,6 +44,7 @@ #include "dir-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "read-po.h" @@ -144,7 +145,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c index c43a68a7a..29c0a98e5 100644 --- a/gettext-tools/src/msgfmt.c +++ b/gettext-tools/src/msgfmt.c @@ -33,6 +33,7 @@ #include "dir-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "xerror.h" #include "format.h" @@ -214,7 +215,7 @@ main (int argc, char *argv[]) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); while ((opt = getopt_long (argc, argv, "a:cCd:D:fhjl:o:r:vV", long_options, diff --git a/gettext-tools/src/msggrep.c b/gettext-tools/src/msggrep.c index 5306ab993..fe35e272b 100644 --- a/gettext-tools/src/msggrep.c +++ b/gettext-tools/src/msggrep.c @@ -39,6 +39,7 @@ #include "dir-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "read-po.h" @@ -143,7 +144,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ diff --git a/gettext-tools/src/msginit.c b/gettext-tools/src/msginit.c index 339a8ab23..bd146e730 100644 --- a/gettext-tools/src/msginit.c +++ b/gettext-tools/src/msginit.c @@ -67,6 +67,7 @@ #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "strpbrk.h" #include "strstr.h" @@ -157,7 +158,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ @@ -850,7 +851,7 @@ englishname_of_language () static const char * project_id () { - char *gettextlibdir; + const char *gettextlibdir; char *prog; char *argv[3]; pid_t child; @@ -863,7 +864,7 @@ project_id () gettextlibdir = getenv ("GETTEXTLIBDIR"); if (gettextlibdir == NULL || gettextlibdir[0] == '\0') - gettextlibdir = concatenated_pathname (LIBDIR, "gettext", NULL); + gettextlibdir = relocate (LIBDIR "/gettext"); prog = concatenated_pathname (gettextlibdir, "project-id", NULL); @@ -901,7 +902,7 @@ project_id () static const char * project_id_version () { - char *gettextlibdir; + const char *gettextlibdir; char *prog; char *argv[4]; pid_t child; @@ -914,7 +915,7 @@ project_id_version () gettextlibdir = getenv ("GETTEXTLIBDIR"); if (gettextlibdir == NULL || gettextlibdir[0] == '\0') - gettextlibdir = concatenated_pathname (LIBDIR, "gettext", NULL); + gettextlibdir = relocate (LIBDIR "/gettext"); prog = concatenated_pathname (gettextlibdir, "project-id", NULL); @@ -1042,7 +1043,7 @@ get_user_fullname () static const char * get_user_email () { - char *prog = concatenated_pathname (LIBDIR, "gettext/user-email", NULL); + const char *prog = relocate (LIBDIR "/gettext/user-email"); char *argv[4]; pid_t child; int fd[1]; @@ -1054,7 +1055,7 @@ get_user_email () /* Ask the user for his email address. */ argv[0] = "/bin/sh"; - argv[1] = prog; + argv[1] = (char *) prog; argv[2] = _("\ The new message catalog should contain your email address, so that users can\n\ give you feedback about the translations, and so that maintainers can contact\n\ @@ -1109,7 +1110,7 @@ last_translator () static const char * language_team_address () { - char *prog = concatenated_pathname (PROJECTSDIR, "team-address", NULL); + const char *prog = relocate (PROJECTSDIR "/team-address"); char *argv[7]; pid_t child; int fd[1]; @@ -1121,9 +1122,9 @@ language_team_address () /* Call the team-address shell script. */ argv[0] = "/bin/sh"; - argv[1] = prog; - argv[2] = PROJECTSDIR; - argv[3] = concatenated_pathname (LIBDIR, "gettext", NULL); + argv[1] = (char *) prog; + argv[2] = (char *) relocate (PROJECTSDIR); + argv[3] = (char *) relocate (LIBDIR "/gettext"); argv[4] = (char *) catalogname; argv[5] = (char *) language; argv[6] = NULL; diff --git a/gettext-tools/src/msgmerge.c b/gettext-tools/src/msgmerge.c index 41c51e02f..b134a5b70 100644 --- a/gettext-tools/src/msgmerge.c +++ b/gettext-tools/src/msgmerge.c @@ -32,6 +32,7 @@ #include "dir-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "read-po.h" @@ -153,7 +154,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ diff --git a/gettext-tools/src/msgunfmt.c b/gettext-tools/src/msgunfmt.c index ff7b13b4b..38344760f 100644 --- a/gettext-tools/src/msgunfmt.c +++ b/gettext-tools/src/msgunfmt.c @@ -29,6 +29,7 @@ #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "exit.h" #include "message.h" @@ -109,7 +110,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); while ((optchar = getopt_long (argc, argv, "d:eEhijl:o:r:svVw:", diff --git a/gettext-tools/src/msguniq.c b/gettext-tools/src/msguniq.c index 39284b370..3bf1cbfc2 100644 --- a/gettext-tools/src/msguniq.c +++ b/gettext-tools/src/msguniq.c @@ -31,6 +31,7 @@ #include "str-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "message.h" #include "read-po.h" @@ -105,7 +106,7 @@ main (int argc, char **argv) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ diff --git a/gettext-tools/src/read-java.c b/gettext-tools/src/read-java.c index b9f376eb5..ed6459138 100644 --- a/gettext-tools/src/read-java.c +++ b/gettext-tools/src/read-java.c @@ -1,5 +1,5 @@ /* Reading Java ResourceBundles. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -29,6 +29,7 @@ #include #include "msgunfmt.h" +#include "relocatable.h" #include "javaexec.h" #include "pipe.h" #include "wait-process.h" @@ -98,7 +99,7 @@ msgdomain_read_java (const char *resource_name, const char *locale_name) necessary for running the testsuite before "make install". */ gettextjexedir = getenv ("GETTEXTJEXEDIR"); if (gettextjexedir == NULL || gettextjexedir[0] == '\0') - gettextjexedir = GETTEXTJEXEDIR; + gettextjexedir = relocate (GETTEXTJEXEDIR); #else gettextjexedir = NULL; #endif diff --git a/gettext-tools/src/read-tcl.c b/gettext-tools/src/read-tcl.c index 44831177e..71567ce4f 100644 --- a/gettext-tools/src/read-tcl.c +++ b/gettext-tools/src/read-tcl.c @@ -29,6 +29,7 @@ #include #include "msgunfmt.h" +#include "relocatable.h" #include "pathname.h" #include "sh-quote.h" #include "pipe.h" @@ -66,7 +67,7 @@ msgdomain_read_tcl (const char *locale_name, const char *directory) necessary for running the testsuite before "make install". */ gettextdatadir = getenv ("GETTEXTDATADIR"); if (gettextdatadir == NULL || gettextdatadir[0] == '\0') - gettextdatadir = GETTEXTDATADIR; + gettextdatadir = relocate (GETTEXTDATADIR); tclscript = concatenated_pathname (gettextdatadir, "msgunfmt.tcl", NULL); diff --git a/gettext-tools/src/urlget.c b/gettext-tools/src/urlget.c index c2d2aca4f..f11ee1b4d 100644 --- a/gettext-tools/src/urlget.c +++ b/gettext-tools/src/urlget.c @@ -1,5 +1,5 @@ /* Get the contents of an URL. - Copyright (C) 2001-2002 Free Software Foundation, Inc. + Copyright (C) 2001-2003 Free Software Foundation, Inc. Written by Bruno Haible , 2001. This program is free software; you can redistribute it and/or modify @@ -35,6 +35,7 @@ #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "full-write.h" #include "execute.h" @@ -96,7 +97,7 @@ main (int argc, char *argv[]) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set default values for variables. */ @@ -129,7 +130,7 @@ main (int argc, char *argv[]) This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ "), - "2001"); + "2001-2003"); printf (_("Written by %s.\n"), "Bruno Haible"); exit (EXIT_SUCCESS); } @@ -244,7 +245,7 @@ fetch (const char *url, const char *file) necessary for running the testsuite before "make install". */ gettextjexedir = getenv ("GETTEXTJEXEDIR"); if (gettextjexedir == NULL || gettextjexedir[0] == '\0') - gettextjexedir = GETTEXTJEXEDIR; + gettextjexedir = relocate (GETTEXTJEXEDIR); #else gettextjexedir = NULL; #endif diff --git a/gettext-tools/src/user-email.in b/gettext-tools/src/user-email.in index 3957e5ee9..bd4a7c9ac 100644 --- a/gettext-tools/src/user-email.in +++ b/gettext-tools/src/user-email.in @@ -17,6 +17,36 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Prerequisites for using @libdir@. +prefix="@prefix@" +exec_prefix="@exec_prefix@" +# Set variable @libdir@. +libdir="@libdir@" + +# Support for relocatability. +if test "@RELOCATABLE@" = yes; then + orig_installdir="$libdir"/gettext # see Makefile.am's install rule + # Determine curr_installdir without caring for symlinked callers. + curr_installdir=`echo "$0" | sed -e 's,/[^/]*$,,'` + curr_installdir=`cd "$curr_installdir" && pwd` + # Compute the original/current installation prefixes by stripping the + # trailing directories off the original/current installation directories. + while true; do + orig_last=`echo "$orig_installdir" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` + curr_last=`echo "$curr_installdir" | sed -n -e 's,^.*/\([^/]*\)$,\1,p'` + if test -z "$orig_last" || test -z "$curr_last"; then + break + fi + if test "$orig_last" != "$curr_last"; then + break + fi + orig_installdir=`echo "$orig_installdir" | sed -e 's,/[^/]*$,,'` + curr_installdir=`echo "$curr_installdir" | sed -e 's,/[^/]*$,,'` + done + # Now relocate the directory variables that we use. + libdir=`echo "$libdir/" | sed -e "s%^${orig_installdir}/%${curr_installdir}/%" | sed -e 's,/$,,'` +fi + # Redirect fileno 3 to interactive I/O. exec 3>/dev/tty @@ -37,18 +67,14 @@ if test -z "$user"; then fi fi -# Prerequisites for using @libdir@. -prefix="@prefix@" -exec_prefix="@exec_prefix@" - # Find the hostname. # hostname on some systems (SVR3.2, old Linux) returns a bogus exit status, # so uname gets run too, so we keep only the first line of output. #host=`(hostname || uname -n) 2>/dev/null | sed 1q` -host=`@libdir@/gettext/hostname --short 2>/dev/null | sed 1q` +host=`"$libdir"/gettext/hostname --short 2>/dev/null | sed 1q` # Find the hostname. -hostfqdn=`@libdir@/gettext/hostname --fqdn 2>/dev/null | sed 1q` +hostfqdn=`"$libdir"/gettext/hostname --fqdn 2>/dev/null | sed 1q` # Find a list of email addresses from various mailer configuration files. # All mailers use configuration files under $HOME. We handle them in a diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index e1706a734..e42097fd5 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -37,6 +37,7 @@ #include "str-list.h" #include "error.h" #include "progname.h" +#include "relocatable.h" #include "basename.h" #include "xerror.h" #include "xmalloc.h" @@ -228,7 +229,7 @@ main (int argc, char *argv[]) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Set initial value of variables. */ diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog index 3ff128f50..25fbca0b0 100644 --- a/gettext-tools/tests/ChangeLog +++ b/gettext-tools/tests/ChangeLog @@ -1,3 +1,16 @@ +2003-02-28 Bruno Haible + + Support for relocatable installation. + * tstgettext.c: Include progname.h, relocatable.h. + (program_name): Remove variable. + (main): Use set_program_name. Relocate LOCALEDIR value. Update + copyright year. + * tstngettext.c: Include progname.h, relocatable.h. + (program_name): Remove variable. + (main): Use set_program_name. Relocate LOCALEDIR value. Update + copyright year. + * Makefile.am (tstgettext_CFLAGS, tstngettext_CFLAGS): New variables. + 2003-02-28 Bruno Haible * Makefile.am (localedir): New variable. diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index f136630b5..a5e33a4d5 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -115,8 +115,10 @@ LDADD_yes = ../intl/libintl.la LDADD_no = ../intl/libgnuintl.la @LTLIBINTL@ noinst_PROGRAMS = tstgettext tstngettext cake fc3 fc4 tstgettext_SOURCES = tstgettext.c setlocale.c +tstgettext_CFLAGS = -DINSTALLDIR=\".\" tstgettext_LDADD = ../lib/libgettextlib.la $(LDADD) tstngettext_SOURCES = tstngettext.c setlocale.c +tstngettext_CFLAGS = -DINSTALLDIR=\".\" tstngettext_LDADD = ../lib/libgettextlib.la $(LDADD) cake_SOURCES = plural-1-prg.c setlocale.c cake_LDADD = ../lib/libgettextlib.la $(LDADD) diff --git a/gettext-tools/tests/tstgettext.c b/gettext-tools/tests/tstgettext.c index 4fdfb1c50..e8b163273 100644 --- a/gettext-tools/tests/tstgettext.c +++ b/gettext-tools/tests/tstgettext.c @@ -1,5 +1,5 @@ /* gettext - retrieve text string from message catalog and print it. - Copyright (C) 1995-1997, 2000-2002 Free Software Foundation, Inc. + Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc. Written by Ulrich Drepper , May 1995. This program is free software; you can redistribute it and/or modify @@ -28,6 +28,8 @@ #include #include "error.h" +#include "progname.h" +#include "relocatable.h" #include "basename.h" #include "xmalloc.h" #include "exit.h" @@ -47,9 +49,6 @@ int add_newline; message catalog. */ int do_expand; -/* Name the program is called with. */ -extern const char *program_name; - /* Long options. */ static const struct option long_options[] = { @@ -86,9 +85,7 @@ main (int argc, char *argv[]) do_expand = 0; /* Set program name for message texts. */ - program_name = argv[0]; - if (strncmp (program_name, "lt-", 3) == 0) - program_name += 3; + set_program_name (argv[0]); #ifdef HAVE_SETLOCALE /* Set locale via LC_ALL. */ @@ -96,7 +93,7 @@ main (int argc, char *argv[]) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Parse command line options. */ @@ -159,7 +156,7 @@ main (int argc, char *argv[]) This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ "), - "1995-1997, 2000-2002"); + "1995-1997, 2000-2003"); printf (_("Written by %s.\n"), "Ulrich Drepper"); exit (EXIT_SUCCESS); } diff --git a/gettext-tools/tests/tstngettext.c b/gettext-tools/tests/tstngettext.c index a7429c248..bea4cabfd 100644 --- a/gettext-tools/tests/tstngettext.c +++ b/gettext-tools/tests/tstngettext.c @@ -1,5 +1,5 @@ /* ngettext - retrieve plural form strings from message catalog and print them. - Copyright (C) 1995-1997, 2000-2002 Free Software Foundation, Inc. + Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc. 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 @@ -27,6 +27,8 @@ #include #include "error.h" +#include "progname.h" +#include "relocatable.h" #include "basename.h" #include "exit.h" #include "xsetenv.h" @@ -38,9 +40,6 @@ #define _(str) gettext (str) -/* Name the program is called with. */ -extern const char *program_name; - /* Long options. */ static const struct option long_options[] = { @@ -75,7 +74,7 @@ main (int argc, char *argv[]) const char *domaindir = getenv ("TEXTDOMAINDIR"); /* Set program name for message texts. */ - program_name = argv[0]; + set_program_name (argv[0]); #ifdef HAVE_SETLOCALE /* Set locale via LC_ALL. */ @@ -83,7 +82,7 @@ main (int argc, char *argv[]) #endif /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); /* Parse command line options. */ @@ -134,7 +133,7 @@ main (int argc, char *argv[]) This is free software; see the source for copying conditions. There is NO\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ "), - "1995-1997, 2000-2002"); + "1995-1997, 2000-2003"); printf (_("Written by %s.\n"), "Ulrich Drepper"); exit (EXIT_SUCCESS); }