xref: /DragonOS/user/Makefile (revision 0d0705a1694bfa057c1f84ee7c683a3653a9160f)
1user_sub_dirs = libs 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)
14all:
15
16	$(shell if [ ! -e $(tmp_output_dir) ];then mkdir -p $(tmp_output_dir); fi)
17	$(shell if [ ! -e $(output_dir) ];then mkdir -p $(output_dir); fi)
18
19	@list='$(user_sub_dirs)'; for subdir in $$list; do \
20    		echo "make all in $$subdir";\
21    		cd $$subdir;\
22    		 $(MAKE) all CFLAGS="$(CFLAGS)" tmp_output_dir="$(tmp_output_dir)" output_dir="$(output_dir)" sys_libs_dir="$(shell pwd)/libs";\
23    		cd ..;\
24	done
25
26# 系统库
27sys_api_lib:
28	@list='./libs'; for subdir in $$list; do \
29    		echo "make all in $$subdir";\
30    		cd $$subdir;\
31    		 $(MAKE) all CFLAGS="$(CFLAGS)";\
32    		cd ..;\
33	done
34
35# ld -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/sys_api_lib $(shell find ./libs -name "*.o")
36#ld -b elf64-x86-64 -z muldefs -o sys_api_lib init.o $(shell find . -name "*.o") -T init.lds
37
38
39clean:
40	rm -rf $(GARBAGE)
41