Remove redundant call to listing_prev_line
[deliverable/binutils-gdb.git] / opcodes / cgen.sh
1 #! /bin/sh
2 # CGEN generic assembler support code.
3 #
4 # Copyright 2001 Free Software Foundation, Inc.
5 #
6 # This file is part of the GNU Binutils and GDB, the GNU debugger.
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
11 # any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along
19 # with this program; if not, write to the Free Software Foundation, Inc.,
20 # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 #
22 # Generate CGEN opcode files: arch-desc.[ch], arch-opc.[ch],
23 # arch-asm.c, arch-dis.c, arch-opinst.c, arch-ibld.[ch].
24 #
25 # Usage:
26 # cgen.sh action srcdir cgen cgendir cgenflags arch prefix options
27 #
28 # ACTION is currently always "opcodes". It exists to be consistent with the
29 # simulator.
30 # OPTIONS is comma separated list of options:
31 # - opinst - arch-opinst.c is being made, causes semantic analysis
32 #
33 # We store the generated files in the source directory until we decide to
34 # ship a Scheme interpreter (or other implementation) with gdb/binutils.
35 # Maybe we never will.
36
37 # We want to behave like make, any error forces us to stop.
38 set -e
39
40 action=$1
41 srcdir=$2
42 cgen=$3
43 cgendir=$4
44 cgenflags=$5
45 arch=$6
46 prefix=$7
47 options=$8
48
49 # List of extra files to build.
50 # Values: opinst (only 1 extra file at present)
51 extrafiles=$9
52
53 rootdir=${srcdir}/..
54
55 # $arch is $6, as passed on the command line.
56 # $ARCH is the same argument but in all uppercase.
57 # Both forms are used in this script.
58
59 lowercase='abcdefghijklmnopqrstuvwxyz'
60 uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
61 ARCH=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
62
63 extrafile_args=""
64 for ef in .. $extrafiles
65 do
66 case $ef in
67 ..) ;;
68 opinst) extrafile_args="-Q tmp-opinst.c1 $extrafile_args" ;;
69 esac
70 done
71
72 case $action in
73 opcodes)
74 # Remove residual working files.
75 rm -f tmp-desc.h tmp-desc.h1
76 rm -f tmp-desc.c tmp-desc.c1
77 rm -f tmp-opc.h tmp-opc.h1
78 rm -f tmp-opc.c tmp-opc.c1
79 rm -f tmp-opinst.c tmp-opinst.c1
80 rm -f tmp-ibld.h tmp-ibld.h1
81 rm -f tmp-ibld.c tmp-ibld.in1
82 rm -f tmp-asm.c tmp-asm.in1
83 rm -f tmp-dis.c tmp-dis.in1
84
85 # Run CGEN.
86 ${cgen} -s ${cgendir}/cgen-opc.scm \
87 -s ${cgendir} \
88 ${cgenflags} \
89 -f "${options}" \
90 -m all \
91 -a ${arch} \
92 -H tmp-desc.h1 \
93 -C tmp-desc.c1 \
94 -O tmp-opc.h1 \
95 -P tmp-opc.c1 \
96 -L tmp-ibld.in1 \
97 -A tmp-asm.in1 \
98 -D tmp-dis.in1 \
99 ${extrafile_args}
100
101 # Customise generated files for the particular architecture.
102 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-desc.h1 > tmp-desc.h
103 ${rootdir}/move-if-change tmp-desc.h ${srcdir}/${prefix}-desc.h
104
105 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
106 -e "s/@prefix@/${prefix}/" < tmp-desc.c1 > tmp-desc.c
107 ${rootdir}/move-if-change tmp-desc.c ${srcdir}/${prefix}-desc.c
108
109 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-opc.h1 > tmp-opc.h
110 ${rootdir}/move-if-change tmp-opc.h ${srcdir}/${prefix}-opc.h
111
112 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
113 -e "s/@prefix@/${prefix}/" < tmp-opc.c1 > tmp-opc.c
114 ${rootdir}/move-if-change tmp-opc.c ${srcdir}/${prefix}-opc.c
115
116 case $extrafiles in
117 *opinst*)
118 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
119 -e "s/@prefix@/${prefix}/" < tmp-opinst.c1 >tmp-opinst.c
120 ${rootdir}/move-if-change tmp-opinst.c ${srcdir}/${prefix}-opinst.c
121 ;;
122 esac
123
124 cat ${srcdir}/cgen-ibld.in tmp-ibld.in1 | \
125 sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
126 -e "s/@prefix@/${prefix}/" > tmp-ibld.c
127 ${rootdir}/move-if-change tmp-ibld.c ${srcdir}/${prefix}-ibld.c
128
129 sed -e "/ -- assembler routines/ r tmp-asm.in1" ${srcdir}/cgen-asm.in \
130 | sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
131 -e "s/@prefix@/${prefix}/" > tmp-asm.c
132 ${rootdir}/move-if-change tmp-asm.c ${srcdir}/${prefix}-asm.c
133
134 sed -e "/ -- disassembler routines/ r tmp-dis.in1" ${srcdir}/cgen-dis.in \
135 | sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
136 -e "s/@prefix@/${prefix}/" > tmp-dis.c
137 ${rootdir}/move-if-change tmp-dis.c ${srcdir}/${prefix}-dis.c
138
139 # Remove temporary files.
140 rm -f tmp-desc.h1 tmp-desc.c1
141 rm -f tmp-opc.h1 tmp-opc.c1
142 rm -f tmp-opinst.c1
143 rm -f tmp-ibld.h1 tmp-ibld.in1
144 rm -f tmp-asm.in1 tmp-dis.in1
145 ;;
146
147 *)
148 echo "$0: bad action: ${action}" >&2
149 exit 1
150 ;;
151
152 esac
153
154 exit 0
This page took 0.03501 seconds and 4 git commands to generate.