annotate scripts/mk-component.sh @ 35:686b2e77043e

scripts/mk-component.sh: define COMPILER=tms470
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 16 Jul 2018 16:41:59 +0000
parents 0085ce06b728
children 2106617f1291
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #!/bin/sh
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2
19
294b440431fe scripts/mk-component.sh: no more component flavors
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
3 if [ $# != 1 ]
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 then
19
294b440431fe scripts/mk-component.sh: no more component flavors
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
5 echo "usage: $0 component-lib" 1>&2
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 exit 1
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 fi
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 LIBNAME="$1"
19
294b440431fe scripts/mk-component.sh: no more component flavors
Mychaela Falconia <falcon@freecalypso.org>
parents: 13
diff changeset
10 recipe_file="components/$1"
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 if [ ! -f "$recipe_file" ]
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 then
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 echo "Error: $recipe_file not found" 1>&2
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 exit 1
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 fi
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if [ -z "$BUILD_DIR" ]
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 then
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 echo "Error: BUILD_DIR= must be passed via environment" 1>&2
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 exit 1
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 fi
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 set -e
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 mkdir -p $BUILD_DIR/$LIBNAME
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 # beginning of the Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 echo "all: $LIBNAME.lib" > $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 echo >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 # shell functions to be used in the recipes
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 make_version() {
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 case $# in
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 1)
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 echo "$1_version.c:" >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 echo " ../../scripts/make-version.sh $1 > $1_version.c" \
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 ;;
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 2)
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 echo "$2_version.c:" >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 echo " ../../scripts/make-version.sh $1 > $2_version.c" \
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 ;;
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 *)
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 echo "Error: make_version takes 1 or 2 arguments" 1>&2
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 exit 1
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 ;;
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 esac
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 echo >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 asm_file() {
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 if [ $# != 1 ]
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 then
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 echo "Error: asm_file takes 1 argument" 1>&2
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 exit 1
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 fi
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 objname=`basename "$1" .s`.obj
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile
21
b7059379dd87 scripts/mk-component.sh: tool wrappers moved to tms470/toolwrap
Mychaela Falconia <falcon@freecalypso.org>
parents: 20
diff changeset
62 helpers/makeline cmd ../../tms470/toolwrap/asm470 ${ASMFLAGS} "$1" \
b7059379dd87 scripts/mk-component.sh: tool wrappers moved to tms470/toolwrap
Mychaela Falconia <falcon@freecalypso.org>
parents: 20
diff changeset
63 '$@' >> $BUILD_DIR/$LIBNAME/Makefile
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 echo >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 OBJS="$OBJS $objname"
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 }
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67
20
889745bf8615 scripts/mk-component.sh: no more str2ind
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
68 c_file() {
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 if [ $# != 1 ]
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 then
20
889745bf8615 scripts/mk-component.sh: no more str2ind
Mychaela Falconia <falcon@freecalypso.org>
parents: 19
diff changeset
71 echo "Error: c_file takes 1 argument" 1>&2
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 exit 1
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 fi
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 objname=`basename "$1" .c`.obj
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 case "$objname" in
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 *[A-Z]*)
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 helpers/makeline cmd rm -f '$@' \
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 ;;
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 esac
21
b7059379dd87 scripts/mk-component.sh: tool wrappers moved to tms470/toolwrap
Mychaela Falconia <falcon@freecalypso.org>
parents: 20
diff changeset
82 helpers/makeline cmd ../../tms470/toolwrap/cl470 -q -c ${CFLAGS} \
b7059379dd87 scripts/mk-component.sh: tool wrappers moved to tms470/toolwrap
Mychaela Falconia <falcon@freecalypso.org>
parents: 20
diff changeset
83 ${CPPFLAGS} "$1" >> $BUILD_DIR/$LIBNAME/Makefile
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 case "$objname" in
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 *[A-Z]*)
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 objname_lc=`echo $objname | tr A-Z a-z`
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 helpers/makeline cmd mv $objname_lc $objname \
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 ;;
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 esac
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 echo >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 OBJS="$OBJS $objname"
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 }
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 # invoke the recipe
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96
35
686b2e77043e scripts/mk-component.sh: define COMPILER=tms470
Mychaela Falconia <falcon@freecalypso.org>
parents: 24
diff changeset
97 COMPILER=tms470
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 SRC=../../src
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 OBJS=
24
0085ce06b728 scripts/mk-component.sh: set MMI=0
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
100 MMI=0
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 . "$recipe_file"
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 # finish the Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 helpers/makeline dep $LIBNAME.lib ${OBJS} >> $BUILD_DIR/$LIBNAME/Makefile
21
b7059379dd87 scripts/mk-component.sh: tool wrappers moved to tms470/toolwrap
Mychaela Falconia <falcon@freecalypso.org>
parents: 20
diff changeset
106 echo ' ../../tms470/toolwrap/ar470 r $@ $^' >> $BUILD_DIR/$LIBNAME/Makefile
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 echo >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 echo 'clean:' >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 echo ' rm -f *.obj *.lib *.c' >> $BUILD_DIR/$LIBNAME/Makefile