blob: 09f73d85b2d2c3b7588ef993209bf6d5e614fe14 [file] [log] [blame]
# Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
# Distributed under the terms of the GNU General Public License v2
EAPI=2
CROS_WORKON_COMMIT="44573f2a80042796544c9a4a3f085942258da988"
CROS_WORKON_PROJECT="chromiumos/third_party/u-boot-next"
inherit cros-debug toolchain-funcs
DESCRIPTION="Das U-Boot boot loader"
HOMEPAGE="http://www.denx.de/wiki/U-Boot"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="arm x86"
IUSE=""
# TODO(clchiou): coreboot couldn't care less about vboot for now
DEPEND="arm? ( chromeos-base/vboot_reference-firmware )
!sys-boot/chromeos-u-boot"
RDEPEND="${DEPEND}
"
CROS_WORKON_LOCALNAME="u-boot-next"
CROS_WORKON_SUBDIR="files"
# This must be inherited *after* EGIT/CROS_WORKON variables defined
inherit cros-workon
BUILD_ROOT="${WORKDIR}/${P}/builds"
# TODO(vbendeb): this will have to be populated when it becomes necessary to
# build different config flavors.
ALL_UBOOT_FLAVORS=''
IUSE="${IUSE} ${ALL_UBOOT_FLAVORS}"
UB_ARCH="$(tc-arch-kernel)"
COMMON_MAKE_FLAGS="ARCH=${UB_ARCH} CROSS_COMPILE=${CHOST}-"
# TODO(clchiou): coreboot couldn't care less about vboot for now
use arm && COMMON_MAKE_FLAGS+=" VBOOT=${ROOT%/}/usr"
if use cros-debug; then
use arm && COMMON_MAKE_FLAGS+=" VBOOT_DEBUG=1"
fi
get_required_config() {
case "${UB_ARCH}" in
(arm) echo 'chromeos_seaboard_onestop_config';;
(i386) echo 'coreboot-x86_config';;
(*) die "can not build for unknown architecture ${UB_ARCH}";;
esac
}
# TODO: remove this once cros_bundle_firmware is complete
get_fdt_name() {
local name=${PKG_CONFIG#pkg-config-}
if use arm; then
echo "${name}" | tr _ '-'
fi
}
# Returns the directory containing the dts files
get_fdt_dir() {
local name=${PKG_CONFIG#pkg-config-}
if use arm; then
echo "board/nvidia/seaboard"
fi
}
if use arm; then
COMMON_MAKE_FLAGS+=" USE_PRIVATE_LIBGCC=yes"
# We will supply an fdt at run time
COMMON_MAKE_FLAGS+=" DEV_TREE_SEPARATE=1 DEV_TREE_SRC=$(get_fdt_name)"
fi
src_configure() {
local config
config=$(get_required_config)
elog "Using U-Boot config: ${config}"
dtb=$(get_fdt_name)
if [ -n "${dtb}" ]; then
elog "Using fdt: ${dtb}"
else
elog "Not building fdt"
fi
emake \
${COMMON_MAKE_FLAGS} \
distclean
emake \
${COMMON_MAKE_FLAGS} \
${config} || die "U-Boot configuration ${config} failed"
}
src_compile() {
local config
tc-getCC
config=$(get_required_config)
emake \
${COMMON_MAKE_FLAGS} \
HOSTCC=${CC} \
HOSTSTRIP=true \
all || die "U-Boot compile ${config} failed"
}
src_install() {
local config
local inst_dir
if use x86; then
inst_dir='/coreboot'
else
inst_dir='/u-boot'
fi
dodir "${inst_dir}"
insinto "${inst_dir}"
config=$(get_required_config)
local files_to_copy='System.map include/autoconf.mk u-boot.bin'
if [ -n "$(get_fdt_name)" ]; then
files_to_copy+=" u-boot.dtb"
fi
for file in ${files_to_copy}; do
doins "${file}" || die
done
# Install device tree source files
if [ -n "$(get_fdt_dir)" ]; then
dodir "${inst_dir}/dts"
insinto "${inst_dir}/dts"
for file in "$(get_fdt_dir)"/*.dts "$(get_fdt_dir)"/*.dtsi; do
doins "${file}" || die
done
fi
if use x86; then
newins "u-boot" u-boot.elf || die
fi
}