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 <gentoo-commits+bounces-393495-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1RGDaQ-0005hW-GG
	for garchives@archives.gentoo.org; Tue, 18 Oct 2011 17:36:23 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 7D19721C089;
	Tue, 18 Oct 2011 17:36:15 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id 3C15421C088
	for <gentoo-commits@lists.gentoo.org>; Tue, 18 Oct 2011 17:36:15 +0000 (UTC)
Received: from pelican.gentoo.org (unknown [66.219.59.40])
	(using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id 941151B4010
	for <gentoo-commits@lists.gentoo.org>; Tue, 18 Oct 2011 17:36:14 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id 06DC38004C
	for <gentoo-commits@lists.gentoo.org>; Tue, 18 Oct 2011 17:36:14 +0000 (UTC)
From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" <vapier@gentoo.org>
Message-ID: <d1cde0072cc08279447505c57eabe647e4be5eb0.vapier@gentoo>
Subject: [gentoo-commits] proj/crossdev:master commit in: /
X-VCS-Repository: proj/crossdev
X-VCS-Files: crossdev
X-VCS-Directories: /
X-VCS-Committer: vapier
X-VCS-Committer-Name: Mike Frysinger
X-VCS-Revision: d1cde0072cc08279447505c57eabe647e4be5eb0
Date: Tue, 18 Oct 2011 17:36:14 +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
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: 
X-Archives-Hash: 41679df4eda276b825c0daeaa6c66050

commit:     d1cde0072cc08279447505c57eabe647e4be5eb0
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 17 16:22:20 2011 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Oct 17 20:05:50 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/crossdev.git;=
a=3Dcommit;h=3Dd1cde007

crossdev: go back to setting up multilib, but smarter

The recent commit 48942e883df62 didn't operate exactly the way I wanted
and allowed the host profile's idea of multilib to bleed in for most
packages (but not the cross-compiler ones where multilib.eclass fixed
things up).  So leverage multilib.eclass to avoid duplicating the env
func locally and to setup the ABI env as we want.

Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

---
 crossdev |   75 ++++++++++++++++++++++++++++++++++++++++++++++++++------=
-----
 1 files changed, 61 insertions(+), 14 deletions(-)

diff --git a/crossdev b/crossdev
index 767c580..48c6f96 100755
--- a/crossdev
+++ b/crossdev
@@ -439,7 +439,8 @@ UOPTS=3D
 TARCH=3D
 HARCH=3D
 CTARGET=3D
-MULTILIB_ABIS=3D""
+MULTILIB_ABIS=3D"default"
+MULTILIB_USE=3D""
 STAGE=3D""
 BCAT=3D"sys-devel"  ; BPKG=3D"binutils"      ; BVER=3D"" BUSE=3D"" BENV=3D=
"" BOVL=3D""
 GCAT=3D"sys-devel"  ; GPKG=3D"gcc"           ; GVER=3D"" GUSE=3D"" GENV=3D=
"" GOVL=3D""
@@ -556,6 +557,57 @@ for v in MULTILIB_ABIS UCLIBC_CPU USE BVER GVER KVER=
 LVER STAGE CFLAGS LDFLAGS A
 	fi
 done
=20
+# parse multilib settings until profiles are sane
+DEFAULT_ABI=3D${MULTILIB_ABIS%% *}
+eval $(
+	# clean the env
+	unset ${!CFLAGS_*} ${!CHOST_*} ${!CTARGET_*} ${!LDFLAGS_*} ${!LIBDIR_*}
+
+	# ask multilib.eclass to tell us how things work
+	inherit() { :; }
+	for p in ${SEARCH_OVERLAYS} ${PORTDIR} ; do
+		p+=3D"/eclass/multilib.eclass"
+		if [[ -e ${p} ]] ; then
+			. "${p}"
+			break
+		fi
+	done
+	unset DEFAULT_ABI
+	if [[ ${MULTILIB_ABIS} =3D=3D "default" ]] ; then
+		unset MULTILIB_ABIS
+		single_abi=3Dtrue
+	else
+		single_abi=3Dfalse
+	fi
+	multilib_env
+	${single_abi} && MULTILIB_ABIS=3D${DEFAULT_ABI}
+
+	# output the desired env
+	for v in ${!CFLAGS_*} ${!CHOST_*} ${!CTARGET_*} ${!LDFLAGS_*} ${!LIBDIR=
_*} MULTILIB_ABIS DEFAULT_ABI ; do
+		echo ${v}=3D\'${!v}\'
+	done
+
+	# make sure all ABIs have valid vars
+	def_CFLAGS=3D
+	def_LIBDIR=3D"lib"
+	def_LDFLAGS=3D
+	for v in CFLAGS LIBDIR LDFLAGS ; do
+		d=3D"def_${v}"
+		for a in ${MULTILIB_ABIS} ; do
+			_v=3D"${v}_${a}"
+			[[ ${!_v+set} =3D=3D "set" ]] && continue
+			echo ${_v}=3D\'${!d}\'
+		done
+	done
+)
+if [[ -z ${MULTILIB_USE} ]] ; then
+	if [[ $(set -- ${MULTILIB_ABIS}; echo $#) -eq 1 ]] ; then
+		MULTILIB_USE=3D"no"
+	else
+		MULTILIB_USE=3D"yes"
+	fi
+fi
+
 #####################
 ### do the emerge ###
 info() {
@@ -565,7 +617,8 @@ einfo "Host Portage ARCH:     ${HARCH}"
 einfo "Target Portage ARCH:   ${TARCH}"
 einfo "Target System:         ${CTARGET}"
 einfo "Stage:                 ${STAGE} (${STAGE_DISP[${STAGE}]})"
-einfo "ABIs:                  ${MULTILIB_ABIS:-<just one: the default>}"
+[[ ${DEFAULT_ABI} !=3D "${MULTILIB_ABIS}" ]] && def_out=3D" (default: ${=
DEFAULT_ABI})" || def_out=3D
+einfo "ABIs:                  ${MULTILIB_ABIS}${def_out}"
 echo
 ex_fast || {
 is_s0 && {
@@ -695,17 +748,11 @@ set_env() {
 	$(printf '%b' "${env}")
 	EOF
=20
-	# allow USE=3D-multilib to work its magic via multilib.eclass
-	# by not setting random values when we simply want one abi
-	if [[ -n ${MULTILIB_ABIS} ]] ; then
-		ABI=3D$(set -- ${MULTILIB_ABIS}; echo $1)
-		cat <<-EOF >> "${output}"
-		# handle multilib ourselves
-		ABI=3D${ABI}
-		MULTILIB_ABIS=3D"${MULTILIB_ABIS}"
-		DEFAULT_ABI=3D${ABI}
-		EOF
-	fi
+	local v
+	local ABI=3D$(set -- ${MULTILIB_ABIS}; echo $1)
+	for v in ${!CFLAGS_*} ${!CHOST_*} ${!CTARGET_*} ${!LDFLAGS_*} ${!LIBDIR=
_*} ABI MULTILIB_ABIS DEFAULT_ABI ; do
+		echo "${v}=3D'${!v}'" >> "${output}"
+	done
 }
 set_portage() {
 	local cat=3D$1 pkg=3D$2 ver=3D$3 env=3D$4 ovl=3D$5
@@ -817,7 +864,7 @@ doemerge() {
 	einfo "Log: ${logfile}"
 	ebegin "Emerging cross-${2:-$1}"
=20
-	set_use $1 ${USE} $( [[ -z ${MULTILIB_ABIS} ]] && echo - )multilib
+	set_use $1 ${USE} $( [[ ${MULTILIB_USE} =3D=3D "no" ]] && echo - )multi=
lib
=20
 	if [[ ${UOPTS/-v} !=3D ${UOPTS} || ${UOPTS/-p} !=3D ${UOPTS} ]] ; then
 		emerge cross-${CTARGET}/$1 ${EOPTS} \