-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
41 lines (30 loc) · 796 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
38
39
40
41
TOOLCHAIN=~/toolchain/gcc-arm-none-eabi-4_9-2014q4/bin
PREFIX=$(TOOLCHAIN)/arm-none-eabi-
ARCHFLAGS=-mthumb -mcpu=cortex-m0plus
CFLAGS=-I./includes/ -g -O2 -Wall -Werror
LDFLAGS=--specs=nano.specs -Wl,--gc-sections,-Map,$(TARGET).map,-Tlink.ld
CC=$(PREFIX)gcc
LD=$(PREFIX)gcc
OBJCOPY=$(PREFIX)objcopy
SIZE=$(PREFIX)size
RM=rm -f
TARGET=main
SRC=$(wildcard *.c)
OBJ=$(patsubst %.c, %.o, $(SRC))
all: build size
build: elf srec bin
elf: $(TARGET).elf
srec: $(TARGET).srec
bin: $(TARGET).bin
clean:
$(RM) $(TARGET).srec $(TARGET).elf $(TARGET).bin $(TARGET).map $(OBJ)
%.o: %.c
$(CC) -c $(ARCHFLAGS) $(CFLAGS) -o $@ $<
$(TARGET).elf: $(OBJ)
$(LD) $(LDFLAGS) -o $@ $(OBJ)
%.srec: %.elf
$(OBJCOPY) -O srec $< $@
%.bin: %.elf
$(OBJCOPY) -O binary $< $@
size:
$(SIZE) $(TARGET).elf