From patchwork Fri Jul 29 23:32:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 1021982 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6TNXC3c014268 for ; Fri, 29 Jul 2011 23:33:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753174Ab1G2XdM (ORCPT ); Fri, 29 Jul 2011 19:33:12 -0400 Received: from casper.infradead.org ([85.118.1.10]:42670 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753058Ab1G2XdL (ORCPT ); Fri, 29 Jul 2011 19:33:11 -0400 Received: from i7.infradead.org ([2001:8b0:10b:1:225:64ff:fee8:e9df]) by casper.infradead.org with esmtpsa (Exim 4.76 #1 (Red Hat Linux)) id 1QmwXt-0002fr-9J; Fri, 29 Jul 2011 23:32:45 +0000 Subject: [PATCH v2] Enable 'make CONFIG_FOO=y oldconfig' From: David Woodhouse To: Michal Marek Cc: Arnaud Lacombe , "Ted Ts'o" , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org, linux-kbuild@vger.kernel.org, hpa@zytor.com Date: Sat, 30 Jul 2011 00:32:43 +0100 In-Reply-To: <4E0495F4.7080300@suse.cz> References: <1306707270.2029.377.camel@i7.infradead.org> <20110530072300.GA9802@elte.hu> <1306745835.2029.389.camel@i7.infradead.org> <20110530104231.GF17821@elte.hu> <20110530104656.GA19532@elte.hu> <20110530105809.GA20133@elte.hu> <1A4DB87D-9B32-44C0-B7C9-47A003CABD96@mit.edu> <20110530195545.GG2890@dhcp-172-31-194-241.cam.corp.google.com> <1306795186.2029.459.camel@i7.infradead.org> <1306856937.27477.3.camel@i7.infradead.org> <4E0495F4.7080300@suse.cz> X-Mailer: Evolution 3.0.2 (3.0.2-3.fc15) Message-ID: <1311982365.20983.42.camel@i7.infradead.org> Mime-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 29 Jul 2011 23:33:13 +0000 (UTC) This allows you to set (and clear) config options on the make command line, for all config targets. For example: make CONFIG_64BIT=n randconfig make CONFIG_64BIT=n allmodconfig make CONFIG_64BIT=y CONFIG_SATA_MV=y oldconfig Signed-off-by: David Woodhouse --- v2: Add call to sym_calc_value() before sym_set_string_value(), to set symbol visibility. 'make ARCH=arm CONFIG_ARCH_OMAP=y allnoconfig' should work correctly now. scripts/kconfig/conf.c | 7 ++++++- scripts/kconfig/confdata.c | 42 ++++++++++++++++++++++++++++++++++++++++++ scripts/kconfig/lkc.h | 1 + 3 files changed, 49 insertions(+), 1 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 006ad81..2b91e3b 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -456,7 +456,7 @@ static struct option long_opts[] = { {NULL, 0, NULL, 0} }; -int main(int ac, char **av) +int main(int ac, char **av, char **ep) { int opt; const char *name; @@ -563,6 +563,11 @@ int main(int ac, char **av) break; } + for ( ; *ep; ep++) { + if (!strncmp(*ep, CONFIG_, strlen(CONFIG_))) + conf_set_symbol_from_env(*ep); + } + if (sync_kconfig) { if (conf_get_changed()) { name = getenv("KCONFIG_NOSILENTUPDATE"); diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 2bafd9a..ada3c4b 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -338,6 +338,48 @@ setsym: return 0; } +void conf_set_symbol_from_env(char *str) +{ + char *p = strchr(str, '='); + struct symbol *sym; + int def = S_DEF_USER; + int def_flags = SYMBOL_DEF << def; + + if (!p) + return; + + *p = 0; + sym = sym_find(str + strlen(CONFIG_)); + *p++ = '='; + + if (!sym) + return; + + sym_calc_value(sym); + if (!sym_set_string_value(sym, p)) + return; + conf_message("CONFIG_%s set to %s from environment", sym->name, p); + if (sym && sym_is_choice_value(sym)) { + struct symbol *cs = prop_get_symbol(sym_get_choice_prop(sym)); + switch (sym->def[def].tri) { + case no: + break; + case mod: + if (cs->def[def].tri == yes) { + conf_warning("%s creates inconsistent choice state", sym->name); + cs->flags &= ~def_flags; + } + break; + case yes: + if (cs->def[def].tri != no) + conf_warning("override: %s changes choice state", sym->name); + cs->def[def].val = sym; + break; + } + cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri); + } +} + int conf_read(const char *name) { struct symbol *sym, *choice_sym; diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index f34a0a9..fc2f3ad 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -89,6 +89,7 @@ char *conf_get_default_confname(void); void sym_set_change_count(int count); void sym_add_change_count(int count); void conf_set_all_new_symbols(enum conf_def_mode mode); +void conf_set_symbol_from_env(char *); /* confdata.c and expr.c */ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out)