Re: [bug #62441] Recursive make & PHONY = targets being rebuilt [feature reques]

2022-05-11 Thread Henrik Carlqvist
> I have two makefiles:
> 
> *Makefile*
> 
> .PHONY: other_file
> other_file:
>   $(MAKE) -f Makefile2 other_file
> 
> my_file: other_file
>   touch $@
> 
> 
> *Makefile2*
> 
> other_file:
>   touch $@
> 
> 
> 
> When I first run the command, it builds my_file and other_file as expected.
> 
> > make my_file --trace --no-print-directory
> Makefile:6: target 'other_file' does not exist
> make -f Makefile2 other_file
> Makefile2:3: target 'other_file' does not exist
> touch other_file
> Makefile:9: update target 'my_file' due to: other_file
> touch my_file
> 
> 
> However, the next time I run the same command, it doesn't rebuild
> other_file, but it does rebuild my_file.
> 
> make my_file --trace --no-print-directory
> Makefile:6: target 'other_file' does not exist
> make -f Makefile2 other_file
> make[1]: 'other_file' is up to date.
> Makefile:9: update target 'my_file' due to: other_file
> touch my_file
> 
> 
> This is obviously because other_file is marked as PHONY.
> 
> What I would like is this functionality for recursive make support: When it
> is time to consider such a target, make will run its recipe unconditionally.
> After the recipe is run, make will use the target's timestamp to determine
> if other targets are out of date.
> 
> It would look something like: 
> *Makefile*
> 
> .RECURSIVE_MAKE: other_file
> other_file:
>   $(MAKE) -f Makefile2 other_file
> 
> my_file: other_file
>   touch $@
> 
> 
> *Makefile2*
> 
> other_file:
>   touch $@
> 
> 
> 
> > make my_file --trace --no-print-directory
> Makefile:6: target 'other_file' does not exist
> make -f Makefile2 other_file
> Makefile2:3: target 'other_file' does not exist
> touch other_file
> Makefile:9: update target 'my_file' due to: other_file
> touch my_file
> 
> > make my_file --trace --no-print-directory
> Makefile:6: target 'other_file' requires recursive make.
> make -f Makefile2 other_file
> make[1]: 'other_file' is up to date.
> make: 'my_file' is up to date.

Wouldn't the easy solution be to not make other_file a phony target and
instead force it to be rebuilt?

-8<-
other_file: FORCE
$(MAKE) -f Makefile2 other_file

my_file: other_file
touch $@

FORCE:
-8<-

regards Henrik



[bug #62441] Recursive make & PHONY = targets being rebuilt [feature reques]

2022-05-11 Thread Paul D. Smith
Update of bug #62441 (project make):

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

___

Follow-up Comment #1:

There's no new feature needed for this: this is something that's easily
achievable today.  We prefer to use the mailing lists, either
help-m...@gnu.org or bug-make@gnu.org, when asking for assistance and advice,
not the bug tracker.  Then if something is really a bug it can be reported
here.

You can do what you want by having other_file _depend on_ a phony file, rather
than making other_file itself phony.


other_file: FORCE
$(MAKE) ... other_file

FORCE:


See info about force targets in the GNU make manual:
https://www.gnu.org/software/make/manual/html_node/Force-Targets.html


___

Reply to this item at:

  

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




[bug #62441] Recursive make & PHONY = targets being rebuilt [feature reques]

2022-05-11 Thread anonymous
URL:
  

 Summary: Recursive make & PHONY = targets being rebuilt
[feature reques]
 Project: make
Submitted by: None
Submitted on: Wed 11 May 2022 03:48:10 PM UTC
Severity: 3 - Normal
  Item Group: None
  Status: None
 Privacy: Public
 Assigned to: None
 Open/Closed: Open
 Discussion Lock: Any
   Component Version: None
Operating System: None
   Fixed Release: None
   Triage Status: None

___

Details:

I have two makefiles:

*Makefile*

.PHONY: other_file
other_file:
$(MAKE) -f Makefile2 other_file

my_file: other_file
touch $@


*Makefile2*

other_file:
touch $@



When I first run the command, it builds my_file and other_file as expected.

> make my_file --trace --no-print-directory
Makefile:6: target 'other_file' does not exist
make -f Makefile2 other_file
Makefile2:3: target 'other_file' does not exist
touch other_file
Makefile:9: update target 'my_file' due to: other_file
touch my_file


However, the next time I run the same command, it doesn't rebuild other_file,
but it does rebuild my_file.

make my_file --trace --no-print-directory
Makefile:6: target 'other_file' does not exist
make -f Makefile2 other_file
make[1]: 'other_file' is up to date.
Makefile:9: update target 'my_file' due to: other_file
touch my_file


This is obviously because other_file is marked as PHONY.

What I would like is this functionality for recursive make support: When it is
time to consider such a target, make will run its recipe unconditionally.
After the recipe is run, make will use the target's timestamp to determine if
other targets are out of date.

It would look something like: 
*Makefile*

.RECURSIVE_MAKE: other_file
other_file:
$(MAKE) -f Makefile2 other_file

my_file: other_file
touch $@


*Makefile2*

other_file:
touch $@



> make my_file --trace --no-print-directory
Makefile:6: target 'other_file' does not exist
make -f Makefile2 other_file
Makefile2:3: target 'other_file' does not exist
touch other_file
Makefile:9: update target 'my_file' due to: other_file
touch my_file

> make my_file --trace --no-print-directory
Makefile:6: target 'other_file' requires recursive make.
make -f Makefile2 other_file
make[1]: 'other_file' is up to date.
make: 'my_file' is up to date.







___

Reply to this item at:

  

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




Re: Archive Members as Targets

2022-05-11 Thread Paul Smith
On Tue, 2022-05-10 at 22:45 +0200, Michael Lehn wrote:
> But not on the Linux boxes there make always rebuild everything. On
> all machines I am using GNU Make.

This is because whatever GNU/Linux distribution is being used, has
configured their binutils so that ar is in "deterministic mode" by
default, which is bogus and breaks make.

On such a system you'll have to pass the "U" option to ar, to disable
deterministic mode.



Re: Crash in 'find_and_set_default_shell()'

2022-05-11 Thread Gisle Vanem

Paul Smith wrote:


... else (b) make has to parse this string
and break it up into words that it can use to call exec() without going
through a shell


The crash and wild call-stack seems to be caused
by an overflow to 'sprintf(sh_path, ..)'. But replacing
with 'snprintf()' works w/o any crash:

--- a/src/main.c 2022-05-10 13:37:02
+++ b/src/main.c 2022-05-11 07:47:07
@@ -956,7 +956,7 @@
 {
   batch_mode_shell = 1;
   unixy_shell = 0;
-  sprintf (sh_path, "%s", search_token);
+  snprintf (sh_path, GET_PATH_MAX, "%s", search_token);
   default_shell = xstrdup (w32ify (sh_path, 0));
   DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"),
default_shell));
@@ -971,7 +971,7 @@
   else if (_access (search_token, 0) == 0)
 {
   /* search token path was found */
-  sprintf (sh_path, "%s", search_token);
+  snprintf (sh_path, GET_PATH_MAX, "%s", search_token);
   default_shell = xstrdup (w32ify (sh_path, 0));
   DB (DB_VERBOSE, (_("find_and_set_shell() setting default_shell = %s\n"),
default_shell));
@@ -994,7 +994,7 @@
 {
   *ep = '\0';

-  sprintf (sh_path, "%s/%s", p, search_token);
+  snprintf (sh_path, GET_PATH_MAX, "%s/%s", p, search_token);
   if (_access (sh_path, 0) == 0)
 {
   default_shell = xstrdup (w32ify (sh_path, 0));
@@ -1016,7 +1016,7 @@
   /* be sure to check last element of Path */
   if (p && *p)
 {
-  sprintf (sh_path, "%s/%s", p, search_token);
+  snprintf (sh_path, GET_PATH_MAX, "%s/%s", p, search_token);
   if (_access (sh_path, 0) == 0)
 {
   default_shell = xstrdup (w32ify (sh_path, 0));

--

And testing it with:
  set GNUMAKEFLAGS=--debug=verbose,jobs
  gnumake -f Minimal.make

seems to work okay:
  ..
  find_and_set_shell() path search set default_shell = f:/CygWin32/bin/sh.exe
  ..
  CreateProcess(f:\CygWin32\bin\sh.exe,f:/CygWin32/bin/sh.exe -c "echo 
\"Hello\"",...)
  Putting child 012E9F10 (all) PID 20053024 on the chain.
  Live child 012E9F10 (all) PID 20053024
  Main thread handle = 0118
  Hello

--
--gv