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

Contents of /eclass/qt4.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.63 - (hide annotations) (download)
Mon Aug 22 04:46:32 2011 UTC (3 years, 4 months ago) by vapier
Branch: MAIN
Changes since 1.62: +3 -3 lines
fix random bugs in eclass documentation, and convert to new @AUTHOR tag

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

  ViewVC Help
Powered by ViewVC 1.1.20