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
|
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 () {
|
invalid_opt () {
|
||||||
if [ "${option_check}" = "yes" ]; then
|
if [ "${option_check}" = "yes" ]; then
|
||||||
invalid_arg $@
|
unknown_arg $@
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +97,16 @@ pch_use=
|
|||||||
silent_rules=
|
silent_rules=
|
||||||
#debug_loc=" -DSYSTEM_DEBUG=OFF"
|
#debug_loc=" -DSYSTEM_DEBUG=OFF"
|
||||||
debug_loc=
|
debug_loc=
|
||||||
|
|
||||||
|
# default is to warn for unknown options, but this can be disabled
|
||||||
option_check=yes
|
option_check=yes
|
||||||
|
|
||||||
# this variable will get feature options
|
# this variable will get feature options
|
||||||
FEATURES=
|
FEATURES=
|
||||||
|
|
||||||
|
# this array will get all variable assignments from command-line
|
||||||
|
VARS=()
|
||||||
|
|
||||||
# command that launches cmake; look for 2.8 if available
|
# command that launches cmake; look for 2.8 if available
|
||||||
if [ "${CMAKE_COMMAND}" = "" ]; then
|
if [ "${CMAKE_COMMAND}" = "" ]; then
|
||||||
if which cmake28 >/dev/null 2>&1; then
|
if which cmake28 >/dev/null 2>&1; then
|
||||||
@ -105,12 +116,10 @@ if [ "${CMAKE_COMMAND}" = "" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# long arguments are implemented by putting a dash character followed by
|
for OPT in "$@"; do
|
||||||
# a colon in the optspec, see trick by Arvid Requate at
|
case "$OPT" in
|
||||||
# <http://stackoverflow.com/questions/402377/#7680682>
|
--*)
|
||||||
while getopts -- ":-:" optchar; do
|
OPTARG=${OPT#--}
|
||||||
case "${optchar}" in
|
|
||||||
-)
|
|
||||||
# OPTARG now contains everything after double dashes
|
# OPTARG now contains everything after double dashes
|
||||||
case "${OPTARG}" in
|
case "${OPTARG}" in
|
||||||
prefix=*)
|
prefix=*)
|
||||||
@ -137,7 +146,7 @@ while getopts -- ":-:" optchar; do
|
|||||||
eval pkgloc=$(printf "%q" "${pkgloc}")
|
eval pkgloc=$(printf "%q" "${pkgloc}")
|
||||||
# expand to full path since CMake changes to source directory (!)
|
# expand to full path since CMake changes to source directory (!)
|
||||||
# this also normalize the path name wrt. not having a trailing slash
|
# 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
|
# special aliases
|
||||||
case "${pkgname}" in
|
case "${pkgname}" in
|
||||||
umfpack)
|
umfpack)
|
||||||
@ -271,8 +280,12 @@ while getopts -- ":-:" optchar; do
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
[A-Za-z0-9_]*=*)
|
||||||
|
# collect for further processing later
|
||||||
|
VARS+=("$OPT")
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
invalid_arg -$OPTARG
|
invalid_arg $OPT
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
@ -280,8 +293,9 @@ done
|
|||||||
# remove all arguments processed by getopts
|
# remove all arguments processed by getopts
|
||||||
shift $((OPTIND-1))
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
# remove Autotools-specific variables
|
# remove Autotools-specific variables. notice the usage of a quoted
|
||||||
for a in "$@"; do
|
# array: each element will be returned even with spaces.
|
||||||
|
for a in "${VARS[@]}"; do
|
||||||
a="${a/ACLOCAL_*=*/}"
|
a="${a/ACLOCAL_*=*/}"
|
||||||
[ -n "$a" ] && ENVVARS="$ENVVARS \"${a/\"/\\\"}\""
|
[ -n "$a" ] && ENVVARS="$ENVVARS \"${a/\"/\\\"}\""
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user