1 # Copyright 1999-2019 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: kde5-functions.eclass
8 # @BLURB: Common ebuild functions for packages based on KDE Frameworks 5.
10 # This eclass contains functions shared by the other KDE eclasses and forms
11 # part of their public API.
13 # This eclass must not be inherited directly by an ebuild.
15 if [[ -z ${_KDE5_FUNCTIONS_ECLASS} ]]; then
16 _KDE5_FUNCTIONS_ECLASS=1
20 *) die "EAPI=${EAPI:-0} is not supported" ;;
23 # @ECLASS-VARIABLE: QT_MINIMAL
25 # Minimum version of Qt to require. This affects add_qt_dep.
26 : ${QT_MINIMAL:=5.12.3}
28 # @ECLASS-VARIABLE: FRAMEWORKS_MINIMAL
30 # Minimum version of Frameworks to require. This affects add_frameworks_dep.
31 : ${FRAMEWORKS_MINIMAL:=5.60.0}
33 # @ECLASS-VARIABLE: PLASMA_MINIMAL
35 # Minimum version of Plasma to require. This affects add_plasma_dep.
36 : ${PLASMA_MINIMAL:=5.15.5}
38 # @ECLASS-VARIABLE: KDE_APPS_MINIMAL
40 # Minimum version of KDE Applications to require. This affects add_kdeapps_dep.
41 : ${KDE_APPS_MINIMAL:=19.04.3}
43 # @FUNCTION: _add_category_dep
46 # Implementation of add_plasma_dep, add_frameworks_dep, add_kdeapps_dep,
47 # and finally, add_qt_dep.
49 debug-print-function ${FUNCNAME} "$@"
57 if [[ -n ${use} ]] ; then
61 if [[ -n ${version} ]] ; then
63 local version="-${version}"
66 if [[ -n ${slot} ]] ; then
68 elif [[ ${SLOT%\/*} = 5 ]] ; then
72 echo " ${operator}${category}/${package}${version}${slot}${use}"
75 # @FUNCTION: add_frameworks_dep
76 # @USAGE: <package name> [USE flags] [minimum version] [slot + operator]
78 # Create proper dependency for kde-frameworks/ dependencies.
79 # This takes 1 to 4 arguments. The first being the package name, the optional
80 # second is additional USE flags to append, and the optional third is the
81 # version to use instead of the automatic version (use sparingly). In addition,
82 # the optional fourth argument defines slot+operator instead of automatic slot
83 # (use even more sparingly).
84 # The output of this should be added directly to DEPEND/RDEPEND, and may be
85 # wrapped in a USE conditional (but not an || conditional without an extra set
87 # PORTING: no replacement
88 add_frameworks_dep() {
89 debug-print-function ${FUNCNAME} "$@"
91 if [[ $# -gt 4 ]]; then
92 die "${FUNCNAME} was called with too many arguments"
97 if [[ -n ${3} ]]; then
99 elif [[ ${CATEGORY} = kde-frameworks ]]; then
100 version=$(ver_cut 1-2)
101 elif [[ -z ${3} ]] ; then
102 version=${FRAMEWORKS_MINIMAL}
105 _add_category_dep kde-frameworks "${1}" "${2}" "${version}" "${4}"
108 # @FUNCTION: add_plasma_dep
109 # @USAGE: <package name> [USE flags] [minimum version] [slot + operator]
111 # Create proper dependency for kde-plasma/ dependencies.
112 # This takes 1 to 4 arguments. The first being the package name, the optional
113 # second is additional USE flags to append, and the optional third is the
114 # version to use instead of the automatic version (use sparingly). In addition,
115 # the optional fourth argument defines slot+operator instead of automatic slot
116 # (use even more sparingly).
117 # The output of this should be added directly to DEPEND/RDEPEND, and may be
118 # wrapped in a USE conditional (but not an || conditional without an extra set
120 # PORTING: no replacement
122 debug-print-function ${FUNCNAME} "$@"
124 if [[ $# -gt 4 ]]; then
125 die "${FUNCNAME} was called with too many arguments"
130 if [[ -n ${3} ]]; then
132 elif [[ ${CATEGORY} = kde-plasma ]]; then
133 version=$(ver_cut 1-3)
134 elif [[ -z ${3} ]] ; then
135 version=${PLASMA_MINIMAL}
138 _add_category_dep kde-plasma "${1}" "${2}" "${version}" "${4}"
141 # @FUNCTION: add_kdeapps_dep
142 # @USAGE: <package name> [USE flags] [minimum version] [slot + operator]
144 # Create proper dependency for kde-apps/ dependencies.
145 # This takes 1 to 4 arguments. The first being the package name, the optional
146 # second is additional USE flags to append, and the optional third is the
147 # version to use instead of the automatic version (use sparingly). In addition,
148 # the optional fourth argument defines slot+operator instead of automatic slot
149 # (use even more sparingly).
150 # The output of this should be added directly to DEPEND/RDEPEND, and may be
151 # wrapped in a USE conditional (but not an || conditional without an extra set
153 # PORTING: no replacement
155 debug-print-function ${FUNCNAME} "$@"
157 if [[ $# -gt 4 ]]; then
158 die "${FUNCNAME} was called with too many arguments"
163 if [[ -n ${3} ]]; then
165 elif [[ ${CATEGORY} = kde-apps ]]; then
166 version=$(ver_cut 1-3)
167 elif [[ -z ${3} ]] ; then
168 version=${KDE_APPS_MINIMAL}
171 _add_category_dep kde-apps "${1}" "${2}" "${version}" "${4}"
174 # @FUNCTION: add_qt_dep
175 # @USAGE: <package name> [USE flags] [minimum version] [slot + operator]
177 # Create proper dependency for dev-qt/ dependencies.
178 # This takes 1 to 4 arguments. The first being the package name, the optional
179 # second is additional USE flags to append, and the optional third is the
180 # version to use instead of the automatic version (use sparingly). In addition,
181 # the optional fourth argument defines slot+operator instead of automatic slot
182 # (use even more sparingly).
183 # The output of this should be added directly to DEPEND/RDEPEND, and may be
184 # wrapped in a USE conditional (but not an || conditional without an extra set
186 # PORTING: no replacement
188 debug-print-function ${FUNCNAME} "$@"
190 if [[ $# -gt 4 ]]; then
191 die "${FUNCNAME} was called with too many arguments"
197 if [[ -z ${version} ]]; then
198 version=${QT_MINIMAL}
200 if [[ -z ${slot} ]]; then
204 _add_category_dep dev-qt "${1}" "${2}" "${version}" "${slot}"
207 # @FUNCTION: punt_bogus_dep
208 # @USAGE: <prefix> <dependency>
210 # Removes a specified dependency from a find_package call with multiple components.
211 # PORTING: Use ecm_punt_bogus_dep from ecm.eclass instead.
216 if [[ ! -e "CMakeLists.txt" ]]; then
220 pcregrep -Mni "(?s)find_package\s*\(\s*${prefix}[^)]*?${dep}.*?\)" CMakeLists.txt > "${T}/bogus${dep}"
222 # pcregrep returns non-zero on no matches/error
223 if [[ $? != 0 ]] ; then
227 local length=$(wc -l "${T}/bogus${dep}" | cut -d " " -f 1)
228 local first=$(head -n 1 "${T}/bogus${dep}" | cut -d ":" -f 1)
229 local last=$(( ${length} + ${first} - 1))
231 sed -e "${first},${last}s/${dep}//" -i CMakeLists.txt || die
233 if [[ ${length} = 1 ]] ; then
234 sed -e "/find_package\s*(\s*${prefix}\(\s\+\(REQUIRED\|CONFIG\|COMPONENTS\|\${[A-Z0-9_]*}\)\)\+\s*)/Is/^/# removed by kde5-functions.eclass - /" -i CMakeLists.txt || die