Makefile 42 KB

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