/[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.28 - (show annotations) (download)
Tue Jun 16 21:38:00 2015 UTC (3 years, 10 months ago) by pesa
Branch: MAIN
CVS Tags: HEAD
Changes since 1.27: +15 -11 lines
Minor changes to reduce diff with qt5-build.eclass

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

  ViewVC Help
Powered by ViewVC 1.1.20