toplevel.mk 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. # Makefile for OpenWrt
  2. #
  3. # Copyright (C) 2007-2011 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:=Attitude Adjustment
  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. HOSTCC ?= gcc
  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:=$(subst ::,:,$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(STAGING_DIR_HOST)/lib)
  23. export DYLD_LIBRARY_PATH:=$(subst ::,:,$(if $(DYLD_LIBRARY_PATH),$(DYLD_LIBRARY_PATH):)$(STAGING_DIR_HOST)/lib)
  24. export GIT_CONFIG_PARAMETERS='core.autocrlf=false'
  25. export MAKE_JOBSERVER=$(filter --jobserver%,$(MAKEFLAGS))
  26. # prevent perforce from messing with the patch utility
  27. unexport P4PORT P4USER P4CONFIG P4CLIENT
  28. # prevent user defaults for quilt from interfering
  29. unexport QUILT_PATCHES QUILT_PATCH_OPTS
  30. unexport C_INCLUDE_PATH CROSS_COMPILE ARCH
  31. # prevent distro default LPATH from interfering
  32. unexport LPATH
  33. # make sure that a predefined CFLAGS variable does not disturb packages
  34. export CFLAGS=
  35. ifeq ($(FORCE),)
  36. .config scripts/config/conf scripts/config/mconf: tmp/.prereq-build
  37. endif
  38. SCAN_COOKIE?=$(shell echo $$$$)
  39. export SCAN_COOKIE
  40. SUBMAKE:=umask 022; $(SUBMAKE)
  41. prepare-mk: FORCE ;
  42. prepare-tmpinfo: FORCE
  43. mkdir -p tmp/info
  44. $(_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=""
  45. $(_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"
  46. for type in package target; do \
  47. f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
  48. [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
  49. done
  50. ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
  51. touch $(TOPDIR)/tmp/.build
  52. .config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo)
  53. @+if [ \! -e .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \
  54. [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
  55. $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
  56. fi
  57. scripts/config/mconf:
  58. @$(_SINGLE)$(SUBMAKE) -s -C scripts/config all CC="$(HOSTCC)"
  59. $(eval $(call rdep,scripts/config,scripts/config/mconf))
  60. scripts/config/conf:
  61. @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf CC="$(HOSTCC)"
  62. config: scripts/config/conf prepare-tmpinfo FORCE
  63. $< Config.in
  64. config-clean: FORCE
  65. $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean
  66. defconfig: scripts/config/conf prepare-tmpinfo FORCE
  67. touch .config
  68. $< -D .config Config.in
  69. oldconfig: scripts/config/conf prepare-tmpinfo FORCE
  70. $< -$(if $(CONFDEFAULT),$(CONFDEFAULT),o) Config.in
  71. menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
  72. if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
  73. cp $(HOME)/.openwrt/defconfig .config; \
  74. fi
  75. $< Config.in
  76. prepare_kernel_conf: .config FORCE
  77. ifeq ($(wildcard staging_dir/host/bin/quilt),)
  78. prepare_kernel_conf:
  79. @+$(SUBMAKE) -r tools/quilt/install
  80. else
  81. prepare_kernel_conf: ;
  82. endif
  83. kernel_oldconfig: prepare_kernel_conf
  84. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig
  85. kernel_menuconfig: prepare_kernel_conf
  86. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig
  87. kernel_nconfig: prepare_kernel_conf
  88. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig
  89. tmp/.prereq-build: include/prereq-build.mk
  90. mkdir -p tmp
  91. rm -f tmp/.host.mk
  92. @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
  93. echo "Prerequisite check failed. Use FORCE=1 to override."; \
  94. false; \
  95. }
  96. touch $@
  97. printdb: FORCE
  98. @$(_SINGLE)$(NO_TRACE_MAKE) -p $@ V=99 DUMP_TARGET_DB=1 2>&1
  99. download: .config FORCE
  100. @+$(SUBMAKE) tools/download
  101. @+$(SUBMAKE) toolchain/download
  102. @+$(SUBMAKE) package/download
  103. @+$(SUBMAKE) target/download
  104. clean dirclean: .config
  105. @+$(SUBMAKE) -r $@
  106. prereq:: prepare-tmpinfo .config
  107. @+$(MAKE) -r -s tmp/.prereq-build $(PREP_MK)
  108. @+$(NO_TRACE_MAKE) -r -s $@
  109. %::
  110. @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
  111. @( \
  112. cp .config tmp/.config; \
  113. ./scripts/config/conf -D tmp/.config -w tmp/.config Config.in > /dev/null 2>&1; \
  114. if ./scripts/kconfig.pl '>' .config tmp/.config | grep -q CONFIG; then \
  115. echo "WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!"; \
  116. fi \
  117. )
  118. @+$(SUBMAKE) -r $@
  119. help:
  120. cat README
  121. docs docs/compile: FORCE
  122. @$(_SINGLE)$(SUBMAKE) -C docs compile
  123. docs/clean: FORCE
  124. @$(_SINGLE)$(SUBMAKE) -C docs clean
  125. distclean:
  126. rm -rf tmp build_dir staging_dir dl .config* feeds package/feeds package/openwrt-packages bin
  127. @$(_SINGLE)$(SUBMAKE) -C scripts/config clean
  128. ifeq ($(findstring v,$(DEBUG)),)
  129. .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
  130. endif
  131. .PHONY: help FORCE
  132. .NOTPARALLEL: