source: rtems/tools/build/multigen @ e6c3378

4.104.114.84.95
Last change on this file since e6c3378 was e6c3378, checked in by Joel Sherrill <joel.sherrill@…>, on 09/06/00 at 15:29:27

2000-09-06 Ralf Corsepius <corsepiu@…>

  • multigen: Fix usage.
  • Property mode set to 100755
File size: 3.3 KB
Line 
1#!/bin/sh
2
3# $Id$
4
5version=0.1
6verbose=0
7target=
8custom=0
9config=0
10
11usage()
12{
13program=`basename $0`
14cat << EOF
15
16$program generates RTEMS custom/*.cfgs and config-files for gcc multilib
17variants a target's gcc supports
18
19Usage: $program [options]
20
21Options:
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
30Examples:
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
40Written by Ralf Corsepius <corsepiu@faw.uni-ulm.de>
41EOF
42}
43
44while 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
76done
77
78if test $# -gt 0; then
79  echo "Invalid number of arguments"
80  exit 1
81fi
82
83if test x$target = x; then
84  echo "Missing required option:"
85  echo "        --target"
86  exit 1
87fi
88
89if test x$rtems_srcdir = x; then
90  echo "Missing required option:"
91  echo "        --rtems"
92  exit 1
93fi
94
95if 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
101fi
102
103if test ! -r $rtems_srcdir/VERSION; then
104  echo "Can't find rtems"
105  echo "Check value passed to --rtems=<DIR>"
106  exit 1
107fi
108
109if test x$target != x ;then
110target_prefix=$target-
111fi
112 
113# Check for CC
114saved_IFS=$IFS; IFS=":"
115for i in $PATH; do
116  if test -f $i/${target_prefix}gcc; then
117    CC=$i/${target_prefix}gcc
118    break
119  fi
120done
121IFS=$saved_IFS
122
123if test x$CC = x; then
124  echo "No valid gcc found"
125  exit 1
126fi
127test $verbose -gt 0 && echo "Using $CC"
128
129for 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
144cat << 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
154EOF
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"
161cat << EOF > $cfg
162#  Config file for the bare-$f BSP
163
164BARE_CPU_FLAGS=$flags
165BARE_CPU_MODEL=NONE
166
167include \$(RTEMS_ROOT)/make/custom/bare.cfg
168EOF
169
170  fi
171done
172
173exit 0
Note: See TracBrowser for help on using the repository browser.