]> sjero.net Git - wget/blob - m4/getline.m4
Check for idna.h in /usr/include/idn.
[wget] / m4 / getline.m4
1 # getline.m4 serial 19
2
3 dnl Copyright (C) 1998-2003, 2005-2007, 2009 Free Software Foundation, Inc.
4 dnl
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.
8
9 AC_PREREQ([2.59])
10
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],
16 [
17   AC_REQUIRE([gl_STDIO_H_DEFAULTS])
18
19   dnl Persuade glibc <stdio.h> to declare getline().
20   AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
21
22   AC_CHECK_DECLS_ONCE([getline])
23
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
32     AC_TRY_RUN([
33 #    include <stdio.h>
34 #    include <stdlib.h>
35 #    include <string.h>
36     int main ()
37     { /* Based on a test program from Karl Heuer.  */
38       char *line = NULL;
39       size_t siz = 0;
40       int len;
41       FILE *in = fopen ("./conftest.data", "r");
42       if (!in)
43         return 1;
44       len = getline (&line, &siz, in);
45       exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
46     }
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],
51          [
52 #include <features.h>
53 #ifdef __GNU_LIBRARY__
54  #if (__GLIBC__ >= 2)
55   Lucky GNU user
56  #endif
57 #endif
58          ],
59          [am_cv_func_working_getline=yes],
60          [am_cv_func_working_getline=no])]
61     )])
62   fi
63
64   if test $ac_cv_have_decl_getline = no; then
65     HAVE_DECL_GETLINE=0
66   fi
67
68   if test $am_cv_func_working_getline = no; then
69     REPLACE_GETLINE=1
70     AC_LIBOBJ([getline])
71
72     gl_PREREQ_GETLINE
73   fi
74 ])
75
76 # Prerequisites of lib/getline.c.
77 AC_DEFUN([gl_PREREQ_GETLINE],
78 [
79   gl_FUNC_GETDELIM
80 ])