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