* argp.m4 (gl_ARGP): Don't call AC_CHECK_DECLS_ONCE with more than
[gnulib.git] / m4 / getpass.m4
1 # getpass.m4 serial 7
2 dnl Copyright (C) 2002-2003, 2005-2006 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 # Provide a getpass() function if the system doesn't have it.
8 AC_DEFUN([gl_FUNC_GETPASS],
9 [
10   AC_LIBSOURCES([getpass.c, getpass.h])
11
12   AC_REPLACE_FUNCS(getpass)
13   AC_CHECK_DECLS_ONCE(getpass)
14   if test $ac_cv_func_getpass = no; then
15     gl_PREREQ_GETPASS
16   fi
17 ])
18
19 # Provide the GNU getpass() implementation. It supports passwords of
20 # arbitrary length (not just 8 bytes as on HP-UX).
21 AC_DEFUN([gl_FUNC_GETPASS_GNU],
22 [
23   AC_LIBSOURCES([getpass.c, getpass.h])
24
25   AC_CHECK_DECLS_ONCE(getpass)
26   dnl TODO: Detect when GNU getpass() is already found in glibc.
27   AC_LIBOBJ(getpass)
28   gl_PREREQ_GETPASS
29   dnl We must choose a different name for our function, since on ELF systems
30   dnl an unusable getpass() in libc.so would override our getpass() if it is
31   dnl compiled into a shared library.
32   AC_DEFINE([getpass], [gnu_getpass],
33     [Define to a replacement function name for getpass().])
34 ])
35
36 # Prerequisites of lib/getpass.c.
37 AC_DEFUN([gl_PREREQ_GETPASS], [
38   AC_CHECK_HEADERS_ONCE(stdio_ext.h termios.h)
39   AC_CHECK_FUNCS_ONCE(__fsetlocking tcgetattr tcsetattr)
40   AC_CHECK_DECLS_ONCE([fflush_unlocked])
41   AC_CHECK_DECLS_ONCE([flockfile])
42   AC_CHECK_DECLS_ONCE([fputs_unlocked])
43   AC_CHECK_DECLS_ONCE([funlockfile])
44   AC_CHECK_DECLS_ONCE([putc_unlocked])
45 ])