1 # Copyright 1999-2015 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.
17 *) die "qt5-build.eclass: unsupported EAPI=${EAPI:-0}" ;;
20 inherit eutils flag-o-matic multilib toolchain-funcs virtualx
22 QT5_MINOR_VERSION=${PV#*.}
23 QT5_MINOR_VERSION=${QT5_MINOR_VERSION%%.*}
25 HOMEPAGE="https://www.qt.io/"
26 LICENSE="|| ( LGPL-2.1 LGPL-3 ) FDL-1.3"
29 # @ECLASS-VARIABLE: QT5_MODULE
31 # The upstream name of the module this package belongs to. Used for
32 # SRC_URI and EGIT_REPO_URI. Must be defined before inheriting the eclass.
33 : ${QT5_MODULE:=${PN}}
44 EGIT_BRANCH=${PV%.9999}
46 *_alpha*|*_beta*|*_rc*)
48 QT5_BUILD_TYPE="release"
49 MY_P=${QT5_MODULE}-opensource-src-${PV/_/-}
50 SRC_URI="http://download.qt.io/development_releases/qt/${PV%.*}/${PV/_/-}/submodules/${MY_P}.tar.xz"
54 # official stable release
55 QT5_BUILD_TYPE="release"
56 MY_P=${QT5_MODULE}-opensource-src-${PV}
57 SRC_URI="http://download.qt.io/official_releases/qt/${PV%.*}/${PV}/submodules/${MY_P}.tar.xz"
63 "git://code.qt.io/qt/${QT5_MODULE}.git"
64 "https://code.qt.io/git/qt/${QT5_MODULE}.git"
65 "https://github.com/qtproject/${QT5_MODULE}.git"
67 [[ ${QT5_BUILD_TYPE} == live ]] && inherit git-r3
71 [[ ${PN} == qtwebkit ]] && RESTRICT+=" mirror" # bug 524584
72 [[ ${QT5_BUILD_TYPE} == release ]] && RESTRICT+=" test" # bug 457182
78 if [[ ${PN} != qttest ]]; then
79 if [[ ${QT5_MODULE} == qtbase ]]; then
80 DEPEND+=" test? ( ~dev-qt/qttest-${PV} )"
82 DEPEND+=" test? ( >=dev-qt/qttest-${PV}:5 )"
89 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm
92 # @ECLASS-VARIABLE: PATCHES
95 # Array variable containing all the patches to be applied. This variable
96 # is expected to be defined in the global scope of ebuilds. Make sure to
97 # specify the full path. This variable is used in src_prepare phase.
102 # "${FILESDIR}/mypatch.patch"
103 # "${FILESDIR}/mypatch2.patch"
107 # @ECLASS-VARIABLE: QT5_TARGET_SUBDIRS
110 # Array variable containing the source directories that should be built.
111 # All paths must be relative to ${S}.
113 # @ECLASS-VARIABLE: QT5_BUILD_DIR
115 # Build directory for out-of-source builds.
116 case ${QT5_BUILD_TYPE} in
117 live) : ${QT5_BUILD_DIR:=${S}_build} ;;
118 release) : ${QT5_BUILD_DIR:=${S}} ;; # workaround for bug 497312
121 # @ECLASS-VARIABLE: QT5_GENTOO_CONFIG
124 # Array of <useflag:feature:macro> triplets that are evaluated in src_install
125 # to generate the per-package list of enabled QT_CONFIG features and macro
126 # definitions, which are then merged together with all other Qt5 packages
127 # installed on the system to obtain the global qconfig.{h,pri} files.
129 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
131 # For proper description see virtualx.eclass man page.
132 # Here we redefine default value to be manual, if your package needs virtualx
133 # for tests you should proceed with setting VIRTUALX_REQUIRED=test.
134 : ${VIRTUALX_REQUIRED:=manual}
137 ###### Phase functions ######
139 # @FUNCTION: qt5-build_src_unpack
141 # Unpacks the sources.
142 qt5-build_src_unpack() {
143 if [[ $(gcc-major-version) -lt 4 ]] || [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 5 ]]; then
145 ewarn "Using a GCC version lower than 4.5 is not supported."
149 if [[ ${PN} == qtwebkit ]]; then
150 eshopts_push -s extglob
151 if is-flagq '-g?(gdb)?([1-9])'; then
153 ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
154 ewarn "You may experience really long compilation times and/or increased memory usage."
155 ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
156 ewarn "For more info check out https://bugs.gentoo.org/307861"
162 case ${QT5_BUILD_TYPE} in
163 live) git-r3_src_unpack ;;
168 # @FUNCTION: qt5-build_src_prepare
170 # Prepares the environment and patches the sources if necessary.
171 qt5-build_src_prepare() {
174 if [[ ${QT5_MODULE} == qtbase ]]; then
175 qt5_symlink_tools_to_build_dir
177 # Avoid unnecessary qmake recompilations
178 sed -i -re "s|^if true;.*(\[ '\!').*(\"\\\$outpath/bin/qmake\".*)|if \1 -e \2 then|" \
179 configure || die "sed failed (skip qmake bootstrap)"
181 # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when bootstrapping qmake
182 sed -i -e "/outpath\/qmake\".*\"\$MAKE\")/ s:): \
183 ${MAKEOPTS} ${EXTRA_EMAKE} 'CC=$(tc-getCC)' 'CXX=$(tc-getCXX)' \
184 'QMAKE_CFLAGS=${CFLAGS}' 'QMAKE_CXXFLAGS=${CXXFLAGS}' 'QMAKE_LFLAGS=${LDFLAGS}'&:" \
185 -e '/"$CFG_RELEASE_QMAKE"/,/^\s\+fi$/ d' \
186 configure || die "sed failed (respect env for qmake build)"
187 sed -i -e '/^CPPFLAGS\s*=/ s/-g //' \
188 qmake/Makefile.unix || die "sed failed (CPPFLAGS for qmake build)"
190 # Respect CXX in {bsymbolic_functions,fvisibility,precomp}.test
191 sed -i -e "/^QMAKE_CONF_COMPILER=/ s:=.*:=\"$(tc-getCXX)\":" \
192 configure || die "sed failed (QMAKE_CONF_COMPILER)"
194 # Respect toolchain and flags in config.tests
195 find config.tests/unix -name '*.test' -type f \
196 -execdir sed -i -e '/bin\/qmake/ s/-nocache //' '{}' + \
197 || die "sed failed (config.tests)"
199 # Don't add -O3 to CXXFLAGS (bug 549140)
200 sed -i -e '/CONFIG\s*+=/ s/optimize_full//' \
201 src/{corelib/corelib,gui/gui}.pro || die "sed failed (optimize_full)"
205 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
209 # @FUNCTION: qt5-build_src_configure
211 # Runs qmake in the target directories. For packages
212 # in qtbase, ./configure is also run before qmake.
213 qt5-build_src_configure() {
214 if [[ ${QT5_MODULE} == qtbase ]]; then
218 qt5_foreach_target_subdir qt5_qmake
221 # @FUNCTION: qt5-build_src_compile
223 # Runs emake in the target directories.
224 qt5-build_src_compile() {
225 qt5_foreach_target_subdir emake
228 # @FUNCTION: qt5-build_src_test
230 # Runs tests in the target directories.
231 qt5-build_src_test() {
232 # disable broken cmake tests (bug 474004)
233 local myqmakeargs=("${myqmakeargs[@]}" -after SUBDIRS-=cmake SUBDIRS-=installed_cmake)
235 qt5_foreach_target_subdir qt5_qmake
236 qt5_foreach_target_subdir emake
238 # create a custom testrunner script that correctly sets
239 # {,DY}LD_LIBRARY_PATH before executing the given test
240 local testrunner=${QT5_BUILD_DIR}/gentoo-testrunner
241 cat <<-EOF > "${testrunner}"
243 export LD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}"
244 export DYLD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}"
247 chmod +x "${testrunner}"
250 qt5_foreach_target_subdir emake TESTRUNNER="'${testrunner}'" check
253 if [[ ${VIRTUALX_REQUIRED} == test ]]; then
254 VIRTUALX_COMMAND="_qt5_test_runner" virtualmake
260 # @FUNCTION: qt5-build_src_install
262 # Runs emake install in the target directories.
263 qt5-build_src_install() {
264 qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install
266 if [[ ${PN} == qtcore ]]; then
267 pushd "${QT5_BUILD_DIR}" >/dev/null || die
269 set -- emake INSTALL_ROOT="${D}" install_{global_docs,mkspecs,qmake,syncqt}
273 popd >/dev/null || die
275 docompress -x "${QT5_DOCDIR#${EPREFIX}}"/global
277 # install an empty Gentoo/gentoo-qconfig.h in ${D}
278 # so that it's placed under package manager control
279 > "${T}"/gentoo-qconfig.h
281 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
282 doins "${T}"/gentoo-qconfig.h
285 # include gentoo-qconfig.h at the beginning of QtCore/qconfig.h
286 sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
287 "${D}${QT5_HEADERDIR}"/QtCore/qconfig.h \
288 || die "sed failed (qconfig.h)"
290 # install qtchooser configuration file
291 cat > "${T}/qt5-${CHOST}.conf" <<-_EOF_
297 insinto /etc/xdg/qtchooser
298 doins "${T}/qt5-${CHOST}.conf"
301 # convenience symlinks
302 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/5.conf
303 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/qt5.conf
306 qt5_install_module_qconfigs
310 # @FUNCTION: qt5-build_pkg_postinst
312 # Regenerate configuration after installation or upgrade/downgrade.
313 qt5-build_pkg_postinst() {
314 qt5_regenerate_global_qconfigs
317 # @FUNCTION: qt5-build_pkg_postrm
319 # Regenerate configuration when a module is completely removed.
320 qt5-build_pkg_postrm() {
321 if [[ -z ${REPLACED_BY_VERSION} && ${PN} != qtcore ]]; then
322 qt5_regenerate_global_qconfigs
327 ###### Public helpers ######
330 # @USAGE: <flag> [feature] [enableval]
332 # <flag> is the name of a flag in IUSE.
334 # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
335 # otherwise. If [feature] is not specified, <flag> is used in its place.
336 # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
338 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
340 usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
343 # @FUNCTION: qt_use_compile_test
344 # @USAGE: <flag> [config]
346 # <flag> is the name of a flag in IUSE.
347 # [config] is the argument of qtCompileTest, defaults to <flag>.
349 # This function is useful to disable optional dependencies that are checked
350 # at qmake-time using the qtCompileTest() function. If <flag> is disabled,
351 # the compile test is skipped and the dependency is assumed to be unavailable,
352 # i.e. the corresponding feature will be disabled. Note that all invocations
353 # of this function must happen before calling qt5-build_src_configure.
354 qt_use_compile_test() {
355 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
358 mkdir -p "${QT5_BUILD_DIR}" || die
359 echo "CONFIG += done_config_${2:-$1}" >> "${QT5_BUILD_DIR}"/.qmake.cache || die
363 # @FUNCTION: qt_use_disable_mod
364 # @USAGE: <flag> <module> <files...>
366 # <flag> is the name of a flag in IUSE.
367 # <module> is the (lowercase) name of a Qt5 module.
368 # <files...> is a list of one or more qmake project files.
370 # This function patches <files> to treat <module> as not installed
371 # when <flag> is disabled, otherwise it does nothing.
372 # This can be useful to avoid an automagic dependency when the module
373 # is present on the system but the corresponding USE flag is disabled.
374 qt_use_disable_mod() {
375 [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
381 if ! use "${flag}"; then
382 echo "$@" | xargs sed -i -e "s/qtHaveModule(${module})/false/g" || die
387 ###### Internal functions ######
389 # @FUNCTION: qt5_prepare_env
392 # Prepares the environment for building Qt.
394 # setup installation directories
395 # note: keep paths in sync with qmake-utils.eclass
396 QT5_PREFIX=${EPREFIX}/usr
397 QT5_HEADERDIR=${QT5_PREFIX}/include/qt5
398 QT5_LIBDIR=${QT5_PREFIX}/$(get_libdir)
399 QT5_ARCHDATADIR=${QT5_PREFIX}/$(get_libdir)/qt5
400 QT5_BINDIR=${QT5_ARCHDATADIR}/bin
401 QT5_PLUGINDIR=${QT5_ARCHDATADIR}/plugins
402 QT5_LIBEXECDIR=${QT5_ARCHDATADIR}/libexec
403 QT5_IMPORTDIR=${QT5_ARCHDATADIR}/imports
404 QT5_QMLDIR=${QT5_ARCHDATADIR}/qml
405 QT5_DATADIR=${QT5_PREFIX}/share/qt5
406 QT5_DOCDIR=${QT5_PREFIX}/share/doc/qt-${PV}
407 QT5_TRANSLATIONDIR=${QT5_DATADIR}/translations
408 QT5_EXAMPLESDIR=${QT5_DATADIR}/examples
409 QT5_TESTSDIR=${QT5_DATADIR}/tests
410 QT5_SYSCONFDIR=${EPREFIX}/etc/xdg
412 if [[ ${QT5_MODULE} == qtbase ]]; then
413 # see mkspecs/features/qt_config.prf
414 export QMAKEMODULES="${QT5_BUILD_DIR}/mkspecs/modules:${S}/mkspecs/modules:${QT5_ARCHDATADIR}/mkspecs/modules"
418 # @FUNCTION: qt5_foreach_target_subdir
421 # Executes the arguments inside each directory listed in QT5_TARGET_SUBDIRS.
422 qt5_foreach_target_subdir() {
423 [[ -z ${QT5_TARGET_SUBDIRS[@]} ]] && QT5_TARGET_SUBDIRS=("")
426 for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do
427 if [[ ${EBUILD_PHASE} == test ]]; then
428 subdir=tests/auto${subdir#src}
429 [[ -d ${S}/${subdir} ]] || continue
432 mkdir -p "${QT5_BUILD_DIR}/${subdir}" || die
433 pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die
435 einfo "Running $* ${subdir:+in ${subdir}}"
439 popd >/dev/null || die
445 # @FUNCTION: qt5_symlink_tools_to_build_dir
448 # Symlinks qmake and a few other tools to QT5_BUILD_DIR,
449 # so that they can be used when building other modules.
450 qt5_symlink_tools_to_build_dir() {
452 if [[ ${PN} != qtcore ]]; then
453 tools+=(qmake moc rcc qlalr)
454 [[ ${PN} != qdoc ]] && tools+=(qdoc)
455 [[ ${PN} != qtdbus ]] && tools+=(qdbuscpp2xml qdbusxml2cpp)
456 [[ ${PN} != qtwidgets ]] && tools+=(uic)
459 mkdir -p "${QT5_BUILD_DIR}"/bin || die
460 pushd "${QT5_BUILD_DIR}"/bin >/dev/null || die
462 for tool in "${tools[@]}"; do
463 [[ -e ${QT5_BINDIR}/${tool} ]] || continue
464 ln -s "${QT5_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
467 popd >/dev/null || die
470 # @FUNCTION: qt5_base_configure
473 # Runs ./configure for modules belonging to qtbase.
474 qt5_base_configure() {
475 # setup toolchain variables used by configure
476 tc-export AR CC CXX OBJDUMP RANLIB STRIP
477 export LD="$(tc-getCXX)"
479 # configure arguments
482 -prefix "${QT5_PREFIX}"
483 -bindir "${QT5_BINDIR}"
484 -headerdir "${QT5_HEADERDIR}"
485 -libdir "${QT5_LIBDIR}"
486 -archdatadir "${QT5_ARCHDATADIR}"
487 -plugindir "${QT5_PLUGINDIR}"
488 -libexecdir "${QT5_LIBEXECDIR}"
489 -importdir "${QT5_IMPORTDIR}"
490 -qmldir "${QT5_QMLDIR}"
491 -datadir "${QT5_DATADIR}"
492 -docdir "${QT5_DOCDIR}"
493 -translationdir "${QT5_TRANSLATIONDIR}"
494 -sysconfdir "${QT5_SYSCONFDIR}"
495 -examplesdir "${QT5_EXAMPLESDIR}"
496 -testsdir "${QT5_TESTSDIR}"
498 # configure in release mode by default,
499 # override via the CONFIG qmake variable
501 -no-separate-debug-info
504 -opensource -confirm-license
506 # let configure automatically figure out if C++11 is supported
509 # build shared libraries
512 # always enable large file support
515 # disabling accessibility is not recommended by upstream, as
516 # it will break QStyle and may break other internal parts of Qt
519 # disable all SQL drivers by default, override in qtsql
520 -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc
521 -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds
523 # obsolete flag, does nothing
526 # instruction set support
527 $(is-flagq -mno-sse2 && echo -no-sse2)
528 $(is-flagq -mno-sse3 && echo -no-sse3)
529 $(is-flagq -mno-ssse3 && echo -no-ssse3)
530 $(is-flagq -mno-sse4.1 && echo -no-sse4.1)
531 $(is-flagq -mno-sse4.2 && echo -no-sse4.2)
532 $(is-flagq -mno-avx && echo -no-avx)
533 $(is-flagq -mno-avx2 && echo -no-avx2)
534 $(is-flagq -mno-dsp && echo -no-mips_dsp)
535 $(is-flagq -mno-dspr2 && echo -no-mips_dspr2)
537 # use pkg-config to detect include and library paths
540 # prefer system libraries (only common deps here)
544 # disable everything to prevent automagic deps (part 1)
547 $([[ ${QT5_MINOR_VERSION} -ge 6 ]] && echo -no-syslog)
548 -no-libpng -no-libjpeg
549 -no-freetype -no-harfbuzz
551 $([[ ${QT5_MINOR_VERSION} -ge 5 ]] && echo -no-libproxy)
552 $([[ ${QT5_MINOR_VERSION} -ge 5 ]] && echo -no-xkbcommon-{x11,evdev})
553 -no-xinput2 -no-xcb-xlib
555 # don't specify -no-gif because there is no way to override it later
558 # always enable glib event loop support
561 # disable everything to prevent automagic deps (part 2)
562 -no-pulseaudio -no-alsa
563 $([[ ${QT5_MINOR_VERSION} -ge 7 ]] && echo -no-gtk || echo -no-gtkstyle)
565 # exclude examples and tests from default build
570 # disable rpath on non-prefix (bugs 380415 and 417169)
571 $(usex prefix '' -no-rpath)
573 # print verbose information about each configure test
576 # doesn't actually matter since we override CXXFLAGS
579 # obsolete flag, does nothing
582 # always enable iconv support
585 # disable everything to prevent automagic deps (part 3)
587 $([[ ${QT5_MINOR_VERSION} -ge 5 ]] && echo -no-tslib)
588 -no-icu -no-fontconfig
594 # precompiled headers are not that useful for us
595 # and cause problems on hardened, so turn them off
598 # reduced relocations cause major breakage on at least arm and ppc, so
599 # don't specify anything and let the configure figure out if they are
600 # supported; see also https://bugreports.qt.io/browse/QTBUG-36129
603 # let configure automatically detect if GNU gold is available
606 # disable all platform plugins by default, override in qtgui
607 -no-xcb -no-eglfs -no-kms -no-directfb -no-linuxfb
608 $([[ ${QT5_MINOR_VERSION} -ge 6 ]] && echo -no-mirclient)
610 # disable undocumented X11-related flags, override in qtgui
611 # (not shown in ./configure -help output)
614 # disable obsolete/unused X11-related flags
615 # (not shown in ./configure -help output)
616 -no-mitshm -no-xcursor -no-xfixes -no-xinerama -no-xinput
617 -no-xrandr -no-xshape -no-xsync -no-xvideo
619 # always enable session management support: it doesn't need extra deps
620 # at configure time and turning it off is dangerous, see bug 518262
623 # typedef qreal to double (warning: changing this flag breaks the ABI)
626 # disable OpenGL and EGL support by default, override in qtgui,
627 # qtopengl, qtprintsupport and qtwidgets
630 # disable libinput-based generic plugin by default, override in qtgui
631 $([[ ${QT5_MINOR_VERSION} -ge 5 ]] && echo -no-libinput)
633 # disable gstreamer by default, override in qtmultimedia
634 $([[ ${QT5_MINOR_VERSION} -ge 5 ]] && echo -no-gstreamer)
636 # use upstream default
639 # do not build with -Werror
640 -no-warnings-are-errors
642 # module-specific options
646 pushd "${QT5_BUILD_DIR}" >/dev/null || die
648 einfo "Configuring with: ${conf[@]}"
649 "${S}"/configure "${conf[@]}" || die "configure failed"
651 popd >/dev/null || die
654 # @FUNCTION: qt5_qmake
657 # Helper function that runs qmake in the current target subdir.
658 # Intended to be called by qt5_foreach_target_subdir().
660 local projectdir=${PWD/#${QT5_BUILD_DIR}/${S}}
662 if [[ ${QT5_MODULE} == qtbase ]]; then
663 qmakepath=${QT5_BUILD_DIR}/bin
665 qmakepath=${QT5_BINDIR}
668 "${qmakepath}"/qmake \
670 CONFIG+=$(usex debug debug release) \
671 CONFIG-=$(usex debug release debug) \
672 QMAKE_AR="$(tc-getAR) cqs" \
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= \
690 QMAKE_LFLAGS_DEBUG= \
691 "${myqmakeargs[@]}" \
692 || die "qmake failed (${projectdir#${S}/})"
695 # @FUNCTION: qt5_install_module_qconfigs
698 # Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
699 qt5_install_module_qconfigs() {
700 local x qconfig_add= qconfig_remove=
702 > "${T}"/${PN}-qconfig.h
703 > "${T}"/${PN}-qconfig.pri
705 # generate qconfig_{add,remove} and ${PN}-qconfig.h
706 for x in "${QT5_GENTOO_CONFIG[@]}"; do
709 local feature=${x%%:*}
712 macro=$(tr 'a-z-' 'A-Z_' <<< "${macro}")
714 if [[ -z ${flag} ]] || { [[ ${flag} != '!' ]] && use ${flag}; }; then
715 [[ -n ${feature} ]] && qconfig_add+=" ${feature}"
716 [[ -n ${macro} ]] && echo "#define QT_${macro}" >> "${T}"/${PN}-qconfig.h
718 [[ -n ${feature} ]] && qconfig_remove+=" ${feature}"
719 [[ -n ${macro} ]] && echo "#define QT_NO_${macro}" >> "${T}"/${PN}-qconfig.h
723 # install ${PN}-qconfig.h
724 [[ -s ${T}/${PN}-qconfig.h ]] && (
725 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
726 doins "${T}"/${PN}-qconfig.h
729 # generate and install ${PN}-qconfig.pri
730 [[ -n ${qconfig_add} ]] && echo "QCONFIG_ADD=${qconfig_add}" >> "${T}"/${PN}-qconfig.pri
731 [[ -n ${qconfig_remove} ]] && echo "QCONFIG_REMOVE=${qconfig_remove}" >> "${T}"/${PN}-qconfig.pri
732 [[ -s ${T}/${PN}-qconfig.pri ]] && (
733 insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo
734 doins "${T}"/${PN}-qconfig.pri
738 # @FUNCTION: qt5_regenerate_global_qconfigs
741 # Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
742 # Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
743 qt5_regenerate_global_qconfigs() {
744 einfo "Regenerating gentoo-qconfig.h"
746 find "${ROOT%/}${QT5_HEADERDIR}"/Gentoo \
747 -name '*-qconfig.h' -a \! -name 'gentoo-qconfig.h' -type f \
748 -execdir cat '{}' + | sort -u > "${T}"/gentoo-qconfig.h
750 [[ -s ${T}/gentoo-qconfig.h ]] || ewarn "Generated gentoo-qconfig.h is empty"
751 mv -f "${T}"/gentoo-qconfig.h "${ROOT%/}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \
752 || eerror "Failed to install new gentoo-qconfig.h"
754 einfo "Updating QT_CONFIG in qconfig.pri"
756 local qconfig_pri=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri
757 if [[ -f ${qconfig_pri} ]]; then
758 local x qconfig_add= qconfig_remove=
759 local qt_config=$(sed -n 's/^QT_CONFIG\s*+=\s*//p' "${qconfig_pri}")
762 # generate list of QT_CONFIG entries from the existing list,
763 # appending QCONFIG_ADD and excluding QCONFIG_REMOVE
764 eshopts_push -s nullglob
765 for x in "${ROOT%/}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
766 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=\s*//p' "${x}")"
767 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=\s*//p' "${x}")"
770 for x in ${qt_config} ${qconfig_add}; do
771 if ! has "${x}" ${new_qt_config} ${qconfig_remove}; then
772 new_qt_config+=" ${x}"
776 # now replace the existing QT_CONFIG with the generated list
777 sed -i -e "s/^QT_CONFIG\s*+=.*/QT_CONFIG +=${new_qt_config}/" \
778 "${qconfig_pri}" || eerror "Failed to sed QT_CONFIG in ${qconfig_pri}"
780 ewarn "${qconfig_pri} does not exist or is not a regular file"