help-make
[Top][All Lists]
Advanced

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

Re: Variables within Pattern Rules


From: John Graham-Cumming
Subject: Re: Variables within Pattern Rules
Date: Wed, 05 Jan 2005 08:18:18 -0500

On Wed, 2005-01-05 at 06:25, Barry Clarkson wrote:
> If I have two files called 'myfile.c' and
> 'anotherfile.c', a pattern rule for '(%.o) : %.c' I
> want to be able to pass 'MYFILE_DEFS' and
> 'ANOTHERFILE_DEFS' as a define to $(CC) along the
> lines of...
> 
> DEF=`echo $(basename $<) | tr '[a-z]' '[A-Z]'`_DEFS
> 
> ...so that I can perform...
> 
> gcc -DMYFILE_DEFS myfile.c ...
> gcc -DANOTHERFILE_DEFS anotherfile.c ...

I think the easiest way for you to do this is:

    (%.o) : CFLAGS += -D$(DEF)

That means for every .o file generated you'll get -D$(DEF) added to the
CFLAGS. DEF will only be expanded when the rule is about to run and
hence will have the correct value.

John.
-- 
John Graham-Cumming

Home: http://www.jgc.org/
Work: http://www.electric-cloud.com/
POPFile: http://getpopfile.org/






reply via email to

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