Makefile 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. # Makefile for OpenWrt
  2. #
  3. # Copyright (C) 2007 OpenWrt.org
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. TOPDIR:=${CURDIR}
  9. LC_ALL:=C
  10. LANG:=C
  11. export TOPDIR LC_ALL LANG
  12. empty:=
  13. space:= $(empty) $(empty)
  14. $(if $(findstring $(space),$(TOPDIR)),$(error ERROR: The path to the OpenWrt directory must not include any spaces))
  15. world:
  16. include $(TOPDIR)/include/host.mk
  17. ifneq ($(OPENWRT_BUILD),1)
  18. # XXX: these three lines are normally defined by rules.mk
  19. # but we can't include that file in this context
  20. empty:=
  21. space:= $(empty) $(empty)
  22. _SINGLE=export MAKEFLAGS=$(space);
  23. override OPENWRT_BUILD=1
  24. export OPENWRT_BUILD
  25. GREP_OPTIONS=
  26. export GREP_OPTIONS
  27. include $(TOPDIR)/include/debug.mk
  28. include $(TOPDIR)/include/depends.mk
  29. include $(TOPDIR)/include/toplevel.mk
  30. else
  31. include rules.mk
  32. include $(INCLUDE_DIR)/depends.mk
  33. include $(INCLUDE_DIR)/subdir.mk
  34. include target/Makefile
  35. include package/Makefile
  36. include tools/Makefile
  37. include toolchain/Makefile
  38. $(toolchain/stamp-install): $(tools/stamp-install)
  39. $(target/stamp-compile): $(toolchain/stamp-install) $(tools/stamp-install) $(BUILD_DIR)/.prepared
  40. $(package/stamp-compile): $(target/stamp-compile) $(package/stamp-cleanup)
  41. $(package/stamp-install): $(package/stamp-compile)
  42. $(target/stamp-install): $(package/stamp-compile) $(package/stamp-install)
  43. printdb:
  44. @true
  45. prepare: $(target/stamp-compile)
  46. clean: FORCE
  47. $(_SINGLE)$(SUBMAKE) target/linux/clean
  48. rm -rf $(BUILD_DIR) $(BIN_DIR) $(BUILD_LOG_DIR)
  49. dirclean: clean
  50. rm -rf $(STAGING_DIR) $(STAGING_DIR_HOST) $(STAGING_DIR_TOOLCHAIN) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) $(BUILD_DIR_TOOLCHAIN)
  51. rm -rf $(TMP_DIR)
  52. ifndef DUMP_TARGET_DB
  53. $(BUILD_DIR)/.prepared: Makefile
  54. @mkdir -p $$(dirname $@)
  55. @touch $@
  56. tmp/.prereq_packages: .config
  57. unset ERROR; \
  58. for package in $(sort $(prereq-y) $(prereq-m)); do \
  59. $(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \
  60. done; \
  61. if [ -n "$$ERROR" ]; then \
  62. echo "Package prerequisite check failed."; \
  63. false; \
  64. fi
  65. touch $@
  66. endif
  67. # check prerequisites before starting to build
  68. prereq: $(target/stamp-prereq) tmp/.prereq_packages
  69. @if [ ! -f "$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)" ]; then \
  70. echo 'ERROR: Missing site config for target "$(REAL_GNU_TARGET_NAME)" !'; \
  71. echo ' The missing file will cause configure scripts to fail during compilation.'; \
  72. echo ' Please provide a "$(INCLUDE_DIR)/site/$(REAL_GNU_TARGET_NAME)" file and restart the build.'; \
  73. exit 1; \
  74. fi
  75. prepare: .config $(tools/stamp-install) $(toolchain/stamp-install)
  76. world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE
  77. $(_SINGLE)$(SUBMAKE) -r package/index
  78. # update all feeds, re-create index files, install symlinks
  79. package/symlinks:
  80. $(SCRIPT_DIR)/feeds update -a
  81. $(SCRIPT_DIR)/feeds install -a
  82. # re-create index files, install symlinks
  83. package/symlinks-install:
  84. $(SCRIPT_DIR)/feeds update -i
  85. $(SCRIPT_DIR)/feeds install -a
  86. # remove all symlinks, don't touch ./feeds
  87. package/symlinks-clean:
  88. $(SCRIPT_DIR)/feeds uninstall -a
  89. .PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean
  90. endif