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

Contents of /eclass/qt4-build-multilib.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.11 - (show annotations) (download)
Sat May 9 18:19:31 2015 UTC (4 years ago) by pesa
Branch: MAIN
Changes since 1.10: +22 -6 lines
Update from qt overlay: overhaul toolchain and *FLAGS handling for proper multilib support during the configure phase. Fixes bug #545106.

1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/qt4-build-multilib.eclass,v 1.10 2015/04/22 20:23:47 pesa Exp $
4
5 # @ECLASS: qt4-build-multilib.eclass
6 # @MAINTAINER:
7 # Qt herd <qt@gentoo.org>
8 # @AUTHOR:
9 # Davide Pesavento <pesa@gentoo.org>
10 # @BLURB: Eclass for Qt4 split ebuilds with multilib support.
11 # @DESCRIPTION:
12 # This eclass contains various functions that are used when building Qt4.
13 # Requires EAPI 5.
14
15 case ${EAPI} in
16 5) : ;;
17 *) die "qt4-build-multilib.eclass: unsupported EAPI=${EAPI:-0}" ;;
18 esac
19
20 inherit eutils flag-o-matic multilib multilib-minimal toolchain-funcs
21
22 HOMEPAGE="https://www.qt.io/"
23 LICENSE="|| ( LGPL-2.1 GPL-3 )"
24 SLOT="4"
25
26 case ${PV} in
27 4.?.9999)
28 QT4_BUILD_TYPE="live"
29 EGIT_REPO_URI=(
30 "git://code.qt.io/qt/qt.git"
31 "https://code.qt.io/git/qt/qt.git"
32 "https://github.com/qtproject/qt.git"
33 )
34 EGIT_BRANCH=${PV%.9999}
35 inherit git-r3
36 ;;
37 *)
38 QT4_BUILD_TYPE="release"
39 MY_P=qt-everywhere-opensource-src-${PV/_/-}
40 SRC_URI="http://download.qt.io/official_releases/qt/${PV%.*}/${PV}/${MY_P}.tar.gz"
41 S=${WORKDIR}/${MY_P}
42 ;;
43 esac
44
45 if [[ ${PN} != qttranslations ]]; then
46 IUSE="aqua debug pch"
47 [[ ${PN} != qtxmlpatterns ]] && IUSE+=" +exceptions"
48 fi
49
50 DEPEND="
51 dev-lang/perl
52 virtual/pkgconfig[${MULTILIB_USEDEP}]
53 "
54 RDEPEND="
55 dev-qt/qtchooser
56 abi_x86_32? ( !app-emulation/emul-linux-x86-qtlibs[-abi_x86_32(-)] )
57 "
58
59
60 # src_{configure,compile,test,install} are inherited from multilib-minimal
61 EXPORT_FUNCTIONS src_unpack src_prepare pkg_postinst pkg_postrm
62
63 multilib_src_configure() { qt4_multilib_src_configure; }
64 multilib_src_compile() { qt4_multilib_src_compile; }
65 multilib_src_test() { qt4_multilib_src_test; }
66 multilib_src_install() { qt4_multilib_src_install; }
67 multilib_src_install_all() { qt4_multilib_src_install_all; }
68
69
70 # @ECLASS-VARIABLE: PATCHES
71 # @DEFAULT_UNSET
72 # @DESCRIPTION:
73 # Array variable containing all the patches to be applied. This variable
74 # is expected to be defined in the global scope of ebuilds. Make sure to
75 # specify the full path. This variable is used in src_prepare phase.
76 #
77 # Example:
78 # @CODE
79 # PATCHES=(
80 # "${FILESDIR}/mypatch.patch"
81 # "${FILESDIR}/mypatch2.patch"
82 # )
83 # @CODE
84
85 # @ECLASS-VARIABLE: QT4_TARGET_DIRECTORIES
86 # @DEFAULT_UNSET
87 # @DESCRIPTION:
88 # Space-separated list of directories that will be configured,
89 # compiled, and installed. All paths must be relative to ${S}.
90
91 # @ECLASS-VARIABLE: QT4_VERBOSE_BUILD
92 # @DESCRIPTION:
93 # Set to false to reduce build output during compilation.
94 : ${QT4_VERBOSE_BUILD:=true}
95
96 # @ECLASS-VARIABLE: QCONFIG_ADD
97 # @DEFAULT_UNSET
98 # @DESCRIPTION:
99 # List of options that must be added to QT_CONFIG in qconfig.pri
100
101 # @ECLASS-VARIABLE: QCONFIG_REMOVE
102 # @DEFAULT_UNSET
103 # @DESCRIPTION:
104 # List of options that must be removed from QT_CONFIG in qconfig.pri
105
106 # @ECLASS-VARIABLE: QCONFIG_DEFINE
107 # @DEFAULT_UNSET
108 # @DESCRIPTION:
109 # List of macros that must be defined in QtCore/qconfig.h
110
111 # @FUNCTION: qt4-build-multilib_src_unpack
112 # @DESCRIPTION:
113 # Unpacks the sources.
114 qt4-build-multilib_src_unpack() {
115 if [[ $(gcc-major-version) -lt 4 ]] || [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 4 ]]; then
116 ewarn
117 ewarn "Using a GCC version lower than 4.4 is not supported."
118 ewarn
119 fi
120
121 if [[ ${PN} == qtwebkit ]]; then
122 eshopts_push -s extglob
123 if is-flagq '-g?(gdb)?([1-9])'; then
124 ewarn
125 ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
126 ewarn "You may experience really long compilation times and/or increased memory usage."
127 ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
128 ewarn "For more info check out https://bugs.gentoo.org/307861"
129 ewarn
130 fi
131 eshopts_pop
132 fi
133
134 case ${QT4_BUILD_TYPE} in
135 live) git-r3_src_unpack ;;
136 release) default ;;
137 esac
138 }
139
140 # @FUNCTION: qt4-build-multilib_src_prepare
141 # @DESCRIPTION:
142 # Prepare the sources before the configure phase. Strip CFLAGS if necessary, and fix
143 # the build system in order to respect CFLAGS/CXXFLAGS/LDFLAGS specified in make.conf.
144 qt4-build-multilib_src_prepare() {
145 if [[ ${PN} != qtcore ]]; then
146 # avoid unnecessary qmake recompilations
147 sed -i -e 's/^if true;/if false;/' configure \
148 || die "sed failed (skip qmake bootstrap)"
149 fi
150
151 # skip X11 tests in non-gui packages to avoid spurious dependencies
152 if has ${PN} qtbearer qtcore qtdbus qtscript qtsql qttest qttranslations qtxmlpatterns; then
153 sed -i -e '/^if.*PLATFORM_X11.*CFG_GUI/,/^fi$/d' configure \
154 || die "sed failed (skip X11 tests)"
155 fi
156
157 if use_if_iuse aqua; then
158 sed -i \
159 -e '/^CONFIG/s:app_bundle::' \
160 -e '/^CONFIG/s:plugin_no_soname:plugin_with_soname absolute_library_soname:' \
161 mkspecs/$(qt4_get_mkspec)/qmake.conf \
162 || die "sed failed (aqua)"
163
164 # we are crazy and build cocoa + qt3support
165 if { ! in_iuse qt3support || use qt3support; } && [[ ${CHOST##*-darwin} -ge 9 ]]; then
166 sed -i -e "/case \"\$PLATFORM,\$CFG_MAC_COCOA\" in/,/;;/ s|CFG_QT3SUPPORT=\"no\"|CFG_QT3SUPPORT=\"yes\"|" \
167 configure || die "sed failed (cocoa + qt3support)"
168 fi
169 fi
170
171 if [[ ${PN} == qtcore ]]; then
172 # Bug 373061
173 # qmake bus errors with -O2 or -O3 but -O1 works
174 if [[ ${CHOST} == *86*-apple-darwin* ]]; then
175 replace-flags -O[23] -O1
176 fi
177
178 # Bug 503500
179 # undefined reference with -Os and --as-needed
180 if use x86 || use_if_iuse abi_x86_32; then
181 replace-flags -Os -O2
182 fi
183 fi
184
185 # Bug 261632
186 if use ppc64; then
187 append-flags -mminimal-toc
188 fi
189
190 # Bug 417105
191 # graphite on gcc 4.7 causes miscompilations
192 if [[ $(gcc-version) == "4.7" ]]; then
193 filter-flags -fgraphite-identity
194 fi
195
196 # Read also AR from the environment
197 sed -i -e 's/^SYSTEM_VARIABLES="/&AR /' \
198 configure || die "sed SYSTEM_VARIABLES failed"
199
200 # Reset QMAKE_*FLAGS_{RELEASE,DEBUG} variables,
201 # or they will override the user's flags (via .qmake.cache)
202 sed -i -e '/^SYSTEM_VARIABLES=/ i \
203 QMakeVar set QMAKE_CFLAGS_RELEASE\
204 QMakeVar set QMAKE_CFLAGS_DEBUG\
205 QMakeVar set QMAKE_CXXFLAGS_RELEASE\
206 QMakeVar set QMAKE_CXXFLAGS_DEBUG\
207 QMakeVar set QMAKE_LFLAGS_RELEASE\
208 QMakeVar set QMAKE_LFLAGS_DEBUG\n' \
209 configure || die "sed QMAKE_*FLAGS_{RELEASE,DEBUG} failed"
210
211 # Drop -nocache from qmake invocation in all configure tests, to ensure that the
212 # correct toolchain and build flags are picked up from config.tests/.qmake.cache
213 find config.tests/unix -name '*.test' -type f -print0 | xargs -0 \
214 sed -i -e '/bin\/qmake/s/ -nocache//' || die "sed -nocache failed"
215
216 # compile.test needs additional patching so that it doesn't create another cache file
217 # inside the test subdir, which would incorrectly override config.tests/.qmake.cache
218 sed -i -e '/echo.*QT_BUILD_TREE.*\.qmake\.cache/d' \
219 -e '/bin\/qmake/s/ "$SRCDIR/ "QT_BUILD_TREE=$OUTDIR"&/' \
220 config.tests/unix/compile.test || die "sed compile.test failed"
221
222 # Delete references to the obsolete /usr/X11R6 directory
223 # On prefix, this also prevents looking at non-prefix stuff
224 sed -i -re '/^QMAKE_(LIB|INC)DIR(_X11|_OPENGL|)\s+/ s/=.*/=/' \
225 mkspecs/common/linux.conf \
226 mkspecs/$(qt4_get_mkspec)/qmake.conf \
227 || die "sed QMAKE_(LIB|INC)DIR failed"
228
229 if [[ ${CHOST} == *-darwin* ]]; then
230 # Set FLAGS and remove -arch, since our gcc-apple is multilib crippled (by design)
231 sed -i \
232 -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
233 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
234 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=-headerpad_max_install_names ${LDFLAGS}:" \
235 -e "s:-arch\s\w*::g" \
236 mkspecs/common/g++-macx.conf \
237 || die "sed g++-macx.conf failed"
238
239 # Fix configure's -arch settings that appear in qmake/Makefile and also
240 # fix arch handling (automagically duplicates our -arch arg and breaks
241 # pch). Additionally disable Xarch support.
242 sed -i \
243 -e "s:-arch i386::" \
244 -e "s:-arch ppc::" \
245 -e "s:-arch x86_64::" \
246 -e "s:-arch ppc64::" \
247 -e "s:-arch \$i::" \
248 -e "/if \[ ! -z \"\$NATIVE_64_ARCH\" \]; then/,/fi/ d" \
249 -e "s:CFG_MAC_XARCH=yes:CFG_MAC_XARCH=no:g" \
250 -e "s:-Xarch_x86_64::g" \
251 -e "s:-Xarch_ppc64::g" \
252 configure mkspecs/common/gcc-base-macx.conf mkspecs/common/g++-macx.conf \
253 || die "sed -arch/-Xarch failed"
254
255 # On Snow Leopard don't fall back to 10.5 deployment target.
256 if [[ ${CHOST} == *-apple-darwin10 ]]; then
257 sed -i \
258 -e "s:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET.*:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.6:g" \
259 -e "s:-mmacosx-version-min=10.[0-9]:-mmacosx-version-min=10.6:g" \
260 configure mkspecs/common/g++-macx.conf \
261 || die "sed deployment target failed"
262 fi
263 fi
264
265 if [[ ${CHOST} == *-solaris* ]]; then
266 sed -i -e '/^QMAKE_LFLAGS_THREAD/a QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list,' \
267 mkspecs/$(qt4_get_mkspec)/qmake.conf || die
268 fi
269
270 # apply patches
271 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
272 epatch_user
273 }
274
275 qt4_multilib_src_configure() {
276 qt4_prepare_env
277
278 qt4_symlink_tools_to_build_dir
279
280 # toolchain setup ('local -x' because of bug 532510)
281 local -x \
282 AR="$(tc-getAR) cqs" \
283 CC=$(tc-getCC) \
284 CXX=$(tc-getCXX) \
285 LD=$(tc-getCXX) \
286 OBJCOPY=$(tc-getOBJCOPY) \
287 STRIP=$(tc-getSTRIP)
288
289 # convert tc-arch to the values supported by Qt
290 local arch=
291 case $(tc-arch) in
292 amd64|x64-*) arch=x86_64 ;;
293 ppc*-macos) arch=ppc ;;
294 ppc*) arch=powerpc ;;
295 sparc*) arch=sparc ;;
296 x86-macos) arch=x86 ;;
297 x86*) arch=i386 ;;
298 alpha|arm|ia64|mips|s390) arch=$(tc-arch) ;;
299 arm64|hppa|sh) arch=generic ;;
300 *) die "qt4-build-multilib.eclass: unsupported tc-arch '$(tc-arch)'" ;;
301 esac
302
303 # configure arguments
304 local conf=(
305 # installation paths
306 -prefix "${QT4_PREFIX}"
307 -bindir "${QT4_BINDIR}"
308 -libdir "${QT4_LIBDIR}"
309 -docdir "${QT4_DOCDIR}"
310 -headerdir "${QT4_HEADERDIR}"
311 -plugindir "${QT4_PLUGINDIR}"
312 -importdir "${QT4_IMPORTDIR}"
313 -datadir "${QT4_DATADIR}"
314 -translationdir "${QT4_TRANSLATIONDIR}"
315 -sysconfdir "${QT4_SYSCONFDIR}"
316 -examplesdir "${QT4_EXAMPLESDIR}"
317 -demosdir "${QT4_DEMOSDIR}"
318
319 # debug/release
320 $(use_if_iuse debug && echo -debug || echo -release)
321 -no-separate-debug-info
322
323 # licensing stuff
324 -opensource -confirm-license
325
326 # build shared libraries
327 -shared
328
329 # skip recursive processing of .pro files at the end of configure
330 # (we run qmake by ourselves), thus saving quite a bit of time
331 -dont-process
332
333 # always enable large file support
334 -largefile
335
336 # exceptions USE flag
337 $(in_iuse exceptions && qt_use exceptions || echo -exceptions)
338
339 # build STL support
340 -stl
341
342 # architecture/platform (mkspec)
343 -arch ${arch}
344 -platform $(qt4_get_mkspec)
345
346 # instruction set support
347 $(is-flagq -mno-mmx && echo -no-mmx)
348 $(is-flagq -mno-3dnow && echo -no-3dnow)
349 $(is-flagq -mno-sse && echo -no-sse)
350 $(is-flagq -mno-sse2 && echo -no-sse2)
351 $(is-flagq -mno-sse3 && echo -no-sse3)
352 $(is-flagq -mno-ssse3 && echo -no-ssse3)
353 $(is-flagq -mno-sse4.1 && echo -no-sse4.1)
354 $(is-flagq -mno-sse4.2 && echo -no-sse4.2)
355 $(is-flagq -mno-avx && echo -no-avx)
356 $(is-flagq -mfpu=* && ! is-flagq -mfpu=*neon* && echo -no-neon)
357
358 # prefer system libraries
359 -system-zlib
360
361 # exclude examples and demos from default build
362 -nomake examples
363 -nomake demos
364
365 # disable rpath on non-prefix (bugs 380415 and 417169)
366 $(use prefix || echo -no-rpath)
367
368 # verbosity of the configure and build phases
369 -verbose $(${QT4_VERBOSE_BUILD} || echo -silent)
370
371 # precompiled headers don't work on hardened, where the flag is masked
372 $(in_iuse pch && qt_use pch || echo -no-pch)
373
374 # enable linker optimizations to reduce relocations, except on Solaris
375 # where this flag seems to introduce major breakage to applications,
376 # mostly to be seen as a core dump with the message:
377 # "QPixmap: Must construct a QApplication before a QPaintDevice"
378 $([[ ${CHOST} != *-solaris* ]] && echo -reduce-relocations)
379
380 # this one is needed for all systems with a separate -liconv, apart from
381 # Darwin, for which the sources already cater for -liconv
382 $(use !elibc_glibc && [[ ${CHOST} != *-darwin* ]] && echo -liconv)
383 )
384
385 if use_if_iuse aqua; then
386 if [[ ${CHOST##*-darwin} -ge 9 ]]; then
387 conf+=(
388 # on (snow) leopard use the new (frameworked) cocoa code
389 -cocoa -framework
390 # add hint for the framework location
391 -F"${QT4_LIBDIR}"
392 )
393 else
394 conf+=(-no-framework)
395 fi
396 fi
397
398 conf+=(
399 # module-specific options
400 "${myconf[@]}"
401 )
402
403 einfo "Configuring with: ${conf[@]}"
404 "${S}"/configure "${conf[@]}" || die "configure failed"
405
406 # configure is stupid and assigns QMAKE_LFLAGS twice,
407 # thus the previous -rpath-link flag gets overwritten
408 # and some packages (e.g. qthelp) fail to link
409 sed -i -e '/^QMAKE_LFLAGS =/ s:$: $$QMAKE_LFLAGS:' \
410 .qmake.cache || die "sed .qmake.cache failed"
411
412 qt4_qmake
413 qt4_foreach_target_subdir qt4_qmake
414 }
415
416 qt4_multilib_src_compile() {
417 qt4_prepare_env
418
419 qt4_foreach_target_subdir emake
420 }
421
422 qt4_multilib_src_test() {
423 qt4_prepare_env
424
425 qt4_foreach_target_subdir emake -j1 check
426 }
427
428 qt4_multilib_src_install() {
429 qt4_prepare_env
430
431 qt4_foreach_target_subdir emake INSTALL_ROOT="${D}" install
432
433 if [[ ${PN} == qtcore ]]; then
434 set -- emake INSTALL_ROOT="${D}" install_{mkspecs,qmake}
435 einfo "Running $*"
436 "$@"
437
438 # install env.d file
439 cat > "${T}/44qt4-${CHOST}" <<-_EOF_
440 LDPATH="${QT4_LIBDIR}"
441 _EOF_
442 doenvd "${T}/44qt4-${CHOST}"
443
444 # install qtchooser configuration file
445 cat > "${T}/qt4-${CHOST}.conf" <<-_EOF_
446 ${QT4_BINDIR}
447 ${QT4_LIBDIR}
448 _EOF_
449
450 (
451 insinto /etc/xdg/qtchooser
452 doins "${T}/qt4-${CHOST}.conf"
453 )
454
455 if multilib_is_native_abi; then
456 # convenience symlinks
457 dosym qt4-"${CHOST}".conf /etc/xdg/qtchooser/4.conf
458 dosym qt4-"${CHOST}".conf /etc/xdg/qtchooser/qt4.conf
459 # TODO bug 522646: write an eselect module to manage default.conf
460 dosym qt4.conf /etc/xdg/qtchooser/default.conf
461 fi
462 fi
463
464 install_qconfigs
465 fix_library_files
466 fix_includes
467 }
468
469 qt4_multilib_src_install_all() {
470 if [[ ${PN} == qtcore ]]; then
471 # include gentoo-qconfig.h at the beginning of Qt{,Core}/qconfig.h
472 if use aqua && [[ ${CHOST#*-darwin} -ge 9 ]]; then
473 sed -i -e '1i #include <QtCore/Gentoo/gentoo-qconfig.h>\n' \
474 "${D}${QT4_LIBDIR}"/QtCore.framework/Headers/qconfig.h \
475 || die "sed failed (qconfig.h)"
476 dosym "${QT4_HEADERDIR#${EPREFIX}}"/Gentoo \
477 "${QT4_LIBDIR#${EPREFIX}}"/QtCore.framework/Headers/Gentoo
478 else
479 sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
480 "${D}${QT4_HEADERDIR}"/Qt{,Core}/qconfig.h \
481 || die "sed failed (qconfig.h)"
482 fi
483
484 dodir "${QT4_DATADIR#${EPREFIX}}"/mkspecs/gentoo
485 mv "${D}${QT4_DATADIR}"/mkspecs/{qconfig.pri,gentoo/} || die
486 fi
487
488 # install private headers of a few modules
489 if has ${PN} qtcore qtdeclarative qtgui qtscript; then
490 local moduledir=${PN#qt}
491 local modulename=Qt$(tr 'a-z' 'A-Z' <<< ${moduledir:0:1})${moduledir:1}
492 [[ ${moduledir} == core ]] && moduledir=corelib
493
494 einfo "Installing private headers into ${QT4_HEADERDIR}/${modulename}/private"
495 insinto "${QT4_HEADERDIR#${EPREFIX}}"/${modulename}/private
496 find "${S}"/src/${moduledir} -type f -name '*_p.h' -exec doins '{}' + || die
497 fi
498
499 # remove .la files since we are building only shared libraries
500 prune_libtool_files
501 }
502
503 # @FUNCTION: qt4-build-multilib_pkg_postinst
504 # @DESCRIPTION:
505 # Regenerate configuration, plus throw a message about possible
506 # breakages and proposed solutions.
507 qt4-build-multilib_pkg_postinst() {
508 generate_qconfigs
509 }
510
511 # @FUNCTION: qt4-build-multilib_pkg_postrm
512 # @DESCRIPTION:
513 # Regenerate configuration when the package is completely removed.
514 qt4-build-multilib_pkg_postrm() {
515 generate_qconfigs
516 }
517
518 # @FUNCTION: qt_use
519 # @USAGE: <flag> [feature] [enableval]
520 # @DESCRIPTION:
521 # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
522 # otherwise. If [feature] is not specified, <flag> is used in its place.
523 # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
524 qt_use() {
525 use "$1" && echo "${3:+-$3}-${2:-$1}" || echo "-no-${2:-$1}"
526 }
527
528 # @FUNCTION: qt_native_use
529 # @USAGE: <flag> [feature] [enableval]
530 # @DESCRIPTION:
531 # Outputs "-${enableval}-${feature}" if <flag> is enabled and we are currently
532 # building for the native ABI, "-no-${feature}" otherwise. If [feature] is not
533 # specified, <flag> is used in its place. If [enableval] is not specified,
534 # the "-${enableval}" prefix is omitted.
535 qt_native_use() {
536 multilib_is_native_abi && use "$1" && echo "${3:+-$3}-${2:-$1}" || echo "-no-${2:-$1}"
537 }
538
539
540 ###### Internal functions ######
541
542 # @FUNCTION: qt4_prepare_env
543 # @INTERNAL
544 # @DESCRIPTION:
545 # Prepares the environment for building Qt.
546 qt4_prepare_env() {
547 # setup installation directories
548 QT4_PREFIX=${EPREFIX}/usr
549 QT4_HEADERDIR=${QT4_PREFIX}/include/qt4
550 QT4_LIBDIR=${QT4_PREFIX}/$(get_libdir)/qt4
551 QT4_PCDIR=${QT4_PREFIX}/$(get_libdir)/pkgconfig
552 QT4_BINDIR=${QT4_LIBDIR}/bin
553 QT4_PLUGINDIR=${QT4_LIBDIR}/plugins
554 QT4_IMPORTDIR=${QT4_LIBDIR}/imports
555 QT4_DATADIR=${QT4_PREFIX}/share/qt4
556 QT4_DOCDIR=${QT4_PREFIX}/share/doc/qt-${PV}
557 QT4_TRANSLATIONDIR=${QT4_DATADIR}/translations
558 QT4_EXAMPLESDIR=${QT4_DATADIR}/examples
559 QT4_DEMOSDIR=${QT4_DATADIR}/demos
560 QT4_SYSCONFDIR=${EPREFIX}/etc/qt4
561 QMAKE_LIBDIR_QT=${QT4_LIBDIR}
562
563 export XDG_CONFIG_HOME="${T}"
564 }
565
566 # @FUNCTION: qt4_foreach_target_subdir
567 # @INTERNAL
568 # @DESCRIPTION:
569 # Executes the given command inside each directory listed in QT4_TARGET_DIRECTORIES.
570 qt4_foreach_target_subdir() {
571 local subdir
572 for subdir in ${QT4_TARGET_DIRECTORIES}; do
573 mkdir -p "${subdir}" || die
574 pushd "${subdir}" >/dev/null || die
575
576 einfo "Running $* ${subdir:+in ${subdir}}"
577 "$@"
578
579 popd >/dev/null || die
580 done
581 }
582
583 # @FUNCTION: qt4_symlink_tools_to_build_dir
584 # @INTERNAL
585 # @DESCRIPTION:
586 # Symlinks qtcore tools to BUILD_DIR,
587 # so that they can be used when building other modules.
588 qt4_symlink_tools_to_build_dir() {
589 local tool= tools=()
590 if [[ ${PN} != qtcore ]]; then
591 tools+=(qmake moc rcc uic)
592 fi
593
594 mkdir -p "${BUILD_DIR}"/bin || die
595 pushd "${BUILD_DIR}"/bin >/dev/null || die
596
597 for tool in "${tools[@]}"; do
598 [[ -e ${QT4_BINDIR}/${tool} ]] || continue
599 ln -s "${QT4_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
600 done
601
602 popd >/dev/null || die
603 }
604
605 # @FUNCTION: qt4_qmake
606 # @INTERNAL
607 # @DESCRIPTION:
608 # Helper function that runs qmake in the current target subdir.
609 # Intended to be called by qt4_foreach_target_subdir().
610 qt4_qmake() {
611 local projectdir=${PWD/#${BUILD_DIR}/${S}}
612
613 "${BUILD_DIR}"/bin/qmake \
614 CONFIG+=nostrip \
615 LIBS+=-L"${QT4_LIBDIR}" \
616 "${projectdir}" \
617 || die "qmake failed (${projectdir})"
618 }
619
620 # @FUNCTION: install_qconfigs
621 # @INTERNAL
622 # @DESCRIPTION:
623 # Install gentoo-specific mkspecs configurations.
624 install_qconfigs() {
625 local x
626 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
627 for x in QCONFIG_ADD QCONFIG_REMOVE; do
628 [[ -n ${!x} ]] && echo ${x}=${!x} >> "${BUILD_DIR}"/${PN}-qconfig.pri
629 done
630 insinto ${QT4_DATADIR#${EPREFIX}}/mkspecs/gentoo
631 doins "${BUILD_DIR}"/${PN}-qconfig.pri
632 fi
633
634 if [[ -n ${QCONFIG_DEFINE} ]]; then
635 for x in ${QCONFIG_DEFINE}; do
636 echo "#define ${x}" >> "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
637 done
638 insinto ${QT4_HEADERDIR#${EPREFIX}}/Gentoo
639 doins "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
640 fi
641 }
642
643 # @FUNCTION: generate_qconfigs
644 # @INTERNAL
645 # @DESCRIPTION:
646 # Generates gentoo-specific qconfig.{h,pri}.
647 generate_qconfigs() {
648 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${PN} == qtcore ]]; then
649 local x qconfig_add qconfig_remove qconfig_new
650 for x in "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
651 [[ -f ${x} ]] || continue
652 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
653 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
654 done
655
656 # these error checks do not use die because dying in pkg_post{inst,rm}
657 # just makes things worse.
658 if [[ -e "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
659 # start with the qconfig.pri that qtcore installed
660 if ! cp "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri \
661 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
662 eerror "cp qconfig failed."
663 return 1
664 fi
665
666 # generate list of QT_CONFIG entries from the existing list
667 # including qconfig_add and excluding qconfig_remove
668 for x in $(sed -n 's/^QT_CONFIG +=//p' \
669 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
670 has ${x} ${qconfig_remove} || qconfig_new+=" ${x}"
671 done
672
673 # replace the existing QT_CONFIG list with qconfig_new
674 if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
675 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
676 eerror "Sed for QT_CONFIG failed"
677 return 1
678 fi
679
680 # create Gentoo/qconfig.h
681 if [[ ! -e ${ROOT}${QT4_HEADERDIR}/Gentoo ]]; then
682 if ! mkdir -p "${ROOT}${QT4_HEADERDIR}"/Gentoo; then
683 eerror "mkdir ${QT4_HEADERDIR}/Gentoo failed"
684 return 1
685 fi
686 fi
687 : > "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
688 for x in "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
689 [[ -f ${x} ]] || continue
690 cat "${x}" >> "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
691 done
692 else
693 rm -f "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri
694 rm -f "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
695 rmdir "${ROOT}${QT4_DATADIR}"/mkspecs \
696 "${ROOT}${QT4_DATADIR}" \
697 "${ROOT}${QT4_HEADERDIR}"/Gentoo \
698 "${ROOT}${QT4_HEADERDIR}" 2>/dev/null
699 fi
700 fi
701 }
702
703 # @FUNCTION: fix_library_files
704 # @INTERNAL
705 # @DESCRIPTION:
706 # Fixes the paths in *.prl and *.pc, as they are wrong due to sandbox, and
707 # moves the *.pc files into the pkgconfig directory.
708 fix_library_files() {
709 local libfile
710 for libfile in "${D}"/${QT4_LIBDIR}/{*.prl,pkgconfig/*.pc}; do
711 if [[ -e ${libfile} ]]; then
712 sed -i -e "s:${S}/lib:${QT4_LIBDIR}:g" ${libfile} || die "sed on ${libfile} failed"
713 fi
714 done
715
716 # pkgconfig files refer to WORKDIR/bin as the moc and uic locations
717 for libfile in "${D}"/${QT4_LIBDIR}/pkgconfig/*.pc; do
718 if [[ -e ${libfile} ]]; then
719 sed -i -e "s:${S}/bin:${QT4_BINDIR}:g" ${libfile} || die "sed on ${libfile} failed"
720
721 # Move .pc files into the pkgconfig directory
722 dodir ${QT4_PCDIR#${EPREFIX}}
723 mv ${libfile} "${D}"/${QT4_PCDIR}/ || die "moving ${libfile} to ${D}/${QT4_PCDIR}/ failed"
724 fi
725 done
726
727 # Don't install an empty directory
728 rmdir "${D}"/${QT4_LIBDIR}/pkgconfig
729 }
730
731 # @FUNCTION: fix_includes
732 # @DESCRIPTION:
733 # For MacOS X we need to add some symlinks when frameworks are
734 # being used, to avoid complications with some more or less stupid packages.
735 fix_includes() {
736 if use_if_iuse aqua && [[ ${CHOST##*-darwin} -ge 9 ]]; then
737 local frw dest f h rdir
738 # Some packages tend to include <Qt/...>
739 dodir "${QT4_HEADERDIR#${EPREFIX}}"/Qt
740
741 # Fake normal headers when frameworks are installed... eases life later
742 # on, make sure we use relative links though, as some ebuilds assume
743 # these dirs exist in src_install to add additional files
744 f=${QT4_HEADERDIR}
745 h=${QT4_LIBDIR}
746 while [[ -n ${f} && ${f%%/*} == ${h%%/*} ]] ; do
747 f=${f#*/}
748 h=${h#*/}
749 done
750 rdir=${h}
751 f="../"
752 while [[ ${h} == */* ]] ; do
753 f="${f}../"
754 h=${h#*/}
755 done
756 rdir="${f}${rdir}"
757
758 for frw in "${D}${QT4_LIBDIR}"/*.framework; do
759 [[ -e "${frw}"/Headers ]] || continue
760 f=$(basename ${frw})
761 dest="${QT4_HEADERDIR#${EPREFIX}}"/${f%.framework}
762 dosym "${rdir}"/${f}/Headers "${dest}"
763
764 # Link normal headers as well.
765 for hdr in "${D}/${QT4_LIBDIR}/${f}"/Headers/*; do
766 h=$(basename ${hdr})
767 dosym "../${rdir}"/${f}/Headers/${h} \
768 "${QT4_HEADERDIR#${EPREFIX}}"/Qt/${h}
769 done
770 done
771 fi
772 }
773
774 # @FUNCTION: qt4_get_mkspec
775 # @INTERNAL
776 # @DESCRIPTION:
777 # Returns the right mkspec for the current CHOST/CXX combination.
778 qt4_get_mkspec() {
779 local spec=
780
781 case ${CHOST} in
782 *-linux*)
783 spec=linux ;;
784 *-darwin*)
785 use_if_iuse aqua &&
786 spec=macx || # mac with carbon/cocoa
787 spec=darwin ;; # darwin/mac with X11
788 *-freebsd*|*-dragonfly*)
789 spec=freebsd ;;
790 *-netbsd*)
791 spec=netbsd ;;
792 *-openbsd*)
793 spec=openbsd ;;
794 *-aix*)
795 spec=aix ;;
796 hppa*-hpux*)
797 spec=hpux ;;
798 ia64*-hpux*)
799 spec=hpuxi ;;
800 *-solaris*)
801 spec=solaris ;;
802 *)
803 die "qt4-build-multilib.eclass: unsupported CHOST '${CHOST}'" ;;
804 esac
805
806 case $(tc-getCXX) in
807 *g++*)
808 spec+=-g++ ;;
809 *clang*)
810 if [[ -d ${S}/mkspecs/unsupported/${spec}-clang ]]; then
811 spec=unsupported/${spec}-clang
812 else
813 ewarn "${spec}-clang mkspec does not exist, falling back to ${spec}-g++"
814 spec+=-g++
815 fi ;;
816 *icpc*)
817 if [[ -d ${S}/mkspecs/${spec}-icc ]]; then
818 spec+=-icc
819 else
820 ewarn "${spec}-icc mkspec does not exist, falling back to ${spec}-g++"
821 spec+=-g++
822 fi ;;
823 *)
824 die "qt4-build-multilib.eclass: unsupported compiler '$(tc-getCXX)'" ;;
825 esac
826
827 # Add -64 for 64-bit prefix profiles
828 if use amd64-linux || use ia64-linux || use ppc64-linux ||
829 use x64-macos ||
830 use sparc64-freebsd || use x64-freebsd || use x64-openbsd ||
831 use ia64-hpux ||
832 use sparc64-solaris || use x64-solaris
833 then
834 [[ -d ${S}/mkspecs/${spec}-64 ]] && spec+=-64
835 fi
836
837 echo ${spec}
838 }

  ViewVC Help
Powered by ViewVC 1.1.20