|
From: | Martin Gaarde Lund |
Subject: | Re: Gmake problem when including sub makefiles |
Date: | Thu, 17 Aug 2006 09:23:15 +0200 |
On Wednesday, 16 August, Martin Gaarde Lund (address@hidden) wrote:
> ERRORFILE = $(PROJECT).err
>
> PROJECT = project
>
> test.o:
> armcc test.c -o test.o --errors $(ERRORFILE)
>
> PROJECT = project1
>
> test1.o:
> armcc test1.c -o test1.o --errors $(ERRORFILE)
> From this example I would have expected make to assemble the following
> target commands:
> armcc test.c -o test.o --errors project.err
> armcc test1.c -o test1.o --errors project1.err
> Is it possible to make a construction which works as I intended it to?
>
> Please note that I can not depend on the target rule for defining my error
> output.
One solution has already been provided: using target-specific variables.
However, the syntax given was incorrect: you can't put a target-specific
variable setting into a command rule. You need to write them separately:
CC = armcc
ERRORFILE = $(PROJECT).err
test.o: PROJECT = project
test.o:
$(CC) $< -o $@ --errors $(ERRORFILE)
test1.o: PROJECT = project1
test1.o:
$(CC) $< -o $@ --errors $(ERRORFILE)
Alternatively you can do a similar thing with constructed variable names;
this is portable to other versions of make (including older versions of GNU
make that didn't support target-specific variable settings) if you care
about that:
CC = armcc
ERRORFILE = $(PROJECT-$@).err
PROJECT-test.o = project
test.o:
$(CC) $< -o $@ --errors $(ERRORFILE)
PROJECT-test1.o = project1
test1.o:
$(CC) $< -o $@ --errors $(ERRORFILE)
--
-------------------------------------------------------------------------------
Paul D. Smith < address@hidden> Find some GNU make tips at:
http://www.gnu.org http://make.paulandlesley.org
"Please remain calm...I may be mad, but I am a professional." --Mad Scientist
[Prev in Thread] | Current Thread | [Next in Thread] |