1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: qt4-build-multilib.eclass
8 # Davide Pesavento <pesa@gentoo.org>
9 # @BLURB: Eclass for Qt4 split ebuilds with multilib support.
11 # This eclass contains various functions that are used when building Qt4.
16 *) die "qt4-build-multilib.eclass: unsupported EAPI=${EAPI:-0}" ;;
19 inherit eutils flag-o-matic multilib multilib-minimal toolchain-funcs
21 HOMEPAGE="https://www.qt.io/"
22 LICENSE="|| ( LGPL-2.1 LGPL-3 GPL-3 ) FDL-1.3"
29 EGIT_BRANCH=${PV%.9999}
32 # official stable release
33 QT4_BUILD_TYPE="release"
34 MY_P=qt-everywhere-opensource-src-${PV/_/-}
35 SRC_URI="http://download.qt.io/official_releases/qt/${PV%.*}/${PV}/${MY_P}.tar.gz"
41 "git://code.qt.io/qt/qt.git"
42 "https://code.qt.io/git/qt/qt.git"
43 "https://github.com/qtproject/qt.git"
45 [[ ${QT4_BUILD_TYPE} == live ]] && inherit git-r3
47 if [[ ${PN} != qttranslations ]]; then
49 [[ ${PN} != qtxmlpatterns ]] && IUSE+=" +exceptions"
54 virtual/pkgconfig[${MULTILIB_USEDEP}]
58 abi_x86_32? ( !app-emulation/emul-linux-x86-qtlibs[-abi_x86_32(-)] )
62 # src_{configure,compile,test,install} are inherited from multilib-minimal
63 EXPORT_FUNCTIONS src_unpack src_prepare pkg_postinst pkg_postrm
65 multilib_src_configure() { qt4_multilib_src_configure; }
66 multilib_src_compile() { qt4_multilib_src_compile; }
67 multilib_src_test() { qt4_multilib_src_test; }
68 multilib_src_install() { qt4_multilib_src_install; }
69 multilib_src_install_all() { qt4_multilib_src_install_all; }
72 # @ECLASS-VARIABLE: PATCHES
75 # Array variable containing all the patches to be applied. This variable
76 # is expected to be defined in the global scope of ebuilds. Make sure to
77 # specify the full path. This variable is used in src_prepare phase.
82 # "${FILESDIR}/mypatch.patch"
83 # "${FILESDIR}/mypatch2.patch"
87 # @ECLASS-VARIABLE: QT4_TARGET_DIRECTORIES
90 # Space-separated list of directories that will be configured,
91 # compiled, and installed. All paths must be relative to ${S}.
93 # @ECLASS-VARIABLE: QCONFIG_ADD
96 # List of options that must be added to QT_CONFIG in qconfig.pri
98 # @ECLASS-VARIABLE: QCONFIG_REMOVE
101 # List of options that must be removed from QT_CONFIG in qconfig.pri
103 # @ECLASS-VARIABLE: QCONFIG_DEFINE
106 # List of macros that must be defined in QtCore/qconfig.h
109 ###### Phase functions ######
111 # @FUNCTION: qt4-build-multilib_src_unpack
113 # Unpacks the sources.
114 qt4-build-multilib_src_unpack() {
116 if [[ $(gcc-major-version) -lt 4 ]] || \
117 [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 4 ]]; then
119 ewarn "Using a GCC version lower than 4.4 is not supported"
124 if [[ ${PN} == qtwebkit ]]; then
125 eshopts_push -s extglob
126 if is-flagq '-g?(gdb)?([1-9])'; then
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"
137 case ${QT4_BUILD_TYPE} in
138 live) git-r3_src_unpack ;;
143 # @FUNCTION: qt4-build-multilib_src_prepare
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)"
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)"
160 # Qt4 is not safe to build with C++14 (the new gcc-6 default).
161 # Upstream has addressed this for Qt5, but while we continue to
162 # support Qt4, we need to ensure everything is built in C++98 mode.
163 # See bugs 582522, 582618, 583662, 583744.
164 append-cxxflags -std=gnu++98
166 if [[ ${PN} == qtcore ]]; then
168 # qmake bus errors with -O2 or -O3 but -O1 works
169 if [[ ${CHOST} == *86*-apple-darwin* ]]; then
170 replace-flags -O[23] -O1
174 # undefined reference with -Os and --as-needed
175 if use x86 || use_if_iuse abi_x86_32; then
176 replace-flags -Os -O2
180 if [[ ${PN} == qtdeclarative ]]; then
182 # gcc-4.8 ICE with -Os, fixed in 4.9
183 if use x86 && tc-is-gcc && [[ $(gcc-version) == 4.8 ]]; then
184 replace-flags -Os -O2
188 if [[ ${PN} == qtwebkit ]]; then
190 # various ICEs with graphite-related flags, gcc-5 works
191 if [[ $(gcc-major-version) -lt 5 ]]; then
192 filter-flags -fgraphite-identity -floop-strip-mine
198 append-flags -mminimal-toc
201 # Teach configure about gcc-6 and later
202 sed -i -e 's:5\*|:[5-9]*|:' \
203 configure || die "sed gcc version failed"
205 # Read also AR from the environment
206 sed -i -e 's/^SYSTEM_VARIABLES="/&AR /' \
207 configure || die "sed SYSTEM_VARIABLES failed"
209 # Reset QMAKE_*FLAGS_{RELEASE,DEBUG} variables,
210 # or they will override the user's flags (via .qmake.cache)
211 sed -i -e '/^SYSTEM_VARIABLES=/ i \
212 QMakeVar set QMAKE_CFLAGS_RELEASE\
213 QMakeVar set QMAKE_CFLAGS_DEBUG\
214 QMakeVar set QMAKE_CXXFLAGS_RELEASE\
215 QMakeVar set QMAKE_CXXFLAGS_DEBUG\
216 QMakeVar set QMAKE_LFLAGS_RELEASE\
217 QMakeVar set QMAKE_LFLAGS_DEBUG\n' \
218 configure || die "sed QMAKE_*FLAGS_{RELEASE,DEBUG} failed"
220 # Drop -nocache from qmake invocation in all configure tests, to ensure that the
221 # correct toolchain and build flags are picked up from config.tests/.qmake.cache
222 find config.tests/unix -name '*.test' -type f -execdir \
223 sed -i -e '/bin\/qmake/s/-nocache//' '{}' + || die "sed -nocache failed"
225 # compile.test needs additional patching so that it doesn't create another cache file
226 # inside the test subdir, which would incorrectly override config.tests/.qmake.cache
227 sed -i -e '/echo.*QT_BUILD_TREE.*\.qmake\.cache/d' \
228 -e '/bin\/qmake/s/ "$SRCDIR/ "QT_BUILD_TREE=$OUTDIR"&/' \
229 config.tests/unix/compile.test || die "sed compile.test failed"
231 # Delete references to the obsolete /usr/X11R6 directory
232 # On prefix, this also prevents looking at non-prefix stuff
233 sed -i -re '/^QMAKE_(LIB|INC)DIR(_X11|_OPENGL|)\s+/ s/=.*/=/' \
234 mkspecs/common/linux.conf \
235 mkspecs/$(qt4_get_mkspec)/qmake.conf \
236 || die "sed QMAKE_(LIB|INC)DIR failed"
238 if use_if_iuse aqua; then
240 -e '/^CONFIG/s:app_bundle::' \
241 -e '/^CONFIG/s:plugin_no_soname:plugin_with_soname absolute_library_soname:' \
242 mkspecs/$(qt4_get_mkspec)/qmake.conf \
243 || die "sed failed (aqua)"
245 # we are crazy and build cocoa + qt3support
246 if { ! in_iuse qt3support || use qt3support; } && [[ ${CHOST##*-darwin} -ge 9 ]]; then
247 sed -i -e "/case \"\$PLATFORM,\$CFG_MAC_COCOA\" in/,/;;/ s|CFG_QT3SUPPORT=\"no\"|CFG_QT3SUPPORT=\"yes\"|" \
248 configure || die "sed failed (cocoa + qt3support)"
252 if [[ ${CHOST} == *-darwin* ]]; then
253 # Set FLAGS and remove -arch, since our gcc-apple is multilib crippled (by design)
255 -e "s:QMAKE_CFLAGS_RELEASE.*=.*:QMAKE_CFLAGS_RELEASE=${CFLAGS}:" \
256 -e "s:QMAKE_CXXFLAGS_RELEASE.*=.*:QMAKE_CXXFLAGS_RELEASE=${CXXFLAGS}:" \
257 -e "s:QMAKE_LFLAGS_RELEASE.*=.*:QMAKE_LFLAGS_RELEASE=-headerpad_max_install_names ${LDFLAGS}:" \
258 -e "s:-arch\s\w*::g" \
259 mkspecs/common/g++-macx.conf \
260 || die "sed g++-macx.conf failed"
262 # Fix configure's -arch settings that appear in qmake/Makefile and also
263 # fix arch handling (automagically duplicates our -arch arg and breaks
264 # pch). Additionally disable Xarch support.
266 -e "s:-arch i386::" \
268 -e "s:-arch x86_64::" \
269 -e "s:-arch ppc64::" \
271 -e "/if \[ ! -z \"\$NATIVE_64_ARCH\" \]; then/,/fi/ d" \
272 -e "s:CFG_MAC_XARCH=yes:CFG_MAC_XARCH=no:g" \
273 -e "s:-Xarch_x86_64::g" \
274 -e "s:-Xarch_ppc64::g" \
275 configure mkspecs/common/gcc-base-macx.conf mkspecs/common/g++-macx.conf \
276 || die "sed -arch/-Xarch failed"
278 # On Snow Leopard don't fall back to 10.5 deployment target.
279 if [[ ${CHOST} == *-apple-darwin10 ]]; then
281 -e "s:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET.*:QMakeVar set QMAKE_MACOSX_DEPLOYMENT_TARGET 10.6:g" \
282 -e "s:-mmacosx-version-min=10.[0-9]:-mmacosx-version-min=10.6:g" \
283 configure mkspecs/common/g++-macx.conf \
284 || die "sed deployment target failed"
288 if [[ ${CHOST} == *-solaris* ]]; then
289 sed -i -e '/^QMAKE_LFLAGS_THREAD/a QMAKE_LFLAGS_DYNAMIC_LIST = -Wl,--dynamic-list,' \
290 mkspecs/$(qt4_get_mkspec)/qmake.conf || die
294 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
298 qt4_multilib_src_configure() {
301 qt4_symlink_tools_to_build_dir
303 # toolchain setup ('local -x' because of bug 532510)
305 AR="$(tc-getAR) cqs" \
309 MAKEFLAGS=${MAKEOPTS} \
310 OBJCOPY=$(tc-getOBJCOPY) \
311 OBJDUMP=$(tc-getOBJDUMP) \
314 # convert tc-arch to the values supported by Qt
315 local arch=$(tc-arch)
317 amd64|x64-*) arch=x86_64 ;;
318 arm64|hppa) arch=generic ;;
319 ppc*-macos) arch=ppc ;;
320 ppc*) arch=powerpc ;;
321 sparc*) arch=sparc ;;
322 x86-macos) arch=x86 ;;
326 # configure arguments
329 -prefix "${QT4_PREFIX}"
330 -bindir "${QT4_BINDIR}"
331 -libdir "${QT4_LIBDIR}"
332 -docdir "${QT4_DOCDIR}"
333 -headerdir "${QT4_HEADERDIR}"
334 -plugindir "${QT4_PLUGINDIR}"
335 -importdir "${QT4_IMPORTDIR}"
336 -datadir "${QT4_DATADIR}"
337 -translationdir "${QT4_TRANSLATIONDIR}"
338 -sysconfdir "${QT4_SYSCONFDIR}"
339 -examplesdir "${QT4_EXAMPLESDIR}"
340 -demosdir "${QT4_DEMOSDIR}"
343 $(use_if_iuse debug && echo -debug || echo -release)
344 -no-separate-debug-info
347 -opensource -confirm-license
349 # build shared libraries
352 # skip recursive processing of .pro files at the end of configure
353 # (we run qmake by ourselves), thus saving quite a bit of time
356 # always enable large file support
359 # exceptions USE flag
360 $(in_iuse exceptions && qt_use exceptions || echo -exceptions)
365 # architecture/platform (mkspec)
367 -platform $(qt4_get_mkspec)
369 # instruction set support
370 $(is-flagq -mno-mmx && echo -no-mmx)
371 $(is-flagq -mno-3dnow && echo -no-3dnow)
372 $(is-flagq -mno-sse && echo -no-sse)
373 $(is-flagq -mno-sse2 && echo -no-sse2)
374 $(is-flagq -mno-sse3 && echo -no-sse3)
375 $(is-flagq -mno-ssse3 && echo -no-ssse3)
376 $(is-flagq -mno-sse4.1 && echo -no-sse4.1)
377 $(is-flagq -mno-sse4.2 && echo -no-sse4.2)
378 $(is-flagq -mno-avx && echo -no-avx)
379 $(is-flagq -mfpu=* && ! is-flagq -mfpu=*neon* && echo -no-neon)
382 $([[ ${CHOST} == *86*-apple-darwin* ]] && echo -no-ssse3)
384 # prefer system libraries
387 # exclude examples and demos from default build
391 # disable rpath on non-prefix (bugs 380415 and 417169)
392 $(usex prefix '' -no-rpath)
394 # print verbose information about each configure test
397 # precompiled headers don't work on hardened, where the flag is masked
398 $(in_iuse pch && qt_use pch || echo -no-pch)
400 # enable linker optimizations to reduce relocations, except on Solaris
401 # where this flag seems to introduce major breakage to applications,
402 # mostly to be seen as a core dump with the message:
403 # "QPixmap: Must construct a QApplication before a QPaintDevice"
404 $([[ ${CHOST} != *-solaris* ]] && echo -reduce-relocations)
407 if use_if_iuse aqua; then
408 if [[ ${CHOST##*-darwin} -ge 9 ]]; then
410 # on (snow) leopard use the new (frameworked) cocoa code
412 # add hint for the framework location
416 conf+=(-no-framework)
421 # module-specific options
425 einfo "Configuring with: ${conf[@]}"
426 "${S}"/configure "${conf[@]}" || die "configure failed"
428 # configure is stupid and assigns QMAKE_LFLAGS twice,
429 # thus the previous -rpath-link flag gets overwritten
430 # and some packages (e.g. qthelp) fail to link
431 sed -i -e '/^QMAKE_LFLAGS =/ s:$: $$QMAKE_LFLAGS:' \
432 .qmake.cache || die "sed .qmake.cache failed"
435 qt4_foreach_target_subdir qt4_qmake
438 qt4_multilib_src_compile() {
441 qt4_foreach_target_subdir emake
444 qt4_multilib_src_test() {
447 qt4_foreach_target_subdir emake -j1 check
450 qt4_multilib_src_install() {
453 qt4_foreach_target_subdir emake INSTALL_ROOT="${D}" install
455 if [[ ${PN} == qtcore ]]; then
456 set -- emake INSTALL_ROOT="${D}" install_{mkspecs,qmake}
461 cat > "${T}/44qt4-${CHOST}" <<-_EOF_
462 LDPATH="${QT4_LIBDIR}"
464 doenvd "${T}/44qt4-${CHOST}"
466 # install qtchooser configuration file
467 cat > "${T}/qt4-${CHOST}.conf" <<-_EOF_
473 insinto /etc/xdg/qtchooser
474 doins "${T}/qt4-${CHOST}.conf"
477 if multilib_is_native_abi; then
478 # convenience symlinks
479 dosym qt4-"${CHOST}".conf /etc/xdg/qtchooser/4.conf
480 dosym qt4-"${CHOST}".conf /etc/xdg/qtchooser/qt4.conf
481 # TODO bug 522646: write an eselect module to manage default.conf
482 dosym qt4.conf /etc/xdg/qtchooser/default.conf
486 # move pkgconfig directory to the correct location
487 if [[ -d ${D}${QT4_LIBDIR}/pkgconfig ]]; then
488 mv "${D}${QT4_LIBDIR}"/pkgconfig "${ED}usr/$(get_libdir)" || die
491 qt4_install_module_qconfigs
492 qt4_symlink_framework_headers
495 qt4_multilib_src_install_all() {
496 if [[ ${PN} == qtcore ]]; then
497 # include gentoo-qconfig.h at the beginning of Qt{,Core}/qconfig.h
498 if use aqua && [[ ${CHOST#*-darwin} -ge 9 ]]; then
499 sed -i -e '1i #include <QtCore/Gentoo/gentoo-qconfig.h>\n' \
500 "${D}${QT4_LIBDIR}"/QtCore.framework/Headers/qconfig.h \
501 || die "sed failed (qconfig.h)"
502 dosym "${QT4_HEADERDIR#${EPREFIX}}"/Gentoo \
503 "${QT4_LIBDIR#${EPREFIX}}"/QtCore.framework/Headers/Gentoo
505 sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
506 "${D}${QT4_HEADERDIR}"/Qt{,Core}/qconfig.h \
507 || die "sed failed (qconfig.h)"
510 dodir "${QT4_DATADIR#${EPREFIX}}"/mkspecs/gentoo
511 mv "${D}${QT4_DATADIR}"/mkspecs/{qconfig.pri,gentoo/} || die
514 # install private headers of a few modules
515 if has ${PN} qtcore qtdeclarative qtgui qtscript; then
516 local moduledir=${PN#qt}
517 local modulename=Qt$(tr 'a-z' 'A-Z' <<< ${moduledir:0:1})${moduledir:1}
518 [[ ${moduledir} == core ]] && moduledir=corelib
520 einfo "Installing private headers into ${QT4_HEADERDIR}/${modulename}/private"
521 insinto "${QT4_HEADERDIR#${EPREFIX}}"/${modulename}/private
522 find "${S}"/src/${moduledir} -type f -name '*_p.h' -exec doins '{}' + || die
528 # @FUNCTION: qt4-build-multilib_pkg_postinst
530 # Regenerate configuration after installation or upgrade/downgrade.
531 qt4-build-multilib_pkg_postinst() {
532 qt4_regenerate_global_qconfigs
535 # @FUNCTION: qt4-build-multilib_pkg_postrm
537 # Regenerate configuration when a module is completely removed.
538 qt4-build-multilib_pkg_postrm() {
539 qt4_regenerate_global_qconfigs
543 ###### Public helpers ######
546 # @USAGE: <flag> [feature] [enableval]
548 # <flag> is the name of a flag in IUSE.
550 # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
551 # otherwise. If [feature] is not specified, <flag> is used in its place.
552 # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
554 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
556 usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
559 # @FUNCTION: qt_native_use
560 # @USAGE: <flag> [feature] [enableval]
562 # <flag> is the name of a flag in IUSE.
564 # Outputs "-${enableval}-${feature}" if <flag> is enabled and we are currently
565 # building for the native ABI, "-no-${feature}" otherwise. If [feature] is not
566 # specified, <flag> is used in its place. If [enableval] is not specified,
567 # the "-${enableval}" prefix is omitted.
569 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
571 multilib_is_native_abi && qt_use "$@" || echo "-no-${2:-$1}"
575 ###### Internal functions ######
577 # @FUNCTION: qt4_prepare_env
580 # Prepares the environment for building Qt.
582 # setup installation directories
583 # note: keep paths in sync with qmake-utils.eclass
584 QT4_PREFIX=${EPREFIX}/usr
585 QT4_HEADERDIR=${QT4_PREFIX}/include/qt4
586 QT4_LIBDIR=${QT4_PREFIX}/$(get_libdir)/qt4
587 QT4_BINDIR=${QT4_LIBDIR}/bin
588 QT4_PLUGINDIR=${QT4_LIBDIR}/plugins
589 QT4_IMPORTDIR=${QT4_LIBDIR}/imports
590 QT4_DATADIR=${QT4_PREFIX}/share/qt4
591 QT4_DOCDIR=${QT4_PREFIX}/share/doc/qt-${PV}
592 QT4_TRANSLATIONDIR=${QT4_DATADIR}/translations
593 QT4_EXAMPLESDIR=${QT4_DATADIR}/examples
594 QT4_DEMOSDIR=${QT4_DATADIR}/demos
595 QT4_SYSCONFDIR=${EPREFIX}/etc/qt4
597 # are these still needed?
598 QMAKE_LIBDIR_QT=${QT4_LIBDIR}
599 export XDG_CONFIG_HOME="${T}"
601 # can confuse qmake if set (bug 583352)
605 # @FUNCTION: qt4_foreach_target_subdir
608 # Executes the given command inside each directory listed in QT4_TARGET_DIRECTORIES.
609 qt4_foreach_target_subdir() {
611 for subdir in ${QT4_TARGET_DIRECTORIES}; do
612 mkdir -p "${subdir}" || die
613 pushd "${subdir}" >/dev/null || die
615 einfo "Running $* ${subdir:+in ${subdir}}"
619 popd >/dev/null || die
625 # @FUNCTION: qt4_symlink_tools_to_build_dir
628 # Symlinks qtcore tools to BUILD_DIR,
629 # so that they can be used when building other modules.
630 qt4_symlink_tools_to_build_dir() {
632 if [[ ${PN} != qtcore ]]; then
633 tools+=(qmake moc rcc uic)
636 mkdir -p "${BUILD_DIR}"/bin || die
637 pushd "${BUILD_DIR}"/bin >/dev/null || die
639 for tool in "${tools[@]}"; do
640 [[ -e ${QT4_BINDIR}/${tool} ]] || continue
641 ln -s "${QT4_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
644 popd >/dev/null || die
647 # @FUNCTION: qt4_qmake
650 # Helper function that runs qmake in the current target subdir.
651 # Intended to be called by qt4_foreach_target_subdir().
653 local projectdir=${PWD/#${BUILD_DIR}/${S}}
655 "${BUILD_DIR}"/bin/qmake \
658 LIBS+=-L"${QT4_LIBDIR}" \
659 "${myqmakeargs[@]}" \
660 || die "qmake failed (${projectdir#${S}/})"
663 # @FUNCTION: qt4_install_module_qconfigs
666 # Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
667 qt4_install_module_qconfigs() {
669 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
670 for x in QCONFIG_ADD QCONFIG_REMOVE; do
671 [[ -n ${!x} ]] && echo ${x}=${!x} >> "${BUILD_DIR}"/${PN}-qconfig.pri
673 insinto ${QT4_DATADIR#${EPREFIX}}/mkspecs/gentoo
674 doins "${BUILD_DIR}"/${PN}-qconfig.pri
677 if [[ -n ${QCONFIG_DEFINE} ]]; then
678 for x in ${QCONFIG_DEFINE}; do
679 echo "#define ${x}" >> "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
681 insinto ${QT4_HEADERDIR#${EPREFIX}}/Gentoo
682 doins "${BUILD_DIR}"/gentoo-${PN}-qconfig.h
686 # @FUNCTION: qt4_regenerate_global_qconfigs
689 # Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
690 # Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
691 qt4_regenerate_global_qconfigs() {
692 if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} || ${PN} == qtcore ]]; then
693 local x qconfig_add qconfig_remove qconfig_new
694 for x in "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
695 [[ -f ${x} ]] || continue
696 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
697 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
700 if [[ -e "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
701 # start with the qconfig.pri that qtcore installed
702 if ! cp "${ROOT}${QT4_DATADIR}"/mkspecs/gentoo/qconfig.pri \
703 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
704 eerror "cp qconfig failed."
708 # generate list of QT_CONFIG entries from the existing list
709 # including qconfig_add and excluding qconfig_remove
710 for x in $(sed -n 's/^QT_CONFIG +=//p' \
711 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
712 has ${x} ${qconfig_remove} || qconfig_new+=" ${x}"
715 # replace the existing QT_CONFIG list with qconfig_new
716 if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
717 "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri; then
718 eerror "Sed for QT_CONFIG failed"
722 # create Gentoo/qconfig.h
723 if [[ ! -e ${ROOT}${QT4_HEADERDIR}/Gentoo ]]; then
724 if ! mkdir -p "${ROOT}${QT4_HEADERDIR}"/Gentoo; then
725 eerror "mkdir ${QT4_HEADERDIR}/Gentoo failed"
729 : > "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
730 for x in "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
731 [[ -f ${x} ]] || continue
732 cat "${x}" >> "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
735 rm -f "${ROOT}${QT4_DATADIR}"/mkspecs/qconfig.pri
736 rm -f "${ROOT}${QT4_HEADERDIR}"/Gentoo/gentoo-qconfig.h
737 rmdir "${ROOT}${QT4_DATADIR}"/mkspecs \
738 "${ROOT}${QT4_DATADIR}" \
739 "${ROOT}${QT4_HEADERDIR}"/Gentoo \
740 "${ROOT}${QT4_HEADERDIR}" 2>/dev/null
745 # @FUNCTION: qt4_symlink_framework_headers
747 # On OS X we need to add some symlinks when frameworks are being
748 # used, to avoid complications with some more or less stupid packages.
749 qt4_symlink_framework_headers() {
750 if use_if_iuse aqua && [[ ${CHOST##*-darwin} -ge 9 ]]; then
751 local frw dest f h rdir
752 # Some packages tend to include <Qt/...>
753 dodir "${QT4_HEADERDIR#${EPREFIX}}"/Qt
755 # Fake normal headers when frameworks are installed... eases life later
756 # on, make sure we use relative links though, as some ebuilds assume
757 # these dirs exist in src_install to add additional files
760 while [[ -n ${f} && ${f%%/*} == ${h%%/*} ]] ; do
766 while [[ ${h} == */* ]] ; do
772 for frw in "${D}${QT4_LIBDIR}"/*.framework; do
773 [[ -e "${frw}"/Headers ]] || continue
775 dest="${QT4_HEADERDIR#${EPREFIX}}"/${f%.framework}
776 dosym "${rdir}"/${f}/Headers "${dest}"
778 # Link normal headers as well.
779 for hdr in "${D}${QT4_LIBDIR}/${f}"/Headers/*; do
781 dosym "../${rdir}"/${f}/Headers/${h} \
782 "${QT4_HEADERDIR#${EPREFIX}}"/Qt/${h}
788 # @FUNCTION: qt4_get_mkspec
791 # Returns the right mkspec for the current CHOST/CXX combination.
800 spec=macx || # mac with carbon/cocoa
801 spec=darwin ;; # darwin/mac with X11
802 *-freebsd*|*-dragonfly*)
817 die "qt4-build-multilib.eclass: unsupported CHOST '${CHOST}'" ;;
824 if [[ -d ${S}/mkspecs/unsupported/${spec}-clang ]]; then
825 spec=unsupported/${spec}-clang
827 ewarn "${spec}-clang mkspec does not exist, falling back to ${spec}-g++"
831 if [[ -d ${S}/mkspecs/${spec}-icc ]]; then
834 ewarn "${spec}-icc mkspec does not exist, falling back to ${spec}-g++"
838 die "qt4-build-multilib.eclass: unsupported compiler '$(tc-getCXX)'" ;;
841 # Add -64 for 64-bit prefix profiles
842 if use amd64-linux || use ppc64-linux ||
844 use sparc64-solaris || use x64-solaris
846 [[ -d ${S}/mkspecs/${spec}-64 ]] && spec+=-64