help-make
[Top][All Lists]
Advanced

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

Re: My first makefile. Please help.


From: Allan Wind
Subject: Re: My first makefile. Please help.
Date: Wed, 18 Dec 2002 12:20:57 -0500
User-agent: Mutt/1.4i

On 2002-12-18 18:02:33, Andrea Riciputi wrote:
> It seems not to make any difference. Anyway the error message seems to 
> complain to unable to find a rule for '/obj/foo.o'. I suspect that it 
> can't match the target of the following rule:
> 
> $(ObjectDir)/%.o: $(SourceDir)%.c
>         $(CCompiler) $(CFLAGS) -c $^ -o $@

Hmm... $(ObjectDir) should be full path (so /obj/foo.o seems odd), add a
'/' for the src too.

> Note that an explicit rule such as:
> 
> $(ObjectDir)/foo.o: $(SourceDir)/foo.c
>          $(CCompiler) $(CFLAGS) -c $^ -o $@
> works. But I'd happy to avoid to write an explicit rule for each source 
> file!!!!

That's understandable, I usually do one of two things:

1) pattern + explicit rules

%.o: %.c
        $(CC) ..

file.o: file.c

file.c: file.h

...

2) auto generate dependencies (see info page) which I then include:

Maybe your % is matching the wrong thing.  Also are you sure that all .o
files depend on all .c files?


/Allan
-- 
Allan Wind
P.O. Box 2022
Woburn, MA 01888-0022
USA

Attachment: pgpj5nlQs93rb.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]