xref: /DragonOS/user/Makefile (revision 5ed4cd460200cb19aae8c3c67dfd77e1e9f0e105)
1user_sub_dirs = apps
2
3SUBDIR_ROOTS := .
4DIRS := . $(shell find $(SUBDIR_ROOTS) -type d)
5GARBAGE_PATTERNS := *.o *.s~ *.s *.S~ *.c~ *.h~ sys_api_lib
6GARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS)))
7
8
9tmp_output_dir=$(ROOT_PATH)/bin/tmp/user
10output_dir=$(ROOT_PATH)/bin/user
11
12CFLAGS := $(GLOBAL_CFLAGS) -I $(shell pwd)/libs
13current_CFLAGS := $(CFLAGS)
14
15ECHO:
16	@echo "$@"
17
18$(user_sub_dirs): ECHO sys_api_lib
19
20	$(MAKE) -C $@ all CFLAGS="$(CFLAGS)" tmp_output_dir="$(tmp_output_dir)" output_dir="$(output_dir)" sys_libs_dir="$(shell pwd)/libs"
21
22app: $(user_sub_dirs)
23
24all: app
25	@if [ -z $$DragonOS_GCC ]; then echo "\033[31m  [错误]尚未安装DragonOS交叉编译器, 请使用tools文件夹下的build_gcc_toolchain.sh脚本安装  \033[0m"; exit 1; fi
26	$(shell if [ ! -e $(tmp_output_dir) ];then mkdir -p $(tmp_output_dir); fi)
27	$(shell if [ ! -e $(output_dir) ];then mkdir -p $(output_dir); fi)
28
29	@echo 用户态程序编译完成
30
31# 系统库
32sys_api_lib:
33	$(MAKE) -C libs all CFLAGS="$(CFLAGS)" tmp_output_dir="$(tmp_output_dir)" output_dir="$(output_dir)" sys_libs_dir="$(shell pwd)/libs"
34
35
36
37clean:
38	rm -rf $(GARBAGE)
39	$(MAKE) clean -C libs
40	@list='$(user_sub_dirs)'; for subdir in $$list; do \
41		echo "Clean in dir: $$subdir";\
42		cd $$subdir && $(MAKE) clean;\
43		cd .. ;\
44	done
45