Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. user_sub_dirs = apps
  2. DADK_VERSION=$(shell dadk -V | awk 'END {print $$2}')
  3. # 最小的DADK版本
  4. MIN_DADK_VERSION = 0.2.0
  5. DADK_CACHE_DIR = $(ROOT_PATH)/bin/dadk_cache
  6. ECHO:
  7. @echo "$@"
  8. install_dadk:
  9. # 如果未安装
  10. ifeq ("$(DADK_VERSION)", "")
  11. @echo "\ndadk is not installed."
  12. @echo "Please install dadk $(MIN_DADK_VERSION) or higher version"
  13. @echo "\nYou can install dadk by running the following command:"
  14. @echo "\n\tcargo install dadk"
  15. @echo "\nOr you can install dadk from source by running the following command:"
  16. @echo "\n\tcargo install --git https://git.mirrors.dragonos.org.cn/DragonOS-Community/DADK.git --tag v$(MIN_DADK_VERSION)"
  17. @echo "\n"
  18. @echo "Auto installing dadk..."
  19. cargo install dadk
  20. else
  21. # 如果DADK版本过低,则自动更新
  22. @echo "dadk version $(DADK_VERSION) installed"
  23. # 如果DADK版本过低,则自动更新
  24. ifneq ($(shell printf '%s\n%s' "$(DADK_VERSION)" "$(MIN_DADK_VERSION)" | sort -V | head -n1), $(MIN_DADK_VERSION))
  25. @echo "dadk version is too low, please update to $(MIN_DADK_VERSION) or higher version"
  26. @echo "Updating dadk..."
  27. cargo install --git https://git.mirrors.dragonos.org.cn/DragonOS-Community/DADK.git --tag v$(MIN_DADK_VERSION) || (echo "dadk update failed" && exit 1)
  28. @echo "dadk updated"
  29. endif
  30. endif
  31. .PHONY: dadk_run
  32. dadk_run: install_dadk
  33. mkdir -p $(DADK_CACHE_DIR)
  34. $(DADK) user build -w $(ROOT_PATH)
  35. $(DADK) user install -w $(ROOT_PATH)
  36. .PHONY: dadk_clean
  37. dadk_clean: install_dadk
  38. @echo dadk_clean
  39. all:
  40. mkdir -p $(ROOT_PATH)/bin/sysroot
  41. $(MAKE) dadk_run
  42. $(MAKE) copy_sysconfig
  43. @echo 用户态程序编译完成
  44. .PHONY: copy_sysconfig
  45. copy_sysconfig:
  46. cp -r sysconfig/* $(ROOT_PATH)/bin/sysroot/
  47. .PHONY: clean
  48. clean:
  49. $(MAKE) dadk_clean
  50. @list='$(user_sub_dirs)'; for subdir in $$list; do \
  51. echo "Clean in dir: $$subdir";\
  52. cd $$subdir && $(MAKE) clean;\
  53. cd .. ;\
  54. done
  55. .PHONY: fmt
  56. fmt:
  57. FMT_CHECK=$(FMT_CHECK) $(MAKE) -C apps fmt