toplevel.mk 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. SHELL:=/usr/bin/env bash
  10. PREP_MK= OPENWRT_BUILD= QUIET=0
  11. include $(TOPDIR)/include/verbose.mk
  12. ifeq ($(SDK),1)
  13. include $(TOPDIR)/include/version.mk
  14. else
  15. REVISION:=$(shell $(TOPDIR)/scripts/getver.sh)
  16. endif
  17. OPENWRTVERSION:=$(RELEASE)$(if $(REVISION), ($(REVISION)))
  18. export RELEASE
  19. export REVISION
  20. export OPENWRTVERSION
  21. export IS_TTY=$(shell tty -s && echo 1 || echo 0)
  22. export LD_LIBRARY_PATH:=$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(STAGING_DIR_HOST)/lib
  23. export DYLD_LIBRARY_PATH:=$(if $(DYLD_LIBRARY_PATH),$(DYLD_LIBRARY_PATH):)$(STAGING_DIR_HOST)/lib
  24. # prevent perforce from messing with the patch utility
  25. unexport P4PORT P4USER P4CONFIG P4CLIENT
  26. # prevent user defaults for quilt from interfering
  27. unexport QUILT_PATCHES QUILT_PATCH_OPTS
  28. # make sure that a predefined CFLAGS variable does not disturb packages
  29. export CFLAGS=
  30. ifeq ($(FORCE),)
  31. .config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
  32. endif
  33. SCAN_COOKIE?=$(shell echo $$$$)
  34. export SCAN_COOKIE
  35. prepare-mk: FORCE ;
  36. prepare-tmpinfo: FORCE
  37. mkdir -p tmp/info
  38. $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="packageinfo" SCAN_DIR="package" SCAN_NAME="package" SCAN_DEPS="$(TOPDIR)/include/package*.mk $(TOPDIR)/overlay/*/*.mk" SCAN_DEPTH=5 SCAN_EXTRA=""
  39. $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="profiles/*.mk $(TOPDIR)/include/kernel*.mk $(TOPDIR)/include/target.mk" SCAN_DEPTH=2 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1"
  40. for type in package target; do \
  41. f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
  42. [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
  43. done
  44. ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
  45. touch $(TOPDIR)/tmp/.build
  46. .config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo)
  47. @+if [ \! -e .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \
  48. [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
  49. $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
  50. fi
  51. scripts/config/mconf:
  52. @$(_SINGLE)$(SUBMAKE) -s -C scripts/config all
  53. $(eval $(call rdep,scripts/config,scripts/config/mconf))
  54. scripts/config/conf:
  55. @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf
  56. config: scripts/config/conf prepare-tmpinfo FORCE
  57. $< Config.in
  58. config-clean: FORCE
  59. $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean
  60. defconfig: scripts/config/conf prepare-tmpinfo FORCE
  61. touch .config
  62. $< -D .config Config.in
  63. oldconfig: scripts/config/conf prepare-tmpinfo FORCE
  64. $< -$(if $(CONFDEFAULT),$(CONFDEFAULT),o) Config.in
  65. menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
  66. if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
  67. cp $(HOME)/.openwrt/defconfig .config; \
  68. fi
  69. $< Config.in
  70. prepare_kernel_conf: .config FORCE
  71. ifeq ($(wildcard staging_dir/host/bin/sed),)
  72. prepare_kernel_conf:
  73. @+$(SUBMAKE) -r tools/sed/install
  74. else
  75. prepare_kernel_conf: ;
  76. endif
  77. kernel_oldconfig: prepare_kernel_conf
  78. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig
  79. kernel_menuconfig: prepare_kernel_conf
  80. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig
  81. tmp/.prereq-build: include/prereq-build.mk
  82. mkdir -p tmp
  83. rm -f tmp/.host.mk
  84. @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
  85. echo "Prerequisite check failed. Use FORCE=1 to override."; \
  86. false; \
  87. }
  88. touch $@
  89. download: .config FORCE
  90. @+$(SUBMAKE) tools/download
  91. @+$(SUBMAKE) toolchain/download
  92. @+$(SUBMAKE) package/download
  93. @+$(SUBMAKE) target/download
  94. clean dirclean: .config
  95. @+$(SUBMAKE) -r $@
  96. prereq:: prepare-tmpinfo .config
  97. @+$(MAKE) -r -s tmp/.prereq-build $(PREP_MK)
  98. @+$(NO_TRACE_MAKE) -r -s $@
  99. %::
  100. @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
  101. @+$(SUBMAKE) -r $@
  102. help:
  103. cat README
  104. docs docs/compile: FORCE
  105. @$(_SINGLE)$(SUBMAKE) -C docs compile
  106. docs/clean: FORCE
  107. @$(_SINGLE)$(SUBMAKE) -C docs clean
  108. distclean:
  109. rm -rf tmp build_dir staging_dir dl .config* feeds package/feeds package/openwrt-packages bin
  110. @$(_SINGLE)$(SUBMAKE) -C scripts/config clean
  111. ifeq ($(findstring v,$(DEBUG)),)
  112. .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
  113. endif
  114. .PHONY: help FORCE
  115. .NOTPARALLEL: