Gentoo Archives: gentoo-commits

From: Davide Pesavento <pesa@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/qt:master commit in: eclass/
Date: Thu, 22 May 2014 01:07:41
Message-Id: 1400720709.646a897c283518ca5825aea3eeee338dfe6bcbca.pesa@gentoo
1 commit: 646a897c283518ca5825aea3eeee338dfe6bcbca
2 Author: Davide Pesavento <pesa <AT> gentoo <DOT> org>
3 AuthorDate: Thu May 22 00:38:09 2014 +0000
4 Commit: Davide Pesavento <pesa <AT> gentoo <DOT> org>
5 CommitDate: Thu May 22 01:05:09 2014 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/qt.git;a=commit;h=646a897c
7
8 [qt4-build-multilib.eclass] New multilib-compatible eclass for building Qt4.
9
10 For now it's just a copy of qt4-build.eclass with tons of cleanups, removal
11 of dead code and old cruft, and general function reorganization to improve
12 readability. Real multilib support will be added soon. See also bug 498010.
13
14 One major change of this eclass is that all Qt4 binaries are now installed
15 into '/usr/$(get_libdir)/qt4/bin', similarly to Qt5.
16
17 ---
18 eclass/qt4-build-multilib.eclass | 758 +++++++++++++++++++++++++++++++++++++++
19 1 file changed, 758 insertions(+)
20
21 diff --git a/eclass/qt4-build-multilib.eclass b/eclass/qt4-build-multilib.eclass
22 new file mode 100644
23 index 0000000..b35f334
24 --- /dev/null
25 +++ b/eclass/qt4-build-multilib.eclass
26 @@ -0,0 +1,758 @@
27 +# Copyright 1999-2014 Gentoo Foundation
28 +# Distributed under the terms of the GNU General Public License v2
29 +# $Header: $
30 +
31 +# @ECLASS: qt4-build-multilib.eclass
32 +# @MAINTAINER:
33 +# Qt herd <qt@g.o>
34 +# @AUTHOR:
35 +# Davide Pesavento <pesa@g.o>
36 +# @BLURB: Eclass for Qt4 split ebuilds with multilib support.
37 +# @DESCRIPTION:
38 +# This eclass contains various functions that are used when building Qt4.
39 +# Requires EAPI 5.
40 +
41 +case ${EAPI} in
42 + 5) : ;;
43 + *) die "qt4-build-multilib.eclass: unsupported EAPI=${EAPI:-0}" ;;
44 +esac
45 +
46 +inherit eutils flag-o-matic multilib toolchain-funcs # TODO multilib-minimal
47 +
48 +HOMEPAGE="http://qt-project.org/ http://qt.digia.com/"
49 +LICENSE="|| ( LGPL-2.1 GPL-3 )"
50 +SLOT="4"
51 +
52 +case ${PV} in
53 + 4.?.9999)
54 + QT4_BUILD_TYPE="live"
55 + EGIT_REPO_URI=(
56 + "git://gitorious.org/qt/qt.git"
57 + "https://git.gitorious.org/qt/qt.git"
58 + )
59 + EGIT_BRANCH=${PV%.9999}
60 + inherit git-r3
61 + ;;
62 + *)
63 + QT4_BUILD_TYPE="release"
64 + MY_P=qt-everywhere-opensource-src-${PV/_/-}
65 + SRC_URI="http://download.qt-project.org/official_releases/qt/${PV%.*}/${PV}/${MY_P}.tar.gz"
66 + S=${WORKDIR}/${MY_P}
67 + ;;
68 +esac
69 +
70 +IUSE="aqua debug pch"
71 +[[ ${CATEGORY}/${PN} != dev-qt/qtxmlpatterns ]] && IUSE+=" +exceptions"
72 +
73 +DEPEND="virtual/pkgconfig"
74 +if [[ ${QT4_BUILD_TYPE} == live ]]; then
75 + DEPEND+=" dev-lang/perl"
76 +fi
77 +
78 +EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm
79 +
80 +# @FUNCTION: qt4-build-multilib_pkg_setup
81 +# @DESCRIPTION:
82 +# Sets up PATH and LD_LIBRARY_PATH.
83 +qt4-build-multilib_pkg_setup() {
84 + # Warn users of possible breakage when downgrading to a previous release.
85 + # Downgrading revisions within the same release is safe.
86 + if has_version ">${CATEGORY}/${P}-r9999:4"; then
87 + ewarn
88 + ewarn "Downgrading Qt is completely unsupported and can break your system!"
89 + ewarn
90 + fi
91 +
92 + PATH="${S}/bin${PATH:+:}${PATH}"
93 + if [[ ${CHOST} != *-darwin* ]]; then
94 + LD_LIBRARY_PATH="${S}/lib${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"
95 + else
96 + DYLD_LIBRARY_PATH="${S}/lib${DYLD_LIBRARY_PATH:+:}${DYLD_LIBRARY_PATH}"
97 + fi
98 +}
99 +
100 +# @ECLASS-VARIABLE: QT4_EXTRACT_DIRECTORIES
101 +# @DEFAULT_UNSET
102 +# @DESCRIPTION:
103 +# Space-separated list including the directories that will be extracted from
104 +# Qt tarball.
105 +
106 +# @ECLASS-VARIABLE: QT4_TARGET_DIRECTORIES
107 +# @DEFAULT_UNSET
108 +# @DESCRIPTION:
109 +# Arguments for build_target_directories. Takes the directories in which the
110 +# code should be compiled. This is a space-separated list.
111 +
112 +# @FUNCTION: qt4-build-multilib_src_unpack
113 +# @DESCRIPTION:
114 +# Unpacks the sources.
115 +qt4-build-multilib_src_unpack() {
116 + if [[ $(gcc-major-version) -lt 4 ]] || [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 4 ]]; then
117 + ewarn
118 + ewarn "Using a GCC version lower than 4.4 is not supported."
119 + ewarn
120 + fi
121 +
122 + if [[ ${CATEGORY}/${PN} == dev-qt/qtwebkit ]]; then
123 + eshopts_push -s extglob
124 + if is-flagq '-g?(gdb)?([1-9])'; then
125 + ewarn
126 + ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
127 + ewarn "You may experience really long compilation times and/or increased memory usage."
128 + ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
129 + ewarn "For more info check out https://bugs.gentoo.org/307861"
130 + ewarn
131 + fi
132 + eshopts_pop
133 + fi
134 +
135 + case ${QT4_BUILD_TYPE} in
136 + live)
137 + git-r3_src_unpack
138 + ;;
139 + release)
140 + local tarball="${MY_P}.tar.gz" target= targets=
141 + # On MacOS we need src/gui/kernel/qapplication_mac.mm for platform detection
142 + for target in \
143 + bin config.tests configure LICENSE.GPL3 LICENSE.LGPL mkspecs \
144 + projects.pro qmake src/{qbase,qt_install,qt_targets}.pri \
145 + $([[ ${CHOST} == *-apple-darwin* ]] && echo src/gui/kernel/qapplication_mac.mm) \
146 + ${QT4_EXTRACT_DIRECTORIES}
147 + do
148 + targets+="${MY_P}/${target} "
149 + done
150 +
151 + ebegin "Unpacking parts of ${tarball}:" ${targets//${MY_P}\/}
152 + tar -xzf "${DISTDIR}"/${tarball} ${targets}
153 + eend $? || die "failed to unpack"
154 + ;;
155 + esac
156 +}
157 +
158 +# @ECLASS-VARIABLE: PATCHES
159 +# @DEFAULT_UNSET
160 +# @DESCRIPTION:
161 +# PATCHES array variable containing all various patches to be applied.
162 +# This variable is expected to be defined in global scope of ebuild.
163 +# Make sure to specify the full path. This variable is utilised in
164 +# src_prepare() phase.
165 +#
166 +# @CODE
167 +# PATCHES=( "${FILESDIR}/mypatch.patch"
168 +# "${FILESDIR}/patches_folder/" )
169 +# @CODE
170 +
171 +# @FUNCTION: qt4-build-multilib_src_prepare
172 +# @DESCRIPTION:
173 +# Prepare the sources before the configure phase. Strip CFLAGS if necessary, and fix
174 +# the build system in order to respect CFLAGS/CXXFLAGS/LDFLAGS specified in make.conf.
175 +qt4-build-multilib_src_prepare() {
176 + qt4_prepare_env
177 +
178 + if [[ ${QT4_BUILD_TYPE} == live ]]; then
179 + QTDIR="." ./bin/syncqt || die "syncqt failed"
180 + fi
181 +
182 + if [[ ${CATEGORY}/${PN} != dev-qt/qtcore ]]; then
183 + skip_qmake_build
184 + skip_project_generation
185 + symlink_binaries_to_buildtree
186 + fi
187 +
188 + # skip X11 tests in non-gui packages to avoid spurious dependencies
189 + if has ${PN} qtbearer qtcore qtdbus qtscript qtsql qttest qtxmlpatterns; then
190 + sed -i -e '/^if.*PLATFORM_X11.*CFG_GUI/,/^fi$/d' configure || die
191 + fi
192 +
193 + if use aqua; then
194 + # provide a proper macx-g++-64
195 + use x64-macos && ln -s macx-g++ mkspecs/$(qt_mkspecs_dir)
196 +
197 + sed -e '/^CONFIG/s:app_bundle::' \
198 + -e '/^CONFIG/s:plugin_no_soname:plugin_with_soname absolute_library_soname:' \
199 + -i mkspecs/$(qt_mkspecs_dir)/qmake.conf || die
200 + fi
201 +
202 + # Bug 261632
203 + if use ppc64; then
204 + append-flags -mminimal-toc
205 + fi
206 +
207 + # Bug 373061
208 + # qmake bus errors with -O2 or -O3 but -O1 works
209 + if [[ ${CHOST} == *86*-apple-darwin* ]]; then
210 + replace-flags -O[23] -O1
211 + fi
212 +
213 + # Bug 417105
214 + # graphite on gcc 4.7 causes miscompilations
215 + if [[ $(gcc-version) == "4.7" ]]; then
216 + filter-flags -fgraphite-identity
217 + fi
218 +
219 + # Respect CC, CXX, {C,CXX,LD}FLAGS in .qmake.cache
220 + sed -e "/^SYSTEM_VARIABLES=/i \
221 + CC='$(tc-getCC)'\n\
222 + CXX='$(tc-getCXX)'\n\
223 + CFLAGS='${CFLAGS}'\n\
224 + CXXFLAGS='${CXXFLAGS}'\n\
225 + LDFLAGS='${LDFLAGS}'\n\
226 + QMakeVar set QMAKE_CFLAGS_RELEASE\n\
227 + QMakeVar set QMAKE_CFLAGS_DEBUG\n\
228 + QMakeVar set QMAKE_CXXFLAGS_RELEASE\n\
229 + QMakeVar set QMAKE_CXXFLAGS_DEBUG\n\
230 + QMakeVar set QMAKE_LFLAGS_RELEASE\n\
231 + QMakeVar set QMAKE_LFLAGS_DEBUG\n"\
232 + -i configure \
233 + || die "sed SYSTEM_VARIABLES failed"
234 +
235 + # Respect CC, CXX, LINK and *FLAGS in config.tests
236 + find config.tests/unix -name '*.test' -type f -print0 | xargs -0 \
237 + sed -i -e "/bin\/qmake/ s: \"\$SRCDIR/: \
238 + 'QMAKE_CC=$(tc-getCC)' 'QMAKE_CXX=$(tc-getCXX)' 'QMAKE_LINK=$(tc-getCXX)' \
239 + 'QMAKE_CFLAGS+=${CFLAGS}' 'QMAKE_CXXFLAGS+=${CXXFLAGS}' 'QMAKE_LFLAGS+=${LDFLAGS}'&:" \
240 + || die "sed config.tests failed"
241 +
242 + # Bug 172219
243 + sed -e 's:/X11R6/:/:' -i mkspecs/$(qt_mkspecs_dir)/qmake.conf || die
244 +
245 + if [[ ${CHOST} == *-darwin* ]]; then
246 + # Set FLAGS *and* remove -arch, since our gcc-apple is multilib
247 + # crippled (by design) :/
248 + local mac_gpp_conf=
249 + if [[ -f mkspecs/common/mac-g++.conf ]]; then
250 + # qt < 4.8 has mac-g++.conf
251 + mac_gpp_conf="mkspecs/common/mac-g++.conf"
252 + elif [[ -f mkspecs/common/g++-macx.conf ]]; then
253 + # qt >= 4.8 has g++-macx.conf
254 + mac_gpp_conf="mkspecs/common/g++-macx.conf"
255 + else
256 + die "no known conf file for mac found"
257 + fi
258 + sed \
259 + -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
260 + -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
261 + -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=-headerpad_max_install_names ${LDFLAGS}:" \
262 + -e "s:-arch\s\w*::g" \
263 + -i ${mac_gpp_conf} \
264 + || die "sed ${mac_gpp_conf} failed"
265 +
266 + # Fix configure's -arch settings that appear in qmake/Makefile and also
267 + # fix arch handling (automagically duplicates our -arch arg and breaks
268 + # pch). Additionally disable Xarch support.
269 + local mac_gcc_confs="${mac_gpp_conf}"
270 + if [[ -f mkspecs/common/gcc-base-macx.conf ]]; then
271 + mac_gcc_confs+=" mkspecs/common/gcc-base-macx.conf"
272 + fi
273 + sed \
274 + -e "s:-arch i386::" \
275 + -e "s:-arch ppc::" \
276 + -e "s:-arch x86_64::" \
277 + -e "s:-arch ppc64::" \
278 + -e "s:-arch \$i::" \
279 + -e "/if \[ ! -z \"\$NATIVE_64_ARCH\" \]; then/,/fi/ d" \
280 + -e "s:CFG_MAC_XARCH=yes:CFG_MAC_XARCH=no:g" \
281 + -e "s:-Xarch_x86_64::g" \
282 + -e "s:-Xarch_ppc64::g" \
283 + -i configure ${mac_gcc_confs} \
284 + || die "sed -arch/-Xarch failed"
285 +
286 + # On Snow Leopard don't fall back to 10.5 deployment target.
287 + if [[ ${CHOST} == *-apple-darwin10 ]]; then
288 + sed -e "s:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET.*:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.6:g" \
289 + -e "s:-mmacosx-version-min=10.[0-9]:-mmacosx-version-min=10.6:g" \
290 + -i configure ${mac_gpp_conf} \
291 + || die "sed deployment target failed"
292 + fi
293 + fi
294 +
295 + # this is needed for all systems with a separate -liconv, except
296 + # Darwin, for which the sources already cater for -liconv
297 + if use !elibc_glibc && [[ ${CHOST} != *-darwin* ]]; then
298 + sed -e 's|mac:\(LIBS += -liconv\)|\1|g' \
299 + -i config.tests/unix/iconv/iconv.pro \
300 + || die "sed iconv.pro failed"
301 + fi
302 +
303 + # we need some patches for Solaris
304 + sed -i -e '/^QMAKE_LFLAGS_THREAD/a\QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list,' \
305 + mkspecs/$(qt_mkspecs_dir)/qmake.conf || die
306 + # use GCC over SunStudio
307 + sed -i -e '/PLATFORM=solaris-cc/s/cc/g++/' configure || die
308 + # do not flirt with non-Prefix stuff, we're quite possessive
309 + sed -i -e '/^QMAKE_\(LIB\|INC\)DIR\(_X11\|_OPENGL\|\)\t/s/=.*$/=/' \
310 + mkspecs/$(qt_mkspecs_dir)/qmake.conf || die
311 +
312 + # apply patches
313 + [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
314 + debug-print "$FUNCNAME: applying user patches"
315 + epatch_user
316 +}
317 +
318 +# @FUNCTION: qt4-build-multilib_src_configure
319 +# @DESCRIPTION:
320 +# Runs configure and generates Makefiles for all QT4_TARGET_DIRECTORIES.
321 +qt4-build-multilib_src_configure() {
322 + # configure arguments
323 + local conf="
324 + -prefix ${QT4_PREFIX}
325 + -bindir ${QT4_BINDIR}
326 + -libdir ${QT4_LIBDIR}
327 + -docdir ${QT4_DOCDIR}
328 + -headerdir ${QT4_HEADERDIR}
329 + -plugindir ${QT4_PLUGINDIR}
330 + -importdir ${QT4_IMPORTDIR}
331 + -datadir ${QT4_DATADIR}
332 + -translationdir ${QT4_TRANSLATIONDIR}
333 + -sysconfdir ${QT4_SYSCONFDIR}
334 + -examplesdir ${QT4_EXAMPLESDIR}
335 + -demosdir ${QT4_DEMOSDIR}
336 + -opensource -confirm-license
337 + -shared -fast -largefile -stl -verbose
338 + -nomake examples -nomake demos"
339 +
340 + # Convert tc-arch to the values supported by Qt
341 + case $(tc-arch) in
342 + amd64|x64-*) conf+=" -arch x86_64" ;;
343 + ppc*-macos) conf+=" -arch ppc" ;;
344 + ppc*) conf+=" -arch powerpc" ;;
345 + sparc*) conf+=" -arch sparc" ;;
346 + x86-macos) conf+=" -arch x86" ;;
347 + x86*) conf+=" -arch i386" ;;
348 + alpha|arm|ia64|mips|s390) conf+=" -arch $(tc-arch)" ;;
349 + hppa|sh) conf+=" -arch generic" ;;
350 + *) die "$(tc-arch) is unsupported by this eclass. Please file a bug." ;;
351 + esac
352 +
353 + conf+=" -platform $(qt_mkspecs_dir)"
354 +
355 + # debug/release
356 + if use debug; then
357 + conf+=" -debug"
358 + else
359 + conf+=" -release"
360 + fi
361 + conf+=" -no-separate-debug-info"
362 +
363 + # exceptions USE flag
364 + conf+=" $(in_iuse exceptions && qt_use exceptions || echo -exceptions)"
365 +
366 + # disable rpath (bug 380415), except on prefix (bug 417169)
367 + use prefix || conf+=" -no-rpath"
368 +
369 + # precompiled headers don't work on hardened, where the flag is masked
370 + conf+=" $(qt_use pch)"
371 +
372 + # -reduce-relocations
373 + # This flag seems to introduce major breakage to applications,
374 + # mostly to be seen as a core dump with the message "QPixmap: Must
375 + # construct a QApplication before a QPaintDevice" on Solaris.
376 + # -- Daniel Vergien
377 + [[ ${CHOST} != *-solaris* ]] && conf+=" -reduce-relocations"
378 +
379 + # this one is needed for all systems with a separate -liconv, apart from
380 + # Darwin, for which the sources already cater for -liconv
381 + if use !elibc_glibc && [[ ${CHOST} != *-darwin* ]]; then
382 + conf+=" -liconv"
383 + fi
384 +
385 + if use aqua; then
386 + # On (snow) leopard use the new (frameworked) cocoa code.
387 + if [[ ${CHOST##*-darwin} -ge 9 ]]; then
388 + conf+=" -cocoa -framework"
389 + # We need the source's headers, not the installed ones.
390 + conf+=" -I${S}/include"
391 + # Add hint for the framework location.
392 + conf+=" -F${QT4_LIBDIR}"
393 +
394 + # We are crazy and build cocoa + qt3support :-)
395 + if use qt3support; then
396 + sed -e "/case \"\$PLATFORM,\$CFG_MAC_COCOA\" in/,/;;/ s|CFG_QT3SUPPORT=\"no\"|CFG_QT3SUPPORT=\"yes\"|" \
397 + -i configure || die
398 + fi
399 + else
400 + conf+=" -no-framework"
401 + fi
402 + fi
403 +
404 + conf+=" ${myconf}"
405 + myconf=
406 +
407 + einfo "Configuring with:" ${conf}
408 + ./configure ${conf} || die "configure failed"
409 +
410 + local dir
411 + for dir in ${QT4_TARGET_DIRECTORIES}; do
412 + pushd ${dir} >/dev/null || die
413 + einfo "Running qmake in: ${dir}"
414 + "${S}"/bin/qmake \
415 + "LIBS+=-L${QT4_LIBDIR}" \
416 + "CONFIG+=nostrip" \
417 + || die "qmake failed"
418 + popd >/dev/null || die
419 + done
420 +}
421 +
422 +# @FUNCTION: qt4-build-multilib_src_compile
423 +# @DESCRIPTION:
424 +# Compiles the code in QT4_TARGET_DIRECTORIES.
425 +qt4-build-multilib_src_compile() {
426 + local dir
427 + for dir in ${QT4_TARGET_DIRECTORIES}; do
428 + pushd ${dir} >/dev/null || die
429 + emake \
430 + AR="$(tc-getAR) cqs" \
431 + CC="$(tc-getCC)" \
432 + CXX="$(tc-getCXX)" \
433 + LINK="$(tc-getCXX)" \
434 + RANLIB=":" \
435 + STRIP=":"
436 + popd >/dev/null || die
437 + done
438 +}
439 +
440 +# @FUNCTION: qt4-build-multilib_src_test
441 +# @DESCRIPTION:
442 +# Runs tests only in target directories.
443 +qt4-build-multilib_src_test() {
444 + # QtMultimedia does not have any test suite (bug #332299)
445 + [[ ${CATEGORY}/${PN} == dev-qt/qtmultimedia ]] && return
446 +
447 + local dir
448 + for dir in ${QT4_TARGET_DIRECTORIES}; do
449 + emake -j1 check -C ${dir}
450 + done
451 +}
452 +
453 +# @FUNCTION: qt4-build-multilib_src_install
454 +# @DESCRIPTION:
455 +# Perform the actual installation including some library fixes.
456 +qt4-build-multilib_src_install() {
457 + install_directories ${QT4_TARGET_DIRECTORIES}
458 + install_qconfigs
459 + fix_library_files
460 + fix_includes
461 +
462 + # remove .la files since we are building only shared libraries
463 + prune_libtool_files
464 +}
465 +
466 +# @FUNCTION: qt4-build-multilib_pkg_postinst
467 +# @DESCRIPTION:
468 +# Regenerate configuration, plus throw a message about possible
469 +# breakages and proposed solutions.
470 +qt4-build-multilib_pkg_postinst() {
471 + generate_qconfigs
472 +}
473 +
474 +# @FUNCTION: qt4-build-multilib_pkg_postrm
475 +# @DESCRIPTION:
476 +# Regenerate configuration when the package is completely removed.
477 +qt4-build-multilib_pkg_postrm() {
478 + generate_qconfigs
479 +}
480 +
481 +# @FUNCTION: qt_use
482 +# @USAGE: <flag> [feature] [enableval]
483 +# @DESCRIPTION:
484 +# This will echo "-${enableval}-${feature}" if <flag> is enabled, or
485 +# "-no-${feature}" if it's disabled. If [feature] is not specified,
486 +# <flag> will be used for that. If [enableval] is not specified, the
487 +# "-${enableval}" prefix is omitted.
488 +qt_use() {
489 + use "$1" && echo "${3:+-$3}-${2:-$1}" || echo "-no-${2:-$1}"
490 +}
491 +
492 +
493 +###### Internal functions ######
494 +
495 +# @FUNCTION: qt4_prepare_env
496 +# @INTERNAL
497 +# @DESCRIPTION:
498 +# Prepares the environment for building Qt.
499 +qt4_prepare_env() {
500 + # setup installation directories
501 + QT4_PREFIX=${EPREFIX}/usr
502 + QT4_HEADERDIR=${QT4_PREFIX}/include/qt4
503 + QT4_LIBDIR=${QT4_PREFIX}/$(get_libdir)/qt4
504 + QT4_PCDIR=${QT4_PREFIX}/$(get_libdir)/pkgconfig
505 + QT4_BINDIR=${QT4_LIBDIR}/bin
506 + QT4_PLUGINDIR=${QT4_LIBDIR}/plugins
507 + QT4_IMPORTDIR=${QT4_LIBDIR}/imports
508 + QT4_DATADIR=${QT4_PREFIX}/share/qt4
509 + QT4_DOCDIR=${QT4_PREFIX}/share/doc/qt-${PV}
510 + QT4_TRANSLATIONDIR=${QT4_DATADIR}/translations
511 + QT4_EXAMPLESDIR=${QT4_DATADIR}/examples
512 + QT4_DEMOSDIR=${QT4_DATADIR}/demos
513 + QT4_SYSCONFDIR=${EPREFIX}/etc/qt4
514 + QMAKE_LIBDIR_QT=${QT4_LIBDIR}
515 +
516 + PLATFORM=$(qt_mkspecs_dir)
517 + unset QMAKESPEC
518 +
519 + export XDG_CONFIG_HOME="${T}"
520 +}
521 +
522 +# @FUNCTION: install_directories
523 +# @USAGE: < directories >
524 +# @INTERNAL
525 +# @DESCRIPTION:
526 +# Runs emake install in the given directories, which are separated by spaces.
527 +install_directories() {
528 + for x in "$@"; do
529 + pushd "${S}"/${x} >/dev/null || die
530 + emake INSTALL_ROOT="${D}" install
531 + popd >/dev/null || die
532 + done
533 +}
534 +
535 +# @ECLASS-VARIABLE: QCONFIG_ADD
536 +# @DESCRIPTION:
537 +# List options that need to be added to QT_CONFIG in qconfig.pri
538 +: ${QCONFIG_ADD:=}
539 +
540 +# @ECLASS-VARIABLE: QCONFIG_REMOVE
541 +# @DESCRIPTION:
542 +# List options that need to be removed from QT_CONFIG in qconfig.pri
543 +: ${QCONFIG_REMOVE:=}
544 +
545 +# @ECLASS-VARIABLE: QCONFIG_DEFINE
546 +# @DESCRIPTION:
547 +# List variables that should be defined at the top of QtCore/qconfig.h
548 +: ${QCONFIG_DEFINE:=}
549 +
550 +# @FUNCTION: install_qconfigs
551 +# @INTERNAL
552 +# @DESCRIPTION:
553 +# Install gentoo-specific mkspecs configurations.
554 +install_qconfigs() {
555 + local x
556 + if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
557 + for x in QCONFIG_ADD QCONFIG_REMOVE; do
558 + [[ -n ${!x} ]] && echo ${x}=${!x} >> "${T}"/${PN}-qconfig.pri
559 + done
560 + insinto ${QT4_DATADIR#${EPREFIX}}/mkspecs/gentoo
561 + doins "${T}"/${PN}-qconfig.pri
562 + fi
563 +
564 + if [[ -n ${QCONFIG_DEFINE} ]]; then
565 + for x in ${QCONFIG_DEFINE}; do
566 + echo "#define ${x}" >> "${T}"/gentoo-${PN}-qconfig.h
567 + done
568 + insinto ${QT4_HEADERDIR#${EPREFIX}}/Gentoo
569 + doins "${T}"/gentoo-${PN}-qconfig.h
570 + fi
571 +}
572 +
573 +# @FUNCTION: generate_qconfigs
574 +# @INTERNAL
575 +# @DESCRIPTION:
576 +# Generates gentoo-specific qconfig.{h,pri}.
577 +generate_qconfigs() {
578 + if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${CATEGORY}/${PN} == dev-qt/qtcore ]]; then
579 + local x qconfig_add qconfig_remove qconfig_new
580 + for x in "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
581 + [[ -f ${x} ]] || continue
582 + qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
583 + qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
584 + done
585 +
586 + # these error checks do not use die because dying in pkg_post{inst,rm}
587 + # just makes things worse.
588 + if [[ -e "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
589 + # start with the qconfig.pri that qtcore installed
590 + if ! cp "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri \
591 + "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
592 + eerror "cp qconfig failed."
593 + return 1
594 + fi
595 +
596 + # generate list of QT_CONFIG entries from the existing list
597 + # including qconfig_add and excluding qconfig_remove
598 + for x in $(sed -n 's/^QT_CONFIG +=//p' \
599 + "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
600 + has ${x} ${qconfig_remove} || qconfig_new+=" ${x}"
601 + done
602 +
603 + # replace the existing QT_CONFIG list with qconfig_new
604 + if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
605 + "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
606 + eerror "Sed for QT_CONFIG failed"
607 + return 1
608 + fi
609 +
610 + # create Gentoo/qconfig.h
611 + if [[ ! -e ${ROOT}${QT4_HEADERDIR}/Gentoo ]]; then
612 + if ! mkdir -p "${ROOT}${QT4_HEADERDIR}"/Gentoo; then
613 + eerror "mkdir ${QT4_HEADERDIR}/Gentoo failed"
614 + return 1
615 + fi
616 + fi
617 + : > "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
618 + for x in "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
619 + [[ -f ${x} ]] || continue
620 + cat "${x}" >> "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
621 + done
622 + else
623 + rm -f "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri
624 + rm -f "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
625 + rmdir "${ROOT}${QT4_DATADIR}"/mkspecs \
626 + "${ROOT}${QT4_DATADIR}" \
627 + "${ROOT}${QT4_HEADERDIR}"/Gentoo \
628 + "${ROOT}${QT4_HEADERDIR}" 2>/dev/null
629 + fi
630 + fi
631 +}
632 +
633 +# @FUNCTION: skip_qmake_build
634 +# @INTERNAL
635 +# @DESCRIPTION:
636 +# Patches configure to skip qmake compilation, as it's already installed by qtcore.
637 +skip_qmake_build() {
638 + sed -i -e "s:if true:if false:g" "${S}"/configure || die
639 +}
640 +
641 +# @FUNCTION: skip_project_generation
642 +# @INTERNAL
643 +# @DESCRIPTION:
644 +# Exit the script early by throwing in an exit before all of the .pro files are scanned.
645 +skip_project_generation() {
646 + sed -i -e "s:echo \"Finding:exit 0\n\necho \"Finding:g" "${S}"/configure || die
647 +}
648 +
649 +# @FUNCTION: symlink_binaries_to_buildtree
650 +# @INTERNAL
651 +# @DESCRIPTION:
652 +# Symlinks generated binaries to buildtree, so they can be used during compilation time.
653 +symlink_binaries_to_buildtree() {
654 + for bin in qmake moc uic rcc; do
655 + ln -s "${QT4_BINDIR}"/${bin} "${S}"/bin/ || die "symlinking ${bin} to ${S}/bin failed"
656 + done
657 +}
658 +
659 +# @FUNCTION: fix_library_files
660 +# @INTERNAL
661 +# @DESCRIPTION:
662 +# Fixes the paths in *.la, *.prl, *.pc, as they are wrong due to sandbox and
663 +# moves the *.pc files into the pkgconfig directory.
664 +fix_library_files() {
665 + local libfile
666 + for libfile in "${D}"/${QT4_LIBDIR}/{*.la,*.prl,pkgconfig/*.pc}; do
667 + if [[ -e ${libfile} ]]; then
668 + sed -i -e "s:${S}/lib:${QT4_LIBDIR}:g" ${libfile} || die "sed on ${libfile} failed"
669 + fi
670 + done
671 +
672 + # pkgconfig files refer to WORKDIR/bin as the moc and uic locations
673 + for libfile in "${D}"/${QT4_LIBDIR}/pkgconfig/*.pc; do
674 + if [[ -e ${libfile} ]]; then
675 + sed -i -e "s:${S}/bin:${QT4_BINDIR}:g" ${libfile} || die "sed on ${libfile} failed"
676 +
677 + # Move .pc files into the pkgconfig directory
678 + dodir ${QT4_PCDIR#${EPREFIX}}
679 + mv ${libfile} "${D}"/${QT4_PCDIR}/ || die "moving ${libfile} to ${D}/${QT4_PCDIR}/ failed"
680 + fi
681 + done
682 +
683 + # Don't install an empty directory
684 + rmdir "${D}"/${QT4_LIBDIR}/pkgconfig
685 +}
686 +
687 +# @FUNCTION: fix_includes
688 +# @DESCRIPTION:
689 +# For MacOS X we need to add some symlinks when frameworks are
690 +# being used, to avoid complications with some more or less stupid packages.
691 +fix_includes() {
692 + if use aqua && [[ ${CHOST##*-darwin} -ge 9 ]]; then
693 + local frw dest f h rdir
694 + # Some packages tend to include <Qt/...>
695 + dodir "${QT4_HEADERDIR#${EPREFIX}}"/Qt
696 +
697 + # Fake normal headers when frameworks are installed... eases life later
698 + # on, make sure we use relative links though, as some ebuilds assume
699 + # these dirs exist in src_install to add additional files
700 + f=${QT4_HEADERDIR}
701 + h=${QT4_LIBDIR}
702 + while [[ -n ${f} && ${f%%/*} == ${h%%/*} ]] ; do
703 + f=${f#*/}
704 + h=${h#*/}
705 + done
706 + rdir=${h}
707 + f="../"
708 + while [[ ${h} == */* ]] ; do
709 + f="${f}../"
710 + h=${h#*/}
711 + done
712 + rdir="${f}${rdir}"
713 +
714 + for frw in "${D}${QT4_LIBDIR}"/*.framework; do
715 + [[ -e "${frw}"/Headers ]] || continue
716 + f=$(basename ${frw})
717 + dest="${QT4_HEADERDIR#${EPREFIX}}"/${f%.framework}
718 + dosym "${rdir}"/${f}/Headers "${dest}"
719 +
720 + # Link normal headers as well.
721 + for hdr in "${D}/${QT4_LIBDIR}/${f}"/Headers/*; do
722 + h=$(basename ${hdr})
723 + dosym "../${rdir}"/${f}/Headers/${h} \
724 + "${QT4_HEADERDIR#${EPREFIX}}"/Qt/${h}
725 + done
726 + done
727 + fi
728 +}
729 +
730 +# @FUNCTION: qt_mkspecs_dir
731 +# @RETURN: the specs-directory w/o path
732 +# @INTERNAL
733 +# @DESCRIPTION:
734 +# Allows us to define which mkspecs dir we want to use.
735 +qt_mkspecs_dir() {
736 + local spec=
737 +
738 + case "${CHOST}" in
739 + *-freebsd*|*-dragonfly*)
740 + spec=freebsd ;;
741 + *-openbsd*)
742 + spec=openbsd ;;
743 + *-netbsd*)
744 + spec=netbsd ;;
745 + *-darwin*)
746 + if use aqua; then
747 + # mac with carbon/cocoa
748 + spec=macx
749 + else
750 + # darwin/mac with x11
751 + spec=darwin
752 + fi
753 + ;;
754 + *-solaris*)
755 + spec=solaris ;;
756 + *-linux-*|*-linux)
757 + spec=linux ;;
758 + *)
759 + die "${FUNCNAME}(): Unknown CHOST '${CHOST}'" ;;
760 + esac
761 +
762 + case "$(tc-getCXX)" in
763 + *g++*)
764 + spec+=-g++ ;;
765 + *icpc*)
766 + spec+=-icc ;;
767 + *clang*)
768 + spec+=-clang ;;
769 + *)
770 + die "${FUNCNAME}(): Unknown compiler '$(tc-getCXX)'" ;;
771 + esac
772 +
773 + # Add -64 for 64bit profiles
774 + if use x64-freebsd ||
775 + use amd64-linux ||
776 + use x64-macos ||
777 + use x64-solaris ||
778 + use sparc64-solaris
779 + then
780 + spec+=-64
781 + fi
782 +
783 + echo "${spec}"
784 +}