From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-594396-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id 8D9671381F3
	for <garchives@archives.gentoo.org>; Fri, 31 May 2013 09:03:01 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 3C234E07F0;
	Fri, 31 May 2013 09:02:59 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id B694BE07F0
	for <gentoo-commits@lists.gentoo.org>; Fri, 31 May 2013 09:02:58 +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 77E5633E1DC
	for <gentoo-commits@lists.gentoo.org>; Fri, 31 May 2013 09:02:57 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by hornbill.gentoo.org (Postfix) with ESMTP id BB904E5309
	for <gentoo-commits@lists.gentoo.org>; Fri, 31 May 2013 09:02:54 +0000 (UTC)
From: "Davide Pesavento" <pesa@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Davide Pesavento" <pesa@gentoo.org>
Message-ID: <1369990954.d11a5636128d2fa3c8be327e270396e9879d113b.pesa@gentoo>
Subject: [gentoo-commits] proj/qt:master commit in: eclass/
X-VCS-Repository: proj/qt
X-VCS-Files: eclass/qmake-utils.eclass
X-VCS-Directories: eclass/
X-VCS-Committer: pesa
X-VCS-Committer-Name: Davide Pesavento
X-VCS-Revision: d11a5636128d2fa3c8be327e270396e9879d113b
X-VCS-Branch: master
Date: Fri, 31 May 2013 09:02:54 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Archives-Salt: 21353357-7652-40a8-b33b-0fe0686e4fa8
X-Archives-Hash: 2f47803a43562ddb583188bc9d7de3fc

commit:     d11a5636128d2fa3c8be327e270396e9879d113b
Author:     Davide Pesavento <davidepesa <AT> gmail <DOT> com>
AuthorDate: Fri May 31 09:02:34 2013 +0000
Commit:     Davide Pesavento <pesa <AT> gentoo <DOT> org>
CommitDate: Fri May 31 09:02:34 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/qt.git;a=commit;h=d11a5636

First version of qmake-utils.eclass

---
 eclass/qmake-utils.eclass | 190 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 190 insertions(+)

diff --git a/eclass/qmake-utils.eclass b/eclass/qmake-utils.eclass
new file mode 100644
index 0000000..6fa2734
--- /dev/null
+++ b/eclass/qmake-utils.eclass
@@ -0,0 +1,190 @@
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+# @ECLASS: qmake-utils.eclass
+# @MAINTAINER:
+# Qt herd <qt@gentoo.org>
+# @AUTHOR:
+# Davide Pesavento <pesa@gentoo.org>
+# @BLURB: Common functions for qmake-based packages.
+# @DESCRIPTION:
+# Utility eclass providing wrapper functions for Qt4 and Qt5 qmake.
+# Requires EAPI=2 or later.
+
+case ${EAPI} in
+	2|3|4|5) : ;;
+	*)	 die "qmake-utils.eclass: unsupported EAPI=${EAPI:-0}" ;;
+esac
+
+inherit multilib toolchain-funcs
+
+# @FUNCTION: eqmake4
+# @USAGE: [project_file] [parameters to qmake]
+# @DESCRIPTION:
+# Wrapper for Qt4's qmake. If project_file isn't specified, eqmake4 will
+# look for it in the current directory (${S}, non-recursively). If more
+# than one project file are found, then ${PN}.pro is processed, provided
+# that it exists. Otherwise eqmake4 fails.
+#
+# All other arguments are appended unmodified to qmake command line.
+# For recursive build systems, i.e. those based on the subdirs template,
+# you should run eqmake5 on the top-level project file only, unless you
+# have a valid reason to do otherwise. During the building, qmake will
+# be automatically re-invoked with the right arguments on every directory
+# specified inside the top-level project file.
+eqmake4() {
+	debug-print-function ${FUNCNAME} "$@"
+
+	[[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
+
+	ebegin "Running qmake"
+
+	local qmake_args=("$@")
+
+	# check if project file was passed as a first argument
+	# if not, then search for it
+	local regexp='.*\.pro'
+	if ! [[ ${1} =~ ${regexp} ]]; then
+		local project_file=$(_find_project_file)
+		if [[ -z ${project_file} ]]; then
+			echo
+			eerror "No project files found in '${PWD}'!"
+			eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
+			echo
+			die "eqmake4 failed"
+		fi
+		qmake_args+=("${project_file}")
+	fi
+
+	# make sure CONFIG variable is correctly set
+	# for both release and debug builds
+	local config_add="release"
+	local config_remove="debug"
+	if has debug ${IUSE} && use debug; then
+		config_add="debug"
+		config_remove="release"
+	fi
+	local awkscript='BEGIN {
+				printf "### eqmake4 was here ###\n" > file;
+				printf "CONFIG -= debug_and_release %s\n", remove >> file;
+				printf "CONFIG += %s\n\n", add >> file;
+				fixed=0;
+			}
+			/^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ {
+				if (gsub("\\<((" remove ")|(debug_and_release))\\>", "") > 0) {
+					fixed=1;
+				}
+			}
+			/^[[:blank:]]*CONFIG[[:blank:]]*-=/ {
+				if (gsub("\\<" add "\\>", "") > 0) {
+					fixed=1;
+				}
+			}
+			{
+				print >> file;
+			}
+			END {
+				print fixed;
+			}'
+	local file=
+	while read file; do
+		grep -q '^### eqmake4 was here ###$' "${file}" && continue
+		local retval=$({
+				rm -f "${file}" || echo FAIL
+				awk -v file="${file}" \
+					-v add=${config_add} \
+					-v remove=${config_remove} \
+					-- "${awkscript}" || echo FAIL
+				} < "${file}")
+		if [[ ${retval} == 1 ]]; then
+			einfo " - fixed CONFIG in ${file}"
+		elif [[ ${retval} != 0 ]]; then
+			eerror " - error while processing ${file}"
+			die "eqmake4 failed to process ${file}"
+		fi
+	done < <(find . -type f -name '*.pr[io]' -printf '%P\n' 2>/dev/null)
+
+	"${EPREFIX}"/usr/bin/qmake \
+		-makefile \
+		QTDIR="${EPREFIX}"/usr/$(get_libdir) \
+		QMAKE="${EPREFIX}"/usr/bin/qmake \
+		QMAKE_AR="$(tc-getAR) cqs" \
+		QMAKE_CC="$(tc-getCC)" \
+		QMAKE_CXX="$(tc-getCXX)" \
+		QMAKE_LINK="$(tc-getCXX)" \
+		QMAKE_LINK_C="$(tc-getCC)" \
+		QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
+		QMAKE_RANLIB= \
+		QMAKE_STRIP= \
+		QMAKE_CFLAGS="${CFLAGS}" \
+		QMAKE_CFLAGS_RELEASE= \
+		QMAKE_CFLAGS_DEBUG= \
+		QMAKE_CXXFLAGS="${CXXFLAGS}" \
+		QMAKE_CXXFLAGS_RELEASE= \
+		QMAKE_CXXFLAGS_DEBUG= \
+		QMAKE_LFLAGS="${LDFLAGS}" \
+		QMAKE_LFLAGS_RELEASE= \
+		QMAKE_LFLAGS_DEBUG= \
+		QMAKE_LIBDIR_QT="${EPREFIX}"/usr/$(get_libdir)/qt4 \
+		QMAKE_LIBDIR_X11="${EPREFIX}"/usr/$(get_libdir) \
+		QMAKE_LIBDIR_OPENGL="${EPREFIX}"/usr/$(get_libdir) \
+		"${qmake_args[@]}"
+
+	# was qmake successful?
+	if ! eend $? ; then
+		echo
+		eerror "Running qmake has failed! (see above for details)"
+		eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
+		echo
+		die "eqmake4 failed"
+	fi
+}
+
+# @FUNCTION: eqmake5
+# @USAGE: [arguments for qmake]
+# @DESCRIPTION:
+# Wrapper for Qt5's qmake. All arguments are passed to qmake.
+#
+# For recursive build systems, i.e. those based on the subdirs template,
+# you should run eqmake5 on the top-level project file only, unless you
+# have a valid reason to do otherwise. During the building, qmake will
+# be automatically re-invoked with the right arguments on every directory
+# specified inside the top-level project file.
+eqmake5() {
+	debug-print-function ${FUNCNAME} "$@"
+
+	[[ ${EAPI} == 2 ]] && use !prefix && EPREFIX=
+
+	ebegin "Running qmake"
+
+	"${EPREFIX}"/usr/$(get_libdir)/qt5/bin/qmake \
+		-makefile \
+		QMAKE_AR="$(tc-getAR) cqs" \
+		QMAKE_CC="$(tc-getCC)" \
+		QMAKE_CXX="$(tc-getCXX)" \
+		QMAKE_LINK="$(tc-getCXX)" \
+		QMAKE_LINK_C="$(tc-getCC)" \
+		QMAKE_OBJCOPY="$(tc-getOBJCOPY)" \
+		QMAKE_RANLIB= \
+		QMAKE_STRIP= \
+		QMAKE_CFLAGS="${CFLAGS}" \
+		QMAKE_CFLAGS_RELEASE= \
+		QMAKE_CFLAGS_DEBUG= \
+		QMAKE_CXXFLAGS="${CXXFLAGS}" \
+		QMAKE_CXXFLAGS_RELEASE= \
+		QMAKE_CXXFLAGS_DEBUG= \
+		QMAKE_LFLAGS="${LDFLAGS}" \
+		QMAKE_LFLAGS_RELEASE= \
+		QMAKE_LFLAGS_DEBUG= \
+		"$@"
+
+	# was qmake successful?
+	if ! eend $? ; then
+		echo
+		eerror "Running qmake has failed! (see above for details)"
+		eerror "This shouldn't happen - please send a bug report to https://bugs.gentoo.org/"
+		echo
+		die "eqmake5 failed"
+	fi
+}