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

Contents of /eclass/qt4.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.65 - (hide annotations) (download)
Sat May 19 13:40:52 2012 UTC (2 years, 1 month ago) by pesa
Branch: MAIN
Changes since 1.64: +4 -3 lines
qt4.eclass is dead.

1 pesa 1.65 # Copyright 1999-2012 Gentoo Foundation
2 caleb 1.1 # Distributed under the terms of the GNU General Public License v2
3 pesa 1.65 # $Header: /var/cvsroot/gentoo-x86/eclass/qt4.eclass,v 1.64 2011/11/22 18:42:10 vapier Exp $
4 wired 1.62
5 pesa 1.65 # @DEAD
6 wired 1.62 # @DEPRECATED
7     # This eclass has been superseded by qt4-r2
8     # Please modify your ebuilds to use that instead
9 troll 1.29
10     # @ECLASS: qt4.eclass
11     # @MAINTAINER:
12 vapier 1.64 # Ben de Groot <yngwin@gentoo.org>
13     # Markos Chandras <hwoarang@gentoo.org>
14     # Caleb Tennis <caleb@gentoo.org>
15     # Przemyslaw Maciag <troll@gentoo.org>
16 pesa 1.65 # Davide Pesavento <pesa@gentoo.org>
17 ingmar 1.38 # @BLURB: Eclass for Qt4 packages
18 troll 1.29 # @DESCRIPTION:
19     # This eclass contains various functions that may be useful
20     # when dealing with packages using Qt4 libraries.
21    
22 yngwin 1.51 inherit base eutils multilib toolchain-funcs versionator
23 caleb 1.16
24 hwoarang 1.56 export XDG_CONFIG_HOME="${T}"
25    
26 zlin 1.44 qt4_monolithic_to_split_flag() {
27     case ${1} in
28     zlib)
29     # Qt 4.4+ is always built with zlib enabled, so this flag isn't needed
30     ;;
31     gif|jpeg|png)
32     # qt-gui always installs with these enabled
33     checkpkgs+=" x11-libs/qt-gui"
34     ;;
35     dbus|opengl)
36     # Make sure the qt-${1} package has been installed already
37     checkpkgs+=" x11-libs/qt-${1}"
38     ;;
39     qt3support)
40     checkpkgs+=" x11-libs/qt-${1}"
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
75     }
76    
77 troll 1.29 # @FUNCTION: qt4_pkg_setup
78     # @DESCRIPTION:
79     # Default pkg_setup function for packages that depends on qt4. If you have to
80     # create ebuilds own pkg_setup in your ebuild, call qt4_pkg_setup in it.
81     # This function uses two global vars from ebuild:
82     # - QT4_BUILT_WITH_USE_CHECK - contains use flags that need to be turned on for
83     # =x11-libs/qt-4*
84     # - QT4_OPTIONAL_BUILT_WITH_USE_CHECK - qt4 flags that provides some
85     # functionality, but can alternatively be disabled in ${CATEGORY}/${PN}
86     # (so qt4 don't have to be recompiled)
87 caleb 1.31 #
88 yngwin 1.51 # NOTE: Using the above vars is now deprecated in favor of eapi-2 use deps
89     #
90 caleb 1.31 # flags to watch for for Qt4.4:
91     # zlib png | opengl dbus qt3support | sqlite3 ssl
92 caleb 1.16 qt4_pkg_setup() {
93 zlin 1.44 local x y checkpkgs checkflags fatalerrors=0 requiredflags=""
94 caleb 1.31
95 zlin 1.44 # lots of has_version calls can be very expensive
96     if [[ -n ${QT4_BUILT_WITH_USE_CHECK}${QT4_OPTIONAL_BUILT_WITH_USE_CHECK} ]]; then
97 yngwin 1.51 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 zlin 1.44 has_version x11-libs/qt-core && local QT44=true
101     fi
102 caleb 1.31
103 caleb 1.20 for x in ${QT4_BUILT_WITH_USE_CHECK}; do
104 zlin 1.44 if [[ -n ${QT44} ]]; then
105     # The use flags are different in 4.4 and above, and it's split packages, so this is used to catch
106     # the various use flag combos specified in the ebuilds to make sure we don't error out for no reason.
107     qt4_monolithic_to_split_flag ${x}
108 gentoofan23 1.42 else
109 zlin 1.44 [[ ${x} == *accessibility ]] && x=${x#gui} && x=${x#qt3}
110 gentoofan23 1.42 if ! built_with_use =x11-libs/qt-4* ${x}; then
111     requiredflags="${requiredflags} ${x}"
112 caleb 1.31 fi
113 troll 1.29 fi
114     done
115    
116     local optionalflags=""
117     for x in ${QT4_OPTIONAL_BUILT_WITH_USE_CHECK}; do
118 zlin 1.44 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}
123     elif ! built_with_use =x11-libs/qt-4* ${x}; then
124     optionalflags="${optionalflags} ${x}"
125     fi
126     fi
127     done
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 caleb 1.16 fi
148     done
149 troll 1.29
150     local diemessage=""
151 zlin 1.44 if [[ ${fatalerrors} -ne 0 ]]; then
152     diemessage="${fatalerrors} fatal errors were detected. Please read the above error messages and act accordingly."
153     fi
154     if [[ -n ${requiredflags} ]]; then
155 troll 1.29 eerror
156     eerror "(1) In order to compile ${CATEGORY}/${PN} first you need to build"
157     eerror "=x11-libs/qt-4* with USE=\"${requiredflags}\" flag(s)"
158     eerror
159     diemessage="(1) recompile qt4 with \"${requiredflags}\" USE flag(s) ; "
160     fi
161 zlin 1.44 if [[ -n ${optionalflags} ]]; then
162 troll 1.29 eerror
163     eerror "(2) You are trying to compile ${CATEGORY}/${PN} package with"
164     eerror "USE=\"${optionalflags}\""
165     eerror "while qt4 is built without this particular flag(s): it will"
166     eerror "not work."
167     eerror
168     eerror "Possible solutions to this problem are:"
169     eerror "a) install package ${CATEGORY}/${PN} without \"${optionalflags}\" USE flag(s)"
170     eerror "b) re-emerge qt4 with \"${optionalflags}\" USE flag(s)"
171     eerror
172     diemessage="${diemessage}(2) recompile qt4 with \"${optionalflags}\" USE flag(s) or disable them for ${PN} package\n"
173     fi
174    
175 zlin 1.44 [[ -n ${diemessage} ]] && die "can't install ${CATEGORY}/${PN}: ${diemessage}"
176 caleb 1.16 }
177 caleb 1.20
178 yngwin 1.51 # @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 scarabeus 1.60 # PATCHES=(
185     # "${FILESDIR}/mypatch.patch"
186     # "${FILESDIR}/mypatch2.patch"
187     # )
188 vapier 1.63
189 yngwin 1.51 # @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!
194     qt4_src_prepare() {
195     debug-print-function $FUNCNAME "$@"
196     base_src_prepare
197     }
198    
199 troll 1.29 # @FUNCTION: eqmake4
200     # @USAGE: [.pro file] [additional parameters to qmake]
201     # @DESCRIPTION:
202 hwoarang 1.53 # Runs qmake on the specified .pro file (defaults to ${PN}.pro if called
203     # without arguments). Additional parameters are appended unmodified to
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.
210 caleb 1.20 eqmake4() {
211 abcd 1.61 has "${EAPI:-0}" 0 1 2 && use !prefix && EPREFIX=
212    
213 hwoarang 1.53 local projectfile="${1:-${PN}.pro}"
214     shift
215 caleb 1.20
216 hwoarang 1.53 if [[ ! -f ${projectfile} ]]; then
217 caleb 1.20 echo
218 hwoarang 1.53 eerror "Project file '${projectfile#${WORKDIR}/}' does not exists!"
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/"
222 caleb 1.20 echo
223 hwoarang 1.53 die "Project file not found in ${CATEGORY}/${PN} sources."
224 caleb 1.20 fi
225    
226 hwoarang 1.53 ebegin "Running qmake on ${projectfile}"
227 caleb 1.20
228 hwoarang 1.53 # make sure CONFIG variable is correctly set for both release and debug builds
229     local CONFIG_ADD="release"
230     local CONFIG_REMOVE="debug"
231 caleb 1.22 if has debug ${IUSE} && use debug; then
232 hwoarang 1.53 CONFIG_ADD="debug"
233     CONFIG_REMOVE="release"
234 caleb 1.20 fi
235 hwoarang 1.53 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 hwoarang 1.57 printf "\nCONFIG -= debug_and_release %s\n", rem >> file;
255 hwoarang 1.53 printf "CONFIG += %s\n", add >> file;
256     print fixed;
257     }'
258 hwoarang 1.55 local filepath=
259     while read filepath; do
260     local file="${filepath#./}"
261 hwoarang 1.53 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}'."
271     fi
272 hwoarang 1.55 done < <(find "$(dirname "${projectfile}")" -type f -name "*.pr[io]" 2>/dev/null)
273 caleb 1.20
274 abcd 1.61 "${EPREFIX}"/usr/bin/qmake -makefile -nocache \
275     QTDIR="${EPREFIX}"/usr/$(get_libdir) \
276     QMAKE="${EPREFIX}"/usr/bin/qmake \
277 caleb 1.20 QMAKE_CC=$(tc-getCC) \
278     QMAKE_CXX=$(tc-getCXX) \
279     QMAKE_LINK=$(tc-getCXX) \
280     QMAKE_CFLAGS_RELEASE="${CFLAGS}" \
281     QMAKE_CFLAGS_DEBUG="${CFLAGS}" \
282     QMAKE_CXXFLAGS_RELEASE="${CXXFLAGS}" \
283     QMAKE_CXXFLAGS_DEBUG="${CXXFLAGS}" \
284     QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \
285     QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \
286 hwoarang 1.50 QMAKE_STRIP= \
287 hwoarang 1.53 "${projectfile}" "${@}"
288 caleb 1.20
289 hwoarang 1.53 eend $?
290 caleb 1.20
291     # was qmake successful?
292 hwoarang 1.53 if [[ $? -ne 0 ]]; then
293 caleb 1.20 echo
294 hwoarang 1.53 eerror "Running qmake on '${projectfile#${WORKDIR}/}' has failed!"
295     eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/"
296 caleb 1.20 echo
297 hwoarang 1.53 die "qmake failed on '${projectfile}'."
298 caleb 1.20 fi
299    
300 hwoarang 1.53 return 0
301 caleb 1.20 }
302    
303 yngwin 1.51 case ${EAPI:-0} in
304 abcd 1.61 2|3)
305 yngwin 1.52 EXPORT_FUNCTIONS pkg_setup src_prepare
306 yngwin 1.51 ;;
307     0|1)
308 yngwin 1.52 EXPORT_FUNCTIONS pkg_setup
309 yngwin 1.51 ;;
310     esac

  ViewVC Help
Powered by ViewVC 1.1.20