aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.headersinst230
-rwxr-xr-xscripts/diffconfig129
-rwxr-xr-xscripts/hdrcheck.sh10
-rwxr-xr-xscripts/headers.sh41
-rw-r--r--scripts/headers_check.pl56
-rw-r--r--scripts/headers_install.pl45
-rw-r--r--scripts/kconfig/conf.c161
-rw-r--r--scripts/kconfig/confdata.c70
-rw-r--r--scripts/kconfig/lkc.h9
-rwxr-xr-xscripts/kernel-doc1
-rwxr-xr-xscripts/setlocalversion4
11 files changed, 490 insertions, 266 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 53dae3eb3d1f..612dc13ddd85 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -1,194 +1,98 @@
1# ========================================================================== 1# ==========================================================================
2# Installing headers 2# Installing headers
3# 3#
4# header-y files will be installed verbatim 4# header-y - list files to be installed. They are preprocessed
5# unifdef-y are the files where unifdef will be run before installing files 5# to remove __KERNEL__ section of the file
6# objhdr-y are generated files that will be installed verbatim 6# unifdef-y - Same as header-y. Obsolete
7# objhdr-y - Same as header-y but for generated files
7# 8#
8# ========================================================================== 9# ==========================================================================
9 10
10UNIFDEF := scripts/unifdef -U__KERNEL__ 11# called may set destination dir (when installing to asm/)
11
12# Eliminate the contents of (and inclusions of) compiler.h
13HDRSED := sed -e "s/ inline / __inline__ /g" \
14 -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \
15 -e "s/(__user[[:space:]]\{1,\}/ (/g" \
16 -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \
17 -e "s/(__force[[:space:]]\{1,\}/ (/g" \
18 -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \
19 -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \
20 -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \
21 -e "s/[[:space:]]__attribute_const__$$//" \
22 -e "/^\#include <linux\/compiler.h>/d"
23
24_dst := $(if $(dst),$(dst),$(obj)) 12_dst := $(if $(dst),$(dst),$(obj))
25 13
26ifeq (,$(patsubst include/asm/%,,$(obj)/)) 14kbuild-file := $(srctree)/$(obj)/Kbuild
27# For producing the generated stuff in include/asm for biarch builds, include 15include $(kbuild-file)
28# both sets of Kbuild files; we'll generate anything which is mentioned in
29# _either_ arch, and recurse into subdirectories which are mentioned in either
30# arch. Since some directories may exist in one but not the other, we must
31# use $(wildcard...).
32GENASM := 1
33archasm := $(subst include/asm,asm-$(ARCH),$(obj))
34altarchasm := $(subst include/asm,asm-$(ALTARCH),$(obj))
35KBUILDFILES := $(wildcard $(srctree)/include/$(archasm)/Kbuild $(srctree)/include/$(altarchasm)/Kbuild)
36else
37KBUILDFILES := $(srctree)/$(obj)/Kbuild
38endif
39 16
40include $(KBUILDFILES) 17include scripts/Kbuild.include
41 18
42include scripts/Kbuild.include 19install := $(INSTALL_HDR_PATH)/$(_dst)
43 20
44# If this is include/asm-$(ARCH) and there's no $(ALTARCH), then 21header-y := $(sort $(header-y) $(unifdef-y))
45# override $(_dst) so that we install to include/asm directly. 22subdirs := $(patsubst %/,%,$(filter %/, $(header-y)))
46# Unless $(BIASMDIR) is set, in which case we're probably doing 23header-y := $(filter-out %/, $(header-y))
47# a 'headers_install_all' build and we should keep the -$(ARCH)
48# in the directory name.
49ifeq ($(obj)$(ALTARCH),include/asm-$(ARCH)$(BIASMDIR))
50 _dst := include/asm
51endif
52 24
53header-y := $(sort $(header-y)) 25# files used to track state of install/check
54unifdef-y := $(sort $(unifdef-y)) 26install-file := $(install)/.install
55subdir-y := $(patsubst %/,%,$(filter %/, $(header-y))) 27check-file := $(install)/.check
56header-y := $(filter-out %/, $(header-y))
57header-y := $(filter-out $(unifdef-y),$(header-y))
58 28
59# stamp files for header checks 29# all headers files for this dir
60check-y := $(patsubst %,.check.%,$(header-y) $(unifdef-y) $(objhdr-y)) 30all-files := $(header-y) $(objhdr-y)
31input-files := $(addprefix $(srctree)/$(obj)/,$(header-y)) \
32 $(addprefix $(objtree)/$(obj)/,$(objhdr-y))
33output-files := $(addprefix $(install)/, $(all-files))
61 34
62# Work out what needs to be removed 35# Work out what needs to be removed
63oldheaders := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/*.h)) 36oldheaders := $(patsubst $(install)/%,%,$(wildcard $(install)/*.h))
64unwanted := $(filter-out $(header-y) $(unifdef-y) $(objhdr-y),$(oldheaders)) 37unwanted := $(filter-out $(all-files),$(oldheaders))
65 38
66oldcheckstamps := $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$(wildcard $(INSTALL_HDR_PATH)/$(_dst)/.check.*.h)) 39# Prefix unwanted with full paths to $(INSTALL_HDR_PATH)
67unwanted += $(filter-out $(check-y),$(oldcheckstamps)) 40unwanted-file := $(addprefix $(install)/, $(unwanted))
68 41
69# Prefix them all with full paths to $(INSTALL_HDR_PATH) 42printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
70header-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(header-y))
71unifdef-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(unifdef-y))
72objhdr-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(objhdr-y))
73check-y := $(patsubst %,$(INSTALL_HDR_PATH)/$(_dst)/%,$(check-y))
74 43
44quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
45 file$(if $(word 2, $(all-files)),s))
46 cmd_install = \
47 $(PERL) $< $(srctree)/$(obj) $(install) $(SRCARCH) $(header-y); \
48 $(PERL) $< $(objtree)/$(obj) $(install) $(SRCARCH) $(objhdr-y); \
49 touch $@
75 50
76ifdef ALTARCH 51quiet_cmd_remove = REMOVE $(unwanted)
77ifeq ($(obj),include/asm-$(ARCH)) 52 cmd_remove = rm -f $(unwanted-file)
78altarch-y := altarch-dir
79endif
80endif
81 53
82# Make the definitions visible for recursive make invocations 54quiet_cmd_check = CHECK $(printdir) ($(words $(all-files)) files)
83export ALTARCH 55 cmd_check = $(PERL) $< $(INSTALL_HDR_PATH)/include $(SRCARCH) \
84export ARCHDEF 56 $(addprefix $(install)/, $(all-files)); \
85export ALTARCHDEF 57 touch $@
86
87quiet_cmd_o_hdr_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
88 cmd_o_hdr_install = cp $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(objtree)/$(obj)/%,$@) \
89 $(INSTALL_HDR_PATH)/$(_dst)
90
91quiet_cmd_headers_install = INSTALL $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
92 cmd_headers_install = $(HDRSED) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
93 > $@
94
95quiet_cmd_unifdef = UNIFDEF $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
96 cmd_unifdef = $(UNIFDEF) $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,$(srctree)/$(obj)/%,$@) \
97 | $(HDRSED) > $@ || :
98
99quiet_cmd_check = CHECK $(patsubst $(INSTALL_HDR_PATH)/$(_dst)/.check.%,$(_dst)/%,$@)
100 cmd_check = $(CONFIG_SHELL) $(srctree)/scripts/hdrcheck.sh \
101 $(INSTALL_HDR_PATH)/include $(subst /.check.,/,$@) $@
102
103quiet_cmd_remove = REMOVE $(_dst)/$@
104 cmd_remove = rm -f $(INSTALL_HDR_PATH)/$(_dst)/$@
105
106quiet_cmd_mkdir = MKDIR $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
107 cmd_mkdir = mkdir -p $@
108
109quiet_cmd_gen = GEN $(patsubst $(INSTALL_HDR_PATH)/%,%,$@)
110 cmd_gen = \
111FNAME=$(patsubst $(INSTALL_HDR_PATH)/$(_dst)/%,%,$@); \
112STUBDEF=__ASM_STUB_`echo $$FNAME | tr a-z.- A-Z__`; \
113(echo "/* File autogenerated by 'make headers_install' */" ; \
114echo "\#ifndef $$STUBDEF" ; \
115echo "\#define $$STUBDEF" ; \
116echo "\# if $(ARCHDEF)" ; \
117if [ -r $(subst /$(_dst)/,/include/$(archasm)/,$@) ]; then \
118 echo "\# include <$(archasm)/$$FNAME>" ; \
119else \
120 echo "\# error $(archasm)/$$FNAME does not exist in" \
121 "the $(ARCH) architecture" ; \
122fi ; \
123echo "\# elif $(ALTARCHDEF)" ; \
124if [ -r $(subst /$(_dst)/,/include/$(altarchasm)/,$@) ]; then \
125 echo "\# include <$(altarchasm)/$$FNAME>" ; \
126else \
127 echo "\# error $(altarchasm)/$$FNAME does not exist in" \
128 "the $(ALTARCH) architecture" ; \
129fi ; \
130echo "\# else" ; \
131echo "\# warning This machine appears to be" \
132 "neither $(ARCH) nor $(ALTARCH)." ; \
133echo "\# endif" ; \
134echo "\#endif /* $$STUBDEF */" ; \
135) > $@
136
137.PHONY: __headersinst __headerscheck
138
139ifdef HDRCHECK
140__headerscheck: $(subdir-y) $(check-y)
141 @true
142
143$(check-y) : $(INSTALL_HDR_PATH)/$(_dst)/.check.%.h : $(INSTALL_HDR_PATH)/$(_dst)/%.h
144 $(call cmd,check)
145
146# Other dependencies for $(check-y)
147include /dev/null $(wildcard $(check-y))
148
149# ... but leave $(check-y) as .PHONY for now until those deps are actually correct.
150.PHONY: $(check-y)
151 58
152else 59PHONY += __headersinst __headerscheck
153# Rules for installing headers
154__headersinst: $(subdir-y) $(header-y) $(unifdef-y) $(altarch-y) $(objhdr-y)
155 @true
156 60
157$(objhdr-y) $(subdir-y) $(header-y) $(unifdef-y): | $(INSTALL_HDR_PATH)/$(_dst) $(unwanted) 61ifndef HDRCHECK
158 62# Rules for installing headers
159$(INSTALL_HDR_PATH)/$(_dst): 63__headersinst: $(subdirs) $(install-file)
160 $(call cmd,mkdir) 64 @:
161
162.PHONY: $(unwanted)
163$(unwanted):
164 $(call cmd,remove)
165 65
166ifdef GENASM 66targets += $(install-file)
167$(objhdr-y) $(header-y) $(unifdef-y): $(KBUILDFILES) 67$(install-file): scripts/headers_install.pl $(input-files) FORCE
168 $(call cmd,gen) 68 $(if $(unwanted),$(call cmd,remove),)
69 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
70 $(call if_changed,install)
169 71
170else 72else
171$(objhdr-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(objtree)/$(obj)/%.h $(KBUILDFILES) 73__headerscheck: $(subdirs) $(check-file)
172 $(call cmd,o_hdr_install) 74 @:
173 75
174$(header-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES) 76targets += $(check-file)
175 $(call cmd,headers_install) 77$(check-file): scripts/headers_check.pl $(output-files) FORCE
78 $(call if_changed,check)
176 79
177$(unifdef-y) : $(INSTALL_HDR_PATH)/$(_dst)/%.h: $(srctree)/$(obj)/%.h $(KBUILDFILES)
178 $(call cmd,unifdef)
179endif
180endif 80endif
181 81
182hdrinst := -rR -f $(srctree)/scripts/Makefile.headersinst obj 82# Recursion
83hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
84.PHONY: $(subdirs)
85$(subdirs):
86 $(Q)$(MAKE) $(hdr-inst)=$(obj)/$@ dst=$(_dst)/$@
183 87
184.PHONY: altarch-dir 88targets := $(wildcard $(sort $(targets)))
185# All the files in the normal arch dir must be created first, since we test 89cmd_files := $(wildcard \
186# for their existence. 90 $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
187altarch-dir: $(subdir-y) $(header-y) $(unifdef-y) $(objhdr-y)
188 $(Q)$(MAKE) $(hdrinst)=include/asm-$(ALTARCH) dst=include/asm-$(ALTARCH)
189 $(Q)$(MAKE) $(hdrinst)=include/asm dst=include/asm$(BIASMDIR)
190 91
191# Recursion 92ifneq ($(cmd_files),)
192.PHONY: $(subdir-y) 93 include $(cmd_files)
193$(subdir-y): 94endif
194 $(Q)$(MAKE) $(hdrinst)=$(obj)/$@ dst=$(_dst)/$@ rel=../$(rel) 95
96.PHONY: $(PHONY)
97PHONY += FORCE
98FORCE: ;
diff --git a/scripts/diffconfig b/scripts/diffconfig
new file mode 100755
index 000000000000..b91f3e34d44d
--- /dev/null
+++ b/scripts/diffconfig
@@ -0,0 +1,129 @@
1#!/usr/bin/python
2#
3# diffconfig - a tool to compare .config files.
4#
5# originally written in 2006 by Matt Mackall
6# (at least, this was in his bloatwatch source code)
7# last worked on 2008 by Tim Bird
8#
9
10import sys, os
11
12def usage():
13 print """Usage: diffconfig [-h] [-m] [<config1> <config2>]
14
15Diffconfig is a simple utility for comparing two .config files.
16Using standard diff to compare .config files often includes extraneous and
17distracting information. This utility produces sorted output with only the
18changes in configuration values between the two files.
19
20Added and removed items are shown with a leading plus or minus, respectively.
21Changed items show the old and new values on a single line.
22
23If -m is specified, then output will be in "merge" style, which has the
24changed and new values in kernel config option format.
25
26If no config files are specified, .config and .config.old are used.
27
28Example usage:
29 $ diffconfig .config config-with-some-changes
30-EXT2_FS_XATTR n
31-EXT2_FS_XIP n
32 CRAMFS n -> y
33 EXT2_FS y -> n
34 LOG_BUF_SHIFT 14 -> 16
35 PRINTK_TIME n -> y
36"""
37 sys.exit(0)
38
39# returns a dictionary of name/value pairs for config items in the file
40def readconfig(config_file):
41 d = {}
42 for line in config_file:
43 line = line[:-1]
44 if line[:7] == "CONFIG_":
45 name, val = line[7:].split("=", 1)
46 d[name] = val
47 if line[-11:] == " is not set":
48 d[line[9:-11]] = "n"
49 return d
50
51def print_config(op, config, value, new_value):
52 global merge_style
53
54 if merge_style:
55 if new_value:
56 if new_value=="n":
57 print "# CONFIG_%s is not set" % config
58 else:
59 print "CONFIG_%s=%s" % (config, new_value)
60 else:
61 if op=="-":
62 print "-%s %s" % (config, value)
63 elif op=="+":
64 print "+%s %s" % (config, new_value)
65 else:
66 print " %s %s -> %s" % (config, value, new_value)
67
68def main():
69 global merge_style
70
71 # parse command line args
72 if ("-h" in sys.argv or "--help" in sys.argv):
73 usage()
74
75 merge_style = 0
76 if "-m" in sys.argv:
77 merge_style = 1
78 sys.argv.remove("-m")
79
80 argc = len(sys.argv)
81 if not (argc==1 or argc == 3):
82 print "Error: incorrect number of arguments or unrecognized option"
83 usage()
84
85 if argc == 1:
86 # if no filenames given, assume .config and .config.old
87 build_dir=""
88 if os.environ.has_key("KBUILD_OUTPUT"):
89 build_dir = os.environ["KBUILD_OUTPUT"]+"/"
90
91 configa_filename = build_dir + ".config.old"
92 configb_filename = build_dir + ".config"
93 else:
94 configa_filename = sys.argv[1]
95 configb_filename = sys.argv[2]
96
97 a = readconfig(file(configa_filename))
98 b = readconfig(file(configb_filename))
99
100 # print items in a but not b (accumulate, sort and print)
101 old = []
102 for config in a:
103 if config not in b:
104 old.append(config)
105 old.sort()
106 for config in old:
107 print_config("-", config, a[config], None)
108 del a[config]
109
110 # print items that changed (accumulate, sort, and print)
111 changed = []
112 for config in a:
113 if a[config] != b[config]:
114 changed.append(config)
115 else:
116 del b[config]
117 changed.sort()
118 for config in changed:
119 print_config("->", config, a[config], b[config])
120 del b[config]
121
122 # now print items in b but not in a
123 # (items from b that were in a were removed above)
124 new = b.keys()
125 new.sort()
126 for config in new:
127 print_config("+", config, None, b[config])
128
129main()
diff --git a/scripts/hdrcheck.sh b/scripts/hdrcheck.sh
deleted file mode 100755
index 31598584f871..000000000000
--- a/scripts/hdrcheck.sh
+++ /dev/null
@@ -1,10 +0,0 @@
1#!/bin/sh
2
3for FILE in `grep '^[ \t]*#[ \t]*include[ \t]*<' $2 | cut -f2 -d\< | cut -f1 -d\> | egrep ^linux\|^asm` ; do
4 if [ ! -r $1/$FILE ]; then
5 echo $2 requires $FILE, which does not exist in exported headers
6 exit 1
7 fi
8done
9# FIXME: List dependencies into $3
10touch $3
diff --git a/scripts/headers.sh b/scripts/headers.sh
new file mode 100755
index 000000000000..d33426f866db
--- /dev/null
+++ b/scripts/headers.sh
@@ -0,0 +1,41 @@
1#!/bin/sh
2# Run headers_$1 command for all suitable architectures
3
4# Stop on error
5set -e
6
7do_command()
8{
9 if [ -f ${srctree}/arch/$2/include/asm/Kbuild ]; then
10 make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
11 elif [ -f ${srctree}/include/asm-$2/Kbuild ]; then
12 make ARCH=$2 KBUILD_HEADERS=$1 headers_$1
13 else
14 printf "Ignoring arch: %s\n" ${arch}
15 fi
16}
17
18# Do not try this architecture
19drop="generic um ppc sparc64 cris"
20
21archs=$(ls ${srctree}/arch)
22
23for arch in ${archs}; do
24 case ${arch} in
25 um) # no userspace export
26 ;;
27 ppc) # headers exported by powerpc
28 ;;
29 sparc64) # headers exported by sparc
30 ;;
31 cris) # headers export are known broken
32 ;;
33 *)
34 if [ -d ${srctree}/arch/${arch} ]; then
35 do_command $1 ${arch}
36 fi
37 ;;
38 esac
39done
40
41
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
new file mode 100644
index 000000000000..15d53a6b1a1f
--- /dev/null
+++ b/scripts/headers_check.pl
@@ -0,0 +1,56 @@
1#!/usr/bin/perl
2#
3# headers_check.pl execute a number of trivial consistency checks
4#
5# Usage: headers_check.pl dir [files...]
6# dir: dir to look for included files
7# arch: architecture
8# files: list of files to check
9#
10# The script reads the supplied files line by line and:
11#
12# 1) for each include statement it checks if the
13# included file actually exists.
14# Only include files located in asm* and linux* are checked.
15# The rest are assumed to be system include files.
16#
17# 2) TODO: check for leaked CONFIG_ symbols
18
19use strict;
20use warnings;
21
22my ($dir, $arch, @files) = @ARGV;
23
24my $ret = 0;
25my $line;
26my $lineno = 0;
27my $filename;
28
29foreach my $file (@files) {
30 $filename = $file;
31 open(my $fh, '<', "$filename") or die "$filename: $!\n";
32 $lineno = 0;
33 while ($line = <$fh>) {
34 $lineno++;
35 check_include();
36 }
37 close $fh;
38}
39exit $ret;
40
41sub check_include
42{
43 if ($line =~ m/^\s*#\s*include\s+<((asm|linux).*)>/) {
44 my $inc = $1;
45 my $found;
46 $found = stat($dir . "/" . $inc);
47 if (!$found) {
48 $inc =~ s#asm/#asm-$arch/#;
49 $found = stat($dir . "/" . $inc);
50 }
51 if (!$found) {
52 printf STDERR "$filename:$lineno: included file '$inc' is not exported\n";
53 $ret = 1;
54 }
55 }
56}
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
new file mode 100644
index 000000000000..68591cd08731
--- /dev/null
+++ b/scripts/headers_install.pl
@@ -0,0 +1,45 @@
1#!/usr/bin/perl
2#
3# headers_install prepare the listed header files for use in
4# user space and copy the files to their destination.
5#
6# Usage: headers_install.pl readdir installdir arch [files...]
7# readdir: dir to open files
8# installdir: dir to install the files
9# arch: current architecture
10# arch is used to force a reinstallation when the arch
11# changes because kbuild then detect a command line change.
12# files: list of files to check
13#
14# Step in preparation for users space:
15# 1) Drop all use of compiler.h definitions
16# 2) Drop include of compiler.h
17# 3) Drop all sections defined out by __KERNEL__ (using unifdef)
18
19use strict;
20use warnings;
21
22my ($readdir, $installdir, $arch, @files) = @ARGV;
23
24my $unifdef = "scripts/unifdef -U__KERNEL__";
25
26foreach my $file (@files) {
27 my $tmpfile = "$installdir/$file.tmp";
28 open(my $infile, '<', "$readdir/$file")
29 or die "$readdir/$file: $!\n";
30 open(my $outfile, '>', "$tmpfile") or die "$tmpfile: $!\n";
31 while (my $line = <$infile>) {
32 $line =~ s/([\s(])__user\s/$1/g;
33 $line =~ s/([\s(])__force\s/$1/g;
34 $line =~ s/([\s(])__iomem\s/$1/g;
35 $line =~ s/\s__attribute_const__\s/ /g;
36 $line =~ s/\s__attribute_const__$//g;
37 $line =~ s/^#include <linux\/compiler.h>//;
38 printf $outfile "%s", $line;
39 }
40 close $outfile;
41 close $infile;
42 system $unifdef . " $tmpfile > $installdir/$file";
43 unlink $tmpfile;
44}
45exit 0;
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index fda63136ae68..9fba838c7069 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -76,7 +76,6 @@ static void check_stdin(void)
76static int conf_askvalue(struct symbol *sym, const char *def) 76static int conf_askvalue(struct symbol *sym, const char *def)
77{ 77{
78 enum symbol_type type = sym_get_type(sym); 78 enum symbol_type type = sym_get_type(sym);
79 tristate val;
80 79
81 if (!sym_has_value(sym)) 80 if (!sym_has_value(sym))
82 printf(_("(NEW) ")); 81 printf(_("(NEW) "));
@@ -92,15 +91,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
92 } 91 }
93 92
94 switch (input_mode) { 93 switch (input_mode) {
95 case set_no:
96 case set_mod:
97 case set_yes:
98 case set_random:
99 if (sym_has_value(sym)) {
100 printf("%s\n", def);
101 return 0;
102 }
103 break;
104 case ask_new: 94 case ask_new:
105 case ask_silent: 95 case ask_silent:
106 if (sym_has_value(sym)) { 96 if (sym_has_value(sym)) {
@@ -112,9 +102,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
112 fflush(stdout); 102 fflush(stdout);
113 fgets(line, 128, stdin); 103 fgets(line, 128, stdin);
114 return 1; 104 return 1;
115 case set_default:
116 printf("%s\n", def);
117 return 1;
118 default: 105 default:
119 break; 106 break;
120 } 107 }
@@ -128,52 +115,6 @@ static int conf_askvalue(struct symbol *sym, const char *def)
128 default: 115 default:
129 ; 116 ;
130 } 117 }
131 switch (input_mode) {
132 case set_yes:
133 if (sym_tristate_within_range(sym, yes)) {
134 line[0] = 'y';
135 line[1] = '\n';
136 line[2] = 0;
137 break;
138 }
139 case set_mod:
140 if (type == S_TRISTATE) {
141 if (sym_tristate_within_range(sym, mod)) {
142 line[0] = 'm';
143 line[1] = '\n';
144 line[2] = 0;
145 break;
146 }
147 } else {
148 if (sym_tristate_within_range(sym, yes)) {
149 line[0] = 'y';
150 line[1] = '\n';
151 line[2] = 0;
152 break;
153 }
154 }
155 case set_no:
156 if (sym_tristate_within_range(sym, no)) {
157 line[0] = 'n';
158 line[1] = '\n';
159 line[2] = 0;
160 break;
161 }
162 case set_random:
163 do {
164 val = (tristate)(rand() % 3);
165 } while (!sym_tristate_within_range(sym, val));
166 switch (val) {
167 case no: line[0] = 'n'; break;
168 case mod: line[0] = 'm'; break;
169 case yes: line[0] = 'y'; break;
170 }
171 line[1] = '\n';
172 line[2] = 0;
173 break;
174 default:
175 break;
176 }
177 printf("%s", line); 118 printf("%s", line);
178 return 1; 119 return 1;
179} 120}
@@ -374,15 +315,7 @@ static int conf_choice(struct menu *menu)
374 else 315 else
375 continue; 316 continue;
376 break; 317 break;
377 case set_random: 318 default:
378 if (is_new)
379 def = (rand() % cnt) + 1;
380 case set_default:
381 case set_yes:
382 case set_mod:
383 case set_no:
384 cnt = def;
385 printf("%d\n", cnt);
386 break; 319 break;
387 } 320 }
388 321
@@ -494,6 +427,43 @@ static void check_conf(struct menu *menu)
494 check_conf(child); 427 check_conf(child);
495} 428}
496 429
430static void conf_do_update(void)
431{
432 /* Update until a loop caused no more changes */
433 do {
434 conf_cnt = 0;
435 check_conf(&rootmenu);
436 } while (conf_cnt);
437}
438
439static int conf_silent_update(void)
440{
441 const char *name;
442
443 if (conf_get_changed()) {
444 name = getenv("KCONFIG_NOSILENTUPDATE");
445 if (name && *name) {
446 fprintf(stderr,
447 _("\n*** Kernel configuration requires explicit update.\n\n"));
448 return 1;
449 }
450 conf_do_update();
451 }
452 return 0;
453}
454
455static int conf_update(void)
456{
457 rootEntry = &rootmenu;
458 conf(&rootmenu);
459 if (input_mode == ask_all) {
460 input_mode = ask_silent;
461 valid_stdin = 1;
462 }
463 conf_do_update();
464 return 0;
465}
466
497int main(int ac, char **av) 467int main(int ac, char **av)
498{ 468{
499 int opt; 469 int opt;
@@ -599,36 +569,43 @@ int main(int ac, char **av)
599 default: 569 default:
600 break; 570 break;
601 } 571 }
572 switch (input_mode) {
573 case set_no:
574 conf_set_all_new_symbols(def_no);
575 break;
576 case set_yes:
577 conf_set_all_new_symbols(def_yes);
578 break;
579 case set_mod:
580 conf_set_all_new_symbols(def_mod);
581 break;
582 case set_random:
583 conf_set_all_new_symbols(def_random);
584 break;
585 case set_default:
586 conf_set_all_new_symbols(def_default);
587 break;
588 case ask_silent:
589 case ask_new:
590 if (conf_silent_update())
591 exit(1);
592 break;
593 case ask_all:
594 if (conf_update())
595 exit(1);
596 break;
597 }
602 598
603 if (input_mode != ask_silent) { 599 if (conf_get_changed() && conf_write(NULL)) {
604 rootEntry = &rootmenu;
605 conf(&rootmenu);
606 if (input_mode == ask_all) {
607 input_mode = ask_silent;
608 valid_stdin = 1;
609 }
610 } else if (conf_get_changed()) {
611 name = getenv("KCONFIG_NOSILENTUPDATE");
612 if (name && *name) {
613 fprintf(stderr, _("\n*** Kernel configuration requires explicit update.\n\n"));
614 return 1;
615 }
616 } else
617 goto skip_check;
618
619 do {
620 conf_cnt = 0;
621 check_conf(&rootmenu);
622 } while (conf_cnt);
623 if (conf_write(NULL)) {
624 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 600 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
625 return 1; 601 exit(1);
626 } 602 }
627skip_check: 603 /* ask_silent is used during the build so we shall update autoconf.
604 * All other commands are only used to generate a config.
605 */
628 if (input_mode == ask_silent && conf_write_autoconf()) { 606 if (input_mode == ask_silent && conf_write_autoconf()) {
629 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); 607 fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n"));
630 return 1; 608 return 1;
631 } 609 }
632
633 return 0; 610 return 0;
634} 611}
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index ee5fe943d58d..07597611cc50 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -812,3 +812,73 @@ void conf_set_changed_callback(void (*fn)(void))
812{ 812{
813 conf_changed_callback = fn; 813 conf_changed_callback = fn;
814} 814}
815
816
817void conf_set_all_new_symbols(enum conf_def_mode mode)
818{
819 struct symbol *sym, *csym;
820 struct property *prop;
821 struct expr *e;
822 int i, cnt, def;
823
824 for_all_symbols(i, sym) {
825 if (sym_has_value(sym))
826 continue;
827 switch (sym_get_type(sym)) {
828 case S_BOOLEAN:
829 case S_TRISTATE:
830 switch (mode) {
831 case def_yes:
832 sym->def[S_DEF_USER].tri = yes;
833 break;
834 case def_mod:
835 sym->def[S_DEF_USER].tri = mod;
836 break;
837 case def_no:
838 sym->def[S_DEF_USER].tri = no;
839 break;
840 case def_random:
841 sym->def[S_DEF_USER].tri = (tristate)(rand() % 3);
842 break;
843 default:
844 continue;
845 }
846 if (!sym_is_choice(sym) || mode != def_random)
847 sym->flags |= SYMBOL_DEF_USER;
848 break;
849 default:
850 break;
851 }
852
853 }
854
855 if (modules_sym)
856 sym_calc_value(modules_sym);
857
858 if (mode != def_random)
859 return;
860
861 for_all_symbols(i, csym) {
862 if (sym_has_value(csym) || !sym_is_choice(csym))
863 continue;
864
865 sym_calc_value(csym);
866 prop = sym_get_choice_prop(csym);
867 def = -1;
868 while (1) {
869 cnt = 0;
870 expr_list_for_each_sym(prop->expr, e, sym) {
871 if (sym->visible == no)
872 continue;
873 if (def == cnt++) {
874 csym->def[S_DEF_USER].val = sym;
875 break;
876 }
877 }
878 if (def >= 0 || cnt < 2)
879 break;
880 def = (rand() % cnt) + 1;
881 }
882 csym->flags |= SYMBOL_DEF_USER;
883 }
884}
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 96521cb087ec..4a9af6f7886b 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -42,6 +42,14 @@ extern "C" {
42#define TF_PARAM 0x0002 42#define TF_PARAM 0x0002
43#define TF_OPTION 0x0004 43#define TF_OPTION 0x0004
44 44
45enum conf_def_mode {
46 def_default,
47 def_yes,
48 def_mod,
49 def_no,
50 def_random
51};
52
45#define T_OPT_MODULES 1 53#define T_OPT_MODULES 1
46#define T_OPT_DEFCONFIG_LIST 2 54#define T_OPT_DEFCONFIG_LIST 2
47#define T_OPT_ENV 3 55#define T_OPT_ENV 3
@@ -69,6 +77,7 @@ const char *conf_get_configname(void);
69char *conf_get_default_confname(void); 77char *conf_get_default_confname(void);
70void sym_set_change_count(int count); 78void sym_set_change_count(int count);
71void sym_add_change_count(int count); 79void sym_add_change_count(int count);
80void conf_set_all_new_symbols(enum conf_def_mode mode);
72 81
73/* kconfig_load.c */ 82/* kconfig_load.c */
74void kconfig_load(void); 83void kconfig_load(void);
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 88e3934a8b8c..d8f77e26081c 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -1643,6 +1643,7 @@ sub dump_function($$) {
1643 $prototype =~ s/^__always_inline +//; 1643 $prototype =~ s/^__always_inline +//;
1644 $prototype =~ s/^noinline +//; 1644 $prototype =~ s/^noinline +//;
1645 $prototype =~ s/__devinit +//; 1645 $prototype =~ s/__devinit +//;
1646 $prototype =~ s/__init +//;
1646 $prototype =~ s/^#define\s+//; #ak added 1647 $prototype =~ s/^#define\s+//; #ak added
1647 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; 1648 $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//;
1648 1649
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 1c1bdaf7348a..83b75126c9f7 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -12,7 +12,9 @@ cd "${1:-.}" || usage
12if head=`git rev-parse --verify HEAD 2>/dev/null`; then 12if head=`git rev-parse --verify HEAD 2>/dev/null`; then
13 # Do we have an untagged version? 13 # Do we have an untagged version?
14 if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then 14 if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then
15 git describe | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' 15 if tag=`git describe 2>/dev/null`; then
16 echo $tag | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
17 fi
16 fi 18 fi
17 19
18 # Are there uncommitted changes? 20 # Are there uncommitted changes?