Makefile 41 KB

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