| 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.15 2008/08/11 12:52:10 yngwin Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/qt4-build.eclass,v 1.20 2009/02/11 21:14:59 yngwin 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 | |
| 12 | inherit eutils multilib toolchain-funcs flag-o-matic |
14 | inherit eutils multilib toolchain-funcs flag-o-matic versionator |
| 13 | |
15 | |
| 14 | IUSE="${IUSE} debug pch" |
16 | IUSE="${IUSE} custom-cxxflags debug pch" |
| 15 | |
17 | |
| 16 | case "${PV}" in |
18 | case "${PV}" in |
| 17 | 4.4.0_beta*) |
|
|
| 18 | SRCTYPE="${SRCTYPE:-opensource-src}" |
|
|
| 19 | MY_PV="${PV/_beta/-beta}" |
|
|
| 20 | ;; |
|
|
| 21 | 4.4.0_rc*) |
19 | 4.?.?_rc*) |
| 22 | SRCTYPE="${SRCTYPE:-opensource-src}" |
20 | SRCTYPE="${SRCTYPE:-opensource-src}" |
| 23 | MY_PV="${PV/_rc/-rc}" |
21 | MY_PV="${PV/_rc/-rc}" |
| 24 | ;; |
22 | ;; |
| 25 | *) |
23 | *) |
| 26 | SRCTYPE="${SRCTYPE:-opensource-src}" |
24 | SRCTYPE="${SRCTYPE:-opensource-src}" |
| … | |
… | |
| 28 | ;; |
26 | ;; |
| 29 | esac |
27 | esac |
| 30 | MY_P=qt-x11-${SRCTYPE}-${MY_PV} |
28 | MY_P=qt-x11-${SRCTYPE}-${MY_PV} |
| 31 | S=${WORKDIR}/${MY_P} |
29 | S=${WORKDIR}/${MY_P} |
| 32 | |
30 | |
|
|
31 | HOMEPAGE="http://www.qtsoftware.com/" |
| 33 | SRC_URI="ftp://ftp.trolltech.com/qt/source/${MY_P}.tar.bz2" |
32 | SRC_URI="ftp://ftp.trolltech.com/qt/source/${MY_P}.tar.bz2" |
| 34 | |
33 | |
| 35 | case "${PV}" in |
34 | case "${PV}" in |
| 36 | 4.4.1|4.4.0|4.4.0_rc*) |
|
|
| 37 | SRC_URI="${SRC_URI} mirror://gentoo/${MY_P}-headers.tar.bz2" |
35 | 4.4.?) SRC_URI="${SRC_URI} mirror://gentoo/${MY_P}-headers.tar.bz2" ;; |
| 38 | ;; |
36 | *) ;; |
| 39 | *) |
|
|
| 40 | ;; |
|
|
| 41 | esac |
37 | esac |
| 42 | |
38 | |
| 43 | qt4-build_pkg_setup() { |
39 | qt4-build_pkg_setup() { |
|
|
40 | # EAPI=2 ebuilds set use-deps, others need this: |
|
|
41 | if [[ $EAPI != 2 ]]; then |
|
|
42 | # Make sure debug setting corresponds with qt-core (bug 258512) |
|
|
43 | if [[ $PN != "qt-core" ]]; then |
|
|
44 | use debug && QT4_BUILT_WITH_USE_CHECK="${QT4_BUILT_WITH_USE_CHECK} |
|
|
45 | ~x11-libs/qt-core-${PV} debug" |
|
|
46 | fi |
|
|
47 | |
| 44 | # Check USE requirements |
48 | # Check USE requirements |
| 45 | qt4-build_check_use |
49 | qt4-build_check_use |
|
|
50 | fi |
| 46 | |
51 | |
| 47 | # Set up installation directories |
52 | # Set up installation directories |
| 48 | QTBASEDIR=/usr/$(get_libdir)/qt4 |
53 | QTBASEDIR=/usr/$(get_libdir)/qt4 |
| 49 | QTPREFIXDIR=/usr |
54 | QTPREFIXDIR=/usr |
| 50 | QTBINDIR=/usr/bin |
55 | QTBINDIR=/usr/bin |
| … | |
… | |
| 61 | |
66 | |
| 62 | PLATFORM=$(qt_mkspecs_dir) |
67 | PLATFORM=$(qt_mkspecs_dir) |
| 63 | |
68 | |
| 64 | PATH="${S}/bin:${PATH}" |
69 | PATH="${S}/bin:${PATH}" |
| 65 | LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}" |
70 | LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}" |
| 66 | } |
|
|
| 67 | |
71 | |
| 68 | qt4_unpack() { |
72 | if ! version_is_at_least 4.1 $(gcc-version) ; then |
|
|
73 | ewarn "Using a GCC version lower than 4.1 is not supported!" |
|
|
74 | echo |
|
|
75 | ebeep 5 |
|
|
76 | fi |
|
|
77 | } |
|
|
78 | |
|
|
79 | qt4-build_src_unpack() { |
| 69 | local target targets |
80 | local target targets |
| 70 | for target in configure LICENSE.{GPL2,GPL3} projects.pro \ |
81 | for target in configure LICENSE.{GPL2,GPL3} projects.pro \ |
| 71 | src/{qbase,qt_targets,qt_install}.pri bin config.tests mkspecs qmake \ |
82 | src/{qbase,qt_targets,qt_install}.pri bin config.tests mkspecs qmake \ |
| 72 | ${QT4_EXTRACT_DIRECTORIES}; do |
83 | ${QT4_EXTRACT_DIRECTORIES}; do |
| 73 | targets="${targets} ${MY_P}/${target}" |
84 | targets="${targets} ${MY_P}/${target}" |
| … | |
… | |
| 75 | |
86 | |
| 76 | echo tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets} |
87 | echo tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets} |
| 77 | tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets} |
88 | tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets} |
| 78 | |
89 | |
| 79 | case "${PV}" in |
90 | case "${PV}" in |
| 80 | 4.4.1|4.4.0|4.4.0_rc*) |
91 | 4.4.?) |
| 81 | echo tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2 |
92 | echo tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2 |
| 82 | tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2 |
93 | tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2 |
| 83 | ;; |
94 | ;; |
| 84 | esac |
95 | esac |
| 85 | } |
|
|
| 86 | |
96 | |
|
|
97 | # Be backwards compatible for now |
|
|
98 | if [[ $EAPI != 2 ]]; then |
|
|
99 | qt4-build_src_prepare |
|
|
100 | fi |
|
|
101 | } |
|
|
102 | |
| 87 | qt4-build_src_unpack() { |
103 | qt4-build_src_prepare() { |
| 88 | qt4_unpack |
104 | cd "${S}" |
|
|
105 | |
| 89 | if [[ ${PN} != qt-core ]]; then |
106 | if [[ ${PN} != qt-core ]]; then |
| 90 | cd "${S}" |
|
|
| 91 | skip_qmake_build_patch |
107 | skip_qmake_build_patch |
| 92 | skip_project_generation_patch |
108 | skip_project_generation_patch |
| 93 | symlink_binaries_to_buildtree |
109 | symlink_binaries_to_buildtree |
|
|
110 | fi |
|
|
111 | |
|
|
112 | # Bug 253127 |
|
|
113 | if [[ $(gcc-major-version) -lt "4" ]] ; then |
|
|
114 | sed -e "/^QMAKE_CFLAGS\t/ s:$: -fno-stack-protector-all:" \ |
|
|
115 | -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed" |
| 94 | fi |
116 | fi |
| 95 | |
117 | |
| 96 | sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \ |
118 | sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \ |
| 97 | -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \ |
119 | -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \ |
| 98 | -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \ |
120 | -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \ |
| … | |
… | |
| 103 | -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \ |
125 | -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \ |
| 104 | -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \ |
126 | -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \ |
| 105 | -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed" |
127 | -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed" |
| 106 | } |
128 | } |
| 107 | |
129 | |
| 108 | qt4-build_src_compile() { |
130 | qt4-build_src_configure() { |
| 109 | # Don't let the user go too overboard with flags. If you really want to, uncomment |
131 | if use custom-cxxflags; then |
| 110 | # out the line below and give 'er a whirl. |
132 | echo |
|
|
133 | ewarn "You have set USE=custom-cxxflags, which means Qt will be built with the" |
|
|
134 | ewarn "CXXFLAGS you have set in /etc/make.conf. This is not supported, and we" |
|
|
135 | ewarn "recommend to unset this useflag. But you are free to experiment with it." |
|
|
136 | ewarn "Just do not start crying if it breaks your system, or eats your kitten" |
|
|
137 | ewarn "for breakfast. ;-) " |
|
|
138 | echo |
|
|
139 | else |
|
|
140 | # Don't let the user go too overboard with flags. |
| 111 | strip-flags |
141 | strip-flags |
| 112 | replace-flags -O3 -O2 |
142 | replace-flags -O3 -O2 |
|
|
143 | fi |
| 113 | |
144 | |
| 114 | if [[ $(gcc-fullversion) == "3.4.6" && gcc-specs-ssp ]] ; then |
145 | # Unsupported old gcc versions - hardened needs this :( |
|
|
146 | if [[ $(gcc-major-version) -lt "4" ]] ; then |
| 115 | ewarn "Appending -fno-stack-protector to CFLAGS/CXXFLAGS" |
147 | ewarn "Appending -fno-stack-protector to CXXFLAGS" |
| 116 | append-flags -fno-stack-protector |
148 | append-cxxflags -fno-stack-protector |
| 117 | fi |
149 | fi |
| 118 | |
150 | |
| 119 | # Bug 178652 |
151 | # Bug 178652 |
| 120 | if [[ "$(gcc-major-version)" == "3" ]] && use amd64; then |
152 | if [[ "$(gcc-major-version)" == "3" ]] && use amd64; then |
| 121 | ewarn "Appending -fno-gcse to CFLAGS/CXXFLAGS" |
153 | ewarn "Appending -fno-gcse to CFLAGS/CXXFLAGS" |
| … | |
… | |
| 124 | |
156 | |
| 125 | myconf="$(standard_configure_options) ${myconf}" |
157 | myconf="$(standard_configure_options) ${myconf}" |
| 126 | |
158 | |
| 127 | echo ./configure ${myconf} |
159 | echo ./configure ${myconf} |
| 128 | ./configure ${myconf} || die "./configure failed" |
160 | ./configure ${myconf} || die "./configure failed" |
|
|
161 | } |
| 129 | |
162 | |
| 130 | build_target_directories |
163 | qt4-build_src_compile() { |
|
|
164 | # Be backwards compatible for now |
|
|
165 | if [[ $EAPI != 2 ]]; then |
|
|
166 | qt4-build_src_configure |
|
|
167 | fi |
|
|
168 | |
|
|
169 | build_directories "${QT4_TARGET_DIRECTORIES}" |
| 131 | } |
170 | } |
| 132 | |
171 | |
| 133 | qt4-build_src_install() { |
172 | qt4-build_src_install() { |
| 134 | install_directories "${QT4_TARGET_DIRECTORIES}" |
173 | install_directories "${QT4_TARGET_DIRECTORIES}" |
| 135 | install_qconfigs |
174 | install_qconfigs |
| … | |
… | |
| 157 | myconf="${myconf} -debug -no-separate-debug-info" |
196 | myconf="${myconf} -debug -no-separate-debug-info" |
| 158 | else |
197 | else |
| 159 | myconf="${myconf} -release -no-separate-debug-info" |
198 | myconf="${myconf} -release -no-separate-debug-info" |
| 160 | fi |
199 | fi |
| 161 | |
200 | |
| 162 | # ARCH is set on Gentoo. QT now falls back to generic on an unsupported |
201 | # ARCH is set on Gentoo. Qt now falls back to generic on an unsupported |
| 163 | # ${ARCH}. Therefore we convert it to supported values. |
202 | # ${ARCH}. Therefore we convert it to supported values. |
| 164 | case "${ARCH}" in |
203 | case "${ARCH}" in |
| 165 | amd64) myconf="${myconf} -arch x86_64" ;; |
204 | amd64) myconf="${myconf} -arch x86_64" ;; |
| 166 | ppc|ppc64) myconf="${myconf} -arch powerpc" ;; |
205 | ppc|ppc64) myconf="${myconf} -arch powerpc" ;; |
| 167 | x86|x86-*) myconf="${myconf} -arch i386" ;; |
206 | x86|x86-*) myconf="${myconf} -arch i386" ;; |
| … | |
… | |
| 173 | myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath |
212 | myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath |
| 174 | -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR} |
213 | -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR} |
| 175 | -datadir ${QTDATADIR} -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR} |
214 | -datadir ${QTDATADIR} -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR} |
| 176 | -plugindir ${QTPLUGINDIR} -sysconfdir ${QTSYSCONFDIR} |
215 | -plugindir ${QTPLUGINDIR} -sysconfdir ${QTSYSCONFDIR} |
| 177 | -translationdir ${QTTRANSDIR} -examplesdir ${QTEXAMPLESDIR} |
216 | -translationdir ${QTTRANSDIR} -examplesdir ${QTEXAMPLESDIR} |
| 178 | -demosdir ${QTDEMOSDIR} -silent -fast -reduce-relocations |
217 | -demosdir ${QTDEMOSDIR} -silent -fast |
|
|
218 | $([[ ${PN} == qt-xmlpatterns ]] || echo -no-exceptions) |
|
|
219 | $(use x86-fbsd || echo -reduce-relocations) |
| 179 | -nomake examples -nomake demos" |
220 | -nomake examples -nomake demos" |
| 180 | |
221 | |
| 181 | echo "${myconf}" |
222 | echo "${myconf}" |
| 182 | } |
|
|
| 183 | |
|
|
| 184 | build_target_directories() { |
|
|
| 185 | build_directories "${QT4_TARGET_DIRECTORIES}" |
|
|
| 186 | } |
223 | } |
| 187 | |
224 | |
| 188 | build_directories() { |
225 | build_directories() { |
| 189 | local dirs="$@" |
226 | local dirs="$@" |
| 190 | for x in ${dirs}; do |
227 | for x in ${dirs}; do |
| … | |
… | |
| 234 | done |
271 | done |
| 235 | insinto ${QTHEADERDIR}/Gentoo |
272 | insinto ${QTHEADERDIR}/Gentoo |
| 236 | doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed" |
273 | doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed" |
| 237 | fi |
274 | fi |
| 238 | } |
275 | } |
| 239 | |
|
|
| 240 | # Stubs for functions used by the Qt 4.4.0_technical_preview_1. |
|
|
| 241 | qconfig_add_option() { : ; } |
|
|
| 242 | qconfig_remove_option() { : ; } |
|
|
| 243 | |
276 | |
| 244 | generate_qconfigs() { |
277 | generate_qconfigs() { |
| 245 | if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${CATEGORY}/${PN} == x11-libs/qt-core ]]; then |
278 | if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${CATEGORY}/${PN} == x11-libs/qt-core ]]; then |
| 246 | local x qconfig_add qconfig_remove qconfig_new |
279 | local x qconfig_add qconfig_remove qconfig_new |
| 247 | for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do |
280 | for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do |
| … | |
… | |
| 301 | generate_qconfigs |
334 | generate_qconfigs |
| 302 | } |
335 | } |
| 303 | |
336 | |
| 304 | qt4-build_pkg_postinst() { |
337 | qt4-build_pkg_postinst() { |
| 305 | generate_qconfigs |
338 | generate_qconfigs |
|
|
339 | echo |
|
|
340 | ewarn "After a rebuild or upgrade of Qt, it can happen that Qt plugins (such as Qt" |
|
|
341 | ewarn "and KDE styles and widgets) can no longer be loaded. In this situation you" |
|
|
342 | ewarn "should recompile the packages providing these plugins. Also, make sure you" |
|
|
343 | ewarn "compile the Qt packages, and the packages that depend on it, with the same" |
|
|
344 | ewarn "GCC version and the same USE flag settings (especially the debug flag)." |
|
|
345 | ewarn |
|
|
346 | ewarn "Packages that typically need to be recompiled are kdelibs from KDE4, any" |
|
|
347 | ewarn "additional KDE4/Qt4 styles, qscintilla and PyQt4. Before filing a bug report," |
|
|
348 | ewarn "make sure all your Qt4 packages are up-to-date and built with the same" |
|
|
349 | ewarn "configuration." |
|
|
350 | ewarn |
|
|
351 | ewarn "For more information, see http://doc.trolltech.com/4.4/plugins-howto.html" |
|
|
352 | echo |
| 306 | } |
353 | } |
| 307 | |
354 | |
| 308 | skip_qmake_build_patch() { |
355 | skip_qmake_build_patch() { |
| 309 | # Don't need to build qmake, as it's already installed from qt-core |
356 | # Don't need to build qmake, as it's already installed from qt-core |
| 310 | sed -i -e "s:if true:if false:g" "${S}"/configure || die "Sed failed" |
357 | sed -i -e "s:if true:if false:g" "${S}"/configure || die "Sed failed" |
| … | |
… | |
| 459 | fi |
506 | fi |
| 460 | |
507 | |
| 461 | echo "${spec}" |
508 | echo "${spec}" |
| 462 | } |
509 | } |
| 463 | |
510 | |
|
|
511 | case ${EAPI:-0} in |
| 464 | EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postrm pkg_postinst |
512 | 0|1) EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postrm pkg_postinst ;; |
|
|
513 | 2) EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_postrm pkg_postinst ;; |
|
|
514 | esac |