]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blobdiff - Makefile
Update for 2015.05-rc2
[coffee/buildroot.git] / Makefile
index b3bd91eb54d4375cc22a65dc8d9b70be52be02f8..5c4293bc576336c66a4684e4d6b22b443a3e9f52 100644 (file)
--- a/Makefile
+++ b/Makefile
 # You shouldn't need to mess with anything beyond this point...
 #--------------------------------------------------------------
 
+# This is our default rule, so must come first
+all:
+
 # Set and export the version string
-export BR2_VERSION := 2014.08-git
+export BR2_VERSION := 2015.05-rc2
 
 # Check for minimal make version (note: this check will break at make 10.x)
 MIN_MAKE_VERSION = 3.81
@@ -72,7 +75,25 @@ export BR2_VERSION_FULL := $(BR2_VERSION)$(shell $(TOPDIR)/support/scripts/setlo
 noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconfig \
        defconfig %_defconfig allyesconfig allnoconfig silentoldconfig release \
        randpackageconfig allyespackageconfig allnopackageconfig \
-       source-check print-version olddefconfig
+       print-version olddefconfig
+
+# Some global targets do not trigger a build, but are used to collect
+# metadata, or do various checks. When such targets are triggered,
+# some packages should not do their configuration sanity
+# checks. Provide them a BR_BUILDING variable set to 'y' when we're
+# actually building and they should do their sanity checks.
+#
+# We're building in two situations: when MAKECMDGOALS is empty
+# (default target is to build), or when MAKECMDGOALS contains
+# something else than one of the nobuild_targets.
+nobuild_targets := source source-check \
+       legal-info external-deps _external-deps \
+       clean distclean
+ifeq ($(MAKECMDGOALS),)
+BR_BUILDING = y
+else ifneq ($(filter-out $(nobuild_targets),$(MAKECMDGOALS)),)
+BR_BUILDING = y
+endif
 
 # Strip quotes and then whitespaces
 qstrip = $(strip $(subst ",,$(1)))
@@ -120,8 +141,9 @@ $(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
 # On subsequent invocations of make, it is read in. It can still be overridden
 # on the command line, therefore the file is re-created every time make is run.
 #
-# When BR2_EXTERNAL is not set, the .br-external file is removed and we point
-# to support/dummy-external. This makes sure we can unconditionally include the
+# When BR2_EXTERNAL is set to an empty value (e.g. explicitly in command
+# line), the .br-external file is removed and we point to
+# support/dummy-external. This makes sure we can unconditionally include the
 # Config.in and external.mk from the BR2_EXTERNAL directory. In this case,
 # override is necessary so the user can clear BR2_EXTERNAL from the command
 # line, but the dummy path is still used internally.
@@ -140,7 +162,7 @@ else
   $(shell echo BR2_EXTERNAL ?= $(BR2_EXTERNAL) > $(BR2_EXTERNAL_FILE))
 endif
 
-# To make sure the the environment variable overrides the .config option,
+# To make sure that the environment variable overrides the .config option,
 # set this before including .config.
 ifneq ($(BR2_DL_DIR),)
 DL_DIR := $(BR2_DL_DIR)
@@ -157,6 +179,7 @@ TARGET_DIR := $(BASE_DIR)/target
 # initial definition so that 'make clean' works for most users, even without
 # .config. HOST_DIR will be overwritten later when .config is included.
 HOST_DIR := $(BASE_DIR)/host
+GRAPHS_DIR := $(BASE_DIR)/graphs
 
 LEGAL_INFO_DIR = $(BASE_DIR)/legal-info
 REDIST_SOURCES_DIR_TARGET = $(LEGAL_INFO_DIR)/sources
@@ -179,10 +202,8 @@ endif
 
 # To put more focus on warnings, be less verbose as default
 # Use 'make V=1' to see the full commands
-ifdef V
-  ifeq ("$(origin V)", "command line")
-    KBUILD_VERBOSE = $(V)
-  endif
+ifeq ("$(origin V)", "command line")
+  KBUILD_VERBOSE = $(V)
 endif
 ifndef KBUILD_VERBOSE
   KBUILD_VERBOSE = 0
@@ -225,9 +246,6 @@ HOSTCXX := g++
 HOSTCXX := $(shell which $(HOSTCXX) || type -p $(HOSTCXX) || echo g++)
 endif
 HOSTCXX_NOCCACHE := $(HOSTCXX)
-ifndef HOSTFC
-HOSTFC := gfortran
-endif
 ifndef HOSTCPP
 HOSTCPP := cpp
 endif
@@ -248,7 +266,6 @@ HOSTRANLIB := ranlib
 endif
 HOSTAR := $(shell which $(HOSTAR) || type -p $(HOSTAR) || echo ar)
 HOSTAS := $(shell which $(HOSTAS) || type -p $(HOSTAS) || echo as)
-HOSTFC := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo || which g77 || type -p g77 || echo gfortran)
 HOSTCPP := $(shell which $(HOSTCPP) || type -p $(HOSTCPP) || echo cpp)
 HOSTLD := $(shell which $(HOSTLD) || type -p $(HOSTLD) || echo ld)
 HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
@@ -256,10 +273,11 @@ HOSTNM := $(shell which $(HOSTNM) || type -p $(HOSTNM) || echo nm)
 HOSTOBJCOPY := $(shell which $(HOSTOBJCOPY) || type -p $(HOSTOBJCOPY) || echo objcopy)
 HOSTRANLIB := $(shell which $(HOSTRANLIB) || type -p $(HOSTRANLIB) || echo ranlib)
 
-export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTFC HOSTLD
+export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
 
 # Make sure pkg-config doesn't look outside the buildroot tree
+HOST_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
 unexport PKG_CONFIG_PATH
 unexport PKG_CONFIG_SYSROOT_DIR
 unexport PKG_CONFIG_LIBDIR
@@ -271,6 +289,9 @@ unexport DESTDIR
 # Causes breakage with packages that needs host-ruby
 unexport RUBYOPT
 
+include package/pkg-utils.mk
+include package/doc-asciidoc.mk
+
 ifeq ($(BR2_HAVE_DOT_CONFIG),y)
 
 ################################################################################
@@ -290,13 +311,14 @@ unexport TAR_OPTIONS
 unexport CONFIG_SITE
 unexport QMAKESPEC
 unexport TERMINFO
+unexport MACHINE
 
 GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
 
-TARGETS :=
+PACKAGES :=
 
 # silent mode requested?
-QUIET := $(if $(findstring s,$(MAKEFLAGS)),-q)
+QUIET := $(if $(findstring s,$(filter-out --%,$(MAKEFLAGS))),-q)
 
 # Strip off the annoying quoting
 ARCH := $(call qstrip,$(BR2_ARCH))
@@ -366,10 +388,7 @@ endif
 include package/Makefile.in
 include support/dependencies/dependencies.mk
 
-# We also need the various per-package makefiles, which also add
-# each selected package to TARGETS if that package was selected
-# in the .config file.
-include toolchain/helpers.mk
+include toolchain/*.mk
 include toolchain/*/*.mk
 
 # Include the package override file if one has been provided in the
@@ -388,31 +407,6 @@ include fs/common.mk
 
 include $(BR2_EXTERNAL)/external.mk
 
-TARGETS_SOURCE := $(patsubst %,%-source,$(TARGETS))
-TARGETS_DIRCLEAN := $(patsubst %,%-dirclean,$(TARGETS))
-
-# host-* dependencies have to be handled specially, as those aren't
-# visible in Kconfig and hence not added to a variable like TARGETS.
-# instead, find all the host-* targets listed in each <PKG>_DEPENDENCIES
-# variable for each enabled target.
-# Notice: this only works for newstyle gentargets/autotargets packages
-TARGETS_HOST_DEPS = $(sort $(filter host-%,$(foreach dep,\
-               $(addsuffix _DEPENDENCIES,\
-                       $(call UPPERCASE,$(TARGETS) $(TARGETS_ROOTFS))),\
-               $($(dep)))))
-# Host packages can in turn have their own dependencies. Likewise find
-# all the package names listed in the HOST_<PKG>_DEPENDENCIES for each
-# host package found above. Ideally this should be done recursively until
-# no more packages are found, but that's hard to do in make, so limit to
-# 1 level for now.
-HOST_DEPS = $(sort $(foreach dep,\
-               $(addsuffix _DEPENDENCIES,$(call UPPERCASE,$(TARGETS_HOST_DEPS))),\
-               $($(dep))))
-HOST_SOURCE += $(addsuffix -source,$(sort $(TARGETS_HOST_DEPS) $(HOST_DEPS)))
-
-TARGETS_LEGAL_INFO := $(patsubst %,%-legal-info,\
-               $(TARGETS) $(TARGETS_HOST_DEPS) $(HOST_DEPS))))
-
 dirs: $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
        $(HOST_DIR) $(BINARIES_DIR)
 
@@ -424,12 +418,8 @@ prepare: $(BUILD_DIR)/buildroot-config/auto.conf
 world: target-post-image
 
 .PHONY: all world toolchain dirs clean distclean source outputmakefile \
-       legal-info legal-info-prepare legal-info-clean printvars \
-       target-finalize target-post-image \
-       $(TARGETS) $(TARGETS_ROOTFS) \
-       $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) $(TARGETS_LEGAL_INFO) \
-       $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
-       $(HOST_DIR) $(BINARIES_DIR)
+       legal-info legal-info-prepare legal-info-clean printvars help \
+       list-defconfigs target-finalize target-post-image source-check
 
 ################################################################################
 #
@@ -491,7 +481,7 @@ STRIP_FIND_CMD += -type f \( -perm /111 -o -name '*.so*' \)
 #   applications and libraries. Normally kernel modules are already excluded
 #   by the executable permission check above, so the explicit exclusion is only
 #   done for kernel modules with incorrect permissions.
-STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print
+STRIP_FIND_CMD += -not \( $(call findfileclauses,libpthread*.so* *.ko $(call qstrip,$(BR2_STRIP_EXCLUDE_FILES))) \) -print0
 
 ifeq ($(BR2_ECLIPSE_REGISTER),y)
 define TOOLCHAIN_ECLIPSE_REGISTER
@@ -507,13 +497,13 @@ endif
 # not have them (Linaro toolchains), we use the ones available on the
 # host machine.
 ifeq ($(BR2_TOOLCHAIN_USES_GLIBC),y)
-GENERATE_LOCALE = $(call qstrip,$(BR2_GENERATE_LOCALE))
-ifneq ($(GENERATE_LOCALE),)
-TARGETS += host-localedef
+GLIBC_GENERATE_LOCALES = $(call qstrip,$(BR2_GENERATE_LOCALE))
+ifneq ($(GLIBC_GENERATE_LOCALES),)
+PACKAGES += host-localedef
 
-define GENERATE_LOCALES
+define GENERATE_GLIBC_LOCALES
        $(Q)mkdir -p $(TARGET_DIR)/usr/lib/locale/
-       $(Q)for locale in $(GENERATE_LOCALE) ; do \
+       $(Q)for locale in $(GLIBC_GENERATE_LOCALES) ; do \
                inputfile=`echo $${locale} | cut -f1 -d'.'` ; \
                charmap=`echo $${locale} | cut -f2 -d'.' -s` ; \
                if test -z "$${charmap}" ; then \
@@ -528,7 +518,7 @@ define GENERATE_LOCALES
                        $${locale} ; \
        done
 endef
-TARGET_FINALIZE_HOOKS += GENERATE_LOCALES
+TARGET_FINALIZE_HOOKS += GENERATE_GLIBC_LOCALES
 endif
 endif
 
@@ -538,7 +528,7 @@ LOCALE_NOPURGE = $(call qstrip,$(BR2_ENABLE_LOCALE_WHITELIST))
 
 define PURGE_LOCALES
        rm -f $(LOCALE_WHITELIST)
-       for i in $(LOCALE_NOPURGE); do echo $$i >> $(LOCALE_WHITELIST); done
+       for i in $(LOCALE_NOPURGE) locale-archive; do echo $$i >> $(LOCALE_WHITELIST); done
 
        for dir in $(wildcard $(addprefix $(TARGET_DIR),/usr/share/locale /usr/share/X11/locale /usr/man /usr/share/man /usr/lib/locale)); \
        do \
@@ -553,7 +543,7 @@ endif
 
 $(TARGETS_ROOTFS): target-finalize
 
-target-finalize: $(TARGETS)
+target-finalize: $(PACKAGES)
        @$(call MESSAGE,"Finalizing target directory")
        $(foreach hook,$(TARGET_FINALIZE_HOOKS),$($(hook))$(sep))
        rm -rf $(TARGET_DIR)/usr/include $(TARGET_DIR)/usr/share/aclocal \
@@ -570,21 +560,10 @@ endif
        rm -rf $(TARGET_DIR)/usr/doc $(TARGET_DIR)/usr/share/doc
        rm -rf $(TARGET_DIR)/usr/share/gtk-doc
        -rmdir $(TARGET_DIR)/usr/share 2>/dev/null
-ifeq ($(BR2_PACKAGE_PYTHON_PY_ONLY)$(BR2_PACKAGE_PYTHON3_PY_ONLY),y)
-       find $(TARGET_DIR)/usr/lib/ -name '*.pyc' -print0 | xargs -0 rm -f
-endif
-ifeq ($(BR2_PACKAGE_PYTHON_PYC_ONLY)$(BR2_PACKAGE_PYTHON3_PYC_ONLY),y)
-       find $(TARGET_DIR)/usr/lib/ -name '*.py' -print0 | xargs -0 rm -f
-endif
-       rm -rf $(TARGET_DIR)/usr/lib/luarocks
-       rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/pod
-       rm -rf $(TARGET_DIR)/usr/lib/perl5/$(PERL_VERSION)/$(PERL_ARCHNAME)/CORE
-       find $(TARGET_DIR)/usr/lib/perl5/ -name '*.bs' -print0 | xargs -0 rm -f
-       find $(TARGET_DIR)/usr/lib/perl5/ -name '.packlist' -print0 | xargs -0 rm -f
-       $(STRIP_FIND_CMD) | xargs $(STRIPCMD) 2>/dev/null || true
+       $(STRIP_FIND_CMD) | xargs -0 $(STRIPCMD) 2>/dev/null || true
        if test -d $(TARGET_DIR)/lib/modules; then \
-               find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | \
-               xargs -r $(KSTRIPCMD); fi
+               find $(TARGET_DIR)/lib/modules -type f -name '*.ko' -print0 | \
+               xargs -0 -r $(KSTRIPCMD); fi
 
 # See http://sourceware.org/gdb/wiki/FAQ, "GDB does not see any threads
 # besides the one in which crash occurred; or SIGTRAP kills my program when
@@ -595,15 +574,17 @@ ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
 endif
 
        mkdir -p $(TARGET_DIR)/etc
-       # Mandatory configuration file and auxilliary cache directory
+       # Mandatory configuration file and auxiliary cache directory
        # for recent versions of ldconfig
        touch $(TARGET_DIR)/etc/ld.so.conf
        mkdir -p $(TARGET_DIR)/var/cache/ldconfig
        if [ -x "$(TARGET_CROSS)ldconfig" ]; \
        then \
-               $(TARGET_CROSS)ldconfig -r $(TARGET_DIR); \
+               $(TARGET_CROSS)ldconfig -r $(TARGET_DIR) \
+                                       -f $(TARGET_DIR)/etc/ld.so.conf; \
        else \
-               /sbin/ldconfig -r $(TARGET_DIR); \
+               /sbin/ldconfig -r $(TARGET_DIR) \
+                              -f $(TARGET_DIR)/etc/ld.so.conf; \
        fi
        ( \
                echo "NAME=Buildroot"; \
@@ -628,10 +609,14 @@ target-post-image: $(TARGETS_ROOTFS) target-finalize
                $(call MESSAGE,"Executing post-image script $(s)"); \
                $(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))
 
-source: $(TARGETS_SOURCE) $(HOST_SOURCE)
+source: $(foreach p,$(PACKAGES),$(p)-all-source)
 
+_external-deps: $(foreach p,$(PACKAGES),$(p)-all-external-deps)
 external-deps:
-       @$(MAKE1) -Bs DL_MODE=SHOW_EXTERNAL_DEPS $(EXTRAMAKEARGS) source | sort -u
+       @$(MAKE1) -Bs $(EXTRAMAKEARGS) _external-deps | sort -u
+
+# check if download URLs are outdated
+source-check: $(foreach p,$(PACKAGES),$(p)-all-source-check)
 
 legal-info-clean:
        @rm -fr $(LEGAL_INFO_DIR)
@@ -639,14 +624,14 @@ legal-info-clean:
 legal-info-prepare: $(LEGAL_INFO_DIR)
        @$(call MESSAGE,"Collecting legal info")
        @$(call legal-license-file,buildroot,COPYING,COPYING,HOST)
-       @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,TARGET)
-       @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,HOST)
-       @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPLv2+,COPYING,not saved,HOST)
+       @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,TARGET)
+       @$(call legal-manifest,PACKAGE,VERSION,LICENSE,LICENSE FILES,SOURCE ARCHIVE,SOURCE SITE,HOST)
+       @$(call legal-manifest,buildroot,$(BR2_VERSION_FULL),GPLv2+,COPYING,not saved,not saved,HOST)
        @$(call legal-warning,the Buildroot source code has not been saved)
        @$(call legal-warning,the toolchain has not been saved)
        @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
 
-legal-info: dirs legal-info-clean legal-info-prepare $(TARGETS_LEGAL_INFO) \
+legal-info: dirs legal-info-clean legal-info-prepare $(foreach p,$(PACKAGES),$(p)-all-legal-info) \
                $(REDIST_SOURCES_DIR_TARGET) $(REDIST_SOURCES_DIR_HOST)
        @cat support/legal-info/README.header >>$(LEGAL_REPORT)
        @if [ -r $(LEGAL_WARNINGS) ]; then \
@@ -657,17 +642,17 @@ legal-info: dirs legal-info-clean legal-info-prepare $(TARGETS_LEGAL_INFO) \
        @rm -f $(LEGAL_WARNINGS)
 
 show-targets:
-       @echo $(HOST_DEPS) $(TARGETS_HOST_DEPS) $(TARGETS) $(TARGETS_ROOTFS)
+       @echo $(PACKAGES) $(TARGETS_ROOTFS)
 
 graph-build: $(O)/build/build-time.log
-       @install -d $(O)/graphs
+       @install -d $(GRAPHS_DIR)
        $(foreach o,name build duration,./support/scripts/graph-build-time \
                                        --type=histogram --order=$(o) --input=$(<) \
-                                       --output=$(O)/graphs/build.hist-$(o).$(BR_GRAPH_OUT) \
+                                       --output=$(GRAPHS_DIR)/build.hist-$(o).$(BR_GRAPH_OUT) \
                                        $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
        $(foreach t,packages steps,./support/scripts/graph-build-time \
                                   --type=pie-$(t) --input=$(<) \
-                                  --output=$(O)/graphs/build.pie-$(t).$(BR_GRAPH_OUT) \
+                                  --output=$(GRAPHS_DIR)/build.pie-$(t).$(BR_GRAPH_OUT) \
                                   $(if $(BR2_GRAPH_ALT),--alternate-colors)$(sep))
 
 graph-depends-requirements:
@@ -675,11 +660,11 @@ graph-depends-requirements:
                { echo "ERROR: The 'dot' program from Graphviz is needed for graph-depends" >&2; exit 1; }
 
 graph-depends: graph-depends-requirements
-       @$(INSTALL) -d $(O)/graphs
+       @$(INSTALL) -d $(GRAPHS_DIR)
        @cd "$(CONFIG_DIR)"; \
        $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
-       |tee $(BASE_DIR)/graphs/$(@).dot \
-       |dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) -o $(BASE_DIR)/graphs/$(@).$(BR_GRAPH_OUT)
+       |tee $(GRAPHS_DIR)/$(@).dot \
+       |dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT)
 
 else # ifeq ($(BR2_HAVE_DOT_CONFIG),y)
 
@@ -695,7 +680,8 @@ export HOSTCFLAGS
 
 $(BUILD_DIR)/buildroot-config/%onf:
        mkdir -p $(@D)/lxdialog
-       $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
+       PKG_CONFIG_PATH="$(HOST_PKG_CONFIG_PATH)" $(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" \
+           obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)
 
 DEFCONFIG = $(call qstrip,$(BR2_DEFCONFIG))
 
@@ -707,104 +693,91 @@ COMMON_CONFIG_ENV = \
        KCONFIG_AUTOHEADER=$(BUILD_DIR)/buildroot-config/autoconf.h \
        KCONFIG_TRISTATE=$(BUILD_DIR)/buildroot-config/tristate.config \
        BR2_CONFIG=$(BR2_CONFIG) \
-       BR2_EXTERNAL=$(BR2_EXTERNAL)
+       BR2_EXTERNAL=$(BR2_EXTERNAL) \
+       SKIP_LEGACY=
 
 xconfig: $(BUILD_DIR)/buildroot-config/qconf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
 
 gconfig: $(BUILD_DIR)/buildroot-config/gconf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        @$(COMMON_CONFIG_ENV) srctree=$(TOPDIR) $< $(CONFIG_CONFIG_IN)
 
 menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
 
 nconfig: $(BUILD_DIR)/buildroot-config/nconf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
 
 config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        @$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)
 
+# For the config targets that automatically select options, we pass
+# SKIP_LEGACY=y to disable the legacy options. However, in that case
+# no values are set for the legacy options so a subsequent oldconfig
+# will query them. Therefore, run an additional olddefconfig.
+
 oldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       mkdir -p $(BUILD_DIR)/buildroot-config
        @$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)
 
 randconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
-       @$(COMMON_CONFIG_ENV) $< --randconfig $(CONFIG_CONFIG_IN)
+       @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --randconfig $(CONFIG_CONFIG_IN)
+       @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
 
 allyesconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
-       @$(COMMON_CONFIG_ENV) $< --allyesconfig $(CONFIG_CONFIG_IN)
+       @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allyesconfig $(CONFIG_CONFIG_IN)
+       @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
 
 allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
-       @$(COMMON_CONFIG_ENV) $< --allnoconfig $(CONFIG_CONFIG_IN)
+       @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y $< --allnoconfig $(CONFIG_CONFIG_IN)
+       @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
 
 randpackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
-       @grep '^config BR2_PACKAGE_' Config.in.legacy | \
-               while read config pkg; do \
-               echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
-       @$(COMMON_CONFIG_ENV) \
+       @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
                KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
                $< --randconfig $(CONFIG_CONFIG_IN)
        @rm -f $(CONFIG_DIR)/.config.nopkg
+       @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
 
 allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
-       @grep '^config BR2_PACKAGE_' Config.in.legacy | \
-               while read config pkg; do \
-               echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
-       @$(COMMON_CONFIG_ENV) \
+       @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
                KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
                $< --allyesconfig $(CONFIG_CONFIG_IN)
        @rm -f $(CONFIG_DIR)/.config.nopkg
+       @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
 
 allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        @grep -v BR2_PACKAGE_ $(BR2_CONFIG) > $(CONFIG_DIR)/.config.nopkg
-       @$(COMMON_CONFIG_ENV) \
+       @$(COMMON_CONFIG_ENV) SKIP_LEGACY=y \
                KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
                $< --allnoconfig $(CONFIG_CONFIG_IN)
        @rm -f $(CONFIG_DIR)/.config.nopkg
+       @$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN) >/dev/null
 
 silentoldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        $(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)
 
 olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        $(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN)
 
 defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        @$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)
 
+# Override the BR2_DEFCONFIG from COMMON_CONFIG_ENV with the new defconfig
 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
-       @$(COMMON_CONFIG_ENV) $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN)
+       @$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(TOPDIR)/configs/$@ \
+               $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN)
 
 %_defconfig: $(BUILD_DIR)/buildroot-config/conf $(BR2_EXTERNAL)/configs/%_defconfig outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
-       @$(COMMON_CONFIG_ENV) $< --defconfig=$(BR2_EXTERNAL)/configs/$@ $(CONFIG_CONFIG_IN)
+       @$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(BR2_EXTERNAL)/configs/$@ \
+               $< --defconfig=$(BR2_EXTERNAL)/configs/$@ $(CONFIG_CONFIG_IN)
 
 savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
-       @mkdir -p $(BUILD_DIR)/buildroot-config
        @$(COMMON_CONFIG_ENV) $< \
                --savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
                $(CONFIG_CONFIG_IN)
 
-# check if download URLs are outdated
-source-check:
-       $(MAKE1) DL_MODE=SOURCE_CHECK $(EXTRAMAKEARGS) source
-
 .PHONY: defconfig savedefconfig
 
 ################################################################################
@@ -832,7 +805,7 @@ printvars:
 clean:
        rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
                $(BUILD_DIR) $(BASE_DIR)/staging \
-               $(LEGAL_INFO_DIR)
+               $(LEGAL_INFO_DIR) $(GRAPHS_DIR)
 
 distclean: clean
 ifeq ($(DL_DIR),$(TOPDIR)/dl)
@@ -841,7 +814,8 @@ endif
 ifeq ($(O),output)
        rm -rf $(O)
 endif
-       rm -rf $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/.auto.deps
+       rm -rf $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
+               $(CONFIG_DIR)/.auto.deps
 
 help:
        @echo 'Cleaning:'
@@ -851,9 +825,6 @@ help:
        @echo 'Build:'
        @echo '  all                    - make world'
        @echo '  toolchain              - build toolchain'
-       @echo '  <package>-rebuild      - force recompile <package>'
-       @echo '  <package>-reconfigure  - force reconfigure <package>'
-       @echo '  <package>-graph-depends    - generate graph of the dependency tree for package'
        @echo
        @echo 'Configuration:'
        @echo '  menuconfig             - interactive curses-based configurator'
@@ -866,18 +837,34 @@ help:
        @echo '  randconfig             - New config with random answer to all options'
        @echo '  defconfig              - New config with default answer to all options'
        @echo '                             BR2_DEFCONFIG, if set, is used as input'
-       @echo '  savedefconfig          - Save current config as ./defconfig (minimal config)'
+       @echo '  savedefconfig          - Save current config to BR2_DEFCONFIG (minimal config)'
        @echo '  allyesconfig           - New config where all options are accepted with yes'
        @echo '  allnoconfig            - New config where all options are answered with no'
        @echo '  randpackageconfig      - New config with random answer to package options'
        @echo '  allyespackageconfig    - New config where pkg options are accepted with yes'
        @echo '  allnopackageconfig     - New config where package options are answered with no'
+       @echo
+       @echo 'Package-specific:'
+       @echo '  <pkg>                  - Build and install <pkg> and all its dependencies'
+       @echo '  <pkg>-source           - Only download the source files for <pkg>'
+       @echo '  <pkg>-extract          - Extract <pkg> sources'
+       @echo '  <pkg>-patch            - Apply patches to <pkg>'
+       @echo '  <pkg>-depends          - Build <pkg>'\''s dependencies'
+       @echo '  <pkg>-configure        - Build <pkg> up to the configure step'
+       @echo '  <pkg>-build            - Build <pkg> up to the build step'
+       @echo '  <pkg>-graph-depends    - Generate a graph of <pkg>'\''s dependencies'
+       @echo '  <pkg>-dirclean         - Remove <pkg> build directory'
+       @echo '  <pkg>-reconfigure      - Restart the build from the configure step'
+       @echo '  <pkg>-rebuild          - Restart the build from the build step'
+       @echo '  <pkg>-legal-info       - Generate license information for <pkg>'
 ifeq ($(BR2_PACKAGE_BUSYBOX),y)
        @echo '  busybox-menuconfig     - Run BusyBox menuconfig'
 endif
 ifeq ($(BR2_LINUX_KERNEL),y)
        @echo '  linux-menuconfig       - Run Linux kernel menuconfig'
        @echo '  linux-savedefconfig    - Run Linux kernel savedefconfig'
+       @echo '  linux-update-defconfig - Save the Linux configuration to the path specified'
+       @echo '                             by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE'
 endif
 ifeq ($(BR2_TOOLCHAIN_BUILDROOT),y)
        @echo '  uclibc-menuconfig      - Run uClibc menuconfig'
@@ -896,6 +883,7 @@ endif
        @echo '  manual-epub            - build manual in ePub'
        @echo '  graph-build            - generate graphs of the build times'
        @echo '  graph-depends          - generate graph of the dependency tree'
+       @echo '  list-defconfigs        - list all defconfigs (pre-configured minimal systems)'
        @echo
        @echo 'Miscellaneous:'
        @echo '  source                 - download all sources needed for offline-build'
@@ -906,6 +894,11 @@ endif
        @echo '  make V=0|1             - 0 => quiet build (default), 1 => verbose build'
        @echo '  make O=dir             - Locate all output files in "dir", including .config'
        @echo
+       @echo 'For further details, see README, generate the Buildroot manual, or consult'
+       @echo 'it on-line at http://buildroot.org/docs.html'
+       @echo
+
+list-defconfigs:
        @echo 'Built-in configs:'
        @$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
          printf "  %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
@@ -916,8 +909,6 @@ ifneq ($(wildcard $(BR2_EXTERNAL)/configs/*_defconfig),)
          printf "  %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
 endif
        @echo
-       @echo 'See docs/README, or generate the Buildroot manual for further details'
-       @echo
 
 release: OUT = buildroot-$(BR2_VERSION)
 
@@ -935,5 +926,6 @@ print-version:
        @echo $(BR2_VERSION_FULL)
 
 include docs/manual/manual.mk
+-include $(BR2_EXTERNAL)/docs/*/*.mk
 
 .PHONY: $(noconfig_targets)