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