Add copyright notice to acinclude.m4.
[bpt/guile.git] / acinclude.m4
index 345e323..82fa24e 100644 (file)
@@ -1,3 +1,26 @@
+dnl -*- Autoconf -*-
+
+dnl Copyright (C) 1997, 1999, 2000, 2001, 2002, 2004, 2006,
+dnl   2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+dnl
+dnl This file is part of GUILE
+dnl
+dnl GUILE is free software; you can redistribute it and/or modify it under
+dnl the terms of the GNU Lesser General Public License as published by the
+dnl Free Software Foundation; either version 3, or (at your option) any
+dnl later version.
+dnl
+dnl GUILE is distributed in the hope that it will be useful, but WITHOUT
+dnl ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+dnl FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
+dnl License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with GUILE; see the file COPYING.LESSER.  If not, write
+dnl to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
+dnl Floor, Boston, MA 02110-1301, USA.
+
+
 dnl  On the NeXT, #including <utime.h> doesn't give you a definition for
 dnl  struct utime, unless you #define _POSIX_SOURCE.
 
@@ -55,7 +78,7 @@ AC_DEFUN([GUILE_HEADER_LIBC_WITH_UNISTD],
       ]
     )
     if test "$guile_cv_header_libc_with_unistd" = yes; then
-      AC_DEFINE(LIBC_H_WITH_UNISTD_H, 1,
+      AC_DEFINE([LIBC_H_WITH_UNISTD_H], 1,
         [Define this if we should include <libc.h> when we've already
          included <unistd.h>.  On some systems, they conflict, and libc.h
          should be omitted.  See GUILE_HEADER_LIBC_WITH_UNISTD in
@@ -265,7 +288,7 @@ if test "x$acx_pthread_ok" = xyes; then
         done
         AC_MSG_RESULT($attr_name)
         if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
-            AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+            AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], $attr_name,
                                [Define to necessary symbol if this constant
                                 uses a non-standard name on your system.])
         fi
@@ -300,7 +323,7 @@ AC_SUBST(PTHREAD_CC)
 
 # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
 if test x"$acx_pthread_ok" = xyes; then
-        ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+        ifelse([$1],,AC_DEFINE([HAVE_PTHREAD],1,[Define if you have POSIX threads libraries and header files.]),[$1])
         :
 else
         acx_pthread_ok=no
@@ -308,3 +331,139 @@ else
 fi
 AC_LANG_RESTORE
 ])dnl ACX_PTHREAD
+
+dnl GUILE_GNU_LD_RELRO
+dnl
+dnl Check whether GNU ld's read-only relocations (the `PT_GNU_RELRO'
+dnl ELF segment header) are supported.  This allows things like
+dnl statically allocated cells (1) to eventually be remapped read-only
+dnl by the loader, and (2) to be identified as pointerless by the
+dnl garbage collector.  Substitute `GNU_LD_FLAGS' with the relevant
+dnl flags.
+AC_DEFUN([GUILE_GNU_LD_RELRO], [
+  AC_MSG_CHECKING([whether the linker understands `-z relro'])
+
+  GNU_LD_FLAGS="-Wl,-z -Wl,relro"
+
+  save_LDFLAGS="$LDFLAGS"
+  LDFLAGS="$LDFLAGS $GNU_LD_FLAGS"
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])],
+    [AC_MSG_RESULT([yes])],
+    [AC_MSG_RESULT([no])
+     GNU_LD_FLAGS=""])
+  LDFLAGS="$save_LDFLAGS"
+
+  AC_SUBST([GNU_LD_FLAGS])
+])
+
+dnl GUILE_THREAD_LOCAL_STORAGE
+dnl
+dnl Check for compiler thread-local storage (TLS) support.
+AC_DEFUN([GUILE_THREAD_LOCAL_STORAGE], [
+  AC_CACHE_CHECK([whether the `__thread' storage class is available],
+    [ac_cv_have_thread_storage_class],
+    [dnl On some systems, e.g., NetBSD 5.0 with GCC 4.1, `__thread' is
+     dnl properly compiled but fails to link due to the lack of TLS
+     dnl support in the C library.  Thus we try to link, not just
+     dnl compile.  Unfortunately, this test is not enough, so we
+     dnl explicitly check for known-broken systems.  See
+     dnl http://lists.gnu.org/archive/html/guile-devel/2009-10/msg00138.html
+     dnl for details.
+     dnl
+     dnl Known broken systems includes:
+     dnl   - x86_64-unknown-netbsd5.0.
+     dnl   - sparc-sun-solaris2.8
+     case "x$enable_shared--$host" in
+       xyes--*netbsd[0-5].[0-9].|xyes--*solaris2.8)
+         ac_cv_have_thread_storage_class="no"
+        ;;
+       *)
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([__thread int tls_integer;],
+                         [tls_integer = 123;])],
+          [ac_cv_have_thread_storage_class="yes"],
+          [ac_cv_have_thread_storage_class="no"])
+        ;;
+     esac])
+
+  if test "x$ac_cv_have_thread_storage_class" = "xyes"; then
+     SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS=1
+  else
+     SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS=0
+  fi
+
+  AC_SUBST([SCM_I_GSC_HAVE_THREAD_STORAGE_CLASS])
+])
+
+dnl GUILE_READLINE
+dnl
+dnl Check all the things needed by `guile-readline', the Readline
+dnl bindings.
+AC_DEFUN([GUILE_READLINE], [
+  for termlib in ncurses curses termcap terminfo termlib pdcurses ; do
+     AC_CHECK_LIB(${termlib}, [tgoto],
+       [READLINE_LIBS="-l${termlib} $READLINE_LIBS"; break])
+  done
+
+  AC_LIB_LINKFLAGS([readline])
+
+  if test "x$LTLIBREADLINE" = "x"; then
+    AC_MSG_WARN([GNU Readline was not found on your system.])
+  else
+    rl_save_LIBS="$LIBS"
+    LIBS="$LIBREADLINE $READLINE_LIBS $LIBS"
+
+    AC_CHECK_FUNCS([siginterrupt rl_clear_signals rl_cleanup_after_signal])
+
+    dnl Check for modern readline naming
+    AC_CHECK_FUNCS([rl_filename_completion_function])
+    AC_CHECK_DECLS([rl_catch_signals, rl_catch_sigwinch], [], [],
+                   [[#include <stdio.h>]
+                    [#include <readline/readline.h>]])
+
+    dnl Check for rl_get_keymap.  We only use this for deciding whether to
+    dnl install paren matching on the Guile command line (when using
+    dnl readline for input), so it's completely optional.
+    AC_CHECK_FUNCS([rl_get_keymap])
+
+    AC_CACHE_CHECK([for rl_getc_function pointer in readline],
+                    ac_cv_var_rl_getc_function,
+                    [AC_TRY_LINK([
+    #include <stdio.h>
+    #include <readline/readline.h>],
+                                 [printf ("%ld", (long) rl_getc_function)],
+                                 [ac_cv_var_rl_getc_function=yes],
+                                 [ac_cv_var_rl_getc_function=no])])
+    if test "${ac_cv_var_rl_getc_function}" = "yes"; then
+      AC_DEFINE([HAVE_RL_GETC_FUNCTION], 1,
+       [Define if your readline library has the rl_getc_function variable.])
+    fi
+
+    if test $ac_cv_var_rl_getc_function = no; then
+      AC_MSG_WARN([*** GNU Readline is too old on your system.])
+      AC_MSG_WARN([*** You need readline version 2.1 or later.])
+      LTLIBREADLINE=""
+      LIBREADLINE=""
+    fi
+
+    LIBS="$rl_save_LIBS"
+
+    READLINE_LIBS="$LTLIBREADLINE $READLINE_LIBS"
+  fi
+
+  AM_CONDITIONAL([HAVE_READLINE], [test "x$LTLIBREADLINE" != "x"])
+
+  AC_CHECK_FUNCS([strdup])
+
+  AC_SUBST([READLINE_LIBS])
+
+  . $srcdir/guile-readline/LIBGUILEREADLINE-VERSION
+  AC_SUBST(LIBGUILEREADLINE_MAJOR)
+  AC_SUBST(LIBGUILEREADLINE_INTERFACE_CURRENT)
+  AC_SUBST(LIBGUILEREADLINE_INTERFACE_REVISION)
+  AC_SUBST(LIBGUILEREADLINE_INTERFACE_AGE)
+  AC_SUBST(LIBGUILEREADLINE_INTERFACE)
+])
+
+dnl Declare file $1 to be a script that needs configuring,
+dnl and arrange to make it executable in the process.
+AC_DEFUN([GUILE_CONFIG_SCRIPT],[AC_CONFIG_FILES([$1],[chmod +x $1])])