forked from knsathya/mkroot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcross.sh
executable file
·50 lines (39 loc) · 986 Bytes
/
cross.sh
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
# Convenience wrapper to set CROSS_COMPILE variable to musl-cross-make pathname
# using "mcm" symlink to musl-cross-make output directory.
# Usage: ./cross.sh TARGET ./mkroot.sh
# With no arguments, lists available targets.
# Use target "all" to iterate through all targets.
MCM="$(dirname "$(readlink -f "$0")")"/mcm
if [ ! -d "$MCM" ]
then
echo "Create symlink 'mcm' to musl-cross-make output directory"
exit 1
fi
unset X Y
# Display target list?
list()
{
ls "$MCM" | sed 's/-.*//' | sort -u | xargs
}
[ $# -eq 0 ] && list && exit
X="$1"
shift
# build all targets?
if [ "$X" == all ]
then
for i in $(list)
do
mkdir -p output/$i
{
"$0" $i "$@" 2>&1 || mv output/$i{,.failed}
} | tee output/$i/log.txt
done
exit
fi
# Call command with CROSS_COMPILE= as its first argument
Y=$(readlink -f "$MCM"/$X-*-cross)
X=$(basename "$Y")
X="$Y/bin/${X/-cross/-}"
[ ! -e "${X}cc" ] && echo "${X}cc not found" && exit 1
CROSS_COMPILE="$X" "$@"