From 732e1530e3ef48c225295e81fe84ed282eef3a39 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 25 Aug 2022 14:44:43 +0100 Subject: [PATCH] autotools: Require GNU sort find_lib() uses sort -V, which is a GNU extension. Users of non-GNU operating systems should either install GNU coreutils (assumed to provide a gsort executable), or use the CMake build system. Resolves: https://github.com/libsdl-org/SDL/issues/6106 Signed-off-by: Simon McVittie --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 55ba94972..4d2249f54 100644 --- a/configure.ac +++ b/configure.ac @@ -70,6 +70,9 @@ if [ test -z "$AWK" ]; then AC_MSG_ERROR([*** awk not found, aborting]) fi +AC_CHECK_PROGS([SORT], [gsort sort], [false]) +AS_IF([! "$SORT" -V /dev/null], [AC_MSG_ERROR([GNU sort(1) is required])]) + dnl 64-bit file offsets if possible unless --disable-largefile is specified AC_SYS_LARGEFILE @@ -186,7 +189,7 @@ find_lib() host_lib_path="/usr/$base_libdir /usr/local/$base_libdir" fi for path in $env_lib_path $gcc_bin_path $gcc_lib_path $host_lib_path; do - lib=[`ls -- $path/$1 2>/dev/null | sed 's,.*/,,' | sort -V -r | $AWK 'BEGIN{FS="."}{ print NF, $0 }' | sort -n -s | sed 's,[0-9]* ,,' | head -1`] + lib=[`ls -- $path/$1 2>/dev/null | sed 's,.*/,,' | "$SORT" -V -r | $AWK 'BEGIN{FS="."}{ print NF, $0 }' | "$SORT" -n -s | sed 's,[0-9]* ,,' | head -1`] if test x$lib != x; then echo $lib return