History

Merge tag 'kconfig-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild

Pull Kconfig updates from Masahiro Yamada: - show clearer error messages where pkg-config is needed, but not installed - rename SYMBOL_AUTO to SYMBOL_NO_WRITE to reflect its semantics - create all necessary directories by Kconfig tool itself instead of Makefile - update the .config unconditionally when syncconfig is invoked - use 'include' directive instead of '-include' where include/config/{auto,tristate}.conf is mandatory - do not try to update the .config when running install targets - add .DELETE_ON_ERROR to delete partially updated files - misc cleanups and fixes * tag 'kconfig-v4.19' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: kconfig: remove P_ENV property type kconfig: remove unused sym_get_env_prop() function kconfig: fix the rule of mainmenu_stmt symbol init/Kconfig: Use short unix-style option instead of --longname Kbuild: Makefile.modbuiltin: include auto.conf and tristate.conf mandatory kbuild: remove auto.conf from prerequisite of phony targets kbuild: do not update config for 'make kernelrelease' kbuild: do not update config when running install targets kbuild: add .DELETE_ON_ERROR special target kbuild: use 'include' directive to load auto.conf from top Makefile kconfig: allow all config targets to write auto.conf if missing kconfig: make syncconfig update .config regardless of sym_change_count kconfig: create directories needed for syncconfig by itself kconfig: remove unneeded directory generation from local*config kconfig: split out useful helpers in confdata.c kconfig: rename file_write_dep and move it to confdata.c kconfig: fix typos in description of "choice" in kconfig-language.txt kconfig: handle format string before calling conf_message_callback() kconfig: rename SYMBOL_AUTO to SYMBOL_NO_WRITE kconfig: check for pkg-config on make {menu,n,g,x}config

Linus Torvalds committed 8 years ago

Commit 01f0e5c2 parents e026bcc 188086121 files · +227 −146Browse files

Unified · Split

21 files
  1. Documentation/kbuild/kconfig-language.txt +2 −2
  2. Documentation/process/changes.rst +8 −0
  3. Makefile +26 −18
  4. init/Kconfig +2 −2
  5. scripts/Kbuild.include +3 −0
  6. scripts/Makefile.modbuiltin +2 −2
  7. scripts/kconfig/Makefile +7 −10
  8. scripts/kconfig/check-pkgconfig.sh +8 −0
  9. scripts/kconfig/conf.c +22 −17
  10. scripts/kconfig/confdata.c +127 −29
  11. scripts/kconfig/expr.h +1 −2
  12. scripts/kconfig/gconf.c +3 −2
  13. scripts/kconfig/lkc.h +0 −2
  14. scripts/kconfig/lkc_proto.h +2 −2
  15. scripts/kconfig/mconf.c +4 −6
  16. scripts/kconfig/menu.c +1 −1
  17. scripts/kconfig/nconf.c +3 −5
  18. scripts/kconfig/qconf.cc +2 −1
  19. scripts/kconfig/symbol.c +1 −12
  20. scripts/kconfig/util.c +0 −30
  21. scripts/kconfig/zconf.y +3 −3
Documentation/kbuild/kconfig-language.txt+2−2
@@ -370,7 +370,7 @@ choices: · 369 unmodified lines
370 370
371This defines a choice group and accepts any of the above attributes as371This defines a choice group and accepts any of the above attributes as
372options. A choice can only be of type bool or tristate. If no type is372options. A choice can only be of type bool or tristate. If no type is
373specified for a choice, it's type will be determined by the type of373specified for a choice, its type will be determined by the type of
374the first choice element in the group or remain unknown if none of the374the first choice element in the group or remain unknown if none of the
375choice elements have a type specified, as well.375choice elements have a type specified, as well.
376 376
@@ -384,7 +384,7 @@ A choice accepts another option "optional", which allows to set the · 7 unmodified lines
384choice to 'n' and no entry needs to be selected.384choice to 'n' and no entry needs to be selected.
385If no [symbol] is associated with a choice, then you can not have multiple385If no [symbol] is associated with a choice, then you can not have multiple
386definitions of that choice. If a [symbol] is associated to the choice,386definitions of that choice. If a [symbol] is associated to the choice,
387then you may define the same choice (ie. with the same entries) in another387then you may define the same choice (i.e. with the same entries) in another
388place.388place.
389 389
390comment:390comment:
Documentation/process/changes.rst+8−0
@@ -81,6 +81,14 @@ The build system has, as of 4.13, switched to using thin archives (`ar T`) · 80 unmodified lines
81rather than incremental linking (`ld -r`) for built-in.a intermediate steps.81rather than incremental linking (`ld -r`) for built-in.a intermediate steps.
82This requires binutils 2.20 or newer.82This requires binutils 2.20 or newer.
83 83
84pkg-config
85----------
86
87The build system, as of 4.18, requires pkg-config to check for installed
88kconfig tools and to determine flags settings for use in
89'make {menu,n,g,x}config'. Previously pkg-config was being used but not
90verified or documented.
91
84Flex92Flex
85----93----
86 94
Makefile+26−18
@@ -225,10 +225,13 @@ no-dot-config-targets := $(clean-targets) \ · 224 unmodified lines
225 cscope gtags TAGS tags help% %docs check% coccicheck \225 cscope gtags TAGS tags help% %docs check% coccicheck \
226 $(version_h) headers_% archheaders archscripts \226 $(version_h) headers_% archheaders archscripts \
227 %asm-generic kernelversion %src-pkg227 %asm-generic kernelversion %src-pkg
228no-sync-config-targets := $(no-dot-config-targets) install %install \
229 kernelrelease
228 230
229config-targets := 0231config-targets := 0
230mixed-targets := 0232mixed-targets := 0
231dot-config := 1233dot-config := 1
234may-sync-config := 1
232 235
233ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)236ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
234 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)237 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
@@ -236,6 +239,16 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) · 1 unmodified line
236 endif239 endif
237endif240endif
238 241
242ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
243 ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
244 may-sync-config := 0
245 endif
246endif
247
248ifneq ($(KBUILD_EXTMOD),)
249 may-sync-config := 0
250endif
251
239ifeq ($(KBUILD_EXTMOD),)252ifeq ($(KBUILD_EXTMOD),)
240 ifneq ($(filter config %config,$(MAKECMDGOALS)),)253 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
241 config-targets := 1254 config-targets := 1
@@ -585,7 +598,7 @@ virt-y := virt/ · 343 unmodified lines
585endif # KBUILD_EXTMOD598endif # KBUILD_EXTMOD
586 599
587ifeq ($(dot-config),1)600ifeq ($(dot-config),1)
588-include include/config/auto.conf601include include/config/auto.conf
589endif602endif
590 603
591# The all: target is the default when no target is given on the604# The all: target is the default when no target is given on the
@@ -607,7 +620,7 @@ ARCH_CFLAGS := · 15 unmodified lines
607include arch/$(SRCARCH)/Makefile620include arch/$(SRCARCH)/Makefile
608 621
609ifeq ($(dot-config),1)622ifeq ($(dot-config),1)
610ifeq ($(KBUILD_EXTMOD),)623ifeq ($(may-sync-config),1)
611# Read in dependencies to all Kconfig* files, make sure to run syncconfig if624# Read in dependencies to all Kconfig* files, make sure to run syncconfig if
612# changes are detected. This should be included after arch/$(SRCARCH)/Makefile625# changes are detected. This should be included after arch/$(SRCARCH)/Makefile
613# because some architectures define CROSS_COMPILE there.626# because some architectures define CROSS_COMPILE there.
@@ -622,8 +635,9 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; · 8 unmodified lines
622include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd635include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
623 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig636 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
624else637else
625# external modules needs include/generated/autoconf.h and include/config/auto.conf638# External modules and some install targets need include/generated/autoconf.h
626# but do not care if they are up-to-date. Use auto.conf to trigger the test639# and include/config/auto.conf but do not care if they are up-to-date.
640# Use auto.conf to trigger the test
627PHONY += include/config/auto.conf641PHONY += include/config/auto.conf
628 642
629include/config/auto.conf:643include/config/auto.conf:
@@ -635,11 +649,7 @@ include/config/auto.conf: · 5 unmodified lines
635 echo >&2 ; \649 echo >&2 ; \
636 /bin/false)650 /bin/false)
637 651
638endif # KBUILD_EXTMOD652endif # may-sync-config
639
640else
641# Dummy target needed, because used as prerequisite
642include/config/auto.conf: ;
643endif # $(dot-config)653endif # $(dot-config)
644 654
645KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)655KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
@@ -1035,15 +1045,14 @@ define filechk_kernel.release · 389 unmodified lines
1035endef1045endef
1036 1046
1037# Store (new) KERNELRELEASE string in include/config/kernel.release1047# Store (new) KERNELRELEASE string in include/config/kernel.release
1038include/config/kernel.release: include/config/auto.conf FORCE1048include/config/kernel.release: $(srctree)/Makefile FORCE
1039 $(call filechk,kernel.release)1049 $(call filechk,kernel.release)
1040 1050
1041# Additional helpers built in scripts/1051# Additional helpers built in scripts/
1042# Carefully list dependencies so we do not try to build scripts twice1052# Carefully list dependencies so we do not try to build scripts twice
1043# in parallel1053# in parallel
1044PHONY += scripts1054PHONY += scripts
1045scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \1055scripts: scripts_basic asm-generic gcc-plugins $(autoksyms_h)
1046 asm-generic gcc-plugins $(autoksyms_h)
1047 $(Q)$(MAKE) $(build)=$(@)1056 $(Q)$(MAKE) $(build)=$(@)
1048 1057
1049# Things we need to do before we recursively start building the kernel1058# Things we need to do before we recursively start building the kernel
@@ -1073,8 +1082,7 @@ endif · 23 unmodified lines
1073# that need to depend on updated CONFIG_* values can be checked here.1082# that need to depend on updated CONFIG_* values can be checked here.
1074prepare2: prepare3 outputmakefile asm-generic1083prepare2: prepare3 outputmakefile asm-generic
1075 1084
1076prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h \1085prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h
1077 include/config/auto.conf
1078 $(cmd_crmodverdir)1086 $(cmd_crmodverdir)
1079 1087
1080archprepare: archheaders archscripts prepare1 scripts_basic1088archprepare: archheaders archscripts prepare1 scripts_basic
@@ -1212,7 +1220,7 @@ modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin · 131 unmodified lines
1212modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)1220modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
1213 $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin1221 $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin
1214 1222
1215%/modules.builtin: include/config/auto.conf1223%/modules.builtin: include/config/auto.conf include/config/tristate.conf
1216 $(Q)$(MAKE) $(modbuiltin)=$*1224 $(Q)$(MAKE) $(modbuiltin)=$*
1217 1225
1218 1226
init/Kconfig+2−2
@@ -2,9 +2,9 @@ config DEFCONFIG_LIST · 1 unmodified line
2 string2 string
3 depends on !UML3 depends on !UML
4 option defconfig_list4 option defconfig_list
5 default "/lib/modules/$(shell,uname --release)/.config"5 default "/lib/modules/$(shell,uname -r)/.config"
6 default "/etc/kernel-config"6 default "/etc/kernel-config"
7 default "/boot/config-$(shell,uname --release)"7 default "/boot/config-$(shell,uname -r)"
8 default ARCH_DEFCONFIG8 default ARCH_DEFCONFIG
9 default "arch/$(ARCH)/defconfig"9 default "arch/$(ARCH)/defconfig"
10 10
scripts/Kbuild.include+3−0
@@ -400,3 +400,6 @@ endif · 399 unmodified lines
400endef400endef
401#401#
402###############################################################################402###############################################################################
403
404# delete partially updated (i.e. corrupted) files on error
405.DELETE_ON_ERROR:
scripts/Makefile.modbuiltin+2−2
@@ -8,10 +8,10 @@ src := $(obj) · 7 unmodified lines
8PHONY := __modbuiltin8PHONY := __modbuiltin
9__modbuiltin:9__modbuiltin:
10 10
11-include include/config/auto.conf11include include/config/auto.conf
12# tristate.conf sets tristate variables to uppercase 'Y' or 'M'12# tristate.conf sets tristate variables to uppercase 'Y' or 'M'
13# That way, we get the list of built-in modules in obj-Y13# That way, we get the list of built-in modules in obj-Y
14-include include/config/tristate.conf14include include/config/tristate.conf
15 15
16include scripts/Kbuild.include16include scripts/Kbuild.include
17 17
scripts/kconfig/Makefile+7−10
@@ -3,8 +3,7 @@ · 2 unmodified lines
3# Kernel configuration targets3# Kernel configuration targets
4# These targets are used from top-level makefile4# These targets are used from top-level makefile
5 5
6PHONY += xconfig gconfig menuconfig config syncconfig \6PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig
7 localmodconfig localyesconfig
8 7
9ifdef KBUILD_KCONFIG8ifdef KBUILD_KCONFIG
10Kconfig := $(KBUILD_KCONFIG)9Kconfig := $(KBUILD_KCONFIG)
@@ -34,14 +33,7 @@ config: $(obj)/conf · 23 unmodified lines
34nconfig: $(obj)/nconf33nconfig: $(obj)/nconf
35 $< $(silent) $(Kconfig)34 $< $(silent) $(Kconfig)
36 35
37# This has become an internal implementation detail and is now deprecated
38# for external use.
39syncconfig: $(obj)/conf
40 $(Q)mkdir -p include/config include/generated
41 $< $(silent) --$@ $(Kconfig)
42
43localyesconfig localmodconfig: $(obj)/conf36localyesconfig localmodconfig: $(obj)/conf
44 $(Q)mkdir -p include/config include/generated
45 $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config37 $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
46 $(Q)if [ -f .config ]; then \38 $(Q)if [ -f .config ]; then \
47 cmp -s .tmp.config .config || \39 cmp -s .tmp.config .config || \
@@ -56,8 +48,12 @@ localyesconfig localmodconfig: $(obj)/conf · 8 unmodified lines
56 $(Q)rm -f .tmp.config48 $(Q)rm -f .tmp.config
57 49
58# These targets map 1:1 to the commandline options of 'conf'50# These targets map 1:1 to the commandline options of 'conf'
51#
52# Note:
53# syncconfig has become an internal implementation detail and is now
54# deprecated for external use
59simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \55simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
60 alldefconfig randconfig listnewconfig olddefconfig56 alldefconfig randconfig listnewconfig olddefconfig syncconfig
61PHONY += $(simple-targets)57PHONY += $(simple-targets)
62 58
63$(simple-targets): $(obj)/conf59$(simple-targets): $(obj)/conf
@@ -215,6 +211,7 @@ $(obj)/zconf.tab.o: $(obj)/zconf.lex.c · 151 unmodified lines
215 211
216# check if necessary packages are available, and configure build flags212# check if necessary packages are available, and configure build flags
217define filechk_conf_cfg213define filechk_conf_cfg
214 $(CONFIG_SHELL) $(srctree)/scripts/kconfig/check-pkgconfig.sh; \
218 $(CONFIG_SHELL) $<215 $(CONFIG_SHELL) $<
219endef216endef
220 217
scripts/kconfig/check-pkgconfig.sh+8−0
@@ -0,0 +1,8 @@
1#!/bin/sh
2# SPDX-License-Identifier: GPL-2.0
3# Check for pkg-config presence
4
5if [ -z $(command -v pkg-config) ]; then
6 echo "'make *config' requires 'pkg-config'. Please install it." 1>&2
7 exit 1
8fi
scripts/kconfig/conf.c+22−17
@@ -496,6 +496,7 @@ int main(int ac, char **av) · 495 unmodified lines
496 int opt;496 int opt;
497 const char *name, *defconfig_file = NULL /* gcc uninit */;497 const char *name, *defconfig_file = NULL /* gcc uninit */;
498 struct stat tmpstat;498 struct stat tmpstat;
499 int no_conf_write = 0;
499 500
500 tty_stdio = isatty(0) && isatty(1);501 tty_stdio = isatty(0) && isatty(1);
501 502
@@ -633,13 +634,14 @@ int main(int ac, char **av) · 131 unmodified lines
633 }634 }
634 635
635 if (sync_kconfig) {636 if (sync_kconfig) {
636 if (conf_get_changed()) {637 name = getenv("KCONFIG_NOSILENTUPDATE");
637 name = getenv("KCONFIG_NOSILENTUPDATE");638 if (name && *name) {
638 if (name && *name) {639 if (conf_get_changed()) {
639 fprintf(stderr,640 fprintf(stderr,
640 "\n*** The configuration requires explicit update.\n\n");641 "\n*** The configuration requires explicit update.\n\n");
641 return 1;642 return 1;
642 }643 }
644 no_conf_write = 1;
643 }645 }
644 }646 }
645 647
@@ -684,29 +686,32 @@ int main(int ac, char **av) · 38 unmodified lines
684 break;686 break;
685 }687 }
686 688
687 if (sync_kconfig) {689 if (input_mode == savedefconfig) {
688 /* syncconfig is used during the build so we shall update autoconf.
689 * All other commands are only used to generate a config.
690 */
691 if (conf_get_changed() && conf_write(NULL)) {
692 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
693 exit(1);
694 }
695 if (conf_write_autoconf()) {
696 fprintf(stderr, "\n*** Error during update of the configuration.\n\n");
697 return 1;
698 }
699 } else if (input_mode == savedefconfig) {
700 if (conf_write_defconfig(defconfig_file)) {690 if (conf_write_defconfig(defconfig_file)) {
701 fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n",691 fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n",
702 defconfig_file);692 defconfig_file);
703 return 1;693 return 1;
704 }694 }
705 } else if (input_mode != listnewconfig) {695 } else if (input_mode != listnewconfig) {
706 if (conf_write(NULL)) {696 if (!no_conf_write && conf_write(NULL)) {
707 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");697 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
708 exit(1);698 exit(1);
709 }699 }
700
701 /*
702 * Create auto.conf if it does not exist.
703 * This prevents GNU Make 4.1 or older from emitting
704 * "include/config/auto.conf: No such file or directory"
705 * in the top-level Makefile
706 *
707 * syncconfig always creates or updates auto.conf because it is
708 * used during the build.
709 */
710 if (conf_write_autoconf(sync_kconfig) && sync_kconfig) {
711 fprintf(stderr,
712 "\n*** Error during sync of the configuration.\n\n");
713 return 1;
714 }
710 }715 }
711 return 0;716 return 0;
712}717}
scripts/kconfig/confdata.c+127−29
@@ -16,6 +16,64 @@ · 15 unmodified lines
16 16
17#include "lkc.h"17#include "lkc.h"
18 18
19/* return true if 'path' exists, false otherwise */
20static bool is_present(const char *path)
21{
22 struct stat st;
23
24 return !stat(path, &st);
25}
26
27/* return true if 'path' exists and it is a directory, false otherwise */
28static bool is_dir(const char *path)
29{
30 struct stat st;
31
32 if (stat(path, &st))
33 return 0;
34
35 return S_ISDIR(st.st_mode);
36}
37
38/*
39 * Create the parent directory of the given path.
40 *
41 * For example, if 'include/config/auto.conf' is given, create 'include/config'.
42 */
43static int make_parent_dir(const char *path)
44{
45 char tmp[PATH_MAX + 1];
46 char *p;
47
48 strncpy(tmp, path, sizeof(tmp));
49 tmp[sizeof(tmp) - 1] = 0;
50
51 /* Remove the base name. Just return if nothing is left */
52 p = strrchr(tmp, '/');
53 if (!p)
54 return 0;
55 *(p + 1) = 0;
56
57 /* Just in case it is an absolute path */
58 p = tmp;
59 while (*p == '/')
60 p++;
61
62 while ((p = strchr(p, '/'))) {
63 *p = 0;
64
65 /* skip if the directory exists */
66 if (!is_dir(tmp) && mkdir(tmp, 0755))
67 return -1;
68
69 *p = '/';
70 while (*p == '/')
71 p++;
72 }
73
74 return 0;
75}
76
19struct conf_printer {77struct conf_printer {
20 void (*print_symbol)(FILE *, struct symbol *, const char *, void *);78 void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
21 void (*print_comment)(FILE *, const char *, void *);79 void (*print_comment)(FILE *, const char *, void *);
@@ -43,16 +101,16 @@ static void conf_warning(const char *fmt, ...) · 21 unmodified lines
43 conf_warnings++;101 conf_warnings++;
44}102}
45 103
46static void conf_default_message_callback(const char *fmt, va_list ap)104static void conf_default_message_callback(const char *s)
47{105{
48 printf("#\n# ");106 printf("#\n# ");
49 vprintf(fmt, ap);107 printf("%s", s);
50 printf("\n#\n");108 printf("\n#\n");
51}109}
52 110
53static void (*conf_message_callback) (const char *fmt, va_list ap) =111static void (*conf_message_callback)(const char *s) =
54 conf_default_message_callback;112 conf_default_message_callback;
55void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))113void conf_set_message_callback(void (*fn)(const char *s))
56{114{
57 conf_message_callback = fn;115 conf_message_callback = fn;
58}116}
@@ -60,10 +118,15 @@ void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) · 1 unmodified line
60static void conf_message(const char *fmt, ...)118static void conf_message(const char *fmt, ...)
61{119{
62 va_list ap;120 va_list ap;
121 char buf[4096];
122
123 if (!conf_message_callback)
124 return;
63 125
64 va_start(ap, fmt);126 va_start(ap, fmt);
65 if (conf_message_callback)127
66 conf_message_callback(fmt, ap);128 vsnprintf(buf, sizeof(buf), fmt, ap);
129 conf_message_callback(buf);
67 va_end(ap);130 va_end(ap);
68}131}
69 132
@@ -83,7 +146,6 @@ const char *conf_get_autoconfig_name(void) · 13 unmodified lines
83 146
84char *conf_get_default_confname(void)147char *conf_get_default_confname(void)
85{148{
86 struct stat buf;
87 static char fullname[PATH_MAX+1];149 static char fullname[PATH_MAX+1];
88 char *env, *name;150 char *env, *name;
89 151
@@ -91,7 +153,7 @@ char *conf_get_default_confname(void) · 1 unmodified line
91 env = getenv(SRCTREE);153 env = getenv(SRCTREE);
92 if (env) {154 if (env) {
93 sprintf(fullname, "%s/%s", env, name);155 sprintf(fullname, "%s/%s", env, name);
94 if (!stat(fullname, &buf))156 if (is_present(fullname))
95 return fullname;157 return fullname;
96 }158 }
97 return name;159 return name;
@@ -397,7 +459,7 @@ int conf_read(const char *name) · 299 unmodified lines
397 459
398 for_all_symbols(i, sym) {460 for_all_symbols(i, sym) {
399 sym_calc_value(sym);461 sym_calc_value(sym);
400 if (sym_is_choice(sym) || (sym->flags & SYMBOL_AUTO))462 if (sym_is_choice(sym) || (sym->flags & SYMBOL_NO_WRITE))
401 continue;463 continue;
402 if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {464 if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
403 /* check that calculated value agrees with saved value */465 /* check that calculated value agrees with saved value */
@@ -725,10 +787,9 @@ int conf_write(const char *name) · 321 unmodified lines
725 787
726 dirname[0] = 0;788 dirname[0] = 0;
727 if (name && name[0]) {789 if (name && name[0]) {
728 struct stat st;
729 char *slash;790 char *slash;
730 791
731 if (!stat(name, &st) && S_ISDIR(st.st_mode)) {792 if (is_dir(name)) {
732 strcpy(dirname, name);793 strcpy(dirname, name);
733 strcat(dirname, "/");794 strcat(dirname, "/");
734 basename = conf_get_configname();795 basename = conf_get_configname();
@@ -813,26 +874,59 @@ next: · 78 unmodified lines
813 return 0;874 return 0;
814}875}
815 876
877/* write a dependency file as used by kbuild to track dependencies */
878static int conf_write_dep(const char *name)
879{
880 struct file *file;
881 FILE *out;
882
883 if (!name)
884 name = ".kconfig.d";
885 out = fopen("..config.tmp", "w");
886 if (!out)
887 return 1;
888 fprintf(out, "deps_config := \\\n");
889 for (file = file_list; file; file = file->next) {
890 if (file->next)
891 fprintf(out, "\t%s \\\n", file->name);
892 else
893 fprintf(out, "\t%s\n", file->name);
894 }
895 fprintf(out, "\n%s: \\\n"
896 "\t$(deps_config)\n\n", conf_get_autoconfig_name());
897
898 env_write_dep(out, conf_get_autoconfig_name());
899
900 fprintf(out, "\n$(deps_config): ;\n");
901 fclose(out);
902
903 if (make_parent_dir(name))
904 return 1;
905 rename("..config.tmp", name);
906 return 0;
907}
908
816static int conf_split_config(void)909static int conf_split_config(void)
817{910{
818 const char *name;911 const char *name;
819 char path[PATH_MAX+1];912 char path[PATH_MAX+1];
820 char *s, *d, c;913 char *s, *d, c;
821 struct symbol *sym;914 struct symbol *sym;
822 struct stat sb;
823 int res, i, fd;915 int res, i, fd;
824 916
825 name = conf_get_autoconfig_name();917 name = conf_get_autoconfig_name();
826 conf_read_simple(name, S_DEF_AUTO);918 conf_read_simple(name, S_DEF_AUTO);
827 sym_calc_value(modules_sym);919 sym_calc_value(modules_sym);
828 920
921 if (make_parent_dir("include/config/foo.h"))
922 return 1;
829 if (chdir("include/config"))923 if (chdir("include/config"))
830 return 1;924 return 1;
831 925
832 res = 0;926 res = 0;
833 for_all_symbols(i, sym) {927 for_all_symbols(i, sym) {
834 sym_calc_value(sym);928 sym_calc_value(sym);
835 if ((sym->flags & SYMBOL_AUTO) || !sym->name)929 if ((sym->flags & SYMBOL_NO_WRITE) || !sym->name)
836 continue;930 continue;
837 if (sym->flags & SYMBOL_WRITE) {931 if (sym->flags & SYMBOL_WRITE) {
838 if (sym->flags & SYMBOL_DEF_AUTO) {932 if (sym->flags & SYMBOL_DEF_AUTO) {
@@ -897,19 +991,12 @@ static int conf_split_config(void) · 58 unmodified lines
897 res = 1;991 res = 1;
898 break;992 break;
899 }993 }
900 /*994
901 * Create directory components,995 if (make_parent_dir(path)) {
902 * unless they exist already.996 res = 1;
903 */997 goto out;
904 d = path;
905 while ((d = strchr(d, '/'))) {
906 *d = 0;
907 if (stat(path, &sb) && mkdir(path, 0755)) {
908 res = 1;
909 goto out;
910 }
911 *d++ = '/';
912 }998 }
999
913 /* Try it again. */1000 /* Try it again. */
914 fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);1001 fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
915 if (fd == -1) {1002 if (fd == -1) {
@@ -926,16 +1013,20 @@ out: · 10 unmodified lines
926 return res;1013 return res;
927}1014}
928 1015
929int conf_write_autoconf(void)1016int conf_write_autoconf(int overwrite)
930{1017{
931 struct symbol *sym;1018 struct symbol *sym;
932 const char *name;1019 const char *name;
1020 const char *autoconf_name = conf_get_autoconfig_name();
933 FILE *out, *tristate, *out_h;1021 FILE *out, *tristate, *out_h;
934 int i;1022 int i;
935 1023
1024 if (!overwrite && is_present(autoconf_name))
1025 return 0;
1026
936 sym_clear_all_valid();1027 sym_clear_all_valid();
937 1028
938 file_write_dep("include/config/auto.conf.cmd");1029 conf_write_dep("include/config/auto.conf.cmd");
939 1030
940 if (conf_split_config())1031 if (conf_split_config())
941 return 1;1032 return 1;
@@ -982,19 +1073,26 @@ int conf_write_autoconf(void) · 40 unmodified lines
982 name = getenv("KCONFIG_AUTOHEADER");1073 name = getenv("KCONFIG_AUTOHEADER");
983 if (!name)1074 if (!name)
984 name = "include/generated/autoconf.h";1075 name = "include/generated/autoconf.h";
1076 if (make_parent_dir(name))
1077 return 1;
985 if (rename(".tmpconfig.h", name))1078 if (rename(".tmpconfig.h", name))
986 return 1;1079 return 1;
1080
987 name = getenv("KCONFIG_TRISTATE");1081 name = getenv("KCONFIG_TRISTATE");
988 if (!name)1082 if (!name)
989 name = "include/config/tristate.conf";1083 name = "include/config/tristate.conf";
1084 if (make_parent_dir(name))
1085 return 1;
990 if (rename(".tmpconfig_tristate", name))1086 if (rename(".tmpconfig_tristate", name))
991 return 1;1087 return 1;
992 name = conf_get_autoconfig_name();1088
1089 if (make_parent_dir(autoconf_name))
1090 return 1;
993 /*1091 /*
994 * This must be the last step, kbuild has a dependency on auto.conf1092 * This must be the last step, kbuild has a dependency on auto.conf
995 * and this marks the successful completion of the previous steps.1093 * and this marks the successful completion of the previous steps.
996 */1094 */
997 if (rename(".tmpconfig", name))1095 if (rename(".tmpconfig", autoconf_name))
998 return 1;1096 return 1;
999 1097
1000 return 0;1098 return 0;
scripts/kconfig/expr.h+1−2
@@ -141,7 +141,7 @@ struct symbol { · 140 unmodified lines
141#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */141#define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
142#define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */142#define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */
143#define SYMBOL_CHANGED 0x0400 /* ? */143#define SYMBOL_CHANGED 0x0400 /* ? */
144#define SYMBOL_AUTO 0x1000 /* value from environment variable */144#define SYMBOL_NO_WRITE 0x1000 /* Symbol for internal use only; it will not be written */
145#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */145#define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
146#define SYMBOL_WARNED 0x8000 /* warning has been issued */146#define SYMBOL_WARNED 0x8000 /* warning has been issued */
147 147
@@ -185,7 +185,6 @@ enum prop_type { · 37 unmodified lines
185 P_SELECT, /* select BAR */185 P_SELECT, /* select BAR */
186 P_IMPLY, /* imply BAR */186 P_IMPLY, /* imply BAR */
187 P_RANGE, /* range 7..100 (for a symbol) */187 P_RANGE, /* range 7..100 (for a symbol) */
188 P_ENV, /* value from environment variable */
189 P_SYMBOL, /* where a symbol is defined */188 P_SYMBOL, /* where a symbol is defined */
190};189};
191 190
scripts/kconfig/gconf.c+3−2
@@ -101,8 +101,8 @@ const char *dbg_sym_flags(int val) · 100 unmodified lines
101 strcat(buf, "write/");101 strcat(buf, "write/");
102 if (val & SYMBOL_CHANGED)102 if (val & SYMBOL_CHANGED)
103 strcat(buf, "changed/");103 strcat(buf, "changed/");
104 if (val & SYMBOL_AUTO)104 if (val & SYMBOL_NO_WRITE)
105 strcat(buf, "auto/");105 strcat(buf, "no_write/");
106 106
107 buf[strlen(buf) - 1] = '\0';107 buf[strlen(buf) - 1] = '\0';
108 108
@@ -525,6 +525,7 @@ void on_save_activate(GtkMenuItem * menuitem, gpointer user_data) · 416 unmodified lines
525{525{
526 if (conf_write(NULL))526 if (conf_write(NULL))
527 text_insert_msg("Error", "Unable to save configuration !");527 text_insert_msg("Error", "Unable to save configuration !");
528 conf_write_autoconf(0);
528}529}
529 530
530 531
scripts/kconfig/lkc.h+0−2
@@ -97,7 +97,6 @@ void menu_set_type(int type); · 96 unmodified lines
97 97
98/* util.c */98/* util.c */
99struct file *file_lookup(const char *name);99struct file *file_lookup(const char *name);
100int file_write_dep(const char *name);
101void *xmalloc(size_t size);100void *xmalloc(size_t size);
102void *xcalloc(size_t nmemb, size_t size);101void *xcalloc(size_t nmemb, size_t size);
103void *xrealloc(void *p, size_t size);102void *xrealloc(void *p, size_t size);
@@ -126,7 +125,6 @@ const char *sym_get_string_default(struct symbol *sym); · 22 unmodified lines
126struct symbol *sym_check_deps(struct symbol *sym);125struct symbol *sym_check_deps(struct symbol *sym);
127struct property *prop_alloc(enum prop_type type, struct symbol *sym);126struct property *prop_alloc(enum prop_type type, struct symbol *sym);
128struct symbol *prop_get_symbol(struct property *prop);127struct symbol *prop_get_symbol(struct property *prop);
129struct property *sym_get_env_prop(struct symbol *sym);
130 128
131static inline tristate sym_get_tristate_value(struct symbol *sym)129static inline tristate sym_get_tristate_value(struct symbol *sym)
132{130{
scripts/kconfig/lkc_proto.h+2−2
@@ -7,10 +7,10 @@ int conf_read(const char *name); · 6 unmodified lines
7int conf_read_simple(const char *name, int);7int conf_read_simple(const char *name, int);
8int conf_write_defconfig(const char *name);8int conf_write_defconfig(const char *name);
9int conf_write(const char *name);9int conf_write(const char *name);
10int conf_write_autoconf(void);10int conf_write_autoconf(int overwrite);
11bool conf_get_changed(void);11bool conf_get_changed(void);
12void conf_set_changed_callback(void (*fn)(void));12void conf_set_changed_callback(void (*fn)(void));
13void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap));13void conf_set_message_callback(void (*fn)(const char *s));
14 14
15/* menu.c */15/* menu.c */
16extern struct menu rootmenu;16extern struct menu rootmenu;
scripts/kconfig/mconf.c+4−6
@@ -772,16 +772,13 @@ static void show_helptext(const char *title, const char *text) · 771 unmodified lines
772 show_textbox(title, text, 0, 0);772 show_textbox(title, text, 0, 0);
773}773}
774 774
775static void conf_message_callback(const char *fmt, va_list ap)775static void conf_message_callback(const char *s)
776{776{
777 char buf[PATH_MAX+1];
778
779 vsnprintf(buf, sizeof(buf), fmt, ap);
780 if (save_and_exit) {777 if (save_and_exit) {
781 if (!silent)778 if (!silent)
782 printf("%s", buf);779 printf("%s", s);
783 } else {780 } else {
784 show_textbox(NULL, buf, 6, 60);781 show_textbox(NULL, s, 6, 60);
785 }782 }
786}783}
787 784
@@ -977,6 +974,7 @@ static int handle_exit(void) · 189 unmodified lines
977 "\n\n");974 "\n\n");
978 return 1;975 return 1;
979 }976 }
977 conf_write_autoconf(0);
980 /* fall through */978 /* fall through */
981 case -1:979 case -1:
982 if (!silent)980 if (!silent)
scripts/kconfig/menu.c+1−1
@@ -212,7 +212,7 @@ void menu_add_option(int token, char *arg) · 211 unmodified lines
212 sym_defconfig_list = current_entry->sym;212 sym_defconfig_list = current_entry->sym;
213 else if (sym_defconfig_list != current_entry->sym)213 else if (sym_defconfig_list != current_entry->sym)
214 zconf_error("trying to redefine defconfig symbol");214 zconf_error("trying to redefine defconfig symbol");
215 sym_defconfig_list->flags |= SYMBOL_AUTO;215 sym_defconfig_list->flags |= SYMBOL_NO_WRITE;
216 break;216 break;
217 case T_OPT_ALLNOCONFIG_Y:217 case T_OPT_ALLNOCONFIG_Y:
218 current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;218 current_entry->sym->flags |= SYMBOL_ALLNOCONFIG_Y;
scripts/kconfig/nconf.c+3−5
@@ -674,6 +674,7 @@ static int do_exit(void) · 673 unmodified lines
674 "Your configuration changes were NOT saved.",674 "Your configuration changes were NOT saved.",
675 1,675 1,
676 "<OK>");676 "<OK>");
677 conf_write_autoconf(0);
677 break;678 break;
678 default:679 default:
679 btn_dialog(680 btn_dialog(
@@ -1210,12 +1211,9 @@ static void conf(struct menu *menu) · 530 unmodified lines
1210 }1211 }
1211}1212}
1212 1213
1213static void conf_message_callback(const char *fmt, va_list ap)1214static void conf_message_callback(const char *s)
1214{1215{
1215 char buf[1024];1216 btn_dialog(main_window, s, 1, "<OK>");
1216
1217 vsnprintf(buf, sizeof(buf), fmt, ap);
1218 btn_dialog(main_window, buf, 1, "<OK>");
1219}1217}
1220 1218
1221static void show_help(struct menu *menu)1219static void show_help(struct menu *menu)
scripts/kconfig/qconf.cc+2−1
@@ -1149,7 +1149,6 @@ QString ConfigInfoView::debug_info(struct symbol *sym) · 1148 unmodified lines
1149 case P_DEFAULT:1149 case P_DEFAULT:
1150 case P_SELECT:1150 case P_SELECT:
1151 case P_RANGE:1151 case P_RANGE:
1152 case P_ENV:
1153 debug += prop_get_type_name(prop->type);1152 debug += prop_get_type_name(prop->type);
1154 debug += ": ";1153 debug += ": ";
1155 expr_print(prop->expr, expr_print_help, &debug, E_NONE);1154 expr_print(prop->expr, expr_print_help, &debug, E_NONE);
@@ -1535,6 +1534,8 @@ bool ConfigMainWindow::saveConfig(void) · 379 unmodified lines
1535 QMessageBox::information(this, "qconf", "Unable to save configuration!");1534 QMessageBox::information(this, "qconf", "Unable to save configuration!");
1536 return false;1535 return false;
1537 }1536 }
1537 conf_write_autoconf(0);
1538
1538 return true;1539 return true;
1539}1540}
1540 1541
scripts/kconfig/symbol.c+1−12
@@ -76,15 +76,6 @@ struct property *sym_get_choice_prop(struct symbol *sym) · 75 unmodified lines
76 return NULL;76 return NULL;
77}77}
78 78
79struct property *sym_get_env_prop(struct symbol *sym)
80{
81 struct property *prop;
82
83 for_all_properties(sym, prop, P_ENV)
84 return prop;
85 return NULL;
86}
87
88static struct property *sym_get_default_prop(struct symbol *sym)79static struct property *sym_get_default_prop(struct symbol *sym)
89{80{
90 struct property *prop;81 struct property *prop;
@@ -463,7 +454,7 @@ void sym_calc_value(struct symbol *sym) · 372 unmodified lines
463 }454 }
464 }455 }
465 456
466 if (sym->flags & SYMBOL_AUTO)457 if (sym->flags & SYMBOL_NO_WRITE)
467 sym->flags &= ~SYMBOL_WRITE;458 sym->flags &= ~SYMBOL_WRITE;
468 459
469 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)460 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
@@ -1298,8 +1289,6 @@ const char *prop_get_type_name(enum prop_type type) · 828 unmodified lines
1298 switch (type) {1289 switch (type) {
1299 case P_PROMPT:1290 case P_PROMPT:
1300 return "prompt";1291 return "prompt";
1301 case P_ENV:
1302 return "env";
1303 case P_COMMENT:1292 case P_COMMENT:
1304 return "comment";1293 return "comment";
1305 case P_MENU:1294 case P_MENU:
scripts/kconfig/util.c+0−30
@@ -29,36 +29,6 @@ struct file *file_lookup(const char *name) · 28 unmodified lines
29 return file;29 return file;
30}30}
31 31
32/* write a dependency file as used by kbuild to track dependencies */
33int file_write_dep(const char *name)
34{
35 struct file *file;
36 FILE *out;
37
38 if (!name)
39 name = ".kconfig.d";
40 out = fopen("..config.tmp", "w");
41 if (!out)
42 return 1;
43 fprintf(out, "deps_config := \\\n");
44 for (file = file_list; file; file = file->next) {
45 if (file->next)
46 fprintf(out, "\t%s \\\n", file->name);
47 else
48 fprintf(out, "\t%s\n", file->name);
49 }
50 fprintf(out, "\n%s: \\\n"
51 "\t$(deps_config)\n\n", conf_get_autoconfig_name());
52
53 env_write_dep(out, conf_get_autoconfig_name());
54
55 fprintf(out, "\n$(deps_config): ;\n");
56 fclose(out);
57 rename("..config.tmp", name);
58 return 0;
59}
60
61
62/* Allocate initial growable string */32/* Allocate initial growable string */
63struct gstr str_new(void)33struct gstr str_new(void)
64{34{
scripts/kconfig/zconf.y+3−3
@@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE]; · 30 unmodified lines
31static struct menu *current_menu, *current_entry;31static struct menu *current_menu, *current_entry;
32 32
33%}33%}
34%expect 3134%expect 30
35 35
36%union36%union
37{37{
@@ -117,7 +117,7 @@ start: mainmenu_stmt stmt_list | stmt_list; · 79 unmodified lines
117 117
118/* mainmenu entry */118/* mainmenu entry */
119 119
120mainmenu_stmt: T_MAINMENU prompt nl120mainmenu_stmt: T_MAINMENU prompt T_EOL
121{121{
122 menu_add_prompt(P_MENU, $2, NULL);122 menu_add_prompt(P_MENU, $2, NULL);
123};123};
@@ -265,7 +265,7 @@ symbol_option_arg: · 141 unmodified lines
265choice: T_CHOICE word_opt T_EOL265choice: T_CHOICE word_opt T_EOL
266{266{
267 struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE);267 struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE);
268 sym->flags |= SYMBOL_AUTO;268 sym->flags |= SYMBOL_NO_WRITE;
269 menu_add_entry(sym);269 menu_add_entry(sym);
270 menu_add_expr(P_CHOICE, NULL, NULL);270 menu_add_expr(P_CHOICE, NULL, NULL);
271 free($2);271 free($2);