2 # Generate CGEN simulator files.
4 # Usage: /bin/sh cgen.sh {"arch"|"cpu"|"decode"} srcdir \
7 # arch archflags cpu mach suffix extrafiles
9 # We store the generated files in the source directory until we decide to
10 # ship a Scheme interpreter with gdb/binutils. Maybe we never will.
12 # We want to behave like make, any error forces us to stop.
28 lowercase='abcdefghijklmnopqrstuvwxyz'
29 uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
30 # FIXME: May have to rewrite this.
31 ARCH=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
32 CPU=`echo ${cpu} | tr "${lowercase}" "${uppercase}"`
34 rootdir=${srcdir}/../..
38 rm -f tmp-arch.h1 tmp-arch.h
39 rm -f tmp-arch.c1 tmp-arch.c
40 rm -f tmp-all.h1 tmp-all.h
42 ${scheme} ${schemeflags} ${cgendir}/cgen-sim.scm \
51 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-arch.h1 > tmp-arch.h
52 ${rootdir}/move-if-change tmp-arch.h ${srcdir}/arch.h
53 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-arch.c1 > tmp-arch.c
54 ${rootdir}/move-if-change tmp-arch.c ${srcdir}/arch.c
55 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-all.h1 > tmp-all.h
56 ${rootdir}/move-if-change tmp-all.h ${srcdir}/cpuall.h
58 rm -f tmp-arch.h1 tmp-arch.c1 tmp-all.h1
62 rm -f tmp-cpu.h1 tmp-ext.c1 tmp-read.c1 tmp-sem.c1 tmp-semsw.c1 tmp-mod.c1
63 rm -f tmp-cpu.h tmp-ext.c tmp-read.c tmp-sem.c tmp-semsw.c tmp-mod.c
65 ${scheme} ${schemeflags} ${cgendir}/cgen-sim.scm \
74 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-cpu.h1 > tmp-cpu.h
75 ${rootdir}/move-if-change tmp-cpu.h ${srcdir}/cpu${suffix}.h
76 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-mod.c1 > tmp-mod.c
77 ${rootdir}/move-if-change tmp-mod.c ${srcdir}/model${suffix}.c
78 if test -f tmp-ext.c1 ; then \
79 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-ext.c1 > tmp-ext.c ; \
80 ${rootdir}/move-if-change tmp-ext.c ${srcdir}/extract${suffix}.c ; \
82 if test -f tmp-read.c1 ; then \
83 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-read.c1 > tmp-read.c ; \
84 ${rootdir}/move-if-change tmp-read.c ${srcdir}/read${suffix}.c ; \
86 if test -f tmp-sem.c1 ; then \
87 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-sem.c1 > tmp-sem.c ; \
88 ${rootdir}/move-if-change tmp-sem.c ${srcdir}/sem${suffix}.c ; \
90 if test -f tmp-semsw.c1 ; then \
91 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-semsw.c1 > tmp-semsw.c ; \
92 ${rootdir}/move-if-change tmp-semsw.c ${srcdir}/sem${suffix}-switch.c ; \
95 rm -f tmp-cpu.h1 tmp-mod.c1
96 rm -f tmp-read.c1 tmp-ext.c1 tmp-sem.c1 tmp-semsw.c1
100 rm -f tmp-dec.h1 tmp-dec.h tmp-dec.c1 tmp-dec.c
102 ${scheme} ${schemeflags} ${cgendir}/cgen-sim.scm \
110 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-dec.h1 > tmp-dec.h
111 ${rootdir}/move-if-change tmp-dec.h ${srcdir}/decode${suffix}.h
112 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@CPU@/${CPU}/g" -e "s/@cpu@/${cpu}/g" < tmp-dec.c1 > tmp-dec.c
113 ${rootdir}/move-if-change tmp-dec.c ${srcdir}/decode${suffix}.c
115 rm -f tmp-dec.h1 tmp-dec.c1
119 echo "cgen.sh: bad action: ${action}" >&2