views:

282

answers:

3

Hi all,

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 item2 works
  • all: item1 item2 doesn'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.

+1  A: 

Try phony-declaring your all-target.

unwind
A: 

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.

Please add extra info to the question. I've done it for you; now remove this. Thanks.
Jonathan Leffler
+2  A: 

When you write:

all: item1 item2

and then request make all, that tells make:

  • Find a file system object called all and make sure anything it depends on (item1, item2) is up to date.
  • If all does not exist or is out of date w.r.t either of the file system objects called item1 or item2, then do the specified actions (none in this example) and then consider all up to date.
  • If all is 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.

Jonathan Leffler