From 559736432356e2bb4ce805e60c32353a5582a568 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Mon, 25 Apr 2022 13:42:06 +0200 Subject: working makefile for 3pi robot --- makefile | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 makefile (limited to 'makefile') diff --git a/makefile b/makefile new file mode 100644 index 0000000..0f00eaf --- /dev/null +++ b/makefile @@ -0,0 +1,41 @@ +DEVICE = atmega328p +MCU = atmega328p +AVRDUDE_DEVICE = m328p +DEVICE ?= atmega168 +MCU ?= atmega168 +AVRDUDE_DEVICE ?= m168 + +CFLAGS=-g -Wall -mcall-prologues -mmcu=$(MCU) $(DEVICE_SPECIFIC_CFLAGS) -Os +LDFLAGS=-Wl,-gc-sections -lpololu_$(DEVICE) -Wl,-relax + +PORT ?= /dev/ttyACM0 + +SOURCES := $(wildcard *.c) +OBJECTS := $(patsubst %.c,%.o, $(SOURCES)) + +AVRDUDE=avrdude +CC=avr-gcc +OBJ2HEX=avr-objcopy + +all: out.hex + +clean: + rm -f *.o out.hex a.out compile_commands.json + +a.out: $(OBJECTS) + $(CC) $(OBJECTS) $(LDFLAGS) + +.o: + $(CC) -c $(CFLAGS) $< + +out.hex: a.out + $(OBJ2HEX) -R .eeprom -O ihex $< $@ + +flash: out.hex + $(AVRDUDE) -p $(AVRDUDE_DEVICE) -c avrisp2 -P $(PORT) -U flash:w:out.hex + +format: + find . -name '*.c' -o -name '*.h' | clang-format -i + +compile_commands: clean + bear -- make -- cgit v1.2.3