Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. user_sub_dirs = apps
  2. DADK_VERSION=$(shell dadk -V | awk 'END {print $$2}')
  3. # 最小的DADK版本
  4. MIN_DADK_VERSION = 0.1.11
  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 --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot build
  35. dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot install
  36. .PHONY: dadk_clean
  37. dadk_clean: install_dadk
  38. @echo dadk_clean
  39. # 不运行dadk clean的原因是,把clean的工作交给应用程序自己去做,这样可以节省编译时间
  40. #dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot clean src
  41. #dadk --config-dir dadk/config --cache-dir $(DADK_CACHE_DIR) --dragonos-dir $(ROOT_PATH)/bin/sysroot clean target
  42. all:
  43. mkdir -p $(ROOT_PATH)/bin/sysroot
  44. $(MAKE) dadk_run
  45. $(MAKE) copy_sysconfig
  46. @echo 用户态程序编译完成
  47. copy_sysconfig: dadk_run
  48. cp -r sysconfig/* $(ROOT_PATH)/bin/sysroot/
  49. .PHONY: clean
  50. clean:
  51. $(MAKE) dadk_clean
  52. @list='$(user_sub_dirs)'; for subdir in $$list; do \
  53. echo "Clean in dir: $$subdir";\
  54. cd $$subdir && $(MAKE) clean;\
  55. cd .. ;\
  56. done
  57. .PHONY: fmt
  58. fmt:
  59. FMT_CHECK=$(FMT_CHECK) $(MAKE) -C apps fmt