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

2021-11-29 Thread Paul D. Smith
Update of bug #55242 (project make):

  Status:None => Not A Bug  
 Open/Closed:Open => Closed 

___

Follow-up Comment #5:

Thanks for your thoughts on this Dmitry.  I'm going to close this issue;
anyone who wants to comment further can still do so.

___

Reply to this item at:

  

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




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

2021-11-28 Thread Dmitry Goncharov
Follow-up Comment #4, bug #55242 (project make):

i agree that the makefile in question is incorrect.
i don't think the patch should be applied. i should not have provided the
patch to begin with.

i'd just gave the 'a.mk: b' rule a proper recipe which builds 'a.mk', rather
than an empty recipe.
With an empty recipe when 'b' is present, but 'a.mk' is missing, 'a.mk' won't
be created.

___

Reply to this item at:

  

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




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

2021-11-28 Thread Paul D. Smith
Follow-up Comment #3, bug #55242 (project make):

I tried these patches (some updates were needed as remake.c has changed
slightly).  They do fix the original issue but I thought of a new test to
add:

# Allow included files to be updated as side-effects of prereqs.  Here a.mk
# already exists, but b (which is rebuilt) updates it so we should re-exec.

touch('a.mk');
unlink('b');

run_make_test(q!
all:; @echo hello=$(hello)
include a.mk
a.mk: b
b: ; @echo hello=world >a.mk
!, '', "touch b\nhello=world");


This does not pass; even though a.mk was rebuilt we don't re-exec because a.mk
was pre-existing, we don't look to see if it's timestamp has changed.

We could continue on to fix this too, but I'm not convinced we should do
that.

In general, make doesn't actually check timestamps of targets unless make
believes that they've been updated.  I'm not sure that it's correct to break
this general rule and do something unique and special for rebuilt makefiles in
particular (or, I guess, this patch does something special for goal targets).

The way to "correct" the original makefile provided in the bug is the same as
when you run into this situation in any other target which is not an included
makefile: it is to add a recipe to the *a.mk* rule.  The recipe can be a "do
nothing" empty recipe: as long as make sees there is SOME recipe then it will
consider the target updated.

So for example, instead of this:

all:; @echo hello=$(hello)
include a.mk
a.mk: b
b: ; @echo hello=world >a.mk

if you added a semicolon (empty recipe) to *a.mk* like this:

all:; @echo hello=$(hello)
include a.mk
a.mk: b ;
b: ; @echo hello=world >a.mk

then it would work fine.

My inclination is to close this as "Not a Bug".

Comments welcome.

___

Reply to this item at:

  

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




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

2020-04-11 Thread Dmitry Goncharov
Additional Item Attachment, bug #55242 (project make):

File name: sv_55242_let_included_files_be_byproduct_of_unrelated_rules.diff
Size:2 KB
   


File name:
sv_55242_let_included_files_be_byproduct_of_unrelated_rules_test.diff Size:0
KB
   




___

Reply to this item at:

  

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




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

2020-04-11 Thread Dmitry Goncharov
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:

  

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




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

2020-04-11 Thread Dmitry Goncharov
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:

  

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




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

2018-12-19 Thread anonymous
URL:
  

 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:

  

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


___
Bug-make mailing list
Bug-make@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-make