| 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.13 2008/05/15 12:33:53 ingmar Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/qt4-build.eclass,v 1.28 2009/03/16 08:21:18 aballier 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="http://download.qtsoftware.com/qt/source/${MY_P}.tar.bz2" |
| 34 | |
33 | |
| 35 | case "${PV}" in |
34 | case "${PV}" in |
| 36 | 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 | |
|
|
39 | if version_is_at_least 4.5 ${PV} ; then |
|
|
40 | LICENSE="|| ( LGPL-2.1 GPL-3 )" |
|
|
41 | fi |
|
|
42 | |
| 43 | qt4-build_pkg_setup() { |
43 | qt4-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 | |
| 44 | # Check USE requirements |
52 | # Check USE requirements |
| 45 | qt4-build_check_use |
53 | qt4-build_check_use |
|
|
54 | fi |
| 46 | |
55 | |
| 47 | # Set up installation directories |
56 | # Set up installation directories |
| 48 | QTBASEDIR=/usr/$(get_libdir)/qt4 |
57 | QTBASEDIR=/usr/$(get_libdir)/qt4 |
| 49 | QTPREFIXDIR=/usr |
58 | QTPREFIXDIR=/usr |
| 50 | QTBINDIR=/usr/bin |
59 | QTBINDIR=/usr/bin |
| … | |
… | |
| 61 | |
70 | |
| 62 | PLATFORM=$(qt_mkspecs_dir) |
71 | PLATFORM=$(qt_mkspecs_dir) |
| 63 | |
72 | |
| 64 | PATH="${S}/bin:${PATH}" |
73 | PATH="${S}/bin:${PATH}" |
| 65 | LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}" |
74 | LD_LIBRARY_PATH="${S}/lib:${LD_LIBRARY_PATH}" |
| 66 | } |
|
|
| 67 | |
75 | |
| 68 | qt4_unpack() { |
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 | |
|
|
92 | } |
|
|
93 | |
|
|
94 | qt4-build_src_unpack() { |
| 69 | local target targets |
95 | local target targets licenses |
| 70 | for target in configure LICENSE.{GPL2,GPL3,QPL} projects.pro \ |
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 \ |
| 71 | src/{qbase,qt_targets,qt_install}.pri bin config.tests mkspecs qmake \ |
102 | src/{qbase,qt_targets,qt_install}.pri bin config.tests mkspecs qmake \ |
| 72 | ${QT4_EXTRACT_DIRECTORIES}; do |
103 | ${QT4_EXTRACT_DIRECTORIES}; do |
| 73 | targets="${targets} ${MY_P}/${target}" |
104 | targets="${targets} ${MY_P}/${target}" |
| 74 | done |
105 | done |
| 75 | |
106 | |
| 76 | echo tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets} |
107 | echo tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets} |
| 77 | tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets} |
108 | tar xjpf "${DISTDIR}"/${MY_P}.tar.bz2 ${targets} |
| 78 | |
109 | |
| 79 | case "${PV}" in |
110 | case "${PV}" in |
| 80 | 4.4.0|4.4.0_rc*) |
111 | 4.4.?) |
| 81 | echo tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2 |
112 | echo tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2 |
| 82 | tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2 |
113 | tar xjpf "${DISTDIR}"/${MY_P}-headers.tar.bz2 |
| 83 | ;; |
114 | ;; |
| 84 | esac |
115 | esac |
| 85 | } |
|
|
| 86 | |
116 | |
|
|
117 | # Be backwards compatible for now |
|
|
118 | if [[ $EAPI != 2 ]]; then |
|
|
119 | qt4-build_src_prepare |
|
|
120 | fi |
|
|
121 | } |
|
|
122 | |
| 87 | qt4-build_src_unpack() { |
123 | qt4-build_src_prepare() { |
| 88 | qt4_unpack |
124 | cd "${S}" |
|
|
125 | |
| 89 | if [[ ${PN} != qt-core ]]; then |
126 | if [[ ${PN} != qt-core ]]; then |
| 90 | cd "${S}" |
|
|
| 91 | skip_qmake_build_patch |
127 | skip_qmake_build_patch |
| 92 | skip_project_generation_patch |
128 | skip_project_generation_patch |
| 93 | symlink_binaries_to_buildtree |
129 | symlink_binaries_to_buildtree |
| 94 | fi |
130 | fi |
| 95 | |
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 253127 |
|
|
139 | # Unsupported old gcc versions - hardened needs this :( |
|
|
140 | if [[ $(gcc-major-version) -lt "4" ]] ; then |
|
|
141 | ewarn "Appending -fno-stack-protector to CXXFLAGS" |
|
|
142 | append-cxxflags -fno-stack-protector |
|
|
143 | fi |
|
|
144 | |
|
|
145 | # Bug 178652 |
|
|
146 | if [[ "$(gcc-major-version)" == "3" ]] && use amd64; then |
|
|
147 | ewarn "Appending -fno-gcse to CFLAGS/CXXFLAGS" |
|
|
148 | append-flags -fno-gcse |
|
|
149 | fi |
|
|
150 | |
|
|
151 | # Bug 172219 |
| 96 | sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \ |
152 | sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \ |
| 97 | -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \ |
153 | -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \ |
| 98 | -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \ |
154 | -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \ |
| 99 | -e "s:X11R6/::" \ |
155 | -e "s:X11R6/::" \ |
| 100 | -i "${S}"/mkspecs/$(qt_mkspecs_dir)/qmake.conf || die "sed ${S}/mkspecs/$(qt_mkspecs_dir)/qmake.conf failed" |
156 | -i "${S}"/mkspecs/$(qt_mkspecs_dir)/qmake.conf || die "sed ${S}/mkspecs/$(qt_mkspecs_dir)/qmake.conf failed" |
| 101 | |
157 | |
| 102 | sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \ |
158 | sed -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \ |
| 103 | -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \ |
159 | -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \ |
| 104 | -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \ |
160 | -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=${LDFLAGS}:" \ |
| 105 | -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed" |
161 | -i "${S}"/mkspecs/common/g++.conf || die "sed ${S}/mkspecs/common/g++.conf failed" |
| 106 | } |
|
|
| 107 | |
162 | |
|
|
163 | } |
|
|
164 | |
| 108 | qt4-build_src_compile() { |
165 | qt4-build_src_configure() { |
| 109 | # Don't let the user go too overboard with flags. If you really want to, uncomment |
|
|
| 110 | # out the line below and give 'er a whirl. |
|
|
| 111 | strip-flags |
|
|
| 112 | replace-flags -O3 -O2 |
|
|
| 113 | |
|
|
| 114 | if [[ $(gcc-fullversion) == "3.4.6" && gcc-specs-ssp ]] ; then |
|
|
| 115 | ewarn "Appending -fno-stack-protector to CFLAGS/CXXFLAGS" |
|
|
| 116 | append-flags -fno-stack-protector |
|
|
| 117 | fi |
|
|
| 118 | |
|
|
| 119 | # Bug 178652 |
|
|
| 120 | if [[ "$(gcc-major-version)" == "3" ]] && use amd64; then |
|
|
| 121 | ewarn "Appending -fno-gcse to CFLAGS/CXXFLAGS" |
|
|
| 122 | append-flags -fno-gcse |
|
|
| 123 | fi |
|
|
| 124 | |
166 | |
| 125 | myconf="$(standard_configure_options) ${myconf}" |
167 | myconf="$(standard_configure_options) ${myconf}" |
| 126 | |
168 | |
| 127 | echo ./configure ${myconf} |
169 | echo ./configure ${myconf} |
| 128 | ./configure ${myconf} || die "./configure failed" |
170 | ./configure ${myconf} || die "./configure failed" |
|
|
171 | } |
| 129 | |
172 | |
| 130 | build_target_directories |
173 | qt4-build_src_compile() { |
|
|
174 | # Be backwards compatible for now |
|
|
175 | if [[ $EAPI != 2 ]]; then |
|
|
176 | qt4-build_src_configure |
|
|
177 | fi |
|
|
178 | |
|
|
179 | build_directories "${QT4_TARGET_DIRECTORIES}" |
| 131 | } |
180 | } |
| 132 | |
181 | |
| 133 | qt4-build_src_install() { |
182 | qt4-build_src_install() { |
| 134 | install_directories "${QT4_TARGET_DIRECTORIES}" |
183 | install_directories "${QT4_TARGET_DIRECTORIES}" |
| 135 | install_qconfigs |
184 | install_qconfigs |
| … | |
… | |
| 157 | myconf="${myconf} -debug -no-separate-debug-info" |
206 | myconf="${myconf} -debug -no-separate-debug-info" |
| 158 | else |
207 | else |
| 159 | myconf="${myconf} -release -no-separate-debug-info" |
208 | myconf="${myconf} -release -no-separate-debug-info" |
| 160 | fi |
209 | fi |
| 161 | |
210 | |
| 162 | # ARCH is set on Gentoo. QT now falls back to generic on an unsupported |
211 | # ARCH is set on Gentoo. Qt now falls back to generic on an unsupported |
| 163 | # ${ARCH}. Therefore we convert it to supported values. |
212 | # $(tc-arch). Therefore we convert it to supported values. |
| 164 | case "${ARCH}" in |
213 | case "$(tc-arch)" in |
| 165 | amd64) myconf="${myconf} -arch x86_64" ;; |
214 | amd64) myconf="${myconf} -arch x86_64" ;; |
| 166 | ppc|ppc64) myconf="${myconf} -arch powerpc" ;; |
215 | ppc|ppc64) myconf="${myconf} -arch powerpc" ;; |
| 167 | x86) myconf="${myconf} -arch i386" ;; |
216 | x86|x86-*) myconf="${myconf} -arch i386" ;; |
| 168 | alpha|arm|ia64|mips|s390|sparc) myconf="${myconf} -arch ${ARCH}" ;; |
217 | alpha|arm|ia64|mips|s390|sparc) myconf="${myconf} -arch $(tc-arch)" ;; |
| 169 | hppa|sh) myconf="${myconf} -arch generic" ;; |
218 | hppa|sh) myconf="${myconf} -arch generic" ;; |
| 170 | *) die "${ARCH} is unsupported by this eclass. Please file a bug." ;; |
219 | *) die "$(tc-arch) is unsupported by this eclass. Please file a bug." ;; |
| 171 | esac |
220 | esac |
| 172 | |
221 | |
| 173 | myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath |
222 | myconf="${myconf} -stl -verbose -largefile -confirm-license -no-rpath |
| 174 | -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR} |
223 | -prefix ${QTPREFIXDIR} -bindir ${QTBINDIR} -libdir ${QTLIBDIR} |
| 175 | -datadir ${QTDATADIR} -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR} |
224 | -datadir ${QTDATADIR} -docdir ${QTDOCDIR} -headerdir ${QTHEADERDIR} |
| 176 | -plugindir ${QTPLUGINDIR} -sysconfdir ${QTSYSCONFDIR} |
225 | -plugindir ${QTPLUGINDIR} -sysconfdir ${QTSYSCONFDIR} |
| 177 | -translationdir ${QTTRANSDIR} -examplesdir ${QTEXAMPLESDIR} |
226 | -translationdir ${QTTRANSDIR} -examplesdir ${QTEXAMPLESDIR} |
| 178 | -demosdir ${QTDEMOSDIR} -silent -fast -reduce-relocations |
227 | -demosdir ${QTDEMOSDIR} -silent -fast |
|
|
228 | $([[ ${PN} == qt-xmlpatterns ]] || echo -no-exceptions) |
| 179 | -nomake examples -nomake demos" |
229 | -reduce-relocations -nomake examples -nomake demos" |
| 180 | |
230 | |
| 181 | echo "${myconf}" |
231 | echo "${myconf}" |
| 182 | } |
|
|
| 183 | |
|
|
| 184 | build_target_directories() { |
|
|
| 185 | build_directories "${QT4_TARGET_DIRECTORIES}" |
|
|
| 186 | } |
232 | } |
| 187 | |
233 | |
| 188 | build_directories() { |
234 | build_directories() { |
| 189 | local dirs="$@" |
235 | local dirs="$@" |
| 190 | for x in ${dirs}; do |
236 | for x in ${dirs}; do |
| … | |
… | |
| 234 | done |
280 | done |
| 235 | insinto ${QTHEADERDIR}/Gentoo |
281 | insinto ${QTHEADERDIR}/Gentoo |
| 236 | doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed" |
282 | doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed" |
| 237 | fi |
283 | fi |
| 238 | } |
284 | } |
| 239 | |
|
|
| 240 | # Stubs for functions used by the Qt 4.4.0_technical_preview_1. |
|
|
| 241 | qconfig_add_option() { : ; } |
|
|
| 242 | qconfig_remove_option() { : ; } |
|
|
| 243 | |
285 | |
| 244 | generate_qconfigs() { |
286 | generate_qconfigs() { |
| 245 | if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${CATEGORY}/${PN} == x11-libs/qt-core ]]; then |
287 | 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 |
288 | local x qconfig_add qconfig_remove qconfig_new |
| 247 | for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do |
289 | for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do |
| … | |
… | |
| 301 | generate_qconfigs |
343 | generate_qconfigs |
| 302 | } |
344 | } |
| 303 | |
345 | |
| 304 | qt4-build_pkg_postinst() { |
346 | qt4-build_pkg_postinst() { |
| 305 | generate_qconfigs |
347 | generate_qconfigs |
|
|
348 | echo |
|
|
349 | ewarn "After a rebuild or upgrade of Qt, it can happen that Qt plugins (such as Qt" |
|
|
350 | ewarn "and KDE styles and widgets) can no longer be loaded. In this situation you" |
|
|
351 | ewarn "should recompile the packages providing these plugins. Also, make sure you" |
|
|
352 | ewarn "compile the Qt packages, and the packages that depend on it, with the same" |
|
|
353 | ewarn "GCC version and the same USE flag settings (especially the debug flag)." |
|
|
354 | ewarn |
|
|
355 | ewarn "Packages that typically need to be recompiled are kdelibs from KDE4, any" |
|
|
356 | ewarn "additional KDE4/Qt4 styles, qscintilla and PyQt4. Before filing a bug report," |
|
|
357 | ewarn "make sure all your Qt4 packages are up-to-date and built with the same" |
|
|
358 | ewarn "configuration." |
|
|
359 | ewarn |
|
|
360 | ewarn "For more information, see http://doc.trolltech.com/4.4/plugins-howto.html" |
|
|
361 | echo |
| 306 | } |
362 | } |
| 307 | |
363 | |
| 308 | skip_qmake_build_patch() { |
364 | skip_qmake_build_patch() { |
| 309 | # Don't need to build qmake, as it's already installed from qt-core |
365 | # 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" |
366 | sed -i -e "s:if true:if false:g" "${S}"/configure || die "Sed failed" |
| … | |
… | |
| 459 | fi |
515 | fi |
| 460 | |
516 | |
| 461 | echo "${spec}" |
517 | echo "${spec}" |
| 462 | } |
518 | } |
| 463 | |
519 | |
|
|
520 | case ${EAPI:-0} in |
| 464 | EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postrm pkg_postinst |
521 | 0|1) EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_install pkg_postrm pkg_postinst ;; |
|
|
522 | 2) EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install pkg_postrm pkg_postinst ;; |
|
|
523 | esac |