I am facing a rather strange problem with make. My make file contains:
all: item1 item2
item1: dep1 dep2
dep1:
@echo
cd $(HOME)/apps; /bin/rm -f $(D_ALL_OBJECTS)
cd $(SRCHOME)/fusionapps; make -k -f $(SOMEMAKEFILE) $(D_ALL_OBJECTS)
@echo
dep2:
@echo
cd $(HOME)/apps; /bin/rm -f $(D2_ALL_OBJECTS)
cd $(SRCHOME)/fusionapps; make -k -f $(SOMEMAKEFILE) $(D2_ALL_OBJECTS)
@echo
item2: ...
.....
Now, "make -f Makefile item1" works, but when I try "make -f Makefile all" it doesn't work. Do you people see any problems in my makefile?
Thanks
Addendum:
Well, it looks like make doesn't allow targets that have same name as some directory in the current level. Observation:
- "all" is a directory @ $(HOME)/apps
all1: item1 item2worksall: item1 item2doesn't work
So any target name having same name as a directory seems to fail (as in, fails to do anything useful).
I am pretty sure I am doing something absurdly wrong here.
-
make: Nothing to be done for `all'.matt– matt2009年02月25日 14:24:41 +00:00Commented Feb 25, 2009 at 14:24
-
Fails to do anything useful - sort of. The directory exists; if it was last modified (a file added or removed) since the dependencies were last changed, there is nothing that make needs to do to bring it up to date. It is good advice not to use a directory name as a target.Jonathan Leffler– Jonathan Leffler2010年02月02日 15:20:35 +00:00Commented Feb 2, 2010 at 15:20
3 Answers 3
When you write:
all: item1 item2
and then request make all, that tells make:
- Find a file system object called
alland make sure anything it depends on (item1,item2) is up to date. - If
alldoes not exist or is out of date w.r.t either of the file system objects calleditem1oritem2, then do the specified actions (none in this example) and then considerallup to date. - If
allis a directory, it exists. If it has been modified recently, it will be up to date.
The suggestion to use .PHONY: all item1 item2 is good for GNU Make; it does not work with other variants of make.
Do not use target names that are directory names - unless you're sure you know what you're doing. And use .PHONY.
Comments
Try phony-declaring your all-target.
Comments
Well looks like make doesn't allow targets who have same name as some directory in the current level. Observation :
-"all" is a directory @ $(HOME)/apps -all1/2/3: item1 item2 works -all: item1 item2 doesn't work so is the any target name having same name as the directory.
I am pretty sure I am doing anything absurdly wrong here.