From aad4085647aca96d8c2cba29ebf9c75d3ff63acf Mon Sep 17 00:00:00 2001 From: Peter Wang Date: Sat, 1 Jun 2019 17:38:48 +1000 Subject: [PATCH] Fix bison and flex makefile rules in trace directory. trace/Mmakefile Fix incorrect makefile rule with multiple targets. A rule with multiple targets is equivalent to writing many rules, each with one target, so the bison rule would (in parallel make) run bison once for the .c target and once for the .h target. The solution is to use a pattern rule, which GNU make recognises as a single recipe generating multiple outputs. Write separate rules for mercury_event_scanner.c and mercury_event_scanner.h. --- trace/Mmakefile | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/trace/Mmakefile b/trace/Mmakefile index 5428a0623..6f469e919 100644 --- a/trace/Mmakefile +++ b/trace/Mmakefile @@ -235,16 +235,20 @@ trace: $(LIB_DLL_H) $(LIB_GLOBALS_H) endif -mercury_event_parser.c mercury_event_parser.h: mercury_event_parser.y - $(BISON) $(BISON_OPTS) -p mercury_event_ -d -o mercury_event_parser.c \ - mercury_event_parser.y +# This uses a pattern rule to express to make that the rule's recipe is +# responsible for making all of the targets, not individual targets. +mercury_event_%.c mercury_event_%.h: mercury_event_%.y + $(BISON) $(BISON_OPTS) -p mercury_event_ -d \ + -o mercury_event_$*.c mercury_event_$*.y -mercury_event_scanner.c mercury_event_scanner.h: \ - mercury_event_scanner.l mercury_event_parser.h +mercury_event_scanner.c: mercury_event_scanner.l mercury_event_parser.h $(FLEX) $(FLEX_OPTS) -s -Pmercury_event_ \ -omercury_event_scanner.c \ mercury_event_scanner.l - echo "extern int mercury_event_lex(void);" > mercury_event_scanner.h + +# XXX does mercury_event_scanner.h need to be generated at all? +mercury_event_scanner.h: mercury_event_scanner.c + echo "extern int mercury_event_lex(void);" > mercury_event_scanner.h RPATH_1=$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_LIB_DIR) RPATH_2=$(SHLIB_RPATH_SEP)$(FINAL_INSTALL_MERC_GC_LIB_DIR)