Makefile 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072
  1. # Makefile for buildroot
  2. #
  3. # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
  4. # Copyright (C) 2006-2014 by the Buildroot developers <buildroot@uclibc.org>
  5. # Copyright (C) 2014-2016 by the Buildroot developers <buildroot@buildroot.org>
  6. #
  7. # This program is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program; if not, write to the Free Software
  19. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. #
  21. #--------------------------------------------------------------
  22. # Just run 'make menuconfig', configure stuff, then run 'make'.
  23. # You shouldn't need to mess with anything beyond this point...
  24. #--------------------------------------------------------------
  25. # Delete default rules. We don't use them. This saves a bit of time.
  26. .SUFFIXES:
  27. # we want bash as shell
  28. SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  29. else if [ -x /bin/bash ]; then echo /bin/bash; \
  30. else echo sh; fi; fi)
  31. # Set O variable if not already done on the command line;
  32. # or avoid confusing packages that can use the O=<dir> syntax for out-of-tree
  33. # build by preventing it from being forwarded to sub-make calls.
  34. ifneq ("$(origin O)", "command line")
  35. O := $(CURDIR)/output
  36. endif
  37. # Check if the current Buildroot execution meets all the pre-requisites.
  38. # If they are not met, Buildroot will actually do its job in a sub-make meeting
  39. # its pre-requisites, which are:
  40. # 1- Permissive enough umask:
  41. # Wrong or too restrictive umask will prevent Buildroot and packages from
  42. # creating files and directories.
  43. # 2- Absolute canonical CWD (i.e. $(CURDIR)):
  44. # Otherwise, some packages will use CWD as-is, others will compute its
  45. # absolute canonical path. This makes harder tracking and fixing host
  46. # machine path leaks.
  47. # 3- Absolute canonical output location (i.e. $(O)):
  48. # For the same reason as the one for CWD.
  49. # Remove the trailing '/.' from $(O) as it can be added by the makefile wrapper
  50. # installed in the $(O) directory.
  51. # Also remove the trailing '/' the user can set when on the command line.
  52. override O := $(patsubst %/,%,$(patsubst %.,%,$(O)))
  53. # Make sure $(O) actually exists before calling realpath on it; this is to
  54. # avoid empty CANONICAL_O in case on non-existing entry.
  55. CANONICAL_O := $(shell mkdir -p $(O) >/dev/null 2>&1)$(realpath $(O))
  56. CANONICAL_CURDIR = $(realpath $(CURDIR))
  57. REQ_UMASK = 0022
  58. # Make sure O= is passed (with its absolute canonical path) everywhere the
  59. # toplevel makefile is called back.
  60. EXTRAMAKEARGS := O=$(CANONICAL_O)
  61. # Check Buildroot execution pre-requisites here.
  62. ifneq ($(shell umask):$(CURDIR):$(O),$(REQ_UMASK):$(CANONICAL_CURDIR):$(CANONICAL_O))
  63. .PHONY: _all $(MAKECMDGOALS)
  64. $(MAKECMDGOALS): _all
  65. @:
  66. _all:
  67. @umask $(REQ_UMASK) && \
  68. $(MAKE) -C $(CANONICAL_CURDIR) --no-print-directory \
  69. $(MAKECMDGOALS) $(EXTRAMAKEARGS)
  70. else # umask / $(CURDIR) / $(O)
  71. # This is our default rule, so must come first
  72. all:
  73. # Set and export the version string
  74. export BR2_VERSION := 2017.02-git
  75. # Actual time the release is cut (for reproducible builds)
  76. BR2_VERSION_EPOCH = 1478206447
  77. # Save running make version since it's clobbered by the make package
  78. RUNNING_MAKE_VERSION := $(MAKE_VERSION)
  79. # Check for minimal make version (note: this check will break at make 10.x)
  80. MIN_MAKE_VERSION = 3.81
  81. ifneq ($(firstword $(sort $(RUNNING_MAKE_VERSION) $(MIN_MAKE_VERSION))),$(MIN_MAKE_VERSION))
  82. $(error You have make '$(RUNNING_MAKE_VERSION)' installed. GNU make >= $(MIN_MAKE_VERSION) is required)
  83. endif
  84. # Parallel execution of this Makefile is disabled because it changes
  85. # the packages building order, that can be a problem for two reasons:
  86. # - If a package has an unspecified optional dependency and that
  87. # dependency is present when the package is built, it is used,
  88. # otherwise it isn't (but compilation happily proceeds) so the end
  89. # result will differ if the order is swapped due to parallel
  90. # building.
  91. # - Also changing the building order can be a problem if two packages
  92. # manipulate the same file in the target directory.
  93. #
  94. # Taking into account the above considerations, if you still want to execute
  95. # this top-level Makefile in parallel comment the ".NOTPARALLEL" line and
  96. # use the -j<jobs> option when building, e.g:
  97. # make -j$((`getconf _NPROCESSORS_ONLN`+1))
  98. .NOTPARALLEL:
  99. # absolute path
  100. TOPDIR := $(CURDIR)
  101. CONFIG_CONFIG_IN = Config.in
  102. CONFIG = support/kconfig
  103. DATE := $(shell date +%Y%m%d)
  104. # Compute the full local version string so packages can use it as-is
  105. # Need to export it, so it can be got from environment in children (eg. mconf)
  106. export BR2_VERSION_FULL := $(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)
  107. noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconfig \
  108. defconfig %_defconfig allyesconfig allnoconfig silentoldconfig release \
  109. randpackageconfig allyespackageconfig allnopackageconfig \
  110. print-version olddefconfig distclean manual manual-html manual-split-html \
  111. manual-pdf manual-text manual-epub
  112. # Some global targets do not trigger a build, but are used to collect
  113. # metadata, or do various checks. When such targets are triggered,
  114. # some packages should not do their configuration sanity
  115. # checks. Provide them a BR_BUILDING variable set to 'y' when we're
  116. # actually building and they should do their sanity checks.
  117. #
  118. # We're building in two situations: when MAKECMDGOALS is empty
  119. # (default target is to build), or when MAKECMDGOALS contains
  120. # something else than one of the nobuild_targets.
  121. nobuild_targets := source %-source source-check \
  122. legal-info %-legal-info external-deps _external-deps \
  123. clean distclean help show-targets graph-depends \
  124. %-graph-depends %-show-depends %-show-version \
  125. graph-build graph-size list-defconfigs \
  126. savedefconfig printvars
  127. ifeq ($(MAKECMDGOALS),)
  128. BR_BUILDING = y
  129. else ifneq ($(filter-out $(nobuild_targets),$(MAKECMDGOALS)),)
  130. BR_BUILDING = y
  131. endif
  132. # We call make recursively to build packages. The command-line overrides that
  133. # are passed to Buildroot don't apply to those package build systems. In
  134. # particular, we don't want to pass down the O=<dir> option for out-of-tree
  135. # builds, because the value specified on the command line will not be correct
  136. # for packages.
  137. MAKEOVERRIDES :=
  138. # Include some helper macros and variables
  139. include support/misc/utils.mk
  140. # Set variables related to in-tree or out-of-tree build.
  141. # Here, both $(O) and $(CURDIR) are absolute canonical paths.
  142. ifeq ($(O),$(CURDIR)/output)
  143. CONFIG_DIR := $(CURDIR)
  144. NEED_WRAPPER =
  145. else
  146. CONFIG_DIR := $(O)
  147. NEED_WRAPPER = y
  148. endif
  149. # bash prints the name of the directory on 'cd <dir>' if CDPATH is
  150. # set, so unset it here to not cause problems. Notice that the export
  151. # line doesn't affect the environment of $(shell ..) calls.
  152. export CDPATH :=
  153. BASE_DIR := $(CANONICAL_O)
  154. $(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
  155. # Handling of BR2_EXTERNAL.
  156. #
  157. # The value of BR2_EXTERNAL is stored in .br-external in the output directory.
  158. # The location of the external.mk makefile fragments is computed in that file.
  159. # On subsequent invocations of make, this file is read in. BR2_EXTERNAL can
  160. # still be overridden on the command line, therefore the file is re-created
  161. # every time make is run.
  162. BR2_EXTERNAL_FILE = $(BASE_DIR)/.br-external.mk
  163. -include $(BR2_EXTERNAL_FILE)
  164. $(shell support/scripts/br2-external \
  165. -m -o '$(BR2_EXTERNAL_FILE)' $(BR2_EXTERNAL))
  166. BR2_EXTERNAL_ERROR =
  167. include $(BR2_EXTERNAL_FILE)
  168. ifneq ($(BR2_EXTERNAL_ERROR),)
  169. $(error $(BR2_EXTERNAL_ERROR))
  170. endif
  171. # To make sure that the environment variable overrides the .config option,
  172. # set this before including .config.
  173. ifneq ($(BR2_DL_DIR),)
  174. DL_DIR := $(BR2_DL_DIR)
  175. endif
  176. ifneq ($(BR2_CCACHE_DIR),)
  177. BR_CACHE_DIR := $(BR2_CCACHE_DIR)
  178. endif
  179. # Need that early, before we scan packages
  180. # Avoids doing the $(or...) everytime
  181. BR_GRAPH_OUT := $(or $(BR2_GRAPH_OUT),pdf)
  182. BUILD_DIR := $(BASE_DIR)/build
  183. BINARIES_DIR := $(BASE_DIR)/images
  184. TARGET_DIR := $(BASE_DIR)/target
  185. # initial definition so that 'make clean' works for most users, even without
  186. # .config. HOST_DIR will be overwritten later when .config is included.
  187. HOST_DIR := $(BASE_DIR)/host
  188. GRAPHS_DIR := $(BASE_DIR)/graphs
  189. LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
  190. REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
  191. REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
  192. LICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses
  193. LICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses
  194. LEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv
  195. LEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv
  196. LEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings
  197. LEGAL_REPORT = $(LEGAL_INFO_DIR)/README
  198. ################################################################################
  199. #
  200. # staging and target directories do NOT list these as
  201. # dependencies anywhere else
  202. #
  203. ################################################################################
  204. $(BUILD_DIR) $(TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
  205. @mkdir -p $@
  206. BR2_CONFIG = $(CONFIG_DIR)/.config
  207. # Pull in the user's configuration file
  208. ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
  209. -include $(BR2_CONFIG)
  210. endif
  211. # timezone and locale may affect build output
  212. ifeq ($(BR2_REPRODUCIBLE),y)
  213. export TZ = UTC
  214. export LANG = C
  215. export LC_ALL = C
  216. export GZIP = -n
  217. BR2_VERSION_GIT_EPOCH = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1 --format=%at)
  218. export SOURCE_DATE_EPOCH = $(if $(wildcard $(TOPDIR)/.git),$(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
  219. endif
  220. # To put more focus on warnings, be less verbose as default
  221. # Use 'make V=1' to see the full commands
  222. ifeq ("$(origin V)", "command line")
  223. KBUILD_VERBOSE = $(V)
  224. endif
  225. ifndef KBUILD_VERBOSE
  226. KBUILD_VERBOSE = 0
  227. endif
  228. ifeq ($(KBUILD_VERBOSE),1)
  229. Q =
  230. ifndef VERBOSE
  231. VERBOSE = 1
  232. endif
  233. export VERBOSE
  234. else
  235. Q = @
  236. endif
  237. # kconfig uses CONFIG_SHELL
  238. CONFIG_SHELL := $(SHELL)
  239. export SHELL CONFIG_SHELL Q KBUILD_VERBOSE
  240. ifndef HOSTAR
  241. HOSTAR := ar
  242. endif
  243. ifndef HOSTAS
  244. HOSTAS := as
  245. endif
  246. ifndef HOSTCC
  247. HOSTCC := gcc
  248. HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
  249. endif
  250. HOSTCC_NOCCACHE := $(HOSTCC)
  251. ifndef HOSTCXX
  252. HOSTCXX := g++
  253. HOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
  254. endif
  255. HOSTCXX_NOCCACHE := $(HOSTCXX)
  256. ifndef HOSTCPP
  257. HOSTCPP := cpp
  258. endif
  259. ifndef HOSTLD
  260. HOSTLD := ld
  261. endif
  262. ifndef HOSTLN
  263. HOSTLN := ln
  264. endif
  265. ifndef HOSTNM
  266. HOSTNM := nm
  267. endif
  268. ifndef HOSTOBJCOPY
  269. HOSTOBJCOPY := objcopy
  270. endif
  271. ifndef HOSTRANLIB
  272. HOSTRANLIB := ranlib
  273. endif
  274. HOSTAR := $(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
  275. HOSTAS := $(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
  276. HOSTCPP := $(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
  277. HOSTLD := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
  278. HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
  279. HOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
  280. HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
  281. HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
  282. SED := $(shell which sed || type -p sed) -i -e
  283. export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
  284. export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
  285. # Determine the userland we are running on.
  286. #
  287. # Note that, despite its name, we are not interested in the actual
  288. # architecture name. This is mostly used to determine whether some
  289. # of the binary tools (e.g. pre-built external toolchains) can run
  290. # on the current host. So we need to know if the userland we're
  291. # running on can actually run those toolchains.
  292. #
  293. # For example, a 64-bit prebuilt toolchain will not run on a 64-bit
  294. # kernel if the userland is 32-bit (e.g. in a chroot for example).
  295. #
  296. # So, we extract the first part of the tuple the host gcc was
  297. # configured to generate code for; we assume this is our userland.
  298. #
  299. export HOSTARCH := $(shell LC_ALL=C $(HOSTCC_NOCCACHE) -v 2>&1 | \
  300. sed -e '/^Target: \([^-]*\).*/!d' \
  301. -e 's//\1/' \
  302. -e 's/i.86/x86/' \
  303. -e 's/sun4u/sparc64/' \
  304. -e 's/arm.*/arm/' \
  305. -e 's/sa110/arm/' \
  306. -e 's/ppc64/powerpc64/' \
  307. -e 's/ppc/powerpc/' \
  308. -e 's/macppc/powerpc/' \
  309. -e 's/sh.*/sh/' )
  310. HOSTCC_VERSION := $(shell $(HOSTCC_NOCCACHE) --version | \
  311. sed -n -r 's/^.* ([0-9]*)\.([0-9]*)\.([0-9]*)[ ]*.*/\1 \2/p')
  312. # For gcc >= 5.x, we only need the major version.
  313. ifneq ($(firstword $(HOSTCC_VERSION)),4)
  314. HOSTCC_VERSION := $(firstword $(HOSTCC_VERSION))
  315. endif
  316. # Make sure pkg-config doesn't look outside the buildroot tree
  317. HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
  318. unexport PKG_CONFIG_PATH
  319. unexport PKG_CONFIG_SYSROOT_DIR
  320. unexport PKG_CONFIG_LIBDIR
  321. # Having DESTDIR set in the environment confuses the installation
  322. # steps of some packages.
  323. unexport DESTDIR
  324. # Causes breakage with packages that needs host-ruby
  325. unexport RUBYOPT
  326. include package/pkg-utils.mk
  327. include package/doc-asciidoc.mk
  328. ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  329. ################################################################################
  330. #
  331. # Hide troublesome environment variables from sub processes
  332. #
  333. ################################################################################
  334. unexport CROSS_COMPILE
  335. unexport ARCH
  336. unexport CC
  337. unexport LD
  338. unexport AR
  339. unexport CXX
  340. unexport CPP
  341. unexport RANLIB
  342. unexport CFLAGS
  343. unexport CXXFLAGS
  344. unexport GREP_OPTIONS
  345. unexport TAR_OPTIONS
  346. unexport CONFIG_SITE
  347. unexport QMAKESPEC
  348. unexport TERMINFO
  349. unexport MACHINE
  350. unexport O
  351. GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
  352. PACKAGES :=
  353. PACKAGES_ALL :=
  354. # silent mode requested?
  355. QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
  356. # Strip off the annoying quoting
  357. ARCH := $(call qstrip,$(BR2_ARCH))
  358. KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
  359. -e s/i.86/i386/ -e s/sun4u/sparc64/ \
  360. -e s/arcle/arc/ \
  361. -e s/arceb/arc/ \
  362. -e s/arm.*/arm/ -e s/sa110/arm/ \
  363. -e s/aarch64.*/arm64/ \
  364. -e s/bfin/blackfin/ \
  365. -e s/parisc64/parisc/ \
  366. -e s/powerpc64.*/powerpc/ \
  367. -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
  368. -e s/sh.*/sh/ \
  369. -e s/microblazeel/microblaze/)
  370. ZCAT := $(call qstrip,$(BR2_ZCAT))
  371. BZCAT := $(call qstrip,$(BR2_BZCAT))
  372. XZCAT := $(call qstrip,$(BR2_XZCAT))
  373. TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
  374. # packages compiled for the host go here
  375. HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
  376. # Quotes are needed for spaces and all in the original PATH content.
  377. BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin:$(PATH)"
  378. # Location of a file giving a big fat warning that output/target
  379. # should not be used as the root filesystem.
  380. TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
  381. ifeq ($(BR2_CCACHE),y)
  382. CCACHE := $(HOST_DIR)/usr/bin/ccache
  383. BR_CACHE_DIR ?= $(call qstrip,$(BR2_CCACHE_DIR))
  384. export BR_CACHE_DIR
  385. HOSTCC := $(CCACHE) $(HOSTCC)
  386. HOSTCXX := $(CCACHE) $(HOSTCXX)
  387. else
  388. export BR_NO_CCACHE
  389. endif
  390. # Scripts in support/ or post-build scripts may need to reference
  391. # these locations, so export them so it is easier to use
  392. export BR2_CONFIG
  393. export BR2_REPRODUCIBLE
  394. export TARGET_DIR
  395. export STAGING_DIR
  396. export HOST_DIR
  397. export BINARIES_DIR
  398. export BASE_DIR
  399. ################################################################################
  400. #
  401. # You should probably leave this stuff alone unless you know
  402. # what you are doing.
  403. #
  404. ################################################################################
  405. all: world
  406. # Include legacy before the other things, because package .mk files
  407. # may rely on it.
  408. include Makefile.legacy
  409. include package/Makefile.in
  410. include support/dependencies/dependencies.mk
  411. include toolchain/*.mk
  412. include toolchain/*/*.mk
  413. # Include the package override file if one has been provided in the
  414. # configuration.
  415. PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
  416. ifneq ($(PACKAGE_OVERRIDE_FILE),)
  417. -include $(PACKAGE_OVERRIDE_FILE)
  418. endif
  419. include $(sort $(wildcard package/*/*.mk))
  420. include boot/common.mk
  421. include linux/linux.mk
  422. include fs/common.mk
  423. # If using a br2-external tree, the BR2_EXTERNAL_$(NAME)_PATH variables
  424. # are also present in the .config file. Since .config is included after
  425. # we defined them in the Makefile, the values for those variables are
  426. # quoted. We just include the generated Makefile fragment .br2-external.mk
  427. # a third time, which will set those variables to the un-quoted values.
  428. include $(BR2_EXTERNAL_FILE)
  429. # Nothing to include if no BR2_EXTERNAL tree in use
  430. include $(BR2_EXTERNAL_MKS)
  431. # Now we are sure we have all the packages scanned and defined. We now
  432. # check for each package in the list of enabled packages, that all its
  433. # dependencies are indeed enabled.
  434. #
  435. # Only trigger the check for default builds. If the user forces building
  436. # a package, even if not enabled in the configuration, we want to accept
  437. # it.
  438. #
  439. ifeq ($(MAKECMDGOALS),)
  440. define CHECK_ONE_DEPENDENCY
  441. ifeq ($$($(2)_TYPE),target)
  442. ifeq ($$($(2)_IS_VIRTUAL),)
  443. ifneq ($$($$($(2)_KCONFIG_VAR)),y)
  444. $$(error $$($(2)_NAME) is in the dependency chain of $$($(1)_NAME) that \
  445. has added it to its _DEPENDENCIES variable without selecting it or \
  446. depending on it from Config.in)
  447. endif
  448. endif
  449. endif
  450. endef
  451. $(foreach pkg,$(call UPPERCASE,$(PACKAGES)),\
  452. $(foreach dep,$(call UPPERCASE,$($(pkg)_FINAL_ALL_DEPENDENCIES)),\
  453. $(eval $(call CHECK_ONE_DEPENDENCY,$(pkg),$(dep))$(sep))))
  454. endif
  455. dirs: $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
  456. $(HOST_DIR) $(BINARIES_DIR)
  457. $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
  458. $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
  459. prepare: $(BUILD_DIR)/buildroot-config/auto.conf
  460. world: target-post-image
  461. .PHONY: all world toolchain dirs clean distclean source outputmakefile \
  462. legal-info legal-info-prepare legal-info-clean printvars help \
  463. list-defconfigs target-finalize target-post-image source-check
  464. # Populating the staging with the base directories is handled by the skeleton package
  465. $(STAGING_DIR):
  466. @mkdir -p $(STAGING_DIR)
  467. @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
  468. RSYNC_VCS_EXCLUSIONS = \
  469. --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
  470. --exclude CVS
  471. STRIP_FIND_CMD = find $(TARGET_DIR)
  472. ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
  473. STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
  474. endif
  475. STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
  476. # file exclusions:
  477. # - libpthread.so: a non-stripped libpthread shared library is needed for
  478. # proper debugging of pthread programs using gdb.
  479. # - ld.so: a non-stripped dynamic linker library is needed for valgrind
  480. # - kernel modules (*.ko): do not function properly when stripped like normal
  481. # applications and libraries. Normally kernel modules are already excluded
  482. # by the executable permission check above, so the explicit exclusion is only
  483. # done for kernel modules with incorrect permissions.
  484. STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print0
  485. ifeq ($(BR2_ECLIPSE_REGISTER),y)
  486. define TOOLCHAIN_ECLIPSE_REGISTER
  487. ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \
  488. $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
  489. endef
  490. TARGET_FINALIZE_HOOKS += TOOLCHAIN_ECLIPSE_REGISTER
  491. endif
  492. # Generate locale data. Basically, we call the localedef program
  493. # (built by the host-localedef package) for each locale. The input
  494. # data comes preferably from the toolchain, or if the toolchain does
  495. # not have them (Linaro toolchains), we use the ones available on the
  496. # host machine.
  497. ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
  498. GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
  499. ifneq ($(GLIBC_GENERATE_LOCALES),)
  500. PACKAGES += host-localedef
  501. define GENERATE_GLIBC_LOCALES
  502. $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
  503. $(Q)for locale in $(GLIBC_GENERATE_LOCALES) ; do \
  504. inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
  505. charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
  506. if test -z "$${charmap}" ; then \
  507. charmap="UTF-8" ; \
  508. fi ; \
  509. echo "Generating locale $${inputfile}.$${charmap}" ; \
  510. I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
  511. $(HOST_DIR)/usr/bin/localedef \
  512. --prefix=$(TARGET_DIR) \
  513. --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
  514. -i $${inputfile} -f $${charmap} \
  515. $${locale} ; \
  516. done
  517. endef
  518. TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
  519. endif
  520. endif
  521. ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
  522. LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
  523. LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
  524. # This piece of junk does the following:
  525. # First collect the whitelist in a file.
  526. # Then go over all the locale dirs and for each subdir, check if it exists
  527. # in the whitelist file. If it doesn't, kill it.
  528. # Finally, specifically for X11, regenerate locale.dir from the whitelist.
  529. define PURGE_LOCALES
  530. rm -f $(LOCALE_WHITELIST)
  531. for i in $(LOCALE_NOPURGE) locale-archive; do echo $$i >> $(LOCALE_WHITELIST); done
  532. for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/lib/locale)); \
  533. do \
  534. for langdir in $$dir/*; \
  535. do \
  536. if [ -e "$${langdir}" ]; \
  537. then \
  538. grep -qx "$${langdir##*/}" $(LOCALE_WHITELIST) || rm -rf $$langdir; \
  539. fi \
  540. done; \
  541. done
  542. if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \
  543. then \
  544. for lang in $(LOCALE_NOPURGE); \
  545. do \
  546. if [ -f $(TARGET_DIR)/usr/share/X11/locale/$$lang/XLC_LOCALE ]; \
  547. then \
  548. echo "$$lang/XLC_LOCALE: $$lang"; \
  549. fi \
  550. done > $(TARGET_DIR)/usr/share/X11/locale/locale.dir; \
  551. fi
  552. endef
  553. TARGET_FINALIZE_HOOKS += PURGE_LOCALES
  554. endif
  555. $(TARGETS_ROOTFS): target-finalize
  556. target-finalize: $(PACKAGES)
  557. @$(call MESSAGE,"Finalizing target directory")
  558. $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
  559. rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
  560. $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
  561. $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
  562. find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
  563. find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \
  564. \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
  565. ifneq ($(BR2_PACKAGE_GDB),y)
  566. rm -rf $(TARGET_DIR)/usr/share/gdb
  567. endif
  568. ifneq ($(BR2_PACKAGE_BASH),y)
  569. rm -rf $(TARGET_DIR)/usr/share/bash-completion
  570. endif
  571. ifneq ($(BR2_PACKAGE_ZSH),y)
  572. rm -rf $(TARGET_DIR)/usr/share/zsh
  573. endif
  574. rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
  575. rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
  576. rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
  577. rm -rf $(TARGET_DIR)/usr/share/gtk-doc
  578. rmdir $(TARGET_DIR)/usr/share 2>/dev/null || true
  579. $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
  580. # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
  581. # besides the one in which crash occurred; or SIGTRAP kills my program when
  582. # I set a breakpoint"
  583. ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
  584. find $(TARGET_DIR)/lib/ -type f -name 'libpthread*.so*' | \
  585. xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
  586. endif
  587. # Valgrind needs ld.so with enough information, so only strip
  588. # debugging symbols.
  589. find $(TARGET_DIR)/lib/ -type f -name 'ld-*.so*' | \
  590. xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
  591. test -f $(TARGET_DIR)/etc/ld.so.conf && \
  592. { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
  593. test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
  594. { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
  595. mkdir -p $(TARGET_DIR)/etc
  596. ( \
  597. echo "NAME=Buildroot"; \
  598. echo "VERSION=$(BR2_VERSION_FULL)"; \
  599. echo "ID=buildroot"; \
  600. echo "VERSION_ID=$(BR2_VERSION)"; \
  601. echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
  602. ) > $(TARGET_DIR)/etc/os-release
  603. @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
  604. $(call MESSAGE,"Copying overlay $(d)"); \
  605. rsync -a --ignore-times --keep-dirlinks $(RSYNC_VCS_EXCLUSIONS) \
  606. --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
  607. $(d)/ $(TARGET_DIR)$(sep))
  608. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
  609. $(call MESSAGE,"Executing post-build script $(s)"); \
  610. $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
  611. target-post-image: $(TARGETS_ROOTFS) target-finalize
  612. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
  613. $(call MESSAGE,"Executing post-image script $(s)"); \
  614. $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
  615. source: $(foreach p,$(PACKAGES),$(p)-all-source)
  616. _external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
  617. external-deps:
  618. @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
  619. # check if download URLs are outdated
  620. source-check: $(foreach p,$(PACKAGES),$(p)-all-source-check)
  621. legal-info-clean:
  622. @rm -fr $(LEGAL_INFO_DIR)
  623. legal-info-prepare: $(LEGAL_INFO_DIR)
  624. @$(call MESSAGE,"Collecting legal info")
  625. @$(call legal-license-file,buildroot,COPYING,COPYING,HOST)
  626. @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
  627. @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
  628. @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPLv2+,COPYING,not saved,not saved,HOST)
  629. @$(call legal-warning,the Buildroot source code has not been saved)
  630. @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
  631. legal-info: dirs legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
  632. $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
  633. @cat support/legal-info/README.header >>$(LEGAL_REPORT)
  634. @if [ -r $(LEGAL_WARNINGS) ]; then \
  635. cat support/legal-info/README.warnings-header \
  636. $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
  637. cat $(LEGAL_WARNINGS); fi
  638. @rm -f $(LEGAL_WARNINGS)
  639. @(cd $(LEGAL_INFO_DIR); \
  640. find * -type f -exec sha256sum {} + | LC_ALL=C sort -k2 \
  641. >.legal-info.sha256; \
  642. mv .legal-info.sha256 legal-info.sha256)
  643. @echo "Legal info produced in $(LEGAL_INFO_DIR)"
  644. show-targets:
  645. @echo $(PACKAGES) $(TARGETS_ROOTFS)
  646. graph-build: $(O)/build/build-time.log
  647. @install -d $(GRAPHS_DIR)
  648. $(foreach o,name build duration,./support/scripts/graph-build-time \
  649. --type=histogram --order=$(o) --input=$(<) \
  650. --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
  651. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  652. $(foreach t,packages steps,./support/scripts/graph-build-time \
  653. --type=pie-$(t) --input=$(<) \
  654. --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
  655. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  656. graph-depends-requirements:
  657. @dot -? >/dev/null 2>&1 || \
  658. { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
  659. graph-depends: graph-depends-requirements
  660. @$(INSTALL) -d $(GRAPHS_DIR)
  661. @cd "$(CONFIG_DIR)"; \
  662. $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
  663. --direct -o $(GRAPHS_DIR)/$(@).dot
  664. dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \
  665. -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \
  666. $(GRAPHS_DIR)/$(@).dot
  667. graph-size:
  668. $(Q)mkdir -p $(GRAPHS_DIR)
  669. $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
  670. --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
  671. --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
  672. --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv
  673. check-dependencies:
  674. @cd "$(CONFIG_DIR)"; \
  675. $(TOPDIR)/support/scripts/graph-depends -C
  676. else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  677. all: menuconfig
  678. endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  679. # configuration
  680. # ---------------------------------------------------------------------------
  681. HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
  682. export HOSTCFLAGS
  683. .PHONY: prepare-kconfig
  684. prepare-kconfig: outputmakefile $(BUILD_DIR)/.br2-external.in
  685. $(BUILD_DIR)/buildroot-config/%onf:
  686. mkdir -p $(@D)/lxdialog
  687. PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
  688. obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
  689. DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
  690. # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
  691. # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
  692. COMMON_CONFIG_ENV = \
  693. BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
  694. KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
  695. KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
  696. KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
  697. BR2_CONFIG=$(BR2_CONFIG) \
  698. HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
  699. BUILD_DIR=$(BUILD_DIR) \
  700. SKIP_LEGACY=
  701. xconfig: $(BUILD_DIR)/buildroot-config/qconf prepare-kconfig
  702. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  703. gconfig: $(BUILD_DIR)/buildroot-config/gconf prepare-kconfig
  704. @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
  705. menuconfig: $(BUILD_DIR)/buildroot-config/mconf prepare-kconfig
  706. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  707. nconfig: $(BUILD_DIR)/buildroot-config/nconf prepare-kconfig
  708. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  709. config: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  710. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  711. # For the config targets that automatically select options, we pass
  712. # SKIP_LEGACY=y to disable the legacy options. However, in that case
  713. # no values are set for the legacy options so a subsequent oldconfig
  714. # will query them. Therefore, run an additional olddefconfig.
  715. oldconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  716. @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
  717. randconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  718. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --randconfig $(CONFIG_CONFIG_IN)
  719. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  720. allyesconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  721. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allyesconfig $(CONFIG_CONFIG_IN)
  722. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  723. allnoconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  724. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allnoconfig $(CONFIG_CONFIG_IN)
  725. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  726. randpackageconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  727. @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
  728. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
  729. KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
  730. $< --randconfig $(CONFIG_CONFIG_IN)
  731. @rm -f $(CONFIG_DIR)/.config.nopkg
  732. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  733. allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  734. @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
  735. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
  736. KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
  737. $< --allyesconfig $(CONFIG_CONFIG_IN)
  738. @rm -f $(CONFIG_DIR)/.config.nopkg
  739. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  740. allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  741. @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
  742. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
  743. KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
  744. $< --allnoconfig $(CONFIG_CONFIG_IN)
  745. @rm -f $(CONFIG_DIR)/.config.nopkg
  746. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  747. silentoldconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  748. $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)
  749. olddefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  750. $(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN)
  751. defconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  752. @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
  753. define percent_defconfig
  754. # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
  755. %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig prepare-kconfig
  756. @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \
  757. $$< --defconfig=$(1)/configs/$$@ $$(CONFIG_CONFIG_IN)
  758. endef
  759. $(eval $(foreach d,$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(call percent_defconfig,$(d))$(sep)))
  760. savedefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  761. @$(COMMON_CONFIG_ENV) $< \
  762. --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
  763. $(CONFIG_CONFIG_IN)
  764. @$(SED) '/BR2_DEFCONFIG=/d' $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig)
  765. .PHONY: defconfig savedefconfig
  766. ################################################################################
  767. #
  768. # Cleanup and misc junk
  769. #
  770. ################################################################################
  771. # outputmakefile generates a Makefile in the output directory, if using a
  772. # separate output directory. This allows convenient use of make in the
  773. # output directory.
  774. outputmakefile:
  775. ifeq ($(NEED_WRAPPER),y)
  776. $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
  777. endif
  778. # Even though the target is a real file, we mark it as PHONY as we
  779. # want it to be re-generated each time make is invoked, in case the
  780. # value of BR2_EXTERNAL is changed.
  781. .PHONY: $(BUILD_DIR)/.br2-external.in
  782. $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
  783. $(Q)support/scripts/br2-external -k -o "$(@)" $(BR2_EXTERNAL)
  784. # printvars prints all the variables currently defined in our
  785. # Makefiles. Alternatively, if a non-empty VARS variable is passed,
  786. # only the variables matching the make pattern passed in VARS are
  787. # displayed.
  788. printvars:
  789. @$(foreach V, \
  790. $(sort $(if $(VARS),$(filter $(VARS),$(.VARIABLES)),$(.VARIABLES))), \
  791. $(if $(filter-out environment% default automatic, \
  792. $(origin $V)), \
  793. $(info $V=$($V) ($(value $V)))))
  794. clean:
  795. rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
  796. $(BUILD_DIR) $(BASE_DIR)/staging \
  797. $(LEGAL_INFO_DIR) $(GRAPHS_DIR)
  798. distclean: clean
  799. ifeq ($(O),$(CURDIR)/output)
  800. rm -rf $(O)
  801. endif
  802. rm -rf $(TOPDIR)/dl $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
  803. $(CONFIG_DIR)/.auto.deps $(BR2_EXTERNAL_FILE)
  804. help:
  805. @echo 'Cleaning:'
  806. @echo ' clean - delete all files created by build'
  807. @echo ' distclean - delete all non-source files (including .config)'
  808. @echo
  809. @echo 'Build:'
  810. @echo ' all - make world'
  811. @echo ' toolchain - build toolchain'
  812. @echo
  813. @echo 'Configuration:'
  814. @echo ' menuconfig - interactive curses-based configurator'
  815. @echo ' nconfig - interactive ncurses-based configurator'
  816. @echo ' xconfig - interactive Qt-based configurator'
  817. @echo ' gconfig - interactive GTK-based configurator'
  818. @echo ' oldconfig - resolve any unresolved symbols in .config'
  819. @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
  820. @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
  821. @echo ' randconfig - New config with random answer to all options'
  822. @echo ' defconfig - New config with default answer to all options'
  823. @echo ' BR2_DEFCONFIG, if set, is used as input'
  824. @echo ' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
  825. @echo ' allyesconfig - New config where all options are accepted with yes'
  826. @echo ' allnoconfig - New config where all options are answered with no'
  827. @echo ' randpackageconfig - New config with random answer to package options'
  828. @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
  829. @echo ' allnopackageconfig - New config where package options are answered with no'
  830. @echo
  831. @echo 'Package-specific:'
  832. @echo ' <pkg> - Build and install <pkg> and all its dependencies'
  833. @echo ' <pkg>-source - Only download the source files for <pkg>'
  834. @echo ' <pkg>-extract - Extract <pkg> sources'
  835. @echo ' <pkg>-patch - Apply patches to <pkg>'
  836. @echo ' <pkg>-depends - Build <pkg>'\''s dependencies'
  837. @echo ' <pkg>-configure - Build <pkg> up to the configure step'
  838. @echo ' <pkg>-build - Build <pkg> up to the build step'
  839. @echo ' <pkg>-show-depends - List packages on which <pkg> depends'
  840. @echo ' <pkg>-show-rdepends - List packages which have <pkg> as a dependency'
  841. @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
  842. @echo ' <pkg>-graph-rdepends - Generate a graph of <pkg>'\''s reverse dependencies'
  843. @echo ' <pkg>-dirclean - Remove <pkg> build directory'
  844. @echo ' <pkg>-reconfigure - Restart the build from the configure step'
  845. @echo ' <pkg>-rebuild - Restart the build from the build step'
  846. $(foreach p,$(HELP_PACKAGES), \
  847. @echo $(sep) \
  848. @echo '$($(p)_NAME):' $(sep) \
  849. $($(p)_HELP_CMDS)$(sep))
  850. @echo
  851. @echo 'Documentation:'
  852. @echo ' manual - build manual in all formats'
  853. @echo ' manual-html - build manual in HTML'
  854. @echo ' manual-split-html - build manual in split HTML'
  855. @echo ' manual-pdf - build manual in PDF'
  856. @echo ' manual-text - build manual in text'
  857. @echo ' manual-epub - build manual in ePub'
  858. @echo ' graph-build - generate graphs of the build times'
  859. @echo ' graph-depends - generate graph of the dependency tree'
  860. @echo ' graph-size - generate stats of the filesystem size'
  861. @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
  862. @echo
  863. @echo 'Miscellaneous:'
  864. @echo ' source - download all sources needed for offline-build'
  865. @echo ' source-check - check selected packages for valid download URLs'
  866. @echo ' external-deps - list external packages used'
  867. @echo ' legal-info - generate info about license compliance'
  868. @echo
  869. @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
  870. @echo ' make O=dir - Locate all output files in "dir", including .config'
  871. @echo
  872. @echo 'For further details, see README, generate the Buildroot manual, or consult'
  873. @echo 'it on-line at http://buildroot.org/docs.html'
  874. @echo
  875. # List the defconfig files
  876. # $(1): base directory
  877. # $(2): br2-external name, empty for bundled
  878. define list-defconfigs
  879. @first=true; \
  880. for defconfig in $(1)/configs/*_defconfig; do \
  881. [ -f "$${defconfig}" ] || continue; \
  882. if $${first}; then \
  883. if [ "$(2)" ]; then \
  884. printf 'External configs in "$(call qstrip,$(2))":\n'; \
  885. else \
  886. printf "Built-in configs:\n"; \
  887. fi; \
  888. first=false; \
  889. fi; \
  890. defconfig="$${defconfig##*/}"; \
  891. printf " %-35s - Build for %s\n" "$${defconfig}" "$${defconfig%_defconfig}"; \
  892. done; \
  893. $${first} || printf "\n"
  894. endef
  895. # We iterate over BR2_EXTERNAL_NAMES rather than BR2_EXTERNAL_DIRS,
  896. # because we want to display the name of the br2-external tree.
  897. list-defconfigs:
  898. $(call list-defconfigs,$(TOPDIR))
  899. $(foreach name,$(BR2_EXTERNAL_NAMES),\
  900. $(call list-defconfigs,$(BR2_EXTERNAL_$(name)_PATH),\
  901. $(BR2_EXTERNAL_$(name)_DESC))$(sep))
  902. release: OUT = buildroot-$(BR2_VERSION)
  903. # Create release tarballs. We need to fiddle a bit to add the generated
  904. # documentation to the git output
  905. release:
  906. git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
  907. $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
  908. $(MAKE) O=$(OUT) manual-clean
  909. tar rf $(OUT).tar $(OUT)
  910. gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
  911. bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
  912. rm -rf $(OUT) $(OUT).tar
  913. print-version:
  914. @echo $(BR2_VERSION_FULL)
  915. include docs/manual/manual.mk
  916. -include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(dir)/docs/*/*.mk)
  917. .PHONY: $(noconfig_targets)
  918. endif #umask / $(CURDIR) / $(O)