]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Support for relocatable installation.
authorBruno Haible <bruno@clisp.org>
Mon, 17 Mar 2003 09:38:55 +0000 (09:38 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:10:16 +0000 (12:10 +0200)
62 files changed:
ChangeLog
INSTALL
Makefile.am
autoconf-lib-link/ChangeLog
autoconf-lib-link/INSTALL
gettext-runtime/ChangeLog
gettext-runtime/INSTALL
gettext-runtime/configure.ac
gettext-runtime/intl/ChangeLog
gettext-runtime/intl/Makefile.in
gettext-runtime/intl/libgnuintl.h
gettext-runtime/intl/localcharset.c
gettext-runtime/intl/localealias.c
gettext-runtime/lib/ChangeLog
gettext-runtime/lib/Makefile.am
gettext-runtime/libasprintf/INSTALL
gettext-runtime/po/ChangeLog
gettext-runtime/src/ChangeLog
gettext-runtime/src/Makefile.am
gettext-runtime/src/gettext.c
gettext-runtime/src/ngettext.c
gettext-tools/ChangeLog
gettext-tools/INSTALL
gettext-tools/configure.ac
gettext-tools/lib/ChangeLog
gettext-tools/lib/Makefile.am
gettext-tools/lib/localcharset.c
gettext-tools/lib/progname.c
gettext-tools/lib/progname.h
gettext-tools/lib/xmalloc.c
gettext-tools/lib/xmalloc.h
gettext-tools/m4/ChangeLog
gettext-tools/m4/Makefile.am
gettext-tools/misc/ChangeLog
gettext-tools/misc/autopoint.in
gettext-tools/misc/gettextize.in
gettext-tools/src/ChangeLog
gettext-tools/src/Makefile.am
gettext-tools/src/hostname.c
gettext-tools/src/msgattrib.c
gettext-tools/src/msgcat.c
gettext-tools/src/msgcmp.c
gettext-tools/src/msgcomm.c
gettext-tools/src/msgconv.c
gettext-tools/src/msgen.c
gettext-tools/src/msgexec.c
gettext-tools/src/msgfilter.c
gettext-tools/src/msgfmt.c
gettext-tools/src/msggrep.c
gettext-tools/src/msginit.c
gettext-tools/src/msgmerge.c
gettext-tools/src/msgunfmt.c
gettext-tools/src/msguniq.c
gettext-tools/src/read-java.c
gettext-tools/src/read-tcl.c
gettext-tools/src/urlget.c
gettext-tools/src/user-email.in
gettext-tools/src/xgettext.c
gettext-tools/tests/ChangeLog
gettext-tools/tests/Makefile.am
gettext-tools/tests/tstgettext.c
gettext-tools/tests/tstngettext.c

index 3831e262aab7e2ab1585d069701be7bf3b70a7de..a71aeb06edbffec5ac8f0c66580c833dda54d25e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+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,
diff --git a/INSTALL b/INSTALL
index 863ccc31e87998ca0993b3584520fc0c78338f6f..3c7993200b27b6d98073d826406e41c8e93a933f 100644 (file)
--- 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
 ==================
index 22367901fcede9b806878bc425c96d2b3e9f4dfd..8865d49285ad7b4ae86b6c71a3f9543f1a52296e 100644 (file)
@@ -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
 
index d5cd0cbd6dff6de74e13acbab5e4b13f68ffebdd..2141a2f95ec414b3de3a0f15331ae24581dc0afe 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 863ccc31e87998ca0993b3584520fc0c78338f6f..3c7993200b27b6d98073d826406e41c8e93a933f 100644 (file)
@@ -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
 ==================
index a28ea74ec47891271ff383d2ce82a295b7d1f05d..30214489d82e1f99f64a639f0726ee757a99a756 100644 (file)
@@ -1,3 +1,11 @@
+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.
index 863ccc31e87998ca0993b3584520fc0c78338f6f..3c7993200b27b6d98073d826406e41c8e93a933f 100644 (file)
@@ -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
 ==================
index f09aa5fc167f8ef6c9d49d3912071435031d9026..5db4242126aa4ae120e78e747512f92f8cbfc650 100644 (file)
@@ -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.)
index 49ed8a0bebfe0068eb89c734d5df10e43d41f8b2..cc86b4147f18e03f49218769c81446b5a5fcca54 100644 (file)
@@ -1,3 +1,20 @@
+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)/"
index b6b0485488b11477ccb1c069f89df2d31a68b5e6..ce49f05fd0b391a1ebb28e6a43e10e015ef7a84b 100644 (file)
@@ -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
 
index 3ae78abed21f297f64e0b4f87b90dedb6889cf2e..4123c44ade670fcb75c1b16b67cbdf81a945347f 100644 (file)
@@ -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
index 6676e8b50d9d7a0e2586625f942e4d5854e082bb..998882470cfc259f972f8a26de0dc060e387ed3c 100644 (file)
 # 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) == '\\')
@@ -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;
 
index 785540307c7824dc8a424d1a9c662355f5337dc4..12ad821e691edeb10ab1d6dfafd6ec530a01290b 100644 (file)
@@ -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;
index f9fdce9a6e3f03d202cd27fbd688981b008ecb75..f2b8b074f73181275cdb55f14e22b063e104d9c2 100644 (file)
@@ -1,3 +1,32 @@
+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.
index 35fc8bec8c673e93e47cab5e8f6cc3d5a6308277..3b65b08ffc48eddaa963f55932fc4f32a8a68acb 100644 (file)
 ## 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.
index 863ccc31e87998ca0993b3584520fc0c78338f6f..3c7993200b27b6d98073d826406e41c8e93a933f 100644 (file)
@@ -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
 ==================
index 1690181204239956e7e941986cfb8273af163a42..d64dc4010c0cf9473ac6fd7391090cabd0d04370 100644 (file)
@@ -1,3 +1,7 @@
+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
index f9fdce9a6e3f03d202cd27fbd688981b008ecb75..8458099e1f115c881da915ea88bb8404d08c873f 100644 (file)
@@ -1,3 +1,19 @@
+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.
index df5ae47ca6fa5d9eb3e87b9f7ec20a6a7f05e22b..2383e71643673a2a49c68d767118a0a136216843 100644 (file)
@@ -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@
index 78ea862b41248f9ead8cd97811556399141ee0ac..b39daa508bd1384920aaa11ab6042dba9e150edc 100644 (file)
@@ -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 <drepper@gnu.ai.mit.edu>, May 1995.
 
    This program is free software; you can redistribute it and/or modify
@@ -27,6 +27,8 @@
 #include <locale.h>
 
 #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);
     }
index 989e0ff66d400da494764bba0e44586695ca4df9..654a34740b11a8ff956035461230323185215678 100644 (file)
@@ -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 <errno.h>
 
 #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);
     }
index 98f1cfb906389fca2775e0a51ab66e805e741e53..9caf58674e71535cf055cf9c635ad1dc900f7fc6 100644 (file)
@@ -1,3 +1,10 @@
+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.
index 863ccc31e87998ca0993b3584520fc0c78338f6f..3c7993200b27b6d98073d826406e41c8e93a933f 100644 (file)
@@ -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
 ==================
index 88fd70173c5eaeb92e710f2dde445f17969e1fa7..e978beeb3c245b713a4bd357a992706f23ea7157 100644 (file)
@@ -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
index 36d6c0097f37beea3f4d16b0c2ed99875d873f8b..3ada6c0fba01c1798aafb1a0808b1d358b89e7d9 100644 (file)
@@ -1,3 +1,36 @@
+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
index efceef1f7b7422b914604567ec28625a704999e0..59405335894bd32dc2ddfcbb0c0e70e937a36b33 100644 (file)
@@ -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
 
index 6676e8b50d9d7a0e2586625f942e4d5854e082bb..998882470cfc259f972f8a26de0dc060e387ed3c 100644 (file)
 # 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) == '\\')
@@ -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;
 
index 98e1a6013e72638dae74be14c595ddaa219c0e77..11bf92ebe37ed7272dcae4c1e69790a9cd4f6cdd 100644 (file)
@@ -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 <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.
@@ -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/<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;
index 0b50bfe38d25687a78aa4ee328248225a56132c9..13d87cd001437d873e3771246bc88da09ee85add 100644 (file)
@@ -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 <haible@clisp.cons.org>, 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'
index ed757d2a9c70ec755d821360826d84c20288ea03..0f6577989162f26bcc348876169444b86076163f 100644 (file)
@@ -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
    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;
 }
 
index c5b47ece378aa9bb2506987cd82465733c28ef1c..aa85e1f5ff5e74d9e9b778d07709257b50ab3f98 100644 (file)
@@ -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 <haible@clisp.cons.org>, 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.  */
 
index dac5395a93baca2511460d85dde8bc00c5df5db4..ed46eb4789b46c68a98ff082561ca69a8c0dc3aa 100644 (file)
@@ -1,3 +1,12 @@
+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.
index 274f0b23472e7657a4c4ee141967bcd7bdb72c5b..7ae0632543045ca7071878ec7a81685a51606b37 100644 (file)
@@ -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
index a232545112d1e1630571a06c41e59ed2b0a416ce..a5a9ea9cc5a03d829cc043df58b4f124b8ec877e 100644 (file)
@@ -1,3 +1,9 @@
+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
index d22f14e5a40fbdddda656cb8e6b44566ee427f16..7b7a13d44f0550f45c86bc73fbe551a3e1cb1a1f 100644 (file)
@@ -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.
index 46059a9f257182445fce5a358d32ac100ef6c261..94f51f076ff330ee3efb680213ca311f46078ff8 100644 (file)
@@ -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 ||
index f76f461f2084881e97c929374bc40723d429f8dd..7babeb529e2caca86c40ef3b078e60a6911d2c9b 100644 (file)
@@ -1,3 +1,67 @@
+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
index 14c73c09afade93cc2cadcff888b3fff68184ee1..1a3beeed5c6925b46b505f397434224cf1da9166 100644 (file)
@@ -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@
index 0bcbe413ca64f918c20ca63d9a3c7647398e26c4..32fae9cdf4898ea5fbd1a24f4827e792aa098a42 100644 (file)
@@ -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 <haible@clisp.cons.org>, 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);
     }
index 36d2284e3e3b4a189d8aa62abd56a54d9ef82384..fac9ae7935bac3cb7fe0db99f6d9e13b073e45e6 100644 (file)
@@ -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.  */
index 7109b21f9980b4e5853f0c46ed757d19af660588..a949f562b89aa38b2121e077d8177f91e5b98438 100644 (file)
@@ -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.  */
index c47f46b911af7ec8c840b912adc5a4a5f5066c5c..9d60745b6810ba2be5d21fc7e2dc6c56da759535 100644 (file)
@@ -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;
index 021278f8a919ddad1c7db09c2224fef3671a5e01..2f1d799ed26de13c41a716e35354e0f08e11fa5a 100644 (file)
@@ -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.  */
index 76d3e6f846c89bce9baf27afae482c672ce9c62e..e843eb3a01b9dbfa9bc07d4a41c84cd48d39f84e 100644 (file)
@@ -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.  */
index 04da1040921ad8242290a0f6813b6ea66b0940b3..ac66ebb48be92e7e3ed5c2b588b1ad68b6f8d218 100644 (file)
@@ -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.  */
index 1e1f5d90b27838eede280327135dab73e61d5ba1..4840ee4d3131eb9977eea489011319643de1ccf1 100644 (file)
@@ -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.  */
index 96fda4b1f0a43ef16770e1e38714d654024a79cf..11e5f57246631c1a06ffeb476d02cf0dce3b5041 100644 (file)
@@ -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.  */
index c43a68a7a79d9146f1dc51edda39508b02342622..29c0a98e5359a4b393eb62bb3383bcf10323d54c 100644 (file)
@@ -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,
index 5306ab993798431c1226504b6ab2c0af52d35d97..fe35e272b3b08fd5684a511755ac103f1783d67a 100644 (file)
@@ -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.  */
index 339a8ab239e6bb5aef525a202906dafc09bf5681..bd146e730b7174e3f307aaeae608dc1bc5a29c22 100644 (file)
@@ -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;
index 41c51e02f92f7a1062ae2fbe29438d71ef21aeb7..b134a5b70230d7a4cec71eb42554457e781628e3 100644 (file)
@@ -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.  */
index ff7b13b4be5af4817adde4133c9c99493d27cdf3..38344760f3f73f269cadd936446aa20cacdbceb4 100644 (file)
@@ -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:",
index 39284b370b89e6e26c805b7665b43693846542db..3bf1cbfc2f017e337458232778c174d6dba93230 100644 (file)
@@ -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.  */
index b9f376eb54343ce0b2d2d0ba76d505e318869ccd..ed64591386a3872ba899f05ef9532c2251f10468 100644 (file)
@@ -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 <haible@clisp.cons.org>, 2001.
 
    This program is free software; you can redistribute it and/or modify
@@ -29,6 +29,7 @@
 #include <errno.h>
 
 #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
index 44831177e48ffaeefa1b2e785e0807a5c45e3d0e..71567ce4f6bd6b7de34db97a050c94ef06914d6b 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 
 #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);
 
index c2d2aca4fa0b0f864d414cb02cc3b17da96fdea5..f11ee1b4dac1e7425c6a60b6c76065cfda1fd6b6 100644 (file)
@@ -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 <haible@clisp.cons.org>, 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
index 3957e5ee9bda10ecbc38aef54fd9e9d7fed33a39..bd4a7c9ac8bccd173ee975a4d47e3c81b5a861b6 100644 (file)
 # 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
index e1706a73446c3983c97a19fd26355ce4ee25f692..e42097fd556974e4c7b8ae820b39d96819fd284f 100644 (file)
@@ -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.  */
index 3ff128f50ae37de40c752e2c8ac4694d8853f737..25fbca0b03ce9c5d21e72af241d8454389945035 100644 (file)
@@ -1,3 +1,16 @@
+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.
index f136630b53d06dd36334d39fc452eaef38f0f65e..a5e33a4d5abc1c4e6e30d47e18e3e4c23152cfed 100644 (file)
@@ -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)
index 4fdfb1c504ddbb7a0b2b658cebaa3998ff08e207..e8b163273dac0933d4ab63584b31c93ac49fca5c 100644 (file)
@@ -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 <drepper@gnu.ai.mit.edu>, May 1995.
 
    This program is free software; you can redistribute it and/or modify
@@ -28,6 +28,8 @@
 #include <locale.h>
 
 #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);
     }
index a7429c24827cbfb357eea65824f2959ae209144d..bea4cabfde3e0ed58df1fa8960bb3027a0d1b916 100644 (file)
@@ -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 <errno.h>
 
 #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);
     }