2 # Generate CGEN simulator files.
4 # Usage: /bin/sh cgen.sh {"arch"|"cpu"|"decode"|"cpu-decode"} srcdir \
5 # cgen cgendir cgenflags \
6 # arch archflags cpu mach suffix extrafiles
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 # bring parms past 9 portably into view
28 rootdir
=${srcdir}/..
/..
30 lowercase
='abcdefghijklmnopqrstuvwxyz'
31 uppercase
='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
32 ARCH
=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
33 CPU
=`echo ${cpu} | tr "${lowercase}" "${uppercase}"`
37 rm -f tmp-arch.h1 tmp-arch.h
38 rm -f tmp-arch.c1 tmp-arch.c
39 rm -f tmp-all.h1 tmp-all.h
41 ${cgen} -s ${cgendir}/cgen-sim.scm \
50 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-arch.h1
> tmp-arch.h
51 ${rootdir}/move-if-change tmp-arch.h
${srcdir}/arch.h
52 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-arch.c1
> tmp-arch.c
53 ${rootdir}/move-if-change tmp-arch.c
${srcdir}/arch.c
54 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-all.h1
> tmp-all.h
55 ${rootdir}/move-if-change tmp-all.h
${srcdir}/cpuall.h
57 rm -f tmp-arch.h1 tmp-arch.c1 tmp-all.h1
60 cpu | decode | cpu-decode
)
65 rm -f tmp-cpu.h1 tmp-cpu.c1
66 rm -f tmp-ext.c1 tmp-read.c1 tmp-write.c1
67 rm -f tmp-sem.c1 tmp-semsw.c1
69 rm -f tmp-cpu.h tmp-cpu.c
70 rm -f tmp-ext.c tmp-read.c tmp-write.c
71 rm -f tmp-sem.c tmp-semsw.c tmp-mod.c
81 rm -f tmp-dec.h1 tmp-dec.h tmp-dec.c1 tmp-dec.c
88 ${cgen} -s ${cgendir}/cgen-sim.scm \
98 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-cpu.h1
> tmp-cpu.h
99 ${rootdir}/move-if-change tmp-cpu.h ${srcdir}/cpu${suffix}.h
100 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-cpu.c1
> tmp-cpu.c
101 ${rootdir}/move-if-change tmp-cpu.c ${srcdir}/cpu${suffix}.c
102 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-mod.c1
> tmp-mod.c
103 ${rootdir}/move-if-change tmp-mod.c ${srcdir}/model${suffix}.c
104 if test -f tmp-ext.c1
; then \
105 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-ext.c1
> tmp-ext.c
; \
106 ${rootdir}/move-if-change tmp-ext.c ${srcdir}/extract${suffix}.c
; \
108 if test -f tmp-read.c1
; then \
109 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-read.c1
> tmp-read.c
; \
110 ${rootdir}/move-if-change tmp-read.c ${srcdir}/read${suffix}.c
; \
112 if test -f tmp-write.c1
; then \
113 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-write.c1
> tmp-write.c
; \
114 ${rootdir}/move-if-change tmp-write.c ${srcdir}/write${suffix}.c
; \
116 if test -f tmp-sem.c1
; then \
117 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-sem.c1
> tmp-sem.c
; \
118 ${rootdir}/move-if-change tmp-sem.c ${srcdir}/sem${suffix}.c
; \
120 if test -f tmp-semsw.c1
; then \
121 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-semsw.c1
> tmp-semsw.c
; \
122 ${rootdir}/move-if-change tmp-semsw.c ${srcdir}/sem${suffix}-switch.c
; \
125 rm -f tmp-cpu.h1 tmp-cpu.c1
126 rm -f tmp-ext.c1 tmp-read.c1 tmp-write.c1
127 rm -f tmp-sem.c1 tmp-semsw.c1 tmp-mod.c1
133 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-dec.h1
> tmp-dec.h
134 ${rootdir}/move-if-change tmp-dec.h ${srcdir}/decode${suffix}.h
135 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-dec.c1
> tmp-dec.c
136 ${rootdir}/move-if-change tmp-dec.c ${srcdir}/decode${suffix}.c
138 rm -f tmp-dec.h1 tmp-dec.c1
145 rm -f tmp-desc.h1 tmp-desc.h
146 rm -f tmp-desc.c1 tmp-desc.c
147 rm -f tmp-opc.h1 tmp-opc.h
149 ${cgen} -s ${cgendir}/cgen-opc.scm \
158 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-desc.h1
> tmp-desc.h
159 ${rootdir}/move-if-change tmp-desc.h ${srcdir}/${arch}-desc.h
160 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
161 -e "s/@prefix@/${arch}/" < tmp-desc.c1
> tmp-desc.c
162 ${rootdir}/move-if-change tmp-desc.c ${srcdir}/${arch}-desc.c
163 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-opc.h1
> tmp-opc.h
164 ${rootdir}/move-if-change tmp-opc.h ${srcdir}/${arch}-opc.h
166 rm -f tmp-desc.h1 tmp-desc.c1 tmp-opc.h1
170 echo "cgen.sh: bad action: ${action}" >&2