Subject: lex/yacc with subdir-objects and --disable-dependency-tracking broken

From: Nick Brown <[email-masked]>
Date: Thu, 1 Jun 2017 14:25:15 +0000

By default Debian dh passes --disable-dependacy-tracking when building.
If the package rules also adds --builddirectory to use out of source builds
(eg. "dh $@ --builddirectory=build --parallel --with autoreconf"), and the
package happens to be using subdir-objects automake option and generated source
files from lex/yacc then the build will fail.

Eg.

mkdir build
../configure --disable-dependency-tracking --disable-silent-rules
make

/bin/bash ../ylwrap ../src/scanner.ll lex.yy.c src/scanner.cc -- flex
../ylwrap: line 206: ../src/scanner.cc: No such file or directory
Makefile:422: recipe for target 'src/scanner.cc' failed
make: *** [src/scanner.cc] Error 1

A simple patch to lex.am and yacc.am fixes this.
>From bd6971224f304c8f5951afca620f33c25248b446 Mon Sep 17 00:00:00 2001
From: Nicholas Brown <[email-masked]>
Date: Fri, 4 Dec 2015 10:49:18 +0000
Subject: [PATCH] yacc and lex built objects without dependancy tracking

---
 lib/am/lex.am  | 1 +
 lib/am/yacc.am | 1 +
 2 files changed, 2 insertions(+)

diff --git a/lib/am/lex.am b/lib/am/lex.am
index d7ddc77..6357507 100644
--- a/lib/am/lex.am
+++ b/lib/am/lex.am
@@ -23,6 +23,7 @@ endif %?MAINTAINER-MODE%
 
 ?GENERIC?%EXT%%DERIVED-EXT%:
 ?!GENERIC?%OBJ%: %SOURCE%
+?SUBDIROBJ?	%SILENT%test -d $(dir $@) || $(MKDIR_P) $(dir $@)
 ?GENERIC?	%VERBOSE%$(am__skiplex) $(SHELL) $(YLWRAP) %SOURCE% $(LEX_OUTPUT_ROOT).c %OBJ% -- %COMPILE%
 ?!GENERIC?	%VERBOSE% \
 ?!GENERIC??DIST_SOURCE?	$(am__skiplex) \
diff --git a/lib/am/yacc.am b/lib/am/yacc.am
index 2b3f92a..2c33023 100644
--- a/lib/am/yacc.am
+++ b/lib/am/yacc.am
@@ -43,6 +43,7 @@ endif %?FIRST%
 
 ?GENERIC?%EXT%%DERIVED-EXT%:
 ?!GENERIC?%OBJ%: %SOURCE%
+?SUBDIROBJ?	%SILENT%test -d $(dir $@) || $(MKDIR_P) $(dir $@)
 ?GENERIC?	%VERBOSE%$(am__skipyacc) $(SHELL) $(YLWRAP) %SOURCE% y.tab.c %OBJ% y.tab.h `echo %OBJ% | $(am__yacc_c2h)` y.output %BASE%.output -- %COMPILE%
 ?!GENERIC?	%VERBOSE% \
 ?!GENERIC??DIST_SOURCE?	$(am__skipyacc) \
-- 
2.1.4