1 # Makefile for buildroot
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.
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.
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
22 #--------------------------------------------------------------
23 # Just run 'make menuconfig', configure stuff, then run 'make'.
24 # You shouldn't need to mess with anything beyond this point...
25 #--------------------------------------------------------------
27 # we want bash as shell
28 SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
29 else if [ -x /bin/bash ]; then echo /bin/bash; \
32 # Trick for always running with a fixed umask
34 ifneq ($(shell umask),$(UMASK))
35 .PHONY: _all $(MAKECMDGOALS)
41 @umask $(UMASK) && $(MAKE) --no-print-directory $(MAKECMDGOALS)
45 # This is our default rule, so must come first
48 # Set and export the version string
49 export BR2_VERSION := 2016.11-git
51 # Save running make version since it's clobbered by the make package
52 RUNNING_MAKE_VERSION := $(MAKE_VERSION)
54 # Check for minimal make version (note: this check will break at make 10.x)
55 MIN_MAKE_VERSION = 3.81
56 ifneq ($(firstword $(sort $(RUNNING_MAKE_VERSION) $(MIN_MAKE_VERSION))),$(MIN_MAKE_VERSION))
57 $(error You have make '$(RUNNING_MAKE_VERSION)' installed. GNU make >= $(MIN_MAKE_VERSION) is required)
60 # Parallel execution of this Makefile is disabled because it changes
61 # the packages building order, that can be a problem for two reasons:
62 # - If a package has an unspecified optional dependency and that
63 # dependency is present when the package is built, it is used,
64 # otherwise it isn't (but compilation happily proceeds) so the end
65 # result will differ if the order is swapped due to parallel
67 # - Also changing the building order can be a problem if two packages
68 # manipulate the same file in the target directory.
70 # Taking into account the above considerations, if you still want to execute
71 # this top-level Makefile in parallel comment the ".NOTPARALLEL" line and
72 # use the -j<jobs> option when building, e.g:
73 # make -j$((`getconf _NPROCESSORS_ONLN`+1))
78 CONFIG_CONFIG_IN = Config.in
79 CONFIG = support/kconfig
80 DATE := $(shell date +%Y%m%d)
82 # Compute the full local version string so packages can use it as-is
83 # Need to export it, so it can be got from environment in children (eg. mconf)
84 export BR2_VERSION_FULL := $(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)
86 noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconfig \
87 defconfig %_defconfig allyesconfig allnoconfig silentoldconfig release \
88 randpackageconfig allyespackageconfig allnopackageconfig \
89 print-version olddefconfig
91 # Some global targets do not trigger a build, but are used to collect
92 # metadata, or do various checks. When such targets are triggered,
93 # some packages should not do their configuration sanity
94 # checks. Provide them a BR_BUILDING variable set to 'y' when we're
95 # actually building and they should do their sanity checks.
97 # We're building in two situations: when MAKECMDGOALS is empty
98 # (default target is to build), or when MAKECMDGOALS contains
99 # something else than one of the nobuild_targets.
100 nobuild_targets := source source-check \
101 legal-info external-deps _external-deps \
103 ifeq ($(MAKECMDGOALS),)
105 else ifneq ($(filter-out $(nobuild_targets),$(MAKECMDGOALS)),)
109 # Include some helper macros and variables
110 include support/misc/utils.mk
112 ifneq ("$(origin O)", "command line")
114 CONFIG_DIR := $(TOPDIR)
117 # other packages might also support Linux-style out of tree builds
118 # with the O=<dir> syntax (E.G. BusyBox does). As make automatically
119 # forwards command line variable definitions those packages get very
120 # confused. Fix this by telling make to not do so
122 # strangely enough O is still passed to submakes with MAKEOVERRIDES
123 # (with make 3.81 atleast), the only thing that changes is the output
124 # of the origin function (command line -> environment).
125 # Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+)
126 # To really make O go away, we have to override it.
129 # we need to pass O= everywhere we call back into the toplevel makefile
130 EXTRAMAKEARGS = O=$(O)
134 # bash prints the name of the directory on 'cd <dir>' if CDPATH is
135 # set, so unset it here to not cause problems. Notice that the export
136 # line doesn't affect the environment of $(shell ..) calls, so
137 # explictly throw away any output from 'cd' here.
139 BASE_DIR := $(shell mkdir -p $(O) && cd $(O) >/dev/null && pwd)
140 $(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
143 # Handling of BR2_EXTERNAL.
145 # The value of BR2_EXTERNAL is stored in .br-external in the output directory.
146 # On subsequent invocations of make, it is read in. It can still be overridden
147 # on the command line, therefore the file is re-created every time make is run.
149 # When BR2_EXTERNAL is set to an empty value (e.g. explicitly in command
150 # line), the .br-external file is removed and we point to
151 # support/dummy-external. This makes sure we can unconditionally include the
152 # Config.in and external.mk from the BR2_EXTERNAL directory. In this case,
153 # override is necessary so the user can clear BR2_EXTERNAL from the command
154 # line, but the dummy path is still used internally.
156 BR2_EXTERNAL_FILE = $(BASE_DIR)/.br-external
157 -include $(BR2_EXTERNAL_FILE)
158 ifeq ($(BR2_EXTERNAL),)
159 override BR2_EXTERNAL = support/dummy-external
160 $(shell rm -f $(BR2_EXTERNAL_FILE))
162 _BR2_EXTERNAL = $(shell cd $(BR2_EXTERNAL) >/dev/null 2>&1 && pwd)
163 ifeq ($(_BR2_EXTERNAL),)
164 $(error BR2_EXTERNAL='$(BR2_EXTERNAL)' does not exist, relative to $(TOPDIR))
166 override BR2_EXTERNAL := $(_BR2_EXTERNAL)
167 $(shell echo BR2_EXTERNAL ?= $(BR2_EXTERNAL) > $(BR2_EXTERNAL_FILE))
170 # To make sure that the environment variable overrides the .config option,
171 # set this before including .config.
172 ifneq ($(BR2_DL_DIR),)
173 DL_DIR := $(BR2_DL_DIR)
175 ifneq ($(BR2_CCACHE_DIR),)
176 BR_CACHE_DIR := $(BR2_CCACHE_DIR)
179 # Need that early, before we scan packages
180 # Avoids doing the $(or...) everytime
181 BR_GRAPH_OUT := $(or $(BR2_GRAPH_OUT),pdf)
183 BUILD_DIR := $(BASE_DIR)/build
184 BINARIES_DIR := $(BASE_DIR)/images
185 TARGET_DIR := $(BASE_DIR)/target
186 # initial definition so that 'make clean' works for most users, even without
187 # .config. HOST_DIR will be overwritten later when .config is included.
188 HOST_DIR := $(BASE_DIR)/host
189 GRAPHS_DIR := $(BASE_DIR)/graphs
191 LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
192 REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
193 REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
194 LICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses
195 LICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses
196 LEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv
197 LEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv
198 LEGAL_LICENSES_TXT_TARGET = $(LEGAL_INFO_DIR)/licenses.txt
199 LEGAL_LICENSES_TXT_HOST = $(LEGAL_INFO_DIR)/host-licenses.txt
200 LEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings
201 LEGAL_REPORT = $(LEGAL_INFO_DIR)/README
203 ################################################################################
205 # staging and target directories do NOT list these as
206 # dependencies anywhere else
208 ################################################################################
209 $(BUILD_DIR) $(TARGET_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
212 BR2_CONFIG = $(CONFIG_DIR)/.config
214 # Pull in the user's configuration file
215 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
216 -include $(BR2_CONFIG)
219 # timezone and locale may affect build output
220 ifeq ($(BR2_REPRODUCIBLE),y)
226 # To put more focus on warnings, be less verbose as default
227 # Use 'make V=1' to see the full commands
228 ifeq ("$(origin V)", "command line")
229 KBUILD_VERBOSE = $(V)
231 ifndef KBUILD_VERBOSE
235 ifeq ($(KBUILD_VERBOSE),1)
245 # kconfig uses CONFIG_SHELL
246 CONFIG_SHELL := $(SHELL)
248 export SHELL CONFIG_SHELL Q KBUILD_VERBOSE
258 HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
260 HOSTCC_NOCCACHE := $(HOSTCC)
263 HOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
265 HOSTCXX_NOCCACHE := $(HOSTCXX)
279 HOSTOBJCOPY := objcopy
284 HOSTAR := $(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
285 HOSTAS := $(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
286 HOSTCPP := $(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
287 HOSTLD := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
288 HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
289 HOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
290 HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
291 HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
293 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
294 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
296 # Determine the userland we are running on.
298 # Note that, despite its name, we are not interested in the actual
299 # architecture name. This is mostly used to determine whether some
300 # of the binary tools (e.g. pre-built external toolchains) can run
301 # on the current host. So we need to know if the userland we're
302 # running on can actually run those toolchains.
304 # For example, a 64-bit prebuilt toolchain will not run on a 64-bit
305 # kernel if the userland is 32-bit (e.g. in a chroot for example).
307 # So, we extract the first part of the tuple the host gcc was
308 # configured to generate code for; we assume this is our userland.
310 export HOSTARCH := $(shell LC_ALL=C $(HOSTCC_NOCCACHE) -v 2>&1 | \
311 sed -e '/^Target: \([^-]*\).*/!d' \
314 -e 's/sun4u/sparc64/' \
317 -e 's/ppc64/powerpc64/' \
318 -e 's/ppc/powerpc/' \
319 -e 's/macppc/powerpc/' \
322 HOSTCC_VERSION := $(shell $(HOSTCC_NOCCACHE) --version | \
323 sed -n -r 's/^.* ([0-9]*)\.([0-9]*)\.([0-9]*)[ ]*.*/\1 \2/p')
325 # For gcc >= 5.x, we only need the major version.
326 ifneq ($(firstword $(HOSTCC_VERSION)),4)
327 HOSTCC_VERSION := $(firstword $(HOSTCC_VERSION))
330 # Make sure pkg-config doesn't look outside the buildroot tree
331 HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
332 unexport PKG_CONFIG_PATH
333 unexport PKG_CONFIG_SYSROOT_DIR
334 unexport PKG_CONFIG_LIBDIR
336 # Having DESTDIR set in the environment confuses the installation
337 # steps of some packages.
340 # Causes breakage with packages that needs host-ruby
343 include package/pkg-utils.mk
344 include package/doc-asciidoc.mk
346 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
348 ################################################################################
350 # Hide troublesome environment variables from sub processes
352 ################################################################################
353 unexport CROSS_COMPILE
363 unexport GREP_OPTIONS
371 GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
376 # silent mode requested?
377 QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
379 # Strip off the annoying quoting
380 ARCH := $(call qstrip,$(BR2_ARCH))
382 KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
383 -e s/i.86/i386/ -e s/sun4u/sparc64/ \
386 -e s/arm.*/arm/ -e s/sa110/arm/ \
387 -e s/aarch64.*/arm64/ \
388 -e s/bfin/blackfin/ \
389 -e s/parisc64/parisc/ \
390 -e s/powerpc64.*/powerpc/ \
391 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
393 -e s/microblazeel/microblaze/)
395 ZCAT := $(call qstrip,$(BR2_ZCAT))
396 BZCAT := $(call qstrip,$(BR2_BZCAT))
397 XZCAT := $(call qstrip,$(BR2_XZCAT))
398 TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
400 # packages compiled for the host go here
401 HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
403 # Quotes are needed for spaces and all in the original PATH content.
404 BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin:$(PATH)"
406 # Location of a file giving a big fat warning that output/target
407 # should not be used as the root filesystem.
408 TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
410 ifeq ($(BR2_CCACHE),y)
411 CCACHE := $(HOST_DIR)/usr/bin/ccache
412 BR_CACHE_DIR ?= $(call qstrip,$(BR2_CCACHE_DIR))
414 HOSTCC := $(CCACHE) $(HOSTCC)
415 HOSTCXX := $(CCACHE) $(HOSTCXX)
420 # Scripts in support/ or post-build scripts may need to reference
421 # these locations, so export them so it is easier to use
423 export BR2_REPRODUCIBLE
430 ################################################################################
432 # You should probably leave this stuff alone unless you know
433 # what you are doing.
435 ################################################################################
439 # Include legacy before the other things, because package .mk files
441 ifneq ($(BR2_DEPRECATED),y)
442 include Makefile.legacy
445 include package/Makefile.in
446 include support/dependencies/dependencies.mk
448 include toolchain/*.mk
449 include toolchain/*/*.mk
451 # Include the package override file if one has been provided in the
453 PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
454 ifneq ($(PACKAGE_OVERRIDE_FILE),)
455 -include $(PACKAGE_OVERRIDE_FILE)
458 include $(sort $(wildcard package/*/*.mk))
460 include boot/common.mk
461 include linux/linux.mk
464 include $(BR2_EXTERNAL)/external.mk
466 # Now we are sure we have all the packages scanned and defined. We now
467 # check for each package in the list of enabled packages, that all its
468 # dependencies are indeed enabled.
470 # Only trigger the check for default builds. If the user forces building
471 # a package, even if not enabled in the configuration, we want to accept
474 ifeq ($(MAKECMDGOALS),)
476 define CHECK_ONE_DEPENDENCY
477 ifeq ($$($(2)_TYPE),target)
478 ifeq ($$($(2)_IS_VIRTUAL),)
479 ifneq ($$($$($(2)_KCONFIG_VAR)),y)
480 $$(error $$($(2)_NAME) is in the dependency chain of $$($(1)_NAME) that \
481 has added it to its _DEPENDENCIES variable without selecting it or \
482 depending on it from Config.in)
488 $(foreach pkg,$(call UPPERCASE,$(PACKAGES)),\
489 $(foreach dep,$(call UPPERCASE,$($(pkg)_FINAL_ALL_DEPENDENCIES)),\
490 $(eval $(call CHECK_ONE_DEPENDENCY,$(pkg),$(dep))$(sep))))
494 dirs: $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
495 $(HOST_DIR) $(BINARIES_DIR)
497 $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
498 $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
500 prepare: $(BUILD_DIR)/buildroot-config/auto.conf
502 world: target-post-image
504 .PHONY: all world toolchain dirs clean distclean source outputmakefile \
505 legal-info legal-info-prepare legal-info-clean printvars help \
506 list-defconfigs target-finalize target-post-image source-check
508 # Populating the staging with the base directories is handled by the skeleton package
510 @mkdir -p $(STAGING_DIR)
511 @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
513 RSYNC_VCS_EXCLUSIONS = \
514 --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
517 STRIP_FIND_CMD = find $(TARGET_DIR)
518 ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
519 STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
521 STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
523 # - libpthread.so: a non-stripped libpthread shared library is needed for
524 # proper debugging of pthread programs using gdb.
525 # - ld.so: a non-stripped dynamic linker library is needed for valgrind
526 # - kernel modules (*.ko): do not function properly when stripped like normal
527 # applications and libraries. Normally kernel modules are already excluded
528 # by the executable permission check above, so the explicit exclusion is only
529 # done for kernel modules with incorrect permissions.
530 STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* ld-*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print0
532 ifeq ($(BR2_ECLIPSE_REGISTER),y)
533 define TOOLCHAIN_ECLIPSE_REGISTER
534 ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \
535 $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
537 TARGET_FINALIZE_HOOKS += TOOLCHAIN_ECLIPSE_REGISTER
540 # Generate locale data. Basically, we call the localedef program
541 # (built by the host-localedef package) for each locale. The input
542 # data comes preferably from the toolchain, or if the toolchain does
543 # not have them (Linaro toolchains), we use the ones available on the
545 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
546 GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
547 ifneq ($(GLIBC_GENERATE_LOCALES),)
548 PACKAGES += host-localedef
550 define GENERATE_GLIBC_LOCALES
551 $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
552 $(Q)for locale in $(GLIBC_GENERATE_LOCALES) ; do \
553 inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
554 charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
555 if test -z "$${charmap}" ; then \
558 echo "Generating locale $${inputfile}.$${charmap}" ; \
559 I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
560 $(HOST_DIR)/usr/bin/localedef \
561 --prefix=$(TARGET_DIR) \
562 --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
563 -i $${inputfile} -f $${charmap} \
567 TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
571 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
572 LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
573 LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
575 # This piece of junk does the following:
576 # First collect the whitelist in a file.
577 # Then go over all the locale dirs and for each subdir, check if it exists
578 # in the whitelist file. If it doesn't, kill it.
579 # Finally, specifically for X11, regenerate locale.dir from the whitelist.
581 rm -f $(LOCALE_WHITELIST)
582 for i in $(LOCALE_NOPURGE) locale-archive; do echo $$i >> $(LOCALE_WHITELIST); done
584 for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/lib/locale)); \
586 for langdir in $$dir/*; \
588 if [ -e "$${langdir}" ]; \
590 grep -qx "$${langdir##*/}" $(LOCALE_WHITELIST) || rm -rf $$langdir; \
594 if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \
596 for lang in $(LOCALE_NOPURGE); \
598 if [ -f $(TARGET_DIR)/usr/share/X11/locale/$$lang/XLC_LOCALE ]; \
600 echo "$$lang/XLC_LOCALE: $$lang"; \
602 done > $(TARGET_DIR)/usr/share/X11/locale/locale.dir; \
605 TARGET_FINALIZE_HOOKS += PURGE_LOCALES
608 $(TARGETS_ROOTFS): target-finalize
610 target-finalize: $(PACKAGES)
611 @$(call MESSAGE,"Finalizing target directory")
612 $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
613 rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
614 $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
615 $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
616 find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
617 find $(TARGET_DIR)/lib $(TARGET_DIR)/usr/lib $(TARGET_DIR)/usr/libexec \
618 \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
619 ifneq ($(BR2_PACKAGE_GDB),y)
620 rm -rf $(TARGET_DIR)/usr/share/gdb
622 ifneq ($(BR2_PACKAGE_BASH),y)
623 rm -rf $(TARGET_DIR)/usr/share/bash-completion
625 ifneq ($(BR2_PACKAGE_ZSH),y)
626 rm -rf $(TARGET_DIR)/usr/share/zsh
628 rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
629 rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
630 rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
631 rm -rf $(TARGET_DIR)/usr/share/gtk-doc
632 -rmdir $(TARGET_DIR)/usr/share 2>/dev/null
633 $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
634 if test -d $(TARGET_DIR)/lib/modules; then \
635 find $(TARGET_DIR)/lib/modules -type f -name '*.ko' -print0 | \
636 xargs -0 -r $(KSTRIPCMD); fi
638 # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
639 # besides the one in which crash occurred; or SIGTRAP kills my program when
640 # I set a breakpoint"
641 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
642 find $(TARGET_DIR)/lib -type f -name 'libpthread*.so*' | \
643 xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
646 # Valgrind needs ld.so with enough information, so only strip
648 find $(TARGET_DIR)/lib -type f -name 'ld-*.so*' | \
649 xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
650 test -f $(TARGET_DIR)/etc/ld.so.conf && \
651 { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
652 test -d $(TARGET_DIR)/etc/ld.so.conf.d && \
653 { echo "ERROR: we shouldn't have a /etc/ld.so.conf.d directory"; exit 1; } || true
654 mkdir -p $(TARGET_DIR)/etc
656 echo "NAME=Buildroot"; \
657 echo "VERSION=$(BR2_VERSION_FULL)"; \
658 echo "ID=buildroot"; \
659 echo "VERSION_ID=$(BR2_VERSION)"; \
660 echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
661 ) > $(TARGET_DIR)/etc/os-release
663 @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
664 $(call MESSAGE,"Copying overlay $(d)"); \
665 rsync -a --ignore-times --keep-dirlinks $(RSYNC_VCS_EXCLUSIONS) \
666 --chmod=u=rwX,go=rX --exclude .empty --exclude '*~' \
667 $(d)/ $(TARGET_DIR)$(sep))
669 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
670 $(call MESSAGE,"Executing post-build script $(s)"); \
671 $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
673 target-post-image: $(TARGETS_ROOTFS) target-finalize
674 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
675 $(call MESSAGE,"Executing post-image script $(s)"); \
676 $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
678 source: $(foreach p,$(PACKAGES),$(p)-all-source)
680 _external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
682 @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
684 # check if download URLs are outdated
685 source-check: $(foreach p,$(PACKAGES),$(p)-all-source-check)
688 @rm -fr $(LEGAL_INFO_DIR)
690 legal-info-prepare: $(LEGAL_INFO_DIR)
691 @$(call MESSAGE,"Collecting legal info")
692 @$(call legal-license-file,buildroot,COPYING,COPYING,HOST)
693 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
694 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
695 @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPLv2+,COPYING,not saved,not saved,HOST)
696 @$(call legal-warning,the Buildroot source code has not been saved)
697 @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
699 legal-info: dirs legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
700 $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
701 @cat support/legal-info/README.header >>$(LEGAL_REPORT)
702 @if [ -r $(LEGAL_WARNINGS) ]; then \
703 cat support/legal-info/README.warnings-header \
704 $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
705 cat $(LEGAL_WARNINGS); fi
706 @rm -f $(LEGAL_WARNINGS)
707 @(cd $(LEGAL_INFO_DIR); \
708 find * -type f -exec sha256sum {} + | LC_ALL=C sort -k2 \
709 >.legal-info.sha256; \
710 mv .legal-info.sha256 legal-info.sha256)
711 @echo "Legal info produced in $(LEGAL_INFO_DIR)"
714 @echo $(PACKAGES) $(TARGETS_ROOTFS)
716 graph-build: $(O)/build/build-time.log
717 @install -d $(GRAPHS_DIR)
718 $(foreach o,name build duration,./support/scripts/graph-build-time \
719 --type=histogram --order=$(o) --input=$(<) \
720 --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
721 $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
722 $(foreach t,packages steps,./support/scripts/graph-build-time \
723 --type=pie-$(t) --input=$(<) \
724 --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
725 $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
727 graph-depends-requirements:
728 @dot -? >/dev/null 2>&1 || \
729 { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
731 graph-depends: graph-depends-requirements
732 @$(INSTALL) -d $(GRAPHS_DIR)
733 @cd "$(CONFIG_DIR)"; \
734 $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
735 -o $(GRAPHS_DIR)/$(@).dot
736 dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \
737 -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \
738 $(GRAPHS_DIR)/$(@).dot
741 $(Q)mkdir -p $(GRAPHS_DIR)
742 $(Q)$(TOPDIR)/support/scripts/size-stats --builddir $(BASE_DIR) \
743 --graph $(GRAPHS_DIR)/graph-size.$(BR_GRAPH_OUT) \
744 --file-size-csv $(GRAPHS_DIR)/file-size-stats.csv \
745 --package-size-csv $(GRAPHS_DIR)/package-size-stats.csv
748 @cd "$(CONFIG_DIR)"; \
749 $(TOPDIR)/support/scripts/graph-depends -C
751 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
755 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
758 # ---------------------------------------------------------------------------
760 HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
763 .PHONY: prepare-kconfig
764 prepare-kconfig: outputmakefile $(BUILD_DIR)/.br2-external.in
766 $(BUILD_DIR)/buildroot-config/%onf:
767 mkdir -p $(@D)/lxdialog
768 PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
769 obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
771 DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
773 # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
774 # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
775 COMMON_CONFIG_ENV = \
776 BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
777 KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
778 KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
779 KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
780 BR2_CONFIG=$(BR2_CONFIG) \
781 BR2_EXTERNAL=$(BR2_EXTERNAL) \
782 HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
783 BUILD_DIR=$(BUILD_DIR) \
786 xconfig: $(BUILD_DIR)/buildroot-config/qconf prepare-kconfig
787 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
789 gconfig: $(BUILD_DIR)/buildroot-config/gconf prepare-kconfig
790 @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
792 menuconfig: $(BUILD_DIR)/buildroot-config/mconf prepare-kconfig
793 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
795 nconfig: $(BUILD_DIR)/buildroot-config/nconf prepare-kconfig
796 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
798 config: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
799 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
801 # For the config targets that automatically select options, we pass
802 # SKIP_LEGACY=y to disable the legacy options. However, in that case
803 # no values are set for the legacy options so a subsequent oldconfig
804 # will query them. Therefore, run an additional olddefconfig.
806 oldconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
807 @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
809 randconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
810 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --randconfig $(CONFIG_CONFIG_IN)
811 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
813 allyesconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
814 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allyesconfig $(CONFIG_CONFIG_IN)
815 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
817 allnoconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
818 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allnoconfig $(CONFIG_CONFIG_IN)
819 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
821 randpackageconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
822 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
823 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
824 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
825 $< --randconfig $(CONFIG_CONFIG_IN)
826 @rm -f $(CONFIG_DIR)/.config.nopkg
827 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
829 allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
830 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
831 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
832 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
833 $< --allyesconfig $(CONFIG_CONFIG_IN)
834 @rm -f $(CONFIG_DIR)/.config.nopkg
835 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
837 allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
838 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
839 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
840 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
841 $< --allnoconfig $(CONFIG_CONFIG_IN)
842 @rm -f $(CONFIG_DIR)/.config.nopkg
843 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
845 silentoldconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
846 $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)
848 olddefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
849 $(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN)
851 defconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
852 @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
854 define percent_defconfig
855 # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
856 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(1)/configs/%_defconfig prepare-kconfig
857 @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \
858 $$< --defconfig=$(1)/configs/$$@ $$(CONFIG_CONFIG_IN)
860 $(eval $(foreach d,$(TOPDIR) $(BR2_EXTERNAL),$(call percent_defconfig,$(d))$(sep)))
862 savedefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
863 @$(COMMON_CONFIG_ENV) $< \
864 --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
866 @$(SED) '/BR2_DEFCONFIG=/d' $(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig)
868 .PHONY: defconfig savedefconfig
870 ################################################################################
872 # Cleanup and misc junk
874 ################################################################################
876 # outputmakefile generates a Makefile in the output directory, if using a
877 # separate output directory. This allows convenient use of make in the
880 ifeq ($(NEED_WRAPPER),y)
881 $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
884 # Even though the target is a real file, we mark it as PHONY as we
885 # want it to be re-generated each time make is invoked, in case the
886 # value of BR2_EXTERNAL is changed.
887 .PHONY: $(BUILD_DIR)/.br2-external.in
888 $(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
891 # printvars prints all the variables currently defined in our
892 # Makefiles. Alternatively, if a non-empty VARS variable is passed,
893 # only the variables matching the make pattern passed in VARS are
897 $(sort $(if $(VARS),$(filter $(VARS),$(.VARIABLES)),$(.VARIABLES))), \
898 $(if $(filter-out environment% default automatic, \
900 $(info $V=$($V) ($(value $V)))))
903 rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
904 $(BUILD_DIR) $(BASE_DIR)/staging \
905 $(LEGAL_INFO_DIR) $(GRAPHS_DIR)
908 ifeq ($(DL_DIR),$(TOPDIR)/dl)
914 rm -rf $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
915 $(CONFIG_DIR)/.auto.deps $(BR2_EXTERNAL_FILE)
919 @echo ' clean - delete all files created by build'
920 @echo ' distclean - delete all non-source files (including .config)'
923 @echo ' all - make world'
924 @echo ' toolchain - build toolchain'
926 @echo 'Configuration:'
927 @echo ' menuconfig - interactive curses-based configurator'
928 @echo ' nconfig - interactive ncurses-based configurator'
929 @echo ' xconfig - interactive Qt-based configurator'
930 @echo ' gconfig - interactive GTK-based configurator'
931 @echo ' oldconfig - resolve any unresolved symbols in .config'
932 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
933 @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
934 @echo ' randconfig - New config with random answer to all options'
935 @echo ' defconfig - New config with default answer to all options'
936 @echo ' BR2_DEFCONFIG, if set, is used as input'
937 @echo ' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
938 @echo ' allyesconfig - New config where all options are accepted with yes'
939 @echo ' allnoconfig - New config where all options are answered with no'
940 @echo ' randpackageconfig - New config with random answer to package options'
941 @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
942 @echo ' allnopackageconfig - New config where package options are answered with no'
944 @echo 'Package-specific:'
945 @echo ' <pkg> - Build and install <pkg> and all its dependencies'
946 @echo ' <pkg>-source - Only download the source files for <pkg>'
947 @echo ' <pkg>-extract - Extract <pkg> sources'
948 @echo ' <pkg>-patch - Apply patches to <pkg>'
949 @echo ' <pkg>-depends - Build <pkg>'\''s dependencies'
950 @echo ' <pkg>-configure - Build <pkg> up to the configure step'
951 @echo ' <pkg>-build - Build <pkg> up to the build step'
952 @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
953 @echo ' <pkg>-dirclean - Remove <pkg> build directory'
954 @echo ' <pkg>-reconfigure - Restart the build from the configure step'
955 @echo ' <pkg>-rebuild - Restart the build from the build step'
956 $(foreach p,$(HELP_PACKAGES), \
958 @echo '$($(p)_NAME):' $(sep) \
959 $($(p)_HELP_CMDS)$(sep))
961 @echo 'Documentation:'
962 @echo ' manual - build manual in all formats'
963 @echo ' manual-html - build manual in HTML'
964 @echo ' manual-split-html - build manual in split HTML'
965 @echo ' manual-pdf - build manual in PDF'
966 @echo ' manual-text - build manual in text'
967 @echo ' manual-epub - build manual in ePub'
968 @echo ' graph-build - generate graphs of the build times'
969 @echo ' graph-depends - generate graph of the dependency tree'
970 @echo ' graph-size - generate stats of the filesystem size'
971 @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
973 @echo 'Miscellaneous:'
974 @echo ' source - download all sources needed for offline-build'
975 @echo ' source-check - check selected packages for valid download URLs'
976 @echo ' external-deps - list external packages used'
977 @echo ' legal-info - generate info about license compliance'
979 @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
980 @echo ' make O=dir - Locate all output files in "dir", including .config'
982 @echo 'For further details, see README, generate the Buildroot manual, or consult'
983 @echo 'it on-line at http://buildroot.org/docs.html'
987 @echo 'Built-in configs:'
988 @$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
989 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
990 ifneq ($(wildcard $(BR2_EXTERNAL)/configs/*_defconfig),)
992 @echo 'User-provided configs:'
993 @$(foreach b, $(sort $(notdir $(wildcard $(BR2_EXTERNAL)/configs/*_defconfig))), \
994 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
998 release: OUT = buildroot-$(BR2_VERSION)
1000 # Create release tarballs. We need to fiddle a bit to add the generated
1001 # documentation to the git output
1003 git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
1004 $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
1005 $(MAKE) O=$(OUT) manual-clean
1006 tar rf $(OUT).tar $(OUT)
1007 gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
1008 bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
1009 rm -rf $(OUT) $(OUT).tar
1012 @echo $(BR2_VERSION_FULL)
1014 include docs/manual/manual.mk
1015 -include $(BR2_EXTERNAL)/docs/*/*.mk
1017 .PHONY: $(noconfig_targets)