aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile11
-rw-r--r--arch/arm/Makefile2
-rw-r--r--arch/sh/Makefile4
-rw-r--r--arch/xtensa/Makefile2
-rw-r--r--scripts/basic/Makefile6
-rw-r--r--scripts/basic/split-include.c226
-rw-r--r--scripts/kconfig/confdata.c121
-rw-r--r--scripts/kconfig/expr.h3
8 files changed, 129 insertions, 246 deletions
diff --git a/Makefile b/Makefile
index b1610562a65f..4b996c8fb70a 100644
--- a/Makefile
+++ b/Makefile
@@ -418,7 +418,7 @@ ifeq ($(KBUILD_EXTMOD),)
418# Carefully list dependencies so we do not try to build scripts twice 418# Carefully list dependencies so we do not try to build scripts twice
419# in parrallel 419# in parrallel
420PHONY += scripts 420PHONY += scripts
421scripts: scripts_basic include/config/MARKER 421scripts: scripts_basic include/config/auto.conf
422 $(Q)$(MAKE) $(build)=$(@) 422 $(Q)$(MAKE) $(build)=$(@)
423 423
424# Objects we will link into vmlinux / subdirs we need to visit 424# Objects we will link into vmlinux / subdirs we need to visit
@@ -787,7 +787,7 @@ endif
787prepare2: prepare3 outputmakefile 787prepare2: prepare3 outputmakefile
788 788
789prepare1: prepare2 include/linux/version.h include/asm \ 789prepare1: prepare2 include/linux/version.h include/asm \
790 include/config/MARKER 790 include/config/auto.conf
791ifneq ($(KBUILD_MODULES),) 791ifneq ($(KBUILD_MODULES),)
792 $(Q)mkdir -p $(MODVERDIR) 792 $(Q)mkdir -p $(MODVERDIR)
793 $(Q)rm -f $(MODVERDIR)/* 793 $(Q)rm -f $(MODVERDIR)/*
@@ -815,13 +815,6 @@ include/asm:
815 $(Q)if [ ! -d include ]; then mkdir -p include; fi; 815 $(Q)if [ ! -d include ]; then mkdir -p include; fi;
816 @ln -fsn asm-$(ARCH) $@ 816 @ln -fsn asm-$(ARCH) $@
817 817
818# Split autoconf.h into include/linux/config/*
819
820include/config/MARKER: scripts/basic/split-include include/config/auto.conf
821 @echo ' SPLIT include/linux/autoconf.h -> include/config/*'
822 @scripts/basic/split-include include/linux/autoconf.h include/config
823 @touch $@
824
825# Generate some files 818# Generate some files
826# --------------------------------------------------------------------------- 819# ---------------------------------------------------------------------------
827 820
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 6f8e84c1c1f2..9791d870ae71 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -175,7 +175,7 @@ boot := arch/arm/boot
175# them changed. We use .arch to indicate when they were updated 175# them changed. We use .arch to indicate when they were updated
176# last, otherwise make uses the target directory mtime. 176# last, otherwise make uses the target directory mtime.
177 177
178include/asm-arm/.arch: $(wildcard include/config/arch/*.h) include/config/MARKER 178include/asm-arm/.arch: $(wildcard include/config/arch/*.h) include/config/auto.conf
179 @echo ' SYMLINK include/asm-arm/arch -> include/asm-arm/$(INCDIR)' 179 @echo ' SYMLINK include/asm-arm/arch -> include/asm-arm/$(INCDIR)'
180ifneq ($(KBUILD_SRC),) 180ifneq ($(KBUILD_SRC),)
181 $(Q)mkdir -p include/asm-arm 181 $(Q)mkdir -p include/asm-arm
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index c72e17a96eed..e467a450662b 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -147,7 +147,7 @@ endif
147# them changed. We use .arch and .mach to indicate when they were 147# them changed. We use .arch and .mach to indicate when they were
148# updated last, otherwise make uses the target directory mtime. 148# updated last, otherwise make uses the target directory mtime.
149 149
150include/asm-sh/.cpu: $(wildcard include/config/cpu/*.h) include/config/MARKER 150include/asm-sh/.cpu: $(wildcard include/config/cpu/*.h) include/config/auto.conf
151 @echo ' SYMLINK include/asm-sh/cpu -> include/asm-sh/$(cpuincdir-y)' 151 @echo ' SYMLINK include/asm-sh/cpu -> include/asm-sh/$(cpuincdir-y)'
152 $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi 152 $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi
153 $(Q)ln -fsn $(incdir-prefix)$(cpuincdir-y) include/asm-sh/cpu 153 $(Q)ln -fsn $(incdir-prefix)$(cpuincdir-y) include/asm-sh/cpu
@@ -157,7 +157,7 @@ include/asm-sh/.cpu: $(wildcard include/config/cpu/*.h) include/config/MARKER
157# don't, just reference the parent directory so the semantics are 157# don't, just reference the parent directory so the semantics are
158# kept roughly the same. 158# kept roughly the same.
159 159
160include/asm-sh/.mach: $(wildcard include/config/sh/*.h) include/config/MARKER 160include/asm-sh/.mach: $(wildcard include/config/sh/*.h) include/config/auto.conf
161 @echo -n ' SYMLINK include/asm-sh/mach -> ' 161 @echo -n ' SYMLINK include/asm-sh/mach -> '
162 $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi 162 $(Q)if [ ! -d include/asm-sh ]; then mkdir -p include/asm-sh; fi
163 $(Q)if [ -d $(incdir-prefix)$(incdir-y) ]; then \ 163 $(Q)if [ -d $(incdir-prefix)$(incdir-y) ]; then \
diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile
index 98fac8489aed..3a3a4c66ef87 100644
--- a/arch/xtensa/Makefile
+++ b/arch/xtensa/Makefile
@@ -71,7 +71,7 @@ archprepare: $(archinc)/.platform
71# Update machine cpu and platform symlinks if something which affects 71# Update machine cpu and platform symlinks if something which affects
72# them changed. 72# them changed.
73 73
74$(archinc)/.platform: $(wildcard include/config/arch/*.h) include/config/MARKER 74$(archinc)/.platform: $(wildcard include/config/arch/*.h) include/config/auto.conf
75 @echo ' SYMLINK $(archinc)/xtensa/config -> $(archinc)/xtensa/config-$(CPU)' 75 @echo ' SYMLINK $(archinc)/xtensa/config -> $(archinc)/xtensa/config-$(CPU)'
76 $(Q)mkdir -p $(archinc) 76 $(Q)mkdir -p $(archinc)
77 $(Q)mkdir -p $(archinc)/xtensa 77 $(Q)mkdir -p $(archinc)/xtensa
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile
index f22e94c3a2d1..2f60070f9733 100644
--- a/scripts/basic/Makefile
+++ b/scripts/basic/Makefile
@@ -1,17 +1,15 @@
1### 1###
2# Makefile.basic list the most basic programs used during the build process. 2# Makefile.basic list the most basic programs used during the build process.
3# The programs listed herein is what is needed to do the basic stuff, 3# The programs listed herein is what is needed to do the basic stuff,
4# such as splitting .config and fix dependency file. 4# such as fix dependency file.
5# This initial step is needed to avoid files to be recompiled 5# This initial step is needed to avoid files to be recompiled
6# when kernel configuration changes (which is what happens when 6# when kernel configuration changes (which is what happens when
7# .config is included by main Makefile. 7# .config is included by main Makefile.
8# --------------------------------------------------------------------------- 8# ---------------------------------------------------------------------------
9# fixdep: Used to generate dependency information during build process 9# fixdep: Used to generate dependency information during build process
10# split-include: Divide all config symbols up in a number of files in
11# include/config/...
12# docproc: Used in Documentation/docbook 10# docproc: Used in Documentation/docbook
13 11
14hostprogs-y := fixdep split-include docproc 12hostprogs-y := fixdep docproc
15always := $(hostprogs-y) 13always := $(hostprogs-y)
16 14
17# fixdep is needed to compile other host programs 15# fixdep is needed to compile other host programs
diff --git a/scripts/basic/split-include.c b/scripts/basic/split-include.c
deleted file mode 100644
index 459c45276cb1..000000000000
--- a/scripts/basic/split-include.c
+++ /dev/null
@@ -1,226 +0,0 @@
1/*
2 * split-include.c
3 *
4 * Copyright abandoned, Michael Chastain, <mailto:mec@shout.net>.
5 * This is a C version of syncdep.pl by Werner Almesberger.
6 *
7 * This program takes autoconf.h as input and outputs a directory full
8 * of one-line include files, merging onto the old values.
9 *
10 * Think of the configuration options as key-value pairs. Then there
11 * are five cases:
12 *
13 * key old value new value action
14 *
15 * KEY-1 VALUE-1 VALUE-1 leave file alone
16 * KEY-2 VALUE-2A VALUE-2B write VALUE-2B into file
17 * KEY-3 - VALUE-3 write VALUE-3 into file
18 * KEY-4 VALUE-4 - write an empty file
19 * KEY-5 (empty) - leave old empty file alone
20 */
21
22#include <sys/stat.h>
23#include <sys/types.h>
24
25#include <ctype.h>
26#include <errno.h>
27#include <fcntl.h>
28#include <stdio.h>
29#include <stdlib.h>
30#include <string.h>
31#include <unistd.h>
32
33#define ERROR_EXIT(strExit) \
34 { \
35 const int errnoSave = errno; \
36 fprintf(stderr, "%s: ", str_my_name); \
37 errno = errnoSave; \
38 perror((strExit)); \
39 exit(1); \
40 }
41
42
43
44int main(int argc, const char * argv [])
45{
46 const char * str_my_name;
47 const char * str_file_autoconf;
48 const char * str_dir_config;
49
50 FILE * fp_config;
51 FILE * fp_target;
52 FILE * fp_find;
53
54 int buffer_size;
55
56 char * line;
57 char * old_line;
58 char * list_target;
59 char * ptarget;
60
61 struct stat stat_buf;
62
63 /* Check arg count. */
64 if (argc != 3)
65 {
66 fprintf(stderr, "%s: wrong number of arguments.\n", argv[0]);
67 exit(1);
68 }
69
70 str_my_name = argv[0];
71 str_file_autoconf = argv[1];
72 str_dir_config = argv[2];
73
74 /* Find a buffer size. */
75 if (stat(str_file_autoconf, &stat_buf) != 0)
76 ERROR_EXIT(str_file_autoconf);
77 buffer_size = 2 * stat_buf.st_size + 4096;
78
79 /* Allocate buffers. */
80 if ( (line = malloc(buffer_size)) == NULL
81 || (old_line = malloc(buffer_size)) == NULL
82 || (list_target = malloc(buffer_size)) == NULL )
83 ERROR_EXIT(str_file_autoconf);
84
85 /* Open autoconfig file. */
86 if ((fp_config = fopen(str_file_autoconf, "r")) == NULL)
87 ERROR_EXIT(str_file_autoconf);
88
89 /* Make output directory if needed. */
90 if (stat(str_dir_config, &stat_buf) != 0)
91 {
92 if (mkdir(str_dir_config, 0755) != 0)
93 ERROR_EXIT(str_dir_config);
94 }
95
96 /* Change to output directory. */
97 if (chdir(str_dir_config) != 0)
98 ERROR_EXIT(str_dir_config);
99
100 /* Put initial separator into target list. */
101 ptarget = list_target;
102 *ptarget++ = '\n';
103
104 /* Read config lines. */
105 while (fgets(line, buffer_size, fp_config))
106 {
107 const char * str_config;
108 int is_same;
109 int itarget;
110
111 if (line[0] != '#')
112 continue;
113 if ((str_config = strstr(line, "CONFIG_")) == NULL)
114 continue;
115
116 /* Make the output file name. */
117 str_config += sizeof("CONFIG_") - 1;
118 for (itarget = 0; !isspace(str_config[itarget]); itarget++)
119 {
120 int c = (unsigned char) str_config[itarget];
121 if (isupper(c)) c = tolower(c);
122 if (c == '_') c = '/';
123 ptarget[itarget] = c;
124 }
125 ptarget[itarget++] = '.';
126 ptarget[itarget++] = 'h';
127 ptarget[itarget++] = '\0';
128
129 /* Check for existing file. */
130 is_same = 0;
131 if ((fp_target = fopen(ptarget, "r")) != NULL)
132 {
133 fgets(old_line, buffer_size, fp_target);
134 if (fclose(fp_target) != 0)
135 ERROR_EXIT(ptarget);
136 if (!strcmp(line, old_line))
137 is_same = 1;
138 }
139
140 if (!is_same)
141 {
142 /* Auto-create directories. */
143 int islash;
144 for (islash = 0; islash < itarget; islash++)
145 {
146 if (ptarget[islash] == '/')
147 {
148 ptarget[islash] = '\0';
149 if (stat(ptarget, &stat_buf) != 0
150 && mkdir(ptarget, 0755) != 0)
151 ERROR_EXIT( ptarget );
152 ptarget[islash] = '/';
153 }
154 }
155
156 /* Write the file. */
157 if ((fp_target = fopen(ptarget, "w" )) == NULL)
158 ERROR_EXIT(ptarget);
159 fputs(line, fp_target);
160 if (ferror(fp_target) || fclose(fp_target) != 0)
161 ERROR_EXIT(ptarget);
162 }
163
164 /* Update target list */
165 ptarget += itarget;
166 *(ptarget-1) = '\n';
167 }
168
169 /*
170 * Close autoconfig file.
171 * Terminate the target list.
172 */
173 if (fclose(fp_config) != 0)
174 ERROR_EXIT(str_file_autoconf);
175 *ptarget = '\0';
176
177 /*
178 * Fix up existing files which have no new value.
179 * This is Case 4 and Case 5.
180 *
181 * I re-read the tree and filter it against list_target.
182 * This is crude. But it avoids data copies. Also, list_target
183 * is compact and contiguous, so it easily fits into cache.
184 *
185 * Notice that list_target contains strings separated by \n,
186 * with a \n before the first string and after the last.
187 * fgets gives the incoming names a terminating \n.
188 * So by having an initial \n, strstr will find exact matches.
189 */
190
191 fp_find = popen("find * -type f -name \"*.h\" -print", "r");
192 if (fp_find == 0)
193 ERROR_EXIT( "find" );
194
195 line[0] = '\n';
196 while (fgets(line+1, buffer_size, fp_find))
197 {
198 if (strstr(list_target, line) == NULL)
199 {
200 /*
201 * This is an old file with no CONFIG_* flag in autoconf.h.
202 */
203
204 /* First strip the \n. */
205 line[strlen(line)-1] = '\0';
206
207 /* Grab size. */
208 if (stat(line+1, &stat_buf) != 0)
209 ERROR_EXIT(line);
210
211 /* If file is not empty, make it empty and give it a fresh date. */
212 if (stat_buf.st_size != 0)
213 {
214 if ((fp_target = fopen(line+1, "w")) == NULL)
215 ERROR_EXIT(line);
216 if (fclose(fp_target) != 0)
217 ERROR_EXIT(line);
218 }
219 }
220 }
221
222 if (pclose(fp_find) != 0)
223 ERROR_EXIT("find");
224
225 return 0;
226}
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index ca693fcd023f..e28cd0c2ca08 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -5,6 +5,7 @@
5 5
6#include <sys/stat.h> 6#include <sys/stat.h>
7#include <ctype.h> 7#include <ctype.h>
8#include <fcntl.h>
8#include <stdio.h> 9#include <stdio.h>
9#include <stdlib.h> 10#include <stdlib.h>
10#include <string.h> 11#include <string.h>
@@ -520,6 +521,119 @@ int conf_write(const char *name)
520 return 0; 521 return 0;
521} 522}
522 523
524int conf_split_config(void)
525{
526 char *name, path[128];
527 char *s, *d, c;
528 struct symbol *sym;
529 struct stat sb;
530 int res, i, fd;
531
532 name = getenv("KCONFIG_AUTOCONFIG");
533 if (!name)
534 name = "include/config/auto.conf";
535 conf_read_simple(name, S_DEF_AUTO);
536
537 if (chdir("include/config"))
538 return 1;
539
540 res = 0;
541 for_all_symbols(i, sym) {
542 sym_calc_value(sym);
543 if ((sym->flags & SYMBOL_AUTO) || !sym->name)
544 continue;
545 if (sym->flags & SYMBOL_WRITE) {
546 if (sym->flags & SYMBOL_DEF_AUTO) {
547 /*
548 * symbol has old and new value,
549 * so compare them...
550 */
551 switch (sym->type) {
552 case S_BOOLEAN:
553 case S_TRISTATE:
554 if (sym_get_tristate_value(sym) ==
555 sym->def[S_DEF_AUTO].tri)
556 continue;
557 break;
558 case S_STRING:
559 case S_HEX:
560 case S_INT:
561 if (!strcmp(sym_get_string_value(sym),
562 sym->def[S_DEF_AUTO].val))
563 continue;
564 break;
565 default:
566 break;
567 }
568 } else {
569 /*
570 * If there is no old value, only 'no' (unset)
571 * is allowed as new value.
572 */
573 switch (sym->type) {
574 case S_BOOLEAN:
575 case S_TRISTATE:
576 if (sym_get_tristate_value(sym) == no)
577 continue;
578 break;
579 default:
580 break;
581 }
582 }
583 } else if (!(sym->flags & SYMBOL_DEF_AUTO))
584 /* There is neither an old nor a new value. */
585 continue;
586 /* else
587 * There is an old value, but no new value ('no' (unset)
588 * isn't saved in auto.conf, so the old value is always
589 * different from 'no').
590 */
591
592 /* Replace all '_' and append ".h" */
593 s = sym->name;
594 d = path;
595 while ((c = *s++)) {
596 c = tolower(c);
597 *d++ = (c == '_') ? '/' : c;
598 }
599 strcpy(d, ".h");
600
601 /* Assume directory path already exists. */
602 fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
603 if (fd == -1) {
604 if (errno != ENOENT) {
605 res = 1;
606 break;
607 }
608 /*
609 * Create directory components,
610 * unless they exist already.
611 */
612 d = path;
613 while ((d = strchr(d, '/'))) {
614 *d = 0;
615 if (stat(path, &sb) && mkdir(path, 0755)) {
616 res = 1;
617 goto out;
618 }
619 *d++ = '/';
620 }
621 /* Try it again. */
622 fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
623 if (fd == -1) {
624 res = 1;
625 break;
626 }
627 }
628 close(fd);
629 }
630out:
631 if (chdir("../.."))
632 return 1;
633
634 return res;
635}
636
523int conf_write_autoconf(void) 637int conf_write_autoconf(void)
524{ 638{
525 struct symbol *sym; 639 struct symbol *sym;
@@ -529,8 +643,13 @@ int conf_write_autoconf(void)
529 time_t now; 643 time_t now;
530 int i, l; 644 int i, l;
531 645
646 sym_clear_all_valid();
647
532 file_write_dep("include/config/auto.conf.cmd"); 648 file_write_dep("include/config/auto.conf.cmd");
533 649
650 if (conf_split_config())
651 return 1;
652
534 out = fopen(".tmpconfig", "w"); 653 out = fopen(".tmpconfig", "w");
535 if (!out) 654 if (!out)
536 return 1; 655 return 1;
@@ -558,8 +677,6 @@ int conf_write_autoconf(void)
558 "#define AUTOCONF_INCLUDED\n", 677 "#define AUTOCONF_INCLUDED\n",
559 sym_get_string_value(sym), ctime(&now)); 678 sym_get_string_value(sym), ctime(&now));
560 679
561 sym_clear_all_valid();
562
563 for_all_symbols(i, sym) { 680 for_all_symbols(i, sym) {
564 sym_calc_value(sym); 681 sym_calc_value(sym);
565 if (!(sym->flags & SYMBOL_WRITE) || !sym->name) 682 if (!(sym->flags & SYMBOL_WRITE) || !sym->name)
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 998cf4f656b8..ffd42c7007ee 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -65,6 +65,7 @@ enum symbol_type {
65 65
66enum { 66enum {
67 S_DEF_USER, /* main user value */ 67 S_DEF_USER, /* main user value */
68 S_DEF_AUTO,
68}; 69};
69 70
70struct symbol { 71struct symbol {
@@ -97,7 +98,7 @@ struct symbol {
97#define SYMBOL_WARNED 0x8000 98#define SYMBOL_WARNED 0x8000
98#define SYMBOL_DEF 0x10000 99#define SYMBOL_DEF 0x10000
99#define SYMBOL_DEF_USER 0x10000 100#define SYMBOL_DEF_USER 0x10000
100#define SYMBOL_DEF2 0x20000 101#define SYMBOL_DEF_AUTO 0x20000
101#define SYMBOL_DEF3 0x40000 102#define SYMBOL_DEF3 0x40000
102#define SYMBOL_DEF4 0x80000 103#define SYMBOL_DEF4 0x80000
103 104