xref: /DragonOS/user/Makefile (revision 978043e47d1143ca2d5cf22b20793f032e8eb5a5)
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	$(shell if [ ! -e $(tmp_output_dir) ];then mkdir -p $(tmp_output_dir); fi)
26	$(shell if [ ! -e $(output_dir) ];then mkdir -p $(output_dir); fi)
27
28	@echo 用户态程序编译完成
29
30# 系统库
31sys_api_lib:
32	$(MAKE) -C libs all CFLAGS="$(CFLAGS)" tmp_output_dir="$(tmp_output_dir)" output_dir="$(output_dir)" sys_libs_dir="$(shell pwd)/libs"
33
34
35
36clean:
37	rm -rf $(GARBAGE)
38	$(MAKE) clean -C libs
39	@list='$(user_sub_dirs)'; for subdir in $$list; do \
40		echo "Clean in dir: $$subdir";\
41		cd $$subdir && $(MAKE) clean;\
42		cd .. ;\
43	done
44