From: Paul Smith Date: Sat, 5 Dec 2020 20:06:25 +0000 (-0500) Subject: [SV 57676] Support included files being built after failing X-Git-Tag: 4.3.90~197 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c4cc2e95953baae800eb9c694c691f7263317035;p=thirdparty%2Fmake.git [SV 57676] Support included files being built after failing If a -include file does not exist, then some subsequent operation creates it, then allow it to be successfully included. * src/read.c (eval_makefile): If our last mtime was NONEXISTENT then reset it to 0 so we'll check it again. * tests/scripts/features/include: Add a test for this behavior. --- diff --git a/src/read.c b/src/read.c index b66f3d4a..545514c5 100644 --- a/src/read.c +++ b/src/read.c @@ -410,6 +410,11 @@ eval_makefile (const char *filename, unsigned short flags) /* Success; clear errno. */ deps->error = 0; + /* If we tried and failed to read the included file before but this + time we succeeded, reset the last mtime. */ + if (deps->file->last_mtime == NONEXISTENT_MTIME) + deps->file->last_mtime = 0; + /* Avoid leaking the makefile to children. */ fd_noinherit (fileno (ebuf.fp)); diff --git a/tests/scripts/features/include b/tests/scripts/features/include index 7dd17b5b..11e30736 100644 --- a/tests/scripts/features/include +++ b/tests/scripts/features/include @@ -237,8 +237,8 @@ inc1: foo; echo > $@ rmfiles('inc1'); } -# Including files that can't be read should show an error if (defined $ERR_unreadable_file) { + # Including files that can't be read should show an error create_file('inc1', 'FOO := foo'); chmod 0000, 'inc1'; @@ -271,7 +271,19 @@ run_make_test(q! all:; !, '', "i1\ni2\ni3\ni4\n#MAKE#: 'all' is up to date.\n"); -rmfiles('foo'); + +# Check that included files work if created after the first include failed +# https://savannah.gnu.org/bugs/?57676 + +run_make_test(q! +-include hello.mk +$(shell echo hello=world >hello.mk) +include hello.mk +default:; @echo $(hello) +!, + '', "world\n"); + +unlink('hello.mk'); # Check the default makefiles... this requires us to invoke make with no # arguments. Also check MAKEFILES