1 # Copyright 1999-2017 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
4 # @ECLASS: qt5-build.eclass
8 # Davide Pesavento <pesa@gentoo.org>
10 # @BLURB: Eclass for Qt5 split ebuilds.
12 # This eclass contains various functions that are used when building Qt5.
15 if [[ ${CATEGORY} != dev-qt ]]; then
16 die "qt5-build.eclass is only to be used for building Qt 5."
21 *) die "qt5-build.eclass: unsupported EAPI=${EAPI:-0}" ;;
24 # @ECLASS-VARIABLE: QT5_MODULE
27 # The upstream name of the module this package belongs to. Used for
28 # SRC_URI and EGIT_REPO_URI. Must be set before inheriting the eclass.
29 : ${QT5_MODULE:=${PN}}
31 # @ECLASS-VARIABLE: QT5_TARGET_SUBDIRS
34 # Array variable containing the source directories that should be built.
35 # All paths must be relative to ${S}.
37 # @ECLASS-VARIABLE: QT5_GENTOO_CONFIG
40 # Array of <useflag:feature:macro> triplets that are evaluated in src_install
41 # to generate the per-package list of enabled QT_CONFIG features and macro
42 # definitions, which are then merged together with all other Qt5 packages
43 # installed on the system to obtain the global qconfig.{h,pri} files.
45 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
47 # For proper description see virtualx.eclass man page.
48 # Here we redefine default value to be manual, if your package needs virtualx
49 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
50 : ${VIRTUALX_REQUIRED:=manual}
52 inherit estack flag-o-matic ltprune toolchain-funcs versionator virtualx
54 HOMEPAGE="https://www.qt.io/"
55 LICENSE="|| ( GPL-2 GPL-3 LGPL-3 ) FDL-1.3"
56 SLOT=5/$(get_version_component_range 1-2)
58 QT5_MINOR_VERSION=$(get_version_component_range 2)
59 QT5_PATCH_VERSION=$(get_version_component_range 3)
60 readonly QT5_MINOR_VERSION QT5_PATCH_VERSION
68 5.?.9999|5.??.9999|5.???.9999)
71 EGIT_BRANCH=${PV%.9999}
73 *_alpha*|*_beta*|*_rc*)
75 QT5_BUILD_TYPE="release"
77 if [[ ${QT5_MINOR_VERSION} -ge 10 ]]; then
78 MY_P=${QT5_MODULE}-everywhere-src-${PV/_/-}
80 MY_P=${QT5_MODULE}-opensource-src-${PV/_/-}
83 SRC_URI="https://download.qt.io/development_releases/qt/${PV%.*}/${PV/_/-}/submodules/${MY_P}.tar.xz"
87 # official stable release
88 QT5_BUILD_TYPE="release"
90 if [[ ${QT5_MINOR_VERSION} -ge 10 ]]; then
91 MY_P=${QT5_MODULE}-everywhere-src-${PV}
93 MY_P=${QT5_MODULE}-opensource-src-${PV}
96 SRC_URI="https://download.qt.io/official_releases/qt/${PV%.*}/${PV}/submodules/${MY_P}.tar.xz"
100 readonly QT5_BUILD_TYPE
103 "https://code.qt.io/qt/${QT5_MODULE}.git"
104 "https://github.com/qt/${QT5_MODULE}.git"
106 [[ ${QT5_BUILD_TYPE} == live ]] && inherit git-r3
108 # @ECLASS-VARIABLE: QT5_BUILD_DIR
111 # Build directory for out-of-source builds.
112 case ${QT5_BUILD_TYPE} in
113 live) : ${QT5_BUILD_DIR:=${S}_build} ;;
114 release) : ${QT5_BUILD_DIR:=${S}} ;; # workaround for bug 497312
119 [[ ${PN} == qtwebkit ]] && RESTRICT+=" mirror" # bug 524584
120 [[ ${QT5_BUILD_TYPE} == release ]] && RESTRICT+=" test" # bug 457182
126 if [[ (${PN} != qttest && ${PN} != qtwebkit) || (${PN} == qtwebkit && ${QT5_MINOR_VERSION} -lt 9) ]]; then
127 DEPEND+=" test? ( ~dev-qt/qttest-${PV} )"
134 ###### Phase functions ######
136 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm
138 # @FUNCTION: qt5-build_src_unpack
140 # Unpacks the sources.
141 qt5-build_src_unpack() {
143 local min_gcc4_minor_version=7
144 if [[ $(gcc-major-version) -lt 4 ]] || \
145 [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt ${min_gcc4_minor_version} ]]; then
146 eerror "GCC version 4.${min_gcc4_minor_version} or later is required to build this package"
147 die "GCC 4.${min_gcc4_minor_version} or later required"
152 if [[ ${PN} == qtwebengine || ${PN} == qtwebkit ]]; then
153 eshopts_push -s extglob
154 if is-flagq '-g?(gdb)?([1-9])'; then
156 ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
157 ewarn "You may experience really long compilation times and/or increased memory usage."
158 ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
164 case ${QT5_BUILD_TYPE} in
165 live) git-r3_src_unpack ;;
170 # @FUNCTION: qt5-build_src_prepare
172 # Prepares the environment and patches the sources if necessary.
173 qt5-build_src_prepare() {
176 if [[ ${QT5_MODULE} == qtbase ]]; then
177 qt5_symlink_tools_to_build_dir
179 # Avoid unnecessary qmake recompilations
180 if [[ ${QT5_MINOR_VERSION} -ge 8 ]]; then
181 sed -i -e "/Creating qmake/i if [ '!' -e \"\$outpath/bin/qmake\" ]; then" \
182 -e '/echo "Done."/a fi' \
183 configure || die "sed failed (skip qmake bootstrap)"
185 sed -i -re "s|^if true;.*(\[ '\!').*(\"\\\$outpath/bin/qmake\".*)|if \1 -e \2 then|" \
186 configure || die "sed failed (skip qmake bootstrap)"
189 # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when bootstrapping qmake
190 sed -i -e "/outpath\/qmake\".*\"\$MAKE\")/ s:): \
191 ${MAKEOPTS} ${EXTRA_EMAKE} 'CC=$(tc-getCC)' 'CXX=$(tc-getCXX)' \
192 'QMAKE_CFLAGS=${CFLAGS}' 'QMAKE_CXXFLAGS=${CXXFLAGS}' 'QMAKE_LFLAGS=${LDFLAGS}'&:" \
193 -e 's/\(setBootstrapVariable\s\+\|EXTRA_C\(XX\)\?FLAGS=.*\)QMAKE_C\(XX\)\?FLAGS_\(DEBUG\|RELEASE\).*/:/' \
194 configure || die "sed failed (respect env for qmake build)"
195 sed -i -e '/^CPPFLAGS\s*=/ s/-g //' \
196 qmake/Makefile.unix || die "sed failed (CPPFLAGS for qmake build)"
198 # Respect CXX in bsymbolic_functions, fvisibility, precomp, and a few other tests
199 sed -i -e "/^QMAKE_CONF_COMPILER=/ s:=.*:=\"$(tc-getCXX)\":" \
200 configure || die "sed failed (QMAKE_CONF_COMPILER)"
202 if [[ ${QT5_MINOR_VERSION} -le 7 ]]; then
203 # Respect toolchain and flags in config.tests
204 find config.tests/unix -name '*.test' -type f -execdir \
205 sed -i -e 's/-nocache //' '{}' + || die
208 # Don't inject -msse/-mavx/... into CXXFLAGS when detecting
209 # compiler support for extended instruction sets (bug 552942)
210 find config.tests/common -name '*.pro' -type f -execdir \
211 sed -i -e '/QMAKE_CXXFLAGS\s*+=/ d' '{}' + || die
213 # Don't add -O3 to CXXFLAGS (bug 549140)
214 sed -i -e '/CONFIG\s*+=/ s/optimize_full//' \
215 src/{corelib/corelib,gui/gui}.pro || die "sed failed (optimize_full)"
221 # @FUNCTION: qt5-build_src_configure
223 # Runs qmake in the target directories. For packages
224 # in qtbase, ./configure is also run before qmake.
225 qt5-build_src_configure() {
226 if [[ ${QT5_MODULE} == qtbase ]]; then
230 qt5_foreach_target_subdir qt5_qmake
233 # @FUNCTION: qt5-build_src_compile
235 # Runs emake in the target directories.
236 qt5-build_src_compile() {
237 qt5_foreach_target_subdir emake
240 # @FUNCTION: qt5-build_src_test
242 # Runs tests in the target directories.
243 qt5-build_src_test() {
244 # disable broken cmake tests (bug 474004)
245 local myqmakeargs=("${myqmakeargs[@]}" -after SUBDIRS-=cmake SUBDIRS-=installed_cmake)
247 qt5_foreach_target_subdir qt5_qmake
248 qt5_foreach_target_subdir emake
250 # create a custom testrunner script that correctly sets
251 # LD_LIBRARY_PATH before executing the given test
252 local testrunner=${QT5_BUILD_DIR}/gentoo-testrunner
253 cat > "${testrunner}" <<-_EOF_ || die
255 export LD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}"
258 chmod +x "${testrunner}"
260 set -- qt5_foreach_target_subdir emake TESTRUNNER="'${testrunner}'" check
261 if [[ ${VIRTUALX_REQUIRED} == test ]]; then
268 # @FUNCTION: qt5-build_src_install
270 # Runs emake install in the target directories.
271 qt5-build_src_install() {
272 qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install
274 if [[ ${PN} == qtcore ]]; then
275 pushd "${QT5_BUILD_DIR}" >/dev/null || die
277 set -- emake INSTALL_ROOT="${D}" \
278 sub-qmake-qmake-aux-pro-install_subtargets \
279 install_{syncqt,mkspecs}
284 popd >/dev/null || die
286 docompress -x "${QT5_DOCDIR#${EPREFIX}}"/global
288 # install an empty Gentoo/gentoo-qconfig.h in ${D}
289 # so that it's placed under package manager control
290 > "${T}"/gentoo-qconfig.h
292 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
293 doins "${T}"/gentoo-qconfig.h
296 # include gentoo-qconfig.h at the beginning of QtCore/qconfig.h
297 sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
298 "${D}${QT5_HEADERDIR}"/QtCore/qconfig.h \
299 || die "sed failed (qconfig.h)"
301 # install qtchooser configuration file
302 cat > "${T}/qt5-${CHOST}.conf" <<-_EOF_ || die
308 insinto /etc/xdg/qtchooser
309 doins "${T}/qt5-${CHOST}.conf"
312 # convenience symlinks
313 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/5.conf
314 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/qt5.conf
317 qt5_install_module_qconfigs
321 # @FUNCTION: qt5-build_pkg_postinst
323 # Regenerate configuration after installation or upgrade/downgrade.
324 qt5-build_pkg_postinst() {
325 qt5_regenerate_global_qconfigs
328 # @FUNCTION: qt5-build_pkg_postrm
330 # Regenerate configuration when a module is completely removed.
331 qt5-build_pkg_postrm() {
332 if [[ -z ${REPLACED_BY_VERSION} && ${PN} != qtcore ]]; then
333 qt5_regenerate_global_qconfigs
338 ###### Public helpers ######
341 # @USAGE: <flag> [feature] [enableval]
343 # <flag> is the name of a flag in IUSE.
345 # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
346 # otherwise. If [feature] is not specified, <flag> is used in its place.
347 # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
349 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
351 usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
354 # @FUNCTION: qt_use_compile_test
355 # @USAGE: <flag> [config]
357 # <flag> is the name of a flag in IUSE.
358 # [config] is the argument of qtCompileTest, defaults to <flag>.
360 # This function is useful to disable optional dependencies that are checked
361 # at qmake-time using the qtCompileTest() function. If <flag> is disabled,
362 # the compile test is skipped and the dependency is assumed to be unavailable,
363 # i.e. the corresponding feature will be disabled. Note that all invocations
364 # of this function must happen before calling qt5-build_src_configure.
365 qt_use_compile_test() {
366 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
369 mkdir -p "${QT5_BUILD_DIR}" || die
370 echo "CONFIG += done_config_${2:-$1}" >> "${QT5_BUILD_DIR}"/.qmake.cache || die
374 # @FUNCTION: qt_use_disable_config
375 # @USAGE: <flag> <config> <files...>
377 # <flag> is the name of a flag in IUSE.
378 # <config> is the (lowercase) name of a Qt5 config entry.
379 # <files...> is a list of one or more qmake project files.
381 # This function patches <files> to treat <config> as disabled
382 # when <flag> is disabled, otherwise it does nothing.
383 # This can be useful to avoid an automagic dependency when the config entry
384 # is enabled on the system but the corresponding USE flag is disabled.
385 qt_use_disable_config() {
386 [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
392 if ! use "${flag}"; then
393 echo "$@" | xargs sed -i -e "s/qtConfig(${config})/false/g" || die
397 # @FUNCTION: qt_use_disable_mod
398 # @USAGE: <flag> <module> <files...>
400 # <flag> is the name of a flag in IUSE.
401 # <module> is the (lowercase) name of a Qt5 module.
402 # <files...> is a list of one or more qmake project files.
404 # This function patches <files> to treat <module> as not installed
405 # when <flag> is disabled, otherwise it does nothing.
406 # This can be useful to avoid an automagic dependency when the module
407 # is present on the system but the corresponding USE flag is disabled.
408 qt_use_disable_mod() {
409 [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
415 if ! use "${flag}"; then
416 echo "$@" | xargs sed -i -e "s/qtHaveModule(${module})/false/g" || die
421 ###### Internal functions ######
423 # @FUNCTION: qt5_prepare_env
426 # Prepares the environment for building Qt.
428 # setup installation directories
429 # note: keep paths in sync with qmake-utils.eclass
430 QT5_PREFIX=${EPREFIX}/usr
431 QT5_HEADERDIR=${QT5_PREFIX}/include/qt5
432 QT5_LIBDIR=${QT5_PREFIX}/$(get_libdir)
433 QT5_ARCHDATADIR=${QT5_PREFIX}/$(get_libdir)/qt5
434 QT5_BINDIR=${QT5_ARCHDATADIR}/bin
435 QT5_PLUGINDIR=${QT5_ARCHDATADIR}/plugins
436 QT5_LIBEXECDIR=${QT5_ARCHDATADIR}/libexec
437 QT5_IMPORTDIR=${QT5_ARCHDATADIR}/imports
438 QT5_QMLDIR=${QT5_ARCHDATADIR}/qml
439 QT5_DATADIR=${QT5_PREFIX}/share/qt5
440 QT5_DOCDIR=${QT5_PREFIX}/share/doc/qt-${PV}
441 QT5_TRANSLATIONDIR=${QT5_DATADIR}/translations
442 QT5_EXAMPLESDIR=${QT5_DATADIR}/examples
443 QT5_TESTSDIR=${QT5_DATADIR}/tests
444 QT5_SYSCONFDIR=${EPREFIX}/etc/xdg
445 readonly QT5_PREFIX QT5_HEADERDIR QT5_LIBDIR QT5_ARCHDATADIR \
446 QT5_BINDIR QT5_PLUGINDIR QT5_LIBEXECDIR QT5_IMPORTDIR \
447 QT5_QMLDIR QT5_DATADIR QT5_DOCDIR QT5_TRANSLATIONDIR \
448 QT5_EXAMPLESDIR QT5_TESTSDIR QT5_SYSCONFDIR
450 if [[ ${QT5_MODULE} == qtbase ]]; then
451 # see mkspecs/features/qt_config.prf
452 export QMAKEMODULES="${QT5_BUILD_DIR}/mkspecs/modules:${S}/mkspecs/modules:${QT5_ARCHDATADIR}/mkspecs/modules"
456 # @FUNCTION: qt5_foreach_target_subdir
459 # Executes the command given as argument from inside each directory
460 # listed in QT5_TARGET_SUBDIRS. Handles autotests subdirs automatically.
461 qt5_foreach_target_subdir() {
462 [[ -z ${QT5_TARGET_SUBDIRS[@]} ]] && QT5_TARGET_SUBDIRS=("")
465 for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do
466 if [[ ${EBUILD_PHASE} == test ]]; then
467 subdir=tests/auto${subdir#src}
468 [[ -d ${S}/${subdir} ]] || continue
471 local msg="Running $* ${subdir:+in ${subdir}}"
474 mkdir -p "${QT5_BUILD_DIR}/${subdir}" || die -n || return $?
475 pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die -n || return $?
477 "$@" || die -n "${msg} failed" || return $?
479 popd >/dev/null || die -n || return $?
483 # @FUNCTION: qt5_symlink_tools_to_build_dir
486 # Symlinks qmake and a few other tools to QT5_BUILD_DIR,
487 # so that they can be used when building other modules.
488 qt5_symlink_tools_to_build_dir() {
490 if [[ ${PN} != qtcore ]]; then
491 tools+=(qmake moc rcc qlalr)
492 [[ ${PN} != qtdbus ]] && tools+=(qdbuscpp2xml qdbusxml2cpp)
493 [[ ${PN} != qtwidgets ]] && tools+=(uic)
496 mkdir -p "${QT5_BUILD_DIR}"/bin || die
497 pushd "${QT5_BUILD_DIR}"/bin >/dev/null || die
499 for tool in "${tools[@]}"; do
500 [[ -e ${QT5_BINDIR}/${tool} ]] || continue
501 ln -s "${QT5_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
504 popd >/dev/null || die
507 # @FUNCTION: qt5_base_configure
510 # Runs ./configure for modules belonging to qtbase.
511 qt5_base_configure() {
512 # setup toolchain variables used by configure
513 tc-export AR CC CXX OBJDUMP RANLIB STRIP
514 export LD="$(tc-getCXX)"
517 if [[ ${QT5_MINOR_VERSION} -ge 9 ]]; then
518 unset QMAKESPEC XQMAKESPEC QMAKEPATH QMAKEFEATURES
521 # configure arguments
524 -prefix "${QT5_PREFIX}"
525 -bindir "${QT5_BINDIR}"
526 -headerdir "${QT5_HEADERDIR}"
527 -libdir "${QT5_LIBDIR}"
528 -archdatadir "${QT5_ARCHDATADIR}"
529 -plugindir "${QT5_PLUGINDIR}"
530 -libexecdir "${QT5_LIBEXECDIR}"
531 -importdir "${QT5_IMPORTDIR}"
532 -qmldir "${QT5_QMLDIR}"
533 -datadir "${QT5_DATADIR}"
534 -docdir "${QT5_DOCDIR}"
535 -translationdir "${QT5_TRANSLATIONDIR}"
536 -sysconfdir "${QT5_SYSCONFDIR}"
537 -examplesdir "${QT5_EXAMPLESDIR}"
538 -testsdir "${QT5_TESTSDIR}"
540 # configure in release mode by default,
541 # override via the CONFIG qmake variable
543 -no-separate-debug-info
545 # no need to forcefully build host tools in optimized mode,
546 # just follow the overall debug/release build type
550 -opensource -confirm-license
552 # autodetect the highest supported version of the C++ standard
553 #-c++std <c++11|c++14|c++1z>
555 # build shared libraries
558 # always enable large file support
559 $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -largefile)
561 # disabling accessibility is not recommended by upstream, as
562 # it will break QStyle and may break other internal parts of Qt
565 # disable all SQL drivers by default, override in qtsql
566 -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc
567 -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds
569 # ensure the QML debugging support (qmltooling) is built in qtdeclarative
572 # MIPS DSP instruction set extensions
573 $(is-flagq -mno-dsp && echo -no-mips_dsp)
574 $(is-flagq -mno-dspr2 && echo -no-mips_dspr2)
576 # use pkg-config to detect include and library paths
579 # prefer system libraries (only common hard deps here)
582 -system-doubleconversion
584 # disable everything to prevent automagic deps (part 1)
586 -no-journald -no-syslog
587 -no-libpng -no-libjpeg
588 -no-freetype -no-harfbuzz
589 -no-openssl -no-libproxy
590 -no-xkbcommon-x11 -no-xkbcommon-evdev
591 -no-xinput2 -no-xcb-xlib
593 # cannot use -no-gif because there is no way to override it later
596 # always enable glib event loop support
599 # disable everything to prevent automagic deps (part 2)
601 $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-pulseaudio -no-alsa)
603 # exclude examples and tests from default build
608 # disable rpath on non-prefix (bugs 380415 and 417169)
609 $(usex prefix '' -no-rpath)
611 # print verbose information about each configure test
614 # always enable iconv support
615 # since 5.8 this is handled in qtcore
616 $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -iconv)
618 # disable everything to prevent automagic deps (part 3)
619 -no-cups -no-evdev -no-tslib -no-icu -no-fontconfig -no-dbus
621 # let portage handle stripping
624 # precompiled headers can cause problems on hardened, so turn them off
627 # link-time code generation is not something we want to enable by default
630 # reduced relocations cause major breakage on at least arm and ppc, so
631 # don't specify anything and let the configure figure out if they are
632 # supported; see also https://bugreports.qt.io/browse/QTBUG-36129
635 # use the system linker (gold will be selected automagically otherwise)
636 $(tc-ld-is-gold && echo -use-gold-linker || echo -no-use-gold-linker)
638 # disable all platform plugins by default, override in qtgui
639 -no-xcb -no-eglfs -no-kms -no-gbm -no-directfb -no-linuxfb -no-mirclient
641 # disable undocumented X11-related flags, override in qtgui
642 # (not shown in ./configure -help output)
644 $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-xrender)
646 # disable obsolete/unused X11-related flags
647 $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-mitshm -no-xcursor -no-xfixes -no-xrandr -no-xshape -no-xsync)
649 # always enable session management support: it doesn't need extra deps
650 # at configure time and turning it off is dangerous, see bug 518262
653 # typedef qreal to double (warning: changing this flag breaks the ABI)
656 # disable OpenGL and EGL support by default, override in qtgui,
657 # qtopengl, qtprintsupport and qtwidgets
660 # disable libinput-based generic plugin by default, override in qtgui
663 # disable gstreamer by default, override in qtmultimedia
664 $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-gstreamer)
666 # respect system proxies by default: it's the most natural
667 # setting, and it'll become the new upstream default in 5.8
670 # do not build with -Werror
671 -no-warnings-are-errors
673 # module-specific options
677 pushd "${QT5_BUILD_DIR}" >/dev/null || die
679 einfo "Configuring with: ${conf[@]}"
680 "${S}"/configure "${conf[@]}" || die "configure failed"
682 if [[ ${QT5_MINOR_VERSION} -ge 8 ]]; then
683 # a forwarding header is no longer created since 5.8, causing the system
684 # config to always be used. bug 599636
685 cp src/corelib/global/qconfig.h include/QtCore/ || die
688 popd >/dev/null || die
692 # @FUNCTION: qt5_qmake
695 # Helper function that runs qmake in the current target subdir.
696 # Intended to be called by qt5_foreach_target_subdir().
698 local projectdir=${PWD/#${QT5_BUILD_DIR}/${S}}
700 if [[ ${QT5_MODULE} == qtbase ]]; then
701 qmakepath=${QT5_BUILD_DIR}/bin
703 qmakepath=${QT5_BINDIR}
706 "${qmakepath}"/qmake \
708 CONFIG+=$(usex debug debug release) \
709 CONFIG-=$(usex debug release debug) \
710 QMAKE_AR="$(tc-getAR) cqs" \
711 QMAKE_CC="$(tc-getCC)" \
712 QMAKE_LINK_C="$(tc-getCC)" \
713 QMAKE_LINK_C_SHLIB="$(tc-getCC)" \
714 QMAKE_CXX="$(tc-getCXX)" \
715 QMAKE_LINK="$(tc-getCXX)" \
716 QMAKE_LINK_SHLIB="$(tc-getCXX)" \
717 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
719 QMAKE_STRIP="$(tc-getSTRIP)" \
720 QMAKE_CFLAGS="${CFLAGS}" \
721 QMAKE_CFLAGS_RELEASE= \
722 QMAKE_CFLAGS_DEBUG= \
723 QMAKE_CXXFLAGS="${CXXFLAGS}" \
724 QMAKE_CXXFLAGS_RELEASE= \
725 QMAKE_CXXFLAGS_DEBUG= \
726 QMAKE_LFLAGS="${LDFLAGS}" \
727 QMAKE_LFLAGS_RELEASE= \
728 QMAKE_LFLAGS_DEBUG= \
729 "${myqmakeargs[@]}" \
730 || die "qmake failed (${projectdir#${S}/})"
733 # @FUNCTION: qt5_install_module_qconfigs
736 # Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
737 qt5_install_module_qconfigs() {
738 local x qconfig_add= qconfig_remove=
740 > "${T}"/${PN}-qconfig.h
741 > "${T}"/${PN}-qconfig.pri
743 # generate qconfig_{add,remove} and ${PN}-qconfig.h
744 for x in "${QT5_GENTOO_CONFIG[@]}"; do
747 local feature=${x%%:*}
750 macro=$(tr 'a-z-' 'A-Z_' <<< "${macro}")
752 if [[ -z ${flag} ]] || { [[ ${flag} != '!' ]] && use ${flag}; }; then
753 [[ -n ${feature} ]] && qconfig_add+=" ${feature}"
754 [[ -n ${macro} ]] && echo "#define QT_${macro}" >> "${T}"/${PN}-qconfig.h
756 [[ -n ${feature} ]] && qconfig_remove+=" ${feature}"
757 [[ -n ${macro} ]] && echo "#define QT_NO_${macro}" >> "${T}"/${PN}-qconfig.h
761 # install ${PN}-qconfig.h
762 [[ -s ${T}/${PN}-qconfig.h ]] && (
763 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
764 doins "${T}"/${PN}-qconfig.h
767 # generate and install ${PN}-qconfig.pri
768 [[ -n ${qconfig_add} ]] && echo "QCONFIG_ADD=${qconfig_add}" >> "${T}"/${PN}-qconfig.pri
769 [[ -n ${qconfig_remove} ]] && echo "QCONFIG_REMOVE=${qconfig_remove}" >> "${T}"/${PN}-qconfig.pri
770 [[ -s ${T}/${PN}-qconfig.pri ]] && (
771 insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo
772 doins "${T}"/${PN}-qconfig.pri
776 # @FUNCTION: qt5_regenerate_global_qconfigs
779 # Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
780 # Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
781 qt5_regenerate_global_qconfigs() {
782 einfo "Regenerating gentoo-qconfig.h"
784 find "${ROOT%/}${QT5_HEADERDIR}"/Gentoo \
785 -name '*-qconfig.h' -a \! -name 'gentoo-qconfig.h' -type f \
786 -execdir cat '{}' + | sort -u > "${T}"/gentoo-qconfig.h
788 [[ -s ${T}/gentoo-qconfig.h ]] || ewarn "Generated gentoo-qconfig.h is empty"
789 mv -f "${T}"/gentoo-qconfig.h "${ROOT%/}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \
790 || eerror "Failed to install new gentoo-qconfig.h"
792 einfo "Updating QT_CONFIG in qconfig.pri"
794 local qconfig_pri=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri
795 if [[ -f ${qconfig_pri} ]]; then
796 local x qconfig_add= qconfig_remove=
797 local qt_config=$(sed -n 's/^QT_CONFIG\s*+=\s*//p' "${qconfig_pri}")
800 # generate list of QT_CONFIG entries from the existing list,
801 # appending QCONFIG_ADD and excluding QCONFIG_REMOVE
802 eshopts_push -s nullglob
803 for x in "${ROOT%/}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
804 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=\s*//p' "${x}")"
805 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=\s*//p' "${x}")"
808 for x in ${qt_config} ${qconfig_add}; do
809 if ! has "${x}" ${new_qt_config} ${qconfig_remove}; then
810 new_qt_config+=" ${x}"
814 # now replace the existing QT_CONFIG with the generated list
815 sed -i -e "s/^QT_CONFIG\s*+=.*/QT_CONFIG +=${new_qt_config}/" \
816 "${qconfig_pri}" || eerror "Failed to sed QT_CONFIG in ${qconfig_pri}"
818 ewarn "${qconfig_pri} does not exist or is not a regular file"