annotate scripts/mk-component-gcc.sh @ 158:8fe0cde2fd79

doc/Compiling: update for SE J100 target and fc-host-tools-r10
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 17 Mar 2019 07:20:28 +0000
parents 2106617f1291
children
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
140
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
82 cfile_symlink() {
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
83 if [ $# != 1 ]
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
84 then
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
85 echo "Error: cfile_symlink takes 1 argument" 1>&2
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
86 exit 1
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
87 fi
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
88 localcopy=`basename "$1"`
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
89 echo "$localcopy:" >> $BUILD_DIR/$LIBNAME/Makefile
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
90 echo " ln -s $1 ." >> $BUILD_DIR/$LIBNAME/Makefile
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
91 echo >> $BUILD_DIR/$LIBNAME/Makefile
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
92 c_file $localcopy
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
93 }
2106617f1291 scripts/mk-component*: added cfile_symlink function like in Magnetite
Mychaela Falconia <falcon@freecalypso.org>
parents: 49
diff changeset
94
49
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 # invoke the recipe
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 COMPILER=gcc
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 SRC=../../src
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 OBJS=
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 MMI=0
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 . "$recipe_file"
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 # finish the Makefile
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 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
106 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
107 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
108 echo >> $BUILD_DIR/$LIBNAME/Makefile
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 echo 'clean:' >> $BUILD_DIR/$LIBNAME/Makefile
19f5e7133949 scripts/mk-component-gcc.sh: initial version created
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 echo ' rm -f *.[oa] *.c' >> $BUILD_DIR/$LIBNAME/Makefile