avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] Make file to recursivly generate code for more than


From: Christian Ludlam
Subject: Re: [avr-gcc-list] Make file to recursivly generate code for more than one target ?
Date: Thu, 03 Jun 2004 23:10:46 +0100
User-agent: Messenger-Pro/1.00c (MsgServe/1.00a) (RISC-OS/5.06) POPstar/2.05

On 3 Jun Anton Erasmus wrote:

> >From: "Anton Erasmus" <address@hidden> To: <address@hidden>
> >Sent: Wednesday, June 02, 2004 1:56 PM Subject: [avr-gcc-list] Make file
> >to recursivly generate code for more than one target ?


> >Hi,

> >Does anyone have a nice example of a makefile that can generate code
> >for more than one target ? On one PCB I can use either the ATMega16 or
> >ATMega32.
> >I want my makefile to generate a target_16.rom and a target_32.rom every
> >time I
> >build the code.
> >For library code it would also be nice to be able to build the library for
> >all possible
> >AVR targets with one make command.

> I would prefer not to use a shell script, as I am sure that one can do this
> with only the makefile itself.

You can do it with make. You need to keep a set of object files for each
architecture, each of which depends on the corresponding source file. Using
GNU make syntax, you might want something like this:



OBJS = source_file_1 source_file_2 source_file_etc

OBJS_MEGA32 = $(addsuffix .o32, $(OBJS))
OBJS_MEGA16 = $(addsuffix .o16, $(OBJS))

# default target
all:     target_16.rom target_32.rom

target_32.rom: $(OBJS_MEGA32)
        avr-ld -o $@ $(LINKOPTS) -mmcu=atmega32 $(OBJS_MEGA32)

target_16.rom: $(OBJS_MEGA16)
        avr-ld -o $@ $(LINKOPTS) -mmcu=atmega16 $(OBJS_MEGA16)

%.o32: %.c
        avr-gcc -o $@ -c $< $(CCOPTS) -mmcu=atmega32

%.o16: %.c
        avr-gcc -o $@ -c $< $(CCOPTS) -mmcu=atmega16



Completely untested, but it shows the principle of what you'd need to do.

-- 
Christian Ludlam
address@hidden


reply via email to

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