annotate scripts/mk-component.sh @ 17:9a8a20d45be7

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