1 # Copyright 1999-2016 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
5 # @ECLASS: qt5-build.eclass
9 # Davide Pesavento <pesa@gentoo.org>
10 # @BLURB: Eclass for Qt5 split ebuilds.
12 # This eclass contains various functions that are used when building Qt5.
13 # Requires EAPI 5 or 6.
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
26 # The upstream name of the module this package belongs to. Used for
27 # SRC_URI and EGIT_REPO_URI. Must be defined before inheriting the eclass.
28 : ${QT5_MODULE:=${PN}}
30 # @ECLASS-VARIABLE: QT5_TARGET_SUBDIRS
33 # Array variable containing the source directories that should be built.
34 # All paths must be relative to ${S}.
36 # @ECLASS-VARIABLE: QT5_GENTOO_CONFIG
39 # Array of <useflag:feature:macro> triplets that are evaluated in src_install
40 # to generate the per-package list of enabled QT_CONFIG features and macro
41 # definitions, which are then merged together with all other Qt5 packages
42 # installed on the system to obtain the global qconfig.{h,pri} files.
44 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
46 # For proper description see virtualx.eclass man page.
47 # Here we redefine default value to be manual, if your package needs virtualx
48 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
49 : ${VIRTUALX_REQUIRED:=manual}
51 [[ ${EAPI} == 5 ]] && inherit multilib
52 inherit eutils flag-o-matic toolchain-funcs versionator virtualx
54 HOMEPAGE="https://www.qt.io/"
56 QT5_MINOR_VERSION=$(get_version_component_range 2)
57 readonly QT5_MINOR_VERSION
59 if [[ ${QT5_MINOR_VERSION} -ge 7 ]]; then
60 LICENSE="|| ( GPL-2 GPL-3 LGPL-3 ) FDL-1.3"
62 LICENSE="|| ( LGPL-2.1 LGPL-3 ) FDL-1.3"
65 if [[ ${QT5_MINOR_VERSION} -ge 6 ]]; then
66 SLOT=5/$(get_version_component_range 1-2)
80 EGIT_BRANCH=${PV%.9999}
82 *_alpha*|*_beta*|*_rc*)
84 QT5_BUILD_TYPE="release"
85 MY_P=${QT5_MODULE}-opensource-src-${PV/_/-}
86 SRC_URI="https://download.qt.io/development_releases/qt/${PV%.*}/${PV/_/-}/submodules/${MY_P}.tar.xz"
90 # official stable release
91 QT5_BUILD_TYPE="release"
92 MY_P=${QT5_MODULE}-opensource-src-${PV}
93 SRC_URI="https://download.qt.io/official_releases/qt/${PV%.*}/${PV}/submodules/${MY_P}.tar.xz"
97 readonly QT5_BUILD_TYPE
100 "git://code.qt.io/qt/${QT5_MODULE}.git"
101 "https://code.qt.io/git/qt/${QT5_MODULE}.git"
102 "https://github.com/qtproject/${QT5_MODULE}.git"
104 [[ ${QT5_BUILD_TYPE} == live ]] && inherit git-r3
106 # @ECLASS-VARIABLE: QT5_BUILD_DIR
108 # Build directory for out-of-source builds.
109 case ${QT5_BUILD_TYPE} in
110 live) : ${QT5_BUILD_DIR:=${S}_build} ;;
111 release) : ${QT5_BUILD_DIR:=${S}} ;; # workaround for bug 497312
116 [[ ${PN} == qtwebkit ]] && RESTRICT+=" mirror" # bug 524584
117 [[ ${QT5_BUILD_TYPE} == release ]] && RESTRICT+=" test" # bug 457182
123 if [[ ${PN} != qttest ]]; then
124 DEPEND+=" test? ( ~dev-qt/qttest-${PV} )"
131 ###### Phase functions ######
133 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm
135 # @FUNCTION: qt5-build_src_unpack
137 # Unpacks the sources.
138 qt5-build_src_unpack() {
139 local min_gcc4_minor_version=5
140 if [[ ${QT5_MINOR_VERSION} -ge 7 || ${PN} == qtwebengine ]]; then
141 min_gcc4_minor_version=7
143 if [[ $(gcc-major-version) -lt 4 ]] || \
144 [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt ${min_gcc4_minor_version} ]]; then
145 if [[ ${QT5_MINOR_VERSION} -ge 6 ]]; 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"
150 ewarn "Using a GCC version lower than 4.${min_gcc4_minor_version} is not supported"
156 if [[ ${PN} == qtwebengine || ${PN} == qtwebkit ]]; then
157 eshopts_push -s extglob
158 if is-flagq '-g?(gdb)?([1-9])'; then
160 ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
161 ewarn "You may experience really long compilation times and/or increased memory usage."
162 ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
168 case ${QT5_BUILD_TYPE} in
169 live) git-r3_src_unpack ;;
174 # @FUNCTION: qt5-build_src_prepare
176 # Prepares the environment and patches the sources if necessary.
177 qt5-build_src_prepare() {
180 if [[ ${QT5_MODULE} == qtbase ]]; then
181 qt5_symlink_tools_to_build_dir
183 # Avoid unnecessary qmake recompilations
184 sed -i -re "s|^if true;.*(\[ '\!').*(\"\\\$outpath/bin/qmake\".*)|if \1 -e \2 then|" \
185 configure || die "sed failed (skip qmake bootstrap)"
187 # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when bootstrapping qmake
188 sed -i -e "/outpath\/qmake\".*\"\$MAKE\")/ s:): \
189 ${MAKEOPTS} ${EXTRA_EMAKE} 'CC=$(tc-getCC)' 'CXX=$(tc-getCXX)' \
190 'QMAKE_CFLAGS=${CFLAGS}' 'QMAKE_CXXFLAGS=${CXXFLAGS}' 'QMAKE_LFLAGS=${LDFLAGS}'&:" \
191 -e 's/\(setBootstrapVariable\s\+\|EXTRA_C\(XX\)\?FLAGS=.*\)QMAKE_C\(XX\)\?FLAGS_\(DEBUG\|RELEASE\).*/:/' \
192 configure || die "sed failed (respect env for qmake build)"
193 sed -i -e '/^CPPFLAGS\s*=/ s/-g //' \
194 qmake/Makefile.unix || die "sed failed (CPPFLAGS for qmake build)"
196 # Respect CXX in bsymbolic_functions, fvisibility, precomp, and a few other tests
197 sed -i -e "/^QMAKE_CONF_COMPILER=/ s:=.*:=\"$(tc-getCXX)\":" \
198 configure || die "sed failed (QMAKE_CONF_COMPILER)"
200 # Respect toolchain and flags in config.tests
201 find config.tests/unix -name '*.test' -type f -execdir \
202 sed -i -re '/(bin\/qmake|QMAKE")/ s/-nocache //' '{}' + || die
204 # Don't inject -msse/-mavx/... into CXXFLAGS when detecting
205 # compiler support for extended instruction sets (bug 552942)
206 find config.tests/common -name '*.pro' -type f -execdir \
207 sed -i -e '/QMAKE_CXXFLAGS\s*+=/ d' '{}' + || die
209 # Don't add -O3 to CXXFLAGS (bug 549140)
210 sed -i -e '/CONFIG\s*+=/ s/optimize_full//' \
211 src/{corelib/corelib,gui/gui}.pro || die "sed failed (optimize_full)"
214 if [[ ${EAPI} == 5 ]]; then
215 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
222 # @FUNCTION: qt5-build_src_configure
224 # Runs qmake in the target directories. For packages
225 # in qtbase, ./configure is also run before qmake.
226 qt5-build_src_configure() {
227 if [[ ${QT5_MODULE} == qtbase ]]; then
231 qt5_foreach_target_subdir qt5_qmake
234 # @FUNCTION: qt5-build_src_compile
236 # Runs emake in the target directories.
237 qt5-build_src_compile() {
238 qt5_foreach_target_subdir emake
241 # @FUNCTION: qt5-build_src_test
243 # Runs tests in the target directories.
244 qt5-build_src_test() {
245 # disable broken cmake tests (bug 474004)
246 local myqmakeargs=("${myqmakeargs[@]}" -after SUBDIRS-=cmake SUBDIRS-=installed_cmake)
248 qt5_foreach_target_subdir qt5_qmake
249 qt5_foreach_target_subdir emake
251 # create a custom testrunner script that correctly sets
252 # LD_LIBRARY_PATH before executing the given test
253 local testrunner=${QT5_BUILD_DIR}/gentoo-testrunner
254 cat > "${testrunner}" <<-_EOF_ || die
256 export LD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}"
259 chmod +x "${testrunner}"
261 set -- qt5_foreach_target_subdir emake TESTRUNNER="'${testrunner}'" check
262 if [[ ${VIRTUALX_REQUIRED} == test ]]; then
269 # @FUNCTION: qt5-build_src_install
271 # Runs emake install in the target directories.
272 qt5-build_src_install() {
273 qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install
275 if [[ ${PN} == qtcore ]]; then
276 pushd "${QT5_BUILD_DIR}" >/dev/null || die
278 local qmake_install_target=install_qmake
279 if [[ ${QT5_MINOR_VERSION} -ge 7 ]]; then
280 # qmake/qmake-aux.pro
281 qmake_install_target=sub-qmake-qmake-aux-pro-install_subtargets
284 set -- emake INSTALL_ROOT="${D}" \
285 ${qmake_install_target} \
286 install_{syncqt,mkspecs,global_docs}
290 popd >/dev/null || die
292 docompress -x "${QT5_DOCDIR#${EPREFIX}}"/global
294 # install an empty Gentoo/gentoo-qconfig.h in ${D}
295 # so that it's placed under package manager control
296 > "${T}"/gentoo-qconfig.h
298 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
299 doins "${T}"/gentoo-qconfig.h
302 # include gentoo-qconfig.h at the beginning of QtCore/qconfig.h
303 sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
304 "${D}${QT5_HEADERDIR}"/QtCore/qconfig.h \
305 || die "sed failed (qconfig.h)"
307 # install qtchooser configuration file
308 cat > "${T}/qt5-${CHOST}.conf" <<-_EOF_ || die
314 insinto /etc/xdg/qtchooser
315 doins "${T}/qt5-${CHOST}.conf"
318 # convenience symlinks
319 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/5.conf
320 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/qt5.conf
323 qt5_install_module_qconfigs
327 # @FUNCTION: qt5-build_pkg_postinst
329 # Regenerate configuration after installation or upgrade/downgrade.
330 qt5-build_pkg_postinst() {
331 qt5_regenerate_global_qconfigs
334 # @FUNCTION: qt5-build_pkg_postrm
336 # Regenerate configuration when a module is completely removed.
337 qt5-build_pkg_postrm() {
338 if [[ -z ${REPLACED_BY_VERSION} && ${PN} != qtcore ]]; then
339 qt5_regenerate_global_qconfigs
344 ###### Public helpers ######
347 # @USAGE: <flag> [feature] [enableval]
349 # <flag> is the name of a flag in IUSE.
351 # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
352 # otherwise. If [feature] is not specified, <flag> is used in its place.
353 # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
355 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
357 usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
360 # @FUNCTION: qt_use_compile_test
361 # @USAGE: <flag> [config]
363 # <flag> is the name of a flag in IUSE.
364 # [config] is the argument of qtCompileTest, defaults to <flag>.
366 # This function is useful to disable optional dependencies that are checked
367 # at qmake-time using the qtCompileTest() function. If <flag> is disabled,
368 # the compile test is skipped and the dependency is assumed to be unavailable,
369 # i.e. the corresponding feature will be disabled. Note that all invocations
370 # of this function must happen before calling qt5-build_src_configure.
371 qt_use_compile_test() {
372 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
375 mkdir -p "${QT5_BUILD_DIR}" || die
376 echo "CONFIG += done_config_${2:-$1}" >> "${QT5_BUILD_DIR}"/.qmake.cache || die
380 # @FUNCTION: qt_use_disable_mod
381 # @USAGE: <flag> <module> <files...>
383 # <flag> is the name of a flag in IUSE.
384 # <module> is the (lowercase) name of a Qt5 module.
385 # <files...> is a list of one or more qmake project files.
387 # This function patches <files> to treat <module> as not installed
388 # when <flag> is disabled, otherwise it does nothing.
389 # This can be useful to avoid an automagic dependency when the module
390 # is present on the system but the corresponding USE flag is disabled.
391 qt_use_disable_mod() {
392 [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
398 if ! use "${flag}"; then
399 echo "$@" | xargs sed -i -e "s/qtHaveModule(${module})/false/g" || die
404 ###### Internal functions ######
406 # @FUNCTION: qt5_prepare_env
409 # Prepares the environment for building Qt.
411 # setup installation directories
412 # note: keep paths in sync with qmake-utils.eclass
413 QT5_PREFIX=${EPREFIX}/usr
414 QT5_HEADERDIR=${QT5_PREFIX}/include/qt5
415 QT5_LIBDIR=${QT5_PREFIX}/$(get_libdir)
416 QT5_ARCHDATADIR=${QT5_PREFIX}/$(get_libdir)/qt5
417 QT5_BINDIR=${QT5_ARCHDATADIR}/bin
418 QT5_PLUGINDIR=${QT5_ARCHDATADIR}/plugins
419 QT5_LIBEXECDIR=${QT5_ARCHDATADIR}/libexec
420 QT5_IMPORTDIR=${QT5_ARCHDATADIR}/imports
421 QT5_QMLDIR=${QT5_ARCHDATADIR}/qml
422 QT5_DATADIR=${QT5_PREFIX}/share/qt5
423 QT5_DOCDIR=${QT5_PREFIX}/share/doc/qt-${PV}
424 QT5_TRANSLATIONDIR=${QT5_DATADIR}/translations
425 QT5_EXAMPLESDIR=${QT5_DATADIR}/examples
426 QT5_TESTSDIR=${QT5_DATADIR}/tests
427 QT5_SYSCONFDIR=${EPREFIX}/etc/xdg
428 readonly QT5_PREFIX QT5_HEADERDIR QT5_LIBDIR QT5_ARCHDATADIR \
429 QT5_BINDIR QT5_PLUGINDIR QT5_LIBEXECDIR QT5_IMPORTDIR \
430 QT5_QMLDIR QT5_DATADIR QT5_DOCDIR QT5_TRANSLATIONDIR \
431 QT5_EXAMPLESDIR QT5_TESTSDIR QT5_SYSCONFDIR
433 if [[ ${QT5_MODULE} == qtbase ]]; then
434 # see mkspecs/features/qt_config.prf
435 export QMAKEMODULES="${QT5_BUILD_DIR}/mkspecs/modules:${S}/mkspecs/modules:${QT5_ARCHDATADIR}/mkspecs/modules"
439 # @FUNCTION: qt5_foreach_target_subdir
442 # Executes the command given as argument from inside each directory
443 # listed in QT5_TARGET_SUBDIRS. Handles autotests subdirs automatically.
444 qt5_foreach_target_subdir() {
445 [[ -z ${QT5_TARGET_SUBDIRS[@]} ]] && QT5_TARGET_SUBDIRS=("")
448 [[ ${EAPI} != 5 ]] && die_args+=(-n)
451 for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do
452 if [[ ${EBUILD_PHASE} == test ]]; then
453 subdir=tests/auto${subdir#src}
454 [[ -d ${S}/${subdir} ]] || continue
457 local msg="Running $* ${subdir:+in ${subdir}}"
460 mkdir -p "${QT5_BUILD_DIR}/${subdir}" || die "${die_args[@]}" || return $?
461 pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die "${die_args[@]}" || return $?
463 "$@" || die "${die_args[@]}" "${msg} failed" || return $?
465 popd >/dev/null || die "${die_args[@]}" || return $?
469 # @FUNCTION: qt5_symlink_tools_to_build_dir
472 # Symlinks qmake and a few other tools to QT5_BUILD_DIR,
473 # so that they can be used when building other modules.
474 qt5_symlink_tools_to_build_dir() {
476 if [[ ${PN} != qtcore ]]; then
477 tools+=(qmake moc rcc qlalr)
478 [[ ${PN} != qtdbus ]] && tools+=(qdbuscpp2xml qdbusxml2cpp)
479 [[ ${PN} != qtwidgets ]] && tools+=(uic)
482 mkdir -p "${QT5_BUILD_DIR}"/bin || die
483 pushd "${QT5_BUILD_DIR}"/bin >/dev/null || die
485 for tool in "${tools[@]}"; do
486 [[ -e ${QT5_BINDIR}/${tool} ]] || continue
487 ln -s "${QT5_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
490 popd >/dev/null || die
493 # @FUNCTION: qt5_base_configure
496 # Runs ./configure for modules belonging to qtbase.
497 qt5_base_configure() {
498 # setup toolchain variables used by configure
499 tc-export AR CC CXX OBJDUMP RANLIB STRIP
500 export LD="$(tc-getCXX)"
502 # configure arguments
505 -prefix "${QT5_PREFIX}"
506 -bindir "${QT5_BINDIR}"
507 -headerdir "${QT5_HEADERDIR}"
508 -libdir "${QT5_LIBDIR}"
509 -archdatadir "${QT5_ARCHDATADIR}"
510 -plugindir "${QT5_PLUGINDIR}"
511 -libexecdir "${QT5_LIBEXECDIR}"
512 -importdir "${QT5_IMPORTDIR}"
513 -qmldir "${QT5_QMLDIR}"
514 -datadir "${QT5_DATADIR}"
515 -docdir "${QT5_DOCDIR}"
516 -translationdir "${QT5_TRANSLATIONDIR}"
517 -sysconfdir "${QT5_SYSCONFDIR}"
518 -examplesdir "${QT5_EXAMPLESDIR}"
519 -testsdir "${QT5_TESTSDIR}"
521 # configure in release mode by default,
522 # override via the CONFIG qmake variable
524 -no-separate-debug-info
526 # no need to forcefully build host tools in optimized mode,
527 # just follow the overall debug/release build type
528 $([[ ${QT5_MINOR_VERSION} -ge 6 ]] && echo -no-optimized-tools)
531 -opensource -confirm-license
533 # autodetect the highest supported version of the C++ standard
534 #-c++std <c++11|c++14|c++1z>
536 # build shared libraries
539 # always enable large file support
542 # disabling accessibility is not recommended by upstream, as
543 # it will break QStyle and may break other internal parts of Qt
546 # disable all SQL drivers by default, override in qtsql
547 -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc
548 -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds
550 # obsolete flag, does nothing
553 # MIPS DSP instruction set extensions
554 $(is-flagq -mno-dsp && echo -no-mips_dsp)
555 $(is-flagq -mno-dspr2 && echo -no-mips_dspr2)
557 # use pkg-config to detect include and library paths
560 # prefer system libraries (only common deps here)
564 # disable everything to prevent automagic deps (part 1)
567 $([[ ${QT5_MINOR_VERSION} -ge 6 ]] && echo -no-syslog)
568 -no-libpng -no-libjpeg
569 -no-freetype -no-harfbuzz
570 -no-openssl -no-libproxy
571 -no-xkbcommon-x11 -no-xkbcommon-evdev
572 -no-xinput2 -no-xcb-xlib
574 # don't specify -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)
581 -no-pulseaudio -no-alsa
582 $([[ ${QT5_MINOR_VERSION} -ge 7 ]] && echo -no-gtk || echo -no-gtkstyle)
584 # exclude examples and tests from default build
589 # disable rpath on non-prefix (bugs 380415 and 417169)
590 $(usex prefix '' -no-rpath)
592 # print verbose information about each configure test
595 # obsolete flag, does nothing
598 # always enable iconv support
601 # disable everything to prevent automagic deps (part 3)
602 -no-cups -no-evdev -no-tslib -no-icu -no-fontconfig -no-dbus
604 # let portage handle stripping
607 # precompiled headers can cause problems on hardened, so turn them off
610 # link-time code generation is not something we want to enable by default
611 $([[ ${QT5_MINOR_VERSION} -ge 6 ]] && echo -no-ltcg)
613 # reduced relocations cause major breakage on at least arm and ppc, so
614 # don't specify anything and let the configure figure out if they are
615 # supported; see also https://bugreports.qt.io/browse/QTBUG-36129
618 # let configure automatically detect if GNU gold is available
621 # disable all platform plugins by default, override in qtgui
622 -no-xcb -no-eglfs -no-kms
623 $([[ ${QT5_MINOR_VERSION} -ge 6 ]] && echo -no-gbm)
624 -no-directfb -no-linuxfb
625 $([[ ${QT5_MINOR_VERSION} -ge 6 ]] && echo -no-mirclient)
627 # disable undocumented X11-related flags, override in qtgui
628 # (not shown in ./configure -help output)
631 # disable obsolete/unused X11-related flags
632 # (not shown in ./configure -help output)
633 -no-mitshm -no-xcursor -no-xfixes -no-xrandr -no-xshape -no-xsync
635 # always enable session management support: it doesn't need extra deps
636 # at configure time and turning it off is dangerous, see bug 518262
639 # typedef qreal to double (warning: changing this flag breaks the ABI)
642 # disable OpenGL and EGL support by default, override in qtgui,
643 # qtopengl, qtprintsupport and qtwidgets
646 # disable libinput-based generic plugin by default, override in qtgui
649 # disable gstreamer by default, override in qtmultimedia
652 # use upstream default
655 # do not build with -Werror
656 -no-warnings-are-errors
658 # module-specific options
662 pushd "${QT5_BUILD_DIR}" >/dev/null || die
664 einfo "Configuring with: ${conf[@]}"
665 "${S}"/configure "${conf[@]}" || die "configure failed"
667 popd >/dev/null || die
670 # @FUNCTION: qt5_qmake
673 # Helper function that runs qmake in the current target subdir.
674 # Intended to be called by qt5_foreach_target_subdir().
676 local projectdir=${PWD/#${QT5_BUILD_DIR}/${S}}
678 if [[ ${QT5_MODULE} == qtbase ]]; then
679 qmakepath=${QT5_BUILD_DIR}/bin
681 qmakepath=${QT5_BINDIR}
684 "${qmakepath}"/qmake \
686 CONFIG+=$(usex debug debug release) \
687 CONFIG-=$(usex debug release debug) \
688 QMAKE_AR="$(tc-getAR) cqs" \
689 QMAKE_CC="$(tc-getCC)" \
690 QMAKE_LINK_C="$(tc-getCC)" \
691 QMAKE_LINK_C_SHLIB="$(tc-getCC)" \
692 QMAKE_CXX="$(tc-getCXX)" \
693 QMAKE_LINK="$(tc-getCXX)" \
694 QMAKE_LINK_SHLIB="$(tc-getCXX)" \
695 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
697 QMAKE_STRIP="$(tc-getSTRIP)" \
698 QMAKE_CFLAGS="${CFLAGS}" \
699 QMAKE_CFLAGS_RELEASE= \
700 QMAKE_CFLAGS_DEBUG= \
701 QMAKE_CXXFLAGS="${CXXFLAGS}" \
702 QMAKE_CXXFLAGS_RELEASE= \
703 QMAKE_CXXFLAGS_DEBUG= \
704 QMAKE_LFLAGS="${LDFLAGS}" \
705 QMAKE_LFLAGS_RELEASE= \
706 QMAKE_LFLAGS_DEBUG= \
707 "${myqmakeargs[@]}" \
708 || die "qmake failed (${projectdir#${S}/})"
711 # @FUNCTION: qt5_install_module_qconfigs
714 # Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
715 qt5_install_module_qconfigs() {
716 local x qconfig_add= qconfig_remove=
718 > "${T}"/${PN}-qconfig.h
719 > "${T}"/${PN}-qconfig.pri
721 # generate qconfig_{add,remove} and ${PN}-qconfig.h
722 for x in "${QT5_GENTOO_CONFIG[@]}"; do
725 local feature=${x%%:*}
728 macro=$(tr 'a-z-' 'A-Z_' <<< "${macro}")
730 if [[ -z ${flag} ]] || { [[ ${flag} != '!' ]] && use ${flag}; }; then
731 [[ -n ${feature} ]] && qconfig_add+=" ${feature}"
732 [[ -n ${macro} ]] && echo "#define QT_${macro}" >> "${T}"/${PN}-qconfig.h
734 [[ -n ${feature} ]] && qconfig_remove+=" ${feature}"
735 [[ -n ${macro} ]] && echo "#define QT_NO_${macro}" >> "${T}"/${PN}-qconfig.h
739 # install ${PN}-qconfig.h
740 [[ -s ${T}/${PN}-qconfig.h ]] && (
741 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
742 doins "${T}"/${PN}-qconfig.h
745 # generate and install ${PN}-qconfig.pri
746 [[ -n ${qconfig_add} ]] && echo "QCONFIG_ADD=${qconfig_add}" >> "${T}"/${PN}-qconfig.pri
747 [[ -n ${qconfig_remove} ]] && echo "QCONFIG_REMOVE=${qconfig_remove}" >> "${T}"/${PN}-qconfig.pri
748 [[ -s ${T}/${PN}-qconfig.pri ]] && (
749 insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo
750 doins "${T}"/${PN}-qconfig.pri
754 # @FUNCTION: qt5_regenerate_global_qconfigs
757 # Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
758 # Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
759 qt5_regenerate_global_qconfigs() {
760 einfo "Regenerating gentoo-qconfig.h"
762 find "${ROOT%/}${QT5_HEADERDIR}"/Gentoo \
763 -name '*-qconfig.h' -a \! -name 'gentoo-qconfig.h' -type f \
764 -execdir cat '{}' + | sort -u > "${T}"/gentoo-qconfig.h
766 [[ -s ${T}/gentoo-qconfig.h ]] || ewarn "Generated gentoo-qconfig.h is empty"
767 mv -f "${T}"/gentoo-qconfig.h "${ROOT%/}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \
768 || eerror "Failed to install new gentoo-qconfig.h"
770 einfo "Updating QT_CONFIG in qconfig.pri"
772 local qconfig_pri=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri
773 if [[ -f ${qconfig_pri} ]]; then
774 local x qconfig_add= qconfig_remove=
775 local qt_config=$(sed -n 's/^QT_CONFIG\s*+=\s*//p' "${qconfig_pri}")
778 # generate list of QT_CONFIG entries from the existing list,
779 # appending QCONFIG_ADD and excluding QCONFIG_REMOVE
780 eshopts_push -s nullglob
781 for x in "${ROOT%/}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
782 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=\s*//p' "${x}")"
783 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=\s*//p' "${x}")"
786 for x in ${qt_config} ${qconfig_add}; do
787 if ! has "${x}" ${new_qt_config} ${qconfig_remove}; then
788 new_qt_config+=" ${x}"
792 # now replace the existing QT_CONFIG with the generated list
793 sed -i -e "s/^QT_CONFIG\s*+=.*/QT_CONFIG +=${new_qt_config}/" \
794 "${qconfig_pri}" || eerror "Failed to sed QT_CONFIG in ${qconfig_pri}"
796 ewarn "${qconfig_pri} does not exist or is not a regular file"