This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] cgen.sh: Handle multiple simultaneous runs for parallel makes.


Hi.

This patch is straightforward.
It allows parallel runs of cgen.
Tested with "make -j3 stamp-{x,y,z}" for various cgen ports.

Ok to check in?

2009-06-09  Doug Evans  <dje@sebabeach.org>

	* cgen.sh: Handle multiple simultaneous runs for parallel makes.

Index: cgen.sh
===================================================================
RCS file: /cvs/src/src/opcodes/cgen.sh,v
retrieving revision 1.7
diff -u -p -d -u -r1.7 cgen.sh
--- cgen.sh	5 Jul 2007 09:49:00 -0000	1.7
+++ cgen.sh	10 Jun 2009 18:08:13 -0000
@@ -1,7 +1,7 @@
 #! /bin/sh
 # CGEN generic assembler support code.
 #
-#   Copyright 2000, 2003, 2005, 2007 Free Software Foundation, Inc.
+#   Copyright 2000, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
 #
 #   This file is part of the GNU opcodes library.
 #
@@ -70,27 +70,30 @@ lowercase='abcdefghijklmnopqrstuvwxyz'
 uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
 ARCH=`echo ${arch} | tr "${lowercase}" "${uppercase}"`
 
+# Allow parallel makes to run multiple cgen's without colliding.
+tmp=tmp-$$
+
 extrafile_args=""
 for ef in .. $extrafiles
 do
     case $ef in
     ..) ;;
-    opinst) extrafile_args="-Q tmp-opinst.c1 $extrafile_args" ;;
+    opinst) extrafile_args="-Q ${tmp}-opinst.c1 $extrafile_args" ;;
     esac
 done
 
 case $action in
 opcodes)
 	# Remove residual working files.
-	rm -f tmp-desc.h tmp-desc.h1
-	rm -f tmp-desc.c tmp-desc.c1
-	rm -f tmp-opc.h tmp-opc.h1
-	rm -f tmp-opc.c tmp-opc.c1
-	rm -f tmp-opinst.c tmp-opinst.c1
-	rm -f tmp-ibld.h tmp-ibld.h1
-	rm -f tmp-ibld.c tmp-ibld.in1
-	rm -f tmp-asm.c tmp-asm.in1
-	rm -f tmp-dis.c tmp-dis.in1
+	rm -f ${tmp}-desc.h ${tmp}-desc.h1
+	rm -f ${tmp}-desc.c ${tmp}-desc.c1
+	rm -f ${tmp}-opc.h ${tmp}-opc.h1
+	rm -f ${tmp}-opc.c ${tmp}-opc.c1
+	rm -f ${tmp}-opinst.c ${tmp}-opinst.c1
+	rm -f ${tmp}-ibld.h ${tmp}-ibld.h1
+	rm -f ${tmp}-ibld.c ${tmp}-ibld.in1
+	rm -f ${tmp}-asm.c ${tmp}-asm.in1
+	rm -f ${tmp}-dis.c ${tmp}-dis.in1
 
 	# Run CGEN.
 	${cgen} ${cgendir}/cgen-opc.scm \
@@ -100,59 +103,59 @@ opcodes)
 		-m all \
 		-a ${archfile} \
 	        -OPC ${opcfile} \
-		-H tmp-desc.h1 \
-		-C tmp-desc.c1 \
-		-O tmp-opc.h1 \
-		-P tmp-opc.c1 \
-		-L tmp-ibld.in1 \
-		-A tmp-asm.in1 \
-		-D tmp-dis.in1 \
+		-H ${tmp}-desc.h1 \
+		-C ${tmp}-desc.c1 \
+		-O ${tmp}-opc.h1 \
+		-P ${tmp}-opc.c1 \
+		-L ${tmp}-ibld.in1 \
+		-A ${tmp}-asm.in1 \
+		-D ${tmp}-dis.in1 \
 		${extrafile_args}
 
 	# Customise generated files for the particular architecture.
-	sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-desc.h1 > tmp-desc.h
-	${rootdir}/move-if-change tmp-desc.h ${srcdir}/${prefix}-desc.h
+	sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < ${tmp}-desc.h1 > ${tmp}-desc.h
+	${rootdir}/move-if-change ${tmp}-desc.h ${srcdir}/${prefix}-desc.h
 
 	sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
-		-e "s/@prefix@/${prefix}/" < tmp-desc.c1 > tmp-desc.c
-	${rootdir}/move-if-change tmp-desc.c ${srcdir}/${prefix}-desc.c
+		-e "s/@prefix@/${prefix}/" < ${tmp}-desc.c1 > ${tmp}-desc.c
+	${rootdir}/move-if-change ${tmp}-desc.c ${srcdir}/${prefix}-desc.c
 
-	sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < tmp-opc.h1 > tmp-opc.h
-	${rootdir}/move-if-change tmp-opc.h ${srcdir}/${prefix}-opc.h
+	sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" < ${tmp}-opc.h1 > ${tmp}-opc.h
+	${rootdir}/move-if-change ${tmp}-opc.h ${srcdir}/${prefix}-opc.h
 
 	sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
-		-e "s/@prefix@/${prefix}/" < tmp-opc.c1 > tmp-opc.c
-	${rootdir}/move-if-change tmp-opc.c ${srcdir}/${prefix}-opc.c
+		-e "s/@prefix@/${prefix}/" < ${tmp}-opc.c1 > ${tmp}-opc.c
+	${rootdir}/move-if-change ${tmp}-opc.c ${srcdir}/${prefix}-opc.c
 
 	case $extrafiles in
 	*opinst*)
 	  sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
-		-e "s/@prefix@/${prefix}/" < tmp-opinst.c1 >tmp-opinst.c
-	  ${rootdir}/move-if-change tmp-opinst.c ${srcdir}/${prefix}-opinst.c
+		-e "s/@prefix@/${prefix}/" < ${tmp}-opinst.c1 >${tmp}-opinst.c
+	  ${rootdir}/move-if-change ${tmp}-opinst.c ${srcdir}/${prefix}-opinst.c
 	  ;;
 	esac
 
-	cat ${srcdir}/cgen-ibld.in tmp-ibld.in1 | \
+	cat ${srcdir}/cgen-ibld.in ${tmp}-ibld.in1 | \
 	  sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
-		-e "s/@prefix@/${prefix}/" > tmp-ibld.c
-	${rootdir}/move-if-change tmp-ibld.c ${srcdir}/${prefix}-ibld.c
+		-e "s/@prefix@/${prefix}/" > ${tmp}-ibld.c
+	${rootdir}/move-if-change ${tmp}-ibld.c ${srcdir}/${prefix}-ibld.c
 
-	sed -e "/ -- assembler routines/ r tmp-asm.in1" ${srcdir}/cgen-asm.in \
+	sed -e "/ -- assembler routines/ r ${tmp}-asm.in1" ${srcdir}/cgen-asm.in \
 	  | sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
-		-e "s/@prefix@/${prefix}/" > tmp-asm.c
-	${rootdir}/move-if-change tmp-asm.c ${srcdir}/${prefix}-asm.c
+		-e "s/@prefix@/${prefix}/" > ${tmp}-asm.c
+	${rootdir}/move-if-change ${tmp}-asm.c ${srcdir}/${prefix}-asm.c
 
-	sed -e "/ -- disassembler routines/ r tmp-dis.in1" ${srcdir}/cgen-dis.in \
+	sed -e "/ -- disassembler routines/ r ${tmp}-dis.in1" ${srcdir}/cgen-dis.in \
 	  | sed -e "s/@ARCH@/${ARCH}/g" -e "s/@arch@/${arch}/g" \
-		-e "s/@prefix@/${prefix}/" > tmp-dis.c
-	${rootdir}/move-if-change tmp-dis.c ${srcdir}/${prefix}-dis.c
+		-e "s/@prefix@/${prefix}/" > ${tmp}-dis.c
+	${rootdir}/move-if-change ${tmp}-dis.c ${srcdir}/${prefix}-dis.c
 
 	# Remove temporary files.
-	rm -f tmp-desc.h1 tmp-desc.c1
-	rm -f tmp-opc.h1 tmp-opc.c1
-	rm -f tmp-opinst.c1
-	rm -f tmp-ibld.h1 tmp-ibld.in1
-	rm -f tmp-asm.in1 tmp-dis.in1
+	rm -f ${tmp}-desc.h1 ${tmp}-desc.c1
+	rm -f ${tmp}-opc.h1 ${tmp}-opc.c1
+	rm -f ${tmp}-opinst.c1
+	rm -f ${tmp}-ibld.h1 ${tmp}-ibld.in1
+	rm -f ${tmp}-asm.in1 ${tmp}-dis.in1
 	;;
 
 *)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]