help-make
[Top][All Lists]
Advanced

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

Re: Problem using -R in MAKEFLAGS


From: Colm Aengus Murphy
Subject: Re: Problem using -R in MAKEFLAGS
Date: Mon, 06 Nov 2006 16:38:04 +0000
User-agent: Thunderbird 1.5.0.7 (Windows/20060909)

Hi John,

I tried using ".SUFFIXES:".
Its a lot better but it still doesn't stop all of the built in rules.

For the simple makefile:
.SUFFIXES:
%.exe : %.c
   gcc -o $(@F) $<

I still get:
 Considering target file `helloworld.c'.
  Looking for an implicit rule for `helloworld.c'.
  Trying pattern rule with stem `helloworld'.
  Trying implicit prerequisite `helloworld.w'.
  Trying pattern rule with stem `helloworld.c'.
  Trying implicit prerequisite `helloworld.c,v'.
  Trying pattern rule with stem `helloworld.c'.
  Trying implicit prerequisite `RCS/helloworld.c,v'.
  Trying pattern rule with stem `helloworld.c'.
  Trying implicit prerequisite `RCS/helloworld.c'.
  Trying pattern rule with stem `helloworld.c'.
  Trying implicit prerequisite `s.helloworld.c'.
  Trying pattern rule with stem `helloworld.c'.
  Trying implicit prerequisite `SCCS/s.helloworld.c'.
  Trying pattern rule with stem `helloworld'.
  Trying implicit prerequisite `helloworld.w'.
  Looking for a rule with intermediate file `helloworld.w'.
   Avoiding implicit rule recursion.
   Trying pattern rule with stem `helloworld.w'.
   Trying implicit prerequisite `helloworld.w,v'.
   Trying pattern rule with stem `helloworld.w'.
   Trying implicit prerequisite `RCS/helloworld.w,v'.
   Trying pattern rule with stem `helloworld.w'.
   Trying implicit prerequisite `RCS/helloworld.w'.
   Trying pattern rule with stem `helloworld.w'.
   Trying implicit prerequisite `s.helloworld.w'.
   Trying pattern rule with stem `helloworld.w'.
   Trying implicit prerequisite `SCCS/s.helloworld.w'.
  No implicit rule found for `helloworld.c'.
  Finished prerequisites of target file `helloworld.c'.
 No need to remake target `helloworld.c'.

Regards

Colm A

John Graham-Cumming wrote:
Philip Guenther wrote:
You can't affect how make processes a makefile by setting MAKEFLAGS in
the makefile itself.  Currently, make sets all the built-in variables
and rules before parsing the makefile, and that can be tested by the
makefile itself, so changing it would create all sorts of problems.

That's not actually totally true. Page 50 of the GNU Make manual states: 'You can also set MAKEFLAGS in a makefile, to specify additional flags that should be in effect for that makefile.'

For example,

    MAKEFLAGS += -n

    .PHONY: all
    all:
        @echo Doing all

will print 'echo Doing all' because the -n is in effect for that Makefile. Unfortunately, as you do state, there are some flags that will not work when MAKEFLAGS is set inside a Makefile. The source of GNU Make shows that MAKEFLAGS is actually parsed twice: once before handling the Makefile and once after:

/* Decode switches again, in case the variables were set by the makefile. */
  decode_env_switches (STRING_SIZE_TUPLE ("MAKEFLAGS"));

The flag you want to set for no built in rules is -r (note that the original message errorneously talked about -R which is for built in variables although it does force -r). This translates to the no_builtin_rules_flag variable in GNU Make's source.

Unfortunately, this flag is used to control the setting up of the built in rules BEFORE the Makefiles are parsed (as you state) and hence you can't add -r to MAKEFLAGS in a Makefile and have it affect that Makefile. This is done so that new rules in the Makefile can override the default rules as necessary.

Most of the command-line switches will work if specified in MAKEFLAGS in the Makefile and affect that Makefile (you can try out silly examples like -v and -p to see the effect).

Now, to actually solve your problem (disabling default rules in a Makefile), there's a simple technique: you clear the default suffix list for built-in rules. This will prevent any of the built-in rules from being searched and you can go ahead and define your own pattern rules.

So simply write:

    .SUFFIXES:

in the Makefile where you want to disable built-in rules. This won't kill the built-in variables, but they are probably less of a worry.

John.

--
---------------------------------------------------------------------
Colm Aengus Murphy,                Tel       : +353 1 2911000
Senior Hardware Design Engineer,   Direct Tel: +353 1 2911373
Silicon & Software Systems,        Fax       : +353 1 2911001
South County Business Park,
Leopardstown,                      E-mail: address@hidden
Dublin 18.                         WWW   : www.s3group.com
Ireland
---------------------------------------------------------------------


The information contained in this e-mail and in any attachments is confidential 
and is designated solely for the attention of the intended recipient(s). If you 
are not an intended recipient, you must not use, disclose, copy, distribute or 
retain this e-mail or any part thereof. If you have received this e-mail in 
error, please notify the sender by return e-mail and delete all copies of this 
e-mail from your computer system(s).
Please direct any additional queries to: address@hidden
Thank You.




reply via email to

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