Makefile 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279
  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 := 2025.05-git
  80. # Actual time the release is cut (for reproducible builds)
  81. BR2_VERSION_EPOCH = 1742234000
  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 CROSS_COMPILE
  353. unexport ARCH
  354. unexport CC
  355. unexport LD
  356. unexport AR
  357. unexport CXX
  358. unexport CPP
  359. unexport RANLIB
  360. unexport CFLAGS
  361. unexport CXXFLAGS
  362. unexport GREP_OPTIONS
  363. unexport TAR_OPTIONS
  364. unexport CONFIG_SITE
  365. unexport QMAKESPEC
  366. unexport TERMINFO
  367. unexport MACHINE
  368. unexport O
  369. unexport GCC_COLORS
  370. unexport PLATFORM
  371. unexport OS
  372. unexport DEVICE_TREE
  373. GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
  374. PACKAGES :=
  375. PACKAGES_ALL :=
  376. # silent mode requested?
  377. QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
  378. # Strip off the annoying quoting
  379. ARCH := $(call qstrip,$(BR2_ARCH))
  380. NORMALIZED_ARCH := $(call qstrip,$(BR2_NORMALIZED_ARCH))
  381. KERNEL_ARCH := $(call qstrip,$(BR2_NORMALIZED_ARCH))
  382. ZCAT := $(call qstrip,$(BR2_ZCAT))
  383. BZCAT := $(call qstrip,$(BR2_BZCAT))
  384. XZCAT := $(call qstrip,$(BR2_XZCAT))
  385. LZCAT := $(call qstrip,$(BR2_LZCAT))
  386. ZSTDCAT := $(call qstrip,$(BR2_ZSTDCAT))
  387. TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
  388. ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
  389. HOST_DIR = $(if $(PKG),$(PER_PACKAGE_DIR)/$($(PKG)_NAME)/host,$(call qstrip,$(BR2_HOST_DIR)))
  390. TARGET_DIR = $(if $(ROOTFS),$(ROOTFS_$(ROOTFS)_TARGET_DIR),$(if $(PKG),$(PER_PACKAGE_DIR)/$($(PKG)_NAME)/target,$(BASE_TARGET_DIR)))
  391. else
  392. HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
  393. TARGET_DIR = $(if $(ROOTFS),$(ROOTFS_$(ROOTFS)_TARGET_DIR),$(BASE_TARGET_DIR))
  394. endif
  395. ifneq ($(HOST_DIR),$(BASE_DIR)/host)
  396. HOST_DIR_SYMLINK = $(BASE_DIR)/host
  397. $(HOST_DIR_SYMLINK): | $(BASE_DIR)
  398. ln -snf $(HOST_DIR) $(HOST_DIR_SYMLINK)
  399. endif
  400. STAGING_DIR_SYMLINK = $(BASE_DIR)/staging
  401. $(STAGING_DIR_SYMLINK): | $(BASE_DIR)
  402. ln -snf $(STAGING_DIR) $(STAGING_DIR_SYMLINK)
  403. # Quotes are needed for spaces and all in the original PATH content.
  404. BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(PATH)"
  405. # Location of a file giving a big fat warning that output/target
  406. # should not be used as the root filesystem.
  407. TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
  408. ifeq ($(BR2_CCACHE),y)
  409. CCACHE = $(HOST_DIR)/bin/ccache
  410. BR_CACHE_DIR ?= $(call qstrip,$(BR2_CCACHE_DIR))
  411. export BR_CACHE_DIR
  412. HOSTCC = $(CCACHE) $(HOSTCC_NOCCACHE)
  413. HOSTCXX = $(CCACHE) $(HOSTCXX_NOCCACHE)
  414. export BR2_USE_CCACHE ?= 1
  415. endif
  416. # Scripts in support/ or post-build scripts may need to reference
  417. # these locations, so export them so it is easier to use
  418. export BR2_CONFIG
  419. export BR2_REPRODUCIBLE
  420. export TARGET_DIR
  421. export STAGING_DIR
  422. export HOST_DIR
  423. export BINARIES_DIR
  424. export BASE_DIR
  425. ################################################################################
  426. #
  427. # You should probably leave this stuff alone unless you know
  428. # what you are doing.
  429. #
  430. ################################################################################
  431. all: world
  432. # Include legacy before the other things, because package .mk files
  433. # may rely on it.
  434. include Makefile.legacy
  435. include system/system.mk
  436. include package/Makefile.in
  437. # arch/arch.mk must be after package/Makefile.in because it may need to
  438. # complement variables defined therein, like BR_NO_CHECK_HASH_FOR.
  439. include arch/arch.mk
  440. include support/dependencies/dependencies.mk
  441. include $(sort $(wildcard toolchain/*.mk))
  442. include $(sort $(wildcard toolchain/*/*.mk))
  443. ifeq ($(BR2_REPRODUCIBLE),y)
  444. # If SOURCE_DATE_EPOCH has not been set then use the commit date, or the last
  445. # release date if the source tree is not within a Git repository.
  446. # See: https://reproducible-builds.org/specs/source-date-epoch/
  447. BR2_VERSION_GIT_EPOCH := $(shell $(GIT) log -1 --format=%at 2> /dev/null)
  448. export SOURCE_DATE_EPOCH ?= $(or $(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
  449. endif
  450. # Include the package override file if one has been provided in the
  451. # configuration.
  452. PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
  453. ifneq ($(PACKAGE_OVERRIDE_FILE),)
  454. -include $(PACKAGE_OVERRIDE_FILE)
  455. endif
  456. include $(sort $(wildcard package/*/*.mk))
  457. include boot/common.mk
  458. include linux/linux.mk
  459. include fs/common.mk
  460. # If using a br2-external tree, the BR2_EXTERNAL_$(NAME)_PATH variables
  461. # are also present in the .config file. Since .config is included after
  462. # we defined them in the Makefile, the values for those variables are
  463. # quoted. We just include the generated Makefile fragment .br2-external.mk
  464. # a third time, which will set those variables to the un-quoted values.
  465. include $(BR2_EXTERNAL_FILE)
  466. # Nothing to include if no BR2_EXTERNAL tree in use
  467. include $(BR2_EXTERNAL_MKS)
  468. # Now we are sure we have all the packages scanned and defined. We now
  469. # check for each package in the list of enabled packages, that all its
  470. # dependencies are indeed enabled.
  471. #
  472. # Only trigger the check for default builds. If the user forces building
  473. # a package, even if not enabled in the configuration, we want to accept
  474. # it. However; we also want to be able to force checking the dependencies
  475. # if the user so desires. Forcing a dependency check is useful in the case
  476. # of test-pkg, as we want to make sure during testing, that a package has
  477. # all the dependencies selected in the config file.
  478. #
  479. ifeq ($(MAKECMDGOALS),)
  480. BR_FORCE_CHECK_DEPENDENCIES = YES
  481. endif
  482. ifeq ($(BR_FORCE_CHECK_DEPENDENCIES),YES)
  483. define CHECK_ONE_DEPENDENCY
  484. ifeq ($$($(2)_TYPE),target)
  485. ifneq ($$($$($(2)_KCONFIG_VAR)),y)
  486. $$(error $$($(2)_NAME) is in the dependency chain of $$($(1)_NAME) that \
  487. has added it to its _DEPENDENCIES variable without selecting it or \
  488. depending on it from Config.in)
  489. endif
  490. endif
  491. endef
  492. $(foreach pkg,$(call UPPERCASE,$(PACKAGES)),\
  493. $(foreach dep,$(call UPPERCASE,$($(pkg)_FINAL_ALL_DEPENDENCIES)),\
  494. $(eval $(call CHECK_ONE_DEPENDENCY,$(pkg),$(dep))$(sep))))
  495. endif
  496. $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
  497. $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" syncconfig
  498. .PHONY: prepare
  499. prepare: $(BUILD_DIR)/buildroot-config/auto.conf
  500. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT)), \
  501. $(call MESSAGE,"Executing pre-build script $(s)"); \
  502. $(EXTRA_ENV) $(s) \
  503. $(TARGET_DIR) \
  504. $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)) \
  505. $(call qstrip,$(BR2_ROOTFS_PRE_BUILD_SCRIPT_ARGS))$(sep))
  506. .PHONY: world
  507. world: target-post-image
  508. .PHONY: prepare-sdk
  509. prepare-sdk: world
  510. @$(call MESSAGE,"Preparing the SDK")
  511. $(INSTALL) -m 755 $(TOPDIR)/support/misc/relocate-sdk.sh $(HOST_DIR)/relocate-sdk.sh
  512. mkdir -p $(HOST_DIR)/share/buildroot
  513. echo $(HOST_DIR) > $(HOST_DIR)/share/buildroot/sdk-location
  514. BR2_SDK_PREFIX ?= $(GNU_TARGET_NAME)_sdk-buildroot
  515. .PHONY: sdk
  516. sdk: prepare-sdk $(BR2_TAR_HOST_DEPENDENCY)
  517. @$(call MESSAGE,"Generating SDK tarball")
  518. $(if $(BR2_SDK_PREFIX),,$(error BR2_SDK_PREFIX can not be empty))
  519. $(Q)mkdir -p $(BINARIES_DIR)
  520. $(TAR) czf "$(BINARIES_DIR)/$(BR2_SDK_PREFIX).tar.gz" \
  521. --owner=0 --group=0 --numeric-owner \
  522. --transform='s#^$(patsubst /%,%,$(HOST_DIR))#$(BR2_SDK_PREFIX)#' \
  523. -C / $(patsubst /%,%,$(HOST_DIR))
  524. RSYNC_VCS_EXCLUSIONS = \
  525. --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
  526. --exclude CVS
  527. # When stripping, obey to BR2_STRIP_EXCLUDE_DIRS and
  528. # BR2_STRIP_EXCLUDE_FILES
  529. STRIP_FIND_COMMON_CMD = \
  530. find $(TARGET_DIR) \
  531. $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)), \
  532. \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) \
  533. -prune -o \
  534. ) \
  535. $(if $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES)), \
  536. -not \( $(call findfileclauses,$(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) )
  537. # Regular stripping for everything, except libpthread, ld-*.so and
  538. # kernel modules:
  539. # - libpthread.so: a non-stripped libpthread shared library is needed for
  540. # proper debugging of pthread programs using gdb.
  541. # - ld.so: a non-stripped dynamic linker library is needed for valgrind
  542. # - kernel modules (*.ko): do not function properly when stripped like normal
  543. # applications and libraries. Normally kernel modules are already excluded
  544. # by the executable permission check, so the explicit exclusion is only
  545. # done for kernel modules with incorrect permissions.
  546. STRIP_FIND_CMD = \
  547. $(STRIP_FIND_COMMON_CMD) \
  548. -type f \( -perm /111 -o -name '*.so*' \) \
  549. -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko) \) \
  550. -print0
  551. # Special stripping (only debugging symbols) for libpthread and ld-*.so.
  552. STRIP_FIND_SPECIAL_LIBS_CMD = \
  553. $(STRIP_FIND_COMMON_CMD) \
  554. \( -name 'ld-*.so*' -o -name 'libpthread*.so*' \) \
  555. -print0
  556. # Generate locale data.
  557. ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
  558. GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
  559. ifneq ($(GLIBC_GENERATE_LOCALES),)
  560. PACKAGES += host-localedef
  561. define GENERATE_GLIBC_LOCALES
  562. +$(MAKE) -f support/misc/gen-glibc-locales.mk \
  563. ENDIAN=$(call LOWERCASE,$(BR2_ENDIAN)) \
  564. LOCALES="$(GLIBC_GENERATE_LOCALES)" \
  565. Q=$(Q)
  566. endef
  567. TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
  568. endif
  569. endif
  570. ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
  571. LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
  572. LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
  573. # This piece of junk does the following:
  574. # First collect the whitelist in a file.
  575. # Then go over all the locale dirs and for each subdir, check if it exists
  576. # in the whitelist file. If it doesn't, kill it.
  577. # Finally, specifically for X11, regenerate locale.dir from the whitelist.
  578. define PURGE_LOCALES
  579. printf '%s\n' $(LOCALE_NOPURGE) locale-archive > $(LOCALE_WHITELIST)
  580. for dir in $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/lib/locale); \
  581. do \
  582. if [ ! -d $$dir ]; then continue; fi; \
  583. for langdir in $$dir/*; \
  584. do \
  585. if [ -e "$${langdir}" ]; \
  586. then \
  587. grep -qx "$${langdir##*/}" $(LOCALE_WHITELIST) || rm -rf $$langdir; \
  588. fi \
  589. done; \
  590. done
  591. if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \
  592. then \
  593. for lang in $(LOCALE_NOPURGE); \
  594. do \
  595. if [ -f $(TARGET_DIR)/usr/share/X11/locale/$$lang/XLC_LOCALE ]; \
  596. then \
  597. echo "$$lang/XLC_LOCALE: $$lang"; \
  598. fi \
  599. done > $(TARGET_DIR)/usr/share/X11/locale/locale.dir; \
  600. fi
  601. endef
  602. TARGET_FINALIZE_HOOKS += PURGE_LOCALES
  603. endif
  604. $(TARGETS_ROOTFS): target-finalize
  605. # Avoid the rootfs name leaking down the dependency chain
  606. target-finalize: ROOTFS=
  607. TARGET_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list.txt))
  608. HOST_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list-host.txt))
  609. STAGING_DIR_FILES_LISTS = $(sort $(wildcard $(BUILD_DIR)/*/.files-list-staging.txt))
  610. .PHONY: host-finalize
  611. host-finalize: $(PACKAGES) $(HOST_DIR) $(HOST_DIR_SYMLINK)
  612. @$(call MESSAGE,"Finalizing host directory")
  613. $(call per-package-rsync,$(sort $(PACKAGES)),host,$(HOST_DIR),copy)
  614. $(Q)PARALLEL_JOBS=$(PARALLEL_JOBS) \
  615. PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) \
  616. $(TOPDIR)/support/scripts/fix-rpath host
  617. $(Q)PARALLEL_JOBS=$(PARALLEL_JOBS) \
  618. PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) \
  619. $(TOPDIR)/support/scripts/fix-rpath staging
  620. $(call ppd-fixup-paths,$(BASE_DIR))
  621. .PHONY: staging-finalize
  622. staging-finalize: $(STAGING_DIR_SYMLINK)
  623. .PHONY: target-finalize
  624. target-finalize: $(PACKAGES) $(TARGET_DIR) host-finalize
  625. @$(call MESSAGE,"Finalizing target directory")
  626. $(call per-package-rsync,$(sort $(PACKAGES)),target,$(TARGET_DIR),copy)
  627. $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
  628. rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
  629. $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
  630. $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake \
  631. $(TARGET_DIR)/usr/lib/rpm $(TARGET_DIR)/usr/doc
  632. find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
  633. find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \
  634. \( -name '*.a' -o -name '*.la' -o -name '*.prl' \) -print0 | xargs -0 rm -f
  635. ifneq ($(BR2_PACKAGE_GDB),y)
  636. rm -rf $(TARGET_DIR)/usr/share/gdb
  637. endif
  638. ifneq ($(BR2_PACKAGE_BASH),y)
  639. rm -rf $(TARGET_DIR)/usr/share/bash-completion
  640. rm -rf $(TARGET_DIR)/etc/bash_completion.d
  641. endif
  642. ifneq ($(BR2_PACKAGE_ZSH),y)
  643. rm -rf $(TARGET_DIR)/usr/share/zsh
  644. endif
  645. rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
  646. rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
  647. rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
  648. rm -rf $(TARGET_DIR)/usr/share/gtk-doc
  649. rmdir $(TARGET_DIR)/usr/share 2>/dev/null || true
  650. ifneq ($(BR2_ENABLE_DEBUG):$(BR2_STRIP_strip),y:)
  651. rm -rf $(TARGET_DIR)/lib/debug $(TARGET_DIR)/usr/lib/debug
  652. endif
  653. $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
  654. $(STRIP_FIND_SPECIAL_LIBS_CMD) | xargs -0 -r $(STRIPCMD) $(STRIP_STRIP_DEBUG) 2>/dev/null || true
  655. test -f $(TARGET_DIR)/etc/ld.so.conf && \
  656. { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
  657. test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
  658. { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
  659. mkdir -p $(TARGET_DIR)/etc
  660. ( \
  661. echo "NAME=Buildroot"; \
  662. echo "VERSION=$(BR2_VERSION_FULL)"; \
  663. echo "ID=buildroot"; \
  664. echo "VERSION_ID=$(BR2_VERSION)"; \
  665. echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
  666. ) > $(TARGET_DIR)/usr/lib/os-release
  667. ln -sf ../usr/lib/os-release $(TARGET_DIR)/etc
  668. @$(call MESSAGE,"Sanitizing RPATH in target tree")
  669. PARALLEL_JOBS=$(PARALLEL_JOBS) \
  670. PER_PACKAGE_DIR=$(PER_PACKAGE_DIR) \
  671. $(TOPDIR)/support/scripts/fix-rpath target
  672. # For a merged /usr, ensure that /lib, /bin and /sbin and their /usr
  673. # counterparts are appropriately setup as symlinks ones to the others.
  674. ifeq ($(BR2_ROOTFS_MERGED_USR),y)
  675. $(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
  676. @$(call MESSAGE,"Sanity check in overlay $(d)")$(sep) \
  677. $(Q)not_merged_dirs="$$(support/scripts/check-merged-usr.sh $(d))"; \
  678. test -n "$$not_merged_dirs" && { \
  679. echo "ERROR: The overlay in $(d) is not" \
  680. "using a merged /usr for the following directories:" \
  681. $$not_merged_dirs; \
  682. exit 1; \
  683. } || true$(sep))
  684. endif # merged /usr
  685. $(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
  686. @$(call MESSAGE,"Copying overlay $(d)")$(sep) \
  687. $(Q)$(call SYSTEM_RSYNC,$(d),$(TARGET_DIR))$(sep))
  688. $(Q)$(if $(TARGET_DIR_FILES_LISTS), \
  689. cat $(TARGET_DIR_FILES_LISTS)) > $(BUILD_DIR)/packages-file-list.txt
  690. $(Q)$(if $(HOST_DIR_FILES_LISTS), \
  691. cat $(HOST_DIR_FILES_LISTS)) > $(BUILD_DIR)/packages-file-list-host.txt
  692. $(Q)$(if $(STAGING_DIR_FILES_LISTS), \
  693. cat $(STAGING_DIR_FILES_LISTS)) > $(BUILD_DIR)/packages-file-list-staging.txt
  694. $(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
  695. @$(call MESSAGE,"Executing post-build script $(s)")$(sep) \
  696. $(Q)$(EXTRA_ENV) $(s) \
  697. $(TARGET_DIR) \
  698. $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)) \
  699. $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT_ARGS))$(sep))
  700. touch $(TARGET_DIR)/usr
  701. # Note: this will run in the filesystem context, so will use a copy
  702. # of target/, not the real one, so the files are still available on
  703. # re-builds (foo-rebuild, etc...)
  704. define ROOTFS_RM_HWDB_DATA
  705. rm -rf $(TARGET_DIR)/usr/lib/udev/hwdb.d/ $(TARGET_DIR)/etc/udev/hwdb.d/
  706. endef
  707. ROOTFS_PRE_CMD_HOOKS += ROOTFS_RM_HWDB_DATA
  708. .PHONY: target-post-image
  709. target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize
  710. @rm -f $(ROOTFS_COMMON_TAR)
  711. $(Q)mkdir -p $(BINARIES_DIR)
  712. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
  713. $(call MESSAGE,"Executing post-image script $(s)"); \
  714. $(EXTRA_ENV) $(s) \
  715. $(BINARIES_DIR) \
  716. $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS)) \
  717. $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT_ARGS))$(sep))
  718. .PHONY: source
  719. source: $(foreach p,$(PACKAGES),$(p)-all-source)
  720. .PHONY: _external-deps external-deps
  721. _external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
  722. external-deps:
  723. @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
  724. .PHONY: legal-info-clean
  725. legal-info-clean:
  726. @rm -fr $(LEGAL_INFO_DIR)
  727. .PHONY: legal-info-prepare
  728. legal-info-prepare: $(LEGAL_INFO_DIR)
  729. @$(call MESSAGE,"Buildroot $(BR2_VERSION_FULL) Collecting legal info")
  730. @$(call legal-license-file,HOST,buildroot,buildroot,COPYING,COPYING,support/legal-info/buildroot.hash)
  731. @$(call legal-manifest,TARGET,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,DEPENDENCIES WITH LICENSES)
  732. @$(call legal-manifest,HOST,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,DEPENDENCIES WITH LICENSES)
  733. @$(call legal-manifest,HOST,buildroot,$(BR2_VERSION_FULL),GPL-2.0+,COPYING,not saved,not saved)
  734. @$(call legal-warning,the Buildroot source code has not been saved)
  735. @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
  736. .PHONY: legal-info
  737. legal-info: legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
  738. $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
  739. @cat support/legal-info/README.header >>$(LEGAL_REPORT)
  740. @if [ -r $(LEGAL_WARNINGS) ]; then \
  741. cat support/legal-info/README.warnings-header \
  742. $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
  743. cat $(LEGAL_WARNINGS); fi
  744. @rm -f $(LEGAL_WARNINGS)
  745. @(cd $(LEGAL_INFO_DIR); \
  746. find * -type f -exec sha256sum {} + | LC_ALL=C sort -k2 \
  747. >.legal-info.sha256; \
  748. mv .legal-info.sha256 legal-info.sha256)
  749. @echo "Legal info produced in $(LEGAL_INFO_DIR)"
  750. .PHONY: show-targets
  751. show-targets:
  752. @echo $(sort $(PACKAGES)) $(sort $(TARGETS_ROOTFS))
  753. .PHONY: show-build-order
  754. show-build-order: $(patsubst %,%-show-build-order,$(PACKAGES))
  755. .PHONY: graph-build
  756. graph-build: $(O)/build/build-time.log
  757. @install -d $(GRAPHS_DIR)
  758. $(foreach o,name build duration,./support/scripts/graph-build-time \
  759. --type=histogram --order=$(o) --input=$(<) \
  760. --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
  761. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  762. $(foreach t,packages steps,./support/scripts/graph-build-time \
  763. --type=pie-$(t) --input=$(<) \
  764. --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
  765. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  766. ./support/scripts/graph-build-time --type=timeline --input=$(<) \
  767. --output=$(GRAPHS_DIR)/build.timeline.$(BR_GRAPH_OUT) \
  768. $(if $(BR2_GRAPH_ALT),--alternate-colors)
  769. .PHONY: graph-depends-requirements
  770. graph-depends-requirements:
  771. @dot -? >/dev/null 2>&1 || \
  772. { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
  773. .PHONY: graph-depends
  774. graph-depends: graph-depends-requirements
  775. @$(INSTALL) -d $(GRAPHS_DIR)
  776. @cd "$(CONFIG_DIR)"; \
  777. $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
  778. --direct -o $(GRAPHS_DIR)/$(@).dot
  779. dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \
  780. -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \
  781. $(GRAPHS_DIR)/$(@).dot
  782. .PHONY: graph-size
  783. graph-size:
  784. $(Q)mkdir -p $(GRAPHS_DIR)
  785. $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
  786. --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
  787. --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
  788. --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv \
  789. $(BR2_GRAPH_SIZE_OPTS)
  790. .PHONY: check-dependencies
  791. check-dependencies:
  792. @cd "$(CONFIG_DIR)"; \
  793. $(TOPDIR)/support/scripts/graph-depends -C
  794. .PHONY: show-info
  795. show-info:
  796. @:
  797. $(info $(call clean-json, \
  798. { $(foreach p, \
  799. $(sort $(foreach i,$(PACKAGES) $(TARGETS_ROOTFS), \
  800. $(i) \
  801. $($(call UPPERCASE,$(i))_FINAL_RECURSIVE_DEPENDENCIES) \
  802. ) \
  803. ), \
  804. $(call json-info,$(call UPPERCASE,$(p)))$(comma) \
  805. ) } \
  806. ) \
  807. )
  808. .PHONY: pkg-stats
  809. pkg-stats:
  810. @cd "$(CONFIG_DIR)" ; \
  811. $(TOPDIR)/support/scripts/pkg-stats -c \
  812. --json $(O)/pkg-stats.json \
  813. --html $(O)/pkg-stats.html \
  814. --nvd-path $(DL_DIR)/buildroot-nvd
  815. else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  816. # Some subdirectories are also package names. To avoid that "make linux"
  817. # on an unconfigured tree produces "Nothing to be done", add an explicit
  818. # rule for it.
  819. # Also for 'all' we error out and ask the user to configure first.
  820. .PHONY: linux toolchain
  821. linux toolchain all: outputmakefile
  822. $(error Please configure Buildroot first (e.g. "make menuconfig"))
  823. @exit 1
  824. endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  825. # configuration
  826. # ---------------------------------------------------------------------------
  827. HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
  828. export HOSTCFLAGS
  829. $(BUILD_DIR)/buildroot-config/%onf:
  830. mkdir -p $(@D)/lxdialog
  831. PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
  832. obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
  833. DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
  834. # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
  835. # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
  836. COMMON_CONFIG_ENV = \
  837. BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
  838. KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
  839. KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
  840. KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
  841. BR2_CONFIG=$(BR2_CONFIG) \
  842. HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
  843. BASE_DIR=$(BASE_DIR) \
  844. SKIP_LEGACY=
  845. xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
  846. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  847. gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile
  848. @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
  849. menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
  850. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  851. nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile
  852. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  853. config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  854. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  855. # For the config targets that automatically select options, we pass
  856. # SKIP_LEGACY=y to disable the legacy options. However, in that case
  857. # no values are set for the legacy options so a subsequent oldconfig
  858. # will query them. Therefore, run an additional olddefconfig.
  859. randconfig allyesconfig alldefconfig allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  860. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --$@ $(CONFIG_CONFIG_IN)
  861. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  862. randpackageconfig allyespackageconfig allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  863. @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
  864. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
  865. KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
  866. $< --$(subst package,,$@) $(CONFIG_CONFIG_IN)
  867. @rm -f $(CONFIG_DIR)/.config.nopkg
  868. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  869. oldconfig syncconfig olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  870. @$(COMMON_CONFIG_ENV) $< --$@ $(CONFIG_CONFIG_IN)
  871. defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  872. @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
  873. %_defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  874. @defconfig=$(or \
  875. $(firstword \
  876. $(foreach d, \
  877. $(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)), \
  878. $(wildcard $(d)/configs/$@) \
  879. ) \
  880. ), \
  881. $(error "Can't find $@") \
  882. ); \
  883. $(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$${defconfig} \
  884. $< --defconfig=$${defconfig} $(CONFIG_CONFIG_IN)
  885. update-defconfig: savedefconfig
  886. savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
  887. @$(COMMON_CONFIG_ENV) $< \
  888. --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
  889. $(CONFIG_CONFIG_IN)
  890. @$(SED) '/^BR2_DEFCONFIG=/d' $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig)
  891. .PHONY: defconfig savedefconfig update-defconfig
  892. ################################################################################
  893. #
  894. # Cleanup and misc junk
  895. #
  896. ################################################################################
  897. # staging and target directories do NOT list these as
  898. # dependencies anywhere else
  899. $(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):
  900. @mkdir -p $@
  901. # outputmakefile generates a Makefile in the output directory, if using a
  902. # separate output directory. This allows convenient use of make in the
  903. # output directory.
  904. .PHONY: outputmakefile
  905. outputmakefile:
  906. ifeq ($(NEED_WRAPPER),y)
  907. $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
  908. endif
  909. # printvars prints all the variables currently defined in our
  910. # Makefiles. Alternatively, if a non-empty VARS variable is passed,
  911. # only the variables matching the make pattern passed in VARS are
  912. # displayed.
  913. # show-vars does the same, but as a JSON dictionnary.
  914. #
  915. # Note: we iterate of .VARIABLES and filter each variable individually,
  916. # to workaround a bug in make 4.3; see https://savannah.gnu.org/bugs/?59093
  917. .PHONY: printvars
  918. printvars:
  919. ifndef VARS
  920. $(error Please pass a non-empty VARS to 'make printvars')
  921. endif
  922. @:
  923. $(foreach V, \
  924. $(sort $(foreach X, $(.VARIABLES), $(filter $(VARS),$(X)))), \
  925. $(if $(filter-out environment% default automatic, \
  926. $(origin $V)), \
  927. $(if $(QUOTED_VARS),\
  928. $(info $V='$(subst ','\'',$(if $(RAW_VARS),$(value $V),$($V)))'), \
  929. $(info $V=$(if $(RAW_VARS),$(value $V),$($V))))))
  930. # ')))) # Syntax colouring...
  931. # See details above, same as for printvars
  932. .PHONY: show-vars
  933. show-vars: VARS?=%
  934. show-vars:
  935. @:
  936. $(foreach i, \
  937. $(call clean-json, { \
  938. $(foreach V, \
  939. $(.VARIABLES), \
  940. $(and $(filter $(VARS),$(V)) \
  941. , \
  942. $(filter-out environment% default automatic, $(origin $V)) \
  943. , \
  944. "$V": { \
  945. "expanded": $(call mk-json-str,$($V))$(comma) \
  946. "raw": $(call mk-json-str,$(value $V)) \
  947. }$(comma) \
  948. ) \
  949. ) \
  950. } ) \
  951. , \
  952. $(info $(i)) \
  953. )
  954. .PHONY: clean
  955. clean:
  956. rm -rf $(BASE_TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) $(HOST_DIR_SYMLINK) \
  957. $(BUILD_DIR) $(BASE_DIR)/staging \
  958. $(LEGAL_INFO_DIR) $(GRAPHS_DIR) $(PER_PACKAGE_DIR) $(O)/pkg-stats.*
  959. .PHONY: distclean
  960. distclean: clean
  961. ifeq ($(O),$(CURDIR)/output)
  962. rm -rf $(O)
  963. endif
  964. rm -rf $(TOPDIR)/dl $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
  965. $(CONFIG_DIR)/.auto.deps $(BASE_DIR)/.br2-external.*
  966. .PHONY: help
  967. help:
  968. @echo 'Cleaning:'
  969. @echo ' clean - delete all files created by build'
  970. @echo ' distclean - delete all non-source files (including .config)'
  971. @echo
  972. @echo 'Build:'
  973. @echo ' all - make world'
  974. @echo ' toolchain - build toolchain'
  975. @echo ' sdk - build relocatable SDK'
  976. @echo
  977. @echo 'Configuration:'
  978. @echo ' menuconfig - interactive curses-based configurator'
  979. @echo ' nconfig - interactive ncurses-based configurator'
  980. @echo ' xconfig - interactive Qt-based configurator'
  981. @echo ' gconfig - interactive GTK-based configurator'
  982. @echo ' oldconfig - resolve any unresolved symbols in .config'
  983. @echo ' syncconfig - Same as oldconfig, but quietly, additionally update deps'
  984. @echo ' olddefconfig - Same as syncconfig but sets new symbols to their default value'
  985. @echo ' randconfig - New config with random answer to all options'
  986. @echo ' defconfig - New config with default answer to all options;'
  987. @echo ' BR2_DEFCONFIG, if set on the command line, is used as input'
  988. @echo ' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
  989. @echo ' update-defconfig - Same as savedefconfig'
  990. @echo ' allyesconfig - New config where all options are accepted with yes'
  991. @echo ' allnoconfig - New config where all options are answered with no'
  992. @echo ' alldefconfig - New config where all options are set to default'
  993. @echo ' randpackageconfig - New config with random answer to package options'
  994. @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
  995. @echo ' allnopackageconfig - New config where package options are answered with no'
  996. @echo
  997. @echo 'Package-specific:'
  998. @echo ' <pkg> - Build and install <pkg> and all its dependencies'
  999. @echo ' <pkg>-source - Only download the source files for <pkg>'
  1000. @echo ' <pkg>-extract - Extract <pkg> sources'
  1001. @echo ' <pkg>-patch - Apply patches to <pkg>'
  1002. @echo ' <pkg>-depends - Build <pkg>'\''s dependencies'
  1003. @echo ' <pkg>-configure - Build <pkg> up to the configure step'
  1004. @echo ' <pkg>-build - Build <pkg> up to the build step'
  1005. @echo ' <pkg>-show-info - generate info about <pkg>, as a JSON blurb'
  1006. @echo ' <pkg>-show-depends - List packages on which <pkg> depends'
  1007. @echo ' <pkg>-show-rdepends - List packages which have <pkg> as a dependency'
  1008. @echo ' <pkg>-show-recursive-depends'
  1009. @echo ' - Recursively list packages on which <pkg> depends'
  1010. @echo ' <pkg>-show-recursive-rdepends'
  1011. @echo ' - Recursively list packages which have <pkg> as a dependency'
  1012. @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
  1013. @echo ' <pkg>-graph-rdepends - Generate a graph of <pkg>'\''s reverse dependencies'
  1014. @echo ' <pkg>-graph-both-depends'
  1015. @echo ' - Generate a graph of both <pkg>'\''s forward and'
  1016. @echo ' reverse dependencies.'
  1017. @echo ' <pkg>-dirclean - Remove <pkg> build directory'
  1018. @echo ' <pkg>-reconfigure - Restart the build from the configure step'
  1019. @echo ' <pkg>-rebuild - Restart the build from the build step'
  1020. @echo ' <pkg>-reinstall - Restart the build from the install step'
  1021. $(foreach p,$(HELP_PACKAGES), \
  1022. @echo $(sep) \
  1023. @echo '$($(p)_NAME):' $(sep) \
  1024. $($(p)_HELP_CMDS)$(sep))
  1025. @echo
  1026. @echo 'Documentation:'
  1027. @echo ' manual - build manual in all formats'
  1028. @echo ' manual-html - build manual in HTML'
  1029. @echo ' manual-split-html - build manual in split HTML'
  1030. @echo ' manual-pdf - build manual in PDF'
  1031. @echo ' manual-text - build manual in text'
  1032. @echo ' manual-epub - build manual in ePub'
  1033. @echo ' graph-build - generate graphs of the build times'
  1034. @echo ' graph-depends - generate graph of the dependency tree'
  1035. @echo ' graph-size - generate stats of the filesystem size'
  1036. @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
  1037. @echo
  1038. @echo 'Miscellaneous:'
  1039. @echo ' source - download all sources needed for offline-build'
  1040. @echo ' external-deps - list external packages used'
  1041. @echo ' legal-info - generate info about license compliance'
  1042. @echo ' show-info - generate info about packages, as a JSON blurb'
  1043. @echo ' pkg-stats - generate info about packages as JSON and HTML'
  1044. @echo ' printvars - dump internal variables selected with VARS=...'
  1045. @echo ' show-vars - dump all internal variables as a JSON blurb; use VARS=...'
  1046. @echo ' to limit the list to variables names matching that pattern'
  1047. @echo
  1048. @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
  1049. @echo ' make O=dir - Locate all output files in "dir", including .config'
  1050. @echo
  1051. @echo 'For further details, see README, generate the Buildroot manual, or consult'
  1052. @echo 'it on-line at http://buildroot.org/docs.html'
  1053. @echo
  1054. # List the defconfig files
  1055. # $(1): base directory
  1056. # $(2): br2-external name, empty for bundled
  1057. define list-defconfigs
  1058. @first=true; \
  1059. for defconfig in $(1)/configs/*_defconfig; do \
  1060. [ -f "$${defconfig}" ] || continue; \
  1061. if $${first}; then \
  1062. if [ "$(2)" ]; then \
  1063. printf 'External configs in "$(call qstrip,$(2))":\n'; \
  1064. else \
  1065. printf "Built-in configs:\n"; \
  1066. fi; \
  1067. first=false; \
  1068. fi; \
  1069. defconfig="$${defconfig##*/}"; \
  1070. printf " %-35s - Build for %s\n" "$${defconfig}" "$${defconfig%_defconfig}"; \
  1071. done; \
  1072. $${first} || printf "\n"
  1073. endef
  1074. # We iterate over BR2_EXTERNAL_NAMES rather than BR2_EXTERNAL_DIRS,
  1075. # because we want to display the name of the br2-external tree.
  1076. .PHONY: list-defconfigs
  1077. list-defconfigs:
  1078. $(call list-defconfigs,$(TOPDIR))
  1079. $(foreach name,$(BR2_EXTERNAL_NAMES),\
  1080. $(call list-defconfigs,$(BR2_EXTERNAL_$(name)_PATH),\
  1081. $(BR2_EXTERNAL_$(name)_DESC))$(sep))
  1082. release: OUT = buildroot-$(BR2_VERSION)
  1083. # Create release tarballs. We need to fiddle a bit to add the generated
  1084. # documentation to the git output
  1085. release:
  1086. git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
  1087. $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
  1088. $(MAKE) O=$(OUT) distclean
  1089. tar rf $(OUT).tar $(OUT)
  1090. gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
  1091. xz -9 -c < $(OUT).tar > $(OUT).tar.xz
  1092. rm -rf $(OUT) $(OUT).tar
  1093. print-version:
  1094. @echo $(BR2_VERSION_FULL)
  1095. check-package:
  1096. $(Q)./utils/check-package `git ls-tree -r --name-only HEAD` \
  1097. --ignore-list=$(TOPDIR)/.checkpackageignore
  1098. .PHONY: .checkpackageignore
  1099. .checkpackageignore:
  1100. $(Q)./utils/check-package --failed-only `git ls-tree -r --name-only HEAD` \
  1101. > .checkpackageignore
  1102. include docs/manual/manual.mk
  1103. -include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(sort $(wildcard $(dir)/docs/*/*.mk)))
  1104. .PHONY: $(noconfig_targets)
  1105. # .WAIT was introduced in make 4.4. For older make, define it as phony.
  1106. .PHONY: .WAIT
  1107. endif #umask / $(CURDIR) / $(O)