1#serial 4 2 3dnl See if there's a working, system-supplied version of the getline function. 4dnl We can't just do AC_REPLACE_FUNCS(getline) because some systems 5dnl have a function by that name in -linet that doesn't have anything 6dnl to do with the function we need. 7AC_DEFUN([AM_FUNC_GETLINE], 8[dnl 9 am_getline_needs_run_time_check=no 10 AC_CHECK_FUNC(getline, 11 dnl Found it in some library. Verify that it works. 12 am_getline_needs_run_time_check=yes, 13 am_cv_func_working_getline=no) 14 if test $am_getline_needs_run_time_check = yes; then 15 AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline, 16 [echo fooN |tr -d '\012'|tr N '\012' > conftest.data 17 AC_TRY_RUN([ 18# include <stdio.h> 19# include <sys/types.h> 20# include <string.h> 21 int main () 22 { /* Based on a test program from Karl Heuer. */ 23 char *line = NULL; 24 size_t siz = 0; 25 int len; 26 FILE *in = fopen ("./conftest.data", "r"); 27 if (!in) 28 return 1; 29 len = getline (&line, &siz, in); 30 exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1); 31 } 32 ], am_cv_func_working_getline=yes dnl The library version works. 33 , am_cv_func_working_getline=no dnl The library version does NOT work. 34 , am_cv_func_working_getline=no dnl We're cross compiling. 35 )]) 36 fi 37 38 if test $am_cv_func_working_getline = no; then 39 AC_LIBOBJ(getline) 40 fi 41]) 42