aboutsummaryrefslogtreecommitdiff
blob: 7b63756a3abee63be3a1b087849a803e0502e996 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/sh
# Copyright 2008-2011 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

if [ -z "${CHOST}" ] ; then
	CHOST=${0##*/}
	CHOST=${CHOST%-emerge}
	CHOST=${CHOST#emerge-}
fi
export CHOST

EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
if [ "${EPREFIX}" = "@"GENTOO_PORTAGE_EPREFIX"@" ] ; then
	EPREFIX=""
fi

: ${SYSROOT=${EPREFIX}/usr/${CHOST}}
: ${PORTAGE_CONFIGROOT=${SYSROOT}}
export SYSROOT PORTAGE_CONFIGROOT

if [ -z "${CHOST}" ] || [ ! -d "${SYSROOT}" ] ; then
	echo "cross-emerge: CHOST is not set properly"
	exit 1
fi

# Portage defaults CBUILD to CHOST, so we have to remove CHOST
# from the env to get a "good" value for CBUILD
query_vars="CBUILD CFLAGS CXXFLAGS CPPFLAGS LDFLAGS"
clean_vars="${query_vars} CHOST SYSROOT PORTAGE_CONFIGROOT"
eval $(env $(printf -- '-u %s ' ${clean_vars}) \
	portageq envvar -v ${query_vars} | sed s:^:_E_:)
: ${CBUILD=${_E_CBUILD}}
: ${BUILD_CFLAGS=${_E_CFLAGS}}
: ${BUILD_CXXFLAGS=${_E_CXXFLAGS}}
: ${BUILD_CPPFLAGS=${_E_CPPFLAGS}}
: ${BUILD_LDFLAGS=${_E_LDFLAGS}}
export CBUILD BUILD_CFLAGS BUILD_CXXFLAGS BUILD_CPPFLAGS BUILD_LDFLAGS

: ${CROSS_CMD:=emerge --root-deps=rdeps}
exec ${CROSS_CMD} "$@"