1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: kde5-functions.eclass
8 # @BLURB: Common ebuild functions for KDE 5 packages
10 # This eclass contains all functions shared by the different eclasses,
13 if [[ -z ${_KDE5_FUNCTIONS_ECLASS} ]]; then
14 _KDE5_FUNCTIONS_ECLASS=1
16 inherit toolchain-funcs versionator
18 # @ECLASS-VARIABLE: EAPI
20 # Currently EAPI 5 and 6 is supported.
23 *) die "EAPI=${EAPI:-0} is not supported" ;;
26 # @ECLASS-VARIABLE: FRAMEWORKS_MINIMAL
28 # Minimal Frameworks version to require for the package.
29 : ${FRAMEWORKS_MINIMAL:=5.18.0}
31 # @ECLASS-VARIABLE: PLASMA_MINIMAL
33 # Minimal Plasma version to require for the package.
34 : ${PLASMA_MINIMAL:=5.4.1}
36 # @ECLASS-VARIABLE: KDE_APPS_MINIMAL
38 # Minimal KDE Applications version to require for the package.
39 : ${KDE_APPS_MINIMAL:=14.12.0}
41 # @ECLASS-VARIABLE: KDE_GCC_MINIMAL
43 # Minimal GCC version to require for the package.
44 if [[ ${CATEGORY} = kde-frameworks ]]; then
45 : ${KDE_GCC_MINIMAL:=4.5}
47 : ${KDE_GCC_MINIMAL:=4.8}
51 # @ECLASS-VARIABLE: KDEBASE
53 # This gets set to a non-zero value when a package is considered a
55 if [[ ${KMNAME-${PN}} = kdevelop ]]; then
59 debug-print "${ECLASS}: ${KDEBASE} ebuild recognized"
61 # @ECLASS-VARIABLE: KDE_SCM
63 # SCM to use if this is a live ebuild.
68 *) die "KDE_SCM: ${KDE_SCM} is not supported" ;;
71 # determine the build type
72 if [[ ${PV} = *9999* ]]; then
75 KDE_BUILD_TYPE="release"
79 # @FUNCTION: _check_gcc_version
82 # Determine if the current GCC version is acceptable, otherwise die.
83 _check_gcc_version() {
84 if [[ ${MERGE_TYPE} != binary ]]; then
85 local version=$(gcc-version)
86 local major=${version%.*}
87 local minor=${version#*.}
88 local min_major=${KDE_GCC_MINIMAL%.*}
89 local min_minor=${KDE_GCC_MINIMAL#*.}
91 [[ ${major} -lt ${min_major} ]] || \
92 ( [[ ${major} -eq ${min_major} && ${minor} -lt ${min_minor} ]] ) \
93 && die "Sorry, but gcc-${KDE_GCC_MINIMAL} or later is required for this package."
97 # @FUNCTION: _add_category_dep
100 # Implementation of add_plasma_dep, add_frameworks_dep, add_kdeapps_dep,
101 # and finally, add_qt_dep.
102 _add_category_dep() {
103 debug-print-function ${FUNCNAME} "$@"
111 if [[ -n ${use} ]] ; then
115 if [[ -n ${version} ]] ; then
117 local version="-$(get_version_component_range 1-3 ${version})"
120 if [[ -n ${slot} ]] ; then
122 elif [[ ${SLOT%\/*} = 4 || ${SLOT%\/*} = 5 ]] && ! has kde5-meta-pkg ${INHERITED} ; then
126 echo " ${operator}${category}/${package}${version}${slot}${use}"
129 # @FUNCTION: add_frameworks_dep
130 # @USAGE: <package> [USE flags] [minimum version]
132 # Create proper dependency for kde-frameworks/ dependencies.
133 # This takes 1 to 4 arguments. The first being the package name, the optional
134 # second is additional USE flags to append, and the optional third is the
135 # version to use instead of the automatic version (use sparingly). In addition,
136 # the optional fourth argument defines slot+operator instead of automatic slot
137 # (use even more sparingly).
138 # The output of this should be added directly to DEPEND/RDEPEND, and may be
139 # wrapped in a USE conditional (but not an || conditional without an extra set
141 add_frameworks_dep() {
142 debug-print-function ${FUNCNAME} "$@"
146 if [[ -n ${3} ]]; then
148 elif [[ ${CATEGORY} = kde-frameworks ]]; then
149 version=$(get_version_component_range 1-2)
150 elif [[ -z "${version}" ]] ; then
151 version=${FRAMEWORKS_MINIMAL}
154 _add_category_dep kde-frameworks "${1}" "${2}" "${version}" "${4}"
157 # @FUNCTION: add_plasma_dep
158 # @USAGE: <package> [USE flags] [minimum version]
160 # Create proper dependency for kde-plasma/ dependencies.
161 # This takes 1 to 4 arguments. The first being the package name, the optional
162 # second is additional USE flags to append, and the optional third is the
163 # version to use instead of the automatic version (use sparingly). In addition,
164 # the optional fourth argument defines slot+operator instead of automatic slot
165 # (use even more sparingly).
166 # The output of this should be added directly to DEPEND/RDEPEND, and may be
167 # wrapped in a USE conditional (but not an || conditional without an extra set
170 debug-print-function ${FUNCNAME} "$@"
174 if [[ -n ${3} ]]; then
176 elif [[ ${CATEGORY} = kde-plasma ]]; then
178 elif [[ -z "${version}" ]] ; then
179 version=${PLASMA_MINIMAL}
182 _add_category_dep kde-plasma "${1}" "${2}" "${version}" "${4}"
185 # @FUNCTION: add_kdeapps_dep
186 # @USAGE: <package> [USE flags] [minimum version]
188 # Create proper dependency for kde-apps/ dependencies.
189 # This takes 1 to 4 arguments. The first being the package name, the optional
190 # second is additional USE flags to append, and the optional third is the
191 # version to use instead of the automatic version (use sparingly). In addition,
192 # the optional fourth argument defines slot+operator instead of automatic slot
193 # (use even more sparingly).
194 # The output of this should be added directly to DEPEND/RDEPEND, and may be
195 # wrapped in a USE conditional (but not an || conditional without an extra set
198 debug-print-function ${FUNCNAME} "$@"
202 if [[ -n ${3} ]]; then
204 elif [[ ${CATEGORY} = kde-apps ]]; then
206 elif [[ -z "${version}" ]] ; then
207 # In KDE applications world, 5.9999 > yy.mm.x
208 if [[ ${PV} = 5.9999 || ${PV} = 9999 ]]; then
211 version=${KDE_APPS_MINIMAL}
215 _add_category_dep kde-apps "${1}" "${2}" "${version}" "${4}"
218 # @FUNCTION: add_qt_dep
219 # @USAGE: <package> [USE flags] [minimum version]
221 # Create proper dependency for dev-qt/ dependencies.
222 # This takes 1 to 4 arguments. The first being the package name, the optional
223 # second is additional USE flags to append, and the optional third is the
224 # version to use instead of the automatic version (use sparingly). In addition,
225 # the optional fourth argument defines slot+operator instead of automatic slot
226 # (use even more sparingly).
227 # The output of this should be added directly to DEPEND/RDEPEND, and may be
228 # wrapped in a USE conditional (but not an || conditional without an extra set
231 debug-print-function ${FUNCNAME} "$@"
235 if [[ -n ${3} ]]; then
237 elif [[ -z "${version}" ]] ; then
238 version=${QT_MINIMAL}
241 _add_category_dep dev-qt "${1}" "${2}" "${version}" "${4}"
244 # @FUNCTION: get_kde_version
246 # Translates an ebuild version into a major.minor KDE SC
247 # release version. If no version is specified, ${PV} is used.
249 local ver=${1:-${PV}}
250 local major=$(get_major_version ${ver})
251 local minor=$(get_version_component_range 2 ${ver})
252 local micro=$(get_version_component_range 3 ${ver})
253 if [[ ${ver} == 9999 ]]; then
256 (( micro < 50 )) && echo ${major}.${minor} || echo ${major}.$((minor + 1))
260 # @FUNCTION: punt_bogus_dep
261 # @USAGE: <prefix> <dependency>
263 # Removes a specified dependency from a find_package call with multiple components.
268 pcregrep -Mni "(?s)find_package\s*\(\s*${prefix}[^)]*?${dep}.*?\)" CMakeLists.txt > "${T}/bogus${dep}"
270 # pcregrep returns non-zero on no matches/error
271 if [[ $? != 0 ]] ; then
275 local length=$(wc -l "${T}/bogus${dep}" | cut -d " " -f 1)
276 local first=$(head -n 1 "${T}/bogus${dep}" | cut -d ":" -f 1)
277 local last=$(( ${length} + ${first} - 1))
279 sed -e "${first},${last}s/${dep}//" -i CMakeLists.txt || die
281 if [[ ${length} = 1 ]] ; then
282 sed -e "/find_package\s*(\s*${prefix}\(\s\+\(REQUIRED\|CONFIG\|COMPONENTS\|\${KF5_VERSION}\)\)\+\s*)/Is/^/# removed by kde5-functions.eclass - /" -i CMakeLists.txt || die