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.
/* 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));
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';
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