configure.sh: Cleanup argument parsing. Thanks, Timothy!

* configure.sh: Cleanup argument parsing.
This commit is contained in:
Jan Nieuwenhuizen 2019-10-01 19:12:56 +02:00
parent 5de5853c76
commit 732530d9f9
No known key found for this signature in database
GPG Key ID: F3C1A0D9C1D65273
1 changed files with 28 additions and 54 deletions

View File

@ -24,61 +24,35 @@ VERSION=0.20
srcdir=${srcdir-$(dirname $0)} srcdir=${srcdir-$(dirname $0)}
. ${srcdest}build-aux/trace.sh . ${srcdest}build-aux/trace.sh
# parse --with-system-libc # parse arguments
cmdline=$(echo "$@") while [ $# -gt 0 ]; do
p=$(echo $cmdline | sed s,--with-system-libc,,) case $1 in
if test "$p" != "$cmdline"; then (--with-courage)
mes_libc=${mes_libc-system} courageous=true
else ;;
mes_libc=mes (--with-system-libc)
fi mes_libc=system
;;
(--build=*)
build=${1#--build=}
;;
(--host=*)
host=${1#--host=}
;;
(--prefix=*)
prefix=${1#--prefix=}
;;
(--program-prefix=*)
program_prefix=${1#--program-prefix=}
;;
esac
shift
done
# parse --with-courage prefix=${prefix-/usr/local}
cmdline=$(echo " $@") mes_libc=${mes_libc-mes}
p=$(echo $cmdline | sed s,--with-courage,,) courageous=${courageous-false}
if test "$p" != "$cmdline"; then host=${host-$build}
courageous=true
else
courageous=false
fi
# parse --prefix=PREFIX
p=$(echo $cmdline | sed s,.*--prefix=,-prefix=,)
if test "$p" != "$cmdline"; then
p=$(echo $p | sed s,.*-prefix=,,)
p=$(echo $p | sed 's, .*,,')
prefix=${p-/usr/local}
else
prefix=${prefix-/usr/local}
fi
# parse --build=BUILD
p=$(echo $cmdline | sed s,.*--build=,-build=,)
if [ "$p" != "$cmdline" ]; then
p=$(echo $p | sed s,.*-build=,,)
p=$(echo $p | sed 's, .*,,')
build=${p-$build}
else
build=$build
fi
# parse --host=HOST
p=$(echo $cmdline | sed s,.*--host=,-host=,)
if [ "$p" != "$cmdline" ]; then
p=$(echo $p | sed s,.*-host=,,)
p=$(echo $p | sed 's, .*,,')
host=${p-$build}
elif test -n "$build"; then
host=${host-$build}
fi
# parse --program-prefix=
p=$(echo $cmdline | sed s,.*--program-prefix=,-program-prefix=,)
if test "$p" != "$cmdline"; then
p=$(echo $p | sed s,.*-program-prefix=,,)
p=$(echo $p | sed 's, .*,,')
program_prefix=$p
fi
AR=${AR-$(command -v ar)} || true AR=${AR-$(command -v ar)} || true
BASH=${BASH-$(command -v bash)} BASH=${BASH-$(command -v bash)}