[Top][All Lists]

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

Re: Combining "auto dependency generation" with "Target specific variabl

From: Greg Chicares
Subject: Re: Combining "auto dependency generation" with "Target specific variable values"
Date: Sun, 02 Aug 2009 18:09:52 +0000
User-agent: Thunderbird (Windows/20090302)

On 2009-08-02 16:40Z, mwnn wrote:
> Hi all,
>     The "Auto dependecy generation" mechanism can be used to generation 
> dependency list for a target automatically. For a C file this can be 
> done by invoking gcc with the -MM switch. So in a make file we normally 
> have the following rule to generate dependency files and later include them:
> -------------------------------------------------------------------------------------
> %.d: %.c
>              @set -e; rm -f $@; \
>               $(CC) -M $(CPPFLAGS) $< > address@hidden; \
>               sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < address@hidden > $@; \
>               rm -f address@hidden
>      sources = foo.c bar.c
>      include $(sources:.c=.d)
> -------------------------------------------------------------------------------------
> When using the above facility how can use the "Target specific variable 
> values" facility?
> For example, I would want the CPP flag -DLINUX to be defined for foo.c only.

Set preprocessor flags for generating autodependencies the same
way you would for compiling. For example:


BTW, extra options that have been added to the gnu preprocessor
(-MD -MP -MT -MF...) generally make the use of 'sed' unnecessary
for autodependencies, and you can even generate them as a side
effect of a '%.o: %.c' rule.

reply via email to

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