Makefile 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275
  1. # Makefile for buildroot
  2. #
  3. # Copyright (C) the Buildroot developers <buildroot@buildroot.org>
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. #
  19. #--------------------------------------------------------------
  20. # Just run 'make menuconfig', configure stuff, then run 'make'.
  21. # You shouldn't need to mess with anything beyond this point...
  22. #--------------------------------------------------------------
  23. # Delete default rules. We don't use them. This saves a bit of time.
  24. .SUFFIXES:
  25. # we want bash as shell
  26. SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
  27. else if [ -x /bin/bash ]; then echo /bin/bash; \
  28. else echo sh; fi; fi)
  29. # Set O variable if not already done on the command line;
  30. # or avoid confusing packages that can use the O=<dir> syntax for out-of-tree
  31. # build by preventing it from being forwarded to sub-make calls.
  32. ifneq ("$(origin O)", "command line")
  33. O := $(CURDIR)/output
  34. endif
  35. # Check if the current Buildroot execution meets all the pre-requisites.
  36. # If they are not met, Buildroot will actually do its job in a sub-make meeting
  37. # its pre-requisites, which are:
  38. # 1- Permissive enough umask:
  39. # Wrong or too restrictive umask will prevent Buildroot and packages from
  40. # creating files and directories.
  41. # 2- Absolute canonical CWD (i.e. $(CURDIR)):
  42. # Otherwise, some packages will use CWD as-is, others will compute its
  43. # absolute canonical path. This makes harder tracking and fixing host
  44. # machine path leaks.
  45. # 3- Absolute canonical output location (i.e. $(O)):
  46. # For the same reason as the one for CWD.
  47. # Remove the trailing '/.' from $(O) as it can be added by the makefile wrapper
  48. # installed in the $(O) directory.
  49. # Also remove the trailing '/' the user can set when on the command line.
  50. override O := $(patsubst %/,%,$(patsubst %.,%,$(O)))
  51. # Make sure $(O) actually exists before calling realpath on it; this is to
  52. # avoid empty CANONICAL_O in case on non-existing entry.
  53. CANONICAL_O := $(shell mkdir -p $(O) >/dev/null 2>&1)$(realpath $(O))
  54. # gcc fails to build when the srcdir contains a '@'
  55. ifneq ($(findstring @,$(CANONICAL_O)),)
  56. $(error The build directory can not contain a '@')
  57. endif
  58. CANONICAL_CURDIR = $(realpath $(CURDIR))
  59. REQ_UMASK = 0022
  60. CUR_UMASK := $(shell umask)
  61. # Make sure O= is passed (with its absolute canonical path) everywhere the
  62. # toplevel makefile is called back.
  63. EXTRAMAKEARGS := O=$(CANONICAL_O)
  64. # Check Buildroot execution pre-requisites here.
  65. ifneq ($(CUR_UMASK):$(CURDIR):$(O),$(REQ_UMASK):$(CANONICAL_CURDIR):$(CANONICAL_O))
  66. .PHONY: _all $(MAKECMDGOALS)
  67. $(MAKECMDGOALS): _all
  68. @:
  69. _all:
  70. @umask $(REQ_UMASK) && \
  71. $(MAKE) -C $(CANONICAL_CURDIR) --no-print-directory \
  72. BR_ORIG_UMASK=$(CUR_UMASK) \
  73. $(MAKECMDGOALS) $(EXTRAMAKEARGS)
  74. else # umask / $(CURDIR) / $(O)
  75. # This is our default rule, so must come first
  76. all:
  77. .PHONY: all
  78. # Set and export the version string
  79. export BR2_VERSION := 2026.02-git
  80. # Actual time the release is cut (for reproducible builds)
  81. BR2_VERSION_EPOCH = 1765493000
  82. # Save running make version since it's clobbered by the make package
  83. RUNNING_MAKE_VERSION := $(MAKE_VERSION)
  84. # Check for minimal make version (note: this check will break at make 10.x)
  85. MIN_MAKE_VERSION = 3.81
  86. ifneq ($(firstword $(sort $(RUNNING_MAKE_VERSION) $(MIN_MAKE_VERSION))),$(MIN_MAKE_VERSION))
  87. $(error You have make '$(RUNNING_MAKE_VERSION)' installed. GNU make >= $(MIN_MAKE_VERSION) is required)
  88. endif
  89. # absolute path
  90. TOPDIR := $(CURDIR)
  91. CONFIG_CONFIG_IN = Config.in
  92. CONFIG = support/kconfig
  93. DATE := $(shell date +%Y%m%d)
  94. # Compute the full local version string so packages can use it as-is
  95. # Need to export it, so it can be got from environment in children (eg. mconf)
  96. BR2_LOCALVERSION := $(shell $(TOPDIR)/support/scripts/setlocalversion)
  97. ifeq ($(BR2_LOCALVERSION),)
  98. export BR2_VERSION_FULL := $(BR2_VERSION)
  99. else
  100. export BR2_VERSION_FULL := $(BR2_LOCALVERSION)
  101. endif
  102. # List of targets and target patterns for which .config doesn't need to be read in
  103. noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconfig \
  104. defconfig %_defconfig allyesconfig allnoconfig alldefconfig syncconfig release \
  105. randpackageconfig allyespackageconfig allnopackageconfig \
  106. print-version olddefconfig distclean manual manual-% check-package
  107. # Some global targets do not trigger a build, but are used to collect
  108. # metadata, or do various checks. When such targets are triggered,
  109. # some packages should not do their configuration sanity
  110. # checks. Provide them a BR_BUILDING variable set to 'y' when we're
  111. # actually building and they should do their sanity checks.
  112. #
  113. # We're building in two situations: when MAKECMDGOALS is empty
  114. # (default target is to build), or when MAKECMDGOALS contains
  115. # something else than one of the nobuild_targets.
  116. nobuild_targets := source %-source \
  117. legal-info %-legal-info external-deps _external-deps \
  118. clean distclean help show-targets graph-depends \
  119. %-graph-depends %-show-depends %-show-version \
  120. graph-build graph-size list-defconfigs \
  121. savedefconfig update-defconfig printvars show-vars
  122. ifeq ($(MAKECMDGOALS),)
  123. BR_BUILDING = y
  124. else ifneq ($(filter-out $(nobuild_targets),$(MAKECMDGOALS)),)
  125. BR_BUILDING = y
  126. endif
  127. # We call make recursively to build packages. The command-line overrides that
  128. # are passed to Buildroot don't apply to those package build systems. In
  129. # particular, we don't want to pass down the O=<dir> option for out-of-tree
  130. # builds, because the value specified on the command line will not be correct
  131. # for packages.
  132. MAKEOVERRIDES :=
  133. # Include some helper macros and variables
  134. include support/misc/utils.mk
  135. # Set variables related to in-tree or out-of-tree build.
  136. # Here, both $(O) and $(CURDIR) are absolute canonical paths.
  137. ifeq ($(O),$(CURDIR)/output)
  138. CONFIG_DIR := $(CURDIR)
  139. NEED_WRAPPER =
  140. else
  141. CONFIG_DIR := $(O)
  142. NEED_WRAPPER = y
  143. endif
  144. # bash prints the name of the directory on 'cd <dir>' if CDPATH is
  145. # set, so unset it here to not cause problems. Notice that the export
  146. # line doesn't affect the environment of $(shell ..) calls.
  147. export CDPATH :=
  148. BASE_DIR := $(CANONICAL_O)
  149. $(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
  150. # Handling of BR2_EXTERNAL.
  151. #
  152. # The value of BR2_EXTERNAL is stored in .br-external in the output directory.
  153. # The location of the external.mk makefile fragments is computed in that file.
  154. # On subsequent invocations of make, this file is read in. BR2_EXTERNAL can
  155. # still be overridden on the command line, therefore the file is re-created
  156. # every time make is run.
  157. BR2_EXTERNAL_FILE = $(BASE_DIR)/.br2-external.mk
  158. -include $(BR2_EXTERNAL_FILE)
  159. $(shell support/scripts/br2-external -d '$(BASE_DIR)' $(BR2_EXTERNAL))
  160. BR2_EXTERNAL_ERROR =
  161. include $(BR2_EXTERNAL_FILE)
  162. ifneq ($(BR2_EXTERNAL_ERROR),)
  163. $(error $(BR2_EXTERNAL_ERROR))
  164. endif
  165. # Workaround bug in make-4.3: https://savannah.gnu.org/bugs/?57676
  166. $(BASE_DIR)/.br2-external.mk:;
  167. # To make sure that the environment variable overrides the .config option,
  168. # set this before including .config.
  169. ifneq ($(BR2_DL_DIR),)
  170. DL_DIR := $(BR2_DL_DIR)
  171. endif
  172. ifneq ($(BR2_CCACHE_DIR),)
  173. BR_CACHE_DIR := $(BR2_CCACHE_DIR)
  174. endif
  175. # Need that early, before we scan packages
  176. # Avoids doing the $(or...) everytime
  177. BR_GRAPH_OUT := $(or $(BR2_GRAPH_OUT),pdf)
  178. BUILD_DIR := $(BASE_DIR)/build
  179. BINARIES_DIR := $(BASE_DIR)/images
  180. BASE_TARGET_DIR := $(BASE_DIR)/target
  181. PER_PACKAGE_DIR := $(BASE_DIR)/per-package
  182. # initial definition so that 'make clean' works for most users, even without
  183. # .config. HOST_DIR will be overwritten later when .config is included.
  184. HOST_DIR := $(BASE_DIR)/host
  185. GRAPHS_DIR := $(BASE_DIR)/graphs
  186. LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
  187. REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
  188. REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
  189. LICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses
  190. LICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses
  191. LEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv
  192. LEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv
  193. LEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings
  194. LEGAL_REPORT = $(LEGAL_INFO_DIR)/README
  195. BR2_CONFIG = $(CONFIG_DIR)/.config
  196. # Pull in the user's configuration file
  197. ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
  198. -include $(BR2_CONFIG)
  199. endif
  200. ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),)
  201. # Disable top-level parallel build if per-package directories is not
  202. # used. Indeed, per-package directories is necessary to guarantee
  203. # determinism and reproducibility with top-level parallel build.
  204. .NOTPARALLEL:
  205. endif
  206. # timezone and locale may affect build output
  207. ifeq ($(BR2_REPRODUCIBLE),y)
  208. export TZ = UTC
  209. export LANG = C
  210. export LC_ALL = C
  211. endif
  212. # To put more focus on warnings, be less verbose as default
  213. # Use 'make V=1' to see the full commands
  214. ifeq ("$(origin V)", "command line")
  215. KBUILD_VERBOSE = $(V)
  216. endif
  217. ifndef KBUILD_VERBOSE
  218. KBUILD_VERBOSE = 0
  219. endif
  220. ifeq ($(KBUILD_VERBOSE),1)
  221. Q =
  222. ifndef VERBOSE
  223. VERBOSE = 1
  224. endif
  225. export VERBOSE
  226. else
  227. Q = @
  228. endif
  229. # kconfig uses CONFIG_SHELL
  230. CONFIG_SHELL := $(SHELL)
  231. export SHELL CONFIG_SHELL Q KBUILD_VERBOSE
  232. ifndef HOSTAR
  233. HOSTAR := ar
  234. endif
  235. ifndef HOSTAS
  236. HOSTAS := as
  237. endif
  238. ifndef HOSTCC
  239. HOSTCC := gcc
  240. HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
  241. endif
  242. ifndef HOSTCC_NOCCACHE
  243. HOSTCC_NOCCACHE := $(HOSTCC)
  244. endif
  245. ifndef HOSTCXX
  246. HOSTCXX := g++
  247. HOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
  248. endif
  249. ifndef HOSTCXX_NOCCACHE
  250. HOSTCXX_NOCCACHE := $(HOSTCXX)
  251. endif
  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. # When adding a new host gcc version in Config.in,
  307. # update the HOSTCC_MAX_VERSION variable:
  308. HOSTCC_MAX_VERSION := 15
  309. HOSTCC_VERSION := $(shell V=$$($(HOSTCC_NOCCACHE) --version | \
  310. sed -n -r 's/^.* ([0-9]*)\.([0-9]*)\.([0-9]*)[ ]*.*/\1 \2/p'); \
  311. [ "$${V%% *}" -le $(HOSTCC_MAX_VERSION) ] || V=$(HOSTCC_MAX_VERSION); \
  312. printf "%s" "$${V}")
  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. # Compilation of perl-related packages will fail otherwise
  343. unexport PERL_MM_OPT
  344. include package/pkg-utils.mk
  345. include package/doc-asciidoc.mk
  346. ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  347. ################################################################################
  348. #
  349. # Hide troublesome environment variables from sub processes
  350. #
  351. ################################################################################
  352. unexport AR
  353. unexport ARCH
  354. unexport CC
  355. unexport CFLAGS
  356. unexport CONFIG_SITE
  357. unexport CPP
  358. unexport CROSS_COMPILE
  359. unexport CXX
  360. unexport CXXFLAGS
  361. unexport DEVICE_TREE
  362. unexport GCC_COLORS
  363. unexport GREP_OPTIONS
  364. unexport LD
  365. unexport MACHINE
  366. unexport O
  367. unexport OS
  368. unexport PLATFORM
  369. unexport QMAKESPEC
  370. unexport RANLIB
  371. unexport TAR_OPTIONS
  372. unexport TERMINFO
  373. unexport TOPDIR
  374. GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
  375. PACKAGES :=
  376. PACKAGES_ALL :=
  377. # silent mode requested?
  378. QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
  379. # Strip off the annoying quoting
  380. ARCH := $(call qstrip,$(BR2_ARCH))
  381. NORMALIZED_ARCH := $(call qstrip,$(BR2_NORMALIZED_ARCH))
  382. KERNEL_ARCH := $(call qstrip,$(BR2_NORMALIZED_ARCH))
  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. ZSTDCAT := $(call qstrip,$(BR2_ZSTDCAT))
  388. TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
  389. ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
  390. HOST_DIR = $(if $(PKG),$(PER_PACKAGE_DIR)/$($(PKG)_NAME)/host,$(call qstrip,$(BR2_HOST_DIR)))
  391. TARGET_DIR = $(if $(ROOTFS),$(ROOTFS_$(ROOTFS)_TARGET_DIR),$(if $(PKG),$(PER_PACKAGE_DIR)/$($(PKG)_NAME)/target,$(BASE_TARGET_DIR)))
  392. else
  393. HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
  394. TARGET_DIR = $(if $(ROOTFS),$(ROOTFS_$(ROOTFS)_TARGET_DIR),$(BASE_TARGET_DIR))
  395. endif
  396. ifneq ($(HOST_DIR),$(BASE_DIR)/host)
  397. HOST_DIR_SYMLINK = $(BASE_DIR)/host
  398. $(HOST_DIR_SYMLINK): | $(BASE_DIR)
  399. ln -snf $(HOST_DIR) $(HOST_DIR_SYMLINK)
  400. endif
  401. STAGING_DIR_SYMLINK = $(BASE_DIR)/staging
  402. $(STAGING_DIR_SYMLINK): | $(BASE_DIR)
  403. ln -snf $(STAGING_DIR) $(STAGING_DIR_SYMLINK)
  404. # Quotes are needed for spaces and all in the original PATH content.
  405. BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(PATH)"
  406. # Location of a file giving a big fat warning that output/target
  407. # should not be used as the root filesystem.
  408. TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
  409. ifeq ($(BR2_CCACHE),y)
  410. CCACHE = $(HOST_DIR)/bin/ccache
  411. BR_CACHE_DIR ?= $(call qstrip,$(BR2_CCACHE_DIR))
  412. export BR_CACHE_DIR
  413. HOSTCC = $(CCACHE) $(HOSTCC_NOCCACHE)
  414. HOSTCXX = $(CCACHE) $(HOSTCXX_NOCCACHE)
  415. export BR2_USE_CCACHE ?= 1
  416. endif
  417. # Scripts in support/ or post-build scripts may need to reference
  418. # these locations, so export them so it is easier to use
  419. export BR2_CONFIG
  420. export BR2_REPRODUCIBLE
  421. export TARGET_DIR
  422. export STAGING_DIR
  423. export HOST_DIR
  424. export BINARIES_DIR
  425. export BASE_DIR
  426. ################################################################################
  427. #
  428. # You should probably leave this stuff alone unless you know
  429. # what you are doing.
  430. #
  431. ################################################################################
  432. all: world
  433. # Include legacy before the other things, because package .mk files
  434. # may rely on it.
  435. include Makefile.legacy
  436. include system/system.mk
  437. include package/Makefile.in
  438. # arch/arch.mk must be after package/Makefile.in because it may need to
  439. # complement variables defined therein, like BR_NO_CHECK_HASH_FOR.
  440. include arch/arch.mk
  441. include support/dependencies/dependencies.mk
  442. include $(sort $(wildcard toolchain/*.mk))
  443. include $(sort $(wildcard toolchain/*/*.mk))
  444. ifeq ($(BR2_REPRODUCIBLE),y)
  445. # If SOURCE_DATE_EPOCH has not been set then use the commit date, or the last
  446. # release date if the source tree is not within a Git repository.
  447. # See: https://reproducible-builds.org/specs/source-date-epoch/
  448. BR2_VERSION_GIT_EPOCH := $(shell $(GIT) log -1 --format=%at 2> /dev/null)
  449. export SOURCE_DATE_EPOCH ?= $(or $(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
  450. endif
  451. # Include the package override file if one has been provided in the
  452. # configuration.
  453. PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
  454. ifneq ($(PACKAGE_OVERRIDE_FILE),)
  455. -include $(PACKAGE_OVERRIDE_FILE)
  456. endif
  457. include $(sort $(wildcard package/*/*.mk))
  458. include boot/common.mk
  459. include linux/linux.mk
  460. include fs/common.mk
  461. # If using a br2-external tree, the BR2_EXTERNAL_$(NAME)_PATH variables
  462. # are also present in the .config file. Since .config is included after
  463. # we defined them in the Makefile, the values for those variables are
  464. # quoted. We just include the generated Makefile fragment .br2-external.mk
  465. # a third time, which will set those variables to the un-quoted values.
  466. include $(BR2_EXTERNAL_FILE)
  467. # Nothing to include if no BR2_EXTERNAL tree in use
  468. include $(BR2_EXTERNAL_MKS)
  469. # Now we are sure we have all the packages scanned and defined. We now
  470. # check for each package in the list of enabled packages, that all its
  471. # dependencies are indeed enabled.
  472. #
  473. # Only trigger the check for default builds. If the user forces building
  474. # a package, even if not enabled in the configuration, we want to accept
  475. # it. However; we also want to be able to force checking the dependencies
  476. # if the user so desires. Forcing a dependency check is useful in the case
  477. # of test-pkg, as we want to make sure during testing, that a package has
  478. # all the dependencies selected in the config file.
  479. #
  480. ifeq ($(MAKECMDGOALS),)
  481. BR_FORCE_CHECK_DEPENDENCIES = YES
  482. endif
  483. ifeq ($(BR_FORCE_CHECK_DEPENDENCIES),YES)
  484. define CHECK_ONE_DEPENDENCY
  485. ifeq ($$($(2)_TYPE),target)
  486. ifneq ($$($$($(2)_KCONFIG_VAR)),y)
  487. $$(error $$($(2)_NAME) is in the dependency chain of $$($(1)_NAME) that \
  488. has added it to its _DEPENDENCIES variable without selecting it or \
  489. depending on it from Config.in)
  490. endif
  491. endif
  492. endef
  493. $(foreach pkg,$(call UPPERCASE,$(PACKAGES)),\
  494. $(foreach dep,$(call UPPERCASE,$($(pkg)_FINAL_ALL_DEPENDENCIES)),\
  495. $(eval $(call CHECK_ONE_DEPENDENCY,$(pkg),$(dep))$(sep))))
  496. endif
  497. $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
  498. $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" syncconfig
  499. .PHONY: prepare
  500. prepare: $(BUILD_DIR)/buildroot-config/auto.conf
  501. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT)), \
  502. $(call MESSAGE,"Executing pre-build script $(s)"); \
  503. $(EXTRA_ENV) $(s) \
  504. $(TARGET_DIR) \
  505. $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)) \
  506. $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT_ARGS))$(sep))
  507. .PHONY: world
  508. world: target-post-image
  509. .PHONY: prepare-sdk
  510. prepare-sdk: world
  511. @$(call MESSAGE,"Preparing the SDK")
  512. $(INSTALL) -m 755 $(TOPDIR)/support/misc/relocate-sdk.sh $(HOST_DIR)/relocate-sdk.sh
  513. mkdir -p $(HOST_DIR)/share/buildroot
  514. echo $(HOST_DIR) > $(HOST_DIR)/share/buildroot/sdk-location
  515. BR2_SDK_PREFIX ?= $(GNU_TARGET_NAME)_sdk-buildroot
  516. .PHONY: sdk
  517. sdk: prepare-sdk $(BR2_TAR_HOST_DEPENDENCY)
  518. @$(call MESSAGE,"Generating SDK tarball")
  519. $(if $(BR2_SDK_PREFIX),,$(error BR2_SDK_PREFIX can not be empty))
  520. $(Q)mkdir -p $(BINARIES_DIR)
  521. $(TAR) czf "$(BINARIES_DIR)/$(BR2_SDK_PREFIX).tar.gz" \
  522. --owner=0 --group=0 --numeric-owner \
  523. --transform='s#^$(patsubst /%,%,$(HOST_DIR))#$(BR2_SDK_PREFIX)#' \
  524. -C / $(patsubst /%,%,$(HOST_DIR))
  525. RSYNC_VCS_EXCLUSIONS = \
  526. --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
  527. --exclude CVS
  528. # When stripping, obey to BR2_STRIP_EXCLUDE_DIRS and
  529. # BR2_STRIP_EXCLUDE_FILES
  530. STRIP_FIND_COMMON_CMD = \
  531. find $(TARGET_DIR) \
  532. $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)), \
  533. \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) \
  534. -prune -o \
  535. ) \
  536. $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES)), \
  537. -not \( $(call findfileclauses,$(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) )
  538. # Regular stripping for everything, except libpthread, ld-*.so and
  539. # kernel modules:
  540. # - libpthread.so: a non-stripped libpthread shared library is needed for
  541. # proper debugging of pthread programs using gdb.
  542. # - ld.so: a non-stripped dynamic linker library is needed for valgrind
  543. # - kernel modules (*.ko): do not function properly when stripped like normal
  544. # applications and libraries. Normally kernel modules are already excluded
  545. # by the executable permission check, so the explicit exclusion is only
  546. # done for kernel modules with incorrect permissions.
  547. STRIP_FIND_CMD = \
  548. $(STRIP_FIND_COMMON_CMD) \
  549. -type f \( -perm /111 -o -name '*.so*' \) \
  550. -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko) \) \
  551. -print0
  552. # Special stripping (only debugging symbols) for libpthread and ld-*.so.
  553. STRIP_FIND_SPECIAL_LIBS_CMD = \
  554. $(STRIP_FIND_COMMON_CMD) \
  555. \( -name 'ld-*.so*' -o -name 'libpthread*.so*' \) \
  556. -print0
  557. # Generate locale data.
  558. ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
  559. GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
  560. ifneq ($(GLIBC_GENERATE_LOCALES),)
  561. PACKAGES += host-localedef
  562. define GENERATE_GLIBC_LOCALES
  563. +$(MAKE) -f support/misc/gen-glibc-locales.mk \
  564. ENDIAN=$(call LOWERCASE,$(BR2_ENDIAN)) \
  565. LOCALES="$(GLIBC_GENERATE_LOCALES)" \
  566. Q=$(Q)
  567. endef
  568. TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
  569. endif
  570. endif
  571. ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
  572. LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
  573. LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
  574. # This piece of junk does the following:
  575. # First collect the whitelist in a file.
  576. # Then go over all the locale dirs and for each subdir, check if it exists
  577. # in the whitelist file. If it doesn't, kill it.
  578. # Finally, specifically for X11, regenerate locale.dir from the whitelist.
  579. define PURGE_LOCALES
  580. printf '%s\n' $(LOCALE_NOPURGE) locale-archive > $(LOCALE_WHITELIST)
  581. for dir in $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/lib/locale); \
  582. do \
  583. if [ ! -d $$dir ]; then continue; fi; \
  584. for langdir in $$dir/*; \
  585. do \
  586. if [ -e "$${langdir}" ]; \
  587. then \
  588. grep -qx "$${langdir##*/}" $(LOCALE_WHITELIST) || rm -rf $$langdir; \
  589. fi \
  590. done; \
  591. done
  592. if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \
  593. then \
  594. for lang in $(LOCALE_NOPURGE); \
  595. do \
  596. if [ -f $(TARGET_DIR)/usr/share/X11/locale/$$lang/XLC_LOCALE ]; \
  597. then \
  598. echo "$$lang/XLC_LOCALE: $$lang"; \
  599. fi \
  600. done > $(TARGET_DIR)/usr/share/X11/locale/locale.dir; \
  601. fi
  602. endef
  603. TARGET_FINALIZE_HOOKS += PURGE_LOCALES
  604. endif
  605. $(TARGETS_ROOTFS): target-finalize
  606. # Avoid the rootfs name leaking down the dependency chain
  607. target-finalize: ROOTFS=
  608. TARGET_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list.txt))
  609. HOST_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list-host.txt))
  610. STAGING_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list-staging.txt))
  611. .PHONY: host-finalize
  612. host-finalize: $(PACKAGES) $(HOST_DIR) $(HOST_DIR_SYMLINK)
  613. @$(call MESSAGE,"Finalizing host directory")
  614. $(call per-package-rsync,$(sort $(PACKAGES)),host,$(HOST_DIR),copy)
  615. $(Q)PARALLEL_JOBS=$(PARALLEL_JOBS) \
  616. PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) \
  617. $(TOPDIR)/support/scripts/fix-rpath host
  618. $(Q)PARALLEL_JOBS=$(PARALLEL_JOBS) \
  619. PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) \
  620. $(TOPDIR)/support/scripts/fix-rpath staging
  621. $(call ppd-fixup-paths,$(BASE_DIR))
  622. .PHONY: staging-finalize
  623. staging-finalize: $(STAGING_DIR_SYMLINK)
  624. .PHONY: target-finalize
  625. target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize
  626. @$(call MESSAGE,"Finalizing target directory")
  627. $(call per-package-rsync,$(sort $(PACKAGES)),target,$(TARGET_DIR),copy)
  628. $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
  629. rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
  630. $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
  631. $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake \
  632. $(TARGET_DIR)/usr/lib/rpm $(TARGET_DIR)/usr/doc
  633. find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
  634. find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \
  635. \( -name '*.a' -o -name '*.la' -o -name '*.prl' \) -print0 | xargs -0 rm -f
  636. ifneq ($(BR2_PACKAGE_GDB),y)
  637. rm -rf $(TARGET_DIR)/usr/share/gdb
  638. endif
  639. ifneq ($(BR2_PACKAGE_BASH),y)
  640. rm -rf $(TARGET_DIR)/usr/share/bash-completion
  641. rm -rf $(TARGET_DIR)/etc/bash_completion.d
  642. endif
  643. ifneq ($(BR2_PACKAGE_ZSH),y)
  644. rm -rf $(TARGET_DIR)/usr/share/zsh
  645. endif
  646. rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
  647. rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
  648. rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
  649. rm -rf $(TARGET_DIR)/usr/share/gtk-doc
  650. rmdir $(TARGET_DIR)/usr/share 2>/dev/null || true
  651. ifneq ($(BR2_ENABLE_DEBUG):$(BR2_STRIP_strip),y:)
  652. rm -rf $(TARGET_DIR)/lib/debug $(TARGET_DIR)/usr/lib/debug
  653. endif
  654. $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
  655. $(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $(STRIPCMD) $(STRIP_STRIP_DEBUG) 2>/dev/null || true
  656. test -f $(TARGET_DIR)/etc/ld.so.conf && \
  657. { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
  658. test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
  659. { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
  660. mkdir -p $(TARGET_DIR)/etc
  661. ( \
  662. echo "NAME=Buildroot"; \
  663. echo "VERSION=$(BR2_VERSION_FULL)"; \
  664. echo "ID=buildroot"; \
  665. echo "VERSION_ID=$(BR2_VERSION)"; \
  666. echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
  667. ) > $(TARGET_DIR)/usr/lib/os-release
  668. ln -sf ../usr/lib/os-release $(TARGET_DIR)/etc
  669. @$(call MESSAGE,"Sanitizing RPATH in target tree")
  670. PARALLEL_JOBS=$(PARALLEL_JOBS) \
  671. PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) \
  672. $(TOPDIR)/support/scripts/fix-rpath target
  673. # For a merged /usr, ensure that /lib, /bin and /sbin and their /usr
  674. # counterparts are appropriately setup as symlinks ones to the others.
  675. @$(call MESSAGE,"Sanity check in overlays $(call qstrip,$(BR2_ROOTFS_OVERLAY))")
  676. support/scripts/check-merged \
  677. -t overlay \
  678. $(if $(BR2_ROOTFS_MERGED_USR),-u) \
  679. $(if $(BR2_ROOTFS_MERGED_BIN),-b) \
  680. $(call qstrip,$(BR2_ROOTFS_OVERLAY))
  681. $(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
  682. @$(call MESSAGE,"Copying overlay $(d)")$(sep) \
  683. $(Q)$(call SYSTEM_RSYNC,$(d),$(TARGET_DIR))$(sep))
  684. $(Q)$(if $(TARGET_DIR_FILES_LISTS), \
  685. cat $(TARGET_DIR_FILES_LISTS)) > $(BUILD_DIR)/packages-file-list.txt
  686. $(Q)$(if $(HOST_DIR_FILES_LISTS), \
  687. cat $(HOST_DIR_FILES_LISTS)) > $(BUILD_DIR)/packages-file-list-host.txt
  688. $(Q)$(if $(STAGING_DIR_FILES_LISTS), \
  689. cat $(STAGING_DIR_FILES_LISTS)) > $(BUILD_DIR)/packages-file-list-staging.txt
  690. $(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
  691. @$(call MESSAGE,"Executing post-build script $(s)")$(sep) \
  692. $(Q)$(EXTRA_ENV) $(s) \
  693. $(TARGET_DIR) \
  694. $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)) \
  695. $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT_ARGS))$(sep))
  696. touch $(TARGET_DIR)/usr
  697. # Note: this will run in the filesystem context, so will use a copy
  698. # of target/, not the real one, so the files are still available on
  699. # re-builds (foo-rebuild, etc...)
  700. define ROOTFS_RM_HWDB_DATA
  701. rm -rf $(TARGET_DIR)/usr/lib/udev/hwdb.d/ $(TARGET_DIR)/etc/udev/hwdb.d/
  702. endef
  703. ROOTFS_PRE_CMD_HOOKS += ROOTFS_RM_HWDB_DATA
  704. .PHONY: target-post-image
  705. target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize
  706. @rm -f $(ROOTFS_COMMON_TAR)
  707. $(Q)mkdir -p $(BINARIES_DIR)
  708. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
  709. $(call MESSAGE,"Executing post-image script $(s)"); \
  710. $(EXTRA_ENV) $(s) \
  711. $(BINARIES_DIR) \
  712. $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)) \
  713. $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS))$(sep))
  714. .PHONY: source
  715. source: $(foreach p,$(PACKAGES),$(p)-all-source)
  716. .PHONY: _external-deps external-deps
  717. _external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
  718. external-deps:
  719. @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
  720. .PHONY: legal-info-clean
  721. legal-info-clean:
  722. @rm -fr $(LEGAL_INFO_DIR)
  723. .PHONY: legal-info-prepare
  724. legal-info-prepare: $(LEGAL_INFO_DIR)
  725. @$(call MESSAGE,"Buildroot $(BR2_VERSION_FULL) Collecting legal info")
  726. @$(call legal-license-file,HOST,buildroot,buildroot,COPYING,COPYING,support/legal-info/buildroot.hash)
  727. @$(call legal-manifest,TARGET,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,DEPENDENCIES WITH LICENSES)
  728. @$(call legal-manifest,HOST,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,DEPENDENCIES WITH LICENSES)
  729. @$(call legal-manifest,HOST,buildroot,$(BR2_VERSION_FULL),GPL-2.0+,COPYING,not saved,not saved)
  730. @$(call legal-warning,the Buildroot source code has not been saved)
  731. @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
  732. .PHONY: legal-info
  733. legal-info: legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
  734. $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
  735. @cat support/legal-info/README.header >>$(LEGAL_REPORT)
  736. @if [ -r $(LEGAL_WARNINGS) ]; then \
  737. cat support/legal-info/README.warnings-header \
  738. $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
  739. cat $(LEGAL_WARNINGS); fi
  740. @rm -f $(LEGAL_WARNINGS)
  741. @(cd $(LEGAL_INFO_DIR); \
  742. find * -type f -exec sha256sum {} + | LC_ALL=C sort -k2 \
  743. >.legal-info.sha256; \
  744. mv .legal-info.sha256 legal-info.sha256)
  745. @echo "Legal info produced in $(LEGAL_INFO_DIR)"
  746. .PHONY: show-targets
  747. show-targets:
  748. @echo $(sort $(PACKAGES)) $(sort $(TARGETS_ROOTFS))
  749. .PHONY: show-build-order
  750. show-build-order: $(patsubst %,%-show-build-order,$(PACKAGES))
  751. .PHONY: graph-build
  752. graph-build: $(O)/build/build-time.log
  753. @install -d $(GRAPHS_DIR)
  754. $(foreach o,name build duration,./support/scripts/graph-build-time \
  755. --type=histogram --order=$(o) --input=$(<) \
  756. --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
  757. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  758. $(foreach t,packages steps,./support/scripts/graph-build-time \
  759. --type=pie-$(t) --input=$(<) \
  760. --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
  761. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  762. ./support/scripts/graph-build-time --type=timeline --input=$(<) \
  763. --output=$(GRAPHS_DIR)/build.timeline.$(BR_GRAPH_OUT) \
  764. $(if $(BR2_GRAPH_ALT),--alternate-colors)
  765. .PHONY: graph-depends-requirements
  766. graph-depends-requirements:
  767. @dot -? >/dev/null 2>&1 || \
  768. { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
  769. .PHONY: graph-depends
  770. graph-depends: graph-depends-requirements
  771. @$(INSTALL) -d $(GRAPHS_DIR)
  772. @cd "$(CONFIG_DIR)"; \
  773. $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
  774. --direct -o $(GRAPHS_DIR)/$(@).dot
  775. dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \
  776. -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \
  777. $(GRAPHS_DIR)/$(@).dot
  778. .PHONY: graph-size
  779. graph-size:
  780. $(Q)mkdir -p $(GRAPHS_DIR)
  781. $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
  782. --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
  783. --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
  784. --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv \
  785. $(BR2_GRAPH_SIZE_OPTS)
  786. .PHONY: check-dependencies
  787. check-dependencies:
  788. @cd "$(CONFIG_DIR)"; \
  789. $(TOPDIR)/support/scripts/graph-depends -C
  790. .PHONY: show-info
  791. show-info:
  792. @:
  793. $(info $(call clean-json, \
  794. { $(foreach p, \
  795. $(sort $(foreach i,$(PACKAGES) $(TARGETS_ROOTFS), \
  796. $(i) \
  797. $($(call UPPERCASE,$(i))_FINAL_RECURSIVE_DEPENDENCIES) \
  798. ) \
  799. ), \
  800. $(call json-info,$(call UPPERCASE,$(p)))$(comma) \
  801. ) } \
  802. ) \
  803. )
  804. .PHONY: pkg-stats
  805. pkg-stats:
  806. @cd "$(CONFIG_DIR)" ; \
  807. $(TOPDIR)/support/scripts/pkg-stats -c \
  808. --json $(O)/pkg-stats.json \
  809. --html $(O)/pkg-stats.html \
  810. --nvd-path $(DL_DIR)/buildroot-nvd
  811. else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  812. # Some subdirectories are also package names. To avoid that "make linux"
  813. # on an unconfigured tree produces "Nothing to be done", add an explicit
  814. # rule for it.
  815. # Also for 'all' we error out and ask the user to configure first.
  816. .PHONY: linux toolchain
  817. linux toolchain all: outputmakefile
  818. $(error Please configure Buildroot first (e.g. "make menuconfig"))
  819. @exit 1
  820. endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  821. # configuration
  822. # ---------------------------------------------------------------------------
  823. HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
  824. export HOSTCFLAGS
  825. $(BUILD_DIR)/buildroot-config/%onf:
  826. mkdir -p $(@D)/lxdialog
  827. PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
  828. obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
  829. DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
  830. # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
  831. # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
  832. COMMON_CONFIG_ENV = \
  833. BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
  834. KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
  835. KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
  836. KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
  837. BR2_CONFIG=$(BR2_CONFIG) \
  838. HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
  839. BASE_DIR=$(BASE_DIR) \
  840. SKIP_LEGACY=
  841. xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
  842. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  843. gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile
  844. @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
  845. menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
  846. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  847. nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile
  848. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  849. config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  850. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  851. # For the config targets that automatically select options, we pass
  852. # SKIP_LEGACY=y to disable the legacy options. However, in that case
  853. # no values are set for the legacy options so a subsequent oldconfig
  854. # will query them. Therefore, run an additional olddefconfig.
  855. randconfig allyesconfig alldefconfig allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  856. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --$@ $(CONFIG_CONFIG_IN)
  857. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  858. randpackageconfig allyespackageconfig allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  859. @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
  860. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
  861. KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
  862. $< --$(subst package,,$@) $(CONFIG_CONFIG_IN)
  863. @rm -f $(CONFIG_DIR)/.config.nopkg
  864. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  865. oldconfig syncconfig olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  866. @$(COMMON_CONFIG_ENV) $< --$@ $(CONFIG_CONFIG_IN)
  867. defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  868. @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
  869. %_defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  870. @defconfig=$(or \
  871. $(firstword \
  872. $(foreach d, \
  873. $(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)), \
  874. $(wildcard $(d)/configs/$@) \
  875. ) \
  876. ), \
  877. $(error "Can't find $@") \
  878. ); \
  879. $(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$${defconfig} \
  880. $< --defconfig=$${defconfig} $(CONFIG_CONFIG_IN)
  881. update-defconfig: savedefconfig
  882. savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  883. @$(COMMON_CONFIG_ENV) $< \
  884. --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
  885. $(CONFIG_CONFIG_IN)
  886. @$(SED) '/^BR2_DEFCONFIG=/d' $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig)
  887. .PHONY: defconfig savedefconfig update-defconfig
  888. ################################################################################
  889. #
  890. # Cleanup and misc junk
  891. #
  892. ################################################################################
  893. # staging and target directories do NOT list these as
  894. # dependencies anywhere else
  895. $(BASE_DIR) $(BUILD_DIR) $(BASE_TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST) $(PER_PACKAGE_DIR):
  896. @mkdir -p $@
  897. # outputmakefile generates a Makefile in the output directory, if using a
  898. # separate output directory. This allows convenient use of make in the
  899. # output directory.
  900. .PHONY: outputmakefile
  901. outputmakefile:
  902. ifeq ($(NEED_WRAPPER),y)
  903. $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
  904. endif
  905. # printvars prints all the variables currently defined in our
  906. # Makefiles. Alternatively, if a non-empty VARS variable is passed,
  907. # only the variables matching the make pattern passed in VARS are
  908. # displayed.
  909. # show-vars does the same, but as a JSON dictionnary.
  910. #
  911. # Note: we iterate of .VARIABLES and filter each variable individually,
  912. # to workaround a bug in make 4.3; see https://savannah.gnu.org/bugs/?59093
  913. .PHONY: printvars
  914. printvars:
  915. ifndef VARS
  916. $(error Please pass a non-empty VARS to 'make printvars')
  917. endif
  918. @:
  919. $(foreach V, \
  920. $(sort $(foreach X, $(.VARIABLES), $(filter $(VARS),$(X)))), \
  921. $(if $(filter-out environment% default automatic, \
  922. $(origin $V)), \
  923. $(if $(QUOTED_VARS),\
  924. $(info $V='$(subst ','\'',$(if $(RAW_VARS),$(value $V),$($V)))'), \
  925. $(info $V=$(if $(RAW_VARS),$(value $V),$($V))))))
  926. # ')))) # Syntax colouring...
  927. # See details above, same as for printvars
  928. .PHONY: show-vars
  929. show-vars: VARS?=%
  930. show-vars:
  931. @:
  932. $(foreach i, \
  933. $(call clean-json, { \
  934. $(foreach V, \
  935. $(.VARIABLES), \
  936. $(and $(filter $(VARS),$(V)) \
  937. , \
  938. $(filter-out environment% default automatic, $(origin $V)) \
  939. , \
  940. "$V": { \
  941. "expanded": $(call mk-json-str,$($V))$(comma) \
  942. "raw": $(call mk-json-str,$(value $V)) \
  943. }$(comma) \
  944. ) \
  945. ) \
  946. } ) \
  947. , \
  948. $(info $(i)) \
  949. )
  950. .PHONY: clean
  951. clean:
  952. rm -rf $(BASE_TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) $(HOST_DIR_SYMLINK) \
  953. $(BUILD_DIR) $(BASE_DIR)/staging \
  954. $(LEGAL_INFO_DIR) $(GRAPHS_DIR) $(PER_PACKAGE_DIR) $(O)/pkg-stats.*
  955. .PHONY: distclean
  956. distclean: clean
  957. ifeq ($(O),$(CURDIR)/output)
  958. rm -rf $(O)
  959. endif
  960. rm -rf $(TOPDIR)/dl $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
  961. $(CONFIG_DIR)/.auto.deps $(BASE_DIR)/.br2-external.*
  962. .PHONY: help
  963. help:
  964. @echo 'Cleaning:'
  965. @echo ' clean - delete all files created by build'
  966. @echo ' distclean - delete all non-source files (including .config)'
  967. @echo
  968. @echo 'Build:'
  969. @echo ' all - make world'
  970. @echo ' toolchain - build toolchain'
  971. @echo ' sdk - build relocatable SDK'
  972. @echo
  973. @echo 'Configuration:'
  974. @echo ' menuconfig - interactive curses-based configurator'
  975. @echo ' nconfig - interactive ncurses-based configurator'
  976. @echo ' xconfig - interactive Qt-based configurator'
  977. @echo ' gconfig - interactive GTK-based configurator'
  978. @echo ' oldconfig - resolve any unresolved symbols in .config'
  979. @echo ' syncconfig - Same as oldconfig, but quietly, additionally update deps'
  980. @echo ' olddefconfig - Same as syncconfig but sets new symbols to their default value'
  981. @echo ' randconfig - New config with random answer to all options'
  982. @echo ' defconfig - New config with default answer to all options;'
  983. @echo ' BR2_DEFCONFIG, if set on the command line, is used as input'
  984. @echo ' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
  985. @echo ' update-defconfig - Same as savedefconfig'
  986. @echo ' allyesconfig - New config where all options are accepted with yes'
  987. @echo ' allnoconfig - New config where all options are answered with no'
  988. @echo ' alldefconfig - New config where all options are set to default'
  989. @echo ' randpackageconfig - New config with random answer to package options'
  990. @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
  991. @echo ' allnopackageconfig - New config where package options are answered with no'
  992. @echo
  993. @echo 'Package-specific:'
  994. @echo ' <pkg> - Build and install <pkg> and all its dependencies'
  995. @echo ' <pkg>-source - Only download the source files for <pkg>'
  996. @echo ' <pkg>-extract - Extract <pkg> sources'
  997. @echo ' <pkg>-patch - Apply patches to <pkg>'
  998. @echo ' <pkg>-depends - Build <pkg>'\''s dependencies'
  999. @echo ' <pkg>-configure - Build <pkg> up to the configure step'
  1000. @echo ' <pkg>-build - Build <pkg> up to the build step'
  1001. @echo ' <pkg>-show-info - generate info about <pkg>, as a JSON blurb'
  1002. @echo ' <pkg>-show-depends - List packages on which <pkg> depends'
  1003. @echo ' <pkg>-show-rdepends - List packages which have <pkg> as a dependency'
  1004. @echo ' <pkg>-show-recursive-depends'
  1005. @echo ' - Recursively list packages on which <pkg> depends'
  1006. @echo ' <pkg>-show-recursive-rdepends'
  1007. @echo ' - Recursively list packages which have <pkg> as a dependency'
  1008. @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
  1009. @echo ' <pkg>-graph-rdepends - Generate a graph of <pkg>'\''s reverse dependencies'
  1010. @echo ' <pkg>-graph-both-depends'
  1011. @echo ' - Generate a graph of both <pkg>'\''s forward and'
  1012. @echo ' reverse dependencies.'
  1013. @echo ' <pkg>-dirclean - Remove <pkg> build directory'
  1014. @echo ' <pkg>-reconfigure - Restart the build from the configure step'
  1015. @echo ' <pkg>-rebuild - Restart the build from the build step'
  1016. @echo ' <pkg>-reinstall - Restart the build from the install step'
  1017. $(foreach p,$(HELP_PACKAGES), \
  1018. @echo $(sep) \
  1019. @echo '$($(p)_NAME):' $(sep) \
  1020. $($(p)_HELP_CMDS)$(sep))
  1021. @echo
  1022. @echo 'Documentation:'
  1023. @echo ' manual - build manual in all formats'
  1024. @echo ' manual-html - build manual in HTML'
  1025. @echo ' manual-split-html - build manual in split HTML'
  1026. @echo ' manual-pdf - build manual in PDF'
  1027. @echo ' manual-text - build manual in text'
  1028. @echo ' manual-epub - build manual in ePub'
  1029. @echo ' graph-build - generate graphs of the build times'
  1030. @echo ' graph-depends - generate graph of the dependency tree'
  1031. @echo ' graph-size - generate stats of the filesystem size'
  1032. @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
  1033. @echo
  1034. @echo 'Miscellaneous:'
  1035. @echo ' source - download all sources needed for offline-build'
  1036. @echo ' external-deps - list external packages used'
  1037. @echo ' legal-info - generate info about license compliance'
  1038. @echo ' show-info - generate info about packages, as a JSON blurb'
  1039. @echo ' pkg-stats - generate info about packages as JSON and HTML'
  1040. @echo ' printvars - dump internal variables selected with VARS=...'
  1041. @echo ' show-vars - dump all internal variables as a JSON blurb; use VARS=...'
  1042. @echo ' to limit the list to variables names matching that pattern'
  1043. @echo
  1044. @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
  1045. @echo ' make O=dir - Locate all output files in "dir", including .config'
  1046. @echo
  1047. @echo 'For further details, see README, generate the Buildroot manual, or consult'
  1048. @echo 'it on-line at http://buildroot.org/docs.html'
  1049. @echo
  1050. # List the defconfig files
  1051. # $(1): base directory
  1052. # $(2): br2-external name, empty for bundled
  1053. define list-defconfigs
  1054. @first=true; \
  1055. for defconfig in $$([ -d $(1)/configs ] && find $(1)/configs -name '*_defconfig' |sort); do \
  1056. [ -f "$${defconfig}" ] || continue; \
  1057. if $${first}; then \
  1058. if [ "$(2)" ]; then \
  1059. printf 'External configs in "%s":\n' "$(call qstrip,$(2))"; \
  1060. else \
  1061. printf "Built-in configs:\n"; \
  1062. fi; \
  1063. first=false; \
  1064. fi; \
  1065. defconfig="$${defconfig#$(1)/configs/}"; \
  1066. printf " %-35s - Build for %s\n" "$${defconfig}" "$${defconfig%_defconfig}"; \
  1067. done; \
  1068. $${first} || printf "\n"
  1069. endef
  1070. # We iterate over BR2_EXTERNAL_NAMES rather than BR2_EXTERNAL_DIRS,
  1071. # because we want to display the name of the br2-external tree.
  1072. .PHONY: list-defconfigs
  1073. list-defconfigs:
  1074. $(call list-defconfigs,$(TOPDIR))
  1075. $(foreach name,$(BR2_EXTERNAL_NAMES),\
  1076. $(call list-defconfigs,$(BR2_EXTERNAL_$(name)_PATH),\
  1077. $(BR2_EXTERNAL_$(name)_DESC))$(sep))
  1078. release: OUT = buildroot-$(BR2_VERSION)
  1079. # Create release tarballs. We need to fiddle a bit to add the generated
  1080. # documentation to the git output
  1081. release:
  1082. git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
  1083. SOURCE_DATE_EPOCH=$$(git log -1 --format=%at 2> /dev/null) \
  1084. $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
  1085. $(MAKE) O=$(OUT) distclean
  1086. tar rf $(OUT).tar --owner=0 --group=0 \
  1087. --mtime="$$(git log -1 --pretty=format:%ci)" $(OUT)
  1088. gzip -9 -n -c < $(OUT).tar > $(OUT).tar.gz
  1089. xz -9 -c < $(OUT).tar > $(OUT).tar.xz
  1090. rm -rf $(OUT) $(OUT).tar
  1091. print-version:
  1092. @echo $(BR2_VERSION_FULL)
  1093. check-package:
  1094. $(Q)./utils/check-package `git ls-tree -r --name-only HEAD` \
  1095. --ignore-list=$(TOPDIR)/.checkpackageignore
  1096. .PHONY: .checkpackageignore
  1097. .checkpackageignore:
  1098. $(Q)./utils/check-package --failed-only `git ls-tree -r --name-only HEAD` \
  1099. > .checkpackageignore
  1100. include docs/manual/manual.mk
  1101. -include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(sort $(wildcard $(dir)/docs/*/*.mk)))
  1102. .PHONY: $(noconfig_targets)
  1103. # .WAIT was introduced in make 4.4. For older make, define it as phony.
  1104. .PHONY: .WAIT
  1105. endif #umask / $(CURDIR) / $(O)