1 # canonicalize.m4 serial 16
3 dnl Copyright (C) 2003-2007, 2009-2010 Free Software Foundation, Inc.
5 dnl This file is free software; the Free Software Foundation
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 # Provides canonicalize_file_name and canonicalize_filename_mode, but does
10 # not provide or fix realpath.
11 AC_DEFUN([gl_FUNC_CANONICALIZE_FILENAME_MODE],
13 AC_LIBOBJ([canonicalize])
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
16 AC_CHECK_FUNCS_ONCE([canonicalize_file_name])
17 AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
18 AC_REQUIRE([gl_FUNC_REALPATH_WORKS])
19 if test $ac_cv_func_canonicalize_file_name = no; then
20 HAVE_CANONICALIZE_FILE_NAME=0
21 elif test "$gl_cv_func_realpath_works" != yes; then
22 REPLACE_CANONICALIZE_FILE_NAME=1
26 # Provides canonicalize_file_name and realpath.
27 AC_DEFUN([gl_CANONICALIZE_LGPL],
29 AC_REQUIRE([gl_CANONICALIZE_LGPL_SEPARATE])
30 if test $ac_cv_func_canonicalize_file_name = no; then
31 HAVE_CANONICALIZE_FILE_NAME=0
32 AC_LIBOBJ([canonicalize-lgpl])
33 if test $ac_cv_func_realpath = no; then
35 elif test "$gl_cv_func_realpath_works" != yes; then
38 elif test "$gl_cv_func_realpath_works" != yes; then
39 AC_LIBOBJ([canonicalize-lgpl])
41 REPLACE_CANONICALIZE_FILE_NAME=1
45 # Like gl_CANONICALIZE_LGPL, except prepare for separate compilation
47 AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE],
49 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
50 AC_CHECK_FUNCS_ONCE([canonicalize_file_name getcwd readlink])
51 AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
52 AC_REQUIRE([gl_FUNC_REALPATH_WORKS])
53 AC_CHECK_HEADERS_ONCE([sys/param.h])
56 # Check whether realpath works. Assume that if a platform has both
57 # realpath and canonicalize_file_name, but the former is broken, then
59 AC_DEFUN([gl_FUNC_REALPATH_WORKS],
61 AC_CHECK_FUNCS_ONCE([realpath])
62 AC_CACHE_CHECK([whether realpath works], [gl_cv_func_realpath_works], [
68 char *name1 = realpath ("conftest.a", NULL);
69 char *name2 = realpath ("conftest.b/../conftest.a", NULL);
70 char *name3 = realpath ("conftest.a/", NULL);
71 return !(name1 && *name1 == '/' && !name2 && !name3);
73 ], [gl_cv_func_realpath_works=yes], [gl_cv_func_realpath_works=no],
74 [gl_cv_func_realpath_works="guessing no"])
76 if test "$gl_cv_func_realpath_works" = yes; then
77 AC_DEFINE([FUNC_REALPATH_WORKS], [1], [Define to 1 if realpath()
78 can malloc memory, always gives an absolute path, and handles
79 trailing slash correctly.])