Merge getpass from libc, plus a few fixes.
[gnulib.git] / m4 / getpass.m4
1 # getpass.m4 serial 3
2 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License.  As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
8
9 # Provide a getpass() function if the system doesn't have it.
10 AC_DEFUN([gl_FUNC_GETPASS],
11 [
12   AC_REPLACE_FUNCS(getpass)
13   if test $ac_cv_func_getpass = no; then
14     gl_PREREQ_GETPASS
15   fi
16 ])
17
18 # Provide the GNU getpass() implementation. It supports passwords of
19 # arbitrary length (not just 8 bytes as on HP-UX).
20 AC_DEFUN([gl_FUNC_GETPASS_GNU],
21 [
22   dnl TODO: Detect when GNU getpass() is already found in glibc.
23   AC_LIBOBJ(getpass)
24   gl_PREREQ_GETPASS
25   dnl We must choose a different name for our function, since on ELF systems
26   dnl an unusable getpass() in libc.so would override our getpass() if it is
27   dnl compiled into a shared library.
28   AC_DEFINE([getpass], [gnu_getpass],
29     [Define to a replacement function name for getpass().])
30 ])
31
32 # Prerequisites of lib/getpass.c.
33 AC_DEFUN([gl_PREREQ_GETPASS], [
34   AC_CHECK_HEADERS_ONCE(stdio_ext.h)
35   :
36 ])
37