annotate scripts/mk-component.sh @ 207:4c555a7a3435

helpers/mokosrec2bin.c: sync with master version in freecalypso-tools The only diff is that the fill byte now defaults to 0xFF.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 05:13:01 +0000
parents 2106617f1291
children
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
140
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
95 cfile_symlink() {
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
96 if [ $# != 1 ]
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
97 then
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
98 echo "Error: cfile_symlink takes 1 argument" 1>&2
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
99 exit 1
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
100 fi
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
101 localcopy=`basename "$1"`
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
102 echo "$localcopy:" >> $BUILD_DIR/$LIBNAME/Makefile
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
103 echo " ln -s $1 ." >> $BUILD_DIR/$LIBNAME/Makefile
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
104 echo >> $BUILD_DIR/$LIBNAME/Makefile
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
105 c_file $localcopy
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
106 }
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 35
diff changeset
107
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 # invoke the recipe
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109
35
686b2e77043e scripts/mk-component.sh: define COMPILER=tms470
Mychaela Falconia <falcon@freecalypso.org>
parents: 24
diff changeset
110 COMPILER=tms470
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 SRC=../../src
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 OBJS=
24
0085ce06b728 scripts/mk-component.sh: set MMI=0
Mychaela Falconia <falcon@freecalypso.org>
parents: 21
diff changeset
113 MMI=0
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 . "$recipe_file"
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 # finish the Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 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
119 echo ' ../../tms470/toolwrap/ar470 r $@ $^' >> $BUILD_DIR/$LIBNAME/Makefile
13
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 echo >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 echo 'clean:' >> $BUILD_DIR/$LIBNAME/Makefile
f10cbd8a51c4 scripts: pruned import from Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 echo ' rm -f *.obj *.lib *.c' >> $BUILD_DIR/$LIBNAME/Makefile