X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=m4%2Fcanonicalize.m4;fp=m4%2Fcanonicalize.m4;h=47c5c01aded0c0a205eaf08b65d57d5e4d8f405e;hb=4e793c35b62f5ea945b7d33ce36c78fc4d645b3a;hp=1258b3b4a2096e28be412ed29a31b4425e96aff3;hpb=1d43c4ae818052a72c616311a99b3d1ca3bf1cfb;p=gnulib.git diff --git a/m4/canonicalize.m4 b/m4/canonicalize.m4 index 1258b3b4a..47c5c01ad 100644 --- a/m4/canonicalize.m4 +++ b/m4/canonicalize.m4 @@ -1,18 +1,79 @@ -# canonicalize.m4 serial 14 +# canonicalize.m4 serial 15 -# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 Free Software -# Foundation, Inc. +dnl Copyright (C) 2003-2007, 2009 Free Software Foundation, Inc. -# This file is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# Written by Jim Meyering. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. +# Provides canonicalize_file_name and canonicalize_filename_mode, but does +# not provide or fix realpath. AC_DEFUN([gl_FUNC_CANONICALIZE_FILENAME_MODE], [ AC_LIBOBJ([canonicalize]) AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) AC_CHECK_FUNCS_ONCE([canonicalize_file_name]) + AC_REQUIRE([gl_FUNC_REALPATH_WORKS]) + if test $ac_cv_func_canonicalize_file_name = no; then + HAVE_CANONICALIZE_FILE_NAME=0 + elif test $gl_cv_func_realpath_works != yes; then + REPLACE_CANONICALIZE_FILE_NAME=1 + fi +]) + +# Provides canonicalize_file_name and realpath. +AC_DEFUN([gl_CANONICALIZE_LGPL], +[ + AC_REQUIRE([gl_CANONICALIZE_LGPL_SEPARATE]) + if test $ac_cv_func_canonicalize_file_name = no; then + HAVE_CANONICALIZE_FILE_NAME=0 + AC_LIBOBJ([canonicalize-lgpl]) + if test $ac_cv_func_realpath = no; then + HAVE_REALPATH=0 + elif test $gl_cv_func_realpath_works != yes; then + REPLACE_REALPATH=1 + fi + elif test $gl_cv_func_realpath_works != yes; then + AC_LIBOBJ([canonicalize-lgpl]) + REPLACE_REALPATH=1 + REPLACE_CANONICALIZE_FILE_NAME=1 + fi +]) + +# Like gl_CANONICALIZE_LGPL, except prepare for separate compilation +# (no AC_LIBOBJ). +AC_DEFUN([gl_CANONICALIZE_LGPL_SEPARATE], +[ + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_FUNCS_ONCE([canonicalize_file_name getcwd readlink]) + AC_REQUIRE([gl_FUNC_REALPATH_WORKS]) + AC_CHECK_HEADERS_ONCE([sys/param.h]) +]) + +# Check whether realpath works. Assume that if a platform has both +# realpath and canonicalize_file_name, but the former is broken, then +# so is the latter. +AC_DEFUN([gl_FUNC_REALPATH_WORKS], +[ + AC_CHECK_FUNCS_ONCE([realpath]) + AC_CACHE_CHECK([whether realpath works], [gl_cv_func_realpath_works], [ + touch conftest.a + AC_RUN_IFELSE([ + AC_LANG_PROGRAM([[ + #include + ]], [[ + char *name1 = realpath ("conftest.a", NULL); + char *name2 = realpath ("conftest.b/../conftest.a", NULL); + char *name3 = realpath ("conftest.a/", NULL); + return !(name1 && *name1 == '/' && !name2 && !name3); + ]]) + ], [gl_cv_func_realpath_works=yes], [gl_cv_func_realpath_works=no], + [gl_cv_func_realpath_works="guessing no"]) + ]) + if test $gl_cv_func_realpath_works = yes; then + AC_DEFINE([FUNC_REALPATH_WORKS], [1], [Define to 1 if realpath() + can malloc memory, always gives an absolute path, and handles + trailing slash correctly.]) + fi ])