toplevel.mk 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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. RELEASE:=Kamikaze
  9. #VERSION:=2.0 # uncomment for final release
  10. SHELL:=/usr/bin/env bash
  11. OPENWRTVERSION:=$(RELEASE)
  12. PREP_MK= OPENWRT_BUILD= QUIET=0
  13. include $(TOPDIR)/include/verbose.mk
  14. ifneq ($(VERSION),)
  15. OPENWRTVERSION:=$(VERSION) ($(OPENWRTVERSION))
  16. else
  17. REV:=$(if $(wildcard .svn/entries),$(shell LANG=C svn info | awk '/^Revision:/ { print$$2 }' ))
  18. ifneq ($(REV),)
  19. OPENWRTVERSION:=$(OPENWRTVERSION)/r$(REV)
  20. endif
  21. endif
  22. export OPENWRTVERSION
  23. export IS_TTY=$(shell tty -s && echo 1 || echo 0)
  24. ifeq ($(FORCE),)
  25. .config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
  26. endif
  27. SCAN_COOKIE?=$(shell echo $$$$)
  28. export SCAN_COOKIE
  29. prepare-mk: FORCE ;
  30. prepare-tmpinfo: FORCE
  31. mkdir -p tmp/info
  32. +$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk" SCAN_DEPTH=5 SCAN_EXTRA=""
  33. +$(NO_TRACE_MAKE) -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk" SCAN_DEPTH=2 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1"
  34. for type in package target; do \
  35. f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
  36. [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
  37. done
  38. ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
  39. touch $(TOPDIR)/tmp/.build
  40. .config: ./scripts/config/conf prepare-tmpinfo
  41. @+if [ \! -f .config ]; then \
  42. [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
  43. $(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
  44. fi
  45. scripts/config/mconf:
  46. @+$(MAKE) -C scripts/config all
  47. $(eval $(call rdep,scripts/config,scripts/config/mconf))
  48. scripts/config/conf:
  49. @+$(MAKE) -C scripts/config conf
  50. config: scripts/config/conf prepare-tmpinfo FORCE
  51. $< Config.in
  52. config-clean: FORCE
  53. $(NO_TRACE_MAKE) -C scripts/config clean
  54. defconfig: scripts/config/conf prepare-tmpinfo FORCE
  55. touch .config
  56. $< -D .config Config.in
  57. oldconfig: scripts/config/conf prepare-tmpinfo FORCE
  58. $< -$(if $(CONFDEFAULT),$(CONFDEFAULT),o) Config.in
  59. menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
  60. if [ \! -f .config -a -e $(HOME)/.openwrt/defconfig ]; then \
  61. cp $(HOME)/.openwrt/defconfig .config; \
  62. fi
  63. $< Config.in
  64. kernel_oldconfig: .config FORCE
  65. $(NO_TRACE_MAKE) -C target/linux oldconfig
  66. kernel_menuconfig: .config FORCE
  67. $(NO_TRACE_MAKE) -C target/linux menuconfig
  68. tmp/.prereq-build: include/prereq-build.mk
  69. mkdir -p tmp
  70. rm -f tmp/.host.mk
  71. @+$(NO_TRACE_MAKE) -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
  72. echo "Prerequisite check failed. Use FORCE=1 to override."; \
  73. false; \
  74. }
  75. touch $@
  76. download: .config FORCE
  77. $(MAKE) -j1 tools/download
  78. $(MAKE) -j1 toolchain/download
  79. $(MAKE) -j1 package/download
  80. $(MAKE) -j1 target/download
  81. clean dirclean:
  82. @$(MAKE) $@
  83. prereq:: .config
  84. @+$(SUBMAKE) -s tmp/.prereq-build $(PREP_MK)
  85. @$(NO_TRACE_MAKE) -s $@
  86. %::
  87. @+$(PREP_MK) $(NO_TRACE_MAKE) -s prereq
  88. @+$(MAKE) -r $@
  89. help:
  90. cat README
  91. docs docs/compile: FORCE
  92. $(MAKE) -C docs compile
  93. docs/clean: FORCE
  94. $(MAKE) -C docs clean
  95. symlinkclean:
  96. -find package -type l | xargs rm -f
  97. rm -rf tmp
  98. distclean:
  99. rm -rf tmp build_dir staging_dir dl .config* feeds
  100. ifeq ($(findstring v,$(DEBUG)),)
  101. .SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig tmp/.prereq-build tmp/.prereq-package prepare-tmpinfo
  102. endif
  103. .PHONY: help FORCE
  104. .NOTPARALLEL: