gmake -C mess up MAKEFLAGS?

View: New views
8 Messages — Rating Filter:   Alert me  

gmake -C mess up MAKEFLAGS?

by RobinK :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This is rather odd.
I have a directory: /tmp/aa, inside aa I have a makefile like this:
>cat /tmp/aa/makefile
all:
        @echo "Inside aa $(MAKEFLAGS)" ;\
        touch a.txt

Then, All I did was:
>cd /tmp
>gmake -C aa

This is the result:
gmake: Entering directory `/tmp/aa'
Inside aa w
gmake: Leaving directory `/tmp/aa'

Where's that "w" after "Inside aa" came from? Why is it in $(MAKEFLAGS)?
If I just do:
>cd /tmp/aa
>gmake
Then everything is fine, there's no "w" at the end

Can someone tell me what I did wrong? Thx!

Re: gmake -C mess up MAKEFLAGS?

by Harvey Chapman-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Oct 31, 2009, at 9:10 AM, RobinK wrote:

> This is the result:
> gmake: Entering directory `/tmp/aa'
> Inside aa w
> gmake: Leaving directory `/tmp/aa'
>
> Where's that "w" after "Inside aa" came from? Why is it in $
> (MAKEFLAGS)?
> If I just do:
>> cd /tmp/aa
>> gmake
> Then everything is fine, there's no "w" at the end
>

I think -C enables -w which prints the "gmake: Entering directory `/
tmp/aa'" messages.

‘-w’ ‘--print-directory’
Print a message containing the working directory both before and after  
execut- ing the makefile. This may be useful for tracking down errors  
from complicated nests of recursive make commands. See Section 5.7  
[Recursive Use of make], page 50. (In practice, you rarely need to  
specify this option since ‘make’ does it for you; see Section 5.7.4  
[The ‘--print-directory’ Option], page 54.)





_______________________________________________
Help-make mailing list
Help-make@...
http://lists.gnu.org/mailman/listinfo/help-make

Re: gmake -C mess up MAKEFLAGS?

by RobinK :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I see. Thanks! After adding --no-print-directory it seems to be working now.

But this is inconvenient. I do want it to print the directory, but I don't want that "w" to be in $(MAKEFLAGS). Plus, even if it has to add the w, shouldn't it be "-w" rather than just a "w"? The extra w totally messed up my makefile in the sub directory.

Re: gmake -C mess up MAKEFLAGS?

by Paul Smith-20 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, 2009-10-31 at 07:32 -0700, RobinK wrote:
> But this is inconvenient. I do want it to print the directory, but I
> don't want that "w" to be in $(MAKEFLAGS). Plus, even if it has to add
> the w, shouldn't it be "-w" rather than just a "w"? The extra w
> totally messed up my makefile in the sub directory.

This is exactly how it's supposed to work.  Read about MAKEFLAGS in the
GNU make manual to know why there's no leading "-".

If it messed up your makefile, then your makefile is not correct.
Remember that MAKEFLAGS is an INTERNAL variable, intended for use by
make to pass information to sub-makes through the environment.  It is
not intended to ever be used in a command line; for example you would
never write:

        foo:
                $(MAKE) $(MAKEFLAGS)

or something like that.

In what way did it mess up your makefile in the sub-directory?

--
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@...>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



_______________________________________________
Help-make mailing list
Help-make@...
http://lists.gnu.org/mailman/listinfo/help-make

Re: gmake -C mess up MAKEFLAGS?

by Richard Harvey Chapman-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Oct 31, 2009, at 10:32 AM, RobinK wrote:

> want that "w" to be in $(MAKEFLAGS). Plus, even if it has to add the  
> w,
> shouldn't it be "-w" rather than just a "w"? The extra w totally  
> messed up

Grab a copy of the make manual. I keep a PDF copy on my laptop for  
quick reference.
 From the make manual:

5.7.3 Communicating Options to a Sub-make
Flags such as ‘-s’ and ‘-k’ are passed automatically to the sub-make  
through the variable MAKEFLAGS. This variable is set up automatically  
by make to contain the flag letters that make received. Thus, if you  
do ‘make -ks’ then MAKEFLAGS gets the value ‘ks’.

...

_______________________________________________
Help-make mailing list
Help-make@...
http://lists.gnu.org/mailman/listinfo/help-make

Re: gmake -C mess up MAKEFLAGS?

by RobinK :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

foo:
        $(MAKE) $(MAKEFLAGS)


Yeah, that's exactly what I did. So what's the correct syntax? What I need is, if I pass any parameters to the top level makefile, those params should be passed to subdirectory level makefile.

Re: gmake -C mess up MAKEFLAGS?

by Paul Smith-20 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sat, 2009-10-31 at 11:23 -0700, RobinK wrote:
> foo:
> $(MAKE) $(MAKEFLAGS)
>
>
> Yeah, that's exactly what I did. So what's the correct syntax? What I need
> is, if I pass any parameters to the top level makefile, those params should
> be passed to subdirectory level makefile.

Make already does that.  That's what MAKEFLAGS are for... and make
handles it for you.

Just run:

        foo:
                $(MAKE)

and you're done.  Just be SURE to use the variable $(MAKE), not the
static string "make".

--
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@...>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



_______________________________________________
Help-make mailing list
Help-make@...
http://lists.gnu.org/mailman/listinfo/help-make

Re: gmake -C mess up MAKEFLAGS?

by RobinK :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thank you Paul! Everything's working fine now.

Paul Smith-20 wrote:
On Sat, 2009-10-31 at 11:23 -0700, RobinK wrote:
> foo:
> $(MAKE) $(MAKEFLAGS)
>
>
> Yeah, that's exactly what I did. So what's the correct syntax? What I need
> is, if I pass any parameters to the top level makefile, those params should
> be passed to subdirectory level makefile.

Make already does that.  That's what MAKEFLAGS are for... and make
handles it for you.

Just run:

        foo:
                $(MAKE)

and you're done.  Just be SURE to use the variable $(MAKE), not the
static string "make".

--
-------------------------------------------------------------------------------
 Paul D. Smith <psmith@gnu.org>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist



_______________________________________________
Help-make mailing list
Help-make@gnu.org
http://lists.gnu.org/mailman/listinfo/help-make