help-make
[Top][All Lists]
Advanced

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

Re: trouble cleaning the right files ..


From: sharan basappa
Subject: Re: trouble cleaning the right files ..
Date: Mon, 18 Jun 2007 10:58:58 +0000

Thanks Philip. I have thought about using different name but that makes make file
really clumsy. I will explore target specific variable way of doing it..

Regards,
Sharan


From: "Philip Guenther" <address@hidden>
To: "sharan basappa" <address@hidden>
CC: address@hidden
Subject: Re: trouble cleaning the right files ..
Date: Mon, 18 Jun 2007 04:22:47 -0600

On 6/18/07, sharan basappa <address@hidden> wrote:
...
Each module make appends its clean target to clean variable as :
clean     += clean_dir1 .. so eventually clean_all looks like
clean_all : clean_dir1 clean_dir2

clean_dir1 (for example) rule is :

clean_dir1 :
        \rm $(local_objs)

The expansion of variables in command rules is always deferred until
the command is run.  That doesn't take place until the makefiles have
been completely parsed.  Ergo, unless you use a target-specific
variable assignment, the above will use the value of local_objs that
was last set during the parsing.  That's what's causing your problem.

There are two solutions:
1) use target-specific variables.  Check out the info pages for the details
   (just search for "target-specific"), but the quick-n-dirty kludge would
  be to add something like:
       clean_dir1: local_objs := $(local_objs)
  near where the clean_dir1 target is defined and similar with other
such targets.

2) instead of using the same variable for all the directories, use a different
   name for each:
       local_objs_dir1 := $(subst .c,.o,$(local_src))
       dir1: $(local_objs_dir1)
       clean_dir1:
               $(RM) $(local_objs_dir1)

  That can be mostly automated using computed names:
       local_objs_$(local_dir) := $(subst .c,.o,$(local_src))
       dir1: $(local_objs_$(local_dir))
       clean_dir1:
               $(RM) $(local_objs_$(subst clean_,,$@))

  ...but that's probably only worthwhile if you factor out that code
into a file
  that each submakefile then included.


Philip Guenther

_________________________________________________________________
Marriage? Get Detailed Profiles only at Shaadi.com. http://www.shaadi.com/ptnr.php?ptnr=mhottag





reply via email to

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