2021-02-18 22:00:24 +01:00
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
MCU := atmega328p
|
2021-09-08 13:59:38 +02:00
|
|
|
PROGRAMMER := usbasp
|
2021-02-18 22:00:24 +01:00
|
|
|
|
|
|
|
TARGET := main.hex
|
|
|
|
BIN := main.elf
|
|
|
|
OBJ := main.o
|
|
|
|
|
|
|
|
SHELL := sh
|
|
|
|
CC := avr-gcc
|
|
|
|
OBJCOPY := avr-objcopy
|
|
|
|
SIZE := avr-size
|
|
|
|
AVRDUDE := avrdude
|
|
|
|
|
2021-09-08 14:53:29 +02:00
|
|
|
CFLAGS := -mmcu=$(MCU) -Os -Wall -Werror -Wextra
|
2021-02-18 22:00:24 +01:00
|
|
|
|
|
|
|
all: $(TARGET)
|
|
|
|
|
|
|
|
$(TARGET): $(BIN)
|
|
|
|
${OBJCOPY} -O ihex -j .text -j .data $< $@
|
|
|
|
|
|
|
|
$(BIN): $(OBJ)
|
|
|
|
$(CC) $(CFLAGS) $< -o $@
|
|
|
|
|
|
|
|
%.o: %.c
|
2021-02-27 02:26:57 +01:00
|
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
2021-02-18 22:00:24 +01:00
|
|
|
|
|
|
|
.PHONY: flash clean check size
|
|
|
|
|
|
|
|
flash: $(TARGET) size
|
|
|
|
$(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -U flash:w:$<:a
|
|
|
|
|
|
|
|
clean:
|
2021-09-08 13:59:38 +02:00
|
|
|
$(RM) $(TARGET) $(BIN) $(OBJ)
|
2021-02-18 22:00:24 +01:00
|
|
|
|
|
|
|
check:
|
|
|
|
cppcheck main.c
|
|
|
|
|
|
|
|
size: $(BIN)
|
|
|
|
$(SIZE) --format=avr --mcu=$(MCU) $<
|