10
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #!/bin/sh
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 if [ $# -lt 1 -o $# -gt 2 ]
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 then
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 echo "usage: $0 component-lib [flavor]" 1>&2
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 exit 1
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 fi
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 LIBNAME="$1"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 if [ -n "$2" ]
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 then
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 recipe_file="components/$1-$2"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 else
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 recipe_file="components/$1"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 fi
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if [ ! -f "$recipe_file" ]
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 then
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 echo "Error: $recipe_file not found" 1>&2
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 exit 1
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 fi
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if [ -z "$BUILD_DIR" ]
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 then
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 echo "Error: BUILD_DIR= must be passed via environment" 1>&2
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 exit 1
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 fi
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 set -e
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 mkdir -p $BUILD_DIR/$LIBNAME
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 # beginning of the Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 echo "all: $LIBNAME.lib" > $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 echo >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 # shell functions to be used in the recipes
|
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>
diff
changeset
|
40 make_version() {
|
c8bdae60fcb1
changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
diff
changeset
|
41 if [ $# != 1 ]
|
c8bdae60fcb1
changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
diff
changeset
|
42 then
|
c8bdae60fcb1
changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
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>
diff
changeset
|
44 exit 1
|
c8bdae60fcb1
changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
diff
changeset
|
45 fi
|
c8bdae60fcb1
changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
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>
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>
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>
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>
diff
changeset
|
50 }
|
c8bdae60fcb1
changed the generation of *_version.c files to not break on make clean
Mychaela Falconia <falcon@freecalypso.org>
diff
changeset
|
51
|
10
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 cfile_plain() {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 if [ $# != 1 ]
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 then
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 echo "Error: cfile_plain takes 1 argument" 1>&2
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 exit 1
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 fi
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 objname=`basename "$1" .c`.obj
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 helpers/makeline cmd ../../toolwrap/cl470 -q -c ${CFLAGS} ${CPPFLAGS} \
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 "$1" >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 echo >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 OBJS="$OBJS $objname"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 cfile_str2ind() {
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 if [ $# != 1 ]
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 then
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 echo "Error: cfile_str2ind takes 1 argument" 1>&2
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 exit 1
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 fi
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 if [ "$USE_STR2IND" = 1 ]
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 then
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 objname=`basename "$1" .c`.obj
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 pp_name=`echo $1 | sed -e s/.c\$/.pp/`
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 pp__name=`echo $1 | sed -e s/.c\$/.pp_/`
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 helpers/makeline dep $objname "$1" \
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 helpers/makeline cmd ../../toolwrap/cl470 -q -po -p? -x \
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 ${CPPFLAGS} "$1" >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 helpers/makeline cmd ../../toolwrap/str2ind -a \
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 -t ../str2ind.tab -l ../str2ind.log \
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 -f "$pp_name" >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 helpers/makeline cmd ../../toolwrap/cl470 -q -c ${CFLAGS} \
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 "$pp__name" >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 helpers/makeline cmd @rm -f "$pp_name" \
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 helpers/makeline cmd @rm -f "$pp__name" \
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 echo >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 OBJS="$OBJS $objname"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 else
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 cfile_plain "$1"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 fi
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 }
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 # invoke the recipe
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 SRC=../../src
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 OBJS=
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 . "$recipe_file"
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 # finish the Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 helpers/makeline dep $LIBNAME.lib ${OBJS} >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 echo ' ../../toolwrap/ar470 r $@ $^' >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 echo >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 echo 'clean:' >> $BUILD_DIR/$LIBNAME/Makefile
|
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 echo ' rm -f *.obj *.lib *.c' >> $BUILD_DIR/$LIBNAME/Makefile
|