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

Diff of /eclass/qt4-build.eclass

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

Revision 1.41 Revision 1.51
1# Copyright 2007-2009 Gentoo Foundation 1# Copyright 2007-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/qt4-build.eclass,v 1.41 2009/06/28 15:24:42 hwoarang Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/qt4-build.eclass,v 1.51 2009/11/10 00:56:29 spatz Exp $
4 4
5# @ECLASS: qt4-build.eclass 5# @ECLASS: qt4-build.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Ben de Groot <yngwin@gentoo.org>, 7# Ben de Groot <yngwin@gentoo.org>,
8# Markos Chandras <hwoarang@gentoo.org>, 8# Markos Chandras <hwoarang@gentoo.org>,
9# Caleb Tennis <caleb@gentoo.org> 9# Caleb Tennis <caleb@gentoo.org>
10# Alex Alexander <wired@gentoo.org>
10# @BLURB: Eclass for Qt4 split ebuilds. 11# @BLURB: Eclass for Qt4 split ebuilds.
11# @DESCRIPTION: 12# @DESCRIPTION:
12# This eclass contains various functions that are used when building Qt4 13# This eclass contains various functions that are used when building Qt4
13 14
14inherit base eutils multilib toolchain-funcs flag-o-matic versionator 15inherit base eutils multilib toolchain-funcs flag-o-matic versionator
43 !>x11-libs/qt-webkit-${PV}-r9999 44 !>x11-libs/qt-webkit-${PV}-r9999
44 !<x11-libs/qt-xmlpatterns-${PV} 45 !<x11-libs/qt-xmlpatterns-${PV}
45 !>x11-libs/qt-xmlpatterns-${PV}-r9999 46 !>x11-libs/qt-xmlpatterns-${PV}-r9999
46" 47"
47case "${PV}" in 48case "${PV}" in
48 4.?.?_rc*) 49 4.?.?_rc* | 4.?.?_beta* )
49 SRCTYPE="${SRCTYPE:-opensource-src}" 50 SRCTYPE="${SRCTYPE:-opensource-src}"
50 MY_PV="${PV/_rc/-rc}" 51 MY_PV="${PV/_/-}"
51 ;; 52 ;;
52 *) 53 *)
53 SRCTYPE="${SRCTYPE:-opensource-src}" 54 SRCTYPE="${SRCTYPE:-opensource-src}"
54 MY_PV="${PV}" 55 MY_PV="${PV}"
55 ;; 56 ;;
56esac 57esac
58
59if version_is_at_least 4.5.99999999 ${PV} ; then
60 MY_P="qt-everywhere-${SRCTYPE}-${MY_PV}"
61else
57MY_P=qt-x11-${SRCTYPE}-${MY_PV} 62 MY_P="qt-x11-${SRCTYPE}-${MY_PV}"
63fi
58S=${WORKDIR}/${MY_P} 64S=${WORKDIR}/${MY_P}
59 65
60HOMEPAGE="http://www.qtsoftware.com/" 66HOMEPAGE="http://qt.nokia.com/"
67if version_is_at_least 4.5.3 ${PV} ; then
68 SRC_URI="http://get.qt.nokia.com/qt/source/${MY_P}.tar.gz"
69else
61SRC_URI="http://get.qtsoftware.com/qt/source/${MY_P}.tar.bz2" 70 SRC_URI="http://get.qt.nokia.com/qt/source/${MY_P}.tar.bz2"
71fi
62 72
63case "${PV}" in 73case "${PV}" in
64 4.4.?) SRC_URI="${SRC_URI} mirror://gentoo/${MY_P}-headers.tar.bz2" ;; 74 4.4.?) SRC_URI="${SRC_URI} mirror://gentoo/${MY_P}-headers.tar.bz2" ;;
65 *) ;; 75 *) ;;
66esac 76esac
82 fi 92 fi
83 93
84 # Check USE requirements 94 # Check USE requirements
85 qt4-build_check_use 95 qt4-build_check_use
86 fi 96 fi
97
98 PATH="${S}/bin:${PATH}"
99 LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}"
100
101 if ! version_is_at_least 4.1 $(gcc-version) ; then
102 ewarn "Using a GCC version lower than 4.1 is not supported!"
103 echo
104 ebeep 3
105 fi
106}
107
108# @ECLASS-VARIABLE: QT4_TARGET_DIRECTORIES
109# @DESCRIPTION:
110# Arguments for build_target_directories. Takes the directories, in which the
111# code should be compiled. This is a space-separated list
112
113# @ECLASS-VARIABLE: QT4_EXTRACT_DIRECTORIES
114# @DESCRIPTION:
115# Space separated list including the directories that will be extracted from Qt
116# tarball
117
118# @FUNCTION: qt4-build_src_unpack
119# @DESCRIPTION:
120# Unpacks the sources
121qt4-build_src_unpack() {
122 setqtenv
123 local target targets licenses tar_pkg tar_args
124 if version_is_at_least 4.5 ${PV} ; then
125 licenses="LICENSE.GPL3 LICENSE.LGPL"
126 else
127 licenses="LICENSE.GPL2 LICENSE.GPL3"
128 fi
129 for target in configure ${licenses} projects.pro \
130 src/{qbase,qt_targets,qt_install}.pri bin config.tests mkspecs qmake \
131 ${QT4_EXTRACT_DIRECTORIES}; do
132 targets="${targets} ${MY_P}/${target}"
133 done
134
135 tar_pkg=${MY_P}.tar.bz2
136 tar_args="xjpf"
137 if version_is_at_least 4.5.3 ${PV} ; then
138 tar_pkg=${tar_pkg/bz2/gz}
139 tar_args="xzpf"
140 fi
141
142 echo tar ${tar_args} "${DISTDIR}"/${tar_pkg} ${targets}
143 tar ${tar_args} "${DISTDIR}"/${tar_pkg} ${targets}
144
145 case "${PV}" in
146 4.4.?)
147 echo tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2
148 tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2
149 ;;
150 esac
151
152 # Be backwards compatible for now
153 if [[ $EAPI != 2 ]]; then
154 qt4-build_src_prepare
155 fi
156}
157
158# @ECLASS-VARIABLE: PATCHES
159# @DESCRIPTION:
160# In case you have patches to apply, specify them in PATCHES variable. Make sure
161# to specify the full path. This variable is necessary for src_prepare phase.
162# example:
163# PATCHES="${FILESDIR}"/mypatch.patch
164# ${FILESDIR}"/mypatch2.patch"
165#
166
167# @FUNCTION: qt4-build_src_prepare
168# @DESCRIPTION:
169# Prepare the sources before the configure phase. Strip CFLAGS if necessary, and fix
170# source files in order to respect CFLAGS/CXXFLAGS/LDFLAGS specified on /etc/make.conf.
171qt4-build_src_prepare() {
172 setqtenv
173 cd "${S}"
174
175 if [[ ${PN} != qt-core ]]; then
176 skip_qmake_build_patch
177 skip_project_generation_patch
178 symlink_binaries_to_buildtree
179 fi
180
181 # Bug 282984
182 sed -e "s/\(^SYSTEM_VARIABLES\)/CC=$(tc-getCC)\nCXX=$(tc-getCXX)\n\1/" \
183 -i configure || die "sed qmake compilers failed"
184 sed -e "s/\(\$MAKE\)/\1 CC=$(tc-getCC) CXX=$(tc-getCXX) LD=$(tc-getCXX)/" \
185 -i config.tests/unix/compile.test || die "sed test compilers failed"
186
187 # Bug 178652
188 if [[ "$(gcc-major-version)" == "3" ]] && use amd64; then
189 ewarn "Appending -fno-gcse to CFLAGS/CXXFLAGS"
190 append-flags -fno-gcse
191 fi
192
193 # Unsupported old gcc versions - hardened needs this :(
194 if [[ $(gcc-major-version) -lt "4" ]] ; then
195 ewarn "Appending -fno-stack-protector to CXXFLAGS"
196 append-cxxflags -fno-stack-protector
197 # Bug 253127
198 sed -e "/^QMAKE_CFLAGS\t/ s:$: -fno-stack-protector-all:" \
199 -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed"
200 fi
201
202 # Bug 261632
203 if use ppc64; then
204 ewarn "Appending -mminimal-toc to CFLAGS/CXXFLAGS"
205 append-flags -mminimal-toc
206 fi
207
208 # Bug 172219
209 sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
210 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
211 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
212 -e "s:X11R6/::" \
213 -i "${S}"/mkspecs/$(qt_mkspecs_dir)/qmake.conf || die "sed ${S}/mkspecs/$(qt_mkspecs_dir)/qmake.conf failed"
214
215 sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
216 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
217 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
218 -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed"
219
220 base_src_prepare
221}
222
223# @FUNCTION: qt4-build_src_configure
224# @DESCRIPTION:
225# Default configure phase
226qt4-build_src_configure() {
227 setqtenv
228 myconf="$(standard_configure_options) ${myconf}"
229
230 echo ./configure ${myconf}
231 ./configure ${myconf} || die "./configure failed"
232 myconf=""
233}
234
235# @FUNCTION: qt4-build_src_compile
236# @DESCRIPTION: Actual compile phase
237qt4-build_src_compile() {
238 setqtenv
239 # Be backwards compatible for now
240 if [[ $EAPI != 2 ]]; then
241 qt4-build_src_configure
242 fi
243
244 build_directories "${QT4_TARGET_DIRECTORIES}"
245}
246
247# @FUNCTION: qt4-build_src_install
248# @DESCRIPTION:
249# Perform the actual installation including some library fixes.
250qt4-build_src_install() {
251 setqtenv
252 install_directories "${QT4_TARGET_DIRECTORIES}"
253 install_qconfigs
254 fix_library_files
255}
256
257# @FUNCTION: setqtenv
258setqtenv() {
87 # Set up installation directories 259 # Set up installation directories
88 QTBASEDIR=/usr/$(get_libdir)/qt4 260 QTBASEDIR=/usr/$(get_libdir)/qt4
89 QTPREFIXDIR=/usr 261 QTPREFIXDIR=/usr
90 QTBINDIR=/usr/bin 262 QTBINDIR=/usr/bin
91 QTLIBDIR=/usr/$(get_libdir)/qt4 263 QTLIBDIR=/usr/$(get_libdir)/qt4
264 QMAKE_LIBDIR_QT=${QTLIBDIR}
92 QTPCDIR=/usr/$(get_libdir)/pkgconfig 265 QTPCDIR=/usr/$(get_libdir)/pkgconfig
93 QTDATADIR=/usr/share/qt4 266 QTDATADIR=/usr/share/qt4
94 QTDOCDIR=/usr/share/doc/qt-${PV} 267 QTDOCDIR=/usr/share/doc/qt-${PV}
95 QTHEADERDIR=/usr/include/qt4 268 QTHEADERDIR=/usr/include/qt4
96 QTPLUGINDIR=${QTLIBDIR}/plugins 269 QTPLUGINDIR=${QTLIBDIR}/plugins
97 QTSYSCONFDIR=/etc/qt4 270 QTSYSCONFDIR=/etc/qt4
98 QTTRANSDIR=${QTDATADIR}/translations 271 QTTRANSDIR=${QTDATADIR}/translations
99 QTEXAMPLESDIR=${QTDATADIR}/examples 272 QTEXAMPLESDIR=${QTDATADIR}/examples
100 QTDEMOSDIR=${QTDATADIR}/demos 273 QTDEMOSDIR=${QTDATADIR}/demos
101 274 QT_INSTALL_PREFIX=/usr/$(get_libdir)/qt4
102 PLATFORM=$(qt_mkspecs_dir) 275 PLATFORM=$(qt_mkspecs_dir)
103 276
104 PATH="${S}/bin:${PATH}" 277 unset QMAKESPEC
105 LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}"
106
107 if ! version_is_at_least 4.1 $(gcc-version) ; then
108 ewarn "Using a GCC version lower than 4.1 is not supported!"
109 echo
110 ebeep 3
111 fi
112}
113
114# @ECLASS-VARIABLE: QT4_TARGET_DIRECTORIES
115# @DESCRIPTION:
116# Arguments for build_target_directories. Takes the directories, in which the
117# code should be compiled. This is a space-separated list
118
119# @ECLASS-VARIABLE: QT4_EXTRACT_DIRECTORIES
120# @DESCRIPTION:
121# Space separated list including the directories that will be extracted from Qt
122# tarball
123
124# @FUNCTION: qt4-build_src_unpack
125# @DESCRIPTION:
126# Unpacks the sources
127qt4-build_src_unpack() {
128 local target targets licenses
129 if version_is_at_least 4.5 ${PV} ; then
130 licenses="LICENSE.GPL3 LICENSE.LGPL"
131 else
132 licenses="LICENSE.GPL2 LICENSE.GPL3"
133 fi
134 for target in configure ${licenses} projects.pro \
135 src/{qbase,qt_targets,qt_install}.pri bin config.tests mkspecs qmake \
136 ${QT4_EXTRACT_DIRECTORIES}; do
137 targets="${targets} ${MY_P}/${target}"
138 done
139
140 echo tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets}
141 tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets}
142
143 case "${PV}" in
144 4.4.?)
145 echo tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2
146 tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2
147 ;;
148 esac
149
150 # Be backwards compatible for now
151 if [[ $EAPI != 2 ]]; then
152 qt4-build_src_prepare
153 fi
154}
155
156# @ECLASS-VARIABLE: PATCHES
157# @DESCRIPTION:
158# In case you have patches to apply, specify them in PATCHES variable. Make sure
159# to specify the full path. This variable is necessary for src_prepare phase.
160# example:
161# PATCHES="${FILESDIR}"/mypatch.patch
162# ${FILESDIR}"/mypatch2.patch"
163#
164
165# @FUNCTION: qt4-build_src_prepare
166# @DESCRIPTION:
167# Prepare the sources before the configure phase. Strip CFLAGS if necessary, and fix
168# source files in order to respect CFLAGS/CXXFLAGS/LDFLAGS specified on /etc/make.conf.
169qt4-build_src_prepare() {
170 cd "${S}"
171
172 if [[ ${PN} != qt-core ]]; then
173 skip_qmake_build_patch
174 skip_project_generation_patch
175 symlink_binaries_to_buildtree
176 fi
177
178 # Bug 178652
179 if [[ "$(gcc-major-version)" == "3" ]] && use amd64; then
180 ewarn "Appending -fno-gcse to CFLAGS/CXXFLAGS"
181 append-flags -fno-gcse
182 fi
183
184 # Unsupported old gcc versions - hardened needs this :(
185 if [[ $(gcc-major-version) -lt "4" ]] ; then
186 ewarn "Appending -fno-stack-protector to CXXFLAGS"
187 append-cxxflags -fno-stack-protector
188 # Bug 253127
189 sed -e "/^QMAKE_CFLAGS\t/ s:$: -fno-stack-protector-all:" \
190 -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed"
191 fi
192
193 # Bug 172219
194 sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
195 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
196 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
197 -e "s:X11R6/::" \
198 -i "${S}"/mkspecs/$(qt_mkspecs_dir)/qmake.conf || die "sed ${S}/mkspecs/$(qt_mkspecs_dir)/qmake.conf failed"
199
200 sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
201 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
202 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
203 -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed"
204
205 base_src_prepare
206}
207
208# @FUNCTION: qt4-build_src_configure
209# @DESCRIPTION:
210# Default configure phase
211qt4-build_src_configure() {
212
213 myconf="$(standard_configure_options) ${myconf}"
214
215 echo ./configure ${myconf}
216 ./configure ${myconf} || die "./configure failed"
217}
218
219# @FUNCTION: qt4-build_src_compile
220# @DESCRIPTION: Actual compile phase
221qt4-build_src_compile() {
222 # Be backwards compatible for now
223 if [[ $EAPI != 2 ]]; then
224 qt4-build_src_configure
225 fi
226
227 build_directories "${QT4_TARGET_DIRECTORIES}"
228}
229
230# @FUNCTION: qt4-build_src_install
231# @DESCRIPTION:
232# Perform the actual installation including some library fixes.
233qt4-build_src_install() {
234 install_directories "${QT4_TARGET_DIRECTORIES}"
235 install_qconfigs
236 fix_library_files
237} 278}
238 279
239# @FUNCTION: standard_configure_options 280# @FUNCTION: standard_configure_options
240# @DESCRIPTION: 281# @DESCRIPTION:
241# Sets up some standard configure options, like libdir (if necessary), whether 282# Sets up some standard configure options, like libdir (if necessary), whether
272 alpha|arm|ia64|mips|s390|sparc) myconf="${myconf} -arch $(tc-arch)" ;; 313 alpha|arm|ia64|mips|s390|sparc) myconf="${myconf} -arch $(tc-arch)" ;;
273 hppa|sh) myconf="${myconf} -arch generic" ;; 314 hppa|sh) myconf="${myconf} -arch generic" ;;
274 *) die "$(tc-arch) is unsupported by this eclass. Please file a bug." ;; 315 *) die "$(tc-arch) is unsupported by this eclass. Please file a bug." ;;
275 esac 316 esac
276 317
318 # 4.6: build qt-core with exceptions or qt-xmlpatterns won't build
319 local exceptions=
320 case "${PV}" in
321 4.6.*)
322 if [[ ${PN} != "qt-core" ]] && [[ ${PN} != "qt-xmlpatterns" ]]; then
323 exceptions="-no-exceptions"
324 fi
325 ;;
326 *)
327 [[ ${PN} == "qt-xmlpatterns" ]] || exceptions="-no-exceptions"
328 ;;
329 esac
330
277 myconf="${myconf} -platform $(qt_mkspecs_dir) -stl -verbose -largefile -confirm-license -no-rpath 331 myconf="${myconf} -platform $(qt_mkspecs_dir) -stl -verbose -largefile -confirm-license
278 -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR} 332 -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR}
279 -datadir ${QTDATADIR} -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR} 333 -datadir ${QTDATADIR} -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR}
280 -plugindir ${QTPLUGINDIR} -sysconfdir ${QTSYSCONFDIR} 334 -plugindir ${QTPLUGINDIR} -sysconfdir ${QTSYSCONFDIR}
281 -translationdir ${QTTRANSDIR} -examplesdir ${QTEXAMPLESDIR} 335 -translationdir ${QTTRANSDIR} -examplesdir ${QTEXAMPLESDIR}
282 -demosdir ${QTDEMOSDIR} -silent -fast 336 -demosdir ${QTDEMOSDIR} -silent -fast
283 $([[ ${PN} == qt-xmlpatterns ]] || echo -no-exceptions) 337 ${exceptions}
284 -reduce-relocations -nomake examples -nomake demos" 338 -reduce-relocations -nomake examples -nomake demos"
285 339
286 # Make eclass 4.5.{1,2} ready 340 # Make eclass >= 4.5.x ready
287 case "${MY_PV}" in 341 case "${MY_PV}" in
288 4.5.1 | 4.5.2) 342 4.5.* | 4.6.* )
289 myconf="${myconf} -opensource" 343 myconf="${myconf} -opensource"
290 ;; 344 ;;
291 esac 345 esac
292 346
293 echo "${myconf}" 347 echo "${myconf}"
299# Compiles the code in $QT4_TARGET_DIRECTORIES 353# Compiles the code in $QT4_TARGET_DIRECTORIES
300build_directories() { 354build_directories() {
301 local dirs="$@" 355 local dirs="$@"
302 for x in ${dirs}; do 356 for x in ${dirs}; do
303 cd "${S}"/${x} 357 cd "${S}"/${x}
358 sed -i -e "s:\$\$\[QT_INSTALL_LIBS\]:/usr/$(get_libdir)/qt4:g" $(find "${S}" -name '*.pr[io]') "${S}"/mkspecs/common/linux.conf || die
304 "${S}"/bin/qmake "LIBS+=-L${QTLIBDIR}" "CONFIG+=nostrip" || die "qmake failed" 359 "${S}"/bin/qmake "LIBS+=-L${QTLIBDIR}" "CONFIG+=nostrip" || die "qmake failed"
305 emake || die "emake failed" 360 emake CC="@echo compiling \$< && $(tc-getCC)" \
361 CXX="@echo compiling \$< && $(tc-getCXX)" \
362 LINK="@echo linking \$@ && $(tc-getCXX)" || die "emake failed"
306 done 363 done
307} 364}
308 365
309# @FUNCTION: install_directories 366# @FUNCTION: install_directories
310# @USAGE: < directories > 367# @USAGE: < directories >
615 elif [[ ${CXX/icpc/} != ${CXX} ]]; then 672 elif [[ ${CXX/icpc/} != ${CXX} ]]; then
616 spec="${spec}-icc" 673 spec="${spec}-icc"
617 else 674 else
618 die "Unknown compiler ${CXX}." 675 die "Unknown compiler ${CXX}."
619 fi 676 fi
677 if [[ -n "${LIBDIR/lib}" ]]; then
678 spec="${spec}-${LIBDIR/lib}"
679 fi
620 680
621 echo "${spec}" 681 echo "${spec}"
622} 682}
623 683
624case ${EAPI:-0} in 684case ${EAPI:-0} in

Legend:
Removed from v.1.41  
changed lines
  Added in v.1.51

  ViewVC Help
Powered by ViewVC 1.1.20