2
1

Makefile 39 KB

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