help-make
[Top][All Lists]
Advanced

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

Re: rules and macro query


From: Paul Smith
Subject: Re: rules and macro query
Date: Thu, 06 May 2010 12:27:22 -0400

On Thu, 2010-05-06 at 01:23 -0700, Payal wrote:
> Hello all,
> I have a few simple doubts. Can someone help with them, please?
> 
> 1. In target specific variables, how can I define multiple vars. Is
> this the only way,
> X : a=foo
> X : b=bar

Yes that's the only way.

> 2. How to define a target specific macro (with define)? This does not
> work.
> $ cat -vet Makefile
> aaa : define foo$
> hi foo$
> endef$

In this version of GNU make you have to define the value separately,
then assign it as a target-specific macro.  I did some work on this in
the next version of GNU make but it might not yet be fully implemented.
This is tricky because you can have ifdef's inside the define, as well
as outside, etc.

define foo_value
hi foo
endef

aaa: foo = $(foo_value)

> 3. A silly query. In a rule, after target : prereq. can only these
> things come,
> a. a shell command (after a hard tab)
> b. a make comment
> 
> Can't we give "make" variables or functions there? If yes, can someone
> give simple example or two please?

You cannot.  After the colon from a target you can have EITHER
prerequisites or a semicolon/recipe combination, OR a target variable
assignment.

You cannot, ever, mix and match in the same target definition.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          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





reply via email to

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