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: Andrea Riciputi
Subject: Re: My first makefile. Please help.
Date: Wed, 18 Dec 2002 18:02:33 +0100

On Wednesday, Dec 18, 2002, at 17:16 Europe/Rome, Allan Wind wrote:

AllFiles = $(wildcard *)

This one is evil, it will pick everything up (temporary files, that test
program you wrote to figure something out, object files, binaries etc).

Right, but with the following filter command I throw away everything useless.

ObjectFiles = $(patsubst %.c,$(ObjectDir)/%.o,$(SourceFiles))

You can print these out, to see where things go wrong.

Already done. I get the right list, something like:

./obj/foo.o ./obj/bar.o

MyProject: $(ObjectFiles)
        $(CCompiler) $(CFLAGS) $(LDFLAGS) $(ObjectFiles) -o $@
                                            ^^^^^^^^^^^^^^
Use $^ (or $? instead).

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 $@

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!!!!

Any other hint???

Thanks,
Andrea.
---
Andrea Riciputi        <mailto:address@hidden>

"Science is like sex: sometimes something useful comes out,
  but that is not the reason we are doing it" -- (Richard Feynman)




reply via email to

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