+2005-11-23 Bruno Haible <bruno@clisp.org>
+
+ 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 <bruno@clisp.org>
* build-aux/ltmain.sh: Upgrade to libtool-1.5.20.
+2005-11-23 Bruno Haible <bruno@clisp.org>
+
+ Cygwin portability.
+ * configure.ac: Invoke gl_WOE32_DLL.
+
2005-09-18 Bruno Haible <bruno@clisp.org>
* config.rpath: Upgrade to libtool-1.5.20.
AC_EXEEXT
dnl Check for build configuration.
+gl_WOE32_DLL
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
#!/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 <bruno@clisp.org>, 2003.
#
# This program is free software; you can redistribute it and/or modify
# 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
# - 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
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
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
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
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 ()
# 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
+2005-11-23 Bruno Haible <bruno@clisp.org>
+
+ Cygwin portability.
+ * configure.ac: Invoke gl_WOE32_DLL.
+
2005-11-24 Bruno Haible <bruno@clisp.org>
* Makefile.am (config.h_vms, config.h.msvc): Treat HAVE_FWPRINTF like
gl_USE_SYSTEM_EXTENSIONS
dnl Check for build configuration.
+gl_WOE32_DLL
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
+2005-12-04 Bruno Haible <bruno@clisp.org>
+
+ Cygwin portability.
+ * relocatable.c: Include <windows.h> also on Cygwin.
+ (DllMain): Add support for Cygwin.
+ (get_shared_library_fullname): Update.
+ Patches partially from Charles Wilson <cygwin@cwilson.fastmail.fm>.
+
2005-10-09 Bruno Haible <bruno@clisp.org>
2002-07-24 Ulrich Drepper <drepper@redhat.com>
/* Provide relocatable packages.
- Copyright (C) 2003-2004 Free Software Foundation, Inc.
+ Copyright (C) 2003-2005 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify it
# include "xalloc.h"
#endif
-#if defined _WIN32 || defined __WIN32__
+#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
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)
/* 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. */
/* 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 ()
#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)
{
+2005-11-23 Bruno Haible <bruno@clisp.org>
+
+ Cygwin portability.
+ * configure.ac: Invoke gl_WOE32_DLL.
+
2005-07-07 Bruno Haible <bruno@clisp.org>
Add ability to create shared library on BeOS.
AC_EXEEXT
dnl Check for build configuration.
+gl_WOE32_DLL
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
case "$host_os" in
+2005-11-23 Bruno Haible <bruno@clisp.org>
+
+ Cygwin portability.
+ * woe32-dll.m4: New file.
+ * Makefile.am (EXTRA_DIST): Add it.
+
2005-11-21 Bruno Haible <bruno@clisp.org>
* gettext.m4 (AM_INTL_SUBDIR): Invoke gt_LC_MESSAGES always, since we
visibility.m4 \
wchar_t.m4 \
wint_t.m4 \
+woe32-dll.m4 \
xsize.m4
+2005-11-23 Bruno Haible <bruno@clisp.org>
+
+ Cygwin portability.
+ * configure.ac: Invoke gl_WOE32_DLL.
+
2005-11-24 Bruno Haible <bruno@clisp.org>
* Makefile.am (config.h_vms, config.h.msvc): Treat HAVE_FWPRINTF like
gl_USE_SYSTEM_EXTENSIONS
dnl Check for build configuration.
+gl_WOE32_DLL
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
case "$host_os" in
+2005-12-04 Bruno Haible <bruno@clisp.org>
+
+ Cygwin portability.
+ * progreloc.c: Include <windows.h> also on Cygwin.
+ (find_executable): Add support for Cygwin.
+ (set_program_name_and_installdir): Handle also platforms with nonempty
+ EXEEXT.
+ * relocatable.c: Include <windows.h> 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 <cygwin@cwilson.fastmail.fm>.
+
2005-10-09 Bruno Haible <bruno@clisp.org>
* c-strcasestr.h: New file.
/* Provide relocatable programs.
- Copyright (C) 2003-2004 Free Software Foundation, Inc.
+ Copyright (C) 2003-2005 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify it
# define WIN32
#endif
-#ifdef WIN32
+#if defined WIN32 || defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
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/<pid>/exe. In newer Linux
versions, also as /proc/self/exe. Linux >= 2.1 provides a symlink
{
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;
+ }
}
}
}
/* Provide relocatable packages.
- Copyright (C) 2003-2004 Free Software Foundation, Inc.
+ Copyright (C) 2003-2005 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify it
# include "xalloc.h"
#endif
-#if defined _WIN32 || defined __WIN32__
+#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
#endif
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)
/* 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. */
/* 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 ()
#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)
{
/* Relocating wrapper program.
- Copyright (C) 2003 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2005 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2003.
This program is free software; you can redistribute it and/or modify
#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)
{
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;
+2005-11-24 Bruno Haible <bruno@clisp.org>
+
+ Cygwin portability.
+ * relocatable.m4 (AC_RELOCATABLE): Require AC_EXEEXT. Arrange to set
+ RELOC_EXEEXT while invoking install-reloc.
+
2005-09-20 Bruno Haible <bruno@clisp.org>
* bison-i18n.m4: New file, from bison-2.1.
-# 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,
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
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" ;;