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

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

RE: [avr-gcc-list] unknown Make %. behavior


From: Dean Ferreyra
Subject: RE: [avr-gcc-list] unknown Make %. behavior
Date: Mon, 13 Jan 2003 01:01:33 -0800

I think this:

$(TARGET).elf: $(OBJ)
        $(COMPILE) $(LDFLAGS) $(OBJ) $(LIBFLAGS) --output $@

is probably the better way to write that particular rule.

As for the deletions, that's how gnu make works.  All the rules in that
makefile are implicit rules, except this line:

all: $(TARGET).elf

When gnu uses chains of implicit rules to generate a file, the files created
along the way are considered intermediate files and are deleted once the
final target is created.  This part:

%.elf: $(OBJ)
        $(COMPILE) $(LDFLAGS) $(OBJ) $(LIBFLAGS) --output $@

is an implicit pattern rule, too, thanks to the % wildcard.  If the .o files
don't already exist, and they're not mentioned anywhere else in a normal
rule, then the .o files will be considered intermediate files and will be
deleted.

On the other hand, this:

$(TARGET).elf: $(OBJ)
        $(COMPILE) $(LDFLAGS) $(OBJ) $(LIBFLAGS) --output $@

is a normal rule so now the .o files are not considered intermediate files
and will remain.

Dean

-----Original Message-----
From: address@hidden [mailto:address@hidden
Behalf Of Sander Pool
Sent: Sunday, January 12, 2003 8:25 PM
To: Avr-Gcc-List
Subject: [avr-gcc-list] unknown Make %. behavior



Hi,

it's been quite a few years since I wrote makefiles as part of my job and
this was on Solaris with Sun make. Far less capable than gmake. So I'm a
little stumped right now. I use WinAVR on Win2k which comes with Gnu-make
3.78.1. The sample makefile that Eric provided with the package contains
these lines:

.SECONDARY : $(TARGET).elf
%.elf: $(OBJ)
        $(COMPILE) $(LDFLAGS) $(OBJ) $(LIBFLAGS) --output $@

The OBJ variable contains the .0 files that make up the project. The odd
thing is that after the compile/link is done the .o's get removed! There is
no rule in the makefile to do that. If I change the lines above to this:

.SECONDARY : $(TARGET).elf
$(TARGET).elf: $(OBJ)
        $(COMPILE) $(LDFLAGS) $(OBJ) $(LIBFLAGS) --output $@

It leaves the .o files alone, as it should.

Does anyone know what's going on? I have attached the whole Makefile in case
you want to look at it.

Thanks,

        Sander


avr-gcc-list at http://avr1.org



reply via email to

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