-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
45 lines (39 loc) · 1.14 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
.PHONY: debug release test clean
BIN = glitch-controller.elf
BIN_RELEASE = Release/$(BIN)
BIN_DEBUG = Debug/$(BIN)
debug:
$(MAKE) -C Debug all
release:
$(MAKE) -C Release all
test:
@if [ -e $(BIN_RELEASE) ] && [ -e $(BIN_DEBUG) ]; then \
if [ $(BIN_RELEASE) -nt $(BIN_DEBUG) ]; then \
BIN_TEST=$(BIN_RELEASE); \
else \
BIN_TEST=$(BIN_DEBUG); \
fi; \
elif [ -e $(BIN_RELEASE) ] && [ ! -e $(BIN_DEBUG) ]; then \
BIN_TEST=$(BIN_RELEASE); \
elif [ ! -e $(BIN_RELEASE) ] && [ -e $(BIN_DEBUG) ]; then \
BIN_TEST=$(BIN_DEBUG); \
else \
BIN_TEST=$(BIN_DEBUG); \
make debug; \
fi; \
echo "Using: $$BIN_TEST"; \
openocd -f interface/stlink.cfg -f target/stm32f0x.cfg \
-c init -c "reset halt" -c "flash write_image erase $$BIN_TEST" \
-c reset -c shutdown
gdb: debug test
@if ! netstat -tunap | grep -q ":3333"; then \
openocd -f interface/stlink.cfg -f target/stm32f0x.cfg -c "init; reset halt" & \
OPENOCD_PID=$$!; \
fi; \
gdb-multiarch Debug/glitch-controller.elf -ex "target remote :3333"; \
if [ -n "$$OPENOCD_PID" ]; then \
kill $$OPENOCD_PID; \
fi
clean:
$(MAKE) -C Debug clean
$(MAKE) -C Release clean