1b2614801Sfslongjinuser_sub_dirs = apps 20aec6827Sfslongjin 326887c63SLoGinDADK_VERSION=$(shell dadk -V | awk 'END {print $$2}') 47285c927Slogin# 最小的DADK版本 5*182b778aSLoGinMIN_DADK_VERSION = 0.1.11 67285c927SloginDADK_CACHE_DIR = $(ROOT_PATH)/bin/dadk_cache 77285c927Slogin 8b2614801SfslongjinECHO: 9b2614801Sfslongjin @echo "$@" 10b2614801Sfslongjin 117285c927Slogin 127285c927Slogininstall_dadk: 137285c927Slogin# 如果未安装 147285c927Sloginifeq ("$(DADK_VERSION)", "") 157285c927Slogin @echo "\ndadk is not installed." 167285c927Slogin @echo "Please install dadk $(MIN_DADK_VERSION) or higher version" 177285c927Slogin @echo "\nYou can install dadk by running the following command:" 187285c927Slogin @echo "\n\tcargo install dadk" 197285c927Slogin @echo "\nOr you can install dadk from source by running the following command:" 206c7f966cSMemoryShore @echo "\n\tcargo install --git https://git.mirrors.dragonos.org.cn/DragonOS-Community/DADK.git --tag v$(MIN_DADK_VERSION)" 217285c927Slogin @echo "\n" 22abf3f634SLoGin @echo "Auto installing dadk..." 239430523bSyuyi2439 cargo install dadk 247285c927Sloginelse 2526887c63SLoGin# 如果DADK版本过低,则自动更新 267285c927Slogin @echo "dadk version $(DADK_VERSION) installed" 27abf3f634SLoGin# 如果DADK版本过低,则自动更新 2826887c63SLoGinifneq ($(shell printf '%s\n%s' "$(DADK_VERSION)" "$(MIN_DADK_VERSION)" | sort -V | head -n1), $(MIN_DADK_VERSION)) 29abf3f634SLoGin @echo "dadk version is too low, please update to $(MIN_DADK_VERSION) or higher version" 30abf3f634SLoGin @echo "Updating dadk..." 319430523bSyuyi2439 cargo install --git https://git.mirrors.dragonos.org.cn/DragonOS-Community/DADK.git --tag v$(MIN_DADK_VERSION) || (echo "dadk update failed" && exit 1) 32abf3f634SLoGin @echo "dadk updated" 33abf3f634SLoGinendif 347285c927Sloginendif 357285c927Slogin 366d81180bSLoGin.PHONY: dadk_run 377285c927Slogindadk_run: install_dadk 387285c927Slogin mkdir -p $(DADK_CACHE_DIR) 398d72b68dSJomo dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot build 408d72b68dSJomo dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot install 417285c927Slogin 426d81180bSLoGin.PHONY: dadk_clean 437285c927Slogindadk_clean: install_dadk 44bc6f0a96S裕依 @echo dadk_clean 45bb0e4d41SGnoCiYeH# 不运行dadk clean的原因是,把clean的工作交给应用程序自己去做,这样可以节省编译时间 46bb0e4d41SGnoCiYeH#dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot clean src 47bb0e4d41SGnoCiYeH#dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot clean target 487285c927Slogin 49bc6f0a96S裕依all: 50bc6f0a96S裕依 mkdir -p $(ROOT_PATH)/bin/sysroot 51b2614801Sfslongjin 52bc6f0a96S裕依 $(MAKE) dadk_run 539430523bSyuyi2439 $(MAKE) copy_sysconfig 54bc6f0a96S裕依 55bc6f0a96S裕依 @echo 用户态程序编译完成 56b2614801Sfslongjin 579430523bSyuyi2439copy_sysconfig: dadk_run 587c958c9eSVal213 cp -r sysconfig/* $(ROOT_PATH)/bin/sysroot/ 59b2614801Sfslongjin 60afeca182Sfslongjin 616d81180bSLoGin.PHONY: clean 620aec6827Sfslongjinclean: 637285c927Slogin $(MAKE) dadk_clean 64237e95c6Swwc-15172310230 @list='$(user_sub_dirs)'; for subdir in $$list; do \ 65237e95c6Swwc-15172310230 echo "Clean in dir: $$subdir";\ 66237e95c6Swwc-15172310230 cd $$subdir && $(MAKE) clean;\ 67237e95c6Swwc-15172310230 cd .. ;\ 68237e95c6Swwc-15172310230 done 69afeca182Sfslongjin 70e92d0228SLoGin.PHONY: fmt 71e92d0228SLoGinfmt: 72bc6f0a96S裕依 FMT_CHECK=$(FMT_CHECK) $(MAKE) -C apps fmt 73