1 # getcwd.m4 - check for working getcwd that is compatible with glibc
3 # Copyright (C) 2001, 2003, 2004 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_CHECK_HEADERS_ONCE(unistd.h)
13 AC_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result],
14 [gl_cv_func_getcwd_null],
31 char *f = getcwd (NULL, 0);
32 exit (! (f && f[0] == '/' && !f[1]));
35 [gl_cv_func_getcwd_null=yes],
36 [gl_cv_func_getcwd_null=no],
37 [gl_cv_func_getcwd_null=no])])
40 AC_DEFUN([gl_FUNC_GETCWD],
42 AC_REQUIRE([gl_FUNC_GETCWD_NULL])
44 case $gl_cv_func_getcwd_null in
45 yes) gl_FUNC_GETCWD_PATH_MAX;;
48 case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_path_max in
52 AC_DEFINE([__GETCWD_PREFIX], [[rpl_]],
53 [Define to rpl_ if the getcwd replacement function should be used.])
58 # Prerequisites of lib/getcwd.c.
59 AC_DEFUN([gl_PREREQ_GETCWD],
61 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
62 AC_REQUIRE([AC_HEADER_DIRENT])
63 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])
64 AC_CHECK_HEADERS_ONCE(fcntl.h)