annotate scripts/mk-component.sh @ 10:352f80da6813

ACI compiles!
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 27 Sep 2016 02:31:03 +0000
parents
children c8bdae60fcb1
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
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 cfile_plain() {
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 if [ $# != 1 ]
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 then
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 echo "Error: cfile_plain takes 1 argument" 1>&2
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 exit 1
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 fi
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 objname=`basename "$1" .c`.obj
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 helpers/makeline cmd ../../toolwrap/cl470 -q -c ${CFLAGS} ${CPPFLAGS} \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 "$1" >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50 echo >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 OBJS="$OBJS $objname"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 }
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 cfile_str2ind() {
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 if [ $# != 1 ]
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 then
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 echo "Error: cfile_str2ind takes 1 argument" 1>&2
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 exit 1
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 fi
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 if [ "$USE_STR2IND" = 1 ]
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 then
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 objname=`basename "$1" .c`.obj
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 pp_name=`echo $1 | sed -e s/.c\$/.pp/`
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 pp__name=`echo $1 | sed -e s/.c\$/.pp_/`
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 helpers/makeline dep $objname "$1" \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 helpers/makeline cmd ../../toolwrap/cl470 -q -po -p? -x \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 ${CPPFLAGS} "$1" >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 helpers/makeline cmd ../../toolwrap/str2ind -a \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 -t ../str2ind.tab -l ../str2ind.log \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 -f "$pp_name" >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 helpers/makeline cmd ../../toolwrap/cl470 -q -c ${CFLAGS} \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 "$pp__name" >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 helpers/makeline cmd @rm -f "$pp_name" \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 helpers/makeline cmd @rm -f "$pp__name" \
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 echo >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 OBJS="$OBJS $objname"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 else
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 cfile_plain "$1"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 fi
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 }
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 # invoke the recipe
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 SRC=../../src
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 OBJS=
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 . "$recipe_file"
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 # finish the Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 helpers/makeline dep $LIBNAME.lib ${OBJS} >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 echo ' ../../toolwrap/ar470 r $@ $^' >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 echo >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 echo 'clean:' >> $BUILD_DIR/$LIBNAME/Makefile
352f80da6813 ACI compiles!
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 echo ' rm -f *.obj *.lib *.c' >> $BUILD_DIR/$LIBNAME/Makefile