[Top][All Lists]

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

Re: Adding new prerequisites to a target

From: Paul D. Smith
Subject: Re: Adding new prerequisites to a target
Date: Tue, 30 Aug 2005 08:50:48 -0400

%% Bhaskar G <address@hidden> writes:

  bg> I would like to add a new prerequisite to the rule all, I can
  bg> achieve this as mentioned below. I would like to know if there is
  bg> any other way around to achieve this. I am using gmake
  bg> 3.80 in linux.

  bg> gmake NEWRULE=c

  bg> all: a b $(NEWRULE)
  bg>         @echo $@

  bg> a b:
  bg>         @echo $@
  bg> $(NEWRULE):
  bg>         @echo $@

It's really not clear from this example what you are trying to do.

If you're asking, can I create a new rule from the command line, then
the answer is "not really", other than the way you've done it.  You can
use .DEFAULT, like this:

    .DEFAULT: ; @echo $@

to define a rule that will be invoked if no other rule matches (see the
GNU make manual).  You can then do something like:

    gmake c all

which will build "c" using the .DEFAULT rule and then build "all".

But there's no way to add a prerequisite to a rule from the command line
other than the kind of thing you're doing above, with a variable setting.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist

reply via email to

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