/[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.24 - (show annotations) (download)
Sat Jun 13 22:13:24 2015 UTC (3 years, 11 months ago) by pesa
Branch: MAIN
Changes since 1.23: +10 -12 lines
sh is "supported", don't fallback to generic.
Also, don't die when tc-arch is unknown, the configure script can handle this internally.

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.23 2015/06/13 17:28:13 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 LGPL-3 GPL-3 ) FDL-1.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
112 ###### Phase functions ######
113
114 # @FUNCTION: qt4-build-multilib_src_unpack
115 # @DESCRIPTION:
116 # Unpacks the sources.
117 qt4-build-multilib_src_unpack() {
118 if [[ $(gcc-major-version) -lt 4 ]] || [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 4 ]]; then
119 ewarn
120 ewarn "Using a GCC version lower than 4.4 is not supported."
121 ewarn
122 fi
123
124 if [[ ${PN} == qtwebkit ]]; then
125 eshopts_push -s extglob
126 if is-flagq '-g?(gdb)?([1-9])'; then
127 ewarn
128 ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
129 ewarn "You may experience really long compilation times and/or increased memory usage."
130 ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
131 ewarn "For more info check out https://bugs.gentoo.org/307861"
132 ewarn
133 fi
134 eshopts_pop
135 fi
136
137 case ${QT4_BUILD_TYPE} in
138 live) git-r3_src_unpack ;;
139 release) default ;;
140 esac
141 }
142
143 # @FUNCTION: qt4-build-multilib_src_prepare
144 # @DESCRIPTION:
145 # Prepare the sources before the configure phase. Strip CFLAGS if necessary, and fix
146 # the build system in order to respect CFLAGS/CXXFLAGS/LDFLAGS specified in make.conf.
147 qt4-build-multilib_src_prepare() {
148 if [[ ${PN} != qtcore ]]; then
149 # avoid unnecessary qmake recompilations
150 sed -i -e 's/^if true;/if false;/' configure \
151 || die "sed failed (skip qmake bootstrap)"
152 fi
153
154 # skip X11 tests in non-gui packages to avoid spurious dependencies
155 if has ${PN} qtbearer qtcore qtdbus qtscript qtsql qttest qttranslations qtxmlpatterns; then
156 sed -i -e '/^if.*PLATFORM_X11.*CFG_GUI/,/^fi$/d' configure \
157 || die "sed failed (skip X11 tests)"
158 fi
159
160 if [[ ${PN} == qtcore ]]; then
161 # Bug 373061
162 # qmake bus errors with -O2 or -O3 but -O1 works
163 if [[ ${CHOST} == *86*-apple-darwin* ]]; then
164 replace-flags -O[23] -O1
165 fi
166
167 # Bug 503500
168 # undefined reference with -Os and --as-needed
169 if use x86 || use_if_iuse abi_x86_32; then
170 replace-flags -Os -O2
171 fi
172 fi
173
174 if [[ ${PN} == qtdeclarative ]]; then
175 # Bug 551560
176 # gcc-4.8 ICE with -Os, fixed in 4.9
177 if use x86 && [[ $(gcc-version) == 4.8 ]]; then
178 replace-flags -Os -O2
179 fi
180 fi
181
182 if [[ ${PN} == qtwebkit ]]; then
183 # Bug 550780
184 # various ICEs with graphite-related flags, gcc-5 works
185 if [[ $(gcc-major-version) -lt 5 ]]; then
186 filter-flags -fgraphite-identity -floop-strip-mine
187 fi
188 fi
189
190 # Bug 261632
191 if use ppc64; then
192 append-flags -mminimal-toc
193 fi
194
195 # Read also AR from the environment
196 sed -i -e 's/^SYSTEM_VARIABLES="/&AR /' \
197 configure || die "sed SYSTEM_VARIABLES failed"
198
199 # Reset QMAKE_*FLAGS_{RELEASE,DEBUG} variables,
200 # or they will override the user's flags (via .qmake.cache)
201 sed -i -e '/^SYSTEM_VARIABLES=/ i \
202 QMakeVar set QMAKE_CFLAGS_RELEASE\
203 QMakeVar set QMAKE_CFLAGS_DEBUG\
204 QMakeVar set QMAKE_CXXFLAGS_RELEASE\
205 QMakeVar set QMAKE_CXXFLAGS_DEBUG\
206 QMakeVar set QMAKE_LFLAGS_RELEASE\
207 QMakeVar set QMAKE_LFLAGS_DEBUG\n' \
208 configure || die "sed QMAKE_*FLAGS_{RELEASE,DEBUG} failed"
209
210 # Drop -nocache from qmake invocation in all configure tests, to ensure that the
211 # correct toolchain and build flags are picked up from config.tests/.qmake.cache
212 find config.tests/unix -name '*.test' -type f -print0 | xargs -0 \
213 sed -i -e '/bin\/qmake/s/ -nocache//' || die "sed -nocache failed"
214
215 # compile.test needs additional patching so that it doesn't create another cache file
216 # inside the test subdir, which would incorrectly override config.tests/.qmake.cache
217 sed -i -e '/echo.*QT_BUILD_TREE.*\.qmake\.cache/d' \
218 -e '/bin\/qmake/s/ "$SRCDIR/ "QT_BUILD_TREE=$OUTDIR"&/' \
219 config.tests/unix/compile.test || die "sed compile.test failed"
220
221 # Delete references to the obsolete /usr/X11R6 directory
222 # On prefix, this also prevents looking at non-prefix stuff
223 sed -i -re '/^QMAKE_(LIB|INC)DIR(_X11|_OPENGL|)\s+/ s/=.*/=/' \
224 mkspecs/common/linux.conf \
225 mkspecs/$(qt4_get_mkspec)/qmake.conf \
226 || die "sed QMAKE_(LIB|INC)DIR failed"
227
228 if use_if_iuse aqua; then
229 sed -i \
230 -e '/^CONFIG/s:app_bundle::' \
231 -e '/^CONFIG/s:plugin_no_soname:plugin_with_soname absolute_library_soname:' \
232 mkspecs/$(qt4_get_mkspec)/qmake.conf \
233 || die "sed failed (aqua)"
234
235 # we are crazy and build cocoa + qt3support
236 if { ! in_iuse qt3support || use qt3support; } && [[ ${CHOST##*-darwin} -ge 9 ]]; then
237 sed -i -e "/case \"\$PLATFORM,\$CFG_MAC_COCOA\" in/,/;;/ s|CFG_QT3SUPPORT=\"no\"|CFG_QT3SUPPORT=\"yes\"|" \
238 configure || die "sed failed (cocoa + qt3support)"
239 fi
240 fi
241
242 if [[ ${CHOST} == *-darwin* ]]; then
243 # Set FLAGS and remove -arch, since our gcc-apple is multilib crippled (by design)
244 sed -i \
245 -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
246 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
247 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=-headerpad_max_install_names ${LDFLAGS}:" \
248 -e "s:-arch\s\w*::g" \
249 mkspecs/common/g++-macx.conf \
250 || die "sed g++-macx.conf failed"
251
252 # Fix configure's -arch settings that appear in qmake/Makefile and also
253 # fix arch handling (automagically duplicates our -arch arg and breaks
254 # pch). Additionally disable Xarch support.
255 sed -i \
256 -e "s:-arch i386::" \
257 -e "s:-arch ppc::" \
258 -e "s:-arch x86_64::" \
259 -e "s:-arch ppc64::" \
260 -e "s:-arch \$i::" \
261 -e "/if \[ ! -z \"\$NATIVE_64_ARCH\" \]; then/,/fi/ d" \
262 -e "s:CFG_MAC_XARCH=yes:CFG_MAC_XARCH=no:g" \
263 -e "s:-Xarch_x86_64::g" \
264 -e "s:-Xarch_ppc64::g" \
265 configure mkspecs/common/gcc-base-macx.conf mkspecs/common/g++-macx.conf \
266 || die "sed -arch/-Xarch failed"
267
268 # On Snow Leopard don't fall back to 10.5 deployment target.
269 if [[ ${CHOST} == *-apple-darwin10 ]]; then
270 sed -i \
271 -e "s:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET.*:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.6:g" \
272 -e "s:-mmacosx-version-min=10.[0-9]:-mmacosx-version-min=10.6:g" \
273 configure mkspecs/common/g++-macx.conf \
274 || die "sed deployment target failed"
275 fi
276 fi
277
278 if [[ ${CHOST} == *-solaris* ]]; then
279 sed -i -e '/^QMAKE_LFLAGS_THREAD/a QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list,' \
280 mkspecs/$(qt4_get_mkspec)/qmake.conf || die
281 fi
282
283 # apply patches
284 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
285 epatch_user
286 }
287
288 qt4_multilib_src_configure() {
289 qt4_prepare_env
290
291 qt4_symlink_tools_to_build_dir
292
293 # toolchain setup ('local -x' because of bug 532510)
294 local -x \
295 AR="$(tc-getAR) cqs" \
296 CC=$(tc-getCC) \
297 CXX=$(tc-getCXX) \
298 LD=$(tc-getCXX) \
299 OBJCOPY=$(tc-getOBJCOPY) \
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 # verbosity of the configure and build phases
383 -verbose $(${QT4_VERBOSE_BUILD} || echo -silent)
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 # remove .la files since we are building only shared libraries
514 prune_libtool_files
515 }
516
517 # @FUNCTION: qt4-build-multilib_pkg_postinst
518 # @DESCRIPTION:
519 # Regenerate configuration, plus throw a message about possible
520 # breakages and proposed solutions.
521 qt4-build-multilib_pkg_postinst() {
522 qt4_regenerate_global_qconfigs
523 }
524
525 # @FUNCTION: qt4-build-multilib_pkg_postrm
526 # @DESCRIPTION:
527 # Regenerate configuration when the package is completely removed.
528 qt4-build-multilib_pkg_postrm() {
529 qt4_regenerate_global_qconfigs
530 }
531
532
533 ###### Public helpers ######
534
535 # @FUNCTION: qt_use
536 # @USAGE: <flag> [feature] [enableval]
537 # @DESCRIPTION:
538 # <flag> is the name of a flag in IUSE.
539 #
540 # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
541 # otherwise. If [feature] is not specified, <flag> is used in its place.
542 # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
543 qt_use() {
544 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
545
546 usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
547 }
548
549 # @FUNCTION: qt_native_use
550 # @USAGE: <flag> [feature] [enableval]
551 # @DESCRIPTION:
552 # <flag> is the name of a flag in IUSE.
553 #
554 # Outputs "-${enableval}-${feature}" if <flag> is enabled and we are currently
555 # building for the native ABI, "-no-${feature}" otherwise. If [feature] is not
556 # specified, <flag> is used in its place. If [enableval] is not specified,
557 # the "-${enableval}" prefix is omitted.
558 qt_native_use() {
559 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
560
561 multilib_is_native_abi && qt_use "$@" || echo "-no-${2:-$1}"
562 }
563
564
565 ###### Internal functions ######
566
567 # @FUNCTION: qt4_prepare_env
568 # @INTERNAL
569 # @DESCRIPTION:
570 # Prepares the environment for building Qt.
571 qt4_prepare_env() {
572 # setup installation directories
573 # note: keep paths in sync with qmake-utils.eclass
574 QT4_PREFIX=${EPREFIX}/usr
575 QT4_HEADERDIR=${QT4_PREFIX}/include/qt4
576 QT4_LIBDIR=${QT4_PREFIX}/$(get_libdir)/qt4
577 QT4_BINDIR=${QT4_LIBDIR}/bin
578 QT4_PLUGINDIR=${QT4_LIBDIR}/plugins
579 QT4_IMPORTDIR=${QT4_LIBDIR}/imports
580 QT4_DATADIR=${QT4_PREFIX}/share/qt4
581 QT4_DOCDIR=${QT4_PREFIX}/share/doc/qt-${PV}
582 QT4_TRANSLATIONDIR=${QT4_DATADIR}/translations
583 QT4_EXAMPLESDIR=${QT4_DATADIR}/examples
584 QT4_DEMOSDIR=${QT4_DATADIR}/demos
585 QT4_SYSCONFDIR=${EPREFIX}/etc/qt4
586 QMAKE_LIBDIR_QT=${QT4_LIBDIR}
587
588 export XDG_CONFIG_HOME="${T}"
589 }
590
591 # @FUNCTION: qt4_foreach_target_subdir
592 # @INTERNAL
593 # @DESCRIPTION:
594 # Executes the given command inside each directory listed in QT4_TARGET_DIRECTORIES.
595 qt4_foreach_target_subdir() {
596 local subdir
597 for subdir in ${QT4_TARGET_DIRECTORIES}; do
598 mkdir -p "${subdir}" || die
599 pushd "${subdir}" >/dev/null || die
600
601 einfo "Running $* ${subdir:+in ${subdir}}"
602 "$@"
603
604 popd >/dev/null || die
605 done
606 }
607
608 # @FUNCTION: qt4_symlink_tools_to_build_dir
609 # @INTERNAL
610 # @DESCRIPTION:
611 # Symlinks qtcore tools to BUILD_DIR,
612 # so that they can be used when building other modules.
613 qt4_symlink_tools_to_build_dir() {
614 local tool= tools=()
615 if [[ ${PN} != qtcore ]]; then
616 tools+=(qmake moc rcc uic)
617 fi
618
619 mkdir -p "${BUILD_DIR}"/bin || die
620 pushd "${BUILD_DIR}"/bin >/dev/null || die
621
622 for tool in "${tools[@]}"; do
623 [[ -e ${QT4_BINDIR}/${tool} ]] || continue
624 ln -s "${QT4_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
625 done
626
627 popd >/dev/null || die
628 }
629
630 # @FUNCTION: qt4_qmake
631 # @INTERNAL
632 # @DESCRIPTION:
633 # Helper function that runs qmake in the current target subdir.
634 # Intended to be called by qt4_foreach_target_subdir().
635 qt4_qmake() {
636 local projectdir=${PWD/#${BUILD_DIR}/${S}}
637
638 "${BUILD_DIR}"/bin/qmake \
639 CONFIG+=nostrip \
640 LIBS+=-L"${QT4_LIBDIR}" \
641 "${projectdir}" \
642 || die "qmake failed (${projectdir})"
643 }
644
645 # @FUNCTION: qt4_install_module_qconfigs
646 # @INTERNAL
647 # @DESCRIPTION:
648 # Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
649 qt4_install_module_qconfigs() {
650 local x
651 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
652 for x in QCONFIG_ADD QCONFIG_REMOVE; do
653 [[ -n ${!x} ]] && echo ${x}=${!x} >> "${BUILD_DIR}"/${PN}-qconfig.pri
654 done
655 insinto ${QT4_DATADIR#${EPREFIX}}/mkspecs/gentoo
656 doins "${BUILD_DIR}"/${PN}-qconfig.pri
657 fi
658
659 if [[ -n ${QCONFIG_DEFINE} ]]; then
660 for x in ${QCONFIG_DEFINE}; do
661 echo "#define ${x}" >> "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
662 done
663 insinto ${QT4_HEADERDIR#${EPREFIX}}/Gentoo
664 doins "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
665 fi
666 }
667
668 # @FUNCTION: qt4_regenerate_global_qconfigs
669 # @INTERNAL
670 # @DESCRIPTION:
671 # Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
672 # Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
673 qt4_regenerate_global_qconfigs() {
674 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${PN} == qtcore ]]; then
675 local x qconfig_add qconfig_remove qconfig_new
676 for x in "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
677 [[ -f ${x} ]] || continue
678 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
679 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
680 done
681
682 if [[ -e "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
683 # start with the qconfig.pri that qtcore installed
684 if ! cp "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri \
685 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
686 eerror "cp qconfig failed."
687 return 1
688 fi
689
690 # generate list of QT_CONFIG entries from the existing list
691 # including qconfig_add and excluding qconfig_remove
692 for x in $(sed -n 's/^QT_CONFIG +=//p' \
693 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
694 has ${x} ${qconfig_remove} || qconfig_new+=" ${x}"
695 done
696
697 # replace the existing QT_CONFIG list with qconfig_new
698 if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
699 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
700 eerror "Sed for QT_CONFIG failed"
701 return 1
702 fi
703
704 # create Gentoo/qconfig.h
705 if [[ ! -e ${ROOT}${QT4_HEADERDIR}/Gentoo ]]; then
706 if ! mkdir -p "${ROOT}${QT4_HEADERDIR}"/Gentoo; then
707 eerror "mkdir ${QT4_HEADERDIR}/Gentoo failed"
708 return 1
709 fi
710 fi
711 : > "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
712 for x in "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
713 [[ -f ${x} ]] || continue
714 cat "${x}" >> "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
715 done
716 else
717 rm -f "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri
718 rm -f "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
719 rmdir "${ROOT}${QT4_DATADIR}"/mkspecs \
720 "${ROOT}${QT4_DATADIR}" \
721 "${ROOT}${QT4_HEADERDIR}"/Gentoo \
722 "${ROOT}${QT4_HEADERDIR}" 2>/dev/null
723 fi
724 fi
725 }
726
727 # @FUNCTION: qt4_symlink_framework_headers
728 # @DESCRIPTION:
729 # On OS X we need to add some symlinks when frameworks are being
730 # used, to avoid complications with some more or less stupid packages.
731 qt4_symlink_framework_headers() {
732 if use_if_iuse aqua && [[ ${CHOST##*-darwin} -ge 9 ]]; then
733 local frw dest f h rdir
734 # Some packages tend to include <Qt/...>
735 dodir "${QT4_HEADERDIR#${EPREFIX}}"/Qt
736
737 # Fake normal headers when frameworks are installed... eases life later
738 # on, make sure we use relative links though, as some ebuilds assume
739 # these dirs exist in src_install to add additional files
740 f=${QT4_HEADERDIR}
741 h=${QT4_LIBDIR}
742 while [[ -n ${f} && ${f%%/*} == ${h%%/*} ]] ; do
743 f=${f#*/}
744 h=${h#*/}
745 done
746 rdir=${h}
747 f="../"
748 while [[ ${h} == */* ]] ; do
749 f="${f}../"
750 h=${h#*/}
751 done
752 rdir="${f}${rdir}"
753
754 for frw in "${D}${QT4_LIBDIR}"/*.framework; do
755 [[ -e "${frw}"/Headers ]] || continue
756 f=$(basename ${frw})
757 dest="${QT4_HEADERDIR#${EPREFIX}}"/${f%.framework}
758 dosym "${rdir}"/${f}/Headers "${dest}"
759
760 # Link normal headers as well.
761 for hdr in "${D}${QT4_LIBDIR}/${f}"/Headers/*; do
762 h=$(basename ${hdr})
763 dosym "../${rdir}"/${f}/Headers/${h} \
764 "${QT4_HEADERDIR#${EPREFIX}}"/Qt/${h}
765 done
766 done
767 fi
768 }
769
770 # @FUNCTION: qt4_get_mkspec
771 # @INTERNAL
772 # @DESCRIPTION:
773 # Returns the right mkspec for the current CHOST/CXX combination.
774 qt4_get_mkspec() {
775 local spec=
776
777 case ${CHOST} in
778 *-linux*)
779 spec=linux ;;
780 *-darwin*)
781 use_if_iuse aqua &&
782 spec=macx || # mac with carbon/cocoa
783 spec=darwin ;; # darwin/mac with X11
784 *-freebsd*|*-dragonfly*)
785 spec=freebsd ;;
786 *-netbsd*)
787 spec=netbsd ;;
788 *-openbsd*)
789 spec=openbsd ;;
790 *-aix*)
791 spec=aix ;;
792 hppa*-hpux*)
793 spec=hpux ;;
794 ia64*-hpux*)
795 spec=hpuxi ;;
796 *-solaris*)
797 spec=solaris ;;
798 *)
799 die "qt4-build-multilib.eclass: unsupported CHOST '${CHOST}'" ;;
800 esac
801
802 case $(tc-getCXX) in
803 *g++*)
804 spec+=-g++ ;;
805 *clang*)
806 if [[ -d ${S}/mkspecs/unsupported/${spec}-clang ]]; then
807 spec=unsupported/${spec}-clang
808 else
809 ewarn "${spec}-clang mkspec does not exist, falling back to ${spec}-g++"
810 spec+=-g++
811 fi ;;
812 *icpc*)
813 if [[ -d ${S}/mkspecs/${spec}-icc ]]; then
814 spec+=-icc
815 else
816 ewarn "${spec}-icc mkspec does not exist, falling back to ${spec}-g++"
817 spec+=-g++
818 fi ;;
819 *)
820 die "qt4-build-multilib.eclass: unsupported compiler '$(tc-getCXX)'" ;;
821 esac
822
823 # Add -64 for 64-bit prefix profiles
824 if use amd64-linux || use ia64-linux || use ppc64-linux ||
825 use x64-macos ||
826 use sparc64-freebsd || use x64-freebsd || use x64-openbsd ||
827 use ia64-hpux ||
828 use sparc64-solaris || use x64-solaris
829 then
830 [[ -d ${S}/mkspecs/${spec}-64 ]] && spec+=-64
831 fi
832
833 echo ${spec}
834 }

  ViewVC Help
Powered by ViewVC 1.1.20