1 # getcwd.m4 - check for working getcwd that is compatible with glibc
3 # Copyright (C) 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
8 # Written by Paul Eggert.
10 AC_DEFUN([gl_FUNC_GETCWD_NULL],
12 AC_LIBSOURCES([getcwd.c, getcwd.h])
14 AC_CHECK_HEADERS_ONCE(unistd.h)
15 AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result],
16 [gl_cv_func_getcwd_null],
33 char *f = getcwd (NULL, 0);
34 exit (! (f && f[0] == '/' && !f[1]));
37 [gl_cv_func_getcwd_null=yes],
38 [gl_cv_func_getcwd_null=no],
39 [gl_cv_func_getcwd_null=no])])
42 AC_DEFUN([gl_FUNC_GETCWD],
44 AC_REQUIRE([gl_FUNC_GETCWD_NULL])
46 case $gl_cv_func_getcwd_null in
47 yes) gl_FUNC_GETCWD_PATH_MAX;;
50 case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_path_max in
54 AC_DEFINE([__GETCWD_PREFIX], [[rpl_]],
55 [Define to rpl_ if the getcwd replacement function should be used.])
60 # Prerequisites of lib/getcwd.c.
61 AC_DEFUN([gl_PREREQ_GETCWD],
63 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
64 AC_REQUIRE([AC_HEADER_DIRENT])
65 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])