From: =?utf-8?q?Guido_G=C3=BCnther?= <agx@sigxcpu.org>
Date: Sun, 17 Sep 2023 11:42:13 +0200
Subject: install_all_schemes: Allow to install with prefix and without sudo

---
 build_all_schemes.sh   | 2 ++
 build_scheme.sh        | 2 ++
 install_all_schemes.sh | 8 ++++++--
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/build_all_schemes.sh b/build_all_schemes.sh
index 2744b8d..fd19336 100755
--- a/build_all_schemes.sh
+++ b/build_all_schemes.sh
@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
+set -e
+
 schemes=("as" "bn" "gu" "hi" "kn" "ml" "ml-inscript" "mr" "ne" "or" "pa" "sa" "ta" "te")
 for f in ${schemes[@]}; do
   ./build_scheme.sh $f
diff --git a/build_scheme.sh b/build_scheme.sh
index e64a3a7..9bfe91c 100755
--- a/build_scheme.sh
+++ b/build_scheme.sh
@@ -1,5 +1,7 @@
 #!/usr/bin/env bash
 
+set -e
+
 f=$1
 vst=schemes/$f/$f.vst
 ./compile-scheme.rb -s schemes/$f/$f.scheme -o $vst
diff --git a/install_all_schemes.sh b/install_all_schemes.sh
index 2530b39..ad2570a 100755
--- a/install_all_schemes.sh
+++ b/install_all_schemes.sh
@@ -1,7 +1,11 @@
 #!/usr/bin/env bash
 
-sudo mkdir -p /usr/local/share/varnam/schemes/
+set -e
+
+PREFIX=${PREFIX:-/usr/local}
+
+mkdir -p "${DESTDIR}${PREFIX}/share/varnam/schemes/"
 for scheme in schemes/*/*.vst; do
   echo $scheme;
-  sudo cp $scheme /usr/local/share/varnam/schemes/
+  cp $scheme "${DESTDIR}${PREFIX}/share/varnam/schemes/"
 done
