2 # $Id: mkopt.sh,v 1.8 2014/11/15 07:07:18 sjg Exp $
4 # @(#) Copyright (c) 2014, Simon J. Gerraty
6 # This file is provided in the hope that it will
7 # be of use. There is absolutely NO WARRANTY.
8 # Permission to copy, redistribute or otherwise
9 # use this file is hereby granted provided that
10 # the above copyright notice and this notice are
13 # Please send copies of changes and bug-fixes to:
17 # handle WITH[OUT]_* options in a manner compatible with
18 # options.mk and bsd.mkopt.mk in recent FreeBSD
20 # no need to be included more than once
28 # The semantics are simple, if MK_$OPT has no value
29 # WITHOUT_$OPT results in MK_$OPT=no
30 # otherwise WITH_$OPT results in MK_$OPT=yes.
31 # Note WITHOUT_$OPT overrides WITH_$OPT.
33 # For backwards compatability reasons we treat WITH_$OPT=no
34 # the same as WITHOUT_$OPT.
38 _mo=MK_$2 _wo=WITHOUT_$2 _wi=WITH_$2
39 eval "_mov=\$$_mo _wov=\$$_wo _wiv=\$$_wi"
44 _v=${_mov:-${_wov:+no}}
45 _v=${_v:-${_wiv:+yes}}
47 _opt_list="$_opt_list $_mo"
50 0|[NnFf]*) _v=no;; # they mean no
51 1|[YyTt]*) _v=yes;; # they mean yes
52 *) _v=$_d;; # ignore bogus value
58 # _mk_opts default opt ... [default [opt] ...]
60 # see _mk_opts_defaults for example
67 yes|no) _d=$_o; continue;;
74 _mk_opts no $__DEFAULT_NO_OPTIONS yes $__DEFAULT_YES_OPTIONS
83 *=*) eval "$1"; shift;;
84 --no|no) _list="$_list no"; shift;;
85 --yes|yes) _list="$_list yes"; shift;;
86 -DWITH*) eval "${1#-D}=1"; shift;;
87 [A-Z]*) _list="$_list $1"; shift;;