[bug #55242] Included Makefile not found, no rule to build it but make does not fail

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #55242] Included Makefile not found, no rule to build it but make does not fail

anonymous
URL:
  <https://savannah.gnu.org/bugs/?55242>

                 Summary: Included Makefile not found, no rule to build it but
make does not fail
                 Project: make
            Submitted by: None
            Submitted on: Wed 19 Dec 2018 12:37:06 PM UTC
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.2.1
        Operating System: Any
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

With the following Makefile:


.PHONY: all clean

all:;

include a.mk

a.mk: b

b:
        @touch $@
        @printf '$$(info a.mk included)' > a.mk

clean:
        @rm -f a.mk b


The first make invocation produces:


$ make
make: Nothing to be done for 'all'.


And the second make invocation:


make
a.mk included
make: Nothing to be done for 'all'.


So we are in a situation where:

0 a makefile is included with the include directive (no -include),
0 the included makefile is not found,
0 make finds no rule to produce it and decides not to include it,
0 make executes a recipe for a prerequisite of the included makefile that
incidentally also produces the included makefile,
0 as the included makefile is finally found make does not fail... but it does
not read the included makefile.

This could be considered as contradictory with the documentation:

_After all makefiles have been checked, if any have actually been changed,
make starts with a clean slate and reads all the makefiles over again._

make should either fail or include the included makefile.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55242>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


_______________________________________________
Bug-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/bug-make
Reply | Threaded
Open this post in threaded view
|

[bug #55242] Included Makefile not found, no rule to build it but make does not fail

anonymous
Follow-up Comment #1, bug #55242 (project make):

Here is a patch against the current master
(0c326a66c9eb3a3b5e4ab7892578b016b0590b1f).

This patch causes make to re-execute itself to read the included makefile.

diff --git a/src/remake.c b/src/remake.c
index fb237c5..4dc91d8 100644
--- a/src/remake.c
+++ b/src/remake.c
@@ -175,24 +175,30 @@ update_goal_chain (struct goaldep *goaldeps)
                     }
                   else
                     {
-                      FILE_TIMESTAMP mtime = MTIME (file);
+                      struct file *oldfile = file;
                       check_renamed (file);
 
-                      if (file->updated && g->changed &&
-                           mtime != file->mtime_before_update)
+                      if (file->updated && g->changed)
                         {
-                          /* Updating was done.  If this is a makefile and
-                             just_print_flag or question_flag is set
(meaning
-                             -n or -q was given and this file was specified
-                             as a command-line target), don't change STATUS.
-                             If STATUS is changed, we will get re-exec'd,
and
-                             enter an infinite loop.  */
-                          if (!rebuilding_makefiles
-                              || (!just_print_flag && !question_flag))
-                            status = us_success;
-                          if (rebuilding_makefiles && file->dontcare)
-                            /* This is a default makefile; stop remaking.
*/
-                            stop = 1;
+                          FILE_TIMESTAMP lm = oldfile->last_mtime;
+                          FILE_TIMESTAMP mtime =
+                            lm == UNKNOWN_MTIME || lm == NONEXISTENT_MTIME ?
+                            f_mtime (oldfile, 0) : lm;
+                          if (mtime != file->mtime_before_update)
+                            {
+                              /* Updating was done.  If this is a makefile
and
+                                 just_print_flag or question_flag is set
(meaning
+                                 -n or -q was given and this file was
specified
+                                 as a command-line target), don't change
STATUS.
+                                 If STATUS is changed, we will get re-exec'd,
and
+                                 enter an infinite loop.  */
+                              if (!rebuilding_makefiles
+                                  || (!just_print_flag && !question_flag))
+                                status = us_success;
+                              if (rebuilding_makefiles && file->dontcare)
+                                /* This is a default makefile; stop remaking.
 */
+                                stop = 1;
+                            }
                         }
                     }
                 }


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55242>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #55242] Included Makefile not found, no rule to build it but make does not fail

anonymous
Follow-up Comment #2, bug #55242 (project make):

Here is a test.

diff --git a/tests/scripts/features/include b/tests/scripts/features/include
index 0c63c06..f39e5ec 100644
--- a/tests/scripts/features/include
+++ b/tests/scripts/features/include
@@ -260,4 +260,16 @@ inc1:; @%s $@ && echo FOO := bar > $@
     rmfiles('inc1');
 }
 
+unlink('b');
+unlink('a.mk');
+run_make_test(q!
+all:; @echo hello=$(hello)
+include a.mk
+a.mk: b
+b:
+       @echo hello=world >a.mk
+!, '', 'hello=world');
+unlink('a.mk');
+unlink('b');
+
 1;


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55242>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #55242] Included Makefile not found, no rule to build it but make does not fail

anonymous
Additional Item Attachment, bug #55242 (project make):

File name: sv_55242_let_included_files_be_byproduct_of_unrelated_rules.diff
Size:2 KB
   
<https://savannah.gnu.org/file/sv_55242_let_included_files_be_byproduct_of_unrelated_rules.diff?file_id=48811>

File name:
sv_55242_let_included_files_be_byproduct_of_unrelated_rules_test.diff Size:0
KB
   
<https://savannah.gnu.org/file/sv_55242_let_included_files_be_byproduct_of_unrelated_rules_test.diff?file_id=48812>



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?55242>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/