1b2614801Sfslongjinuser_sub_dirs = apps 20aec6827Sfslongjin 30aec6827SfslongjinSUBDIR_ROOTS := . 40aec6827SfslongjinDIRS := . $(shell find $(SUBDIR_ROOTS) -type d) 5bc6f0a96S裕依GARBAGE_PATTERNS := *.o *.a 60aec6827SfslongjinGARBAGE := $(foreach DIR,$(DIRS),$(addprefix $(DIR)/,$(GARBAGE_PATTERNS))) 70aec6827Sfslongjin 826887c63SLoGinDADK_VERSION=$(shell dadk -V | awk 'END {print $$2}') 97285c927Slogin# 最小的DADK版本 101cd9bb43SLoGinMIN_DADK_VERSION = 0.1.10 117285c927SloginDADK_CACHE_DIR = $(ROOT_PATH)/bin/dadk_cache 127285c927Slogin 13b2614801SfslongjinECHO: 14b2614801Sfslongjin @echo "$@" 15b2614801Sfslongjin 167285c927Slogin 177285c927Slogininstall_dadk: 187285c927Slogin# 如果未安装 197285c927Sloginifeq ("$(DADK_VERSION)", "") 207285c927Slogin @echo "\ndadk is not installed." 217285c927Slogin @echo "Please install dadk $(MIN_DADK_VERSION) or higher version" 227285c927Slogin @echo "\nYou can install dadk by running the following command:" 237285c927Slogin @echo "\n\tcargo install dadk" 247285c927Slogin @echo "\nOr you can install dadk from source by running the following command:" 256c7f966cSMemoryShore @echo "\n\tcargo install --git https://git.mirrors.dragonos.org.cn/DragonOS-Community/DADK.git --tag v$(MIN_DADK_VERSION)" 267285c927Slogin @echo "\n" 27abf3f634SLoGin @echo "Auto installing dadk..." 28*9430523bSyuyi2439 cargo install dadk 297285c927Sloginelse 3026887c63SLoGin# 如果DADK版本过低,则自动更新 317285c927Slogin @echo "dadk version $(DADK_VERSION) installed" 32abf3f634SLoGin# 如果DADK版本过低,则自动更新 3326887c63SLoGinifneq ($(shell printf '%s\n%s' "$(DADK_VERSION)" "$(MIN_DADK_VERSION)" | sort -V | head -n1), $(MIN_DADK_VERSION)) 34abf3f634SLoGin @echo "dadk version is too low, please update to $(MIN_DADK_VERSION) or higher version" 35abf3f634SLoGin @echo "Updating dadk..." 36*9430523bSyuyi2439 cargo install --git https://git.mirrors.dragonos.org.cn/DragonOS-Community/DADK.git --tag v$(MIN_DADK_VERSION) || (echo "dadk update failed" && exit 1) 37abf3f634SLoGin @echo "dadk updated" 38abf3f634SLoGinendif 397285c927Sloginendif 407285c927Slogin 416d81180bSLoGin.PHONY: dadk_run 427285c927Slogindadk_run: install_dadk 437285c927Slogin mkdir -p $(DADK_CACHE_DIR) 448d72b68dSJomo dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot build 458d72b68dSJomo dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot install 467285c927Slogin 476d81180bSLoGin.PHONY: dadk_clean 487285c927Slogindadk_clean: install_dadk 49bc6f0a96S裕依 @echo dadk_clean 50bb0e4d41SGnoCiYeH# 不运行dadk clean的原因是,把clean的工作交给应用程序自己去做,这样可以节省编译时间 51bb0e4d41SGnoCiYeH#dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot clean src 52bb0e4d41SGnoCiYeH#dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot clean target 537285c927Slogin 54bc6f0a96S裕依all: 55bc6f0a96S裕依 mkdir -p $(ROOT_PATH)/bin/sysroot 56b2614801Sfslongjin 57bc6f0a96S裕依 $(MAKE) dadk_run 58*9430523bSyuyi2439 $(MAKE) copy_sysconfig 59bc6f0a96S裕依 60bc6f0a96S裕依 @echo 用户态程序编译完成 61b2614801Sfslongjin 62*9430523bSyuyi2439copy_sysconfig: dadk_run 637c958c9eSVal213 cp -r sysconfig/* $(ROOT_PATH)/bin/sysroot/ 64b2614801Sfslongjin 65afeca182Sfslongjin 666d81180bSLoGin.PHONY: clean 670aec6827Sfslongjinclean: 680aec6827Sfslongjin rm -rf $(GARBAGE) 697285c927Slogin $(MAKE) dadk_clean 70237e95c6Swwc-15172310230 @list='$(user_sub_dirs)'; for subdir in $$list; do \ 71237e95c6Swwc-15172310230 echo "Clean in dir: $$subdir";\ 72237e95c6Swwc-15172310230 cd $$subdir && $(MAKE) clean;\ 73237e95c6Swwc-15172310230 cd .. ;\ 74237e95c6Swwc-15172310230 done 75afeca182Sfslongjin 76e92d0228SLoGin.PHONY: fmt 77e92d0228SLoGinfmt: 78bc6f0a96S裕依 FMT_CHECK=$(FMT_CHECK) $(MAKE) -C apps fmt 79