aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-08-15 15:50:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-15 15:50:10 -0400
commit01f0e5cdedea448ea48eaddc1366593126b0fe98 (patch)
tree463c89311ac3b52aeb258324723e92d89ec1672f /scripts
parente026bcc561071c9895c73058b9cc6823defb7be6 (diff)
parent1880861226c13ddd42c34ddd30c3b502b650fe29 (diff)
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
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include3
-rw-r--r--scripts/Makefile.modbuiltin4
-rw-r--r--scripts/kconfig/Makefile17
-rw-r--r--scripts/kconfig/check-pkgconfig.sh8
-rw-r--r--scripts/kconfig/conf.c39
-rw-r--r--scripts/kconfig/confdata.c156
-rw-r--r--scripts/kconfig/expr.h3
-rw-r--r--scripts/kconfig/gconf.c5
-rw-r--r--scripts/kconfig/lkc.h2
-rw-r--r--scripts/kconfig/lkc_proto.h4
-rw-r--r--scripts/kconfig/mconf.c10
-rw-r--r--scripts/kconfig/menu.c2
-rw-r--r--scripts/kconfig/nconf.c8
-rw-r--r--scripts/kconfig/qconf.cc3
-rw-r--r--scripts/kconfig/symbol.c13
-rw-r--r--scripts/kconfig/util.c30
-rw-r--r--scripts/kconfig/zconf.y6
17 files changed, 189 insertions, 124 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 1d0665e83bf9..7c98f60e2266 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -400,3 +400,6 @@ endif
400endef 400endef
401# 401#
402############################################################################### 402###############################################################################
403
404# delete partially updated (i.e. corrupted) files on error
405.DELETE_ON_ERROR:
diff --git a/scripts/Makefile.modbuiltin b/scripts/Makefile.modbuiltin
index 40867a41615b..a072a4267746 100644
--- a/scripts/Makefile.modbuiltin
+++ b/scripts/Makefile.modbuiltin
@@ -8,10 +8,10 @@ src := $(obj)
8PHONY := __modbuiltin 8PHONY := __modbuiltin
9__modbuiltin: 9__modbuiltin:
10 10
11-include include/config/auto.conf 11include 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-Y 13# That way, we get the list of built-in modules in obj-Y
14-include include/config/tristate.conf 14include include/config/tristate.conf
15 15
16include scripts/Kbuild.include 16include scripts/Kbuild.include
17 17
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index f3c0e6261e2a..8d8791069abf 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -3,8 +3,7 @@
3# Kernel configuration targets 3# Kernel configuration targets
4# These targets are used from top-level makefile 4# 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_KCONFIG 8ifdef KBUILD_KCONFIG
10Kconfig := $(KBUILD_KCONFIG) 9Kconfig := $(KBUILD_KCONFIG)
@@ -34,14 +33,7 @@ config: $(obj)/conf
34nconfig: $(obj)/nconf 33nconfig: $(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)/conf 36localyesconfig localmodconfig: $(obj)/conf
44 $(Q)mkdir -p include/config include/generated
45 $(Q)perl $(srctree)/$(src)/streamline_config.pl --$@ $(srctree) $(Kconfig) > .tmp.config 37 $(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
56 $(Q)rm -f .tmp.config 48 $(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 olddefconfig 56 alldefconfig randconfig listnewconfig olddefconfig syncconfig
61PHONY += $(simple-targets) 57PHONY += $(simple-targets)
62 58
63$(simple-targets): $(obj)/conf 59$(simple-targets): $(obj)/conf
@@ -215,6 +211,7 @@ $(obj)/zconf.tab.o: $(obj)/zconf.lex.c
215 211
216# check if necessary packages are available, and configure build flags 212# check if necessary packages are available, and configure build flags
217define filechk_conf_cfg 213define filechk_conf_cfg
214 $(CONFIG_SHELL) $(srctree)/scripts/kconfig/check-pkgconfig.sh; \
218 $(CONFIG_SHELL) $< 215 $(CONFIG_SHELL) $<
219endef 216endef
220 217
diff --git a/scripts/kconfig/check-pkgconfig.sh b/scripts/kconfig/check-pkgconfig.sh
new file mode 100644
index 000000000000..7a1c40bfb58c
--- /dev/null
+++ b/scripts/kconfig/check-pkgconfig.sh
@@ -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
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 671ff5364497..b35cc9303979 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -496,6 +496,7 @@ int main(int ac, char **av)
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)
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)
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}
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 39e20974f4a3..91d0a5c014ac 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -16,6 +16,64 @@
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, ...)
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))
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)
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)
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)
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)
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:
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)
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:
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)
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.conf 1092 * 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;
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index f63b41b0dd49..7c329e179007 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -141,7 +141,7 @@ struct symbol {
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 {
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
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 610c4ab54d76..36f578415c4a 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -101,8 +101,8 @@ const char *dbg_sym_flags(int val)
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)
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
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index ed3ff88e60ba..9eb7c837cd8f 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -97,7 +97,6 @@ void menu_set_type(int type);
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);
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{
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index a8b7a330587e..86c267540ccc 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -7,10 +7,10 @@ int conf_read(const char *name);
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;
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 5294ed159b98..83b5836615fb 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -772,16 +772,13 @@ static void show_helptext(const char *title, const char *text)
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)
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)
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 379a119dcd1e..4cf15d449c05 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -212,7 +212,7 @@ void menu_add_option(int token, char *arg)
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;
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index 97b78445584b..1ef232ae5ab9 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -674,6 +674,7 @@ static int do_exit(void)
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)
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)
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index ad9c22dd04f5..ef4310f2558b 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1149,7 +1149,6 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
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)
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
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 7c9a88e91cfa..4ec8b1f0d42c 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -76,15 +76,6 @@ struct property *sym_get_choice_prop(struct symbol *sym)
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)
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)
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:
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index a365594770d9..d999683bb2a7 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -29,36 +29,6 @@ struct file *file_lookup(const char *name)
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{
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 4b68272ebdb9..22fceb264cf5 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -31,7 +31,7 @@ struct symbol *symbol_hash[SYMBOL_HASHSIZE];
31static struct menu *current_menu, *current_entry; 31static struct menu *current_menu, *current_entry;
32 32
33%} 33%}
34%expect 31 34%expect 30
35 35
36%union 36%union
37{ 37{
@@ -117,7 +117,7 @@ start: mainmenu_stmt stmt_list | stmt_list;
117 117
118/* mainmenu entry */ 118/* mainmenu entry */
119 119
120mainmenu_stmt: T_MAINMENU prompt nl 120mainmenu_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:
265choice: T_CHOICE word_opt T_EOL 265choice: 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);