Makefile 2.1 KB

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