bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gettext patches for cygwin, update


From: Charles Wilson
Subject: gettext patches for cygwin, update
Date: Sun, 27 Nov 2005 02:10:31 -0500
User-agent: Thunderbird 1.5 (Windows/20051025)

Okay, given the contents of the five different threads I started, I'm trying to port the more-or-less agreed-upon portions up to CVS. However, the current cvs-HEAD won't compile -- po-gram-gen.[c|h] haven't been regenerated from po-gram-gen.y, so I get compile errors in po-lex.c ("`MSGCTXT' undeclared"). Makefile.am doesn't seem to describe any rules for re-generating the dependent files, and cygwin-bison is the wrong version anyway.

At present, I'm using the patch below (which doesn't include any changes due to running the autotools). But, I can't test it until the problem described above is fixed...

NOTES: changed AM_CONDITION from MINGW to WOE32GCC, which more accurately describes when it is necessary to use the C++ compiler: to work around a gcc-C-compiler issue present only on win32 (e.g. mingw + cygwin, but not msvc)

Using win32api call to determine app name and dll name.

--
Chuck
Index: build-aux/install-reloc
===================================================================
RCS file: /cvsroot/gettext/gettext/build-aux/install-reloc,v
retrieving revision 1.2
diff -u -r1.2 install-reloc
--- build-aux/install-reloc     20 May 2005 21:05:57 -0000      1.2
+++ build-aux/install-reloc     27 Nov 2005 06:55:43 -0000
@@ -108,12 +108,19 @@
 # wrapper.
 test -n "$libdirs" || exit 0
 
+# deduce EXEEXT.  if $destprog endswith .exe, fine...
+EXEEXT=
+p1=`echo ${destprog}|sed -e 's/\.exe$//'`
+test "${p1}" == "${destprog}" || EXEEXT=.exe
+# otherwise, check for file existence
+test -f "${p1}.exe" && EXEEXT=.exe
+
 # 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" "$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 ${p1}.wrapper${EXEEXT} || exit $?
 
 # Rename $destprog.wrapper -> $destprog -> $destprog.bin.
-ln -f $destprog $destprog.bin || exit 1
-mv $destprog.wrapper $destprog || exit 1
+ln -f ${p1}${EXEEXT} ${p1}.bin${EXEEXT} || exit 1
+mv ${p1}.wrapper${EXEEXT} ${p1}${EXEEXT} || exit 1
 
 exit 0
Index: gettext-runtime/configure.ac
===================================================================
RCS file: /cvsroot/gettext/gettext/gettext-runtime/configure.ac,v
retrieving revision 1.31
diff -u -r1.31 configure.ac
--- gettext-runtime/configure.ac        30 Aug 2005 20:35:42 -0000      1.31
+++ gettext-runtime/configure.ac        27 Nov 2005 06:56:10 -0000
@@ -106,7 +106,7 @@
 dnl Put some default definitions into config.h.
 AH_BOTTOM([
 /* On Windows, variables that may be in a DLL must be marked specially.  */
-#if (defined _MSC_VER && defined _DLL) || (defined __MINGW32__ && defined 
DLL_EXPORT)
+#if (defined _MSC_VER && defined _DLL) || ((defined __MINGW32__ || defined 
__CYGWIN__) && defined DLL_EXPORT)
 # define DLL_VARIABLE __declspec (dllimport)
 #else
 # define DLL_VARIABLE
Index: gettext-runtime/intl/relocatable.c
===================================================================
RCS file: /cvsroot/gettext/gettext/gettext-runtime/intl/relocatable.c,v
retrieving revision 1.10
diff -u -r1.10 relocatable.c
--- gettext-runtime/intl/relocatable.c  20 May 2005 21:05:59 -0000      1.10
+++ gettext-runtime/intl/relocatable.c  27 Nov 2005 06:56:11 -0000
@@ -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 <windows.h>
 #endif
@@ -234,12 +234,17 @@
                  same = true;
                break;
              }
-#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined 
__EMX__ || defined __DJGPP__
+#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
            /* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */
            if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi)
                != (*cpi >= 'a' && *cpi <= 'z' ? *cpi - 'a' + 'A' : *cpi))
              break;
 #else
+  /* technically, cygwin should be treated as above.  But, with 'managed'
+     mounts, cygwin can fake case-sensitivity.  So, we choose to use
+     case-sensitive comparison on cygwin, even though it may infrequently
+     break things if not using managed mounts
+  */
            if (*rpi != *cpi)
              break;
 #endif
@@ -280,7 +285,7 @@
 /* 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,7 +307,15 @@
        /* Shouldn't happen.  */
        return FALSE;
 
+#if defined __CYGWIN__
+      {
+        static char cyglocation[MAX_PATH];
+        cygwin_conv_to_posix_path(location, cyglocation);
+        shared_library_fullname = strdup (cyglocation);
+      }
+#else
       shared_library_fullname = strdup (location);
+#endif
     }
 
   return TRUE;
@@ -363,11 +376,11 @@
 
 /* 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)
     {
Index: gettext-tools/configure.ac
===================================================================
RCS file: /cvsroot/gettext/gettext/gettext-tools/configure.ac,v
retrieving revision 1.59
diff -u -r1.59 configure.ac
--- gettext-tools/configure.ac  19 Oct 2005 11:17:34 -0000      1.59
+++ gettext-tools/configure.ac  27 Nov 2005 06:57:07 -0000
@@ -182,13 +182,14 @@
 
 gt_PREREQ_HOSTNAME
 
-dnl Compilation on mingw needs special Makefile rules, because of variables
-dnl being exported from or imported into shared libraries.
+dnl Compilation on mingw or cygwin needs special Makefile rules, because of
+dnl variables being exported from or imported into shared libraries.
 case "$host_os" in
-  mingw*) is_mingw=yes ;;
-  *) is_mingw=no ;;
+  mingw*) is_woe32gcc=yes ;;
+  *cygwin*) is_woe32gcc=yes ;;
+  *) is_woe32gcc=no ;;
 esac
-AM_CONDITIONAL([MINGW], [test $is_mingw = yes])
+AM_CONDITIONAL([WOE32GCC], [test $is_woe32gcc = yes])
 
 dnl Put some default definitions into config.h.
 AH_TOP([
@@ -221,7 +222,7 @@
 #define PAGE_WIDTH 79
 
 /* On Windows, variables that may be in a DLL must be marked specially.  */
-#if (defined _MSC_VER && defined _DLL) || (defined __MINGW32__ && defined 
DLL_EXPORT)
+#if (defined _MSC_VER && defined _DLL) || ((defined __MINGW32__ || defined 
__CYGWIN__) && defined DLL_EXPORT)
 # define DLL_VARIABLE __declspec (dllimport)
 #else
 # define DLL_VARIABLE
Index: gettext-tools/lib/Makefile.am
===================================================================
RCS file: /cvsroot/gettext/gettext/gettext-tools/lib/Makefile.am,v
retrieving revision 1.46
diff -u -r1.46 Makefile.am
--- gettext-tools/lib/Makefile.am       20 Oct 2005 17:53:10 -0000      1.46
+++ gettext-tools/lib/Makefile.am       27 Nov 2005 06:57:23 -0000
@@ -189,8 +189,7 @@
 # We need the following in order to create <byteswap.h> when the system
 # doesn't have one.
 byteswap.h: byteswap_.h
-       cp $(srcdir)/$< address@hidden
-       mv address@hidden $@
+       cp $(srcdir)/byteswap_.h byteswap.h
 MOSTLYCLEANFILES += byteswap.h
 # <<< gnulib module byteswap.
 
Index: gettext-tools/lib/progreloc.c
===================================================================
RCS file: /cvsroot/gettext/gettext/gettext-tools/lib/progreloc.c,v
retrieving revision 1.7
diff -u -r1.7 progreloc.c
--- gettext-tools/lib/progreloc.c       20 May 2005 21:06:02 -0000      1.7
+++ gettext-tools/lib/progreloc.c       27 Nov 2005 06:57:24 -0000
@@ -91,7 +91,7 @@
 static bool
 maybe_executable (const char *filename)
 {
-#if !defined WIN32
+#if (!defined WIN32) || defined __CYGWIN__
   if (access (filename, X_OK) < 0)
     return false;
 
@@ -126,7 +126,7 @@
 static char *
 find_executable (const char *argv0)
 {
-#ifdef WIN32
+#if defined WIN32 || defined __CYGWIN__
   char buf[1024];
   int length = GetModuleFileName (NULL, buf, sizeof (buf));
   if (length < 0)
@@ -134,7 +134,17 @@
   if (!IS_PATH_WITH_DIR (buf))
     /* Shouldn't happen.  */
     return NULL;
+
+# if defined __CYGWIN__
+  {
+    static char cygbuf[MAX_PATH];
+    cygwin_conv_to_posix_path(buf, cygbuf);
+    return xstrdup (cygbuf);
+  }
+# else
   return xstrdup (buf);
+# endif
+
 #else /* Unix */
 #ifdef __linux__
   /* The executable is accessible as /proc/<pid>/exe.  In newer Linux
@@ -260,11 +270,12 @@
 {
   const char *argv0_stripped = argv0;
 
-  /* Relocatable programs are renamed to .bin by install-reloc.  Remove
-     this suffix here.  */
+  /* Relocatable programs are renamed to .bin (or .bin.exe) 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)
+      /* foo.bin --> foo */
       {
        char *shorter = (char *) xmalloc (argv0_len - 4 + 1);
 #ifdef NO_XMALLOC
@@ -275,6 +286,20 @@
            shorter[argv0_len - 4] = '\0';
            argv0_stripped = shorter;
          }
+      }
+    else if (argv0_len > 8 && memcmp (argv0 + argv0_len - 8, ".bin", 4) == 0)
+      /* foo.bin.exe --> foo.exe */
+      {
+        char *shorter = (char *) xmalloc (argv0_len - 4 + 1);
+#ifdef NO_XMALLOC
+        if (shorter != NULL)
+#endif
+          {
+            memcpy (shorter, argv0, argv0_len - 8);
+            memcpy (shorter + argv0_len - 8, ".exe", 4);
+            shorter[argv0_len - 4] = '\0';
+            argv0_stripped = shorter;
+          }
       }
   }
 
Index: gettext-tools/lib/relocatable.c
===================================================================
RCS file: /cvsroot/gettext/gettext/gettext-tools/lib/relocatable.c,v
retrieving revision 1.10
diff -u -r1.10 relocatable.c
--- gettext-tools/lib/relocatable.c     20 May 2005 21:06:02 -0000      1.10
+++ gettext-tools/lib/relocatable.c     27 Nov 2005 06:57:24 -0000
@@ -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 <windows.h>
 #endif
@@ -234,12 +234,17 @@
                  same = true;
                break;
              }
-#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined 
__EMX__ || defined __DJGPP__
+#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
            /* Win32, Cygwin, OS/2, DOS - case insignificant filesystem */
            if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi)
                != (*cpi >= 'a' && *cpi <= 'z' ? *cpi - 'a' + 'A' : *cpi))
              break;
 #else
+  /* technically, cygwin should be treated as above.  But, with 'managed'
+     mounts, cygwin can fake case-sensitivity.  So, we choose to use
+     case-sensitive comparison on cygwin, even though it may infrequently
+     break things if not using managed mounts
+  */
            if (*rpi != *cpi)
              break;
 #endif
@@ -280,7 +285,7 @@
 /* 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,7 +307,15 @@
        /* Shouldn't happen.  */
        return FALSE;
 
+#if defined __CYGWIN__
+      {
+        static char cyglocation[MAX_PATH];
+        cygwin_conv_to_posix_path(location, cyglocation);
+        shared_library_fullname = strdup (cyglocation);
+      }
+#else
       shared_library_fullname = strdup (location);
+#endif
     }
 
   return TRUE;
@@ -363,11 +376,11 @@
 
 /* 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)
     {
Index: gettext-tools/lib/relocwrapper.c
===================================================================
RCS file: /cvsroot/gettext/gettext/gettext-tools/lib/relocwrapper.c,v
retrieving revision 1.5
diff -u -r1.5 relocwrapper.c
--- gettext-tools/lib/relocwrapper.c    20 May 2005 21:06:02 -0000      1.5
+++ gettext-tools/lib/relocwrapper.c    27 Nov 2005 06:57:24 -0000
@@ -58,7 +58,9 @@
 #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.
+   If filename ends with .exe, then ".bin" is inserted between 
+   the .exe and the rest of the filename */
 static char *
 add_dotbin (const char *filename)
 {
@@ -67,8 +69,19 @@
 
   if (result != NULL)
     {
-      memcpy (result, filename, filename_len);
-      memcpy (result + filename_len, ".bin", 4 + 1);
+      if ((filename_len > 4) &&
+          ((strncmp(filename + filename_len - 4, ".exe", 4) == 0) ||
+           (strncmp(filename + filename_len - 4, ".EXE", 4) == 0)))
+        {
+          memcpy (result, filename, filename_len - 4);
+          memcpy (result + filename_len - 4, ".bin", 4);
+          memcpy (result + filename_len, filename + filename_len - 4, 4 + 1);
+        }
+      else
+        {
+          memcpy (result, filename, filename_len);
+          memcpy (result + filename_len, ".bin", 4 + 1);
+        }
       return result;
     }
   else
Index: gettext-tools/src/Makefile.am
===================================================================
RCS file: /cvsroot/gettext/gettext/gettext-tools/src/Makefile.am,v
retrieving revision 1.48
diff -u -r1.48 Makefile.am
--- gettext-tools/src/Makefile.am       24 Oct 2005 11:58:57 -0000      1.48
+++ gettext-tools/src/Makefile.am       27 Nov 2005 06:57:28 -0000
@@ -136,7 +136,7 @@
 msgfmt_SOURCES += \
   write-mo.c write-java.c write-csharp.c write-resources.c write-tcl.c \
   write-qt.c ../../gettext-runtime/intl/hash-string.c
-if !MINGW
+if !WOE32GCC
 msgmerge_SOURCES = msgmerge.c
 else
 msgmerge_SOURCES = ../mingw/c++msgmerge.cc
@@ -145,7 +145,7 @@
 msgunfmt_SOURCES = msgunfmt.c
 msgunfmt_SOURCES += \
   read-mo.c read-java.c read-csharp.c read-resources.c read-tcl.c
-if !MINGW
+if !WOE32GCC
 xgettext_SOURCES = xgettext.c
 else
 xgettext_SOURCES = ../mingw/c++xgettext.cc
@@ -154,45 +154,45 @@
   x-c.c x-po.c x-sh.c x-python.c x-lisp.c x-elisp.c x-librep.c x-scheme.c \
   x-smalltalk.c x-java.c x-csharp.c x-awk.c x-ycp.c x-tcl.c x-perl.c x-php.c \
   x-rst.c x-glade.c
-if !MINGW
+if !WOE32GCC
 msgattrib_SOURCES = msgattrib.c
 else
 msgattrib_SOURCES = ../mingw/c++msgattrib.cc
 endif
-if !MINGW
+if !WOE32GCC
 msgcat_SOURCES = msgcat.c
 else
 msgcat_SOURCES = ../mingw/c++msgcat.cc
 endif
-if !MINGW
+if !WOE32GCC
 msgcomm_SOURCES = msgcomm.c
 else
 msgcomm_SOURCES = ../mingw/c++msgcomm.cc
 endif
-if !MINGW
+if !WOE32GCC
 msgconv_SOURCES = msgconv.c
 else
 msgconv_SOURCES = ../mingw/c++msgconv.cc
 endif
-if !MINGW
+if !WOE32GCC
 msgen_SOURCES = msgen.c
 else
 msgen_SOURCES = ../mingw/c++msgen.cc
 endif
 msgexec_SOURCES = msgexec.c
-if !MINGW
+if !WOE32GCC
 msgfilter_SOURCES = msgfilter.c
 else
 msgfilter_SOURCES = ../mingw/c++msgfilter.cc
 endif
-if !MINGW
+if !WOE32GCC
 msggrep_SOURCES = msggrep.c
 else
 msggrep_SOURCES = ../mingw/c++msggrep.cc
 endif
 msginit_SOURCES = msginit.c
 msginit_SOURCES +=  plural-count.c ../../gettext-runtime/intl/localealias.c
-if !MINGW
+if !WOE32GCC
 msguniq_SOURCES = msguniq.c
 else
 msguniq_SOURCES = ../mingw/c++msguniq.cc
@@ -210,7 +210,7 @@
   ../lib/libgettextlib.la @LTLIBINTL@ @LTLIBICONV@ -lc @LTNOUNDEF@
 
 # Special rules for mingw.
-if MINGW
+if WOE32GCC
 format_CFLAGS = -x c++
 # Work around an automake 1.9 bug: *_CFLAGS settings are ignored for elements
 # of a libtool library.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]