[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
trouble cleaning the right files ..
From: |
sharan basappa |
Subject: |
trouble cleaning the right files .. |
Date: |
Mon, 18 Jun 2007 08:43:43 +0000 |
** sorry for such a long post, but I dont know how else to explain this **
I am having trouble cleaning up the right set of files. Basically the make
is divided into a
a top make file which includes module level makes. Top make has a target
called clean_all
which has module level clean targets as prereqs as follows :
clean_all : $(clean)
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)
Each module make has the following common lines at the beginning ..
local_dir := dir1
local_src := $(addprefix $(local_dir)/,print1dir1.c)
local_src += $(addprefix $(local_dir)/,print2dir1.c)
local_objs := $(subst .c,.o,$(local_src))
When I try cleaning with clean_all target, make throws out the following :
Reading makefile `SmallPrjMain.mk'...
Reading makefile `dir1/dir1.mk' (search path) (no ~ expansion)...
Reading makefile `dir2/dir2.mk' (search path) (no ~ expansion)...
Updating goal targets....
Considering target file `clean_all'.
File `clean_all' does not exist.
Considering target file `clean_dir1'.
File `clean_dir1' does not exist.
Finished prerequisites of target file `clean_dir1'.
Must remake target `clean_dir1'.
\rm dir2/print1dir2.o dir2/print2dir2.o
rm: cannot lstat `dir2/print1dir2.o': No such file or directory
rm: cannot lstat `dir2/print2dir2.o': No such file or directory
make: *** [clean_dir1] Error 1
I expect that clean_all should lead to clean_dir1 and clean_dir2.
This should result in \rm dir1/print1dir1.o dir1/print2dir1 and
\rm dir2/print1dir2.o dir2/print2dir2
But clean_all always leads to dir2/print1dir2.o dir2/print2dir2.o
I can see that make has the right rule and has proper prereqs.
But it seems defered variable substitution for local_objs in the
command is causing this issue. I know that this is how make
is expected to work, but given a problem of my kind, what
is the way out.
I can think of appending all objects to a variable and use it,
but if I want to clean objects relating to a particular target alone
then I am stuck ..
I am pasting all the 3 make file I am using
top make file
programs :=
sources :=
clean :=
objects :=
dependencies = $(subst .c,.d,$(sources));
include_dirs := lib include
CPPFLAGS += $(addprefix -I,$(include_dirs))
programs += main.c
vpath %.h $(include_dirs)
VPATH = dir1:dir2
MV := mv -f
RM := rm -f
SED := sed
all:
include dir1/dir1.mk
include dir2/dir2.mk
objects := $(subst .c,.o,$(sources))
.PHONY : all
all : main
main : main.o $(objects)
.PHONY : clean_all
clean_all : $(clean)
echo clean
dir1.mk
local_dir := dir1
local_src := $(addprefix $(local_dir)/,print1dir1.c)
local_src += $(addprefix $(local_dir)/,print2dir1.c)
local_objs := $(subst .c,.o,$(local_src))
libraries += $(local_lib)
sources += $(local_src)
programs += dir1
clean += clean_dir1
dir1 : $(local_objs)
.PHONY : clean_dir1
clean_dir1 :
\rm $(local_objs)
~
dir2.mk
local_dir := dir2
local_src := $(addprefix $(local_dir)/,print1dir2.c)
local_src += $(addprefix $(local_dir)/,print2dir2.c)
local_objs := $(subst .c,.o,$(local_src))
libraries += $(local_lib)
sources += $(local_src)
programs += dir2
clean += clean_dir2
dir2 : $(local_objs)
.PHONY : clean_dir2
clean_dir2 :
\rm $(local_objs)
Shell command
make -f SmallPrjMain.mk clean_all --debug=verbose
_________________________________________________________________
Catch all the cricketing action right here. Live score, match reports,
photos et al. http://content.msn.co.in/Sports/Cricket/Default.aspx
- trouble cleaning the right files ..,
sharan basappa <=