Index: ChangeLog =================================================================== RCS file: /sources/hello/hello/ChangeLog,v retrieving revision 1.32 diff -u -p -r1.32 ChangeLog --- ChangeLog 23 Nov 2006 15:02:24 -0000 1.32 +++ ChangeLog 26 Feb 2007 02:12:11 -0000 @@ -1,3 +1,18 @@ +2007-02-20 Ben Pfaff + + Add support for relocatability. + + * Imported gnulib "relocatable" module. + + * configure.ac: AM_PROG_CC_C_O needed for target-specific flags. + + * src/Makefile.am: Add Automake magic for relocatability. + + * src/hello.c: Use program_name from gnulib progname and progreloc + modules, instead of rolling our own. + (main): Call set_program_name. Call relocate on LOCALEDIR when + passing to bindtextdomain. + 2006-11-23 Karl Berry * Version 2.2. Index: configure.ac =================================================================== RCS file: /sources/hello/hello/configure.ac,v retrieving revision 1.22 diff -u -p -r1.22 configure.ac --- configure.ac 23 Nov 2006 15:02:24 -0000 1.22 +++ configure.ac 26 Feb 2007 02:12:11 -0000 @@ -24,6 +24,7 @@ AC_CONFIG_SRCDIR([src/hello.c]) dnl Checks for programs. # We need a C compiler. AC_PROG_CC +AM_PROG_CC_C_O # Since we use gnulib: gl_EARLY must be called as soon as possible after # the C compiler is checked. The others could be later, but we just Index: src/Makefile.am =================================================================== RCS file: /sources/hello/hello/src/Makefile.am,v retrieving revision 1.9 diff -u -p -r1.9 Makefile.am --- src/Makefile.am 17 Oct 2006 21:57:42 -0000 1.9 +++ src/Makefile.am 26 Feb 2007 02:12:11 -0000 @@ -26,3 +26,8 @@ localedir = $(datadir)/locale AM_CPPFLAGS = -I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@ + +hello_CFLAGS = -DINSTALLDIR=\"$(bindir)\" +if RELOCATABLE_VIA_LD +hello_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +endif Index: src/hello.c =================================================================== RCS file: /sources/hello/hello/src/hello.c,v retrieving revision 1.27 diff -u -p -r1.27 hello.c --- src/hello.c 12 Dec 2006 02:01:11 -0000 1.27 +++ src/hello.c 26 Feb 2007 02:12:11 -0000 @@ -18,11 +18,10 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include +#include "progname.h" +#include "relocatable.h" #include "system.h" -/* String containing name the program is called with. */ -const char *program_name; - static const struct option longopts[] = { { "greeting", required_argument, NULL, 'g' }, @@ -43,14 +42,14 @@ main (int argc, char *argv[]) int t = 0, n = 0, lose = 0; const char *greeting = NULL; - program_name = argv[0]; + set_program_name (argv[0]); /* Set locale via LC_ALL. */ setlocale (LC_ALL, ""); #if ENABLE_NLS /* Set the text message domain. */ - bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain (PACKAGE, relocate (LOCALEDIR)); textdomain (PACKAGE); #endif