FreeCalypso > hg > fc-magnetite
annotate scripts/mk-component.sh @ 51:967319e95535
uart_drv.lib done
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 30 Sep 2016 21:30:05 +0000 |
parents | c49c78d9bb5a |
children | 838717193e09 |
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() { |
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 |
10 | 52 cfile_plain() { |
53 if [ $# != 1 ] | |
54 then | |
55 echo "Error: cfile_plain takes 1 argument" 1>&2 | |
56 exit 1 | |
57 fi | |
58 objname=`basename "$1" .c`.obj | |
59 helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile | |
60 helpers/makeline cmd ../../toolwrap/cl470 -q -c ${CFLAGS} ${CPPFLAGS} \ | |
61 "$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
|
62 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
|
63 *[A-Z]*) |
c49c78d9bb5a
scripts/mk-component.sh: fix for cl470's auto-lowercasing of filenames
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
64 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
|
65 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
|
66 >> $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
|
67 ;; |
c49c78d9bb5a
scripts/mk-component.sh: fix for cl470's auto-lowercasing of filenames
Mychaela Falconia <falcon@freecalypso.org>
parents:
15
diff
changeset
|
68 esac |
10 | 69 echo >> $BUILD_DIR/$LIBNAME/Makefile |
70 OBJS="$OBJS $objname" | |
71 } | |
72 | |
73 cfile_str2ind() { | |
74 if [ $# != 1 ] | |
75 then | |
76 echo "Error: cfile_str2ind takes 1 argument" 1>&2 | |
77 exit 1 | |
78 fi | |
79 if [ "$USE_STR2IND" = 1 ] | |
80 then | |
81 objname=`basename "$1" .c`.obj | |
82 pp_name=`echo $1 | sed -e s/.c\$/.pp/` | |
83 pp__name=`echo $1 | sed -e s/.c\$/.pp_/` | |
84 helpers/makeline dep $objname "$1" \ | |
85 >> $BUILD_DIR/$LIBNAME/Makefile | |
86 helpers/makeline cmd ../../toolwrap/cl470 -q -po -p? -x \ | |
87 ${CPPFLAGS} "$1" >> $BUILD_DIR/$LIBNAME/Makefile | |
88 helpers/makeline cmd ../../toolwrap/str2ind -a \ | |
89 -t ../str2ind.tab -l ../str2ind.log \ | |
90 -f "$pp_name" >> $BUILD_DIR/$LIBNAME/Makefile | |
91 helpers/makeline cmd ../../toolwrap/cl470 -q -c ${CFLAGS} \ | |
92 "$pp__name" >> $BUILD_DIR/$LIBNAME/Makefile | |
93 helpers/makeline cmd @rm -f "$pp_name" \ | |
94 >> $BUILD_DIR/$LIBNAME/Makefile | |
95 helpers/makeline cmd @rm -f "$pp__name" \ | |
96 >> $BUILD_DIR/$LIBNAME/Makefile | |
97 echo >> $BUILD_DIR/$LIBNAME/Makefile | |
98 OBJS="$OBJS $objname" | |
99 else | |
100 cfile_plain "$1" | |
101 fi | |
102 } | |
103 | |
104 # invoke the recipe | |
105 | |
106 SRC=../../src | |
107 OBJS= | |
108 . "$recipe_file" | |
109 | |
110 # finish the Makefile | |
111 | |
112 helpers/makeline dep $LIBNAME.lib ${OBJS} >> $BUILD_DIR/$LIBNAME/Makefile | |
113 echo ' ../../toolwrap/ar470 r $@ $^' >> $BUILD_DIR/$LIBNAME/Makefile | |
114 echo >> $BUILD_DIR/$LIBNAME/Makefile | |
115 echo 'clean:' >> $BUILD_DIR/$LIBNAME/Makefile | |
116 echo ' rm -f *.obj *.lib *.c' >> $BUILD_DIR/$LIBNAME/Makefile |