From 3356140fd2d6f15b119ca98b4d7ff969a764cee6 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 6 Sep 2019 21:22:50 -0500 Subject: Add cross.sh to cross compile for one or more targets, and tweak make.sh to produce different output names for different ${TARGET}s. --- scripts/cross.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/make.sh | 2 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100755 scripts/cross.sh (limited to 'scripts') diff --git a/scripts/cross.sh b/scripts/cross.sh new file mode 100755 index 00000000..44bd876e --- /dev/null +++ b/scripts/cross.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +# Convenience wrapper to set $CROSS_COMPILE from short name using "ccc" +# symlink (Cross C Compiler) to a directory of cross compilers named +# $TARGET-*-cross. Tested with scripts/mcm-buildall.sh output. + +# Usage: ./cross.sh $TARGET make distclean defconfig toybox +# With no arguments, lists available targets. Use target "all" to iterate +# through each $TARGET from the list. + +CCC="$(dirname "$(readlink -f "$0")")"/ccc +if [ ! -d "$CCC" ] +then + echo "Create symlink 'ccc' to cross compiler directory" + exit 1 +fi + +unset X Y + +# Display target list? +list() +{ + ls "$CCC" | sed 's/-.*//' | sort -u | xargs +} +[ $# -eq 0 ] && list && exit + +X="$1" +shift + +# build all targets? +if [ "$X" == all ] +then + for TARGET in $(list) + do + mkdir -p output/$TARGET + { + export TARGET + "$0" $TARGET "$@" 2>&1 || mv output/$TARGET{,.failed} + } | tee output/$TARGET/log.txt + done + + exit +fi + +# Call command with CROSS_COMPILE= as its first argument + +Y=$(readlink -f "$CCC"/$X-*cross) +X=$(basename "$Y") +export TARGET="${X/-*/}" +X="$Y/bin/${X/-cross/-}" +[ ! -e "${X}cc" ] && echo "${X}cc not found" && exit 1 + +CROSS_COMPILE="$X" "$@" diff --git a/scripts/make.sh b/scripts/make.sh index 540199b6..ec908ce1 100755 --- a/scripts/make.sh +++ b/scripts/make.sh @@ -15,7 +15,7 @@ set -o pipefail source scripts/portability.sh [ -z "$KCONFIG_CONFIG" ] && KCONFIG_CONFIG=.config -[ -z "$OUTNAME" ] && OUTNAME=toybox +[ -z "$OUTNAME" ] && OUTNAME=toybox"${TARGET:+-$TARGET}" UNSTRIPPED="generated/unstripped/$(basename "$OUTNAME")" # Try to keep one more cc invocation going than we have processors -- cgit v1.2.3