forked from fedetft/miosix-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
131 lines (105 loc) · 4.05 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
##
## Makefile for Miosix embedded OS
##
MAKEFILE_VERSION := 1.07
## Path to kernel directory (edited by init_project_out_of_git_repo.pl)
KPATH := miosix
## Path to config directory (edited by init_project_out_of_git_repo.pl)
CONFPATH := $(KPATH)
include $(CONFPATH)/config/Makefile.inc
##
## List here subdirectories which contains makefiles
##
SUBDIRS := $(KPATH)
##
## List here your source files (both .s, .c and .cpp)
##
SRC := \
main.cpp \
NN/Src/network.c \
NN/Src/network_data.c \
NN/Src/aeabi_memclr.c \
NN/Src/aeabi_memcpy.c \
ActiveObject.cpp \
NeuralNetwork.cpp
#NN/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
#NN/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
#NN/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_crc.c \
#NN/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c
##
## List here additional static libraries with relative path
##
LIBS := NN/Middlewares/ST/AI/Lib/NetworkRuntime410_CM4_GCC.a \
NN/Middlewares/ST/AI/Lib/libarm_cortexM4lf_math.a
##
## List here additional include directories (in the form -Iinclude_dir)
##
INCLUDE_DIRS := -I./NN/Inc -I./NN/Middlewares/ST/AI/Inc -I./NN/Middlewares/ST/AI/Lib -I./NN
##-I./miosix/arch/common/CMSIS/Device/ST/STM32F4xx/Include -I./NN/Drivers/STM32F4xx_HAL_Driver/Inc
##-I./miosix/arch/common/CMSIS/Device/ST/STM32F4xx/Include
##-I./NN/Drivers/CMSIS/Device/ST/STM32F4xx/Include
##-I./NN/Drivers/CMSIS/Include
##############################################################################
## You should not need to modify anything below ##
##############################################################################
ifeq ("$(VERBOSE)","1")
Q :=
ECHO := @true
else
Q := @
ECHO := @echo
endif
## Replaces both "foo.cpp"-->"foo.o" and "foo.c"-->"foo.o"
OBJ := $(addsuffix .o, $(basename $(SRC)))
## Includes the miosix base directory for C/C++
## Always include CONFPATH first, as it overrides the config file location
CXXFLAGS := $(CXXFLAGS_BASE) -I$(CONFPATH) -I$(CONFPATH)/config/$(BOARD_INC) \
-I. -I$(KPATH) -I$(KPATH)/arch/common -I$(KPATH)/$(ARCH_INC) \
-I$(KPATH)/$(BOARD_INC) $(INCLUDE_DIRS)
CFLAGS := $(CFLAGS_BASE) -I$(CONFPATH) -I$(CONFPATH)/config/$(BOARD_INC) \
-I. -I$(KPATH) -I$(KPATH)/arch/common -I$(KPATH)/$(ARCH_INC) \
-I$(KPATH)/$(BOARD_INC) $(INCLUDE_DIRS)
AFLAGS := $(AFLAGS_BASE)
LFLAGS := $(LFLAGS_BASE)
DFLAGS := -MMD -MP
#LINK_LIBS := $(LIBS) -L$(KPATH) -Wl,--start-group -lmiosix -lstdc++ -lc \
-lm -lgcc -Wl,--end-group
#LINK_LIBS := $(LIBS) -Wl,--start-group -lmiosix $(ARCH_LIBS) -Wl,--end-group
LINK_LIBS := $(LIBS) -L$(KPATH) -Wl,--start-group -lmiosix $(ARCH_LIBS) -Wl,--end-group
all: all-recursive main
clean: clean-recursive clean-topdir
program:
$(PROGRAM_CMDLINE)
all-recursive:
$(foreach i,$(SUBDIRS),$(MAKE) -C $(i) \
KPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(KPATH)) \
CONFPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(CONFPATH)) \
|| exit 1;)
clean-recursive:
$(foreach i,$(SUBDIRS),$(MAKE) -C $(i) \
KPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(KPATH)) \
CONFPATH=$(shell perl $(KPATH)/_tools/relpath.pl $(i) $(CONFPATH)) \
clean || exit 1;)
clean-topdir:
-rm -f $(OBJ) main.elf main.hex main.bin main.map $(OBJ:.o=.d)
main: main.elf
$(ECHO) "[CP ] main.hex"
$(Q)$(CP) -O ihex main.elf main.hex
$(ECHO) "[CP ] main.bin"
$(Q)$(CP) -O binary main.elf main.bin
$(Q)$(SZ) main.elf
main.elf: $(OBJ) all-recursive
$(ECHO) "[LD ] main.elf"
$(Q)$(ARM_NONE_EABI)/bin/arm-none-eabi-gcc $(LFLAGS) -o main.elf $(OBJ) $(KPATH)/$(BOOT_FILE) $(LINK_LIBS)
##$(Q)$(CXX) $(LFLAGS) -o main.elf $(OBJ) $(KPATH)/$(BOOT_FILE)
%.o: %.s
$(ECHO) "[AS ] $<"
$(Q)$(AS) $(AFLAGS) $< -o $@
%.o : %.c
$(ECHO) "[CC ] $<"
$(Q)$(CC) $(DFLAGS) $(CFLAGS) $< -o $@
%.o : %.cpp
$(ECHO) "[CXX ] $<"
$(Q)$(CXX) $(DFLAGS) $(CXXFLAGS) $< -o $@
#pull in dependecy info for existing .o files
-include $(OBJ:.o=.d)