Makefile 44 KB

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