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

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.30

  ViewVC Help
Powered by ViewVC 1.1.20