annotate scripts/mk-component-gcc.sh @ 49:19f5e7133949

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