xref: /DragonOS/user/Makefile (revision e2a59dbd433abe07260fe20d8c1bda7ca460f35c)
1afeca182Sfslongjinuser_sub_dirs = libs apps
20aec6827Sfslongjin
30aec6827SfslongjinSUBDIR_ROOTS := .
40aec6827SfslongjinDIRS := . $(shell find $(SUBDIR_ROOTS) -type d)
5b7437b24SfslongjinGARBAGE_PATTERNS := *.o *.s~ *.s *.S~ *.c~ *.h~ sys_api_lib
60aec6827SfslongjinGARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS)))
70aec6827Sfslongjin
80aec6827Sfslongjin
9afeca182Sfslongjintmp_output_dir=$(ROOT_PATH)/bin/tmp/user
10afeca182Sfslongjinoutput_dir=$(ROOT_PATH)/bin/user
11afeca182Sfslongjin
12afeca182SfslongjinCFLAGS := $(GLOBAL_CFLAGS) -I $(shell pwd)/libs
13afeca182Sfslongjincurrent_CFLAGS := $(CFLAGS)
140aec6827Sfslongjinall:
150aec6827Sfslongjin
16*e2a59dbdSfslongjin	$(shell if [ ! -e $(tmp_output_dir) ];then mkdir -p $(tmp_output_dir); fi)
17*e2a59dbdSfslongjin	$(shell if [ ! -e $(output_dir) ];then mkdir -p $(output_dir); fi)
18*e2a59dbdSfslongjin
190aec6827Sfslongjin	@list='$(user_sub_dirs)'; for subdir in $$list; do \
200aec6827Sfslongjin    		echo "make all in $$subdir";\
210aec6827Sfslongjin    		cd $$subdir;\
22*e2a59dbdSfslongjin    		 $(MAKE) all CFLAGS="$(CFLAGS)" tmp_output_dir="$(tmp_output_dir)" output_dir="$(output_dir)" sys_libs_dir="$(shell pwd)/libs";\
23*e2a59dbdSfslongjin    		cd ..;\
24*e2a59dbdSfslongjin	done
25*e2a59dbdSfslongjin
26*e2a59dbdSfslongjin# 系统库
27*e2a59dbdSfslongjinsys_api_lib:
28*e2a59dbdSfslongjin	@list='./libs'; for subdir in $$list; do \
29*e2a59dbdSfslongjin    		echo "make all in $$subdir";\
30*e2a59dbdSfslongjin    		cd $$subdir;\
310aec6827Sfslongjin    		 $(MAKE) all CFLAGS="$(CFLAGS)";\
320aec6827Sfslongjin    		cd ..;\
330aec6827Sfslongjin	done
34afeca182Sfslongjin
35*e2a59dbdSfslongjin# ld -b elf64-x86-64 -z muldefs -o $(tmp_output_dir)/sys_api_lib $(shell find ./libs -name "*.o")
365df5d799Sfslongjin#ld -b elf64-x86-64 -z muldefs -o sys_api_lib init.o $(shell find . -name "*.o") -T init.lds
370aec6827Sfslongjin
38afeca182Sfslongjin
390aec6827Sfslongjinclean:
400aec6827Sfslongjin	rm -rf $(GARBAGE)
41afeca182Sfslongjin