forked from antmicro/ecos-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake.sh
executable file
·108 lines (87 loc) · 2.04 KB
/
make.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
TOOLS_PATH=$(dirname $(readlink -f $0))
function get_option {
VALUE=`echo $1 | sed 's/[-a-zA-Z0-9]*=//'`
}
function ecc_get_value {
echo `cat $ECC | grep $1 -A 100 | grep user_value | head -1 | sed 's,user_value,|,g' | cut -f 2 -d '|' | tr -d '"'`
}
function usage {
echo "Usage: `basename $0` --config=<config-name> (--output-filename=<filename>|--tests|--rebuild)"
echo " Use a config with FILES='' to just generate a kernel"
}
TESTS=false
REBUILD=false
for i in "$@"
do
get_option $i
case $i in
-c=*|--config=*)
CONFIG=$VALUE
;;
-o=*|--output-filename=*)
OUTPUT_FILENAME=$VALUE
;;
-t|--tests)
TESTS=true
;;
-r|--rebuild)
REBUILD=true
;;
*)
echo "FATAL: You have provided an unknown option: $i."
usage
exit 1
esac
done
if [ -z $CONFIG ]
then
echo "FATAL: No config file provided."
usage
exit 1
fi
CONFIG_FILE=$CONFIG.config
if [ ! -e $CONFIG_FILE ]
then
echo "FATAL: The config file \"$CONFIG_FILE\" does not exist."
exit 1
fi
CONFIG_SHARED=$CONFIG.config_shared
if [ -e $CONFIG_SHARED ]
then
. ./$CONFIG_SHARED
fi
# include config file to set appropriate variables
. ./$CONFIG_FILE
if [ -z $ECOS_REPOSITORY ] || [ -z $ECC ]
then
echo "FATAL: The variables \"ECOS_REPOSITORY\" AND \"ECC\" have not been set properly."
exit 1
fi
ECOS_REPOSITORY=`readlink -f $ECOS_REPOSITORY`
ECC=`readlink -f $ECC`
GCC=`ecc_get_value CYGBLD_GLOBAL_COMMAND_PREFIX`-gcc
CFLAGS=`ecc_get_value CYGBLD_GLOBAL_CFLAGS`
mkdir -p $CONFIG\_build
if $REBUILD ; then
rm -rf $CONFIG\_build/*
fi
cd $CONFIG\_build
KPATH=`pwd`
$TOOLS_PATH/ecosconfig --config=$ECC tree
if $TESTS ; then
make tests
exit
else
make
fi
cd ..
if [ ! -z "$FILES" ]
then
if [ -z $OUTPUT_FILENAME ] ; then
OUTPUT_FILENAME=$CONFIG
fi
echo "Compiling eCos application..."
PATH="${TOOLS_PATH}:$PATH" $GCC -g -I./ -g -I${KPATH}/install/include ${FILES} \
-L${KPATH}/install/lib -Ttarget.ld ${CFLAGS} ${ADD_OPT} -nostdlib -o $OUTPUT_FILENAME
fi