1
0

Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. #
  3. # Copyright (C) 2007 OpenWrt.org
  4. TOPDIR:=${CURDIR}
  5. LC_ALL:=C
  6. LANG:=C
  7. TZ:=UTC
  8. export TOPDIR LC_ALL LANG TZ
  9. empty:=
  10. space:= $(empty) $(empty)
  11. $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the libreCMC directory must not include any spaces))
  12. world:
  13. DISTRO_PKG_CONFIG:=$(shell $(TOPDIR)/scripts/command_all.sh pkg-config | grep -e '/usr' -e '/nix/store' -m 1)
  14. export ORIG_PATH:=$(if $(ORIG_PATH),$(ORIG_PATH),$(PATH))
  15. export PATH:=$(if $(STAGING_DIR),$(abspath $(STAGING_DIR)/../host/bin),$(TOPDIR)/staging_dir/host/bin):$(PATH)
  16. ifneq ($(LIBRECMC_BUILD),1)
  17. _SINGLE=export MAKEFLAGS=$(space);
  18. override LIBRECMC_BUILD=1
  19. export LIBRECMC_BUILD
  20. GREP_OPTIONS=
  21. export GREP_OPTIONS
  22. CDPATH=
  23. export CDPATH
  24. include $(TOPDIR)/include/debug.mk
  25. include $(TOPDIR)/include/depends.mk
  26. include $(TOPDIR)/include/toplevel.mk
  27. else
  28. include rules.mk
  29. include $(INCLUDE_DIR)/depends.mk
  30. include $(INCLUDE_DIR)/subdir.mk
  31. include target/Makefile
  32. include package/Makefile
  33. include tools/Makefile
  34. include toolchain/Makefile
  35. $(toolchain/stamp-compile): $(tools/stamp-compile) $(if $(CONFIG_BUILDBOT),toolchain_rebuild_check)
  36. $(target/stamp-compile): $(toolchain/stamp-compile) $(tools/stamp-compile) $(BUILD_DIR)/.prepared
  37. $(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup)
  38. $(package/stamp-install): $(package/stamp-compile)
  39. $(target/stamp-install): $(package/stamp-compile) $(package/stamp-install)
  40. check: $(tools/stamp-check) $(toolchain/stamp-check) $(package/stamp-check)
  41. printdb:
  42. @true
  43. prepare: $(target/stamp-compile)
  44. _clean: FORCE
  45. rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(OUTPUT_DIR)/packages/$(ARCH_PACKAGES) $(TOPDIR)/staging_dir/packages
  46. clean: _clean
  47. rm -rf $(BUILD_LOG_DIR)
  48. targetclean: _clean
  49. rm -rf $(TOOLCHAIN_DIR) $(BUILD_DIR_BASE)/hostpkg $(BUILD_DIR_TOOLCHAIN)
  50. dirclean: targetclean clean
  51. rm -rf $(STAGING_DIR_HOST) $(STAGING_DIR_HOSTPKG) $(BUILD_DIR_BASE)/host
  52. rm -rf $(TMP_DIR)
  53. $(MAKE) -C $(TOPDIR)/scripts/config clean
  54. toolchain_rebuild_check:
  55. $(SCRIPT_DIR)/check-toolchain-clean.sh
  56. cacheclean:
  57. ifneq ($(CONFIG_CCACHE),)
  58. $(STAGING_DIR_HOST)/bin/ccache -C
  59. endif
  60. ifndef DUMP_TARGET_DB
  61. $(BUILD_DIR)/.prepared: Makefile
  62. @mkdir -p $$(dirname $@)
  63. @touch $@
  64. tmp/.prereq_packages: .config
  65. unset ERROR; \
  66. for package in $(sort $(prereq-y) $(prereq-m)); do \
  67. $(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \
  68. done; \
  69. if [ -n "$$ERROR" ]; then \
  70. echo "Package prerequisite check failed."; \
  71. false; \
  72. fi
  73. touch $@
  74. endif
  75. # check prerequisites before starting to build
  76. prereq: $(target/stamp-prereq) tmp/.prereq_packages
  77. @if [ ! -f "$(INCLUDE_DIR)/site/$(ARCH)" ]; then \
  78. echo 'ERROR: Missing site config for architecture "$(ARCH)" !'; \
  79. echo ' The missing file will cause configure scripts to fail during compilation.'; \
  80. echo ' Please provide a "$(INCLUDE_DIR)/site/$(ARCH)" file and restart the build.'; \
  81. exit 1; \
  82. fi
  83. $(BIN_DIR)/profiles.json: FORCE
  84. $(if $(CONFIG_JSON_OVERVIEW_IMAGE_INFO), \
  85. WORK_DIR=$(BUILD_DIR)/json_info_files \
  86. $(SCRIPT_DIR)/json_overview_image_info.py $@ \
  87. )
  88. json_overview_image_info: $(BIN_DIR)/profiles.json
  89. checksum: FORCE
  90. $(call sha256sums,$(BIN_DIR),$(CONFIG_BUILDBOT))
  91. buildversion: FORCE
  92. $(SCRIPT_DIR)/getver.sh > $(BIN_DIR)/version.buildinfo
  93. feedsversion: FORCE
  94. $(SCRIPT_DIR)/feeds list -fs > $(BIN_DIR)/feeds.buildinfo
  95. diffconfig: FORCE
  96. mkdir -p $(BIN_DIR)
  97. $(SCRIPT_DIR)/diffconfig.sh > $(BIN_DIR)/config.buildinfo
  98. buildinfo: FORCE
  99. $(_SINGLE)$(SUBMAKE) -r diffconfig buildversion feedsversion
  100. prepare: .config $(tools/stamp-compile) $(toolchain/stamp-compile)
  101. $(_SINGLE)$(SUBMAKE) -r buildinfo
  102. world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE
  103. $(_SINGLE)$(SUBMAKE) -r package/index
  104. $(_SINGLE)$(SUBMAKE) -r json_overview_image_info
  105. $(_SINGLE)$(SUBMAKE) -r checksum
  106. ifneq ($(CONFIG_CCACHE),)
  107. $(STAGING_DIR_HOST)/bin/ccache -s
  108. endif
  109. .PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean
  110. endif