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 # This is our default rule, so must come first
30 # Set and export the version string
31 export BR2_VERSION := 2015.05-git
33 # Check for minimal make version (note: this check will break at make 10.x)
34 MIN_MAKE_VERSION = 3.81
35 ifneq ($(firstword $(sort $(MAKE_VERSION) $(MIN_MAKE_VERSION))),$(MIN_MAKE_VERSION))
36 $(error You have make '$(MAKE_VERSION)' installed. GNU make >= $(MIN_MAKE_VERSION) is required)
39 export HOSTARCH := $(shell uname -m | \
44 -e s/ppc64/powerpc64/ \
49 # Parallel execution of this Makefile is disabled because it changes
50 # the packages building order, that can be a problem for two reasons:
51 # - If a package has an unspecified optional dependency and that
52 # dependency is present when the package is built, it is used,
53 # otherwise it isn't (but compilation happily proceeds) so the end
54 # result will differ if the order is swapped due to parallel
56 # - Also changing the building order can be a problem if two packages
57 # manipulate the same file in the target directory.
59 # Taking into account the above considerations, if you still want to execute
60 # this top-level Makefile in parallel comment the ".NOTPARALLEL" line and
61 # build using the following command:
62 # make BR2_JLEVEL= -j$((`getconf _NPROCESSORS_ONLN`+1))
66 TOPDIR := $(shell pwd)
67 CONFIG_CONFIG_IN = Config.in
68 CONFIG = support/kconfig
69 DATE := $(shell date +%Y%m%d)
71 # Compute the full local version string so packages can use it as-is
72 # Need to export it, so it can be got from environment in children (eg. mconf)
73 export BR2_VERSION_FULL := $(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlocalversion)
75 noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconfig \
76 defconfig %_defconfig allyesconfig allnoconfig silentoldconfig release \
77 randpackageconfig allyespackageconfig allnopackageconfig \
78 print-version olddefconfig
80 # Some global targets do not trigger a build, but are used to collect
81 # metadata, or do various checks. When such targets are triggered,
82 # some packages should not do their configuration sanity
83 # checks. Provide them a BR_BUILDING variable set to 'y' when we're
84 # actually building and they should do their sanity checks.
86 # We're building in two situations: when MAKECMDGOALS is empty
87 # (default target is to build), or when MAKECMDGOALS contains
88 # something else than one of the nobuild_targets.
89 nobuild_targets := source source-check \
90 legal-info external-deps _external-deps \
92 ifeq ($(MAKECMDGOALS),)
94 else ifneq ($(filter-out $(nobuild_targets),$(MAKECMDGOALS)),)
98 # Strip quotes and then whitespaces
99 qstrip = $(strip $(subst ",,$(1)))
102 # Variables for use in Make constructs
105 space := $(empty) $(empty)
107 ifneq ("$(origin O)", "command line")
109 CONFIG_DIR := $(TOPDIR)
112 # other packages might also support Linux-style out of tree builds
113 # with the O=<dir> syntax (E.G. BusyBox does). As make automatically
114 # forwards command line variable definitions those packages get very
115 # confused. Fix this by telling make to not do so
117 # strangely enough O is still passed to submakes with MAKEOVERRIDES
118 # (with make 3.81 atleast), the only thing that changes is the output
119 # of the origin function (command line -> environment).
120 # Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+)
121 # To really make O go away, we have to override it.
124 # we need to pass O= everywhere we call back into the toplevel makefile
125 EXTRAMAKEARGS = O=$(O)
129 # bash prints the name of the directory on 'cd <dir>' if CDPATH is
130 # set, so unset it here to not cause problems. Notice that the export
131 # line doesn't affect the environment of $(shell ..) calls, so
132 # explictly throw away any output from 'cd' here.
134 BASE_DIR := $(shell mkdir -p $(O) && cd $(O) >/dev/null && pwd)
135 $(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
138 # Handling of BR2_EXTERNAL.
140 # The value of BR2_EXTERNAL is stored in .br-external in the output directory.
141 # On subsequent invocations of make, it is read in. It can still be overridden
142 # on the command line, therefore the file is re-created every time make is run.
144 # When BR2_EXTERNAL is set to an empty value (e.g. explicitly in command
145 # line), the .br-external file is removed and we point to
146 # support/dummy-external. This makes sure we can unconditionally include the
147 # Config.in and external.mk from the BR2_EXTERNAL directory. In this case,
148 # override is necessary so the user can clear BR2_EXTERNAL from the command
149 # line, but the dummy path is still used internally.
151 BR2_EXTERNAL_FILE = $(BASE_DIR)/.br-external
152 -include $(BR2_EXTERNAL_FILE)
153 ifeq ($(BR2_EXTERNAL),)
154 override BR2_EXTERNAL = support/dummy-external
155 $(shell rm -f $(BR2_EXTERNAL_FILE))
157 _BR2_EXTERNAL = $(shell cd $(BR2_EXTERNAL) >/dev/null 2>&1 && pwd)
158 ifeq ($(_BR2_EXTERNAL),)
159 $(error BR2_EXTERNAL='$(BR2_EXTERNAL)' does not exist, relative to $(TOPDIR))
161 override BR2_EXTERNAL := $(_BR2_EXTERNAL)
162 $(shell echo BR2_EXTERNAL ?= $(BR2_EXTERNAL) > $(BR2_EXTERNAL_FILE))
165 # To make sure that the environment variable overrides the .config option,
166 # set this before including .config.
167 ifneq ($(BR2_DL_DIR),)
168 DL_DIR := $(BR2_DL_DIR)
172 # Need that early, before we scan packages
173 # Avoids doing the $(or...) everytime
174 BR_GRAPH_OUT := $(or $(BR2_GRAPH_OUT),pdf)
176 BUILD_DIR := $(BASE_DIR)/build
177 BINARIES_DIR := $(BASE_DIR)/images
178 TARGET_DIR := $(BASE_DIR)/target
179 # initial definition so that 'make clean' works for most users, even without
180 # .config. HOST_DIR will be overwritten later when .config is included.
181 HOST_DIR := $(BASE_DIR)/host
182 GRAPHS_DIR := $(BASE_DIR)/graphs
184 LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
185 REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
186 REDIST_SOURCES_DIR_HOST = $(LEGAL_INFO_DIR)/host-sources
187 LICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses
188 LICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses
189 LEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv
190 LEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv
191 LEGAL_LICENSES_TXT_TARGET = $(LEGAL_INFO_DIR)/licenses.txt
192 LEGAL_LICENSES_TXT_HOST = $(LEGAL_INFO_DIR)/host-licenses.txt
193 LEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings
194 LEGAL_REPORT = $(LEGAL_INFO_DIR)/README
196 BR2_CONFIG = $(CONFIG_DIR)/.config
198 # Pull in the user's configuration file
199 ifeq ($(filter $(noconfig_targets),$(MAKECMDGOALS)),)
200 -include $(BR2_CONFIG)
203 # To put more focus on warnings, be less verbose as default
204 # Use 'make V=1' to see the full commands
205 ifeq ("$(origin V)", "command line")
206 KBUILD_VERBOSE = $(V)
208 ifndef KBUILD_VERBOSE
212 ifeq ($(KBUILD_VERBOSE),1)
223 # we want bash as shell
224 SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
225 else if [ -x /bin/bash ]; then echo /bin/bash; \
226 else echo sh; fi; fi)
228 # kconfig uses CONFIG_SHELL
229 CONFIG_SHELL := $(SHELL)
231 export SHELL CONFIG_SHELL quiet Q KBUILD_VERBOSE VERBOSE
241 HOSTCC := $(shell which $(HOSTCC) || type -p $(HOSTCC) || echo gcc)
243 HOSTCC_NOCCACHE := $(HOSTCC)
246 HOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
248 HOSTCXX_NOCCACHE := $(HOSTCXX)
262 HOSTOBJCOPY := objcopy
267 HOSTAR := $(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
268 HOSTAS := $(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
269 HOSTCPP := $(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
270 HOSTLD := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
271 HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
272 HOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
273 HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
274 HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
276 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
277 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
279 # Make sure pkg-config doesn't look outside the buildroot tree
280 HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
281 unexport PKG_CONFIG_PATH
282 unexport PKG_CONFIG_SYSROOT_DIR
283 unexport PKG_CONFIG_LIBDIR
285 # Having DESTDIR set in the environment confuses the installation
286 # steps of some packages.
289 # Causes breakage with packages that needs host-ruby
292 include package/pkg-utils.mk
293 include package/doc-asciidoc.mk
295 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
297 ################################################################################
299 # Hide troublesome environment variables from sub processes
301 ################################################################################
302 unexport CROSS_COMPILE
309 unexport GREP_OPTIONS
316 GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
320 # silent mode requested?
321 QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
323 # Strip off the annoying quoting
324 ARCH := $(call qstrip,$(BR2_ARCH))
326 KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
327 -e s/i.86/i386/ -e s/sun4u/sparc64/ \
330 -e s/arm.*/arm/ -e s/sa110/arm/ \
331 -e s/aarch64/arm64/ \
332 -e s/bfin/blackfin/ \
333 -e s/parisc64/parisc/ \
334 -e s/powerpc64.*/powerpc/ \
335 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
337 -e s/microblazeel/microblaze/)
339 ZCAT := $(call qstrip,$(BR2_ZCAT))
340 BZCAT := $(call qstrip,$(BR2_BZCAT))
341 XZCAT := $(call qstrip,$(BR2_XZCAT))
342 TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
344 # packages compiled for the host go here
345 HOST_DIR := $(call qstrip,$(BR2_HOST_DIR))
347 # Quotes are needed for spaces and all in the original PATH content.
348 BR_PATH = "$(HOST_DIR)/bin:$(HOST_DIR)/sbin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin:$(PATH)"
350 TARGET_SKELETON = $(TOPDIR)/system/skeleton
352 # Location of a file giving a big fat warning that output/target
353 # should not be used as the root filesystem.
354 TARGET_DIR_WARNING_FILE = $(TARGET_DIR)/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
356 ifeq ($(BR2_CCACHE),y)
357 CCACHE := $(HOST_DIR)/usr/bin/ccache
358 BR_CACHE_DIR = $(call qstrip,$(BR2_CCACHE_DIR))
360 HOSTCC := $(CCACHE) $(HOSTCC)
361 HOSTCXX := $(CCACHE) $(HOSTCXX)
364 # Scripts in support/ or post-build scripts may need to reference
365 # these locations, so export them so it is easier to use
373 ################################################################################
375 # You should probably leave this stuff alone unless you know
376 # what you are doing.
378 ################################################################################
382 # Include legacy before the other things, because package .mk files
384 ifneq ($(BR2_DEPRECATED),y)
385 include Makefile.legacy
388 include package/Makefile.in
389 include support/dependencies/dependencies.mk
391 include toolchain/*.mk
392 include toolchain/*/*.mk
394 # Include the package override file if one has been provided in the
396 PACKAGE_OVERRIDE_FILE = $(call qstrip,$(BR2_PACKAGE_OVERRIDE_FILE))
397 ifneq ($(PACKAGE_OVERRIDE_FILE),)
398 -include $(PACKAGE_OVERRIDE_FILE)
401 include $(sort $(wildcard package/*/*.mk))
403 include boot/common.mk
404 include linux/linux.mk
405 include system/system.mk
408 include $(BR2_EXTERNAL)/external.mk
410 dirs: $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
411 $(HOST_DIR) $(BINARIES_DIR)
413 $(BUILD_DIR)/buildroot-config/auto.conf: $(BR2_CONFIG)
414 $(MAKE1) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig
416 prepare: $(BUILD_DIR)/buildroot-config/auto.conf
418 world: target-post-image
420 .PHONY: all world toolchain dirs clean distclean source outputmakefile \
421 legal-info legal-info-prepare legal-info-clean printvars help \
422 list-defconfigs target-finalize target-post-image source-check
424 ################################################################################
426 # staging and target directories do NOT list these as
427 # dependencies anywhere else
429 ################################################################################
430 $(BUILD_DIR) $(HOST_DIR) $(BINARIES_DIR) $(LEGAL_INFO_DIR) $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST):
433 # We make a symlink lib32->lib or lib64->lib as appropriate
434 # MIPS64/n32 requires lib32 even though it's a 64-bit arch.
435 ifeq ($(BR2_ARCH_IS_64)$(BR2_MIPS_NABI32),y)
442 @mkdir -p $(STAGING_DIR)/bin
443 @mkdir -p $(STAGING_DIR)/lib
444 @ln -snf lib $(STAGING_DIR)/$(LIB_SYMLINK)
445 @mkdir -p $(STAGING_DIR)/usr/lib
446 @ln -snf lib $(STAGING_DIR)/usr/$(LIB_SYMLINK)
447 @mkdir -p $(STAGING_DIR)/usr/include
448 @mkdir -p $(STAGING_DIR)/usr/bin
449 @ln -snf $(STAGING_DIR) $(BASE_DIR)/staging
451 ifeq ($(BR2_ROOTFS_SKELETON_CUSTOM),y)
452 TARGET_SKELETON = $(BR2_ROOTFS_SKELETON_CUSTOM_PATH)
455 RSYNC_VCS_EXCLUSIONS = \
456 --exclude .svn --exclude .git --exclude .hg --exclude .bzr \
460 mkdir -p $(TARGET_DIR)
461 rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
462 --chmod=Du+w --exclude .empty --exclude '*~' \
463 $(TARGET_SKELETON)/ $(TARGET_DIR)/
464 $(INSTALL) -m 0644 support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE)
465 @ln -snf lib $(TARGET_DIR)/$(LIB_SYMLINK)
466 @mkdir -p $(TARGET_DIR)/usr
467 @ln -snf lib $(TARGET_DIR)/usr/$(LIB_SYMLINK)
470 $(TARGET_DIR): $(BUILD_DIR)/.root
472 STRIP_FIND_CMD = find $(TARGET_DIR)
473 ifneq (,$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS)))
474 STRIP_FIND_CMD += \( $(call finddirclauses,$(TARGET_DIR),$(call qstrip,$(BR2_STRIP_EXCLUDE_DIRS))) \) -prune -o
476 STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
478 # - libpthread.so: a non-stripped libpthread shared library is needed for
479 # proper debugging of pthread programs using gdb.
480 # - kernel modules (*.ko): do not function properly when stripped like normal
481 # applications and libraries. Normally kernel modules are already excluded
482 # by the executable permission check above, so the explicit exclusion is only
483 # done for kernel modules with incorrect permissions.
484 STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print0
486 ifeq ($(BR2_ECLIPSE_REGISTER),y)
487 define TOOLCHAIN_ECLIPSE_REGISTER
488 ./support/scripts/eclipse-register-toolchain `readlink -f $(O)` \
489 $(notdir $(TARGET_CROSS)) $(BR2_ARCH)
491 TARGET_FINALIZE_HOOKS += TOOLCHAIN_ECLIPSE_REGISTER
494 # Generate locale data. Basically, we call the localedef program
495 # (built by the host-localedef package) for each locale. The input
496 # data comes preferably from the toolchain, or if the toolchain does
497 # not have them (Linaro toolchains), we use the ones available on the
499 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
500 GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
501 ifneq ($(GLIBC_GENERATE_LOCALES),)
502 PACKAGES += host-localedef
504 define GENERATE_GLIBC_LOCALES
505 $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
506 $(Q)for locale in $(GLIBC_GENERATE_LOCALES) ; do \
507 inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
508 charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
509 if test -z "$${charmap}" ; then \
512 echo "Generating locale $${inputfile}.$${charmap}" ; \
513 I18NPATH=$(STAGING_DIR)/usr/share/i18n:/usr/share/i18n \
514 $(HOST_DIR)/usr/bin/localedef \
515 --prefix=$(TARGET_DIR) \
516 --$(call LOWERCASE,$(BR2_ENDIAN))-endian \
517 -i $${inputfile} -f $${charmap} \
521 TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
525 ifeq ($(BR2_ENABLE_LOCALE_PURGE),y)
526 LOCALE_WHITELIST = $(BUILD_DIR)/locales.nopurge
527 LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
530 rm -f $(LOCALE_WHITELIST)
531 for i in $(LOCALE_NOPURGE) locale-archive; do echo $$i >> $(LOCALE_WHITELIST); done
533 for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/man /usr/share/man /usr/lib/locale)); \
535 for lang in $$(cd $$dir; ls .|grep -v man); \
537 grep -qx $$lang $(LOCALE_WHITELIST) || rm -rf $$dir/$$lang; \
541 TARGET_FINALIZE_HOOKS += PURGE_LOCALES
544 $(TARGETS_ROOTFS): target-finalize
546 target-finalize: $(PACKAGES)
547 @$(call MESSAGE,"Finalizing target directory")
548 $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
549 rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
550 $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
551 $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
552 find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
553 find $(TARGET_DIR)/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
554 find $(TARGET_DIR)/usr/lib \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
555 ifneq ($(BR2_PACKAGE_GDB),y)
556 rm -rf $(TARGET_DIR)/usr/share/gdb
558 rm -rf $(TARGET_DIR)/usr/man $(TARGET_DIR)/usr/share/man
559 rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
560 rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
561 rm -rf $(TARGET_DIR)/usr/share/gtk-doc
562 -rmdir $(TARGET_DIR)/usr/share 2>/dev/null
563 $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
564 if test -d $(TARGET_DIR)/lib/modules; then \
565 find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | \
566 xargs -r $(KSTRIPCMD); fi
568 # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
569 # besides the one in which crash occurred; or SIGTRAP kills my program when
570 # I set a breakpoint"
571 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
572 find $(TARGET_DIR)/lib -type f -name 'libpthread*.so*' | \
573 xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
576 mkdir -p $(TARGET_DIR)/etc
577 # Mandatory configuration file and auxiliary cache directory
578 # for recent versions of ldconfig
579 touch $(TARGET_DIR)/etc/ld.so.conf
580 mkdir -p $(TARGET_DIR)/var/cache/ldconfig
581 if [ -x "$(TARGET_CROSS)ldconfig" ]; \
583 $(TARGET_CROSS)ldconfig -r $(TARGET_DIR) \
584 -f $(TARGET_DIR)/etc/ld.so.conf; \
586 /sbin/ldconfig -r $(TARGET_DIR) \
587 -f $(TARGET_DIR)/etc/ld.so.conf; \
590 echo "NAME=Buildroot"; \
591 echo "VERSION=$(BR2_VERSION_FULL)"; \
592 echo "ID=buildroot"; \
593 echo "VERSION_ID=$(BR2_VERSION)"; \
594 echo "PRETTY_NAME=\"Buildroot $(BR2_VERSION)\"" \
595 ) > $(TARGET_DIR)/etc/os-release
597 @$(foreach d, $(call qstrip,$(BR2_ROOTFS_OVERLAY)), \
598 $(call MESSAGE,"Copying overlay $(d)"); \
599 rsync -a --ignore-times $(RSYNC_VCS_EXCLUSIONS) \
600 --chmod=Du+w --exclude .empty --exclude '*~' \
601 $(d)/ $(TARGET_DIR)$(sep))
603 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_BUILD_SCRIPT)), \
604 $(call MESSAGE,"Executing post-build script $(s)"); \
605 $(EXTRA_ENV) $(s) $(TARGET_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
607 target-post-image: $(TARGETS_ROOTFS) target-finalize
608 @$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
609 $(call MESSAGE,"Executing post-image script $(s)"); \
610 $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
612 source: $(foreach p,$(PACKAGES),$(p)-all-source)
614 _external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
616 @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
618 # check if download URLs are outdated
619 source-check: $(foreach p,$(PACKAGES),$(p)-all-source-check)
622 @rm -fr $(LEGAL_INFO_DIR)
624 legal-info-prepare: $(LEGAL_INFO_DIR)
625 @$(call MESSAGE,"Collecting legal info")
626 @$(call legal-license-file,buildroot,COPYING,COPYING,HOST)
627 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
628 @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
629 @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPLv2+,COPYING,not saved,not saved,HOST)
630 @$(call legal-warning,the Buildroot source code has not been saved)
631 @$(call legal-warning,the toolchain has not been saved)
632 @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
634 legal-info: dirs legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
635 $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
636 @cat support/legal-info/README.header >>$(LEGAL_REPORT)
637 @if [ -r $(LEGAL_WARNINGS) ]; then \
638 cat support/legal-info/README.warnings-header \
639 $(LEGAL_WARNINGS) >>$(LEGAL_REPORT); \
640 cat $(LEGAL_WARNINGS); fi
641 @echo "Legal info produced in $(LEGAL_INFO_DIR)"
642 @rm -f $(LEGAL_WARNINGS)
645 @echo $(PACKAGES) $(TARGETS_ROOTFS)
647 graph-build: $(O)/build/build-time.log
648 @install -d $(GRAPHS_DIR)
649 $(foreach o,name build duration,./support/scripts/graph-build-time \
650 --type=histogram --order=$(o) --input=$(<) \
651 --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
652 $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
653 $(foreach t,packages steps,./support/scripts/graph-build-time \
654 --type=pie-$(t) --input=$(<) \
655 --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
656 $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
658 graph-depends-requirements:
659 @dot -? >/dev/null 2>&1 || \
660 { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
662 graph-depends: graph-depends-requirements
663 @$(INSTALL) -d $(GRAPHS_DIR)
664 @cd "$(CONFIG_DIR)"; \
665 $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
666 |tee $(GRAPHS_DIR)/$(@).dot \
667 |dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT)
669 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
673 endif # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
676 # ---------------------------------------------------------------------------
678 HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
681 $(BUILD_DIR)/buildroot-config/%onf:
682 mkdir -p $(@D)/lxdialog
683 PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
684 obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
686 DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
688 # We don't want to fully expand BR2_DEFCONFIG here, so Kconfig will
689 # recognize that if it's still at its default $(CONFIG_DIR)/defconfig
690 COMMON_CONFIG_ENV = \
691 BR2_DEFCONFIG='$(call qstrip,$(value BR2_DEFCONFIG))' \
692 KCONFIG_AUTOCONFIG=$(BUILD_DIR)/buildroot-config/auto.conf \
693 KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
694 KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
695 BR2_CONFIG=$(BR2_CONFIG) \
696 BR2_EXTERNAL=$(BR2_EXTERNAL) \
699 xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
700 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
702 gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile
703 @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
705 menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
706 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
708 nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile
709 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
711 config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
712 @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
714 # For the config targets that automatically select options, we pass
715 # SKIP_LEGACY=y to disable the legacy options. However, in that case
716 # no values are set for the legacy options so a subsequent oldconfig
717 # will query them. Therefore, run an additional olddefconfig.
719 oldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
720 @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
722 randconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
723 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --randconfig $(CONFIG_CONFIG_IN)
724 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
726 allyesconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
727 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allyesconfig $(CONFIG_CONFIG_IN)
728 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
730 allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
731 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allnoconfig $(CONFIG_CONFIG_IN)
732 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
734 randpackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
735 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
736 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
737 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
738 $< --randconfig $(CONFIG_CONFIG_IN)
739 @rm -f $(CONFIG_DIR)/.config.nopkg
740 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
742 allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
743 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
744 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
745 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
746 $< --allyesconfig $(CONFIG_CONFIG_IN)
747 @rm -f $(CONFIG_DIR)/.config.nopkg
748 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
750 allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
751 @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
752 @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
753 KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
754 $< --allnoconfig $(CONFIG_CONFIG_IN)
755 @rm -f $(CONFIG_DIR)/.config.nopkg
756 @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
758 silentoldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
759 $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)
761 olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
762 $(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN)
764 defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
765 @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
767 # Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
768 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig outputmakefile
769 @$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(TOPDIR)/configs/$@ \
770 $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN)
772 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(BR2_EXTERNAL)/configs/%_defconfig outputmakefile
773 @$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(BR2_EXTERNAL)/configs/$@ \
774 $< --defconfig=$(BR2_EXTERNAL)/configs/$@ $(CONFIG_CONFIG_IN)
776 savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
777 @$(COMMON_CONFIG_ENV) $< \
778 --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
781 .PHONY: defconfig savedefconfig
783 ################################################################################
785 # Cleanup and misc junk
787 ################################################################################
789 # outputmakefile generates a Makefile in the output directory, if using a
790 # separate output directory. This allows convenient use of make in the
793 ifeq ($(NEED_WRAPPER),y)
794 $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
797 # printvars prints all the variables currently defined in our Makefiles
800 $(sort $(.VARIABLES)), \
801 $(if $(filter-out environment% default automatic, \
803 $(info $V=$($V) ($(value $V)))))
806 rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
807 $(BUILD_DIR) $(BASE_DIR)/staging \
808 $(LEGAL_INFO_DIR) $(GRAPHS_DIR)
811 ifeq ($(DL_DIR),$(TOPDIR)/dl)
817 rm -rf $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
818 $(CONFIG_DIR)/.auto.deps
822 @echo ' clean - delete all files created by build'
823 @echo ' distclean - delete all non-source files (including .config)'
826 @echo ' all - make world'
827 @echo ' toolchain - build toolchain'
829 @echo 'Configuration:'
830 @echo ' menuconfig - interactive curses-based configurator'
831 @echo ' nconfig - interactive ncurses-based configurator'
832 @echo ' xconfig - interactive Qt-based configurator'
833 @echo ' gconfig - interactive GTK-based configurator'
834 @echo ' oldconfig - resolve any unresolved symbols in .config'
835 @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps'
836 @echo ' olddefconfig - Same as silentoldconfig but sets new symbols to their default value'
837 @echo ' randconfig - New config with random answer to all options'
838 @echo ' defconfig - New config with default answer to all options'
839 @echo ' BR2_DEFCONFIG, if set, is used as input'
840 @echo ' savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)'
841 @echo ' allyesconfig - New config where all options are accepted with yes'
842 @echo ' allnoconfig - New config where all options are answered with no'
843 @echo ' randpackageconfig - New config with random answer to package options'
844 @echo ' allyespackageconfig - New config where pkg options are accepted with yes'
845 @echo ' allnopackageconfig - New config where package options are answered with no'
847 @echo 'Package-specific:'
848 @echo ' <pkg> - Build and install <pkg> and all its dependencies'
849 @echo ' <pkg>-source - Only download the source files for <pkg>'
850 @echo ' <pkg>-extract - Extract <pkg> sources'
851 @echo ' <pkg>-patch - Apply patches to <pkg>'
852 @echo ' <pkg>-depends - Build <pkg>'\''s dependencies'
853 @echo ' <pkg>-configure - Build <pkg> up to the configure step'
854 @echo ' <pkg>-build - Build <pkg> up to the build step'
855 @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies'
856 @echo ' <pkg>-dirclean - Remove <pkg> build directory'
857 @echo ' <pkg>-reconfigure - Restart the build from the configure step'
858 @echo ' <pkg>-rebuild - Restart the build from the build step'
859 @echo ' <pkg>-legal-info - Generate license information for <pkg>'
860 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
861 @echo ' busybox-menuconfig - Run BusyBox menuconfig'
863 ifeq ($(BR2_LINUX_KERNEL),y)
864 @echo ' linux-menuconfig - Run Linux kernel menuconfig'
865 @echo ' linux-savedefconfig - Run Linux kernel savedefconfig'
866 @echo ' linux-update-defconfig - Save the Linux configuration to the path specified'
867 @echo ' by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE'
869 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
870 @echo ' uclibc-menuconfig - Run uClibc menuconfig'
872 ifeq ($(BR2_TARGET_BAREBOX),y)
873 @echo ' barebox-menuconfig - Run barebox menuconfig'
874 @echo ' barebox-savedefconfig - Run barebox savedefconfig'
877 @echo 'Documentation:'
878 @echo ' manual - build manual in all formats'
879 @echo ' manual-html - build manual in HTML'
880 @echo ' manual-split-html - build manual in split HTML'
881 @echo ' manual-pdf - build manual in PDF'
882 @echo ' manual-text - build manual in text'
883 @echo ' manual-epub - build manual in ePub'
884 @echo ' graph-build - generate graphs of the build times'
885 @echo ' graph-depends - generate graph of the dependency tree'
886 @echo ' list-defconfigs - list all defconfigs (pre-configured minimal systems)'
888 @echo 'Miscellaneous:'
889 @echo ' source - download all sources needed for offline-build'
890 @echo ' source-check - check selected packages for valid download URLs'
891 @echo ' external-deps - list external packages used'
892 @echo ' legal-info - generate info about license compliance'
894 @echo ' make V=0|1 - 0 => quiet build (default), 1 => verbose build'
895 @echo ' make O=dir - Locate all output files in "dir", including .config'
897 @echo 'For further details, see README, generate the Buildroot manual, or consult'
898 @echo 'it on-line at http://buildroot.org/docs.html'
902 @echo 'Built-in configs:'
903 @$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
904 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
905 ifneq ($(wildcard $(BR2_EXTERNAL)/configs/*_defconfig),)
907 @echo 'User-provided configs:'
908 @$(foreach b, $(sort $(notdir $(wildcard $(BR2_EXTERNAL)/configs/*_defconfig))), \
909 printf " %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
913 release: OUT = buildroot-$(BR2_VERSION)
915 # Create release tarballs. We need to fiddle a bit to add the generated
916 # documentation to the git output
918 git archive --format=tar --prefix=$(OUT)/ HEAD > $(OUT).tar
919 $(MAKE) O=$(OUT) manual-html manual-text manual-pdf
920 tar rf $(OUT).tar $(OUT)
921 gzip -9 -c < $(OUT).tar > $(OUT).tar.gz
922 bzip2 -9 -c < $(OUT).tar > $(OUT).tar.bz2
923 rm -rf $(OUT) $(OUT).tar
926 @echo $(BR2_VERSION_FULL)
928 include docs/manual/manual.mk
929 -include $(BR2_EXTERNAL)/docs/*/*.mk
931 .PHONY: $(noconfig_targets)