Debian Codegraph @

libc/Config_sh

raw symbols SCIP
1 #!/bin/sh -
2 # Copyright (C) 1996 Robert de Bath <[email protected]>
3 # This file is part of the Linux-8086 C library and is distributed
4 # under the GNU Library General Public License.
5
6 main()
7 {
8 rm -f .config.tmp
9 ALLON=yes
10
11 if [ "$ALLON" = yes -a -f .config.lst ]
12 then grep '^[^:]*:+:' .config.lst > .config.tmp
13 [ -s .config.tmp ] && ALLON=no
14 fi
15
16 if [ "$ALLON" = yes -a -f Config.dflt ]
17 then grep '^[^:]*:+:' Config.dflt > .config.tmp
18 [ -s .config.tmp ] && {
19 ALLON=no
20 grep -q '^kinclude:' .config.tmp >/dev/null 2>&1 || {
21 [ -d "$ELKSSRC/include" ] ||
22 echo 'kinclude:+:' >> .config.tmp
23 }
24 }
25 fi
26
27 egrep -v '^#|^$' /dev/null */[Cc]onfig | \
28 sed -e 's./.:.' -e 's/[ ]*:[ ]*/:/g' >> .config.tmp 2>/dev/null
29 ls */Makefile | sed 's-/Makefile-:+:+-' >> .config.tmp
30 sort .config.tmp > .config.lst
31
32 unset_dups
33
34 if [ ! -s .config.lst ]
35 then echo 'No configuration options'
36 exit 0
37 fi
38
39 CHANGED=0
40 RUNNING=1
41 [ "$DIST" != "" -o ! -t 1 -o ! -t 0 ] && {
42 RUNNING=0
43 echo 'Using default configuration'
44 }
45 while [ $RUNNING = 1 ]
46 do
47 display
48 echo
49 echon 'Select config option to flip [or quit] >'
50 read n
51 v=""
52 case "$n" in
53 [qQ]* ) RUNNING=0
54 ;;
55 [0-9] ) v=$n ;;
56 [0-9][0-9] ) v=$n ;;
57 * ) echo '\007'
58 ;;
59 esac
60
61 if [ "$v" != "" ]
62 then set_option $v
63 fi
64 done
65
66 if [ "$CHANGED" = 1 -a \( -f libc.a -o -f crt0.o \) ]
67 then echo '
68 You should now run a "make clean" to clean out the libc.a
69 '
70 exit 1
71 fi
72
73 exit 0
74 }
75
76 display()
77 {
78 clear
79 awk -F: < .config.lst '{
80 if( $3 == "+" ) next;
81 if( $2 == "+" ) { flags[$1] = 1; next; }
82
83 printf("%2d) ", ++count);
84 if( $1 in flags ) printf("(ON) ");
85 else printf("(OFF) ");
86 if( $2 == "Config" ) printf(" "); else printf("* ");
87 printf("%s\n", $4);
88 }'
89 }
90
91 unset_dups()
92 {
93 awk -F: < .config.lst '{
94 if( $2 == "+" && $3 == "+") { if( noco[$1] != 1 ) noco[$1] = 2; next; }
95 if( $2 == "+" ) { flags[$1] = 1; next; }
96 if( "'$ALLON'" == "yes" && $2 == "Config" ) flags[$1] = 1;
97
98 if( $1 in flags )
99 {
100 if( $3 in gottype )
101 ;
102 else
103 {
104 printf("%s:+:\n", $1);
105 gottype[$3] = 1;
106 }
107 }
108 noco[$1] = 1;
109 printf("%s\n", $0);
110 } END {
111 for(i in noco)
112 if( noco[i] == 2 )
113 printf("%s:+:+\n", i);
114 }' | sort > .config.tmp
115 ALLON=no
116 mv -f .config.tmp .config.lst
117 }
118
119 set_option()
120 {
121 rm -f .config.tmp1
122 awk -F: < .config.lst '{
123 if( $2 == "+" && $3 == "+" ) { print $0; next; }
124 if( $2 == "+" ) { flags[$1] = 1; next; }
125
126 if( ++cnt == '$1' )
127 {
128 if( $1 in flags )
129 ;
130 else
131 printf("%s:+:\n", $1) > ".config.tmp1";
132 printf("%s\n", $0) > ".config.tmp1";
133 }
134 else
135 {
136 if( $1 in flags )
137 printf("%s:+:\n", $1);
138 printf("%s\n", $0);
139 }
140 }' > .config.tmp2
141 if [ -f .config.tmp1 ]
142 then CHANGED=1
143 else echo 'Cannot change that option!'
144 sleep 2
145 fi
146 cat .config.tmp[12] > .config.lst
147 rm .config.tmp[12]
148 unset_dups
149 }
150
151 echon() {
152 [ "$ECHON" = "" ] && {
153 if echo -n | grep -e -n >/dev/null
154 then ECHON="echo "; ECHOT='\c'
155 else ECHON="echo -n"; ECHOT=''
156 fi
157 }
158 $ECHON "$@""$ECHOT"
159 }
160
161 main