toplevel.mk 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. # make sure that a predefined CFLAGS variable does not disturb packages
  27. export CFLAGS=
  28. ifeq ($(FORCE),)
  29. .config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
  30. endif
  31. SCAN_COOKIE?=$(shell echo $$$$)
  32. export SCAN_COOKIE
  33. prepare-mk: FORCE ;
  34. prepare-tmpinfo: FORCE
  35. mkdir -p tmp/info
  36. $(_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=""
  37. $(_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"
  38. for type in package target; do \
  39. f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
  40. [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
  41. done
  42. ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
  43. touch $(TOPDIR)/tmp/.build
  44. .config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo)
  45. @+if [ \! -e .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \
  46. [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
  47. $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
  48. fi
  49. scripts/config/mconf:
  50. @$(_SINGLE)$(SUBMAKE) -s -C scripts/config all
  51. $(eval $(call rdep,scripts/config,scripts/config/mconf))
  52. scripts/config/conf:
  53. @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf
  54. config: scripts/config/conf prepare-tmpinfo FORCE
  55. $< Config.in
  56. config-clean: FORCE
  57. $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean
  58. defconfig: scripts/config/conf prepare-tmpinfo FORCE
  59. touch .config
  60. $< -D .config Config.in
  61. oldconfig: scripts/config/conf prepare-tmpinfo FORCE
  62. $< -$(if $(CONFDEFAULT),$(CONFDEFAULT),o) Config.in
  63. menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
  64. if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
  65. cp $(HOME)/.openwrt/defconfig .config; \
  66. fi
  67. $< Config.in
  68. prepare_kernel_conf: .config FORCE
  69. ifeq ($(wildcard staging_dir/host/bin/sed),)
  70. prepare_kernel_conf:
  71. @+$(SUBMAKE) -r tools/sed/install
  72. else
  73. prepare_kernel_conf: ;
  74. endif
  75. kernel_oldconfig: prepare_kernel_conf
  76. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig
  77. kernel_menuconfig: prepare_kernel_conf
  78. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig
  79. tmp/.prereq-build: include/prereq-build.mk
  80. mkdir -p tmp
  81. rm -f tmp/.host.mk
  82. @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
  83. echo "Prerequisite check failed. Use FORCE=1 to override."; \
  84. false; \
  85. }
  86. touch $@
  87. download: .config FORCE
  88. @+$(SUBMAKE) tools/download
  89. @+$(SUBMAKE) toolchain/download
  90. @+$(SUBMAKE) package/download
  91. @+$(SUBMAKE) target/download
  92. clean dirclean: .config
  93. @+$(SUBMAKE) -r $@
  94. prereq:: prepare-tmpinfo .config
  95. @+$(MAKE) -r -s tmp/.prereq-build $(PREP_MK)
  96. @+$(NO_TRACE_MAKE) -r -s $@
  97. %::
  98. @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
  99. @+$(SUBMAKE) -r $@
  100. help:
  101. cat README
  102. docs docs/compile: FORCE
  103. @$(_SINGLE)$(SUBMAKE) -C docs compile
  104. docs/clean: FORCE
  105. @$(_SINGLE)$(SUBMAKE) -C docs clean
  106. distclean:
  107. rm -rf tmp build_dir staging_dir dl .config* feeds package/feeds package/openwrt-packages bin
  108. @$(_SINGLE)$(SUBMAKE) -C scripts/config clean
  109. ifeq ($(findstring v,$(DEBUG)),)
  110. .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
  111. endif
  112. .PHONY: help FORCE
  113. .NOTPARALLEL: