Commit 0b1c7610 authored by mark's avatar mark
Browse files

STYLE: provide 'die' as alternative to 'usage'

- make option parsing more consistent
parent b66ec91d
...@@ -69,17 +69,16 @@ do ...@@ -69,17 +69,16 @@ do
;; ;;
-f | -force) -f | -force)
forceOpt=true forceOpt=true
shift
;; ;;
[1-9]* | qt-[1-9]*) [1-9]* | qt-[1-9]*)
qtVERSION="${1%%/}"; qtVERSION="${1%%/}";
qtVERSION="${qtVERSION#qt-}" qtVERSION="${qtVERSION#qt-}"
shift
;; ;;
*) *)
usage "unknown option/argument: '$*'" die "unknown option/argument: '$1'"
;; ;;
esac esac
shift
done done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
......
...@@ -61,6 +61,17 @@ then ...@@ -61,6 +61,17 @@ then
fi fi
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error: see '${0##*/} -help' for usage"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
exit 1
}
# Test if it matches "*-none" # Test if it matches "*-none"
_foamIsNone() _foamIsNone()
{ {
......
...@@ -90,23 +90,19 @@ do ...@@ -90,23 +90,19 @@ do
;; ;;
lib|libso) lib|libso)
targetType="$1" targetType="$1"
shift
;; ;;
libccmio-[1-9]*) libccmio-[1-9]*)
ccmioPACKAGE="${1%%/}" ccmioPACKAGE="${1%%/}"
shift
;; ;;
*) *)
usage "unknown option/argument: '$*'" die "unknown option/argument: '$1'"
;; ;;
esac esac
shift
done done
# warn if unavailable # assert: directory must be available
if [ ! -d ${ccmioPACKAGE} ] [ -d "${ccmioPACKAGE}" ] || die "missing source directory '$ccmioPACKAGE'"
then
usage "missing source directory '$ccmioPACKAGE'"
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
......
...@@ -106,40 +106,32 @@ do ...@@ -106,40 +106,32 @@ do
;; ;;
-gcc) -gcc)
export CXX=g++ # use g++ export CXX=g++ # use g++
shift
;; ;;
-sys*) -sys*)
gmpPACKAGE="gmp-system" gmpPACKAGE="gmp-system"
mpfrPACKAGE="mpfr-system" mpfrPACKAGE="mpfr-system"
boostPACKAGE="boost-system" boostPACKAGE="boost-system"
shift
;; ;;
gmp-[4-9]* | gmp-system) gmp-[4-9]* | gmp-system)
gmpPACKAGE="${1%%/}" gmpPACKAGE="${1%%/}"
shift
;; ;;
mpfr-[2-9]* | mpfr-system) mpfr-[2-9]* | mpfr-system)
mpfrPACKAGE="${1%%/}" mpfrPACKAGE="${1%%/}"
shift
;; ;;
CGAL-[0-9]*) CGAL-[0-9]*)
cgalPACKAGE="${1%%/}" cgalPACKAGE="${1%%/}"
shift
;; ;;
boost-[0-9]* | boost_[0-9]* | boost-system ) boost-[0-9]* | boost_[0-9]* | boost-system )
boostPACKAGE="${1%%/}" boostPACKAGE="${1%%/}"
shift
;; ;;
*) *)
usage "unknown option/argument: '$*'" die "unknown option/argument: '$1'"
;; ;;
esac esac
shift
done done
if [ -z "$cgalPACKAGE" ] [ -n "$cgalPACKAGE" ] || die "The cgal-VERSION was not specified"
then
usage "The cgal-VERSION was not specified"
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# #
......
...@@ -74,16 +74,15 @@ do ...@@ -74,16 +74,15 @@ do
-gcc) -gcc)
export CC=gcc # use gcc export CC=gcc # use gcc
export CXX=g++ # use g++ export CXX=g++ # use g++
shift
;; ;;
cmake-[1-9]*) cmake-[1-9]*)
cmakePACKAGE="${1%%/}" cmakePACKAGE="${1%%/}"
shift
;; ;;
*) *)
usage "unknown option/argument: '$*'" die "unknown option/argument: '$1'"
;; ;;
esac esac
shift
done done
......
...@@ -91,41 +91,32 @@ do ...@@ -91,41 +91,32 @@ do
;; ;;
-no-multi*) -no-multi*)
GCC_BUILD_OPTIONS="--disable-multilib" GCC_BUILD_OPTIONS="--disable-multilib"
shift
;; ;;
-sys*) -sys*)
gmpPACKAGE="gmp-system" gmpPACKAGE="gmp-system"
mpfrPACKAGE="mpfr-system" mpfrPACKAGE="mpfr-system"
mpcPACKAGE="mpc-system" mpcPACKAGE="mpc-system"
shift
;; ;;
gmp-[4-9]* | gmp-system) gmp-[4-9]* | gmp-system)
gmpPACKAGE="${1%%/}" gmpPACKAGE="${1%%/}"
shift
;; ;;
mpfr-[2-9]* | mpfr-system) mpfr-[2-9]* | mpfr-system)
mpfrPACKAGE="${1%%/}" mpfrPACKAGE="${1%%/}"
shift
;; ;;
mpc-[0-9]* | mpc-system) mpc-[0-9]* | mpc-system)
mpcPACKAGE="${1%%/}" mpcPACKAGE="${1%%/}"
shift
;; ;;
gcc-[4-9]*) gcc-[4-9]*)
gccPACKAGE="${1%%/}" gccPACKAGE="${1%%/}"
shift
;; ;;
*) *)
usage "unknown option/argument: '$*'" die "unknown option/argument: '$1'"
;; ;;
esac esac
shift
done done
if [ -z "$gccPACKAGE" ] [ -n "$gccPACKAGE" ] || die "The gcc-VERSION was not specified"
then
usage "Please specify gcc-VERSION"
exit 1
fi
cat<<SUMMARY cat<<SUMMARY
GCC configuration GCC configuration
...@@ -143,7 +134,7 @@ case "$WM_ARCH_OPTION" in ...@@ -143,7 +134,7 @@ case "$WM_ARCH_OPTION" in
ABI=$WM_ARCH_OPTION ABI=$WM_ARCH_OPTION
;; ;;
*) *)
usage "Please set WM_ARCH_OPTION to either 32 or 64'$*'" die "The WM_ARCH_OPTION ($WM_ARCH_OPTION) must be 32 or 64"
;; ;;
esac esac
......
...@@ -69,12 +69,12 @@ do ...@@ -69,12 +69,12 @@ do
;; ;;
gperftools-[0-9]* | gperftools-svn*) gperftools-[0-9]* | gperftools-svn*)
gperftoolsPACKAGE="${1%%/}" gperftoolsPACKAGE="${1%%/}"
shift
;; ;;
*) *)
usage "unknown option/argument: '$*'" die "unknown option/argument: '$1'"
;; ;;
esac esac
shift
done done
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
......
...@@ -86,19 +86,15 @@ do ...@@ -86,19 +86,15 @@ do
;; ;;
llvm-[0-9]* | llvm-svn*) llvm-[0-9]* | llvm-svn*)
llvmPACKAGE="${1%%/}" llvmPACKAGE="${1%%/}"
shift
;; ;;
*) *)
usage "unknown option/argument: '$*'" die "unknown option/argument: '$1'"
;; ;;
esac esac
shift
done done
if [ -z "$llvmPACKAGE" ] [ -n "$llvmPACKAGE" ] || die "The llvm-VERSION was not specified"
then
die "The llvm-VERSION was not specified"
exit 1
fi
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# build/install without compiler name # build/install without compiler name
......
...@@ -78,6 +78,7 @@ CMAKE_PATH="" ...@@ -78,6 +78,7 @@ CMAKE_PATH=""
Script=${0##*/} Script=${0##*/}
usage() { usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
...@@ -159,138 +160,118 @@ do ...@@ -159,138 +160,118 @@ do
;; ;;
[A-Z]*=*) # cmake variables [A-Z]*=*) # cmake variables
addCMakeVariable "$1" addCMakeVariable "$1"
shift
;; ;;
-gcc) -gcc)
export CXX=g++ # use g++ export CXX=g++ # use g++
shift
;; ;;
-patch) # stage 0: patch sources -patch) # stage 0: patch sources
runPATCH=true runPATCH=true
unset runDEFAULT unset runDEFAULT
shift
;; ;;
-no-patch) -no-patch)
runPATCH=false runPATCH=false
shift
;; ;;
-config) # stage 1: config only -config) # stage 1: config only
runCONFIG=true runCONFIG=true
unset runDEFAULT unset runDEFAULT
shift
;; ;;
-no-config) -no-config)
runCONFIG=false runCONFIG=false
shift
;; ;;
-make) # stage 2: make only -make) # stage 2: make only
runMAKE=true runMAKE=true
unset runDEFAULT unset runDEFAULT
shift
;; ;;
-no-make) -no-make)
runMAKE=false runMAKE=false
shift
;; ;;
-install) # stage 3: install only -install) # stage 3: install only
runINSTALL=true runINSTALL=true
unset runDEFAULT unset runDEFAULT
shift
;; ;;
-no-install) -no-install)
runINSTALL=false runINSTALL=false
shift
;; ;;
-rebuild) # shortcut for rebuilding -rebuild) # shortcut for rebuilding
runMAKE=true runMAKE=true
runINSTALL=true runINSTALL=true
unset runDEFAULT unset runDEFAULT
shift
;; ;;
-mesa) -mesa)
withMESA=true withMESA=true
shift
;; ;;
-no-mesa) -no-mesa)
withMESA=false withMESA=false
shift
;; ;;
-mesa-include) -mesa-include)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || die "'$1' option requires an argument"
MESA_INCLUDE="$2" MESA_INCLUDE="$2"
shift 2 shift
;; ;;
-mesa-lib) -mesa-lib)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || die "'$1' option requires an argument"
MESA_LIBRARY="$2" MESA_LIBRARY="$2"
shift 2 shift
;; ;;
-mpi) -mpi)
withMPI=true withMPI=true
shift
;; ;;
-no-mpi) -no-mpi)
withMPI=false withMPI=false
shift
;; ;;
-python) -python)
withPYTHON=true withPYTHON=true
shift
;; ;;
-no-python) -no-python)
withPYTHON=false withPYTHON=false
shift
;; ;;
-python-lib) -python-lib)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || die "'$1' option requires an argument"
PYTHON_LIBRARY="$2" PYTHON_LIBRARY="$2"
shift 2 shift
;; ;;
-cmake) -cmake)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || die "'$1' option requires an argument"
CMAKE_PATH=$2 CMAKE_PATH=$2
shift 2 shift
;; ;;
-qmake) -qmake)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || die "'$1' option requires an argument"
QMAKE_PATH=$2 QMAKE_PATH=$2
shift 2 shift
;; ;;
-qt) -qt)
withQT=true withQT=true
shift
;; ;;
-no-qt) -no-qt)
withQT=false withQT=false
shift
;; ;;
-qt-[1-9]*) -qt-[1-9]*)
QMAKE_PATH="$installBASE/${1##-}" QMAKE_PATH="$installBASE/${1##-}"
shift
;; ;;
-verbose) -verbose)
withVERBOSE=true withVERBOSE=true
shift
;; ;;
-version) -version)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || die "'$1' option requires an argument"
setVersion "$2" setVersion "$2"
shift 2 shift
;; ;;
-major) -major)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || die "'$1' option requires an argument"
export ParaView_MAJOR="$2" export ParaView_MAJOR="$2"
shift 2 shift
;; ;;
-buildType) -buildType)
[ "$#" -ge 2 ] || usage "'$1' option requires an argument" [ "$#" -ge 2 ] || die "'$1' option requires an argument"
buildType="$2" buildType="$2"
shift 2 shift
;; ;;
*) *)
usage "unknown option/argument: '$*'" die "unknown option/argument: '$1'"
;; ;;
esac esac
shift
done done
......
...@@ -78,6 +78,7 @@ CMAKE_PATH="" ...@@ -78,6 +78,7 @@ CMAKE_PATH=""
Script=${0##*/} Script=${0##*/}
usage() { usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE cat<<USAGE
...@@ -156,124 +157,106 @@ do ...@@ -156,124 +157,106 @@ do
;; ;;
[A-Z]*=*) # cmake variables [A-Z]*=*) # cmake variables
addCMakeVariable "$1" addCMakeVariable "$1"
shift
;; ;;
-gcc) -gcc)
export CXX=g++ # use g++ export CXX=g++ # use g++
shift
;; ;;
-config) # stage 1: config only -config) # stage 1: config only
runCONFIG=true runCONFIG=true
unset runDEFAULT unset runDEFAULT
shift
;; ;;
-no-config) -no-config)
runCONFIG=false runCONFIG=false
shift
;; ;;
-make) # stage 2: make only -make) # stage 2: make only
runMAKE=true runMAKE=true
unset runDEFAULT unset runDEFAULT
shift
;; ;;
-no-make) -no-make)
runMAKE=false runMAKE=false
shift
;; ;;
-install) # stage 3: install only -install) # stage 3: install only
runINSTALL=true runINSTALL=true
unset runDEFAULT unset runDEFAULT
shift
;; ;;
-no-install) -no-install)
runINSTALL=false runINSTALL=false