diff options
Diffstat (limited to 'libc/Config_sh')
-rw-r--r-- | libc/Config_sh | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/libc/Config_sh b/libc/Config_sh new file mode 100644 index 0000000..6c93784 --- /dev/null +++ b/libc/Config_sh @@ -0,0 +1,145 @@ +#!/bin/sh - +# Copyright (C) 1996 Robert de Bath <rdebath@cix.compulink.co.uk> +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. + +main() +{ + rm -f .config.tmp + ALLON=no + + if [ -f .config.lst ] + then grep '^[^:]*:+:' .config.lst > .config.tmp + if [ ! -s .config.tmp ] + then ALLON=yes + fi + else ALLON=yes + fi + + egrep -v '^#|^$' /dev/null */[Cc]onfig | \ + sed -e 's./.:.' -e 's/[ ]*:[ ]*/:/g' >> .config.tmp 2>/dev/null + ls */Makefile | sed 's-/Makefile-:+:+-' >> .config.tmp + sort .config.tmp > .config.lst + + unset_dups + + if [ ! -s .config.lst ] + then echo 'No configuration options' + exit 0 + fi + + CHANGED=0 + RUNNING=1 + [ "$DIST" != "" ] && { + RUNNING=0 + echo 'Using default configuration' + } + while [ $RUNNING = 1 ] + do + display + echo + echo -n 'Option to flip [or quit] >' + read n + v="" + case "$n" in + [qQ]* ) RUNNING=0 + ;; + [0-9] ) v=$n ;; + [0-9][0-9] ) v=$n ;; + * ) echo '\007' + ;; + esac + + if [ "$v" != "" ] + then set_option $v + fi + done + + if [ "$CHANGED" = 1 -a \( -f libc.a -o -f crt0.o \) ] + then echo ' + You should now run a "make clean" to clean out the libc.a +' + exit 1 + fi + + exit 0 +} + +display() +{ + clear + echo 'Configuration options' + echo + awk -F: < .config.lst '{ + if( $3 == "+" ) next; + if( $2 == "+" ) { flags[$1] = 1; next; } + + printf("%2d) ", ++count); + if( $1 in flags ) printf("(ON) "); + else printf("(OFF) "); + if( $2 == "Config" ) printf(" "); else printf("* "); + printf("%s\n", $4); + }' +} + +unset_dups() +{ + awk -F: < .config.lst '{ + if( $2 == "+" && $3 == "+") { if( noco[$1] != 1 ) noco[$1] = 2; next; } + if( $2 == "+" ) { flags[$1] = 1; next; } + if( "'$ALLON'" == "yes" && $2 == "Config" ) flags[$1] = 1; + + if( $1 in flags ) + { + if( $3 in gottype ) + ; + else + { + printf("%s:+:\n", $1); + gottype[$3] = 1; + } + } + noco[$1] = 1; + printf("%s\n", $0); + } END { + for(i in noco) + if( noco[i] == 2 ) + printf("%s:+:+\n", i); + }' | sort > .config.tmp + ALLON=no + mv -f .config.tmp .config.lst +} + +set_option() +{ + rm -f .config.tmp1 + awk -F: < .config.lst '{ + if( $2 == "+" && $3 == "+" ) { print $0; next; } + if( $2 == "+" ) { flags[$1] = 1; next; } + + if( ++cnt == '$1' ) + { + if( $1 in flags ) + ; + else + printf("%s:+:\n", $1) > ".config.tmp1"; + printf("%s\n", $0) > ".config.tmp1"; + } + else + { + if( $1 in flags ) + printf("%s:+:\n", $1); + printf("%s\n", $0); + } + }' > .config.tmp2 + if [ -f .config.tmp1 ] + then CHANGED=1 + else echo 'Cannot change that option!' + sleep 2 + fi + cat .config.tmp[12] > .config.lst + rm .config.tmp[12] + unset_dups +} + +main |