3 dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software
6 dnl This file is free software, distributed under the terms of the GNU
7 dnl General Public License. As a special exception to the GNU General
8 dnl Public License, this file may be distributed as part of a program
9 dnl that contains a configuration script generated by Autoconf, under
10 dnl the same distribution terms as the rest of that program.
14 dnl See if there's a working, system-supplied version of the getline function.
15 dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
16 dnl have a function by that name in -linet that doesn't have anything
17 dnl to do with the function we need.
18 AC_DEFUN([AM_FUNC_GETLINE],
20 dnl Persuade glibc <stdio.h> to declare getline() and getdelim().
21 AC_REQUIRE([AC_GNU_SOURCE])
23 am_getline_needs_run_time_check=no
24 AC_CHECK_FUNC(getline,
25 dnl Found it in some library. Verify that it works.
26 am_getline_needs_run_time_check=yes,
27 am_cv_func_working_getline=no)
28 if test $am_getline_needs_run_time_check = yes; then
29 AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
30 [echo fooN |tr -d '\012'|tr N '\012' > conftest.data
36 { /* Based on a test program from Karl Heuer. */
40 FILE *in = fopen ("./conftest.data", "r");
43 len = getline (&line, &siz, in);
44 exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
46 ], am_cv_func_working_getline=yes dnl The library version works.
47 , am_cv_func_working_getline=no dnl The library version does NOT work.
48 , am_cv_func_working_getline=no dnl We're cross compiling.
52 if test $am_cv_func_working_getline = no; then
53 dnl We must choose a different name for our function, since on ELF systems
54 dnl a broken getline() in libc.so would override our getline() in
56 AC_DEFINE([getline], [gnu_getline],
57 [Define to a replacement function name for getline().])
65 # Prerequisites of lib/getline.c.
66 AC_DEFUN([gl_PREREQ_GETLINE],
68 AC_CHECK_FUNCS(getdelim)