Merge pull request #176 from rolk/176_optcheck
Perform option checking in ./configure like autotools does
This commit is contained in:
commit
3a096c5810
40
configure
vendored
40
configure
vendored
@ -74,11 +74,17 @@ Try \`$0 --help' for more information
|
||||
EOF
|
||||
}
|
||||
|
||||
# exit only if option checking is enabled, otherwise ignore
|
||||
# notify the user that this argument is not known
|
||||
unknown_arg () {
|
||||
cat <<EOF
|
||||
configure: warning: unrecognized option: \`$1'
|
||||
EOF
|
||||
}
|
||||
|
||||
# warn only if option checking is enabled
|
||||
invalid_opt () {
|
||||
if [ "${option_check}" = "yes" ]; then
|
||||
invalid_arg $@
|
||||
exit 1
|
||||
unknown_arg $@
|
||||
fi
|
||||
}
|
||||
|
||||
@ -91,11 +97,16 @@ pch_use=
|
||||
silent_rules=
|
||||
#debug_loc=" -DSYSTEM_DEBUG=OFF"
|
||||
debug_loc=
|
||||
|
||||
# default is to warn for unknown options, but this can be disabled
|
||||
option_check=yes
|
||||
|
||||
# this variable will get feature options
|
||||
FEATURES=
|
||||
|
||||
# this array will get all variable assignments from command-line
|
||||
VARS=()
|
||||
|
||||
# command that launches cmake; look for 2.8 if available
|
||||
if [ "${CMAKE_COMMAND}" = "" ]; then
|
||||
if which cmake28 >/dev/null 2>&1; then
|
||||
@ -105,12 +116,10 @@ if [ "${CMAKE_COMMAND}" = "" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# long arguments are implemented by putting a dash character followed by
|
||||
# a colon in the optspec, see trick by Arvid Requate at
|
||||
# <http://stackoverflow.com/questions/402377/#7680682>
|
||||
while getopts -- ":-:" optchar; do
|
||||
case "${optchar}" in
|
||||
-)
|
||||
for OPT in "$@"; do
|
||||
case "$OPT" in
|
||||
--*)
|
||||
OPTARG=${OPT#--}
|
||||
# OPTARG now contains everything after double dashes
|
||||
case "${OPTARG}" in
|
||||
prefix=*)
|
||||
@ -137,7 +146,7 @@ while getopts -- ":-:" optchar; do
|
||||
eval pkgloc=$(printf "%q" "${pkgloc}")
|
||||
# expand to full path since CMake changes to source directory (!)
|
||||
# this also normalize the path name wrt. not having a trailing slash
|
||||
pkgloc=$(test -d "${pkgloc}" && sh -c "cd \"${pkgloc}\"; pwd")
|
||||
test -d "${pkgloc}" && pkgloc=$(sh -c "cd \"${pkgloc}\"; pwd")
|
||||
# special aliases
|
||||
case "${pkgname}" in
|
||||
umfpack)
|
||||
@ -271,8 +280,12 @@ while getopts -- ":-:" optchar; do
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
[A-Za-z0-9_]*=*)
|
||||
# collect for further processing later
|
||||
VARS+=("$OPT")
|
||||
;;
|
||||
*)
|
||||
invalid_arg -$OPTARG
|
||||
invalid_arg $OPT
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@ -280,8 +293,9 @@ done
|
||||
# remove all arguments processed by getopts
|
||||
shift $((OPTIND-1))
|
||||
|
||||
# remove Autotools-specific variables
|
||||
for a in "$@"; do
|
||||
# remove Autotools-specific variables. notice the usage of a quoted
|
||||
# array: each element will be returned even with spaces.
|
||||
for a in "${VARS[@]}"; do
|
||||
a="${a/ACLOCAL_*=*/}"
|
||||
[ -n "$a" ] && ENVVARS="$ENVVARS \"${a/\"/\\\"}\""
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user