]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 57676] Support included files being built after failing
authorPaul Smith <psmith@gnu.org>
Sat, 5 Dec 2020 20:06:25 +0000 (15:06 -0500)
committerPaul Smith <psmith@gnu.org>
Sat, 5 Dec 2020 20:06:25 +0000 (15:06 -0500)
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.

src/read.c
tests/scripts/features/include

index b66f3d4a46626ef3a98cae25dc0242b7cc4ede7d..545514c588c1330bbc16e05d2360d9694532bb54 100644 (file)
@@ -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));
 
index 7dd17b5bfc9ed01ea8e3f0cb97c53e7df5fd15c0..11e30736525df17ac407a88a8cd4cbb457ab0bce 100644 (file)
@@ -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