32 lines
692 B
Makefile
32 lines
692 B
Makefile
PREFIX := avr-
|
|
CFLAGS_COMMON := -I/usr/avr/include/
|
|
CFLAGS_CPU := -DF_CPU=16000000UL -mmcu=atmega328p -Os
|
|
CFLAGS := $(CFLAGS_COMMON) $(CFLAGS_CPU)
|
|
LDFLAGS_COMMON := -I/usr/avr/include/
|
|
LDFLAGS_CPU := -mmcu=atmega328p
|
|
LDFLAGS := $(LDFLAGS_COMMON) $(LDFLAGS_CPU)
|
|
CC := $(PREFIX)gcc
|
|
|
|
build: main.hex
|
|
|
|
flash: main.hex
|
|
sudo avrdude -FV -c arduino -p ATmega328p -P /dev/ttyUSB0 -b 57600 -U flash:w:$<
|
|
|
|
clean:
|
|
$(RM) *.hex *.elf *.o
|
|
|
|
bear: compile_commands.json
|
|
|
|
compile_commands.json: clean
|
|
bear -- make build
|
|
|
|
main.hex: main.elf
|
|
$(PREFIX)objcopy -O ihex -R .eeprom $< $@
|
|
|
|
main.elf: main.o
|
|
$(CC) -w $(LDFLAGS) -o $@ $<
|
|
|
|
%.o: %.c %.h
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
.PHONY: build flash clean bear
|