From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1ScKQ3-0007t4-Qq for garchives@archives.gentoo.org; Wed, 06 Jun 2012 17:53:20 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C9CAAE068F; Wed, 6 Jun 2012 17:53:12 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 8BF28E068F for ; Wed, 6 Jun 2012 17:53:12 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CE6451B4005 for ; Wed, 6 Jun 2012 17:53:11 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 96BE9E5404 for ; Wed, 6 Jun 2012 17:53:10 +0000 (UTC) From: "Davide Pesavento" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Davide Pesavento" Message-ID: <1339004909.73b63d05c22a7772b1947e2187bc1ff251d25e04.pesa@gentoo> Subject: [gentoo-commits] proj/qt:master commit in: eclass/ X-VCS-Repository: proj/qt X-VCS-Files: eclass/qt5-build.eclass X-VCS-Directories: eclass/ X-VCS-Committer: pesa X-VCS-Committer-Name: Davide Pesavento X-VCS-Revision: 73b63d05c22a7772b1947e2187bc1ff251d25e04 X-VCS-Branch: master Date: Wed, 6 Jun 2012 17:53:10 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: d2dcacb7-9832-4c5a-a0ec-0b2a9484687f X-Archives-Hash: 355ce459db4631aa53cfffb437c262cd commit: 73b63d05c22a7772b1947e2187bc1ff251d25e04 Author: Davide Pesavento gmail com> AuthorDate: Wed Jun 6 17:48:29 2012 +0000 Commit: Davide Pesavento gentoo org> CommitDate: Wed Jun 6 17:48:29 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/qt.git;a=3Dco= mmit;h=3D73b63d05 [qt5-build.eclass] New work-in-progress eclass for Qt5 split ebuilds. --- eclass/qt5-build.eclass | 436 +++++++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 436 insertions(+), 0 deletions(-) diff --git a/eclass/qt5-build.eclass b/eclass/qt5-build.eclass new file mode 100644 index 0000000..bf8d3f7 --- /dev/null +++ b/eclass/qt5-build.eclass @@ -0,0 +1,436 @@ +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $ + +# @ECLASS: qt5-build.eclass +# @MAINTAINER: +# Qt herd +# @BLURB: Eclass for Qt5 split ebuilds. +# @DESCRIPTION: +# This eclass contains various functions that are used when building Qt5= . +# eutils, flag-o-matic, multilib eclasses are guaranteed to be already i= nherited. +# Requires EAPI 4. + +case ${EAPI} in + 4) : ;; + *) die "qt5-build.eclass: unsupported EAPI=3D${EAPI:-0}" ;; +esac + +inherit base eutils flag-o-matic multilib toolchain-funcs versionator + +if [[ ${PV} =3D=3D *9999* ]]; then + QT5_BUILD_TYPE=3D"live" + inherit git-2 +else + QT5_BUILD_TYPE=3D"release" +fi + +EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_comp= ile src_install src_test pkg_postinst pkg_postrm + +HOMEPAGE=3D"http://qt-project.org/ http://qt.nokia.com/" +LICENSE=3D"|| ( LGPL-2.1 GPL-3 )" +SLOT=3D"5" + +case ${PN#qt-} in + bearer|core|dbus|gui|sql|test|xml) repo_name=3D"qtbase" ;; + 3d|jsbackend|script|svg|xmlpatterns) repo_name=3D"${PN/-}" ;; + *) die "qt5-build.eclass: unknown module ${PN}" ;; +esac +case ${QT5_BUILD_TYPE} in + live) + EGIT_REPO_URI=3D"git://gitorious.org/qt/${repo_name}.git + https://git.gitorious.org/qt/${repo_name}.git" + ;; + release) + SRC_URI=3D"" # TODO +esac +unset repo_name + +IUSE=3D"+c++11 debug +pch" + +DEPEND=3D"virtual/pkgconfig" +if [[ ${QT5_BUILD_TYPE} =3D=3D live ]]; then + DEPEND+=3D" dev-lang/perl" +fi + +# @ECLASS-VARIABLE: PATCHES +# @DEFAULT_UNSET +# @DESCRIPTION: +# Array variable containing all the patches to be applied. This variable +# is expected to be defined in the global scope of ebuilds. Make sure to +# specify the full path. This variable is used in src_prepare phase. +# +# Example: +# @CODE +# PATCHES=3D( +# "${FILESDIR}/mypatch.patch" +# "${FILESDIR}/mypatch2.patch" +# ) +# @CODE + +# @ECLASS-VARIABLE: QT5_TARGET_SUBDIRS +# @DEFAULT_UNSET +# @DESCRIPTION: +# Array variable containing the source directories that should be built. +# All paths must be relative to ${S}. + +# @ECLASS-VARIABLE: QT5_BUILD_DIR +# @DESCRIPTION: +# Build directory for out-of-source builds. +: ${QT5_BUILD_DIR:=3D${WORKDIR}/${P}_build} + +# @ECLASS-VARIABLE: QT5_VERBOSE_CONFIGURE +# @DESCRIPTION: +# Set to false to suppress printing of detailed information +# about each step of the configure process. +: ${QT5_VERBOSE_CONFIGURE:=3Dtrue} + +# @ECLASS-VARIABLE: QT5_VERBOSE_BUILD +# @DESCRIPTION: +# Set to false to reduce build output during compilation. +: ${QT5_VERBOSE_BUILD:=3Dtrue} + +# @ECLASS-VARIABLE: QCONFIG_ADD +# @DESCRIPTION: +# List of options that need to be added to QT_CONFIG in qconfig.pri +: ${QCONFIG_ADD:=3D} + +# @ECLASS-VARIABLE: QCONFIG_REMOVE +# @DESCRIPTION: +# List of options that need to be removed from QT_CONFIG in qconfig.pri +: ${QCONFIG_REMOVE:=3D} + +# @ECLASS-VARIABLE: QCONFIG_DEFINE +# @DESCRIPTION: +# List of variables that should be defined at the top of QtCore/qconfig.= h +: ${QCONFIG_DEFINE:=3D} + +# @FUNCTION: qt5-build_pkg_setup +# @DESCRIPTION: +# Warns and/or dies if the user is trying to downgrade Qt. +qt5-build_pkg_setup() { + # Protect users by not allowing downgrades between releases. + # Downgrading revisions within the same release should be allowed. + if has_version ">${CATEGORY}/${P}-r9999:${SLOT}"; then + if [[ -z ${I_KNOW_WHAT_I_AM_DOING} ]]; then + eerror " *** Sanity check to keep you from breaking your system = ***" + eerror "Downgrading Qt is completely unsupported and will break your = system!" + die "aborting to save your system" + else + ewarn "Downgrading Qt is completely unsupported and will break your s= ystem!" + fi + fi +} + +# @FUNCTION: qt5-build_src_unpack +# @DESCRIPTION: +# Unpacks the sources. +qt5-build_src_unpack() { + if ! version_is_at_least 4.4 $(gcc-version); then + ewarn "Using a GCC version lower than 4.4 is not supported." + fi + + if [[ ${PN} =3D=3D "qt-webkit" ]]; then + eshopts_push -s extglob + if is-flagq '-g?(gdb)?([1-9])'; then + echo + ewarn "You have enabled debug info (probably have -g or -ggdb in your= CFLAGS/CXXFLAGS)." + ewarn "You may experience really long compilation times and/or increa= sed memory usage." + ewarn "If compilation fails, please try removing -g/-ggdb before repo= rting a bug." + ewarn "For more info check out https://bugs.gentoo.org/307861" + echo + fi + eshopts_pop + fi + + case ${QT5_BUILD_TYPE} in + live) + git-2_src_unpack + ;; + release) + default + ;; + esac + + qt5_prepare_env +} + +# @FUNCTION: qt5-build_src_prepare +# @DESCRIPTION: +# Prepare the sources before the configure phase. +qt5-build_src_prepare() { + if [[ ${PN} !=3D "qt-core" ]]; then + skip_qmake_build + skip_project_generation + symlink_binaries_to_buildtree + fi + + # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when building qmake + sed -i -e "/\"\$MAKE\".*QMAKE_BUILD_ERROR/ s:): \ + ${MAKEOPTS} ${EXTRA_EMAKE} \ + 'CC=3D$(tc-getCC)' 'CXX=3D$(tc-getCXX)' \ + 'QMAKE_CFLAGS=3D${CFLAGS}' 'QMAKE_CXXFLAGS=3D${CXXFLAGS}' 'QMAKE_LFLAG= S=3D${LDFLAGS}'&:" \ + configure || die "sed configure failed" + + # Respect CC, CXX, LINK and *FLAGS in config.tests + find config.tests/unix -name '*.test' -type f -print0 | xargs -0 \ + sed -i -e "/bin\/qmake/ s: \"QT_BUILD_TREE=3D: \ + 'QMAKE_CC=3D$(tc-getCC)' 'QMAKE_CXX=3D$(tc-getCXX)' 'QMAKE_LI= NK=3D$(tc-getCXX)' \ + 'QMAKE_CFLAGS+=3D${CFLAGS}' 'QMAKE_CXXFLAGS+=3D${CXXFLAGS}' 'QMAKE_LF= LAGS+=3D${LDFLAGS}'&:" \ + || die "sed config.tests failed" + + # TODO + # in compile.test, -m flags are passed to the linker via LIBS + # config tests that use $COMPILER directly ignore toolchain + + # respect compiler + tc-export CC CXX + # qmake-generated Makefiles use LD/LINK for linking + export LD=3D"$(tc-getCXX)" + # don't strip binaries + export STRIP=3D":" + + base_src_prepare +} + +# @FUNCTION: qt5-build_src_configure +# @DESCRIPTION: +# Default configure phase. +qt5-build_src_configure() { + # configure arguments + local conf=3D( + # installation paths + -prefix "${QTPREFIXDIR}" + -bindir "${QTBINDIR}" + -libdir "${QTLIBDIR}" + -docdir "${QTDOCDIR}" + -headerdir "${QTHEADERDIR}" + -plugindir "${QTPLUGINDIR}" + -importdir "${QTIMPORTDIR}" + -datadir "${QTDATADIR}" + -translationdir "${QTTRANSDIR}" + -sysconfdir "${QTSYSCONFDIR}" + -examplesdir "${QTEXAMPLESDIR}" + -testsdir "${QTTESTSDIR}" + + # debug/release + $(use debug && echo -debug || echo -release) + -no-separate-debug-info + + # licensing stuff + -opensource -confirm-license + + # C++11 support + $(qt_use c++11) + + # general configure options + -shared -fast -largefile + -pkg-config + -system-zlib -system-pcre + + # don't build examples + -nomake examples + + # disable rpath on non-prefix (bugs 380415 and 417169) + $(use prefix || echo -no-rpath) + + # verbosity of the configure and build phases + $(${QT5_VERBOSE_CONFIGURE} && echo -verbose) + $(${QT5_VERBOSE_BUILD} || echo -silent) + + # precompiled headers don't work on hardened, where the flag is masked + $(qt_use pch) + + # reduce relocations in libraries through extra linker optimizations + # requires GNU ld >=3D 2.18 + -reduce-relocations + + # freetype2 include dir is non-standard + # FIXME: move to qt-gui ebuild? + $($(tc-getPKG_CONFIG) --cflags-only-I freetype2 2>/dev/null) + + # package-specific options + "${myconf[@]}" + ) + + mkdir -p "${QT5_BUILD_DIR}" || die + pushd "${QT5_BUILD_DIR}" >/dev/null || die + + einfo "Configuring with: ${conf[@]}" + "${S}"/configure "${conf[@]}" || die "configure failed" + + popd >/dev/null || die +} + +# @FUNCTION: qt5-build_src_compile +# @DESCRIPTION: +# Compiles the code in QT5_TARGET_SUBDIRS. +qt5-build_src_compile() { + local subdir + for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do + pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die + einfo "Building in ${subdir}" + emake + popd >/dev/null || die + done +} + +# @FUNCTION: qt5-build_src_test +# @DESCRIPTION: +# Runs tests in target directories. +qt5-build_src_test() { + # TODO + : +} + +# @FUNCTION: qt5-build_src_install +# @DESCRIPTION: +# Perform the actual installation including some library fixes. +qt5-build_src_install() { + local subdir + for subdir in "${QT5_TARGET_SUBDIRS[@]}"; do + pushd "${QT5_BUILD_DIR}/${subdir}" >/dev/null || die + emake INSTALL_ROOT=3D"${D}" install + popd >/dev/null || die + done + + # TODO: install_qconfigs + # TODO: pkgconfig files are installed in the wrong place + + # remove .la files since we are building only shared Qt libraries + # FIXME: use prune_libtool_files when it'll be available in eutils.ecla= ss + find "${D}"${QTLIBDIR} -type f -name '*.la' -print0 | xargs -0 rm -f +} + +# @FUNCTION: qt5-build_pkg_postinst +# @DESCRIPTION: +# Regenerate configuration, plus throw a message about possible +# breakages and proposed solutions. +qt5-build_pkg_postinst() { + # TODO + #generate_qconfigs + : +} + +# @FUNCTION: qt5-build_pkg_postrm +# @DESCRIPTION: +# Regenerate configuration when the package is completely removed. +qt5-build_pkg_postrm() { + # TODO + #generate_qconfigs + : +} + +# @FUNCTION: qt5_prepare_env +# @INTERNAL +# @DESCRIPTION: +# Sets up installation directories. +qt5_prepare_env() { + QTPREFIXDIR=3D${EPREFIX}/usr + QTBINDIR=3D${EPREFIX}/usr/qt5/bin # FIXME + QTLIBDIR=3D${QTPREFIXDIR}/$(get_libdir)/qt5 + QTDOCDIR=3D${QTPREFIXDIR}/share/doc/qt-${PV} + QTHEADERDIR=3D${QTPREFIXDIR}/include/qt5 + QTPLUGINDIR=3D${QTLIBDIR}/plugins + QTIMPORTDIR=3D${QTLIBDIR}/imports + QTDATADIR=3D${QTPREFIXDIR}/share/qt5 + QTTRANSDIR=3D${QTDATADIR}/translations + QTEXAMPLESDIR=3D${QTDATADIR}/examples + QTTESTSDIR=3D${QTDATADIR}/tests + QTSYSCONFDIR=3D${EPREFIX}/etc/qt5 +} + +# @FUNCTION: qt_use +# @USAGE: < flag > [ feature ] [ enableval ] +# @DESCRIPTION: +# This will echo "-${enableval}-${feature}" if is enabled, or +# "-no-${feature}" if it's disabled. If [feature] is not specified, +# will be used for that. If [enableval] is not specified, it omits the +# "-${enableval}" part. +qt_use() { + use "$1" && echo "${3:+-$3}-${2:-$1}" || echo "-no-${2:-$1}" +} + +# @FUNCTION: install_qconfigs +# @INTERNAL +# @DESCRIPTION: +# Install gentoo-specific mkspecs configurations. +install_qconfigs() { + local x + + if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} ]]; then + for x in QCONFIG_ADD QCONFIG_REMOVE; do + [[ -n ${!x} ]] && echo ${x}=3D${!x} >> "${T}"/${PN}-qconfig.pri + done + insinto ${QTDATADIR#${EPREFIX}}/mkspecs/gentoo + doins "${T}"/${PN}-qconfig.pri || die "installing ${PN}-qconfig.pri fa= iled" + fi + + if [[ -n ${QCONFIG_DEFINE} ]]; then + for x in ${QCONFIG_DEFINE}; do + echo "#define ${x}" >> "${T}"/gentoo-${PN}-qconfig.h + done + insinto ${QTHEADERDIR#${EPREFIX}}/Gentoo + doins "${T}"/gentoo-${PN}-qconfig.h || die "installing ${PN}-qconfig.h= failed" + fi +} + +# @FUNCTION: generate_qconfigs +# @INTERNAL +# @DESCRIPTION: +# Generates gentoo-specific qconfig.{h,pri}. +generate_qconfigs() { + if [[ -n ${QCONFIG_ADD} || -n ${QCONFIG_REMOVE} || -n ${QCONFIG_DEFINE}= ]]; then + local x qconfig_add qconfig_remove qconfig_new + for x in "${ROOT}${QTDATADIR}"/mkspecs/gentoo/*-qconfig.pri; do + [[ -f ${x} ]] || continue + qconfig_add+=3D" $(sed -n 's/^QCONFIG_ADD=3D//p' "${x}")" + qconfig_remove+=3D" $(sed -n 's/^QCONFIG_REMOVE=3D//p' "${x}")" + done + + # these error checks do not use die because dying in pkg_post{inst,rm} + # just makes things worse. + if [[ -e "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri ]]; then + # start with the qconfig.pri that qt-core installed + if ! cp "${ROOT}${QTDATADIR}"/mkspecs/gentoo/qconfig.pri \ + "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then + eerror "cp qconfig failed." + return 1 + fi + + # generate list of QT_CONFIG entries from the existing list + # including qconfig_add and excluding qconfig_remove + for x in $(sed -n 's/^QT_CONFIG +=3D//p' \ + "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri) ${qconfig_add}; do + has ${x} ${qconfig_remove} || qconfig_new+=3D" ${x}" + done + + # replace the existing QT_CONFIG list with qconfig_new + if ! sed -i -e "s/QT_CONFIG +=3D.*/QT_CONFIG +=3D ${qconfig_new}/" \ + "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri; then + eerror "Sed for QT_CONFIG failed" + return 1 + fi + + # create Gentoo/qconfig.h + if [[ ! -e ${ROOT}${QTHEADERDIR}/Gentoo ]]; then + if ! mkdir -p "${ROOT}${QTHEADERDIR}"/Gentoo; then + eerror "mkdir ${QTHEADERDIR}/Gentoo failed" + return 1 + fi + fi + : > "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h + for x in "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-*-qconfig.h; do + [[ -f ${x} ]] || continue + cat "${x}" >> "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h + done + else + rm -f "${ROOT}${QTDATADIR}"/mkspecs/qconfig.pri + rm -f "${ROOT}${QTHEADERDIR}"/Gentoo/gentoo-qconfig.h + rmdir "${ROOT}${QTDATADIR}"/mkspecs \ + "${ROOT}${QTDATADIR}" \ + "${ROOT}${QTHEADERDIR}"/Gentoo \ + "${ROOT}${QTHEADERDIR}" 2>/dev/null + fi + fi +}