deps-tools.mk 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. # Copyright (c) 2013-2015, Loïc Hoguin <essen@ninenines.eu>
  2. # Copyright (c) 2015-2016, Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com>
  3. # This file is part of erlang.mk and subject to the terms of the ISC License.
  4. # Fetch dependencies recursively (without building them).
  5. .PHONY: fetch-deps fetch-doc-deps fetch-rel-deps fetch-test-deps \
  6. fetch-shell-deps
  7. .PHONY: $(ERLANG_MK_RECURSIVE_DEPS_LIST) \
  8. $(ERLANG_MK_RECURSIVE_DOC_DEPS_LIST) \
  9. $(ERLANG_MK_RECURSIVE_REL_DEPS_LIST) \
  10. $(ERLANG_MK_RECURSIVE_TEST_DEPS_LIST) \
  11. $(ERLANG_MK_RECURSIVE_SHELL_DEPS_LIST)
  12. fetch-deps: $(ERLANG_MK_RECURSIVE_DEPS_LIST)
  13. fetch-doc-deps: $(ERLANG_MK_RECURSIVE_DOC_DEPS_LIST)
  14. fetch-rel-deps: $(ERLANG_MK_RECURSIVE_REL_DEPS_LIST)
  15. fetch-test-deps: $(ERLANG_MK_RECURSIVE_TEST_DEPS_LIST)
  16. fetch-shell-deps: $(ERLANG_MK_RECURSIVE_SHELL_DEPS_LIST)
  17. ifneq ($(SKIP_DEPS),)
  18. $(ERLANG_MK_RECURSIVE_DEPS_LIST) \
  19. $(ERLANG_MK_RECURSIVE_DOC_DEPS_LIST) \
  20. $(ERLANG_MK_RECURSIVE_REL_DEPS_LIST) \
  21. $(ERLANG_MK_RECURSIVE_TEST_DEPS_LIST) \
  22. $(ERLANG_MK_RECURSIVE_SHELL_DEPS_LIST):
  23. $(verbose) :> $@
  24. else
  25. # By default, we fetch "normal" dependencies. They are also included no
  26. # matter the type of requested dependencies.
  27. #
  28. # $(ALL_DEPS_DIRS) includes $(BUILD_DEPS).
  29. $(ERLANG_MK_RECURSIVE_DEPS_LIST): $(ALL_DEPS_DIRS)
  30. $(ERLANG_MK_RECURSIVE_DOC_DEPS_LIST): $(ALL_DEPS_DIRS) $(ALL_DOC_DEPS_DIRS)
  31. $(ERLANG_MK_RECURSIVE_REL_DEPS_LIST): $(ALL_DEPS_DIRS) $(ALL_REL_DEPS_DIRS)
  32. $(ERLANG_MK_RECURSIVE_TEST_DEPS_LIST): $(ALL_DEPS_DIRS) $(ALL_TEST_DEPS_DIRS)
  33. $(ERLANG_MK_RECURSIVE_SHELL_DEPS_LIST): $(ALL_DEPS_DIRS) $(ALL_SHELL_DEPS_DIRS)
  34. # Allow to use fetch-deps and $(DEP_TYPES) to fetch multiple types of
  35. # dependencies with a single target.
  36. ifneq ($(filter doc,$(DEP_TYPES)),)
  37. $(ERLANG_MK_RECURSIVE_DEPS_LIST): $(ALL_DOC_DEPS_DIRS)
  38. endif
  39. ifneq ($(filter rel,$(DEP_TYPES)),)
  40. $(ERLANG_MK_RECURSIVE_DEPS_LIST): $(ALL_REL_DEPS_DIRS)
  41. endif
  42. ifneq ($(filter test,$(DEP_TYPES)),)
  43. $(ERLANG_MK_RECURSIVE_DEPS_LIST): $(ALL_TEST_DEPS_DIRS)
  44. endif
  45. ifneq ($(filter shell,$(DEP_TYPES)),)
  46. $(ERLANG_MK_RECURSIVE_DEPS_LIST): $(ALL_SHELL_DEPS_DIRS)
  47. endif
  48. ERLANG_MK_RECURSIVE_TMP_LIST := $(abspath $(ERLANG_MK_TMP)/recursive-tmp-deps.log)
  49. $(ERLANG_MK_RECURSIVE_DEPS_LIST) \
  50. $(ERLANG_MK_RECURSIVE_DOC_DEPS_LIST) \
  51. $(ERLANG_MK_RECURSIVE_REL_DEPS_LIST) \
  52. $(ERLANG_MK_RECURSIVE_TEST_DEPS_LIST) \
  53. $(ERLANG_MK_RECURSIVE_SHELL_DEPS_LIST):
  54. ifeq ($(IS_APP)$(IS_DEP),)
  55. $(verbose) mkdir -p $(ERLANG_MK_TMP)
  56. $(verbose) rm -f $(ERLANG_MK_RECURSIVE_TMP_LIST)
  57. endif
  58. ifndef IS_APP
  59. $(verbose) for dep in $(ALL_APPS_DIRS) ; do \
  60. $(MAKE) -C $$dep $@ \
  61. IS_APP=1 \
  62. ERLANG_MK_RECURSIVE_TMP_LIST=$(ERLANG_MK_RECURSIVE_TMP_LIST) \
  63. || exit $$?; \
  64. done
  65. endif
  66. $(verbose) for dep in $^ ; do \
  67. if ! grep -qs ^$$dep$$ $(ERLANG_MK_RECURSIVE_TMP_LIST); then \
  68. echo $$dep >> $(ERLANG_MK_RECURSIVE_TMP_LIST); \
  69. if grep -qs -E "^[[:blank:]]*include[[:blank:]]+(erlang\.mk|.*/erlang\.mk)$$" \
  70. $$dep/GNUmakefile $$dep/makefile $$dep/Makefile; then \
  71. $(MAKE) -C $$dep fetch-deps \
  72. IS_DEP=1 \
  73. ERLANG_MK_RECURSIVE_TMP_LIST=$(ERLANG_MK_RECURSIVE_TMP_LIST) \
  74. || exit $$?; \
  75. fi \
  76. fi \
  77. done
  78. ifeq ($(IS_APP)$(IS_DEP),)
  79. $(verbose) sort < $(ERLANG_MK_RECURSIVE_TMP_LIST) | uniq > $@
  80. $(verbose) rm $(ERLANG_MK_RECURSIVE_TMP_LIST)
  81. endif
  82. endif # ifneq ($(SKIP_DEPS),)
  83. # List dependencies recursively.
  84. .PHONY: list-deps list-doc-deps list-rel-deps list-test-deps \
  85. list-shell-deps
  86. list-deps: $(ERLANG_MK_RECURSIVE_DEPS_LIST)
  87. list-doc-deps: $(ERLANG_MK_RECURSIVE_DOC_DEPS_LIST)
  88. list-rel-deps: $(ERLANG_MK_RECURSIVE_REL_DEPS_LIST)
  89. list-test-deps: $(ERLANG_MK_RECURSIVE_TEST_DEPS_LIST)
  90. list-shell-deps: $(ERLANG_MK_RECURSIVE_SHELL_DEPS_LIST)
  91. list-deps list-doc-deps list-rel-deps list-test-deps list-shell-deps:
  92. $(verbose) cat $^