2021-02-18 22:00:24 +01:00
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
MCU := atmega328p
|
|
|
|
PROGRAMMER := usbtiny
|
|
|
|
|
|
|
|
TARGET := main.hex
|
|
|
|
BIN := main.elf
|
|
|
|
OBJ := main.o
|
|
|
|
|
|
|
|
SHELL := sh
|
|
|
|
CC := avr-gcc
|
|
|
|
OBJCOPY := avr-objcopy
|
|
|
|
SIZE := avr-size
|
|
|
|
AVRDUDE := avrdude
|
|
|
|
|
|
|
|
CFLAGS := -mmcu=$(MCU) -Os -Wall -Werror -Wextra -Wpedantic
|
|
|
|
|
|
|
|
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:
|
|
|
|
$(RM) main.o main.elf main.hex
|
|
|
|
|
|
|
|
check:
|
|
|
|
cppcheck main.c
|
|
|
|
|
|
|
|
size: $(BIN)
|
|
|
|
$(SIZE) --format=avr --mcu=$(MCU) $<
|