Hi all:

I have hit an interesting bug in Automake. It has taken me a few hours of 
learning and experimentation to track it down.

The OpenOCD project uses the Autotools and everything seems fine: bootstrap, ./configure, 
"make install", etc. work fine. Only make "make dist" fails:

$ make dist
make  dist-bzip2 dist-gzip dist-zip am__post_remove_distdir='@:'
make[1]: Entering directory 
'/home/rdiez/rdiez/LocalSoftware/OpenOCD/openocd-dev-obj'
make  distdir-am
make[2]: Entering directory 
'/home/rdiez/rdiez/LocalSoftware/OpenOCD/openocd-dev-obj'
gcc -g -O2    
/home/rdiez/rdiez/LocalSoftware/OpenOCD/openocd-dev-src/src/jtag/drivers/angie.c
   -o src/jtag/drivers/angie
/home/rdiez/rdiez/LocalSoftware/OpenOCD/openocd-dev-src/src/jtag/drivers/angie.c:19:10:
 fatal error: helper/system.h: No such file or directory
   19 | #include "helper/system.h"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [<builtin>: src/jtag/drivers/angie] Error 1
make[2]: Leaving directory 
'/home/rdiez/rdiez/LocalSoftware/OpenOCD/openocd-dev-obj'
make[1]: *** [Makefile:5076: distdir] Error 2
make[1]: Leaving directory 
'/home/rdiez/rdiez/LocalSoftware/OpenOCD/openocd-dev-obj'
make: *** [Makefile:5183: dist] Error 2

The problem is here:

https://sourceforge.net/p/openocd/code/ci/master/tree/src/jtag/drivers/Makefile.am

In this line:

EXTRA_DIST += $(ULINK_FIRMWARE) \
        $(ANGIE_FILES) \

$(ANGIE_FILES) refers to source subdirectory "src/jtag/drivers/angie/", but next to it there is a source file 
called "src/jtag/drivers/angie.c". GNU Make tries then to use a built-in rule to make executable 
"angie" from source "angie.c", using the wrong compilers flags etc., and that fails.

The Automake documentation actually discourages adding whole directories in 
EXTRA_DIST. I'll try to get that improved in OpenOCD. But the documentation 
cites other reasons and does not prohibit this practice.

If I change the definition of ANGIE_FILES:
from: ANGIE_FILES = %D%/angie
to  : ANGIE_FILES = %D%/angie/
then it works fine.

If that is really the solution, it should probably be documented (or did I miss 
it?). This is the spot in the documentation:

"You can also mention a directory in EXTRA_DIST; in this case the entire directory 
will be recursively copied into the distribution."

Now, I thought that Automake 1.17 had actually disabled such GNU Make built-in 
rules:

  GNU Make's default pattern rules are disabled, for speed and debugging.
  (.SUFFIXES was already cleared.) (bug#64743)

But Automake 1.16.5 also emits a similar clear .SUFFIXES rules, and GNU Make 
stills seems to use a built-in rule for that file/directory.

I wonder why GNU Make is then trying a built-in rule, or where such a rule is coming 
from, or perhaps disabling default rules is not working well or is not active during 
"make dist".

Best regards,
  rdiez


Reply via email to