summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>1998-03-17 22:05:47 +0000
committerRalf Baechle <ralf@linux-mips.org>1998-03-17 22:05:47 +0000
commit27cfca1ec98e91261b1a5355d10a8996464b63af (patch)
tree8e895a53e372fa682b4c0a585b9377d67ed70d0e /scripts
parent6a76fb7214c477ccf6582bd79c5b4ccc4f9c41b1 (diff)
Look Ma' what I found on my harddisk ...
o New faster syscalls for 2.1.x, too o Upgrade to 2.1.89. Don't try to run this. It's flaky as hell. But feel free to debug ...
Diffstat (limited to 'scripts')
-rw-r--r--scripts/.cvsignore1
-rw-r--r--scripts/Configure4
-rw-r--r--scripts/Makefile32
-rw-r--r--scripts/Menuconfig121
-rw-r--r--scripts/README.Menuconfig4
-rw-r--r--scripts/checkconfig.pl53
-rw-r--r--scripts/depend.awk154
-rw-r--r--scripts/header.tk53
-rw-r--r--scripts/hfiles.sh11
-rw-r--r--scripts/lxdialog/checklist.c11
-rw-r--r--scripts/lxdialog/lxdialog.c2
-rw-r--r--scripts/mkdep.c563
-rw-r--r--scripts/patch-kernel42
-rw-r--r--scripts/split-include.c226
-rw-r--r--scripts/tkcond.c3
-rw-r--r--scripts/tkgen.c43
-rw-r--r--scripts/tkparse.c9
-rw-r--r--scripts/tkparse.h1
18 files changed, 792 insertions, 541 deletions
diff --git a/scripts/.cvsignore b/scripts/.cvsignore
index 43b7f79e8..07fa550f5 100644
--- a/scripts/.cvsignore
+++ b/scripts/.cvsignore
@@ -1 +1,2 @@
mkdep
+split-include
diff --git a/scripts/Configure b/scripts/Configure
index 79a2ce28a..5ca0e8366 100644
--- a/scripts/Configure
+++ b/scripts/Configure
@@ -12,10 +12,10 @@
#
# ***** IMPORTANT COMPATIBILITY NOTE ****
# If configuration changes are made which might adversely effect
-# Menuconfig or xconfig, please notify the respective authors so that
+# Menuconfig or xconfig, please notify the respective maintainers so that
# those utilities can be updated in parallel.
#
-# Menuconfig: <roadcapw@cfw.com>
+# Menuconfig: <mec@shout.net>
# xconfig: <apenwarr@foxnet.net> <eric@aib.com>
# ****************************************
#
diff --git a/scripts/Makefile b/scripts/Makefile
index a214e709e..eaf0db043 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -2,29 +2,21 @@ HOSTCFLAGS:=$(HOSTCFLAGS) -g -Wall
HEADER=header.tk
TAIL=tail.tk
-# We allow the Makefile in drivers/sound to decide when to rebuild its
-# files, rather than trying to second-guess it like we did before.
-#
-soundscript:
- make -C ${TOPDIR}/drivers/sound mkscript
- @echo
-
-# There is probably a better way to decide when to rebuild kconfig.tk; this
-# one won't catch every last change to the various Config.in files. However,
-# the reliance on ${TOPDIR}/Makefile makes sure we at least rebuild when the
-# kernel version number changes.
-#
-kconfig.tk: soundscript ${TOPDIR}/Makefile ${TOPDIR}/arch/${ARCH}/config.in \
+# Previous versions always remade kconfig.tk because they always depended
+# on soundscript. This runs fairly fast, and I can't find all the
+# Config.in files to depend on anyways. So I'll force it to remake.
+
+kconfig.tk: dummy
+
+kconfig.tk: ${TOPDIR}/Makefile ${TOPDIR}/arch/${ARCH}/config.in \
tkparse ${HEADER} ${TAIL}
- ./tkparse < ../arch/${ARCH}/config.in > kconfig.tmp
@if [ -f /usr/local/bin/wish ]; then \
echo '#!'"/usr/local/bin/wish -f" > kconfig.tk; \
else \
echo '#!'"/usr/bin/wish -f" > kconfig.tk; \
fi
cat ${HEADER} >> ./kconfig.tk
- cat kconfig.tmp >> kconfig.tk
- rm -f kconfig.tmp
+ ./tkparse < ../arch/${ARCH}/config.in >> kconfig.tk
echo "set defaults \"arch/${ARCH}/defconfig\"" >> kconfig.tk
cat ${TAIL} >> kconfig.tk
chmod 755 kconfig.tk
@@ -33,15 +25,15 @@ tkparse: tkparse.o tkcond.o tkgen.o
${HOSTCC} -o tkparse tkparse.o tkcond.o tkgen.o
tkparse.o: tkparse.c tkparse.h
- $(HOSTCC) $(HOSTCFLAGS) -c -o tkparse.o tkparse.c
tkcond.o: tkcond.c tkparse.h
- $(HOSTCC) $(HOSTCFLAGS) -c -o tkcond.o tkcond.c
tkgen.o: tkgen.c tkparse.h
- $(HOSTCC) $(HOSTCFLAGS) -c -o tkgen.o tkgen.c
+
+tkparse.o tkcond.o tkgen.o:
+ $(HOSTCC) $(HOSTCFLAGS) -c -o $@ $(@:.o=.c)
clean:
- rm -f *~ kconfig.tk *.o tkparse
+ rm -f *~ kconfig.tk *.o tkparse mkdep split-include
include $(TOPDIR)/Rules.make
diff --git a/scripts/Menuconfig b/scripts/Menuconfig
index 2897643ce..0679ae8cf 100644
--- a/scripts/Menuconfig
+++ b/scripts/Menuconfig
@@ -19,15 +19,31 @@
# Portions of this script were borrowed from the original Configure
# script.
#
-# Please send comments / questions / bug fixes to roadcapw@cfw.com
+# William Roadcap was the original author of Menuconfig.
+# Michael Elizabeth Chastain (mec@shout.net) is the current maintainer.
#
# 070497 Bernhard Kaindl (bkaindl@netway.at) - get default values for
# new bool, tristate and dep_tristate parameters from the defconfig file.
# new configuration parameters are marked with '(NEW)' as in make config.
+#
# 180697 Bernhard Kaindl (bkaindl@netway.at) - added the needed support
# for string options. They are handled like the int and hex options.
+#
# 081297 Pavel Machek (pavel@atrey.karlin.mff.cuni.cz) - better error
# handling
+#
+# 131197 Michael Chastain (mec@shout.net) - output all lines for a
+# choice list, not just the selected one. This makes the output
+# the same as Configure output, which is important for smart config
+# dependencies.
+#
+# 101297 Michael Chastain (mec@shout.net) - remove sound driver cruft.
+#
+# 221297 Michael Chastain (mec@shout.net) - make define_bool actually
+# define its arguments so that later tests on them work right.
+#
+# 160198 Michael Chastain (mec@shout.net) - fix bug with 'c' command
+# (complement existing value) when used on virgin uninitialized variables.
#----------------------------------------------------------------------------
@@ -96,10 +112,10 @@ function comment () {
}
#
-# Don't need this yet, but we don't want to puke either.
+# Define a boolean to a specific value.
#
function define_bool () {
- :
+ eval $1=$2
}
#
@@ -326,23 +342,6 @@ function submenu () {
}
#
-# Create a menu entry to handle the traditional sound configuration.
-#
-function soundcfg () {
- echo -ne "'l_soundcfg' "\
- "'Old configuration script "\
- "(For: SM Wave, PSS & AudioTrix Pro) -->' " >>MCmenu
-}
-
-#
-# Startup the traditional sound configuration program.
-#
-function l_soundcfg () {
- clear
- $MAKE -C drivers/sound config
-}
-
-#
# Handle a boolean (Yes/No) option.
#
function l_bool () {
@@ -354,6 +353,7 @@ function l_bool () {
case $x in
y) eval $1=n ;;
n) eval $1=y ;;
+ *) eval $1=y ;;
esac ;;
*) eval $1=n ;;
esac
@@ -397,6 +397,7 @@ As a result, this feature will be built as a module." 4 70
case $x in
m) eval $1=n ;;
n) eval $1=m ;;
+ *) eval $1=m ;;
esac ;;
*) eval $1=n ;;
esac
@@ -421,6 +422,7 @@ function l_tristate () {
y) eval $1=n ;;
n) eval $1=m ;;
m) eval $1=y ;;
+ *) eval $1=y ;;
esac ;;
*) eval $1=n ;;
esac
@@ -445,7 +447,7 @@ function l_int () {
# Semantics of + and ? in GNU expr changed, so
# we avoid them:
- if expr "$answer" : '0$\|\(-[1-9]\|[1-9]\)[0-9]*$' >/dev/null
+ if expr "$answer" : '0$\|-[1-9][0-9]*$\|[1-9][0-9]*$' >/dev/null
then
eval $2="$answer"
else
@@ -629,11 +631,6 @@ function parser(ifile,menu) {
printf("") >>menu
}
else if ($1 == "source") {
- # Yuk! Blah! Phooey!
- if ($2 ~ "drivers/sound") {
- printf("soundcfg\n") >>menu
- }
-
parser($2,menu)
}
else {
@@ -662,9 +659,6 @@ function parser(ifile,menu) {
printf("") >>menu
}
else if ($1 == "source") {
- if ($2 ~ "drivers/sound") {
- printf("soundcfg\n") >>menu
- }
parser($2,menu)
}
else {
@@ -733,9 +727,8 @@ function activate_menu () {
Menuconfig has encountered a possible error in one of the kernel's
configuration files and is unable to continue.
-Please report this to the author <roadcapw@cfw.com>. You may also
-send a problem report to linux-kernel@vger.rutgers.edu or post a
-message to the linux.dev.kernel news group.
+Please report this to the maintainer <mec@shout.net>. You may also
+send a problem report to <linux-kernel@vger.rutgers.edu>.
Please indicate the kernel version you are trying to configure and
which menu you were trying to enter when this error occurred.
@@ -795,8 +788,8 @@ the /usr/src/linux/scripts/lxdialog directory and issuing the
"make clean all" command.
If you have verified that your ncurses install is correct, you may email
-the author <roadcapw@cfw.com> or post a message on the linux.dev.kernel
-news group for additional assistance.
+the maintainer <mec@shout.net> or post a message to
+<linux-kernel@vger.rutgers.edu> for additional assistance.
EOM
cleanup
@@ -1069,11 +1062,19 @@ save_configuration () {
: ${current:=$default}
#
- # Then extract the actual option from the list of choices.
+ # Output all choices (to be compatible with other configs).
#
- current=${choices#*$current} ; set $current
-
- define_bool "$1" "y"
+ set -- $choices
+ while [ -n "$2" ]
+ do
+ if eval [ "$1" = "$current" ]
+ then
+ define_bool "$2" "y"
+ else
+ define_bool "$2" "n"
+ fi
+ shift ; shift
+ done
}
function mainmenu_name () {
@@ -1121,25 +1122,11 @@ save_configuration () {
echo " */" >>$CONFIG_H
echo "#define AUTOCONF_INCLUDED" >> $CONFIG_H
- MAKE=: #To prevent sound Makefile from running.
-
echo -n "."
if . $CONFIG_IN >>.menuconfig.log 2>&1
then
if [ "$DEF_CONFIG" = ".config" ]
then
- #
- # Create the sound driver's config files for cards
- # Which are compatible with the new config method.
- #
- if [ "_$CONFIG_TRIX" != "_y" -a\
- "_$CONFIG_PSS" != "_y" -a\
- "_$CONFIG_SMWAVE" != "_y" ]
- then
- echo -n ", sound..."
- make -C drivers/sound kernelconfig >>.menuconfig.log 2>&1
- fi
-
mv $CONFIG_H $DEF_CONFIG_H
fi
@@ -1213,7 +1200,7 @@ followed by the <SPACE BAR>.
Press <?> for additional information about this option."
inputbox_instructions_int="\
-Please enter a decimal value between 1 and 9999. \
+Please enter a decimal value. \
Fractions will not be accepted. \
Use the <TAB> key to move from the input field to the buttons below it."
@@ -1231,7 +1218,7 @@ kernel_version="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}"
backtitle="Linux Kernel v$kernel_version Configuration"
-trap "cleanup ; rm -f .menuconfig ; exit 1" 1 2 15
+trap "cleanup ; exit 1" 1 2 15
#
@@ -1261,32 +1248,6 @@ fi
echo -n "Preparing configuration scripts: version"
-#
-# Check kernel version of previous menuconfig build.
-# If it's different then we should tell the sound driver
-# to rebuild its Config.in file.
-#
-rebuildsound=TRUE
-if [ -e .menuconfig ]
-then
- read x <.menuconfig
- if [ "$x" = "# $kernel_version" ]
- then
- rebuildsound=
- fi
-fi
-
-if [ "$rebuildsound" ]
-then
- echo -n ", sound"
- # Activate the Linux compatible sound configuration.
- # This may not work for all sound cards. (See sound docs)
- #
- make -C drivers/sound mkscript kernelconfig >>.menuconfig.log 2>&1
-
- echo "# $kernel_version" >.menuconfig
-fi
-
# Load the functions used by the config.in files.
echo -n ", functions"
load_functions
diff --git a/scripts/README.Menuconfig b/scripts/README.Menuconfig
index b3ec5aaaf..5c2858996 100644
--- a/scripts/README.Menuconfig
+++ b/scripts/README.Menuconfig
@@ -188,7 +188,7 @@ is significantly different from dialog, I have left Savio's copyrights
intact. Please DO NOT contact Savio with questions about lxdialog.
He will not be able to assist.
-Please feel free to send any questions, comments or suggestions to
-William Roadcap <roadcapw@cfw.com>.
+William Roadcap was the original author of Menuconfig.
+Michael Elizabeth Chastain <mec@shout.net> is the current maintainer.
<END OF FILE>
diff --git a/scripts/checkconfig.pl b/scripts/checkconfig.pl
new file mode 100644
index 000000000..b82aa1a8b
--- /dev/null
+++ b/scripts/checkconfig.pl
@@ -0,0 +1,53 @@
+#! /usr/bin/perl
+#
+# checkconfig: find uses of CONFIG_* names without matching definitions.
+# Copyright abandoned, 1998, Michael Elizabeth Chastain <mailto:mec@shout.net>.
+
+use integer;
+
+$| = 1;
+
+foreach $file (@ARGV)
+{
+ # Open this file.
+ open(FILE, $file) || die "Can't open $file: $!\n";
+
+ # Initialize variables.
+ my $fInComment = 0;
+ my $fUseConfig = 0;
+ my $iLinuxConfig = 0;
+ my %configList = ();
+
+ LINE: while ( <FILE> )
+ {
+ # Strip comments.
+ $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
+ m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
+
+ # Pick up definitions.
+ if ( m/^#/o )
+ {
+ $iLinuxConfig = $. if m/^#\s*include\s*<linux\/config\.h>/o;
+ $configList{uc $1} = 1 if m/^#\s*include\s*<config\/(\S*)\.h>/o;
+ $configList{$1} = 1 if m/^#\s*define\s+CONFIG_(\w*)/o;
+ $configList{$1} = 1 if m/^#\s*undef\s+CONFIG_(\w*)/o;
+ }
+
+ # Look for usages.
+ next unless m/CONFIG_/o;
+ WORD: while ( m/\bCONFIG_(\w+)/og )
+ {
+ $fUseConfig = 1;
+ last LINE if $iLinuxConfig;
+ next WORD if exists $configList{$1};
+ print "$file: $.: need CONFIG_$1.\n";
+ $configList{$1} = 0;
+ }
+ }
+
+ # Report superfluous includes.
+ if ( $iLinuxConfig && ! $fUseConfig )
+ { print "$file: $iLinuxConfig: <linux/config.h> not needed.\n"; }
+
+ close(FILE);
+}
diff --git a/scripts/depend.awk b/scripts/depend.awk
deleted file mode 100644
index 93cb0ebbc..000000000
--- a/scripts/depend.awk
+++ /dev/null
@@ -1,154 +0,0 @@
-# This is an awk script which does dependencies. We do NOT want it to
-# recursively follow #include directives.
-#
-# The HPATH environment variable should be set to indicate where to look
-# for include files. The -I in front of the path is optional.
-
-#
-# Surely there is a more elegant way to see if a file exists. Anyone know
-# what it is?
-#
-function fileExists(f, TMP, dummy, result) {
- if(result=FILEHASH[f]) {
- if(result=="Yes") {
- return "Yes"
- } else {return ""}
- }
- ERRNO = getline dummy < f
- if(ERRNO >= 0) {
- close(f)
- return FILEHASH[f]="Yes"
- } else {
- FILEHASH[f]="No"
- return ""
- }
-}
-
-function endfile(f) {
- if (hasconfig && !needsconfig) {
- printf "%s doesn't need config\n",f > "/dev/stderr"
- }
- if (hasdep) {
- print cmd
- }
-}
-
-BEGIN{
- hasdep=0
- hasconfig=0
- needsconfig=0
- incomment=0
- if(!(TOPDIR=ENVIRON["TOPDIR"])) {
- print "Environment variable TOPDIR is not set"
- exit 1
- }
- split(ENVIRON["HPATH"],parray," ")
- for(path in parray) {
- sub("^-I","",parray[path])
- sub("[/ ]*$","",parray[path])
- }
-}
-
-# eliminate comments
-{
- # remove all comments fully contained on a single line
- gsub("\\/\\*.*\\*\\/", "")
- if (incomment) {
- if ($0 ~ /\*\//) {
- incomment = 0;
- gsub(".*\\*\\/", "")
- } else {
- next
- }
- } else {
- # start of multi-line comment
- if ($0 ~ /\/\*/)
- {
- incomment = 1;
- sub("\\/\\*.*", "")
- } else if ($0 ~ /\*\//) {
- incomment = 0;
- sub(".*\\*\\/", "")
- }
- }
-}
-
-/^[ ]*#[ ]*if.*[^A-Za-z_]CONFIG_/ {
- needsconfig=1
- if (!hasconfig) {
- printf "%s needs config but has not included config file\n",FILENAME > "/dev/stderr"
- # only say it once per file..
- hasconfig = 1
- }
-}
-
-/^[ ]*#[ ]*include[ ]*[<"][^ ]*[>"]/{
- found=0
- if(LASTFILE!=FILENAME) {
- endfile(LASTFILE)
- hasdep=0
- hasconfig=0
- needsconfig=0
- incomment=0
- cmd=""
- LASTFILE=FILENAME
- depname=FILENAME
- relpath=FILENAME
- sub("\\.c$",".o: ",depname)
- sub("\\.S$",".o: ",depname)
- if (depname==FILENAME) {
- cmd="\n\t@touch "depname
- }
- sub("\\.h$",".h: ",depname)
- if(relpath ~ "^\\." ) {
- sub("[^/]*$","", relpath)
- relpath=relpath"/"
- sub("//","/", relpath)
- } else {
- relpath=""
- }
- }
- fname=$0
- sub("^#[ ]*include[ ]*[<\"]","",fname)
- sub("[>\"].*","",fname)
- if (fname=="linux/config.h") {
- hasconfig=1
- }
- rfname=relpath""fname
- if(fileExists(rfname)) {
- found=1
- if (!hasdep) {
- printf "%s", depname
- }
- hasdep=1
- printf " \\\n %s", rfname
- if(fname ~ "^\\." ) {
- fnd=0;
- for(i in ARGV) {
- if(ARGV[i]==rfname) {
- fnd=1
- }
- }
- if(fnd==0) {
- ARGV[ARGC]=rfname
- ++ARGC
- }
- }
- } else {
- for(path in parray) {
- if(fileExists(parray[path]"/"fname)) {
- shortp=parray[path]
- found=1
- if (!hasdep) {
- printf "%s", depname
- }
- hasdep=1
- printf " \\\n %s", parray[path]"/"fname
- }
- }
- }
-}
-
-END{
- endfile(FILENAME)
-}
diff --git a/scripts/header.tk b/scripts/header.tk
index 54637138a..6e4a1f2cc 100644
--- a/scripts/header.tk
+++ b/scripts/header.tk
@@ -50,9 +50,6 @@ proc menu_option { w menu_num text } {
# Not used at the moment, but this runs a command in a subprocess and
# displays the result in a window with a scrollbar.
#
-# For now, we just do external "make" commands to stdout with do_make, so
-# this function is never called.
-#
proc do_cmd { w command } {
catch {destroy $w}
toplevel $w -class Dialog
@@ -209,7 +206,7 @@ proc read_config { filename } {
set cmd "global $var; set $var $value"
eval $cmd
}
- if [regexp {([0-9A-Za-z_]+)="([0-9A-Za-z]+)"} $line foo var value] {
+ if [regexp {([0-9A-Za-z_]+)="([^"]*)"} $line foo var value] {
set cmd "global $var; set $var $value"
eval $cmd
}
@@ -231,23 +228,23 @@ proc write_comment { file1 file2 text } {
proc write_tristate { file1 file2 varname variable dep } {
if { $variable == 0 } \
then { puts $file1 "# $varname is not set"; \
- puts $file2 "#undef $varname"} \
+ puts $file2 "#undef $varname"} \
elseif { $variable == 2 || ($dep == 2 && $variable == 1) } \
then { puts $file1 "$varname=m"; \
- puts $file2 "#undef $varname"; \
+ puts $file2 "#undef $varname"; \
puts $file2 "#define ${varname}_MODULE 1" } \
elseif { $variable == 1 && $dep != 2 } \
then { puts $file1 "$varname=y"; \
puts $file2 "#define $varname 1" } \
else { \
- error "Attempting to write value for variable that is not configured ($varname)." \
+ puts stdout "ERROR - Attempting to write value for unconfigured variable ($varname)." \
}
}
proc write_int { file1 file2 varname variable dep } {
if { $dep == 0 } \
then { puts $file1 "# $varname is not set"; \
- puts $file2 "#undef $varname"} \
+ puts $file2 "#undef $varname"} \
else {
puts $file1 "$varname=$variable"; \
puts $file2 "#define $varname $variable"; \
@@ -257,7 +254,7 @@ proc write_int { file1 file2 varname variable dep } {
proc write_hex { file1 file2 varname variable dep } {
if { $dep == 0 } \
then { puts $file1 "# $varname is not set"; \
- puts $file2 "#undef $varname"} \
+ puts $file2 "#undef $varname"} \
else {
puts $file1 "$varname=$variable"; \
puts $file2 "#define $varname 0x$variable"; \
@@ -267,7 +264,7 @@ proc write_hex { file1 file2 varname variable dep } {
proc write_string { file1 file2 varname variable dep } {
if { $dep == 0 } \
then { puts $file1 "# $varname is not set"; \
- puts $file2 "#undef $varname"} \
+ puts $file2 "#undef $varname"} \
else {
puts $file1 "$varname=\"$variable\""; \
puts $file2 "#define $varname \"$variable\""; \
@@ -284,7 +281,21 @@ proc option_name {w mnum line text helpidx} {
pack $w.x$line.l -side right -fill both -expand on
}
-proc toggle_switch {w mnum line text variable} {
+proc toggle_switch2 {w mnum line text variable} {
+ frame $w.x$line -relief sunken
+ radiobutton $w.x$line.y -text "y" -variable $variable -value 1 \
+ -relief groove -width 2 -command "update_menu$mnum .menu$mnum"
+ radiobutton $w.x$line.m -text "-" -variable $variable -value 2 \
+ -relief groove -width 2 -command "update_menu$mnum .menu$mnum"
+ radiobutton $w.x$line.n -text "n" -variable $variable -value 0 \
+ -relief groove -width 2 -command "update_menu$mnum .menu$mnum"
+
+ option_name $w $mnum $line $text $variable
+
+ pack $w.x$line.n $w.x$line.m $w.x$line.y -side right -fill y
+}
+
+proc toggle_switch3 {w mnum line text variable} {
frame $w.x$line -relief sunken
radiobutton $w.x$line.y -text "y" -variable $variable -value 1 \
-relief groove -width 2 -command "update_menu$mnum .menu$mnum"
@@ -299,13 +310,13 @@ proc toggle_switch {w mnum line text variable} {
}
proc bool {w mnum line text variable} {
- toggle_switch $w $mnum $line $text $variable
+ toggle_switch2 $w $mnum $line $text $variable
$w.x$line.m configure -state disabled
pack $w.x$line -anchor w -fill both -expand on
}
proc tristate {w mnum line text variable } {
- toggle_switch $w $mnum $line $text $variable
+ toggle_switch3 $w $mnum $line $text $variable
pack $w.x$line -anchor w -fill both -expand on
}
@@ -339,7 +350,7 @@ proc minimenu { w mnum line text variable helpidx } {
frame $w.x$line
menubutton $w.x$line.x -textvariable $variable -menu \
$w.x$line.x.menu -relief raised \
- -width 15 -anchor w
+ -anchor w
option_name $w $mnum $line $text $helpidx
pack $w.x$line.x -anchor w -side right -fill y
pack $w.x$line -anchor w -fill both -expand on
@@ -349,11 +360,6 @@ proc comment {w line text } {
#nothing done for comments now.
}
-proc do_make { command } {
- exec sh -c $command <@stdin >@stdout 2>@stderr
-# do_cmd .make_window "sh -c $command"
-}
-
proc dohelp {w var } {
catch {destroy $w}
toplevel $w -class Dialog
@@ -443,15 +449,6 @@ proc wrapup {w } {
}
-proc check_sound_config { num } {
-#nothing for now.
-}
-
-proc do_sound {w mnum line} {
- message $w.x$line -width 400 -aspect 300 -text "Note: The sound drivers cannot as of yet be configured via the X-based interface" -relief raised
- pack $w.x$line -side top -pady 10
-}
-
#
# Next set up the particulars for the top level menu, and define a few
# buttons which we will stick down at the bottom.
diff --git a/scripts/hfiles.sh b/scripts/hfiles.sh
deleted file mode 100644
index 4643194c8..000000000
--- a/scripts/hfiles.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-#
-# This script looks to see if a directory contains .h files
-#
-for dir in $@; do
- for hfile in $dir/*.h; do
- if [ -f $hfile ]; then echo $dir; fi
- break
- done
-done
-exit 0
diff --git a/scripts/lxdialog/checklist.c b/scripts/lxdialog/checklist.c
index b986b3a2e..ad6102070 100644
--- a/scripts/lxdialog/checklist.c
+++ b/scripts/lxdialog/checklist.c
@@ -188,9 +188,16 @@ dialog_checklist (const char *title, const char *prompt, int height, int width,
check_x = (list_width - check_x) / 2;
item_x = check_x + 4;
+ if (choice >= list_height) {
+ scroll = choice - list_height + 1;
+ choice -= scroll;
+ }
+
/* Print the list */
- for (i = 0; i < max_choice; i++)
- print_item (list, items[i * 3 + 1], status[i], i, i == choice);
+ for (i = 0; i < max_choice; i++) {
+ print_item (list, items[(scroll+i) * 3 + 1],
+ status[i+scroll], i, i == choice);
+ }
wnoutrefresh (list);
diff --git a/scripts/lxdialog/lxdialog.c b/scripts/lxdialog/lxdialog.c
index 94d75ded6..33f99fb09 100644
--- a/scripts/lxdialog/lxdialog.c
+++ b/scripts/lxdialog/lxdialog.c
@@ -158,7 +158,7 @@ Usage (const char *name)
\n --textbox <file> <height> <width>\
\n --inputbox <text> <height> <width> [<init>]\
\n --yesno <text> <height> <width>\
-", name, name);
+\n", name, name);
exit (-1);
}
diff --git a/scripts/mkdep.c b/scripts/mkdep.c
index 6eef92f74..c08eafad7 100644
--- a/scripts/mkdep.c
+++ b/scripts/mkdep.c
@@ -1,22 +1,33 @@
+/*
+ * Originally by Linus Torvalds.
+ * Smart CONFIG_* processing by Werner Almesberger, Michael Chastain.
+ *
+ * Usage: mkdep file ...
+ *
+ * Read source files and output makefile dependency lines for them.
+ * I make simple dependency lines for #include <*.h> and #include "*.h".
+ * I also find instances of CONFIG_FOO and generate dependencies
+ * like include/config/foo.h.
+ */
+
+#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
-
-#include <errno.h>
#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include <unistd.h>
+
#include <sys/fcntl.h>
#include <sys/mman.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#ifndef MAP_AUTOGROW
#define MAP_AUTOGROW 0
#endif
-char *filename, *command, __depname[256] = "\n\t@touch ";
-int needsconfig, hasconfig, hasmodules, hasdep;
-
+char __depname[512] = "\n\t@touch ";
#define depname (__depname+9)
+int hasdep;
struct path_struct {
int len;
@@ -26,22 +37,113 @@ struct path_struct {
{ 0, "" }
};
-static void handle_include(int type, char *name, int len)
+
+
+/*
+ * This records all the configuration options seen.
+ * In perl this would be a hash, but here it's a long string
+ * of values separated by newlines. This is simple and
+ * extremely fast.
+ */
+char * str_config = NULL;
+int size_config = 0;
+int len_config = 0;
+
+
+
+/*
+ * Grow the configuration string to a desired length.
+ * Usually the first growth is plenty.
+ */
+void grow_config(int len)
+{
+ if (str_config == NULL) {
+ len_config = 0;
+ size_config = 4096;
+ str_config = malloc(4096);
+ if (str_config == NULL)
+ { perror("malloc"); exit(1); }
+ }
+
+ while (len_config + len > size_config) {
+ str_config = realloc(str_config, size_config *= 2);
+ if (str_config == NULL)
+ { perror("malloc"); exit(1); }
+ }
+}
+
+
+
+/*
+ * Lookup a value in the configuration string.
+ */
+int is_defined_config(const char * name, int len)
+{
+ const char * pconfig;
+ const char * plast = str_config + len_config - len;
+ for ( pconfig = str_config + 1; pconfig < plast; pconfig++ ) {
+ if (pconfig[ -1] == '\n'
+ && pconfig[len] == '\n'
+ && !memcmp(pconfig, name, len))
+ return 1;
+ }
+ return 0;
+}
+
+
+
+/*
+ * Add a new value to the configuration string.
+ */
+void define_config(int convert, const char * name, int len)
+{
+ grow_config(len + 1);
+
+ memcpy(str_config+len_config, name, len);
+
+ if (convert) {
+ int i;
+ for (i = 0; i < len; i++) {
+ char c = str_config[len_config+i];
+ if (isupper(c)) c = tolower(c);
+ if (c == '_') c = '/';
+ str_config[len_config+i] = c;
+ }
+ }
+
+ len_config += len;
+ str_config[len_config++] = '\n';
+}
+
+
+
+/*
+ * Clear the set of configuration strings.
+ */
+void clear_config( )
+{
+ len_config = 0;
+ define_config(0, "", 0);
+}
+
+
+
+/*
+ * Handle an #include line.
+ */
+void handle_include(int type, const char * name, int len)
{
- int plen;
struct path_struct *path = path_array+type;
- if (len == 14)
- if (!memcmp(name, "linux/config.h", len))
- hasconfig = 1;
- else if (!memcmp(name, "linux/module.h", len))
- hasmodules = 1;
-
- plen = path->len;
- memcpy(path->buffer+plen, name, len);
- len += plen;
- path->buffer[len] = '\0';
- if (access(path->buffer, F_OK))
+ if (len == 14 && !memcmp(name, "linux/config.h", len))
+ return;
+
+ if (len >= 7 && !memcmp(name, "config/", 7))
+ define_config(0, name+7, len-7-2);
+
+ memcpy(path->buffer+path->len, name, len);
+ path->buffer[path->len+len] = '\0';
+ if (access(path->buffer, F_OK) != 0)
return;
if (!hasdep) {
@@ -51,15 +153,48 @@ static void handle_include(int type, char *name, int len)
printf(" \\\n %s", path->buffer);
}
-static void handle_config(void)
+
+
+/*
+ * Record the use of a CONFIG_* word.
+ */
+void use_config(const char * name, int len)
{
- needsconfig = 1;
- if (!hasconfig)
- fprintf(stderr,
- "%s needs config but has not included config file\n",
- filename);
+ char *pc;
+ int i;
+
+ pc = path_array[0].buffer + path_array[0].len;
+ memcpy(pc, "config/", 7);
+ pc += 7;
+
+ for (i = 0; i < len; i++) {
+ char c = name[i];
+ if (isupper(c)) c = tolower(c);
+ if (c == '_') c = '/';
+ pc[i] = c;
+ }
+ pc[len] = '\0';
+
+ if (is_defined_config(pc, len))
+ return;
+
+ define_config(0, pc, len);
+
+ if (!hasdep) {
+ hasdep = 1;
+ printf("%s: ", depname);
+ }
+ printf(" \\\n $(wildcard %s.h)", path_array[0].buffer);
}
+
+
+/*
+ * Macros for stunningly fast map-based character access.
+ * __buf is a register which holds the current word of the input.
+ * Thus, there is one memory access per sizeof(unsigned long) characters.
+ */
+
#if defined(__alpha__) || defined(__i386__) || defined(__MIPSEL__)
#define LE_MACHINE
#endif
@@ -73,243 +208,283 @@ static void handle_config(void)
#endif
#define GETNEXT { \
-next_byte(__buf); \
-if (!__nrbuf) { \
- __buf = *(unsigned long *) next; \
- __nrbuf = sizeof(unsigned long); \
- if (!__buf) \
- break; \
-} next++; __nrbuf--; }
+ next_byte(__buf); \
+ if ((unsigned long) next % sizeof(unsigned long) == 0) { \
+ __buf = * (unsigned long *) next; \
+ if (!__buf) \
+ break; \
+ } \
+ next++; \
+}
+
+/*
+ * State machine macros.
+ */
#define CASE(c,label) if (current == c) goto label
#define NOTCASE(c,label) if (current != c) goto label
-static void state_machine(register char *next)
+/*
+ * Yet another state machine speedup.
+ */
+#define MAX2(a,b) ((a)>(b)?(a):(b))
+#define MIN2(a,b) ((a)<(b)?(a):(b))
+#define MAX5(a,b,c,d,e) (MAX2(a,MAX2(b,MAX2(c,MAX2(d,e)))))
+#define MIN5(a,b,c,d,e) (MIN2(a,MIN2(b,MIN2(c,MIN2(d,e)))))
+
+
+
+/*
+ * The state machine looks for (approximately) these Perl regular expressions:
+ *
+ * m|\/\*.*?\*\/|
+ * m|'.*?'|
+ * m|".*?"|
+ * m|#\s*include\s*"(.*?)"|
+ * m|#\s*include\s*<(.*?>"|
+ * m|#\s*(?define|undef)\s*CONFIG_(\w*)|
+ * m|(?!\w)CONFIG_|
+ *
+ * About 98% of the CPU time is spent here, and most of that is in
+ * the 'start' paragraph. Because the current characters are
+ * in a register, the start loop usually eats 4 or 8 characters
+ * per memory read. The MAX5 and MIN5 tests dispose of most
+ * input characters with 1 or 2 comparisons.
+ */
+void state_machine(const char * map)
{
- for(;;) {
- register unsigned long __buf = 0;
- register unsigned long __nrbuf = 0;
+ const char * next = map;
+ const char * map_dot;
+ unsigned long __buf = 0;
-normal:
+ for (;;) {
+start:
GETNEXT
-__normal:
- CASE('/',slash);
- CASE('"',string);
- CASE('\'',char_const);
- CASE('#',preproc);
- goto normal;
-
+__start:
+ if (current > MAX5('/','\'','"','#','C')) goto start;
+ if (current < MIN5('/','\'','"','#','C')) goto start;
+ CASE('/', slash);
+ CASE('\'', squote);
+ CASE('"', dquote);
+ CASE('#', pound);
+ CASE('C', cee);
+ goto start;
+
+/* / */
slash:
GETNEXT
- CASE('*',comment);
- goto __normal;
-
-string:
+ NOTCASE('*', __start);
+slash_star_dot_star:
GETNEXT
- CASE('"',normal);
- NOTCASE('\\',string);
+__slash_star_dot_star:
+ NOTCASE('*', slash_star_dot_star);
GETNEXT
- goto string;
+ NOTCASE('/', __slash_star_dot_star);
+ goto start;
-char_const:
+/* '.*?' */
+squote:
GETNEXT
- CASE('\'',normal);
- NOTCASE('\\',char_const);
+ CASE('\'', start);
+ NOTCASE('\\', squote);
GETNEXT
- goto char_const;
+ goto squote;
-comment:
+/* ".*?" */
+dquote:
GETNEXT
-__comment:
- NOTCASE('*',comment);
+ CASE('"', start);
+ NOTCASE('\\', dquote);
GETNEXT
- CASE('/',normal);
- goto __comment;
+ goto dquote;
-preproc:
+/* #\s* */
+pound:
GETNEXT
- CASE('\n',normal);
- CASE(' ',preproc);
- CASE('\t',preproc);
- CASE('i',i_preproc);
- CASE('e',e_preproc);
+ CASE(' ', pound);
+ CASE('\t', pound);
+ CASE('i', pound_i);
+ CASE('d', pound_d);
+ CASE('u', pound_u);
+ goto __start;
+
+/* #\s*i */
+pound_i:
+ GETNEXT NOTCASE('n', __start);
+ GETNEXT NOTCASE('c', __start);
+ GETNEXT NOTCASE('l', __start);
+ GETNEXT NOTCASE('u', __start);
+ GETNEXT NOTCASE('d', __start);
+ GETNEXT NOTCASE('e', __start);
+ goto pound_include;
+
+/* #\s*include\s* */
+pound_include:
GETNEXT
-
-skippreproc:
- CASE('\n',normal);
- CASE('\\',skippreprocslash);
+ CASE(' ', pound_include);
+ CASE('\t', pound_include);
+ map_dot = next;
+ CASE('"', pound_include_dquote);
+ CASE('<', pound_include_langle);
+ goto __start;
+
+/* #\s*include\s*"(.*)" */
+pound_include_dquote:
GETNEXT
- goto skippreproc;
-
-skippreprocslash:
- GETNEXT;
- GETNEXT;
- goto skippreproc;
+ CASE('\n', start);
+ NOTCASE('"', pound_include_dquote);
+ handle_include(1, map_dot, next - map_dot - 1);
+ goto start;
-e_preproc:
+/* #\s*include\s*<(.*)> */
+pound_include_langle:
GETNEXT
- NOTCASE('l',skippreproc);
+ CASE('\n', start);
+ NOTCASE('>', pound_include_langle);
+ handle_include(0, map_dot, next - map_dot - 1);
+ goto start;
+
+/* #\s*d */
+pound_d:
+ GETNEXT NOTCASE('e', __start);
+ GETNEXT NOTCASE('f', __start);
+ GETNEXT NOTCASE('i', __start);
+ GETNEXT NOTCASE('n', __start);
+ GETNEXT NOTCASE('e', __start);
+ goto pound_define_undef;
+
+/* #\s*u */
+pound_u:
+ GETNEXT NOTCASE('n', __start);
+ GETNEXT NOTCASE('d', __start);
+ GETNEXT NOTCASE('e', __start);
+ GETNEXT NOTCASE('f', __start);
+ goto pound_define_undef;
+
+/* #\s*(define|undef)\s*CONFIG_(\w*) */
+pound_define_undef:
GETNEXT
- NOTCASE('i',skippreproc);
+ CASE(' ', pound_define_undef);
+ CASE('\t', pound_define_undef);
+
+ NOTCASE('C', __start);
+ GETNEXT NOTCASE('O', __start);
+ GETNEXT NOTCASE('N', __start);
+ GETNEXT NOTCASE('F', __start);
+ GETNEXT NOTCASE('I', __start);
+ GETNEXT NOTCASE('G', __start);
+ GETNEXT NOTCASE('_', __start);
+
+ map_dot = next;
+pound_define_undef_CONFIG_word:
GETNEXT
- CASE('f',if_line);
- goto skippreproc;
-
-i_preproc:
- GETNEXT
- CASE('f',if_line);
- NOTCASE('n',skippreproc);
- GETNEXT
- NOTCASE('c',skippreproc);
- GETNEXT
- NOTCASE('l',skippreproc);
- GETNEXT
- NOTCASE('u',skippreproc);
- GETNEXT
- NOTCASE('d',skippreproc);
- GETNEXT
- NOTCASE('e',skippreproc);
-
-/* "# include" found */
-include_line:
- GETNEXT
- CASE('\n',normal);
- CASE('<', std_include_file);
- NOTCASE('"', include_line);
-
-/* "local" include file */
-{
- char *incname = next;
-local_include_name:
- GETNEXT
- CASE('\n',normal);
- NOTCASE('"', local_include_name);
- handle_include(1, incname, next-incname-1);
- goto skippreproc;
-}
-
-/* <std> include file */
-std_include_file:
-{
- char *incname = next;
-std_include_name:
+ if (isalnum(current) || current == '_')
+ goto pound_define_undef_CONFIG_word;
+ define_config(1, map_dot, next - map_dot - 1);
+ goto __start;
+
+/* \<CONFIG_(\w*) */
+cee:
+ if (next >= map+2 && (isalnum(next[-2]) || next[-2] == '_'))
+ goto start;
+ GETNEXT NOTCASE('O', __start);
+ GETNEXT NOTCASE('N', __start);
+ GETNEXT NOTCASE('F', __start);
+ GETNEXT NOTCASE('I', __start);
+ GETNEXT NOTCASE('G', __start);
+ GETNEXT NOTCASE('_', __start);
+
+ map_dot = next;
+cee_CONFIG_word:
GETNEXT
- CASE('\n',normal);
- NOTCASE('>', std_include_name);
- handle_include(0, incname, next-incname-1);
- goto skippreproc;
+ if (isalnum(current) || current == '_')
+ goto cee_CONFIG_word;
+ use_config(map_dot, next - map_dot - 1);
+ goto __start;
+ }
}
-if_line:
- if (needsconfig)
- goto skippreproc;
-if_start:
- GETNEXT
- CASE('C', config);
- CASE('\n', normal);
- CASE('_', if_middle);
- if (current >= 'a' && current <= 'z')
- goto if_middle;
- if (current < 'A' || current > 'Z')
- goto if_start;
-config:
- GETNEXT
- NOTCASE('O', __if_middle);
- GETNEXT
- NOTCASE('N', __if_middle);
- GETNEXT
- NOTCASE('F', __if_middle);
- GETNEXT
- NOTCASE('I', __if_middle);
- GETNEXT
- NOTCASE('G', __if_middle);
- GETNEXT
- NOTCASE('_', __if_middle);
- handle_config();
- goto skippreproc;
-if_middle:
- GETNEXT
-__if_middle:
- CASE('\n', normal);
- CASE('_', if_middle);
- if (current >= 'a' && current <= 'z')
- goto if_middle;
- if (current < 'A' || current > 'Z')
- goto if_start;
- goto if_middle;
- }
-}
-static void do_depend(void)
+/*
+ * Generate dependencies for one file.
+ */
+void do_depend(const char * filename, const char * command)
{
- char *map;
int mapsize;
int pagesizem1 = getpagesize()-1;
- int fd = open(filename, O_RDONLY);
+ int fd;
struct stat st;
+ char * map;
+ fd = open(filename, O_RDONLY);
if (fd < 0) {
- if (errno != ENOENT)
- perror(filename);
+ perror(filename);
return;
}
+
fstat(fd, &st);
if (st.st_size == 0) {
fprintf(stderr,"%s is empty\n",filename);
+ close(fd);
return;
}
+
mapsize = st.st_size + 2*sizeof(unsigned long);
mapsize = (mapsize+pagesizem1) & ~pagesizem1;
map = mmap(NULL, mapsize, PROT_READ, MAP_AUTOGROW | MAP_PRIVATE, fd, 0);
- if (-1 == (long)map) {
+ if ((long) map == -1) {
perror("mkdep: mmap");
close(fd);
return;
}
- close(fd);
+ if ((unsigned long) map % sizeof(unsigned long) != 0)
+ {
+ fprintf(stderr, "do_depend: map not aligned\n");
+ exit(1);
+ }
+
+ hasdep = 0;
+ clear_config();
state_machine(map);
- munmap(map, mapsize);
if (hasdep)
puts(command);
+
+ munmap(map, mapsize);
+ close(fd);
}
+
+
+/*
+ * Generate dependencies for all files.
+ */
int main(int argc, char **argv)
{
int len;
- char * hpath;
+ char *hpath;
hpath = getenv("HPATH");
if (!hpath)
hpath = "/usr/src/linux/include";
len = strlen(hpath);
memcpy(path_array[0].buffer, hpath, len);
- if (len && hpath[len-1] != '/') {
- path_array[0].buffer[len] = '/';
- len++;
- }
+ if (len && hpath[len-1] != '/')
+ path_array[0].buffer[len++] = '/';
path_array[0].buffer[len] = '\0';
path_array[0].len = len;
while (--argc > 0) {
- int len;
- char *name = *++argv;
-
- filename = name;
- len = strlen(name);
- memcpy(depname, name, len+1);
- command = __depname;
- if (len > 2 && name[len-2] == '.') {
- switch (name[len-1]) {
- case 'c':
- case 'S':
- depname[len-1] = 'o';
- command = "";
+ const char * filename = *++argv;
+ const char * command = __depname;
+ len = strlen(filename);
+ memcpy(depname, filename, len+1);
+ if (len > 2 && filename[len-2] == '.') {
+ if (filename[len-1] == 'c' || filename[len-1] == 'S') {
+ depname[len-1] = 'o';
+ command = "";
}
}
- needsconfig = hasconfig = hasmodules = hasdep = 0;
- do_depend();
- if (hasconfig && !hasmodules && !needsconfig)
- fprintf(stderr, "%s doesn't need config\n", filename);
+ do_depend(filename, command);
}
return 0;
}
diff --git a/scripts/patch-kernel b/scripts/patch-kernel
index 2028efcbc..f5abe4440 100644
--- a/scripts/patch-kernel
+++ b/scripts/patch-kernel
@@ -11,6 +11,11 @@
# successful. If it is, then all of the "*.orig" files are removed.
#
# Nick Holloway <Nick.Holloway@alfie.demon.co.uk>, 2nd January 1995.
+#
+# Added support for handling multiple types of compression. What includes
+# gzip, bzip, bzip2, zip, compress, and plaintext.
+#
+# Adam Sulmicki <adam@cfar.umd.edu>, 1st January 1997.
# Set directories from arguments, or use defaults.
sourcedir=${1-/usr/src/linux}
@@ -29,16 +34,39 @@ echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL"
while :
do
SUBLEVEL=`expr $SUBLEVEL + 1`
- patch=patch-$VERSION.$PATCHLEVEL.$SUBLEVEL.gz
- if [ ! -r $patchdir/$patch ]
- then
- break
+ patch=patch-$VERSION.$PATCHLEVEL.$SUBLEVEL
+ if [ -r $patchdir/${patch}.gz ]; then
+ ext=".gz"
+ name="gzip"
+ uncomp="gunzip -dc"
+ elif [ -r $patchdir/${patch}.bz ]; then
+ ext=".bz"
+ name="bzip"
+ uncomp="bunzip -dc"
+ elif [ -r $patchdir/${patch}.bz2 ]; then
+ ext=".bz2"
+ name="bzip2"
+ uncomp="bunzip2 -dc"
+ elif [ -r $patchdir/${patch}.zip ]; then
+ ext=".zip"
+ name="zip"
+ uncomp="unzip -d"
+ elif [ -r $patchdir/${patch}.Z ]; then
+ ext=".Z"
+ name="uncompress"
+ uncomp="uncompress -c"
+ elif [ -r $patchdir/${patch} ]; then
+ ext=""
+ name="plaintext"
+ uncomp="cat"
+ else
+ break
fi
- echo -n "Applying $patch... "
- if gunzip -dc $patchdir/$patch | patch -p1 -s -N -E -d $sourcedir
+ echo -n "Applying ${patch} (${name})... "
+ if $uncomp ${patchdir}/${patch}${ext} | patch -p1 -s -N -E -d $sourcedir
then
- echo "done."
+ echo "done."
else
echo "failed. Clean up yourself."
break
diff --git a/scripts/split-include.c b/scripts/split-include.c
new file mode 100644
index 000000000..4c02cc897
--- /dev/null
+++ b/scripts/split-include.c
@@ -0,0 +1,226 @@
+/*
+ * split-include.c
+ *
+ * Copyright abandoned, Michael Chastain, <mailto:mec@shout.net>.
+ * This is a C version of syncdep.pl by Werner Almesberger.
+ *
+ * This program takes autoconf.h as input and outputs a directory full
+ * of one-line include files, merging onto the old values.
+ *
+ * Think of the configuration options as key-value pairs. Then there
+ * are five cases:
+ *
+ * key old value new value action
+ *
+ * KEY-1 VALUE-1 VALUE-1 leave file alone
+ * KEY-2 VALUE-2A VALUE-2B write VALUE-2B into file
+ * KEY-3 - VALUE-3 write VALUE-3 into file
+ * KEY-4 VALUE-4 - write an empty file
+ * KEY-5 (empty) - leave old empty file alone
+ */
+
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define ERROR_EXIT(strExit) \
+ { \
+ const int errnoSave = errno; \
+ fprintf(stderr, "%s: ", str_my_name); \
+ errno = errnoSave; \
+ perror((strExit)); \
+ exit(1); \
+ }
+
+
+
+int main(int argc, const char * argv [])
+{
+ const char * str_my_name;
+ const char * str_file_autoconf;
+ const char * str_dir_config;
+
+ FILE * fp_config;
+ FILE * fp_target;
+ FILE * fp_find;
+
+ int buffer_size;
+
+ char * line;
+ char * old_line;
+ char * list_target;
+ char * ptarget;
+
+ struct stat stat_buf;
+
+ /* Check arg count. */
+ if (argc != 3)
+ {
+ fprintf(stderr, "%s: wrong number of arguments.\n", argv[0]);
+ exit(1);
+ }
+
+ str_my_name = argv[0];
+ str_file_autoconf = argv[1];
+ str_dir_config = argv[2];
+
+ /* Find a buffer size. */
+ if (stat(str_file_autoconf, &stat_buf) != 0)
+ ERROR_EXIT(str_file_autoconf);
+ buffer_size = 2 * stat_buf.st_size + 4096;
+
+ /* Allocate buffers. */
+ if ( (line = malloc(buffer_size)) == NULL
+ || (old_line = malloc(buffer_size)) == NULL
+ || (list_target = malloc(buffer_size)) == NULL )
+ ERROR_EXIT(str_file_autoconf);
+
+ /* Open autoconfig file. */
+ if ((fp_config = fopen(str_file_autoconf, "r")) == NULL)
+ ERROR_EXIT(str_file_autoconf);
+
+ /* Make output directory if needed. */
+ if (stat(str_dir_config, &stat_buf) != 0)
+ {
+ if (mkdir(str_dir_config, 0755) != 0)
+ ERROR_EXIT(str_dir_config);
+ }
+
+ /* Change to output directory. */
+ if (chdir(str_dir_config) != 0)
+ ERROR_EXIT(str_dir_config);
+
+ /* Put initial separator into target list. */
+ ptarget = list_target;
+ *ptarget++ = '\n';
+
+ /* Read config lines. */
+ while (fgets(line, buffer_size, fp_config))
+ {
+ const char * str_config;
+ int is_same;
+ int itarget;
+
+ if (line[0] != '#')
+ continue;
+ if ((str_config = strstr(line, "CONFIG_")) == NULL)
+ continue;
+
+ /* Make the output file name. */
+ str_config += sizeof("CONFIG_") - 1;
+ for (itarget = 0; !isspace(str_config[itarget]); itarget++)
+ {
+ char c = str_config[itarget];
+ if (isupper(c)) c = tolower(c);
+ if (c == '_') c = '/';
+ ptarget[itarget] = c;
+ }
+ ptarget[itarget++] = '.';
+ ptarget[itarget++] = 'h';
+ ptarget[itarget++] = '\0';
+
+ /* Check for existing file. */
+ is_same = 0;
+ if ((fp_target = fopen(ptarget, "r")) != NULL)
+ {
+ fgets(old_line, buffer_size, fp_target);
+ if (fclose(fp_target) != 0)
+ ERROR_EXIT(ptarget);
+ if (!strcmp(line, old_line))
+ is_same = 1;
+ }
+
+ if (!is_same)
+ {
+ /* Auto-create directories. */
+ int islash;
+ for (islash = 0; islash < itarget; islash++)
+ {
+ if (ptarget[islash] == '/')
+ {
+ ptarget[islash] = '\0';
+ if (stat(ptarget, &stat_buf) != 0
+ && mkdir(ptarget, 0755) != 0)
+ ERROR_EXIT( ptarget );
+ ptarget[islash] = '/';
+ }
+ }
+
+ /* Write the file. */
+ if ((fp_target = fopen(ptarget, "w" )) == NULL)
+ ERROR_EXIT(ptarget);
+ fputs(line, fp_target);
+ if (ferror(fp_target) || fclose(fp_target) != 0)
+ ERROR_EXIT(ptarget);
+ }
+
+ /* Update target list */
+ ptarget += itarget;
+ *(ptarget-1) = '\n';
+ }
+
+ /*
+ * Close autoconfig file.
+ * Terminate the target list.
+ */
+ if (fclose(fp_config) != 0)
+ ERROR_EXIT(str_file_autoconf);
+ *ptarget = '\0';
+
+ /*
+ * Fix up existing files which have no new value.
+ * This is Case 4 and Case 5.
+ *
+ * I re-read the tree and filter it against list_target.
+ * This is crude. But it avoids data copies. Also, list_target
+ * is compact and contiguous, so it easily fits into cache.
+ *
+ * Notice that list_target contains strings separated by \n,
+ * with a \n before the first string and after the last.
+ * fgets gives the incoming names a terminating \n.
+ * So by having an initial \n, strstr will find exact matches.
+ */
+
+ fp_find = popen("find * -type f -print", "r");
+ if (fp_find == 0)
+ ERROR_EXIT( "find" );
+
+ line[0] = '\n';
+ while (fgets(line+1, buffer_size, fp_find))
+ {
+ if (strstr(list_target, line) == NULL)
+ {
+ /*
+ * This is an old file with no CONFIG_* flag in autoconf.h.
+ */
+
+ /* First strip the \n. */
+ line[strlen(line)-1] = '\0';
+
+ /* Grab size. */
+ if (stat(line+1, &stat_buf) != 0)
+ ERROR_EXIT(line);
+
+ /* If file is not empty, make it empty and give it a fresh date. */
+ if (stat_buf.st_size != 0)
+ {
+ if ((fp_target = fopen(line+1, "w")) == NULL)
+ ERROR_EXIT(line);
+ if (fclose(fp_target) != 0)
+ ERROR_EXIT(line);
+ }
+ }
+ }
+
+ if (pclose(fp_find) != 0)
+ ERROR_EXIT("find");
+
+ return 0;
+}
diff --git a/scripts/tkcond.c b/scripts/tkcond.c
index 41b370f43..58bb072ff 100644
--- a/scripts/tkcond.c
+++ b/scripts/tkcond.c
@@ -101,7 +101,7 @@ void fix_choice_cond()
struct condition * cond;
struct condition * cond2;
struct kconfig * cfg;
- char tmpbuf[10];
+ char tmpbuf[255];
for(cfg = config;cfg != NULL; cfg = cfg->next)
{
@@ -361,7 +361,6 @@ void fix_conditionals(struct kconfig * scfg)
case tok_hex:
case tok_string:
case tok_choice:
- case tok_make:
/*
* We need to duplicate the chain of conditions and attach them to
* this token.
diff --git a/scripts/tkgen.c b/scripts/tkgen.c
index 15f8f7bfd..dcf025e2e 100644
--- a/scripts/tkgen.c
+++ b/scripts/tkgen.c
@@ -50,6 +50,17 @@
* Avery Pennarun - Reduced flicker when creating windows, even with "update
* idletasks" hack.
*
+ * 1997 12 08
+ * Michael Chastain - Remove sound driver special cases.
+ *
+ * 1997 11 15
+ * Michael Chastain - For choice buttons, write values for all options,
+ * not just the single chosen one. This is compatible
+ * with 'make config' and 'make oldconfig', and is
+ * needed so smart-config dependencies work if the
+ * user switches from one configuration method to
+ * another.
+ *
* TO DO:
* - clean up - there are useless ifdef's everywhere.
* - better comments throughout - C code generating tcl is really cryptic.
@@ -492,9 +503,6 @@ void generate_if_for_outfile(struct kconfig * item,
printf("} then { write_string $cfg $autocfg %s $%s $notmod }\n",
item->optionname, item->optionname);
break;
- case tok_make:
- printf("} then { do_make {%s} }\n",item->value);
- break;
case tok_choose:
case tok_choice:
fprintf(stderr,"Fixme\n");
@@ -677,7 +685,7 @@ void dump_tk_script(struct kconfig *scfg)
int menu_maxlines = 0;
struct kconfig * cfg;
struct kconfig * cfg1 = NULL;
- char * menulabel;
+ char * menulabel = "tkgen error";
/*
* Start by assigning menu numbers, and submenu numbers.
@@ -893,25 +901,6 @@ void dump_tk_script(struct kconfig *scfg)
*/
end_proc(menu_num);
-#ifdef ERIC_DONT_DEF
- /*
- * Generate the code for configuring the sound driver. Right now this
- * cannot be done from the X script, but we insert the menu anyways.
- */
- start_proc("Configure sound driver", ++menu_num, TRUE);
-#if 0
- printf("\tdo_make -C drivers/sound config\n");
- printf("\techo check_sound_config %d\n",menu_num);
-#endif
- printf("\tlabel $w.config.f.m0 -bitmap error\n");
- printf("\tmessage $w.config.f.m1 -width 400 -aspect 300 -text \"The sound drivers cannot as of yet be configured via the X-based interface\" -relief raised\n");
- printf("\tpack $w.config.f.m0 $w.config.f.m1 -side top -pady 10 -expand on\n");
- /*
- * Close out the last menu.
- */
- end_proc(menu_num);
-#endif
-
/*
* The top level menu also needs an update function. When we exit a
* submenu, we may need to disable one or more of the submenus on
@@ -1018,7 +1007,6 @@ void dump_tk_script(struct kconfig *scfg)
printf("\tglobal %s\n", cfg->optionname);
}
/* fall through */
- case tok_make:
case tok_comment:
if (cfg->cond != NULL )
generate_if_for_outfile(cfg, cfg->cond);
@@ -1054,9 +1042,10 @@ void dump_tk_script(struct kconfig *scfg)
cfg1 != NULL && cfg1->tok == tok_choice;
cfg1 = cfg1->next)
{
- printf("\tif { $%s == \"%s\" } then { write_tristate $cfg $autocfg %s 1 $notmod }\n",
+ printf("\tif { $%s == \"%s\" } then { write_tristate $cfg $autocfg %s 1 $notmod } else { write_tristate $cfg $autocfg %s 0 $notmod }\n",
cfg->optionname,
cfg1->label,
+ cfg1->optionname,
cfg1->optionname);
}
}
@@ -1078,10 +1067,6 @@ void dump_tk_script(struct kconfig *scfg)
cfg->optionname,
cfg->optionname);
}
- else if (cfg->tok == tok_make )
- {
- printf("\tdo_make {%s}\n",cfg->value);
- }
else
{
printf("\twrite_tristate $cfg $autocfg %s $%s $notmod\n",
diff --git a/scripts/tkparse.c b/scripts/tkparse.c
index 98d1393ca..f91d0f355 100644
--- a/scripts/tkparse.c
+++ b/scripts/tkparse.c
@@ -326,10 +326,6 @@ void parse(char * pnt) {
tok = tok_menuoption;
pnt += 15;
}
- else if (strncmp(pnt, "$MAKE ", 6) == 0)
- {
- tok = tok_make;
- }
else if (strncmp(pnt, "comment", 7) == 0)
{
tok = tok_comment;
@@ -513,9 +509,6 @@ void parse(char * pnt) {
pnt = get_qstring(pnt, &kcfg->label);
}
break;
- case tok_make:
- kcfg->value=strdup(pnt);
- break;
case tok_else:
case tok_fi:
case tok_endmenu:
@@ -585,7 +578,7 @@ static int do_source(char * filename)
char buffer[1024];
int offset;
int old_lineno;
- char * old_file;
+ char * old_file = 0; /* superfluous, just for gcc */
char * pnt;
FILE * infile;
diff --git a/scripts/tkparse.h b/scripts/tkparse.h
index af7beac93..523ba7131 100644
--- a/scripts/tkparse.h
+++ b/scripts/tkparse.h
@@ -13,7 +13,6 @@ enum token {
tok_int,
tok_hex,
tok_string,
- tok_make,
tok_define,
tok_choose,
tok_choice,