forked from itsyuxuan/microbit-light-show
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
37 lines (24 loc) · 855 Bytes
/
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
COMP2300 ?= $(shell echo ~/.comp2300)
ARM_PREFIX=$(COMP2300)/arm-none-eabi/bin/arm-none-eabi-
CC=$(ARM_PREFIX)gcc
LD=$(ARM_PREFIX)ld
OBJCOPY=$(ARM_PREFIX)objcopy
OPENOCD=$(COMP2300)/openocd/bin/openocd
SRCS := $(shell find src lib -name '*.c' -or -name '*.S')
OBJS := $(addsuffix .o,$(basename $(SRCS)))
CFLAGS ?=-nostdlib -nostartfiles -mcpu=cortex-m4 -mthumb -Wall -Werror -g
LDFLAGS ?=-nostdlib -T lib/link.ld --print-memory-usage
TARGET ?= program.elf
all: $(TARGET)
$(TARGET): $(OBJS)
"$(LD)" $(LDFLAGS) $^ -o $@
%.o: %.c
"$(CC)" $(CFLAGS) -o $@ -c $<
%.o: %.S
"$(CC)" $(CFLAGS) -o $@ -c $<
.PHONY: upload
upload: $(TARGET)
"$(OBJCOPY)" -O binary $(TARGET) program.bin
"$(OPENOCD)" -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c "program program.elf verify reset exit"
clean:
rm $(TARGET) $(OBJS) >/dev/null 2>/dev/null || true