On Sun, 2023-02-19 at 22:15 +0100, Bruno Haible wrote: > gnulib/m4/glob.m4 contains a test for this bug:
Thanks! I adapted this for GNU make and hopefully it will correctly detect this issue. # Check the system to see if it provides GNU glob. If not, use our # 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 ])