1 |
commit: 28220ab69ae4359ea742a89dea2c127d719b70d0 |
2 |
Author: Aric Belsito <lluixhi <AT> gmail <DOT> com> |
3 |
AuthorDate: Wed Nov 29 19:59:23 2017 +0000 |
4 |
Commit: Aric Belsito <lluixhi <AT> gmail <DOT> com> |
5 |
CommitDate: Wed Nov 29 19:59:23 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=28220ab6 |
7 |
|
8 |
eclass: disable gold linker in qt5 |
9 |
|
10 |
eclass/qt5-build.eclass | 808 ++++++++++++++++++++++++++++++++++++++++++++++++ |
11 |
1 file changed, 808 insertions(+) |
12 |
|
13 |
diff --git a/eclass/qt5-build.eclass b/eclass/qt5-build.eclass |
14 |
new file mode 100644 |
15 |
index 0000000..82a2aaf |
16 |
--- /dev/null |
17 |
+++ b/eclass/qt5-build.eclass |
18 |
@@ -0,0 +1,808 @@ |
19 |
+# Copyright 1999-2017 Gentoo Foundation |
20 |
+# Distributed under the terms of the GNU General Public License v2 |
21 |
+ |
22 |
+# @ECLASS: qt5-build.eclass |
23 |
+# @MAINTAINER: |
24 |
+# qt@g.o |
25 |
+# @AUTHOR: |
26 |
+# Davide Pesavento <pesa@g.o> |
27 |
+# @SUPPORTED_EAPIS: 6 |
28 |
+# @BLURB: Eclass for Qt5 split ebuilds. |
29 |
+# @DESCRIPTION: |
30 |
+# This eclass contains various functions that are used when building Qt5. |
31 |
+# Requires EAPI 6. |
32 |
+ |
33 |
+if [[ ${CATEGORY} != dev-qt ]]; then |
34 |
+ die "qt5-build.eclass is only to be used for building Qt 5." |
35 |
+fi |
36 |
+ |
37 |
+case ${EAPI} in |
38 |
+ 6) : ;; |
39 |
+ *) die "qt5-build.eclass: unsupported EAPI=${EAPI:-0}" ;; |
40 |
+esac |
41 |
+ |
42 |
+# @ECLASS-VARIABLE: QT5_MODULE |
43 |
+# @PRE_INHERIT |
44 |
+# @DESCRIPTION: |
45 |
+# The upstream name of the module this package belongs to. Used for |
46 |
+# SRC_URI and EGIT_REPO_URI. Must be set before inheriting the eclass. |
47 |
+: ${QT5_MODULE:=${PN}} |
48 |
+ |
49 |
+# @ECLASS-VARIABLE: QT5_TARGET_SUBDIRS |
50 |
+# @DEFAULT_UNSET |
51 |
+# @DESCRIPTION: |
52 |
+# Array variable containing the source directories that should be built. |
53 |
+# All paths must be relative to ${S}. |
54 |
+ |
55 |
+# @ECLASS-VARIABLE: QT5_GENTOO_CONFIG |
56 |
+# @DEFAULT_UNSET |
57 |
+# @DESCRIPTION: |
58 |
+# Array of <useflag:feature:macro> triplets that are evaluated in src_install |
59 |
+# to generate the per-package list of enabled QT_CONFIG features and macro |
60 |
+# definitions, which are then merged together with all other Qt5 packages |
61 |
+# installed on the system to obtain the global qconfig.{h,pri} files. |
62 |
+ |
63 |
+# @ECLASS-VARIABLE: VIRTUALX_REQUIRED |
64 |
+# @DESCRIPTION: |
65 |
+# For proper description see virtualx.eclass man page. |
66 |
+# Here we redefine default value to be manual, if your package needs virtualx |
67 |
+# for tests you should proceed with setting VIRTUALX_REQUIRED=test. |
68 |
+: ${VIRTUALX_REQUIRED:=manual} |
69 |
+ |
70 |
+inherit estack flag-o-matic ltprune toolchain-funcs versionator virtualx |
71 |
+ |
72 |
+HOMEPAGE="https://www.qt.io/" |
73 |
+LICENSE="|| ( GPL-2 GPL-3 LGPL-3 ) FDL-1.3" |
74 |
+SLOT=5/$(get_version_component_range 1-2) |
75 |
+ |
76 |
+QT5_MINOR_VERSION=$(get_version_component_range 2) |
77 |
+QT5_PATCH_VERSION=$(get_version_component_range 3) |
78 |
+readonly QT5_MINOR_VERSION QT5_PATCH_VERSION |
79 |
+ |
80 |
+case ${PV} in |
81 |
+ 5.9999) |
82 |
+ # git dev branch |
83 |
+ QT5_BUILD_TYPE="live" |
84 |
+ EGIT_BRANCH="dev" |
85 |
+ ;; |
86 |
+ 5.?.9999|5.??.9999|5.???.9999) |
87 |
+ # git stable branch |
88 |
+ QT5_BUILD_TYPE="live" |
89 |
+ EGIT_BRANCH=${PV%.9999} |
90 |
+ ;; |
91 |
+ *_alpha*|*_beta*|*_rc*) |
92 |
+ # development release |
93 |
+ QT5_BUILD_TYPE="release" |
94 |
+ MY_P=${QT5_MODULE}-opensource-src-${PV/_/-} |
95 |
+ SRC_URI="https://download.qt.io/development_releases/qt/${PV%.*}/${PV/_/-}/submodules/${MY_P}.tar.xz" |
96 |
+ S=${WORKDIR}/${MY_P} |
97 |
+ ;; |
98 |
+ *) |
99 |
+ # official stable release |
100 |
+ QT5_BUILD_TYPE="release" |
101 |
+ MY_P=${QT5_MODULE}-opensource-src-${PV} |
102 |
+ SRC_URI="https://download.qt.io/official_releases/qt/${PV%.*}/${PV}/submodules/${MY_P}.tar.xz" |
103 |
+ S=${WORKDIR}/${MY_P} |
104 |
+ ;; |
105 |
+esac |
106 |
+readonly QT5_BUILD_TYPE |
107 |
+ |
108 |
+EGIT_REPO_URI=( |
109 |
+ "https://code.qt.io/qt/${QT5_MODULE}.git" |
110 |
+ "https://github.com/qt/${QT5_MODULE}.git" |
111 |
+) |
112 |
+[[ ${QT5_BUILD_TYPE} == live ]] && inherit git-r3 |
113 |
+ |
114 |
+# @ECLASS-VARIABLE: QT5_BUILD_DIR |
115 |
+# @OUTPUT_VARIABLE |
116 |
+# @DESCRIPTION: |
117 |
+# Build directory for out-of-source builds. |
118 |
+case ${QT5_BUILD_TYPE} in |
119 |
+ live) : ${QT5_BUILD_DIR:=${S}_build} ;; |
120 |
+ release) : ${QT5_BUILD_DIR:=${S}} ;; # workaround for bug 497312 |
121 |
+esac |
122 |
+ |
123 |
+IUSE="debug test" |
124 |
+ |
125 |
+[[ ${PN} == qtwebkit ]] && RESTRICT+=" mirror" # bug 524584 |
126 |
+[[ ${QT5_BUILD_TYPE} == release ]] && RESTRICT+=" test" # bug 457182 |
127 |
+ |
128 |
+DEPEND=" |
129 |
+ dev-lang/perl |
130 |
+ virtual/pkgconfig |
131 |
+" |
132 |
+if [[ (${PN} != qttest && ${PN} != qtwebkit) || (${PN} == qtwebkit && ${QT5_MINOR_VERSION} -lt 9) ]]; then |
133 |
+ DEPEND+=" test? ( ~dev-qt/qttest-${PV} )" |
134 |
+fi |
135 |
+RDEPEND=" |
136 |
+ dev-qt/qtchooser |
137 |
+" |
138 |
+ |
139 |
+ |
140 |
+###### Phase functions ###### |
141 |
+ |
142 |
+EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm |
143 |
+ |
144 |
+# @FUNCTION: qt5-build_src_unpack |
145 |
+# @DESCRIPTION: |
146 |
+# Unpacks the sources. |
147 |
+qt5-build_src_unpack() { |
148 |
+ if tc-is-gcc; then |
149 |
+ local min_gcc4_minor_version=7 |
150 |
+ if [[ $(gcc-major-version) -lt 4 ]] || \ |
151 |
+ [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt ${min_gcc4_minor_version} ]]; then |
152 |
+ eerror "GCC version 4.${min_gcc4_minor_version} or later is required to build this package" |
153 |
+ die "GCC 4.${min_gcc4_minor_version} or later required" |
154 |
+ fi |
155 |
+ fi |
156 |
+ |
157 |
+ # bug 307861 |
158 |
+ if [[ ${PN} == qtwebengine || ${PN} == qtwebkit ]]; then |
159 |
+ eshopts_push -s extglob |
160 |
+ if is-flagq '-g?(gdb)?([1-9])'; then |
161 |
+ ewarn |
162 |
+ ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)." |
163 |
+ ewarn "You may experience really long compilation times and/or increased memory usage." |
164 |
+ ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug." |
165 |
+ ewarn |
166 |
+ fi |
167 |
+ eshopts_pop |
168 |
+ fi |
169 |
+ |
170 |
+ case ${QT5_BUILD_TYPE} in |
171 |
+ live) git-r3_src_unpack ;; |
172 |
+ release) default ;; |
173 |
+ esac |
174 |
+} |
175 |
+ |
176 |
+# @FUNCTION: qt5-build_src_prepare |
177 |
+# @DESCRIPTION: |
178 |
+# Prepares the environment and patches the sources if necessary. |
179 |
+qt5-build_src_prepare() { |
180 |
+ qt5_prepare_env |
181 |
+ |
182 |
+ if [[ ${QT5_MODULE} == qtbase ]]; then |
183 |
+ qt5_symlink_tools_to_build_dir |
184 |
+ |
185 |
+ # Avoid unnecessary qmake recompilations |
186 |
+ if [[ ${QT5_MINOR_VERSION} -ge 8 ]]; then |
187 |
+ sed -i -e "/Creating qmake/i if [ '!' -e \"\$outpath/bin/qmake\" ]; then" \ |
188 |
+ -e '/echo "Done."/a fi' \ |
189 |
+ configure || die "sed failed (skip qmake bootstrap)" |
190 |
+ else |
191 |
+ sed -i -re "s|^if true;.*(\[ '\!').*(\"\\\$outpath/bin/qmake\".*)|if \1 -e \2 then|" \ |
192 |
+ configure || die "sed failed (skip qmake bootstrap)" |
193 |
+ fi |
194 |
+ |
195 |
+ # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when bootstrapping qmake |
196 |
+ sed -i -e "/outpath\/qmake\".*\"\$MAKE\")/ s:): \ |
197 |
+ ${MAKEOPTS} ${EXTRA_EMAKE} 'CC=$(tc-getCC)' 'CXX=$(tc-getCXX)' \ |
198 |
+ 'QMAKE_CFLAGS=${CFLAGS}' 'QMAKE_CXXFLAGS=${CXXFLAGS}' 'QMAKE_LFLAGS=${LDFLAGS}'&:" \ |
199 |
+ -e 's/\(setBootstrapVariable\s\+\|EXTRA_C\(XX\)\?FLAGS=.*\)QMAKE_C\(XX\)\?FLAGS_\(DEBUG\|RELEASE\).*/:/' \ |
200 |
+ configure || die "sed failed (respect env for qmake build)" |
201 |
+ sed -i -e '/^CPPFLAGS\s*=/ s/-g //' \ |
202 |
+ qmake/Makefile.unix || die "sed failed (CPPFLAGS for qmake build)" |
203 |
+ |
204 |
+ # Respect CXX in bsymbolic_functions, fvisibility, precomp, and a few other tests |
205 |
+ sed -i -e "/^QMAKE_CONF_COMPILER=/ s:=.*:=\"$(tc-getCXX)\":" \ |
206 |
+ configure || die "sed failed (QMAKE_CONF_COMPILER)" |
207 |
+ |
208 |
+ if [[ ${QT5_MINOR_VERSION} -le 7 ]]; then |
209 |
+ # Respect toolchain and flags in config.tests |
210 |
+ find config.tests/unix -name '*.test' -type f -execdir \ |
211 |
+ sed -i -e 's/-nocache //' '{}' + || die |
212 |
+ fi |
213 |
+ |
214 |
+ # Don't inject -msse/-mavx/... into CXXFLAGS when detecting |
215 |
+ # compiler support for extended instruction sets (bug 552942) |
216 |
+ find config.tests/common -name '*.pro' -type f -execdir \ |
217 |
+ sed -i -e '/QMAKE_CXXFLAGS\s*+=/ d' '{}' + || die |
218 |
+ |
219 |
+ # Don't add -O3 to CXXFLAGS (bug 549140) |
220 |
+ sed -i -e '/CONFIG\s*+=/ s/optimize_full//' \ |
221 |
+ src/{corelib/corelib,gui/gui}.pro || die "sed failed (optimize_full)" |
222 |
+ fi |
223 |
+ |
224 |
+ default |
225 |
+} |
226 |
+ |
227 |
+# @FUNCTION: qt5-build_src_configure |
228 |
+# @DESCRIPTION: |
229 |
+# Runs qmake in the target directories. For packages |
230 |
+# in qtbase, ./configure is also run before qmake. |
231 |
+qt5-build_src_configure() { |
232 |
+ if [[ ${QT5_MODULE} == qtbase ]]; then |
233 |
+ qt5_base_configure |
234 |
+ fi |
235 |
+ |
236 |
+ qt5_foreach_target_subdir qt5_qmake |
237 |
+} |
238 |
+ |
239 |
+# @FUNCTION: qt5-build_src_compile |
240 |
+# @DESCRIPTION: |
241 |
+# Runs emake in the target directories. |
242 |
+qt5-build_src_compile() { |
243 |
+ qt5_foreach_target_subdir emake |
244 |
+} |
245 |
+ |
246 |
+# @FUNCTION: qt5-build_src_test |
247 |
+# @DESCRIPTION: |
248 |
+# Runs tests in the target directories. |
249 |
+qt5-build_src_test() { |
250 |
+ # disable broken cmake tests (bug 474004) |
251 |
+ local myqmakeargs=("${myqmakeargs[@]}" -after SUBDIRS-=cmake SUBDIRS-=installed_cmake) |
252 |
+ |
253 |
+ qt5_foreach_target_subdir qt5_qmake |
254 |
+ qt5_foreach_target_subdir emake |
255 |
+ |
256 |
+ # create a custom testrunner script that correctly sets |
257 |
+ # LD_LIBRARY_PATH before executing the given test |
258 |
+ local testrunner=${QT5_BUILD_DIR}/gentoo-testrunner |
259 |
+ cat > "${testrunner}" <<-_EOF_ || die |
260 |
+ #!/bin/sh |
261 |
+ export LD_LIBRARY_PATH="${QT5_BUILD_DIR}/lib:${QT5_LIBDIR}" |
262 |
+ "\$@" |
263 |
+ _EOF_ |
264 |
+ chmod +x "${testrunner}" |
265 |
+ |
266 |
+ set -- qt5_foreach_target_subdir emake TESTRUNNER="'${testrunner}'" check |
267 |
+ if [[ ${VIRTUALX_REQUIRED} == test ]]; then |
268 |
+ virtx "$@" |
269 |
+ else |
270 |
+ "$@" |
271 |
+ fi |
272 |
+} |
273 |
+ |
274 |
+# @FUNCTION: qt5-build_src_install |
275 |
+# @DESCRIPTION: |
276 |
+# Runs emake install in the target directories. |
277 |
+qt5-build_src_install() { |
278 |
+ qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install |
279 |
+ |
280 |
+ if [[ ${PN} == qtcore ]]; then |
281 |
+ pushd "${QT5_BUILD_DIR}" >/dev/null || die |
282 |
+ |
283 |
+ set -- emake INSTALL_ROOT="${D}" \ |
284 |
+ sub-qmake-qmake-aux-pro-install_subtargets \ |
285 |
+ install_{syncqt,mkspecs} |
286 |
+ |
287 |
+ einfo "Running $*" |
288 |
+ "$@" |
289 |
+ |
290 |
+ popd >/dev/null || die |
291 |
+ |
292 |
+ docompress -x "${QT5_DOCDIR#${EPREFIX}}"/global |
293 |
+ |
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 |
297 |
+ ( |
298 |
+ insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo |
299 |
+ doins "${T}"/gentoo-qconfig.h |
300 |
+ ) |
301 |
+ |
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)" |
306 |
+ |
307 |
+ # install qtchooser configuration file |
308 |
+ cat > "${T}/qt5-${CHOST}.conf" <<-_EOF_ || die |
309 |
+ ${QT5_BINDIR} |
310 |
+ ${QT5_LIBDIR} |
311 |
+ _EOF_ |
312 |
+ |
313 |
+ ( |
314 |
+ insinto /etc/xdg/qtchooser |
315 |
+ doins "${T}/qt5-${CHOST}.conf" |
316 |
+ ) |
317 |
+ |
318 |
+ # convenience symlinks |
319 |
+ dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/5.conf |
320 |
+ dosym qt5-"${CHOST}".conf /etc/xdg/qtchooser/qt5.conf |
321 |
+ fi |
322 |
+ |
323 |
+ qt5_install_module_qconfigs |
324 |
+ prune_libtool_files |
325 |
+} |
326 |
+ |
327 |
+# @FUNCTION: qt5-build_pkg_postinst |
328 |
+# @DESCRIPTION: |
329 |
+# Regenerate configuration after installation or upgrade/downgrade. |
330 |
+qt5-build_pkg_postinst() { |
331 |
+ qt5_regenerate_global_qconfigs |
332 |
+} |
333 |
+ |
334 |
+# @FUNCTION: qt5-build_pkg_postrm |
335 |
+# @DESCRIPTION: |
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 |
340 |
+ fi |
341 |
+} |
342 |
+ |
343 |
+ |
344 |
+###### Public helpers ###### |
345 |
+ |
346 |
+# @FUNCTION: qt_use |
347 |
+# @USAGE: <flag> [feature] [enableval] |
348 |
+# @DESCRIPTION: |
349 |
+# <flag> is the name of a flag in IUSE. |
350 |
+# |
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. |
354 |
+qt_use() { |
355 |
+ [[ $# -ge 1 ]] || die "${FUNCNAME}() requires at least one argument" |
356 |
+ |
357 |
+ usex "$1" "${3:+-$3}-${2:-$1}" "-no-${2:-$1}" |
358 |
+} |
359 |
+ |
360 |
+# @FUNCTION: qt_use_compile_test |
361 |
+# @USAGE: <flag> [config] |
362 |
+# @DESCRIPTION: |
363 |
+# <flag> is the name of a flag in IUSE. |
364 |
+# [config] is the argument of qtCompileTest, defaults to <flag>. |
365 |
+# |
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" |
373 |
+ |
374 |
+ if ! use "$1"; then |
375 |
+ mkdir -p "${QT5_BUILD_DIR}" || die |
376 |
+ echo "CONFIG += done_config_${2:-$1}" >> "${QT5_BUILD_DIR}"/.qmake.cache || die |
377 |
+ fi |
378 |
+} |
379 |
+ |
380 |
+# @FUNCTION: qt_use_disable_config |
381 |
+# @USAGE: <flag> <config> <files...> |
382 |
+# @DESCRIPTION: |
383 |
+# <flag> is the name of a flag in IUSE. |
384 |
+# <config> is the (lowercase) name of a Qt5 config entry. |
385 |
+# <files...> is a list of one or more qmake project files. |
386 |
+# |
387 |
+# This function patches <files> to treat <config> as disabled |
388 |
+# when <flag> is disabled, otherwise it does nothing. |
389 |
+# This can be useful to avoid an automagic dependency when the config entry |
390 |
+# is enabled on the system but the corresponding USE flag is disabled. |
391 |
+qt_use_disable_config() { |
392 |
+ [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments" |
393 |
+ |
394 |
+ local flag=$1 |
395 |
+ local config=$2 |
396 |
+ shift 2 |
397 |
+ |
398 |
+ if ! use "${flag}"; then |
399 |
+ echo "$@" | xargs sed -i -e "s/qtConfig(${config})/false/g" || die |
400 |
+ fi |
401 |
+} |
402 |
+ |
403 |
+# @FUNCTION: qt_use_disable_mod |
404 |
+# @USAGE: <flag> <module> <files...> |
405 |
+# @DESCRIPTION: |
406 |
+# <flag> is the name of a flag in IUSE. |
407 |
+# <module> is the (lowercase) name of a Qt5 module. |
408 |
+# <files...> is a list of one or more qmake project files. |
409 |
+# |
410 |
+# This function patches <files> to treat <module> as not installed |
411 |
+# when <flag> is disabled, otherwise it does nothing. |
412 |
+# This can be useful to avoid an automagic dependency when the module |
413 |
+# is present on the system but the corresponding USE flag is disabled. |
414 |
+qt_use_disable_mod() { |
415 |
+ [[ $# -ge 3 ]] || die "${FUNCNAME}() requires at least three arguments" |
416 |
+ |
417 |
+ local flag=$1 |
418 |
+ local module=$2 |
419 |
+ shift 2 |
420 |
+ |
421 |
+ if ! use "${flag}"; then |
422 |
+ echo "$@" | xargs sed -i -e "s/qtHaveModule(${module})/false/g" || die |
423 |
+ fi |
424 |
+} |
425 |
+ |
426 |
+ |
427 |
+###### Internal functions ###### |
428 |
+ |
429 |
+# @FUNCTION: qt5_prepare_env |
430 |
+# @INTERNAL |
431 |
+# @DESCRIPTION: |
432 |
+# Prepares the environment for building Qt. |
433 |
+qt5_prepare_env() { |
434 |
+ # setup installation directories |
435 |
+ # note: keep paths in sync with qmake-utils.eclass |
436 |
+ QT5_PREFIX=${EPREFIX}/usr |
437 |
+ QT5_HEADERDIR=${QT5_PREFIX}/include/qt5 |
438 |
+ QT5_LIBDIR=${QT5_PREFIX}/$(get_libdir) |
439 |
+ QT5_ARCHDATADIR=${QT5_PREFIX}/$(get_libdir)/qt5 |
440 |
+ QT5_BINDIR=${QT5_ARCHDATADIR}/bin |
441 |
+ QT5_PLUGINDIR=${QT5_ARCHDATADIR}/plugins |
442 |
+ QT5_LIBEXECDIR=${QT5_ARCHDATADIR}/libexec |
443 |
+ QT5_IMPORTDIR=${QT5_ARCHDATADIR}/imports |
444 |
+ QT5_QMLDIR=${QT5_ARCHDATADIR}/qml |
445 |
+ QT5_DATADIR=${QT5_PREFIX}/share/qt5 |
446 |
+ QT5_DOCDIR=${QT5_PREFIX}/share/doc/qt-${PV} |
447 |
+ QT5_TRANSLATIONDIR=${QT5_DATADIR}/translations |
448 |
+ QT5_EXAMPLESDIR=${QT5_DATADIR}/examples |
449 |
+ QT5_TESTSDIR=${QT5_DATADIR}/tests |
450 |
+ QT5_SYSCONFDIR=${EPREFIX}/etc/xdg |
451 |
+ readonly QT5_PREFIX QT5_HEADERDIR QT5_LIBDIR QT5_ARCHDATADIR \ |
452 |
+ QT5_BINDIR QT5_PLUGINDIR QT5_LIBEXECDIR QT5_IMPORTDIR \ |
453 |
+ QT5_QMLDIR QT5_DATADIR QT5_DOCDIR QT5_TRANSLATIONDIR \ |
454 |
+ QT5_EXAMPLESDIR QT5_TESTSDIR QT5_SYSCONFDIR |
455 |
+ |
456 |
+ if [[ ${QT5_MODULE} == qtbase ]]; then |
457 |
+ # see mkspecs/features/qt_config.prf |
458 |
+ export QMAKEMODULES="${QT5_BUILD_DIR}/mkspecs/modules:${S}/mkspecs/modules:${QT5_ARCHDATADIR}/mkspecs/modules" |
459 |
+ fi |
460 |
+} |
461 |
+ |
462 |
+# @FUNCTION: qt5_foreach_target_subdir |
463 |
+# @INTERNAL |
464 |
+# @DESCRIPTION: |
465 |
+# Executes the command given as argument from inside each directory |
466 |
+# listed in QT5_TARGET_SUBDIRS. Handles autotests subdirs automatically. |
467 |
+qt5_foreach_target_subdir() { |
468 |
+ [[ -z ${QT5_TARGET_SUBDIRS[@]} ]] && QT5_TARGET_SUBDIRS=("") |
469 |
+ |
470 |
+ local subdir= |
471 |
+ for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do |
472 |
+ if [[ ${EBUILD_PHASE} == test ]]; then |
473 |
+ subdir=tests/auto${subdir#src} |
474 |
+ [[ -d ${S}/${subdir} ]] || continue |
475 |
+ fi |
476 |
+ |
477 |
+ local msg="Running $* ${subdir:+in ${subdir}}" |
478 |
+ einfo "${msg}" |
479 |
+ |
480 |
+ mkdir -p "${QT5_BUILD_DIR}/${subdir}" || die -n || return $? |
481 |
+ pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die -n || return $? |
482 |
+ |
483 |
+ "$@" || die -n "${msg} failed" || return $? |
484 |
+ |
485 |
+ popd >/dev/null || die -n || return $? |
486 |
+ done |
487 |
+} |
488 |
+ |
489 |
+# @FUNCTION: qt5_symlink_tools_to_build_dir |
490 |
+# @INTERNAL |
491 |
+# @DESCRIPTION: |
492 |
+# Symlinks qmake and a few other tools to QT5_BUILD_DIR, |
493 |
+# so that they can be used when building other modules. |
494 |
+qt5_symlink_tools_to_build_dir() { |
495 |
+ local tool= tools=() |
496 |
+ if [[ ${PN} != qtcore ]]; then |
497 |
+ tools+=(qmake moc rcc qlalr) |
498 |
+ [[ ${PN} != qtdbus ]] && tools+=(qdbuscpp2xml qdbusxml2cpp) |
499 |
+ [[ ${PN} != qtwidgets ]] && tools+=(uic) |
500 |
+ fi |
501 |
+ |
502 |
+ mkdir -p "${QT5_BUILD_DIR}"/bin || die |
503 |
+ pushd "${QT5_BUILD_DIR}"/bin >/dev/null || die |
504 |
+ |
505 |
+ for tool in "${tools[@]}"; do |
506 |
+ [[ -e ${QT5_BINDIR}/${tool} ]] || continue |
507 |
+ ln -s "${QT5_BINDIR}/${tool}" . || die "failed to symlink ${tool}" |
508 |
+ done |
509 |
+ |
510 |
+ popd >/dev/null || die |
511 |
+} |
512 |
+ |
513 |
+# @FUNCTION: qt5_base_configure |
514 |
+# @INTERNAL |
515 |
+# @DESCRIPTION: |
516 |
+# Runs ./configure for modules belonging to qtbase. |
517 |
+qt5_base_configure() { |
518 |
+ # setup toolchain variables used by configure |
519 |
+ tc-export AR CC CXX OBJDUMP RANLIB STRIP |
520 |
+ export LD="$(tc-getCXX)" |
521 |
+ |
522 |
+ # bug 633838 |
523 |
+ if [[ ${QT5_MINOR_VERSION} -ge 9 ]]; then |
524 |
+ unset QMAKESPEC XQMAKESPEC QMAKEPATH QMAKEFEATURES |
525 |
+ fi |
526 |
+ |
527 |
+ # configure arguments |
528 |
+ local conf=( |
529 |
+ # installation paths |
530 |
+ -prefix "${QT5_PREFIX}" |
531 |
+ -bindir "${QT5_BINDIR}" |
532 |
+ -headerdir "${QT5_HEADERDIR}" |
533 |
+ -libdir "${QT5_LIBDIR}" |
534 |
+ -archdatadir "${QT5_ARCHDATADIR}" |
535 |
+ -plugindir "${QT5_PLUGINDIR}" |
536 |
+ -libexecdir "${QT5_LIBEXECDIR}" |
537 |
+ -importdir "${QT5_IMPORTDIR}" |
538 |
+ -qmldir "${QT5_QMLDIR}" |
539 |
+ -datadir "${QT5_DATADIR}" |
540 |
+ -docdir "${QT5_DOCDIR}" |
541 |
+ -translationdir "${QT5_TRANSLATIONDIR}" |
542 |
+ -sysconfdir "${QT5_SYSCONFDIR}" |
543 |
+ -examplesdir "${QT5_EXAMPLESDIR}" |
544 |
+ -testsdir "${QT5_TESTSDIR}" |
545 |
+ |
546 |
+ # configure in release mode by default, |
547 |
+ # override via the CONFIG qmake variable |
548 |
+ -release |
549 |
+ -no-separate-debug-info |
550 |
+ |
551 |
+ # no need to forcefully build host tools in optimized mode, |
552 |
+ # just follow the overall debug/release build type |
553 |
+ -no-optimized-tools |
554 |
+ |
555 |
+ # licensing stuff |
556 |
+ -opensource -confirm-license |
557 |
+ |
558 |
+ # autodetect the highest supported version of the C++ standard |
559 |
+ #-c++std <c++11|c++14|c++1z> |
560 |
+ |
561 |
+ # build shared libraries |
562 |
+ -shared |
563 |
+ |
564 |
+ # always enable large file support |
565 |
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -largefile) |
566 |
+ |
567 |
+ # disabling accessibility is not recommended by upstream, as |
568 |
+ # it will break QStyle and may break other internal parts of Qt |
569 |
+ -accessibility |
570 |
+ |
571 |
+ # disable all SQL drivers by default, override in qtsql |
572 |
+ -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc |
573 |
+ -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds |
574 |
+ |
575 |
+ # ensure the QML debugging support (qmltooling) is built in qtdeclarative |
576 |
+ -qml-debug |
577 |
+ |
578 |
+ # MIPS DSP instruction set extensions |
579 |
+ $(is-flagq -mno-dsp && echo -no-mips_dsp) |
580 |
+ $(is-flagq -mno-dspr2 && echo -no-mips_dspr2) |
581 |
+ |
582 |
+ # use pkg-config to detect include and library paths |
583 |
+ -pkg-config |
584 |
+ |
585 |
+ # prefer system libraries (only common hard deps here) |
586 |
+ -system-zlib |
587 |
+ -system-pcre |
588 |
+ -system-doubleconversion |
589 |
+ |
590 |
+ # disable everything to prevent automagic deps (part 1) |
591 |
+ -no-mtdev |
592 |
+ -no-journald -no-syslog |
593 |
+ -no-libpng -no-libjpeg |
594 |
+ -no-freetype -no-harfbuzz |
595 |
+ -no-openssl -no-libproxy |
596 |
+ -no-xkbcommon-x11 -no-xkbcommon-evdev |
597 |
+ -no-xinput2 -no-xcb-xlib |
598 |
+ |
599 |
+ # cannot use -no-gif because there is no way to override it later |
600 |
+ #-no-gif |
601 |
+ |
602 |
+ # always enable glib event loop support |
603 |
+ -glib |
604 |
+ |
605 |
+ # disable everything to prevent automagic deps (part 2) |
606 |
+ -no-gtk |
607 |
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-pulseaudio -no-alsa) |
608 |
+ |
609 |
+ # exclude examples and tests from default build |
610 |
+ -nomake examples |
611 |
+ -nomake tests |
612 |
+ -no-compile-examples |
613 |
+ |
614 |
+ # disable rpath on non-prefix (bugs 380415 and 417169) |
615 |
+ $(usex prefix '' -no-rpath) |
616 |
+ |
617 |
+ # print verbose information about each configure test |
618 |
+ -verbose |
619 |
+ |
620 |
+ # always enable iconv support |
621 |
+ # since 5.8 this is handled in qtcore |
622 |
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -iconv) |
623 |
+ |
624 |
+ # disable everything to prevent automagic deps (part 3) |
625 |
+ -no-cups -no-evdev -no-tslib -no-icu -no-fontconfig -no-dbus |
626 |
+ |
627 |
+ # let portage handle stripping |
628 |
+ -no-strip |
629 |
+ |
630 |
+ # precompiled headers can cause problems on hardened, so turn them off |
631 |
+ -no-pch |
632 |
+ |
633 |
+ # link-time code generation is not something we want to enable by default |
634 |
+ -no-ltcg |
635 |
+ |
636 |
+ # reduced relocations cause major breakage on at least arm and ppc, so |
637 |
+ # don't specify anything and let the configure figure out if they are |
638 |
+ # supported; see also https://bugreports.qt.io/browse/QTBUG-36129 |
639 |
+ #-reduce-relocations |
640 |
+ |
641 |
+ # let configure automatically detect if GNU gold is available |
642 |
+ -no-use-gold-linker |
643 |
+ |
644 |
+ # disable all platform plugins by default, override in qtgui |
645 |
+ -no-xcb -no-eglfs -no-kms -no-gbm -no-directfb -no-linuxfb -no-mirclient |
646 |
+ |
647 |
+ # disable undocumented X11-related flags, override in qtgui |
648 |
+ # (not shown in ./configure -help output) |
649 |
+ -no-xkb |
650 |
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-xrender) |
651 |
+ |
652 |
+ # disable obsolete/unused X11-related flags |
653 |
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-mitshm -no-xcursor -no-xfixes -no-xrandr -no-xshape -no-xsync) |
654 |
+ |
655 |
+ # always enable session management support: it doesn't need extra deps |
656 |
+ # at configure time and turning it off is dangerous, see bug 518262 |
657 |
+ -sm |
658 |
+ |
659 |
+ # typedef qreal to double (warning: changing this flag breaks the ABI) |
660 |
+ -qreal double |
661 |
+ |
662 |
+ # disable OpenGL and EGL support by default, override in qtgui, |
663 |
+ # qtopengl, qtprintsupport and qtwidgets |
664 |
+ -no-opengl -no-egl |
665 |
+ |
666 |
+ # disable libinput-based generic plugin by default, override in qtgui |
667 |
+ -no-libinput |
668 |
+ |
669 |
+ # disable gstreamer by default, override in qtmultimedia |
670 |
+ $([[ ${QT5_MINOR_VERSION} -lt 8 ]] && echo -no-gstreamer) |
671 |
+ |
672 |
+ # respect system proxies by default: it's the most natural |
673 |
+ # setting, and it'll become the new upstream default in 5.8 |
674 |
+ -system-proxies |
675 |
+ |
676 |
+ # do not build with -Werror |
677 |
+ -no-warnings-are-errors |
678 |
+ |
679 |
+ # module-specific options |
680 |
+ "${myconf[@]}" |
681 |
+ ) |
682 |
+ |
683 |
+ pushd "${QT5_BUILD_DIR}" >/dev/null || die |
684 |
+ |
685 |
+ einfo "Configuring with: ${conf[@]}" |
686 |
+ "${S}"/configure "${conf[@]}" || die "configure failed" |
687 |
+ |
688 |
+ if [[ ${QT5_MINOR_VERSION} -ge 8 ]]; then |
689 |
+ # a forwarding header is no longer created since 5.8, causing the system |
690 |
+ # config to always be used. bug 599636 |
691 |
+ cp src/corelib/global/qconfig.h include/QtCore/ || die |
692 |
+ fi |
693 |
+ |
694 |
+ popd >/dev/null || die |
695 |
+ |
696 |
+} |
697 |
+ |
698 |
+# @FUNCTION: qt5_qmake |
699 |
+# @INTERNAL |
700 |
+# @DESCRIPTION: |
701 |
+# Helper function that runs qmake in the current target subdir. |
702 |
+# Intended to be called by qt5_foreach_target_subdir(). |
703 |
+qt5_qmake() { |
704 |
+ local projectdir=${PWD/#${QT5_BUILD_DIR}/${S}} |
705 |
+ local qmakepath= |
706 |
+ if [[ ${QT5_MODULE} == qtbase ]]; then |
707 |
+ qmakepath=${QT5_BUILD_DIR}/bin |
708 |
+ else |
709 |
+ qmakepath=${QT5_BINDIR} |
710 |
+ fi |
711 |
+ |
712 |
+ "${qmakepath}"/qmake \ |
713 |
+ "${projectdir}" \ |
714 |
+ CONFIG+=$(usex debug debug release) \ |
715 |
+ CONFIG-=$(usex debug release debug) \ |
716 |
+ QMAKE_AR="$(tc-getAR) cqs" \ |
717 |
+ QMAKE_CC="$(tc-getCC)" \ |
718 |
+ QMAKE_LINK_C="$(tc-getCC)" \ |
719 |
+ QMAKE_LINK_C_SHLIB="$(tc-getCC)" \ |
720 |
+ QMAKE_CXX="$(tc-getCXX)" \ |
721 |
+ QMAKE_LINK="$(tc-getCXX)" \ |
722 |
+ QMAKE_LINK_SHLIB="$(tc-getCXX)" \ |
723 |
+ QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \ |
724 |
+ QMAKE_RANLIB= \ |
725 |
+ QMAKE_STRIP="$(tc-getSTRIP)" \ |
726 |
+ QMAKE_CFLAGS="${CFLAGS}" \ |
727 |
+ QMAKE_CFLAGS_RELEASE= \ |
728 |
+ QMAKE_CFLAGS_DEBUG= \ |
729 |
+ QMAKE_CXXFLAGS="${CXXFLAGS}" \ |
730 |
+ QMAKE_CXXFLAGS_RELEASE= \ |
731 |
+ QMAKE_CXXFLAGS_DEBUG= \ |
732 |
+ QMAKE_LFLAGS="${LDFLAGS}" \ |
733 |
+ QMAKE_LFLAGS_RELEASE= \ |
734 |
+ QMAKE_LFLAGS_DEBUG= \ |
735 |
+ "${myqmakeargs[@]}" \ |
736 |
+ || die "qmake failed (${projectdir#${S}/})" |
737 |
+} |
738 |
+ |
739 |
+# @FUNCTION: qt5_install_module_qconfigs |
740 |
+# @INTERNAL |
741 |
+# @DESCRIPTION: |
742 |
+# Creates and installs gentoo-specific ${PN}-qconfig.{h,pri} files. |
743 |
+qt5_install_module_qconfigs() { |
744 |
+ local x qconfig_add= qconfig_remove= |
745 |
+ |
746 |
+ > "${T}"/${PN}-qconfig.h |
747 |
+ > "${T}"/${PN}-qconfig.pri |
748 |
+ |
749 |
+ # generate qconfig_{add,remove} and ${PN}-qconfig.h |
750 |
+ for x in "${QT5_GENTOO_CONFIG[@]}"; do |
751 |
+ local flag=${x%%:*} |
752 |
+ x=${x#${flag}:} |
753 |
+ local feature=${x%%:*} |
754 |
+ x=${x#${feature}:} |
755 |
+ local macro=${x} |
756 |
+ macro=$(tr 'a-z-' 'A-Z_' <<< "${macro}") |
757 |
+ |
758 |
+ if [[ -z ${flag} ]] || { [[ ${flag} != '!' ]] && use ${flag}; }; then |
759 |
+ [[ -n ${feature} ]] && qconfig_add+=" ${feature}" |
760 |
+ [[ -n ${macro} ]] && echo "#define QT_${macro}" >> "${T}"/${PN}-qconfig.h |
761 |
+ else |
762 |
+ [[ -n ${feature} ]] && qconfig_remove+=" ${feature}" |
763 |
+ [[ -n ${macro} ]] && echo "#define QT_NO_${macro}" >> "${T}"/${PN}-qconfig.h |
764 |
+ fi |
765 |
+ done |
766 |
+ |
767 |
+ # install ${PN}-qconfig.h |
768 |
+ [[ -s ${T}/${PN}-qconfig.h ]] && ( |
769 |
+ insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo |
770 |
+ doins "${T}"/${PN}-qconfig.h |
771 |
+ ) |
772 |
+ |
773 |
+ # generate and install ${PN}-qconfig.pri |
774 |
+ [[ -n ${qconfig_add} ]] && echo "QCONFIG_ADD=${qconfig_add}" >> "${T}"/${PN}-qconfig.pri |
775 |
+ [[ -n ${qconfig_remove} ]] && echo "QCONFIG_REMOVE=${qconfig_remove}" >> "${T}"/${PN}-qconfig.pri |
776 |
+ [[ -s ${T}/${PN}-qconfig.pri ]] && ( |
777 |
+ insinto "${QT5_ARCHDATADIR#${EPREFIX}}"/mkspecs/gentoo |
778 |
+ doins "${T}"/${PN}-qconfig.pri |
779 |
+ ) |
780 |
+} |
781 |
+ |
782 |
+# @FUNCTION: qt5_regenerate_global_qconfigs |
783 |
+# @INTERNAL |
784 |
+# @DESCRIPTION: |
785 |
+# Generates Gentoo-specific qconfig.{h,pri} according to the build configuration. |
786 |
+# Don't call die here because dying in pkg_post{inst,rm} only makes things worse. |
787 |
+qt5_regenerate_global_qconfigs() { |
788 |
+ einfo "Regenerating gentoo-qconfig.h" |
789 |
+ |
790 |
+ find "${ROOT%/}${QT5_HEADERDIR}"/Gentoo \ |
791 |
+ -name '*-qconfig.h' -a \! -name 'gentoo-qconfig.h' -type f \ |
792 |
+ -execdir cat '{}' + | sort -u > "${T}"/gentoo-qconfig.h |
793 |
+ |
794 |
+ [[ -s ${T}/gentoo-qconfig.h ]] || ewarn "Generated gentoo-qconfig.h is empty" |
795 |
+ mv -f "${T}"/gentoo-qconfig.h "${ROOT%/}${QT5_HEADERDIR}"/Gentoo/gentoo-qconfig.h \ |
796 |
+ || eerror "Failed to install new gentoo-qconfig.h" |
797 |
+ |
798 |
+ einfo "Updating QT_CONFIG in qconfig.pri" |
799 |
+ |
800 |
+ local qconfig_pri=${ROOT%/}${QT5_ARCHDATADIR}/mkspecs/qconfig.pri |
801 |
+ if [[ -f ${qconfig_pri} ]]; then |
802 |
+ local x qconfig_add= qconfig_remove= |
803 |
+ local qt_config=$(sed -n 's/^QT_CONFIG\s*+=\s*//p' "${qconfig_pri}") |
804 |
+ local new_qt_config= |
805 |
+ |
806 |
+ # generate list of QT_CONFIG entries from the existing list, |
807 |
+ # appending QCONFIG_ADD and excluding QCONFIG_REMOVE |
808 |
+ eshopts_push -s nullglob |
809 |
+ for x in "${ROOT%/}${QT5_ARCHDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do |
810 |
+ qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=\s*//p' "${x}")" |
811 |
+ qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=\s*//p' "${x}")" |
812 |
+ done |
813 |
+ eshopts_pop |
814 |
+ for x in ${qt_config} ${qconfig_add}; do |
815 |
+ if ! has "${x}" ${new_qt_config} ${qconfig_remove}; then |
816 |
+ new_qt_config+=" ${x}" |
817 |
+ fi |
818 |
+ done |
819 |
+ |
820 |
+ # now replace the existing QT_CONFIG with the generated list |
821 |
+ sed -i -e "s/^QT_CONFIG\s*+=.*/QT_CONFIG +=${new_qt_config}/" \ |
822 |
+ "${qconfig_pri}" || eerror "Failed to sed QT_CONFIG in ${qconfig_pri}" |
823 |
+ else |
824 |
+ ewarn "${qconfig_pri} does not exist or is not a regular file" |
825 |
+ fi |
826 |
+} |