Makefile 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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. _SINGLE=export MAKEFLAGS=$(space);
  19. override OPENWRT_BUILD=1
  20. export OPENWRT_BUILD
  21. GREP_OPTIONS=
  22. export GREP_OPTIONS
  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-install): $(tools/stamp-install)
  35. $(target/stamp-compile): $(toolchain/stamp-install) $(tools/stamp-install) $(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. printdb:
  40. @true
  41. prepare: $(target/stamp-compile)
  42. clean: FORCE
  43. rm -rf $(BUILD_DIR) $(STAGING_DIR) $(BIN_DIR) $(BUILD_LOG_DIR)
  44. dirclean: clean
  45. rm -rf $(STAGING_DIR_HOST) $(TOOLCHAIN_DIR) $(BUILD_DIR_HOST) $(BUILD_DIR_TOOLCHAIN)
  46. rm -rf $(TMP_DIR)
  47. ifndef DUMP_TARGET_DB
  48. $(BUILD_DIR)/.prepared: Makefile
  49. @mkdir -p $$(dirname $@)
  50. @touch $@
  51. tmp/.prereq_packages: .config
  52. unset ERROR; \
  53. for package in $(sort $(prereq-y) $(prereq-m)); do \
  54. $(_SINGLE)$(NO_TRACE_MAKE) -s -r -C package/$$package prereq || ERROR=1; \
  55. done; \
  56. if [ -n "$$ERROR" ]; then \
  57. echo "Package prerequisite check failed."; \
  58. false; \
  59. fi
  60. touch $@
  61. endif
  62. # check prerequisites before starting to build
  63. prereq: $(target/stamp-prereq) tmp/.prereq_packages
  64. @if [ ! -f "$(INCLUDE_DIR)/site/$(ARCH)" ]; then \
  65. echo 'ERROR: Missing site config for architecture "$(ARCH)" !'; \
  66. echo ' The missing file will cause configure scripts to fail during compilation.'; \
  67. echo ' Please provide a "$(INCLUDE_DIR)/site/$(ARCH)" file and restart the build.'; \
  68. exit 1; \
  69. fi
  70. prepare: .config $(tools/stamp-install) $(toolchain/stamp-install)
  71. world: prepare $(target/stamp-compile) $(package/stamp-compile) $(package/stamp-install) $(target/stamp-install) FORCE
  72. $(_SINGLE)$(SUBMAKE) -r package/index
  73. .PHONY: clean dirclean prereq prepare world package/symlinks package/symlinks-install package/symlinks-clean
  74. endif