/[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.7 Revision 1.29
1# Copyright 2007-2008 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.7 2008/03/05 23:06:26 ingmar Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/qt4-build.eclass,v 1.29 2009/03/28 00:21:13 gengor Exp $
4 4
5# @ECLASS: qt4-build.eclass 5# @ECLASS: qt4-build.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# Ben de Groot <yngwin@gentoo.org>,
8# Markos Chandras <hwoarang@gentoo.org>,
7# Caleb Tennis <caleb@gentoo.org> 9# Caleb Tennis <caleb@gentoo.org>
8# @BLURB: 10# @BLURB: Eclass for Qt4 split ebuilds.
9# Eclass for Qt4
10# @DESCRIPTION: 11# @DESCRIPTION:
11# This eclass contains various functions that are used when building Qt4 12# This eclass contains various functions that are used when building Qt4
12 13
13inherit eutils multilib toolchain-funcs flag-o-matic 14inherit eutils multilib toolchain-funcs flag-o-matic versionator
14 15
15IUSE="${IUSE} debug" 16IUSE="${IUSE} custom-cxxflags debug pch"
16 17
17case "${PV}" in 18case "${PV}" in
18 4.4.0_beta*) 19 4.?.?_rc*)
19 SRCTYPE="${SRCTYPE:-opensource-src}" 20 SRCTYPE="${SRCTYPE:-opensource-src}"
20 MY_PV="${PV/_beta/-beta}" 21 MY_PV="${PV/_rc/-rc}"
21 ;; 22 ;;
22 *) 23 *)
23 SRCTYPE="${SRCTYPE:-opensource-src}" 24 SRCTYPE="${SRCTYPE:-opensource-src}"
24 MY_PV="${PV}" 25 MY_PV="${PV}"
25 ;; 26 ;;
26esac 27esac
27S=${WORKDIR}/qt-x11-${SRCTYPE}-${MY_PV} 28MY_P=qt-x11-${SRCTYPE}-${MY_PV}
29S=${WORKDIR}/${MY_P}
28 30
29SRC_URI="ftp://ftp.trolltech.com/qt/source/qt-x11-${SRCTYPE}-${MY_PV}.tar.bz2" 31HOMEPAGE="http://www.qtsoftware.com/"
32SRC_URI="http://download.qtsoftware.com/qt/source/${MY_P}.tar.bz2"
33
34case "${PV}" in
35 4.4.?) SRC_URI="${SRC_URI} mirror://gentoo/${MY_P}-headers.tar.bz2" ;;
36 *) ;;
37esac
38
39if version_is_at_least 4.5 ${PV} ; then
40 LICENSE="|| ( LGPL-2.1 GPL-3 )"
41fi
30 42
31qt4-build_pkg_setup() { 43qt4-build_pkg_setup() {
44 # EAPI=2 ebuilds set use-deps, others need this:
45 if [[ $EAPI != 2 ]]; then
46 # Make sure debug setting corresponds with qt-core (bug 258512)
47 if [[ $PN != "qt-core" ]]; then
48 use debug && QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK}
49 ~x11-libs/qt-core-${PV} debug"
50 fi
51
32 # Check USE requirements 52 # Check USE requirements
33 qt4-build_check_use 53 qt4-build_check_use
54 fi
34 55
35 # Set up installation directories 56 # Set up installation directories
36 QTBASEDIR=/usr/$(get_libdir)/qt4 57 QTBASEDIR=/usr/$(get_libdir)/qt4
37 QTPREFIXDIR=/usr 58 QTPREFIXDIR=/usr
38 QTBINDIR=/usr/bin 59 QTBINDIR=/usr/bin
49 70
50 PLATFORM=$(qt_mkspecs_dir) 71 PLATFORM=$(qt_mkspecs_dir)
51 72
52 PATH="${S}/bin:${PATH}" 73 PATH="${S}/bin:${PATH}"
53 LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}" 74 LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}"
75
76 if ! version_is_at_least 4.1 $(gcc-version) ; then
77 ewarn "Using a GCC version lower than 4.1 is not supported!"
78 echo
79 ebeep 5
80 fi
81
82 if use custom-cxxflags; then
83 echo
84 ewarn "You have set USE=custom-cxxflags, which means Qt will be built with the"
85 ewarn "CXXFLAGS you have set in /etc/make.conf. This is not supported, and we"
86 ewarn "recommend to unset this useflag. But you are free to experiment with it."
87 ewarn "Just do not start crying if it breaks your system, or eats your kitten"
88 ewarn "for breakfast. ;-) "
89 echo
90 fi
91
54} 92}
55 93
56qt4-build_src_unpack() { 94qt4-build_src_unpack() {
57 # TODO: partial unpacks, cfr split KDE ebuilds. 95 local target targets licenses
58 unpack ${A} 96 if version_is_at_least 4.5 ${PV} ; then
97 licenses="LICENSE.GPL3 LICENSE.LGPL"
98 else
99 licenses="LICENSE.GPL2 LICENSE.GPL3"
100 fi
101 for target in configure ${licenses} projects.pro \
102 src/{qbase,qt_targets,qt_install}.pri bin config.tests mkspecs qmake \
103 ${QT4_EXTRACT_DIRECTORIES}; do
104 targets="${targets} ${MY_P}/${target}"
105 done
106
107 echo tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets}
108 tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets}
109
110 case "${PV}" in
111 4.4.?)
112 echo tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2
113 tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2
114 ;;
115 esac
116
117 # Be backwards compatible for now
118 if [[ $EAPI != 2 ]]; then
119 qt4-build_src_prepare
120 fi
121}
122
123qt4-build_src_prepare() {
59 cd "${S}" 124 cd "${S}"
60 125
61 if [[ ${PN} != qt-core ]]; then 126 if [[ ${PN} != qt-core ]]; then
62 skip_qmake_build_patch 127 skip_qmake_build_patch
63 skip_project_generation_patch 128 skip_project_generation_patch
64 symlink_binaries_to_buildtree 129 symlink_binaries_to_buildtree
65 fi 130 fi
66 131
132 if ! use custom-cxxflags;then
133 # Don't let the user go too overboard with flags.
134 strip-flags
135 replace-flags -O3 -O2
136 fi
137
138 # Unsupported old gcc versions - hardened needs this :(
139 if [[ $(gcc-major-version) -lt "4" ]] ; then
140 ewarn "Appending -fno-stack-protector to CXXFLAGS"
141 append-cxxflags -fno-stack-protector
142 fi
143
144 # Bug 178652
145 if [[ "$(gcc-major-version)" == "3" ]] && use amd64; then
146 ewarn "Appending -fno-gcse to CFLAGS/CXXFLAGS"
147 append-flags -fno-gcse
148 fi
149
150 # Bug 253127
151 if [[ $(gcc-major-version) -lt "4" ]] ; then
152 sed -e "/^QMAKE_CFLAGS\t/ s:$: -fno-stack-protector-all:" \
153 -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed"
154 fi
155
156 # Bug 172219
67 sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \ 157 sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
68 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \ 158 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
69 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \ 159 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
70 -e "s:X11R6/::" \ 160 -e "s:X11R6/::" \
71 -i "${S}"/mkspecs/$(qt_mkspecs_dir)/qmake.conf || die "sed ${S}/mkspecs/$(qt_mkspecs_dir)/qmake.conf failed" 161 -i "${S}"/mkspecs/$(qt_mkspecs_dir)/qmake.conf || die "sed ${S}/mkspecs/$(qt_mkspecs_dir)/qmake.conf failed"
72 162
73 sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \ 163 sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
74 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \ 164 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
75 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \ 165 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \
76 -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed" 166 -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed"
77}
78 167
168}
169
79qt4-build_src_compile() { 170qt4-build_src_configure() {
80 # Don't let the user go too overboard with flags. If you really want to, uncomment
81 # out the line below and give 'er a whirl.
82 strip-flags
83 replace-flags -O3 -O2
84
85 if [[ $(gcc-fullversion) == "3.4.6" && gcc-specs-ssp ]] ; then
86 ewarn "Appending -fno-stack-protector to CFLAGS/CXXFLAGS"
87 append-flags -fno-stack-protector
88 fi
89 171
90 myconf="$(standard_configure_options) ${myconf}" 172 myconf="$(standard_configure_options) ${myconf}"
91 173
92 echo ./configure ${myconf} 174 echo ./configure ${myconf}
93 ./configure ${myconf} || die "./configure failed" 175 ./configure ${myconf} || die "./configure failed"
176}
94 177
95 build_target_directories 178qt4-build_src_compile() {
179 # Be backwards compatible for now
180 if [[ $EAPI != 2 ]]; then
181 qt4-build_src_configure
182 fi
183
184 build_directories "${QT4_TARGET_DIRECTORIES}"
96} 185}
97 186
98qt4-build_src_install() { 187qt4-build_src_install() {
99 install_directories "${QT4_TARGET_DIRECTORIES}" 188 install_directories "${QT4_TARGET_DIRECTORIES}"
100 install_qconfigs 189 install_qconfigs
109 # Disable visibility explicitly if gcc version isn't 4 198 # Disable visibility explicitly if gcc version isn't 4
110 if [[ "$(gcc-major-version)" -lt "4" ]]; then 199 if [[ "$(gcc-major-version)" -lt "4" ]]; then
111 myconf="${myconf} -no-reduce-exports" 200 myconf="${myconf} -no-reduce-exports"
112 fi 201 fi
113 202
203 # precompiled headers doesn't work on hardened, where the flag is masked.
204 if use pch; then
205 myconf="${myconf} -pch"
206 else
207 myconf="${myconf} -no-pch"
208 fi
209
114 if use debug; then 210 if use debug; then
115 myconf="${myconf} -debug -no-separate-debug-info" 211 myconf="${myconf} -debug -no-separate-debug-info"
116 else 212 else
117 myconf="${myconf} -release -no-separate-debug-info" 213 myconf="${myconf} -release -no-separate-debug-info"
118 fi 214 fi
215
216 # ARCH is set on Gentoo. Qt now falls back to generic on an unsupported
217 # $(tc-arch). Therefore we convert it to supported values.
218 case "$(tc-arch)" in
219 amd64) myconf="${myconf} -arch x86_64" ;;
220 ppc|ppc64) myconf="${myconf} -arch powerpc" ;;
221 x86|x86-*) myconf="${myconf} -arch i386" ;;
222 alpha|arm|ia64|mips|s390|sparc) myconf="${myconf} -arch $(tc-arch)" ;;
223 hppa|sh) myconf="${myconf} -arch generic" ;;
224 *) die "$(tc-arch) is unsupported by this eclass. Please file a bug." ;;
225 esac
119 226
120 myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath 227 myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath
121 -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR} 228 -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR}
122 -datadir ${QTDATADIR} -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR} 229 -datadir ${QTDATADIR} -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR}
123 -plugindir ${QTPLUGINDIR} -sysconfdir ${QTSYSCONFDIR} 230 -plugindir ${QTPLUGINDIR} -sysconfdir ${QTSYSCONFDIR}
124 -translationdir ${QTTRANSDIR} -examplesdir ${QTEXAMPLESDIR} 231 -translationdir ${QTTRANSDIR} -examplesdir ${QTEXAMPLESDIR}
125 -demosdir ${QTDEMOSDIR} -silent -fast -reduce-relocations 232 -demosdir ${QTDEMOSDIR} -silent -fast
233 $([[ ${PN} == qt-xmlpatterns ]] || echo -no-exceptions)
126 -nomake examples -nomake demos" 234 -reduce-relocations -nomake examples -nomake demos"
127 235
128 echo "${myconf}" 236 echo "${myconf}"
129}
130
131build_target_directories() {
132 build_directories "${QT4_TARGET_DIRECTORIES}"
133} 237}
134 238
135build_directories() { 239build_directories() {
136 local dirs="$@" 240 local dirs="$@"
137 for x in ${dirs}; do 241 for x in ${dirs}; do
164# @DESCRIPTION: 268# @DESCRIPTION:
165# List variables that should be defined at the top of QtCore/qconfig.h 269# List variables that should be defined at the top of QtCore/qconfig.h
166QCONFIG_DEFINE="${QCONFIG_DEFINE:-}" 270QCONFIG_DEFINE="${QCONFIG_DEFINE:-}"
167 271
168install_qconfigs() { 272install_qconfigs() {
169 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} ]]; then
170 local x 273 local x
274 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
171 for x in QCONFIG_ADD QCONFIG_REMOVE; do 275 for x in QCONFIG_ADD QCONFIG_REMOVE; do
172 [[ -n ${!x} ]] && echo ${x}=${!x} >> "${T}"/${PN}-qconfig.pri 276 [[ -n ${!x} ]] && echo ${x}=${!x} >> "${T}"/${PN}-qconfig.pri
173 done 277 done
174 insinto ${QTDATADIR}/mkspecs/gentoo 278 insinto ${QTDATADIR}/mkspecs/gentoo
175 doins "${T}"/${PN}-qconfig.pri || die "installing ${PN}-qconfig.pri failed" 279 doins "${T}"/${PN}-qconfig.pri || die "installing ${PN}-qconfig.pri failed"
280 fi
176 281
282 if [[ -n ${QCONFIG_DEFINE} ]]; then
177 for x in ${QCONFIG_DEFINE}; do 283 for x in ${QCONFIG_DEFINE}; do
178 echo "#define ${x}" >> "${T}"/gentoo-${PN}-qconfig.h 284 echo "#define ${x}" >> "${T}"/gentoo-${PN}-qconfig.h
179 done 285 done
180 insinto ${QTHEADERDIR}/Gentoo 286 insinto ${QTHEADERDIR}/Gentoo
181 doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed" 287 doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed"
182 fi 288 fi
183} 289}
184
185# Stubs for functions used by the Qt 4.4.0_technical_preview_1.
186qconfig_add_option() { : ; }
187qconfig_remove_option() { : ; }
188 290
189generate_qconfigs() { 291generate_qconfigs() {
190 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${CATEGORY}/${PN} == x11-libs/qt-core ]]; then 292 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${CATEGORY}/${PN} == x11-libs/qt-core ]]; then
191 local x qconfig_add qconfig_remove qconfig_new 293 local x qconfig_add qconfig_remove qconfig_new
192 for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do 294 for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
246 generate_qconfigs 348 generate_qconfigs
247} 349}
248 350
249qt4-build_pkg_postinst() { 351qt4-build_pkg_postinst() {
250 generate_qconfigs 352 generate_qconfigs
353 echo
354 ewarn "After a rebuild or upgrade of Qt, it can happen that Qt plugins (such as Qt"
355 ewarn "and KDE styles and widgets) can no longer be loaded. In this situation you"
356 ewarn "should recompile the packages providing these plugins. Also, make sure you"
357 ewarn "compile the Qt packages, and the packages that depend on it, with the same"
358 ewarn "GCC version and the same USE flag settings (especially the debug flag)."
359 ewarn
360 ewarn "Packages that typically need to be recompiled are kdelibs from KDE4, any"
361 ewarn "additional KDE4/Qt4 styles, qscintilla and PyQt4. Before filing a bug report,"
362 ewarn "make sure all your Qt4 packages are up-to-date and built with the same"
363 ewarn "configuration."
364 ewarn
365 ewarn "For more information, see http://doc.trolltech.com/4.4/plugins-howto.html"
366 echo
251} 367}
252 368
253skip_qmake_build_patch() { 369skip_qmake_build_patch() {
254 # Don't need to build qmake, as it's already installed from qt-core 370 # Don't need to build qmake, as it's already installed from qt-core
255 sed -i -e "s:if true:if false:g" "${S}"/configure || die "Sed failed" 371 sed -i -e "s:if true:if false:g" "${S}"/configure || die "Sed failed"
404 fi 520 fi
405 521
406 echo "${spec}" 522 echo "${spec}"
407} 523}
408 524
525case ${EAPI:-0} in
409EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postrm pkg_postinst 526 0|1) EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postrm pkg_postinst ;;
527 2) EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_postrm pkg_postinst ;;
528esac

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.29

  ViewVC Help
Powered by ViewVC 1.1.20