getlogin_r: Small fixes.
[gnulib.git] / m4 / getlogin_r.m4
1 #serial 5
2
3 # Copyright (C) 2005-2007, 2009-2010 Free Software Foundation, Inc.
4 #
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 dnl From Derek Price
10 dnl
11 dnl Provide getlogin_r when the system lacks it.
12 dnl
13
14 AC_DEFUN([gl_GETLOGIN_R],
15 [
16   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
17
18   dnl Persuade glibc <unistd.h> to declare getlogin_r().
19   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
20
21   AC_CHECK_FUNCS_ONCE([getlogin_r])
22   if test $ac_cv_func_getlogin_r = no; then
23     AC_LIBOBJ([getlogin_r])
24     gl_PREREQ_GETLOGIN_R
25     AC_CHECK_DECLS_ONCE([getlogin_r])
26     if test $ac_cv_have_decl_getlogin_r = no; then
27       HAVE_DECL_GETLOGIN_R=0
28     fi
29   fi
30 ])
31
32 AC_DEFUN([gl_PREREQ_GETLOGIN_R],
33 [
34   AC_CHECK_DECLS_ONCE([getlogin])
35 ])