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

Diff of /eclass/qt4.eclass

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

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

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.61

  ViewVC Help
Powered by ViewVC 1.1.20