Subject: Re: [platform-testers] Guile 2.0.4 release imminent

From: [email-masked] (Ludovic Courtès)
Date: Tue, 17 Jan 2012 16:01:33 +0100

Hi Bruno,

Bruno Haible <[email-masked]> skribis:

>> >     How about changing that section to mention
>> >       1) that pkg-config ought to be installed before libffi and libgc?
>> >       2) that usually setting PKG_CONFIG_PATH to include
>> >            $BDW_LIBDIR/pkgconfig:$LIBFFI_LIBDIR/pkgconfig:/usr/lib/pkgconfig
>> >          will work,
>> >       3) the BDW_GC_CFLAGS, BDW_GC_LIBS, LIBFFI_CFLAGS, LIBFFI_LIBS
>> >          approach as a last resort.
>> 
>> I’ve done something along these lines:
>> 
>>   http://git.savannah.gnu.org/cgit/guile.git/commit/?h=stable-2.0&id=ad17b1551241a0fbaa9f9557016cbe440cc6338b
>
> Hmm, two comments about your advice
>   PKG_CONFIG_PATH=/path/to/libgc/lib/pkgconfig:/path/to/libffi/lib/pkgconfig
>
> - When the packages are installed on a bi-arch system, in $prefix/lib64/
>   (or, on Solaris, $prefix/lib/64/), then the pkgconfig dir is a subdir
>   of that directory. More precisely, if the package was installed with
>   --libdir=$LIBFFI_LIBDIR, then the dir to use is $LIBFFI_LIBDIR/pkgconfig.
>
> - If the user sets this variable and then forgets about it, and it does not
>   contain /usr/lib/pkgconfig or /usr/lib64/pkgconfig, then AFAIU other
>   packages installed in /usr/lib[64] will no longer be found.

I know, I know.  I really view README as a hint, in the hope that the
user will understand that /path/to/libgc/lib/pkgconfig will have to be
replaced by the correct file name.  I don’t think another convention,
such as writing $LIBFFI_LIBDIR, really helps.

>> > 2) On Linux/glibc/PowerPC, MacOS X 10.5, Cygwin, I happen not to have
>> > pkg-config installed. But I have installed all the other packages!
>> > The configuration fails:
>> 
>> [...]
>> 
>> > Isn't this a *gratuitous* build dependency?
>> 
>> Isn’t this a gratuitous troll?  ;-)
>
> Given the size of the thread about this topic in gnu-prog-discuss, it
> is not gratuitous to talk about it.
>
>> Seriously, I understand your frustration.  Yet, we use upstream’s method
>> to check for package availability, whether we like it or not.
>
> You can do better than that.

[...]

> Can't you just change 
>
>   PKG_CHECK_MODULES(LIBFFI, libffi)
>
> to
>
>   AC_LIB_HAVE_LINKFLAGS([ffi],
>     [],
>     [#include <ffi.h>
>      #include <stdlib.h>],
>     [ffi_call (NULL, NULL, NULL, NULL);])
>   if test "$HAVE_LIBFFI" = yes; then
>     LIBFFI_CFLAGS=          # CPPFLAGS already augmented
>     LIBFFI_LIBS="$LTLIBFFI" # since linking is done with libtool
>   else
>     PKG_CHECK_MODULES(LIBFFI, libffi)
>   fi
>
> and similarly for libgc.

The problem we could run into, by not using libffi’s and BDW-GC’s
recommended methods, is that we could miss CFLAGS, CPPFLAGS, or LDFLAGS
that appear in their .pc files.

Thus, it seems more robust to configure these packages the way they are
meant to be configured, rather than do our own guesswork.

WDYT?

Perhaps the pkg-config discussion should actually be moved to bug-gnulib
or bug-standards, because it’s beyond Guile’s scope.

> No, I meant Oracle Solaris 11, released on 2011-11-09. Cf.
> http://en.wikipedia.org/wiki/Solaris_(operating_system)
> http://www.oracle.com/technetwork/server-storage/solaris11/downloads/index.html
>
> But I warn you: with this OS, before you have a usable system,
> you have to learn how to use their package manager. Otherwise,
> no gcc, no development tools.

Hmm, OK, noted!

>> > This could be easily fixed by including the gnulib module 'nl_langinfo'. See
>> > http://www.gnu.org/software/gnulib/manual/html_node/nl_005flanginfo.html
>> 
>> I considered using it some time ago but decided not to, as the comment
>> in i18n.c says:
>> 
>>    Note: We don't use Gnulib's `nl_langinfo' module because it's currently not
>>    as complete as the compatibility hacks in `i18n.scm'.  */
>
> If you are not satisfied with the contents of a particular gnulib module,
> please by all means say so on the bug-gnulib list. I beg you. Then the
> enhancements will not only profit guile but also other packages.

Yes, sure.  It turns out that i18n.{c,scm} in Guile predate the
‘langinfo’ module in Gnulib, and Guile’s needs may be different than
those of other packages.

Actually, I have a stash here to do that (see below), but I can’t
remember why I didn’t apply it.  I’ll try again and report back.

>> > 9) Test failure on Linux/glibc/i386 (32-bit build on a x86_64 machine):
>> >
>> > FAIL: gc.test: gc: Lexical vars are collectable
>> 
>> This is a known “problem”, and harmless.
>
> Then, why not change the test so that it only prints a warning message,
> and always succeeds?

This is being discussed elsewhere:

  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10336
  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9900#35

Thanks,
Ludo’.

	Modified configure.ac
diff --git a/configure.ac b/configure.ac
index 35e902c..8fcea88 100644
--- a/configure.ac
+++ b/configure.ac
@@ -663,13 +663,13 @@ AC_SUBST([SCM_I_GSC_HAVE_STRUCT_DIRENT64])
 #   machine/fpu.h - on Tru64 5.1b, the declaration of fesetround(3) is in
 #     this file instead of <fenv.h>
 #   process.h - mingw specific
-#   langinfo.h, nl_types.h - SuS v2
+#   nl_types.h - SuS v2
 #
 AC_CHECK_HEADERS([complex.h fenv.h io.h libc.h limits.h malloc.h memory.h process.h string.h \
 regex.h rxposix.h rx/rxposix.h sys/dir.h sys/ioctl.h sys/select.h \
 sys/time.h sys/timeb.h sys/times.h sys/stdtypes.h sys/types.h \
 sys/utime.h time.h unistd.h utime.h pwd.h grp.h sys/utsname.h \
-direct.h langinfo.h nl_types.h machine/fpu.h])
+direct.h nl_types.h machine/fpu.h])
 
 # "complex double" is new in C99, and "complex" is only a keyword if
 # <complex.h> is included
@@ -763,10 +763,9 @@ AC_CHECK_HEADERS([assert.h crt_externs.h])
 #   isblank - available as a GNU extension or in C99
 #   _NSGetEnviron - Darwin specific
 #   strcoll_l, newlocale - GNU extensions (glibc), also available on Darwin
-#   nl_langinfo - X/Open, not available on Windows.
 #   utimensat: posix.1-2008
 #
-AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround ftime ftruncate fchown getcwd geteuid getsid gettimeofday gmtime_r ioctl lstat mkdir mknod nice pipe _pipe readdir_r readdir64_r readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt stat64 strftime strptime symlink sync sysconf tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron strcoll strcoll_l newlocale nl_langinfo utimensat])
+AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround ftime ftruncate fchown getcwd geteuid getsid gettimeofday gmtime_r ioctl lstat mkdir mknod nice pipe _pipe readdir_r readdir64_r readlink rename rmdir select setegid seteuid setlocale setpgid setsid sigaction siginterrupt stat64 strftime strptime symlink sync sysconf tcgetpgrp tcsetpgrp times uname waitpid strdup system usleep atexit on_exit chown link fcntl ttyname getpwent getgrent kill getppid getpgrp fork setitimer getitimer strchr strcmp index bcopy memcpy rindex truncate unsetenv isblank _NSGetEnviron strcoll strcoll_l newlocale utimensat])
 
 # Reasons for testing:
 #   netdb.h - not in mingw
	Modified lib/Makefile.am
diff --git a/lib/Makefile.am b/lib/Makefile.am
index b9f4f8a..648a62e 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -9,7 +9,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs getaddrinfo gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs getaddrinfo gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile nl_langinfo putenv stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
 
 AUTOMAKE_OPTIONS = 1.5 gnits subdir-objects
 
@@ -449,6 +449,34 @@ EXTRA_libgnu_la_SOURCES += inet_pton.c
 
 ## end   gnulib module inet_pton
 
+## begin gnulib module langinfo
+
+BUILT_SOURCES += langinfo.h
+
+# We need the following in order to create an empty placeholder for
+# <langinfo.h> when the system doesn't have one.
+langinfo.h: langinfo.in.h $(WARN_ON_USE_H)
+	$(AM_V_GEN)rm -f $@-t $@ && \
+	{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+	  sed -e 's|@''HAVE_LANGINFO_H''@|$(HAVE_LANGINFO_H)|g' \
+	      -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+	      -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+	      -e 's|@''NEXT_LANGINFO_H''@|$(NEXT_LANGINFO_H)|g' \
+	      -e 's|@''GNULIB_NL_LANGINFO''@|$(GNULIB_NL_LANGINFO)|g' \
+	      -e 's|@''HAVE_LANGINFO_CODESET''@|$(HAVE_LANGINFO_CODESET)|g' \
+	      -e 's|@''HAVE_LANGINFO_ERA''@|$(HAVE_LANGINFO_ERA)|g' \
+	      -e 's|@''HAVE_NL_LANGINFO''@|$(HAVE_NL_LANGINFO)|g' \
+	      -e 's|@''REPLACE_NL_LANGINFO''@|$(REPLACE_NL_LANGINFO)|g' \
+	      -e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
+	      < $(srcdir)/langinfo.in.h; \
+	} > $@-t && \
+	mv $@-t $@
+MOSTLYCLEANFILES += langinfo.h langinfo.h-t
+
+EXTRA_DIST += langinfo.in.h
+
+## end   gnulib module langinfo
+
 ## begin gnulib module lib-symbol-visibility
 
 # The value of $(CFLAG_VISIBILITY) needs to be added to the CFLAGS for the
@@ -680,6 +708,15 @@ EXTRA_DIST += netinet_in.in.h
 
 ## end   gnulib module netinet_in
 
+## begin gnulib module nl_langinfo
+
+
+EXTRA_DIST += nl_langinfo.c
+
+EXTRA_libgnu_la_SOURCES += nl_langinfo.c
+
+## end   gnulib module nl_langinfo
+
 ## begin gnulib module pathmax

	New      lib/langinfo.in.h
diff --git a/lib/langinfo.in.h b/lib/langinfo.in.h
new file mode 100644
index 0000000..6d15f2f
--- /dev/null
+++ b/lib/langinfo.in.h
@@ -0,0 +1,162 @@
+/* Substitute for and wrapper around <langinfo.h>.
+   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/*
+ * POSIX <langinfo.h> for platforms that lack it or have an incomplete one.
+ * <http://www.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html>
+ */
+
+#ifndef _GL_LANGINFO_H
+
+#if __GNUC__ >= 3
+@PRAGMA_SYSTEM_HEADER@
+#endif
+
+/* The include_next requires a split double-inclusion guard.  */
+#if @HAVE_LANGINFO_H@
+# @INCLUDE_NEXT@ @NEXT_LANGINFO_H@
+#endif
+
+#ifndef _GL_LANGINFO_H
+#define _GL_LANGINFO_H
+
+
+#if !@HAVE_LANGINFO_H@
+
+/* A platform that lacks <langinfo.h>.  */
+
+/* Assume that it also lacks <nl_types.h> and the nl_item type.  */
+typedef int nl_item;
+
+/* nl_langinfo items of the LC_CTYPE category */
+# define CODESET     10000
+/* nl_langinfo items of the LC_NUMERIC category */
+# define RADIXCHAR   10001
+# define THOUSEP     10002
+/* nl_langinfo items of the LC_TIME category */
+# define D_T_FMT     10003
+# define D_FMT       10004
+# define T_FMT       10005
+# define T_FMT_AMPM  10006
+# define AM_STR      10007
+# define PM_STR      10008
+# define DAY_1       10009
+# define DAY_2       (DAY_1 + 1)
+# define DAY_3       (DAY_1 + 2)
+# define DAY_4       (DAY_1 + 3)
+# define DAY_5       (DAY_1 + 4)
+# define DAY_6       (DAY_1 + 5)
+# define DAY_7       (DAY_1 + 6)
+# define ABDAY_1     10016
+# define ABDAY_2     (ABDAY_1 + 1)
+# define ABDAY_3     (ABDAY_1 + 2)
+# define ABDAY_4     (ABDAY_1 + 3)
+# define ABDAY_5     (ABDAY_1 + 4)
+# define ABDAY_6     (ABDAY_1 + 5)
+# define ABDAY_7     (ABDAY_1 + 6)
+# define MON_1       10023
+# define MON_2       (MON_1 + 1)
+# define MON_3       (MON_1 + 2)
+# define MON_4       (MON_1 + 3)
+# define MON_5       (MON_1 + 4)
+# define MON_6       (MON_1 + 5)
+# define MON_7       (MON_1 + 6)
+# define MON_8       (MON_1 + 7)
+# define MON_9       (MON_1 + 8)
+# define MON_10      (MON_1 + 9)
+# define MON_11      (MON_1 + 10)
+# define MON_12      (MON_1 + 11)
+# define ABMON_1     10035
+# define ABMON_2     (ABMON_1 + 1)
+# define ABMON_3     (ABMON_1 + 2)
+# define ABMON_4     (ABMON_1 + 3)
+# define ABMON_5     (ABMON_1 + 4)
+# define ABMON_6     (ABMON_1 + 5)
+# define ABMON_7     (ABMON_1 + 6)
+# define ABMON_8     (ABMON_1 + 7)
+# define ABMON_9     (ABMON_1 + 8)
+# define ABMON_10    (ABMON_1 + 9)
+# define ABMON_11    (ABMON_1 + 10)
+# define ABMON_12    (ABMON_1 + 11)
+# define ERA         10047
+# define ERA_D_FMT   10048
+# define ERA_D_T_FMT 10049
+# define ERA_T_FMT   10050
+# define ALT_DIGITS  10051
+/* nl_langinfo items of the LC_MONETARY category */
+# define CRNCYSTR    10052
+/* nl_langinfo items of the LC_MESSAGES category */
+# define YESEXPR     10053
+# define NOEXPR      10054
+
+#else
+
+/* A platform that has <langinfo.h>.  */
+
+# if !@HAVE_LANGINFO_CODESET@
+#  define CODESET     10000
+#  define GNULIB_defined_CODESET 1
+# endif
+
+# if !@HAVE_LANGINFO_ERA@
+#  define ERA         10047
+#  define ERA_D_FMT   10048
+#  define ERA_D_T_FMT 10049
+#  define ERA_T_FMT   10050
+#  define ALT_DIGITS  10051
+#  define GNULIB_defined_ERA 1
+# endif
+
+#endif
+
+/* The definition of _GL_WARN_ON_USE is copied here.  */
+
+/* Declare overridden functions.  */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* Return a piece of locale dependent information.
+   Note: The difference between nl_langinfo (CODESET) and locale_charset ()
+   is that the latter normalizes the encoding names to GNU conventions.  */
+
+#if @GNULIB_NL_LANGINFO@
+# if @REPLACE_NL_LANGINFO@
+#  undef nl_langinfo
+#  define nl_langinfo rpl_nl_langinfo
+# endif
+# if !@HAVE_NL_LANGINFO@ || @REPLACE_NL_LANGINFO@
+extern char *nl_langinfo (nl_item item);
+# endif
+#elif defined GNULIB_POSIXCHECK
+# undef nl_langinfo
+# if HAVE_RAW_DECL_NL_LANGINFO
+_GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - "
+                 "use gnulib module nl_langinfo for portability");
+# endif
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* _GL_LANGINFO_H */
+#endif /* _GL_LANGINFO_H */
	New      lib/nl_langinfo.c
diff --git a/lib/nl_langinfo.c b/lib/nl_langinfo.c
new file mode 100644
index 0000000..0c02346
--- /dev/null
+++ b/lib/nl_langinfo.c
@@ -0,0 +1,260 @@
+/* nl_langinfo() replacement: query locale dependent information.
+
+   Copyright (C) 2007-2010 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+/* Specification.  */
+#include <langinfo.h>
+
+#if REPLACE_NL_LANGINFO
+
+/* Override nl_langinfo with support for added nl_item values.  */
+
+# include <locale.h>
+# include <string.h>
+
+# undef nl_langinfo
+
+char *
+rpl_nl_langinfo (nl_item item)
+{
+  switch (item)
+    {
+# if GNULIB_defined_CODESET
+    case CODESET:
+      {
+        const char *locale;
+        static char buf[2 + 10 + 1];
+
+        locale = setlocale (LC_CTYPE, NULL);
+        if (locale != NULL && locale[0] != '\0')
+          {
+            /* If the locale name contains an encoding after the dot, return
+               it.  */
+            const char *dot = strchr (locale, '.');
+
+            if (dot != NULL)
+              {
+                const char *modifier;
+
+                dot++;
+                /* Look for the possible @... trailer and remove it, if any.  */
+                modifier = strchr (dot, '@');
+                if (modifier == NULL)
+                  return dot;
+                if (modifier - dot < sizeof (buf))
+                  {
+                    memcpy (buf, dot, modifier - dot);
+                    buf [modifier - dot] = '\0';
+                    return buf;
+                  }
+              }
+          }
+        return "";
+      }
+# endif
+# if GNULIB_defined_ERA
+    case ERA:
+      /* The format is not standardized.  In glibc it is a sequence of strings
+         of the form "direction:offset:start_date:end_date:era_name:era_format"
+         with an empty string at the end.  */
+      return "";
+    case ERA_D_FMT:
+      /* The %Ex conversion in strftime behaves like %x if the locale does not
+         have an alternative time format.  */
+      item = D_FMT;
+      break;
+    case ERA_D_T_FMT:
+      /* The %Ec conversion in strftime behaves like %c if the locale does not
+         have an alternative time format.  */
+      item = D_T_FMT;
+      break;
+    case ERA_T_FMT:
+      /* The %EX conversion in strftime behaves like %X if the locale does not
+         have an alternative time format.  */
+      item = T_FMT;
+      break;
+    case ALT_DIGITS:
+      /* The format is not standardized.  In glibc it is a sequence of 10
+         strings, appended in memory.  */
+      return "\0\0\0\0\0\0\0\0\0\0";
+# endif
+    default:
+      break;
+    }
+  return nl_langinfo (item);
+}
+
+#else
+
+/* Provide nl_langinfo from scratch.  */
+
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+
+/* Native Windows platforms.  */
+
+#  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
+#  include <windows.h>
+
+#  include <stdio.h>
+
+# else
+
+/* An old Unix platform without locales, such as Linux libc5 or BeOS.  */
+
+# endif
+
+# include <locale.h>
+
+char *
+nl_langinfo (nl_item item)
+{
+  switch (item)
+    {
+    /* nl_langinfo items of the LC_CTYPE category */
+    case CODESET:
+# if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
+      {
+        static char buf[2 + 10 + 1];
+
+        /* Woe32 has a function returning the locale's codepage as a number.  */
+        sprintf (buf, "CP%u", GetACP ());
+        return buf;
+      }
+# elif defined __BEOS__
+      return "UTF-8";
+# else
+      return "ISO-8859-1";
+# endif
+    /* nl_langinfo items of the LC_NUMERIC category */
+    case RADIXCHAR:
+      return localeconv () ->decimal_point;
+    case THOUSEP:
+      return localeconv () ->thousands_sep;
+    /* nl_langinfo items of the LC_TIME category.
+       TODO: Really use the locale.  */
+    case D_T_FMT:
+    case ERA_D_T_FMT:
+      return "%a %b %e %H:%M:%S %Y";
+    case D_FMT:
+    case ERA_D_FMT:
+      return "%m/%d/%y";
+    case T_FMT:
+    case ERA_T_FMT:
+      return "%H:%M:%S";
+    case T_FMT_AMPM:
+      return "%I:%M:%S %p";
+    case AM_STR:
+      return "AM";
+    case PM_STR:
+      return "PM";
+    case DAY_1:
+      return "Sunday";
+    case DAY_2:
+      return "Monday";
+    case DAY_3:
+      return "Tuesday";
+    case DAY_4:
+      return "Wednesday";
+    case DAY_5:
+      return "Thursday";
+    case DAY_6:
+      return "Friday";
+    case DAY_7:
+      return "Saturday";
+    case ABDAY_1:
+      return "Sun";
+    case ABDAY_2:
+      return "Mon";
+    case ABDAY_3:
+      return "Tue";
+    case ABDAY_4:
+      return "Wed";
+    case ABDAY_5:
+      return "Thu";
+    case ABDAY_6:
+      return "Fri";
+    case ABDAY_7:
+      return "Sat";
+    case MON_1:
+      return "January";
+    case MON_2:
+      return "February";
+    case MON_3:
+      return "March";
+    case MON_4:
+      return "April";
+    case MON_5:
+      return "May";
+    case MON_6:
+      return "June";
+    case MON_7:
+      return "July";
+    case MON_8:
+      return "August";
+    case MON_9:
+      return "September";
+    case MON_10:
+      return "October";
+    case MON_11:
+      return "November";
+    case MON_12:
+      return "December";
+    case ABMON_1:
+      return "Jan";
+    case ABMON_2:
+      return "Feb";
+    case ABMON_3:
+      return "Mar";
+    case ABMON_4:
+      return "Apr";
+    case ABMON_5:
+      return "May";
+    case ABMON_6:
+      return "Jun";
+    case ABMON_7:
+      return "Jul";
+    case ABMON_8:
+      return "Aug";
+    case ABMON_9:
+      return "Sep";
+    case ABMON_10:
+      return "Oct";
+    case ABMON_11:
+      return "Nov";
+    case ABMON_12:
+      return "Dec";
+    case ERA:
+      return "";
+    case ALT_DIGITS:
+      return "\0\0\0\0\0\0\0\0\0\0";
+    /* nl_langinfo items of the LC_MONETARY category
+       TODO: Really use the locale. */
+    case CRNCYSTR:
+      return "-";
+    /* nl_langinfo items of the LC_MESSAGES category
+       TODO: Really use the locale. */
+    case YESEXPR:
+      return "^[yY]";
+    case NOEXPR:
+      return "^[nN]";
+    default:
+      return "";
+    }
+}
+
+#endif
	Modified libguile/Makefile.am
diff --git a/libguile/Makefile.am b/libguile/Makefile.am
index 206c4f4..6e0e7e5 100644
--- a/libguile/Makefile.am
+++ b/libguile/Makefile.am
@@ -443,7 +443,7 @@ noinst_HEADERS += vm-engine.c vm-i-system.c vm-i-scheme.c vm-i-loader.c
 libguile_la_DEPENDENCIES = @LIBLOBJS@
 libguile_la_LIBADD =				\
   @LIBLOBJS@ $(gnulib_library) $(LTLIBGMP)	\
-  $(LTLIBUNISTRING) $(LTLIBICONV)
+  $(LTLIBUNISTRING) $(LTLIBINTL) $(LTLIBICONV)
 libguile_la_LDFLAGS =											\
   @LTLIBINTL@ $(LIBFFI_LIBS) $(INET_NTOP_LIB) $(INET_PTON_LIB)						\
   $(GETADDRINFO_LIB) $(HOSTENT_LIB) $(SERVENT_LIB)							\
	Modified libguile/i18n.c
diff --git a/libguile/i18n.c b/libguile/i18n.c
index b381b05..4bf3764 100644
--- a/libguile/i18n.c
+++ b/libguile/i18n.c
@@ -59,8 +59,8 @@
 
 #include "libguile/posix.h"  /* for `scm_i_locale_mutex' */
 
-#if (defined HAVE_LANGINFO_H) && (defined HAVE_NL_TYPES_H)
-# include <langinfo.h>
+#include <langinfo.h>
+#ifdef HAVE_NL_TYPES_H
 # include <nl_types.h>
 #endif
 
@@ -209,7 +209,7 @@ SCM_GLOBAL_VARIABLE (scm_global_locale, "%global-locale");
 #define SCM_VALIDATE_OPTIONAL_LOCALE_COPY(_pos, _arg, _c_locale)	\
   do									\
     {									\
-      if ((_arg) != SCM_UNDEFINED)					\
+      if (!SCM_UNBNDP (_arg) && scm_is_true (_arg))			\
 	SCM_VALIDATE_LOCALE_COPY (_pos, _arg, _c_locale);		\
       else								\
 	(_c_locale) = NULL;						\
@@ -1472,14 +1472,11 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
 	    "Reference Manual}).")
 #define FUNC_NAME s_scm_nl_langinfo
 {
-#ifdef HAVE_NL_LANGINFO
   SCM result;
   nl_item c_item;
   char *c_result;
   scm_t_locale c_locale;
-#ifdef HAVE_LANGINFO_CODESET
   char *codeset;
-#endif
 
   SCM_VALIDATE_INT_COPY (2, item, c_item);
   SCM_VALIDATE_OPTIONAL_LOCALE_COPY (2, locale, c_locale);
@@ -1496,9 +1493,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
     {
 #ifdef USE_GNU_LOCALE_API
       c_result = nl_langinfo_l (c_item, c_locale);
-#ifdef HAVE_LANGINFO_CODESET
       codeset = nl_langinfo_l (CODESET, c_locale);
-#endif /* HAVE_LANGINFO_CODESET */
 #else /* !USE_GNU_LOCALE_API */
       /* We can't use `RUN_IN_LOCALE_SECTION ()' here because the locale
 	 mutex is already taken.  */
@@ -1523,9 +1518,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
       else
 	{
 	  c_result = nl_langinfo (c_item);
-#ifdef HAVE_LANGINFO_CODESET
           codeset = nl_langinfo (CODESET);
-#endif /* HAVE_LANGINFO_CODESET */
 
 	  restore_locale_settings (&lsec_prev_locale);
 	  free_locale_settings (&lsec_prev_locale);
@@ -1535,9 +1528,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
   else
     {
       c_result = nl_langinfo (c_item);
-#ifdef HAVE_LANGINFO_CODESET
       codeset = nl_langinfo (CODESET);
-#endif /* HAVE_LANGINFO_CODESET */
     }
 
   c_result = strdup (c_result);
@@ -1646,26 +1637,14 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
 #endif
 
 	default:
-#ifdef HAVE_LANGINFO_CODESET
           result = scm_from_stringn (c_result, strlen (c_result),
                                      codeset,
                                      SCM_FAILED_CONVERSION_QUESTION_MARK);
-#else /* !HAVE_LANGINFO_CODESET */
-          /* This may be incorrectly encoded if the locale differs
-             from the c_locale.  */
-          result = scm_from_locale_string (c_result);
-#endif /* !HAVE_LANGINFO_CODESET */
           free (c_result);
 	}
     }
 
   return result;
-#else
-  scm_syserror_msg (FUNC_NAME, "`nl-langinfo' not supported on your system",
-		    SCM_EOL, ENOSYS);
-
-  return SCM_BOOL_F;
-#endif
 }
 #undef FUNC_NAME
 
@@ -1673,7 +1652,7 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinfo", 1, 1, 0,
 static inline void
 define_langinfo_items (void)
 {
-#if (defined HAVE_NL_TYPES_H) && (defined HAVE_LANGINFO_H)
+#ifdef HAVE_NL_TYPES_H
 
 #define DEFINE_NLITEM_CONSTANT(_item)		\
   scm_c_define (# _item, scm_from_int (_item))
@@ -1839,10 +1818,7 @@ scm_init_i18n ()
 {
   SCM global_locale_smob;
 
-#ifdef HAVE_NL_LANGINFO
-  scm_add_feature ("nl-langinfo");
   define_langinfo_items ();
-#endif
 
 #include "libguile/i18n.x"
 
	Modified m4/gnulib-cache.m4
diff --git a/m4/gnulib-cache.m4 b/m4/gnulib-cache.m4
index 3326fb9..d3eca04 100644
--- a/m4/gnulib-cache.m4
+++ b/m4/gnulib-cache.m4
@@ -15,7 +15,7 @@

 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs getaddrinfo gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile putenv stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
+#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --lgpl=3 --libtool --macro-prefix=gl --no-vc-files alignof alloca-opt announce-gen autobuild byteswap canonicalize-lgpl duplocale environ extensions flock fpieee full-read full-write gendocs getaddrinfo gitlog-to-changelog gnu-web-doc-update gnupload havelib iconv_open-utf inet_ntop inet_pton lib-symbol-versions lib-symbol-visibility libunistring locale maintainer-makefile nl_langinfo putenv stdlib strcase strftime striconveh string sys_stat verify version-etc-fsf vsnprintf warnings
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
@@ -47,6 +47,7 @@ gl_MODULES([
   libunistring
   locale
   maintainer-makefile
+  nl_langinfo
   putenv
   stdlib
   strcase
	Modified m4/gnulib-comp.m4
diff --git a/m4/gnulib-comp.m4 b/m4/gnulib-comp.m4
index fc989b2..87825ce 100644
--- a/m4/gnulib-comp.m4
+++ b/m4/gnulib-comp.m4
@@ -89,6 +89,7 @@ AC_DEFUN([gl_INIT],
   gl_INET_PTON
   gl_ARPA_INET_MODULE_INDICATOR([inet_pton])
   gl_INLINE
+  gl_LANGINFO_H
   gl_LD_VERSION_SCRIPT
   gl_VISIBILITY
   gl_LIBUNISTRING
@@ -115,6 +116,8 @@ AC_DEFUN([gl_INIT],
   gl_HEADER_NETDB
   gl_HEADER_NETINET_IN
   AC_PROG_MKDIR_P
+  gl_FUNC_NL_LANGINFO
+  gl_LANGINFO_MODULE_INDICATOR([nl_langinfo])
   gl_PATHMAX
   gl_FUNC_PUTENV
   gl_STDLIB_MODULE_INDICATOR([putenv])
@@ -343,6 +346,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/iconveh.h
   lib/inet_ntop.c
   lib/inet_pton.c
+  lib/langinfo.in.h
   lib/localcharset.c
   lib/localcharset.h
   lib/locale.in.h
@@ -358,6 +362,7 @@ AC_DEFUN([gl_FILE_LIST], [
   lib/memchr.valgrind
   lib/netdb.in.h
   lib/netinet_in.in.h
+  lib/nl_langinfo.c
   lib/pathmax.h
   lib/printf-args.c
   lib/printf-args.h
@@ -447,6 +452,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/inline.m4
   m4/intmax_t.m4
   m4/inttypes_h.m4
+  m4/langinfo_h.m4
   m4/ld-version-script.m4
   m4/lib-ld.m4
   m4/lib-link.m4
@@ -470,6 +476,7 @@ AC_DEFUN([gl_FILE_LIST], [
   m4/multiarch.m4
   m4/netdb_h.m4
   m4/netinet_in_h.m4
+  m4/nl_langinfo.m4
   m4/pathmax.m4
   m4/printf.m4
   m4/putenv.m4
	New      m4/langinfo_h.m4
diff --git a/m4/langinfo_h.m4 b/m4/langinfo_h.m4
new file mode 100644
index 0000000..a4c5409
--- /dev/null
+++ b/m4/langinfo_h.m4
@@ -0,0 +1,74 @@
+# langinfo_h.m4 serial 3
+dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_LANGINFO_H],
+[
+  AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
+
+  dnl Persuade glibc-2.0.6 <langinfo.h> to define CODESET.
+  AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
+
+  gl_CHECK_NEXT_HEADERS([langinfo.h])
+
+  dnl Determine whether <langinfo.h> exists. It is missing on mingw and BeOS.
+  HAVE_LANGINFO_CODESET=0
+  HAVE_LANGINFO_ERA=0
+  AC_CHECK_HEADERS_ONCE([langinfo.h])
+  if test $ac_cv_header_langinfo_h = yes; then
+    HAVE_LANGINFO_H=1
+    dnl Determine what <langinfo.h> defines. CODESET and ERA etc. are missing
+    dnl on OpenBSD 3.8.
+    AC_CACHE_CHECK([whether langinfo.h defines CODESET],
+      [gl_cv_header_langinfo_codeset],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([[#include <langinfo.h>
+int a = CODESET;
+]])],
+         [gl_cv_header_langinfo_codeset=yes],
+         [gl_cv_header_langinfo_codeset=no])
+      ])
+    if test $gl_cv_header_langinfo_codeset = yes; then
+      HAVE_LANGINFO_CODESET=1
+    fi
+    AC_CACHE_CHECK([whether langinfo.h defines ERA],
+      [gl_cv_header_langinfo_era],
+      [AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM([[#include <langinfo.h>
+int a = ERA;
+]])],
+         [gl_cv_header_langinfo_era=yes],
+         [gl_cv_header_langinfo_era=no])
+      ])
+    if test $gl_cv_header_langinfo_era = yes; then
+      HAVE_LANGINFO_ERA=1
+    fi
+  else
+    HAVE_LANGINFO_H=0
+  fi
+  AC_SUBST([HAVE_LANGINFO_H])
+  AC_SUBST([HAVE_LANGINFO_CODESET])
+  AC_SUBST([HAVE_LANGINFO_ERA])
+
+  dnl Check for declarations of anything we want to poison if the
+  dnl corresponding gnulib module is not in use.
+  gl_WARN_ON_USE_PREPARE([[#include <langinfo.h>
+    ]], [nl_langinfo])
+])
+
+AC_DEFUN([gl_LANGINFO_MODULE_INDICATOR],
+[
+  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
+  AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
+  GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+])
+
+AC_DEFUN([gl_LANGINFO_H_DEFAULTS],
+[
+  GNULIB_NL_LANGINFO=0;  AC_SUBST([GNULIB_NL_LANGINFO])
+  dnl Assume proper GNU behavior unless another module says otherwise.
+  HAVE_NL_LANGINFO=1;    AC_SUBST([HAVE_NL_LANGINFO])
+  REPLACE_NL_LANGINFO=0; AC_SUBST([REPLACE_NL_LANGINFO])
+])
	New      m4/nl_langinfo.m4
diff --git a/m4/nl_langinfo.m4 b/m4/nl_langinfo.m4
new file mode 100644
index 0000000..ad456a2
--- /dev/null
+++ b/m4/nl_langinfo.m4
@@ -0,0 +1,25 @@
+# nl_langinfo.m4 serial 3
+dnl Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_FUNC_NL_LANGINFO],
+[
+  AC_REQUIRE([gl_LANGINFO_H_DEFAULTS])
+  AC_REQUIRE([gl_LANGINFO_H])
+  AC_CHECK_FUNCS_ONCE([nl_langinfo])
+  if test $ac_cv_func_nl_langinfo = yes; then
+    if test $HAVE_LANGINFO_CODESET = 1 && test $HAVE_LANGINFO_ERA = 1; then
+      :
+    else
+      REPLACE_NL_LANGINFO=1
+      AC_DEFINE([REPLACE_NL_LANGINFO], [1],
+        [Define if nl_langinfo exists but is overridden by gnulib.])
+      AC_LIBOBJ([nl_langinfo])
+    fi
+  else
+    HAVE_NL_LANGINFO=0
+    AC_LIBOBJ([nl_langinfo])
+  fi
+])
	Modified module/ice-9/i18n.scm
diff --git a/module/ice-9/i18n.scm b/module/ice-9/i18n.scm
index 6fa31e4..8002656 100644
--- a/module/ice-9/i18n.scm
+++ b/module/ice-9/i18n.scm
@@ -100,13 +100,10 @@
 ;;;
 
 ;; Helper macro: Define a procedure named NAME that maps its argument to
-;; NL-ITEMS (when `nl-langinfo' is provided) or DEFAULTS (when `nl-langinfo'
-;; is not provided).
-(define-macro (define-vector-langinfo-mapping name nl-items defaults)
+;; NL-ITEMS (when `nl-langinfo' is provided).
+(define-macro (define-vector-langinfo-mapping name nl-items)
   (let* ((item-count (length nl-items))
-         (defines    (if (provided? 'nl-langinfo)
-                         `(define %nl-items (vector #f ,@nl-items))
-                         `(define %defaults (vector #f ,@defaults))))
+         (defines   `(define %nl-items (vector #f ,@nl-items)))
          (make-body (lambda (result)
                       `(if (and (integer? item) (exact? item))
                            (if (and (>= item 1) (<= item ,item-count))
@@ -115,28 +112,21 @@
                            (throw 'wrong-type-arg "wrong argument type" item)))))
     `(define (,name item . locale)
        ,defines
-       ,(make-body (if (provided? 'nl-langinfo)
-                       '(apply nl-langinfo (vector-ref %nl-items item) locale)
-                       '(vector-ref %defaults item))))))
+       ,(make-body '(apply nl-langinfo (vector-ref %nl-items item) locale)))))

 (define-vector-langinfo-mapping locale-day-short
-  (ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7)
-  ("Sun" "Mon" "Tue" "Wed" "Thu" "Fri" "Sat"))
+  (ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5 ABDAY_6 ABDAY_7))
 
 (define-vector-langinfo-mapping locale-day
-  (DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7)
-  ("Sunday" "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday"))
+  (DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7))
 
 (define-vector-langinfo-mapping locale-month-short
   (ABMON_1 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6
-   ABMON_7 ABMON_8 ABMON_9 ABMON_10 ABMON_11 ABMON_12)
-  ("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec"))
+   ABMON_7 ABMON_8 ABMON_9 ABMON_10 ABMON_11 ABMON_12))
 
 (define-vector-langinfo-mapping locale-month
-  (MON_1 MON_2 MON_3 MON_4 MON_5 MON_6 MON_7 MON_8 MON_9 MON_10 MON_11 MON_12)
-  ("January" "February" "March" "April" "May" "June" "July" "August"
-   "September" "October" "November" "December"))
+  (MON_1 MON_2 MON_3 MON_4 MON_5 MON_6 MON_7 MON_8 MON_9 MON_10 MON_11 MON_12))

 
@@ -145,35 +135,34 @@
 ;;;
 
 ;; Helper macro: Define a procedure NAME that gets langinfo item ITEM.
-(define-macro (define-simple-langinfo-mapping name item default)
-  (let ((body (if (and (provided? 'nl-langinfo) (defined? item))
-                  `(apply nl-langinfo ,item locale)
-                  default)))
-    `(define (,name . locale)
-       ,body)))
+(define-syntax define-simple-langinfo-mapping
+  (syntax-rules ()
+    ((_ name item)
+     (define* (name #:optional locale)
+       (nl-langinfo item locale)))))
 
 (define-simple-langinfo-mapping locale-am-string
-  AM_STR "AM")
+  AM_STR)
 (define-simple-langinfo-mapping locale-pm-string
-  PM_STR "PM")
+  PM_STR)
 (define-simple-langinfo-mapping locale-date+time-format
-  D_T_FMT "%a %b %e %H:%M:%S %Y")
+  D_T_FMT)
 (define-simple-langinfo-mapping locale-date-format
-  D_FMT   "%m/%d/%y")
+  D_FMT)
 (define-simple-langinfo-mapping locale-time-format
-  T_FMT   "%H:%M:%S")
+  T_FMT)
 (define-simple-langinfo-mapping locale-time+am/pm-format
-  T_FMT_AMPM "%I:%M:%S %p")
+  T_FMT_AMPM)
 (define-simple-langinfo-mapping locale-era
-  ERA        "")
+  ERA)
 (define-simple-langinfo-mapping locale-era-year
-  ERA_YEAR   "")
+  ERA_YEAR)
 (define-simple-langinfo-mapping locale-era-date+time-format
-  ERA_D_T_FMT "")
+  ERA_D_T_FMT)
 (define-simple-langinfo-mapping locale-era-date-format
-  ERA_D_FMT   "")
+  ERA_D_FMT)
 (define-simple-langinfo-mapping locale-era-time-format
-  ERA_T_FMT   "")
+  ERA_T_FMT)