check licence
[restas-lisp-overlay.git] / eclass / glo-utils.eclass
blobbb06eac8d1a7b6cdd238a36379fbd83195a238db
1 # Copyright 1999-2009 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
5 # This eclass contains various utilities used in the Gentoo Lisp overlay
7 # Public functions:
9 # glo_usev flagname [<if_yes> [<if_no>]]
10 # If $(use FLAGNAME) return true, echo IF_YES to standard output,
11 # otherwise echo IF_NO. IF_YES defaults to FLAGNAME if not specified
13 # glo_best_flag flag+
14 # Echo to stdout the first active USE flag among those supplied as parameters.
15 # If none are active, echo the first one
18 glo_usev() {
19 if [[ $# < 1 || $# > 3 ]]; then
20 echo "Usage: ${0} flag [if_yes [if_no]]"
21 die "${0}: wrong number of arguments: $#"
23 local if_yes="${2:-${1}}" if_no="${3}"
24 if useq ${1} ; then
25 printf "%s" "${if_yes}"
26 return 0
27 else
28 printf "%s" "${if_no}"
29 return 1
33 glo_best_flag() {
34 if [[ $# < 1 ]]; then
35 echo "Usage: ${0} flag+"
36 die "${0}: wrong number of arguments: $#"
38 for flag in $@ ; do
39 if use ${flag} ; then
40 echo ${flag}
41 return
43 done
44 echo ${1}