Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / m4 / euidaccess.m4
blob55393a4566c8a784a8872cdc133a5cf87357cae1
1 # euidaccess.m4 serial 15
2 dnl Copyright (C) 2002-2014 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 AC_DEFUN([gl_FUNC_NONREENTRANT_EUIDACCESS],
9   AC_REQUIRE([gl_FUNC_EUIDACCESS])
10   AC_CHECK_DECLS([setregid])
11   AC_DEFINE([PREFER_NONREENTRANT_EUIDACCESS], [1],
12     [Define this if you prefer euidaccess to return the correct result
13      even if this would make it nonreentrant.  Define this only if your
14      entire application is safe even if the uid or gid might temporarily
15      change.  If your application uses signal handlers or threads it
16      is probably not safe.])
19 AC_DEFUN([gl_FUNC_EUIDACCESS],
21   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
23   dnl Persuade glibc <unistd.h> to declare euidaccess().
24   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
26   AC_CHECK_FUNCS([euidaccess])
27   if test $ac_cv_func_euidaccess = no; then
28     HAVE_EUIDACCESS=0
29   fi
32 # Prerequisites of lib/euidaccess.c.
33 AC_DEFUN([gl_PREREQ_EUIDACCESS], [
34   dnl Prefer POSIX faccessat over non-standard euidaccess.
35   AC_CHECK_FUNCS_ONCE([faccessat])
36   dnl Try various other non-standard fallbacks.
37   AC_CHECK_HEADERS([libgen.h])
38   AC_FUNC_GETGROUPS
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