add vopt_conflict helper

vopt_conflict prints an error and exits if two options are set at the
same time.
This commit is contained in:
Dominik Honnef 2014-09-05 16:41:50 +02:00
parent 62b3c65d77
commit 191c1eaf51
2 changed files with 10 additions and 0 deletions

View File

@ -535,6 +535,10 @@ package accordingly. Additionally, the following functions are available:
Same as `vopt_with`, but uses `--enable-<flag>` and Same as `vopt_with`, but uses `--enable-<flag>` and
`--disable-<flag>` respectively. `--disable-<flag>` respectively.
- *vopt_conflict()* `vopt_conflict <option 1> <option 2>`
Emits an error and exits if both options are set at the same time.
The following example shows how to change a source package that uses GNU The following example shows how to change a source package that uses GNU
configure to enable a new build option to support PNG images: configure to enable a new build option to support PNG images:

View File

@ -19,3 +19,9 @@ vopt_enable() {
vopt_if "$1" "--enable-${flag}" "--disable-${flag}" vopt_if "$1" "--enable-${flag}" "--disable-${flag}"
} }
vopt_conflict() {
local opt1="$1" opt2="$2" n1="build_option_$1" n2="build_option_$2"
if [ "${!n1}" -a "${!n2}" ]; then
msg_error "options '${opt1}' and '${opt2}' conflict\n"
fi
}