From 2c8beea016055011d3bc9f8d6eba251539aae491 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= Date: Thu, 3 Aug 2023 12:21:37 +0200 Subject: [PATCH] Add special rules for generated headers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bison(1) and flex(1) pose a problem for make(1) because they generate many output files. These files when properly added to dependency tree may make make(1) run rules to generate them twice depending on timing which in turn results in a race condition and failed build especially on heavily loaded systems. To aviod that special rules that serialise dependencies need to be introduced which is what automake(1) has made for long time. https://git.savannah.gnu.org/cgit/automake.git/commit/?id=788a63b300568b1c1876e4ad30b966df2f0710fc Additionally to avoid problems when running `make -n`, rm(1) and make(1) commands need to be placed under separate `if` statements. https://git.savannah.gnu.org/cgit/automake.git/commit/?id=d7c1679b14c1ab691927f3243df1cb3cbb2360aa Signed-off-by: Ɓukasz Stelmach --- src/Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index d029fc4..b425825 100644 --- a/src/Makefile +++ b/src/Makefile @@ -65,12 +65,20 @@ ${STATIC_TARGET}: ${OBJECTS} $(AR) rcs $@ libkafel.o $(RM) libkafel.o -lexer.h lexer.c: lexer.l +lexer.c: lexer.l flex $< -parser.h parser.c: parser.y +lexer.h: lexer.c + @if test ! -f lexer.h; then rm -f lexer.c; fi + @if test ! -f lexer.h; then $(MAKE) lexer.c; fi + +parser.c: parser.y bison $< +parser.h: parser.c + @if test ! -f parser.h; then rm -f parser.c; fi + @if test ! -f parser.h; then $(MAKE) parser.c; fi + # DO NOT DELETE THIS LINE -- make depend depends on it. kafel.o: codegen.h context.h includes.h parser_types.h policy.h expression.h