]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blobdiff - Makefile
check-package: check Config.* files
[coffee/buildroot.git] / Makefile
index c9865a6402fa2e88e2186b440d71c7a77453f67c..941bf789c803635aa382b3c67d36baf5fae4179e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@
 #
 # Copyright (C) 1999-2005 by Erik Andersen <andersen@codepoet.org>
 # Copyright (C) 2006-2014 by the Buildroot developers <buildroot@uclibc.org>
-# Copyright (C) 2014-2016 by the Buildroot developers <buildroot@buildroot.org>
+# Copyright (C) 2014-2017 by the Buildroot developers <buildroot@buildroot.org>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
 # You shouldn't need to mess with anything beyond this point...
 #--------------------------------------------------------------
 
+# Delete default rules. We don't use them. This saves a bit of time.
+.SUFFIXES:
+
 # we want bash as shell
 SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
         else if [ -x /bin/bash ]; then echo /bin/bash; \
         else echo sh; fi; fi)
 
-# Trick for always running with a fixed umask
-UMASK = 0022
-ifneq ($(shell umask),$(UMASK))
+# Set O variable if not already done on the command line;
+# or avoid confusing packages that can use the O=<dir> syntax for out-of-tree
+# build by preventing it from being forwarded to sub-make calls.
+ifneq ("$(origin O)", "command line")
+O := $(CURDIR)/output
+endif
+
+# Check if the current Buildroot execution meets all the pre-requisites.
+# If they are not met, Buildroot will actually do its job in a sub-make meeting
+# its pre-requisites, which are:
+#  1- Permissive enough umask:
+#       Wrong or too restrictive umask will prevent Buildroot and packages from
+#       creating files and directories.
+#  2- Absolute canonical CWD (i.e. $(CURDIR)):
+#       Otherwise, some packages will use CWD as-is, others will compute its
+#       absolute canonical path. This makes harder tracking and fixing host
+#       machine path leaks.
+#  3- Absolute canonical output location (i.e. $(O)):
+#       For the same reason as the one for CWD.
+
+# Remove the trailing '/.' from $(O) as it can be added by the makefile wrapper
+# installed in the $(O) directory.
+# Also remove the trailing '/' the user can set when on the command line.
+override O := $(patsubst %/,%,$(patsubst %.,%,$(O)))
+# Make sure $(O) actually exists before calling realpath on it; this is to
+# avoid empty CANONICAL_O in case on non-existing entry.
+CANONICAL_O := $(shell mkdir -p $(O) >/dev/null 2>&1)$(realpath $(O))
+
+CANONICAL_CURDIR = $(realpath $(CURDIR))
+
+REQ_UMASK = 0022
+
+# Make sure O= is passed (with its absolute canonical path) everywhere the
+# toplevel makefile is called back.
+EXTRAMAKEARGS := O=$(CANONICAL_O)
+
+# Check Buildroot execution pre-requisites here.
+ifneq ($(shell umask):$(CURDIR):$(O),$(REQ_UMASK):$(CANONICAL_CURDIR):$(CANONICAL_O))
 .PHONY: _all $(MAKECMDGOALS)
 
 $(MAKECMDGOALS): _all
        @:
 
 _all:
-       @umask $(UMASK) && $(MAKE) --no-print-directory $(MAKECMDGOALS)
+       @umask $(REQ_UMASK) && \
+               $(MAKE) -C $(CANONICAL_CURDIR) --no-print-directory \
+                       $(MAKECMDGOALS) $(EXTRAMAKEARGS)
 
-else # umask
+else # umask / $(CURDIR) / $(O)
 
 # This is our default rule, so must come first
 all:
 
 # Set and export the version string
-export BR2_VERSION := 2016.08-rc1
+export BR2_VERSION := 2017.05-git
+# Actual time the release is cut (for reproducible builds)
+BR2_VERSION_EPOCH = 1488315000
 
 # Save running make version since it's clobbered by the make package
 RUNNING_MAKE_VERSION := $(MAKE_VERSION)
@@ -86,7 +128,8 @@ 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 \
-       print-version olddefconfig
+       print-version olddefconfig distclean manual manual-html manual-split-html \
+       manual-pdf manual-text manual-epub
 
 # Some global targets do not trigger a build, but are used to collect
 # metadata, or do various checks. When such targets are triggered,
@@ -97,74 +140,63 @@ noconfig_targets := menuconfig nconfig gconfig xconfig config oldconfig randconf
 # 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 help
+nobuild_targets := source %-source source-check \
+       legal-info %-legal-info external-deps _external-deps \
+       clean distclean help show-targets graph-depends \
+       %-graph-depends %-show-depends %-show-version \
+       graph-build graph-size list-defconfigs \
+       savedefconfig printvars
 ifeq ($(MAKECMDGOALS),)
 BR_BUILDING = y
 else ifneq ($(filter-out $(nobuild_targets),$(MAKECMDGOALS)),)
 BR_BUILDING = y
 endif
 
+# We call make recursively to build packages. The command-line overrides that
+# are passed to Buildroot don't apply to those package build systems. In
+# particular, we don't want to pass down the O=<dir> option for out-of-tree
+# builds, because the value specified on the command line will not be correct
+# for packages.
+MAKEOVERRIDES :=
+
 # Include some helper macros and variables
 include support/misc/utils.mk
 
-ifneq ("$(origin O)", "command line")
-O := output
-CONFIG_DIR := $(TOPDIR)
+# Set variables related to in-tree or out-of-tree build.
+# Here, both $(O) and $(CURDIR) are absolute canonical paths.
+ifeq ($(O),$(CURDIR)/output)
+CONFIG_DIR := $(CURDIR)
 NEED_WRAPPER =
 else
-# other packages might also support Linux-style out of tree builds
-# with the O=<dir> syntax (E.G. BusyBox does). As make automatically
-# forwards command line variable definitions those packages get very
-# confused. Fix this by telling make to not do so
-MAKEOVERRIDES =
-# strangely enough O is still passed to submakes with MAKEOVERRIDES
-# (with make 3.81 atleast), the only thing that changes is the output
-# of the origin function (command line -> environment).
-# Unfortunately some packages don't look at origin (E.G. uClibc 0.9.31+)
-# To really make O go away, we have to override it.
-override O := $(O)
 CONFIG_DIR := $(O)
-# we need to pass O= everywhere we call back into the toplevel makefile
-EXTRAMAKEARGS = O=$(O)
 NEED_WRAPPER = y
 endif
 
 # bash prints the name of the directory on 'cd <dir>' if CDPATH is
 # set, so unset it here to not cause problems. Notice that the export
-# line doesn't affect the environment of $(shell ..) calls, so
-# explictly throw away any output from 'cd' here.
+# line doesn't affect the environment of $(shell ..) calls.
 export CDPATH :=
-BASE_DIR := $(shell mkdir -p $(O) && cd $(O) >/dev/null && pwd)
+
+BASE_DIR := $(CANONICAL_O)
 $(if $(BASE_DIR),, $(error output directory "$(O)" does not exist))
 
 
 # Handling of BR2_EXTERNAL.
 #
 # The value of BR2_EXTERNAL is stored in .br-external in the output directory.
-# 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 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.
-
-BR2_EXTERNAL_FILE = $(BASE_DIR)/.br-external
+# The location of the external.mk makefile fragments is computed in that file.
+# On subsequent invocations of make, this file is read in. BR2_EXTERNAL can
+# still be overridden on the command line, therefore the file is re-created
+# every time make is run.
+
+BR2_EXTERNAL_FILE = $(BASE_DIR)/.br-external.mk
 -include $(BR2_EXTERNAL_FILE)
-ifeq ($(BR2_EXTERNAL),)
-  override BR2_EXTERNAL = support/dummy-external
-  $(shell rm -f $(BR2_EXTERNAL_FILE))
-else
-  _BR2_EXTERNAL = $(shell cd $(BR2_EXTERNAL) >/dev/null 2>&1 && pwd)
-  ifeq ($(_BR2_EXTERNAL),)
-    $(error BR2_EXTERNAL='$(BR2_EXTERNAL)' does not exist, relative to $(TOPDIR))
-  endif
-  override BR2_EXTERNAL := $(_BR2_EXTERNAL)
-  $(shell echo BR2_EXTERNAL ?= $(BR2_EXTERNAL) > $(BR2_EXTERNAL_FILE))
+$(shell support/scripts/br2-external \
+       -m -o '$(BR2_EXTERNAL_FILE)' $(BR2_EXTERNAL))
+BR2_EXTERNAL_ERROR =
+include $(BR2_EXTERNAL_FILE)
+ifneq ($(BR2_EXTERNAL_ERROR),)
+$(error $(BR2_EXTERNAL_ERROR))
 endif
 
 # To make sure that the environment variable overrides the .config option,
@@ -195,8 +227,6 @@ LICENSE_FILES_DIR_TARGET = $(LEGAL_INFO_DIR)/licenses
 LICENSE_FILES_DIR_HOST = $(LEGAL_INFO_DIR)/host-licenses
 LEGAL_MANIFEST_CSV_TARGET = $(LEGAL_INFO_DIR)/manifest.csv
 LEGAL_MANIFEST_CSV_HOST = $(LEGAL_INFO_DIR)/host-manifest.csv
-LEGAL_LICENSES_TXT_TARGET = $(LEGAL_INFO_DIR)/licenses.txt
-LEGAL_LICENSES_TXT_HOST = $(LEGAL_INFO_DIR)/host-licenses.txt
 LEGAL_WARNINGS = $(LEGAL_INFO_DIR)/.warnings
 LEGAL_REPORT = $(LEGAL_INFO_DIR)/README
 
@@ -218,9 +248,13 @@ endif
 
 # timezone and locale may affect build output
 ifeq ($(BR2_REPRODUCIBLE),y)
-export TZ=UTC
-export LANG=C
-export LC_ALL=C
+export TZ = UTC
+export LANG = C
+export LC_ALL = C
+export GZIP = -n
+BR2_VERSION_GIT_EPOCH = $(shell GIT_DIR=$(TOPDIR)/.git $(GIT) log -1 --format=%at)
+export SOURCE_DATE_EPOCH = $(if $(wildcard $(TOPDIR)/.git),$(BR2_VERSION_GIT_EPOCH),$(BR2_VERSION_EPOCH))
+DEPENDENCIES_HOST_PREREQ += host-fakedate
 endif
 
 # To put more focus on warnings, be less verbose as default
@@ -289,6 +323,7 @@ HOSTLN := $(shell which $(HOSTLN) || type -p $(HOSTLN) || echo ln)
 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)
+SED := $(shell which sed || type -p sed) -i -e
 
 export HOSTAR HOSTAS HOSTCC HOSTCXX HOSTLD
 export HOSTCC_NOCCACHE HOSTCXX_NOCCACHE
@@ -367,6 +402,7 @@ unexport QMAKESPEC
 unexport TERMINFO
 unexport MACHINE
 unexport O
+unexport GCC_COLORS
 
 GNU_HOST_NAME := $(shell support/gnuconfig/config.guess)
 
@@ -386,6 +422,7 @@ KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
        -e s/arm.*/arm/ -e s/sa110/arm/ \
        -e s/aarch64.*/arm64/ \
        -e s/bfin/blackfin/ \
+       -e s/or1k/openrisc/ \
        -e s/parisc64/parisc/ \
        -e s/powerpc64.*/powerpc/ \
        -e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
@@ -395,6 +432,7 @@ KERNEL_ARCH := $(shell echo "$(ARCH)" | sed -e "s/-.*//" \
 ZCAT := $(call qstrip,$(BR2_ZCAT))
 BZCAT := $(call qstrip,$(BR2_BZCAT))
 XZCAT := $(call qstrip,$(BR2_XZCAT))
+LZCAT := $(call qstrip,$(BR2_LZCAT))
 TAR_OPTIONS = $(call qstrip,$(BR2_TAR_OPTIONS)) -xf
 
 # packages compiled for the host go here
@@ -438,11 +476,12 @@ all: world
 
 # Include legacy before the other things, because package .mk files
 # may rely on it.
-ifneq ($(BR2_DEPRECATED),y)
 include Makefile.legacy
-endif
 
 include package/Makefile.in
+# arch/arch.mk.* must be after package/Makefile.in because it may need to
+# complement variables defined therein, like BR_NO_CHECK_HASH_FOR.
+-include $(wildcard arch/arch.mk.*)
 include support/dependencies/dependencies.mk
 
 include toolchain/*.mk
@@ -461,7 +500,15 @@ include boot/common.mk
 include linux/linux.mk
 include fs/common.mk
 
-include $(BR2_EXTERNAL)/external.mk
+# If using a br2-external tree, the BR2_EXTERNAL_$(NAME)_PATH variables
+# are also present in the .config file. Since .config is included after
+# we defined them in the Makefile, the values for those variables are
+# quoted. We just include the generated Makefile fragment .br2-external.mk
+# a third time, which will set those variables to the un-quoted values.
+include $(BR2_EXTERNAL_FILE)
+
+# Nothing to include if no BR2_EXTERNAL tree in use
+include $(BR2_EXTERNAL_MKS)
 
 # Now we are sure we have all the packages scanned and defined. We now
 # check for each package in the list of enabled packages, that all its
@@ -614,7 +661,7 @@ target-finalize: $(PACKAGES)
                $(TARGET_DIR)/usr/lib/pkgconfig $(TARGET_DIR)/usr/share/pkgconfig \
                $(TARGET_DIR)/usr/lib/cmake $(TARGET_DIR)/usr/share/cmake
        find $(TARGET_DIR)/usr/{lib,share}/ -name '*.cmake' -print0 | xargs -0 rm -f
-       find $(TARGET_DIR)/lib $(TARGET_DIR)/usr/lib $(TARGET_DIR)/usr/libexec \
+       find $(TARGET_DIR)/lib/ $(TARGET_DIR)/usr/lib/ $(TARGET_DIR)/usr/libexec/ \
                \( -name '*.a' -o -name '*.la' \) -print0 | xargs -0 rm -f
 ifneq ($(BR2_PACKAGE_GDB),y)
        rm -rf $(TARGET_DIR)/usr/share/gdb
@@ -629,23 +676,20 @@ endif
        rm -rf $(TARGET_DIR)/usr/info $(TARGET_DIR)/usr/share/info
        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
+       rmdir $(TARGET_DIR)/usr/share 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' -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
 # I set a breakpoint"
 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
-       find $(TARGET_DIR)/lib -type f -name 'libpthread*.so*' | \
+       find $(TARGET_DIR)/lib/ -type f -name 'libpthread*.so*' | \
                xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
 endif
 
 # Valgrind needs ld.so with enough information, so only strip
 # debugging symbols.
-       find $(TARGET_DIR)/lib -type f -name 'ld-*.so*' | \
+       find $(TARGET_DIR)/lib/ -type f -name 'ld-*.so*' | \
                xargs -r $(STRIPCMD) $(STRIP_STRIP_DEBUG)
        test -f $(TARGET_DIR)/etc/ld.so.conf && \
                { echo "ERROR: we shouldn't have a /etc/ld.so.conf file"; exit 1; } || true
@@ -692,7 +736,7 @@ legal-info-prepare: $(LEGAL_INFO_DIR)
        @$(call legal-license-file,buildroot,COPYING,COPYING,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-manifest,buildroot,$(BR2_VERSION_FULL),GPL-2.0+,COPYING,not saved,not saved,HOST)
        @$(call legal-warning,the Buildroot source code has not been saved)
        @cp $(BR2_CONFIG) $(LEGAL_INFO_DIR)/buildroot.config
 
@@ -732,7 +776,7 @@ graph-depends: graph-depends-requirements
        @$(INSTALL) -d $(GRAPHS_DIR)
        @cd "$(CONFIG_DIR)"; \
        $(TOPDIR)/support/scripts/graph-depends $(BR2_GRAPH_DEPS_OPTS) \
-               -o $(GRAPHS_DIR)/$(@).dot
+               --direct -o $(GRAPHS_DIR)/$(@).dot
        dot $(BR2_GRAPH_DOT_OPTS) -T$(BR_GRAPH_OUT) \
                -o $(GRAPHS_DIR)/$(@).$(BR_GRAPH_OUT) \
                $(GRAPHS_DIR)/$(@).dot
@@ -761,7 +805,7 @@ HOSTCFLAGS = $(CFLAGS_FOR_BUILD)
 export HOSTCFLAGS
 
 .PHONY: prepare-kconfig
-prepare-kconfig: outputmakefile
+prepare-kconfig: outputmakefile $(BUILD_DIR)/.br2-external.in
 
 $(BUILD_DIR)/buildroot-config/%onf:
        mkdir -p $(@D)/lxdialog
@@ -778,8 +822,8 @@ 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) \
        HOST_GCC_VERSION="$(HOSTCC_VERSION)" \
+       BUILD_DIR=$(BUILD_DIR) \
        SKIP_LEGACY=
 
 xconfig: $(BUILD_DIR)/buildroot-config/qconf prepare-kconfig
@@ -856,7 +900,7 @@ define percent_defconfig
        @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$(1)/configs/$$@ \
                $$< --defconfig=$(1)/configs/$$@ $$(CONFIG_CONFIG_IN)
 endef
-$(eval $(foreach d,$(TOPDIR) $(BR2_EXTERNAL),$(call percent_defconfig,$(d))$(sep)))
+$(eval $(foreach d,$(call reverse,$(TOPDIR) $(BR2_EXTERNAL_DIRS)),$(call percent_defconfig,$(d))$(sep)))
 
 savedefconfig: $(BUILD_DIR)/buildroot-config/conf prepare-kconfig
        @$(COMMON_CONFIG_ENV) $< \
@@ -880,6 +924,13 @@ ifeq ($(NEED_WRAPPER),y)
        $(Q)$(TOPDIR)/support/scripts/mkmakefile $(TOPDIR) $(O)
 endif
 
+# Even though the target is a real file, we mark it as PHONY as we
+# want it to be re-generated each time make is invoked, in case the
+# value of BR2_EXTERNAL is changed.
+.PHONY: $(BUILD_DIR)/.br2-external.in
+$(BUILD_DIR)/.br2-external.in: $(BUILD_DIR)
+       $(Q)support/scripts/br2-external -k -o "$(@)" $(BR2_EXTERNAL)
+
 # printvars prints all the variables currently defined in our
 # Makefiles. Alternatively, if a non-empty VARS variable is passed,
 # only the variables matching the make pattern passed in VARS are
@@ -889,7 +940,10 @@ printvars:
                $(sort $(if $(VARS),$(filter $(VARS),$(.VARIABLES)),$(.VARIABLES))), \
                $(if $(filter-out environment% default automatic, \
                                $(origin $V)), \
-               $(info $V=$($V) ($(value $V)))))
+               $(if $(QUOTED_VARS),\
+                       $(info $V='$(subst ','\'',$(if $(RAW_VARS),$(value $V),$($V)))'), \
+                       $(info $V=$(if $(RAW_VARS),$(value $V),$($V))))))
+# ' Syntax colouring...
 
 clean:
        rm -rf $(TARGET_DIR) $(BINARIES_DIR) $(HOST_DIR) \
@@ -897,13 +951,10 @@ clean:
                $(LEGAL_INFO_DIR) $(GRAPHS_DIR)
 
 distclean: clean
-ifeq ($(DL_DIR),$(TOPDIR)/dl)
-       rm -rf $(DL_DIR)
-endif
-ifeq ($(O),output)
+ifeq ($(O),$(CURDIR)/output)
        rm -rf $(O)
 endif
-       rm -rf $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
+       rm -rf $(TOPDIR)/dl $(BR2_CONFIG) $(CONFIG_DIR)/.config.old $(CONFIG_DIR)/..config.tmp \
                $(CONFIG_DIR)/.auto.deps $(BR2_EXTERNAL_FILE)
 
 help:
@@ -941,7 +992,10 @@ help:
        @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>-show-depends     - List packages on which <pkg> depends'
+       @echo '  <pkg>-show-rdepends    - List packages which have <pkg> as a dependency'
        @echo '  <pkg>-graph-depends    - Generate a graph of <pkg>'\''s dependencies'
+       @echo '  <pkg>-graph-rdepends   - Generate a graph of <pkg>'\''s reverse 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'
@@ -967,6 +1021,7 @@ help:
        @echo '  source-check           - check selected packages for valid download URLs'
        @echo '  external-deps          - list external packages used'
        @echo '  legal-info             - generate info about license compliance'
+       @echo '  printvars              - dump all the internal variables'
        @echo
        @echo '  make V=0|1             - 0 => quiet build (default), 1 => verbose build'
        @echo '  make O=dir             - Locate all output files in "dir", including .config'
@@ -975,17 +1030,34 @@ help:
        @echo 'it on-line at http://buildroot.org/docs.html'
        @echo
 
+# List the defconfig files
+# $(1): base directory
+# $(2): br2-external name, empty for bundled
+define list-defconfigs
+       @first=true; \
+       for defconfig in $(1)/configs/*_defconfig; do \
+               [ -f "$${defconfig}" ] || continue; \
+               if $${first}; then \
+                       if [ "$(2)" ]; then \
+                               printf 'External configs in "$(call qstrip,$(2))":\n'; \
+                       else \
+                               printf "Built-in configs:\n"; \
+                       fi; \
+                       first=false; \
+               fi; \
+               defconfig="$${defconfig##*/}"; \
+               printf "  %-35s - Build for %s\n" "$${defconfig}" "$${defconfig%_defconfig}"; \
+       done; \
+       $${first} || printf "\n"
+endef
+
+# We iterate over BR2_EXTERNAL_NAMES rather than BR2_EXTERNAL_DIRS,
+# because we want to display the name of the br2-external tree.
 list-defconfigs:
-       @echo 'Built-in configs:'
-       @$(foreach b, $(sort $(notdir $(wildcard $(TOPDIR)/configs/*_defconfig))), \
-         printf "  %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
-ifneq ($(wildcard $(BR2_EXTERNAL)/configs/*_defconfig),)
-       @echo
-       @echo 'User-provided configs:'
-       @$(foreach b, $(sort $(notdir $(wildcard $(BR2_EXTERNAL)/configs/*_defconfig))), \
-         printf "  %-35s - Build for %s\\n" $(b) $(b:_defconfig=);)
-endif
-       @echo
+       $(call list-defconfigs,$(TOPDIR))
+       $(foreach name,$(BR2_EXTERNAL_NAMES),\
+               $(call list-defconfigs,$(BR2_EXTERNAL_$(name)_PATH),\
+                       $(BR2_EXTERNAL_$(name)_DESC))$(sep))
 
 release: OUT = buildroot-$(BR2_VERSION)
 
@@ -1003,9 +1075,12 @@ release:
 print-version:
        @echo $(BR2_VERSION_FULL)
 
+.gitlab-ci.yml: .gitlab-ci.yml.in configs/*_defconfig
+       (cd configs; LC_ALL=C ls -1 *_defconfig) | sed 's/$$/: *defconfig/' | cat $< - > $@
+
 include docs/manual/manual.mk
--include $(BR2_EXTERNAL)/docs/*/*.mk
+-include $(foreach dir,$(BR2_EXTERNAL_DIRS),$(dir)/docs/*/*.mk)
 
 .PHONY: $(noconfig_targets)
 
-endif #umask
+endif #umask / $(CURDIR) / $(O)