+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
* configure.ac: Include AC_CANONICAL_HOST, AC_ARG_ENABLE, AC_ARG_WITH,
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
=================
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
==================
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
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ Support for relocatable installation.
+ * INSTALL: Document --enable-relocatable and --with-libintl-prefix.
+
2003-02-22 Bruno Haible <bruno@clisp.org>
* Makefile.am (ps, pdf): Remove rules, redundant with automake 1.7.2.
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
=================
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
==================
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
* Makefile.am (ps, pdf): Remove rules, redundant with automake 1.7.2.
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
=================
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
==================
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.)
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
* Makefile.in (mkinstalldirs): Simplify. Prepending "$(top_builddir)/"
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@
plural-exp.h \
eval-plural.h \
localcharset.h \
+ relocatable.h \
os2compat.h \
libgnuintl.h
SOURCES = \
plural.y \
plural-exp.c \
localcharset.c \
+ relocatable.c \
localename.c \
log.c \
osdep.c \
plural.$lo \
plural-exp.$lo \
localcharset.$lo \
+ relocatable.$lo \
localename.$lo \
log.$lo \
osdep.$lo \
$(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
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
/* 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
#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
# include <os2.h>
#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) == '\\')
{
#if !defined WIN32
FILE *fp;
- const char *dir = LIBDIR;
+ const char *dir = relocate (LIBDIR);
const char *base = "charset.alias";
char *file_name;
/* 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
#include "gettextP.h"
+#if ENABLE_RELOCATABLE
+# include "relocatable.h"
+#else
+# define relocate(pathname) (pathname)
+#endif
+
/* @@ end of prolog @@ */
#ifdef _LIBC
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;
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
Extracted from gettext package.
## 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 <stdbool.h> 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 <alloca.h> 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.
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
=================
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
==================
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ * POTFILES.in: Use references to ../gettext-tools/lib.
+
2003-02-28 Bruno Haible <bruno@clisp.org>
* Makefile.in.in (mkinstalldirs): Simplify. Prepending
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
Extracted from gettext package.
# 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@
/* 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 <drepper@gnu.ai.mit.edu>, May 1995.
This program is free software; you can redistribute it and/or modify
#include <locale.h>
#include "error.h"
+#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "xmalloc.h"
#include "exit.h"
message catalog. */
int do_expand;
-/* Name the program is called with. */
-const char *program_name;
-
/* Long options. */
static const struct option long_options[] =
{
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. */
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Parse command line options. */
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);
}
/* 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
#include <errno.h>
#include "error.h"
+#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "xmalloc.h"
#include "exit.h"
message catalog. */
int do_expand;
-/* Name the program is called with. */
-const char *program_name;
-
/* Long options. */
static const struct option long_options[] =
{
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. */
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Parse command line options. */
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);
}
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
* configure.ac: Invoke gl_PATHMAX.
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
=================
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
==================
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.
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
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
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
* localcharset.h: Change copyright to LGPL. Enclose declaration in
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 \
# Unused sources.
UNUSED_SOURCE = \
- memmove.c \
xgetcwd.h xgetcwd.c
# How to build libgettextlib.la.
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
# include <os2.h>
#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) == '\\')
{
#if !defined WIN32
FILE *fp;
- const char *dir = LIBDIR;
+ const char *dir = relocate (LIBDIR);
const char *base = "charset.alias";
char *file_name;
/* Program name management.
- Copyright (C) 2001-2002 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003 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
/* Specification. */
#include "progname.h"
+#include <stdbool.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
+#include <fcntl.h>
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <sys/stat.h>
+
+#if defined _WIN32 || defined __WIN32__
+# undef WIN32 /* avoid warning on mingw32 */
+# define WIN32
+#endif
+
+#ifdef WIN32
+# define WIN32_LEAN_AND_MEAN
+# include <windows.h>
+#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.
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/<pid>/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;
/* Program name management.
- Copyright (C) 2001-2002 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003 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
/* 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'
/* 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
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)
{
if (n == 0)
p = malloc ((size_t) 1);
if (p == NULL)
- error (xmalloc_exit_failure, 0, _("memory exhausted"));
+ xalloc_die ();
return p;
}
/* 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 <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
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. */
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
* pathmax.m4: New file, from gnulib.
EXTRA_DIST = README ChangeLog.0 \
alloca.m4 \
backupfile.m4 \
+canonicalize.m4 \
error.m4 \
flex.m4 \
fnmatch.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
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ Support for relocatable installation.
+ * autopoint.in: Relocate $gettext_dir.
+ * gettextize.in: Relocate $gettext_dir.
+
2003-02-16 Bruno Haible <bruno@clisp.org>
* gettextize.in: Create po/Makevars.template from installed
#! /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
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 ()
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.
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 ()
# 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 ||
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
* msggrep.c (main): On Solaris, prefer /usr/xpg4/bin/grep to
EXTRA_DIST += FILES project-id ChangeLog.0
localedir = $(datadir)/locale
+aliaspath = $(localedir)
jardir = $(datadir)/gettext
pkgdatadir = $(datadir)/gettext
projectsdir = $(pkgdatadir)/projects
-I../intl -I$(top_srcdir)/../gettext-runtime/intl
DEFS = \
-DLOCALEDIR=\"$(localedir)\" \
+ -DLOCALE_ALIAS_PATH=\"$(aliaspath)\" \
-DUSEJEXE=$(USEJEXE) \
-DGETTEXTJEXEDIR=\"$(pkglibdir)\" \
-DGETTEXTJAR=\"$(jardir)/gettext.jar\" \
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
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.
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@
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@
/* 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 <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "xmalloc.h"
#include "exit.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
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);
}
#include "dir-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "read-po.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
#include "file-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "read-po.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
#include "dir-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "exit.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
do_help = false;
#include "file-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "read-po.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
#include "dir-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "read-po.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
#include "dir-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "read-po.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
#include "error.h"
#include "xerror.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "read-po.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
#include "dir-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "read-po.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
#include "dir-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "xerror.h"
#include "format.h"
#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,
#include "dir-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "read-po.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "strpbrk.h"
#include "strstr.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
static const char *
project_id ()
{
- char *gettextlibdir;
+ const char *gettextlibdir;
char *prog;
char *argv[3];
pid_t child;
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);
static const char *
project_id_version ()
{
- char *gettextlibdir;
+ const char *gettextlibdir;
char *prog;
char *argv[4];
pid_t child;
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);
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];
/* 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\
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];
/* 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;
#include "dir-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "read-po.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "exit.h"
#include "message.h"
#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:",
#include "str-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "message.h"
#include "read-po.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
/* Reading Java ResourceBundles.
- Copyright (C) 2001-2002 Free Software Foundation, Inc.
+ Copyright (C) 2001-2003 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
#include <errno.h>
#include "msgunfmt.h"
+#include "relocatable.h"
#include "javaexec.h"
#include "pipe.h"
#include "wait-process.h"
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
#include <stdlib.h>
#include "msgunfmt.h"
+#include "relocatable.h"
#include "pathname.h"
#include "sh-quote.h"
#include "pipe.h"
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);
/* 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 <haible@clisp.cons.org>, 2001.
This program is free software; you can redistribute it and/or modify
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "full-write.h"
#include "execute.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set default values for variables. */
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);
}
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
# 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
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
#include "str-list.h"
#include "error.h"
#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "xerror.h"
#include "xmalloc.h"
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Set initial value of variables. */
+2003-02-28 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
* Makefile.am (localedir): New variable.
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)
/* 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 <drepper@gnu.ai.mit.edu>, May 1995.
This program is free software; you can redistribute it and/or modify
#include <locale.h>
#include "error.h"
+#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "xmalloc.h"
#include "exit.h"
message catalog. */
int do_expand;
-/* Name the program is called with. */
-extern const char *program_name;
-
/* Long options. */
static const struct option long_options[] =
{
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. */
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Parse command line options. */
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);
}
/* 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
#include <errno.h>
#include "error.h"
+#include "progname.h"
+#include "relocatable.h"
#include "basename.h"
#include "exit.h"
#include "xsetenv.h"
#define _(str) gettext (str)
-/* Name the program is called with. */
-extern const char *program_name;
-
/* Long options. */
static const struct option long_options[] =
{
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. */
#endif
/* Set the text message domain. */
- bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE, relocate (LOCALEDIR));
textdomain (PACKAGE);
/* Parse command line options. */
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);
}