3
dnl Copyright (C) 1998-2003, 2005-2007, 2009 Free Software Foundation, Inc.
5
dnl This file is free software; the Free Software Foundation
6
dnl gives unlimited permission to copy and/or distribute it,
7
dnl with or without modifications, as long as this notice is preserved.
11
dnl See if there's a working, system-supplied version of the getline function.
12
dnl We can't just do AC_REPLACE_FUNCS([getline]) because some systems
13
dnl have a function by that name in -linet that doesn't have anything
14
dnl to do with the function we need.
15
AC_DEFUN([gl_FUNC_GETLINE],
17
AC_REQUIRE([gl_STDIO_H_DEFAULTS])
19
dnl Persuade glibc <stdio.h> to declare getline().
20
AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
22
AC_CHECK_DECLS_ONCE([getline])
24
gl_getline_needs_run_time_check=no
25
AC_CHECK_FUNC([getline],
26
dnl Found it in some library. Verify that it works.
27
gl_getline_needs_run_time_check=yes,
28
am_cv_func_working_getline=no)
29
if test $gl_getline_needs_run_time_check = yes; then
30
AC_CACHE_CHECK([for working getline function], [am_cv_func_working_getline],
31
[echo fooN |tr -d '\012'|tr N '\012' > conftest.data
37
{ /* Based on a test program from Karl Heuer. */
41
FILE *in = fopen ("./conftest.data", "r");
44
len = getline (&line, &siz, in);
45
exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
47
], am_cv_func_working_getline=yes dnl The library version works.
48
, am_cv_func_working_getline=no dnl The library version does NOT work.
49
, dnl We're cross compiling. Assume it works on glibc2 systems.
50
[AC_EGREP_CPP([Lucky GNU user],
53
#ifdef __GNU_LIBRARY__
59
[am_cv_func_working_getline=yes],
60
[am_cv_func_working_getline=no])]
64
if test $ac_cv_have_decl_getline = no; then
68
if test $am_cv_func_working_getline = no; then
76
# Prerequisites of lib/getline.c.
77
AC_DEFUN([gl_PREREQ_GETLINE],