void-packages

Void Source Packages
git clone git://ezup.dev/void-packages.git
Log | Files | Refs | README | LICENSE

options.sh (910B)


      1# vim: set ts=4 sw=4 et:
      2
      3vopt_if() {
      4    local name="build_option_$1" t="$2" f="$3"
      5    if [ ${!name} ]; then
      6        echo -n "$t"
      7    else
      8        echo -n "$f"
      9    fi
     10}
     11
     12vopt_with() {
     13    local opt="$1" flag="${2:-$1}"
     14    vopt_if "$opt" "--with-${flag}" "--without-${flag}"
     15}
     16
     17vopt_enable() {
     18    local opt="$1" flag="${2:-$1}"
     19    if [ "$#" -gt "2" ]; then
     20        msg_error "vopt_enable $opt: $(($# - 2)) excess parameter(s)\n"
     21    fi
     22    vopt_if "$1" "--enable-${flag}" "--disable-${flag}"
     23}
     24
     25vopt_conflict() {
     26    local opt1="$1" opt2="$2" n1="build_option_$1" n2="build_option_$2"
     27    if [ "${!n1}" -a "${!n2}" ]; then
     28        msg_error "options '${opt1}' and '${opt2}' conflict\n"
     29    fi
     30}
     31
     32vopt_bool() {
     33    local opt="$1" prop="${2:-$1}"
     34    if [ "$#" -gt "2" ]; then
     35        msg_error "vopt_bool $opt: $(($# - 2)) excess parameter(s)\n"
     36    fi
     37    vopt_if "$1" "-D${prop}=true" "-D${prop}=false"
     38}