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