From 315d862e22ee9d41a897d76a0297b67b877a3960 Mon Sep 17 00:00:00 2001 From: Carlo Cabrera <30379873+carlocab@users.noreply.github.com> Date: Tue, 23 Nov 2021 21:57:02 +0800 Subject: [PATCH] Make readline check more portable Currently, `configure.ac` assumes Readline is installed via Homebrew in `/usr/local`. This doesn't work for Homebrew on Apple Silicon, or MacPorts. Let's fix this by checking for a `brew` installation, and querying that for Readline's prefix if available. If not, it checks for an existing MacPorts prefix, and finally falls back to checking `/usr/local` in case a user installed Readline for themselves there. --- configure.ac | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 566c3c80..709594d3 100644 --- a/configure.ac +++ b/configure.ac @@ -210,10 +210,19 @@ AS_IF([test "x$enable_icons_and_clipboard" != xno], [AC_MSG_NOTICE([gtk+-3.0/gtk+2.0 not found, icons and clipboard not enabled])])])])]) AS_IF([test "x$PLATFORM" = xosx], - [AC_CHECK_FILE([/usr/local/opt/readline/lib], + [AC_PATH_PROG([BREW], [brew], ["failed"], + [$PATH$PATH_SEPARATOR/opt/homebrew/bin$PATH_SEPARATOR/usr/local/bin]) + AS_IF([test "x$BREW" = xfailed], + [AC_CHECK_FILE([/opt/local/lib], + [READLINE_PREFIX="/opt/local"], + [READLINE_PREFIX="/usr/local"])], + [READLINE_PREFIX="`$BREW --prefix readline`"])]) + +AS_IF([test "x$PLATFORM" = xosx], + [AC_CHECK_FILE([$READLINE_PREFIX/lib], [LIBS="-lreadline $LIBS" - AM_CPPFLAGS="-I/usr/local/opt/readline/include $AM_CPPFLAGS" - AM_LDFLAGS="-L/usr/local/opt/readline/lib $AM_LDFLAGS" + AM_CPPFLAGS="-I$READLINE_PREFIX/include $AM_CPPFLAGS" + AM_LDFLAGS="-L$READLINE_PREFIX/lib $AM_LDFLAGS" AC_SUBST(AM_LDFLAGS)], [AC_MSG_ERROR([libreadline is required for profanity])])],