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_CACHE_CHECK([whether getcwd (NULL, 0) allocates memory for result],
15 [gl_cv_func_getcwd_null],
30 char *f = getcwd (NULL, 0);
31 exit (! (f && f[0] == '/' && !f[1]));
34 [gl_cv_func_getcwd_null=yes],
35 [gl_cv_func_getcwd_null=no],
36 [gl_cv_func_getcwd_null=no])])
39 AC_DEFUN([gl_FUNC_GETCWD],
41 AC_REQUIRE([gl_FUNC_GETCWD_NULL])
43 case $gl_cv_func_getcwd_null in
44 yes) gl_FUNC_GETCWD_PATH_MAX;;
47 case $gl_cv_func_getcwd_null,$gl_cv_func_getcwd_path_max in
51 AC_DEFINE([__GETCWD_PREFIX], [[rpl_]],
52 [Define to rpl_ if the getcwd replacement function should be used.])
57 # Prerequisites of lib/getcwd.c.
58 AC_DEFUN([gl_PREREQ_GETCWD],
60 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
61 AC_REQUIRE([AC_HEADER_DIRENT])
62 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_INO])