-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
69 lines (55 loc) · 1.62 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
CROSS_COMPILE=arm-none-eabi-
#CROSS_COMPILE =/opt/arm-2011.03/bin/arm-none-eabi-
CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)ld
AR=$(CROSS_COMPILE)ar
AS=$(CROSS_COMPILE)as
OC=$(CROSS_COMPILE)objcopy
OD=$(CROSS_COMPILE)objdump
SZ=$(CROSS_COMPILE)size
CFLAGS= -c -fno-common \
-ffunction-sections \
-fdata-sections \
-Os \
-g3 \
-mcpu=cortex-m3 -Wall \
-mthumb -mfloat-abi=soft
LDSCRIPT=ld/stm32_rom.ld
LDFLAGS = --gc-sections,-T$(LDSCRIPT),-no-startup,-nostdlib,-lnosys
OCFLAGS = -Obinary
ODFLAGS = -S
OUTPUT_DIR = output
TARGET = $(OUTPUT_DIR)/main
INCLUDE = -I./src/fw_lib/include \
-I./src/include \
SRCS = ./src/system_stm32f10x.c \
./src/stm32f10x_it.c \
./src/newlib_stubs.c \
./src/fw_lib/core_cm3.c \
./src/fw_lib/stm32f10x_rcc.c \
./src/fw_lib/stm32f10x_gpio.c \
./src/fw_lib/misc.c \
./src/main.c
OBJS=$(SRCS:.c=.o)
.PHONY : clean all
all: $(TARGET).bin $(TARGET).list
$(SZ) $(TARGET).elf
clean:
-find . -name '*.o' -exec rm {} \;
-find . -name '*.elf' -exec rm {} \;
-find . -name '*.lst' -exec rm {} \;
-find . -name '*.out' -exec rm {} \;
-find . -name '*.bin' -exec rm {} \;
-find . -name '*.map' -exec rm {} \;
$(TARGET).list: $(TARGET).elf
$(OD) $(ODFLAGS) $< > $(TARGET).lst
$(TARGET).bin: $(TARGET).elf
$(OC) $(OCFLAGS) $(TARGET).elf $(TARGET).bin
$(TARGET).elf: $(OBJS) ./src/startup.o
@$(CC) -mcpu=cortex-m3 -mthumb -Wl,$(LDFLAGS),-o$(TARGET).elf,-Map,$(TARGET).map ./src/startup.o $(OBJS)
%.o: %.c
@echo " CC $<"
@$(CC) $(INCLUDE) $(CFLAGS) $< -o $*.o
%.o: %.S
@echo " CC $<"
@$(CC) $(INCLUDE) $(CFLAGS) $< -o $*.o