Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


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

Makefile help needed



On Sat, Jul 02, 2005 at 02:16:32AM -0400, David Kramer wrote:
> My makefile is *mostly* working...

I'm having a little trouble interpreting this part of your note:

> all: target1 target2 target3 ../otherdir/troubletarget.o
> I get "make: *** No rule to make target ../otherdir/troubletarget.o"
> which I can understand, because it doesn't know where the C file is.
> 
> HOWEVER, if I do:
> all: target1 target2 target3 ../otherdir/troubletarget.o
> it simply does not try to build it at all.

... it seems to be describing two different responses to the same thing.

> If I change that to
> ../otherdir/troubletarget.o: troubletarget.c
> 	$(CC) $(CFLAGS) -c $< -o $@
> it works, but I don't see why I have to do that, since it already knows 
> how to turn a .c into a .o, because earlier in the file I have
> .c.o:
> 	$(CC) $(CFLAGS) -c $< -o $@
> which should build it fine,

The Make manual says:

  A double-suffix rule is defined by a pair of suffixes: the target
  suffix and the source suffix. It matches any file whose name ends with
  the target suffix. The corresponding implicit prerequisite is made by
  replacing the target suffix with the source suffix in the file name.
  A two-suffix rule whose target and source suffixes are `.o' and `.c'
  is equivalent to the pattern rule `%.o : %.c'.

This suggests to me that it will fail for the same reason...

> Note that I can't use the newer style
> %.o : %.c ; command...
> because the stem is different on the .o and the .c since they're in 
> different directories.

... that the pattern rule fails.

It looks like you've already found a solution to your problem - you just
don't like it :-).


Nathan




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org