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.
24 # portably bring parameters beyond $9 into view
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
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}"`
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"
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 \
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
)
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
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
101 rm -f tmp-dec.h1 tmp-dec.h tmp-dec.c1 tmp-dec.c
102 fileopts
="$fileopts \
105 case "$extrafiles" in
106 ignored
) # Do nothing.
108 *) fileopts
="$fileopts $extrafiles"
114 ${cgen} ${cgendir}/cgen-sim.scm \
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
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
181 rm -f tmp-defs.h1 tmp-defs.h
183 ${cgen} ${cgendir}/cgen-sim.scm \
191 sed $sedscript < tmp-defs.h1
> tmp-defs.h
192 ${move_if_change} tmp-defs.h ${srcdir}/defs${suffix}.h
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 \
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