1 # Copyright 1999-2016 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>
9 # @BLURB: Eclass for Qt5 split ebuilds.
11 # This eclass contains various functions that are used when building Qt5.
12 # Requires EAPI 5 or 6.
14 if [[ ${CATEGORY} != dev-qt ]]; then
15 die "qt5-build.eclass is only to be used for building Qt 5."
20 *) die "qt5-build.eclass: unsupported EAPI=${EAPI:-0}" ;;
23 # @ECLASS-VARIABLE: QT5_MODULE
25 # The upstream name of the module this package belongs to. Used for
26 # SRC_URI and EGIT_REPO_URI. Must be defined before inheriting the eclass.
27 : ${QT5_MODULE:=${PN}}
29 # @ECLASS-VARIABLE: QT5_TARGET_SUBDIRS
32 # Array variable containing the source directories that should be built.
33 # All paths must be relative to ${S}.
35 # @ECLASS-VARIABLE: QT5_GENTOO_CONFIG
38 # Array of <useflag:feature:macro> triplets that are evaluated in src_install
39 # to generate the per-package list of enabled QT_CONFIG features and macro
40 # definitions, which are then merged together with all other Qt5 packages
41 # installed on the system to obtain the global qconfig.{h,pri} files.
43 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
45 # For proper description see virtualx.eclass man page.
46 # Here we redefine default value to be manual, if your package needs virtualx
47 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
48 : ${VIRTUALX_REQUIRED:=manual}
50 [[ ${EAPI} == 5 ]] && inherit multilib
51 inherit eutils flag-o-matic toolchain-funcs versionator virtualx
53 HOMEPAGE="https://www.qt.io/"
55 QT5_MINOR_VERSION=$(get_version_component_range 2)
56 QT5_PATCH_VERSION=$(get_version_component_range 3)
57 readonly QT5_MINOR_VERSION QT5_PATCH_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 SLOT=5/$(get_version_component_range 1-2)
76 EGIT_BRANCH=${PV%.9999}
78 *_alpha*|*_beta*|*_rc*)
80 QT5_BUILD_TYPE="release"
81 MY_P=${QT5_MODULE}-opensource-src-${PV/_/-}
82 SRC_URI="https://download.qt.io/development_releases/qt/${PV%.*}/${PV/_/-}/submodules/${MY_P}.tar.xz"
86 # official stable release
87 QT5_BUILD_TYPE="release"
88 MY_P=${QT5_MODULE}-opensource-src-${PV}
90 if [[ ${PV} = 5.6.1 ]]; then
91 SRC_URI="https://download.qt.io/official_releases/qt/${PV%.*}/${PV}-1/submodules/${MY_P}-1.tar.xz"
93 SRC_URI="https://download.qt.io/official_releases/qt/${PV%.*}/${PV}/submodules/${MY_P}.tar.xz"
98 readonly QT5_BUILD_TYPE
101 "git://code.qt.io/qt/${QT5_MODULE}.git"
102 "https://code.qt.io/git/qt/${QT5_MODULE}.git"
103 "https://github.com/qtproject/${QT5_MODULE}.git"
105 [[ ${QT5_BUILD_TYPE} == live ]] && inherit git-r3
107 # @ECLASS-VARIABLE: QT5_BUILD_DIR
109 # Build directory for out-of-source builds.
110 case ${QT5_BUILD_TYPE} in
111 live) : ${QT5_BUILD_DIR:=${S}_build} ;;
112 release) : ${QT5_BUILD_DIR:=${S}} ;; # workaround for bug 497312
117 [[ ${PN} == qtwebkit ]] && RESTRICT+=" mirror" # bug 524584
118 [[ ${QT5_BUILD_TYPE} == release ]] && RESTRICT+=" test" # bug 457182
124 if [[ ${PN} != qttest ]]; then
125 DEPEND+=" test? ( ~dev-qt/qttest-${PV} )"
132 ###### Phase functions ######
134 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm
136 # @FUNCTION: qt5-build_src_unpack
138 # Unpacks the sources.
139 qt5-build_src_unpack() {
141 local min_gcc4_minor_version=5
142 if [[ ${QT5_MINOR_VERSION} -ge 7 || ${PN} == qtwebengine ]]; then
143 min_gcc4_minor_version=7
145 if [[ $(gcc-major-version) -lt 4 ]] || \
146 [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt ${min_gcc4_minor_version} ]]; then
147 eerror "GCC version 4.${min_gcc4_minor_version} or later is required to build this package"
148 die "GCC 4.${min_gcc4_minor_version} or later required"
153 if [[ ${PN} == qtwebengine || ${PN} == qtwebkit ]]; then
154 eshopts_push -s extglob
155 if is-flagq '-g?(gdb)?([1-9])'; then
157 ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
158 ewarn "You may experience really long compilation times and/or increased memory usage."
159 ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
165 case ${QT5_BUILD_TYPE} in
166 live) git-r3_src_unpack ;;
171 # @FUNCTION: qt5-build_src_prepare
173 # Prepares the environment and patches the sources if necessary.
174 qt5-build_src_prepare() {
177 if [[ ${QT5_MODULE} == qtbase ]]; then
178 qt5_symlink_tools_to_build_dir
180 # Avoid unnecessary qmake recompilations
181 sed -i -re "s|^if true;.*(\[ '\!').*(\"\\\$outpath/bin/qmake\".*)|if \1 -e \2 then|" \
182 configure || die "sed failed (skip qmake bootstrap)"
184 # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when bootstrapping qmake
185 sed -i -e "/outpath\/qmake\".*\"\$MAKE\")/ s:): \
186 ${MAKEOPTS} ${EXTRA_EMAKE} 'CC=$(tc-getCC)' 'CXX=$(tc-getCXX)' \
187 'QMAKE_CFLAGS=${CFLAGS}' 'QMAKE_CXXFLAGS=${CXXFLAGS}' 'QMAKE_LFLAGS=${LDFLAGS}'&:" \
188 -e 's/\(setBootstrapVariable\s\+\|EXTRA_C\(XX\)\?FLAGS=.*\)QMAKE_C\(XX\)\?FLAGS_\(DEBUG\|RELEASE\).*/:/' \
189 configure || die "sed failed (respect env for qmake build)"
190 sed -i -e '/^CPPFLAGS\s*=/ s/-g //' \
191 qmake/Makefile.unix || die "sed failed (CPPFLAGS for qmake build)"
193 # Respect CXX in bsymbolic_functions, fvisibility, precomp, and a few other tests
194 sed -i -e "/^QMAKE_CONF_COMPILER=/ s:=.*:=\"$(tc-getCXX)\":" \
195 configure || die "sed failed (QMAKE_CONF_COMPILER)"
197 # Respect toolchain and flags in config.tests
198 find config.tests/unix -name '*.test' -type f -execdir \
199 sed -i -e 's/-nocache //' '{}' + || die
201 # Don't inject -msse/-mavx/... into CXXFLAGS when detecting
202 # compiler support for extended instruction sets (bug 552942)
203 find config.tests/common -name '*.pro' -type f -execdir \
204 sed -i -e '/QMAKE_CXXFLAGS\s*+=/ d' '{}' + || die
206 # Don't add -O3 to CXXFLAGS (bug 549140)
207 sed -i -e '/CONFIG\s*+=/ s/optimize_full//' \
208 src/{corelib/corelib,gui/gui}.pro || die "sed failed (optimize_full)"
211 if [[ ${EAPI} == 5 ]]; then
212 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
219 # @FUNCTION: qt5-build_src_configure
221 # Runs qmake in the target directories. For packages
222 # in qtbase, ./configure is also run before qmake.
223 qt5-build_src_configure() {
224 if [[ ${QT5_MODULE} == qtbase ]]; then
228 qt5_foreach_target_subdir qt5_qmake
231 # @FUNCTION: qt5-build_src_compile
233 # Runs emake in the target directories.
234 qt5-build_src_compile() {
235 qt5_foreach_target_subdir emake
238 # @FUNCTION: qt5-build_src_test
240 # Runs tests in the target directories.
241 qt5-build_src_test() {
242 # disable broken cmake tests (bug 474004)
243 local myqmakeargs=("${myqmakeargs[@]}" -after SUBDIRS-=cmake SUBDIRS-=installed_cmake)
245 qt5_foreach_target_subdir qt5_qmake
246 qt5_foreach_target_subdir emake
248 # create a custom testrunner script that correctly sets
249 # LD_LIBRARY_PATH before executing the given test
250 local testrunner=${QT5_BUILD_DIR}/gentoo-testrunner
251 cat > "${testrunner}" <<-_EOF_ || die
253 export LD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}"
256 chmod +x "${testrunner}"
258 set -- qt5_foreach_target_subdir emake TESTRUNNER="'${testrunner}'" check
259 if [[ ${VIRTUALX_REQUIRED} == test ]]; then
266 # @FUNCTION: qt5-build_src_install
268 # Runs emake install in the target directories.
269 qt5-build_src_install() {
270 qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install
272 if [[ ${PN} == qtcore ]]; then
273 pushd "${QT5_BUILD_DIR}" >/dev/null || die
275 local qmake_install_target=install_qmake
276 if [[ ${QT5_MINOR_VERSION} -ge 7 ]]; then
277 # qmake/qmake-aux.pro
278 qmake_install_target=sub-qmake-qmake-aux-pro-install_subtargets
281 local global_docs_install_target=
282 if [[ ${QT5_MINOR_VERSION} -le 6 && ${QT5_PATCH_VERSION} -le 2 ]]; then
283 global_docs_install_target=install_global_docs
286 set -- emake INSTALL_ROOT="${D}" \
287 ${qmake_install_target} \
288 install_{syncqt,mkspecs} \
289 ${global_docs_install_target}
294 popd >/dev/null || die
296 docompress -x "${QT5_DOCDIR#${EPREFIX}}"/global
298 # install an empty Gentoo/gentoo-qconfig.h in ${D}
299 # so that it's placed under package manager control
300 > "${T}"/gentoo-qconfig.h
302 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
303 doins "${T}"/gentoo-qconfig.h
306 # include gentoo-qconfig.h at the beginning of QtCore/qconfig.h
307 sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
308 "${D}${QT5_HEADERDIR}"/QtCore/qconfig.h \
309 || die "sed failed (qconfig.h)"
311 # install qtchooser configuration file
312 cat > "${T}/qt5-${CHOST}.conf" <<-_EOF_ || die
318 insinto /etc/xdg/qtchooser
319 doins "${T}/qt5-${CHOST}.conf"
322 # convenience symlinks
323 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/5.conf
324 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/qt5.conf
327 qt5_install_module_qconfigs
331 # @FUNCTION: qt5-build_pkg_postinst
333 # Regenerate configuration after installation or upgrade/downgrade.
334 qt5-build_pkg_postinst() {
335 qt5_regenerate_global_qconfigs
338 # @FUNCTION: qt5-build_pkg_postrm
340 # Regenerate configuration when a module is completely removed.
341 qt5-build_pkg_postrm() {
342 if [[ -z ${REPLACED_BY_VERSION} && ${PN} != qtcore ]]; then
343 qt5_regenerate_global_qconfigs
348 ###### Public helpers ######
351 # @USAGE: <flag> [feature] [enableval]
353 # <flag> is the name of a flag in IUSE.
355 # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
356 # otherwise. If [feature] is not specified, <flag> is used in its place.
357 # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
359 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
361 usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
364 # @FUNCTION: qt_use_compile_test
365 # @USAGE: <flag> [config]
367 # <flag> is the name of a flag in IUSE.
368 # [config] is the argument of qtCompileTest, defaults to <flag>.
370 # This function is useful to disable optional dependencies that are checked
371 # at qmake-time using the qtCompileTest() function. If <flag> is disabled,
372 # the compile test is skipped and the dependency is assumed to be unavailable,
373 # i.e. the corresponding feature will be disabled. Note that all invocations
374 # of this function must happen before calling qt5-build_src_configure.
375 qt_use_compile_test() {
376 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
379 mkdir -p "${QT5_BUILD_DIR}" || die
380 echo "CONFIG += done_config_${2:-$1}" >> "${QT5_BUILD_DIR}"/.qmake.cache || die
384 # @FUNCTION: qt_use_disable_mod
385 # @USAGE: <flag> <module> <files...>
387 # <flag> is the name of a flag in IUSE.
388 # <module> is the (lowercase) name of a Qt5 module.
389 # <files...> is a list of one or more qmake project files.
391 # This function patches <files> to treat <module> as not installed
392 # when <flag> is disabled, otherwise it does nothing.
393 # This can be useful to avoid an automagic dependency when the module
394 # is present on the system but the corresponding USE flag is disabled.
395 qt_use_disable_mod() {
396 [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
402 if ! use "${flag}"; then
403 echo "$@" | xargs sed -i -e "s/qtHaveModule(${module})/false/g" || die
408 ###### Internal functions ######
410 # @FUNCTION: qt5_prepare_env
413 # Prepares the environment for building Qt.
415 # setup installation directories
416 # note: keep paths in sync with qmake-utils.eclass
417 QT5_PREFIX=${EPREFIX}/usr
418 QT5_HEADERDIR=${QT5_PREFIX}/include/qt5
419 QT5_LIBDIR=${QT5_PREFIX}/$(get_libdir)
420 QT5_ARCHDATADIR=${QT5_PREFIX}/$(get_libdir)/qt5
421 QT5_BINDIR=${QT5_ARCHDATADIR}/bin
422 QT5_PLUGINDIR=${QT5_ARCHDATADIR}/plugins
423 QT5_LIBEXECDIR=${QT5_ARCHDATADIR}/libexec
424 QT5_IMPORTDIR=${QT5_ARCHDATADIR}/imports
425 QT5_QMLDIR=${QT5_ARCHDATADIR}/qml
426 QT5_DATADIR=${QT5_PREFIX}/share/qt5
427 QT5_DOCDIR=${QT5_PREFIX}/share/doc/qt-${PV}
428 QT5_TRANSLATIONDIR=${QT5_DATADIR}/translations
429 QT5_EXAMPLESDIR=${QT5_DATADIR}/examples
430 QT5_TESTSDIR=${QT5_DATADIR}/tests
431 QT5_SYSCONFDIR=${EPREFIX}/etc/xdg
432 readonly QT5_PREFIX QT5_HEADERDIR QT5_LIBDIR QT5_ARCHDATADIR \
433 QT5_BINDIR QT5_PLUGINDIR QT5_LIBEXECDIR QT5_IMPORTDIR \
434 QT5_QMLDIR QT5_DATADIR QT5_DOCDIR QT5_TRANSLATIONDIR \
435 QT5_EXAMPLESDIR QT5_TESTSDIR QT5_SYSCONFDIR
437 if [[ ${QT5_MODULE} == qtbase ]]; then
438 # see mkspecs/features/qt_config.prf
439 export QMAKEMODULES="${QT5_BUILD_DIR}/mkspecs/modules:${S}/mkspecs/modules:${QT5_ARCHDATADIR}/mkspecs/modules"
443 # @FUNCTION: qt5_foreach_target_subdir
446 # Executes the command given as argument from inside each directory
447 # listed in QT5_TARGET_SUBDIRS. Handles autotests subdirs automatically.
448 qt5_foreach_target_subdir() {
449 [[ -z ${QT5_TARGET_SUBDIRS[@]} ]] && QT5_TARGET_SUBDIRS=("")
452 [[ ${EAPI} != 5 ]] && die_args+=(-n)
455 for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do
456 if [[ ${EBUILD_PHASE} == test ]]; then
457 subdir=tests/auto${subdir#src}
458 [[ -d ${S}/${subdir} ]] || continue
461 local msg="Running $* ${subdir:+in ${subdir}}"
464 mkdir -p "${QT5_BUILD_DIR}/${subdir}" || die "${die_args[@]}" || return $?
465 pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die "${die_args[@]}" || return $?
467 "$@" || die "${die_args[@]}" "${msg} failed" || return $?
469 popd >/dev/null || die "${die_args[@]}" || return $?
473 # @FUNCTION: qt5_symlink_tools_to_build_dir
476 # Symlinks qmake and a few other tools to QT5_BUILD_DIR,
477 # so that they can be used when building other modules.
478 qt5_symlink_tools_to_build_dir() {
480 if [[ ${PN} != qtcore ]]; then
481 tools+=(qmake moc rcc qlalr)
482 [[ ${PN} != qtdbus ]] && tools+=(qdbuscpp2xml qdbusxml2cpp)
483 [[ ${PN} != qtwidgets ]] && tools+=(uic)
486 mkdir -p "${QT5_BUILD_DIR}"/bin || die
487 pushd "${QT5_BUILD_DIR}"/bin >/dev/null || die
489 for tool in "${tools[@]}"; do
490 [[ -e ${QT5_BINDIR}/${tool} ]] || continue
491 ln -s "${QT5_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
494 popd >/dev/null || die
497 # @FUNCTION: qt5_base_configure
500 # Runs ./configure for modules belonging to qtbase.
501 qt5_base_configure() {
502 # setup toolchain variables used by configure
503 tc-export AR CC CXX OBJDUMP RANLIB STRIP
504 export LD="$(tc-getCXX)"
506 # configure arguments
509 -prefix "${QT5_PREFIX}"
510 -bindir "${QT5_BINDIR}"
511 -headerdir "${QT5_HEADERDIR}"
512 -libdir "${QT5_LIBDIR}"
513 -archdatadir "${QT5_ARCHDATADIR}"
514 -plugindir "${QT5_PLUGINDIR}"
515 -libexecdir "${QT5_LIBEXECDIR}"
516 -importdir "${QT5_IMPORTDIR}"
517 -qmldir "${QT5_QMLDIR}"
518 -datadir "${QT5_DATADIR}"
519 -docdir "${QT5_DOCDIR}"
520 -translationdir "${QT5_TRANSLATIONDIR}"
521 -sysconfdir "${QT5_SYSCONFDIR}"
522 -examplesdir "${QT5_EXAMPLESDIR}"
523 -testsdir "${QT5_TESTSDIR}"
525 # configure in release mode by default,
526 # override via the CONFIG qmake variable
528 -no-separate-debug-info
530 # no need to forcefully build host tools in optimized mode,
531 # just follow the overall debug/release build type
535 -opensource -confirm-license
537 # autodetect the highest supported version of the C++ standard
538 #-c++std <c++11|c++14|c++1z>
540 # build shared libraries
543 # always enable large file support
544 $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -largefile)
546 # disabling accessibility is not recommended by upstream, as
547 # it will break QStyle and may break other internal parts of Qt
550 # disable all SQL drivers by default, override in qtsql
551 -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc
552 -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds
554 # ensure the QML debugging support (qmltooling) is built in qtdeclarative
557 # MIPS DSP instruction set extensions
558 $(is-flagq -mno-dsp && echo -no-mips_dsp)
559 $(is-flagq -mno-dspr2 && echo -no-mips_dspr2)
561 # use pkg-config to detect include and library paths
564 # prefer system libraries (only common hard deps here)
567 $([[ ${QT5_MINOR_VERSION} -ge 7 ]] && echo -system-doubleconversion)
569 # disable everything to prevent automagic deps (part 1)
571 -no-journald -no-syslog
572 -no-libpng -no-libjpeg
573 -no-freetype -no-harfbuzz
574 -no-openssl -no-libproxy
575 -no-xkbcommon-x11 -no-xkbcommon-evdev
576 -no-xinput2 -no-xcb-xlib
578 # cannot use -no-gif because there is no way to override it later
581 # always enable glib event loop support
584 # disable everything to prevent automagic deps (part 2)
585 -no-pulseaudio -no-alsa
586 $([[ ${QT5_MINOR_VERSION} -ge 7 ]] && echo -no-gtk || echo -no-gtkstyle)
588 # exclude examples and tests from default build
593 # disable rpath on non-prefix (bugs 380415 and 417169)
594 $(usex prefix '' -no-rpath)
596 # print verbose information about each configure test
599 # always enable iconv support
602 # disable everything to prevent automagic deps (part 3)
603 -no-cups -no-evdev -no-tslib -no-icu -no-fontconfig -no-dbus
605 # let portage handle stripping
608 # precompiled headers can cause problems on hardened, so turn them off
611 # link-time code generation is not something we want to enable by default
614 # reduced relocations cause major breakage on at least arm and ppc, so
615 # don't specify anything and let the configure figure out if they are
616 # supported; see also https://bugreports.qt.io/browse/QTBUG-36129
619 # let configure automatically detect if GNU gold is available
622 # disable all platform plugins by default, override in qtgui
623 -no-xcb -no-eglfs -no-kms -no-gbm -no-directfb -no-linuxfb -no-mirclient
625 # disable undocumented X11-related flags, override in qtgui
626 # (not shown in ./configure -help output)
629 # disable obsolete/unused X11-related flags
630 $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-mitshm -no-xcursor -no-xfixes -no-xrandr -no-xshape -no-xsync)
632 # always enable session management support: it doesn't need extra deps
633 # at configure time and turning it off is dangerous, see bug 518262
636 # typedef qreal to double (warning: changing this flag breaks the ABI)
639 # disable OpenGL and EGL support by default, override in qtgui,
640 # qtopengl, qtprintsupport and qtwidgets
643 # disable libinput-based generic plugin by default, override in qtgui
646 # disable gstreamer by default, override in qtmultimedia
649 # respect system proxies by default: it's the most natural
650 # setting, and it'll become the new upstream default in 5.8
653 # do not build with -Werror
654 -no-warnings-are-errors
656 # module-specific options
660 pushd "${QT5_BUILD_DIR}" >/dev/null || die
662 einfo "Configuring with: ${conf[@]}"
663 "${S}"/configure "${conf[@]}" || die "configure failed"
665 popd >/dev/null || die
668 # @FUNCTION: qt5_qmake
671 # Helper function that runs qmake in the current target subdir.
672 # Intended to be called by qt5_foreach_target_subdir().
674 local projectdir=${PWD/#${QT5_BUILD_DIR}/${S}}
676 if [[ ${QT5_MODULE} == qtbase ]]; then
677 qmakepath=${QT5_BUILD_DIR}/bin
679 qmakepath=${QT5_BINDIR}
682 "${qmakepath}"/qmake \
684 CONFIG+=$(usex debug debug release) \
685 CONFIG-=$(usex debug release debug) \
686 QMAKE_AR="$(tc-getAR) cqs" \
687 QMAKE_CC="$(tc-getCC)" \
688 QMAKE_LINK_C="$(tc-getCC)" \
689 QMAKE_LINK_C_SHLIB="$(tc-getCC)" \
690 QMAKE_CXX="$(tc-getCXX)" \
691 QMAKE_LINK="$(tc-getCXX)" \
692 QMAKE_LINK_SHLIB="$(tc-getCXX)" \
693 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
695 QMAKE_STRIP="$(tc-getSTRIP)" \
696 QMAKE_CFLAGS="${CFLAGS}" \
697 QMAKE_CFLAGS_RELEASE= \
698 QMAKE_CFLAGS_DEBUG= \
699 QMAKE_CXXFLAGS="${CXXFLAGS}" \
700 QMAKE_CXXFLAGS_RELEASE= \
701 QMAKE_CXXFLAGS_DEBUG= \
702 QMAKE_LFLAGS="${LDFLAGS}" \
703 QMAKE_LFLAGS_RELEASE= \
704 QMAKE_LFLAGS_DEBUG= \
705 "${myqmakeargs[@]}" \
706 || die "qmake failed (${projectdir#${S}/})"
709 # @FUNCTION: qt5_install_module_qconfigs
712 # Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
713 qt5_install_module_qconfigs() {
714 local x qconfig_add= qconfig_remove=
716 > "${T}"/${PN}-qconfig.h
717 > "${T}"/${PN}-qconfig.pri
719 # generate qconfig_{add,remove} and ${PN}-qconfig.h
720 for x in "${QT5_GENTOO_CONFIG[@]}"; do
723 local feature=${x%%:*}
726 macro=$(tr 'a-z-' 'A-Z_' <<< "${macro}")
728 if [[ -z ${flag} ]] || { [[ ${flag} != '!' ]] && use ${flag}; }; then
729 [[ -n ${feature} ]] && qconfig_add+=" ${feature}"
730 [[ -n ${macro} ]] && echo "#define QT_${macro}" >> "${T}"/${PN}-qconfig.h
732 [[ -n ${feature} ]] && qconfig_remove+=" ${feature}"
733 [[ -n ${macro} ]] && echo "#define QT_NO_${macro}" >> "${T}"/${PN}-qconfig.h
737 # install ${PN}-qconfig.h
738 [[ -s ${T}/${PN}-qconfig.h ]] && (
739 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
740 doins "${T}"/${PN}-qconfig.h
743 # generate and install ${PN}-qconfig.pri
744 [[ -n ${qconfig_add} ]] && echo "QCONFIG_ADD=${qconfig_add}" >> "${T}"/${PN}-qconfig.pri
745 [[ -n ${qconfig_remove} ]] && echo "QCONFIG_REMOVE=${qconfig_remove}" >> "${T}"/${PN}-qconfig.pri
746 [[ -s ${T}/${PN}-qconfig.pri ]] && (
747 insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo
748 doins "${T}"/${PN}-qconfig.pri
752 # @FUNCTION: qt5_regenerate_global_qconfigs
755 # Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
756 # Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
757 qt5_regenerate_global_qconfigs() {
758 einfo "Regenerating gentoo-qconfig.h"
760 find "${ROOT%/}${QT5_HEADERDIR}"/Gentoo \
761 -name '*-qconfig.h' -a \! -name 'gentoo-qconfig.h' -type f \
762 -execdir cat '{}' + | sort -u > "${T}"/gentoo-qconfig.h
764 [[ -s ${T}/gentoo-qconfig.h ]] || ewarn "Generated gentoo-qconfig.h is empty"
765 mv -f "${T}"/gentoo-qconfig.h "${ROOT%/}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \
766 || eerror "Failed to install new gentoo-qconfig.h"
768 einfo "Updating QT_CONFIG in qconfig.pri"
770 local qconfig_pri=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri
771 if [[ -f ${qconfig_pri} ]]; then
772 local x qconfig_add= qconfig_remove=
773 local qt_config=$(sed -n 's/^QT_CONFIG\s*+=\s*//p' "${qconfig_pri}")
776 # generate list of QT_CONFIG entries from the existing list,
777 # appending QCONFIG_ADD and excluding QCONFIG_REMOVE
778 eshopts_push -s nullglob
779 for x in "${ROOT%/}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
780 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=\s*//p' "${x}")"
781 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=\s*//p' "${x}")"
784 for x in ${qt_config} ${qconfig_add}; do
785 if ! has "${x}" ${new_qt_config} ${qconfig_remove}; then
786 new_qt_config+=" ${x}"
790 # now replace the existing QT_CONFIG with the generated list
791 sed -i -e "s/^QT_CONFIG\s*+=.*/QT_CONFIG +=${new_qt_config}/" \
792 "${qconfig_pri}" || eerror "Failed to sed QT_CONFIG in ${qconfig_pri}"
794 ewarn "${qconfig_pri} does not exist or is not a regular file"