immutable: Add tests.
[gnulib.git] / m4 / ptsname.m4
blob66e50c992b871e8bb03f5d233253f7a5de8fad8c
1 # ptsname.m4 serial 8
2 dnl Copyright (C) 2010-2021 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_PTSNAME],
9   AC_REQUIRE([gl_UNISTD_H_DEFAULTS])
10   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
12   dnl Persuade glibc <stdlib.h> to declare ptsname().
13   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
15   AC_CHECK_FUNCS([ptsname])
16   if test $ac_cv_func_ptsname = no; then
17     HAVE_PTSNAME=0
18   else
19     AC_CACHE_CHECK([whether ptsname sets errno on failure],
20       [gl_cv_func_ptsname_sets_errno],
21       [AC_RUN_IFELSE(
22          [AC_LANG_PROGRAM([[
23               #include <stdlib.h>
24               #include <errno.h>
25             ]], [[
26               return ptsname (-1) || !errno;
27             ]])],
28          [gl_cv_func_ptsname_sets_errno=yes],
29          [gl_cv_func_ptsname_sets_errno=no],
30          [case "$host_os" in
31                            # Guess yes on glibc systems.
32             *-gnu* | gnu*) gl_cv_func_ptsname_sets_errno="guessing yes" ;;
33                            # Guess yes on musl systems.
34             *-musl*)       gl_cv_func_ptsname_sets_errno="guessing yes" ;;
35                            # If we don't know, obey --enable-cross-guesses.
36             *)             gl_cv_func_ptsname_sets_errno="$gl_cross_guess_normal" ;;
37           esac
38          ])])
39     case $gl_cv_func_ptsname_sets_errno in
40       *no) REPLACE_PTSNAME=1 ;;
41     esac
42   fi
45 # Prerequisites of lib/ptsname.c.
46 AC_DEFUN([gl_PREREQ_PTSNAME], [
47   :