miller/configure
Brian Fulton-Howard 39a6ddd782
Allow more typical --prefix= syntax (#744)
Co-authored-by: John Kerl <kerl.john.r@gmail.com>
2021-11-11 14:40:55 -05:00

40 lines
No EOL
931 B
Bash
Executable file

#!/bin/bash
usage() {
echo "Usage: $0 [--prefix {prefix directory}], e.g. /usr/local" 2>&1
echo " or $0 [--prefix={prefix directory}], e.g. /usr/local" 2>&1
exit 1
}
prefix="/usr/local"
if [ $# -eq 0 ]; then
echo "Using $prefix"
elif [ $# -gt 2 ]; then
usage
else
while [ $# -gt 0 ]; do
case "$1" in
-p=* | --prefix=*)
prefix="${1#*=}"
;;
-p | --prefix)
prefix="$2"
shift
;;
*)
printf "Error: unknown option: $1\n"
usage
esac
shift
done
# Test for read access, not write access, since people can ./configure, make,
# and make check outside of sudo and then make install inside sudo.
if [ ! -d "$prefix" ]; then
echo "$0: could not find prefix directory \"$prefix\""
exit 1
fi
fi
sed -I .prefix-backup 's@^PREFIX.*@PREFIX='$prefix'@' Makefile
sed -I .prefix-backup 's@^PREFIX.*@PREFIX='$prefix'@' man/Makefile