Makefile 3.7 KB

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