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