[m-rev.] for review: Fix bison and flex makefile rules in trace directory.
Peter Wang
novalazy at gmail.com
Sat Jun 1 17:41:16 AEST 2019
I think this will fix the occasional build failures seen on the test
server.
----
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.
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)
--
2.21.0
More information about the reviews
mailing list