changeset 6489:840b403f7762

mingw::guile: another round of 1.9 patches.
author Jan Nieuwenhuizen <janneke@gnu.org>
date Mon, 07 Feb 2011 12:51:53 +0100
parents 5241c71e066c
children c79ddba57147
files gub/specs/guile.py patches/guile-1.9.15-mingw-cachedir.patch patches/guile-1.9.15-mingw-canonicalize.patch patches/guile-1.9.15-mingw-compile.patch patches/guile-1.9.15-mingw-rename.patch
diffstat 5 files changed, 166 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/gub/specs/guile.py	Fri Feb 04 00:47:47 2011 +0100
+++ b/gub/specs/guile.py	Mon Feb 07 12:51:53 2011 +0100
@@ -173,16 +173,16 @@
         Guile.__init__ (self, settings, source)
         # Configure (compile) without -mwindows for console
         self.target_gcc_flags = '-mms-bitfields'
-    patches = Guile.patches + [ # [x for x in Guile.patches if not 'libunistring' in x] + [
+    patches = Guile.patches + [
         'guile-1.9.15-mingw.patch',
-        'guile-1.9.14-gnulib-mingw.patch',
         'guile-1.9.14-mingw-dirent.patch',
-        #'guile-1.9.14-gnulib-libunistring-retooled.patch',
         'guile-1.9.15-mingw-compile.patch',
+        'guile-1.9.15-mingw-canonicalize.patch',
         'guile-1.9.15-mingw-fports.patch',
+        'guile-1.9.15-mingw-rename.patch',
+        'guile-1.9.15-mingw-cachedir.patch',
         ]
-    dependencies = (Guile.dependencies
-                    + [
+    dependencies = (Guile.dependencies + [
             'regex-devel',
             'mingw-extras',
             ])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/guile-1.9.15-mingw-cachedir.patch	Mon Feb 07 12:51:53 2011 +0100
@@ -0,0 +1,13 @@
+--- guile-1.9.15/libguile/load.c~	2011-02-05 00:12:37.229094428 +0100
++++ guile-1.9.15/libguile/load.c	2011-02-06 11:24:34.469218789 +0100
+@@ -329,6 +329,10 @@ scm_init_load_path ()
+ 
+     if ((e = getenv ("XDG_CACHE_HOME")))
+       snprintf (cachedir, sizeof(cachedir), "%s/" FALLBACK_DIR, e);
++#ifdef __MINGW32__
++    else if ((e = getenv ("LOCALAPPDATA")))
++      snprintf (cachedir, sizeof (cachedir), "%s/.cache/" FALLBACK_DIR, e);
++#endif /* __MINGW32__ */
+     else if ((e = getenv ("HOME")))
+       snprintf (cachedir, sizeof(cachedir), "%s/.cache/" FALLBACK_DIR, e);
+ #ifdef HAVE_GETPWENT
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/guile-1.9.15-mingw-canonicalize.patch	Mon Feb 07 12:51:53 2011 +0100
@@ -0,0 +1,92 @@
+--- guile-1.9.15/libguile/filesys.h	2011-02-04 21:19:36.819015451 +0100
++++ guile-1.9.15/libguile/filesys.h-	2011-02-04 21:42:50.560522283 +0100
+@@ -27,6 +27,12 @@
+ 
+ 
+ 
++#ifdef __MINGW32__
++extern char *mingw_canonicalize_file_name  (char const *name);
++#undef canonicalize_file_name
++#define canonicalize_file_name mingw_canonicalize_file_name
++#endif /* __MINGW32__ */
++
+ SCM_API scm_t_bits scm_tc16_dir;
+ 
+ #define SCM_DIR_FLAG_OPEN (1L << 0)
+--- guile-1.9.15/libguile/filesys.c	2011-02-04 21:19:36.803015067 +0100
++++ guile-1.9.15/libguile/filesys.c-	2011-02-04 21:42:55.912651065 +0100
+@@ -1634,6 +1634,74 @@ SCM_DEFINE (scm_basename, "basename", 1,
+ }
+ #undef FUNC_NAME
+ 
++#ifdef __MINGW32__
++/* gnulib's canonicalize_file_name silently fails on Mingw.  */
++#include <ctype.h>
++#include <direct.h>
++#include <windows.h>
++
++static char const *
++slashify (char const *str)
++{
++  char *p = (char*)str;
++  
++  while (*p)
++    {
++      if (*p == '\\')
++	*p = '/';
++      p++;
++    }
++  return str;
++}
++
++static char const *
++strlower (char const *str)
++{
++  char *p = str;
++  while (*p)
++    {
++      *p = (char)tolower (*p);
++      p++;
++    }
++  return str;
++}
++
++static char *
++mingw_realpath (char const *name, char *resolved)
++{
++  char *rpath = NULL;
++
++  if (name == NULL || name[0] == '\0')
++    return NULL;
++
++  if (resolved == NULL)
++    {
++      rpath = malloc (PATH_MAX + 1);
++      if (rpath == NULL)
++          return NULL;
++    }
++  else
++    rpath = resolved;
++
++  GetFullPathName (name, PATH_MAX, rpath, NULL);
++  strlower (slashify (rpath));
++  struct stat st;
++  if (lstat (rpath, &st) < 0)
++    {
++      if (resolved == NULL)
++	free (rpath);
++      return NULL;
++    }
++  return rpath;
++}
++
++char *
++mingw_canonicalize_file_name (char const *name)
++{
++  return mingw_realpath (name, NULL);
++}
++#endif /* __MINGW32__ */
++
+ SCM_DEFINE (scm_canonicalize_path, "canonicalize-path", 1, 0, 0, 
+             (SCM path),
+ 	    "Return the canonical path of @var{path}. A canonical path has\n"
--- a/patches/guile-1.9.15-mingw-compile.patch	Fri Feb 04 00:47:47 2011 +0100
+++ b/patches/guile-1.9.15-mingw-compile.patch	Mon Feb 07 12:51:53 2011 +0100
@@ -1,10 +1,21 @@
 --- guile-1.9.15/module/system/base/compile.scm~	2011-01-26 23:03:16.000000000 +0100
-+++ guile-1.9.15/module/system/base/compile.scm	2011-02-03 23:29:08.090142894 +0100
-@@ -104,6 +104,7 @@
++++ guile-1.9.15/module/system/base/compile.scm	2011-02-04 12:04:15.765055771 +0100
+@@ -100,11 +100,16 @@
+            ".go")
+           (else (car %load-compiled-extensions))))
+   (and %compile-fallback-path
+-       (let ((f (string-append
++       (let* ((c (canonicalize-path file))
++	      (f (string-append
                   %compile-fallback-path
                   ;; no need for '/' separator here, canonicalize-path
                   ;; will give us an absolute path
-+		 "/" ;; which does not start with / on MINGW
-                  (canonicalize-path file)
+-                 (canonicalize-path file)
++		 (if (eq? (string-ref c 1) #\:)
++		     ;; on Mingw remove drive-letter separator `:' to
++		     ;; obtain valid file name
++		     (substring c 2)
++		     c)
                   (compiled-extension))))
           (and (false-if-exception (ensure-writable-dir (dirname f)))
+               f))))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/guile-1.9.15-mingw-rename.patch	Mon Feb 07 12:51:53 2011 +0100
@@ -0,0 +1,41 @@
+--- guile-1.9.15/libguile/filesys.c.orig	2011-02-07 12:07:09.984516150 +0100
++++ guile-1.9.15/libguile/filesys.c	2011-02-07 12:11:53.627350574 +0100
+@@ -680,9 +680,10 @@ SCM_DEFINE (scm_link, "link", 2, 0, 0,
+ #undef FUNC_NAME
+ #endif /* HAVE_LINK */
+ 
+-#ifdef HAVE_RENAME
++#if defined (HAVE_RENAME) && !defined (__MINGW32__)
+ #define my_rename rename
+-#else
++#else /* !HAVE_RENAME || __MINGW32__ */
++#ifndef __MINGW32__
+ static int
+ my_rename (const char *oldname, const char *newname)
+ {
+@@ -698,7 +699,24 @@ my_rename (const char *oldname, const ch
+     }
+   return rv;
+ }
+-#endif
++#else /* __MINGW32__ */
++static int
++my_rename (const char *oldname, const char *newname)
++{
++  int rv;
++  struct stat stat;
++
++  SCM_SYSCALL (rv = stat (newname, &stat));
++  if (rv == 0)
++    SCM_SYSCALL (rv = unlink (newname));
++  if (rv == 0)
++    rv = rename (oldname, newname);
++
++  return rv;
++}
++#endif /* __MINGW32__ */
++#endif /* !HAVE_RENAME || __MINGW32__ */
++
+ 
+ SCM_DEFINE (scm_rename, "rename-file", 2, 0, 0,
+             (SCM oldname, SCM newname),