README-release: various improvements
[gnulib.git] / m4 / euidaccess.m4
1 # euidaccess.m4 serial 14
2 dnl Copyright (C) 2002-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 AC_DEFUN([gl_FUNC_NONREENTRANT_EUIDACCESS],
8 [
9   AC_REQUIRE([gl_FUNC_EUIDACCESS])
10   AC_DEFINE([PREFER_NONREENTRANT_EUIDACCESS], [1],
11     [Define this if you prefer euidaccess to return the correct result
12      even if this would make it nonreentrant.  Define this only if your
13      entire application is safe even if the uid or gid might temporarily
14      change.  If your application uses signal handlers or threads it
15      is probably not safe.])
16 ])
17
18 AC_DEFUN([gl_FUNC_EUIDACCESS],
19 [
20   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
21
22   dnl Persuade glibc <unistd.h> to declare euidaccess().
23   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
24
25   AC_CHECK_FUNCS([euidaccess])
26   if test $ac_cv_func_euidaccess = no; then
27     HAVE_EUIDACCESS=0
28   fi
29 ])
30
31 # Prerequisites of lib/euidaccess.c.
32 AC_DEFUN([gl_PREREQ_EUIDACCESS], [
33   dnl Prefer POSIX faccessat over non-standard euidaccess.
34   AC_CHECK_FUNCS_ONCE([faccessat])
35   dnl Try various other non-standard fallbacks.
36   AC_CHECK_HEADERS_ONCE([libgen.h])
37   AC_CHECK_DECLS_ONCE([setregid])
38   AC_REQUIRE([AC_FUNC_GETGROUPS])
39
40   # Solaris 9 and 10 need -lgen to get the eaccess function.
41   # Save and restore LIBS so -lgen isn't added to it.  Otherwise, *all*
42   # programs in the package would end up linked with that potentially-shared
43   # library, inducing unnecessary run-time overhead.
44   LIB_EACCESS=
45   AC_SUBST([LIB_EACCESS])
46   gl_saved_libs=$LIBS
47     AC_SEARCH_LIBS([eaccess], [gen],
48                    [test "$ac_cv_search_eaccess" = "none required" ||
49                     LIB_EACCESS=$ac_cv_search_eaccess])
50     AC_CHECK_FUNCS([eaccess])
51   LIBS=$gl_saved_libs
52 ])