summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2023-02-19 17:43:12 -0500
committerPaul Smith <psmith@gnu.org>2023-02-19 17:43:12 -0500
commitac159491da0f837f7a4b23591c15c1b1d78eb616 (patch)
tree7672b3bc1bc652297318ea24f52d901514dd11ee
parent44366555681f7a855ecf7df987967649c7ff3595 (diff)
downloadmake-git-ac159491da0f837f7a4b23591c15c1b1d78eb616.tar.gz
* gl/modules/make-glob: Avoid glibc glob if bug #866 is present
-rw-r--r--configure.ac4
-rw-r--r--gl/modules/make-glob68
2 files changed, 55 insertions, 17 deletions
diff --git a/configure.ac b/configure.ac
index 2f1168e9..ac183b54 100644
--- a/configure.ac
+++ b/configure.ac
@@ -353,14 +353,14 @@ AS_CASE([/$make_cv_load/$user_load/],
# For example passing -rdynamic to the SunPRO linker gives a warning
# but succeeds and creates a shared object, not an executable!
AS_IF([test "$make_cv_load" = yes], [
- AC_MSG_CHECKING([If the linker accepts -Wl,--export-dynamic])
+ AC_MSG_CHECKING([if the linker accepts -Wl,--export-dynamic])
old_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){}])],
[AC_MSG_RESULT([yes])
AC_SUBST([AM_LDFLAGS], [-Wl,--export-dynamic])],
[AC_MSG_RESULT([no])
- AC_MSG_CHECKING([If the linker accepts -rdynamic])
+ AC_MSG_CHECKING([if the linker accepts -rdynamic])
LDFLAGS="$old_LDFLAGS -rdynamic"
AC_LINK_IFELSE([AC_LANG_SOURCE([int main(){}])],
[AC_MSG_RESULT([yes])
diff --git a/gl/modules/make-glob b/gl/modules/make-glob
index 3b6cdee2..1193ed97 100644
--- a/gl/modules/make-glob
+++ b/gl/modules/make-glob
@@ -10,21 +10,59 @@ lib/glob.in.h
configure.ac:
# Check the system to see if it provides GNU glob. If not, use our
-# local version.
-AC_CACHE_CHECK([if system libc has GNU glob], [make_cv_sys_gnu_glob],
-[ AC_EGREP_CPP([gnu glob],[
-#include <features.h>
-#include <glob.h>
-#include <fnmatch.h>
-
-#if !defined _LIBC && defined __GNU_LIBRARY__ && __GNU_LIBRARY__ > 1
-# include <gnu-versions.h>
-# if _GNU_GLOB_INTERFACE_VERSION == 1 || _GNU_GLOB_INTERFACE_VERSION == 2
- gnu glob
-# endif
-#endif],
- [make_cv_sys_gnu_glob=yes],
- [make_cv_sys_gnu_glob=no])])
+# local version. Also avoid versions of glibc which have symlink bug
+# https://sourceware.org/bugzilla/show_bug.cgi?id=866 (test from gnulib)
+AC_CACHE_CHECK([if system libc has working GNU glob], [make_cv_sys_gnu_glob],[
+ if ln -s conf-doesntexist conf$$-globtest 2>/dev/null; then
+ make_check_symlink=yes
+ else
+ make_check_symlink=no
+ fi
+ if test $cross_compiling = yes || test $make_check_symlink = no; then
+ # When cross-compiling or without symlink support, check the version
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <features.h>
+ #include <gnu-versions.h>
+ #include <glob.h>
+ #include <fnmatch.h>
+ ]],
+ [[
+ #if _GNU_GLOB_INTERFACE_VERSION == 0
+ GNU glob not available in libc
+ #elif __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 27)
+ GNU glob in libc has dangling symlink bug
+ #endif
+ ]])],
+ [make_cv_sys_gnu_glob=yes],
+ [make_cv_sys_gnu_glob=no])
+ else
+ # Check for GNU glob, and that it handles dangling symlinks properly
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <features.h>
+ #include <gnu-versions.h>
+ #include <glob.h>
+ #include <fnmatch.h>
+ ]],
+ [[
+ #if _GNU_GLOB_INTERFACE_VERSION == 0
+ return 1;
+ #else
+ glob_t found;
+ if (glob ("conf*-globtest", 0, 0, &found) == GLOB_NOMATCH)
+ return 1;
+ globfree (&found);
+ #endif
+ ]])],
+ [make_cv_sys_gnu_glob=yes],
+ [make_cv_sys_gnu_glob=no],
+ [dnl We don't get here.
+ :
+ ])
+ fi
+ test $make_check_symlink = no || rm -f conf$$-globtest
+])
# Tell automake about this, so it can build the right .c files.
AM_CONDITIONAL([USE_SYSTEM_GLOB], [test "$make_cv_sys_gnu_glob" = yes])