Makefile 45 KB

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