about summary refs log tree commit diff stats
path: root/configure.ac
diff options
context:
space:
mode:
authorCarlo Cabrera <30379873+carlocab@users.noreply.github.com>2021-11-23 21:57:02 +0800
committerCarlo Cabrera <30379873+carlocab@users.noreply.github.com>2021-11-23 21:57:02 +0800
commit315d862e22ee9d41a897d76a0297b67b877a3960 (patch)
tree02cad90dd1dac5d10b9545d9224ac2b480778090 /configure.ac
parent9a9122c148a8462eb612c7a28ab0f2e3f2f0464e (diff)
downloadprofani-tty-315d862e22ee9d41a897d76a0297b67b877a3960.tar.gz
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.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac15
1 files 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])])],