2 dnl Copyright (C) 2008-2018 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 dnl Written by Bruno Haible.
11 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
12 dnl once only, before all statements that occur in other macros.
13 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
15 dnl <spawn.h> is always overridden, because of GNULIB_POSIXCHECK.
16 gl_CHECK_NEXT_HEADERS([spawn.h])
18 if test $ac_cv_header_spawn_h = yes; then
20 AC_CHECK_TYPES([posix_spawnattr_t], [], [HAVE_POSIX_SPAWNATTR_T=0], [[
23 AC_CHECK_TYPES([posix_spawn_file_actions_t], [],
24 [HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0], [[
29 HAVE_POSIX_SPAWNATTR_T=0
30 HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0
32 AC_SUBST([HAVE_SPAWN_H])
34 dnl Ensure the type pid_t gets defined.
35 AC_REQUIRE([AC_TYPE_PID_T])
37 dnl Ensure the type mode_t gets defined.
38 AC_REQUIRE([AC_TYPE_MODE_T])
40 AC_REQUIRE([gl_HAVE_POSIX_SPAWN])
42 AC_REQUIRE([AC_C_RESTRICT])
44 dnl Check for declarations of anything we want to poison if the
45 dnl corresponding gnulib module is not in use.
46 gl_WARN_ON_USE_PREPARE([[#include <spawn.h>
47 ]], [posix_spawn posix_spawnp posix_spawnattr_init posix_spawnattr_destroy
48 posix_spawnattr_getsigdefault posix_spawnattr_setsigdefault
49 posix_spawnattr_getsigmask posix_spawnattr_setsigmask
50 posix_spawnattr_getflags posix_spawnattr_setflags
51 posix_spawnattr_getpgroup posix_spawnattr_setpgroup
52 posix_spawnattr_getschedpolicy posix_spawnattr_setschedpolicy
53 posix_spawnattr_getschedparam posix_spawnattr_setschedparam
54 posix_spawn_file_actions_init posix_spawn_file_actions_destroy
55 posix_spawn_file_actions_addopen posix_spawn_file_actions_addclose
56 posix_spawn_file_actions_adddup2 posix_spawn_file_actions_addchdir])
59 dnl Checks whether the system has the functions posix_spawn.
60 dnl Sets ac_cv_func_posix_spawn and HAVE_POSIX_SPAWN.
61 AC_DEFUN([gl_HAVE_POSIX_SPAWN],
63 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
64 dnl once only, before all statements that occur in other macros.
65 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
68 AC_SUBST([LIB_POSIX_SPAWN])
70 AC_SEARCH_LIBS([posix_spawn], [rt],
71 [test "$ac_cv_search_posix_spawn" = "none required" ||
72 LIB_POSIX_SPAWN=$ac_cv_search_posix_spawn])
73 AC_CHECK_FUNCS([posix_spawn])
76 if test $ac_cv_func_posix_spawn != yes; then
81 AC_DEFUN([gl_SPAWN_MODULE_INDICATOR],
83 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
84 AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
85 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
86 dnl Define it also as a C macro, for the benefit of the unit tests.
87 gl_MODULE_INDICATOR_FOR_TESTS([$1])
90 AC_DEFUN([gl_SPAWN_H_DEFAULTS],
92 GNULIB_POSIX_SPAWN=0; AC_SUBST([GNULIB_POSIX_SPAWN])
93 GNULIB_POSIX_SPAWNP=0; AC_SUBST([GNULIB_POSIX_SPAWNP])
94 GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT])
95 GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
96 GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE])
97 GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2])
98 GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN])
99 GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY])
100 GNULIB_POSIX_SPAWNATTR_INIT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_INIT])
101 GNULIB_POSIX_SPAWNATTR_GETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETFLAGS])
102 GNULIB_POSIX_SPAWNATTR_SETFLAGS=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETFLAGS])
103 GNULIB_POSIX_SPAWNATTR_GETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETPGROUP])
104 GNULIB_POSIX_SPAWNATTR_SETPGROUP=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETPGROUP])
105 GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM])
106 GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM])
107 GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY])
108 GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY])
109 GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT])
110 GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT])
111 GNULIB_POSIX_SPAWNATTR_GETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGMASK])
112 GNULIB_POSIX_SPAWNATTR_SETSIGMASK=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGMASK])
113 GNULIB_POSIX_SPAWNATTR_DESTROY=0; AC_SUBST([GNULIB_POSIX_SPAWNATTR_DESTROY])
114 dnl Assume proper GNU behavior unless another module says otherwise.
115 HAVE_POSIX_SPAWN=1; AC_SUBST([HAVE_POSIX_SPAWN])
116 HAVE_POSIX_SPAWNATTR_T=1; AC_SUBST([HAVE_POSIX_SPAWNATTR_T])
117 HAVE_POSIX_SPAWN_FILE_ACTIONS_T=1;
118 AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_T])
119 HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=1;
120 AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
121 REPLACE_POSIX_SPAWN=0; AC_SUBST([REPLACE_POSIX_SPAWN])
122 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR=0;
123 AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR])
124 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0;
125 AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE])
126 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0;
127 AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2])
128 REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0;
129 AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN])