AC_PREREQ(2.52)
AC_DEFUN([gl_FUNC_GETLINE],
[
AC_LIBSOURCES([getline.c, getline.h])
AC_REQUIRE([AC_GNU_SOURCE])
AC_CHECK_DECLS([getline])
gl_getline_needs_run_time_check=no
AC_CHECK_FUNC(getline,
gl_getline_needs_run_time_check=yes,
am_cv_func_working_getline=no)
if test $gl_getline_needs_run_time_check = yes; then
AC_CACHE_CHECK([for working getline function], am_cv_func_working_getline,
[echo fooN |tr -d '\012'|tr N '\012' > conftest.data
AC_TRY_RUN([
int main ()
{ /* Based on a test program from Karl Heuer. */
char *line = NULL;
size_t siz = 0;
int len;
FILE *in = fopen ("./conftest.data", "r");
if (!in)
return 1;
len = getline (&line, &siz, in);
exit ((len == 4 && line && strcmp (line, "foo\n") == 0) ? 0 : 1);
}
], am_cv_func_working_getline=yes , am_cv_func_working_getline=no , am_cv_func_working_getline=no )])
fi
if test $am_cv_func_working_getline = no; then
AC_DEFINE([getline], [gnu_getline],
[Define to a replacement function name for getline().])
AC_LIBOBJ(getline)
gl_PREREQ_GETLINE
fi
])
AC_DEFUN([gl_PREREQ_GETLINE],
[
gl_FUNC_GETDELIM
])