Makefile 38 KB

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