/[gentoo-x86]/eclass/qt5-build.eclass
Gentoo

Contents of /eclass/qt5-build.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.23 - (show annotations) (download)
Fri Aug 7 02:05:19 2015 UTC (3 years, 8 months ago) by pesa
Branch: MAIN
CVS Tags: HEAD
Changes since 1.22: +9 -1 lines
Fix bugs #549140 and #552942.

1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/qt5-build.eclass,v 1.22 2015/08/07 01:07:09 pesa Exp $
4
5 # @ECLASS: qt5-build.eclass
6 # @MAINTAINER:
7 # Qt herd <qt@gentoo.org>
8 # @AUTHOR:
9 # Davide Pesavento <pesa@gentoo.org>
10 # @BLURB: Eclass for Qt5 split ebuilds.
11 # @DESCRIPTION:
12 # This eclass contains various functions that are used when building Qt5.
13 # Requires EAPI 5.
14
15 case ${EAPI} in
16 5) : ;;
17 *) die "qt5-build.eclass: unsupported EAPI=${EAPI:-0}" ;;
18 esac
19
20 inherit eutils flag-o-matic multilib toolchain-funcs virtualx
21
22 QT5_MINOR_VERSION=${PV#*.}
23 QT5_MINOR_VERSION=${QT5_MINOR_VERSION%%.*}
24
25 HOMEPAGE="https://www.qt.io/"
26 LICENSE="|| ( LGPL-2.1 LGPL-3 ) FDL-1.3"
27 SLOT="5"
28
29 # @ECLASS-VARIABLE: QT5_MODULE
30 # @DESCRIPTION:
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}}
34
35 case ${PV} in
36 5.9999)
37 # git dev branch
38 QT5_BUILD_TYPE="live"
39 EGIT_BRANCH="dev"
40 ;;
41 5.?.9999)
42 # git stable branch
43 QT5_BUILD_TYPE="live"
44 EGIT_BRANCH=${PV%.9999}
45 ;;
46 *_alpha*|*_beta*|*_rc*)
47 # development release
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"
51 S=${WORKDIR}/${MY_P}
52 ;;
53 *)
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"
58 S=${WORKDIR}/${MY_P}
59 ;;
60 esac
61
62 EGIT_REPO_URI=(
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"
66 )
67 [[ ${QT5_BUILD_TYPE} == live ]] && inherit git-r3
68
69 IUSE="debug test"
70
71 [[ ${PN} == qtwebkit ]] && RESTRICT+=" mirror" # bug 524584
72 [[ ${QT5_BUILD_TYPE} == release ]] && RESTRICT+=" test" # bug 457182
73
74 DEPEND="
75 dev-lang/perl
76 virtual/pkgconfig
77 "
78 if [[ ${PN} != qttest ]]; then
79 if [[ ${QT5_MODULE} == qtbase ]]; then
80 DEPEND+=" test? ( ~dev-qt/qttest-${PV} )"
81 else
82 DEPEND+=" test? ( >=dev-qt/qttest-${PV}:5 )"
83 fi
84 fi
85 RDEPEND="
86 dev-qt/qtchooser
87 "
88
89 EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm
90
91
92 # @ECLASS-VARIABLE: PATCHES
93 # @DEFAULT_UNSET
94 # @DESCRIPTION:
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.
98 #
99 # Example:
100 # @CODE
101 # PATCHES=(
102 # "${FILESDIR}/mypatch.patch"
103 # "${FILESDIR}/mypatch2.patch"
104 # )
105 # @CODE
106
107 # @ECLASS-VARIABLE: QT5_TARGET_SUBDIRS
108 # @DEFAULT_UNSET
109 # @DESCRIPTION:
110 # Array variable containing the source directories that should be built.
111 # All paths must be relative to ${S}.
112
113 # @ECLASS-VARIABLE: QT5_BUILD_DIR
114 # @DESCRIPTION:
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
119 esac
120
121 # @ECLASS-VARIABLE: QT5_GENTOO_CONFIG
122 # @DEFAULT_UNSET
123 # @DESCRIPTION:
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.
128
129 # @ECLASS-VARIABLE: VIRTUALX_REQUIRED
130 # @DESCRIPTION:
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}
135
136
137 ###### Phase functions ######
138
139 # @FUNCTION: qt5-build_src_unpack
140 # @DESCRIPTION:
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
144 ewarn
145 ewarn "Using a GCC version lower than 4.5 is not supported."
146 ewarn
147 fi
148
149 if [[ ${PN} == qtwebkit ]]; then
150 eshopts_push -s extglob
151 if is-flagq '-g?(gdb)?([1-9])'; then
152 ewarn
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"
157 ewarn
158 fi
159 eshopts_pop
160 fi
161
162 case ${QT5_BUILD_TYPE} in
163 live) git-r3_src_unpack ;;
164 release) default ;;
165 esac
166 }
167
168 # @FUNCTION: qt5-build_src_prepare
169 # @DESCRIPTION:
170 # Prepares the environment and patches the sources if necessary.
171 qt5-build_src_prepare() {
172 qt5_prepare_env
173
174 if [[ ${QT5_MODULE} == qtbase ]]; then
175 qt5_symlink_tools_to_build_dir
176
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)"
180
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)"
189
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)"
193
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)"
198
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)"
202
203 # Don't force sse2 on x86 (bug 552942)
204 sed -i -e 's/^sse2:/false:&/' \
205 mkspecs/features/qt_module.prf || die "sed failed (sse2)"
206 fi
207
208 # apply patches
209 [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
210 epatch_user
211 }
212
213 # @FUNCTION: qt5-build_src_configure
214 # @DESCRIPTION:
215 # Runs qmake in the target directories. For packages
216 # in qtbase, ./configure is also run before qmake.
217 qt5-build_src_configure() {
218 if [[ ${QT5_MODULE} == qtbase ]]; then
219 qt5_base_configure
220 fi
221
222 qt5_foreach_target_subdir qt5_qmake
223 }
224
225 # @FUNCTION: qt5-build_src_compile
226 # @DESCRIPTION:
227 # Runs emake in the target directories.
228 qt5-build_src_compile() {
229 qt5_foreach_target_subdir emake
230 }
231
232 # @FUNCTION: qt5-build_src_test
233 # @DESCRIPTION:
234 # Runs tests in the target directories.
235 qt5-build_src_test() {
236 # disable broken cmake tests (bug 474004)
237 local myqmakeargs=("${myqmakeargs[@]}" -after SUBDIRS-=cmake SUBDIRS-=installed_cmake)
238
239 qt5_foreach_target_subdir qt5_qmake
240 qt5_foreach_target_subdir emake
241
242 # create a custom testrunner script that correctly sets
243 # {,DY}LD_LIBRARY_PATH before executing the given test
244 local testrunner=${QT5_BUILD_DIR}/gentoo-testrunner
245 cat <<-EOF > "${testrunner}"
246 #!/bin/sh
247 export LD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}"
248 export DYLD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}"
249 "\$@"
250 EOF
251 chmod +x "${testrunner}"
252
253 _qt5_test_runner() {
254 qt5_foreach_target_subdir emake TESTRUNNER="'${testrunner}'" check
255 }
256
257 if [[ ${VIRTUALX_REQUIRED} == test ]]; then
258 VIRTUALX_COMMAND="_qt5_test_runner" virtualmake
259 else
260 _qt5_test_runner
261 fi
262 }
263
264 # @FUNCTION: qt5-build_src_install
265 # @DESCRIPTION:
266 # Runs emake install in the target directories.
267 qt5-build_src_install() {
268 qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install
269
270 if [[ ${PN} == qtcore ]]; then
271 pushd "${QT5_BUILD_DIR}" >/dev/null || die
272
273 set -- emake INSTALL_ROOT="${D}" install_{global_docs,mkspecs,qmake,syncqt}
274 einfo "Running $*"
275 "$@"
276
277 popd >/dev/null || die
278
279 docompress -x "${QT5_DOCDIR#${EPREFIX}}"/global
280
281 # install an empty Gentoo/gentoo-qconfig.h in ${D}
282 # so that it's placed under package manager control
283 > "${T}"/gentoo-qconfig.h
284 (
285 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
286 doins "${T}"/gentoo-qconfig.h
287 )
288
289 # include gentoo-qconfig.h at the beginning of QtCore/qconfig.h
290 sed -i -e '1i #include <Gentoo/gentoo-qconfig.h>\n' \
291 "${D}${QT5_HEADERDIR}"/QtCore/qconfig.h \
292 || die "sed failed (qconfig.h)"
293
294 # install qtchooser configuration file
295 cat > "${T}/qt5-${CHOST}.conf" <<-_EOF_
296 ${QT5_BINDIR}
297 ${QT5_LIBDIR}
298 _EOF_
299
300 (
301 insinto /etc/xdg/qtchooser
302 doins "${T}/qt5-${CHOST}.conf"
303 )
304
305 # convenience symlinks
306 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/5.conf
307 dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/qt5.conf
308 fi
309
310 qt5_install_module_qconfigs
311 prune_libtool_files
312 }
313
314 # @FUNCTION: qt5-build_pkg_postinst
315 # @DESCRIPTION:
316 # Regenerate configuration after installation or upgrade/downgrade.
317 qt5-build_pkg_postinst() {
318 qt5_regenerate_global_qconfigs
319 }
320
321 # @FUNCTION: qt5-build_pkg_postrm
322 # @DESCRIPTION:
323 # Regenerate configuration when a module is completely removed.
324 qt5-build_pkg_postrm() {
325 if [[ -z ${REPLACED_BY_VERSION} && ${PN} != qtcore ]]; then
326 qt5_regenerate_global_qconfigs
327 fi
328 }
329
330
331 ###### Public helpers ######
332
333 # @FUNCTION: qt_use
334 # @USAGE: <flag> [feature] [enableval]
335 # @DESCRIPTION:
336 # <flag> is the name of a flag in IUSE.
337 #
338 # Outputs "-${enableval}-${feature}" if <flag> is enabled, "-no-${feature}"
339 # otherwise. If [feature] is not specified, <flag> is used in its place.
340 # If [enableval] is not specified, the "-${enableval}" prefix is omitted.
341 qt_use() {
342 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
343
344 usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}"
345 }
346
347 # @FUNCTION: qt_use_compile_test
348 # @USAGE: <flag> [config]
349 # @DESCRIPTION:
350 # <flag> is the name of a flag in IUSE.
351 # [config] is the argument of qtCompileTest, defaults to <flag>.
352 #
353 # This function is useful to disable optional dependencies that are checked
354 # at qmake-time using the qtCompileTest() function. If <flag> is disabled,
355 # the compile test is skipped and the dependency is assumed to be unavailable,
356 # i.e. the corresponding feature will be disabled. Note that all invocations
357 # of this function must happen before calling qt5-build_src_configure.
358 qt_use_compile_test() {
359 [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument"
360
361 if ! use "$1"; then
362 mkdir -p "${QT5_BUILD_DIR}" || die
363 echo "CONFIG += done_config_${2:-$1}" >> "${QT5_BUILD_DIR}"/.qmake.cache || die
364 fi
365 }
366
367 # @FUNCTION: qt_use_disable_mod
368 # @USAGE: <flag> <module> <files...>
369 # @DESCRIPTION:
370 # <flag> is the name of a flag in IUSE.
371 # <module> is the (lowercase) name of a Qt5 module.
372 # <files...> is a list of one or more qmake project files.
373 #
374 # This function patches <files> to treat <module> as not installed
375 # when <flag> is disabled, otherwise it does nothing.
376 # This can be useful to avoid an automagic dependency when the module
377 # is present on the system but the corresponding USE flag is disabled.
378 qt_use_disable_mod() {
379 [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments"
380
381 local flag=$1
382 local module=$2
383 shift 2
384
385 if ! use "${flag}"; then
386 echo "$@" | xargs sed -i -e "s/qtHaveModule(${module})/false/g" || die
387 fi
388 }
389
390
391 ###### Internal functions ######
392
393 # @FUNCTION: qt5_prepare_env
394 # @INTERNAL
395 # @DESCRIPTION:
396 # Prepares the environment for building Qt.
397 qt5_prepare_env() {
398 # setup installation directories
399 # note: keep paths in sync with qmake-utils.eclass
400 QT5_PREFIX=${EPREFIX}/usr
401 QT5_HEADERDIR=${QT5_PREFIX}/include/qt5
402 QT5_LIBDIR=${QT5_PREFIX}/$(get_libdir)
403 QT5_ARCHDATADIR=${QT5_PREFIX}/$(get_libdir)/qt5
404 QT5_BINDIR=${QT5_ARCHDATADIR}/bin
405 QT5_PLUGINDIR=${QT5_ARCHDATADIR}/plugins
406 QT5_LIBEXECDIR=${QT5_ARCHDATADIR}/libexec
407 QT5_IMPORTDIR=${QT5_ARCHDATADIR}/imports
408 QT5_QMLDIR=${QT5_ARCHDATADIR}/qml
409 QT5_DATADIR=${QT5_PREFIX}/share/qt5
410 QT5_DOCDIR=${QT5_PREFIX}/share/doc/qt-${PV}
411 QT5_TRANSLATIONDIR=${QT5_DATADIR}/translations
412 QT5_EXAMPLESDIR=${QT5_DATADIR}/examples
413 QT5_TESTSDIR=${QT5_DATADIR}/tests
414 QT5_SYSCONFDIR=${EPREFIX}/etc/xdg
415
416 if [[ ${QT5_MODULE} == qtbase ]]; then
417 # see mkspecs/features/qt_config.prf
418 export QMAKEMODULES="${QT5_BUILD_DIR}/mkspecs/modules:${S}/mkspecs/modules:${QT5_ARCHDATADIR}/mkspecs/modules"
419 fi
420 }
421
422 # @FUNCTION: qt5_foreach_target_subdir
423 # @INTERNAL
424 # @DESCRIPTION:
425 # Executes the arguments inside each directory listed in QT5_TARGET_SUBDIRS.
426 qt5_foreach_target_subdir() {
427 [[ -z ${QT5_TARGET_SUBDIRS[@]} ]] && QT5_TARGET_SUBDIRS=("")
428
429 local ret=0 subdir=
430 for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do
431 if [[ ${EBUILD_PHASE} == test ]]; then
432 subdir=tests/auto${subdir#src}
433 [[ -d ${S}/${subdir} ]] || continue
434 fi
435
436 mkdir -p "${QT5_BUILD_DIR}/${subdir}" || die
437 pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die
438
439 einfo "Running $* ${subdir:+in ${subdir}}"
440 "$@"
441 ((ret+=$?))
442
443 popd >/dev/null || die
444 done
445
446 return ${ret}
447 }
448
449 # @FUNCTION: qt5_symlink_tools_to_build_dir
450 # @INTERNAL
451 # @DESCRIPTION:
452 # Symlinks qmake and a few other tools to QT5_BUILD_DIR,
453 # so that they can be used when building other modules.
454 qt5_symlink_tools_to_build_dir() {
455 local tool= tools=()
456 if [[ ${PN} != qtcore ]]; then
457 tools+=(qmake moc rcc qlalr)
458 [[ ${PN} != qdoc ]] && tools+=(qdoc)
459 [[ ${PN} != qtdbus ]] && tools+=(qdbuscpp2xml qdbusxml2cpp)
460 [[ ${PN} != qtwidgets ]] && tools+=(uic)
461 fi
462
463 mkdir -p "${QT5_BUILD_DIR}"/bin || die
464 pushd "${QT5_BUILD_DIR}"/bin >/dev/null || die
465
466 for tool in "${tools[@]}"; do
467 [[ -e ${QT5_BINDIR}/${tool} ]] || continue
468 ln -s "${QT5_BINDIR}/${tool}" . || die "failed to symlink ${tool}"
469 done
470
471 popd >/dev/null || die
472 }
473
474 # @FUNCTION: qt5_base_configure
475 # @INTERNAL
476 # @DESCRIPTION:
477 # Runs ./configure for modules belonging to qtbase.
478 qt5_base_configure() {
479 # setup toolchain variables used by configure
480 tc-export AR CC CXX OBJDUMP RANLIB STRIP
481 export LD="$(tc-getCXX)"
482
483 # configure arguments
484 local conf=(
485 # installation paths
486 -prefix "${QT5_PREFIX}"
487 -bindir "${QT5_BINDIR}"
488 -headerdir "${QT5_HEADERDIR}"
489 -libdir "${QT5_LIBDIR}"
490 -archdatadir "${QT5_ARCHDATADIR}"
491 -plugindir "${QT5_PLUGINDIR}"
492 -libexecdir "${QT5_LIBEXECDIR}"
493 -importdir "${QT5_IMPORTDIR}"
494 -qmldir "${QT5_QMLDIR}"
495 -datadir "${QT5_DATADIR}"
496 -docdir "${QT5_DOCDIR}"
497 -translationdir "${QT5_TRANSLATIONDIR}"
498 -sysconfdir "${QT5_SYSCONFDIR}"
499 -examplesdir "${QT5_EXAMPLESDIR}"
500 -testsdir "${QT5_TESTSDIR}"
501
502 # configure in release mode by default,
503 # override via the CONFIG qmake variable
504 -release
505 -no-separate-debug-info
506
507 # licensing stuff
508 -opensource -confirm-license
509
510 # let configure automatically figure out if C++11 is supported
511 #-c++11
512
513 # build shared libraries
514 -shared
515
516 # always enable large file support
517 -largefile
518
519 # disabling accessibility is not recommended by upstream, as
520 # it will break QStyle and may break other internal parts of Qt
521 -accessibility
522
523 # disable all SQL drivers by default, override in qtsql
524 -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc
525 -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds
526
527 # obsolete flag, does nothing
528 #-qml-debug
529
530 # instruction set support
531 $(is-flagq -mno-sse2 && echo -no-sse2)
532 $(is-flagq -mno-sse3 && echo -no-sse3)
533 $(is-flagq -mno-ssse3 && echo -no-ssse3)
534 $(is-flagq -mno-sse4.1 && echo -no-sse4.1)
535 $(is-flagq -mno-sse4.2 && echo -no-sse4.2)
536 $(is-flagq -mno-avx && echo -no-avx)
537 $(is-flagq -mno-avx2 && echo -no-avx2)
538 $(is-flagq -mno-dsp && echo -no-mips_dsp)
539 $(is-flagq -mno-dspr2 && echo -no-mips_dspr2)
540
541 # use pkg-config to detect include and library paths
542 -pkg-config
543
544 # prefer system libraries (only common deps here)
545 -system-zlib
546 -system-pcre
547
548 # disable everything to prevent automagic deps (part 1)
549 -no-mtdev
550 -no-journald
551 -no-libpng -no-libjpeg
552 -no-freetype -no-harfbuzz
553 -no-openssl
554 $([[ ${QT5_MINOR_VERSION} -ge 5 ]] && echo -no-libproxy)
555 $([[ ${QT5_MINOR_VERSION} -ge 5 ]] && echo -no-xkbcommon-{x11,evdev})
556 -no-xinput2 -no-xcb-xlib
557
558 # don't specify -no-gif because there is no way to override it later
559 #-no-gif
560
561 # always enable glib event loop support
562 -glib
563
564 # disable everything to prevent automagic deps (part 2)
565 -no-pulseaudio -no-alsa
566
567 # override in qtgui and qtwidgets where x11-libs/cairo[qt4] is blocked
568 # to avoid adding qt4 include paths (bug 433826)
569 -no-gtkstyle
570
571 # exclude examples and tests from default build
572 -nomake examples
573 -nomake tests
574 -no-compile-examples
575
576 # disable rpath on non-prefix (bugs 380415 and 417169)
577 $(usex prefix '' -no-rpath)
578
579 # print verbose information about each configure test
580 -verbose
581
582 # doesn't actually matter since we override CXXFLAGS
583 #-no-optimized-qmake
584
585 # obsolete flag, does nothing
586 #-nis
587
588 # always enable iconv support
589 -iconv
590
591 # disable everything to prevent automagic deps (part 3)
592 -no-cups -no-evdev
593 $([[ ${QT5_MINOR_VERSION} -ge 5 ]] && echo -no-tslib)
594 -no-icu -no-fontconfig
595 -no-dbus
596
597 # don't strip
598 -no-strip
599
600 # precompiled headers are not that useful for us
601 # and cause problems on hardened, so turn them off
602 -no-pch
603
604 # reduced relocations cause major breakage on at least arm and ppc, so
605 # don't specify anything and let the configure figure out if they are
606 # supported; see also https://bugreports.qt.io/browse/QTBUG-36129
607 #-reduce-relocations
608
609 # let configure automatically detect if GNU gold is available
610 #-use-gold-linker
611
612 # disable all platform plugins by default, override in qtgui
613 -no-xcb -no-eglfs -no-directfb -no-linuxfb -no-kms
614
615 # disable undocumented X11-related flags, override in qtgui
616 # (not shown in ./configure -help output)
617 -no-xkb -no-xrender
618
619 # disable obsolete/unused X11-related flags
620 # (not shown in ./configure -help output)
621 -no-mitshm -no-xcursor -no-xfixes -no-xinerama -no-xinput
622 -no-xrandr -no-xshape -no-xsync -no-xvideo
623
624 # always enable session management support: it doesn't need extra deps
625 # at configure time and turning it off is dangerous, see bug 518262
626 -sm
627
628 # typedef qreal to double (warning: changing this flag breaks the ABI)
629 -qreal double
630
631 # disable OpenGL and EGL support by default, override in qtgui,
632 # qtopengl, qtprintsupport and qtwidgets
633 -no-opengl -no-egl
634
635 # disable libinput-based generic plugin by default, override in qtgui
636 $([[ ${QT5_MINOR_VERSION} -ge 5 ]] && echo -no-libinput)
637
638 # disable gstreamer by default, override in qtmultimedia
639 $([[ ${QT5_MINOR_VERSION} -ge 5 ]] && echo -no-gstreamer)
640
641 # use upstream default
642 #-no-system-proxies
643
644 # do not build with -Werror
645 -no-warnings-are-errors
646
647 # module-specific options
648 "${myconf[@]}"
649 )
650
651 pushd "${QT5_BUILD_DIR}" >/dev/null || die
652
653 einfo "Configuring with: ${conf[@]}"
654 "${S}"/configure "${conf[@]}" || die "configure failed"
655
656 popd >/dev/null || die
657 }
658
659 # @FUNCTION: qt5_qmake
660 # @INTERNAL
661 # @DESCRIPTION:
662 # Helper function that runs qmake in the current target subdir.
663 # Intended to be called by qt5_foreach_target_subdir().
664 qt5_qmake() {
665 local projectdir=${PWD/#${QT5_BUILD_DIR}/${S}}
666 local qmakepath=
667 if [[ ${QT5_MODULE} == qtbase ]]; then
668 qmakepath=${QT5_BUILD_DIR}/bin
669 else
670 qmakepath=${QT5_BINDIR}
671 fi
672
673 "${qmakepath}"/qmake \
674 "${projectdir}" \
675 CONFIG+=$(usex debug debug release) \
676 CONFIG-=$(usex debug release debug) \
677 QMAKE_AR="$(tc-getAR) cqs" \
678 QMAKE_CC="$(tc-getCC)" \
679 QMAKE_LINK_C="$(tc-getCC)" \
680 QMAKE_LINK_C_SHLIB="$(tc-getCC)" \
681 QMAKE_CXX="$(tc-getCXX)" \
682 QMAKE_LINK="$(tc-getCXX)" \
683 QMAKE_LINK_SHLIB="$(tc-getCXX)" \
684 QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
685 QMAKE_RANLIB= \
686 QMAKE_STRIP="$(tc-getSTRIP)" \
687 QMAKE_CFLAGS="${CFLAGS}" \
688 QMAKE_CFLAGS_RELEASE= \
689 QMAKE_CFLAGS_DEBUG= \
690 QMAKE_CXXFLAGS="${CXXFLAGS}" \
691 QMAKE_CXXFLAGS_RELEASE= \
692 QMAKE_CXXFLAGS_DEBUG= \
693 QMAKE_LFLAGS="${LDFLAGS}" \
694 QMAKE_LFLAGS_RELEASE= \
695 QMAKE_LFLAGS_DEBUG= \
696 "${myqmakeargs[@]}" \
697 || die "qmake failed (${projectdir#${S}/})"
698 }
699
700 # @FUNCTION: qt5_install_module_qconfigs
701 # @INTERNAL
702 # @DESCRIPTION:
703 # Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files.
704 qt5_install_module_qconfigs() {
705 local x qconfig_add= qconfig_remove=
706
707 > "${T}"/${PN}-qconfig.h
708 > "${T}"/${PN}-qconfig.pri
709
710 # generate qconfig_{add,remove} and ${PN}-qconfig.h
711 for x in "${QT5_GENTOO_CONFIG[@]}"; do
712 local flag=${x%%:*}
713 x=${x#${flag}:}
714 local feature=${x%%:*}
715 x=${x#${feature}:}
716 local macro=${x}
717 macro=$(tr 'a-z-' 'A-Z_' <<< "${macro}")
718
719 if [[ -z ${flag} ]] || { [[ ${flag} != '!' ]] && use ${flag}; }; then
720 [[ -n ${feature} ]] && qconfig_add+=" ${feature}"
721 [[ -n ${macro} ]] && echo "#define QT_${macro}" >> "${T}"/${PN}-qconfig.h
722 else
723 [[ -n ${feature} ]] && qconfig_remove+=" ${feature}"
724 [[ -n ${macro} ]] && echo "#define QT_NO_${macro}" >> "${T}"/${PN}-qconfig.h
725 fi
726 done
727
728 # install ${PN}-qconfig.h
729 [[ -s ${T}/${PN}-qconfig.h ]] && (
730 insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
731 doins "${T}"/${PN}-qconfig.h
732 )
733
734 # generate and install ${PN}-qconfig.pri
735 [[ -n ${qconfig_add} ]] && echo "QCONFIG_ADD=${qconfig_add}" >> "${T}"/${PN}-qconfig.pri
736 [[ -n ${qconfig_remove} ]] && echo "QCONFIG_REMOVE=${qconfig_remove}" >> "${T}"/${PN}-qconfig.pri
737 [[ -s ${T}/${PN}-qconfig.pri ]] && (
738 insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo
739 doins "${T}"/${PN}-qconfig.pri
740 )
741 }
742
743 # @FUNCTION: qt5_regenerate_global_qconfigs
744 # @INTERNAL
745 # @DESCRIPTION:
746 # Generates Gentoo-specific qconfig.{h,pri} according to the build configuration.
747 # Don't call die here because dying in pkg_post{inst,rm} only makes things worse.
748 qt5_regenerate_global_qconfigs() {
749 einfo "Regenerating gentoo-qconfig.h"
750
751 find "${ROOT%/}${QT5_HEADERDIR}"/Gentoo \
752 -name '*-qconfig.h' -a \! -name 'gentoo-qconfig.h' -type f \
753 -execdir cat '{}' + | sort -u > "${T}"/gentoo-qconfig.h
754
755 [[ -s ${T}/gentoo-qconfig.h ]] || ewarn "Generated gentoo-qconfig.h is empty"
756 mv -f "${T}"/gentoo-qconfig.h "${ROOT%/}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \
757 || eerror "Failed to install new gentoo-qconfig.h"
758
759 einfo "Updating QT_CONFIG in qconfig.pri"
760
761 local qconfig_pri=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri
762 if [[ -f ${qconfig_pri} ]]; then
763 local x qconfig_add= qconfig_remove=
764 local qt_config=$(sed -n 's/^QT_CONFIG\s*+=\s*//p' "${qconfig_pri}")
765 local new_qt_config=
766
767 # generate list of QT_CONFIG entries from the existing list,
768 # appending QCONFIG_ADD and excluding QCONFIG_REMOVE
769 eshopts_push -s nullglob
770 for x in "${ROOT%/}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
771 qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=\s*//p' "${x}")"
772 qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=\s*//p' "${x}")"
773 done
774 eshopts_pop
775 for x in ${qt_config} ${qconfig_add}; do
776 if ! has "${x}" ${new_qt_config} ${qconfig_remove}; then
777 new_qt_config+=" ${x}"
778 fi
779 done
780
781 # now replace the existing QT_CONFIG with the generated list
782 sed -i -e "s/^QT_CONFIG\s*+=.*/QT_CONFIG +=${new_qt_config}/" \
783 "${qconfig_pri}" || eerror "Failed to sed QT_CONFIG in ${qconfig_pri}"
784 else
785 ewarn "${qconfig_pri} does not exist or is not a regular file"
786 fi
787 }

  ViewVC Help
Powered by ViewVC 1.1.20