55 lines
1.0 KiB
Makefile
55 lines
1.0 KiB
Makefile
OPTIMIZE = -O2
|
|
CPPFLAGS += -DF_CPU=$(MCU_FREQ)
|
|
override CFLAGS = -g --std=c99 -Wall $(OPTIMIZE) -mmcu=$(MCU_TARGET)
|
|
override LDFLAGS =
|
|
CC = avr-gcc
|
|
OBJCOPY = avr-objcopy
|
|
OBJDUMP = avr-objdump
|
|
AVRDUDE_ARGS =
|
|
|
|
ifdef BOARD
|
|
include boards/$(BOARD).mk
|
|
endif
|
|
|
|
default: $(PROG).hex
|
|
|
|
clean:
|
|
rm -rf *.o drivers/*.o *.elf *.lst *.hex *.bin *.asm
|
|
|
|
# dependencies
|
|
blink.elf: drivers/led.o
|
|
|
|
# generic rules
|
|
%.o: %.c
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $^
|
|
|
|
%.elf: %.o
|
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
|
|
|
%.lst: %.elf
|
|
$(OBJDUMP) -h -S $< > $@
|
|
|
|
%.hex: %.elf
|
|
$(OBJCOPY) -j .text -j .data -O ihex $< $@
|
|
|
|
%.bin: %.elf
|
|
$(OBJCOPY) -j .text -j .data -O binary $< $@
|
|
|
|
%.asm: %.elf
|
|
$(OBJDUMP) -z -j .text -m avr5 -d $< > $@
|
|
|
|
# flashing definitions and helper target
|
|
AVRDUDE_ARGS += -p$(MCU_TARGET)
|
|
AVRDUDE_ARGS += -c$(AVRDUDE_TYPE)
|
|
ifdef AVRDUDE_TTY
|
|
AVRDUDE_ARGS += -P$(AVRDUDE_TTY)
|
|
endif
|
|
ifdef AVRDUDE_BAUD
|
|
AVRDUDE_ARGS += -b$(AVRDUDE_BAUD)
|
|
endif
|
|
|
|
ifdef AVRDUDE_TYPE
|
|
flash: $(PROG).hex
|
|
avrdude $(AVRDUDE_ARGS) -U flash:w:$(PROG).hex
|
|
endif
|