1 | #!/bin/sh |
---|
2 | |
---|
3 | # $Id$ |
---|
4 | |
---|
5 | version=0.1 |
---|
6 | verbose=0 |
---|
7 | target= |
---|
8 | custom=0 |
---|
9 | config=0 |
---|
10 | |
---|
11 | usage() |
---|
12 | { |
---|
13 | program=`basename $0` |
---|
14 | cat << EOF |
---|
15 | |
---|
16 | $program generates RTEMS custom/*.cfgs and config-files for gcc multilib |
---|
17 | variants a target's gcc supports |
---|
18 | |
---|
19 | Usage: $program [options] |
---|
20 | |
---|
21 | Options: |
---|
22 | --target=STRING target |
---|
23 | --custom generate make/custom/*.cfg files |
---|
24 | --config generate config scripts |
---|
25 | --rtems=DIR use DIR as location of RTEMS source tree |
---|
26 | -v, --verbose verbose |
---|
27 | -h, --help Print this usage |
---|
28 | --version Print version and exit |
---|
29 | |
---|
30 | Examples: |
---|
31 | $program --config --target=sh-rtems --rtems=/usr/src/rtems-4.5.0 |
---|
32 | Generates config scripts for all possible bare BSPs from all |
---|
33 | valid multilib variants sh-rtems-gcc supports |
---|
34 | |
---|
35 | $program --custom --target=sh-rtems --rtems=/usr/src/rtems-4.5.0 |
---|
36 | Generates /usr/src/rtems-4.5.0/make/custom/*.cfg files |
---|
37 | for all possible bare BSPs from the multilib variants |
---|
38 | sh-rtems-gcc supports |
---|
39 | |
---|
40 | Written by Ralf Corsepius <corsepiu@faw.uni-ulm.de> |
---|
41 | EOF |
---|
42 | } |
---|
43 | |
---|
44 | while test $# -gt 0; do |
---|
45 | case "$1" in |
---|
46 | --rtems=*) |
---|
47 | rtems_srcdir=`echo "$1" | sed -e 's%--rtems=\(.*\)%\1%g'` |
---|
48 | ;; |
---|
49 | --target=*) |
---|
50 | target=`echo "$1" | sed -e 's%--target=\(.*\)%\1%g'` |
---|
51 | ;; |
---|
52 | -v|--verbose) |
---|
53 | verbose=1 |
---|
54 | ;; |
---|
55 | --custom) |
---|
56 | custom=1 |
---|
57 | ;; |
---|
58 | --config) |
---|
59 | config=1 |
---|
60 | ;; |
---|
61 | --version) |
---|
62 | echo `basename $0` version $version |
---|
63 | exit 0 |
---|
64 | ;; |
---|
65 | -h|--help) |
---|
66 | usage |
---|
67 | exit 1 |
---|
68 | ;; |
---|
69 | *) |
---|
70 | echo "unknown option $1" |
---|
71 | usage |
---|
72 | exit 1 |
---|
73 | ;; |
---|
74 | esac |
---|
75 | shift |
---|
76 | done |
---|
77 | |
---|
78 | if test $# -gt 0; then |
---|
79 | echo "Invalid number of arguments" |
---|
80 | exit 1 |
---|
81 | fi |
---|
82 | |
---|
83 | if test x$target = x; then |
---|
84 | echo "Missing required option:" |
---|
85 | echo " --target" |
---|
86 | exit 1 |
---|
87 | fi |
---|
88 | |
---|
89 | if test x$rtems_srcdir = x; then |
---|
90 | echo "Missing required option:" |
---|
91 | echo " --rtems" |
---|
92 | exit 1 |
---|
93 | fi |
---|
94 | |
---|
95 | if test $config -eq 0 && test $custom -eq 0; then |
---|
96 | echo "Missing required option:" |
---|
97 | echo " --config" |
---|
98 | echo " --custom" |
---|
99 | echo " (At least one of these is required)" |
---|
100 | exit 1 |
---|
101 | fi |
---|
102 | |
---|
103 | if test ! -r $rtems_srcdir/VERSION; then |
---|
104 | echo "Can't find rtems" |
---|
105 | echo "Check value passed to --rtems=<DIR>" |
---|
106 | exit 1 |
---|
107 | fi |
---|
108 | |
---|
109 | if test x$target != x ;then |
---|
110 | target_prefix=$target- |
---|
111 | fi |
---|
112 | |
---|
113 | # Check for CC |
---|
114 | saved_IFS=$IFS; IFS=":" |
---|
115 | for i in $PATH; do |
---|
116 | if test -f $i/${target_prefix}gcc; then |
---|
117 | CC=$i/${target_prefix}gcc |
---|
118 | break |
---|
119 | fi |
---|
120 | done |
---|
121 | IFS=$saved_IFS |
---|
122 | |
---|
123 | if test x$CC = x; then |
---|
124 | echo "No valid gcc found" |
---|
125 | exit 1 |
---|
126 | fi |
---|
127 | test $verbose -gt 0 && echo "Using $CC" |
---|
128 | |
---|
129 | for i in `${CC} --print-multi-lib 2>/dev/null`; do |
---|
130 | dir=`echo $i | sed -e 's/;.*$//'` |
---|
131 | case $dir in |
---|
132 | .) f=$target |
---|
133 | flags="" |
---|
134 | ;; |
---|
135 | *) f=`echo $target-$dir | sed -e 's%\/%-%g'` |
---|
136 | flags=`echo $i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'` |
---|
137 | ;; |
---|
138 | esac |
---|
139 | |
---|
140 | if test $config -gt 0; then |
---|
141 | cfg="rtems-config.$f" |
---|
142 | test $verbose -gt 0 && echo "Generating: $cfg" |
---|
143 | |
---|
144 | cat << EOF > $cfg |
---|
145 | #!/bin/sh |
---|
146 | |
---|
147 | ${rtems_srcdir}/configure --target=$target \\ |
---|
148 | '--enable-bare-cpu-cflags=$flags' \\ |
---|
149 | --enable-rtemsbsp="bare" \\ |
---|
150 | --enable-bare-cpu-model=NONE \\ |
---|
151 | --disable-networking \\ |
---|
152 | --disable-tests \\ |
---|
153 | --enable-maintainer-mode |
---|
154 | EOF |
---|
155 | chmod +x $cfg |
---|
156 | fi |
---|
157 | |
---|
158 | if test $custom -gt 0; then |
---|
159 | cfg=${rtems_srcdir}/make/custom/bare-$f.cfg |
---|
160 | test $verbose -gt 0 && echo "Generating: $cfg" |
---|
161 | cat << EOF > $cfg |
---|
162 | # Config file for the bare-$f BSP |
---|
163 | |
---|
164 | BARE_CPU_FLAGS=$flags |
---|
165 | BARE_CPU_MODEL=NONE |
---|
166 | |
---|
167 | include \$(RTEMS_ROOT)/make/custom/bare.cfg |
---|
168 | EOF |
---|
169 | |
---|
170 | fi |
---|
171 | done |
---|
172 | |
---|
173 | exit 0 |
---|