]> git.ipfire.org Git - thirdparty/make.git/commitdiff
* configure.ac: Add --disable-posix-spawn option
authorPaul Smith <psmith@gnu.org>
Sat, 4 Aug 2018 15:13:57 +0000 (11:13 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 4 Aug 2018 16:37:19 +0000 (12:37 -0400)
* maintMakefile: Add a test for the option
* src/job.c: Change HAVE_* preprocessor checks to USE_POSIX_SPAWN

configure.ac
maintMakefile
src/job.c

index 6155db7c801afc7b043001f5d12eca33befaab94..31a00a657ccff96ebaf863ac34527746983cad3a 100644 (file)
@@ -357,6 +357,22 @@ 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_CASE([/$make_cv_posix_spawn/$user_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], [
@@ -498,6 +514,12 @@ 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 lib/Makefile po/Makefile.in doc/Makefile \
                  tests/config-flags.pm])
index cea4db14387b9bc211b8ebe4bb857bf45fea3b03..05578e6f29f78a1022543daae9304a28790e433f 100644 (file)
@@ -240,6 +240,7 @@ CONFIG_CHECKS := \
        checkcfg.--disable-job-server \
        checkcfg.--disable-load \
        checkcfg.--without-guile \
+       checkcfg.--disable-posix-spawn \
        checkcfg.make_cv_sys_gnu_glob^no \
        checkcfg.ac_cv_func_getloadavg^no+ac_cv_have_decl_getloadavg^no+gl_cv_have_raw_decl_getloadavg^no+ac_cv_lib_util_getloadavg^no+ac_cv_lib_getloadavg_getloadavg^no \
        checkcfg.CPPFLAGS^-DNO_OUTPUT_SYNC \
index 099934b188998115da813eba7aa26ad529c5b096..afe742e26f1b74be0cffadaccae8e1a714c4a717 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -137,9 +137,9 @@ extern int wait3 ();
 # endif /* Have wait3.  */
 #endif /* Have waitpid.  */
 
-#ifdef HAVE_SPAWN_H
+#ifdef USE_POSIX_SPAWN
 # include <spawn.h>
-#endif /* have spawn.h */
+#endif
 
 #if !defined (wait) && !defined (POSIX)
 int wait ();
@@ -2234,13 +2234,13 @@ child_execute_job (struct output *out, int good_stdin, char **argv, char **envp)
   const int fdin = good_stdin ? FD_STDIN : get_bad_stdin ();
   int fdout = FD_STDOUT;
   int fderr = FD_STDERR;
-  int r;
   pid_t pid;
-#if HAVE_POSIX_SPAWN
+  int r;
+#if USE_POSIX_SPAWN
   short flags = 0;
   posix_spawnattr_t attr;
   posix_spawn_file_actions_t fa;
-#endif /* have posix_spawn() */
+#endif
 
   /* Divert child output if we want to capture it.  */
   if (out && out->syncout)
@@ -2251,8 +2251,7 @@ child_execute_job (struct output *out, int good_stdin, char **argv, char **envp)
         fderr = out->err;
     }
 
-#if ! HAVE_POSIX_SPAWN
-  /* does not have posix_spawn() */
+#if !defined(USE_POSIX_SPAWN)
 
   pid = vfork();
   if (pid != 0)