2 # Generate CGEN opcode files: arch-desc.[ch], arch-opc.[ch],
3 # arch-asm.c, arch-dis.c, arch-opinst.c, arch-ibld.[ch].
6 # cgen.sh action srcdir cgen cgendir cgenflags arch prefix options
8 # ACTION is currently always "opcodes". It exists to be consistent with the
10 # OPTIONS is comma separated list of options:
11 # - opinst - arch-opinst.c is being made, causes semantic analysis
13 # We store the generated files in the source directory until we decide to
14 # ship a Scheme interpreter (or other implementation) with gdb/binutils.
15 # Maybe we never will.
17 # We want to behave like make, any error forces us to stop.
29 # List of extra files to build.
30 # Values: opinst (only 1 extra file at present)
35 # $arch is $6, as passed on the command line.
36 # $ARCH is the same argument but in all uppercase.
37 # Both forms are used in this script.
39 lowercase
='abcdefghijklmnopqrstuvwxyz'
40 uppercase
='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
41 ARCH
=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
44 for ef
in ..
$extrafiles
48 opinst
) extrafile_args
="-Q tmp-opinst.c1 $extrafile_args" ;;
54 # Remove residual working files.
55 rm -f tmp-desc.h tmp-desc.h1
56 rm -f tmp-desc.c tmp-desc.c1
57 rm -f tmp-opc.h tmp-opc.h1
58 rm -f tmp-opc.c tmp-opc.c1
59 rm -f tmp-opinst.c tmp-opinst.c1
60 rm -f tmp-ibld.h tmp-ibld.h1
61 rm -f tmp-ibld.c tmp-ibld.in1
62 rm -f tmp-asm.c tmp-asm.in1
63 rm -f tmp-dis.c tmp-dis.in1
66 ${cgen} -s ${cgendir}/cgen-opc.scm \
81 # Customise generated files for the particular architecture.
82 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-desc.h1
> tmp-desc.h
83 ${rootdir}/move-if-change tmp-desc.h ${srcdir}/${prefix}-desc.h
85 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
86 -e "s/@prefix@/${prefix}/" < tmp-desc.c1
> tmp-desc.c
87 ${rootdir}/move-if-change tmp-desc.c ${srcdir}/${prefix}-desc.c
89 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-opc.h1
> tmp-opc.h
90 ${rootdir}/move-if-change tmp-opc.h ${srcdir}/${prefix}-opc.h
92 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
93 -e "s/@prefix@/${prefix}/" < tmp-opc.c1
> tmp-opc.c
94 ${rootdir}/move-if-change tmp-opc.c ${srcdir}/${prefix}-opc.c
98 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
99 -e "s/@prefix@/${prefix}/" < tmp-opinst.c1
>tmp-opinst.c
100 ${rootdir}/move-if-change tmp-opinst.c ${srcdir}/${prefix}-opinst.c
104 cat ${srcdir}/cgen-ibld.
in tmp-ibld.in1 | \
105 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
106 -e "s/@prefix@/${prefix}/" > tmp-ibld.c
107 ${rootdir}/move-if-change tmp-ibld.c ${srcdir}/${prefix}-ibld.c
109 sed -e "/ -- assembler routines/ r tmp-asm.in1" ${srcdir}/cgen-asm.
in \
110 |
sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
111 -e "s/@prefix@/${prefix}/" > tmp-asm.c
112 ${rootdir}/move-if-change tmp-asm.c ${srcdir}/${prefix}-asm.c
114 sed -e "/ -- disassembler routines/ r tmp-dis.in1" ${srcdir}/cgen-dis.
in \
115 |
sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
116 -e "s/@prefix@/${prefix}/" > tmp-dis.c
117 ${rootdir}/move-if-change tmp-dis.c ${srcdir}/${prefix}-dis.c
119 # Remove temporary files.
120 rm -f tmp-desc.h1 tmp-desc.c1
121 rm -f tmp-opc.h1 tmp-opc.c1
123 rm -f tmp-ibld.h1 tmp-ibld.in1
124 rm -f tmp-asm.in1 tmp-dis.in1
128 echo "$0: bad action: ${action}" >&2