Makefile 41 KB

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