From patchwork Tue Jun 21 04:56:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Bobroff X-Patchwork-Id: 638448 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rYb710b8xz9sdg for ; Tue, 21 Jun 2016 14:57:00 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C90988A0D7; Tue, 21 Jun 2016 04:56:56 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4upU8Toxho9D; Tue, 21 Jun 2016 04:56:53 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 8F29189F25; Tue, 21 Jun 2016 04:56:53 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id A1FBA1C1031 for ; Tue, 21 Jun 2016 04:56:52 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id A010E89DEF for ; Tue, 21 Jun 2016 04:56:52 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aUpQAa2GGD3i for ; Tue, 21 Jun 2016 04:56:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by whitealder.osuosl.org (Postfix) with ESMTPS id 00BA2899F3 for ; Tue, 21 Jun 2016 04:56:51 +0000 (UTC) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5L4rvqd135392 for ; Tue, 21 Jun 2016 00:56:51 -0400 Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142]) by mx0a-001b2d01.pphosted.com with ESMTP id 23n2f15a57-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 21 Jun 2016 00:56:51 -0400 Received: from localhost by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 21 Jun 2016 14:56:48 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 21 Jun 2016 14:56:47 +1000 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: sam.bobroff@au1.ibm.com X-IBM-RcptTo: buildroot@busybox.net Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id CE6932CE8059 for ; Tue, 21 Jun 2016 14:56:46 +1000 (EST) Received: from d23av06.au.ibm.com (d23av06.au.ibm.com [9.190.235.151]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5L4ukgY065922 for ; Tue, 21 Jun 2016 14:56:46 +1000 Received: from d23av06.au.ibm.com (localhost [127.0.0.1]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u5L4ukg4019735 for ; Tue, 21 Jun 2016 14:56:46 +1000 Received: from ozlabs.au.ibm.com (ozlabs.au.ibm.com [9.192.253.14]) by d23av06.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u5L4ukRg019724; Tue, 21 Jun 2016 14:56:46 +1000 Received: from tungsten.ozlabs.ibm.com (haven.au.ibm.com [9.192.254.114]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.au.ibm.com (Postfix) with ESMTPSA id 0022BA026F; Tue, 21 Jun 2016 14:56:45 +1000 (AEST) From: Sam Bobroff To: buildroot@busybox.net Date: Tue, 21 Jun 2016 14:56:41 +1000 X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16062104-0052-0000-0000-000001A5105F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16062104-0053-0000-0000-0000063AEFB2 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-21_02:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606210059 Cc: patrick@stwcx.xyz, sam@mendozajonas.com, eliner@us.ibm.com Subject: [Buildroot] [PATCH v2 1/5] Add support for merged defconfigs X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Signed-off-by: Sam Bobroff --- Makefile | 38 +++++++++++++++++++++++ docs/manual/adding-board-support.txt | 3 ++ docs/manual/appendix.txt | 1 + docs/manual/merged-defconfigs.txt | 60 ++++++++++++++++++++++++++++++++++++ 4 files changed, 102 insertions(+) create mode 100644 docs/manual/merged-defconfigs.txt diff --git a/Makefile b/Makefile index 78b44c5..9f3fc92 100644 --- a/Makefile +++ b/Makefile @@ -858,6 +858,44 @@ savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile .PHONY: defconfig savedefconfig +# Find the path of a config file that may be either in TOPDIR or BR2_EXTERNAL. +# Missing or duplicate matches must be checked for elsewhere. +define FIND_CONFIG_FILE = +$(foreach d,$(TOPDIR)/configs $(BR2_EXTERNAL)/configs,$(wildcard $(d)/$(1))) +endef + +define CONFIG_FILE_LIST = +$(foreach f,$1,$(call FIND_CONFIG_FILE,$f)) +endef + +# Check that each config file is found once and only once. +define CHECK_CONFIG_FILE_LIST = +$(foreach f,$(1), +ifeq "$(words $(call FIND_CONFIG_FILE,$(f)))" "0" +$$(error ERROR: Missing input file: $(f)) +else +ifneq "$(words $(call FIND_CONFIG_FILE,$(f)))" "1" +$$(error ERROR: Duplicate input file: $(f)) +endif +endif +) +endef + +# To be called by configuration fragments (*.mk) to set up defconfigs built +# by merge_config.sh, via the include that follows: +define merge_config = +$(call CHECK_CONFIG_FILE_LIST,$2 $3) +$(1): $$(BUILD_DIR)/buildroot-config/conf $(call CONFIG_FILE_LIST,$2 $3) outputmakefile + @mkdir $$(CONFIG_DIR)/.merge_config + @$$(TOPDIR)/support/kconfig/merge_config.sh -m -O $$(CONFIG_DIR)/.merge_config \ + $(call CONFIG_FILE_LIST,$2 $3) + @$$(COMMON_CONFIG_ENV) BR2_DEFCONFIG=$$(CONFIG_DIR)/.merge_config/.config \ + $$< --defconfig=$$(CONFIG_DIR)/.merge_config/.config $$(CONFIG_CONFIG_IN) + @rm -rf $$(CONFIG_DIR)/.merge_config +endef + +$(foreach d,$(TOPDIR)/configs $(BR2_EXTERNAL)/configs,$(eval -include $(d)/*.mk)) + ################################################################################ # # Cleanup and misc junk diff --git a/docs/manual/adding-board-support.txt b/docs/manual/adding-board-support.txt index f6d74ae..086a67e 100644 --- a/docs/manual/adding-board-support.txt +++ b/docs/manual/adding-board-support.txt @@ -24,6 +24,9 @@ savedefconfig+. This will generate a minimal +defconfig+ file at the root of the Buildroot source tree. Move this file into the +configs/+ directory, and rename it +_defconfig+. +It is also possible to create configurations by specifying differences from +an existing configuration. See xref:merged-defconfigs[]. + It is recommended to use as much as possible upstream versions of the Linux kernel and bootloaders, and to use as much as possible default kernel and bootloader configurations. If they are incorrect for your diff --git a/docs/manual/appendix.txt b/docs/manual/appendix.txt index 87a20bd..9abc37e 100644 --- a/docs/manual/appendix.txt +++ b/docs/manual/appendix.txt @@ -3,6 +3,7 @@ include::makedev-syntax.txt[] include::makeusers-syntax.txt[] +include::merged-defconfigs.txt[] // Automatically generated lists: diff --git a/docs/manual/merged-defconfigs.txt b/docs/manual/merged-defconfigs.txt new file mode 100644 index 0000000..e1f50fd --- /dev/null +++ b/docs/manual/merged-defconfigs.txt @@ -0,0 +1,60 @@ +// -*- mode:doc -*- ; +// vim: set syntax=asciidoc: + +[[merged-defconfigs]] +== Merged configurations + +Buildroot supports the use of the Linux kernel's +merge_config.sh+ script to +create configurations by merging a set of partial configurations (or overlays) +on top of a base configuration. This may be useful when there are several +configurations that are specializations of a single generic configuration. + +Files in the +configs/+ directory with the extension ++.mk+ will be read by the top level Makefile and the Make function ++merge_config+ can be used within them to define new merged configurations. + +The merge_config function takes three parameters: the first is the name of the +new configuration (which should end with +_defconfig+), the second is the name +of the base configuration file and the third is a space separated list of the +partial configuration files to merge from the +configs/+ directory. All files +should be specified relative to the +configs/+ directory and the name of the +Make fragment file should match the name of the configuration it creates. + +The new configuration can be selected as if it were a normal configuration, i.e. with ++make foo_defconfig+. + +Partial configurations have the same format as full configuration +files except that they contain only a subset of values. They can be created by +starting with a normal configuration file and deleting lines as appropriate. + +External configuration files from the +$(BR2_EXTERNAL)/configs+ directory are fully +supported, and merge configurations may freely refer to files from either +location. + +Example: + +If configs/foo_defconfig contains: +----- +BR2_TARGET_GENERIC_HOSTNAME="buildroot" +----- + +And configs/bar_defconfig.mk contains: +----- +$(eval $(call merge_config,bar_defconfig,foo_defconfig,b.config)) +----- + +And configs/b.config contains: +----- +BR2_TARGET_GENERIC_ISSUE="Welcome to BAR" +----- + +After running the command: +----- +make bar_defconfig +----- + +The resulting .config file would contain: +----- +BR2_TARGET_GENERIC_HOSTNAME="buildroot" +BR2_TARGET_GENERIC_ISSUE="Welcome to BAR" +-----