summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: b4393dd9bad0caafc49f17b2e01a61adfc628dc6 (plain)
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
CPU = cortex-m4
MCU = MK20DX256
TARGET_ARCH = -mcpu=$(CPU) -mthumb

AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy

HKTOOL = hktool $(MCU)

WARNINGS = -Wpointer-arith -Wcast-align -Wformat=2 \
	   -Wsuggest-attribute=format -Wall \
	   -Wextra -Wpedantic -Winit-self -Wshadow -Wcast-qual \
	   -Wstrict-prototypes -Wmissing-prototypes
CFLAGS = -std=c11 $(WARNINGS) -O2 -flto -MMD -MP -ffreestanding -nostdlib -Ilib
LDFLAGS = -T layout.ld -O2 -flto -ffreestanding -nostdlib
ASFLAGS = $(TARGET_ARCH)

OBJ := crt0.o vectors.o flashconf.o setup.o fmk.o lib/string.o lib/le.o usb/usb.o usb/endpt0.o usb/endpt1.o

%.bin: %
	$(OBJCOPY) -O binary $< $@

all: fmk.bin
fmk: $(OBJ)

flash: fmk.bin
	hktool 0x40000 1024 64 0 $<
	hktool -r

clean:
	$(RM) $(OBJ) $(OBJ:.o=.d) fmk fmk.bin

-include $(OBJ:.o=.d)

.PHONY: all flash clean