Makefile 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151
  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. # 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.08.4
  80. # Actual time the release is cut (for reproducible builds)
  81. BR2_VERSION_EPOCH = 1545299000
  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. # The target directory is common to all packages,
  190. # but there is one that is specific to each filesystem.
  191. BASE_TARGET_DIR := $(BASE_DIR)/target
  192. TARGET_DIR = $(if $(ROOTFS),$(ROOTFS_$(ROOTFS)_TARGET_DIR),$(BASE_TARGET_DIR))
  193. # initial definition so that 'make clean' works for most users, even without
  194. # .config. HOST_DIR will be overwritten later when .config is included.
  195. HOST_DIR := $(BASE_DIR)/host
  196. GRAPHS_DIR := $(BASE_DIR)/graphs
  197. LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
  198. REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
  199. REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
  200. LICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses
  201. LICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses
  202. LEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv
  203. LEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv
  204. LEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings
  205. LEGAL_REPORT = $(LEGAL_INFO_DIR)/README
  206. BR2_CONFIG = $(CONFIG_DIR)/.config
  207. # Pull in the user's configuration file
  208. ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
  209. -include $(BR2_CONFIG)
  210. endif
  211. # timezone and locale may affect build output
  212. ifeq ($(BR2_REPRODUCIBLE),y)
  213. export TZ = UTC
  214. export LANG = C
  215. export LC_ALL = C
  216. export GZIP = -n
  217. endif
  218. # To put more focus on warnings, be less verbose as default
  219. # Use 'make V=1' to see the full commands
  220. ifeq ("$(origin V)", "command line")
  221. KBUILD_VERBOSE = $(V)
  222. endif
  223. ifndef KBUILD_VERBOSE
  224. KBUILD_VERBOSE = 0
  225. endif
  226. ifeq ($(KBUILD_VERBOSE),1)
  227. Q =
  228. ifndef VERBOSE
  229. VERBOSE = 1
  230. endif
  231. export VERBOSE
  232. else
  233. Q = @
  234. endif
  235. # kconfig uses CONFIG_SHELL
  236. CONFIG_SHELL := $(SHELL)
  237. export SHELL CONFIG_SHELL Q KBUILD_VERBOSE
  238. ifndef HOSTAR
  239. HOSTAR := ar
  240. endif
  241. ifndef HOSTAS
  242. HOSTAS := as
  243. endif
  244. ifndef HOSTCC
  245. HOSTCC := gcc
  246. HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
  247. endif
  248. HOSTCC_NOCCACHE := $(HOSTCC)
  249. ifndef HOSTCXX
  250. HOSTCXX := g++
  251. HOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
  252. endif
  253. HOSTCXX_NOCCACHE := $(HOSTCXX)
  254. ifndef HOSTCPP
  255. HOSTCPP := cpp
  256. endif
  257. ifndef HOSTLD
  258. HOSTLD := ld
  259. endif
  260. ifndef HOSTLN
  261. HOSTLN := ln
  262. endif
  263. ifndef HOSTNM
  264. HOSTNM := nm
  265. endif
  266. ifndef HOSTOBJCOPY
  267. HOSTOBJCOPY := objcopy
  268. endif
  269. ifndef HOSTRANLIB
  270. HOSTRANLIB := ranlib
  271. endif
  272. HOSTAR := $(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
  273. HOSTAS := $(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
  274. HOSTCPP := $(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
  275. HOSTLD := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
  276. HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
  277. HOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
  278. HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
  279. HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
  280. SED := $(shell which sed || type -p sed) -i -e
  281. export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
  282. export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
  283. # Determine the userland we are running on.
  284. #
  285. # Note that, despite its name, we are not interested in the actual
  286. # architecture name. This is mostly used to determine whether some
  287. # of the binary tools (e.g. pre-built external toolchains) can run
  288. # on the current host. So we need to know if the userland we're
  289. # running on can actually run those toolchains.
  290. #
  291. # For example, a 64-bit prebuilt toolchain will not run on a 64-bit
  292. # kernel if the userland is 32-bit (e.g. in a chroot for example).
  293. #
  294. # So, we extract the first part of the tuple the host gcc was
  295. # configured to generate code for; we assume this is our userland.
  296. #
  297. export HOSTARCH := $(shell LC_ALL=C $(HOSTCC_NOCCACHE) -v 2>&1 | \
  298. sed -e '/^Target: \([^-]*\).*/!d' \
  299. -e 's//\1/' \
  300. -e 's/i.86/x86/' \
  301. -e 's/sun4u/sparc64/' \
  302. -e 's/arm.*/arm/' \
  303. -e 's/sa110/arm/' \
  304. -e 's/ppc64/powerpc64/' \
  305. -e 's/ppc/powerpc/' \
  306. -e 's/macppc/powerpc/' \
  307. -e 's/sh.*/sh/' )
  308. # When adding a new host gcc version in Config.in,
  309. # update the HOSTCC_MAX_VERSION variable:
  310. HOSTCC_MAX_VERSION := 8
  311. HOSTCC_VERSION := $(shell V=$$($(HOSTCC_NOCCACHE) --version | \
  312. sed -n -r 's/^.* ([0-9]*)\.([0-9]*)\.([0-9]*)[ ]*.*/\1 \2/p'); \
  313. [ "$${V%% *}" -le $(HOSTCC_MAX_VERSION) ] || V=$(HOSTCC_MAX_VERSION); \
  314. printf "%s" "$${V}")
  315. # For gcc >= 5.x, we only need the major version.
  316. ifneq ($(firstword $(HOSTCC_VERSION)),4)
  317. HOSTCC_VERSION := $(firstword $(HOSTCC_VERSION))
  318. endif
  319. ifeq ($(BR2_NEEDS_HOST_UTF8_LOCALE),y)
  320. # First, we try to use the user's configured locale (as that's the
  321. # language they'd expect messages to be displayed), then we favour
  322. # a non language-specific locale like C.UTF-8 if one is available,
  323. # so we sort with the C locale to get it at the top.
  324. # This is guaranteed to not be empty, because of the check in
  325. # support/dependencies/dependencies.sh
  326. HOST_UTF8_LOCALE := $(shell \
  327. ( echo $${LC_ALL:-$${LC_MESSAGES:-$${LANG}}}; \
  328. locale -a 2>/dev/null | LC_ALL=C sort \
  329. ) \
  330. | grep -i -E 'utf-?8$$' \
  331. | head -n 1)
  332. HOST_UTF8_LOCALE_ENV := LC_ALL=$(HOST_UTF8_LOCALE)
  333. endif
  334. # Make sure pkg-config doesn't look outside the buildroot tree
  335. HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
  336. unexport PKG_CONFIG_PATH
  337. unexport PKG_CONFIG_SYSROOT_DIR
  338. unexport PKG_CONFIG_LIBDIR
  339. # Having DESTDIR set in the environment confuses the installation
  340. # steps of some packages.
  341. unexport DESTDIR
  342. # Causes breakage with packages that needs host-ruby
  343. unexport RUBYOPT
  344. include package/pkg-utils.mk
  345. include package/doc-asciidoc.mk
  346. ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  347. ################################################################################
  348. #
  349. # Hide troublesome environment variables from sub processes
  350. #
  351. ################################################################################
  352. unexport CROSS_COMPILE
  353. unexport ARCH
  354. unexport CC
  355. unexport LD
  356. unexport AR
  357. unexport CXX
  358. unexport CPP
  359. unexport RANLIB
  360. unexport CFLAGS
  361. unexport CXXFLAGS
  362. unexport GREP_OPTIONS
  363. unexport TAR_OPTIONS
  364. unexport CONFIG_SITE
  365. unexport QMAKESPEC
  366. unexport TERMINFO
  367. unexport MACHINE
  368. unexport O
  369. unexport GCC_COLORS
  370. GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
  371. PACKAGES :=
  372. PACKAGES_ALL :=
  373. # silent mode requested?
  374. QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
  375. # Strip off the annoying quoting
  376. ARCH := $(call qstrip,$(BR2_ARCH))
  377. KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
  378. -e s/i.86/i386/ -e s/sun4u/sparc64/ \
  379. -e s/arcle/arc/ \
  380. -e s/arceb/arc/ \
  381. -e s/arm.*/arm/ -e s/sa110/arm/ \
  382. -e s/aarch64.*/arm64/ \
  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. ifneq ($(HOST_DIR),$(BASE_DIR)/host)
  397. HOST_DIR_SYMLINK = $(BASE_DIR)/host
  398. $(HOST_DIR_SYMLINK): $(BASE_DIR)
  399. ln -snf $(HOST_DIR) $(BASE_DIR)/host
  400. endif
  401. # Quotes are needed for spaces and all in the original PATH content.
  402. BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(PATH)"
  403. # Location of a file giving a big fat warning that output/target
  404. # should not be used as the root filesystem.
  405. TARGET_DIR_WARNING_FILE = $(BASE_TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
  406. ifeq ($(BR2_CCACHE),y)
  407. CCACHE := $(HOST_DIR)/bin/ccache
  408. BR_CACHE_DIR ?= $(call qstrip,$(BR2_CCACHE_DIR))
  409. export BR_CACHE_DIR
  410. HOSTCC := $(CCACHE) $(HOSTCC)
  411. HOSTCXX := $(CCACHE) $(HOSTCXX)
  412. else
  413. export BR_NO_CCACHE
  414. endif
  415. # Scripts in support/ or post-build scripts may need to reference
  416. # these locations, so export them so it is easier to use
  417. export BR2_CONFIG
  418. export BR2_REPRODUCIBLE
  419. export TARGET_DIR
  420. export STAGING_DIR
  421. export HOST_DIR
  422. export BINARIES_DIR
  423. export BASE_DIR
  424. ################################################################################
  425. #
  426. # You should probably leave this stuff alone unless you know
  427. # what you are doing.
  428. #
  429. ################################################################################
  430. all: world
  431. # Include legacy before the other things, because package .mk files
  432. # may rely on it.
  433. include Makefile.legacy
  434. include system/system.mk
  435. include package/Makefile.in
  436. # arch/arch.mk.* must be after package/Makefile.in because it may need to
  437. # complement variables defined therein, like BR_NO_CHECK_HASH_FOR.
  438. -include $(sort $(wildcard arch/arch.mk.*))
  439. include support/dependencies/dependencies.mk
  440. include $(sort $(wildcard toolchain/*.mk))
  441. include $(sort $(wildcard toolchain/*/*.mk))
  442. ifeq ($(BR2_REPRODUCIBLE),y)
  443. # If SOURCE_DATE_EPOCH has not been set then use the commit date, or the last
  444. # release date if the source tree is not within a Git repository.
  445. # See: https://reproducible-builds.org/specs/source-date-epoch/
  446. BR2_VERSION_GIT_EPOCH := $(shell $(GIT) log -1 --format=%at 2> /dev/null)
  447. export SOURCE_DATE_EPOCH ?= $(or $(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
  448. endif
  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) $(BASE_TARGET_DIR) \
  493. $(HOST_DIR) $(HOST_DIR_SYMLINK) $(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. mkdir -p $(HOST_DIR)/share/buildroot
  507. echo $(HOST_DIR) > $(HOST_DIR)/share/buildroot/sdk-location
  508. # Populating the staging with the base directories is handled by the skeleton package
  509. $(STAGING_DIR):
  510. @mkdir -p $(STAGING_DIR)
  511. @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
  512. RSYNC_VCS_EXCLUSIONS = \
  513. --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
  514. --exclude CVS
  515. STRIP_FIND_CMD = find $(TARGET_DIR)
  516. ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
  517. STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
  518. endif
  519. STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
  520. # file exclusions:
  521. # - libpthread.so: a non-stripped libpthread shared library is needed for
  522. # proper debugging of pthread programs using gdb.
  523. # - ld.so: a non-stripped dynamic linker library is needed for valgrind
  524. # - kernel modules (*.ko): do not function properly when stripped like normal
  525. # applications and libraries. Normally kernel modules are already excluded
  526. # by the executable permission check above, so the explicit exclusion is only
  527. # done for kernel modules with incorrect permissions.
  528. STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print0
  529. ifeq ($(BR2_ECLIPSE_REGISTER),y)
  530. define TOOLCHAIN_ECLIPSE_REGISTER
  531. ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \
  532. $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
  533. endef
  534. TARGET_FINALIZE_HOOKS += TOOLCHAIN_ECLIPSE_REGISTER
  535. endif
  536. # Generate locale data. Basically, we call the localedef program
  537. # (built by the host-localedef package) for each locale. The input
  538. # data comes preferably from the toolchain, or if the toolchain does
  539. # not have them (Linaro toolchains), we use the ones available on the
  540. # host machine.
  541. ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
  542. GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
  543. ifneq ($(GLIBC_GENERATE_LOCALES),)
  544. PACKAGES += host-localedef
  545. define GENERATE_GLIBC_LOCALES
  546. $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
  547. $(Q)for locale in $(GLIBC_GENERATE_LOCALES) ; do \
  548. inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
  549. charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
  550. if test -z "$${charmap}" ; then \
  551. charmap="UTF-8" ; \
  552. fi ; \
  553. echo "Generating locale $${inputfile}.$${charmap}" ; \
  554. I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
  555. $(HOST_DIR)/bin/localedef \
  556. --prefix=$(TARGET_DIR) \
  557. --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
  558. -i $${inputfile} -f $${charmap} \
  559. $${locale} ; \
  560. done
  561. endef
  562. TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
  563. endif
  564. endif
  565. ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
  566. LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
  567. LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
  568. # This piece of junk does the following:
  569. # First collect the whitelist in a file.
  570. # Then go over all the locale dirs and for each subdir, check if it exists
  571. # in the whitelist file. If it doesn't, kill it.
  572. # Finally, specifically for X11, regenerate locale.dir from the whitelist.
  573. define PURGE_LOCALES
  574. rm -f $(LOCALE_WHITELIST)
  575. for i in $(LOCALE_NOPURGE) locale-archive; do echo $$i >> $(LOCALE_WHITELIST); done
  576. for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/lib/locale)); \
  577. do \
  578. for langdir in $$dir/*; \
  579. do \
  580. if [ -e "$${langdir}" ]; \
  581. then \
  582. grep -qx "$${langdir##*/}" $(LOCALE_WHITELIST) || rm -rf $$langdir; \
  583. fi \
  584. done; \
  585. done
  586. if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \
  587. then \
  588. for lang in $(LOCALE_NOPURGE); \
  589. do \
  590. if [ -f $(TARGET_DIR)/usr/share/X11/locale/$$lang/XLC_LOCALE ]; \
  591. then \
  592. echo "$$lang/XLC_LOCALE: $$lang"; \
  593. fi \
  594. done > $(TARGET_DIR)/usr/share/X11/locale/locale.dir; \
  595. fi
  596. endef
  597. TARGET_FINALIZE_HOOKS += PURGE_LOCALES
  598. endif
  599. $(TARGETS_ROOTFS): target-finalize
  600. # Avoid the rootfs name leaking down the dependency chain
  601. target-finalize: ROOTFS=
  602. .PHONY: target-finalize
  603. target-finalize: $(PACKAGES)
  604. @$(call MESSAGE,"Finalizing target directory")
  605. # Check files that are touched by more than one package
  606. ./support/scripts/check-uniq-files -t target $(BUILD_DIR)/packages-file-list.txt
  607. ./support/scripts/check-uniq-files -t staging $(BUILD_DIR)/packages-file-list-staging.txt
  608. ./support/scripts/check-uniq-files -t host $(BUILD_DIR)/packages-file-list-host.txt
  609. $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
  610. rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
  611. $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
  612. $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
  613. find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
  614. find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \
  615. \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
  616. ifneq ($(BR2_PACKAGE_GDB),y)
  617. rm -rf $(TARGET_DIR)/usr/share/gdb
  618. endif
  619. ifneq ($(BR2_PACKAGE_BASH),y)
  620. rm -rf $(TARGET_DIR)/usr/share/bash-completion
  621. endif
  622. ifneq ($(BR2_PACKAGE_ZSH),y)
  623. rm -rf $(TARGET_DIR)/usr/share/zsh
  624. endif
  625. rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
  626. rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
  627. rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
  628. rm -rf $(TARGET_DIR)/usr/share/gtk-doc
  629. rmdir $(TARGET_DIR)/usr/share 2>/dev/null || true
  630. $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
  631. # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
  632. # besides the one in which crash occurred; or SIGTRAP kills my program when
  633. # I set a breakpoint"
  634. ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
  635. find $(TARGET_DIR)/lib/ -type f -name 'libpthread*.so*' | \
  636. xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
  637. endif
  638. # Valgrind needs ld.so with enough information, so only strip
  639. # debugging symbols.
  640. find $(TARGET_DIR)/lib/ -type f -name 'ld-*.so*' | \
  641. xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
  642. test -f $(TARGET_DIR)/etc/ld.so.conf && \
  643. { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
  644. test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
  645. { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
  646. mkdir -p $(TARGET_DIR)/etc
  647. ( \
  648. echo "NAME=Buildroot"; \
  649. echo "VERSION=$(BR2_VERSION_FULL)"; \
  650. echo "ID=buildroot"; \
  651. echo "VERSION_ID=$(BR2_VERSION)"; \
  652. echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
  653. ) > $(TARGET_DIR)/usr/lib/os-release
  654. ln -sf ../usr/lib/os-release $(TARGET_DIR)/etc
  655. @$(call MESSAGE,"Sanitizing RPATH in target tree")
  656. $(TOPDIR)/support/scripts/fix-rpath target
  657. @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
  658. $(call MESSAGE,"Copying overlay $(d)"); \
  659. rsync -a --ignore-times --keep-dirlinks $(RSYNC_VCS_EXCLUSIONS) \
  660. --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
  661. $(d)/ $(TARGET_DIR)$(sep))
  662. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
  663. $(call MESSAGE,"Executing post-build script $(s)"); \
  664. $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
  665. touch $(TARGET_DIR)/usr
  666. .PHONY: target-post-image
  667. target-post-image: $(TARGETS_ROOTFS) target-finalize
  668. @rm -f $(ROOTFS_COMMON_TAR)
  669. @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
  670. $(call MESSAGE,"Executing post-image script $(s)"); \
  671. $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
  672. .PHONY: source
  673. source: $(foreach p,$(PACKAGES),$(p)-all-source)
  674. .PHONY: _external-deps external-deps
  675. _external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
  676. external-deps:
  677. @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
  678. .PHONY: legal-info-clean
  679. legal-info-clean:
  680. @rm -fr $(LEGAL_INFO_DIR)
  681. .PHONY: legal-info-prepare
  682. legal-info-prepare: $(LEGAL_INFO_DIR)
  683. @$(call MESSAGE,"Buildroot $(BR2_VERSION_FULL) Collecting legal info")
  684. @$(call legal-license-file,buildroot,buildroot,support/legal-info,COPYING,COPYING,HOST)
  685. @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
  686. @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
  687. @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPL-2.0+,COPYING,not saved,not saved,HOST)
  688. @$(call legal-warning,the Buildroot source code has not been saved)
  689. @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
  690. .PHONY: legal-info
  691. legal-info: dirs legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
  692. $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
  693. @cat support/legal-info/README.header >>$(LEGAL_REPORT)
  694. @if [ -r $(LEGAL_WARNINGS) ]; then \
  695. cat support/legal-info/README.warnings-header \
  696. $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
  697. cat $(LEGAL_WARNINGS); fi
  698. @rm -f $(LEGAL_WARNINGS)
  699. @(cd $(LEGAL_INFO_DIR); \
  700. find * -type f -exec sha256sum {} + | LC_ALL=C sort -k2 \
  701. >.legal-info.sha256; \
  702. mv .legal-info.sha256 legal-info.sha256)
  703. @echo "Legal info produced in $(LEGAL_INFO_DIR)"
  704. .PHONY: show-targets
  705. show-targets:
  706. @echo $(sort $(PACKAGES)) $(sort $(TARGETS_ROOTFS))
  707. .PHONY: show-build-order
  708. show-build-order: $(patsubst %,%-show-build-order,$(PACKAGES))
  709. .PHONY: graph-build
  710. graph-build: $(O)/build/build-time.log
  711. @install -d $(GRAPHS_DIR)
  712. $(foreach o,name build duration,./support/scripts/graph-build-time \
  713. --type=histogram --order=$(o) --input=$(<) \
  714. --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
  715. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  716. $(foreach t,packages steps,./support/scripts/graph-build-time \
  717. --type=pie-$(t) --input=$(<) \
  718. --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
  719. $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
  720. .PHONY: graph-depends-requirements
  721. graph-depends-requirements:
  722. @dot -? >/dev/null 2>&1 || \
  723. { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
  724. .PHONY: graph-depends
  725. graph-depends: graph-depends-requirements
  726. @$(INSTALL) -d $(GRAPHS_DIR)
  727. @cd "$(CONFIG_DIR)"; \
  728. $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
  729. --direct -o $(GRAPHS_DIR)/$(@).dot
  730. dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \
  731. -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \
  732. $(GRAPHS_DIR)/$(@).dot
  733. .PHONY: graph-size
  734. graph-size:
  735. $(Q)mkdir -p $(GRAPHS_DIR)
  736. $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
  737. --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
  738. --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
  739. --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv
  740. .PHONY: check-dependencies
  741. check-dependencies:
  742. @cd "$(CONFIG_DIR)"; \
  743. $(TOPDIR)/support/scripts/graph-depends -C
  744. else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  745. # Some subdirectories are also package names. To avoid that "make linux"
  746. # on an unconfigured tree produces "Nothing to be done", add an explicit
  747. # rule for it.
  748. # Also for 'all' we error out and ask the user to configure first.
  749. .PHONY: linux toolchain
  750. linux toolchain all: outputmakefile
  751. $(error Please configure Buildroot first (e.g. "make menuconfig"))
  752. @exit 1
  753. endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
  754. # configuration
  755. # ---------------------------------------------------------------------------
  756. HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
  757. export HOSTCFLAGS
  758. .PHONY: prepare-kconfig
  759. prepare-kconfig: outputmakefile $(BUILD_DIR)/.br2-external.in
  760. $(BUILD_DIR)/buildroot-config/%onf:
  761. mkdir -p $(@D)/lxdialog
  762. PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
  763. obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
  764. DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
  765. # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
  766. # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
  767. COMMON_CONFIG_ENV = \
  768. BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
  769. KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
  770. KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
  771. KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
  772. BR2_CONFIG=$(BR2_CONFIG) \
  773. HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
  774. BUILD_DIR=$(BUILD_DIR) \
  775. SKIP_LEGACY=
  776. xconfig: $(BUILD_DIR)/buildroot-config/qconf prepare-kconfig
  777. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  778. gconfig: $(BUILD_DIR)/buildroot-config/gconf prepare-kconfig
  779. @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
  780. menuconfig: $(BUILD_DIR)/buildroot-config/mconf prepare-kconfig
  781. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  782. nconfig: $(BUILD_DIR)/buildroot-config/nconf prepare-kconfig
  783. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  784. config: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  785. @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
  786. # For the config targets that automatically select options, we pass
  787. # SKIP_LEGACY=y to disable the legacy options. However, in that case
  788. # no values are set for the legacy options so a subsequent oldconfig
  789. # will query them. Therefore, run an additional olddefconfig.
  790. randconfig allyesconfig alldefconfig allnoconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  791. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --$@ $(CONFIG_CONFIG_IN)
  792. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  793. randpackageconfig allyespackageconfig allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  794. @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
  795. @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
  796. KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
  797. $< --$(subst package,,$@) $(CONFIG_CONFIG_IN)
  798. @rm -f $(CONFIG_DIR)/.config.nopkg
  799. @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
  800. oldconfig silentoldconfig olddefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  801. @$(COMMON_CONFIG_ENV) $< --$@ $(CONFIG_CONFIG_IN)
  802. defconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  803. @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
  804. define percent_defconfig
  805. # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
  806. %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig prepare-kconfig
  807. @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \
  808. $$< --defconfig=$(1)/configs/$$@ $$(CONFIG_CONFIG_IN)
  809. endef
  810. $(eval $(foreach d,$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(call percent_defconfig,$(d))$(sep)))
  811. savedefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
  812. @$(COMMON_CONFIG_ENV) $< \
  813. --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
  814. $(CONFIG_CONFIG_IN)
  815. @$(SED) '/BR2_DEFCONFIG=/d' $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig)
  816. .PHONY: defconfig savedefconfig
  817. ################################################################################
  818. #
  819. # Cleanup and misc junk
  820. #
  821. ################################################################################
  822. # staging and target directories do NOT list these as
  823. # dependencies anywhere else
  824. $(BUILD_DIR) $(BASE_TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
  825. @mkdir -p $@
  826. # outputmakefile generates a Makefile in the output directory, if using a
  827. # separate output directory. This allows convenient use of make in the
  828. # output directory.
  829. .PHONY: outputmakefile
  830. outputmakefile:
  831. ifeq ($(NEED_WRAPPER),y)
  832. $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
  833. endif
  834. # Even though the target is a real file, we mark it as PHONY as we
  835. # want it to be re-generated each time make is invoked, in case the
  836. # value of BR2_EXTERNAL is changed.
  837. .PHONY: $(BUILD_DIR)/.br2-external.in
  838. $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
  839. $(Q)support/scripts/br2-external -k -o "$(@)" $(BR2_EXTERNAL)
  840. # printvars prints all the variables currently defined in our
  841. # Makefiles. Alternatively, if a non-empty VARS variable is passed,
  842. # only the variables matching the make pattern passed in VARS are
  843. # displayed.
  844. .PHONY: printvars
  845. printvars:
  846. @:
  847. $(foreach V, \
  848. $(sort $(if $(VARS),$(filter $(VARS),$(.VARIABLES)),$(.VARIABLES))), \
  849. $(if $(filter-out environment% default automatic, \
  850. $(origin $V)), \
  851. $(if $(QUOTED_VARS),\
  852. $(info $V='$(subst ','\'',$(if $(RAW_VARS),$(value $V),$($V)))'), \
  853. $(info $V=$(if $(RAW_VARS),$(value $V),$($V))))))
  854. # ' Syntax colouring...
  855. .PHONY: clean
  856. clean:
  857. rm -rf $(BASE_TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) $(HOST_DIR_SYMLINK) \
  858. $(BUILD_DIR) $(BASE_DIR)/staging \
  859. $(LEGAL_INFO_DIR) $(GRAPHS_DIR)
  860. .PHONY: distclean
  861. distclean: clean
  862. ifeq ($(O),$(CURDIR)/output)
  863. rm -rf $(O)
  864. endif
  865. rm -rf $(TOPDIR)/dl $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
  866. $(CONFIG_DIR)/.auto.deps $(BR2_EXTERNAL_FILE)
  867. .PHONY: help
  868. help:
  869. @echo 'Cleaning:'
  870. @echo ' clean - delete all files created by build'
  871. @echo ' distclean - delete all non-source files (including .config)'
  872. @echo
  873. @echo 'Build:'
  874. @echo ' all - make world'
  875. @echo ' toolchain - build toolchain'
  876. @echo ' sdk - build relocatable SDK'
  877. @echo
  878. @echo 'Configuration:'
  879. @echo ' menuconfig - interactive curses-based configurator'
  880. @echo ' nconfig - interactive ncurses-based configurator'
  881. @echo ' xconfig - interactive Qt-based configurator'
  882. @echo ' gconfig - interactive GTK-based configurator'
  883. @echo ' oldconfig - resolve any unresolved symbols in .config'
  884. @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
  885. @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
  886. @echo ' randconfig - New config with random answer to all options'
  887. @echo ' defconfig - New config with default answer to all options;'
  888. @echo ' BR2_DEFCONFIG, if set on the command line, is used as input'
  889. @echo ' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
  890. @echo ' allyesconfig - New config where all options are accepted with yes'
  891. @echo ' allnoconfig - New config where all options are answered with no'
  892. @echo ' alldefconfig - New config where all options are set to default'
  893. @echo ' randpackageconfig - New config with random answer to package options'
  894. @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
  895. @echo ' allnopackageconfig - New config where package options are answered with no'
  896. @echo
  897. @echo 'Package-specific:'
  898. @echo ' <pkg> - Build and install <pkg> and all its dependencies'
  899. @echo ' <pkg>-source - Only download the source files for <pkg>'
  900. @echo ' <pkg>-extract - Extract <pkg> sources'
  901. @echo ' <pkg>-patch - Apply patches to <pkg>'
  902. @echo ' <pkg>-depends - Build <pkg>'\''s dependencies'
  903. @echo ' <pkg>-configure - Build <pkg> up to the configure step'
  904. @echo ' <pkg>-build - Build <pkg> up to the build step'
  905. @echo ' <pkg>-show-depends - List packages on which <pkg> depends'
  906. @echo ' <pkg>-show-rdepends - List packages which have <pkg> as a dependency'
  907. @echo ' <pkg>-show-recursive-depends'
  908. @echo ' - Recursively list packages on which <pkg> depends'
  909. @echo ' <pkg>-show-recursive-rdepends'
  910. @echo ' - Recursively list packages which have <pkg> as a dependency'
  911. @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
  912. @echo ' <pkg>-graph-rdepends - Generate a graph of <pkg>'\''s reverse dependencies'
  913. @echo ' <pkg>-dirclean - Remove <pkg> build directory'
  914. @echo ' <pkg>-reconfigure - Restart the build from the configure step'
  915. @echo ' <pkg>-rebuild - Restart the build from the build step'
  916. $(foreach p,$(HELP_PACKAGES), \
  917. @echo $(sep) \
  918. @echo '$($(p)_NAME):' $(sep) \
  919. $($(p)_HELP_CMDS)$(sep))
  920. @echo
  921. @echo 'Documentation:'
  922. @echo ' manual - build manual in all formats'
  923. @echo ' manual-html - build manual in HTML'
  924. @echo ' manual-split-html - build manual in split HTML'
  925. @echo ' manual-pdf - build manual in PDF'
  926. @echo ' manual-text - build manual in text'
  927. @echo ' manual-epub - build manual in ePub'
  928. @echo ' graph-build - generate graphs of the build times'
  929. @echo ' graph-depends - generate graph of the dependency tree'
  930. @echo ' graph-size - generate stats of the filesystem size'
  931. @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
  932. @echo
  933. @echo 'Miscellaneous:'
  934. @echo ' source - download all sources needed for offline-build'
  935. @echo ' external-deps - list external packages used'
  936. @echo ' legal-info - generate info about license compliance'
  937. @echo ' printvars - dump all the internal variables'
  938. @echo
  939. @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
  940. @echo ' make O=dir - Locate all output files in "dir", including .config'
  941. @echo
  942. @echo 'For further details, see README, generate the Buildroot manual, or consult'
  943. @echo 'it on-line at http://buildroot.org/docs.html'
  944. @echo
  945. # List the defconfig files
  946. # $(1): base directory
  947. # $(2): br2-external name, empty for bundled
  948. define list-defconfigs
  949. @first=true; \
  950. for defconfig in $(1)/configs/*_defconfig; do \
  951. [ -f "$${defconfig}" ] || continue; \
  952. if $${first}; then \
  953. if [ "$(2)" ]; then \
  954. printf 'External configs in "$(call qstrip,$(2))":\n'; \
  955. else \
  956. printf "Built-in configs:\n"; \
  957. fi; \
  958. first=false; \
  959. fi; \
  960. defconfig="$${defconfig##*/}"; \
  961. printf " %-35s - Build for %s\n" "$${defconfig}" "$${defconfig%_defconfig}"; \
  962. done; \
  963. $${first} || printf "\n"
  964. endef
  965. # We iterate over BR2_EXTERNAL_NAMES rather than BR2_EXTERNAL_DIRS,
  966. # because we want to display the name of the br2-external tree.
  967. .PHONY: list-defconfigs
  968. list-defconfigs:
  969. $(call list-defconfigs,$(TOPDIR))
  970. $(foreach name,$(BR2_EXTERNAL_NAMES),\
  971. $(call list-defconfigs,$(BR2_EXTERNAL_$(name)_PATH),\
  972. $(BR2_EXTERNAL_$(name)_DESC))$(sep))
  973. release: OUT = buildroot-$(BR2_VERSION)
  974. # Create release tarballs. We need to fiddle a bit to add the generated
  975. # documentation to the git output
  976. release:
  977. git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
  978. $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
  979. $(MAKE) O=$(OUT) manual-clean
  980. tar rf $(OUT).tar $(OUT)
  981. gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
  982. bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
  983. rm -rf $(OUT) $(OUT).tar
  984. print-version:
  985. @echo $(BR2_VERSION_FULL)
  986. .PHONY: .gitlab-ci.yml
  987. .gitlab-ci.yml: .gitlab-ci.yml.in
  988. cp $< $@
  989. (cd configs; LC_ALL=C ls -1 *_defconfig) | sed 's/$$/: *defconfig/' >> $@
  990. ./support/testing/run-tests -l 2>&1 | sed -r -e '/^test_run \((.*)\).*/!d; s//\1: *runtime_test/' | LC_ALL=C sort >> $@
  991. include docs/manual/manual.mk
  992. -include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(sort $(wildcard $(dir)/docs/*/*.mk)))
  993. .PHONY: $(noconfig_targets)
  994. endif #umask / $(CURDIR) / $(O)