clock_generator/firmware/src/Makefile

42 lines
634 B
Makefile
Raw Normal View History

.SUFFIXES:
MCU := atmega328p
PROGRAMMER := usbasp
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
$(CC) $(CFLAGS) -c $< -o $@
.PHONY: flash clean check size
flash: $(TARGET) size
$(AVRDUDE) -p $(MCU) -c $(PROGRAMMER) -U flash:w:$<:a
clean:
$(RM) $(TARGET) $(BIN) $(OBJ)
check:
cppcheck main.c
size: $(BIN)
$(SIZE) --format=avr --mcu=$(MCU) $<