From 067b8373d71290eda3263e8f62b29d1ecfa30034 Mon Sep 17 00:00:00 2001 From: Steve Youngs Date: Tue, 28 May 2019 21:34:27 +1000 Subject: [PATCH] Get glibc version with a distro-agnostic check. This replaces all the distro specific little tests we had to determine the glibc version. It's guaranteed to work on any version of glibc running on any platform. It simply calls gnu_get_libc_version(). * m4/sxe-libc.m4 (SXE_CHECK_LIBC_VERSION): Simplify for Linux glibc. Signed-off-by: Steve Youngs --- m4/sxe-libc.m4 | 105 +++++++++++++++++++++---------------------------- 1 file changed, 45 insertions(+), 60 deletions(-) diff --git a/m4/sxe-libc.m4 b/m4/sxe-libc.m4 index 10a414b..2a68829 100644 --- a/m4/sxe-libc.m4 +++ b/m4/sxe-libc.m4 @@ -121,69 +121,54 @@ AC_DEFUN([SXE_CHECK_LIBC_VERSION], [dnl libc_version="" AC_MSG_CHECKING(for standard C library version information) - case "$ac_cv_build" in - *-*-linux*) - dnl #### who would ever _not_ be running the distro's libc? - dnl Whose silly question is this? -hroptatyr - dnl Maybe it would be better to get/augment this info with ldd? - if test -f /etc/redhat-release ; then - libc_version=`rpm -q glibc` - elif test -f /etc/debian_version ; then - libc_version=`dpkg-query --showformat='${version}' --show libc6` - libc_version="GNU libc $libc_version (Debian)" - elif test -f /etc/slackware-version ; then - slackver=`cat /etc/slackware-version` - libc_version=`/lib/libc.so.6|head -1|cut -d ' ' -f7|tr -d ,` - if test "x$libc_version" = "x"; then - libc_version=`/lib64/libc.so.6|head -1|cut -d ' ' -f7|tr -d ,` - fi - libc_version="GNU libc $libc_version ($slackver)" - dnl need SuSE et al checks here... - fi - dnl #### Tested on Debian, does this actually work elsewhere? ;-) - dnl #### NO! -hroptatyr - dnl if test -z "$libc_version"; then - dnl libc_version=`ls /lib/libc-*.so | sed -e 's,/lib/libc-\(.*\)\.so,\1,'` - dnl fi - - if test -z "$libc_version"; then + if test "$have_glibc" = "yes"; then AC_RUN_IFELSE([AC_LANG_SOURCE([[ -int main() { return 0; }]])], [dnl -libc_file_we_use=`$LDD ./conftest | grep libc | sed -e "s/.*=>\(.*\) .*$/\1/"`], - [],[libc_file_we_use=]) - libc_version=`$libc_file_we_use 2>/dev/null | sed "/version/q" | tr -cd "0-9.()"` +#include +#include +int main(void) { puts (gnu_get_libc_version()); return 0; }]])], [dnl +libc_version=`./conftest`], [libc_version=""], + [AC_MSG_WARN([Cross-compiling? Good luck. Let us know how it goes.])] + if test -f /etc/os-release; then + source /etc/os-release + libc_version="GNU libc $libc_version (${PRETTY_NAME})" + else + libc_version="GNU libc $libc_version (Unknown OS)" fi - ;; - - *-*-aix*) - libc_version="bos.rte.libc `lslpp -Lqc bos.rte.libc | cut -f3 -d:`" - ;; - - *-*-solaris*) - libc=`pkginfo -l SUNWcsl | grep VERSION: | awk '{print $2}'` - libc_version="SUNWcsl $libc" - ;; - - mips-sgi-irix*) - libc_version="IRIX libc `uname -sRm`" - ;; - - alpha*-dec-osf*) - dnl Another ugly case - (cd /usr/.smdb.; - libc_version=` grep -h libc.so *.inv | awk '$9 == "f" {print $12}' | tr '\n' ','` - ) - ;; - - *-apple-darwin*) - dnl MacOS guys, does this work? - libc_version="`$LDD /usr/lib/libc.dylib | head -n1 | sed -e 's/.*current version[ ]*\([0-9.]*\).*$/\1/'`" - ;; + fi - *) - libc_version="" - ;; - esac + dnl Amazingly some people don't run Linux, or so I'm told. --SY + if test -z "$libc_version"; then + case "$ac_cv_build" in + *-*-aix*) + libc_version="bos.rte.libc `lslpp -Lqc bos.rte.libc | cut -f3 -d:`" + ;; + + *-*-solaris*) + libc=`pkginfo -l SUNWcsl | grep VERSION: | awk '{print $2}'` + libc_version="SUNWcsl $libc" + ;; + + mips-sgi-irix*) + libc_version="IRIX libc `uname -sRm`" + ;; + + alpha*-dec-osf*) + dnl Another ugly case + (cd /usr/.smdb.; + libc_version=` grep -h libc.so *.inv | awk '$9 == "f" {print $12}' | tr '\n' ','` + ) + ;; + + *-apple-darwin*) + dnl MacOS guys, does this work? + libc_version="`$LDD /usr/lib/libc.dylib | head -n1 | sed -e 's/.*current version[ ]*\([0-9.]*\).*$/\1/'`" + ;; + + *) + libc_version="" + ;; + esac + fi AC_MSG_RESULT($libc_version) -- 2.25.1