3 # Configure.sh Generates interactively a config.h from config.in
5 # net-tools A collection of programs that form the base set of the
6 # NET-3 Networking Distribution for the LINUX operating
9 # Usage: Install.sh [--nobackup] [--test]
11 # Version: Install.sh 1.65 (1996-01-12)
13 # Authors: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
14 # Johannes Grosen, <grosen@argv.cs.ndsu.nodak.edu>
15 # Copyright 1988-1993 MicroWalt Corporation
18 # {1.65} Bernd eckes Eckenfels <net-tools@lina.inka.de>
19 # some layout cleanups, slattach/plipconfig removed.
20 # --test for testinstallations added.
22 # This program is free software; you can redistribute it
23 # and/or modify it under the terms of the GNU General
24 # Public License as published by the Free Software
25 # Foundation; either version 2 of the License, or (at
26 # your option) any later version.
29 # Make sure we're really running bash.
31 # I would really have preferred to write this script in a language with
32 # better string handling, but alas, bash is the only scripting language
33 # that I can be reasonable sure everybody has on their Linux machine.
37 MAKECONFIG=config.make
40 [ -z "$BASH" ] && { echo "Configure requires bash" 1>&2; exit 1; }
42 # Disable filename globbing once and for all.
43 # Enable function cacheing.
47 # readln reads a line into $ans.
49 # readln prompt default
54 IFS='@' read ans </dev/tty || exit 1
55 [ -z "$ans" ] && ans=$2
58 # bool processes a boolean argument
64 # Slimier hack to get bash to rescan a line.
67 while [ "$ans" != "y" -a "$ans" != "n" ]
69 readln "$1 ($2) [$3] " "$3"
71 if [ "$ans" = "y" ]; then
72 echo "#define $2 1" >>${CONFIG}
73 echo "$2=1" >>${MAKECONFIG}
75 echo "#define $2 0" >>${CONFIG}
76 echo "# $2=0" >> ${MAKECONFIG}
78 raw_input_line="bool '$1' $2 $ans"
82 # int processes an integer argument
88 # Slimier hack to get bash to rescan a line.
91 while [ $[$ans+0] != "$ans" ];
93 readln "$1 ($2) [$3] " "$3"
95 echo "#define $2 ($ans)" >>${CONFIG}
96 raw_input_line="int '$1' $2 $ans"
101 # Make sure we start out with a clean slate.
110 while IFS='@' read raw_input_line
112 # Slimy hack to get bash to rescan a line.
113 read cmd rest <<-END_OF_COMMAND
117 if [ "$cmd" = "*" ]; then
118 if [ "$branch" = "t" ]; then
119 echo "$raw_input_line"
120 # echo "# $rest" >>$CONFIG
121 if [ "$prevcmd" != "*" ]; then
123 echo "/* $rest" >>${CONFIG}
125 echo " * $rest" >>${CONFIG}
130 [ "$prevcmd" = "*" ] && echo " */" >>${CONFIG}
133 =) [ "$branch" = "t" ] && echo "$rest" >>${CONFIG};;
134 :) [ "$branch" = "t" ] && echo "$raw_input_line" ;;
135 int) [ "$branch" = "t" ] && int "$rest" ;;
136 bool) [ "$branch" = "t" ] && bool "$rest" ;;
137 exec) [ "$branch" = "t" ] && ( sh -c "$rest" ) ;;
138 if) stack="$branch $stack"
139 if [ "$branch" = "t" ] && eval "$rest"; then
144 else) if [ "$branch" = "t" ]; then
147 read branch rest <<-END_OF_STACK
151 fi) [ -z "$stack" ] && echo "Error! Extra fi." 1>&2
152 read branch stack <<-END_OF_STACK
158 echo "$raw_input_line" >>config.new
160 [ "$prevcmd" = "*" ] && echo " */" >>${CONFIG}
162 [ -z "$stack" ] || echo "Error! Untermiated if." 1>&2
164 mv config.new config.status