toplevel.mk 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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:=Elegant Eleanor
  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 ?= $(CC)
  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):)$(TOPDIR)/staging_dir/host/lib)
  23. export DYLD_LIBRARY_PATH:=$(subst ::,:,$(if $(DYLD_LIBRARY_PATH),$(DYLD_LIBRARY_PATH):)$(TOPDIR)/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. unexport TAR_OPTIONS
  36. ifneq ($(shell $(HOSTCC) 2>&1 | grep clang),)
  37. export HOSTCC_REAL?=$(HOSTCC)
  38. export HOSTCC_WRAPPER:=$(TOPDIR)/scripts/clang-gcc-wrapper
  39. else
  40. export HOSTCC_WRAPPER:=$(HOSTCC)
  41. endif
  42. ifeq ($(FORCE),)
  43. .config scripts/config/conf scripts/config/mconf: staging_dir/host/.prereq-build
  44. endif
  45. SCAN_COOKIE?=$(shell echo $$$$)
  46. export SCAN_COOKIE
  47. SUBMAKE:=umask 022; $(SUBMAKE)
  48. ULIMIT_FIX=_limit=`ulimit -n`; [ "$$_limit" = "unlimited" -o "$$_limit" -ge 1024 ] || ulimit -n 1024;
  49. prepare-mk: FORCE ;
  50. prepare-tmpinfo: FORCE
  51. @+$(MAKE) -r -s staging_dir/host/.prereq-build $(PREP_MK)
  52. mkdir -p tmp/info
  53. $(_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=""
  54. $(_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"
  55. for type in package target; do \
  56. f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
  57. [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
  58. done
  59. [ tmp/.config-feeds.in -nt tmp/.packagefeeds ] || ./scripts/feeds feed_config > tmp/.config-feeds.in
  60. ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
  61. ./scripts/metadata.pl package_feeds tmp/.packageinfo > tmp/.packagefeeds || { rm -f tmp/.packagefeeds; false; }
  62. touch $(TOPDIR)/tmp/.build
  63. .config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo)
  64. @+if [ \! -e .config ] || ! grep CONFIG_HAVE_DOT_CONFIG .config >/dev/null; then \
  65. [ -e $(HOME)/.librecmc/defconfig ] && cp $(HOME)/.librecmc/defconfig .config; \
  66. $(_SINGLE)$(NO_TRACE_MAKE) menuconfig $(PREP_MK); \
  67. fi
  68. scripts/config/mconf:
  69. @$(_SINGLE)$(SUBMAKE) -s -C scripts/config all CC="$(HOSTCC_WRAPPER)"
  70. $(eval $(call rdep,scripts/config,scripts/config/mconf))
  71. scripts/config/conf:
  72. @$(_SINGLE)$(SUBMAKE) -s -C scripts/config conf CC="$(HOSTCC_WRAPPER)"
  73. config: scripts/config/conf prepare-tmpinfo FORCE
  74. $< Config.in
  75. config-clean: FORCE
  76. $(_SINGLE)$(NO_TRACE_MAKE) -C scripts/config clean
  77. defconfig: scripts/config/conf prepare-tmpinfo FORCE
  78. touch .config
  79. @if [ -e $(HOME)/.librecmc/defconfig ]; then cp $(HOME)/.librecmc/defconfig .config; fi
  80. $< --defconfig=.config Config.in
  81. confdefault-y=allyes
  82. confdefault-m=allmod
  83. confdefault-n=allno
  84. confdefault:=$(confdefault-$(CONFDEFAULT))
  85. oldconfig: scripts/config/conf prepare-tmpinfo FORCE
  86. $< --$(if $(confdefault),$(confdefault),old)config Config.in
  87. menuconfig: scripts/config/mconf prepare-tmpinfo FORCE
  88. if [ \! -e .config -a -e $(HOME)/.librecmc/defconfig ]; then \
  89. cp $(HOME)/.librecmc/defconfig .config; \
  90. fi
  91. $< Config.in
  92. prepare_kernel_conf: .config FORCE
  93. ifeq ($(wildcard staging_dir/host/bin/quilt),)
  94. prepare_kernel_conf:
  95. @+$(SUBMAKE) -r tools/quilt/install
  96. else
  97. prepare_kernel_conf: ;
  98. endif
  99. kernel_oldconfig: prepare_kernel_conf
  100. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux oldconfig
  101. kernel_menuconfig: prepare_kernel_conf
  102. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux menuconfig
  103. kernel_nconfig: prepare_kernel_conf
  104. $(_SINGLE)$(NO_TRACE_MAKE) -C target/linux nconfig
  105. staging_dir/host/.prereq-build: include/prereq-build.mk
  106. mkdir -p tmp
  107. rm -f tmp/.host.mk
  108. @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prereq-build.mk prereq 2>/dev/null || { \
  109. echo "Prerequisite check failed. Use FORCE=1 to override."; \
  110. false; \
  111. }
  112. ifneq ($(realpath $(TOPDIR)/include/prepare.mk),)
  113. @$(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f $(TOPDIR)/include/prepare.mk prepare 2>/dev/null || { \
  114. echo "Preparation failed."; \
  115. false; \
  116. }
  117. endif
  118. touch $@
  119. printdb: FORCE
  120. @$(_SINGLE)$(NO_TRACE_MAKE) -p $@ V=99 DUMP_TARGET_DB=1 2>&1
  121. download: .config FORCE
  122. @+$(SUBMAKE) tools/download
  123. @+$(SUBMAKE) toolchain/download
  124. @+$(SUBMAKE) package/download
  125. @+$(SUBMAKE) target/download
  126. clean dirclean: .config
  127. @+$(SUBMAKE) -r $@
  128. prereq:: prepare-tmpinfo .config
  129. @+$(NO_TRACE_MAKE) -r -s $@
  130. WARN_PARALLEL_ERROR = $(if $(BUILD_LOG),,$(and $(filter -j,$(MAKEFLAGS)),$(findstring s,$(LIBRECMC_VERBOSE))))
  131. ifeq ($(SDK),1)
  132. %::
  133. @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
  134. @./scripts/config/conf --defconfig=.config Config.in
  135. @+$(ULIMIT_FIX) $(SUBMAKE) -r $@
  136. else
  137. %::
  138. @+$(PREP_MK) $(NO_TRACE_MAKE) -r -s prereq
  139. @( \
  140. cp .config tmp/.config; \
  141. ./scripts/config/conf --defconfig=tmp/.config -w tmp/.config Config.in > /dev/null 2>&1; \
  142. if ./scripts/kconfig.pl '>' .config tmp/.config | grep -q CONFIG; then \
  143. printf "$(_R)WARNING: your configuration is out of sync. Please run make menuconfig, oldconfig or defconfig!$(_N)\n" >&2; \
  144. fi \
  145. )
  146. @+$(ULIMIT_FIX) $(SUBMAKE) -r $@ $(if $(WARN_PARALLEL_ERROR), || { \
  147. printf "$(_R)Build failed - please re-run with -j1 to see the real error message$(_N)\n" >&2; \
  148. false; \
  149. } )
  150. endif
  151. # update all feeds, re-create index files, install symlinks
  152. package/symlinks:
  153. ./scripts/feeds update -a
  154. ./scripts/feeds install -a
  155. # re-create index files, install symlinks
  156. package/symlinks-install:
  157. ./scripts/feeds update -i
  158. ./scripts/feeds install -a
  159. # remove all symlinks, don't touch ./feeds
  160. package/symlinks-clean:
  161. ./scripts/feeds uninstall -a
  162. help:
  163. cat README
  164. docs docs/compile: FORCE
  165. @$(_SINGLE)$(SUBMAKE) -C docs compile
  166. docs/clean: FORCE
  167. @$(_SINGLE)$(SUBMAKE) -C docs clean
  168. distclean:
  169. rm -rf tmp build_dir staging_dir dl .config* feeds package/feeds package/librecmc-packages bin
  170. @$(_SINGLE)$(SUBMAKE) -C scripts/config clean
  171. ifeq ($(findstring v,$(DEBUG)),)
  172. .SILENT: symlinkclean clean dirclean distclean config-clean download help tmpinfo-clean .config scripts/config/mconf scripts/config/conf menuconfig staging_dir/host/.prereq-build tmp/.prereq-package prepare-tmpinfo
  173. endif
  174. .PHONY: help FORCE
  175. .NOTPARALLEL: