1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: qt4-build-multilib.eclass
7 # Qt herd <qt@gentoo.org>
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 # Read also AR from the environment
194 sed -i -e 's/^SYSTEM_VARIABLES="/&AR /' \
195 configure || die "sed SYSTEM_VARIABLES failed"
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"
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"
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"
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"
226 if use_if_iuse aqua; then
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)"
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)"
240 if [[ ${CHOST} == *-darwin* ]]; then
241 # Set FLAGS and remove -arch, since our gcc-apple is multilib crippled (by design)
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"
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.
254 -e "s:-arch i386::" \
256 -e "s:-arch x86_64::" \
257 -e "s:-arch ppc64::" \
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"
266 # On Snow Leopard don't fall back to 10.5 deployment target.
267 if [[ ${CHOST} == *-apple-darwin10 ]]; then
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"
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
282 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
286 qt4_multilib_src_configure() {
289 qt4_symlink_tools_to_build_dir
291 # toolchain setup ('local -x' because of bug 532510)
293 AR="$(tc-getAR) cqs" \
297 MAKEFLAGS=${MAKEOPTS} \
298 OBJCOPY=$(tc-getOBJCOPY) \
299 OBJDUMP=$(tc-getOBJDUMP) \
302 # convert tc-arch to the values supported by Qt
303 local arch=$(tc-arch)
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 ;;
314 # configure arguments
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}"
331 $(use_if_iuse debug && echo -debug || echo -release)
332 -no-separate-debug-info
335 -opensource -confirm-license
337 # build shared libraries
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
344 # always enable large file support
347 # exceptions USE flag
348 $(in_iuse exceptions && qt_use exceptions || echo -exceptions)
353 # architecture/platform (mkspec)
355 -platform $(qt4_get_mkspec)
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)
370 $([[ ${CHOST} == *86*-apple-darwin* ]] && echo -no-ssse3)
372 # prefer system libraries
375 # exclude examples and demos from default build
379 # disable rpath on non-prefix (bugs 380415 and 417169)
380 $(usex prefix '' -no-rpath)
382 # print verbose information about each configure test
385 # precompiled headers don't work on hardened, where the flag is masked
386 $(in_iuse pch && qt_use pch || echo -no-pch)
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)
395 if use_if_iuse aqua; then
396 if [[ ${CHOST##*-darwin} -ge 9 ]]; then
398 # on (snow) leopard use the new (frameworked) cocoa code
400 # add hint for the framework location
404 conf+=(-no-framework)
409 # module-specific options
413 einfo "Configuring with: ${conf[@]}"
414 "${S}"/configure "${conf[@]}" || die "configure failed"
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"
423 qt4_foreach_target_subdir qt4_qmake
426 qt4_multilib_src_compile() {
429 qt4_foreach_target_subdir emake
432 qt4_multilib_src_test() {
435 qt4_foreach_target_subdir emake -j1 check
438 qt4_multilib_src_install() {
441 qt4_foreach_target_subdir emake INSTALL_ROOT="${D}" install
443 if [[ ${PN} == qtcore ]]; then
444 set -- emake INSTALL_ROOT="${D}" install_{mkspecs,qmake}
449 cat > "${T}/44qt4-${CHOST}" <<-_EOF_
450 LDPATH="${QT4_LIBDIR}"
452 doenvd "${T}/44qt4-${CHOST}"
454 # install qtchooser configuration file
455 cat > "${T}/qt4-${CHOST}.conf" <<-_EOF_
461 insinto /etc/xdg/qtchooser
462 doins "${T}/qt4-${CHOST}.conf"
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
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
479 qt4_install_module_qconfigs
480 qt4_symlink_framework_headers
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
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)"
498 dodir "${QT4_DATADIR#${EPREFIX}}"/mkspecs/gentoo
499 mv "${D}${QT4_DATADIR}"/mkspecs/{qconfig.pri,gentoo/} || die
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
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
516 # @FUNCTION: qt4-build-multilib_pkg_postinst
518 # Regenerate configuration after installation or upgrade/downgrade.
519 qt4-build-multilib_pkg_postinst() {
520 qt4_regenerate_global_qconfigs
523 # @FUNCTION: qt4-build-multilib_pkg_postrm
525 # Regenerate configuration when a module is completely removed.
526 qt4-build-multilib_pkg_postrm() {
527 qt4_regenerate_global_qconfigs
531 ###### Public helpers ######
534 # @USAGE: <flag> [feature] [enableval]
536 # <flag> is the name of a flag in IUSE.
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.
542 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
544 usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
547 # @FUNCTION: qt_native_use
548 # @USAGE: <flag> [feature] [enableval]
550 # <flag> is the name of a flag in IUSE.
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.
557 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
559 multilib_is_native_abi && qt_use "$@" || echo "-no-${2:-$1}"
563 ###### Internal functions ######
565 # @FUNCTION: qt4_prepare_env
568 # Prepares the environment for building Qt.
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}
586 export XDG_CONFIG_HOME="${T}"
589 # @FUNCTION: qt4_foreach_target_subdir
592 # Executes the given command inside each directory listed in QT4_TARGET_DIRECTORIES.
593 qt4_foreach_target_subdir() {
595 for subdir in ${QT4_TARGET_DIRECTORIES}; do
596 mkdir -p "${subdir}" || die
597 pushd "${subdir}" >/dev/null || die
599 einfo "Running $* ${subdir:+in ${subdir}}"
603 popd >/dev/null || die
609 # @FUNCTION: qt4_symlink_tools_to_build_dir
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() {
616 if [[ ${PN} != qtcore ]]; then
617 tools+=(qmake moc rcc uic)
620 mkdir -p "${BUILD_DIR}"/bin || die
621 pushd "${BUILD_DIR}"/bin >/dev/null || die
623 for tool in "${tools[@]}"; do
624 [[ -e ${QT4_BINDIR}/${tool} ]] || continue
625 ln -s "${QT4_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
628 popd >/dev/null || die
631 # @FUNCTION: qt4_qmake
634 # Helper function that runs qmake in the current target subdir.
635 # Intended to be called by qt4_foreach_target_subdir().
637 local projectdir=${PWD/#${BUILD_DIR}/${S}}
639 "${BUILD_DIR}"/bin/qmake \
642 LIBS+=-L"${QT4_LIBDIR}" \
643 "${myqmakeargs[@]}" \
644 || die "qmake failed (${projectdir#${S}/})"
647 # @FUNCTION: qt4_install_module_qconfigs
650 # Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
651 qt4_install_module_qconfigs() {
653 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
654 for x in QCONFIG_ADD QCONFIG_REMOVE; do
655 [[ -n ${!x} ]] && echo ${x}=${!x} >> "${BUILD_DIR}"/${PN}-qconfig.pri
657 insinto ${QT4_DATADIR#${EPREFIX}}/mkspecs/gentoo
658 doins "${BUILD_DIR}"/${PN}-qconfig.pri
661 if [[ -n ${QCONFIG_DEFINE} ]]; then
662 for x in ${QCONFIG_DEFINE}; do
663 echo "#define ${x}" >> "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
665 insinto ${QT4_HEADERDIR#${EPREFIX}}/Gentoo
666 doins "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
670 # @FUNCTION: qt4_regenerate_global_qconfigs
673 # Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
674 # Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
675 qt4_regenerate_global_qconfigs() {
676 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${PN} == qtcore ]]; then
677 local x qconfig_add qconfig_remove qconfig_new
678 for x in "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
679 [[ -f ${x} ]] || continue
680 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
681 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
684 if [[ -e "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
685 # start with the qconfig.pri that qtcore installed
686 if ! cp "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri \
687 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
688 eerror "cp qconfig failed."
692 # generate list of QT_CONFIG entries from the existing list
693 # including qconfig_add and excluding qconfig_remove
694 for x in $(sed -n 's/^QT_CONFIG +=//p' \
695 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
696 has ${x} ${qconfig_remove} || qconfig_new+=" ${x}"
699 # replace the existing QT_CONFIG list with qconfig_new
700 if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
701 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
702 eerror "Sed for QT_CONFIG failed"
706 # create Gentoo/qconfig.h
707 if [[ ! -e ${ROOT}${QT4_HEADERDIR}/Gentoo ]]; then
708 if ! mkdir -p "${ROOT}${QT4_HEADERDIR}"/Gentoo; then
709 eerror "mkdir ${QT4_HEADERDIR}/Gentoo failed"
713 : > "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
714 for x in "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
715 [[ -f ${x} ]] || continue
716 cat "${x}" >> "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
719 rm -f "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri
720 rm -f "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
721 rmdir "${ROOT}${QT4_DATADIR}"/mkspecs \
722 "${ROOT}${QT4_DATADIR}" \
723 "${ROOT}${QT4_HEADERDIR}"/Gentoo \
724 "${ROOT}${QT4_HEADERDIR}" 2>/dev/null
729 # @FUNCTION: qt4_symlink_framework_headers
731 # On OS X we need to add some symlinks when frameworks are being
732 # used, to avoid complications with some more or less stupid packages.
733 qt4_symlink_framework_headers() {
734 if use_if_iuse aqua && [[ ${CHOST##*-darwin} -ge 9 ]]; then
735 local frw dest f h rdir
736 # Some packages tend to include <Qt/...>
737 dodir "${QT4_HEADERDIR#${EPREFIX}}"/Qt
739 # Fake normal headers when frameworks are installed... eases life later
740 # on, make sure we use relative links though, as some ebuilds assume
741 # these dirs exist in src_install to add additional files
744 while [[ -n ${f} && ${f%%/*} == ${h%%/*} ]] ; do
750 while [[ ${h} == */* ]] ; do
756 for frw in "${D}${QT4_LIBDIR}"/*.framework; do
757 [[ -e "${frw}"/Headers ]] || continue
759 dest="${QT4_HEADERDIR#${EPREFIX}}"/${f%.framework}
760 dosym "${rdir}"/${f}/Headers "${dest}"
762 # Link normal headers as well.
763 for hdr in "${D}${QT4_LIBDIR}/${f}"/Headers/*; do
765 dosym "../${rdir}"/${f}/Headers/${h} \
766 "${QT4_HEADERDIR#${EPREFIX}}"/Qt/${h}
772 # @FUNCTION: qt4_get_mkspec
775 # Returns the right mkspec for the current CHOST/CXX combination.
784 spec=macx || # mac with carbon/cocoa
785 spec=darwin ;; # darwin/mac with X11
786 *-freebsd*|*-dragonfly*)
801 die "qt4-build-multilib.eclass: unsupported CHOST '${CHOST}'" ;;
808 if [[ -d ${S}/mkspecs/unsupported/${spec}-clang ]]; then
809 spec=unsupported/${spec}-clang
811 ewarn "${spec}-clang mkspec does not exist, falling back to ${spec}-g++"
815 if [[ -d ${S}/mkspecs/${spec}-icc ]]; then
818 ewarn "${spec}-icc mkspec does not exist, falling back to ${spec}-g++"
822 die "qt4-build-multilib.eclass: unsupported compiler '$(tc-getCXX)'" ;;
825 # Add -64 for 64-bit prefix profiles
826 if use amd64-linux || use ia64-linux || use ppc64-linux ||
828 use sparc64-freebsd || use x64-freebsd || use x64-openbsd ||
830 use sparc64-solaris || use x64-solaris
832 [[ -d ${S}/mkspecs/${spec}-64 ]] && spec+=-64