Makefile 45 KB

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