Makefile 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128
  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. # The target directory is common to all packages,
  186. # but there is one that is specific to each filesystem.
  187. BASE_TARGET_DIR := $(BASE_DIR)/target
  188. TARGET_DIR = $(if $(ROOTFS),$(ROOTFS_$(ROOTFS)_TARGET_DIR),$(BASE_TARGET_DIR))
  189. # initial definition so that 'make clean' works for most users, even without
  190. # .config. HOST_DIR will be overwritten later when .config is included.
  191. HOST_DIR := $(BASE_DIR)/host
  192. GRAPHS_DIR := $(BASE_DIR)/graphs
  193. LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
  194. REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
  195. REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
  196. LICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses
  197. LICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses
  198. LEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv
  199. LEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv
  200. LEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings
  201. LEGAL_REPORT = $(LEGAL_INFO_DIR)/README
  202. BR2_CONFIG = $(CONFIG_DIR)/.config
  203. # Pull in the user's configuration file
  204. ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
  205. -include $(BR2_CONFIG)
  206. endif
  207. # timezone and locale may affect build output
  208. ifeq ($(BR2_REPRODUCIBLE),y)
  209. export TZ = UTC
  210. export LANG = C
  211. export LC_ALL = C
  212. export GZIP = -n
  213. BR2_VERSION_GIT_EPOCH = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1 --format=%at)
  214. export SOURCE_DATE_EPOCH ?= $(if $(wildcard $(TOPDIR)/.git),$(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
  215. endif
  216. # To put more focus on warnings, be less verbose as default
  217. # Use 'make V=1' to see the full commands
  218. ifeq ("$(origin V)", "command line")
  219. KBUILD_VERBOSE = $(V)
  220. endif
  221. ifndef KBUILD_VERBOSE
  222. KBUILD_VERBOSE = 0
  223. endif
  224. ifeq ($(KBUILD_VERBOSE),1)
  225. Q =
  226. ifndef VERBOSE
  227. VERBOSE = 1
  228. endif
  229. export VERBOSE
  230. else
  231. Q = @
  232. endif
  233. # kconfig uses CONFIG_SHELL
  234. CONFIG_SHELL := $(SHELL)
  235. export SHELL CONFIG_SHELL Q KBUILD_VERBOSE
  236. ifndef HOSTAR
  237. HOSTAR := ar
  238. endif
  239. ifndef HOSTAS
  240. HOSTAS := as
  241. endif
  242. ifndef HOSTCC
  243. HOSTCC := gcc
  244. HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
  245. endif
  246. HOSTCC_NOCCACHE := $(HOSTCC)
  247. ifndef HOSTCXX
  248. HOSTCXX := g++
  249. HOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
  250. endif
  251. HOSTCXX_NOCCACHE := $(HOSTCXX)
  252. ifndef HOSTCPP
  253. HOSTCPP := cpp
  254. endif
  255. ifndef HOSTLD
  256. HOSTLD := ld
  257. endif
  258. ifndef HOSTLN
  259. HOSTLN := ln
  260. endif
  261. ifndef HOSTNM
  262. HOSTNM := nm
  263. endif
  264. ifndef HOSTOBJCOPY
  265. HOSTOBJCOPY := objcopy
  266. endif
  267. ifndef HOSTRANLIB
  268. HOSTRANLIB := ranlib
  269. endif
  270. HOSTAR := $(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
  271. HOSTAS := $(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
  272. HOSTCPP := $(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
  273. HOSTLD := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
  274. HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
  275. HOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
  276. HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
  277. HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
  278. SED := $(shell which sed || type -p sed) -i -e
  279. export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
  280. export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
  281. # Determine the userland we are running on.
  282. #
  283. # Note that, despite its name, we are not interested in the actual
  284. # architecture name. This is mostly used to determine whether some
  285. # of the binary tools (e.g. pre-built external toolchains) can run
  286. # on the current host. So we need to know if the userland we're
  287. # running on can actually run those toolchains.
  288. #
  289. # For example, a 64-bit prebuilt toolchain will not run on a 64-bit
  290. # kernel if the userland is 32-bit (e.g. in a chroot for example).
  291. #
  292. # So, we extract the first part of the tuple the host gcc was
  293. # configured to generate code for; we assume this is our userland.
  294. #
  295. export HOSTARCH := $(shell LC_ALL=C $(HOSTCC_NOCCACHE) -v 2>&1 | \
  296. sed -e '/^Target: \([^-]*\).*/!d' \
  297. -e 's//\1/' \
  298. -e 's/i.86/x86/' \
  299. -e 's/sun4u/sparc64/' \
  300. -e 's/arm.*/arm/' \
  301. -e 's/sa110/arm/' \
  302. -e 's/ppc64/powerpc64/' \
  303. -e 's/ppc/powerpc/' \
  304. -e 's/macppc/powerpc/' \
  305. -e 's/sh.*/sh/' )
  306. HOSTCC_VERSION := $(shell $(HOSTCC_NOCCACHE) --version | \
  307. sed -n -r 's/^.* ([0-9]*)\.([0-9]*)\.([0-9]*)[ ]*.*/\1 \2/p')
  308. # For gcc >= 5.x, we only need the major version.
  309. ifneq ($(firstword $(HOSTCC_VERSION)),4)
  310. HOSTCC_VERSION := $(firstword $(HOSTCC_VERSION))
  311. endif
  312. ifeq ($(BR2_NEEDS_HOST_UTF8_LOCALE),y)
  313. # First, we try to use the user's configured locale (as that's the
  314. # language they'd expect messages to be displayed), then we favour
  315. # a non language-specific locale like C.UTF-8 if one is available,
  316. # so we sort with the C locale to get it at the top.
  317. # This is guaranteed to not be empty, because of the check in
  318. # support/dependencies/dependencies.sh
  319. HOST_UTF8_LOCALE := $(shell \
  320. ( echo $${LC_ALL:-$${LC_MESSAGES:-$${LANG}}}; \
  321. locale -a 2>/dev/null | LC_ALL=C sort \
  322. ) \
  323. | grep -i -E 'utf-?8$$' \
  324. | head -n 1)
  325. HOST_UTF8_LOCALE_ENV := LC_ALL=$(HOST_UTF8_LOCALE)
  326. endif
  327. # Make sure pkg-config doesn't look outside the buildroot tree
  328. HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
  329. unexport PKG_CONFIG_PATH
  330. unexport PKG_CONFIG_SYSROOT_DIR
  331. unexport PKG_CONFIG_LIBDIR
  332. # Having DESTDIR set in the environment confuses the installation
  333. # steps of some packages.
  334. unexport DESTDIR
  335. # Causes breakage with packages that needs host-ruby
  336. unexport RUBYOPT
  337. include package/pkg-utils.mk
  338. include package/doc-asciidoc.mk
  339. ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  340. ################################################################################
  341. #
  342. # Hide troublesome environment variables from sub processes
  343. #
  344. ################################################################################
  345. unexport CROSS_COMPILE
  346. unexport ARCH
  347. unexport CC
  348. unexport LD
  349. unexport AR
  350. unexport CXX
  351. unexport CPP
  352. unexport RANLIB
  353. unexport CFLAGS
  354. unexport CXXFLAGS
  355. unexport GREP_OPTIONS
  356. unexport TAR_OPTIONS
  357. unexport CONFIG_SITE
  358. unexport QMAKESPEC
  359. unexport TERMINFO
  360. unexport MACHINE
  361. unexport O
  362. unexport GCC_COLORS
  363. GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
  364. PACKAGES :=
  365. PACKAGES_ALL :=
  366. # silent mode requested?
  367. QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
  368. # Strip off the annoying quoting
  369. ARCH := $(call qstrip,$(BR2_ARCH))
  370. KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
  371. -e s/i.86/i386/ -e s/sun4u/sparc64/ \
  372. -e s/arcle/arc/ \
  373. -e s/arceb/arc/ \
  374. -e s/arm.*/arm/ -e s/sa110/arm/ \
  375. -e s/aarch64.*/arm64/ \
  376. -e s/bfin/blackfin/ \
  377. -e s/or1k/openrisc/ \
  378. -e s/parisc64/parisc/ \
  379. -e s/powerpc64.*/powerpc/ \
  380. -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
  381. -e s/sh.*/sh/ \
  382. -e s/microblazeel/microblaze/)
  383. ZCAT := $(call qstrip,$(BR2_ZCAT))
  384. BZCAT := $(call qstrip,$(BR2_BZCAT))
  385. XZCAT := $(call qstrip,$(BR2_XZCAT))
  386. LZCAT := $(call qstrip,$(BR2_LZCAT))
  387. TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
  388. # packages compiled for the host go here
  389. HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
  390. ifneq ($(HOST_DIR),$(BASE_DIR)/host)
  391. HOST_DIR_SYMLINK = $(BASE_DIR)/host
  392. $(HOST_DIR_SYMLINK): $(BASE_DIR)
  393. ln -snf $(HOST_DIR) $(BASE_DIR)/host
  394. endif
  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 = $(BASE_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) $(BASE_TARGET_DIR) \
  480. $(HOST_DIR) $(HOST_DIR_SYMLINK) $(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. # Avoid the rootfs name leaking down the dependency chain
  588. target-finalize: ROOTFS=
  589. .PHONY: target-finalize
  590. target-finalize: $(PACKAGES)
  591. @$(call MESSAGE,"Finalizing target directory")
  592. # Check files that are touched by more than one package
  593. ./support/scripts/check-uniq-files -t target $(BUILD_DIR)/packages-file-list.txt
  594. ./support/scripts/check-uniq-files -t staging $(BUILD_DIR)/packages-file-list-staging.txt
  595. ./support/scripts/check-uniq-files -t host $(BUILD_DIR)/packages-file-list-host.txt
  596. $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
  597. rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
  598. $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
  599. $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
  600. find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
  601. find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \
  602. \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
  603. ifneq ($(BR2_PACKAGE_GDB),y)
  604. rm -rf $(TARGET_DIR)/usr/share/gdb
  605. endif
  606. ifneq ($(BR2_PACKAGE_BASH),y)
  607. rm -rf $(TARGET_DIR)/usr/share/bash-completion
  608. endif
  609. ifneq ($(BR2_PACKAGE_ZSH),y)
  610. rm -rf $(TARGET_DIR)/usr/share/zsh
  611. endif
  612. rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
  613. rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
  614. rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
  615. rm -rf $(TARGET_DIR)/usr/share/gtk-doc
  616. rmdir $(TARGET_DIR)/usr/share 2>/dev/null || true
  617. $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
  618. # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
  619. # besides the one in which crash occurred; or SIGTRAP kills my program when
  620. # I set a breakpoint"
  621. ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
  622. find $(TARGET_DIR)/lib/ -type f -name 'libpthread*.so*' | \
  623. xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
  624. endif
  625. # Valgrind needs ld.so with enough information, so only strip
  626. # debugging symbols.
  627. find $(TARGET_DIR)/lib/ -type f -name 'ld-*.so*' | \
  628. xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
  629. test -f $(TARGET_DIR)/etc/ld.so.conf && \
  630. { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
  631. test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
  632. { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
  633. mkdir -p $(TARGET_DIR)/etc
  634. ( \
  635. echo "NAME=Buildroot"; \
  636. echo "VERSION=$(BR2_VERSION_FULL)"; \
  637. echo "ID=buildroot"; \
  638. echo "VERSION_ID=$(BR2_VERSION)"; \
  639. echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
  640. ) > $(TARGET_DIR)/usr/lib/os-release
  641. ln -sf ../usr/lib/os-release $(TARGET_DIR)/etc
  642. @$(call MESSAGE,"Sanitizing RPATH in target tree")
  643. $(TOPDIR)/support/scripts/fix-rpath target
  644. @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
  645. $(call MESSAGE,"Copying overlay $(d)"); \
  646. rsync -a --ignore-times --keep-dirlinks $(RSYNC_VCS_EXCLUSIONS) \
  647. --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
  648. $(d)/ $(TARGET_DIR)$(sep))
  649. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
  650. $(call MESSAGE,"Executing post-build script $(s)"); \
  651. $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
  652. .PHONY: target-post-image
  653. target-post-image: $(TARGETS_ROOTFS) target-finalize
  654. @rm -f $(ROOTFS_COMMON_TAR)
  655. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
  656. $(call MESSAGE,"Executing post-image script $(s)"); \
  657. $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
  658. .PHONY: source
  659. source: $(foreach p,$(PACKAGES),$(p)-all-source)
  660. .PHONY: _external-deps external-deps
  661. _external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
  662. external-deps:
  663. @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
  664. .PHONY: legal-info-clean
  665. legal-info-clean:
  666. @rm -fr $(LEGAL_INFO_DIR)
  667. .PHONY: legal-info-prepare
  668. legal-info-prepare: $(LEGAL_INFO_DIR)
  669. @$(call MESSAGE,"Buildroot $(BR2_VERSION_FULL) Collecting legal info")
  670. @$(call legal-license-file,buildroot,buildroot,support/legal-info,COPYING,COPYING,HOST)
  671. @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
  672. @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
  673. @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPL-2.0+,COPYING,not saved,not saved,HOST)
  674. @$(call legal-warning,the Buildroot source code has not been saved)
  675. @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
  676. .PHONY: legal-info
  677. legal-info: dirs legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
  678. $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
  679. @cat support/legal-info/README.header >>$(LEGAL_REPORT)
  680. @if [ -r $(LEGAL_WARNINGS) ]; then \
  681. cat support/legal-info/README.warnings-header \
  682. $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
  683. cat $(LEGAL_WARNINGS); fi
  684. @rm -f $(LEGAL_WARNINGS)
  685. @(cd $(LEGAL_INFO_DIR); \
  686. find * -type f -exec sha256sum {} + | LC_ALL=C sort -k2 \
  687. >.legal-info.sha256; \
  688. mv .legal-info.sha256 legal-info.sha256)
  689. @echo "Legal info produced in $(LEGAL_INFO_DIR)"
  690. .PHONY: show-targets
  691. show-targets:
  692. @echo $(sort $(PACKAGES)) $(sort $(TARGETS_ROOTFS))
  693. .PHONY: show-build-order
  694. show-build-order: $(patsubst %,%-show-build-order,$(PACKAGES))
  695. .PHONY: graph-build
  696. graph-build: $(O)/build/build-time.log
  697. @install -d $(GRAPHS_DIR)
  698. $(foreach o,name build duration,./support/scripts/graph-build-time \
  699. --type=histogram --order=$(o) --input=$(<) \
  700. --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
  701. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  702. $(foreach t,packages steps,./support/scripts/graph-build-time \
  703. --type=pie-$(t) --input=$(<) \
  704. --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
  705. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  706. .PHONY: graph-depends-requirements
  707. graph-depends-requirements:
  708. @dot -? >/dev/null 2>&1 || \
  709. { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
  710. .PHONY: graph-depends
  711. graph-depends: graph-depends-requirements
  712. @$(INSTALL) -d $(GRAPHS_DIR)
  713. @cd "$(CONFIG_DIR)"; \
  714. $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
  715. --direct -o $(GRAPHS_DIR)/$(@).dot
  716. dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \
  717. -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \
  718. $(GRAPHS_DIR)/$(@).dot
  719. .PHONY: graph-size
  720. graph-size:
  721. $(Q)mkdir -p $(GRAPHS_DIR)
  722. $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
  723. --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
  724. --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
  725. --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv
  726. .PHONY: check-dependencies
  727. check-dependencies:
  728. @cd "$(CONFIG_DIR)"; \
  729. $(TOPDIR)/support/scripts/graph-depends -C
  730. else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  731. # Some subdirectories are also package names. To avoid that "make linux"
  732. # on an unconfigured tree produces "Nothing to be done", add an explicit
  733. # rule for it.
  734. # Also for 'all' we error out and ask the user to configure first.
  735. .PHONY: linux toolchain
  736. linux toolchain all: outputmakefile
  737. $(error Please configure Buildroot first (e.g. "make menuconfig"))
  738. @exit 1
  739. endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  740. # configuration
  741. # ---------------------------------------------------------------------------
  742. HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
  743. export HOSTCFLAGS
  744. .PHONY: prepare-kconfig
  745. prepare-kconfig: outputmakefile $(BUILD_DIR)/.br2-external.in
  746. $(BUILD_DIR)/buildroot-config/%onf:
  747. mkdir -p $(@D)/lxdialog
  748. PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
  749. obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
  750. DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
  751. # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
  752. # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
  753. COMMON_CONFIG_ENV = \
  754. BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
  755. KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
  756. KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
  757. KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
  758. BR2_CONFIG=$(BR2_CONFIG) \
  759. HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
  760. BUILD_DIR=$(BUILD_DIR) \
  761. SKIP_LEGACY=
  762. xconfig: $(BUILD_DIR)/buildroot-config/qconf prepare-kconfig
  763. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  764. gconfig: $(BUILD_DIR)/buildroot-config/gconf prepare-kconfig
  765. @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
  766. menuconfig: $(BUILD_DIR)/buildroot-config/mconf prepare-kconfig
  767. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  768. nconfig: $(BUILD_DIR)/buildroot-config/nconf prepare-kconfig
  769. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  770. config: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  771. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  772. # For the config targets that automatically select options, we pass
  773. # SKIP_LEGACY=y to disable the legacy options. However, in that case
  774. # no values are set for the legacy options so a subsequent oldconfig
  775. # will query them. Therefore, run an additional olddefconfig.
  776. randconfig allyesconfig alldefconfig allnoconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  777. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --$@ $(CONFIG_CONFIG_IN)
  778. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  779. randpackageconfig allyespackageconfig allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  780. @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
  781. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
  782. KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
  783. $< --$(subst package,,$@) $(CONFIG_CONFIG_IN)
  784. @rm -f $(CONFIG_DIR)/.config.nopkg
  785. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  786. oldconfig silentoldconfig olddefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  787. @$(COMMON_CONFIG_ENV) $< --$@ $(CONFIG_CONFIG_IN)
  788. defconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  789. @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
  790. define percent_defconfig
  791. # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
  792. %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig prepare-kconfig
  793. @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \
  794. $$< --defconfig=$(1)/configs/$$@ $$(CONFIG_CONFIG_IN)
  795. endef
  796. $(eval $(foreach d,$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(call percent_defconfig,$(d))$(sep)))
  797. savedefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  798. @$(COMMON_CONFIG_ENV) $< \
  799. --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
  800. $(CONFIG_CONFIG_IN)
  801. @$(SED) '/BR2_DEFCONFIG=/d' $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig)
  802. .PHONY: defconfig savedefconfig
  803. ################################################################################
  804. #
  805. # Cleanup and misc junk
  806. #
  807. ################################################################################
  808. # staging and target directories do NOT list these as
  809. # dependencies anywhere else
  810. $(BUILD_DIR) $(BASE_TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
  811. @mkdir -p $@
  812. # outputmakefile generates a Makefile in the output directory, if using a
  813. # separate output directory. This allows convenient use of make in the
  814. # output directory.
  815. .PHONY: outputmakefile
  816. outputmakefile:
  817. ifeq ($(NEED_WRAPPER),y)
  818. $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
  819. endif
  820. # Even though the target is a real file, we mark it as PHONY as we
  821. # want it to be re-generated each time make is invoked, in case the
  822. # value of BR2_EXTERNAL is changed.
  823. .PHONY: $(BUILD_DIR)/.br2-external.in
  824. $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
  825. $(Q)support/scripts/br2-external -k -o "$(@)" $(BR2_EXTERNAL)
  826. # printvars prints all the variables currently defined in our
  827. # Makefiles. Alternatively, if a non-empty VARS variable is passed,
  828. # only the variables matching the make pattern passed in VARS are
  829. # displayed.
  830. .PHONY: printvars
  831. printvars:
  832. @:$(foreach V, \
  833. $(sort $(if $(VARS),$(filter $(VARS),$(.VARIABLES)),$(.VARIABLES))), \
  834. $(if $(filter-out environment% default automatic, \
  835. $(origin $V)), \
  836. $(if $(QUOTED_VARS),\
  837. $(info $V='$(subst ','\'',$(if $(RAW_VARS),$(value $V),$($V)))'), \
  838. $(info $V=$(if $(RAW_VARS),$(value $V),$($V))))))
  839. # ' Syntax colouring...
  840. .PHONY: clean
  841. clean:
  842. rm -rf $(BASE_TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) $(HOST_DIR_SYMLINK) \
  843. $(BUILD_DIR) $(BASE_DIR)/staging \
  844. $(LEGAL_INFO_DIR) $(GRAPHS_DIR)
  845. .PHONY: distclean
  846. distclean: clean
  847. ifeq ($(O),$(CURDIR)/output)
  848. rm -rf $(O)
  849. endif
  850. rm -rf $(TOPDIR)/dl $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
  851. $(CONFIG_DIR)/.auto.deps $(BR2_EXTERNAL_FILE)
  852. .PHONY: help
  853. help:
  854. @echo 'Cleaning:'
  855. @echo ' clean - delete all files created by build'
  856. @echo ' distclean - delete all non-source files (including .config)'
  857. @echo
  858. @echo 'Build:'
  859. @echo ' all - make world'
  860. @echo ' toolchain - build toolchain'
  861. @echo ' sdk - build relocatable SDK'
  862. @echo
  863. @echo 'Configuration:'
  864. @echo ' menuconfig - interactive curses-based configurator'
  865. @echo ' nconfig - interactive ncurses-based configurator'
  866. @echo ' xconfig - interactive Qt-based configurator'
  867. @echo ' gconfig - interactive GTK-based configurator'
  868. @echo ' oldconfig - resolve any unresolved symbols in .config'
  869. @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
  870. @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
  871. @echo ' randconfig - New config with random answer to all options'
  872. @echo ' defconfig - New config with default answer to all options'
  873. @echo ' BR2_DEFCONFIG, if set, is used as input'
  874. @echo ' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
  875. @echo ' allyesconfig - New config where all options are accepted with yes'
  876. @echo ' allnoconfig - New config where all options are answered with no'
  877. @echo ' alldefconfig - New config where all options are set to default'
  878. @echo ' randpackageconfig - New config with random answer to package options'
  879. @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
  880. @echo ' allnopackageconfig - New config where package options are answered with no'
  881. @echo
  882. @echo 'Package-specific:'
  883. @echo ' <pkg> - Build and install <pkg> and all its dependencies'
  884. @echo ' <pkg>-source - Only download the source files for <pkg>'
  885. @echo ' <pkg>-extract - Extract <pkg> sources'
  886. @echo ' <pkg>-patch - Apply patches to <pkg>'
  887. @echo ' <pkg>-depends - Build <pkg>'\''s dependencies'
  888. @echo ' <pkg>-configure - Build <pkg> up to the configure step'
  889. @echo ' <pkg>-build - Build <pkg> up to the build step'
  890. @echo ' <pkg>-show-depends - List packages on which <pkg> depends'
  891. @echo ' <pkg>-show-rdepends - List packages which have <pkg> as a dependency'
  892. @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
  893. @echo ' <pkg>-graph-rdepends - Generate a graph of <pkg>'\''s reverse dependencies'
  894. @echo ' <pkg>-dirclean - Remove <pkg> build directory'
  895. @echo ' <pkg>-reconfigure - Restart the build from the configure step'
  896. @echo ' <pkg>-rebuild - Restart the build from the build step'
  897. $(foreach p,$(HELP_PACKAGES), \
  898. @echo $(sep) \
  899. @echo '$($(p)_NAME):' $(sep) \
  900. $($(p)_HELP_CMDS)$(sep))
  901. @echo
  902. @echo 'Documentation:'
  903. @echo ' manual - build manual in all formats'
  904. @echo ' manual-html - build manual in HTML'
  905. @echo ' manual-split-html - build manual in split HTML'
  906. @echo ' manual-pdf - build manual in PDF'
  907. @echo ' manual-text - build manual in text'
  908. @echo ' manual-epub - build manual in ePub'
  909. @echo ' graph-build - generate graphs of the build times'
  910. @echo ' graph-depends - generate graph of the dependency tree'
  911. @echo ' graph-size - generate stats of the filesystem size'
  912. @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
  913. @echo
  914. @echo 'Miscellaneous:'
  915. @echo ' source - download all sources needed for offline-build'
  916. @echo ' external-deps - list external packages used'
  917. @echo ' legal-info - generate info about license compliance'
  918. @echo ' printvars - dump all the internal variables'
  919. @echo
  920. @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
  921. @echo ' make O=dir - Locate all output files in "dir", including .config'
  922. @echo
  923. @echo 'For further details, see README, generate the Buildroot manual, or consult'
  924. @echo 'it on-line at http://buildroot.org/docs.html'
  925. @echo
  926. # List the defconfig files
  927. # $(1): base directory
  928. # $(2): br2-external name, empty for bundled
  929. define list-defconfigs
  930. @first=true; \
  931. for defconfig in $(1)/configs/*_defconfig; do \
  932. [ -f "$${defconfig}" ] || continue; \
  933. if $${first}; then \
  934. if [ "$(2)" ]; then \
  935. printf 'External configs in "$(call qstrip,$(2))":\n'; \
  936. else \
  937. printf "Built-in configs:\n"; \
  938. fi; \
  939. first=false; \
  940. fi; \
  941. defconfig="$${defconfig##*/}"; \
  942. printf " %-35s - Build for %s\n" "$${defconfig}" "$${defconfig%_defconfig}"; \
  943. done; \
  944. $${first} || printf "\n"
  945. endef
  946. # We iterate over BR2_EXTERNAL_NAMES rather than BR2_EXTERNAL_DIRS,
  947. # because we want to display the name of the br2-external tree.
  948. .PHONY: list-defconfigs
  949. list-defconfigs:
  950. $(call list-defconfigs,$(TOPDIR))
  951. $(foreach name,$(BR2_EXTERNAL_NAMES),\
  952. $(call list-defconfigs,$(BR2_EXTERNAL_$(name)_PATH),\
  953. $(BR2_EXTERNAL_$(name)_DESC))$(sep))
  954. release: OUT = buildroot-$(BR2_VERSION)
  955. # Create release tarballs. We need to fiddle a bit to add the generated
  956. # documentation to the git output
  957. release:
  958. git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
  959. $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
  960. $(MAKE) O=$(OUT) manual-clean
  961. tar rf $(OUT).tar $(OUT)
  962. gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
  963. bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
  964. rm -rf $(OUT) $(OUT).tar
  965. print-version:
  966. @echo $(BR2_VERSION_FULL)
  967. .PHONY: .gitlab-ci.yml
  968. .gitlab-ci.yml: .gitlab-ci.yml.in
  969. cp $< $@
  970. (cd configs; LC_ALL=C ls -1 *_defconfig) | sed 's/$$/: *defconfig/' >> $@
  971. ./support/testing/run-tests -l 2>&1 | sed -r -e '/^test_run \((.*)\).*/!d; s//\1: *runtime_test/' | LC_ALL=C sort >> $@
  972. include docs/manual/manual.mk
  973. -include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(sort $(wildcard $(dir)/docs/*/*.mk)))
  974. .PHONY: $(noconfig_targets)
  975. endif #umask / $(CURDIR) / $(O)