From: Akihiro Sagawa sagawa.aki@gmail.com
In Makefile, foobar.tab.c is made from the following rules: --- foobar.tab.h: foobar.y bison -o foobar.tab.c -d foobar.y ---- Rule X foobar.tab.c: foobar.y foobar.tab.h bison -o $@ foobar.y --- Rule Y --- Normally, Rule X is used. In parallel makes, if foobar.tab.c is considered while updating foobar.tab.h by Rule X, Rule Y is used. So, if we compare build directories, there might be a difference in that foobar.tab.c may or may not contain #include "foobar.tab.h".
To avoid the above situation, this patch introduces Grouped Targets which is new in GNU Make 4.3.
The previous rules still apply to prevent build failures on older systems, such as Ubuntu 20.04 LTS. --- tools/makedep.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/tools/makedep.c b/tools/makedep.c index 8495d93d8c6..2b6e36e6196 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -2685,16 +2685,26 @@ static void output_source_y( struct makefile *make, struct incl_file *source, co
if (find_include_file( make, header )) { + output( "ifneq (,$(filter grouped-target,$(.FEATURES)))\n" ); + output( "%s %s.tab.c &: %s\n", + obj_dir_path( make, header ), obj_dir_path( make, obj ), source->filename ); + output( "\t%s%s -o %s.tab.c -d %s\n", + cmd_prefix( "BISON" ), bison, obj_dir_path( make, obj ), source->filename ); + output( "else\n" ); output( "%s: %s\n", obj_dir_path( make, header ), source->filename ); output( "\t%s%s -o %s.tab.c -d %s\n", cmd_prefix( "BISON" ), bison, obj_dir_path( make, obj ), source->filename ); output( "%s.tab.c: %s %s\n", obj_dir_path( make, obj ), source->filename, obj_dir_path( make, header )); + output( "\t%s%s -o $@ %s\n", cmd_prefix( "BISON" ), bison, source->filename ); + output( "endif\n" ); strarray_add( &make->clean_files, header ); } - else output( "%s.tab.c: %s\n", obj_dir_path( make, obj ), source->filename ); - - output( "\t%s%s -o $@ %s\n", cmd_prefix( "BISON" ), bison, source->filename ); + else + { + output( "%s.tab.c: %s\n", obj_dir_path( make, obj ), source->filename ); + output( "\t%s%s -o $@ %s\n", cmd_prefix( "BISON" ), bison, source->filename ); + } }