1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: qt4-build-multilib.eclass
9 # Davide Pesavento <pesa@gentoo.org>
10 # @BLURB: Eclass for Qt4 split ebuilds with multilib support.
12 # This eclass contains various functions that are used when building Qt4.
17 *) die "qt4-build-multilib.eclass: unsupported EAPI=${EAPI:-0}" ;;
20 inherit eutils flag-o-matic multilib multilib-minimal toolchain-funcs
22 HOMEPAGE="https://www.qt.io/"
23 LICENSE="|| ( LGPL-2.1 LGPL-3 GPL-3 ) FDL-1.3"
30 EGIT_BRANCH=${PV%.9999}
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"
42 "git://code.qt.io/qt/qt.git"
43 "https://code.qt.io/git/qt/qt.git"
44 "https://github.com/qtproject/qt.git"
46 [[ ${QT4_BUILD_TYPE} == live ]] && inherit git-r3
48 if [[ ${PN} != qttranslations ]]; then
50 [[ ${PN} != qtxmlpatterns ]] && IUSE+=" +exceptions"
55 virtual/pkgconfig[${MULTILIB_USEDEP}]
59 abi_x86_32? ( !app-emulation/emul-linux-x86-qtlibs[-abi_x86_32(-)] )
63 # src_{configure,compile,test,install} are inherited from multilib-minimal
64 EXPORT_FUNCTIONS src_unpack src_prepare pkg_postinst pkg_postrm
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; }
73 # @ECLASS-VARIABLE: PATCHES
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.
83 # "${FILESDIR}/mypatch.patch"
84 # "${FILESDIR}/mypatch2.patch"
88 # @ECLASS-VARIABLE: QT4_TARGET_DIRECTORIES
91 # Space-separated list of directories that will be configured,
92 # compiled, and installed. All paths must be relative to ${S}.
94 # @ECLASS-VARIABLE: QCONFIG_ADD
97 # List of options that must be added to QT_CONFIG in qconfig.pri
99 # @ECLASS-VARIABLE: QCONFIG_REMOVE
102 # List of options that must be removed from QT_CONFIG in qconfig.pri
104 # @ECLASS-VARIABLE: QCONFIG_DEFINE
107 # List of macros that must be defined in QtCore/qconfig.h
110 ###### Phase functions ######
112 # @FUNCTION: qt4-build-multilib_src_unpack
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
118 ewarn "Using a GCC version lower than 4.4 is not supported."
122 if [[ ${PN} == qtwebkit ]]; then
123 eshopts_push -s extglob
124 if is-flagq '-g?(gdb)?([1-9])'; then
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"
135 case ${QT4_BUILD_TYPE} in
136 live) git-r3_src_unpack ;;
141 # @FUNCTION: qt4-build-multilib_src_prepare
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)"
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)"
158 if [[ ${PN} == qtcore ]]; then
160 # qmake bus errors with -O2 or -O3 but -O1 works
161 if [[ ${CHOST} == *86*-apple-darwin* ]]; then
162 replace-flags -O[23] -O1
166 # undefined reference with -Os and --as-needed
167 if use x86 || use_if_iuse abi_x86_32; then
168 replace-flags -Os -O2
172 if [[ ${PN} == qtdeclarative ]]; then
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
180 if [[ ${PN} == qtwebkit ]]; then
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
190 append-flags -mminimal-toc
193 # Teach configure about gcc-6 and later
194 sed -i -e 's:5\*|:[5-9]*|:' \
195 configure || die "sed gcc version failed"
197 # Read also AR from the environment
198 sed -i -e 's/^SYSTEM_VARIABLES="/&AR /' \
199 configure || die "sed SYSTEM_VARIABLES failed"
201 # Reset QMAKE_*FLAGS_{RELEASE,DEBUG} variables,
202 # or they will override the user's flags (via .qmake.cache)
203 sed -i -e '/^SYSTEM_VARIABLES=/ i \
204 QMakeVar set QMAKE_CFLAGS_RELEASE\
205 QMakeVar set QMAKE_CFLAGS_DEBUG\
206 QMakeVar set QMAKE_CXXFLAGS_RELEASE\
207 QMakeVar set QMAKE_CXXFLAGS_DEBUG\
208 QMakeVar set QMAKE_LFLAGS_RELEASE\
209 QMakeVar set QMAKE_LFLAGS_DEBUG\n' \
210 configure || die "sed QMAKE_*FLAGS_{RELEASE,DEBUG} failed"
212 # Drop -nocache from qmake invocation in all configure tests, to ensure that the
213 # correct toolchain and build flags are picked up from config.tests/.qmake.cache
214 find config.tests/unix -name '*.test' -type f -execdir \
215 sed -i -e '/bin\/qmake/s/-nocache//' '{}' + || die "sed -nocache failed"
217 # compile.test needs additional patching so that it doesn't create another cache file
218 # inside the test subdir, which would incorrectly override config.tests/.qmake.cache
219 sed -i -e '/echo.*QT_BUILD_TREE.*\.qmake\.cache/d' \
220 -e '/bin\/qmake/s/ "$SRCDIR/ "QT_BUILD_TREE=$OUTDIR"&/' \
221 config.tests/unix/compile.test || die "sed compile.test failed"
223 # Delete references to the obsolete /usr/X11R6 directory
224 # On prefix, this also prevents looking at non-prefix stuff
225 sed -i -re '/^QMAKE_(LIB|INC)DIR(_X11|_OPENGL|)\s+/ s/=.*/=/' \
226 mkspecs/common/linux.conf \
227 mkspecs/$(qt4_get_mkspec)/qmake.conf \
228 || die "sed QMAKE_(LIB|INC)DIR failed"
230 if use_if_iuse aqua; then
232 -e '/^CONFIG/s:app_bundle::' \
233 -e '/^CONFIG/s:plugin_no_soname:plugin_with_soname absolute_library_soname:' \
234 mkspecs/$(qt4_get_mkspec)/qmake.conf \
235 || die "sed failed (aqua)"
237 # we are crazy and build cocoa + qt3support
238 if { ! in_iuse qt3support || use qt3support; } && [[ ${CHOST##*-darwin} -ge 9 ]]; then
239 sed -i -e "/case \"\$PLATFORM,\$CFG_MAC_COCOA\" in/,/;;/ s|CFG_QT3SUPPORT=\"no\"|CFG_QT3SUPPORT=\"yes\"|" \
240 configure || die "sed failed (cocoa + qt3support)"
244 if [[ ${CHOST} == *-darwin* ]]; then
245 # Set FLAGS and remove -arch, since our gcc-apple is multilib crippled (by design)
247 -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
248 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
249 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=-headerpad_max_install_names ${LDFLAGS}:" \
250 -e "s:-arch\s\w*::g" \
251 mkspecs/common/g++-macx.conf \
252 || die "sed g++-macx.conf failed"
254 # Fix configure's -arch settings that appear in qmake/Makefile and also
255 # fix arch handling (automagically duplicates our -arch arg and breaks
256 # pch). Additionally disable Xarch support.
258 -e "s:-arch i386::" \
260 -e "s:-arch x86_64::" \
261 -e "s:-arch ppc64::" \
263 -e "/if \[ ! -z \"\$NATIVE_64_ARCH\" \]; then/,/fi/ d" \
264 -e "s:CFG_MAC_XARCH=yes:CFG_MAC_XARCH=no:g" \
265 -e "s:-Xarch_x86_64::g" \
266 -e "s:-Xarch_ppc64::g" \
267 configure mkspecs/common/gcc-base-macx.conf mkspecs/common/g++-macx.conf \
268 || die "sed -arch/-Xarch failed"
270 # On Snow Leopard don't fall back to 10.5 deployment target.
271 if [[ ${CHOST} == *-apple-darwin10 ]]; then
273 -e "s:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET.*:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.6:g" \
274 -e "s:-mmacosx-version-min=10.[0-9]:-mmacosx-version-min=10.6:g" \
275 configure mkspecs/common/g++-macx.conf \
276 || die "sed deployment target failed"
280 if [[ ${CHOST} == *-solaris* ]]; then
281 sed -i -e '/^QMAKE_LFLAGS_THREAD/a QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list,' \
282 mkspecs/$(qt4_get_mkspec)/qmake.conf || die
286 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
290 qt4_multilib_src_configure() {
293 qt4_symlink_tools_to_build_dir
295 # toolchain setup ('local -x' because of bug 532510)
297 AR="$(tc-getAR) cqs" \
301 MAKEFLAGS=${MAKEOPTS} \
302 OBJCOPY=$(tc-getOBJCOPY) \
303 OBJDUMP=$(tc-getOBJDUMP) \
306 # convert tc-arch to the values supported by Qt
307 local arch=$(tc-arch)
309 amd64|x64-*) arch=x86_64 ;;
310 arm64|hppa) arch=generic ;;
311 ppc*-macos) arch=ppc ;;
312 ppc*) arch=powerpc ;;
313 sparc*) arch=sparc ;;
314 x86-macos) arch=x86 ;;
318 # configure arguments
321 -prefix "${QT4_PREFIX}"
322 -bindir "${QT4_BINDIR}"
323 -libdir "${QT4_LIBDIR}"
324 -docdir "${QT4_DOCDIR}"
325 -headerdir "${QT4_HEADERDIR}"
326 -plugindir "${QT4_PLUGINDIR}"
327 -importdir "${QT4_IMPORTDIR}"
328 -datadir "${QT4_DATADIR}"
329 -translationdir "${QT4_TRANSLATIONDIR}"
330 -sysconfdir "${QT4_SYSCONFDIR}"
331 -examplesdir "${QT4_EXAMPLESDIR}"
332 -demosdir "${QT4_DEMOSDIR}"
335 $(use_if_iuse debug && echo -debug || echo -release)
336 -no-separate-debug-info
339 -opensource -confirm-license
341 # build shared libraries
344 # skip recursive processing of .pro files at the end of configure
345 # (we run qmake by ourselves), thus saving quite a bit of time
348 # always enable large file support
351 # exceptions USE flag
352 $(in_iuse exceptions && qt_use exceptions || echo -exceptions)
357 # architecture/platform (mkspec)
359 -platform $(qt4_get_mkspec)
361 # instruction set support
362 $(is-flagq -mno-mmx && echo -no-mmx)
363 $(is-flagq -mno-3dnow && echo -no-3dnow)
364 $(is-flagq -mno-sse && echo -no-sse)
365 $(is-flagq -mno-sse2 && echo -no-sse2)
366 $(is-flagq -mno-sse3 && echo -no-sse3)
367 $(is-flagq -mno-ssse3 && echo -no-ssse3)
368 $(is-flagq -mno-sse4.1 && echo -no-sse4.1)
369 $(is-flagq -mno-sse4.2 && echo -no-sse4.2)
370 $(is-flagq -mno-avx && echo -no-avx)
371 $(is-flagq -mfpu=* && ! is-flagq -mfpu=*neon* && echo -no-neon)
374 $([[ ${CHOST} == *86*-apple-darwin* ]] && echo -no-ssse3)
376 # prefer system libraries
379 # exclude examples and demos from default build
383 # disable rpath on non-prefix (bugs 380415 and 417169)
384 $(usex prefix '' -no-rpath)
386 # print verbose information about each configure test
389 # precompiled headers don't work on hardened, where the flag is masked
390 $(in_iuse pch && qt_use pch || echo -no-pch)
392 # enable linker optimizations to reduce relocations, except on Solaris
393 # where this flag seems to introduce major breakage to applications,
394 # mostly to be seen as a core dump with the message:
395 # "QPixmap: Must construct a QApplication before a QPaintDevice"
396 $([[ ${CHOST} != *-solaris* ]] && echo -reduce-relocations)
399 if use_if_iuse aqua; then
400 if [[ ${CHOST##*-darwin} -ge 9 ]]; then
402 # on (snow) leopard use the new (frameworked) cocoa code
404 # add hint for the framework location
408 conf+=(-no-framework)
413 # module-specific options
417 einfo "Configuring with: ${conf[@]}"
418 "${S}"/configure "${conf[@]}" || die "configure failed"
420 # configure is stupid and assigns QMAKE_LFLAGS twice,
421 # thus the previous -rpath-link flag gets overwritten
422 # and some packages (e.g. qthelp) fail to link
423 sed -i -e '/^QMAKE_LFLAGS =/ s:$: $$QMAKE_LFLAGS:' \
424 .qmake.cache || die "sed .qmake.cache failed"
427 qt4_foreach_target_subdir qt4_qmake
430 qt4_multilib_src_compile() {
433 qt4_foreach_target_subdir emake
436 qt4_multilib_src_test() {
439 qt4_foreach_target_subdir emake -j1 check
442 qt4_multilib_src_install() {
445 qt4_foreach_target_subdir emake INSTALL_ROOT="${D}" install
447 if [[ ${PN} == qtcore ]]; then
448 set -- emake INSTALL_ROOT="${D}" install_{mkspecs,qmake}
453 cat > "${T}/44qt4-${CHOST}" <<-_EOF_
454 LDPATH="${QT4_LIBDIR}"
456 doenvd "${T}/44qt4-${CHOST}"
458 # install qtchooser configuration file
459 cat > "${T}/qt4-${CHOST}.conf" <<-_EOF_
465 insinto /etc/xdg/qtchooser
466 doins "${T}/qt4-${CHOST}.conf"
469 if multilib_is_native_abi; then
470 # convenience symlinks
471 dosym qt4-"${CHOST}".conf /etc/xdg/qtchooser/4.conf
472 dosym qt4-"${CHOST}".conf /etc/xdg/qtchooser/qt4.conf
473 # TODO bug 522646: write an eselect module to manage default.conf
474 dosym qt4.conf /etc/xdg/qtchooser/default.conf
478 # move pkgconfig directory to the correct location
479 if [[ -d ${D}${QT4_LIBDIR}/pkgconfig ]]; then
480 mv "${D}${QT4_LIBDIR}"/pkgconfig "${ED}usr/$(get_libdir)" || die
483 qt4_install_module_qconfigs
484 qt4_symlink_framework_headers
487 qt4_multilib_src_install_all() {
488 if [[ ${PN} == qtcore ]]; then
489 # include gentoo-qconfig.h at the beginning of Qt{,Core}/qconfig.h
490 if use aqua && [[ ${CHOST#*-darwin} -ge 9 ]]; then
491 sed -i -e '1i #include <QtCore/Gentoo/gentoo-qconfig.h>\n' \
492 "${D}${QT4_LIBDIR}"/QtCore.framework/Headers/qconfig.h \
493 || die "sed failed (qconfig.h)"
494 dosym "${QT4_HEADERDIR#${EPREFIX}}"/Gentoo \
495 "${QT4_LIBDIR#${EPREFIX}}"/QtCore.framework/Headers/Gentoo
497 sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
498 "${D}${QT4_HEADERDIR}"/Qt{,Core}/qconfig.h \
499 || die "sed failed (qconfig.h)"
502 dodir "${QT4_DATADIR#${EPREFIX}}"/mkspecs/gentoo
503 mv "${D}${QT4_DATADIR}"/mkspecs/{qconfig.pri,gentoo/} || die
506 # install private headers of a few modules
507 if has ${PN} qtcore qtdeclarative qtgui qtscript; then
508 local moduledir=${PN#qt}
509 local modulename=Qt$(tr 'a-z' 'A-Z' <<< ${moduledir:0:1})${moduledir:1}
510 [[ ${moduledir} == core ]] && moduledir=corelib
512 einfo "Installing private headers into ${QT4_HEADERDIR}/${modulename}/private"
513 insinto "${QT4_HEADERDIR#${EPREFIX}}"/${modulename}/private
514 find "${S}"/src/${moduledir} -type f -name '*_p.h' -exec doins '{}' + || die
520 # @FUNCTION: qt4-build-multilib_pkg_postinst
522 # Regenerate configuration after installation or upgrade/downgrade.
523 qt4-build-multilib_pkg_postinst() {
524 qt4_regenerate_global_qconfigs
527 # @FUNCTION: qt4-build-multilib_pkg_postrm
529 # Regenerate configuration when a module is completely removed.
530 qt4-build-multilib_pkg_postrm() {
531 qt4_regenerate_global_qconfigs
535 ###### Public helpers ######
538 # @USAGE: <flag> [feature] [enableval]
540 # <flag> is the name of a flag in IUSE.
542 # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
543 # otherwise. If [feature] is not specified, <flag> is used in its place.
544 # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
546 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
548 usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
551 # @FUNCTION: qt_native_use
552 # @USAGE: <flag> [feature] [enableval]
554 # <flag> is the name of a flag in IUSE.
556 # Outputs "-${enableval}-${feature}" if <flag> is enabled and we are currently
557 # building for the native ABI, "-no-${feature}" otherwise. If [feature] is not
558 # specified, <flag> is used in its place. If [enableval] is not specified,
559 # the "-${enableval}" prefix is omitted.
561 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
563 multilib_is_native_abi && qt_use "$@" || echo "-no-${2:-$1}"
567 ###### Internal functions ######
569 # @FUNCTION: qt4_prepare_env
572 # Prepares the environment for building Qt.
574 # setup installation directories
575 # note: keep paths in sync with qmake-utils.eclass
576 QT4_PREFIX=${EPREFIX}/usr
577 QT4_HEADERDIR=${QT4_PREFIX}/include/qt4
578 QT4_LIBDIR=${QT4_PREFIX}/$(get_libdir)/qt4
579 QT4_BINDIR=${QT4_LIBDIR}/bin
580 QT4_PLUGINDIR=${QT4_LIBDIR}/plugins
581 QT4_IMPORTDIR=${QT4_LIBDIR}/imports
582 QT4_DATADIR=${QT4_PREFIX}/share/qt4
583 QT4_DOCDIR=${QT4_PREFIX}/share/doc/qt-${PV}
584 QT4_TRANSLATIONDIR=${QT4_DATADIR}/translations
585 QT4_EXAMPLESDIR=${QT4_DATADIR}/examples
586 QT4_DEMOSDIR=${QT4_DATADIR}/demos
587 QT4_SYSCONFDIR=${EPREFIX}/etc/qt4
588 QMAKE_LIBDIR_QT=${QT4_LIBDIR}
590 export XDG_CONFIG_HOME="${T}"
593 # @FUNCTION: qt4_foreach_target_subdir
596 # Executes the given command inside each directory listed in QT4_TARGET_DIRECTORIES.
597 qt4_foreach_target_subdir() {
599 for subdir in ${QT4_TARGET_DIRECTORIES}; do
600 mkdir -p "${subdir}" || die
601 pushd "${subdir}" >/dev/null || die
603 einfo "Running $* ${subdir:+in ${subdir}}"
607 popd >/dev/null || die
613 # @FUNCTION: qt4_symlink_tools_to_build_dir
616 # Symlinks qtcore tools to BUILD_DIR,
617 # so that they can be used when building other modules.
618 qt4_symlink_tools_to_build_dir() {
620 if [[ ${PN} != qtcore ]]; then
621 tools+=(qmake moc rcc uic)
624 mkdir -p "${BUILD_DIR}"/bin || die
625 pushd "${BUILD_DIR}"/bin >/dev/null || die
627 for tool in "${tools[@]}"; do
628 [[ -e ${QT4_BINDIR}/${tool} ]] || continue
629 ln -s "${QT4_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
632 popd >/dev/null || die
635 # @FUNCTION: qt4_qmake
638 # Helper function that runs qmake in the current target subdir.
639 # Intended to be called by qt4_foreach_target_subdir().
641 local projectdir=${PWD/#${BUILD_DIR}/${S}}
643 "${BUILD_DIR}"/bin/qmake \
646 LIBS+=-L"${QT4_LIBDIR}" \
647 "${myqmakeargs[@]}" \
648 || die "qmake failed (${projectdir#${S}/})"
651 # @FUNCTION: qt4_install_module_qconfigs
654 # Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
655 qt4_install_module_qconfigs() {
657 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
658 for x in QCONFIG_ADD QCONFIG_REMOVE; do
659 [[ -n ${!x} ]] && echo ${x}=${!x} >> "${BUILD_DIR}"/${PN}-qconfig.pri
661 insinto ${QT4_DATADIR#${EPREFIX}}/mkspecs/gentoo
662 doins "${BUILD_DIR}"/${PN}-qconfig.pri
665 if [[ -n ${QCONFIG_DEFINE} ]]; then
666 for x in ${QCONFIG_DEFINE}; do
667 echo "#define ${x}" >> "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
669 insinto ${QT4_HEADERDIR#${EPREFIX}}/Gentoo
670 doins "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
674 # @FUNCTION: qt4_regenerate_global_qconfigs
677 # Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
678 # Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
679 qt4_regenerate_global_qconfigs() {
680 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${PN} == qtcore ]]; then
681 local x qconfig_add qconfig_remove qconfig_new
682 for x in "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
683 [[ -f ${x} ]] || continue
684 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
685 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
688 if [[ -e "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
689 # start with the qconfig.pri that qtcore installed
690 if ! cp "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri \
691 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
692 eerror "cp qconfig failed."
696 # generate list of QT_CONFIG entries from the existing list
697 # including qconfig_add and excluding qconfig_remove
698 for x in $(sed -n 's/^QT_CONFIG +=//p' \
699 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
700 has ${x} ${qconfig_remove} || qconfig_new+=" ${x}"
703 # replace the existing QT_CONFIG list with qconfig_new
704 if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
705 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
706 eerror "Sed for QT_CONFIG failed"
710 # create Gentoo/qconfig.h
711 if [[ ! -e ${ROOT}${QT4_HEADERDIR}/Gentoo ]]; then
712 if ! mkdir -p "${ROOT}${QT4_HEADERDIR}"/Gentoo; then
713 eerror "mkdir ${QT4_HEADERDIR}/Gentoo failed"
717 : > "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
718 for x in "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
719 [[ -f ${x} ]] || continue
720 cat "${x}" >> "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
723 rm -f "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri
724 rm -f "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
725 rmdir "${ROOT}${QT4_DATADIR}"/mkspecs \
726 "${ROOT}${QT4_DATADIR}" \
727 "${ROOT}${QT4_HEADERDIR}"/Gentoo \
728 "${ROOT}${QT4_HEADERDIR}" 2>/dev/null
733 # @FUNCTION: qt4_symlink_framework_headers
735 # On OS X we need to add some symlinks when frameworks are being
736 # used, to avoid complications with some more or less stupid packages.
737 qt4_symlink_framework_headers() {
738 if use_if_iuse aqua && [[ ${CHOST##*-darwin} -ge 9 ]]; then
739 local frw dest f h rdir
740 # Some packages tend to include <Qt/...>
741 dodir "${QT4_HEADERDIR#${EPREFIX}}"/Qt
743 # Fake normal headers when frameworks are installed... eases life later
744 # on, make sure we use relative links though, as some ebuilds assume
745 # these dirs exist in src_install to add additional files
748 while [[ -n ${f} && ${f%%/*} == ${h%%/*} ]] ; do
754 while [[ ${h} == */* ]] ; do
760 for frw in "${D}${QT4_LIBDIR}"/*.framework; do
761 [[ -e "${frw}"/Headers ]] || continue
763 dest="${QT4_HEADERDIR#${EPREFIX}}"/${f%.framework}
764 dosym "${rdir}"/${f}/Headers "${dest}"
766 # Link normal headers as well.
767 for hdr in "${D}${QT4_LIBDIR}/${f}"/Headers/*; do
769 dosym "../${rdir}"/${f}/Headers/${h} \
770 "${QT4_HEADERDIR#${EPREFIX}}"/Qt/${h}
776 # @FUNCTION: qt4_get_mkspec
779 # Returns the right mkspec for the current CHOST/CXX combination.
788 spec=macx || # mac with carbon/cocoa
789 spec=darwin ;; # darwin/mac with X11
790 *-freebsd*|*-dragonfly*)
805 die "qt4-build-multilib.eclass: unsupported CHOST '${CHOST}'" ;;
812 if [[ -d ${S}/mkspecs/unsupported/${spec}-clang ]]; then
813 spec=unsupported/${spec}-clang
815 ewarn "${spec}-clang mkspec does not exist, falling back to ${spec}-g++"
819 if [[ -d ${S}/mkspecs/${spec}-icc ]]; then
822 ewarn "${spec}-icc mkspec does not exist, falling back to ${spec}-g++"
826 die "qt4-build-multilib.eclass: unsupported compiler '$(tc-getCXX)'" ;;
829 # Add -64 for 64-bit prefix profiles
830 if use amd64-linux || use ia64-linux || use ppc64-linux ||
832 use sparc64-freebsd || use x64-freebsd || use x64-openbsd ||
834 use sparc64-solaris || use x64-solaris
836 [[ -d ${S}/mkspecs/${spec}-64 ]] && spec+=-64