2014-08-30 07:10:11 +00:00
|
|
|
# vim: set ts=4 sw=4 et:
|
|
|
|
|
|
|
|
vopt_if() {
|
2014-09-05 14:37:08 +00:00
|
|
|
local name="build_option_$1" t="$2" f="$3"
|
2014-08-30 07:10:11 +00:00
|
|
|
if [ ${!name} ]; then
|
|
|
|
echo -n "$t"
|
|
|
|
else
|
|
|
|
echo -n "$f"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
vopt_with() {
|
|
|
|
local opt="$1" flag="${2:-$1}"
|
2014-09-05 14:37:08 +00:00
|
|
|
vopt_if "$opt" "--with-${flag}" "--without-${flag}"
|
2014-08-30 07:10:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
vopt_enable() {
|
|
|
|
local opt="$1" flag="${2:-$1}"
|
2015-06-20 08:08:44 +00:00
|
|
|
if [ "$#" -gt "2" ]; then
|
|
|
|
msg_error "vopt_enable $opt: $(($# - 2)) excess parameter(s)\n"
|
|
|
|
fi
|
2014-08-30 07:10:11 +00:00
|
|
|
vopt_if "$1" "--enable-${flag}" "--disable-${flag}"
|
|
|
|
}
|
|
|
|
|
2014-09-05 14:41:50 +00:00
|
|
|
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
|
|
|
|
}
|
2016-11-19 06:22:22 +00:00
|
|
|
|
2018-05-03 10:41:48 +00:00
|
|
|
vopt_bool() {
|
2016-11-19 06:22:22 +00:00
|
|
|
local opt="$1" prop="$2"
|
|
|
|
if [ "$#" -lt "2" ]; then
|
2018-05-03 10:41:48 +00:00
|
|
|
msg_error "vopt_bool <build_option> <property>: missing values\n"
|
2016-11-19 06:22:22 +00:00
|
|
|
elif [ "$#" -gt "2" ]; then
|
2018-05-03 10:41:48 +00:00
|
|
|
msg_error "vopt_bool $opt: $(($# - 2)) excess parameter(s)\n"
|
2016-11-19 06:22:22 +00:00
|
|
|
fi
|
2018-05-03 10:41:48 +00:00
|
|
|
vopt_if "$1" "-D${prop}=true" "-D${prop}=false"
|
2016-11-19 06:22:22 +00:00
|
|
|
}
|