Change make license
[platform/upstream/make.git] / configure.ac
index d73dd8c..bfb450d 100644 (file)
@@ -1,6 +1,6 @@
 # Process this file with autoconf to produce a configure script.
 #
-# Copyright (C) 1993-2013 Free Software Foundation, Inc.
+# Copyright (C) 1993-2020 Free Software Foundation, Inc.
 # This file is part of GNU Make.
 #
 # GNU Make is free software; you can redistribute it and/or modify it under
 # You should have received a copy of the GNU General Public License along with
 # this program.  If not, see <http://www.gnu.org/licenses/>.
 
-AC_INIT([GNU make],[4.0],[bug-make@gnu.org])
+AC_INIT([GNU make],[4.3],[bug-make@gnu.org])
 
-AC_PREREQ([2.62])
+AC_PREREQ([2.69])
 
 # Autoconf setup
-AC_CONFIG_AUX_DIR([config])
-AC_CONFIG_SRCDIR([vpath.c])
-AC_CONFIG_HEADERS([config.h])
+AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_SRCDIR([src/vpath.c])
+AC_CONFIG_HEADERS([src/config.h])
+
+AC_CONFIG_LIBOBJ_DIR([lib])
 
 # Automake setup
-AM_INIT_AUTOMAKE([1.11.1 silent-rules])
+# We have to enable "foreign" because ChangeLog is auto-generated
+# Automake 1.15 and gnulib don't get along: gnulib has some strange error
+# in the way it handles getloadavg.c which causes make distcheck to fail.
+# http://lists.gnu.org/archive/html/bug-gnulib/2018-06/msg00024.html
+AM_INIT_AUTOMAKE([1.15.1 foreign -Werror -Wall])
 
 # Checks for programs.
+AC_USE_SYSTEM_EXTENSIONS
 AC_PROG_CC
+
+# Configure gnulib
+gl_EARLY
+gl_INIT
+
 AC_PROG_INSTALL
 AC_PROG_RANLIB
 AC_PROG_CPP
@@ -42,10 +54,10 @@ AC_CANONICAL_HOST
 AC_AIX
 AC_ISC_POSIX
 AC_MINIX
+AC_C_BIGENDIAN
 
 # Enable gettext, in "external" mode.
-
-AM_GNU_GETTEXT_VERSION([0.18.1])
+AM_GNU_GETTEXT_VERSION([0.19.4])
 AM_GNU_GETTEXT([external])
 
 # This test must come as early as possible after the compiler configuration
@@ -62,22 +74,18 @@ AC_HEADER_DIRENT
 AC_HEADER_STAT
 AC_HEADER_TIME
 AC_CHECK_HEADERS([stdlib.h locale.h unistd.h limits.h fcntl.h string.h \
-                  memory.h sys/param.h sys/resource.h sys/time.h sys/timeb.h])
+                  memory.h sys/param.h sys/resource.h sys/time.h sys/timeb.h \
+                  sys/select.h sys/file.h spawn.h])
 
 AM_PROG_CC_C_O
 AC_C_CONST
 AC_TYPE_SIGNAL
 AC_TYPE_UID_T
 AC_TYPE_PID_T
-
-# Find some definition for uintmax_t
-
-AC_CHECK_TYPE([uintmax_t],[],
-[ uintmax_t="unsigned long"
-  AC_CHECK_TYPE([unsigned long long],[uintmax_t="unsigned long long"])
-  AC_DEFINE_UNQUOTED([uintmax_t], [$uintmax_t],
-    [Define uintmax_t if not defined in <stdint.h> or <inttypes.h>.])
-])
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_TYPE_UINTMAX_T
 
 # Find out whether our struct stat returns nanosecond resolution timestamps.
 
@@ -119,8 +127,8 @@ AC_CACHE_CHECK([for standard gettimeofday], [ac_cv_func_gettimeofday],
                   int main ()
                   {
                     struct timeval t; t.tv_sec = -1; t.tv_usec = -1;
-                    exit (gettimeofday (&t, 0) != 0
-                          || t.tv_sec < 0 || t.tv_usec < 0);
+                    return gettimeofday (&t, 0) != 0
+                          || t.tv_sec < 0 || t.tv_usec < 0;
                   }]])],
                   [ac_cv_func_gettimeofday=yes],
                   [ac_cv_func_gettimeofday=no],
@@ -130,11 +138,12 @@ AS_IF([test "$ac_cv_func_gettimeofday" = yes],
             [Define to 1 if you have a standard gettimeofday function])
 ])
 
-AC_CHECK_FUNCS([strdup strndup mkstemp mktemp fdopen fileno \
+AC_CHECK_FUNCS([strdup strndup memrchr umask mkstemp mktemp fdopen \
                 dup dup2 getcwd realpath sigsetmask sigaction \
                 getgroups seteuid setegid setlinebuf setreuid setregid \
-                getrlimit setrlimit setvbuf pipe strerror strsignal \
-                lstat readlink atexit])
+                getrlimit setrlimit setvbuf pipe strsignal \
+                lstat readlink atexit isatty ttyname pselect posix_spawn \
+                posix_spawnattr_setsigmask])
 
 # We need to check declarations, not just existence, because on Tru64 this
 # function is not declared without special flags, which themselves cause
@@ -142,6 +151,8 @@ AC_CHECK_FUNCS([strdup strndup mkstemp mktemp fdopen fileno \
 AC_CHECK_DECLS([bsd_signal], [], [], [[#define _GNU_SOURCE 1
 #include <signal.h>]])
 
+AC_FUNC_FORK
+
 AC_FUNC_SETVBUF_REVERSED
 
 # Rumor has it that strcasecmp lives in -lresolv on some odd systems.
@@ -151,47 +162,44 @@ AC_CHECK_FUNCS([strcasecmp strncasecmp strcmpi strncmpi stricmp strnicmp])
 
 # strcoll() is used by the GNU glob library
 AC_FUNC_STRCOLL
-
-AC_FUNC_ALLOCA
 AC_FUNC_CLOSEDIR_VOID
 
+# dir.c and our glob.c use dirent.d_type if available
+AC_STRUCT_DIRENT_D_TYPE
+
 # See if the user wants to add (or not) GNU Guile support
-PKG_PROG_PKG_CONFIG
 AC_ARG_WITH([guile], [AS_HELP_STRING([--with-guile],
             [Support GNU Guile for embedded scripting])])
 
-# For some strange reason, at least on Ubuntu, each version of Guile
-# comes with it's own PC file so we have to specify them as individual
-# packages.  Ugh.
-AS_IF([test "x$with_guile" != xno],
-[ PKG_CHECK_MODULES([GUILE], [guile-2.0], [have_guile=yes],
-  [PKG_CHECK_MODULES([GUILE], [guile-1.8], [have_guile=yes],
-    [have_guile=no])])
-])
-
-AS_IF([test "$have_guile" = yes],
-      [AC_DEFINE([HAVE_GUILE], [1], [Embed GNU Guile support])])
-
-AM_CONDITIONAL([HAVE_GUILE], [test "$have_guile" = yes])
-
-AC_FUNC_GETLOADAVG
-
-# AC_FUNC_GETLOADAVG is documented to set the NLIST_STRUCT value, but it
-# doesn't.  So, we will.
+# Annoyingly, each version of Guile comes with it's own PC file so we have to
+# specify them as individual packages.  Ugh.
+PKG_PROG_PKG_CONFIG
 
-AS_IF([test "$ac_cv_header_nlist_h" = yes],
-[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <nlist.h>]],
-        [[struct nlist nl;
-          nl.n_name = "string";
-          return 0;]])],
-        [make_cv_nlist_struct=yes],
-        [make_cv_nlist_struct=no])
-  AS_IF([test "$make_cv_nlist_struct" = yes],
-  [ AC_DEFINE([NLIST_STRUCT], [1],
-       [Define to 1 if struct nlist.n_name is a pointer rather than an array.])
+AS_IF([test "x$with_guile" != xno],
+[ guile_versions="3.0 2.2 2.0 1.8"
+  guile_version=no
+  have_guile=no
+  AC_MSG_CHECKING([for GNU Guile])
+  for v in $guile_versions; do
+    PKG_CHECK_EXISTS([guile-$v], [guile_version=$v; have_guile=yes; break], [])
+  done
+  AC_MSG_RESULT([$guile_version])
+  AS_IF([test "$have_guile" = yes],
+  [ PKG_CHECK_MODULES(GUILE, [guile-$guile_version])
+    # Unfortunately Guile requires a C99 compiler but GNU make doesn't, so
+    # verify we can actually compile the header.
+    keep_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS $pkg_cv_GUILE_CFLAGS"
+    AC_CHECK_HEADER([libguile.h],
+                    [AC_DEFINE([HAVE_GUILE], [1], [Embed GNU Guile support])],
+                    [have_guile=no],
+                    [/* Avoid configuration error warnings. */])
+    CPPFLAGS="$keep_CPPFLAGS"
   ])
 ])
 
+AM_CONDITIONAL([HAVE_GUILE], [test "$have_guile" = "yes"])
+
 AC_CHECK_DECLS([sys_siglist, _sys_siglist, __sys_siglist], , ,
   [AC_INCLUDES_DEFAULT
 #include <signal.h>
@@ -243,8 +251,8 @@ AS_IF([test "$PATH_SEPARATOR" = ';'],
 AC_SUBST([REMOTE]) REMOTE=stub
 use_customs=false
 AC_ARG_WITH([customs],
-[ AC_HELP_STRING([--with-customs=DIR],
-                 [enable remote jobs via Customs--see README.customs])],
+[AC_HELP_STRING([--with-customs=DIR],
+                [enable remote jobs via Customs--see README.customs])],
 [ AS_CASE([$withval], [n|no], [:],
     [make_cppflags="$CPPFLAGS"
      AS_CASE([$withval],
@@ -317,20 +325,20 @@ AC_ARG_ENABLE([load],
   [make_cv_load="$enableval" user_load="$enableval"],
   [make_cv_load="yes"])
 
-AS_CASE([/$ac_cv_func_dlopen/$ac_cv_func_dlsym/$ac_cv_func_dlerror/],
+AS_CASE([/$ac_cv_have_decl_dlopen/$ac_cv_have_decl_dlsym/$ac_cv_have_decl_dlerror/],
   [*/no/*], [make_cv_load=no])
 
+# We might need -ldl
+AS_IF([test "$make_cv_load" = yes], [
+  AC_SEARCH_LIBS([dlopen], [dl], [], [make_cv_load=])
+  ])
+
 AS_CASE([/$make_cv_load/$user_load/],
   [*/no/*], [make_cv_load=no],
   [AC_DEFINE(MAKE_LOAD, 1,
              [Define to 1 to enable 'load' support in GNU make.])
   ])
 
-# We might need -ldl
-AS_IF([test "$make_cv_load" = yes], [
-  AC_SEARCH_LIBS([dlopen], [dl], [], [make_cv_load=])
-  ])
-
 # If we want load support, we might need to link with export-dynamic.
 # See if we can figure it out.  Unfortunately this is very difficult.
 # For example passing -rdynamic to the SunPRO linker gives a warning
@@ -360,6 +368,43 @@ AS_IF([test "$ac_cv_func_lstat" = yes && test "$ac_cv_func_readlink" = yes],
               [Define to 1 to enable symbolic link timestamp checking.])
 ])
 
+# Use posix_spawn if we have support and the user didn't disable it
+
+AC_ARG_ENABLE([posix-spawn],
+  AC_HELP_STRING([--disable-posix-spawn],
+                 [disable support for posix_spawn()]),
+  [make_cv_posix_spawn="$enableval" user_posix_spawn="$enableval"],
+  [make_cv_posix_spawn="yes"])
+
+AS_CASE([/$ac_cv_header_spawn/$ac_cv_func_posix_spawn/],
+  [*/no/*], [make_cv_posix_spawn=no])
+
+AS_IF([test "$make_cv_posix_spawn" = yes],
+  AC_CACHE_CHECK([for posix_spawn that fails synchronously],
+    [make_cv_synchronous_posix_spawn],
+    [make_cv_synchronous_posix_spawn=no
+     AC_RUN_IFELSE([AC_LANG_SOURCE([[
+       #include <spawn.h>
+       #include <string.h>
+
+       extern char **environ;
+
+       int main() {
+         char* path = strdup("./non-existent");
+         char *argv[[2]];
+         argv[[0]] = path;
+         argv[[1]] =  0;
+         return posix_spawn(0, path, 0, 0, argv, environ);
+       }]])],
+       [make_cv_synchronous_posix_spawn=no],
+       [make_cv_synchronous_posix_spawn=yes],
+       [make_cv_synchronous_posix_spawn="no (cross-compiling)"])]))
+
+AS_CASE([/$user_posix_spawn/$make_cv_posix_spawn/$make_cv_synchronous_posix_spawn/],
+  [*/no/*], [make_cv_posix_spawn=no],
+  [AC_DEFINE(USE_POSIX_SPAWN, 1, [Define to 1 to use posix_spawn().])
+  ])
+
 # Find the SCCS commands, so we can include them in our default rules.
 
 AC_CACHE_CHECK([for location of SCCS get command], [make_cv_path_sccs_get], [
@@ -387,33 +432,6 @@ AS_IF([(/usr/sccs/admin -n s.conftest || admin -n s.conftest) >/dev/null 2>&1 &&
 ])
 rm -f s.conftest conftoast
 
-# Check the system to see if it provides GNU glob.  If not, use our
-# local version.
-AC_CACHE_CHECK([if system libc has GNU glob], [make_cv_sys_gnu_glob],
-[ AC_EGREP_CPP([gnu glob],[
-#include <features.h>
-#include <glob.h>
-#include <fnmatch.h>
-
-#define GLOB_INTERFACE_VERSION 1
-#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
-# include <gnu-versions.h>
-# if _GNU_GLOB_INTERFACE_VERSION == GLOB_INTERFACE_VERSION
-   gnu glob
-# endif
-#endif],
-        [make_cv_sys_gnu_glob=yes],
-        [make_cv_sys_gnu_glob=no])])
-AS_IF([test "$make_cv_sys_gnu_glob" = no],
-[ GLOBINC='-I$(srcdir)/glob'
-  GLOBLIB=glob/libglob.a
-])
-AC_SUBST([GLOBINC])
-AC_SUBST([GLOBLIB])
-
-# Tell automake about this, so it can build the right .c files.
-AM_CONDITIONAL([USE_LOCAL_GLOB], [test "$make_cv_sys_gnu_glob" = no])
-
 # Let the makefile know what our build host is
 
 AC_DEFINE_UNQUOTED([MAKE_HOST],["$host"],[Build host information.])
@@ -496,21 +514,22 @@ AS_IF([test "x$make_cv_load" = xno && test "x$user_load" = xyes],
   echo
 ])
 
+AS_IF([test "x$make_cv_posix_spawn" = xno && test "x$user_posix_spawn" = xyes],
+[ echo
+  echo "WARNING: posix_spawn() is not supported on this system."
+  echo
+])
+
 # Specify what files are to be created.
-AC_CONFIG_FILES([Makefile glob/Makefile po/Makefile.in config/Makefile \
-                 doc/Makefile w32/Makefile])
+AC_CONFIG_FILES([Makefile build.cfg lib/Makefile po/Makefile.in doc/Makefile \
+                 tests/config-flags.pm])
+# We don't need this: the standard automake output suffices for POSIX systems.
+#mk/Posix.mk
 
 # OK, do it!
 
 AC_OUTPUT
 
-# We only generate the build.sh if we have a build.sh.in; we won't have
-# one before we've created a distribution.
-AS_IF([test -f "$srcdir/build.sh.in"],
-[ ./config.status --file build.sh
-  chmod +x build.sh
-])
-
 dnl Local Variables:
 dnl comment-start: "dnl "
 dnl comment-end: ""