Makefile help needed

Jerry Feldman gaf at blu.org
Sat Jul 2 08:02:18 EDT 2005


Grrr. A day earlier and I could have given you more help since I'm
working on a very complex project. Even the makefiles are generated on
the fly, and use about every element that you can put into a makefile
with many ifeq and ifneq. 

 On Sat, 02 Jul 2005 02:16:32 -0400
David Kramer <david at thekramers.net> wrote:

> My makefile is *mostly* working.
> 
> My problem is this:  I want to build a .o in a different directory from the 
> current one, and it's being rather stubborn unless I spell out the rule.
> 
> Imagine if you will, a makefile that can build target1, target2, and 
> target3, and I'm adding troubletarget.o to it.  Assume troubletarget.c is in 
> the currect directory with everything else
> 
> If I do:
> all: target1 target2 target3 troubletarget.o
> it builds fine.
> 
> If I do:
> all: target1 target2 target3 ./troubletarget.o
> it builds fine.
> 
> If I do:
> 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.
> 
> If I add a rule like:
> ../otherdir/troubletarget.o: troubletarget.c
> it still doesn;t attempt to build it.
> 
> 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,
> 
> 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.
> 
> 
> Does this make sense?  What am I doing wrong?  Thanks in advance.
> _______________________________________________
> Discuss mailing list
> Discuss at blu.org
> http://olduvai.blu.org/mailman/listinfo/discuss
> 


-- 
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.blu.org/pipermail/discuss/attachments/20050702/068af22a/attachment.sig>


More information about the Discuss mailing list