Bug 729109

Summary: -s does not always prevent -w
Product: [Fedora] Fedora Reporter: Stas Sergeev <stsp2>
Component: makeAssignee: Petr Machata <pmachata>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 14CC: mnewsome, pmachata
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-08-09 14:57:16 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
test case none

Description Stas Sergeev 2011-08-08 18:19:45 UTC
Created attachment 517271 [details]
test case

Description of problem:
I am grepping the make output in makefiles or scripts sometimes,
so I used -s to make it silent.
Sometimes that doesn't work, even though the manual says this:
---
`make' will not automatically turn on `-w'
if you also use `-s', which says to be silent, or if you use
`--no-print-directory' to explicitly disable it.
---
It turned out, using -s does not always disable -w.

Version-Release number of selected component (if applicable):
make-3.82-3.fc14.x86_64

How reproducible:
Always

Steps to Reproduce:
1. Unpack attached test-case
2. Run tst.sh
  
Actual results:
make: Entering directory `/home/stas/tests/make'
make[1]: Entering directory `/home/stas/tests/make/tst'
test
make[1]: Leaving directory `/home/stas/tests/make/tst'
make: Leaving directory `/home/stas/tests/make'

Expected results:
make: Entering directory `/home/stas/tests/make'
test
make: Leaving directory `/home/stas/tests/make'

Additional info:
The expected results are achieved when --no-print-directory is used,
so I now use it as a work-around (uncomment that line in the test-case
Makefile to ckeck).
The very interesting thing here is that if "-C ." is removed from
tst.sh, then -s _in the Makefile_ starts taking an effect! How can
those be related? The "-C ." is for toplevel make invocation here, and
-s if for another make process, yet somehow they correlate...

Comment 1 Petr Machata 2011-08-09 13:41:45 UTC
After a closer look, this doesn't seem like a bug to me.  I'm working with this makefile:

all:
	@echo all $(MAKEFLAGS)
	$(MAKE) -C . second
second:
	@echo second $(MAKEFLAGS)
	$(MAKE) -C . -s third
third:
	@echo third $(MAKEFLAGS)
	$(MAKE) -C . fourth
fourth:
	@echo fourth $(MAKEFLAGS)

Now if I run simple "make", the first level is executed as usual, then recursive make is run, and that gets "-w" because in recursive make, we want to let the user know where he is.  When I do "make -C .", it's the same, except one level sooner.  Passing -s further down thus doesn't help, because -w is already implied by -C.  Passing -s on top level _does_ work though, and has the intended consequences.

In your case, I believe, you want to pass --no-print-directory in addition to -s, to suppress the effect of top-level -C.  Then I get:
$ make
all
make -C . second
make[1]: Вход в каталог `/home/petr/tmp/make/2'
second w
make -C . -s --no-print-directory third
third --no-print-directory -s
fourth --no-print-directory -s
make[1]: Выход из каталога `/home/petr/tmp/make/2'

Comment 2 Stas Sergeev 2011-08-09 14:16:39 UTC
Ah, so it explicitly passes -w through the MAKEFLAGS,
what a nasty beast... :)
Then, there is an ambiguity in the info page: it says that
`make' will not automatically turn on `-w', but:
- It does indeed automatically turns it on for the sub-make, by the
use of MAKEFLAGS. It wasn't passed by me explicitly, I only passed -s,
so this pretty much stands for the automatic enabling.
- It does NOT automatically enable it for the entire make process,
since it was already enabled before.

Thanks for your analysis, I guess this can be closed. :)

Comment 3 Petr Machata 2011-08-09 14:57:16 UTC
In the info page, it says "`make' will not automatically turn on `-w' if you also use `-s'", and indeed that is the case.  When I pass -s to toplevel make, -w is not turned on, regardless of whether I used -C or not.  The problem is that in your case (and in my demo), the -w is turned on by toplevel make, and then diligently passed down.  -s is added to the command line later, and at that time -s is not enough to cancel out the -w.