diff options
author | Andreas Fankhauser (@tux-six) | 2022-05-30 17:18:05 +0200 |
---|---|---|
committer | Andreas Fankhauser (@tux-six) | 2022-05-30 17:18:05 +0200 |
commit | d2c0bed52d0a293d5541940dedbfe2b5c9afd2c8 (patch) | |
tree | e2fc2af51d27d5b0df7ac8c932bd0588bcd8ce5d /configure | |
parent | 3f8ac6551aa0f53fd14b216e97e79939635b8b82 (diff) | |
download | bulk-ln-d2c0bed52d0a293d5541940dedbfe2b5c9afd2c8.zip bulk-ln-d2c0bed52d0a293d5541940dedbfe2b5c9afd2c8.tar.gz |
Add 'configure'. Add 'make install'. Format some doc.v0.0.1
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/configure b/configure new file mode 100755 index 0000000..fea5aeb --- /dev/null +++ b/configure @@ -0,0 +1,55 @@ +#!/usr/bin/env sh +set -e + +# See https://www.gnu.org/prep/standards/html_node/Directory-Variables.html +prefix=/usr/local +exec_prefix='$(PREFIX)' +exec_suffix= +bindir='$(EXEC_PREFIX)/bin' + + +main() { + parseArgs "$@" + mangleMakefile +} + + +printHelp() { + echo '' + echo "Example usage: $0 --prefix /usr/local" + echo '' + echo 'Options:' + echo ' --prefix <path> Default "/usr/local"' + echo ' --exec-prefix <path> Default "$(PREFIX)"' + echo ' --exec-suffix <path> Default <empty>' + echo ' --bindir <path> Default "$(EXEC_PREFIX)/bin"' + echo '' +} + + +parseArgs() { + # See: https://stackoverflow.com/a/14203146/4415884 + while test $# -gt 0 ; do + case $1 in + --help) printHelp; exit 1; ;; + --prefix) prefix="$2" shift; shift; ;; + --exec-prefix) exec_prefix="$2" shift; shift; ;; + --exec-suffix) exec_suffix="$2" shift; shift; ;; + --bindir) bindir="$2" shift; shift; ;; + *) echo "[ERROR] Unexpected argument: $1"; exit 1 ;; + esac + done +} + + +mangleMakefile() { + sed -i 's;^PREFIX=.*$;PREFIX='"$prefix"';' Makefile + sed -i 's;^EXEC_PREFIX=.*$;EXEC_PREFIX='"$exec_prefix"';' Makefile + sed -i 's;^EXEC_SUFFIX=.*$;EXEC_SUFFIX='"$exec_suffix"';' Makefile + sed -i 's;^BINDIR=.*$;BINDIR='"$bindir"';' Makefile +} + + +main "$@" + + |