FreeCalypso > hg > ffs-editor
comparison scripts/mk-component.sh @ 4:7ed24ddc5c2a
scripts/mk-component.sh: adapted from Selenite
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 15 May 2020 02:06:09 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:8123259c7f14 | 4:7ed24ddc5c2a |
---|---|
1 #!/bin/sh | |
2 | |
3 if [ $# != 1 ] | |
4 then | |
5 echo "usage: $0 component-lib" 1>&2 | |
6 exit 1 | |
7 fi | |
8 | |
9 LIBNAME="$1" | |
10 recipe_file="components/$1" | |
11 | |
12 if [ ! -f "$recipe_file" ] | |
13 then | |
14 echo "Error: $recipe_file not found" 1>&2 | |
15 exit 1 | |
16 fi | |
17 | |
18 if [ -z "$BUILD_DIR" ] | |
19 then | |
20 echo "Error: BUILD_DIR= must be passed via environment" 1>&2 | |
21 exit 1 | |
22 fi | |
23 | |
24 set -e | |
25 | |
26 mkdir -p $BUILD_DIR/$LIBNAME | |
27 | |
28 # beginning of the Makefile | |
29 echo "all: $LIBNAME.a" > $BUILD_DIR/$LIBNAME/Makefile | |
30 echo >> $BUILD_DIR/$LIBNAME/Makefile | |
31 | |
32 # shell functions to be used in the recipes | |
33 | |
34 asm_file() { | |
35 if [ $# != 1 ] | |
36 then | |
37 echo "Error: asm_file takes 1 argument" 1>&2 | |
38 exit 1 | |
39 fi | |
40 objname=`basename "$1" .S`.o | |
41 helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile | |
42 helpers/makeline cmd arm-elf-gcc -c ${ASMFLAGS} ${CPPFLAGS} "$1" \ | |
43 >> $BUILD_DIR/$LIBNAME/Makefile | |
44 echo >> $BUILD_DIR/$LIBNAME/Makefile | |
45 OBJS="$OBJS $objname" | |
46 } | |
47 | |
48 c_file() { | |
49 if [ $# != 1 ] | |
50 then | |
51 echo "Error: c_file takes 1 argument" 1>&2 | |
52 exit 1 | |
53 fi | |
54 objname=`basename "$1" .c`.o | |
55 helpers/makeline dep $objname "$1" >> $BUILD_DIR/$LIBNAME/Makefile | |
56 helpers/makeline cmd arm-elf-gcc -c ${CFLAGS_gcc} ${CPPFLAGS} "$1" \ | |
57 >> $BUILD_DIR/$LIBNAME/Makefile | |
58 echo >> $BUILD_DIR/$LIBNAME/Makefile | |
59 OBJS="$OBJS $objname" | |
60 } | |
61 | |
62 cfile_symlink() { | |
63 if [ $# != 1 ] | |
64 then | |
65 echo "Error: cfile_symlink takes 1 argument" 1>&2 | |
66 exit 1 | |
67 fi | |
68 localcopy=`basename "$1"` | |
69 echo "$localcopy:" >> $BUILD_DIR/$LIBNAME/Makefile | |
70 echo " ln -s $1 ." >> $BUILD_DIR/$LIBNAME/Makefile | |
71 echo >> $BUILD_DIR/$LIBNAME/Makefile | |
72 c_file $localcopy | |
73 } | |
74 | |
75 # invoke the recipe | |
76 | |
77 COMPILER=gcc | |
78 SRC=../../src | |
79 OBJS= | |
80 MMI=0 | |
81 . "$recipe_file" | |
82 | |
83 # finish the Makefile | |
84 | |
85 helpers/makeline dep $LIBNAME.a ${OBJS} >> $BUILD_DIR/$LIBNAME/Makefile | |
86 echo ' arm-elf-ar rcu $@ $^' >> $BUILD_DIR/$LIBNAME/Makefile | |
87 echo ' arm-elf-ranlib $@' >> $BUILD_DIR/$LIBNAME/Makefile | |
88 echo >> $BUILD_DIR/$LIBNAME/Makefile | |
89 echo 'clean:' >> $BUILD_DIR/$LIBNAME/Makefile | |
90 echo ' rm -f *.[oa] *.c' >> $BUILD_DIR/$LIBNAME/Makefile |