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

Diff of /eclass/qt4.eclass

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

Revision 1.48 Revision 1.57
1# Copyright 2005 Gentoo Foundation 1# Copyright 2005-2009 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.48 2008/08/03 20:47:27 carlo Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/Attic/qt4.eclass,v 1.57 2009/05/17 15:18:58 hwoarang Exp $
4 4
5# @ECLASS: qt4.eclass 5# @ECLASS: qt4.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Ben de Groot <yngwin@gentoo.org>,
8# Markos Chandras <hwoarang@gentoo.org>,
7# Caleb Tennis <caleb@gentoo.org> 9# Caleb Tennis <caleb@gentoo.org>,
10# Przemyslaw Maciag <troll@gentoo.org>,
11# Davide Pesavento <davidepesa@gmail.com>
8# @BLURB: Eclass for Qt4 packages 12# @BLURB: Eclass for Qt4 packages
9# @DESCRIPTION: 13# @DESCRIPTION:
10# This eclass contains various functions that may be useful 14# This eclass contains various functions that may be useful
11# when dealing with packages using Qt4 libraries. 15# when dealing with packages using Qt4 libraries.
12 16
13# 08.16.06 - Renamed qt_min_* to qt4_min_* to avoid conflicts with the qt3 eclass.
14# - Caleb Tennis <caleb@gentoo.org>
15
16inherit eutils multilib toolchain-funcs versionator 17inherit base eutils multilib toolchain-funcs versionator
17 18
18QTPKG="x11-libs/qt-" 19export XDG_CONFIG_HOME="${T}"
19QT4MAJORVERSIONS="4.4 4.3 4.2 4.1 4.0"
20QT4VERSIONS="4.4.1 4.4.0 4.4.0_beta1 4.4.0_rc1
21 4.3.4-r1 4.3.5 4.3.4 4.3.3 4.3.2-r1 4.3.2 4.3.1-r1 4.3.1
22 4.3.0-r2 4.3.0-r1 4.3.0 4.3.0_rc1 4.3.0_beta1
23 4.2.3-r1 4.2.3 4.2.2 4.2.1 4.2.0-r2 4.2.0-r1 4.2.0
24 4.1.4-r2 4.1.4-r1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0
25 4.0.1 4.0.0"
26
27# @FUNCTION: qt4_min_version
28# @USAGE: [minimum version]
29# @DESCRIPTION:
30# This function is deprecated. Use slot dependencies instead.
31qt4_min_version() {
32 local deps="$@"
33 ewarn "${CATEGORY}/${PF}: qt4_min_version() is deprecated. Use slot dependencies instead."
34 case ${EAPI:-0} in
35 # EAPIs without SLOT dependencies
36 0) echo "|| ("
37 qt4_min_version_list "${deps}"
38 echo ")"
39 ;;
40 # EAPIS with SLOT dependencies.
41 *) echo ">=${QTPKG}${1}:4"
42 ;;
43 esac
44}
45
46qt4_min_version_list() {
47 local MINVER="$1"
48 local VERSIONS=""
49
50 case "${MINVER}" in
51 4|4.0|4.0.0) VERSIONS="=${QTPKG}4*";;
52 4.1|4.1.0|4.2|4.2.0|4.3|4.3.0|4.4|4.4.0)
53 for x in ${QT4MAJORVERSIONS}; do
54 if version_is_at_least "${MINVER}" "${x}"; then
55 VERSIONS="${VERSIONS} =${QTPKG}${x}*"
56 fi
57 done
58 ;;
59 4*)
60 for x in ${QT4VERSIONS}; do
61 if version_is_at_least "${MINVER}" "${x}"; then
62 VERSIONS="${VERSIONS} =${QTPKG}${x}"
63 fi
64 done
65 ;;
66 *) VERSIONS="=${QTPKG}4*";;
67 esac
68
69 echo "${VERSIONS}"
70}
71 20
72qt4_monolithic_to_split_flag() { 21qt4_monolithic_to_split_flag() {
73 case ${1} in 22 case ${1} in
74 zlib) 23 zlib)
75 # Qt 4.4+ is always built with zlib enabled, so this flag isn't needed 24 # Qt 4.4+ is always built with zlib enabled, so this flag isn't needed
119 ;; 68 ;;
120 esac 69 esac
121} 70}
122 71
123# @FUNCTION: qt4_pkg_setup 72# @FUNCTION: qt4_pkg_setup
124# @MAINTAINER:
125# Caleb Tennis <caleb@gentoo.org>
126# Przemyslaw Maciag <troll@gentoo.org>
127# @DESCRIPTION: 73# @DESCRIPTION:
128# Default pkg_setup function for packages that depends on qt4. If you have to 74# Default pkg_setup function for packages that depends on qt4. If you have to
129# create ebuilds own pkg_setup in your ebuild, call qt4_pkg_setup in it. 75# create ebuilds own pkg_setup in your ebuild, call qt4_pkg_setup in it.
130# This function uses two global vars from ebuild: 76# This function uses two global vars from ebuild:
131# - QT4_BUILT_WITH_USE_CHECK - contains use flags that need to be turned on for 77# - QT4_BUILT_WITH_USE_CHECK - contains use flags that need to be turned on for
132# =x11-libs/qt-4* 78# =x11-libs/qt-4*
133# - QT4_OPTIONAL_BUILT_WITH_USE_CHECK - qt4 flags that provides some 79# - QT4_OPTIONAL_BUILT_WITH_USE_CHECK - qt4 flags that provides some
134# functionality, but can alternatively be disabled in ${CATEGORY}/${PN} 80# functionality, but can alternatively be disabled in ${CATEGORY}/${PN}
135# (so qt4 don't have to be recompiled) 81# (so qt4 don't have to be recompiled)
136# 82#
83# NOTE: Using the above vars is now deprecated in favor of eapi-2 use deps
84#
137# flags to watch for for Qt4.4: 85# flags to watch for for Qt4.4:
138# zlib png | opengl dbus qt3support | sqlite3 ssl 86# zlib png | opengl dbus qt3support | sqlite3 ssl
139qt4_pkg_setup() { 87qt4_pkg_setup() {
140 local x y checkpkgs checkflags fatalerrors=0 requiredflags="" 88 local x y checkpkgs checkflags fatalerrors=0 requiredflags=""
141 89
142 # lots of has_version calls can be very expensive 90 # lots of has_version calls can be very expensive
143 if [[ -n ${QT4_BUILT_WITH_USE_CHECK}${QT4_OPTIONAL_BUILT_WITH_USE_CHECK} ]]; then 91 if [[ -n ${QT4_BUILT_WITH_USE_CHECK}${QT4_OPTIONAL_BUILT_WITH_USE_CHECK} ]]; then
92 ewarn "QA notice: The QT4_BUILT_WITH_USE functionality is deprecated and"
93 ewarn "will be removed from future versions of qt4.eclass. Please update"
94 ewarn "the ebuild to use eapi-2 use dependencies instead."
144 has_version x11-libs/qt-core && local QT44=true 95 has_version x11-libs/qt-core && local QT44=true
145 fi 96 fi
146 97
147 for x in ${QT4_BUILT_WITH_USE_CHECK}; do 98 for x in ${QT4_BUILT_WITH_USE_CHECK}; do
148 if [[ -n ${QT44} ]]; then 99 if [[ -n ${QT44} ]]; then
217 fi 168 fi
218 169
219 [[ -n ${diemessage} ]] && die "can't install ${CATEGORY}/${PN}: ${diemessage}" 170 [[ -n ${diemessage} ]] && die "can't install ${CATEGORY}/${PN}: ${diemessage}"
220} 171}
221 172
173# @ECLASS-VARIABLE: PATCHES
174# @DESCRIPTION:
175# In case you have patches to apply, specify them in the PATCHES variable.
176# Make sure to specify the full path. This variable is necessary for the
177# src_prepare phase.
178# example:
179# PATCHES="${FILESDIR}/mypatch.patch
180# ${FILESDIR}/mypatch2.patch"
181#
182# @FUNCTION: qt4_src_prepare
183# @DESCRIPTION:
184# Default src_prepare function for packages that depend on qt4. If you have to
185# override src_prepare in your ebuild, you should call qt4_src_prepare in it,
186# otherwise autopatcher will not work!
187qt4_src_prepare() {
188 debug-print-function $FUNCNAME "$@"
189 base_src_prepare
190}
191
192# @FUNCTION: qt4_src_configure
193# @DESCRIPTION:
194# Default src_configure function for packages that depend on qt4. If you have to
195# override src_configure in your ebuild, call qt4_src_configure in it.
196#qt4_src_configure() {
197# debug-print-function $FUNCNAME "$@"
198# eqmake4
199#}
200
201# @FUNCTION: qt4_src_compile
202# @DESCRIPTION:
203# Default src_compile function for packages that depend on qt4. If you have to
204# override src_compile in your ebuild (probably you don't need to), call
205# qt4_src_compile in it.
206#qt4_src_compile() {
207# debug-print-function $FUNCNAME "$@"
208# case "${EAPI:-0}" in
209# 2)
210# emake || die "emake failed"
211# ;;
212# 0|1)
213# qt4_src_prepare
214# qt4_src_configure
215# emake || die "emake failed"
216# ;;
217# esac
218#}
219
222# @FUNCTION: eqmake4 220# @FUNCTION: eqmake4
223# @USAGE: [.pro file] [additional parameters to qmake] 221# @USAGE: [.pro file] [additional parameters to qmake]
224# @MAINTAINER:
225# Przemyslaw Maciag <troll@gentoo.org>
226# Davide Pesavento <davidepesa@gmail.com>
227# @DESCRIPTION: 222# @DESCRIPTION:
228# Runs qmake on the specified .pro file (defaults to 223# Runs qmake on the specified .pro file (defaults to ${PN}.pro if called
229# ${PN}.pro if eqmake4 was called with no argument). 224# without arguments). Additional parameters are appended unmodified to
230# Additional parameters are passed unmodified to qmake. 225# qmake command line. For recursive build systems, i.e. those based on
226# the subdirs template, you should run eqmake4 on the top-level project
227# file only, unless you have strong reasons to do things differently.
228# During the building, qmake will be automatically re-invoked with the
229# right arguments on every directory specified inside the top-level
230# project file by the SUBDIRS variable.
231eqmake4() { 231eqmake4() {
232 local LOGFILE="${T}/qmake-$$.out" 232 local projectfile="${1:-${PN}.pro}"
233 local projprofile="${1}"
234 [[ -z ${projprofile} ]] && projprofile="${PN}.pro"
235 shift 1 233 shift
236 234
237 ebegin "Processing qmake ${projprofile}"
238
239 # file exists?
240 if [[ ! -f ${projprofile} ]]; then 235 if [[ ! -f ${projectfile} ]]; then
241 echo 236 echo
242 eerror "Project .pro file \"${projprofile}\" does not exists" 237 eerror "Project file '${projectfile#${WORKDIR}/}' does not exists!"
243 eerror "qmake cannot handle non-existing .pro files" 238 eerror "eqmake4 cannot handle non-existing project files."
239 eerror
240 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
244 echo 241 echo
245 eerror "This shouldn't happen - please send a bug report to bugs.gentoo.org"
246 echo
247 die "Project file not found in ${PN} sources" 242 die "Project file not found in ${CATEGORY}/${PN} sources."
248 fi 243 fi
249 244
250 echo >> ${LOGFILE} 245 ebegin "Running qmake on ${projectfile}"
251 echo "****** qmake ${projprofile} ******" >> ${LOGFILE}
252 echo >> ${LOGFILE}
253 246
254 # as a workaround for broken qmake, put everything into file 247 # make sure CONFIG variable is correctly set for both release and debug builds
248 local CONFIG_ADD="release"
249 local CONFIG_REMOVE="debug"
255 if has debug ${IUSE} && use debug; then 250 if has debug ${IUSE} && use debug; then
256 echo -e "\nCONFIG -= release\nCONFIG += no_fixpath debug" >> ${projprofile} 251 CONFIG_ADD="debug"
257 else 252 CONFIG_REMOVE="release"
258 echo -e "\nCONFIG -= debug\nCONFIG += no_fixpath release" >> ${projprofile} 253 fi
254 local awkscript='BEGIN {
255 printf "### eqmake4 was here ###\n" > file;
256 fixed=0;
257 }
258 /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
259 for (i=1; i <= NF; i++) {
260 if ($i ~ rem || $i ~ /debug_and_release/)
261 { $i=add; fixed=1; }
262 }
263 }
264 /^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
265 for (i=1; i <= NF; i++) {
266 if ($i ~ add) { $i=rem; fixed=1; }
267 }
268 }
269 {
270 print >> file;
271 }
272 END {
273 printf "\nCONFIG -= debug_and_release %s\n", rem >> file;
274 printf "CONFIG += %s\n", add >> file;
275 print fixed;
276 }'
277 local filepath=
278 while read filepath; do
279 local file="${filepath#./}"
280 grep -q '^### eqmake4 was here ###$' "${file}" && continue
281 local retval=$({
282 rm -f "${file}" || echo "FAILED"
283 awk -v file="${file}" -- "${awkscript}" add=${CONFIG_ADD} rem=${CONFIG_REMOVE} || echo "FAILED"
284 } < "${file}")
285 if [[ ${retval} == 1 ]]; then
286 einfo " Fixed CONFIG in ${file}"
287 elif [[ ${retval} != 0 ]]; then
288 eerror " An error occurred while processing ${file}"
289 die "eqmake4 failed to process '${file}'."
259 fi 290 fi
291 done < <(find "$(dirname "${projectfile}")" -type f -name "*.pr[io]" 2>/dev/null)
260 292
261 /usr/bin/qmake ${projprofile} \ 293 /usr/bin/qmake -makefile -nocache \
262 QTDIR=/usr/$(get_libdir) \ 294 QTDIR=/usr/$(get_libdir) \
263 QMAKE=/usr/bin/qmake \ 295 QMAKE=/usr/bin/qmake \
264 QMAKE_CC=$(tc-getCC) \ 296 QMAKE_CC=$(tc-getCC) \
265 QMAKE_CXX=$(tc-getCXX) \ 297 QMAKE_CXX=$(tc-getCXX) \
266 QMAKE_LINK=$(tc-getCXX) \ 298 QMAKE_LINK=$(tc-getCXX) \
269 QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \ 301 QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \
270 QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \ 302 QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \
271 QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \ 303 QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \
272 QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \ 304 QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \
273 QMAKE_RPATH= \ 305 QMAKE_RPATH= \
274 "${@}" >> ${LOGFILE} 2>&1 306 QMAKE_STRIP= \
307 "${projectfile}" "${@}"
275 308
276 local result=$? 309 eend $?
277 eend ${result}
278 310
279 # was qmake successful? 311 # was qmake successful?
280 if [[ ${result} -ne 0 ]]; then 312 if [[ $? -ne 0 ]]; then
281 echo 313 echo
282 eerror "Running qmake on \"${projprofile}\" has failed" 314 eerror "Running qmake on '${projectfile#${WORKDIR}/}' has failed!"
315 eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
283 echo 316 echo
284 eerror "This shouldn't happen - please send a bug report to bugs.gentoo.org"
285 echo
286 die "qmake failed on ${projprofile}" 317 die "qmake failed on '${projectfile}'."
287 fi 318 fi
288 319
289 return ${result} 320 return 0
290} 321}
291 322
323case ${EAPI:-0} in
324 2)
325 EXPORT_FUNCTIONS pkg_setup src_prepare
326 ;;
327 0|1)
292EXPORT_FUNCTIONS pkg_setup 328 EXPORT_FUNCTIONS pkg_setup
329 ;;
330esac

Legend:
Removed from v.1.48  
changed lines
  Added in v.1.57

  ViewVC Help
Powered by ViewVC 1.1.20