Makefile 2.6 KB

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