Subject: [patch] configure: fix libgccjit detection on MacPorts

From: Dan Ports <[email-masked]>
Date: Fri, 17 Sep 2021 16:19:21 -0700

Tags: patch

The current code in configure checks if a MacPorts gcc port is
installed in order to find libgccjit, but it fails if more than one gcc
port is installed (e.g., both gcc10 and gcc11). 

The attached patch fixes it to return only one version -- specifically,
the latest version (with a bit of ugliness because gcc4x sorts after
gcc11)

Dan

-- 
Dan R. K. Ports                                      https://drkp.net/
diff --git a/configure.ac b/configure.ac
index 1146b581cd..2ef78985ef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3838,9 +3838,11 @@ AC_DEFUN
 
       if test -n "$HAVE_MACPORTS"; then
         # Determine which gcc version has been installed (gcc11, for
-        # instance).
+        # instance). Use the latest version, if more than one is 
+        # available.
         PORT_PACKAGE=$(port installed active | grep '^ *gcc@<:@0-9@:>@* ' | \
-                            awk '{ print $1; }')
+                            awk '{ print $1; }' | grep -v 'gcc4@<:@0-9@:>@' | \
+                            sort -V | tail -n 1)
         if test -n "$PORT_PACKAGE"; then
           MAC_CFLAGS="-I$(dirname $(port contents $PORT_PACKAGE | \
                                            grep libgccjit.h))"