aboutsummaryrefslogtreecommitdiff
blob: 68cec91f8e60abbaa9b44f73b1cdd29dd7e6850f (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
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
# Copyright 2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

TOPDIR=__TOPDIR__

config_site_arch() {
	local host=$(echo ${CHOST/-/ } | awk '{print $1}')

	[[ ${host/arm.*eb/} != ${host} ]] && host=armeb
	[[ ${host/arm/} != ${host} ]] && [[ ${host} != armeb ]] && host=arm

	[[ ${host/mips.*el/} != ${host} ]] && host=mipsel

	#[[ ${host/i[4-5]/6} != ${host} ]] && host=i686

	echo ${host}
}

config_site_names() {
	local site_arch=$(config_site_arch)
	local sites=""
	local x

	[[ ${CHOST/-linux-/} != $CHOST ]] && sites+=" linux ${site_arch}-linux"
	[[ ${CHOST/darwin/} != $CHOST ]] && sites+=" darwin ${site_arch}-linux"

	[[ ${CHOST/-linux-uclibc/} != $CHOST ]] && sites+=" linux-uclibc ${site_arch}-linux-uclibc"
	[[ ${CHOST/-linux-gnu/} != $CHOST ]] && sites+=" linux-gnu ${site_arch}-linux-gnu"

	[[ ${CHOST/-linux-uclibceabi/} != $CHOST ]] && sites+=" linux-uclibceabi ${site_arch}-linux-uclibceabi"
	[[ ${CHOST/-linux-gnueabi/} != $CHOST ]] && sites+=" linux-gnueabi ${site_arch}-linux-gnueabi"

	for x in ${sites} ${CHOST}; do
		[[ -e ${TOPDIR}/${x} ]] && echo ${TOPDIR}/${x}
	done
}

# Only kick in for cross-compiles so we don't break native builds #427184
if [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]; then
	sites="$(config_site_names)"
	if [[ ${sites} != "" ]]; then
		for site in ${sites}; do
			echo "$(basename $0): loading site script ${site}"
			. ${site}
		done
	fi
	unset site
	unset sites
fi