help-make
[Top][All Lists]
Advanced

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

Re: Extracting Name of File in CFLAGS


From: Paul Smith
Subject: Re: Extracting Name of File in CFLAGS
Date: Tue, 29 Nov 2011 20:34:56 -0500

On Tue, 2011-11-29 at 11:21 +0530, Ajay Jain wrote:
> I have an elaborate recursive make system and I want an easy way to have
> the name of the source file handy. To this end, I can use
> 
> .o : %.c
>     $Q$(CC) -D BASENAME_FILE="$(shell basename $<)" $(CFLAGS) -c $< -o $@
> 
> However, this is probably not very neat as I want all variables to reflect
> in CFLAGS.
> 
> I am more comfortable in using something like ..
> CFLAGS += -D BASENAME_FILE="$$(notdir $$<)"
> 
> in my top level Makefile and hope that this will be enough in my
> multi-layer build system. However, this does not work. Can somebody help me
> on this?

Using escaped dollar signs in the CFLAGS settings won't work at all.

Why not just use 'CFLAGS += -D BASENAME_FILE="$(notdir $<)"' ?

-- 
-------------------------------------------------------------------------------
 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]