-
Notifications
You must be signed in to change notification settings - Fork 0
/
rules.mk
69 lines (53 loc) · 1.84 KB
/
rules.mk
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
CC = arm-none-eabi-gcc
LD = arm-none-eabi-gcc
OBJDUMP = arm-none-eabi-objdump
OBJCOPY = arm-none-eabi-objcopy
PYTHON = python3
STLIB_PATH = $(VESC_C_LIB_PATH)/stdperiph_stm32f4/
ifeq ($(USE_STLIB),yes)
SOURCES += \
$(STLIB_PATH)/src/misc.c \
$(STLIB_PATH)/src/stm32f4xx_adc.c \
$(STLIB_PATH)/src/stm32f4xx_dma.c \
$(STLIB_PATH)/src/stm32f4xx_exti.c \
$(STLIB_PATH)/src/stm32f4xx_flash.c \
$(STLIB_PATH)/src/stm32f4xx_rcc.c \
$(STLIB_PATH)/src/stm32f4xx_syscfg.c \
$(STLIB_PATH)/src/stm32f4xx_tim.c \
$(STLIB_PATH)/src/stm32f4xx_iwdg.c \
$(STLIB_PATH)/src/stm32f4xx_wwdg.c
endif
UTILS_PATH = $(VESC_C_LIB_PATH)/utils/
SOURCES += $(UTILS_PATH)/rb.c
SOURCES += $(UTILS_PATH)/utils.c
OBJECTS = $(SOURCES:.c=.so)
ifeq ($(USE_OPT),)
USE_OPT =
endif
CFLAGS = -fpic -Os -Wall -Wextra -Wundef -std=gnu99 -I$(VESC_C_LIB_PATH)
CFLAGS += -I$(STLIB_PATH)/CMSIS/include -I$(STLIB_PATH)/CMSIS/ST -I$(UTILS_PATH)/
CFLAGS += -fomit-frame-pointer -falign-functions=16 -mthumb
CFLAGS += -fsingle-precision-constant -Wdouble-promotion
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mcpu=cortex-m4
CFLAGS += -fdata-sections -ffunction-sections
CFLAGS += -DIS_VESC_LIB
CFLAGS += $(USE_OPT)
ifeq ($(USE_STLIB),yes)
CFLAGS += -DUSE_STLIB -I$(STLIB_PATH)/inc
endif
LDFLAGS = -nostartfiles -static -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mcpu=cortex-m4
LDFLAGS += -lm -Wl,--gc-sections,--undefined=init
LDFLAGS += -T $(VESC_C_LIB_PATH)/link.ld
.PHONY: default all clean
default: $(TARGET)
all: default
%.so: %.c
$(CC) $(CFLAGS) -c $< -o $@
.PRECIOUS: $(TARGET) $(OBJECTS)
$(TARGET): $(OBJECTS)
$(LD) $(OBJECTS) $(LDFLAGS) -o [email protected]
$(OBJDUMP) -D [email protected] > [email protected]
$(OBJCOPY) -O binary [email protected] [email protected] --gap-fill 0x00
$(PYTHON) $(VESC_C_LIB_PATH)/conv.py -f [email protected] -n $@ > [email protected]
clean:
rm -f $(OBJECTS) $(TARGET).elf $(TARGET).list $(TARGET).lisp $(TARGET).bin $(ADD_TO_CLEAN)