No empty .Rs/.Re
[netbsd-mini2440.git] / gnu / dist / gdb6 / sim / common / cgen.sh
blob432c533753f175c54d64f8bee43537aa8194fa80
1 #! /bin/sh
2 # Generate CGEN simulator files.
4 # Usage: /bin/sh cgen.sh {"arch"|"cpu"|"decode"|"defs"|"cpu-decode"} \
5 # srcdir cgen cgendir cgenflags \
6 # arch archflags cpu mach suffix archfile extrafiles opcfile
8 # We store the generated files in the source directory until we decide to
9 # ship a Scheme interpreter (or other implementation) with gdb/binutils.
10 # Maybe we never will.
12 # We want to behave like make, any error forces us to stop.
13 set -e
15 action=$1
16 srcdir=$2
17 cgen="$3"
18 cgendir=$4
19 cgenflags=$5
20 arch=$6
21 archflags=$7
22 cpu=$8
23 isa=$9
24 # portably bring parameters beyond $9 into view
25 shift ; mach=$9
26 shift ; suffix=$9
27 shift ; archfile=$9
28 shift ; extrafiles=$9
29 shift ; opcfile=$9
31 rootdir=${srcdir}/../..
32 move_if_change="${CONFIG_SHELL:-/bin/sh} ${rootdir}/move-if-change"
34 test -z "${opcfile}" && opcfile=/dev/null
36 if test -z "$isa" ; then
37 isa=all
38 prefix=$cpu
39 else
40 prefix=${cpu}_$isa
43 lowercase='abcdefghijklmnopqrstuvwxyz'
44 uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
45 ARCH=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
46 CPU=`echo ${cpu} | tr "${lowercase}" "${uppercase}"`
47 PREFIX=`echo ${prefix} | tr "${lowercase}" "${uppercase}"`
49 sedscript="\
50 -e s/@ARCH@/${ARCH}/g -e s/@arch@/${arch}/g \
51 -e s/@CPU@/${CPU}/g -e s/@cpu@/${cpu}/g \
52 -e s/@PREFIX@/${PREFIX}/g -e s/@prefix@/${prefix}/g"
54 case $action in
55 arch)
56 rm -f tmp-arch.h1 tmp-arch.h
57 rm -f tmp-arch.c1 tmp-arch.c
58 rm -f tmp-all.h1 tmp-all.h
60 ${cgen} ${cgendir}/cgen-sim.scm \
61 -s ${cgendir} \
62 ${cgenflags} \
63 -f "${archflags}" \
64 -m ${mach} \
65 -a ${archfile} \
66 -i ${isa} \
67 -A tmp-arch.h1 \
68 -B tmp-arch.c1 \
69 -N tmp-all.h1
70 sed $sedscript < tmp-arch.h1 > tmp-arch.h
71 ${move_if_change} tmp-arch.h ${srcdir}/arch.h
72 sed $sedscript < tmp-arch.c1 > tmp-arch.c
73 ${move_if_change} tmp-arch.c ${srcdir}/arch.c
74 sed $sedscript < tmp-all.h1 > tmp-all.h
75 ${move_if_change} tmp-all.h ${srcdir}/cpuall.h
77 rm -f tmp-arch.h1 tmp-arch.c1 tmp-all.h1
80 cpu | decode | cpu-decode)
82 fileopts=""
83 case $action in
84 *cpu*)
85 rm -f tmp-cpu.h1 tmp-cpu.c1
86 rm -f tmp-ext.c1 tmp-read.c1 tmp-write.c1
87 rm -f tmp-sem.c1 tmp-semsw.c1
88 rm -f tmp-mod.c1
89 rm -f tmp-cpu.h tmp-cpu.c
90 rm -f tmp-ext.c tmp-read.c tmp-write.c
91 rm -f tmp-sem.c tmp-semsw.c tmp-mod.c
92 fileopts="$fileopts \
93 -C tmp-cpu.h1 \
94 -U tmp-cpu.c1 \
95 -M tmp-mod.c1 \
96 ${extrafiles}"
98 esac
99 case $action in
100 *decode*)
101 rm -f tmp-dec.h1 tmp-dec.h tmp-dec.c1 tmp-dec.c
102 fileopts="$fileopts \
103 -T tmp-dec.h1 \
104 -D tmp-dec.c1"
105 case "$extrafiles" in
106 ignored) # Do nothing.
108 *) fileopts="$fileopts $extrafiles"
110 esac
112 esac
114 ${cgen} ${cgendir}/cgen-sim.scm \
115 -s ${cgendir} \
116 ${cgenflags} \
117 -f "${archflags}" \
118 -m ${mach} \
119 -a ${archfile} \
120 -i ${isa} \
121 ${fileopts}
123 case $action in
124 *cpu*)
125 sed $sedscript < tmp-cpu.h1 > tmp-cpu.h
126 ${move_if_change} tmp-cpu.h ${srcdir}/cpu${suffix}.h
127 sed $sedscript < tmp-cpu.c1 > tmp-cpu.c
128 ${move_if_change} tmp-cpu.c ${srcdir}/cpu${suffix}.c
129 sed $sedscript < tmp-mod.c1 > tmp-mod.c
130 ${move_if_change} tmp-mod.c ${srcdir}/model${suffix}.c
131 if test -f tmp-ext.c1 ; then \
132 sed $sedscript < tmp-ext.c1 > tmp-ext.c ; \
133 ${move_if_change} tmp-ext.c ${srcdir}/extract${suffix}.c ; \
135 if test -f tmp-read.c1 ; then \
136 sed $sedscript < tmp-read.c1 > tmp-read.c ; \
137 ${move_if_change} tmp-read.c ${srcdir}/read${suffix}.c ; \
139 if test -f tmp-write.c1 ; then \
140 sed $sedscript < tmp-write.c1 > tmp-write.c ; \
141 ${move_if_change} tmp-write.c ${srcdir}/write${suffix}.c ; \
143 if test -f tmp-sem.c1 ; then \
144 sed $sedscript < tmp-sem.c1 > tmp-sem.c ; \
145 ${move_if_change} tmp-sem.c ${srcdir}/sem${suffix}.c ; \
147 if test -f tmp-semsw.c1 ; then \
148 sed $sedscript < tmp-semsw.c1 > tmp-semsw.c ; \
149 ${move_if_change} tmp-semsw.c ${srcdir}/sem${suffix}-switch.c ; \
152 rm -f tmp-cpu.h1 tmp-cpu.c1
153 rm -f tmp-ext.c1 tmp-read.c1 tmp-write.c1
154 rm -f tmp-sem.c1 tmp-semsw.c1 tmp-mod.c1
156 esac
158 case $action in
159 *decode*)
160 sed $sedscript < tmp-dec.h1 > tmp-dec.h
161 ${move_if_change} tmp-dec.h ${srcdir}/decode${suffix}.h
162 sed $sedscript < tmp-dec.c1 > tmp-dec.c
163 ${move_if_change} tmp-dec.c ${srcdir}/decode${suffix}.c
165 if test -f tmp-sem.c1 ; then \
166 sed $sedscript < tmp-sem.c1 > tmp-sem.c ; \
167 ${move_if_change} tmp-sem.c ${srcdir}/sem${suffix}.c ; \
169 if test -f tmp-semsw.c1 ; then \
170 sed $sedscript < tmp-semsw.c1 > tmp-semsw.c ; \
171 ${move_if_change} tmp-semsw.c ${srcdir}/sem${suffix}-switch.c ; \
174 rm -f tmp-dec.h1 tmp-dec.c1
176 esac
180 defs)
181 rm -f tmp-defs.h1 tmp-defs.h
183 ${cgen} ${cgendir}/cgen-sim.scm \
184 -s ${cgendir} \
185 ${cgenflags} \
186 -f "${archflags}" \
187 -m ${mach} \
188 -a ${archfile} \
189 -i ${isa} \
190 -G tmp-defs.h1
191 sed $sedscript < tmp-defs.h1 > tmp-defs.h
192 ${move_if_change} tmp-defs.h ${srcdir}/defs${suffix}.h
195 desc)
196 rm -f tmp-desc.h1 tmp-desc.h
197 rm -f tmp-desc.c1 tmp-desc.c
198 rm -f tmp-opc.h1 tmp-opc.h
200 ${cgen} ${cgendir}/cgen-opc.scm \
201 -s ${cgendir} \
202 ${cgenflags} \
203 -OPC ${opcfile} \
204 -f "${archflags}" \
205 -m ${mach} \
206 -a ${archfile} \
207 -i ${isa} \
208 -H tmp-desc.h1 \
209 -C tmp-desc.c1 \
210 -O tmp-opc.h1
211 sed $sedscript < tmp-desc.h1 > tmp-desc.h
212 ${move_if_change} tmp-desc.h ${srcdir}/${arch}-desc.h
213 sed $sedscript < tmp-desc.c1 > tmp-desc.c
214 ${move_if_change} tmp-desc.c ${srcdir}/${arch}-desc.c
215 sed $sedscript < tmp-opc.h1 > tmp-opc.h
216 ${move_if_change} tmp-opc.h ${srcdir}/${arch}-opc.h
218 rm -f tmp-desc.h1 tmp-desc.c1 tmp-opc.h1
222 echo "`basename $0`: unknown action: ${action}" >&2
223 exit 1
226 esac
228 exit 0