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

Contents of /eclass/qt4-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.124 - (hide annotations) (download)
Wed Apr 4 16:37:50 2012 UTC (2 years, 4 months ago) by pesa
Branch: MAIN
Changes since 1.123: +73 -27 lines
Update from qt overlay, fixes #407523.

1 pesa 1.115 # Copyright 1999-2012 Gentoo Foundation
2 caleb 1.1 # Distributed under the terms of the GNU General Public License v2
3 pesa 1.124 # $Header: /var/cvsroot/gentoo-x86/eclass/qt4-build.eclass,v 1.123 2012/03/08 14:24:40 pesa Exp $
4 caleb 1.1
5     # @ECLASS: qt4-build.eclass
6     # @MAINTAINER:
7 pesa 1.98 # Qt herd <qt@gentoo.org>
8 ingmar 1.8 # @BLURB: Eclass for Qt4 split ebuilds.
9 caleb 1.1 # @DESCRIPTION:
10 pesa 1.98 # This eclass contains various functions that are used when building Qt4.
11 caleb 1.1
12 pesa 1.123 case ${EAPI} in
13     2|3|4) : ;;
14     *) die "qt4-build.eclass requires EAPI 2, 3 or 4." ;;
15     esac
16    
17 pesa 1.124 inherit base eutils flag-o-matic multilib toolchain-funcs versionator
18    
19     if [[ ${PV} == *9999* ]]; then
20     QT4_BUILD_TYPE="live"
21     inherit git-2
22     else
23     QT4_BUILD_TYPE="release"
24     fi
25    
26     HOMEPAGE="http://qt-project.org/ http://qt.nokia.com/"
27     LICENSE="|| ( LGPL-2.1 GPL-3 )"
28 caleb 1.1
29 abcd 1.59 MY_PV=${PV/_/-}
30 pesa 1.100 MY_P=qt-everywhere-opensource-src-${MY_PV}
31    
32 pesa 1.124 case ${QT4_BUILD_TYPE} in
33     live)
34     EGIT_REPO_URI="git://gitorious.org/qt/qt.git
35     https://git.gitorious.org/qt/qt.git"
36     EGIT_BRANCH="${PV%.9999}"
37     ;;
38     release)
39     SRC_URI="http://get.qt.nokia.com/qt/source/${MY_P}.tar.gz"
40     ;;
41     esac
42 pesa 1.100
43     IUSE="aqua debug pch"
44 pesa 1.124 if [[ ${CATEGORY}/${PN} != x11-libs/qt-xmlpatterns ]]; then
45 pesa 1.100 IUSE+=" +exceptions"
46 pesa 1.124 fi
47     if version_is_at_least 4.8; then
48 hwoarang 1.96 IUSE+=" c++0x qpa"
49     fi
50    
51 pesa 1.101 DEPEND="dev-util/pkgconfig"
52 pesa 1.124 if [[ ${QT4_BUILD_TYPE} == live ]]; then
53     DEPEND+=" dev-lang/perl"
54     fi
55    
56 hwoarang 1.36 RDEPEND="
57     !<x11-libs/qt-assistant-${PV}
58     !>x11-libs/qt-assistant-${PV}-r9999
59     !<x11-libs/qt-core-${PV}
60     !>x11-libs/qt-core-${PV}-r9999
61     !<x11-libs/qt-dbus-${PV}
62     !>x11-libs/qt-dbus-${PV}-r9999
63 pesa 1.100 !<x11-libs/qt-declarative-${PV}
64     !>x11-libs/qt-declarative-${PV}-r9999
65 hwoarang 1.36 !<x11-libs/qt-demo-${PV}
66     !>x11-libs/qt-demo-${PV}-r9999
67     !<x11-libs/qt-gui-${PV}
68     !>x11-libs/qt-gui-${PV}-r9999
69 wired 1.65 !<x11-libs/qt-multimedia-${PV}
70     !>x11-libs/qt-multimedia-${PV}-r9999
71 hwoarang 1.36 !<x11-libs/qt-opengl-${PV}
72     !>x11-libs/qt-opengl-${PV}-r9999
73 pesa 1.119 !<x11-libs/qt-openvg-${PV}
74     !>x11-libs/qt-openvg-${PV}-r9999
75 hwoarang 1.36 !<x11-libs/qt-phonon-${PV}
76     !>x11-libs/qt-phonon-${PV}-r9999
77     !<x11-libs/qt-qt3support-${PV}
78     !>x11-libs/qt-qt3support-${PV}-r9999
79     !<x11-libs/qt-script-${PV}
80     !>x11-libs/qt-script-${PV}-r9999
81     !<x11-libs/qt-sql-${PV}
82     !>x11-libs/qt-sql-${PV}-r9999
83     !<x11-libs/qt-svg-${PV}
84     !>x11-libs/qt-svg-${PV}-r9999
85     !<x11-libs/qt-test-${PV}
86     !>x11-libs/qt-test-${PV}-r9999
87     !<x11-libs/qt-webkit-${PV}
88     !>x11-libs/qt-webkit-${PV}-r9999
89     !<x11-libs/qt-xmlpatterns-${PV}
90     !>x11-libs/qt-xmlpatterns-${PV}-r9999
91     "
92 abcd 1.55
93 abcd 1.59 S=${WORKDIR}/${MY_P}
94 yngwin 1.25
95 hwoarang 1.34 # @FUNCTION: qt4-build_pkg_setup
96     # @DESCRIPTION:
97 pesa 1.109 # Sets up PATH and LD_LIBRARY_PATH.
98 caleb 1.1 qt4-build_pkg_setup() {
99 abcd 1.57 [[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
100    
101 yngwin 1.66 # Protect users by not allowing downgrades between releases
102     # Downgrading revisions within the same release should be allowed
103 pesa 1.100 if has_version '>'${CATEGORY}/${P}-r9999; then
104     if [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then
105 pesa 1.124 eerror
106 yngwin 1.66 eerror "Sanity check to keep you from breaking your system:"
107     eerror " Downgrading Qt is completely unsupported and will break your system!"
108 pesa 1.124 eerror
109 yngwin 1.66 die "aborting to save your system"
110     else
111     ewarn "Downgrading Qt is completely unsupported and will break your system!"
112     fi
113     fi
114 abcd 1.57
115 pesa 1.123 if [[ ${PN} == qt-webkit ]]; then
116 spatz 1.71 eshopts_push -s extglob
117 hwoarang 1.80 if is-flagq '-g?(gdb)?([1-9])'; then
118 spatz 1.71 echo
119 pesa 1.123 ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
120 spatz 1.71 ewarn "You may experience really long compilation times and/or increased memory usage."
121 pesa 1.123 ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
122 spatz 1.71 ewarn "For more info check out bug #307861"
123     echo
124     fi
125     eshopts_pop
126     fi
127    
128 abcd 1.55 PATH="${S}/bin${PATH:+:}${PATH}"
129 abcd 1.57 if [[ ${CHOST} != *-darwin* ]]; then
130     LD_LIBRARY_PATH="${S}/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"
131     else
132     DYLD_LIBRARY_PATH="${S}/lib${DYLD_LIBRARY_PATH:+:}${DYLD_LIBRARY_PATH}"
133 yngwin 1.63 # On MacOS we *need* at least src/gui/kernel/qapplication_mac.mm for
134     # platform detection. Note: needs to come before any directories to
135     # avoid extract failure.
136     [[ ${CHOST} == *-apple-darwin* ]] && \
137 yngwin 1.66 QT4_EXTRACT_DIRECTORIES="src/gui/kernel/qapplication_mac.mm
138     ${QT4_EXTRACT_DIRECTORIES}"
139 abcd 1.57 fi
140 yngwin 1.20
141 abcd 1.55 if ! version_is_at_least 4.1 $(gcc-version); then
142 pesa 1.123 ewarn "Using a GCC version lower than 4.1 is not supported."
143 yngwin 1.20 fi
144 caleb 1.1 }
145    
146 hwoarang 1.34 # @ECLASS-VARIABLE: QT4_TARGET_DIRECTORIES
147     # @DESCRIPTION:
148 pesa 1.109 # Arguments for build_target_directories. Takes the directories in which the
149     # code should be compiled. This is a space-separated list.
150 hwoarang 1.34
151     # @ECLASS-VARIABLE: QT4_EXTRACT_DIRECTORIES
152     # @DESCRIPTION:
153 pesa 1.109 # Space-separated list including the directories that will be extracted from
154     # Qt tarball.
155 hwoarang 1.34
156     # @FUNCTION: qt4-build_src_unpack
157     # @DESCRIPTION:
158 pesa 1.109 # Unpacks the sources.
159 yngwin 1.20 qt4-build_src_unpack() {
160 hwoarang 1.42 setqtenv
161 pesa 1.112
162 pesa 1.124 case ${QT4_BUILD_TYPE} in
163     live)
164     git-2_src_unpack
165     ;;
166     release)
167     local tarball="${MY_P}.tar.gz" target= targets=
168     for target in configure LICENSE.GPL3 LICENSE.LGPL projects.pro \
169     src/{qbase,qt_targets,qt_install}.pri bin config.tests \
170     mkspecs qmake ${QT4_EXTRACT_DIRECTORIES}
171     do
172     targets+="${MY_P}/${target} "
173     done
174 ingmar 1.11
175 pesa 1.124 ebegin "Unpacking parts of ${tarball}:" ${targets//${MY_P}\/}
176     tar -xzf "${DISTDIR}/${tarball}" ${targets}
177     eend $? || die "failed to unpack"
178     ;;
179     esac
180 ingmar 1.11 }
181    
182 hwoarang 1.37 # @ECLASS-VARIABLE: PATCHES
183 pesa 1.110 # @DEFAULT_UNSET
184 hwoarang 1.37 # @DESCRIPTION:
185 pesa 1.110 # PATCHES array variable containing all various patches to be applied.
186     # This variable is expected to be defined in global scope of ebuild.
187     # Make sure to specify the full path. This variable is utilised in
188     # src_unpack/src_prepare phase, based on EAPI.
189 hwoarang 1.37 #
190 pesa 1.110 # @CODE
191     # PATCHES=( "${FILESDIR}/mypatch.patch"
192     # "${FILESDIR}/patches_folder/" )
193     # @CODE
194 hwoarang 1.34
195     # @FUNCTION: qt4-build_src_prepare
196     # @DESCRIPTION:
197     # Prepare the sources before the configure phase. Strip CFLAGS if necessary, and fix
198 pesa 1.109 # the build system in order to respect CFLAGS/CXXFLAGS/LDFLAGS specified in /etc/make.conf.
199 yngwin 1.20 qt4-build_src_prepare() {
200 hwoarang 1.42 setqtenv
201 pesa 1.124
202     if [[ ${QT4_BUILD_TYPE} == live ]]; then
203     QTDIR="." ./bin/syncqt || die "syncqt failed"
204     fi
205 vapier 1.94
206 pesa 1.123 if version_is_at_least 4.7; then
207 pesa 1.99 # fix libX11 dependency on non X packages
208 pesa 1.98 local nolibx11_pkgs="qt-core qt-dbus qt-script qt-sql qt-test qt-xmlpatterns"
209     has ${PN} ${nolibx11_pkgs} && qt_nolibx11
210 pesa 1.99
211     qt_assistant_cleanup
212 hwoarang 1.77 fi
213 wired 1.69
214 abcd 1.57 if use aqua; then
215     # provide a proper macx-g++-64
216     use x64-macos && ln -s macx-g++ mkspecs/$(qt_mkspecs_dir)
217    
218     sed -e '/^CONFIG/s:app_bundle::' \
219     -e '/^CONFIG/s:plugin_no_soname:plugin_with_soname absolute_library_soname:' \
220 pesa 1.109 -i mkspecs/$(qt_mkspecs_dir)/qmake.conf || die
221 abcd 1.57 fi
222    
223 ingmar 1.7 if [[ ${PN} != qt-core ]]; then
224 pesa 1.100 skip_qmake_build
225     skip_project_generation
226 ingmar 1.7 symlink_binaries_to_buildtree
227     fi
228 hwoarang 1.24
229 pesa 1.120 if [[ ${CHOST} == *86*-apple-darwin* ]]; then
230 pesa 1.124 # qmake bus errors with -O2 or -O3 but -O1 works
231     # Bug 373061
232     replace-flags -O[23] -O1
233 abcd 1.57 fi
234 jer 1.97
235 hwoarang 1.21 # Bug 178652
236 abcd 1.55 if [[ $(gcc-major-version) == 3 ]] && use amd64; then
237 hwoarang 1.21 ewarn "Appending -fno-gcse to CFLAGS/CXXFLAGS"
238     append-flags -fno-gcse
239 gengor 1.18 fi
240    
241 pesa 1.100 if use_if_iuse c++0x; then
242 pesa 1.123 echo
243 hwoarang 1.96 ewarn "You are about to build Qt4 using the C++11 standard. Even though"
244     ewarn "this is an official standard, some of the reverse dependencies"
245     ewarn "may fail to compile or link againt the Qt4 libraries. Before"
246     ewarn "reporting a bug, make sure your bug is reproducible with c++0x"
247     ewarn "disabled."
248 pesa 1.123 echo
249 hwoarang 1.96 append-flags -std=c++0x
250     fi
251 pesa 1.98
252 gengor 1.30 # Unsupported old gcc versions - hardened needs this :(
253 pesa 1.120 if [[ $(gcc-major-version) -lt 4 ]]; then
254 gengor 1.30 ewarn "Appending -fno-stack-protector to CXXFLAGS"
255     append-cxxflags -fno-stack-protector
256     # Bug 253127
257 gengor 1.29 sed -e "/^QMAKE_CFLAGS\t/ s:$: -fno-stack-protector-all:" \
258 pesa 1.109 -i mkspecs/common/g++.conf || die
259 gengor 1.29 fi
260    
261 ayoy 1.49 # Bug 261632
262     if use ppc64; then
263     ewarn "Appending -mminimal-toc to CFLAGS/CXXFLAGS"
264     append-flags -mminimal-toc
265     fi
266    
267 pesa 1.109 # Respect CC, CXX, {C,CXX,LD}FLAGS in .qmake.cache
268     sed -e "/^SYSTEM_VARIABLES=/i \
269     CC='$(tc-getCC)'\n\
270     CXX='$(tc-getCXX)'\n\
271     CFLAGS='${CFLAGS}'\n\
272     CXXFLAGS='${CXXFLAGS}'\n\
273     LDFLAGS='${LDFLAGS}'\n" \
274 pesa 1.114 -i configure \
275     || die "sed SYSTEM_VARIABLES failed"
276 pesa 1.98
277 pesa 1.113 # Respect CC, CXX, LINK and *FLAGS in config.tests
278     find config.tests/unix -name '*.test' -type f -print0 | xargs -0 \
279     sed -i -e "/bin\/qmake/ s: \"QT_BUILD_TREE=: \
280     'QMAKE_CC=$(tc-getCC)' 'QMAKE_CXX=$(tc-getCXX)' 'QMAKE_LINK=$(tc-getCXX)' \
281     'QMAKE_CFLAGS+=${CFLAGS}' 'QMAKE_CXXFLAGS+=${CXXFLAGS}' 'QMAKE_LFLAGS+=${LDFLAGS}'&:" \
282     || die "sed config.tests failed"
283 wired 1.67
284 pesa 1.114 # Strip predefined CFLAGS from mkspecs (bug 312689)
285     sed -i -e '/^QMAKE_CFLAGS_RELEASE/s:+=.*:+=:' mkspecs/common/g++.conf || die
286    
287 hwoarang 1.24 # Bug 172219
288 pesa 1.113 sed -e 's:/X11R6/:/:' -i mkspecs/$(qt_mkspecs_dir)/qmake.conf || die
289 ingmar 1.7
290 wired 1.67 if [[ ${CHOST} == *-darwin* ]]; then
291 abcd 1.57 # Set FLAGS *and* remove -arch, since our gcc-apple is multilib
292     # crippled (by design) :/
293 pesa 1.124 local mac_gpp_conf=
294     if [[ -f mkspecs/common/mac-g++.conf ]]; then
295     # qt < 4.8 has mac-g++.conf
296     mac_gpp_conf="mkspecs/common/mac-g++.conf"
297     elif [[ -f mkspecs/common/g++-macx.conf ]]; then
298     # qt >= 4.8 has g++-macx.conf
299     mac_gpp_conf="mkspecs/common/g++-macx.conf"
300     else
301     die "no known conf file for mac found"
302     fi
303 pesa 1.114 sed \
304     -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
305 abcd 1.57 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
306     -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=-headerpad_max_install_names ${LDFLAGS}:" \
307     -e "s:-arch\s\w*::g" \
308 pesa 1.124 -i ${mac_gpp_conf} \
309     || die "sed ${mac_gpp_conf} failed"
310 abcd 1.57
311     # Fix configure's -arch settings that appear in qmake/Makefile and also
312     # fix arch handling (automagically duplicates our -arch arg and breaks
313     # pch). Additionally disable Xarch support.
314 pesa 1.124 local mac_gcc_confs="${mac_gpp_conf}"
315     if [[ -f mkspecs/common/gcc-base-macx.conf ]]; then
316     mac_gcc_confs+=" mkspecs/common/gcc-base-macx.conf"
317     fi
318 abcd 1.57 sed \
319     -e "s:-arch i386::" \
320     -e "s:-arch ppc::" \
321     -e "s:-arch x86_64::" \
322     -e "s:-arch ppc64::" \
323     -e "s:-arch \$i::" \
324     -e "/if \[ ! -z \"\$NATIVE_64_ARCH\" \]; then/,/fi/ d" \
325     -e "s:CFG_MAC_XARCH=yes:CFG_MAC_XARCH=no:g" \
326     -e "s:-Xarch_x86_64::g" \
327     -e "s:-Xarch_ppc64::g" \
328 pesa 1.124 -i configure ${mac_gcc_confs} \
329 pesa 1.114 || die "sed -arch/-Xarch failed"
330 abcd 1.57
331     # On Snow Leopard don't fall back to 10.5 deployment target.
332 pesa 1.120 if [[ ${CHOST} == *-apple-darwin10 ]]; then
333 abcd 1.57 sed -e "s:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET.*:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.6:g" \
334     -e "s:-mmacosx-version-min=10.[0-9]:-mmacosx-version-min=10.6:g" \
335 pesa 1.124 -i configure ${mac_gpp_conf} \
336 pesa 1.114 || die "sed deployment target failed"
337 abcd 1.57 fi
338     fi
339    
340     # this one is needed for all systems with a separate -liconv, apart from
341     # Darwin, for which the sources already cater for -liconv
342 pesa 1.120 if use !elibc_glibc && [[ ${CHOST} != *-darwin* ]]; then
343 pesa 1.114 sed -e 's|mac:\(LIBS += -liconv\)|\1|g' \
344 abcd 1.57 -i config.tests/unix/iconv/iconv.pro \
345 pesa 1.114 || die "sed iconv.pro failed"
346 abcd 1.57 fi
347    
348     # we need some patches for Solaris
349 pesa 1.114 sed -i -e '/^QMAKE_LFLAGS_THREAD/a\QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list,' \
350 abcd 1.57 mkspecs/$(qt_mkspecs_dir)/qmake.conf || die
351     # use GCC over SunStudio
352     sed -i -e '/PLATFORM=solaris-cc/s/cc/g++/' configure || die
353 pesa 1.114 # do not flirt with non-Prefix stuff, we're quite possessive
354 abcd 1.57 sed -i -e '/^QMAKE_\(LIB\|INC\)DIR\(_X11\|_OPENGL\|\)\t/s/=.*$/=/' \
355     mkspecs/$(qt_mkspecs_dir)/qmake.conf || die
356 pesa 1.113
357 hwoarang 1.37 base_src_prepare
358 ingmar 1.7 }
359    
360 hwoarang 1.34 # @FUNCTION: qt4-build_src_configure
361     # @DESCRIPTION:
362     # Default configure phase
363 yngwin 1.20 qt4-build_src_configure() {
364 hwoarang 1.42 setqtenv
365 pesa 1.121
366     local conf="
367     -prefix ${QTPREFIXDIR}
368     -bindir ${QTBINDIR}
369     -libdir ${QTLIBDIR}
370     -docdir ${QTDOCDIR}
371     -headerdir ${QTHEADERDIR}
372     -plugindir ${QTPLUGINDIR}
373     $(version_is_at_least 4.7 && echo -importdir ${QTIMPORTDIR})
374     -datadir ${QTDATADIR}
375     -translationdir ${QTTRANSDIR}
376     -sysconfdir ${QTSYSCONFDIR}
377     -examplesdir ${QTEXAMPLESDIR}
378     -demosdir ${QTDEMOSDIR}
379     -opensource -confirm-license
380     -shared -fast -largefile -stl -verbose
381     -nomake examples -nomake demos"
382    
383     # ARCH is set on Gentoo. Qt now falls back to generic on an unsupported
384     # $(tc-arch). Therefore we convert it to supported values.
385     case "$(tc-arch)" in
386     amd64|x64-*) conf+=" -arch x86_64" ;;
387     ppc-macos) conf+=" -arch ppc" ;;
388     ppc|ppc64|ppc-*) conf+=" -arch powerpc" ;;
389     sparc|sparc-*|sparc64-*) conf+=" -arch sparc" ;;
390     x86-macos) conf+=" -arch x86" ;;
391     x86|x86-*) conf+=" -arch i386" ;;
392     alpha|arm|ia64|mips|s390) conf+=" -arch $(tc-arch)" ;;
393     hppa|sh) conf+=" -arch generic" ;;
394     *) die "$(tc-arch) is unsupported by this eclass. Please file a bug." ;;
395     esac
396    
397     conf+=" -platform $(qt_mkspecs_dir)"
398    
399     [[ $(get_libdir) != lib ]] && conf+=" -L${EPREFIX}/usr/$(get_libdir)"
400    
401     # debug/release
402     if use debug; then
403     conf+=" -debug"
404     else
405     conf+=" -release"
406     fi
407     conf+=" -no-separate-debug-info"
408    
409     # exceptions USE flag
410     conf+=" $(in_iuse exceptions && qt_use exceptions || echo -exceptions)"
411    
412     # disable RPATH on Qt >= 4.8 (bug 380415)
413     version_is_at_least 4.8 && conf+=" -no-rpath"
414    
415     # precompiled headers don't work on hardened, where the flag is masked
416     conf+=" $(qt_use pch)"
417    
418     # -reduce-relocations
419     # This flag seems to introduce major breakage to applications,
420     # mostly to be seen as a core dump with the message "QPixmap: Must
421     # construct a QApplication before a QPaintDevice" on Solaris.
422     # -- Daniel Vergien
423     [[ ${CHOST} != *-solaris* ]] && conf+=" -reduce-relocations"
424 ingmar 1.7
425 abcd 1.57 # this one is needed for all systems with a separate -liconv, apart from
426     # Darwin, for which the sources already cater for -liconv
427 pesa 1.120 if use !elibc_glibc && [[ ${CHOST} != *-darwin* ]]; then
428 pesa 1.121 conf+=" -liconv"
429 pesa 1.120 fi
430 abcd 1.57
431 pesa 1.98 if use_if_iuse glib; then
432 abcd 1.57 local glibflags="$(pkg-config --cflags --libs glib-2.0 gthread-2.0)"
433     # avoid the -pthread argument
434 pesa 1.121 conf+=" ${glibflags//-pthread}"
435 abcd 1.57 unset glibflags
436     fi
437    
438 pesa 1.98 if use_if_iuse qpa; then
439 pesa 1.123 echo
440 hwoarang 1.96 ewarn "The qpa useflag enables the Qt Platform Abstraction, formely"
441     ewarn "known as Qt Lighthouse. If you are not sure what that is, then"
442     ewarn "disable it before reporting any bugs related to this useflag."
443 pesa 1.123 echo
444 pesa 1.121 conf+=" -qpa"
445 hwoarang 1.96 fi
446    
447 pesa 1.120 if use aqua; then
448 abcd 1.57 # On (snow) leopard use the new (frameworked) cocoa code.
449 pesa 1.120 if [[ ${CHOST##*-darwin} -ge 9 ]]; then
450 pesa 1.121 conf+=" -cocoa -framework"
451 pesa 1.120 # We need the source's headers, not the installed ones.
452 pesa 1.121 conf+=" -I${S}/include"
453 pesa 1.120 # Add hint for the framework location.
454 pesa 1.121 conf+=" -F${QTLIBDIR}"
455 abcd 1.57
456     # We are crazy and build cocoa + qt3support :-)
457     if use qt3support; then
458     sed -e "/case \"\$PLATFORM,\$CFG_MAC_COCOA\" in/,/;;/ s|CFG_QT3SUPPORT=\"no\"|CFG_QT3SUPPORT=\"yes\"|" \
459 pesa 1.114 -i configure || die
460 abcd 1.57 fi
461 pesa 1.120 else
462 pesa 1.121 conf+=" -no-framework"
463 abcd 1.57 fi
464     else
465 pesa 1.121 # freetype2 include dir is non-standard, thus pass it to configure
466     conf+=" $(pkg-config --cflags-only-I freetype2)"
467 abcd 1.57 fi
468    
469 pesa 1.121 conf+=" ${myconf}"
470     myconf=
471    
472     echo ./configure ${conf}
473     ./configure ${conf} || die "./configure failed"
474 wired 1.90
475     prepare_directories ${QT4_TARGET_DIRECTORIES}
476 yngwin 1.20 }
477 ingmar 1.7
478 hwoarang 1.34 # @FUNCTION: qt4-build_src_compile
479 vapier 1.93 # @DESCRIPTION:
480     # Actual compile phase
481 yngwin 1.20 qt4-build_src_compile() {
482 hwoarang 1.42 setqtenv
483 yngwin 1.20
484 abcd 1.55 build_directories ${QT4_TARGET_DIRECTORIES}
485 caleb 1.1 }
486    
487 ayoy 1.76 # @FUNCTION: qt4-build_src_test
488     # @DESCRIPTION:
489     # Runs tests only in target directories.
490     qt4-build_src_test() {
491 pesa 1.118 # QtMultimedia does not have any test suite (bug #332299)
492 pesa 1.123 [[ ${PN} == qt-multimedia ]] && return
493 pesa 1.118
494 ayoy 1.76 for dir in ${QT4_TARGET_DIRECTORIES}; do
495     emake -j1 check -C ${dir}
496     done
497     }
498    
499 abcd 1.57 # @FUNCTION: fix_includes
500     # @DESCRIPTION:
501 pesa 1.109 # For MacOS X we need to add some symlinks when frameworks are
502 abcd 1.57 # being used, to avoid complications with some more or less stupid packages.
503     fix_includes() {
504 pesa 1.120 if use aqua && [[ ${CHOST##*-darwin} -ge 9 ]]; then
505 abcd 1.57 # Some packages tend to include <Qt/...>
506     dodir "${QTHEADERDIR#${EPREFIX}}"/Qt
507    
508     # Fake normal headers when frameworks are installed... eases life later on
509 pesa 1.114 local dest f h
510 abcd 1.57 for frw in "${D}${QTLIBDIR}"/*.framework; do
511     [[ -e "${frw}"/Headers ]] || continue
512     f=$(basename ${frw})
513     dest="${QTHEADERDIR#${EPREFIX}}"/${f%.framework}
514     dosym "${QTLIBDIR#${EPREFIX}}"/${f}/Headers "${dest}"
515    
516     # Link normal headers as well.
517     for hdr in "${D}/${QTLIBDIR}/${f}"/Headers/*; do
518     h=$(basename ${hdr})
519     dosym "${QTLIBDIR#${EPREFIX}}"/${f}/Headers/${h} "${QTHEADERDIR#${EPREFIX}}"/Qt/${h}
520     done
521     done
522     fi
523     }
524    
525 hwoarang 1.34 # @FUNCTION: qt4-build_src_install
526     # @DESCRIPTION:
527     # Perform the actual installation including some library fixes.
528 caleb 1.4 qt4-build_src_install() {
529 abcd 1.57 [[ ${EAPI} == 2 ]] && use !prefix && ED=${D}
530 hwoarang 1.42 setqtenv
531 pesa 1.98
532 abcd 1.55 install_directories ${QT4_TARGET_DIRECTORIES}
533 ingmar 1.7 install_qconfigs
534 caleb 1.4 fix_library_files
535 abcd 1.57 fix_includes
536 pesa 1.98
537 hwoarang 1.78 # remove .la files since we are building only shared Qt libraries
538 pesa 1.114 find "${D}"${QTLIBDIR} -type f -name '*.la' -print0 | xargs -0 rm -f
539 caleb 1.4 }
540    
541 hwoarang 1.42 # @FUNCTION: setqtenv
542 pesa 1.110 # @INTERNAL
543 hwoarang 1.42 setqtenv() {
544     # Set up installation directories
545 abcd 1.57 QTPREFIXDIR=${EPREFIX}/usr
546     QTBINDIR=${EPREFIX}/usr/bin
547     QTLIBDIR=${EPREFIX}/usr/$(get_libdir)/qt4
548     QTPCDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig
549     QTDOCDIR=${EPREFIX}/usr/share/doc/qt-${PV}
550     QTHEADERDIR=${EPREFIX}/usr/include/qt4
551 hwoarang 1.42 QTPLUGINDIR=${QTLIBDIR}/plugins
552 abcd 1.104 QTIMPORTDIR=${QTLIBDIR}/imports
553 pesa 1.109 QTDATADIR=${EPREFIX}/usr/share/qt4
554     QTTRANSDIR=${QTDATADIR}/translations
555 abcd 1.57 QTSYSCONFDIR=${EPREFIX}/etc/qt4
556 hwoarang 1.42 QTEXAMPLESDIR=${QTDATADIR}/examples
557     QTDEMOSDIR=${QTDATADIR}/demos
558 pesa 1.109 QMAKE_LIBDIR_QT=${QTLIBDIR}
559 abcd 1.57 QT_INSTALL_PREFIX=${EPREFIX}/usr/$(get_libdir)/qt4
560 pesa 1.109
561 hwoarang 1.42 PLATFORM=$(qt_mkspecs_dir)
562    
563     unset QMAKESPEC
564     }
565    
566 wired 1.90 # @FUNCTION: prepare_directories
567 hwoarang 1.34 # @USAGE: < directories >
568 pesa 1.110 # @INTERNAL
569 hwoarang 1.34 # @DESCRIPTION:
570 pesa 1.109 # Generates Makefiles for the given list of directories.
571 wired 1.90 prepare_directories() {
572 abcd 1.55 for x in "$@"; do
573 pesa 1.109 pushd "${S}"/${x} >/dev/null || die
574 pesa 1.98 einfo "Running qmake in: ${x}"
575 abcd 1.60 # avoid running over the maximum argument number, bug #299810
576     {
577     echo "${S}"/mkspecs/common/*.conf
578     find "${S}" -name '*.pr[io]'
579 abcd 1.104 } | xargs sed -i \
580     -e "s:\$\$\[QT_INSTALL_LIBS\]:${QTLIBDIR}:g" \
581     -e "s:\$\$\[QT_INSTALL_PLUGINS\]:${QTPLUGINDIR}:g" \
582     || die
583 ingmar 1.7 "${S}"/bin/qmake "LIBS+=-L${QTLIBDIR}" "CONFIG+=nostrip" || die "qmake failed"
584 pesa 1.109 popd >/dev/null || die
585 wired 1.90 done
586     }
587    
588    
589     # @FUNCTION: build_directories
590     # @USAGE: < directories >
591 pesa 1.110 # @INTERNAL
592 wired 1.90 # @DESCRIPTION:
593 pesa 1.109 # Compiles the code in the given list of directories.
594 wired 1.90 build_directories() {
595     for x in "$@"; do
596 pesa 1.109 pushd "${S}"/${x} >/dev/null || die
597 wired 1.67 emake CC="$(tc-getCC)" \
598     CXX="$(tc-getCXX)" \
599     LINK="$(tc-getCXX)" || die "emake failed"
600 pesa 1.109 popd >/dev/null || die
601 caleb 1.1 done
602     }
603    
604 hwoarang 1.34 # @FUNCTION: install_directories
605     # @USAGE: < directories >
606 pesa 1.110 # @INTERNAL
607 hwoarang 1.34 # @DESCRIPTION:
608 pesa 1.109 # Runs emake install in the given directories, which are separated by spaces.
609 caleb 1.1 install_directories() {
610 abcd 1.55 for x in "$@"; do
611 pesa 1.109 pushd "${S}"/${x} >/dev/null || die
612 ingmar 1.7 emake INSTALL_ROOT="${D}" install || die "emake install failed"
613 pesa 1.109 popd >/dev/null || die
614 caleb 1.1 done
615     }
616    
617 ingmar 1.7 # @ECLASS-VARIABLE: QCONFIG_ADD
618     # @DESCRIPTION:
619     # List options that need to be added to QT_CONFIG in qconfig.pri
620 abcd 1.55 : ${QCONFIG_ADD:=}
621 ingmar 1.7
622     # @ECLASS-VARIABLE: QCONFIG_REMOVE
623     # @DESCRIPTION:
624     # List options that need to be removed from QT_CONFIG in qconfig.pri
625 abcd 1.55 : ${QCONFIG_REMOVE:=}
626 ingmar 1.7
627     # @ECLASS-VARIABLE: QCONFIG_DEFINE
628     # @DESCRIPTION:
629     # List variables that should be defined at the top of QtCore/qconfig.h
630 abcd 1.55 : ${QCONFIG_DEFINE:=}
631 ingmar 1.7
632 hwoarang 1.34 # @FUNCTION: install_qconfigs
633 pesa 1.110 # @INTERNAL
634 vapier 1.93 # @DESCRIPTION:
635 pesa 1.109 # Install gentoo-specific mkspecs configurations.
636 ingmar 1.7 install_qconfigs() {
637 zlin 1.9 local x
638     if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
639 ingmar 1.7 for x in QCONFIG_ADD QCONFIG_REMOVE; do
640     [[ -n ${!x} ]] && echo ${x}=${!x} >> "${T}"/${PN}-qconfig.pri
641     done
642 abcd 1.57 insinto ${QTDATADIR#${EPREFIX}}/mkspecs/gentoo
643 ingmar 1.7 doins "${T}"/${PN}-qconfig.pri || die "installing ${PN}-qconfig.pri failed"
644 zlin 1.9 fi
645 ingmar 1.7
646 zlin 1.9 if [[ -n ${QCONFIG_DEFINE} ]]; then
647 ingmar 1.7 for x in ${QCONFIG_DEFINE}; do
648     echo "#define ${x}" >> "${T}"/gentoo-${PN}-qconfig.h
649     done
650 abcd 1.57 insinto ${QTHEADERDIR#${EPREFIX}}/Gentoo
651 ingmar 1.7 doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed"
652     fi
653     }
654    
655 hwoarang 1.34 # @FUNCTION: generate_qconfigs
656 pesa 1.110 # @INTERNAL
657 vapier 1.93 # @DESCRIPTION:
658 pesa 1.109 # Generates gentoo-specific qconfig.{h,pri}.
659 ingmar 1.7 generate_qconfigs() {
660 pesa 1.123 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${PN} == qt-core ]]; then
661 ingmar 1.7 local x qconfig_add qconfig_remove qconfig_new
662     for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
663     [[ -f ${x} ]] || continue
664 abcd 1.55 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
665     qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
666 ingmar 1.7 done
667    
668     # these error checks do not use die because dying in pkg_post{inst,rm}
669     # just makes things worse.
670     if [[ -e "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
671     # start with the qconfig.pri that qt-core installed
672     if ! cp "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri \
673     "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then
674     eerror "cp qconfig failed."
675     return 1
676     fi
677    
678     # generate list of QT_CONFIG entries from the existing list
679     # including qconfig_add and excluding qconfig_remove
680     for x in $(sed -n 's/^QT_CONFIG +=//p' \
681     "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
682 ssuominen 1.91 has ${x} ${qconfig_remove} || qconfig_new+=" ${x}"
683 ingmar 1.7 done
684    
685     # replace the existing QT_CONFIG list with qconfig_new
686     if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
687     "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then
688     eerror "Sed for QT_CONFIG failed"
689     return 1
690     fi
691    
692     # create Gentoo/qconfig.h
693     if [[ ! -e ${ROOT}${QTHEADERDIR}/Gentoo ]]; then
694     if ! mkdir -p "${ROOT}${QTHEADERDIR}"/Gentoo; then
695     eerror "mkdir ${QTHEADERDIR}/Gentoo failed"
696     return 1
697     fi
698     fi
699     : > "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
700     for x in "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
701     [[ -f ${x} ]] || continue
702     cat "${x}" >> "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
703     done
704     else
705     rm -f "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri
706     rm -f "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
707     rmdir "${ROOT}${QTDATADIR}"/mkspecs \
708     "${ROOT}${QTDATADIR}" \
709     "${ROOT}${QTHEADERDIR}"/Gentoo \
710     "${ROOT}${QTHEADERDIR}" 2>/dev/null
711     fi
712     fi
713     }
714    
715 hwoarang 1.34 # @FUNCTION: qt4-build_pkg_postrm
716 vapier 1.93 # @DESCRIPTION:
717 pesa 1.109 # Regenerate configuration when the package is completely removed.
718 ingmar 1.7 qt4-build_pkg_postrm() {
719     generate_qconfigs
720 caleb 1.1 }
721    
722 hwoarang 1.34 # @FUNCTION: qt4-build_pkg_postinst
723 vapier 1.93 # @DESCRIPTION:
724 pesa 1.109 # Regenerate configuration, plus throw a message about possible
725 hwoarang 1.34 # breakages and proposed solutions.
726 ingmar 1.7 qt4-build_pkg_postinst() {
727     generate_qconfigs
728 caleb 1.1 }
729    
730 pesa 1.100 # @FUNCTION: skip_qmake_build
731 pesa 1.110 # @INTERNAL
732 hwoarang 1.34 # @DESCRIPTION:
733 pesa 1.109 # Patches configure to skip qmake compilation, as it's already installed by qt-core.
734 pesa 1.100 skip_qmake_build() {
735 pesa 1.109 sed -i -e "s:if true:if false:g" "${S}"/configure || die
736 caleb 1.1 }
737    
738 pesa 1.100 # @FUNCTION: skip_project_generation
739 pesa 1.110 # @INTERNAL
740 hwoarang 1.34 # @DESCRIPTION:
741 pesa 1.109 # Exit the script early by throwing in an exit before all of the .pro files are scanned.
742 pesa 1.100 skip_project_generation() {
743 pesa 1.109 sed -i -e "s:echo \"Finding:exit 0\n\necho \"Finding:g" "${S}"/configure || die
744 caleb 1.1 }
745    
746 hwoarang 1.34 # @FUNCTION: symlink_binaries_to_buildtree
747 pesa 1.110 # @INTERNAL
748 hwoarang 1.34 # @DESCRIPTION:
749 pesa 1.109 # Symlinks generated binaries to buildtree, so they can be used during compilation time.
750 ingmar 1.7 symlink_binaries_to_buildtree() {
751     for bin in qmake moc uic rcc; do
752 pesa 1.100 ln -s "${QTBINDIR}"/${bin} "${S}"/bin/ || die "symlinking ${bin} to ${S}/bin failed"
753 ingmar 1.7 done
754 caleb 1.1 }
755    
756 hwoarang 1.34 # @FUNCTION: fix_library_files
757 pesa 1.110 # @INTERNAL
758 hwoarang 1.34 # @DESCRIPTION:
759 pesa 1.109 # Fixes the paths in *.la, *.prl, *.pc, as they are wrong due to sandbox and
760     # moves the *.pc files into the pkgconfig directory.
761 caleb 1.1 fix_library_files() {
762 pesa 1.109 local libfile
763 ingmar 1.7 for libfile in "${D}"/${QTLIBDIR}/{*.la,*.prl,pkgconfig/*.pc}; do
764     if [[ -e ${libfile} ]]; then
765 pesa 1.98 sed -i -e "s:${S}/lib:${QTLIBDIR}:g" ${libfile} || die "sed on ${libfile} failed"
766 ingmar 1.7 fi
767     done
768 caleb 1.1
769 pesa 1.109 # pkgconfig files refer to WORKDIR/bin as the moc and uic locations
770 ingmar 1.7 for libfile in "${D}"/${QTLIBDIR}/pkgconfig/*.pc; do
771     if [[ -e ${libfile} ]]; then
772 pesa 1.109 sed -i -e "s:${S}/bin:${QTBINDIR}:g" ${libfile} || die "sed on ${libfile} failed"
773 caleb 1.1
774 abcd 1.55 # Move .pc files into the pkgconfig directory
775 abcd 1.57 dodir ${QTPCDIR#${EPREFIX}}
776 pesa 1.109 mv ${libfile} "${D}"/${QTPCDIR}/ || die "moving ${libfile} to ${D}/${QTPCDIR}/ failed"
777 ingmar 1.7 fi
778     done
779    
780     # Don't install an empty directory
781     rmdir "${D}"/${QTLIBDIR}/pkgconfig
782 caleb 1.1 }
783    
784 hwoarang 1.34 # @FUNCTION: qt_use
785     # @USAGE: < flag > [ feature ] [ enableval ]
786 yngwin 1.39 # @DESCRIPTION:
787 pesa 1.111 # This will echo "-${enableval}-${feature}" if <flag> is enabled, or
788     # "-no-${feature}" if it's disabled. If [feature] is not specified, <flag>
789 hwoarang 1.34 # will be used for that. If [enableval] is not specified, it omits the
790 pesa 1.111 # "-${enableval}" part.
791 caleb 1.1 qt_use() {
792 pesa 1.111 use "$1" && echo "${3:+-$3}-${2:-$1}" || echo "-no-${2:-$1}"
793 ingmar 1.7 }
794    
795 hwoarang 1.34 # @FUNCTION: qt_mkspecs_dir
796     # @RETURN: the specs-directory w/o path
797 yngwin 1.39 # @DESCRIPTION:
798 hwoarang 1.34 # Allows us to define which mkspecs dir we want to use.
799 caleb 1.1 qt_mkspecs_dir() {
800 pesa 1.109 local spec=
801 pesa 1.122
802     case "${CHOST}" in
803 caleb 1.5 *-freebsd*|*-dragonfly*)
804 abcd 1.55 spec=freebsd ;;
805 caleb 1.5 *-openbsd*)
806 abcd 1.55 spec=openbsd ;;
807 caleb 1.5 *-netbsd*)
808 abcd 1.55 spec=netbsd ;;
809 ingmar 1.7 *-darwin*)
810 abcd 1.57 if use aqua; then
811     # mac with carbon/cocoa
812     spec=macx
813     else
814     # darwin/mac with x11
815     spec=darwin
816     fi
817     ;;
818     *-solaris*)
819     spec=solaris ;;
820 caleb 1.5 *-linux-*|*-linux)
821 abcd 1.55 spec=linux ;;
822 caleb 1.5 *)
823 pesa 1.122 die "${FUNCNAME}(): Unknown CHOST '${CHOST}'" ;;
824 caleb 1.5 esac
825    
826 pesa 1.122 case "$(tc-getCXX)" in
827     *g++*)
828     spec+=-g++ ;;
829     *icpc*)
830     spec+=-icc ;;
831     *)
832     die "${FUNCNAME}(): Unknown compiler '$(tc-getCXX)'" ;;
833     esac
834 caleb 1.1
835 abcd 1.57 # Add -64 for 64bit profiles
836     if use x64-freebsd ||
837     use amd64-linux ||
838     use x64-macos ||
839     use x64-solaris ||
840     use sparc64-solaris
841     then
842     spec+=-64
843     fi
844    
845 caleb 1.5 echo "${spec}"
846 caleb 1.1 }
847    
848 hwoarang 1.77 # @FUNCTION: qt_assistant_cleanup
849 pesa 1.110 # @INTERNAL
850 hwoarang 1.77 # @DESCRIPTION:
851 pesa 1.99 # Tries to clean up tools.pro for qt-assistant ebuilds.
852     # Meant to be called in src_prepare().
853     # Since Qt 4.7.4 this function is a no-op.
854 hwoarang 1.77 qt_assistant_cleanup() {
855 pesa 1.99 # apply patching to qt-assistant ebuilds only
856 pesa 1.123 [[ ${PN} != qt-assistant ]] && return
857 pesa 1.99
858     # no longer needed for 4.7.4 and later
859 pesa 1.123 version_is_at_least 4.7.4 && return
860 pesa 1.99
861 hwoarang 1.77 # different versions (and branches...) may need different handling,
862     # add a case if you need special handling
863     case "${MY_PV_EXTRA}" in
864     *kde-qt*)
865     sed -e "/^[ \t]*porting/,/^[ \t]*win32.*activeqt$/d" \
866     -e "/mac/,/^embedded.*makeqpf$/d" \
867     -i tools/tools.pro || die "patching tools.pro failed"
868     ;;
869     *)
870     sed -e "/^[ \t]*porting/,/^[ \t]*win32.*activeqt$/d" \
871     -e "/mac/,/^embedded.*makeqpf$/d" \
872     -e "s/^\([ \t]*pixeltool\) /\1 qdoc3 /" \
873     -i tools/tools.pro || die "patching tools.pro failed"
874     ;;
875     esac
876     }
877    
878     # @FUNCTION: qt_nolibx11
879 pesa 1.110 # @INTERNAL
880 hwoarang 1.77 # @DESCRIPTION:
881 pesa 1.109 # Ignore X11 tests for packages that don't need X libraries installed.
882 hwoarang 1.77 qt_nolibx11() {
883     sed -i "/unixtests\/compile.test.*config.tests\/x11\/xlib/,/fi$/d" "${S}"/configure ||
884     die "x11 check sed failed"
885     }
886    
887 ayoy 1.76 EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install src_test pkg_postrm pkg_postinst

  ViewVC Help
Powered by ViewVC 1.1.20