forked from kendryte/k230_canmv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
170 lines (148 loc) · 7.83 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
FAST_DL ?= 1
$(shell touch .conf)
include .conf
ifeq ("$(origin CONF)", "command line")
update_conf = 1
else ifeq ("$(origin CONF)", "undefined")
CONF = k230_canmv_defconfig
update_conf = 1
else
update_conf = 0
endif
ifeq ($(shell if [ -f configs/$(CONF) ]; then echo 1; else echo 0; fi;), 0)
$(error "Please specify a valid CONF")
endif
ifeq ($(update_conf),1)
$(shell sed -i "/^CONF=/d" .conf)
$(shell echo "CONF=$(CONF)" >> .conf)
endif
ifeq ("$(origin NATIVE_BUILD)", "command line")
update_conf = 1
else ifeq ("$(origin NATIVE_BUILD)", "undefined")
update_conf = 1
ifeq ($(shell curl --output /dev/null --silent --head --fail https://ai.b-bug.org/k230/ && echo $$?),0)
NATIVE_BUILD = 1
else
NATIVE_BUILD = 0
endif
else
update_conf = 0
endif
ifeq ($(update_conf),1)
$(shell sed -i "/^NATIVE_BUILD=/d" .conf)
$(shell echo "NATIVE_BUILD=$(NATIVE_BUILD)" >> .conf)
ifeq ($(NATIVE_BUILD),1)
$(shell git update-index --assume-unchanged .gitmodules)
$(shell git submodule set-url k230_sdk [email protected]:maix_sw/k230_sdk_release.git >> /dev/null)
else
$(shell git update-index --no-assume-unchanged .gitmodules)
$(shell git submodule set-url k230_sdk https://github.com/kendryte/k230_sdk.git >> /dev/null)
endif
endif
SAVECONF ?= $(CONF)
export K230_CANMV_ROOT := $(shell pwd)
export K230_CANMV_BUILD_DIR := $(K230_CANMV_ROOT)/output/$(CONF)
$(shell mkdir -p $(K230_CANMV_BUILD_DIR))
CONFIG_PATH = $(K230_CANMV_ROOT)/configs
KCONFIG_PATH = $(K230_CANMV_ROOT)/scripts/kconfig
KCONFIG_CFG = $(K230_CANMV_ROOT)/Kconfig
.PHONY: all
all: build-image
$(K230_CANMV_BUILD_DIR)/.config: $(CONFIG_PATH)/$(CONF)
@if [ ! -f $(KCONFIG_PATH)/mconf -o ! -f $(KCONFIG_PATH)/conf ];then \
cd $(KCONFIG_PATH); make; fi
@cd $(K230_CANMV_BUILD_DIR); \
$(KCONFIG_PATH)/conf --defconfig $(CONFIG_PATH)/$(CONF) $(KCONFIG_CFG);
$(K230_CANMV_BUILD_DIR)/.config.old: $(K230_CANMV_BUILD_DIR)/.config
@cd $(K230_CANMV_BUILD_DIR); \
$(KCONFIG_PATH)/conf --syncconfig $(KCONFIG_CFG); \
touch .config.old;
.PHONY: menuconfig
menuconfig: $(K230_CANMV_BUILD_DIR)/.config
@cd $(K230_CANMV_BUILD_DIR); \
$(KCONFIG_PATH)/mconf $(KCONFIG_CFG);
.PHONY: savedefconfig
savedefconfig: $(K230_CANMV_BUILD_DIR)/.config
@cd $(K230_CANMV_BUILD_DIR); \
$(KCONFIG_PATH)/conf --savedefconfig $(CONFIG_PATH)/$(SAVECONF) $(KCONFIG_CFG);
.PHONY: .autoconf
.autoconf: $(K230_CANMV_BUILD_DIR)/.config.old
.PHONY: .fast_dl
.fast_dl:
@make -f scripts/helper.mk fast_dl FAST_DL=$(FAST_DL) NATIVE_BUILD=$(NATIVE_BUILD)
.PHONY: sync_submodule
sync_submodule: .fast_dl
@echo "sync_submodule"
@make -f scripts/helper.mk sync_submodule
.PHONY: prepare_sourcecode
prepare_sourcecode: sync_submodule
@echo "prepare_sourcecode"
@make -C k230_sdk prepare_sourcecode CONF=$(CONF) NATIVE_BUILD=$(NATIVE_BUILD)
.PHONY: .sync_overlay
.sync_overlay: .autoconf
@make -f scripts/helper.mk sync_overlay
.PHONY: k230_sdk_build
k230_sdk_build: .sync_overlay
@make -f scripts/helper.mk $(K230_CANMV_BUILD_DIR)/.k230_sdk_all CONF=$(CONF)
.PHONY: micropython
micropython_freetype: .sync_overlay
@rm -rf $(K230_CANMV_BUILD_DIR)/images/res/font/
@mkdir -p $(K230_CANMV_BUILD_DIR)/images/res/font/
@cp -f fs_resource/font/SourceHanSansSC-Normal-Min.ttf $(K230_CANMV_BUILD_DIR)/images/res/font
@cp -f fs_resource/font/LICENSE.txt $(K230_CANMV_BUILD_DIR)/images/res/font/LICENSE.txt
@cp -f fs_resource/font/readme.txt $(K230_CANMV_BUILD_DIR)/images/res/font/readme.txt
@make -C micropython/port/3d-party/freetype/freetype
.PHONY: micropython_freetype_clean
micropython_freetype_clean: .sync_overlay
@make -C micropython/port/3d-party/freetype/freetype clean
.PHONY: micropython
micropython: k230_sdk_build micropython_freetype
@make -C micropython/port
@rm -rf $(K230_CANMV_BUILD_DIR)/images/app/
@mkdir -p $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel/
@cp -f $(K230_CANMV_BUILD_DIR)/micropython/micropython $(K230_CANMV_BUILD_DIR)/images/app
.PHONY: build-image
build-image: micropython
@cp -r fs_resource/libs $(K230_CANMV_BUILD_DIR)/images/app
@cp -r fs_resource/tests $(K230_CANMV_BUILD_DIR)/images/app
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_detection_320.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/nncase_runtime/face_detection
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_recognition.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_detection_320.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/yolov8n_320.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/yolov8n_seg_320.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/LPD_640.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/ocr_det_int16.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/hand_det.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_landmark.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_pose.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_parse.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/LPD_640.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/licence_reco.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/handkp_det.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/ocr_rec_int16.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/hand_reco.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/person_detect_yolov5n.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/yolov8n-pose.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/kws.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_alignment.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/face_alignment_post.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/eye_gaze.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/yolov5n-falldown.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/cropped_test127.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/nanotrack_backbone_sim.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/nanotracker_head_calib_k230.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/gesture.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/recognition.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/hifigan.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/zh_fastspeech_2.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@cp -r k230_sdk/src/big/kmodel/ai_poc/kmodel/zh_fastspeech_1_f32.kmodel $(K230_CANMV_BUILD_DIR)/images/app/tests/kmodel
@make -C k230_sdk build-image
.PHONY: micropython-clean
micropython-clean:
@rm -rf $(K230_CANMV_BUILD_DIR)/micropython
.PHONY: k230_sdk-clean
k230_sdk-clean:
@make -C k230_sdk clean
@rm -f $(K230_CANMV_BUILD_DIR)/.k230_sdk_all
.PHONY: clean
clean: micropython-clean k230_sdk-clean