annotate scripts/mk-component.sh @ 93:6475bde1b170

Building RAM fw images for the Pirelli: finishing touches
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 02 Oct 2016 19:51:37 +0000
parents 838717193e09
children 5e2b0806b098
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 #!/bin/sh
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 if [ $# -lt 1 -o $# -gt 2 ]
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 then
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 echo "usage: $0 component-lib [flavor]" 1>&2
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 exit 1
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 fi
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 LIBNAME="$1"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 if [ -n "$2" ]
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 then
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 recipe_file="components/$1-$2"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 else
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 recipe_file="components/$1"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 fi
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if [ ! -f "$recipe_file" ]
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 then
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 echo "Error: $recipe_file not found" 1>&2
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 exit 1
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 fi
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if [ -z "$BUILD_DIR" ]
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 then
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 echo "Error: BUILD_DIR= must be passed via environment" 1>&2
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 exit 1
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 fi
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 set -e
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 mkdir -p $BUILD_DIR/$LIBNAME
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 # beginning of the Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 echo "all: $LIBNAME.lib" > $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 echo >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 # shell functions to be used in the recipes
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39
15
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
40 make_version() {
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
41 if [ $# != 1 ]
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
42 then
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
43 echo "Error: make_version takes 1 argument" 1>&2
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
44 exit 1
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
45 fi
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
46 echo "$1_version.c:" >> $BUILD_DIR/$LIBNAME/Makefile
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
47 echo " ../../scripts/make-version.sh $1 > $1_version.c" \
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
48 >> $BUILD_DIR/$LIBNAME/Makefile
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
49 echo >> $BUILD_DIR/$LIBNAME/Makefile
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
50 }
c8bdae60fcb1 changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
parents: 10
diff changeset
51
68
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
52 asm_file() {
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
53 if [ $# != 1 ]
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
54 then
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
55 echo "Error: asm_file takes 1 argument" 1>&2
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
56 exit 1
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
57 fi
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
58 objname=`basename "$1" .s`.obj
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
59 helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
60 helpers/makeline cmd ../../toolwrap/asm470 ${ASMFLAGS} "$1" '$@' \
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
61 >> $BUILD_DIR/$LIBNAME/Makefile
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
62 echo >> $BUILD_DIR/$LIBNAME/Makefile
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
63 OBJS="$OBJS $objname"
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
64 }
838717193e09 eliminated the use of bootloader.lib binary blob
Mychaela Falconia <falcon@freecalypso.org>
parents: 32
diff changeset
65
10
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 cfile_plain() {
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 if [ $# != 1 ]
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 then
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 echo "Error: cfile_plain takes 1 argument" 1>&2
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 exit 1
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 fi
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 objname=`basename "$1" .c`.obj
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 helpers/makeline cmd ../../toolwrap/cl470 -q -c ${CFLAGS} ${CPPFLAGS} \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 "$1" >> $BUILD_DIR/$LIBNAME/Makefile
32
c49c78d9bb5a scripts/mk-component.sh: fix for cl470's auto-lowercasing of filenames
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
76 case "$objname" in
c49c78d9bb5a scripts/mk-component.sh: fix for cl470's auto-lowercasing of filenames
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
77 *[A-Z]*)
c49c78d9bb5a scripts/mk-component.sh: fix for cl470's auto-lowercasing of filenames
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
78 objname_lc=`echo $objname | tr A-Z a-z`
c49c78d9bb5a scripts/mk-component.sh: fix for cl470's auto-lowercasing of filenames
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
79 helpers/makeline cmd mv $objname_lc $objname \
c49c78d9bb5a scripts/mk-component.sh: fix for cl470's auto-lowercasing of filenames
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
80 >> $BUILD_DIR/$LIBNAME/Makefile
c49c78d9bb5a scripts/mk-component.sh: fix for cl470's auto-lowercasing of filenames
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
81 ;;
c49c78d9bb5a scripts/mk-component.sh: fix for cl470's auto-lowercasing of filenames
Mychaela Falconia <falcon@freecalypso.org>
parents: 15
diff changeset
82 esac
10
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 echo >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 OBJS="$OBJS $objname"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 }
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 cfile_str2ind() {
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 if [ $# != 1 ]
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 then
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 echo "Error: cfile_str2ind takes 1 argument" 1>&2
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 exit 1
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 fi
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 if [ "$USE_STR2IND" = 1 ]
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 then
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 objname=`basename "$1" .c`.obj
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 pp_name=`echo $1 | sed -e s/.c\$/.pp/`
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 pp__name=`echo $1 | sed -e s/.c\$/.pp_/`
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 helpers/makeline dep $objname "$1" \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 helpers/makeline cmd ../../toolwrap/cl470 -q -po -p? -x \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 ${CPPFLAGS} "$1" >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 helpers/makeline cmd ../../toolwrap/str2ind -a \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 -t ../str2ind.tab -l ../str2ind.log \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 -f "$pp_name" >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 helpers/makeline cmd ../../toolwrap/cl470 -q -c ${CFLAGS} \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 "$pp__name" >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 helpers/makeline cmd @rm -f "$pp_name" \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 helpers/makeline cmd @rm -f "$pp__name" \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 echo >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 OBJS="$OBJS $objname"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 else
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 cfile_plain "$1"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 fi
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 }
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 # invoke the recipe
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 SRC=../../src
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 OBJS=
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 . "$recipe_file"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 # finish the Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 helpers/makeline dep $LIBNAME.lib ${OBJS} >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 echo ' ../../toolwrap/ar470 r $@ $^' >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 echo >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 echo 'clean:' >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 echo ' rm -f *.obj *.lib *.c' >> $BUILD_DIR/$LIBNAME/Makefile