toplevel.mk 5.9 KB

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