summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <demaille@gostai.com>2012-02-22 14:42:39 +0100
committerAkim Demaille <demaille@gostai.com>2012-02-24 07:58:09 +0100
commitdac70b43a0fd90d2470873fb80b261c345944dd3 (patch)
tree3982fd623351bab1b03a635dc23c92a02dd49f6d
parent53645905ea763faa4ec9d28260894c476a19b38e (diff)
downloadbison-next.tar.gz
calc++: don't rely on Automake to compile a C++ parser.next
Basically, revert commit 609b3d8096fb0cc1fa4d908b6e1a860ced260bda, it is currently too hard to use Automake to leave the extracted and generated files in the src tree. * examples/calc++/calc++-parser.hh: Remove. * examples/calc++/local.mk (examples/calc++/calc++-parser.stamp): New.
-rw-r--r--examples/calc++/.gitignore5
-rw-r--r--examples/calc++/calc++-parser.hh4
-rw-r--r--examples/calc++/local.mk74
3 files changed, 54 insertions, 29 deletions
diff --git a/examples/calc++/.gitignore b/examples/calc++/.gitignore
index 2306d175..50eb5ba1 100644
--- a/examples/calc++/.gitignore
+++ b/examples/calc++/.gitignore
@@ -4,10 +4,11 @@
/calc++
/calc++-driver.cc
/calc++-driver.hh
+/calc++-parser.cc
+/calc++-parser.hh
/calc++-parser.output
+/calc++-parser.stamp
/calc++-parser.yy
-/calc++-parser.cc
-/calc++-parser.h
/calc++-scanner.cc
/calc++-scanner.ll
/calc++.cc
diff --git a/examples/calc++/calc++-parser.hh b/examples/calc++/calc++-parser.hh
deleted file mode 100644
index 6f1e8852..00000000
--- a/examples/calc++/calc++-parser.hh
+++ /dev/null
@@ -1,4 +0,0 @@
-// Work around an Automake 1.11.2 bug: it asks for the creation of
-// y.tab.h and then renames it as calc++-parser.h instead of
-// calc++-parser.hh. We don't want this to show in the documentation.
-#include "calc++-parser.h"
diff --git a/examples/calc++/local.mk b/examples/calc++/local.mk
index 5d9dce02..d800ad1b 100644
--- a/examples/calc++/local.mk
+++ b/examples/calc++/local.mk
@@ -20,7 +20,7 @@
## ------------ ##
# Extract in src.
-$(top_srcdir)/examples/calc++/calc.stamp: $(doc) $(extexi)
+$(top_srcdir)/examples/calc++/calc++.stamp: $(doc) $(extexi)
$(AM_V_GEN)rm -f $@ $@.tmp
$(AM_V_at)touch $@.tmp
$(AM_V_at)cd $(top_srcdir)/examples/calc++ && \
@@ -29,41 +29,69 @@ $(top_srcdir)/examples/calc++/calc.stamp: $(doc) $(extexi)
calc++-scanner.ll calc++.cc calc++-driver.hh calc++-driver.cc
$(AM_V_at)mv $@.tmp $@
-$(calc_extracted): $(top_srcdir)/examples/calc++/calc.stamp
- $(AM_V_GEN)if test -f $@; then :; else \
- rm -f $< && \
- $(MAKE) $(AM_MAKEFLAGS) $<; \
- fi
+$(calc_extracted): $(top_srcdir)/examples/calc++/calc++.stamp
+ @test -f $@ || rm -f $(top_srcdir)/examples/calc++/calc++.stamp
+ @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) $(top_srcdir)/calc++/calc++.stamp
+
+## ------------------- ##
+## Parser generation. ##
+## ------------------- ##
+
+BUILT_SOURCES += $(calc_sources)
+CLEANFILES += $(top_srcdir)/examples/calc++/*.output *.tmp
+MAINTAINERCLEANFILES += $(top_srcdir)/examples/calc++/*.stamp $(calc_sources)
+
+# Compile the parser and save cycles.
+# This code comes from "Handling Tools that Produce Many Outputs",
+# from the Automake documentation.
+EXTRA_DIST += \
+ examples/calc++/calc++-parser.stamp \
+ examples/calc++/calc++-parser.yy \
+ examples/calc++/calc.stamp
+# Don't depend on $(BISON) otherwise we would rebuild these files
+# in srcdir, including during distcheck, which is forbidden.
+$(top_srcdir)/examples/calc++/calc++-parser.stamp: $(top_srcdir)/examples/calc++/calc++-parser.yy $(BISON_IN)
+ $(AM_V_YACC)rm -f $@
+ $(AM_V_at)touch $@.tmp
+ $(AM_V_at)$(YACCCOMPILE) \
+ -o $(top_srcdir)/examples/calc++/calc++-parser.cc \
+ $(top_srcdir)/examples/calc++/calc++-parser.yy
+ $(AM_V_at)mv -f $@.tmp $@
+
+$(calc_sources_generated): $(top_srcdir)/examples/calc++/calc++-parser.stamp
+ @test -f $@ || rm -f $(top_srcdir)/examples/calc++/calc++-parser.stamp
+ @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) $(top_srcdir)/examples/calc++/calc++-parser.stamp
+
## -------------------- ##
## Building & testing. ##
## -------------------- ##
-BUILT_SOURCES += $(calc_sources) examples/calc++/calc++-parser.h
-CLEANFILES += *.tmp
-MAINTAINERCLEANFILES += $(top_srcdir)/examples/calc++/calc.stamp $(calc_sources)
-EXTRA_DIST += examples/calc++/calc.stamp
-
-calc_extracted = \
- examples/calc++/calc++-scanner.ll \
- examples/calc++/calc++.cc \
- examples/calc++/calc++-driver.hh \
+calc_sources_extracted = \
examples/calc++/calc++-driver.cc \
+ examples/calc++/calc++-driver.hh \
+ examples/calc++/calc++-scanner.ll \
+ examples/calc++/calc++.cc
+calc_extracted = \
+ $(calc_sources_extracted) \
examples/calc++/calc++-parser.yy
-calc_generated = \
- examples/calc++/stack.hh \
+calc_sources_generated = \
+ examples/calc++/calc++-parser.cc \
+ examples/calc++/calc++-parser.hh \
+ examples/calc++/location.hh \
examples/calc++/position.hh \
- examples/calc++/location.hh
+ examples/calc++/stack.hh
calc_sources = \
- $(calc_extracted) $(calc_generated)
+ $(calc_sources_extracted) \
+ $(calc_sources_generated)
if BISON_CXX_WORKS
check_PROGRAMS += examples/calc++/calc++
examples_calc___calc___SOURCES = \
- $(calc_sources) \
- examples/calc++/y.tab.h \
- examples/calc++/calc++-parser.hh
+ $(calc_sources)
examples_calc___calc___CPPFLAGS = -I$(top_srcdir)/examples/calc++
TESTS += examples/calc++/calc++.test
endif
-EXTRA_DIST += examples/calc++/calc++.test
+EXTRA_DIST += \
+ examples/calc++/calc++-parser.yy \
+ examples/calc++/calc++.test