Gentoo Archives: gentoo-commits

From: Davide Pesavento <pesa@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/qt:master commit in: eclass/
Date: Wed, 06 Jun 2012 17:53:20
Message-Id: 1339004909.73b63d05c22a7772b1947e2187bc1ff251d25e04.pesa@gentoo
1 commit: 73b63d05c22a7772b1947e2187bc1ff251d25e04
2 Author: Davide Pesavento <davidepesa <AT> gmail <DOT> com>
3 AuthorDate: Wed Jun 6 17:48:29 2012 +0000
4 Commit: Davide Pesavento <pesa <AT> gentoo <DOT> org>
5 CommitDate: Wed Jun 6 17:48:29 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/qt.git;a=commit;h=73b63d05
7
8 [qt5-build.eclass] New work-in-progress eclass for Qt5 split ebuilds.
9
10 ---
11 eclass/qt5-build.eclass | 436 +++++++++++++++++++++++++++++++++++++++++++++++
12 1 files changed, 436 insertions(+), 0 deletions(-)
13
14 diff --git a/eclass/qt5-build.eclass b/eclass/qt5-build.eclass
15 new file mode 100644
16 index 0000000..bf8d3f7
17 --- /dev/null
18 +++ b/eclass/qt5-build.eclass
19 @@ -0,0 +1,436 @@
20 +# Copyright 1999-2012 Gentoo Foundation
21 +# Distributed under the terms of the GNU General Public License v2
22 +# $Header: $
23 +
24 +# @ECLASS: qt5-build.eclass
25 +# @MAINTAINER:
26 +# Qt herd <qt@g.o>
27 +# @BLURB: Eclass for Qt5 split ebuilds.
28 +# @DESCRIPTION:
29 +# This eclass contains various functions that are used when building Qt5.
30 +# eutils, flag-o-matic, multilib eclasses are guaranteed to be already inherited.
31 +# Requires EAPI 4.
32 +
33 +case ${EAPI} in
34 + 4) : ;;
35 + *) die "qt5-build.eclass: unsupported EAPI=${EAPI:-0}" ;;
36 +esac
37 +
38 +inherit base eutils flag-o-matic multilib toolchain-funcs versionator
39 +
40 +if [[ ${PV} == *9999* ]]; then
41 + QT5_BUILD_TYPE="live"
42 + inherit git-2
43 +else
44 + QT5_BUILD_TYPE="release"
45 +fi
46 +
47 +EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_install src_test pkg_postinst pkg_postrm
48 +
49 +HOMEPAGE="http://qt-project.org/ http://qt.nokia.com/"
50 +LICENSE="|| ( LGPL-2.1 GPL-3 )"
51 +SLOT="5"
52 +
53 +case ${PN#qt-} in
54 + bearer|core|dbus|gui|sql|test|xml) repo_name="qtbase" ;;
55 + 3d|jsbackend|script|svg|xmlpatterns) repo_name="${PN/-}" ;;
56 + *) die "qt5-build.eclass: unknown module ${PN}" ;;
57 +esac
58 +case ${QT5_BUILD_TYPE} in
59 + live)
60 + EGIT_REPO_URI="git://gitorious.org/qt/${repo_name}.git
61 + https://git.gitorious.org/qt/${repo_name}.git"
62 + ;;
63 + release)
64 + SRC_URI="" # TODO
65 +esac
66 +unset repo_name
67 +
68 +IUSE="+c++11 debug +pch"
69 +
70 +DEPEND="virtual/pkgconfig"
71 +if [[ ${QT5_BUILD_TYPE} == live ]]; then
72 + DEPEND+=" dev-lang/perl"
73 +fi
74 +
75 +# @ECLASS-VARIABLE: PATCHES
76 +# @DEFAULT_UNSET
77 +# @DESCRIPTION:
78 +# Array variable containing all the patches to be applied. This variable
79 +# is expected to be defined in the global scope of ebuilds. Make sure to
80 +# specify the full path. This variable is used in src_prepare phase.
81 +#
82 +# Example:
83 +# @CODE
84 +# PATCHES=(
85 +# "${FILESDIR}/mypatch.patch"
86 +# "${FILESDIR}/mypatch2.patch"
87 +# )
88 +# @CODE
89 +
90 +# @ECLASS-VARIABLE: QT5_TARGET_SUBDIRS
91 +# @DEFAULT_UNSET
92 +# @DESCRIPTION:
93 +# Array variable containing the source directories that should be built.
94 +# All paths must be relative to ${S}.
95 +
96 +# @ECLASS-VARIABLE: QT5_BUILD_DIR
97 +# @DESCRIPTION:
98 +# Build directory for out-of-source builds.
99 +: ${QT5_BUILD_DIR:=${WORKDIR}/${P}_build}
100 +
101 +# @ECLASS-VARIABLE: QT5_VERBOSE_CONFIGURE
102 +# @DESCRIPTION:
103 +# Set to false to suppress printing of detailed information
104 +# about each step of the configure process.
105 +: ${QT5_VERBOSE_CONFIGURE:=true}
106 +
107 +# @ECLASS-VARIABLE: QT5_VERBOSE_BUILD
108 +# @DESCRIPTION:
109 +# Set to false to reduce build output during compilation.
110 +: ${QT5_VERBOSE_BUILD:=true}
111 +
112 +# @ECLASS-VARIABLE: QCONFIG_ADD
113 +# @DESCRIPTION:
114 +# List of options that need to be added to QT_CONFIG in qconfig.pri
115 +: ${QCONFIG_ADD:=}
116 +
117 +# @ECLASS-VARIABLE: QCONFIG_REMOVE
118 +# @DESCRIPTION:
119 +# List of options that need to be removed from QT_CONFIG in qconfig.pri
120 +: ${QCONFIG_REMOVE:=}
121 +
122 +# @ECLASS-VARIABLE: QCONFIG_DEFINE
123 +# @DESCRIPTION:
124 +# List of variables that should be defined at the top of QtCore/qconfig.h
125 +: ${QCONFIG_DEFINE:=}
126 +
127 +# @FUNCTION: qt5-build_pkg_setup
128 +# @DESCRIPTION:
129 +# Warns and/or dies if the user is trying to downgrade Qt.
130 +qt5-build_pkg_setup() {
131 + # Protect users by not allowing downgrades between releases.
132 + # Downgrading revisions within the same release should be allowed.
133 + if has_version ">${CATEGORY}/${P}-r9999:${SLOT}"; then
134 + if [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then
135 + eerror " *** Sanity check to keep you from breaking your system ***"
136 + eerror "Downgrading Qt is completely unsupported and will break your system!"
137 + die "aborting to save your system"
138 + else
139 + ewarn "Downgrading Qt is completely unsupported and will break your system!"
140 + fi
141 + fi
142 +}
143 +
144 +# @FUNCTION: qt5-build_src_unpack
145 +# @DESCRIPTION:
146 +# Unpacks the sources.
147 +qt5-build_src_unpack() {
148 + if ! version_is_at_least 4.4 $(gcc-version); then
149 + ewarn "Using a GCC version lower than 4.4 is not supported."
150 + fi
151 +
152 + if [[ ${PN} == "qt-webkit" ]]; then
153 + eshopts_push -s extglob
154 + if is-flagq '-g?(gdb)?([1-9])'; then
155 + echo
156 + ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
157 + ewarn "You may experience really long compilation times and/or increased memory usage."
158 + ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
159 + ewarn "For more info check out https://bugs.gentoo.org/307861"
160 + echo
161 + fi
162 + eshopts_pop
163 + fi
164 +
165 + case ${QT5_BUILD_TYPE} in
166 + live)
167 + git-2_src_unpack
168 + ;;
169 + release)
170 + default
171 + ;;
172 + esac
173 +
174 + qt5_prepare_env
175 +}
176 +
177 +# @FUNCTION: qt5-build_src_prepare
178 +# @DESCRIPTION:
179 +# Prepare the sources before the configure phase.
180 +qt5-build_src_prepare() {
181 + if [[ ${PN} != "qt-core" ]]; then
182 + skip_qmake_build
183 + skip_project_generation
184 + symlink_binaries_to_buildtree
185 + fi
186 +
187 + # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when building qmake
188 + sed -i -e "/\"\$MAKE\".*QMAKE_BUILD_ERROR/ s:): \
189 + ${MAKEOPTS} ${EXTRA_EMAKE} \
190 + 'CC=$(tc-getCC)' 'CXX=$(tc-getCXX)' \
191 + 'QMAKE_CFLAGS=${CFLAGS}' 'QMAKE_CXXFLAGS=${CXXFLAGS}' 'QMAKE_LFLAGS=${LDFLAGS}'&:" \
192 + configure || die "sed configure failed"
193 +
194 + # Respect CC, CXX, LINK and *FLAGS in config.tests
195 + find config.tests/unix -name '*.test' -type f -print0 | xargs -0 \
196 + sed -i -e "/bin\/qmake/ s: \"QT_BUILD_TREE=: \
197 + 'QMAKE_CC=$(tc-getCC)' 'QMAKE_CXX=$(tc-getCXX)' 'QMAKE_LINK=$(tc-getCXX)' \
198 + 'QMAKE_CFLAGS+=${CFLAGS}' 'QMAKE_CXXFLAGS+=${CXXFLAGS}' 'QMAKE_LFLAGS+=${LDFLAGS}'&:" \
199 + || die "sed config.tests failed"
200 +
201 + # TODO
202 + # in compile.test, -m flags are passed to the linker via LIBS
203 + # config tests that use $COMPILER directly ignore toolchain
204 +
205 + # respect compiler
206 + tc-export CC CXX
207 + # qmake-generated Makefiles use LD/LINK for linking
208 + export LD="$(tc-getCXX)"
209 + # don't strip binaries
210 + export STRIP=":"
211 +
212 + base_src_prepare
213 +}
214 +
215 +# @FUNCTION: qt5-build_src_configure
216 +# @DESCRIPTION:
217 +# Default configure phase.
218 +qt5-build_src_configure() {
219 + # configure arguments
220 + local conf=(
221 + # installation paths
222 + -prefix "${QTPREFIXDIR}"
223 + -bindir "${QTBINDIR}"
224 + -libdir "${QTLIBDIR}"
225 + -docdir "${QTDOCDIR}"
226 + -headerdir "${QTHEADERDIR}"
227 + -plugindir "${QTPLUGINDIR}"
228 + -importdir "${QTIMPORTDIR}"
229 + -datadir "${QTDATADIR}"
230 + -translationdir "${QTTRANSDIR}"
231 + -sysconfdir "${QTSYSCONFDIR}"
232 + -examplesdir "${QTEXAMPLESDIR}"
233 + -testsdir "${QTTESTSDIR}"
234 +
235 + # debug/release
236 + $(use debug && echo -debug || echo -release)
237 + -no-separate-debug-info
238 +
239 + # licensing stuff
240 + -opensource -confirm-license
241 +
242 + # C++11 support
243 + $(qt_use c++11)
244 +
245 + # general configure options
246 + -shared -fast -largefile
247 + -pkg-config
248 + -system-zlib -system-pcre
249 +
250 + # don't build examples
251 + -nomake examples
252 +
253 + # disable rpath on non-prefix (bugs 380415 and 417169)
254 + $(use prefix || echo -no-rpath)
255 +
256 + # verbosity of the configure and build phases
257 + $(${QT5_VERBOSE_CONFIGURE} && echo -verbose)
258 + $(${QT5_VERBOSE_BUILD} || echo -silent)
259 +
260 + # precompiled headers don't work on hardened, where the flag is masked
261 + $(qt_use pch)
262 +
263 + # reduce relocations in libraries through extra linker optimizations
264 + # requires GNU ld >= 2.18
265 + -reduce-relocations
266 +
267 + # freetype2 include dir is non-standard
268 + # FIXME: move to qt-gui ebuild?
269 + $($(tc-getPKG_CONFIG) --cflags-only-I freetype2 2>/dev/null)
270 +
271 + # package-specific options
272 + "${myconf[@]}"
273 + )
274 +
275 + mkdir -p "${QT5_BUILD_DIR}" || die
276 + pushd "${QT5_BUILD_DIR}" >/dev/null || die
277 +
278 + einfo "Configuring with: ${conf[@]}"
279 + "${S}"/configure "${conf[@]}" || die "configure failed"
280 +
281 + popd >/dev/null || die
282 +}
283 +
284 +# @FUNCTION: qt5-build_src_compile
285 +# @DESCRIPTION:
286 +# Compiles the code in QT5_TARGET_SUBDIRS.
287 +qt5-build_src_compile() {
288 + local subdir
289 + for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do
290 + pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die
291 + einfo "Building in ${subdir}"
292 + emake
293 + popd >/dev/null || die
294 + done
295 +}
296 +
297 +# @FUNCTION: qt5-build_src_test
298 +# @DESCRIPTION:
299 +# Runs tests in target directories.
300 +qt5-build_src_test() {
301 + # TODO
302 + :
303 +}
304 +
305 +# @FUNCTION: qt5-build_src_install
306 +# @DESCRIPTION:
307 +# Perform the actual installation including some library fixes.
308 +qt5-build_src_install() {
309 + local subdir
310 + for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do
311 + pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die
312 + emake INSTALL_ROOT="${D}" install
313 + popd >/dev/null || die
314 + done
315 +
316 + # TODO: install_qconfigs
317 + # TODO: pkgconfig files are installed in the wrong place
318 +
319 + # remove .la files since we are building only shared Qt libraries
320 + # FIXME: use prune_libtool_files when it'll be available in eutils.eclass
321 + find "${D}"${QTLIBDIR} -type f -name '*.la' -print0 | xargs -0 rm -f
322 +}
323 +
324 +# @FUNCTION: qt5-build_pkg_postinst
325 +# @DESCRIPTION:
326 +# Regenerate configuration, plus throw a message about possible
327 +# breakages and proposed solutions.
328 +qt5-build_pkg_postinst() {
329 + # TODO
330 + #generate_qconfigs
331 + :
332 +}
333 +
334 +# @FUNCTION: qt5-build_pkg_postrm
335 +# @DESCRIPTION:
336 +# Regenerate configuration when the package is completely removed.
337 +qt5-build_pkg_postrm() {
338 + # TODO
339 + #generate_qconfigs
340 + :
341 +}
342 +
343 +# @FUNCTION: qt5_prepare_env
344 +# @INTERNAL
345 +# @DESCRIPTION:
346 +# Sets up installation directories.
347 +qt5_prepare_env() {
348 + QTPREFIXDIR=${EPREFIX}/usr
349 + QTBINDIR=${EPREFIX}/usr/qt5/bin # FIXME
350 + QTLIBDIR=${QTPREFIXDIR}/$(get_libdir)/qt5
351 + QTDOCDIR=${QTPREFIXDIR}/share/doc/qt-${PV}
352 + QTHEADERDIR=${QTPREFIXDIR}/include/qt5
353 + QTPLUGINDIR=${QTLIBDIR}/plugins
354 + QTIMPORTDIR=${QTLIBDIR}/imports
355 + QTDATADIR=${QTPREFIXDIR}/share/qt5
356 + QTTRANSDIR=${QTDATADIR}/translations
357 + QTEXAMPLESDIR=${QTDATADIR}/examples
358 + QTTESTSDIR=${QTDATADIR}/tests
359 + QTSYSCONFDIR=${EPREFIX}/etc/qt5
360 +}
361 +
362 +# @FUNCTION: qt_use
363 +# @USAGE: < flag > [ feature ] [ enableval ]
364 +# @DESCRIPTION:
365 +# This will echo "-${enableval}-${feature}" if <flag> is enabled, or
366 +# "-no-${feature}" if it's disabled. If [feature] is not specified, <flag>
367 +# will be used for that. If [enableval] is not specified, it omits the
368 +# "-${enableval}" part.
369 +qt_use() {
370 + use "$1" && echo "${3:+-$3}-${2:-$1}" || echo "-no-${2:-$1}"
371 +}
372 +
373 +# @FUNCTION: install_qconfigs
374 +# @INTERNAL
375 +# @DESCRIPTION:
376 +# Install gentoo-specific mkspecs configurations.
377 +install_qconfigs() {
378 + local x
379 +
380 + if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then
381 + for x in QCONFIG_ADD QCONFIG_REMOVE; do
382 + [[ -n ${!x} ]] && echo ${x}=${!x} >> "${T}"/${PN}-qconfig.pri
383 + done
384 + insinto ${QTDATADIR#${EPREFIX}}/mkspecs/gentoo
385 + doins "${T}"/${PN}-qconfig.pri || die "installing ${PN}-qconfig.pri failed"
386 + fi
387 +
388 + if [[ -n ${QCONFIG_DEFINE} ]]; then
389 + for x in ${QCONFIG_DEFINE}; do
390 + echo "#define ${x}" >> "${T}"/gentoo-${PN}-qconfig.h
391 + done
392 + insinto ${QTHEADERDIR#${EPREFIX}}/Gentoo
393 + doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h failed"
394 + fi
395 +}
396 +
397 +# @FUNCTION: generate_qconfigs
398 +# @INTERNAL
399 +# @DESCRIPTION:
400 +# Generates gentoo-specific qconfig.{h,pri}.
401 +generate_qconfigs() {
402 + if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE} ]]; then
403 + local x qconfig_add qconfig_remove qconfig_new
404 + for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do
405 + [[ -f ${x} ]] || continue
406 + qconfig_add+=" $(sed -n 's/^QCONFIG_ADD=//p' "${x}")"
407 + qconfig_remove+=" $(sed -n 's/^QCONFIG_REMOVE=//p' "${x}")"
408 + done
409 +
410 + # these error checks do not use die because dying in pkg_post{inst,rm}
411 + # just makes things worse.
412 + if [[ -e "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then
413 + # start with the qconfig.pri that qt-core installed
414 + if ! cp "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri \
415 + "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then
416 + eerror "cp qconfig failed."
417 + return 1
418 + fi
419 +
420 + # generate list of QT_CONFIG entries from the existing list
421 + # including qconfig_add and excluding qconfig_remove
422 + for x in $(sed -n 's/^QT_CONFIG +=//p' \
423 + "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do
424 + has ${x} ${qconfig_remove} || qconfig_new+=" ${x}"
425 + done
426 +
427 + # replace the existing QT_CONFIG list with qconfig_new
428 + if ! sed -i -e "s/QT_CONFIG +=.*/QT_CONFIG += ${qconfig_new}/" \
429 + "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then
430 + eerror "Sed for QT_CONFIG failed"
431 + return 1
432 + fi
433 +
434 + # create Gentoo/qconfig.h
435 + if [[ ! -e ${ROOT}${QTHEADERDIR}/Gentoo ]]; then
436 + if ! mkdir -p "${ROOT}${QTHEADERDIR}"/Gentoo; then
437 + eerror "mkdir ${QTHEADERDIR}/Gentoo failed"
438 + return 1
439 + fi
440 + fi
441 + : > "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
442 + for x in "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do
443 + [[ -f ${x} ]] || continue
444 + cat "${x}" >> "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
445 + done
446 + else
447 + rm -f "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri
448 + rm -f "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h
449 + rmdir "${ROOT}${QTDATADIR}"/mkspecs \
450 + "${ROOT}${QTDATADIR}" \
451 + "${ROOT}${QTHEADERDIR}"/Gentoo \
452 + "${ROOT}${QTHEADERDIR}" 2>/dev/null
453 + fi
454 + fi
455 +}