From: Chuan-kai Lin <cklin@debian.org>
Date: Tue, 9 Jul 2019 19:46:16 -0700
Subject: Hack explicit dependencies on parse.h

The targets lexcalc-scan.o and reccalc-scan.o need parse.h to build.
Without explicit dependencies, make might attempt to build those targets
before a different rule finishes generating parse.h, leading to FTBFS.
But the Makefile.in generated by automake generates parse.h through a
.y.c suffix rule (without indicating that invoking bison also generates
a .h output), so explicit dependencies on parse.h also do not work.

This patch implements a hack that makes lexcalc-scan.o and
reccalc-scan.o both depend on parse.c. Since parse.c is generated by the
same rule as parse.h, these bogus dependencies ensure that make attempts
to build those .o files only after parse.h becomes available.

Last-Update: 2019-07-09
---
 examples/c/lexcalc/local.mk | 2 ++
 examples/c/reccalc/local.mk | 1 +
 2 files changed, 3 insertions(+)

diff --git a/examples/c/lexcalc/local.mk b/examples/c/lexcalc/local.mk
index 2cd0d64..6ab1fa8 100644
--- a/examples/c/lexcalc/local.mk
+++ b/examples/c/lexcalc/local.mk
@@ -27,6 +27,8 @@ if FLEX_WORKS
   %C%_lexcalc_CPPFLAGS = -I$(top_srcdir)/%D% -I$(top_builddir)/%D%
 endif FLEX_WORKS
 
+%D%/lexcalc$(DASH)scan.o: %D%/parse.c
+
 %D%/parse.c: $(dependencies)
 
 EXTRA_DIST += %D%/lexcalc.test
diff --git a/examples/c/reccalc/local.mk b/examples/c/reccalc/local.mk
index d5f5145..092ad7b 100644
--- a/examples/c/reccalc/local.mk
+++ b/examples/c/reccalc/local.mk
@@ -36,6 +36,7 @@ endif FLEX_WORKS
 # additional dependency.
 DASH = -
 %D%/reccalc$(DASH)parse.o: %D%/scan.h
+%D%/reccalc$(DASH)scan.o: %D%/parse.c
 
 %D%/scan.c %D%/scan.h: %D%/scan.stamp
 	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) %D%/scan.stamp
