2 # BCU SDK bcu development enviroment
3 # Copyright (C) 2005-2011 Martin Koegler <mkoegler@auto.tuwien.ac.at>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 BCUGEN
=@BINDIR@
/bcugen2
21 EXTRACT
=@BINDIR@
/extractprogid
32 progname
="`basename \"$0\"`"
37 $progname $version Copyright (C) 2005-2011 Martin Koegler <mkoegler@auto.tuwien.ac.at>
40 Usage: $progname [options] config_desc
42 -Dxx uses xxx as temorary directory and keep temporary files there
43 (warning: all content can be lost)
44 -cxxx uses xxx as program id
45 -ixxx stores image as xxx (default:config_desc.load)
53 if [ $keep != 1 ]; then
66 value
="`echo x\"$1\" | sed -e 's/^x-.//'`"
68 -D*) keep
=1; TMP
="$value" ;;
72 -*) echo "$progname: unknown option $1"
80 echo "$progname: expect config_desc"
86 if [ ! -f "$IN" ]; then
87 echo "$progname: $IN not found"
91 if [ "x$OUT" = "x" ]; then
95 if [ "x$TMP" = "x" ]; then
96 TMP
=`mktemp -u bcusdk.XXXXXXXXXX`||
exit 1
98 elif [ ! -e "$TMP" ]; then
102 if [ ! -d $TMP ]; then
103 echo "can not create directory $TMP"
109 if [ $keep != 1 ]; then
110 trap "rm -r $TMP; exit 1" 1 2 3 5 10 13 15
113 if [ "x$CONF" = "x" ]; then
114 $EXTRACT "$IN" "$TMP/cf" || error
117 cp "$CONF" "$TMP/cf" || error
120 pushd "$TMP" >/dev
/null || error
121 $TAR x cf bcusdk-version || error
123 if [ "x`cat bcusdk-version`" = "x0.0.0" ]; then
124 $TAR x cf config || error
125 $TAR x cf c.inc || error
127 echo "Unsupported Formatversion: `cat bcusdk-version`"
131 popd >/dev
/null || error
133 $BCUGEN "$TMP/config" "$IN" "$TMP/c.h" "$TMP/p1.s" "$TMP/p.var" || error
135 VAR
=`cat "$TMP/p.var"`
137 if [ ! -f "$LIB/lib$VAR.a" ]; then
138 echo "unknown variant $VAR"
142 LDPATH
="-lc -lm `$TGCC -print-libgcc-file-name`"
144 for a
in `$TGCC --print-search-dirs |grep "libraries: ="|cut -d= -f2-`
146 LDPATH
="$LDPATH -L $a"
150 echo "#include \"c.h\"">"$TMP/c.c"
151 echo "#include \"c.inc\"">>"$TMP/c.c"
153 $TGCC -c -O3 -Os -Wall -Winline -gstabs -I$SINC -o "$TMP/c.o" "$TMP/c.c" || error
154 $TAS -I$SINC -o "$TMP/p1.o" "$TMP/p1.s" || error
156 $TLD -Map "$TMP/elf.map" -N -T "$LD/$VAR.link" --move-sections --relax -o "$TMP/elf" "$TMP/c.o" "$TMP/p1.o" -\
( $LDPATH "$LIB/lib$VAR.a" -\
) || error
157 $TLD -Map "$TMP/load.map" -T $LD/genload.link
-o "$TMP/load" "$TMP/elf" || error
160 cp "$TMP/load" "$OUT" || error
162 if [ $keep != 1 ]; then