toplevel.mk 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. # Makefile for OpenWrt
  2. #
  3. # Copyright (C) 2007-2012 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:=Barrier Breaker
  9. PREP_MK= OPENWRT_BUILD= QUIET=0
  10. export IS_TTY=$(shell tty -s && echo 1 || echo 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. HOSTCC ?= gcc
  18. OPENWRTVERSION:=$(RELEASE)$(if $(REVISION), ($(REVISION)))
  19. export RELEASE
  20. export REVISION
  21. export OPENWRTVERSION
  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. ULIMIT_FIX=_limit=`ulimit -n`; [ "$$_limit" = "unlimited" -o "$$_limit" -ge 1024 ] || ulimit -n 1024;
  42. prepare-mk: FORCE ;
  43. prepare-tmpinfo: FORCE
  44. mkdir -p tmp/info
  45. $(_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=""
  46. $(_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"
  47. for type in package target; do \
  48. f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
  49. [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
  50. done
  51. ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
  52. touch $(TOPDIR)/tmp/.build
  53. .config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo)
  54. @+if [ \! -e .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \
  55. [ -e $(HOME)/.openwrt/defconfig ] && cp $(HOME)/.openwrt/defconfig .config; \
  56. $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
  57. fi
  58. scripts/config/mconf:
  59. @$(_SINGLE)$(SUBMAKE) -s -C scripts/config all CC="$(HOSTCC)"
  60. $(eval $(call rdep,scripts/config,scripts/config/mconf))
  61. scripts/config/conf:
  62. @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf CC="$(HOSTCC)"
  63. config: scripts/config/conf prepare-tmpinfo FORCE
  64. $< Config.in
  65. config-clean: FORCE
  66. $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean
  67. defconfig: scripts/config/conf prepare-tmpinfo FORCE
  68. touch .config
  69. $< --defconfig=.config Config.in
  70. confdefault-y=allyes
  71. confdefault-m=allmod
  72. confdefault-n=allno
  73. confdefault:=$(confdefault-$(CONFDEFAULT))
  74. oldconfig: scripts/config/conf prepare-tmpinfo FORCE
  75. $< --$(if $(confdefault),$(confdefault),old)config Config.in
  76. menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
  77. if [ \! -e .config -a -e $(HOME)/.openwrt/defconfig ]; then \
  78. cp $(HOME)/.openwrt/defconfig .config; \
  79. fi
  80. $< Config.in
  81. prepare_kernel_conf: .config FORCE
  82. ifeq ($(wildcard staging_dir/host/bin/quilt),)
  83. prepare_kernel_conf:
  84. @+$(SUBMAKE) -r tools/quilt/install
  85. else
  86. prepare_kernel_conf: ;
  87. endif
  88. kernel_oldconfig: prepare_kernel_conf
  89. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig
  90. kernel_menuconfig: prepare_kernel_conf
  91. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig
  92. kernel_nconfig: prepare_kernel_conf
  93. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig
  94. tmp/.prereq-build: include/prereq-build.mk
  95. mkdir -p tmp
  96. rm -f tmp/.host.mk
  97. @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
  98. echo "Prerequisite check failed. Use FORCE=1 to override."; \
  99. false; \
  100. }
  101. touch $@
  102. printdb: FORCE
  103. @$(_SINGLE)$(NO_TRACE_MAKE) -p $@ V=99 DUMP_TARGET_DB=1 2>&1
  104. download: .config FORCE
  105. @+$(SUBMAKE) tools/download
  106. @+$(SUBMAKE) toolchain/download
  107. @+$(SUBMAKE) package/download
  108. @+$(SUBMAKE) target/download
  109. clean dirclean: .config
  110. @+$(SUBMAKE) -r $@
  111. prereq:: prepare-tmpinfo .config
  112. @+$(MAKE) -r -s tmp/.prereq-build $(PREP_MK)
  113. @+$(NO_TRACE_MAKE) -r -s $@
  114. %::
  115. @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
  116. @( \
  117. cp .config tmp/.config; \
  118. ./scripts/config/conf --defconfig tmp/.config -w tmp/.config Config.in > /dev/null 2>&1; \
  119. if ./scripts/kconfig.pl '>' .config tmp/.config | grep -q CONFIG; then \
  120. printf "$(_R)WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!$(_N)\n" >&2; \
  121. fi \
  122. )
  123. @+$(ULIMIT_FIX) $(SUBMAKE) -r $@
  124. help:
  125. cat README
  126. docs docs/compile: FORCE
  127. @$(_SINGLE)$(SUBMAKE) -C docs compile
  128. docs/clean: FORCE
  129. @$(_SINGLE)$(SUBMAKE) -C docs clean
  130. distclean:
  131. rm -rf tmp build_dir staging_dir dl .config* feeds package/feeds package/openwrt-packages bin
  132. @$(_SINGLE)$(SUBMAKE) -C scripts/config clean
  133. ifeq ($(findstring v,$(DEBUG)),)
  134. .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
  135. endif
  136. .PHONY: help FORCE
  137. .NOTPARALLEL: