toplevel.mk 4.2 KB

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