diff --git a/setup_board b/setup_board index 1e500f4e8f..2596b30157 100755 --- a/setup_board +++ b/setup_board @@ -48,9 +48,9 @@ DEFINE_boolean force $FLAGS_FALSE \ "Force re-creating board root." DEFINE_string binutils_version "2.21-r3" \ "Version of binutils to use." -DEFINE_string gcc_version "4.6.0-r13" \ +DEFINE_string gcc_version "[stable]" \ "Version of gcc to use." -DEFINE_string libc_version "2.11.1-r3" \ +DEFINE_string libc_version "[stable]" \ "Version of libc to use." DEFINE_string kernel_version "3.1" \ "Version of kernel headers to use." @@ -134,6 +134,11 @@ toolchain_needs_update() { # If toolchain symlinks weren't created yet, we definitely need to update. if [ ! -d /usr/local/portage/crossdev/cross-$toolchain ]; then + # NOTE: In this branch, the versions have not been resolved, and will + # be passed directly to crossdev. That works because crossdev understands + # '[stable]'. + # We cannot resolve the versions because the cross-$toolchain category is + # not yet set up. return 0 fi @@ -142,9 +147,23 @@ toolchain_needs_update() { return 1 fi - # Unmask any ebuilds previously masked by crossdev. crossdev will re-setup - # its masks appropriately the next time we run it. - sudo rm -f /etc/portage/package.mask/cross-$toolchain + # Unmask any ebuilds previously [un]masked by crossdev. crossdev will + # re-setup its masks appropriately the next time we run it. + sudo rm -f /etc/portage/package.{mask,keywords}/cross-$toolchain + + pkg_to_flag() { + [ "${1}" = "glibc" ] && echo "libc" || echo "$1" + } + + local pkg + for pkg in gcc glibc binutils; do + local flagname=FLAGS_$(pkg_to_flag ${pkg})_version + if [ "${!flagname}" = "[stable]" ]; then + eval ${flagname}=$( \ + portageq best_visible / "cross-$toolchain/${pkg}"| \ + sed -e "s,cross-$toolchain/${pkg}-,,") + fi + done local flags="--pretend --quiet --update" local pkgs @@ -206,8 +225,11 @@ build_toolchain() { if [ $FLAGS_latest_toolchain -ne $FLAGS_TRUE ]; then CROSS_ARGS+=" --binutils $FLAGS_binutils_version" CROSS_ARGS+=" --gcc $FLAGS_gcc_version" - CROSS_ARGS+=" --kernel $FLAGS_kernel_version" - CROSS_ARGS+=" --libc $FLAGS_libc_version" + if [[ "$toolchain" != "arm-none-eabi" ]]; then + # arm-none-eabi needs no version specification + CROSS_ARGS+=" --kernel $FLAGS_kernel_version" + CROSS_ARGS+=" --libc $FLAGS_libc_version" + fi fi CROSS_ARGS+=" --ex-gdb"