build: Bail out when 'PKG_CHECK_MODULES' is missing.
[bpt/guile.git] / configure.ac
index 0211996..e99b272 100644 (file)
@@ -5,7 +5,7 @@ dnl
 define(GUILE_CONFIGURE_COPYRIGHT,[[
 
 Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
-  2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+  2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
 
 This file is part of GUILE
 
@@ -29,13 +29,17 @@ Floor, Boston, MA 02110-1301, USA.
 AC_PREREQ(2.61)
 
 AC_INIT([GNU Guile],
-        m4_esyscmd([build-aux/git-version-gen .tarball-version]),
+        m4_esyscmd([build-aux/git-version-gen --match v2.0.\* .tarball-version]),
         [bug-guile@gnu.org])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_SRCDIR(GUILE-VERSION)
 
-AM_INIT_AUTOMAKE([gnu no-define -Wall -Wno-override])
+dnl Use `serial-tests' so the output `check-guile' is not hidden
+dnl (`parallel-tests' is the default in Automake 1.13.)
+dnl `serial-tests' was introduced in Automake 1.12.
+AM_INIT_AUTOMAKE([1.12 gnu no-define -Wall -Wno-override \
+  serial-tests color-tests dist-xz])
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY],1)])
 
 AC_COPYRIGHT(GUILE_CONFIGURE_COPYRIGHT)
@@ -47,6 +51,10 @@ GUILE_VERSION="$PACKAGE_VERSION"
 AC_CONFIG_HEADERS([config.h])
 AH_TOP(/*GUILE_CONFIGURE_COPYRIGHT*/)
 
+dnl We require the pkg.m4 set of macros from pkg-config.
+dnl Make sure it's available.
+m4_pattern_forbid([PKG_CHECK_MODULES])
+
 #--------------------------------------------------------------------
 
 AC_LANG([C])
@@ -63,13 +71,10 @@ AC_PROG_CPP
 AC_PROG_SED
 AC_PROG_AWK
 AC_PROG_LN_S
+AM_PROG_AR
 
 dnl Gnulib.
 gl_INIT
-dnl FIXME: remove me and the acinclude.m4 code when clock-gettime is
-dnl fixed for clock_getcpuclockid and can be imported normally from
-dnl gnulib.
-gl_CLOCK_TIME
 
 AC_PROG_CC_C89
 
@@ -81,10 +86,6 @@ AC_PROG_LIBTOOL
 
 AM_CONDITIONAL([HAVE_SHARED_LIBRARIES], [test "x$enable_shared" = "xyes"])
 
-AC_DEFINE_UNQUOTED([SHARED_LIBRARY_PATH_VARIABLE], ["$shlibpath_var"],
-  [Name of the environment variable that tells the dynamic linker where
-to find shared libraries.])
-
 dnl Check for libltdl.
 AC_LIB_HAVE_LINKFLAGS([ltdl], [], [#include <ltdl.h>],
   [lt_dlopenext ("foo");])
@@ -232,6 +233,8 @@ dnl files which are destined for separate modules.
 
 if test "$use_modules" != no; then
    AC_LIBOBJ([dynl])
+   AC_DEFINE([HAVE_MODULES], 1,
+     [Define this if you want support for dynamically loaded modules in Guile.])
 fi
 
 if test "$enable_posix" = yes; then
@@ -647,24 +650,14 @@ 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
 #   sched.h - missing on MinGW
+#   sys/sendfile.h - non-POSIX, found in glibc
 #
-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 \
+AC_CHECK_HEADERS([complex.h fenv.h io.h libc.h limits.h memory.h process.h string.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 poll.h sched.h])
-
-# Reasons for testing:
-#   nl_item - lacking on Cygwin
-AC_CHECK_TYPES([nl_item], [], [],
-  [[#ifdef HAVE_LANGINFO_H
-    # include <langinfo.h>
-    #endif
-    #ifdef HAVE_NL_TYPES_H
-    # include <nl_types.h>
-    #endif]])
+direct.h machine/fpu.h sched.h sys/sendfile.h])
 
 # "complex double" is new in C99, and "complex" is only a keyword if
 # <complex.h> is included
@@ -717,9 +710,6 @@ case $host in
       [Define if you have the <winsock2.h> header file.])])
     AC_CHECK_LIB(ws2_32, main)
     AC_LIBOBJ([win32-uname])
-    if test "$enable_networking" = yes ; then
-      AC_LIBOBJ([win32-socket])
-    fi
     if test "$enable_shared" = yes ; then
       EXTRA_DEFS="-DSCM_IMPORT"
       AC_DEFINE([USE_DLL_IMPORT], 1,
@@ -748,9 +738,6 @@ AC_CHECK_HEADERS([assert.h crt_externs.h])
 #               has it as an inline for chsize)
 #   ioctl - not in mingw.
 #   gmtime_r - recent posix, not on old systems
-#   pipe - not in mingw
-#   _pipe - specific to mingw, taking 3 args
-#   poll - since posix 2001
 #   readdir_r - recent posix, not on old systems
 #   readdir64_r - not available on HP-UX 11.11
 #   stat64 - SuS largefile stuff, not on old systems
@@ -759,17 +746,32 @@ 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
-#   sched_getaffinity, sched_setaffinity: GNU extensions (glibc)
+#   fork - unavailable on Windows
+#   utimensat - posix.1-2008
+#   sched_getaffinity, sched_setaffinity - GNU extensions (glibc)
+#   sendfile - non-POSIX, found in glibc
 #
-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 poll 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 sched_getaffinity sched_setaffinity])
+AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid                \
+  fesetround ftime ftruncate fchown fchmod getcwd geteuid getsid       \
+  gettimeofday gmtime_r ioctl lstat mkdir mknod nice                   \
+  readdir_r readdir64_r readlink rename rmdir setegid seteuid          \
+  setlocale setpgid setsid sigaction siginterrupt stat64               \
+  strptime symlink sync sysconf tcgetpgrp tcsetpgrp 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 sched_getaffinity              \
+  sched_setaffinity sendfile])
+
+AM_CONDITIONAL([BUILD_ICE_9_POPEN],
+  [test "x$enable_posix" = "xyes" && test "x$ac_cv_func_fork" = "xyes"])
 
 # Reasons for testing:
 #   netdb.h - not in mingw
 #   sys/param.h - not in mingw
 #   pthread.h - only available with pthreads.  ACX_PTHREAD doesn't
 #       check this specifically, we need it for the timespec test below.
+#   pthread_np.h - available on FreeBSD
 #   sethostname - the function itself check because it's not in mingw,
 #       the DECL is checked because Solaris 10 doens't have in any header
 #   hstrerror - on Tru64 5.1b the symbol is available in libc but the
@@ -777,7 +779,7 @@ AC_CHECK_FUNCS([DINFINITY DQNAN cexp chsize clog clog10 ctermid fesetround ftime
 #   cuserid - on Tru64 5.1b the declaration is documented to be available
 #       only with `_XOPEN_SOURCE' or some such.
 #
-AC_CHECK_HEADERS([crypt.h netdb.h pthread.h sys/param.h sys/resource.h sys/file.h sys/mman.h])
+AC_CHECK_HEADERS([crypt.h netdb.h pthread.h pthread_np.h sys/param.h sys/resource.h sys/file.h sys/mman.h])
 AC_CHECK_FUNCS(chroot flock getlogin cuserid getpriority setpriority getpass sethostname gethostname)
 AC_CHECK_DECLS([sethostname, hstrerror, cuserid])
 
@@ -873,6 +875,14 @@ if test "x$HAVE_LIBGMP" != "xyes"; then
   AC_MSG_ERROR([GNU MP 4.1 or greater not found, see README])
 fi
 
+dnl `mpz_inits' and `mpz_clears' appeared in GMP 5.0.0.
+save_CPPFLAGS="$CPPFLAGS"
+if test "x$LIBGMP_PREFIX" != "x"; then
+   CPPFLAGS="-I$LIBGMP_PREFIX $CPPFLAGS"
+fi
+AC_CHECK_DECLS([mpz_inits], [], [], [[#include <gmp.h>]])
+CPPFLAGS="$save_CPPFLAGS"
+
 dnl GNU libunistring is checked for by Gnulib's `libunistring' module.
 if test "x$LTLIBUNISTRING" = "x"; then
   AC_MSG_ERROR([GNU libunistring is required, please install it.])
@@ -929,6 +939,8 @@ AC_DEFUN([GUILE_FUNC_DECLARED], [
 GUILE_FUNC_DECLARED(sleep, unistd.h)
 GUILE_FUNC_DECLARED(usleep, unistd.h)
 
+AC_CHECK_DECLS([getlogin, alarm])
+
 AC_CHECK_DECLS([strptime],,,
 [#define _GNU_SOURCE /* ask glibc to give strptime prototype */
 #include <time.h>])
@@ -1106,24 +1118,8 @@ if test $guile_cv_localtime_cache = yes; then
 fi
 
 if test "$enable_regex" = yes; then
-   if test "$ac_cv_header_regex_h" = yes ||
-      test "$ac_cv_header_rxposix_h" = yes ||
-      test "$ac_cv_header_rx_rxposix_h" = yes; then
-     GUILE_NAMED_CHECK_FUNC(regcomp, norx, [AC_LIBOBJ([regex-posix])],
-     [AC_CHECK_LIB(rx, main)
-      GUILE_NAMED_CHECK_FUNC(regcomp, rx, [AC_LIBOBJ([regex-posix])],
-     [AC_CHECK_LIB(regex, main)
-      GUILE_NAMED_CHECK_FUNC(regcomp, regex, [AC_LIBOBJ([regex-posix])])])]
-     )
-     dnl The following should not be necessary, but for some reason
-     dnl autoheader misses it if we don't include it!
-     if test "$ac_cv_func_regcomp_norx" = yes ||
-        test "$ac_cv_func_regcomp_regex" = yes ||
-        test "$ac_cv_func_regcomp_rx" = yes; then
-       AC_DEFINE([HAVE_REGCOMP], 1,
-         [This is included as part of a workaround for a autoheader bug.])
-     fi
-   fi
+   AC_LIBOBJ([regex-posix])
+   AC_DEFINE([ENABLE_REGEX], 1, [Define when regex support is enabled.])
 fi
 
 AC_REPLACE_FUNCS([strerror memmove mkstemp])
@@ -1209,7 +1205,7 @@ GUILE_UNISTRING_ICONVEH_VALUES
 #
 # Which way does the stack grow?
 #
-# Following code comes from Autoconf 2.61's internal _AC_LIBOBJ_ALLOCA
+# Following code comes from Autoconf 2.69's internal _AC_LIBOBJ_ALLOCA
 # macro (/usr/share/autoconf/autoconf/functions.m4).  Gnulib has
 # very similar code, so in future we could look at using that.
 #
@@ -1224,23 +1220,20 @@ SCM_I_GSC_STACK_GROWS_UP=0
 AC_RUN_IFELSE([AC_LANG_SOURCE(
 [AC_INCLUDES_DEFAULT
 int
-find_stack_direction ()
+find_stack_direction (int *addr, int depth)
 {
-  static char *addr = 0;
-  auto char dummy;
-  if (addr == 0)
-    {
-      addr = &dummy;
-      return find_stack_direction ();
-    }
-  else
-    return (&dummy > addr) ? 1 : -1;
+  int dir, dummy = 0;
+  if (! addr)
+    addr = &dummy;
+  *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1;
+  dir = depth ? find_stack_direction (addr, depth - 1) : 0;
+  return dir + dummy;
 }
 
 int
-main ()
+main (int argc, char **argv)
 {
-  return find_stack_direction () < 0;
+  return find_stack_direction (0, argc + !argv + 20) < 0;
 }])],
               [SCM_I_GSC_STACK_GROWS_UP=1],
               [],
@@ -1257,7 +1250,12 @@ save_LIBS="$LIBS"
 LIBS="$BDW_GC_LIBS $LIBS"
 CFLAGS="$BDW_GC_CFLAGS $CFLAGS"
 
-AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit GC_pthread_cancel GC_allow_register_threads GC_pthread_sigmask GC_set_start_callback])
+AC_CHECK_FUNCS([GC_do_blocking GC_call_with_gc_active GC_pthread_exit  \
+  GC_pthread_cancel GC_allow_register_threads GC_pthread_sigmask       \
+  GC_set_start_callback GC_get_heap_usage_safe                         \
+  GC_get_free_space_divisor GC_gcollect_and_unmap GC_get_unmapped_bytes        \
+  GC_set_finalizer_notifier GC_set_finalize_on_demand                  \
+  GC_set_all_interior_pointers GC_get_gc_no GC_set_java_finalization])
 
 # Though the `GC_do_blocking ()' symbol is present in GC 7.1, it is not
 # declared, and has a different type (returning void instead of
@@ -1307,8 +1305,11 @@ if test $scm_cv_struct_linger = yes; then
 fi
 
 
-# On mingw, struct timespec is in <pthread.h>.
-#
+dnl Check for `struct timespec', for the sake of `gen-scmconfig'.  When
+dnl building Guile, we always have it, thanks to Gnulib; but scmconfig.h
+dnl must tell whether the system has it.
+dnl
+dnl On MinGW, struct timespec is in <pthread.h>.
 AC_MSG_CHECKING(for struct timespec)
 AC_CACHE_VAL(scm_cv_struct_timespec,
        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@@ -1320,7 +1321,9 @@ AC_CACHE_VAL(scm_cv_struct_timespec,
           [scm_cv_struct_timespec="no"]))
 AC_MSG_RESULT($scm_cv_struct_timespec)
 if test $scm_cv_struct_timespec = yes; then
-  AC_DEFINE([HAVE_STRUCT_TIMESPEC], 1,
+  dnl Don't call it `HAVE_STRUCT_TIMESPEC' because pthread-win32's
+  dnl <pthread.h> checks whether that macro is defined.
+  AC_DEFINE([HAVE_SYSTEM_STRUCT_TIMESPEC], 1,
     [Define this if your system defines struct timespec via either <time.h> or <pthread.h>.])
 fi
 
@@ -1362,9 +1365,11 @@ case "$with_threads" in
     #         all; not present on MacOS X or Solaris 10
     #     pthread_get_stackaddr_np - "np" meaning "non portable" says it
     #         all; specific to MacOS X
+    #     pthread_attr_get_np - "np" meaning "non portable" says it
+    #         all; specific to FreeBSD
     #     pthread_sigmask - not available on mingw
     #
-    AC_CHECK_FUNCS(pthread_attr_getstack pthread_getattr_np pthread_get_stackaddr_np pthread_sigmask)
+    AC_CHECK_FUNCS(pthread_attr_getstack pthread_getattr_np pthread_get_stackaddr_np pthread_attr_get_np pthread_sigmask)
 
     # On past versions of Solaris, believe 8 through 10 at least, you
     # had to write "pthread_once_t foo = { PTHREAD_ONCE_INIT };".
@@ -1509,20 +1514,7 @@ AC_SUBST(CCLD_FOR_BUILD)
 HOST_CC="$CC_FOR_BUILD"
 AC_SUBST(HOST_CC)
 
-if test "$cross_compiling" = "yes"; then
-  AC_MSG_CHECKING(guile for build)
-  GUILE_FOR_BUILD="${GUILE_FOR_BUILD-guile}"
-else
-  GUILE_FOR_BUILD='this-value-will-never-be-used'
-fi   
-
-## AC_MSG_CHECKING("if we are cross compiling")
-## AC_MSG_RESULT($cross_compiling)
-if test "$cross_compiling" = "yes"; then
-   AC_MSG_RESULT($GUILE_FOR_BUILD)
-fi
-AC_ARG_VAR(GUILE_FOR_BUILD,[guile for build system])
-AM_SUBST_NOTMAKE(GUILE_FOR_BUILD)
+GUILE_CHECK_GUILE_FOR_BUILD
                        
 ## If we're using GCC, ask for aggressive warnings.
 GCC_CFLAGS=""
@@ -1531,13 +1523,16 @@ 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.
-    ## -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).
     ## -Wundef was removed because Gnulib prevented it (see
     ## <http://thread.gmane.org/gmane.lisp.guile.bugs/5329>.)
+
+    ## Build with `-fno-strict-aliasing' to prevent miscompilation on
+    ## some platforms.  See
+    ## <http://lists.gnu.org/archive/html/guile-devel/2012-01/msg00487.html>.
+
     POTENTIAL_GCC_CFLAGS="-Wall -Wmissing-prototypes \
-      -Wdeclaration-after-statement \
-      -Wswitch-enum"
+      -Wdeclaration-after-statement -Wpointer-arith \
+      -Wswitch-enum -fno-strict-aliasing"
     # Do this here so we don't screw up any of the tests above that might
     # not be "warning free"
     if test "${GUILE_ERROR_ON_WARNING}" = yes
@@ -1559,10 +1554,11 @@ AC_SUBST(GCC_CFLAGS)
 GUILE_GNU_LD_RELRO
 
 
-## If we're creating a shared library (using libtool!), then we'll
-## need to generate a list of .lo files corresponding to the .o files
-## given in LIBOBJS.  We'll call it LIBLOBJS.
-LIBLOBJS="`echo ${LIB@&t@OBJS} | sed 's,\.[[^.]]* ,.lo ,g;s,\.[[^.]]*$,.lo,'`"
+LIBLOBJS=""
+for file in $LIBOBJS; do
+  file=`echo "$file" | sed 's,\.[[^.]]*$,.lo,'`
+  LIBLOBJS="$LIBLOBJS libguile_${GUILE_EFFECTIVE_VERSION}_la-$file"
+done
 
 ## We also need to create corresponding .doc and .x files
 EXTRA_DOT_DOC_FILES="`echo ${LIB@&t@OBJS} | sed 's,\.[[^.]]* ,.doc ,g;s,\.[[^.]]*$,.doc,'`"
@@ -1634,6 +1630,10 @@ pkgdatadir="$datadir/$PACKAGE_TARNAME"
 sitedir="$pkgdatadir/site/$GUILE_EFFECTIVE_VERSION"
 AC_SUBST([sitedir])
 
+dnl Name of the `guile' program.
+guile_program_name="`echo guile | "$SED" "$program_transform_name"`"
+AC_SUBST([guile_program_name])
+
 # Additional SCM_I_GSC definitions are above.
 AC_SUBST([SCM_I_GSC_GUILE_DEBUG])
 AC_SUBST([SCM_I_GSC_ENABLE_DEPRECATED])
@@ -1664,7 +1664,6 @@ AC_CONFIG_FILES([
 
 AC_CONFIG_FILES([meta/guile-2.0.pc])
 AC_CONFIG_FILES([meta/guile-2.0-uninstalled.pc])
-AC_CONFIG_FILES([doc/ref/effective-version.texi])
 
 GUILE_CONFIG_SCRIPT([check-guile])
 GUILE_CONFIG_SCRIPT([benchmark-guile])