From: Bruno Haible Date: Mon, 5 Dec 2005 12:06:30 +0000 (+0000) Subject: Cygwin portability. X-Git-Tag: v0.15~339 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d99da555246411bafd45c19a5c1fcc200f4d2ca;p=thirdparty%2Fgettext.git Cygwin portability. --- diff --git a/ChangeLog b/ChangeLog index c40c0a532..b4ab07d70 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-11-23 Bruno Haible + + Cygwin portability. + * build-aux/install-reloc: Expect additional exeext argument. On + Cygwin, use suffix ".bin.exe" instead of just ".bin". + 2005-09-18 Bruno Haible * build-aux/ltmain.sh: Upgrade to libtool-1.5.20. diff --git a/autoconf-lib-link/ChangeLog b/autoconf-lib-link/ChangeLog index 465fd71a2..63400081e 100644 --- a/autoconf-lib-link/ChangeLog +++ b/autoconf-lib-link/ChangeLog @@ -1,3 +1,8 @@ +2005-11-23 Bruno Haible + + Cygwin portability. + * configure.ac: Invoke gl_WOE32_DLL. + 2005-09-18 Bruno Haible * config.rpath: Upgrade to libtool-1.5.20. diff --git a/autoconf-lib-link/configure.ac b/autoconf-lib-link/configure.ac index 24afbf0b4..db8705ef5 100644 --- a/autoconf-lib-link/configure.ac +++ b/autoconf-lib-link/configure.ac @@ -38,6 +38,7 @@ AC_OBJEXT AC_EXEEXT dnl Check for build configuration. +gl_WOE32_DLL AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL diff --git a/build-aux/install-reloc b/build-aux/install-reloc index cbec00791..55ec38cc8 100755 --- a/build-aux/install-reloc +++ b/build-aux/install-reloc @@ -1,6 +1,6 @@ #!/bin/sh # install-reloc - install a program including a relocating wrapper -# Copyright (C) 2003 Free Software Foundation, Inc. +# Copyright (C) 2003, 2005 Free Software Foundation, Inc. # Written by Bruno Haible , 2003. # # This program is free software; you can redistribute it and/or modify @@ -18,7 +18,7 @@ # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: -# install-reloc library_path_var library_path_value prefix compile_command srcdir config_h_dir install_command... destprog +# install-reloc library_path_var library_path_value prefix compile_command srcdir config_h_dir exeext install_command... destprog # where # - library_path_var is the platform dependent runtime library path variable # - library_path_value is a colon separated list of directories that contain @@ -29,6 +29,7 @@ # - builddir is the directory where to find built dependencies (namely, # alloca.h and stdbool.h) # - config_h_dir is the directory where to find config.h +# - exeext is platform dependent suffix of executables # - install-command is the install command line, excluding the final destprog # - destprog is the destination program name # install-reloc renames destprog to destprog.bin and installs a relocating @@ -45,6 +46,7 @@ if test $# -eq 2; then srcdir=$RELOC_SRCDIR builddir=$RELOC_BUILDDIR config_h_dir=$RELOC_CONFIG_H_DIR + exeext=$RELOC_EXEEXT install_prog=$RELOC_INSTALL_PROG # including the "-c" option else if test $# -ge 9; then @@ -56,7 +58,9 @@ else srcdir=$5 builddir=$6 config_h_dir=$7 - install_prog=$8 # maybe not including the "-c" option + exeext=$8 + install_prog=$9 # maybe not including the "-c" option + shift shift shift shift @@ -66,7 +70,7 @@ else shift shift else - echo "Usage: $0 library_path_var library_path_value prefix compile_command srcdir builddir config_h_dir install_command... destprog" 1>&2 + echo "Usage: $0 library_path_var library_path_value prefix compile_command srcdir builddir config_h_dir exeext install_command... destprog" 1>&2 exit 1 fi fi @@ -77,6 +81,11 @@ for arg do destprog=$arg done +# Remove trailing $exeext, if present. +if test -n "$exeext"; then + sedexpr='s|'`echo "$exeext" | sed -e 's,\.,\\\.,g'`'$||' + destprog=`echo "$destprog" | sed -e "$sedexpr"` +fi # Outputs a command and runs it. func_verbose () @@ -110,10 +119,10 @@ test -n "$libdirs" || exit 0 # Compile wrapper. installdir=`echo "$destprog" | sed -e 's,/[^/]*$,,'` -func_verbose $compile_command -I"$builddir" -I"$srcdir" -I"$config_h_dir" -DHAVE_CONFIG_H -DNO_XMALLOC -D"INSTALLPREFIX=\"$prefix\"" -D"INSTALLDIR=\"$installdir\"" -D"LIBPATHVAR=\"$library_path_var\"" -D"LIBDIRS=$libdirs" "$srcdir"/relocwrapper.c "$srcdir"/progname.c "$srcdir"/progreloc.c "$srcdir"/xreadlink.c "$srcdir"/readlink.c "$srcdir"/canonicalize.c "$srcdir"/allocsa.c "$srcdir"/relocatable.c "$srcdir"/setenv.c "$srcdir"/strerror.c -o $destprog.wrapper || exit $? +func_verbose $compile_command -I"$builddir" -I"$srcdir" -I"$config_h_dir" -DHAVE_CONFIG_H -DNO_XMALLOC -D"INSTALLPREFIX=\"$prefix\"" -D"INSTALLDIR=\"$installdir\"" -D"LIBPATHVAR=\"$library_path_var\"" -D"LIBDIRS=$libdirs" -D"EXEEXT=\"$exeext\"" "$srcdir"/relocwrapper.c "$srcdir"/progname.c "$srcdir"/progreloc.c "$srcdir"/xreadlink.c "$srcdir"/readlink.c "$srcdir"/canonicalize.c "$srcdir"/allocsa.c "$srcdir"/relocatable.c "$srcdir"/setenv.c "$srcdir"/strerror.c -o "$destprog.wrapper$exeext" || exit $? # Rename $destprog.wrapper -> $destprog -> $destprog.bin. -ln -f $destprog $destprog.bin || exit 1 -mv $destprog.wrapper $destprog || exit 1 +ln -f "$destprog$exeext" "$destprog.bin$exeext" || exit 1 +mv "$destprog.wrapper$exeext" "$destprog$exeext" || exit 1 exit 0 diff --git a/gettext-runtime/ChangeLog b/gettext-runtime/ChangeLog index 4eee768ec..7ca1fe4d1 100644 --- a/gettext-runtime/ChangeLog +++ b/gettext-runtime/ChangeLog @@ -1,3 +1,8 @@ +2005-11-23 Bruno Haible + + Cygwin portability. + * configure.ac: Invoke gl_WOE32_DLL. + 2005-11-24 Bruno Haible * Makefile.am (config.h_vms, config.h.msvc): Treat HAVE_FWPRINTF like diff --git a/gettext-runtime/configure.ac b/gettext-runtime/configure.ac index f98f32a0b..1e957ac55 100644 --- a/gettext-runtime/configure.ac +++ b/gettext-runtime/configure.ac @@ -69,6 +69,7 @@ AC_GNU_SOURCE gl_USE_SYSTEM_EXTENSIONS dnl Check for build configuration. +gl_WOE32_DLL AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL diff --git a/gettext-runtime/intl/ChangeLog b/gettext-runtime/intl/ChangeLog index c712708d1..5d5a268e6 100644 --- a/gettext-runtime/intl/ChangeLog +++ b/gettext-runtime/intl/ChangeLog @@ -1,3 +1,11 @@ +2005-12-04 Bruno Haible + + Cygwin portability. + * relocatable.c: Include also on Cygwin. + (DllMain): Add support for Cygwin. + (get_shared_library_fullname): Update. + Patches partially from Charles Wilson . + 2005-10-09 Bruno Haible 2002-07-24 Ulrich Drepper diff --git a/gettext-runtime/intl/relocatable.c b/gettext-runtime/intl/relocatable.c index 5b43d1299..7cc8daf77 100644 --- a/gettext-runtime/intl/relocatable.c +++ b/gettext-runtime/intl/relocatable.c @@ -1,5 +1,5 @@ /* Provide relocatable packages. - Copyright (C) 2003-2004 Free Software Foundation, Inc. + Copyright (C) 2003-2005 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ # include "xalloc.h" #endif -#if defined _WIN32 || defined __WIN32__ +#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN # include #endif @@ -234,6 +234,9 @@ compute_curr_prefix (const char *orig_installprefix, same = true; break; } + /* Do case-insensitive comparison if the filesystem is always or + often case-insensitive. It's better to accept the comparison + if the difference is only in case, rather than to fail. */ #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ /* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */ if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi) @@ -280,7 +283,7 @@ compute_curr_prefix (const char *orig_installprefix, /* Full pathname of shared library, or NULL. */ static char *shared_library_fullname; -#if defined _WIN32 || defined __WIN32__ +#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ /* Determine the full pathname of the shared library when it is loaded. */ @@ -302,13 +305,31 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved) /* Shouldn't happen. */ return FALSE; - shared_library_fullname = strdup (location); + { +#if defined __CYGWIN__ + /* On Cygwin, we need to convert paths coming from Win32 system calls + to the Unix-like slashified notation. */ + static char location_as_posix_path[2 * MAX_PATH]; + /* There's no error return defined for cygwin_conv_to_posix_path. + See cygwin-api/func-cygwin-conv-to-posix-path.html. + Does it overflow the buffer of expected size MAX_PATH or does it + truncate the path? I don't know. Let's catch both. */ + cygwin_conv_to_posix_path (location, location_as_posix_path); + location_as_posix_path[MAX_PATH - 1] = '\0'; + if (strlen (location_as_posix_path) >= MAX_PATH - 1) + /* A sign of buffer overflow or path truncation. */ + return FALSE; + shared_library_fullname = strdup (location_as_posix_path); +#else + shared_library_fullname = strdup (location); +#endif + } } return TRUE; } -#else /* Unix */ +#else /* Unix except Cygwin */ static void find_shared_library_fullname () @@ -359,15 +380,15 @@ find_shared_library_fullname () #endif } -#endif /* WIN32 / Unix */ +#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ /* Return the full pathname of the current shared library. Return NULL if unknown. - Guaranteed to work only on Linux and Woe32. */ + Guaranteed to work only on Linux, Cygwin and Woe32. */ static char * get_shared_library_fullname () { -#if !(defined _WIN32 || defined __WIN32__) +#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__) static bool tried_find_shared_library_fullname; if (!tried_find_shared_library_fullname) { diff --git a/gettext-runtime/libasprintf/ChangeLog b/gettext-runtime/libasprintf/ChangeLog index 86ba909dc..1a8397e27 100644 --- a/gettext-runtime/libasprintf/ChangeLog +++ b/gettext-runtime/libasprintf/ChangeLog @@ -1,3 +1,8 @@ +2005-11-23 Bruno Haible + + Cygwin portability. + * configure.ac: Invoke gl_WOE32_DLL. + 2005-07-07 Bruno Haible Add ability to create shared library on BeOS. diff --git a/gettext-runtime/libasprintf/configure.ac b/gettext-runtime/libasprintf/configure.ac index eee24c9f5..b536bfe4e 100644 --- a/gettext-runtime/libasprintf/configure.ac +++ b/gettext-runtime/libasprintf/configure.ac @@ -37,6 +37,7 @@ AC_OBJEXT AC_EXEEXT dnl Check for build configuration. +gl_WOE32_DLL AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL case "$host_os" in diff --git a/gettext-runtime/m4/ChangeLog b/gettext-runtime/m4/ChangeLog index 12d0002c3..d37b725fc 100644 --- a/gettext-runtime/m4/ChangeLog +++ b/gettext-runtime/m4/ChangeLog @@ -1,3 +1,9 @@ +2005-11-23 Bruno Haible + + Cygwin portability. + * woe32-dll.m4: New file. + * Makefile.am (EXTRA_DIST): Add it. + 2005-11-21 Bruno Haible * gettext.m4 (AM_INTL_SUBDIR): Invoke gt_LC_MESSAGES always, since we diff --git a/gettext-runtime/m4/Makefile.am b/gettext-runtime/m4/Makefile.am index 3b45d07dc..e091e8325 100644 --- a/gettext-runtime/m4/Makefile.am +++ b/gettext-runtime/m4/Makefile.am @@ -31,4 +31,5 @@ ulonglong.m4 \ visibility.m4 \ wchar_t.m4 \ wint_t.m4 \ +woe32-dll.m4 \ xsize.m4 diff --git a/gettext-tools/ChangeLog b/gettext-tools/ChangeLog index 855894a8e..b7f285d7c 100644 --- a/gettext-tools/ChangeLog +++ b/gettext-tools/ChangeLog @@ -1,3 +1,8 @@ +2005-11-23 Bruno Haible + + Cygwin portability. + * configure.ac: Invoke gl_WOE32_DLL. + 2005-11-24 Bruno Haible * Makefile.am (config.h_vms, config.h.msvc): Treat HAVE_FWPRINTF like diff --git a/gettext-tools/configure.ac b/gettext-tools/configure.ac index 5130b20ca..f42667c8d 100644 --- a/gettext-tools/configure.ac +++ b/gettext-tools/configure.ac @@ -94,6 +94,7 @@ AC_GNU_SOURCE gl_USE_SYSTEM_EXTENSIONS dnl Check for build configuration. +gl_WOE32_DLL AC_LIBTOOL_WIN32_DLL AC_PROG_LIBTOOL case "$host_os" in diff --git a/gettext-tools/lib/ChangeLog b/gettext-tools/lib/ChangeLog index 03df93d2b..70b9ecd88 100644 --- a/gettext-tools/lib/ChangeLog +++ b/gettext-tools/lib/ChangeLog @@ -1,3 +1,17 @@ +2005-12-04 Bruno Haible + + Cygwin portability. + * progreloc.c: Include also on Cygwin. + (find_executable): Add support for Cygwin. + (set_program_name_and_installdir): Handle also platforms with nonempty + EXEEXT. + * relocatable.c: Include also on Cygwin. + (DllMain): Add support for Cygwin. + (get_shared_library_fullname): Update. + * relocwrapper.c (add_dotbin): Handle also platforms with nonempty + EXEEXT. + Patches partially from Charles Wilson . + 2005-10-09 Bruno Haible * c-strcasestr.h: New file. diff --git a/gettext-tools/lib/progreloc.c b/gettext-tools/lib/progreloc.c index 3f56a22a9..acf9488be 100644 --- a/gettext-tools/lib/progreloc.c +++ b/gettext-tools/lib/progreloc.c @@ -1,5 +1,5 @@ /* Provide relocatable programs. - Copyright (C) 2003-2004 Free Software Foundation, Inc. + Copyright (C) 2003-2005 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ # define WIN32 #endif -#ifdef WIN32 +#if defined WIN32 || defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN # include #endif @@ -126,16 +126,39 @@ maybe_executable (const char *filename) static char * find_executable (const char *argv0) { -#ifdef WIN32 - char buf[1024]; - int length = GetModuleFileName (NULL, buf, sizeof (buf)); +#if defined WIN32 || defined __CYGWIN__ + char location[MAX_PATH]; + int length = GetModuleFileName (NULL, location, sizeof (location)); if (length < 0) return NULL; - if (!IS_PATH_WITH_DIR (buf)) + if (!IS_PATH_WITH_DIR (location)) /* Shouldn't happen. */ return NULL; - return xstrdup (buf); -#else /* Unix */ + { +#if defined __CYGWIN__ + /* cygwin-1.5.13 (2005-03-01) or newer would also allow a Linux-like + implementation: readlink of "/proc/self/exe". But using the + result of the Win32 system call is simpler and is consistent with the + code in relocatable.c. */ + /* On Cygwin, we need to convert paths coming from Win32 system calls + to the Unix-like slashified notation. */ + static char location_as_posix_path[2 * MAX_PATH]; + /* There's no error return defined for cygwin_conv_to_posix_path. + See cygwin-api/func-cygwin-conv-to-posix-path.html. + Does it overflow the buffer of expected size MAX_PATH or does it + truncate the path? I don't know. Let's catch both. */ + cygwin_conv_to_posix_path (location, location_as_posix_path); + location_as_posix_path[MAX_PATH - 1] = '\0'; + if (strlen (location_as_posix_path) >= MAX_PATH - 1) + /* A sign of buffer overflow or path truncation. */ + return NULL; + /* Call canonicalize_file_name, because Cygwin supports symbolic links. */ + return canonicalize_file_name (location_as_posix_path); +#else + return xstrdup (location); +#endif + } +#else /* Unix && !Cygwin */ #ifdef __linux__ /* The executable is accessible as /proc//exe. In newer Linux versions, also as /proc/self/exe. Linux >= 2.1 provides a symlink @@ -260,20 +283,48 @@ set_program_name_and_installdir (const char *argv0, { const char *argv0_stripped = argv0; - /* Relocatable programs are renamed to .bin by install-reloc. Remove - this suffix here. */ + /* Relocatable programs are renamed to .bin by install-reloc. Or, more + generally, their suffix is changed from $exeext to .bin$exeext. + Remove the ".bin" 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); + const size_t exeext_len = sizeof (EXEEXT) - sizeof (""); + if (argv0_len > 4 + exeext_len) + if (memcmp (argv0 + argv0_len - exeext_len - 4, ".bin", 4) == 0) + { + if (sizeof (EXEEXT) > sizeof ("")) + { + /* Compare using an inlined copy of c_strncasecmp(), because + the filenames may have undergone a case conversion since + they were packaged. In other words, EXEEXT may be ".exe" + on one system and ".EXE" on another. */ + static const char exeext[] = EXEEXT; + const char *s1 = argv0 + argv0_len - exeext_len; + const char *s2 = exeext; + for (; *s1 != '\0'; s1++, s2++) + { + unsigned char c1 = *s1; + unsigned char c2 = *s2; + if ((c1 >= 'A' && c1 <= 'Z' ? c1 - 'A' + 'a' : c1) + != (c2 >= 'A' && c2 <= 'Z' ? c2 - 'A' + 'a' : c2)) + goto done_stripping; + } + } + /* Remove ".bin" before EXEEXT or its equivalent. */ + { + char *shorter = (char *) xmalloc (argv0_len - 4 + 1); #ifdef NO_XMALLOC - if (shorter != NULL) + if (shorter != NULL) #endif - { - memcpy (shorter, argv0, argv0_len - 4); - shorter[argv0_len - 4] = '\0'; - argv0_stripped = shorter; + { + memcpy (shorter, argv0, argv0_len - exeext_len - 4); + if (sizeof (EXEEXT) > sizeof ("")) + memcpy (shorter + argv0_len - exeext_len - 4, + argv0 + argv0_len - exeext_len - 4, + exeext_len); + shorter[argv0_len - 4] = '\0'; + argv0_stripped = shorter; + } } } } diff --git a/gettext-tools/lib/relocatable.c b/gettext-tools/lib/relocatable.c index 5b43d1299..7cc8daf77 100644 --- a/gettext-tools/lib/relocatable.c +++ b/gettext-tools/lib/relocatable.c @@ -1,5 +1,5 @@ /* Provide relocatable packages. - Copyright (C) 2003-2004 Free Software Foundation, Inc. + Copyright (C) 2003-2005 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ # include "xalloc.h" #endif -#if defined _WIN32 || defined __WIN32__ +#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ # define WIN32_LEAN_AND_MEAN # include #endif @@ -234,6 +234,9 @@ compute_curr_prefix (const char *orig_installprefix, same = true; break; } + /* Do case-insensitive comparison if the filesystem is always or + often case-insensitive. It's better to accept the comparison + if the difference is only in case, rather than to fail. */ #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ /* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */ if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi) @@ -280,7 +283,7 @@ compute_curr_prefix (const char *orig_installprefix, /* Full pathname of shared library, or NULL. */ static char *shared_library_fullname; -#if defined _WIN32 || defined __WIN32__ +#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ /* Determine the full pathname of the shared library when it is loaded. */ @@ -302,13 +305,31 @@ DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved) /* Shouldn't happen. */ return FALSE; - shared_library_fullname = strdup (location); + { +#if defined __CYGWIN__ + /* On Cygwin, we need to convert paths coming from Win32 system calls + to the Unix-like slashified notation. */ + static char location_as_posix_path[2 * MAX_PATH]; + /* There's no error return defined for cygwin_conv_to_posix_path. + See cygwin-api/func-cygwin-conv-to-posix-path.html. + Does it overflow the buffer of expected size MAX_PATH or does it + truncate the path? I don't know. Let's catch both. */ + cygwin_conv_to_posix_path (location, location_as_posix_path); + location_as_posix_path[MAX_PATH - 1] = '\0'; + if (strlen (location_as_posix_path) >= MAX_PATH - 1) + /* A sign of buffer overflow or path truncation. */ + return FALSE; + shared_library_fullname = strdup (location_as_posix_path); +#else + shared_library_fullname = strdup (location); +#endif + } } return TRUE; } -#else /* Unix */ +#else /* Unix except Cygwin */ static void find_shared_library_fullname () @@ -359,15 +380,15 @@ find_shared_library_fullname () #endif } -#endif /* WIN32 / Unix */ +#endif /* (WIN32 or Cygwin) / (Unix except Cygwin) */ /* Return the full pathname of the current shared library. Return NULL if unknown. - Guaranteed to work only on Linux and Woe32. */ + Guaranteed to work only on Linux, Cygwin and Woe32. */ static char * get_shared_library_fullname () { -#if !(defined _WIN32 || defined __WIN32__) +#if !(defined _WIN32 || defined __WIN32__ || defined __CYGWIN__) static bool tried_find_shared_library_fullname; if (!tried_find_shared_library_fullname) { diff --git a/gettext-tools/lib/relocwrapper.c b/gettext-tools/lib/relocwrapper.c index 81127d11e..aae6ea4bb 100644 --- a/gettext-tools/lib/relocwrapper.c +++ b/gettext-tools/lib/relocwrapper.c @@ -1,5 +1,5 @@ /* Relocating wrapper program. - Copyright (C) 2003 Free Software Foundation, Inc. + Copyright (C) 2003, 2005 Free Software Foundation, Inc. Written by Bruno Haible , 2003. This program is free software; you can redistribute it and/or modify @@ -58,7 +58,8 @@ #include "relocatable.h" #include "setenv.h" -/* Return a copy of the filename, with an extra ".bin" at the end. */ +/* Return a copy of the filename, with an extra ".bin" at the end. + More generally, it replaces "${EXEEXT}" at the end with ".bin${EXEEXT}". */ static char * add_dotbin (const char *filename) { @@ -67,6 +68,38 @@ add_dotbin (const char *filename) if (result != NULL) { + if (sizeof (EXEEXT) > sizeof ("")) + { + /* EXEEXT handling. */ + const size_t exeext_len = sizeof (EXEEXT) - sizeof (""); + static const char exeext[] = EXEEXT; + if (filename_len > exeext_len) + { + /* Compare using an inlined copy of c_strncasecmp(), because + the filenames may have undergone a case conversion since + they were packaged. In other words, EXEEXT may be ".exe" + on one system and ".EXE" on another. */ + const char *s1 = filename + filename_len - exeext_len; + const char *s2 = exeext; + for (; *s1 != '\0'; s1++, s2++) + { + unsigned char c1 = *s1; + unsigned char c2 = *s2; + if ((c1 >= 'A' && c1 <= 'Z' ? c1 - 'A' + 'a' : c1) + != (c2 >= 'A' && c2 <= 'Z' ? c2 - 'A' + 'a' : c2)) + goto simple_append; + } + /* Insert ".bin" before EXEEXT or its equivalent. */ + memcpy (result, filename, filename_len - exeext_len); + memcpy (result + filename_len - exeext_len, ".bin", 4); + memcpy (result + filename_len - exeext_len + 4, + filename + filename_len - exeext_len, + exeext_len + 1); + return result; + } + } + simple_append: + /* Simply append ".bin". */ memcpy (result, filename, filename_len); memcpy (result + filename_len, ".bin", 4 + 1); return result; diff --git a/gettext-tools/m4/ChangeLog b/gettext-tools/m4/ChangeLog index e9282f34e..e80342bd3 100644 --- a/gettext-tools/m4/ChangeLog +++ b/gettext-tools/m4/ChangeLog @@ -1,3 +1,9 @@ +2005-11-24 Bruno Haible + + Cygwin portability. + * relocatable.m4 (AC_RELOCATABLE): Require AC_EXEEXT. Arrange to set + RELOC_EXEEXT while invoking install-reloc. + 2005-09-20 Bruno Haible * bison-i18n.m4: New file, from bison-2.1. diff --git a/gettext-tools/m4/relocatable.m4 b/gettext-tools/m4/relocatable.m4 index cf05dcf66..40910a16b 100644 --- a/gettext-tools/m4/relocatable.m4 +++ b/gettext-tools/m4/relocatable.m4 @@ -1,4 +1,4 @@ -# relocatable.m4 serial 3 (gettext-0.15) +# relocatable.m4 serial 4 (gettext-0.15) dnl Copyright (C) 2003, 2005 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -13,6 +13,7 @@ AC_DEFUN([AC_RELOCATABLE], AC_BEFORE([AC_PROG_INSTALL],[AC_RELOCATABLE]) AC_REQUIRE([AC_LIB_LIBPATH]) AC_REQUIRE([AC_RELOCATABLE_LIBRARY]) + AC_REQUIRE([AC_EXEEXT]) is_noop=no use_elf_origin_trick=no if test $RELOCATABLE = yes; then @@ -40,7 +41,7 @@ AC_DEFUN([AC_RELOCATABLE], dnl consisting of more than one word - libtool doesn't support this. dnl So we abuse the INSTALL_PROGRAM_ENV hook, originally meant for the dnl 'install-strip' target. - SET_RELOCATABLE="INSTALL_PROGRAM_ENV = RELOC_LIBRARY_PATH_VAR=\"$shlibpath_var\" RELOC_LIBRARY_PATH_VALUE=\"\$(RELOCATABLE_LIBRARY_PATH)\" RELOC_PREFIX=\"\$(prefix)\" RELOC_COMPILE_COMMAND=\"\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(LDFLAGS)\" RELOC_SRCDIR=\"\$(RELOCATABLE_SRC_DIR)\" RELOC_BUILDDIR=\"\$(RELOCATABLE_BUILD_DIR)\" RELOC_CONFIG_H_DIR=\"\$(RELOCATABLE_CONFIG_H_DIR)\" RELOC_INSTALL_PROG=\"$INSTALL_PROGRAM\"" + SET_RELOCATABLE="INSTALL_PROGRAM_ENV = RELOC_LIBRARY_PATH_VAR=\"$shlibpath_var\" RELOC_LIBRARY_PATH_VALUE=\"\$(RELOCATABLE_LIBRARY_PATH)\" RELOC_PREFIX=\"\$(prefix)\" RELOC_COMPILE_COMMAND=\"\$(CC) \$(CPPFLAGS) \$(CFLAGS) \$(LDFLAGS)\" RELOC_SRCDIR=\"\$(RELOCATABLE_SRC_DIR)\" RELOC_BUILDDIR=\"\$(RELOCATABLE_BUILD_DIR)\" RELOC_CONFIG_H_DIR=\"\$(RELOCATABLE_CONFIG_H_DIR)\" RELOC_EXEEXT=\"\$(EXEEXT)\" RELOC_INSTALL_PROG=\"$INSTALL_PROGRAM\"" case "$ac_aux_dir" in /*) INSTALL_PROGRAM="$ac_aux_dir/install-reloc" ;; *) INSTALL_PROGRAM="\$(top_builddir)/$ac_aux_dir/install-reloc" ;;