Subject: Regression in maint: "make distcheck" fails when yacc is used with subdir-objects option

From: Stefano Lattarini <[email-masked]>
Date: Tue, 12 Apr 2011 14:36:56 +0200

Apparently, in projects using Automake yacc support with the 'subdir-objects'
option enabled, "make distcheck" fails, because in a VPATH build make (even
GNU make) seems unable to find the distributed yacc-generated C files.  This
failure happens only with the developement version of automake, while 1.11
behaves fine.

Here is an incomplete stripped-down example:

  $ cat > configure.in <<'END'
  AC_INIT(x, 0)
  AM_INIT_AUTOMAKE(foreign)
  AC_CONFIG_FILES(Makefile)
  AC_PROG_CC
  AM_PROG_CC_C_O
  AC_PROG_YACC
  AC_OUTPUT
  $ cat > Makefile.am <<'END'
  AUTOMAKE_OPTIONS = subdir-objects
  noinst_PROGRAMS = foo
  foo_SOURCES = sub/parse.y
  END
  $ ... # create sub/parse.y here
  $ AUTOMAKE=/path/to/devel/automake ACLOCAL=/path/to/devel/aclocal autoreconf -vi
  autoreconf: Entering directory `.'
  autoreconf: configure.in: not using Gettext
  autoreconf: running: aclocal 
  autoreconf: configure.in: tracing
  autoreconf: configure.in: not using Libtool
  autoreconf: running: /usr/bin/autoconf
  autoreconf: configure.in: not using Autoheader
  autoreconf: running: automake --add-missing --copy --no-force
  configure.in:5: installing `./compile'
  configure.in:2: installing `./install-sh'
  configure.in:2: installing `./missing'
  Makefile.am: installing `./depcomp'
  configure.in: installing `./ylwrap'
  autoreconf: Leaving directory `.'
  $ ./configure
  ...
  $ make
  ...
  $ ls sub
  parse.c  parse.y
  $ make distcheck
  ...
  rm -rf sub/.deps
  rm -f Makefile
  ERROR: files left in build directory after distclean:
  ./sub/parse.c
  make[1]: *** [distcleancheck] Error 1
  make[1]: Leaving directory `/tmp/yyy/x-0/_build'
  $ make distclean
  ...
  $ mkdir build && cd build
  $ ../configure YACC=false
  ...
  $ make
  /bin/sh ../ylwrap ../sub/parse.y y.tab.c sub/parse.c ... -- false  
  make: *** [sub/parse.c] Error 1
  $ make YACC=yacc
  ...
  gcc  -g -O2   -o foo sub/parse.o 
  $ ls sub
  parse.c  parse.o

The attached testcase expeses the bug.

Looking at the diffs of the Makefile.in generated by automake-1.11
and automake-maint, I've found only this suspicious difference:

  @@ -544,6 +551,8 @@
 
   ps-am:
 
  +sub/parse.c: sub/$(am__dirstamp)
  +
   uninstall-am:
 
   .MAKE: install-am install-strip

which makes me suspect that the regression has been introduced
by commit v1.11-328-ge87c030 "Create subdirs for generated
sources even when not dep tracking."

Regards,
  Stefano