/[gentoo-x86]/eclass/qt4.eclass
Gentoo

Diff of /eclass/qt4.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.32 Revision 1.65
1# Copyright 2005 Gentoo Foundation 1# Copyright 1999-2012 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/qt4.eclass,v 1.32 2008/01/05 18:44:38 caleb Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/qt4.eclass,v 1.65 2012/05/19 13:40:52 pesa Exp $
4
5# @DEAD
6# @DEPRECATED
7# This eclass has been superseded by qt4-r2
8# Please modify your ebuilds to use that instead
4 9
5# @ECLASS: qt4.eclass 10# @ECLASS: qt4.eclass
6# @MAINTAINER: 11# @MAINTAINER:
12# Ben de Groot <yngwin@gentoo.org>
13# Markos Chandras <hwoarang@gentoo.org>
7# Caleb Tennis <caleb@gentoo.org> 14# Caleb Tennis <caleb@gentoo.org>
8# @BLURB: 15# Przemyslaw Maciag <troll@gentoo.org>
16# Davide Pesavento <pesa@gentoo.org>
9# Eclass for Qt4 packages 17# @BLURB: Eclass for Qt4 packages
10# @DESCRIPTION: 18# @DESCRIPTION:
11# This eclass contains various functions that may be useful 19# This eclass contains various functions that may be useful
12# when dealing with packages using Qt4 libraries. 20# when dealing with packages using Qt4 libraries.
13 21
14# 08.16.06 - Renamed qt_min_* to qt4_min_* to avoid conflicts with the qt3 eclass.
15# - Caleb Tennis <caleb@gentoo.org>
16
17inherit eutils multilib toolchain-funcs versionator 22inherit base eutils multilib toolchain-funcs versionator
18 23
19QTPKG="x11-libs/qt-" 24export XDG_CONFIG_HOME="${T}"
20QT4MAJORVERSIONS="4.4 4.3 4.2 4.1 4.0"
21QT4VERSIONS="4.4.0_rc1 4.3.3 4.3.2-r1 4.3.2 4.3.1-r1 4.3.1 4.3.0-r2 4.3.0-r1 4.3.0 4.3.0_rc1 4.3.0_beta1 4.2.3-r1 4.2.3 4.2.2 4.2.1 4.2.0-r2 4.2.0-r1 4.2.0 4.1.4-r2 4.1.4-r1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.0.1 4.0.0"
22 25
23# @FUNCTION: qt4_min_version 26qt4_monolithic_to_split_flag() {
24# @USAGE: [minimum version] 27 case ${1} in
25# @DESCRIPTION: 28 zlib)
26# This function should be called in package DEPENDs whenever it depends on qt4. 29 # Qt 4.4+ is always built with zlib enabled, so this flag isn't needed
27# Simple example - in your depend, do something like this: 30 ;;
28# DEPEND="$(qt4_min_version 4.2)" 31 gif|jpeg|png)
29# if package can be build with qt-4.2 or higher. 32 # qt-gui always installs with these enabled
30qt4_min_version() { 33 checkpkgs+=" x11-libs/qt-gui"
31 # This is much simpler for EAPI 1, we can use a slot dependency 34 ;;
32 if [[ "${EAPI}" -ge 1 ]]; then 35 dbus|opengl)
33 echo ">=${QTPKG}${1}:4" 36 # Make sure the qt-${1} package has been installed already
34 else 37 checkpkgs+=" x11-libs/qt-${1}"
35 echo "|| (" 38 ;;
36 qt4_min_version_list "$@" 39 qt3support)
37 echo ")" 40 checkpkgs+=" x11-libs/qt-${1}"
38 fi 41 checkflags+=" x11-libs/qt-core:${1} x11-libs/qt-gui:${1} x11-libs/qt-sql:${1}"
42 ;;
43 ssl)
44 # qt-core controls this flag
45 checkflags+=" x11-libs/qt-core:${1}"
46 ;;
47 cups|mng|nas|nis|tiff|xinerama|input_devices_wacom)
48 # qt-gui controls these flags
49 checkflags+=" x11-libs/qt-gui:${1}"
50 ;;
51 firebird|mysql|odbc|postgres|sqlite3)
52 # qt-sql controls these flags. sqlite2 is no longer supported so it uses sqlite instead of sqlite3.
53 checkflags+=" x11-libs/qt-sql:${1%3}"
54 ;;
55 accessibility)
56 eerror "(QA message): Use guiaccessibility and/or qt3accessibility to specify which of qt-gui and qt-qt3support are relevant for this package."
57 # deal with this gracefully by checking the flag for what is available
58 for y in gui qt3support; do
59 has_version x11-libs/qt-${y} && checkflags+=" x11-libs/qt-${y}:${1}"
60 done
61 ;;
62 guiaccessibility)
63 checkflags+=" x11-libs/qt-gui:accessibility"
64 ;;
65 qt3accessibility)
66 checkflags+=" x11-libs/qt-qt3support:accessibility"
67 ;;
68 debug|doc|examples|glib|pch|sqlite|*)
69 # packages probably shouldn't be checking these flags so we don't handle them currently
70 eerror "qt4.eclass currently doesn't handle the use flag ${1} in QT4_BUILT_WITH_USE_CHECK for qt-4.4. This is either an"
71 eerror "eclass bug or an ebuild bug. Please report it at http://bugs.gentoo.org/"
72 ((fatalerrors+=1))
73 ;;
74 esac
39} 75}
40 76
41qt4_min_version_list() {
42 local MINVER="$1"
43 local VERSIONS=""
44
45 case "${MINVER}" in
46 4|4.0|4.0.0) VERSIONS="=${QTPKG}4*";;
47 4.1|4.1.0|4.2|4.2.0|4.3|4.3.0|4.4|4.4.0)
48 for x in ${QT4MAJORVERSIONS}; do
49 if $(version_is_at_least "${MINVER}" "${x}"); then
50 VERSIONS="${VERSIONS} =${QTPKG}${x}*"
51 fi
52 done
53 ;;
54 4*)
55 for x in ${QT4VERSIONS}; do
56 if $(version_is_at_least "${MINVER}" "${x}"); then
57 VERSIONS="${VERSIONS} =${QTPKG}${x}"
58 fi
59 done
60 ;;
61 *) VERSIONS="=${QTPKG}4*";;
62 esac
63
64 echo "${VERSIONS}"
65}
66
67# @FUNCTION: qt4_pkg_setup 77# @FUNCTION: qt4_pkg_setup
68# @MAINTAINER:
69# Caleb Tennis <caleb@gentoo.org>
70# Przemyslaw Maciag <troll@gentoo.org>
71# @DESCRIPTION: 78# @DESCRIPTION:
72# Default pkg_setup function for packages that depends on qt4. If you have to 79# Default pkg_setup function for packages that depends on qt4. If you have to
73# create ebuilds own pkg_setup in your ebuild, call qt4_pkg_setup in it. 80# create ebuilds own pkg_setup in your ebuild, call qt4_pkg_setup in it.
74# This function uses two global vars from ebuild: 81# This function uses two global vars from ebuild:
75# - QT4_BUILT_WITH_USE_CHECK - contains use flags that need to be turned on for 82# - QT4_BUILT_WITH_USE_CHECK - contains use flags that need to be turned on for
76# =x11-libs/qt-4* 83# =x11-libs/qt-4*
77# - QT4_OPTIONAL_BUILT_WITH_USE_CHECK - qt4 flags that provides some 84# - QT4_OPTIONAL_BUILT_WITH_USE_CHECK - qt4 flags that provides some
78# functionality, but can alternatively be disabled in ${CATEGORY}/${PN} 85# functionality, but can alternatively be disabled in ${CATEGORY}/${PN}
79# (so qt4 don't have to be recompiled) 86# (so qt4 don't have to be recompiled)
80# 87#
88# NOTE: Using the above vars is now deprecated in favor of eapi-2 use deps
89#
81# flags to watch for for Qt4.4: 90# flags to watch for for Qt4.4:
82# zlib png | opengl dbus qt3support | sqlite3 ssl 91# zlib png | opengl dbus qt3support | sqlite3 ssl
83qt4_pkg_setup() { 92qt4_pkg_setup() {
93 local x y checkpkgs checkflags fatalerrors=0 requiredflags=""
84 94
85 QT4_BEST_VERSION="$(best_version =x11-libs/qt-4*)" 95 # lots of has_version calls can be very expensive
86 QT4_MINOR_VERSION="$(get_version_component_range 2 ${QT4_BEST_VERSION/*qt-/})" 96 if [[ -n ${QT4_BUILT_WITH_USE_CHECK}${QT4_OPTIONAL_BUILT_WITH_USE_CHECK} ]]; then
97 ewarn "QA notice: The QT4_BUILT_WITH_USE functionality is deprecated and"
98 ewarn "will be removed from future versions of qt4.eclass. Please update"
99 ewarn "the ebuild to use eapi-2 use dependencies instead."
100 has_version x11-libs/qt-core && local QT44=true
101 fi
87 102
88 local requiredflags=""
89 for x in ${QT4_BUILT_WITH_USE_CHECK}; do 103 for x in ${QT4_BUILT_WITH_USE_CHECK}; do
90 if [[ "${QT4_MINOR_VERSION}" -ge 4 ]]; then 104 if [[ -n ${QT44} ]]; then
91 # The use flags are different in 4.4 and above, and it's a split package, so this is used to catch 105 # The use flags are different in 4.4 and above, and it's split packages, so this is used to catch
92 # the various use flag combos specified in the ebuilds to make sure we don't error out. 106 # the various use flag combos specified in the ebuilds to make sure we don't error out for no reason.
93 107 qt4_monolithic_to_split_flag ${x}
94 if [[ ${x} == zlib || ${x} == png ]]; then 108 else
95 # Qt 4.4+ is built with zlib and png by default, so the use flags aren't needed 109 [[ ${x} == *accessibility ]] && x=${x#gui} && x=${x#qt3}
96 continue; 110 if ! built_with_use =x11-libs/qt-4* ${x}; then
97 elif [[ ${x} == opengl || ${x} == dbus || ${x} == qt3support ]]; then 111 requiredflags="${requiredflags} ${x}"
98 # Make sure the qt-${x} package has been already installed
99
100 if ! has_version x11-libs/qt-${x}; then
101 eerror "You must first install the x11-libs/qt-${x} package."
102 die "Install x11-libs/qt-${x}"
103 fi
104 elif [[ ${x} == ssl ]]; then
105 if ! has_version x11-libs/qt-core || ! built_with_use x11-libs/qt-core ssl; then
106 eerror "You must first install the x11-libs/qt-core package with the ssl flag enabled."
107 die "Install x1-libs/qt-core with USE=\"ssl\""
108 fi
109 elif [[ ${x} == sqlite3 ]]; then
110 if ! has_version x11-libs/qt-sql || ! built_with_use x11-libs/qt-sql sqlite; then
111 eerror "You must first install the x11-libs/qt-sql package with the sqlite flag enabled."
112 die "Install x11-libs/qt-sql with USE="\sqlite\""
113 fi
114 fi 112 fi
115 elif ! built_with_use =x11-libs/qt-4* ${x}; then
116 requiredflags="${requiredflags} ${x}"
117 fi 113 fi
118 done 114 done
119 115
120 local optionalflags="" 116 local optionalflags=""
121 for x in ${QT4_OPTIONAL_BUILT_WITH_USE_CHECK}; do 117 for x in ${QT4_OPTIONAL_BUILT_WITH_USE_CHECK}; do
118 if use ${x}; then
119 if [[ -n ${QT44} ]]; then
120 # The use flags are different in 4.4 and above, and it's split packages, so this is used to catch
121 # the various use flag combos specified in the ebuilds to make sure we don't error out for no reason.
122 qt4_monolithic_to_split_flag ${x}
122 if use ${x} && ! built_with_use =x11-libs/qt-4* ${x}; then 123 elif ! built_with_use =x11-libs/qt-4* ${x}; then
123 optionalflags="${optionalflags} ${x}" 124 optionalflags="${optionalflags} ${x}"
125 fi
124 fi 126 fi
125 done 127 done
126 128
129 # The use flags are different in 4.4 and above, and it's split packages, so this is used to catch
130 # the various use flag combos specified in the ebuilds to make sure we don't error out for no reason.
131 for y in ${checkpkgs}; do
132 if ! has_version ${y}; then
133 eerror "You must first install the ${y} package. It should be added to the dependencies for this package (${CATEGORY}/${PN}). See bug #217161."
134 ((fatalerrors+=1))
135 fi
136 done
137 for y in ${checkflags}; do
138 if ! has_version ${y%:*}; then
139 eerror "You must first install the ${y%:*} package with the ${y##*:} flag enabled."
140 eerror "It should be added to the dependencies for this package (${CATEGORY}/${PN}). See bug #217161."
141 ((fatalerrors+=1))
142 else
143 if ! built_with_use ${y%:*} ${y##*:}; then
144 eerror "You must first install the ${y%:*} package with the ${y##*:} flag enabled."
145 ((fatalerrors+=1))
146 fi
147 fi
148 done
149
127 local diemessage="" 150 local diemessage=""
151 if [[ ${fatalerrors} -ne 0 ]]; then
152 diemessage="${fatalerrors} fatal errors were detected. Please read the above error messages and act accordingly."
153 fi
128 if [[ ${requiredflags} != "" ]]; then 154 if [[ -n ${requiredflags} ]]; then
129 eerror 155 eerror
130 eerror "(1) In order to compile ${CATEGORY}/${PN} first you need to build" 156 eerror "(1) In order to compile ${CATEGORY}/${PN} first you need to build"
131 eerror "=x11-libs/qt-4* with USE=\"${requiredflags}\" flag(s)" 157 eerror "=x11-libs/qt-4* with USE=\"${requiredflags}\" flag(s)"
132 eerror 158 eerror
133 diemessage="(1) recompile qt4 with \"${requiredflags}\" USE flag(s) ; " 159 diemessage="(1) recompile qt4 with \"${requiredflags}\" USE flag(s) ; "
134 fi 160 fi
135 if [[ ${optionalflags} != "" ]]; then 161 if [[ -n ${optionalflags} ]]; then
136 eerror 162 eerror
137 eerror "(2) You are trying to compile ${CATEGORY}/${PN} package with" 163 eerror "(2) You are trying to compile ${CATEGORY}/${PN} package with"
138 eerror "USE=\"${optionalflags}\"" 164 eerror "USE=\"${optionalflags}\""
139 eerror "while qt4 is built without this particular flag(s): it will" 165 eerror "while qt4 is built without this particular flag(s): it will"
140 eerror "not work." 166 eerror "not work."
144 eerror "b) re-emerge qt4 with \"${optionalflags}\" USE flag(s)" 170 eerror "b) re-emerge qt4 with \"${optionalflags}\" USE flag(s)"
145 eerror 171 eerror
146 diemessage="${diemessage}(2) recompile qt4 with \"${optionalflags}\" USE flag(s) or disable them for ${PN} package\n" 172 diemessage="${diemessage}(2) recompile qt4 with \"${optionalflags}\" USE flag(s) or disable them for ${PN} package\n"
147 fi 173 fi
148 174
149 [[ ${diemessage} != "" ]] && die "can't emerge ${CATEGORY}/${PN}: ${diemessage}" 175 [[ -n ${diemessage} ]] && die "can't install ${CATEGORY}/${PN}: ${diemessage}"
176}
177
178# @ECLASS-VARIABLE: PATCHES
179# @DESCRIPTION:
180# In case you have patches to apply, specify them in the PATCHES variable.
181# Make sure to specify the full path. This variable is necessary for the
182# src_prepare phase.
183# example:
184# PATCHES=(
185# "${FILESDIR}/mypatch.patch"
186# "${FILESDIR}/mypatch2.patch"
187# )
188
189# @FUNCTION: qt4_src_prepare
190# @DESCRIPTION:
191# Default src_prepare function for packages that depend on qt4. If you have to
192# override src_prepare in your ebuild, you should call qt4_src_prepare in it,
193# otherwise autopatcher will not work!
194qt4_src_prepare() {
195 debug-print-function $FUNCNAME "$@"
196 base_src_prepare
150} 197}
151 198
152# @FUNCTION: eqmake4 199# @FUNCTION: eqmake4
153# @USAGE: [.pro file] [additional parameters to qmake] 200# @USAGE: [.pro file] [additional parameters to qmake]
154# @MAINTAINER:
155# Przemyslaw Maciag <troll@gentoo.org>
156# Davide Pesavento <davidepesa@gmail.com>
157# @DESCRIPTION: 201# @DESCRIPTION:
158# Runs qmake on the specified .pro file (defaults to 202# Runs qmake on the specified .pro file (defaults to ${PN}.pro if called
159# ${PN}.pro if eqmake4 was called with no argument). 203# without arguments). Additional parameters are appended unmodified to
160# Additional parameters are passed unmodified to qmake. 204# qmake command line. For recursive build systems, i.e. those based on
205# the subdirs template, you should run eqmake4 on the top-level project
206# file only, unless you have strong reasons to do things differently.
207# During the building, qmake will be automatically re-invoked with the
208# right arguments on every directory specified inside the top-level
209# project file by the SUBDIRS variable.
161eqmake4() { 210eqmake4() {
162 local LOGFILE="${T}/qmake-$$.out" 211 has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=
163 local projprofile="${1}" 212
164 [[ -z ${projprofile} ]] && projprofile="${PN}.pro" 213 local projectfile="${1:-${PN}.pro}"
165 shift 1 214 shift
166 215
167 ebegin "Processing qmake ${projprofile}"
168
169 # file exists?
170 if [[ ! -f ${projprofile} ]]; then 216 if [[ ! -f ${projectfile} ]]; then
171 echo 217 echo
172 eerror "Project .pro file \"${projprofile}\" does not exists" 218 eerror "Project file '${projectfile#${WORKDIR}/}' does not exists!"
173 eerror "qmake cannot handle non-existing .pro files" 219 eerror "eqmake4 cannot handle non-existing project files."
220 eerror
221 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
174 echo 222 echo
175 eerror "This shouldn't happen - please send a bug report to bugs.gentoo.org"
176 echo
177 die "Project file not found in ${PN} sources" 223 die "Project file not found in ${CATEGORY}/${PN} sources."
178 fi 224 fi
179 225
180 echo >> ${LOGFILE} 226 ebegin "Running qmake on ${projectfile}"
181 echo "****** qmake ${projprofile} ******" >> ${LOGFILE}
182 echo >> ${LOGFILE}
183 227
184 # as a workaround for broken qmake, put everything into file 228 # make sure CONFIG variable is correctly set for both release and debug builds
229 local CONFIG_ADD="release"
230 local CONFIG_REMOVE="debug"
185 if has debug ${IUSE} && use debug; then 231 if has debug ${IUSE} && use debug; then
186 echo -e "\nCONFIG -= release\nCONFIG += no_fixpath debug" >> ${projprofile} 232 CONFIG_ADD="debug"
187 else 233 CONFIG_REMOVE="release"
188 echo -e "\nCONFIG -= debug\nCONFIG += no_fixpath release" >> ${projprofile} 234 fi
235 local awkscript='BEGIN {
236 printf "### eqmake4 was here ###\n" > file;
237 fixed=0;
238 }
239 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
240 for (i=1; i <= NF; i++) {
241 if ($i ~ rem || $i ~ /debug_and_release/)
242 { $i=add; fixed=1; }
243 }
244 }
245 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
246 for (i=1; i <= NF; i++) {
247 if ($i ~ add) { $i=rem; fixed=1; }
248 }
249 }
250 {
251 print >> file;
252 }
253 END {
254 printf "\nCONFIG -= debug_and_release %s\n", rem >> file;
255 printf "CONFIG += %s\n", add >> file;
256 print fixed;
257 }'
258 local filepath=
259 while read filepath; do
260 local file="${filepath#./}"
261 grep -q '^### eqmake4 was here ###$' "${file}" && continue
262 local retval=$({
263 rm -f "${file}" || echo "FAILED"
264 awk -v file="${file}" -- "${awkscript}" add=${CONFIG_ADD} rem=${CONFIG_REMOVE} || echo "FAILED"
265 } < "${file}")
266 if [[ ${retval} == 1 ]]; then
267 einfo " Fixed CONFIG in ${file}"
268 elif [[ ${retval} != 0 ]]; then
269 eerror " An error occurred while processing ${file}"
270 die "eqmake4 failed to process '${file}'."
189 fi 271 fi
272 done < <(find "$(dirname "${projectfile}")" -type f -name "*.pr[io]" 2>/dev/null)
190 273
191 /usr/bin/qmake ${projprofile} \ 274 "${EPREFIX}"/usr/bin/qmake -makefile -nocache \
192 QTDIR=/usr/$(get_libdir) \ 275 QTDIR="${EPREFIX}"/usr/$(get_libdir) \
193 QMAKE=/usr/bin/qmake \ 276 QMAKE="${EPREFIX}"/usr/bin/qmake \
194 QMAKE_CC=$(tc-getCC) \ 277 QMAKE_CC=$(tc-getCC) \
195 QMAKE_CXX=$(tc-getCXX) \ 278 QMAKE_CXX=$(tc-getCXX) \
196 QMAKE_LINK=$(tc-getCXX) \ 279 QMAKE_LINK=$(tc-getCXX) \
197 QMAKE_CFLAGS_RELEASE="${CFLAGS}" \ 280 QMAKE_CFLAGS_RELEASE="${CFLAGS}" \
198 QMAKE_CFLAGS_DEBUG="${CFLAGS}" \ 281 QMAKE_CFLAGS_DEBUG="${CFLAGS}" \
199 QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \ 282 QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \
200 QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \ 283 QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \
201 QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \ 284 QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \
202 QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \ 285 QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \
203 QMAKE_RPATH= \ 286 QMAKE_STRIP= \
204 ${@} >> ${LOGFILE} 2>&1 287 "${projectfile}" "${@}"
205 288
206 local result=$? 289 eend $?
207 eend ${result}
208 290
209 # was qmake successful? 291 # was qmake successful?
210 if [[ ${result} -ne 0 ]]; then 292 if [[ $? -ne 0 ]]; then
211 echo 293 echo
212 eerror "Running qmake on \"${projprofile}\" has failed" 294 eerror "Running qmake on '${projectfile#${WORKDIR}/}' has failed!"
295 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
213 echo 296 echo
214 eerror "This shouldn't happen - please send a bug report to bugs.gentoo.org"
215 echo
216 die "qmake failed on ${projprofile}" 297 die "qmake failed on '${projectfile}'."
217 fi 298 fi
218 299
219 return ${result} 300 return 0
220} 301}
221 302
303case ${EAPI:-0} in
304 2|3)
305 EXPORT_FUNCTIONS pkg_setup src_prepare
306 ;;
307 0|1)
222EXPORT_FUNCTIONS pkg_setup 308 EXPORT_FUNCTIONS pkg_setup
309 ;;
310esac

Legend:
Removed from v.1.32  
changed lines
  Added in v.1.65

  ViewVC Help
Powered by ViewVC 1.1.20