PRG = glg
OBJ = main.o tff.o mmc.o
MCU_TARGET = atmega168
OPTIMIZE = -Os -mcall-prologues
DEFS =
LIBS =
DEBUG = dwarf-2
CC = avr-gcc
ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs
ALL_ASFLAGS = -mmcu=$(MCU_TARGET) -I. -x assembler-with-cpp $(ASFLAGS)
CFLAGS = -g$(DEBUG) -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET) $(DEFS)
LDFLAGS = -Wl,-Map,$(PRG).map
OBJCOPY = avr-objcopy
OBJDUMP = avr-objdump
SIZE = avr-size
all: $(PRG).elf lst text size
$(PRG).elf: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
clean:
rm -rf *.o $(PRG).elf *.eps *.bak *.a
rm -rf *.lst *.map $(EXTRA_CLEAN_FILES)
rm -rf $(PRG).hex
size: $(PRG).elf
$(SIZE) $(PRG).elf
lst: $(PRG).lst
%.lst: %.elf
$(OBJDUMP) -h -S $< > $@
%.o : %.S
$(CC) -c $(ALL_ASFLAGS) $< -o $@
text: hex
hex: $(PRG).hex
%.hex: %.elf
$(OBJCOPY) -j .text -j .data -O ihex $< $@