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
370370
371371 This defines a choice group and accepts any of the above attributes as
372372 options. A choice can only be of type bool or tristate. If no type is
373−specified for a choice, it's type will be determined by the type of
373+specified for a choice, its type will be determined by the type of
374374 the first choice element in the group or remain unknown if none of the
375375 choice elements have a type specified, as well.
376376
@@ -384,7 +384,7 @@ A choice accepts another option "optional", which allows to set the · 7 unmodified lines
384384 choice to 'n' and no entry needs to be selected.
385385 If no [symbol] is associated with a choice, then you can not have multiple
386386 definitions of that choice. If a [symbol] is associated to the choice,
387−then you may define the same choice (ie. with the same entries) in another
387+then you may define the same choice (i.e. with the same entries) in another
388388 place.
389389
390390 comment:
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
8181 rather than incremental linking (`ld -r`) for built-in.a intermediate steps.
8282 This requires binutils 2.20 or newer.
8383
84+pkg-config
85+----------
86+
87+The build system, as of 4.18, requires pkg-config to check for installed
88+kconfig tools and to determine flags settings for use in
89+'make {menu,n,g,x}config'. Previously pkg-config was being used but not
90+verified or documented.
91+
8492 Flex
8593 ----
8694
Makefile+26−18
@@ -225,10 +225,13 @@ no-dot-config-targets := $(clean-targets) \ · 224 unmodified lines
225225 cscope gtags TAGS tags help% %docs check% coccicheck \
226226 $(version_h) headers_% archheaders archscripts \
227227 %asm-generic kernelversion %src-pkg
228+no-sync-config-targets := $(no-dot-config-targets) install %install \
229+ kernelrelease
228230
229−config-targets := 0
230−mixed-targets := 0
231−dot-config := 1
231+config-targets := 0
232+mixed-targets := 0
233+dot-config := 1
234+may-sync-config := 1
232235
233236 ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),)
234237 ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),)
@@ -236,6 +239,16 @@ ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) · 1 unmodified line
236239 endif
237240 endif
238241
242+ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),)
243+ ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),)
244+ may-sync-config := 0
245+ endif
246+endif
247+
248+ifneq ($(KBUILD_EXTMOD),)
249+ may-sync-config := 0
250+endif
251+
239252 ifeq ($(KBUILD_EXTMOD),)
240253 ifneq ($(filter config %config,$(MAKECMDGOALS)),)
241254 config-targets := 1
@@ -585,7 +598,7 @@ virt-y := virt/ · 343 unmodified lines
585598 endif # KBUILD_EXTMOD
586599
587600 ifeq ($(dot-config),1)
588−-include include/config/auto.conf
601+include include/config/auto.conf
589602 endif
590603
591604 # The all: target is the default when no target is given on the
@@ -607,7 +620,7 @@ ARCH_CFLAGS := · 15 unmodified lines
607620 include arch/$(SRCARCH)/Makefile
608621
609622 ifeq ($(dot-config),1)
610−ifeq ($(KBUILD_EXTMOD),)
623+ifeq ($(may-sync-config),1)
611624 # Read in dependencies to all Kconfig* files, make sure to run syncconfig if
612625 # changes are detected. This should be included after arch/$(SRCARCH)/Makefile
613626 # because some architectures define CROSS_COMPILE there.
@@ -622,8 +635,9 @@ $(KCONFIG_CONFIG) include/config/auto.conf.cmd: ; · 8 unmodified lines
622635 include/config/%.conf: $(KCONFIG_CONFIG) include/config/auto.conf.cmd
623636 $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig
624637 else
625−# external modules needs include/generated/autoconf.h and include/config/auto.conf
626−# but do not care if they are up-to-date. Use auto.conf to trigger the test
638+# External modules and some install targets need include/generated/autoconf.h
639+# and include/config/auto.conf but do not care if they are up-to-date.
640+# Use auto.conf to trigger the test
627641 PHONY += include/config/auto.conf
628642
629643 include/config/auto.conf:
@@ -635,11 +649,7 @@ include/config/auto.conf: · 5 unmodified lines
635649 echo >&2 ; \
636650 /bin/false)
637651
638−endif # KBUILD_EXTMOD
639−
640−else
641−# Dummy target needed, because used as prerequisite
642−include/config/auto.conf: ;
652+endif # may-sync-config
643653 endif # $(dot-config)
644654
645655 KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,)
@@ -1035,15 +1045,14 @@ define filechk_kernel.release · 389 unmodified lines
10351045 endef
10361046
10371047 # Store (new) KERNELRELEASE string in include/config/kernel.release
1038−include/config/kernel.release: include/config/auto.conf FORCE
1048+include/config/kernel.release: $(srctree)/Makefile FORCE
10391049 $(call filechk,kernel.release)
10401050
10411051 # Additional helpers built in scripts/
10421052 # Carefully list dependencies so we do not try to build scripts twice
10431053 # in parallel
10441054 PHONY += scripts
1045−scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \
1046− asm-generic gcc-plugins $(autoksyms_h)
1055+scripts: scripts_basic asm-generic gcc-plugins $(autoksyms_h)
10471056 $(Q)$(MAKE) $(build)=$(@)
10481057
10491058 # Things we need to do before we recursively start building the kernel
@@ -1073,8 +1082,7 @@ endif · 23 unmodified lines
10731082 # that need to depend on updated CONFIG_* values can be checked here.
10741083 prepare2: prepare3 outputmakefile asm-generic
10751084
1076−prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
1077− include/config/auto.conf
1085+prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h
10781086 $(cmd_crmodverdir)
10791087
10801088 archprepare: archheaders archscripts prepare1 scripts_basic
@@ -1212,7 +1220,7 @@ modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin · 131 unmodified lines
12121220 modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
12131221 $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin
12141222
1215−%/modules.builtin: include/config/auto.conf
1223+%/modules.builtin: include/config/auto.conf include/config/tristate.conf
12161224 $(Q)$(MAKE) $(modbuiltin)=$*
12171225
12181226
init/Kconfig+2−2
@@ -2,9 +2,9 @@ config DEFCONFIG_LIST · 1 unmodified line
22 string
33 depends on !UML
44 option defconfig_list
5− default "/lib/modules/$(shell,uname --release)/.config"
5+ default "/lib/modules/$(shell,uname -r)/.config"
66 default "/etc/kernel-config"
7− default "/boot/config-$(shell,uname --release)"
7+ default "/boot/config-$(shell,uname -r)"
88 default ARCH_DEFCONFIG
99 default "arch/$(ARCH)/defconfig"
1010
scripts/Kbuild.include+3−0
@@ -400,3 +400,6 @@ endif · 399 unmodified lines
400400 endef
401401 #
402402 ###############################################################################
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
88 PHONY := __modbuiltin
99 __modbuiltin:
1010
11−-include include/config/auto.conf
11+include include/config/auto.conf
1212 # tristate.conf sets tristate variables to uppercase 'Y' or 'M'
1313 # That way, we get the list of built-in modules in obj-Y
14−-include include/config/tristate.conf
14+include include/config/tristate.conf
1515
1616 include scripts/Kbuild.include
1717
scripts/kconfig/Makefile+7−10
@@ -3,8 +3,7 @@ · 2 unmodified lines
33 # Kernel configuration targets
44 # These targets are used from top-level makefile
55
6−PHONY += xconfig gconfig menuconfig config syncconfig \
7− localmodconfig localyesconfig
6+PHONY += xconfig gconfig menuconfig config localmodconfig localyesconfig
87
98 ifdef KBUILD_KCONFIG
109 Kconfig := $(KBUILD_KCONFIG)
@@ -34,14 +33,7 @@ config: $(obj)/conf · 23 unmodified lines
3433 nconfig: $(obj)/nconf
3534 $< $(silent) $(Kconfig)
3635
37−# This has become an internal implementation detail and is now deprecated
38−# for external use.
39−syncconfig: $(obj)/conf
40− $(Q)mkdir -p include/config include/generated
41− $< $(silent) --$@ $(Kconfig)
42−
4336 localyesconfig localmodconfig: $(obj)/conf
44− $(Q)mkdir -p include/config include/generated
4537 $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config
4638 $(Q)if [ -f .config ]; then \
4739 cmp -s .tmp.config .config || \
@@ -56,8 +48,12 @@ localyesconfig localmodconfig: $(obj)/conf · 8 unmodified lines
5648 $(Q)rm -f .tmp.config
5749
5850 # 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
5955 simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \
60− alldefconfig randconfig listnewconfig olddefconfig
56+ alldefconfig randconfig listnewconfig olddefconfig syncconfig
6157 PHONY += $(simple-targets)
6258
6359 $(simple-targets): $(obj)/conf
@@ -215,6 +211,7 @@ $(obj)/zconf.tab.o: $(obj)/zconf.lex.c · 151 unmodified lines
215211
216212 # check if necessary packages are available, and configure build flags
217213 define filechk_conf_cfg
214+ $(CONFIG_SHELL) $(srctree)/scripts/kconfig/check-pkgconfig.sh; \
218215 $(CONFIG_SHELL) $<
219216 endef
220217
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+
5+if [ -z $(command -v pkg-config) ]; then
6+ echo "'make *config' requires 'pkg-config'. Please install it." 1>&2
7+ exit 1
8+fi
scripts/kconfig/conf.c+22−17
@@ -496,6 +496,7 @@ int main(int ac, char **av) · 495 unmodified lines
496496 int opt;
497497 const char *name, *defconfig_file = NULL /* gcc uninit */;
498498 struct stat tmpstat;
499+ int no_conf_write = 0;
499500
500501 tty_stdio = isatty(0) && isatty(1);
501502
@@ -633,13 +634,14 @@ int main(int ac, char **av) · 131 unmodified lines
633634 }
634635
635636 if (sync_kconfig) {
636− if (conf_get_changed()) {
637− name = getenv("KCONFIG_NOSILENTUPDATE");
638− if (name && *name) {
637+ name = getenv("KCONFIG_NOSILENTUPDATE");
638+ if (name && *name) {
639+ if (conf_get_changed()) {
639640 fprintf(stderr,
640641 "\n*** The configuration requires explicit update.\n\n");
641642 return 1;
642643 }
644+ no_conf_write = 1;
643645 }
644646 }
645647
@@ -684,29 +686,32 @@ int main(int ac, char **av) · 38 unmodified lines
684686 break;
685687 }
686688
687− if (sync_kconfig) {
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) {
689+ if (input_mode == savedefconfig) {
700690 if (conf_write_defconfig(defconfig_file)) {
701691 fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n",
702692 defconfig_file);
703693 return 1;
704694 }
705695 } else if (input_mode != listnewconfig) {
706− if (conf_write(NULL)) {
696+ if (!no_conf_write && conf_write(NULL)) {
707697 fprintf(stderr, "\n*** Error during writing of the configuration.\n\n");
708698 exit(1);
709699 }
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+ }
710715 }
711716 return 0;
712717 }
scripts/kconfig/confdata.c+127−29
@@ -16,6 +16,64 @@ · 15 unmodified lines
1616
1717 #include "lkc.h"
1818
19+/* return true if 'path' exists, false otherwise */
20+static 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 */
28+static 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+ */
43+static 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+
1977 struct conf_printer {
2078 void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
2179 void (*print_comment)(FILE *, const char *, void *);
@@ -43,16 +101,16 @@ static void conf_warning(const char *fmt, ...) · 21 unmodified lines
43101 conf_warnings++;
44102 }
45103
46−static void conf_default_message_callback(const char *fmt, va_list ap)
104+static void conf_default_message_callback(const char *s)
47105 {
48106 printf("#\n# ");
49− vprintf(fmt, ap);
107+ printf("%s", s);
50108 printf("\n#\n");
51109 }
52110
53−static void (*conf_message_callback) (const char *fmt, va_list ap) =
111+static void (*conf_message_callback)(const char *s) =
54112 conf_default_message_callback;
55−void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap))
113+void conf_set_message_callback(void (*fn)(const char *s))
56114 {
57115 conf_message_callback = fn;
58116 }
@@ -60,10 +118,15 @@ void conf_set_message_callback(void (*fn) (const char *fmt, va_list ap)) · 1 unmodified line
60118 static void conf_message(const char *fmt, ...)
61119 {
62120 va_list ap;
121+ char buf[4096];
122+
123+ if (!conf_message_callback)
124+ return;
63125
64126 va_start(ap, fmt);
65− if (conf_message_callback)
66− conf_message_callback(fmt, ap);
127+
128+ vsnprintf(buf, sizeof(buf), fmt, ap);
129+ conf_message_callback(buf);
67130 va_end(ap);
68131 }
69132
@@ -83,7 +146,6 @@ const char *conf_get_autoconfig_name(void) · 13 unmodified lines
83146
84147 char *conf_get_default_confname(void)
85148 {
86− struct stat buf;
87149 static char fullname[PATH_MAX+1];
88150 char *env, *name;
89151
@@ -91,7 +153,7 @@ char *conf_get_default_confname(void) · 1 unmodified line
91153 env = getenv(SRCTREE);
92154 if (env) {
93155 sprintf(fullname, "%s/%s", env, name);
94− if (!stat(fullname, &buf))
156+ if (is_present(fullname))
95157 return fullname;
96158 }
97159 return name;
@@ -397,7 +459,7 @@ int conf_read(const char *name) · 299 unmodified lines
397459
398460 for_all_symbols(i, sym) {
399461 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))
401463 continue;
402464 if (sym_has_value(sym) && (sym->flags & SYMBOL_WRITE)) {
403465 /* check that calculated value agrees with saved value */
@@ -725,10 +787,9 @@ int conf_write(const char *name) · 321 unmodified lines
725787
726788 dirname[0] = 0;
727789 if (name && name[0]) {
728− struct stat st;
729790 char *slash;
730791
731− if (!stat(name, &st) && S_ISDIR(st.st_mode)) {
792+ if (is_dir(name)) {
732793 strcpy(dirname, name);
733794 strcat(dirname, "/");
734795 basename = conf_get_configname();
@@ -813,26 +874,59 @@ next: · 78 unmodified lines
813874 return 0;
814875 }
815876
877+/* write a dependency file as used by kbuild to track dependencies */
878+static 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+
816909 static int conf_split_config(void)
817910 {
818911 const char *name;
819912 char path[PATH_MAX+1];
820913 char *s, *d, c;
821914 struct symbol *sym;
822− struct stat sb;
823915 int res, i, fd;
824916
825917 name = conf_get_autoconfig_name();
826918 conf_read_simple(name, S_DEF_AUTO);
827919 sym_calc_value(modules_sym);
828920
921+ if (make_parent_dir("include/config/foo.h"))
922+ return 1;
829923 if (chdir("include/config"))
830924 return 1;
831925
832926 res = 0;
833927 for_all_symbols(i, sym) {
834928 sym_calc_value(sym);
835− if ((sym->flags & SYMBOL_AUTO) || !sym->name)
929+ if ((sym->flags & SYMBOL_NO_WRITE) || !sym->name)
836930 continue;
837931 if (sym->flags & SYMBOL_WRITE) {
838932 if (sym->flags & SYMBOL_DEF_AUTO) {
@@ -897,19 +991,12 @@ static int conf_split_config(void) · 58 unmodified lines
897991 res = 1;
898992 break;
899993 }
900− /*
901− * Create directory components,
902− * unless they exist already.
903− */
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++ = '/';
994+
995+ if (make_parent_dir(path)) {
996+ res = 1;
997+ goto out;
912998 }
999+
9131000 /* Try it again. */
9141001 fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
9151002 if (fd == -1) {
@@ -926,16 +1013,20 @@ out: · 10 unmodified lines
9261013 return res;
9271014 }
9281015
929−int conf_write_autoconf(void)
1016+int conf_write_autoconf(int overwrite)
9301017 {
9311018 struct symbol *sym;
9321019 const char *name;
1020+ const char *autoconf_name = conf_get_autoconfig_name();
9331021 FILE *out, *tristate, *out_h;
9341022 int i;
9351023
1024+ if (!overwrite && is_present(autoconf_name))
1025+ return 0;
1026+
9361027 sym_clear_all_valid();
9371028
938− file_write_dep("include/config/auto.conf.cmd");
1029+ conf_write_dep("include/config/auto.conf.cmd");
9391030
9401031 if (conf_split_config())
9411032 return 1;
@@ -982,19 +1073,26 @@ int conf_write_autoconf(void) · 40 unmodified lines
9821073 name = getenv("KCONFIG_AUTOHEADER");
9831074 if (!name)
9841075 name = "include/generated/autoconf.h";
1076+ if (make_parent_dir(name))
1077+ return 1;
9851078 if (rename(".tmpconfig.h", name))
9861079 return 1;
1080+
9871081 name = getenv("KCONFIG_TRISTATE");
9881082 if (!name)
9891083 name = "include/config/tristate.conf";
1084+ if (make_parent_dir(name))
1085+ return 1;
9901086 if (rename(".tmpconfig_tristate", name))
9911087 return 1;
992− name = conf_get_autoconfig_name();
1088+
1089+ if (make_parent_dir(autoconf_name))
1090+ return 1;
9931091 /*
9941092 * This must be the last step, kbuild has a dependency on auto.conf
9951093 * and this marks the successful completion of the previous steps.
9961094 */
997− if (rename(".tmpconfig", name))
1095+ if (rename(".tmpconfig", autoconf_name))
9981096 return 1;
9991097
10001098 return 0;
scripts/kconfig/expr.h+1−2
@@ -141,7 +141,7 @@ struct symbol { · 140 unmodified lines
141141 #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */
142142 #define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */
143143 #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 */
145145 #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */
146146 #define SYMBOL_WARNED 0x8000 /* warning has been issued */
147147
@@ -185,7 +185,6 @@ enum prop_type { · 37 unmodified lines
185185 P_SELECT, /* select BAR */
186186 P_IMPLY, /* imply BAR */
187187 P_RANGE, /* range 7..100 (for a symbol) */
188− P_ENV, /* value from environment variable */
189188 P_SYMBOL, /* where a symbol is defined */
190189 };
191190
scripts/kconfig/gconf.c+3−2
@@ -101,8 +101,8 @@ const char *dbg_sym_flags(int val) · 100 unmodified lines
101101 strcat(buf, "write/");
102102 if (val & SYMBOL_CHANGED)
103103 strcat(buf, "changed/");
104− if (val & SYMBOL_AUTO)
105− strcat(buf, "auto/");
104+ if (val & SYMBOL_NO_WRITE)
105+ strcat(buf, "no_write/");
106106
107107 buf[strlen(buf) - 1] = '\0';
108108
@@ -525,6 +525,7 @@ void on_save_activate(GtkMenuItem * menuitem, gpointer user_data) · 416 unmodified lines
525525 {
526526 if (conf_write(NULL))
527527 text_insert_msg("Error", "Unable to save configuration !");
528+ conf_write_autoconf(0);
528529 }
529530
530531
scripts/kconfig/lkc.h+0−2
@@ -97,7 +97,6 @@ void menu_set_type(int type); · 96 unmodified lines
9797
9898 /* util.c */
9999 struct file *file_lookup(const char *name);
100−int file_write_dep(const char *name);
101100 void *xmalloc(size_t size);
102101 void *xcalloc(size_t nmemb, size_t size);
103102 void *xrealloc(void *p, size_t size);
@@ -126,7 +125,6 @@ const char *sym_get_string_default(struct symbol *sym); · 22 unmodified lines
126125 struct symbol *sym_check_deps(struct symbol *sym);
127126 struct property *prop_alloc(enum prop_type type, struct symbol *sym);
128127 struct symbol *prop_get_symbol(struct property *prop);
129−struct property *sym_get_env_prop(struct symbol *sym);
130128
131129 static inline tristate sym_get_tristate_value(struct symbol *sym)
132130 {
scripts/kconfig/lkc_proto.h+2−2
@@ -7,10 +7,10 @@ int conf_read(const char *name); · 6 unmodified lines
77 int conf_read_simple(const char *name, int);
88 int conf_write_defconfig(const char *name);
99 int conf_write(const char *name);
10−int conf_write_autoconf(void);
10+int conf_write_autoconf(int overwrite);
1111 bool conf_get_changed(void);
1212 void conf_set_changed_callback(void (*fn)(void));
13−void conf_set_message_callback(void (*fn)(const char *fmt, va_list ap));
13+void conf_set_message_callback(void (*fn)(const char *s));
1414
1515 /* menu.c */
1616 extern 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
772772 show_textbox(title, text, 0, 0);
773773 }
774774
775−static void conf_message_callback(const char *fmt, va_list ap)
775+static void conf_message_callback(const char *s)
776776 {
777− char buf[PATH_MAX+1];
778−
779− vsnprintf(buf, sizeof(buf), fmt, ap);
780777 if (save_and_exit) {
781778 if (!silent)
782− printf("%s", buf);
779+ printf("%s", s);
783780 } else {
784− show_textbox(NULL, buf, 6, 60);
781+ show_textbox(NULL, s, 6, 60);
785782 }
786783 }
787784
@@ -977,6 +974,7 @@ static int handle_exit(void) · 189 unmodified lines
977974 "\n\n");
978975 return 1;
979976 }
977+ conf_write_autoconf(0);
980978 /* fall through */
981979 case -1:
982980 if (!silent)
scripts/kconfig/menu.c+1−1
@@ -212,7 +212,7 @@ void menu_add_option(int token, char *arg) · 211 unmodified lines
212212 sym_defconfig_list = current_entry->sym;
213213 else if (sym_defconfig_list != current_entry->sym)
214214 zconf_error("trying to redefine defconfig symbol");
215− sym_defconfig_list->flags |= SYMBOL_AUTO;
215+ sym_defconfig_list->flags |= SYMBOL_NO_WRITE;
216216 break;
217217 case T_OPT_ALLNOCONFIG_Y:
218218 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
674674 "Your configuration changes were NOT saved.",
675675 1,
676676 "<OK>");
677+ conf_write_autoconf(0);
677678 break;
678679 default:
679680 btn_dialog(
@@ -1210,12 +1211,9 @@ static void conf(struct menu *menu) · 530 unmodified lines
12101211 }
12111212 }
12121213
1213−static void conf_message_callback(const char *fmt, va_list ap)
1214+static void conf_message_callback(const char *s)
12141215 {
1215− char buf[1024];
1216−
1217− vsnprintf(buf, sizeof(buf), fmt, ap);
1218− btn_dialog(main_window, buf, 1, "<OK>");
1216+ btn_dialog(main_window, s, 1, "<OK>");
12191217 }
12201218
12211219 static 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
11491149 case P_DEFAULT:
11501150 case P_SELECT:
11511151 case P_RANGE:
1152− case P_ENV:
11531152 debug += prop_get_type_name(prop->type);
11541153 debug += ": ";
11551154 expr_print(prop->expr, expr_print_help, &debug, E_NONE);
@@ -1535,6 +1534,8 @@ bool ConfigMainWindow::saveConfig(void) · 379 unmodified lines
15351534 QMessageBox::information(this, "qconf", "Unable to save configuration!");
15361535 return false;
15371536 }
1537+ conf_write_autoconf(0);
1538+
15381539 return true;
15391540 }
15401541
scripts/kconfig/symbol.c+1−12
@@ -76,15 +76,6 @@ struct property *sym_get_choice_prop(struct symbol *sym) · 75 unmodified lines
7676 return NULL;
7777 }
7878
79−struct 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−
8879 static struct property *sym_get_default_prop(struct symbol *sym)
8980 {
9081 struct property *prop;
@@ -463,7 +454,7 @@ void sym_calc_value(struct symbol *sym) · 372 unmodified lines
463454 }
464455 }
465456
466− if (sym->flags & SYMBOL_AUTO)
457+ if (sym->flags & SYMBOL_NO_WRITE)
467458 sym->flags &= ~SYMBOL_WRITE;
468459
469460 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
12981289 switch (type) {
12991290 case P_PROMPT:
13001291 return "prompt";
1301− case P_ENV:
1302− return "env";
13031292 case P_COMMENT:
13041293 return "comment";
13051294 case P_MENU:
scripts/kconfig/util.c+0−30
@@ -29,36 +29,6 @@ struct file *file_lookup(const char *name) · 28 unmodified lines
2929 return file;
3030 }
3131
32−/* write a dependency file as used by kbuild to track dependencies */
33−int 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−
6232 /* Allocate initial growable string */
6333 struct gstr str_new(void)
6434 {
scripts/kconfig/zconf.y+3−3
@@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE]; · 30 unmodified lines
3131 static struct menu *current_menu, *current_entry;
3232
3333 %}
34−%expect 31
34+%expect 30
3535
3636 %union
3737 {
@@ -117,7 +117,7 @@ start: mainmenu_stmt stmt_list | stmt_list; · 79 unmodified lines
117117
118118 /* mainmenu entry */
119119
120−mainmenu_stmt: T_MAINMENU prompt nl
120+mainmenu_stmt: T_MAINMENU prompt T_EOL
121121 {
122122 menu_add_prompt(P_MENU, $2, NULL);
123123 };
@@ -265,7 +265,7 @@ symbol_option_arg: · 141 unmodified lines
265265 choice: T_CHOICE word_opt T_EOL
266266 {
267267 struct symbol *sym = sym_lookup($2, SYMBOL_CHOICE);
268− sym->flags |= SYMBOL_AUTO;
268+ sym->flags |= SYMBOL_NO_WRITE;
269269 menu_add_entry(sym);
270270 menu_add_expr(P_CHOICE, NULL, NULL);
271271 free($2);