[Top][All Lists]

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

Re: [avr-gcc-list] RE: Make question (how to)

From: Rolf Ebert
Subject: Re: [avr-gcc-list] RE: Make question (how to)
Date: Tue, 03 May 2005 11:33:30 +0200
User-agent: Opera M2/7.54 (Win32, build 3929)

On Mon, 2 May 2005 Dave Hylands <address@hidden> wrote:

But this doesn't work. The SRC and ASRC are not substituted for the default
ones defined earlier in the makefile (MCU and other symbols are).

How do I do this?  What is the magic incantation to substitute a list?

The problem is that you can' assign variables as part of the recipie
(well, you can, but they only take effect for that one line).

As shown in my previous post, you do can assign variables depending on the target (at least in GNU and SUN make). The variables are set for all intermediate targets as well.

From the GNU Make Manual:

There is one more special feature of target-specific variables: when you define a target-specific variable, that variable value is also in effect for all prerequisites of this target (unless those prerequisites override it with their own target-specific variable value). So, for example, a statement like this:

prog : CFLAGS = -g
prog : prog.o foo.o bar.o

will set CFLAGS to `-g' in the command script for `prog', but it will also set CFLAGS to `-g' in the command scripts that create `prog.o', `foo.o', and `bar.o', and any command scripts which create their prerequisites.

The problem with target dependant varaiables is that you create a maintainance mess!

The simplest option is probably to create a spearate makefile for each
target, giving them names like target1.mk

I wholeheartedly support Dave's recommendation. It is a much cleaner structure. The makefiles are easier to understand and they can be managed (version control) in two separate projects. You are bound for trouble if you have a single Makefile for multiple projects!

I'd go for a variant of Dave's structure, though. Keep as much as possible in the standard Makefile, e.g. all the pattern rules. Than have Makefile include snippets that define the project specific varables, like MCU, TARGET, SRCS.



reply via email to

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