[bfd] Ensure unique printable names for bfd archs
[binutils-gdb.git] / opcodes / cgen.sh
index 08b606626c6e9674e968db5113eab75b7dcb5644..cf6a5f112a665de95270eee273864fcb3b0ca7af 100644 (file)
@@ -1,7 +1,7 @@
 #! /bin/sh
 # CGEN generic assembler support code.
 #
-#   Copyright (C) 2000-2018 Free Software Foundation, Inc.
+#   Copyright (C) 2000-2021 Free Software Foundation, Inc.
 #
 #   This file is part of the GNU opcodes library.
 #
@@ -175,6 +175,40 @@ opcodes)
        rm -f ${tmp}-asm.in1 ${tmp}-dis.in1
        ;;
 
+desc)
+       # For ports that only generate the desc module & opc header.
+       rm -f ${tmp}-desc.h1 ${tmp}-desc.h
+       rm -f ${tmp}-desc.c1 ${tmp}-desc.c
+       rm -f ${tmp}-opc.h1 ${tmp}-opc.h
+
+       ${cgen} ${cgendir}/cgen-opc.scm \
+               -s ${cgendir} \
+               ${cgenflags} \
+               -OPC ${opcfile} \
+               -f "${archflags}" \
+               -m all \
+               -a ${archfile} \
+               -i all \
+               -H ${tmp}-desc.h1 \
+               -C ${tmp}-desc.c1 \
+               -O ${tmp}-opc.h1
+
+       sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
+               -e "s/@prefix@/${prefix}/g" \
+               < ${tmp}-desc.h1 > ${tmp}-desc.h
+       ${rootdir}/move-if-change ${tmp}-desc.h ${srcdir}/${arch}-desc.h
+       sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
+               -e "s/@prefix@/${prefix}/g" \
+               < ${tmp}-desc.c1 > ${tmp}-desc.c
+       ${rootdir}/move-if-change ${tmp}-desc.c ${srcdir}/${arch}-desc.c
+       sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
+               -e "s/@prefix@/${prefix}/g" \
+               < ${tmp}-opc.h1 > ${tmp}-opc.h
+       ${rootdir}/move-if-change ${tmp}-opc.h ${srcdir}/${arch}-opc.h
+
+       rm -f ${tmp}-desc.h1 ${tmp}-desc.c1 ${tmp}-opc.h1
+       ;;
+
 *)
        echo "$0: bad action: ${action}" >&2
        exit 1