Index: ChangeLog
from BenoƮt Perrot <benoit(a)lrde.epita.fr>
Use a dedicated script to launch bison to control the directory
where the generated files are output.
* config/move-if-change, config/bison++: Provided by Akim Demaille.
* config/Makefile.am: Distribute them.
* src/parse/Makefile.am: Use bison++.
Index: src/parse/Makefile.am
--- src/parse/Makefile.am (revision 135)
+++ src/parse/Makefile.am (working copy)
@@ -30,18 +30,21 @@
@mv -f $@.tmp $@
asm-parse.yy: parse-asm-parse.stamp
-bison.stamp: asm-parse.yy
- @rm -rf $@.tmp
- @touch $@.tmp
- bison -S lalr1.cc -d -ra asm-parse.yy -o asm-parse.cc
- @mv -f $@.tmp $@
+
+BISONXX = $(top_srcdir)/config/bison++
+EXTRA_DIST = $(srcdir)/bison++.stamp
+$(srcdir)/bison++.stamp: $(srcdir)/asm-parse.yy
+ @rm -rf bison++.stamp.tmp
+ @touch bison++.stamp.tmp
+ $(BISONXX) $(srcdir) asm-parse.yy asm-parse.cc -d -ra
+ @mv -f bison++.stamp.tmp $@
# Run bison if a file that can be created by it is missing:
-asm-parse.cc $(FROM_ASM_PARSE_YY): bison.stamp
+$(srcdir)/asm-parse.cc $(FROM_ASM_PARSE_YY): $(srcdir)/bison++.stamp
@if test ! -f $@; then \
- @rm -f bison.stamp; \
- $(MAKE) $(AM_MAKEFLAGS) bison.stamp; \
+ rm -f $(srcdir)/bison++.stamp; \
+ $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/bison++.stamp; \
fi
MAINTAINERCLEANFILES = asm-scan.ll asm-scan.yy $(FROM_ASM_PARSE_YY)
Index: config/Makefile.am
--- config/Makefile.am (revision 135)
+++ config/Makefile.am (working copy)
@@ -1,6 +1,8 @@
## Makefile.am -- Process this file with automake to produce Makefile.in
##
+dist_noinst_SCRIPTS = move-if-change bison++
+
EXTRA_DIST = $(SPECIFIC_MACROS) $(STANDARD_MACROS) $(SPECIFIC_TOOLS)
MAINTAINERCLEANFILES = \
Index: config/bison++
--- config/bison++ (revision 0)
+++ config/bison++ (revision 136)
@@ -0,0 +1,49 @@
+#! /bin/sh
+
+# Any tool failure is a failure of the script.
+set -e
+
+# bison++ SRCDIR INPUT OUTPUT OPTIONS
+# -----------------------------------
+
+me=$(basename $0)
+auxdir=$(cd $(dirname $0) && pwd)
+
+srcdir=$1
+shift
+input=$1
+shift
+output=$1
+shift
+options="-S lalr1.cc $@"
+
+# Alexandre Duret-Lutz also notes that in VPATH-builds $(srcdir) can
+# be an absolute path depending on how ./configure is called ...
+# In that case
+
+# bison $(srcdir)/parsetiger.yy [...]
+
+# will hard code the path in the maintainer's tree. Hence, do not use
+# paths with Bison, chdir there.
+
+# A tmp dir.
+tmp=$output.dir
+rm -rf $tmp
+mkdir $tmp
+
+# Compile in this dir.
+# Don't use `ln -s' as its semantics of paths sucks.
+cp $srcdir/$input $tmp
+cd $tmp
+bison $options -S lalr1.cc $input -o $output
+for file in *
+do
+ case $file in
+ $input) ;;
+ *) $auxdir/move-if-change $file ../$srcdir/$file;;
+ esac
+done
+
+# Get rid of the tmp dir.
+cd ..
+rm -rf $tmp
Index: config/move-if-change
--- config/move-if-change (revision 0)
+++ config/move-if-change (revision 136)
@@ -0,0 +1,18 @@
+#!/bin/sh
+# Like mv $1 $2, but if the files are the same, just delete $1.
+# Status is 0 if $2 is changed, 1 otherwise.
+if
+test -r $2
+then
+if
+cmp -s $1 $2
+then
+echo $2 is unchanged
+rm -f $1
+else
+mv -f $1 $2
+fi
+else
+mv -f $1 $2
+fi
+
Show replies by date