changeset 6452:d0006ae646bd

guile: mingw and linux fixes. Now also runs on mingw.
author Jan Nieuwenhuizen <janneke@gnu.org>
date Sun, 30 Jan 2011 15:11:39 +0100
parents ff3d95a637a7
children e0d807cdae63
files gub/specs/guile.py patches/guile-1.9.14-gnulib-mingw.patch patches/guile-1.9.14-mingw.patch patches/guile-1.9.14-pthreads-cross.patch patches/guile-1.9.14-reloc.patch patches/guile-1.9.14-struct.patch
diffstat 6 files changed, 161 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/gub/specs/guile.py	Sun Jan 30 15:09:27 2011 +0100
+++ b/gub/specs/guile.py	Sun Jan 30 15:11:39 2011 +0100
@@ -100,6 +100,8 @@
         # .libs/libguile_2.0_la-arbiters.o: In function `__gmpz_abs':
         # arbiters.c:(.text+0x0): multiple definition of `__gmpz_abs'
         self.file_sub ([('-std=gnu99', ''),('-std=c99', '')], '%(srcdir)s/configure')
+        self.file_sub ([('cross_compiling=(maybe|no|yes)',
+                         'cross_compiling=yes')], '%(srcdir)s/configure')
     def autopatch (self):
         self.file_sub ([(r'AC_CONFIG_SUBDIRS\(guile-readline\)', '')],
                        '%(srcdir)s/configure.in')
@@ -155,6 +157,7 @@
         self.target_gcc_flags = '-mms-bitfields'
     patches = Guile.patches + [
         'guile-1.9.14-mingw.patch',
+        'guile-1.9.14-gnulib-mingw.patch',
         ]
     dependencies = (Guile.dependencies
                     + [
@@ -197,7 +200,7 @@
 
 class Guile__linux (Guile):
     compile_command = ('export LD_LIBRARY_PATH=%(builddir)s/libguile/.libs:$LD_LIBRARY_PATH;'
-                + Guile.compile_command)
+                       + Guile.compile_command)
 
 class Guile__linux__ppc (Guile__linux):
     config_cache_overrides = Guile__linux.config_cache_overrides + '''
@@ -211,7 +214,7 @@
 '''
 
 class Guile__darwin (Guile):
-    patches = Guile.patches + ['guile-1.8.6-pthreads-cross.patch']
+    patches = Guile.patches + ['guile-1.9.14-pthreads-cross.patch']
     def install (self):
         Guile.install (self)
         def dylib_link (logger, fname):
@@ -228,7 +231,12 @@
         Guile.configure (self)
 
 class Guile__linux__x86 (Guile):
-    patches = Guile.patches + ['guile-1.8.6-pthreads-cross.patch']
+    patches = Guile.patches + [
+        'guile-1.9.14-pthreads-cross.patch',
+        'guile-1.9.14-struct.patch',
+        ]
+    compile_flags_native = (Guile.compile_flags_native +
+                            'CPATH="%(srcdir)s:%(builddir)s:%(system_prefix)s/include" ')
 
 class Guile__tools (tools.AutoBuild, Guile):
     patches = []
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/guile-1.9.14-gnulib-mingw.patch	Sun Jan 30 15:11:39 2011 +0100
@@ -0,0 +1,94 @@
+--- guile-1.9.14/lib/canonicalize-lgpl.c~	2011-01-30 15:05:32.398689016 +0100
++++ guile-1.9.14/lib/canonicalize-lgpl.c	2011-01-30 15:06:45.112470403 +0100
+@@ -76,6 +76,9 @@
+ #endif
+ 
+ #if !FUNC_REALPATH_WORKS || defined _LIBC
++
++#ifndef __MINGW32__
++
+ /* Return the canonical absolute name of file NAME.  A canonical name
+    does not contain any `.', `..' components nor any repeated path
+    separators ('/') or symlinks.  All path components must exist.  If
+@@ -334,6 +337,81 @@ error:
+   }
+   return NULL;
+ }
++
++#else /* __MINGW32__ */
++#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;
++}
++
++char *
++__realpath (const char *name, char *resolved)
++{
++  char *rpath = NULL;
++
++  if (name == NULL)
++    {
++      /* As per Single Unix Specification V2 we must return an error if
++         either parameter is a null pointer.  We extend this to allow
++         the RESOLVED parameter to be NULL in case the we are expected to
++         allocate the room for the return value.  */
++      __set_errno (EINVAL);
++      return NULL;
++    }
++
++  if (name[0] == '\0')
++    {
++      /* As per Single Unix Specification V2 we must return an error if
++         the name argument points to an empty string.  */
++      __set_errno (ENOENT);
++      return NULL;
++    }
++
++  if (resolved == NULL)
++    {
++      rpath = malloc (PATH_MAX + 1);
++      if (rpath == NULL)
++        {
++          /* It's easier to set errno to ENOMEM than to rely on the
++             'malloc-posix' gnulib module.  */
++          errno = ENOMEM;
++          return NULL;
++        }
++    }
++  else
++    rpath = resolved;
++
++  strncpy (rpath, name, PATH_MAX);
++  size_t len = strlen (name);
++  if (len > PATH_MAX)
++    len = PATH_MAX;
++  rpath[len] = '\0';
++  
++  slashify (rpath);
++  struct stat st;
++  if (lstat (rpath, &st) < 0)
++    {
++      if (resolved == NULL)
++	free (rpath);
++      return NULL;
++    }
++  return rpath;
++}
++
++#endif /* __MINGW32__ */
++
+ versioned_symbol (libc, __realpath, realpath, GLIBC_2_3);
+ #endif /* !FUNC_REALPATH_WORKS || defined _LIBC */
+ 
--- a/patches/guile-1.9.14-mingw.patch	Sun Jan 30 15:09:27 2011 +0100
+++ b/patches/guile-1.9.14-mingw.patch	Sun Jan 30 15:11:39 2011 +0100
@@ -80,3 +80,17 @@
  
  #endif
  
+--- guile-1.9.14/libguile/objcodes.c~	2010-12-14 19:15:17.000000000 +0100
++++ guile-1.9.14/libguile/objcodes.c	2011-01-30 14:54:56.075069344 +0100
+@@ -70,7 +70,11 @@ make_objcode_by_mmap (int fd)
+     scm_misc_error (FUNC_NAME, "object file too small (~a bytes)",
+ 		    scm_list_1 (SCM_I_MAKINUM (st.st_size)));
+ 
++#ifndef __MINGW32__
+   addr = mmap (0, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
++#else
++  addr = mmap (0, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
++#endif
+   if (addr == MAP_FAILED)
+     {
+       (void) close (fd);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/guile-1.9.14-pthreads-cross.patch	Sun Jan 30 15:11:39 2011 +0100
@@ -0,0 +1,11 @@
+--- guile-1.9.14/configure.ac~	2011-01-29 21:52:28.240527802 +0100
++++ guile-1.9.14/configure.ac	2011-01-29 22:43:58.874639272 +0100
+@@ -1427,7 +1427,7 @@ if test "$cross_compiling" = "no"; then
+   [works=yes
+    AC_DEFINE([PTHREAD_ATTR_GETSTACK_WORKS], [1], [Define when pthread_att_get_stack works for the main thread])],
+   [works=no],
+-  [])
++  [works=$ac_cv_pthread_attr_getstack_works])
+ else
+   works="assuming it doesn't"
+ fi
--- a/patches/guile-1.9.14-reloc.patch	Sun Jan 30 15:09:27 2011 +0100
+++ b/patches/guile-1.9.14-reloc.patch	Sun Jan 30 15:11:39 2011 +0100
@@ -74,7 +74,7 @@
 index 3e702c4..2341daf 100644
 --- a/libguile/load.c
 +++ b/libguile/load.c
-@@ -195,6 +195,59 @@ SCM_DEFINE (scm_parse_path, "parse-path", 1, 1, 0,
+@@ -195,6 +195,72 @@ SCM_DEFINE (scm_parse_path, "parse-path", 1, 1, 0,
  }
  #undef FUNC_NAME
  
@@ -130,17 +130,33 @@
 +    
 +  return scm_list_1 (datadir);
 +}
++
++SCM
++scm_init_argv0_compiled_relocation (char const* argv0)
++{
++  SCM bindir = scm_dirname (scm_from_locale_string (argv0));
++  SCM prefix = scm_dirname (bindir);
++  SCM pkglibdir = scm_string_append (scm_list_2 (prefix,
++						 scm_from_locale_string ("/lib/guile")));
++  SCM ccachedir = scm_string_append (scm_list_2 (pkglibdir,
++						 scm_from_locale_string ("/" GUILE_EFFECTIVE_VERSION "/ccache")));
++
++  return scm_list_1 (ccachedir);
++}
 +#endif /* ARGV0_RELOCATION */
  
  /* Initialize the global variable %load-path, given the value of the
     SCM_SITE_DIR and SCM_LIBRARY_DIR preprocessor symbols and the
-@@ -215,6 +268,11 @@ scm_init_load_path ()
+@@ -215,6 +268,14 @@ scm_init_load_path ()
    if (env)
      path = scm_parse_path (scm_from_locale_string (env), path);
  
 +#if ARGV0_RELOCATION
 +  if (global_argv0)
-+    path = scm_append (scm_list_2 (path, scm_init_argv0_relocation (global_argv0)));
++    {
++      path = scm_append (scm_list_2 (path, scm_init_argv0_relocation (global_argv0)));
++      cpath = scm_append (scm_list_2 (cpath, scm_init_argv0_compiled_relocation (global_argv0)));
++    }
 +#endif /* __CYGWIN__ || __MINGW32__ */
 +  
    *scm_loc_load_path = path;
@@ -148,13 +164,14 @@
  
 --- a/libguile/load.h~	2010-12-14 19:15:17.000000000 +0100
 +++ a/libguile/load.h	2011-01-26 17:33:13.797510681 +0100
-@@ -27,6 +27,10 @@
+@@ -27,6 +27,11 @@
  
  
  SCM_API SCM scm_parse_path (SCM path, SCM tail);
 +#if ARGV0_RELOCATION
 +SCM_API void scm_c_argv0_relocation (char const *argv0);
 +SCM_API SCM scm_init_argv0_relocation (char const* argv0);
++SCM_API SCM scm_init_argv0_compiled_relocation (char const* argv0);
 +#endif
  SCM_API SCM scm_primitive_load (SCM filename);
  SCM_API SCM scm_c_primitive_load (const char *filename);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/patches/guile-1.9.14-struct.patch	Sun Jan 30 15:11:39 2011 +0100
@@ -0,0 +1,10 @@
+--- guile-1.9.14/libguile/struct.c~	2010-12-14 19:15:17.000000000 +0100
++++ guile-1.9.14/libguile/struct.c	2011-01-29 23:52:07.561965615 +0100
+@@ -23,6 +23,7 @@
+ 
+ #include <alloca.h>
+ #include <assert.h>
++#include <stdarg.h>
+ 
+ #include "libguile/_scm.h"
+ #include "libguile/async.h"