Makefile 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132
  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-2018 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.05-git
  76. # Actual time the release is cut (for reproducible builds)
  77. BR2_VERSION_EPOCH = 1520198000
  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 \
  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. ifeq ($(BR2_NEEDS_HOST_UTF8_LOCALE),y)
  319. # First, we try to use the user's configured locale (as that's the
  320. # language they'd expect messages to be displayed), then we favour
  321. # a non language-specific locale like C.UTF-8 if one is available,
  322. # so we sort with the C locale to get it at the top.
  323. # This is guaranteed to not be empty, because of the check in
  324. # support/dependencies/dependencies.sh
  325. HOST_UTF8_LOCALE := $(shell \
  326. ( echo $${LC_ALL:-$${LC_MESSAGES:-$${LANG}}}; \
  327. locale -a 2>/dev/null | LC_ALL=C sort \
  328. ) \
  329. | grep -i -E 'utf-?8$$' \
  330. | head -n 1)
  331. HOST_UTF8_LOCALE_ENV := LC_ALL=$(HOST_UTF8_LOCALE)
  332. endif
  333. # Make sure pkg-config doesn't look outside the buildroot tree
  334. HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
  335. unexport PKG_CONFIG_PATH
  336. unexport PKG_CONFIG_SYSROOT_DIR
  337. unexport PKG_CONFIG_LIBDIR
  338. # Having DESTDIR set in the environment confuses the installation
  339. # steps of some packages.
  340. unexport DESTDIR
  341. # Causes breakage with packages that needs host-ruby
  342. unexport RUBYOPT
  343. include package/pkg-utils.mk
  344. include package/doc-asciidoc.mk
  345. ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  346. ################################################################################
  347. #
  348. # Hide troublesome environment variables from sub processes
  349. #
  350. ################################################################################
  351. unexport CROSS_COMPILE
  352. unexport ARCH
  353. unexport CC
  354. unexport LD
  355. unexport AR
  356. unexport CXX
  357. unexport CPP
  358. unexport RANLIB
  359. unexport CFLAGS
  360. unexport CXXFLAGS
  361. unexport GREP_OPTIONS
  362. unexport TAR_OPTIONS
  363. unexport CONFIG_SITE
  364. unexport QMAKESPEC
  365. unexport TERMINFO
  366. unexport MACHINE
  367. unexport O
  368. unexport GCC_COLORS
  369. 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/bfin/blackfin/ \
  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/sh.*/sh/ \
  388. -e s/microblazeel/microblaze/)
  389. ZCAT := $(call qstrip,$(BR2_ZCAT))
  390. BZCAT := $(call qstrip,$(BR2_BZCAT))
  391. XZCAT := $(call qstrip,$(BR2_XZCAT))
  392. LZCAT := $(call qstrip,$(BR2_LZCAT))
  393. TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
  394. # packages compiled for the host go here
  395. HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
  396. # Quotes are needed for spaces and all in the original PATH content.
  397. BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(PATH)"
  398. # Location of a file giving a big fat warning that output/target
  399. # should not be used as the root filesystem.
  400. TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
  401. ifeq ($(BR2_CCACHE),y)
  402. CCACHE := $(HOST_DIR)/bin/ccache
  403. BR_CACHE_DIR ?= $(call qstrip,$(BR2_CCACHE_DIR))
  404. export BR_CACHE_DIR
  405. HOSTCC := $(CCACHE) $(HOSTCC)
  406. HOSTCXX := $(CCACHE) $(HOSTCXX)
  407. else
  408. export BR_NO_CCACHE
  409. endif
  410. # Scripts in support/ or post-build scripts may need to reference
  411. # these locations, so export them so it is easier to use
  412. export BR2_CONFIG
  413. export BR2_REPRODUCIBLE
  414. export TARGET_DIR
  415. export STAGING_DIR
  416. export HOST_DIR
  417. export BINARIES_DIR
  418. export BASE_DIR
  419. ################################################################################
  420. #
  421. # You should probably leave this stuff alone unless you know
  422. # what you are doing.
  423. #
  424. ################################################################################
  425. all: world
  426. # Include legacy before the other things, because package .mk files
  427. # may rely on it.
  428. include Makefile.legacy
  429. include system/system.mk
  430. include package/Makefile.in
  431. # arch/arch.mk.* must be after package/Makefile.in because it may need to
  432. # complement variables defined therein, like BR_NO_CHECK_HASH_FOR.
  433. -include $(sort $(wildcard arch/arch.mk.*))
  434. include support/dependencies/dependencies.mk
  435. PACKAGES += $(DEPENDENCIES_HOST_PREREQ)
  436. include $(sort $(wildcard toolchain/*.mk))
  437. include $(sort $(wildcard toolchain/*/*.mk))
  438. # Include the package override file if one has been provided in the
  439. # configuration.
  440. PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
  441. ifneq ($(PACKAGE_OVERRIDE_FILE),)
  442. -include $(PACKAGE_OVERRIDE_FILE)
  443. endif
  444. include $(sort $(wildcard package/*/*.mk))
  445. include boot/common.mk
  446. include linux/linux.mk
  447. include fs/common.mk
  448. # If using a br2-external tree, the BR2_EXTERNAL_$(NAME)_PATH variables
  449. # are also present in the .config file. Since .config is included after
  450. # we defined them in the Makefile, the values for those variables are
  451. # quoted. We just include the generated Makefile fragment .br2-external.mk
  452. # a third time, which will set those variables to the un-quoted values.
  453. include $(BR2_EXTERNAL_FILE)
  454. # Nothing to include if no BR2_EXTERNAL tree in use
  455. include $(BR2_EXTERNAL_MKS)
  456. # Now we are sure we have all the packages scanned and defined. We now
  457. # check for each package in the list of enabled packages, that all its
  458. # dependencies are indeed enabled.
  459. #
  460. # Only trigger the check for default builds. If the user forces building
  461. # a package, even if not enabled in the configuration, we want to accept
  462. # it.
  463. #
  464. ifeq ($(MAKECMDGOALS),)
  465. define CHECK_ONE_DEPENDENCY
  466. ifeq ($$($(2)_TYPE),target)
  467. ifeq ($$($(2)_IS_VIRTUAL),)
  468. ifneq ($$($$($(2)_KCONFIG_VAR)),y)
  469. $$(error $$($(2)_NAME) is in the dependency chain of $$($(1)_NAME) that \
  470. has added it to its _DEPENDENCIES variable without selecting it or \
  471. depending on it from Config.in)
  472. endif
  473. endif
  474. endif
  475. endef
  476. $(foreach pkg,$(call UPPERCASE,$(PACKAGES)),\
  477. $(foreach dep,$(call UPPERCASE,$($(pkg)_FINAL_ALL_DEPENDENCIES)),\
  478. $(eval $(call CHECK_ONE_DEPENDENCY,$(pkg),$(dep))$(sep))))
  479. endif
  480. .PHONY: dirs
  481. dirs: $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
  482. $(HOST_DIR) $(HOST_DIR)/usr $(HOST_DIR)/lib $(BINARIES_DIR)
  483. $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
  484. $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
  485. .PHONY: prepare
  486. prepare: $(BUILD_DIR)/buildroot-config/auto.conf
  487. .PHONY: world
  488. world: target-post-image
  489. .PHONY: sdk
  490. sdk: world
  491. @$(call MESSAGE,"Rendering the SDK relocatable")
  492. $(TOPDIR)/support/scripts/fix-rpath host
  493. $(TOPDIR)/support/scripts/fix-rpath staging
  494. $(INSTALL) -m 755 $(TOPDIR)/support/misc/relocate-sdk.sh $(HOST_DIR)/relocate-sdk.sh
  495. echo $(HOST_DIR) > $(HOST_DIR)/share/buildroot/sdk-location
  496. # Compatibility symlink in case a post-build script still uses $(HOST_DIR)/usr
  497. $(HOST_DIR)/usr: $(HOST_DIR)
  498. @ln -snf . $@
  499. $(HOST_DIR)/lib: $(HOST_DIR)
  500. @mkdir -p $@
  501. @case $(HOSTARCH) in \
  502. (*64) ln -snf lib $(@D)/lib64;; \
  503. (*) ln -snf lib $(@D)/lib32;; \
  504. esac
  505. # Populating the staging with the base directories is handled by the skeleton package
  506. $(STAGING_DIR):
  507. @mkdir -p $(STAGING_DIR)
  508. @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
  509. RSYNC_VCS_EXCLUSIONS = \
  510. --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
  511. --exclude CVS
  512. STRIP_FIND_CMD = find $(TARGET_DIR)
  513. ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
  514. STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
  515. endif
  516. STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
  517. # file exclusions:
  518. # - libpthread.so: a non-stripped libpthread shared library is needed for
  519. # proper debugging of pthread programs using gdb.
  520. # - ld.so: a non-stripped dynamic linker library is needed for valgrind
  521. # - kernel modules (*.ko): do not function properly when stripped like normal
  522. # applications and libraries. Normally kernel modules are already excluded
  523. # by the executable permission check above, so the explicit exclusion is only
  524. # done for kernel modules with incorrect permissions.
  525. STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print0
  526. ifeq ($(BR2_ECLIPSE_REGISTER),y)
  527. define TOOLCHAIN_ECLIPSE_REGISTER
  528. ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \
  529. $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
  530. endef
  531. TARGET_FINALIZE_HOOKS += TOOLCHAIN_ECLIPSE_REGISTER
  532. endif
  533. # Generate locale data. Basically, we call the localedef program
  534. # (built by the host-localedef package) for each locale. The input
  535. # data comes preferably from the toolchain, or if the toolchain does
  536. # not have them (Linaro toolchains), we use the ones available on the
  537. # host machine.
  538. ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
  539. GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
  540. ifneq ($(GLIBC_GENERATE_LOCALES),)
  541. PACKAGES += host-localedef
  542. define GENERATE_GLIBC_LOCALES
  543. $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
  544. $(Q)for locale in $(GLIBC_GENERATE_LOCALES) ; do \
  545. inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
  546. charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
  547. if test -z "$${charmap}" ; then \
  548. charmap="UTF-8" ; \
  549. fi ; \
  550. echo "Generating locale $${inputfile}.$${charmap}" ; \
  551. I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
  552. $(HOST_DIR)/bin/localedef \
  553. --prefix=$(TARGET_DIR) \
  554. --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
  555. -i $${inputfile} -f $${charmap} \
  556. $${locale} ; \
  557. done
  558. endef
  559. TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
  560. endif
  561. endif
  562. ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
  563. LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
  564. LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
  565. # This piece of junk does the following:
  566. # First collect the whitelist in a file.
  567. # Then go over all the locale dirs and for each subdir, check if it exists
  568. # in the whitelist file. If it doesn't, kill it.
  569. # Finally, specifically for X11, regenerate locale.dir from the whitelist.
  570. define PURGE_LOCALES
  571. rm -f $(LOCALE_WHITELIST)
  572. for i in $(LOCALE_NOPURGE) locale-archive; do echo $$i >> $(LOCALE_WHITELIST); done
  573. for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/lib/locale)); \
  574. do \
  575. for langdir in $$dir/*; \
  576. do \
  577. if [ -e "$${langdir}" ]; \
  578. then \
  579. grep -qx "$${langdir##*/}" $(LOCALE_WHITELIST) || rm -rf $$langdir; \
  580. fi \
  581. done; \
  582. done
  583. if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \
  584. then \
  585. for lang in $(LOCALE_NOPURGE); \
  586. do \
  587. if [ -f $(TARGET_DIR)/usr/share/X11/locale/$$lang/XLC_LOCALE ]; \
  588. then \
  589. echo "$$lang/XLC_LOCALE: $$lang"; \
  590. fi \
  591. done > $(TARGET_DIR)/usr/share/X11/locale/locale.dir; \
  592. fi
  593. endef
  594. TARGET_FINALIZE_HOOKS += PURGE_LOCALES
  595. endif
  596. $(TARGETS_ROOTFS): target-finalize
  597. .PHONY: target-finalize
  598. target-finalize: $(PACKAGES)
  599. @$(call MESSAGE,"Finalizing target directory")
  600. # Check files that are touched by more than one package
  601. ./support/scripts/check-uniq-files -t target $(BUILD_DIR)/packages-file-list.txt
  602. ./support/scripts/check-uniq-files -t staging $(BUILD_DIR)/packages-file-list-staging.txt
  603. ./support/scripts/check-uniq-files -t host $(BUILD_DIR)/packages-file-list-host.txt
  604. $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
  605. rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
  606. $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
  607. $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
  608. find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
  609. find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \
  610. \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
  611. ifneq ($(BR2_PACKAGE_GDB),y)
  612. rm -rf $(TARGET_DIR)/usr/share/gdb
  613. endif
  614. ifneq ($(BR2_PACKAGE_BASH),y)
  615. rm -rf $(TARGET_DIR)/usr/share/bash-completion
  616. endif
  617. ifneq ($(BR2_PACKAGE_ZSH),y)
  618. rm -rf $(TARGET_DIR)/usr/share/zsh
  619. endif
  620. rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
  621. rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
  622. rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
  623. rm -rf $(TARGET_DIR)/usr/share/gtk-doc
  624. rmdir $(TARGET_DIR)/usr/share 2>/dev/null || true
  625. $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
  626. # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
  627. # besides the one in which crash occurred; or SIGTRAP kills my program when
  628. # I set a breakpoint"
  629. ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
  630. find $(TARGET_DIR)/lib/ -type f -name 'libpthread*.so*' | \
  631. xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
  632. endif
  633. # Valgrind needs ld.so with enough information, so only strip
  634. # debugging symbols.
  635. find $(TARGET_DIR)/lib/ -type f -name 'ld-*.so*' | \
  636. xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
  637. test -f $(TARGET_DIR)/etc/ld.so.conf && \
  638. { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
  639. test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
  640. { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
  641. mkdir -p $(TARGET_DIR)/etc
  642. ( \
  643. echo "NAME=Buildroot"; \
  644. echo "VERSION=$(BR2_VERSION_FULL)"; \
  645. echo "ID=buildroot"; \
  646. echo "VERSION_ID=$(BR2_VERSION)"; \
  647. echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
  648. ) > $(TARGET_DIR)/usr/lib/os-release
  649. ln -sf ../usr/lib/os-release $(TARGET_DIR)/etc
  650. @$(call MESSAGE,"Sanitizing RPATH in target tree")
  651. $(TOPDIR)/support/scripts/fix-rpath target
  652. @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
  653. $(call MESSAGE,"Copying overlay $(d)"); \
  654. rsync -a --ignore-times --keep-dirlinks $(RSYNC_VCS_EXCLUSIONS) \
  655. --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
  656. $(d)/ $(TARGET_DIR)$(sep))
  657. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
  658. $(call MESSAGE,"Executing post-build script $(s)"); \
  659. $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
  660. .PHONY: target-post-image
  661. target-post-image: $(TARGETS_ROOTFS) target-finalize
  662. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
  663. $(call MESSAGE,"Executing post-image script $(s)"); \
  664. $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
  665. .PHONY: source
  666. source: $(foreach p,$(PACKAGES),$(p)-all-source)
  667. .PHONY: _external-deps external-deps
  668. _external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
  669. external-deps:
  670. @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
  671. .PHONY: legal-info-clean
  672. legal-info-clean:
  673. @rm -fr $(LEGAL_INFO_DIR)
  674. .PHONY: legal-info-prepare
  675. legal-info-prepare: $(LEGAL_INFO_DIR)
  676. @$(call MESSAGE,"Buildroot $(BR2_VERSION_FULL) Collecting legal info")
  677. @$(call legal-license-file,buildroot,buildroot,support/legal-info,COPYING,COPYING,HOST)
  678. @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
  679. @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
  680. @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPL-2.0+,COPYING,not saved,not saved,HOST)
  681. @$(call legal-warning,the Buildroot source code has not been saved)
  682. @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
  683. .PHONY: legal-info
  684. legal-info: dirs legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
  685. $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
  686. @cat support/legal-info/README.header >>$(LEGAL_REPORT)
  687. @if [ -r $(LEGAL_WARNINGS) ]; then \
  688. cat support/legal-info/README.warnings-header \
  689. $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
  690. cat $(LEGAL_WARNINGS); fi
  691. @rm -f $(LEGAL_WARNINGS)
  692. @(cd $(LEGAL_INFO_DIR); \
  693. find * -type f -exec sha256sum {} + | LC_ALL=C sort -k2 \
  694. >.legal-info.sha256; \
  695. mv .legal-info.sha256 legal-info.sha256)
  696. @echo "Legal info produced in $(LEGAL_INFO_DIR)"
  697. .PHONY: show-targets
  698. show-targets:
  699. @echo $(sort $(PACKAGES)) $(sort $(TARGETS_ROOTFS))
  700. .PHONY: show-build-order
  701. show-build-order: $(patsubst %,%-show-build-order,$(PACKAGES))
  702. .PHONY: graph-build
  703. graph-build: $(O)/build/build-time.log
  704. @install -d $(GRAPHS_DIR)
  705. $(foreach o,name build duration,./support/scripts/graph-build-time \
  706. --type=histogram --order=$(o) --input=$(<) \
  707. --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
  708. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  709. $(foreach t,packages steps,./support/scripts/graph-build-time \
  710. --type=pie-$(t) --input=$(<) \
  711. --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
  712. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  713. .PHONY: graph-depends-requirements
  714. graph-depends-requirements:
  715. @dot -? >/dev/null 2>&1 || \
  716. { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
  717. .PHONY: graph-depends
  718. graph-depends: graph-depends-requirements
  719. @$(INSTALL) -d $(GRAPHS_DIR)
  720. @cd "$(CONFIG_DIR)"; \
  721. $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
  722. --direct -o $(GRAPHS_DIR)/$(@).dot
  723. dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \
  724. -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \
  725. $(GRAPHS_DIR)/$(@).dot
  726. .PHONY: graph-size
  727. graph-size:
  728. $(Q)mkdir -p $(GRAPHS_DIR)
  729. $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
  730. --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
  731. --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
  732. --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv
  733. .PHONY: check-dependencies
  734. check-dependencies:
  735. @cd "$(CONFIG_DIR)"; \
  736. $(TOPDIR)/support/scripts/graph-depends -C
  737. else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  738. # Some subdirectories are also package names. To avoid that "make linux"
  739. # on an unconfigured tree produces "Nothing to be done", add an explicit
  740. # rule for it.
  741. # Also for 'all' we error out and ask the user to configure first.
  742. .PHONY: linux toolchain
  743. linux toolchain all: outputmakefile
  744. $(error Please configure Buildroot first (e.g. "make menuconfig"))
  745. @exit 1
  746. endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  747. # configuration
  748. # ---------------------------------------------------------------------------
  749. HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
  750. export HOSTCFLAGS
  751. .PHONY: prepare-kconfig
  752. prepare-kconfig: outputmakefile $(BUILD_DIR)/.br2-external.in
  753. $(BUILD_DIR)/buildroot-config/%onf:
  754. mkdir -p $(@D)/lxdialog
  755. PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
  756. obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
  757. DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
  758. # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
  759. # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
  760. COMMON_CONFIG_ENV = \
  761. BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
  762. KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
  763. KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
  764. KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
  765. BR2_CONFIG=$(BR2_CONFIG) \
  766. HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
  767. BUILD_DIR=$(BUILD_DIR) \
  768. SKIP_LEGACY=
  769. xconfig: $(BUILD_DIR)/buildroot-config/qconf prepare-kconfig
  770. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  771. gconfig: $(BUILD_DIR)/buildroot-config/gconf prepare-kconfig
  772. @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
  773. menuconfig: $(BUILD_DIR)/buildroot-config/mconf prepare-kconfig
  774. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  775. nconfig: $(BUILD_DIR)/buildroot-config/nconf prepare-kconfig
  776. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  777. config: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  778. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  779. # For the config targets that automatically select options, we pass
  780. # SKIP_LEGACY=y to disable the legacy options. However, in that case
  781. # no values are set for the legacy options so a subsequent oldconfig
  782. # will query them. Therefore, run an additional olddefconfig.
  783. randconfig allyesconfig alldefconfig allnoconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  784. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --$@ $(CONFIG_CONFIG_IN)
  785. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  786. randpackageconfig allyespackageconfig allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  787. @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
  788. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
  789. KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
  790. $< --$(subst package,,$@) $(CONFIG_CONFIG_IN)
  791. @rm -f $(CONFIG_DIR)/.config.nopkg
  792. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  793. oldconfig silentoldconfig olddefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  794. @$(COMMON_CONFIG_ENV) $< --$@ $(CONFIG_CONFIG_IN)
  795. defconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  796. @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
  797. define percent_defconfig
  798. # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
  799. %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig prepare-kconfig
  800. @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \
  801. $$< --defconfig=$(1)/configs/$$@ $$(CONFIG_CONFIG_IN)
  802. endef
  803. $(eval $(foreach d,$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(call percent_defconfig,$(d))$(sep)))
  804. savedefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  805. @$(COMMON_CONFIG_ENV) $< \
  806. --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
  807. $(CONFIG_CONFIG_IN)
  808. @$(SED) '/BR2_DEFCONFIG=/d' $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig)
  809. .PHONY: defconfig savedefconfig
  810. ################################################################################
  811. #
  812. # Cleanup and misc junk
  813. #
  814. ################################################################################
  815. # outputmakefile generates a Makefile in the output directory, if using a
  816. # separate output directory. This allows convenient use of make in the
  817. # output directory.
  818. .PHONY: outputmakefile
  819. outputmakefile:
  820. ifeq ($(NEED_WRAPPER),y)
  821. $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
  822. endif
  823. # Even though the target is a real file, we mark it as PHONY as we
  824. # want it to be re-generated each time make is invoked, in case the
  825. # value of BR2_EXTERNAL is changed.
  826. .PHONY: $(BUILD_DIR)/.br2-external.in
  827. $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
  828. $(Q)support/scripts/br2-external -k -o "$(@)" $(BR2_EXTERNAL)
  829. # printvars prints all the variables currently defined in our
  830. # Makefiles. Alternatively, if a non-empty VARS variable is passed,
  831. # only the variables matching the make pattern passed in VARS are
  832. # displayed.
  833. .PHONY: printvars
  834. printvars:
  835. @:$(foreach V, \
  836. $(sort $(if $(VARS),$(filter $(VARS),$(.VARIABLES)),$(.VARIABLES))), \
  837. $(if $(filter-out environment% default automatic, \
  838. $(origin $V)), \
  839. $(if $(QUOTED_VARS),\
  840. $(info $V='$(subst ','\'',$(if $(RAW_VARS),$(value $V),$($V)))'), \
  841. $(info $V=$(if $(RAW_VARS),$(value $V),$($V))))))
  842. # ' Syntax colouring...
  843. .PHONY: clean
  844. clean:
  845. rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
  846. $(BUILD_DIR) $(BASE_DIR)/staging \
  847. $(LEGAL_INFO_DIR) $(GRAPHS_DIR)
  848. .PHONY: distclean
  849. distclean: clean
  850. ifeq ($(O),$(CURDIR)/output)
  851. rm -rf $(O)
  852. endif
  853. rm -rf $(TOPDIR)/dl $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
  854. $(CONFIG_DIR)/.auto.deps $(BR2_EXTERNAL_FILE)
  855. .PHONY: help
  856. help:
  857. @echo 'Cleaning:'
  858. @echo ' clean - delete all files created by build'
  859. @echo ' distclean - delete all non-source files (including .config)'
  860. @echo
  861. @echo 'Build:'
  862. @echo ' all - make world'
  863. @echo ' toolchain - build toolchain'
  864. @echo ' sdk - build relocatable SDK'
  865. @echo
  866. @echo 'Configuration:'
  867. @echo ' menuconfig - interactive curses-based configurator'
  868. @echo ' nconfig - interactive ncurses-based configurator'
  869. @echo ' xconfig - interactive Qt-based configurator'
  870. @echo ' gconfig - interactive GTK-based configurator'
  871. @echo ' oldconfig - resolve any unresolved symbols in .config'
  872. @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
  873. @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
  874. @echo ' randconfig - New config with random answer to all options'
  875. @echo ' defconfig - New config with default answer to all options'
  876. @echo ' BR2_DEFCONFIG, if set, is used as input'
  877. @echo ' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
  878. @echo ' allyesconfig - New config where all options are accepted with yes'
  879. @echo ' allnoconfig - New config where all options are answered with no'
  880. @echo ' alldefconfig - New config where all options are set to default'
  881. @echo ' randpackageconfig - New config with random answer to package options'
  882. @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
  883. @echo ' allnopackageconfig - New config where package options are answered with no'
  884. @echo
  885. @echo 'Package-specific:'
  886. @echo ' <pkg> - Build and install <pkg> and all its dependencies'
  887. @echo ' <pkg>-source - Only download the source files for <pkg>'
  888. @echo ' <pkg>-extract - Extract <pkg> sources'
  889. @echo ' <pkg>-patch - Apply patches to <pkg>'
  890. @echo ' <pkg>-depends - Build <pkg>'\''s dependencies'
  891. @echo ' <pkg>-configure - Build <pkg> up to the configure step'
  892. @echo ' <pkg>-build - Build <pkg> up to the build step'
  893. @echo ' <pkg>-show-depends - List packages on which <pkg> depends'
  894. @echo ' <pkg>-show-rdepends - List packages which have <pkg> as a dependency'
  895. @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
  896. @echo ' <pkg>-graph-rdepends - Generate a graph of <pkg>'\''s reverse dependencies'
  897. @echo ' <pkg>-dirclean - Remove <pkg> build directory'
  898. @echo ' <pkg>-reconfigure - Restart the build from the configure step'
  899. @echo ' <pkg>-rebuild - Restart the build from the build step'
  900. $(foreach p,$(HELP_PACKAGES), \
  901. @echo $(sep) \
  902. @echo '$($(p)_NAME):' $(sep) \
  903. $($(p)_HELP_CMDS)$(sep))
  904. @echo
  905. @echo 'Documentation:'
  906. @echo ' manual - build manual in all formats'
  907. @echo ' manual-html - build manual in HTML'
  908. @echo ' manual-split-html - build manual in split HTML'
  909. @echo ' manual-pdf - build manual in PDF'
  910. @echo ' manual-text - build manual in text'
  911. @echo ' manual-epub - build manual in ePub'
  912. @echo ' graph-build - generate graphs of the build times'
  913. @echo ' graph-depends - generate graph of the dependency tree'
  914. @echo ' graph-size - generate stats of the filesystem size'
  915. @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
  916. @echo
  917. @echo 'Miscellaneous:'
  918. @echo ' source - download all sources needed for offline-build'
  919. @echo ' external-deps - list external packages used'
  920. @echo ' legal-info - generate info about license compliance'
  921. @echo ' printvars - dump all the internal variables'
  922. @echo
  923. @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
  924. @echo ' make O=dir - Locate all output files in "dir", including .config'
  925. @echo
  926. @echo 'For further details, see README, generate the Buildroot manual, or consult'
  927. @echo 'it on-line at http://buildroot.org/docs.html'
  928. @echo
  929. # List the defconfig files
  930. # $(1): base directory
  931. # $(2): br2-external name, empty for bundled
  932. define list-defconfigs
  933. @first=true; \
  934. for defconfig in $(1)/configs/*_defconfig; do \
  935. [ -f "$${defconfig}" ] || continue; \
  936. if $${first}; then \
  937. if [ "$(2)" ]; then \
  938. printf 'External configs in "$(call qstrip,$(2))":\n'; \
  939. else \
  940. printf "Built-in configs:\n"; \
  941. fi; \
  942. first=false; \
  943. fi; \
  944. defconfig="$${defconfig##*/}"; \
  945. printf " %-35s - Build for %s\n" "$${defconfig}" "$${defconfig%_defconfig}"; \
  946. done; \
  947. $${first} || printf "\n"
  948. endef
  949. # We iterate over BR2_EXTERNAL_NAMES rather than BR2_EXTERNAL_DIRS,
  950. # because we want to display the name of the br2-external tree.
  951. .PHONY: list-defconfigs
  952. list-defconfigs:
  953. $(call list-defconfigs,$(TOPDIR))
  954. $(foreach name,$(BR2_EXTERNAL_NAMES),\
  955. $(call list-defconfigs,$(BR2_EXTERNAL_$(name)_PATH),\
  956. $(BR2_EXTERNAL_$(name)_DESC))$(sep))
  957. release: OUT = buildroot-$(BR2_VERSION)
  958. # Create release tarballs. We need to fiddle a bit to add the generated
  959. # documentation to the git output
  960. release:
  961. git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
  962. $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
  963. $(MAKE) O=$(OUT) manual-clean
  964. tar rf $(OUT).tar $(OUT)
  965. gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
  966. bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
  967. rm -rf $(OUT) $(OUT).tar
  968. print-version:
  969. @echo $(BR2_VERSION_FULL)
  970. .PHONY: .gitlab-ci.yml
  971. .gitlab-ci.yml: .gitlab-ci.yml.in
  972. cp $< $@
  973. (cd configs; LC_ALL=C ls -1 *_defconfig) | sed 's/$$/: *defconfig/' >> $@
  974. ./support/testing/run-tests -l 2>&1 | sed -r -e '/^test_run \((.*)\).*/!d; s//\1: *runtime_test/' | LC_ALL=C sort >> $@
  975. include docs/manual/manual.mk
  976. -include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(sort $(wildcard $(dir)/docs/*/*.mk)))
  977. .PHONY: $(noconfig_targets)
  978. endif #umask / $(CURDIR) / $(O)