source: trunk/essentials/sys-apps/findutils/gnulib/m4/getline.m4

Last change on this file was 3170, checked in by bird, 18 years ago

findutils 4.3.2

File size: 2.4 KB
Line 
1# getline.m4 serial 15
2
3dnl Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006 Free Software
4dnl Foundation, Inc.
5dnl
6dnl This file is free software; the Free Software Foundation
7dnl gives unlimited permission to copy and/or distribute it,
8dnl with or without modifications, as long as this notice is preserved.
9
10AC_PREREQ(2.52)
11
12dnl See if there's a working, system-supplied version of the getline function.
13dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems
14dnl have a function by that name in -linet that doesn't have anything
15dnl to do with the function we need.
16AC_DEFUN([gl_FUNC_GETLINE],
17[
18 dnl Persuade glibc <stdio.h> to declare getline().
19 AC_REQUIRE([AC_GNU_SOURCE])
20
21 AC_CHECK_DECLS([getline])
22
23 gl_getline_needs_run_time_check=no
24 AC_CHECK_FUNC(getline,
25 dnl Found it in some library. Verify that it works.
26 gl_getline_needs_run_time_check=yes,
27 am_cv_func_working_getline=no)
28 if test $gl_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
31 AC_TRY_RUN([
32# include <stdio.h>
33# include <stdlib.h>
34# include <string.h>
35 int main ()
36 { /* Based on a test program from Karl Heuer. */
37 char *line = NULL;
38 size_t siz = 0;
39 int len;
40 FILE *in = fopen ("./conftest.data", "r");
41 if (!in)
42 return 1;
43 len = getline (&line, &siz, in);
44 exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
45 }
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 , dnl We're cross compiling. Assume it works on glibc2 systems.
49 [AC_EGREP_CPP([Lucky GNU user],
50 [
51#include <features.h>
52#ifdef __GNU_LIBRARY__
53 #if (__GLIBC__ >= 2)
54 Lucky GNU user
55 #endif
56#endif
57 ],
58 [am_cv_func_working_getline=yes],
59 [am_cv_func_working_getline=no])]
60 )])
61 fi
62
63 if test $am_cv_func_working_getline = no; then
64 dnl We must choose a different name for our function, since on ELF systems
65 dnl a broken getline() in libc.so would override our getline() in
66 dnl libgettextlib.so.
67 AC_DEFINE([getline], [gnu_getline],
68 [Define to a replacement function name for getline().])
69 AC_LIBOBJ(getline)
70
71 gl_PREREQ_GETLINE
72 fi
73])
74
75# Prerequisites of lib/getline.c.
76AC_DEFUN([gl_PREREQ_GETLINE],
77[
78 gl_FUNC_GETDELIM
79])
Note: See TracBrowser for help on using the repository browser.