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