aboutsummaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2019-08-19 14:08:14 +0200
committerFlorian Dold <florian.dold@gmail.com>2019-08-19 14:08:14 +0200
commit10df69131f70c63a94247edf38f40ba5a31ae54e (patch)
tree111bcc00eab8a268c7207b2eda28c8517e0641f6 /configure
parent54fec752796846389ae187834c19e5720a1c43a8 (diff)
adhere better to GNU guidlines
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure57
1 files changed, 57 insertions, 0 deletions
diff --git a/configure b/configure
index 3ec6d4d12..ede3a9164 100755
--- a/configure
+++ b/configure
@@ -2,6 +2,63 @@
set -eu
+prefix=/usr/local
+
+usage() {
+ echo "Usage: ./configure [OPTION]"
+ echo
+ echo "Configuration:"
+ echo " -h, --help display this help and exit"
+ echo
+ echo "Installation directories:"
+ echo " --prefix=PREFIX install architecture-independent files in PREFIX [$prefix]"
+}
+
+
+# -allow a command to fail with !’s side effect on errexit
+# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
+! getopt --test > /dev/null
+if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
+ echo 'getopt not available'
+ exit 1
+fi
+
+LONGOPTS=prefix:,help
+OPTIONS=h
+
+! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
+if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
+ # e.g. return value is 1
+ # then getopt has complained about wrong arguments to stdout
+ exit 2
+fi
+
+# read getopt’s output this way to handle the quoting right:
+eval set -- "$PARSED"
+
+while true; do
+ case "$1" in
+ --prefix)
+ prefix="$2"
+ shift 2
+ ;;
+ -h|--help)
+ usage
+ exit 1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Programming error"
+ exit 3
+ ;;
+ esac
+done
+
+echo "prefix=$prefix" >config.mk
+
node_version=$(node --version)
if [ ! "$?" -eq 0 ]; then
echo 'Error: node executable not found.'