Home | History | Annotate | Download | only in m4
      1 # spawn_h.m4 serial 16
      2 dnl Copyright (C) 2008-2012 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.
      6 
      7 dnl Written by Bruno Haible.
      8 
      9 AC_DEFUN([gl_SPAWN_H],
     10 [
     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])
     14 
     15   dnl <spawn.h> is always overridden, because of GNULIB_POSIXCHECK.
     16   gl_CHECK_NEXT_HEADERS([spawn.h])
     17 
     18   if test $ac_cv_header_spawn_h = yes; then
     19     HAVE_SPAWN_H=1
     20     AC_CHECK_TYPES([posix_spawnattr_t], [], [HAVE_POSIX_SPAWNATTR_T=0], [[
     21 #include <spawn.h>
     22       ]])
     23     AC_CHECK_TYPES([posix_spawn_file_actions_t], [],
     24       [HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0], [[
     25 #include <spawn.h>
     26       ]])
     27   else
     28     HAVE_SPAWN_H=0
     29     HAVE_POSIX_SPAWNATTR_T=0
     30     HAVE_POSIX_SPAWN_FILE_ACTIONS_T=0
     31   fi
     32   AC_SUBST([HAVE_SPAWN_H])
     33 
     34   dnl Ensure the type pid_t gets defined.
     35   AC_REQUIRE([AC_TYPE_PID_T])
     36 
     37   dnl Ensure the type mode_t gets defined.
     38   AC_REQUIRE([AC_TYPE_MODE_T])
     39 
     40   AC_REQUIRE([gl_HAVE_POSIX_SPAWN])
     41 
     42   AC_REQUIRE([AC_C_RESTRICT])
     43 
     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])
     57 ])
     58 
     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],
     62 [
     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])
     66 
     67   AC_CHECK_FUNCS_ONCE([posix_spawn])
     68   if test $ac_cv_func_posix_spawn != yes; then
     69     HAVE_POSIX_SPAWN=0
     70   fi
     71 ])
     72 
     73 AC_DEFUN([gl_SPAWN_MODULE_INDICATOR],
     74 [
     75   dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
     76   AC_REQUIRE([gl_SPAWN_H_DEFAULTS])
     77   gl_MODULE_INDICATOR_SET_VARIABLE([$1])
     78   dnl Define it also as a C macro, for the benefit of the unit tests.
     79   gl_MODULE_INDICATOR_FOR_TESTS([$1])
     80 ])
     81 
     82 AC_DEFUN([gl_SPAWN_H_DEFAULTS],
     83 [
     84   GNULIB_POSIX_SPAWN=0;                       AC_SUBST([GNULIB_POSIX_SPAWN])
     85   GNULIB_POSIX_SPAWNP=0;                      AC_SUBST([GNULIB_POSIX_SPAWNP])
     86   GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT=0;     AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_INIT])
     87   GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0; AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE])
     88   GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0;  AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2])
     89   GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0;  AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN])
     90   GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY=0;  AC_SUBST([GNULIB_POSIX_SPAWN_FILE_ACTIONS_DESTROY])
     91   GNULIB_POSIX_SPAWNATTR_INIT=0;              AC_SUBST([GNULIB_POSIX_SPAWNATTR_INIT])
     92   GNULIB_POSIX_SPAWNATTR_GETFLAGS=0;          AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETFLAGS])
     93   GNULIB_POSIX_SPAWNATTR_SETFLAGS=0;          AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETFLAGS])
     94   GNULIB_POSIX_SPAWNATTR_GETPGROUP=0;         AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETPGROUP])
     95   GNULIB_POSIX_SPAWNATTR_SETPGROUP=0;         AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETPGROUP])
     96   GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM=0;     AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPARAM])
     97   GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM=0;     AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPARAM])
     98   GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY=0;    AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSCHEDPOLICY])
     99   GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY=0;    AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSCHEDPOLICY])
    100   GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT=0;     AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGDEFAULT])
    101   GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT=0;     AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGDEFAULT])
    102   GNULIB_POSIX_SPAWNATTR_GETSIGMASK=0;        AC_SUBST([GNULIB_POSIX_SPAWNATTR_GETSIGMASK])
    103   GNULIB_POSIX_SPAWNATTR_SETSIGMASK=0;        AC_SUBST([GNULIB_POSIX_SPAWNATTR_SETSIGMASK])
    104   GNULIB_POSIX_SPAWNATTR_DESTROY=0;           AC_SUBST([GNULIB_POSIX_SPAWNATTR_DESTROY])
    105   dnl Assume proper GNU behavior unless another module says otherwise.
    106   HAVE_POSIX_SPAWN=1;        AC_SUBST([HAVE_POSIX_SPAWN])
    107   HAVE_POSIX_SPAWNATTR_T=1;  AC_SUBST([HAVE_POSIX_SPAWNATTR_T])
    108   HAVE_POSIX_SPAWN_FILE_ACTIONS_T=1;
    109                              AC_SUBST([HAVE_POSIX_SPAWN_FILE_ACTIONS_T])
    110   REPLACE_POSIX_SPAWN=0;     AC_SUBST([REPLACE_POSIX_SPAWN])
    111   REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=0;
    112                              AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE])
    113   REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=0;
    114                              AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2])
    115   REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=0;
    116                              AC_SUBST([REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN])
    117 ])
    118