Commit 8ce10a000938f231690bd249198f93cf781e7924

Thomas de Grivel 2023-01-12T10:25:35

configure --prefix /usr/local

diff --git a/config.subr b/config.subr
index ad2b9df..0b8f7db 100644
--- a/config.subr
+++ b/config.subr
@@ -95,28 +95,16 @@ if test -z "$INSTALL"; then
 fi
 echo "INSTALL = $INSTALL" >> ${CONFIG_MK}
 
-if test -z "$PREFIX"; then
-    if test -d "$HOME/.rtbuf"; then
-        PREFIX="$HOME/.rtbuf"
-    elif test -d /usr/local; then
-        PREFIX=/usr/local
-    elif test -d /usr; then
-        PREFIX=/usr
-    elif test -d /opt/local; then
-        PREFIX=/opt/local
-    elif test -d /opt; then
-        PREFIX=/opt
-    fi
-fi
+PREFIX="${PREFIX:-/usr/local}"
 echo "PREFIX = $PREFIX" >> ${CONFIG_MK}
 
 if test -z "$OWNER"; then
-    OWNER="$(ls -ld "$HOME/.rtbuf/" | tr -s ' ' | cut -d ' ' -f 3)"
+    OWNER="$(ls -ld "$PREFIX/" | tr -s ' ' | cut -d ' ' -f 3)"
 fi
 echo "OWNER = $OWNER" >> ${CONFIG_MK}
 
 if test -z "$GROUP"; then
-    GROUP="$(ls -ld "$HOME/.rtbuf/" | tr -s ' ' | cut -d ' ' -f 4)"
+    GROUP="$(ls -ld "$PREFIX/" | tr -s ' ' | cut -d ' ' -f 4)"
 fi
 echo "GROUP = $GROUP" >> ${CONFIG_MK}
 
diff --git a/configure b/configure
index effdbbc..6e03c0b 100755
--- a/configure
+++ b/configure
@@ -15,6 +15,13 @@ set -e
 
 export SRCDIR="$PWD"
 
+PREFIX="${PREFIX:-/usr/local}"
+if [ "x$1" = "x--prefix" ]; then
+    PREFIX="$2"
+    shift 2
+fi
+export PREFIX
+
 . ./config.subr
 
 RTBUF_DIRS="librtbuf lib cli gtk3"