Makefile 41 KB

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