toplevel.mk 4.6 KB

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