1 # Copyright 1999-2020 Gentoo Authors
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: QT5_GENTOO_PRIVATE_CONFIG
48 # Array of <useflag:feature> pairs that are evaluated in src_install
49 # to generate the per-package list of enabled QT.global_private features,
50 # which are then merged together with all other Qt5 packages installed on the
51 # system to obtain the global qmodule.pri file.
53 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
55 # For proper description see virtualx.eclass man page.
56 # Here we redefine default value to be manual, if your package needs virtualx
57 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
58 : ${VIRTUALX_REQUIRED:=manual}
60 inherit estack flag-o-matic toolchain-funcs virtualx
62 HOMEPAGE="https://www.qt.io/"
63 LICENSE="|| ( GPL-2 GPL-3 LGPL-3 ) FDL-1.3"
66 QT5_MINOR_VERSION=$(ver_cut 2)
67 readonly QT5_MINOR_VERSION
75 5.?.9999|5.??.9999|5.???.9999)
78 EGIT_BRANCH=${PV%.9999}
80 *_alpha*|*_beta*|*_rc*)
82 QT5_BUILD_TYPE="release"
83 MY_P=${QT5_MODULE}-everywhere-src-${PV/_/-}
84 SRC_URI="https://download.qt.io/development_releases/qt/${PV%.*}/${PV/_/-}/submodules/${MY_P}.tar.xz"
88 # official stable release
89 QT5_BUILD_TYPE="release"
90 MY_P=${QT5_MODULE}-everywhere-src-${PV}
91 SRC_URI="https://download.qt.io/official_releases/qt/${PV%.*}/${PV}/submodules/${MY_P}.tar.xz"
95 readonly QT5_BUILD_TYPE
98 "https://code.qt.io/qt/${QT5_MODULE}.git"
99 "https://github.com/qt/${QT5_MODULE}.git"
101 [[ ${QT5_BUILD_TYPE} == live ]] && inherit git-r3
103 # @ECLASS-VARIABLE: QT5_BUILD_DIR
106 # Build directory for out-of-source builds.
107 case ${QT5_BUILD_TYPE} in
108 live) : ${QT5_BUILD_DIR:=${S}_build} ;;
109 release) : ${QT5_BUILD_DIR:=${S}} ;; # workaround for bug 497312
114 [[ ${QT5_BUILD_TYPE} == release ]] && RESTRICT+=" test" # bug 457182
120 if [[ ${PN} != qttest ]]; then
121 DEPEND+=" test? ( ~dev-qt/qttest-${PV} )"
128 ###### Phase functions ######
130 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm
132 # @FUNCTION: qt5-build_src_unpack
134 # Unpacks the sources.
135 qt5-build_src_unpack() {
137 if [[ ${PN} == qtwebengine ]]; then
138 eshopts_push -s extglob
139 if is-flagq '-g?(gdb)?([1-9])'; then
141 ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
142 ewarn "You may experience really long compilation times and/or increased memory usage."
143 ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
149 case ${QT5_BUILD_TYPE} in
150 live) git-r3_src_unpack ;&
155 # @FUNCTION: qt5-build_src_prepare
157 # Prepares the environment and patches the sources if necessary.
158 qt5-build_src_prepare() {
161 if [[ ${QT5_MODULE} == qtbase ]]; then
162 qt5_symlink_tools_to_build_dir
164 # Avoid unnecessary qmake recompilations
165 sed -i -e "/Creating qmake/i if [ '!' -e \"\$outpath/bin/qmake\" ]; then" \
166 -e '/echo "Done."/a fi' configure || die "sed failed (skip qmake bootstrap)"
168 # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when bootstrapping qmake
169 sed -i -e "/outpath\/qmake\".*\"\$MAKE\")/ s|)| \
170 ${MAKEOPTS} ${EXTRA_EMAKE} 'CC=$(tc-getCC)' 'CXX=$(tc-getCXX)' \
171 'QMAKE_CFLAGS=${CFLAGS}' 'QMAKE_CXXFLAGS=${CXXFLAGS}' 'QMAKE_LFLAGS=${LDFLAGS}'&|" \
172 -e 's/\(setBootstrapVariable\s\+\|EXTRA_C\(XX\)\?FLAGS=.*\)QMAKE_C\(XX\)\?FLAGS_\(DEBUG\|RELEASE\).*/:/' \
173 configure || die "sed failed (respect env for qmake build)"
174 sed -i -e '/^CPPFLAGS\s*=/ s/-g //' \
175 qmake/Makefile.unix || die "sed failed (CPPFLAGS for qmake build)"
177 # Respect CXX in bsymbolic_functions, fvisibility, precomp, and a few other tests
178 sed -i -e "/^QMAKE_CONF_COMPILER=/ s:=.*:=\"$(tc-getCXX)\":" \
179 configure || die "sed failed (QMAKE_CONF_COMPILER)"
181 # Respect build variables in configure tests (bug #639494)
182 sed -i -e "s|\"\$outpath/bin/qmake\" \"\$relpathMangled\" -- \"\$@\"|& $(qt5_qmake_args) |" configure || die
188 # @FUNCTION: qt5-build_src_configure
190 # Runs qmake in the target directories. For packages
191 # in qtbase, ./configure is also run before qmake.
192 qt5-build_src_configure() {
193 if [[ ${QT5_MODULE} == qtbase ]]; then
197 qt5_foreach_target_subdir qt5_qmake
200 # @FUNCTION: qt5-build_src_compile
202 # Runs emake in the target directories.
203 qt5-build_src_compile() {
204 qt5_foreach_target_subdir emake
207 # @FUNCTION: qt5-build_src_test
209 # Runs tests in the target directories.
210 qt5-build_src_test() {
211 # disable broken cmake tests (bug 474004)
212 local myqmakeargs=("${myqmakeargs[@]}" -after SUBDIRS-=cmake SUBDIRS-=installed_cmake)
214 qt5_foreach_target_subdir qt5_qmake
215 qt5_foreach_target_subdir emake
217 # create a custom testrunner script that correctly sets
218 # LD_LIBRARY_PATH before executing the given test
219 local testrunner=${QT5_BUILD_DIR}/gentoo-testrunner
220 cat > "${testrunner}" <<-_EOF_ || die
222 export LD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}"
225 chmod +x "${testrunner}"
227 set -- qt5_foreach_target_subdir emake TESTRUNNER="'${testrunner}'" check
228 if [[ ${VIRTUALX_REQUIRED} == test ]]; then
235 # @FUNCTION: qt5-build_src_install
237 # Runs emake install in the target directories.
238 qt5-build_src_install() {
239 qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install
241 if [[ ${PN} == qtcore ]]; then
242 pushd "${QT5_BUILD_DIR}" >/dev/null || die
244 set -- emake INSTALL_ROOT="${D}" \
245 sub-qmake-qmake-aux-pro-install_subtargets \
246 install_{syncqt,mkspecs}
251 popd >/dev/null || die
253 # install an empty Gentoo/gentoo-qconfig.h in ${D}
254 # so that it's placed under package manager control
255 > "${T}"/gentoo-qconfig.h
257 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
258 doins "${T}"/gentoo-qconfig.h
261 # include gentoo-qconfig.h at the beginning of QtCore/qconfig.h
262 sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
263 "${D}${QT5_HEADERDIR}"/QtCore/qconfig.h \
264 || die "sed failed (qconfig.h)"
266 # install qtchooser configuration file
267 cat > "${T}/qt5-${CHOST}.conf" <<-_EOF_ || die
273 insinto /etc/xdg/qtchooser
274 doins "${T}/qt5-${CHOST}.conf"
277 # convenience symlinks
278 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/5.conf
279 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/qt5.conf
280 # TODO bug 522646: write an eselect module to manage default.conf
281 dosym qt5.conf /etc/xdg/qtchooser/default.conf
284 qt5_install_module_config
286 # prune libtool files
287 find "${D}" -name '*.la' -type f -delete || die
290 # @FUNCTION: qt5-build_pkg_postinst
292 # Regenerate configuration after installation or upgrade/downgrade.
293 qt5-build_pkg_postinst() {
294 qt5_regenerate_global_configs
297 # @FUNCTION: qt5-build_pkg_postrm
299 # Regenerate configuration when a module is completely removed.
300 qt5-build_pkg_postrm() {
301 if [[ -z ${REPLACED_BY_VERSION} && ${PN} != qtcore ]]; then
302 qt5_regenerate_global_configs
307 ###### Public helpers ######
310 # @USAGE: <flag> [feature] [enableval]
312 # <flag> is the name of a flag in IUSE.
314 # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
315 # otherwise. If [feature] is not specified, <flag> is used in its place.
316 # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
318 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
320 usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
323 # @FUNCTION: qt_use_compile_test
324 # @USAGE: <flag> [config]
326 # <flag> is the name of a flag in IUSE.
327 # [config] is the argument of qtCompileTest, defaults to <flag>.
329 # This function is useful to disable optional dependencies that are checked
330 # at qmake-time using the qtCompileTest() function. If <flag> is disabled,
331 # the compile test is skipped and the dependency is assumed to be unavailable,
332 # i.e. the corresponding feature will be disabled. Note that all invocations
333 # of this function must happen before calling qt5-build_src_configure.
334 qt_use_compile_test() {
335 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
338 mkdir -p "${QT5_BUILD_DIR}" || die
339 echo "CONFIG += done_config_${2:-$1}" >> "${QT5_BUILD_DIR}"/.qmake.cache || die
343 # @FUNCTION: qt_use_disable_config
344 # @USAGE: <flag> <config> <files...>
346 # <flag> is the name of a flag in IUSE.
347 # <config> is the (lowercase) name of a Qt5 config entry.
348 # <files...> is a list of one or more qmake project files.
350 # This function patches <files> to treat <config> as disabled
351 # when <flag> is disabled, otherwise it does nothing.
352 # This can be useful to avoid an automagic dependency when the config entry
353 # is enabled on the system but the corresponding USE flag is disabled.
354 qt_use_disable_config() {
355 [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
361 if ! use "${flag}"; then
362 echo "$@" | xargs sed -i -e "s/qtConfig(${config})/false/g" || die
366 # @FUNCTION: qt_use_disable_mod
367 # @USAGE: <flag> <module> <files...>
369 # <flag> is the name of a flag in IUSE.
370 # <module> is the (lowercase) name of a Qt5 module.
371 # <files...> is a list of one or more qmake project files.
373 # This function patches <files> to treat <module> as not installed
374 # when <flag> is disabled, otherwise it does nothing.
375 # This can be useful to avoid an automagic dependency when the module
376 # is present on the system but the corresponding USE flag is disabled.
377 qt_use_disable_mod() {
378 [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
384 if ! use "${flag}"; then
385 echo "$@" | xargs sed -i -e "s/qtHaveModule(${module})/false/g" || die
390 ###### Internal functions ######
392 # @FUNCTION: qt5_prepare_env
395 # Prepares the environment for building Qt.
397 # setup installation directories
398 # note: keep paths in sync with qmake-utils.eclass
399 QT5_PREFIX=${EPREFIX}/usr
400 QT5_HEADERDIR=${QT5_PREFIX}/include/qt5
401 QT5_LIBDIR=${QT5_PREFIX}/$(get_libdir)
402 QT5_ARCHDATADIR=${QT5_PREFIX}/$(get_libdir)/qt5
403 QT5_BINDIR=${QT5_ARCHDATADIR}/bin
404 QT5_PLUGINDIR=${QT5_ARCHDATADIR}/plugins
405 QT5_LIBEXECDIR=${QT5_ARCHDATADIR}/libexec
406 QT5_IMPORTDIR=${QT5_ARCHDATADIR}/imports
407 QT5_QMLDIR=${QT5_ARCHDATADIR}/qml
408 QT5_DATADIR=${QT5_PREFIX}/share/qt5
409 QT5_DOCDIR=${QT5_PREFIX}/share/qt5-doc
410 QT5_TRANSLATIONDIR=${QT5_DATADIR}/translations
411 QT5_EXAMPLESDIR=${QT5_DATADIR}/examples
412 QT5_TESTSDIR=${QT5_DATADIR}/tests
413 QT5_SYSCONFDIR=${EPREFIX}/etc/xdg
414 readonly QT5_PREFIX QT5_HEADERDIR QT5_LIBDIR QT5_ARCHDATADIR \
415 QT5_BINDIR QT5_PLUGINDIR QT5_LIBEXECDIR QT5_IMPORTDIR \
416 QT5_QMLDIR QT5_DATADIR QT5_DOCDIR QT5_TRANSLATIONDIR \
417 QT5_EXAMPLESDIR QT5_TESTSDIR QT5_SYSCONFDIR
419 if [[ ${QT5_MODULE} == qtbase ]]; then
420 # see mkspecs/features/qt_config.prf
421 export QMAKEMODULES="${QT5_BUILD_DIR}/mkspecs/modules:${S}/mkspecs/modules:${QT5_ARCHDATADIR}/mkspecs/modules"
425 # @FUNCTION: qt5_foreach_target_subdir
428 # Executes the command given as argument from inside each directory
429 # listed in QT5_TARGET_SUBDIRS. Handles autotests subdirs automatically.
430 qt5_foreach_target_subdir() {
431 [[ -z ${QT5_TARGET_SUBDIRS[@]} ]] && QT5_TARGET_SUBDIRS=("")
434 for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do
435 if [[ ${EBUILD_PHASE} == test ]]; then
436 subdir=tests/auto${subdir#src}
437 [[ -d ${S}/${subdir} ]] || continue
440 local msg="Running $* ${subdir:+in ${subdir}}"
443 mkdir -p "${QT5_BUILD_DIR}/${subdir}" || die -n || return $?
444 pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die -n || return $?
446 "$@" || die -n "${msg} failed" || return $?
448 popd >/dev/null || die -n || return $?
452 # @FUNCTION: qt5_symlink_tools_to_build_dir
455 # Symlinks qmake and a few other tools to QT5_BUILD_DIR,
456 # so that they can be used when building other modules.
457 qt5_symlink_tools_to_build_dir() {
459 if [[ ${PN} != qtcore ]]; then
460 tools+=(qmake moc rcc qlalr)
461 [[ ${PN} != qtdbus ]] && tools+=(qdbuscpp2xml qdbusxml2cpp)
462 [[ ${PN} != qtwidgets ]] && tools+=(uic)
465 mkdir -p "${QT5_BUILD_DIR}"/bin || die
466 pushd "${QT5_BUILD_DIR}"/bin >/dev/null || die
468 for tool in "${tools[@]}"; do
469 [[ -e ${QT5_BINDIR}/${tool} ]] || continue
470 ln -s "${QT5_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
473 popd >/dev/null || die
476 # @FUNCTION: qt5_base_configure
479 # Runs ./configure for modules belonging to qtbase.
480 qt5_base_configure() {
481 # setup toolchain variables used by configure
482 tc-export AR CC CXX OBJDUMP RANLIB STRIP
483 export LD="$(tc-getCXX)"
486 unset QMAKESPEC XQMAKESPEC QMAKEPATH QMAKEFEATURES
488 # configure arguments
491 -prefix "${QT5_PREFIX}"
492 -bindir "${QT5_BINDIR}"
493 -headerdir "${QT5_HEADERDIR}"
494 -libdir "${QT5_LIBDIR}"
495 -archdatadir "${QT5_ARCHDATADIR}"
496 -plugindir "${QT5_PLUGINDIR}"
497 -libexecdir "${QT5_LIBEXECDIR}"
498 -importdir "${QT5_IMPORTDIR}"
499 -qmldir "${QT5_QMLDIR}"
500 -datadir "${QT5_DATADIR}"
501 -docdir "${QT5_DOCDIR}"
502 -translationdir "${QT5_TRANSLATIONDIR}"
503 -sysconfdir "${QT5_SYSCONFDIR}"
504 -examplesdir "${QT5_EXAMPLESDIR}"
505 -testsdir "${QT5_TESTSDIR}"
507 # force appropriate compiler
508 $(if use kernel_FreeBSD; then
510 echo -platform freebsd-g++
511 elif tc-is-clang; then
512 echo -platform freebsd-clang
515 $(if use kernel_linux; then
517 echo -platform linux-g++
518 elif tc-is-clang; then
519 echo -platform linux-clang
523 # configure in release mode by default,
524 # override via the CONFIG qmake variable
526 -no-separate-debug-info
528 # no need to forcefully build host tools in optimized mode,
529 # just follow the overall debug/release build type
533 -opensource -confirm-license
535 # autodetect the highest supported version of the C++ standard
536 #-c++std <c++11|c++14|c++1z>
538 # build shared libraries
541 # disabling accessibility is not recommended by upstream, as
542 # it will break QStyle and may break other internal parts of Qt
545 # disable all SQL drivers by default, override in qtsql
546 -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc
547 -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds
549 # MIPS DSP instruction set extensions
550 $(is-flagq -mno-dsp && echo -no-mips_dsp)
551 $(is-flagq -mno-dspr2 && echo -no-mips_dspr2)
553 # use pkg-config to detect include and library paths
556 # prefer system libraries (only common hard deps here)
559 -system-doubleconversion
561 # disable everything to prevent automagic deps (part 1)
563 -no-journald -no-syslog
564 -no-libpng -no-libjpeg
565 -no-freetype -no-harfbuzz
566 -no-openssl -no-libproxy
571 $([[ ${QT5_MINOR_VERSION} -lt 15 ]] && echo -no-xcb-xinput)
572 $([[ ${QT5_MINOR_VERSION} -ge 15 ]] && echo -no-bundled-xcb-xinput)
574 # cannot use -no-gif because there is no way to override it later
577 # always enable glib event loop support
580 # disable everything to prevent automagic deps (part 2)
583 # exclude examples and tests from default build
588 # disable rpath on non-prefix (bugs 380415 and 417169)
589 $(usex prefix '' -no-rpath)
591 # print verbose information about each configure test
594 # disable everything to prevent automagic deps (part 3)
595 -no-cups -no-evdev -no-tslib -no-icu -no-fontconfig -no-dbus
597 # let portage handle stripping
600 # precompiled headers can cause problems on hardened, so turn them off
603 # link-time code generation is not something we want to enable by default
606 # reduced relocations cause major breakage on at least arm and ppc, so
607 # don't specify anything and let the configure figure out if they are
608 # supported; see also https://bugreports.qt.io/browse/QTBUG-36129
611 # use the system linker (gold will be selected automagically otherwise)
612 $(tc-ld-is-gold && echo -use-gold-linker || echo -no-use-gold-linker)
614 # disable all platform plugins by default, override in qtgui
615 -no-xcb -no-eglfs -no-kms -no-gbm -no-directfb -no-linuxfb
616 $([[ ${QT5_MINOR_VERSION} -lt 14 ]] && echo -no-mirclient)
618 # disable undocumented X11-related flags, override in qtgui
619 # (not shown in ./configure -help output)
620 $([[ ${QT5_MINOR_VERSION} -lt 15 ]] && echo -no-xkb)
622 # always enable session management support: it doesn't need extra deps
623 # at configure time and turning it off is dangerous, see bug 518262
626 # typedef qreal to double (warning: changing this flag breaks the ABI)
629 # disable OpenGL and EGL support by default, override in qtgui,
630 # qtopengl, qtprintsupport and qtwidgets
633 # disable libinput-based generic plugin by default, override in qtgui
636 # respect system proxies by default: it's the most natural
637 # setting, and it'll become the new upstream default in 5.8
640 # do not build with -Werror
641 -no-warnings-are-errors
643 # enable in respective modules to avoid poisoning QT.global_private.enabled_features
646 # QTBUG-76521, default will change to zstd in Qt6
649 # module-specific options
653 pushd "${QT5_BUILD_DIR}" >/dev/null || die
655 einfo "Configuring with: ${conf[@]}"
656 "${S}"/configure "${conf[@]}" || die "configure failed"
658 # a forwarding header is no longer created since 5.8, causing the system
659 # config to always be used. bug 599636
660 cp src/corelib/global/qconfig.h include/QtCore/ || die
662 popd >/dev/null || die
666 # @FUNCTION: qt5_qmake_args
669 # Helper function to get the various toolchain-related variables.
672 QMAKE_AR=\"$(tc-getAR)\" \
673 QMAKE_CC=\"$(tc-getCC)\" \
674 QMAKE_LINK_C=\"$(tc-getCC)\" \
675 QMAKE_LINK_C_SHLIB=\"$(tc-getCC)\" \
676 QMAKE_CXX=\"$(tc-getCXX)\" \
677 QMAKE_LINK=\"$(tc-getCXX)\" \
678 QMAKE_LINK_SHLIB=\"$(tc-getCXX)\" \
679 QMAKE_OBJCOPY=\"$(tc-getOBJCOPY)\" \
681 QMAKE_STRIP=\"$(tc-getSTRIP)\" \
682 QMAKE_CFLAGS=\"${CFLAGS}\" \
683 QMAKE_CFLAGS_RELEASE= \
684 QMAKE_CFLAGS_DEBUG= \
685 QMAKE_CXXFLAGS=\"${CXXFLAGS}\" \
686 QMAKE_CXXFLAGS_RELEASE= \
687 QMAKE_CXXFLAGS_DEBUG= \
688 QMAKE_LFLAGS=\"${LDFLAGS}\" \
689 QMAKE_LFLAGS_RELEASE= \
693 # @FUNCTION: qt5_qmake
696 # Helper function that runs qmake in the current target subdir.
697 # Intended to be called by qt5_foreach_target_subdir().
699 local projectdir=${PWD/#${QT5_BUILD_DIR}/${S}}
701 if [[ ${QT5_MODULE} == qtbase ]]; then
702 qmakepath=${QT5_BUILD_DIR}/bin
704 qmakepath=${QT5_BINDIR}
707 "${qmakepath}"/qmake \
709 CONFIG+=$(usex debug debug release) \
710 CONFIG-=$(usex debug release debug) \
711 QMAKE_AR="$(tc-getAR) cqs" \
712 QMAKE_CC="$(tc-getCC)" \
713 QMAKE_LINK_C="$(tc-getCC)" \
714 QMAKE_LINK_C_SHLIB="$(tc-getCC)" \
715 QMAKE_CXX="$(tc-getCXX)" \
716 QMAKE_LINK="$(tc-getCXX)" \
717 QMAKE_LINK_SHLIB="$(tc-getCXX)" \
718 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
720 QMAKE_STRIP="$(tc-getSTRIP)" \
721 QMAKE_CFLAGS="${CFLAGS}" \
722 QMAKE_CFLAGS_RELEASE= \
723 QMAKE_CFLAGS_DEBUG= \
724 QMAKE_CXXFLAGS="${CXXFLAGS}" \
725 QMAKE_CXXFLAGS_RELEASE= \
726 QMAKE_CXXFLAGS_DEBUG= \
727 QMAKE_LFLAGS="${LDFLAGS}" \
728 QMAKE_LFLAGS_RELEASE= \
729 QMAKE_LFLAGS_DEBUG= \
730 "${myqmakeargs[@]}" \
731 || die "qmake failed (${projectdir#${S}/})"
734 # @FUNCTION: qt5_install_module_config
737 # Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} and
738 # ${PN}-qmodule.pri files.
739 qt5_install_module_config() {
740 local x qconfig_add= qconfig_remove= qprivateconfig_add= qprivateconfig_remove=
742 > "${T}"/${PN}-qconfig.h
743 > "${T}"/${PN}-qconfig.pri
744 > "${T}"/${PN}-qmodule.pri
746 # generate qconfig_{add,remove} and ${PN}-qconfig.h
747 for x in "${QT5_GENTOO_CONFIG[@]}"; do
750 local feature=${x%%:*}
753 macro=$(tr 'a-z-' 'A-Z_' <<< "${macro}")
755 if [[ -z ${flag} ]] || { [[ ${flag} != '!' ]] && use ${flag}; }; then
756 [[ -n ${feature} ]] && qconfig_add+=" ${feature}"
757 [[ -n ${macro} ]] && echo "#define QT_${macro}" >> "${T}"/${PN}-qconfig.h
759 [[ -n ${feature} ]] && qconfig_remove+=" ${feature}"
760 [[ -n ${macro} ]] && echo "#define QT_NO_${macro}" >> "${T}"/${PN}-qconfig.h
764 # install ${PN}-qconfig.h
765 [[ -s ${T}/${PN}-qconfig.h ]] && (
766 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
767 doins "${T}"/${PN}-qconfig.h
770 # generate and install ${PN}-qconfig.pri
771 [[ -n ${qconfig_add} ]] && echo "QCONFIG_ADD=${qconfig_add}" >> "${T}"/${PN}-qconfig.pri
772 [[ -n ${qconfig_remove} ]] && echo "QCONFIG_REMOVE=${qconfig_remove}" >> "${T}"/${PN}-qconfig.pri
773 [[ -s ${T}/${PN}-qconfig.pri ]] && (
774 insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo
775 doins "${T}"/${PN}-qconfig.pri
778 # generate qprivateconfig
779 for x in "${QT5_GENTOO_PRIVATE_CONFIG[@]}"; do
782 local feature=${x%%:*}
785 if [[ -z ${flag} ]] || { [[ ${flag} != '!' ]] && use ${flag}; }; then
786 [[ -n ${feature} ]] && qprivateconfig_add+=" ${feature}"
788 [[ -n ${feature} ]] && qprivateconfig_remove+=" ${feature}"
792 # generate and install ${PN}-qmodule.pri
793 [[ -n ${qprivateconfig_add} ]] && echo "QT.global_private.enabled_features = ${qprivateconfig_add}" >> "${T}"/${PN}-qmodule.pri
794 [[ -n ${qprivateconfig_remove} ]] && echo "QT.global_private.disabled_features = ${qprivateconfig_remove}" >> "${T}"/${PN}-qmodule.pri
795 [[ -s ${T}/${PN}-qmodule.pri ]] && (
796 insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo
797 doins "${T}"/${PN}-qmodule.pri
800 # install the original {qconfig,qmodule}.pri from qtcore
801 [[ ${PN} == qtcore ]] && (
802 insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo
803 newins "${D}${QT5_ARCHDATADIR}"/mkspecs/qconfig.pri qconfig-qtcore.pri
804 newins "${D}${QT5_ARCHDATADIR}"/mkspecs/qmodule.pri qmodule-qtcore.pri
808 # @FUNCTION: qt5_regenerate_global_configs
811 # Generates Gentoo-specific qconfig.{h,pri} and qmodule.pri according to the
812 # build configuration.
813 # Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
814 qt5_regenerate_global_configs() {
815 einfo "Regenerating gentoo-qconfig.h"
817 find "${ROOT}${QT5_HEADERDIR}"/Gentoo \
818 -name '*-qconfig.h' -a \! -name 'gentoo-qconfig.h' -type f \
819 -execdir cat '{}' + | sort -u > "${T}"/gentoo-qconfig.h
821 [[ -s ${T}/gentoo-qconfig.h ]] || ewarn "Generated gentoo-qconfig.h is empty"
822 cp "${T}"/gentoo-qconfig.h "${ROOT}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \
823 || eerror "Failed to install new gentoo-qconfig.h"
825 einfo "Updating QT_CONFIG in qconfig.pri"
827 local qconfig_pri=${ROOT}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri
828 local qconfig_pri_orig=${ROOT}${QT5_ARCHDATADIR}/mkspecs/gentoo/qconfig-qtcore.pri
829 if [[ -f ${qconfig_pri} ]]; then
830 local x qconfig_add= qconfig_remove=
831 local qt_config new_qt_config=
832 if [[ -f ${qconfig_pri_orig} ]]; then
833 qt_config=$(sed -n 's/^QT_CONFIG\s*+=\s*//p' "${qconfig_pri_orig}")
835 qt_config=$(sed -n 's/^QT_CONFIG\s*+=\s*//p' "${qconfig_pri}")
838 # generate list of QT_CONFIG entries from the existing list,
839 # appending QCONFIG_ADD and excluding QCONFIG_REMOVE
840 eshopts_push -s nullglob
841 for x in "${ROOT}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
842 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=\s*//p' "${x}")"
843 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=\s*//p' "${x}")"
846 for x in ${qt_config} ${qconfig_add}; do
847 if ! has "${x}" ${new_qt_config} ${qconfig_remove}; then
848 new_qt_config+=" ${x}"
852 # now replace the existing QT_CONFIG with the generated list
853 sed -i -e "s/^QT_CONFIG\s*+=.*/QT_CONFIG +=${new_qt_config}/" \
854 "${qconfig_pri}" || eerror "Failed to sed QT_CONFIG in ${qconfig_pri}"
856 ewarn "${qconfig_pri} does not exist or is not a regular file"
859 einfo "Updating QT.global_private in qmodule.pri"
861 local qmodule_pri=${ROOT}${QT5_ARCHDATADIR}/mkspecs/qmodule.pri
862 local qmodule_pri_orig=${ROOT}${QT5_ARCHDATADIR}/mkspecs/gentoo/qmodule-qtcore.pri
863 if [[ -f ${qmodule_pri} && -f ${qmodule_pri_orig} ]]; then
865 local qprivateconfig_enabled= qprivateconfig_disabled=
866 local qprivateconfig_orig_enabled= qprivateconfig_orig_disabled=
867 local new_qprivateconfig_enabled= new_qprivateconfig_disabled=
869 # generate lists of QT.global_private.{dis,en}abled_features
870 qprivateconfig_orig_enabled="$(sed -n 's/^QT.global_private.enabled_features\s=\s*//p' "${qmodule_pri_orig}")"
871 qprivateconfig_orig_disabled="$(sed -n 's/^QT.global_private.disabled_features\s=\s*//p' "${qmodule_pri_orig}")"
872 eshopts_push -s nullglob
873 for x in "${ROOT}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qmodule.pri; do
874 qprivateconfig_enabled+=" $(sed -n 's/^QT.global_private.enabled_features\s=\s*//p' "${x}")"
875 qprivateconfig_disabled+=" $(sed -n 's/^QT.global_private.disabled_features\s=\s*//p' "${x}")"
879 # anything enabled is enabled, but anything disabled is
880 # only disabled if it isn't enabled somewhere else.
881 # this is because we need to forcibly disable some stuff
882 # in qtcore to support split qtbase.
883 new_qprivateconfig_enabled=${qprivateconfig_enabled}
884 for x in ${qprivateconfig_disabled}; do
885 if ! has "${x}" ${qprivateconfig_enabled}; then
886 new_qprivateconfig_disabled+=" ${x}"
890 # check all items from the original qtcore qmodule.pri,
891 # and add them to the appropriate list if not overridden
893 for x in ${qprivateconfig_orig_enabled}; do
894 if ! has "${x}" ${new_qprivateconfig_enabled} ${new_qprivateconfig_disabled}; then
895 new_qprivateconfig_enabled+=" ${x}"
898 for x in ${qprivateconfig_orig_disabled}; do
899 if ! has "${x}" ${new_qprivateconfig_enabled} ${new_qprivateconfig_disabled}; then
900 new_qprivateconfig_disabled+=" ${x}"
904 # now replace the existing QT.global_private.{dis,en}abled_features
905 # with the generated list
907 -e "s/^QT.global_private.enabled_features\s*=.*/QT.global_private.enabled_features =${new_qprivateconfig_enabled}/" \
908 -e "s/^QT.global_private.disabled_features\s*=.*/QT.global_private.disabled_features =${new_qprivateconfig_disabled}/" \
909 -i "${qmodule_pri}" || eerror "Failed to sed QT.global_private.enabled_features in ${qmodule_pri}"
911 ewarn "${qmodule_pri} or ${qmodule_pri_orig} does not exist or is not a regular file"