# #$Id: Makefile,v 1.37 2005/08/23 17:35:35 dkelly Exp $ # CC= avr-gcc #MCU=atmega8 #MCU=atmega16 MCU=atmega32 #MCU=atmega163 #MCU=atmega323 #MCU=atmega64 #MCU=atmega128 #CFLAGS= -O -gdwarf-2 -Wall -ffreestanding -mmcu=$(MCU) CFLAGS= -O -g -Wall -ffreestanding -mmcu=$(MCU) # .eeprom section start must match here and in _eeprom.hex rule: LDFLAGS= -Wl,-Map,address@hidden -Wl,--section-start=.eeprom=00810001 #-Wl, -u,vfprintf -lprintf_min #-Wl, -u,vfprintf -lprintf_flt -lm .SUFFIXES: .SUFFIXES: .c .o .bin .elf .hex .srec .cof .list .c.o: $(CC) $(CFLAGS) -c $< .elf.bin: avr-objcopy -R .eeprom -O binary $< $@ # Note this GNU Make syntax is bass-ackwards from BSD suffix conversion # but it allows changing more than the suffix in generated target. %_flash.hex: %.elf avr-objcopy -j .text -j .data -O ihex $< $@ %_eeprom.hex: %.elf avr-objcopy -j .eeprom --change-section-lma .eeprom=0 -O ihex $< $@ # # This is a fun conversion, creates an assembly dump # including C source lines interspersed as comments. # .elf.list: avr-objdump -DS $< > $@ # one per line makes diffs easier to read SRCS = \ main.c \ lcd.c \ menu.c \ ui.c \ kb.c \ rs.c \ k-line.c \ encoder.c OBJS = $(SRCS:.c=.o) all: object.elf object.list object_flash.hex object_eeprom.hex object.elf: $(OBJS) $(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(OBJS) $(LDLIBS) avr-size $@ clean: rm -f *~ *.elf *.cof *.bin *.hex *.srec *.s *.o *.pdf *core *.list *.map .depend # BSD make automatically reads .depend if it exists depend: clean $(SRCS) $(CC) -E -M $(SRCS) > .depend # -include fails silently in GNU Make if .depend does not exist # OTOH -include is not BSD Make compatible. -include .depend