help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

misunderstanding -s behavior


From: balducci
Subject: misunderstanding -s behavior
Date: Thu, 14 Mar 2013 17:36:31 +0100

hello,

I hope that someone on this list will help me understand this issue
which I stumbled on while building the latest release of emacs (24.3).

In the install-info target of build-d/Makefile a variable called info_misc 
is obtained like this:

     info_misc=`cd doc/misc; ${MAKE} -s echo-info`

Basically, "-s" should induce silent operation, so that
only the result of the echo-info target in doc/misc/Makefile should
be loaded into the shell variable (the echo-info target builds a list
of file names).

Everything works nicely if I run make from the shell prompt.

However, I usually build emacs with a script which is run, in turn, from
a Makefile of mine: if the emacs build is run this way, I find
that the definition of info_misc above contains also the make messages
"Entering directory..." "Leaving directory...", which, of course,
break the build.

In the effort of understanding what was going on, I seem to have captured
the essential points in the following Makefile:

---8<------8<------8<------8<---

target_1:
        @make target_2

target_2: 
        @the_var=`make -s target_3` ; \
        echo "the_var value is:" ; \
        echo "---------" ; \
        echo $$the_var ; \
        echo "---------" ; \

target_3: 
        @echo "hello world!"

---8<------8<------8<------8<---


If I say: "make target_2", I obtain what I expect:

#> make target_2
the_var value is:
---------
hello world!
---------


But, if I say "make target_1", I obtain the additional make messages:

#> make target_1
make[1]: Entering directory `/home/balducci/tmp/make-bug.d'
the_var value is:
---------
make[2]: Entering directory `/home/balducci/tmp/make-bug.d' hello world! 
make[2]: Leaving directory `/home/balducci/tmp/make-bug.d'
---------
make[1]: Leaving directory `/home/balducci/tmp/make-bug.d'


It seems to be a matter of the number of levels of recursion: "make
target_2" (1 recursion) works as expected, while "make target_1" (2
recursions) includes the "Entering directory..." "Leaving
directory..." messages into the_var. This seems identical to what happens
with the emacs build: if I run the build from the shell prompt, there
is only 1 recursion and things work as expected; if I run the build
with my script (which is run from a Makefile), there are 2 make
recursions and things do not work.

I have read make info docs, but I do not seem to have found any
explanation; might it be that make echoes the "Entering directory..."
"Leaving directory..." messages only when the recursion level is >=2?
And even so, shouldn't the use of "-s" suppress any make message at
all?

As a matter of fact, saying  "make --no-print-directory target_1"
restores the "correct" behavior:

#> make --no-print-directory target_1
the_var value is:
---------
hello world!
---------

(the same holds for the emacs build if I run "make
--no-print-directory install" from my script)

But: shouldn't the "-s" option be honored for any recursion level?

I must have misunderstood something somewhere...

Any help on this will be warmly appreciated

ciao
gabriele

#> make --version
GNU Make 3.82
Built for i686-pc-linux-gnu
Copyright (C) 2010  Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]