Config_sh 3.4 KB

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