aboutsummaryrefslogtreecommitdiff
path: root/robot/makefile
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2022-05-13 14:15:13 +0200
committerlonkaars <loek@pipeframe.xyz>2022-05-13 14:15:13 +0200
commit4dc9b15829321e29b82c5f0317d2a0811aee6482 (patch)
tree0b72b2e1ee14d500cd49311131a084983cdf5de6 /robot/makefile
parentd473b1f2a3c37f08510bb8ee5630c9254969bd55 (diff)
implement dummy simulation functionssim
Diffstat (limited to 'robot/makefile')
-rw-r--r--robot/makefile20
1 files changed, 14 insertions, 6 deletions
diff --git a/robot/makefile b/robot/makefile
index 598e0fa..fb30b7e 100644
--- a/robot/makefile
+++ b/robot/makefile
@@ -4,24 +4,30 @@ 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
+SIM =
PORT ?= /dev/ttyACM0
+CFLAGS=-g -Wall $(DEVICE_SPECIFIC_CFLAGS) -Os
+LDFLAGS=-Wl,-gc-sections -Wl,-relax
+
+CFLAGS += $(if $(SIM), -DW2_SIM, -mcall-prologues -mmcu=$(MCU))
+LDFLAGS += $(if $(SIM), , -lpololu_$(DEVICE))
+
SOURCES := $(wildcard *.c)
HEADERS := $(wildcard *.h)
OBJECTS := $(patsubst %.c,%.o, $(SOURCES))
+PREFIX := $(if $(SIM), , avr-)
+
AVRDUDE=avrdude
-CC=avr-gcc
-OBJ2HEX=avr-objcopy
+CC=$(PREFIX)gcc
+OBJ2HEX=$(PREFIX)objcopy
BUILD_STR=$(shell git update-index -q --refresh; git describe --tags --dirty='*' --broken='x' | cut -c1-20)
CFLAGS += -DW2_BUILD_STR="$(BUILD_STR)"
-all: out.hex
+all: $(if $(SIM), a.out, out.hex)
clean:
rm -f *.o out.hex a.out compile_commands.json
@@ -40,6 +46,8 @@ flash: out.hex
$(AVRDUDE) -p $(AVRDUDE_DEVICE) -c avrisp2 -P $(PORT) -U flash:w:out.hex
format:
+ SOURCES := $(filter-out sim.c, $(SOURCES))
+ HEADERS := $(filter-out sim.h, $(HEADERS))
clang-format -i $(SOURCES) $(HEADERS)
clang-tidy --fix-errors $(SOURCES) $(HEADERS)