-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·72 lines (66 loc) · 2.06 KB
/
build.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
export CLEAN=
export HOST=
export TARGET_TESTS=
check_ivm64_env(){
if ! which ivm64-gcc; then
echo "ivm64-gcc compiler not found in PATH"
exit 1
fi
ivm_fsgen=(${IVM_FSGEN:-ivm64-fsgen})
if ! which "${ivm_fsgen[0]}"; then
echo "Neither in-memory filesystem generator ivm64-fsgen found in PATH"
echo "nor IVM_FSGEN environment variable has a valid filesystem generator"
echo "Examples: export IVM_FSGEN=ivm64-fsgen"
echo " export IVM_FSGEN='ivmfs-gen.sh'"
exit 1
fi
ivm_emu=(${IVM_EMU:-ivm64-emu})
if ! which "${ivm_emu[0]}"; then
echo "$ivm_emu: IVM_EMU environment variable must have a valid ivm emulator"
echo "Examples: export IVM_EMU=ivm64-emu"
echo " export IVM_EMU='ivm run'"
exit 1
fi
ivm_as=(${IVM_AS:-ivm64-as})
if ! which "${ivm_as[0]}"; then
echo "IVM_AS environment variable must have a valid ivm emulator"
echo "Examples: export IVM_AS=ivm64-as"
echo " export IVM_AS='ivm as'"
exit 1
fi
}
while test $# -gt 0
do
if test "$1" == '-c'; then
CLEAN=1
elif test "$1" == '-t'; then
# Compile tests
TARGET_TESTS=tests
elif test "$1" == 'linux'; then
HOST=linux
elif [[ "$1" =~ ^ivm ]] ; then
HOST=ivm64
check_ivm64_env
fi
shift
done
if test -z "$HOST" -a -z "$CLEAN"; then
1>&2 echo "Usage: $0 arch #make arch "
1>&2 echo " $0 -c arch #clean before making arch"
1>&2 echo " $0 -c #clean all buildings"
1>&2 echo " arch: select either 'linux' or 'ivm64' target architecture"
exit 1
fi
nproc=8
if test -n "$CLEAN" -a -z "$HOST"; then
HOST=linux make clean
HOST=ivm64 make clean
elif test -n "$CLEAN" -a -n "$HOST"; then
HOST=$HOST make clean
HOST=$HOST make -j${nproc}
! test -z "$TARGET_TESTS" && HOST=$HOST make -j${nproc} "$TARGET_TESTS"
else
HOST="$HOST" make -j${nproc}
! test -z "$TARGET_TESTS" && HOST=$HOST make -j${nproc} "$TARGET_TESTS"
fi