-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·92 lines (69 loc) · 2.4 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
MAKE = make
.PHONY: test
RISCV ?=
X_HEEP_LIB_FOLDER ?=
COMPILER_PREFIX ?= riscv32-unknown-
# Arch options are any RISC-V ISA string supported by the CPU. Default 'rv32imc'
ARCH ?= rv32imc
RISCV_EXE_PREFIX = $(RISCV)/bin/${COMPILER_PREFIX}elf-
CC := $(RISCV_EXE_PREFIX)gcc
CXX := $(RISCV_EXE_PREFIX)g++
AR := $(RISCV_EXE_PREFIX)ar
ARFLAGS := -r
OBJDIR := obj
BINDIR := bin
LIBTFLM := $(BINDIR)/libtflm.a
TFLITE_COMMON_FLAGS := -fno-unwind-tables -fno-exceptions -ffunction-sections -fdata-sections -fmessage-length=0 \
-DTF_LITE_STATIC_MEMORY \
-DTF_LITE_DISABLE_X86_NEON \
-mexplicit-relocs \
-DTF_LITE_MCU_DEBUG_LOG \
-DTF_LITE_USE_GLOBAL_CMATH_FUNCTIONS \
-funsigned-char \
-fno-delete-null-pointer-checks \
-fomit-frame-pointer
RISCV_FLAGS := -march=$(ARCH) \
-mabi=ilp32 \
-mcmodel=medany \
-static \
-w -g -Os \
CFLAGS := $(TFLITE_COMMON_FLAGS) $(RISCV_FLAGS) -std=c11
CXXFLAGS := $(TFLITE_COMMON_FLAGS) $(RISCV_FLAGS) -std=c++14 \
-fno-use-cxa-atexit \
-fpermissive \
-fno-rtti \
-fno-exceptions \
-fno-threadsafe-statics \
-Wnon-virtual-dtor \
-DTF_LITE_USE_GLOBAL_MIN \
-DTF_LITE_USE_GLOBAL_MAX
TFLM_INCLUDES := \
-I . \
-I ./third_party/flatbuffers/include \
-I ./third_party/gemmlowp \
-I ./third_party/kissfft \
-I ./third_party/ruy
XHEEP_INCLUDES := \
-I $(X_HEEP_LIB_FOLDER)/target \
-I $(X_HEEP_LIB_FOLDER)/base \
-I $(X_HEEP_LIB_FOLDER)/
RISCV_INCLUDES := \
-I ${RISCV}/${COMPILER_PREFIX}elf/include \
-I ${RISCV}/${COMPILER_PREFIX}elf/include/
TFLM_CC_SRCS := $(shell find tensorflow -name "*.cc" -o -name "*.c")
THIRD_PARTY_CC_SRCS := $(shell find third_party -name "*.cc" -o -name "*.c")
SIGNAL_CC_SRCS := $(shell find signal -name "*.cc" -o -name "*.c")
ALL_SRCS := $(TFLM_CC_SRCS) $(THIRD_PARTY_CC_SRCS) $(SIGNAL_CC_SRCS)
OBJS := $(addprefix $(OBJDIR)/, $(patsubst %.c,%.o,$(patsubst %.cc,%.o,$(ALL_SRCS))))
$(OBJDIR)/%.o: %.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) $(TFLM_INCLUDES) $(XHEEP_INCLUDES) $(RISCV_INCLUDES) -c $< -o $@
$(OBJDIR)/%.o: %.cc
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(TFLM_INCLUDES) $(XHEEP_INCLUDES) $(RISCV_INCLUDES) -c $< -o $@
$(LIBTFLM): $(OBJS)
@mkdir -p $(dir $@)
$(AR) $(ARFLAGS) $(LIBTFLM) $(OBJS)
clean:
rm -rf $(OBJDIR) $(BINDIR)
libtflm: $(LIBTFLM)