Makefile 42 KB

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