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

Contents of /eclass/qt4.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.53 - (hide annotations) (download)
Sat May 9 12:45:40 2009 UTC (4 years, 11 months ago) by hwoarang
Branch: MAIN
Changes since 1.52: +69 -35 lines
New eqmake4. Fixes bug #244692 . Thanks to Davide Pesavento <davidepesa@gmail.com> for all the patches

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

  ViewVC Help
Powered by ViewVC 1.1.20