* configure.in: check whether localtime caches TZ. copied from
[bpt/guile.git] / configure.in
index 614e57d..89a7fb6 100644 (file)
@@ -53,9 +53,13 @@ AC_ARG_ENABLE(guile-debug,
 AC_ARG_ENABLE(debug-freelist,
   [  --enable-debug-freelist    Include garbage collector freelist debugging code],
   if test "$enable_debug_freelist" = y || test "$enable_debug_freelist" = yes; then
-    AC_DEFINE(DEBUG_FREELIST)
+    AC_DEFINE(GUILE_DEBUG_FREELIST)
   fi)
 
+AC_ARG_ENABLE(arrays,
+  [  --disable-arrays        omit array and uniform array support],,
+  enable_arrays=yes)
+
 AC_ARG_ENABLE(posix,
   [  --disable-posix         omit posix interfaces],,
   enable_posix=yes)
@@ -75,6 +79,11 @@ AC_DEFINE(READER_EXTENSIONS)
 
 dnl files which are destined for separate modules.
 
+if test "$enable_arrays" = yes; then
+   LIBOBJS="$LIBOBJS ramap.o unif.o"
+   AC_DEFINE(HAVE_ARRAYS)
+fi
+
 if test "$enable_posix" = yes; then
    LIBOBJS="$LIBOBJS filesys.o posix.o"
    AC_DEFINE(HAVE_POSIX)
@@ -219,7 +228,7 @@ dnl AC_CHECK_FUNCS...
 dnl restore confdefs.h
 
 dnl cp confdefs.h confdefs.h.bak
-dnl for func in gethostent sethostent endhostent getnetent setnetent endnetent getprotoent setprotoent endprotoent getservent setservent endservent getnetbyaddr getnetbyname inet_lnaof inet_makeaddr inet_netof ; do
+dnl for func in gethostent sethostent endhostent getnetent setnetent endnetent getprotoent setprotoent endprotoent getservent setservent endservent getnetbyaddr getnetbyname inet_lnaof inet_makeaddr inet_netof hstrerror; do
 dnl cp confdefs.h.bak confdefs.h
 dnl cat >> confdefs.h << EOF 
 dnl #ifdef __CYGWIN32__
@@ -234,10 +243,58 @@ AC_CHECK_FUNCS(sethostent   gethostent   endhostent   dnl
                setnetent    getnetent    endnetent    dnl
                setprotoent  getprotoent  endprotoent  dnl
                setservent   getservent   endservent   dnl
-               getnetbyaddr getnetbyname inet_lnaof inet_makeaddr inet_netof)
+               getnetbyaddr getnetbyname dnl
+              inet_lnaof inet_makeaddr inet_netof hstrerror)
 
 dnl </GNU-WIN32 hacks>
 
+AC_MSG_CHECKING(whether localtime caches TZ)
+AC_CACHE_VAL(guile_cv_localtime_cache,
+[if test x$ac_cv_func_tzset = xyes; then
+AC_TRY_RUN([#include <time.h>
+#if STDC_HEADERS
+# include <stdlib.h>
+#endif
+extern char **environ;
+unset_TZ ()
+{
+  char **from, **to;
+  for (to = from = environ; (*to = *from); from++)
+    if (! (to[0][0] == 'T' && to[0][1] == 'Z' && to[0][2] == '='))
+      to++;
+}
+char TZ_GMT0[] = "TZ=GMT0";
+char TZ_PST8[] = "TZ=PST8";
+main()
+{
+  time_t now = time ((time_t *) 0);
+  int hour_GMT0, hour_unset;
+  if (putenv (TZ_GMT0) != 0)
+    exit (1);
+  hour_GMT0 = localtime (&now)->tm_hour;
+  unset_TZ ();
+  hour_unset = localtime (&now)->tm_hour;
+  if (putenv (TZ_PST8) != 0)
+    exit (1);
+  if (localtime (&now)->tm_hour == hour_GMT0)
+    exit (1);
+  unset_TZ ();
+  if (localtime (&now)->tm_hour != hour_unset)
+    exit (1);
+  exit (0);
+}], guile_cv_localtime_cache=no, guile_cv_localtime_cache=yes,
+[# If we have tzset, assume the worst when cross-compiling.
+guile_cv_localtime_cache=yes])
+else
+        # If we lack tzset, report that localtime does not cache TZ,
+        # since we can't invalidate the cache if we don't have tzset.
+        guile_cv_localtime_cache=no
+fi])dnl
+AC_MSG_RESULT($guile_cv_localtime_cache)
+if test $guile_cv_localtime_cache = yes; then
+  AC_DEFINE(LOCALTIME_CACHE)
+fi
+
 dnl Test whether system calls are restartable by default on the
 dnl current system.  If they are not, we put a loop around every system
 dnl call to check for EINTR (see SCM_SYSCALL) and do not attempt to
@@ -411,7 +468,9 @@ case "$GCC" in
     ## We had -Wstrict-prototypes in here for a bit, but Guile does too
     ## much stuff with generic function pointers for that to really be
     ## less than exasperating.
-    CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wmissing-prototypes" ;;
+    ## -Wpointer-arith was here too, but something changed in gcc/glibc
+    ## and it became equally exasperating (gcc 2.95 and/or glibc 2.1.2).
+    CFLAGS="$CFLAGS -Wall -Wmissing-prototypes" ;;
 esac
 
 AC_PROG_AWK
@@ -432,7 +491,7 @@ AC_SUBST(GUILE_LIBS)
 AC_SUBST(AWK)
 AC_SUBST(LIBLOBJS)
 
-AC_OUTPUT([Makefile libguile/Makefile libguile/guile-snarf libguile/versiondat.h ice-9/Makefile qt/Makefile qt/qt.h qt/md/Makefile qt/time/Makefile guile-config/Makefile doc/Makefile], [chmod +x libguile/guile-snarf])
+AC_OUTPUT([Makefile libguile/Makefile libguile/guile-snarf libguile/guile-doc-snarf libguile/guile-snarf.awk libguile/versiondat.h ice-9/Makefile qt/Makefile qt/qt.h qt/md/Makefile qt/time/Makefile guile-config/Makefile doc/Makefile], [chmod +x libguile/guile-snarf; chmod +x libguile/guile-doc-snarf])
 
 dnl Local Variables:
 dnl comment-start: "dnl "