]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - Makefile
lrzsz: install symlinks for XMODEM and YMODEM
[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-rc2
91 # Actual time the release is cut (for reproducible builds)
92 BR2_VERSION_EPOCH = 1527024000
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/or1k/openrisc/ \
433         -e s/parisc64/parisc/ \
434         -e s/powerpc64.*/powerpc/ \
435         -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
436         -e s/sh.*/sh/ \
437         -e s/microblazeel/microblaze/)
438
439 ZCAT := $(call qstrip,$(BR2_ZCAT))
440 BZCAT := $(call qstrip,$(BR2_BZCAT))
441 XZCAT := $(call qstrip,$(BR2_XZCAT))
442 LZCAT := $(call qstrip,$(BR2_LZCAT))
443 TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
444
445 # packages compiled for the host go here
446 HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
447
448 ifneq ($(HOST_DIR),$(BASE_DIR)/host)
449 HOST_DIR_SYMLINK = $(BASE_DIR)/host
450 $(HOST_DIR_SYMLINK): $(BASE_DIR)
451         ln -snf $(HOST_DIR) $(BASE_DIR)/host
452 endif
453
454 # Quotes are needed for spaces and all in the original PATH content.
455 BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(PATH)"
456
457 # Location of a file giving a big fat warning that output/target
458 # should not be used as the root filesystem.
459 TARGET_DIR_WARNING_FILE = $(BASE_TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
460
461 ifeq ($(BR2_CCACHE),y)
462 CCACHE := $(HOST_DIR)/bin/ccache
463 BR_CACHE_DIR ?= $(call qstrip,$(BR2_CCACHE_DIR))
464 export BR_CACHE_DIR
465 HOSTCC := $(CCACHE) $(HOSTCC)
466 HOSTCXX := $(CCACHE) $(HOSTCXX)
467 else
468 export BR_NO_CCACHE
469 endif
470
471 # Scripts in support/ or post-build scripts may need to reference
472 # these locations, so export them so it is easier to use
473 export BR2_CONFIG
474 export BR2_REPRODUCIBLE
475 export TARGET_DIR
476 export STAGING_DIR
477 export HOST_DIR
478 export BINARIES_DIR
479 export BASE_DIR
480
481 ################################################################################
482 #
483 # You should probably leave this stuff alone unless you know
484 # what you are doing.
485 #
486 ################################################################################
487
488 all: world
489
490 # Include legacy before the other things, because package .mk files
491 # may rely on it.
492 include Makefile.legacy
493
494 include system/system.mk
495 include package/Makefile.in
496 # arch/arch.mk.* must be after package/Makefile.in because it may need to
497 # complement variables defined therein, like BR_NO_CHECK_HASH_FOR.
498 -include $(sort $(wildcard arch/arch.mk.*))
499 include support/dependencies/dependencies.mk
500
501 include $(sort $(wildcard toolchain/*.mk))
502 include $(sort $(wildcard toolchain/*/*.mk))
503
504 ifeq ($(BR2_REPRODUCIBLE),y)
505 # If SOURCE_DATE_EPOCH has not been set then use the commit date, or the last
506 # release date if the source tree is not within a Git repository.
507 # See: https://reproducible-builds.org/specs/source-date-epoch/
508 BR2_VERSION_GIT_EPOCH := $(shell $(GIT) log -1 --format=%at 2> /dev/null)
509 export SOURCE_DATE_EPOCH ?= $(or $(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
510 endif
511
512 # Include the package override file if one has been provided in the
513 # configuration.
514 PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
515 ifneq ($(PACKAGE_OVERRIDE_FILE),)
516 -include $(PACKAGE_OVERRIDE_FILE)
517 endif
518
519 include $(sort $(wildcard package/*/*.mk))
520
521 include boot/common.mk
522 include linux/linux.mk
523 include fs/common.mk
524
525 # If using a br2-external tree, the BR2_EXTERNAL_$(NAME)_PATH variables
526 # are also present in the .config file. Since .config is included after
527 # we defined them in the Makefile, the values for those variables are
528 # quoted. We just include the generated Makefile fragment .br2-external.mk
529 # a third time, which will set those variables to the un-quoted values.
530 include $(BR2_EXTERNAL_FILE)
531
532 # Nothing to include if no BR2_EXTERNAL tree in use
533 include $(BR2_EXTERNAL_MKS)
534
535 # Now we are sure we have all the packages scanned and defined. We now
536 # check for each package in the list of enabled packages, that all its
537 # dependencies are indeed enabled.
538 #
539 # Only trigger the check for default builds. If the user forces building
540 # a package, even if not enabled in the configuration, we want to accept
541 # it.
542 #
543 ifeq ($(MAKECMDGOALS),)
544
545 define CHECK_ONE_DEPENDENCY
546 ifeq ($$($(2)_TYPE),target)
547 ifeq ($$($(2)_IS_VIRTUAL),)
548 ifneq ($$($$($(2)_KCONFIG_VAR)),y)
549 $$(error $$($(2)_NAME) is in the dependency chain of $$($(1)_NAME) that \
550 has added it to its _DEPENDENCIES variable without selecting it or \
551 depending on it from Config.in)
552 endif
553 endif
554 endif
555 endef
556
557 $(foreach pkg,$(call UPPERCASE,$(PACKAGES)),\
558         $(foreach dep,$(call UPPERCASE,$($(pkg)_FINAL_ALL_DEPENDENCIES)),\
559                 $(eval $(call CHECK_ONE_DEPENDENCY,$(pkg),$(dep))$(sep))))
560
561 endif
562
563 .PHONY: dirs
564 dirs: $(BUILD_DIR) $(STAGING_DIR) $(BASE_TARGET_DIR) \
565         $(HOST_DIR) $(HOST_DIR_SYMLINK) $(BINARIES_DIR)
566
567 $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
568         $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
569
570 .PHONY: prepare
571 prepare: $(BUILD_DIR)/buildroot-config/auto.conf
572
573 .PHONY: world
574 world: target-post-image
575
576 .PHONY: sdk
577 sdk: world
578         @$(call MESSAGE,"Rendering the SDK relocatable")
579         $(TOPDIR)/support/scripts/fix-rpath host
580         $(TOPDIR)/support/scripts/fix-rpath staging
581         $(INSTALL) -m 755 $(TOPDIR)/support/misc/relocate-sdk.sh $(HOST_DIR)/relocate-sdk.sh
582         mkdir -p $(HOST_DIR)/share/buildroot
583         echo $(HOST_DIR) > $(HOST_DIR)/share/buildroot/sdk-location
584
585 # Populating the staging with the base directories is handled by the skeleton package
586 $(STAGING_DIR):
587         @mkdir -p $(STAGING_DIR)
588         @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
589
590 RSYNC_VCS_EXCLUSIONS = \
591         --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
592         --exclude CVS
593
594 STRIP_FIND_CMD = find $(TARGET_DIR)
595 ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
596 STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
597 endif
598 STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
599 # file exclusions:
600 # - libpthread.so: a non-stripped libpthread shared library is needed for
601 #   proper debugging of pthread programs using gdb.
602 # - ld.so: a non-stripped dynamic linker library is needed for valgrind
603 # - kernel modules (*.ko): do not function properly when stripped like normal
604 #   applications and libraries. Normally kernel modules are already excluded
605 #   by the executable permission check above, so the explicit exclusion is only
606 #   done for kernel modules with incorrect permissions.
607 STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print0
608
609 ifeq ($(BR2_ECLIPSE_REGISTER),y)
610 define TOOLCHAIN_ECLIPSE_REGISTER
611         ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \
612                 $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
613 endef
614 TARGET_FINALIZE_HOOKS += TOOLCHAIN_ECLIPSE_REGISTER
615 endif
616
617 # Generate locale data. Basically, we call the localedef program
618 # (built by the host-localedef package) for each locale. The input
619 # data comes preferably from the toolchain, or if the toolchain does
620 # not have them (Linaro toolchains), we use the ones available on the
621 # host machine.
622 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
623 GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
624 ifneq ($(GLIBC_GENERATE_LOCALES),)
625 PACKAGES += host-localedef
626
627 define GENERATE_GLIBC_LOCALES
628         $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
629         $(Q)for locale in $(GLIBC_GENERATE_LOCALES) ; do \
630                 inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
631                 charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
632                 if test -z "$${charmap}" ; then \
633                         charmap="UTF-8" ; \
634                 fi ; \
635                 echo "Generating locale $${inputfile}.$${charmap}" ; \
636                 I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
637                 $(HOST_DIR)/bin/localedef \
638                         --prefix=$(TARGET_DIR) \
639                         --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
640                         -i $${inputfile} -f $${charmap} \
641                         $${locale} ; \
642         done
643 endef
644 TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
645 endif
646 endif
647
648 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
649 LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
650 LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
651
652 # This piece of junk does the following:
653 # First collect the whitelist in a file.
654 # Then go over all the locale dirs and for each subdir, check if it exists
655 # in the whitelist file. If it doesn't, kill it.
656 # Finally, specifically for X11, regenerate locale.dir from the whitelist.
657 define PURGE_LOCALES
658         rm -f $(LOCALE_WHITELIST)
659         for i in $(LOCALE_NOPURGE) locale-archive; do echo $$i >> $(LOCALE_WHITELIST); done
660
661         for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/lib/locale)); \
662         do \
663                 for langdir in $$dir/*; \
664                 do \
665                         if [ -e "$${langdir}" ]; \
666                         then \
667                                 grep -qx "$${langdir##*/}" $(LOCALE_WHITELIST) || rm -rf $$langdir; \
668                         fi \
669                 done; \
670         done
671         if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \
672         then \
673                 for lang in $(LOCALE_NOPURGE); \
674                 do \
675                         if [ -f $(TARGET_DIR)/usr/share/X11/locale/$$lang/XLC_LOCALE ]; \
676                         then \
677                                 echo "$$lang/XLC_LOCALE: $$lang"; \
678                         fi \
679                 done > $(TARGET_DIR)/usr/share/X11/locale/locale.dir; \
680         fi
681 endef
682 TARGET_FINALIZE_HOOKS += PURGE_LOCALES
683 endif
684
685 $(TARGETS_ROOTFS): target-finalize
686
687 # Avoid the rootfs name leaking down the dependency chain
688 target-finalize: ROOTFS=
689
690 .PHONY: target-finalize
691 target-finalize: $(PACKAGES)
692         @$(call MESSAGE,"Finalizing target directory")
693         # Check files that are touched by more than one package
694         ./support/scripts/check-uniq-files -t target $(BUILD_DIR)/packages-file-list.txt
695         ./support/scripts/check-uniq-files -t staging $(BUILD_DIR)/packages-file-list-staging.txt
696         ./support/scripts/check-uniq-files -t host $(BUILD_DIR)/packages-file-list-host.txt
697         $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
698         rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
699                 $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
700                 $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
701         find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
702         find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \
703                 \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
704 ifneq ($(BR2_PACKAGE_GDB),y)
705         rm -rf $(TARGET_DIR)/usr/share/gdb
706 endif
707 ifneq ($(BR2_PACKAGE_BASH),y)
708         rm -rf $(TARGET_DIR)/usr/share/bash-completion
709 endif
710 ifneq ($(BR2_PACKAGE_ZSH),y)
711         rm -rf $(TARGET_DIR)/usr/share/zsh
712 endif
713         rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
714         rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
715         rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
716         rm -rf $(TARGET_DIR)/usr/share/gtk-doc
717         rmdir $(TARGET_DIR)/usr/share 2>/dev/null || true
718         $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
719
720 # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
721 # besides the one in which crash occurred; or SIGTRAP kills my program when
722 # I set a breakpoint"
723 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
724         find $(TARGET_DIR)/lib/ -type f -name 'libpthread*.so*' | \
725                 xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
726 endif
727
728 # Valgrind needs ld.so with enough information, so only strip
729 # debugging symbols.
730         find $(TARGET_DIR)/lib/ -type f -name 'ld-*.so*' | \
731                 xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
732         test -f $(TARGET_DIR)/etc/ld.so.conf && \
733                 { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
734         test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
735                 { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
736         mkdir -p $(TARGET_DIR)/etc
737         ( \
738                 echo "NAME=Buildroot"; \
739                 echo "VERSION=$(BR2_VERSION_FULL)"; \
740                 echo "ID=buildroot"; \
741                 echo "VERSION_ID=$(BR2_VERSION)"; \
742                 echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
743         ) >  $(TARGET_DIR)/usr/lib/os-release
744         ln -sf ../usr/lib/os-release $(TARGET_DIR)/etc
745
746         @$(call MESSAGE,"Sanitizing RPATH in target tree")
747         $(TOPDIR)/support/scripts/fix-rpath target
748
749         @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
750                 $(call MESSAGE,"Copying overlay $(d)"); \
751                 rsync -a --ignore-times --keep-dirlinks $(RSYNC_VCS_EXCLUSIONS) \
752                         --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
753                         $(d)/ $(TARGET_DIR)$(sep))
754
755         @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
756                 $(call MESSAGE,"Executing post-build script $(s)"); \
757                 $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
758
759         touch $(TARGET_DIR)/usr
760
761 .PHONY: target-post-image
762 target-post-image: $(TARGETS_ROOTFS) target-finalize
763         @rm -f $(ROOTFS_COMMON_TAR)
764         @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
765                 $(call MESSAGE,"Executing post-image script $(s)"); \
766                 $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
767
768 .PHONY: source
769 source: $(foreach p,$(PACKAGES),$(p)-all-source)
770
771 .PHONY: _external-deps external-deps
772 _external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
773 external-deps:
774         @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
775
776 .PHONY: legal-info-clean
777 legal-info-clean:
778         @rm -fr $(LEGAL_INFO_DIR)
779
780 .PHONY: legal-info-prepare
781 legal-info-prepare: $(LEGAL_INFO_DIR)
782         @$(call MESSAGE,"Buildroot $(BR2_VERSION_FULL) Collecting legal info")
783         @$(call legal-license-file,buildroot,buildroot,support/legal-info,COPYING,COPYING,HOST)
784         @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
785         @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
786         @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPL-2.0+,COPYING,not saved,not saved,HOST)
787         @$(call legal-warning,the Buildroot source code has not been saved)
788         @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
789
790 .PHONY: legal-info
791 legal-info: dirs legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
792                 $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
793         @cat support/legal-info/README.header >>$(LEGAL_REPORT)
794         @if [ -r $(LEGAL_WARNINGS) ]; then \
795                 cat support/legal-info/README.warnings-header \
796                         $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
797                 cat $(LEGAL_WARNINGS); fi
798         @rm -f $(LEGAL_WARNINGS)
799         @(cd $(LEGAL_INFO_DIR); \
800                 find * -type f -exec sha256sum {} + | LC_ALL=C sort -k2 \
801                         >.legal-info.sha256; \
802                 mv .legal-info.sha256 legal-info.sha256)
803         @echo "Legal info produced in $(LEGAL_INFO_DIR)"
804
805 .PHONY: show-targets
806 show-targets:
807         @echo $(sort $(PACKAGES)) $(sort $(TARGETS_ROOTFS))
808
809 .PHONY: show-build-order
810 show-build-order: $(patsubst %,%-show-build-order,$(PACKAGES))
811
812 .PHONY: graph-build
813 graph-build: $(O)/build/build-time.log
814         @install -d $(GRAPHS_DIR)
815         $(foreach o,name build duration,./support/scripts/graph-build-time \
816                                         --type=histogram --order=$(o) --input=$(<) \
817                                         --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
818                                         $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
819         $(foreach t,packages steps,./support/scripts/graph-build-time \
820                                    --type=pie-$(t) --input=$(<) \
821                                    --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
822                                    $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
823
824 .PHONY: graph-depends-requirements
825 graph-depends-requirements:
826         @dot -? >/dev/null 2>&1 || \
827                 { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
828
829 .PHONY: graph-depends
830 graph-depends: graph-depends-requirements
831         @$(INSTALL) -d $(GRAPHS_DIR)
832         @cd "$(CONFIG_DIR)"; \
833         $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
834                 --direct -o $(GRAPHS_DIR)/$(@).dot
835         dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \
836                 -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \
837                 $(GRAPHS_DIR)/$(@).dot
838
839 .PHONY: graph-size
840 graph-size:
841         $(Q)mkdir -p $(GRAPHS_DIR)
842         $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
843                 --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
844                 --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
845                 --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv
846
847 .PHONY: check-dependencies
848 check-dependencies:
849         @cd "$(CONFIG_DIR)"; \
850         $(TOPDIR)/support/scripts/graph-depends -C
851
852 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
853
854 # Some subdirectories are also package names. To avoid that "make linux"
855 # on an unconfigured tree produces "Nothing to be done", add an explicit
856 # rule for it.
857 # Also for 'all' we error out and ask the user to configure first.
858 .PHONY: linux toolchain
859 linux toolchain all: outputmakefile
860         $(error Please configure Buildroot first (e.g. "make menuconfig"))
861         @exit 1
862
863 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
864
865 # configuration
866 # ---------------------------------------------------------------------------
867
868 HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
869 export HOSTCFLAGS
870
871 .PHONY: prepare-kconfig
872 prepare-kconfig: outputmakefile $(BUILD_DIR)/.br2-external.in
873
874 $(BUILD_DIR)/buildroot-config/%onf:
875         mkdir -p $(@D)/lxdialog
876         PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
877             obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
878
879 DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
880
881 # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
882 # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
883 COMMON_CONFIG_ENV = \
884         BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
885         KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
886         KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
887         KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
888         BR2_CONFIG=$(BR2_CONFIG) \
889         HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
890         BUILD_DIR=$(BUILD_DIR) \
891         SKIP_LEGACY=
892
893 xconfig: $(BUILD_DIR)/buildroot-config/qconf prepare-kconfig
894         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
895
896 gconfig: $(BUILD_DIR)/buildroot-config/gconf prepare-kconfig
897         @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
898
899 menuconfig: $(BUILD_DIR)/buildroot-config/mconf prepare-kconfig
900         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
901
902 nconfig: $(BUILD_DIR)/buildroot-config/nconf prepare-kconfig
903         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
904
905 config: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
906         @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
907
908 # For the config targets that automatically select options, we pass
909 # SKIP_LEGACY=y to disable the legacy options. However, in that case
910 # no values are set for the legacy options so a subsequent oldconfig
911 # will query them. Therefore, run an additional olddefconfig.
912
913 randconfig allyesconfig alldefconfig allnoconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
914         @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --$@ $(CONFIG_CONFIG_IN)
915         @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
916
917 randpackageconfig allyespackageconfig allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
918         @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
919         @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
920                 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
921                 $< --$(subst package,,$@) $(CONFIG_CONFIG_IN)
922         @rm -f $(CONFIG_DIR)/.config.nopkg
923         @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
924
925 oldconfig silentoldconfig olddefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
926         @$(COMMON_CONFIG_ENV) $< --$@ $(CONFIG_CONFIG_IN)
927
928 defconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
929         @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
930
931 define percent_defconfig
932 # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
933 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig prepare-kconfig
934         @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \
935                 $$< --defconfig=$(1)/configs/$$@ $$(CONFIG_CONFIG_IN)
936 endef
937 $(eval $(foreach d,$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(call percent_defconfig,$(d))$(sep)))
938
939 savedefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
940         @$(COMMON_CONFIG_ENV) $< \
941                 --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
942                 $(CONFIG_CONFIG_IN)
943         @$(SED) '/BR2_DEFCONFIG=/d' $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig)
944
945 .PHONY: defconfig savedefconfig
946
947 ################################################################################
948 #
949 # Cleanup and misc junk
950 #
951 ################################################################################
952
953 # staging and target directories do NOT list these as
954 # dependencies anywhere else
955 $(BUILD_DIR) $(BASE_TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
956         @mkdir -p $@
957
958 # outputmakefile generates a Makefile in the output directory, if using a
959 # separate output directory. This allows convenient use of make in the
960 # output directory.
961 .PHONY: outputmakefile
962 outputmakefile:
963 ifeq ($(NEED_WRAPPER),y)
964         $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
965 endif
966
967 # Even though the target is a real file, we mark it as PHONY as we
968 # want it to be re-generated each time make is invoked, in case the
969 # value of BR2_EXTERNAL is changed.
970 .PHONY: $(BUILD_DIR)/.br2-external.in
971 $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
972         $(Q)support/scripts/br2-external -k -o "$(@)" $(BR2_EXTERNAL)
973
974 # printvars prints all the variables currently defined in our
975 # Makefiles. Alternatively, if a non-empty VARS variable is passed,
976 # only the variables matching the make pattern passed in VARS are
977 # displayed.
978 .PHONY: printvars
979 printvars:
980         @:$(foreach V, \
981                 $(sort $(if $(VARS),$(filter $(VARS),$(.VARIABLES)),$(.VARIABLES))), \
982                 $(if $(filter-out environment% default automatic, \
983                                 $(origin $V)), \
984                 $(if $(QUOTED_VARS),\
985                         $(info $V='$(subst ','\'',$(if $(RAW_VARS),$(value $V),$($V)))'), \
986                         $(info $V=$(if $(RAW_VARS),$(value $V),$($V))))))
987 # ' Syntax colouring...
988
989 .PHONY: clean
990 clean:
991         rm -rf $(BASE_TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) $(HOST_DIR_SYMLINK) \
992                 $(BUILD_DIR) $(BASE_DIR)/staging \
993                 $(LEGAL_INFO_DIR) $(GRAPHS_DIR)
994
995 .PHONY: distclean
996 distclean: clean
997 ifeq ($(O),$(CURDIR)/output)
998         rm -rf $(O)
999 endif
1000         rm -rf $(TOPDIR)/dl $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
1001                 $(CONFIG_DIR)/.auto.deps $(BR2_EXTERNAL_FILE)
1002
1003 .PHONY: help
1004 help:
1005         @echo 'Cleaning:'
1006         @echo '  clean                  - delete all files created by build'
1007         @echo '  distclean              - delete all non-source files (including .config)'
1008         @echo
1009         @echo 'Build:'
1010         @echo '  all                    - make world'
1011         @echo '  toolchain              - build toolchain'
1012         @echo '  sdk                    - build relocatable SDK'
1013         @echo
1014         @echo 'Configuration:'
1015         @echo '  menuconfig             - interactive curses-based configurator'
1016         @echo '  nconfig                - interactive ncurses-based configurator'
1017         @echo '  xconfig                - interactive Qt-based configurator'
1018         @echo '  gconfig                - interactive GTK-based configurator'
1019         @echo '  oldconfig              - resolve any unresolved symbols in .config'
1020         @echo '  silentoldconfig        - Same as oldconfig, but quietly, additionally update deps'
1021         @echo '  olddefconfig           - Same as silentoldconfig but sets new symbols to their default value'
1022         @echo '  randconfig             - New config with random answer to all options'
1023         @echo '  defconfig              - New config with default answer to all options'
1024         @echo '                             BR2_DEFCONFIG, if set, is used as input'
1025         @echo '  savedefconfig          - Save current config to BR2_DEFCONFIG (minimal config)'
1026         @echo '  allyesconfig           - New config where all options are accepted with yes'
1027         @echo '  allnoconfig            - New config where all options are answered with no'
1028         @echo '  alldefconfig           - New config where all options are set to default'
1029         @echo '  randpackageconfig      - New config with random answer to package options'
1030         @echo '  allyespackageconfig    - New config where pkg options are accepted with yes'
1031         @echo '  allnopackageconfig     - New config where package options are answered with no'
1032         @echo
1033         @echo 'Package-specific:'
1034         @echo '  <pkg>                  - Build and install <pkg> and all its dependencies'
1035         @echo '  <pkg>-source           - Only download the source files for <pkg>'
1036         @echo '  <pkg>-extract          - Extract <pkg> sources'
1037         @echo '  <pkg>-patch            - Apply patches to <pkg>'
1038         @echo '  <pkg>-depends          - Build <pkg>'\''s dependencies'
1039         @echo '  <pkg>-configure        - Build <pkg> up to the configure step'
1040         @echo '  <pkg>-build            - Build <pkg> up to the build step'
1041         @echo '  <pkg>-show-depends     - List packages on which <pkg> depends'
1042         @echo '  <pkg>-show-rdepends    - List packages which have <pkg> as a dependency'
1043         @echo '  <pkg>-show-recursive-depends'
1044         @echo '                         - Recursively list packages on which <pkg> depends'
1045         @echo '  <pkg>-show-recursive-rdepends'
1046         @echo '                         - Recursively list packages which have <pkg> as a dependency'
1047         @echo '  <pkg>-graph-depends    - Generate a graph of <pkg>'\''s dependencies'
1048         @echo '  <pkg>-graph-rdepends   - Generate a graph of <pkg>'\''s reverse dependencies'
1049         @echo '  <pkg>-dirclean         - Remove <pkg> build directory'
1050         @echo '  <pkg>-reconfigure      - Restart the build from the configure step'
1051         @echo '  <pkg>-rebuild          - Restart the build from the build step'
1052         $(foreach p,$(HELP_PACKAGES), \
1053                 @echo $(sep) \
1054                 @echo '$($(p)_NAME):' $(sep) \
1055                 $($(p)_HELP_CMDS)$(sep))
1056         @echo
1057         @echo 'Documentation:'
1058         @echo '  manual                 - build manual in all formats'
1059         @echo '  manual-html            - build manual in HTML'
1060         @echo '  manual-split-html      - build manual in split HTML'
1061         @echo '  manual-pdf             - build manual in PDF'
1062         @echo '  manual-text            - build manual in text'
1063         @echo '  manual-epub            - build manual in ePub'
1064         @echo '  graph-build            - generate graphs of the build times'
1065         @echo '  graph-depends          - generate graph of the dependency tree'
1066         @echo '  graph-size             - generate stats of the filesystem size'
1067         @echo '  list-defconfigs        - list all defconfigs (pre-configured minimal systems)'
1068         @echo
1069         @echo 'Miscellaneous:'
1070         @echo '  source                 - download all sources needed for offline-build'
1071         @echo '  external-deps          - list external packages used'
1072         @echo '  legal-info             - generate info about license compliance'
1073         @echo '  printvars              - dump all the internal variables'
1074         @echo
1075         @echo '  make V=0|1             - 0 => quiet build (default), 1 => verbose build'
1076         @echo '  make O=dir             - Locate all output files in "dir", including .config'
1077         @echo
1078         @echo 'For further details, see README, generate the Buildroot manual, or consult'
1079         @echo 'it on-line at http://buildroot.org/docs.html'
1080         @echo
1081
1082 # List the defconfig files
1083 # $(1): base directory
1084 # $(2): br2-external name, empty for bundled
1085 define list-defconfigs
1086         @first=true; \
1087         for defconfig in $(1)/configs/*_defconfig; do \
1088                 [ -f "$${defconfig}" ] || continue; \
1089                 if $${first}; then \
1090                         if [ "$(2)" ]; then \
1091                                 printf 'External configs in "$(call qstrip,$(2))":\n'; \
1092                         else \
1093                                 printf "Built-in configs:\n"; \
1094                         fi; \
1095                         first=false; \
1096                 fi; \
1097                 defconfig="$${defconfig##*/}"; \
1098                 printf "  %-35s - Build for %s\n" "$${defconfig}" "$${defconfig%_defconfig}"; \
1099         done; \
1100         $${first} || printf "\n"
1101 endef
1102
1103 # We iterate over BR2_EXTERNAL_NAMES rather than BR2_EXTERNAL_DIRS,
1104 # because we want to display the name of the br2-external tree.
1105 .PHONY: list-defconfigs
1106 list-defconfigs:
1107         $(call list-defconfigs,$(TOPDIR))
1108         $(foreach name,$(BR2_EXTERNAL_NAMES),\
1109                 $(call list-defconfigs,$(BR2_EXTERNAL_$(name)_PATH),\
1110                         $(BR2_EXTERNAL_$(name)_DESC))$(sep))
1111
1112 release: OUT = buildroot-$(BR2_VERSION)
1113
1114 # Create release tarballs. We need to fiddle a bit to add the generated
1115 # documentation to the git output
1116 release:
1117         git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
1118         $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
1119         $(MAKE) O=$(OUT) manual-clean
1120         tar rf $(OUT).tar $(OUT)
1121         gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
1122         bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
1123         rm -rf $(OUT) $(OUT).tar
1124
1125 print-version:
1126         @echo $(BR2_VERSION_FULL)
1127
1128 .PHONY: .gitlab-ci.yml
1129 .gitlab-ci.yml: .gitlab-ci.yml.in
1130         cp $< $@
1131         (cd configs; LC_ALL=C ls -1 *_defconfig) | sed 's/$$/: *defconfig/' >> $@
1132         ./support/testing/run-tests -l 2>&1 | sed -r -e '/^test_run \((.*)\).*/!d; s//\1: *runtime_test/' | LC_ALL=C sort >> $@
1133
1134 include docs/manual/manual.mk
1135 -include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(sort $(wildcard $(dir)/docs/*/*.mk)))
1136
1137 .PHONY: $(noconfig_targets)
1138
1139 endif #umask / $(CURDIR) / $(O)