rules.mk 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. __THEOS_RULES_MK_VERSION := 1k
  2. ifneq ($(__THEOS_RULES_MK_VERSION),$(__THEOS_COMMON_MK_VERSION))
  3. all::
  4. @echo "Theos version mismatch! common.mk [version $(or $(__THEOS_COMMON_MK_VERSION),0)] loaded in tandem with rules.mk [version $(or $(__THEOS_RULES_MK_VERSION),0)] Check that \$$\(THEOS\) is set properly!" >&2
  5. @exit 1
  6. endif
  7. .PHONY: all before-all internal-all after-all \
  8. clean before-clean internal-clean after-clean update-theos
  9. ifeq ($(THEOS_BUILD_DIR),.)
  10. all:: $(_THEOS_BUILD_SESSION_FILE) before-all internal-all after-all
  11. else
  12. all:: $(THEOS_BUILD_DIR) $(_THEOS_BUILD_SESSION_FILE) before-all internal-all after-all
  13. endif
  14. clean:: before-clean internal-clean after-clean
  15. do:: all package install
  16. before-all::
  17. ifneq ($(SYSROOT),)
  18. @[ -d "$(SYSROOT)" ] || { $(PRINT_FORMAT_ERROR) "Your current SYSROOT, \"$(SYSROOT)\", appears to be missing." >&2; exit 1; }
  19. endif
  20. internal-all::
  21. after-all::
  22. before-clean::
  23. internal-clean::
  24. $(ECHO_CLEANING)rm -rf "$(THEOS_OBJ_DIR)"$(ECHO_END)
  25. ifeq ($(shell [ -f "$(_THEOS_BUILD_SESSION_FILE)" ] && echo 1),1)
  26. $(ECHO_NOTHING)rm "$(_THEOS_BUILD_SESSION_FILE)"$(ECHO_END)
  27. endif
  28. ifeq ($(MAKELEVEL),0)
  29. $(ECHO_NOTHING)rm -rf "$(THEOS_STAGING_DIR)"$(ECHO_END)
  30. endif
  31. after-clean::
  32. ifeq ($(MAKELEVEL),0)
  33. ifneq ($(THEOS_BUILD_DIR),.)
  34. _THEOS_ABSOLUTE_BUILD_DIR = $(call __clean_pwd,$(THEOS_BUILD_DIR))
  35. else
  36. _THEOS_ABSOLUTE_BUILD_DIR = .
  37. endif
  38. else
  39. _THEOS_ABSOLUTE_BUILD_DIR = $(strip $(THEOS_BUILD_DIR))
  40. endif
  41. clean-packages:: before-clean-packages internal-clean-packages after-clean-packages
  42. before-clean-packages::
  43. internal-clean-packages::
  44. $(ECHO_NOTHING)rm -rf $(THEOS_PACKAGE_DIR)/$(THEOS_PACKAGE_NAME)_*-*_$(THEOS_PACKAGE_ARCH).deb$(ECHO_END)
  45. $(ECHO_NOTHING)rm -rf $(THEOS_PACKAGE_DIR)/$(THEOS_PACKAGE_NAME)-*-*.$(THEOS_PACKAGE_ARCH).rpm$(ECHO_END)
  46. after-clean-packages::
  47. $(_THEOS_BUILD_SESSION_FILE):
  48. @mkdir -p $(_THEOS_LOCAL_DATA_DIR)
  49. ifeq ($(shell [ -f "$(_THEOS_BUILD_SESSION_FILE)" ] || echo 0),0)
  50. @touch $(_THEOS_BUILD_SESSION_FILE)
  51. endif
  52. .PRECIOUS: %.variables %.subprojects
  53. %.variables: _INSTANCE = $(basename $(basename $*))
  54. %.variables: _OPERATION = $(subst .,,$(suffix $(basename $*)))
  55. %.variables: _TYPE = $(subst -,_,$(subst .,,$(suffix $*)))
  56. %.variables: __SUBPROJECTS = $(strip $(call __schema_var_all,$(_INSTANCE)_,SUBPROJECTS))
  57. %.variables:
  58. @ \
  59. abs_build_dir=$(_THEOS_ABSOLUTE_BUILD_DIR); \
  60. if [ "$(__SUBPROJECTS)" != "" ]; then \
  61. $(PRINT_FORMAT_MAKING) "Making $(_OPERATION) in subprojects of $(_TYPE) $(_INSTANCE)"; \
  62. for d in $(__SUBPROJECTS); do \
  63. d="$${d%:*}"; \
  64. if [ "$${abs_build_dir}" = "." ]; then \
  65. lbuilddir="."; \
  66. else \
  67. lbuilddir="$${abs_build_dir}/$$d"; \
  68. fi; \
  69. if $(MAKE) -C $$d -f $(_THEOS_PROJECT_MAKEFILE_NAME) $(_THEOS_NO_PRINT_DIRECTORY_FLAG) --no-keep-going $(_OPERATION) \
  70. THEOS_BUILD_DIR="$$lbuilddir" \
  71. ; then\
  72. :; \
  73. else exit $$?; \
  74. fi; \
  75. done; \
  76. fi; \
  77. $(PRINT_FORMAT_MAKING) "Making $(_OPERATION) for $(_TYPE) $(_INSTANCE)"; \
  78. $(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going \
  79. internal-$(_TYPE)-$(_OPERATION) \
  80. _THEOS_CURRENT_TYPE="$(_TYPE)" \
  81. THEOS_CURRENT_INSTANCE="$(_INSTANCE)" \
  82. _THEOS_CURRENT_OPERATION="$(_OPERATION)" \
  83. THEOS_BUILD_DIR="$(_THEOS_ABSOLUTE_BUILD_DIR)"
  84. %.subprojects: _INSTANCE = $(basename $(basename $*))
  85. %.subprojects: _OPERATION = $(subst .,,$(suffix $(basename $*)))
  86. %.subprojects: _TYPE = $(subst -,_,$(subst .,,$(suffix $*)))
  87. %.subprojects: __SUBPROJECTS = $(strip $(call __schema_var_all,$(_INSTANCE)_,SUBPROJECTS))
  88. %.subprojects:
  89. @ \
  90. abs_build_dir=$(_THEOS_ABSOLUTE_BUILD_DIR); \
  91. if [ "$(__SUBPROJECTS)" != "" ]; then \
  92. $(PRINT_FORMAT_MAKING) "Making $(_OPERATION) in subprojects of $(_TYPE) $(_INSTANCE)"; \
  93. for d in $(__SUBPROJECTS); do \
  94. d="$${d%:*}"; \
  95. if [ "$${abs_build_dir}" = "." ]; then \
  96. lbuilddir="."; \
  97. else \
  98. lbuilddir="$${abs_build_dir}/$$d"; \
  99. fi; \
  100. if $(MAKE) -C $$d -f $(_THEOS_PROJECT_MAKEFILE_NAME) $(_THEOS_NO_PRINT_DIRECTORY_FLAG) --no-keep-going $(_OPERATION) \
  101. THEOS_BUILD_DIR="$$lbuilddir" \
  102. ; then\
  103. :; \
  104. else exit $$?; \
  105. fi; \
  106. done; \
  107. fi
  108. update-theos::
  109. @if [ ! -d "$(THEOS)/.git" ]; then \
  110. $(PRINT_FORMAT_ERROR) "$(THEOS) is not a Git repository. For more information, refer to https://github.com/kirb/theos/wiki/Installation#updating." >&2; \
  111. exit 1; \
  112. fi
  113. @cd $(THEOS) && git pull origin master && ./git-submodule-recur.sh init
  114. troubleshoot::
  115. @$(PRINT_FORMAT) "Be sure to check the troubleshooting page at https://github.com/kirb/theos/wiki/Troubleshooting first."
  116. @$(PRINT_FORMAT) "For support with build errors, ask on IRC: http://iphonedevwiki.net/index.php/IRC. If you think you've found a bug in Theos, check the issue tracker at https://github.com/kirb/theos/issues."
  117. @echo
  118. ifeq ($(call __executable,ghost),$(_THEOS_TRUE))
  119. @$(PRINT_FORMAT) "Creating a Ghostbin containing the output of \`make clean all messages=yes\`…"
  120. $(MAKE) -f $(_THEOS_PROJECT_MAKEFILE_NAME) --no-print-directory --no-keep-going clean all messages=yes FORCE_COLOR=yes 2>&1 | ghost -x 336h - ansi
  121. else
  122. @$(PRINT_FORMAT_ERROR) "You don't have ghost installed. For more information, refer to https://github.com/kirb/theos/wiki/Installation#prerequisites." >&2; exit 1
  123. endif
  124. $(eval $(call __mod,master/rules.mk))
  125. ifeq ($(_THEOS_TOP_INVOCATION_DONE),)
  126. export _THEOS_TOP_INVOCATION_DONE = 1
  127. endif