BSD 4_3 development
[unix-history] / usr / contrib / B / Setup
: 'Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1984, 1985.'
echo "Configuration questions for the B system."
: 'Determine if echo -n works'
echo -n "bleep" >.bleep
if grep n .bleep >/dev/null 2>&1
then
n=""
else
n="-n"
fi
rm -f .bleep
: 'What machine?'
echo " "
echo $n "Figuring out what machine you have "
echo $n "..."
cat >machine.c <<EOF
#include <stdio.h>
main() {
#ifdef vax
printf("vax\n");
#else
#ifdef pdp
printf("pdp\n");
#else
#ifdef PDP
printf("pdp\n");
#else
printf("other\n");
#endif
#endif
#endif
}
EOF
cc machine.c -o machine
machine=`machine`
rm -f machine*
echo " "
case $machine in
vax)
echo "This machine appears to be a VAX."
echo $n "Is this true? "
read ans
case $ans in
n*|N*|f*|F*) machine="other"
;;
*) bint="bint"
;;
esac
;;
pdp)
echo "This machine appears to be a PDP."
echo $n "Is this true? "
read ans
case $ans in
n*|N*|f*|F*) machine="other"
;;
*) bint="bsmall"
;;
esac
;;
esac
case $machine in
other)
echo "Your machine does not appear to be a VAX or PDP."
echo $n "Is this a small machine (less than 190K code space)? "
read ans
case $ans in
y*|Y*) bint="bsmall"
;;
*) bint="bint"
;;
esac
echo " "
echo "Since your machine may not be a VAX or PDP, you might have to edit"
echo "the configuration file for the B interpreter '$bint'."
echo "Check the remarks in b0con.h and README in ./src/$bint."
;;
esac
case $bint in
"bsmall")
echo " "
echo "Since you have a small system, we can only use the old"
echo "version of the B interpreter, named $bint."
echo "See the file ./src/bsmall/README for details."
echo " "
echo "The B editor is too big in its full glory."
echo "Therefore all kinds of features will be turned off in an"
echo "attempt to make it fit."
echo "See ./src/bed/feat.h for details."
;;
esac
: 'What unix?'
echo " "
echo $n "Finding out about your brand of unix "
echo $n "..."
cat >unix.c <<EOF
#include <stdio.h>
#include <signal.h>
main() {
#ifdef SIGCHLD
#ifdef SIGVTALRM
printf("BSD4_2\n");
#else
printf("BSD\n");
#endif
#else
#ifdef SIGCLD
printf("ATT\n");
#else
printf("unknown\n"); /* Version 7 we hope ... */
#endif
#endif
}
EOF
cc unix.c -o unix
unix=`unix`
rm -f unix*
echo " "
case $unix in
BSD4_2)
echo "You appear to be running Berkeley's BSD unix, version 4.2 (or later)."
echo $n "Is this true? "
read ans
case $ans in
n*|N*|f*|F*) unix="unknown";;
esac
;;
BSD)
echo "You appear to be running Berkeley's BSD unix."
echo $n "Is this true? "
read ans
case $ans in
n*|N*|f*|F*) unix="unknown";;
esac
;;
ATT)
echo "You appear to be running ATT's System III or System V unix."
echo $n "Is this true? "
read ans
case $ans in
n*|N*|f*|F*) unix="unknown";;
esac
;;
esac
case $machine in
pdp|other)
case $unix in
unknown)
echo $n "Are you running PWB Unix? "
read ans
case $ans in
y*|Y*) unix="PWB";;
esac
;;
esac
esac
case $unix in
unknown)
echo " "
echo "We cannot find out what type of unix you are running."
echo "See ./src/bed/unix.h, ./src/bed/feat.h, /src/$bint/README"
echo "and ./src/$bint/b0con.h in case of problems."
;;
esac
: 'Floating point arithmetic ok?'
echo " "
cat >float.c <<EOF
#include <stdio.h>
double dadd(a, b) double a, b; {
return a+b;
}
main() {
double a, b, c;
double dadd();
a = 3.14;
b = 2.7 * a;
c = dadd(a, b);
exit(0);
}
EOF
cc -O float.c -o float >/dev/null 2>&1
if sh 2>/dev/null <<EOF
if float
then exit 0
else exit 1
fi
EOF
then
echo "Your floating point seems to be alright."
fflag=""
else
echo "Your C compiler seems to need a special flag for"
echo "loading (probably software) floating point routines."
echo $n "What flag is needed (default -f) "
read fflag
case $fflag in
'') fflag="-f";;
esac
cc -O $fflag float.c -o float >/dev/null 2>&1
until sh 2>/dev/null <<EOF
if float
then exit 0
else exit 1
fi
EOF
do
echo "This flag doesn't seem to work."
echo "Try again (default -f) "
read fflag
case $fflag in
'') fflag="-f";;
esac
cc -O $fflag float.c -o float >/dev/null 2>&1
done
fi
rm -f float* core
: 'termio system?'
if test -r /usr/include/termio.h
then
termio="yes"
echo " "
echo "Termio.h found."
else
termio="no"
if test ! -r /usr/include/sgtty.h
then
echo " "
echo "Neither termio.h nor sgtty.h found."
echo "See ./src/bed/unix.h in case of problems."
fi
fi
: 'termcap library for B editor'
echo " "
echo $n "Searching for your termcap-like library routines "
echo $n "... "
if test -r /lib/libtermcap.a -o -r /usr/lib/libtermcap.a
then
termlib="-ltermcap"
echo "termcap library found."
elif test -r /usr/local/lib/libtermcap.a
then
termlib="/usr/local/lib/libtermcap.a"
echo "local termcap library found."
elif test -r /lib/libtermlib.a -o -r /usr/lib/libtermlib.a
then
termlib="-ltermlib"
echo "termlib library found."
elif test -r /usr/local/lib/libtermlib.a
then
termlib="/usr/local/lib/libtermlib.a"
echo "local termlib library found."
elif test -r /lib/libcurses.a -o -r /usr/lib/libcurses.a
then
termlib="-lcurses"
echo "terminfo library found."
elif test -r /usr/local/lib/libcurses.a
then
termlib="/usr/local/lib/libcurses.a"
echo "local terminfo library found."
else
: 'changed for 4.3 BSD release'
termlib="ask_it"
fi
while test "$termlib" = "ask_it" -o "$termlib" = "try_again"; do
case $termlib in
ask_it)
echo " "
echo "Please specify where the termcap-like routines are kept"
echo $n " (either full pathname or -lxxx option) "
;;
try_again)
echo $n "Please try again (full pathname or -lyyy option) "
;;
esac
read termlib
case $termlib in
-l*)
echo "Hope $termlib will do the job."
;;
/*)
if test -r $termlib
then
echo "Ok, we will try that one."
else
echo "$termlib does not appear to exist."
termlib="try_again"
fi
;;
*)
echo "$termlib is not a valid library specification."
termlib="try_again"
;;
esac
done
: 'termcap database, commented out for 4.3 BSD'
#echo " "
#if test -r /etc/termcap
#then
# termcap="yes"
# echo "Termcap database found."
#else
# termcap="no"
# echo "No termcap database found; we will install our own, to be used"
# echo "when your TERMCAP environment variable is not set."
#fi
: 'Shall we make B public?'
public="no"
echo " "
echo $n "Will you want to make B publically available? "
read ans
case $ans in
y*|Y*)
public="yes"
if test -r answers
then
. answers
else
bdef="/usr/new"
libdef="/usr/new/lib/B"
man1def="/usr/man/mann"
man5def="/usr/man/mann"
fi
bdir='blurfl'
while test ! -d "$bdir" ; do
case $bdir in
blurfl)
echo " "
echo "Please type the full pathname of a directory"
echo "in which you have write permission,"
echo "and where you want the 'b' command file installed"
echo $n " (default $bdef) "
;;
*) echo "$bdir does not appear to exist."
echo $n "Are you sure you typed the right name? "
read ans
case $ans in
y*|Y*) echo "Don't forget to make $bdir before 'make install'."
break
;;
*) echo " "
echo $n "Please try again (default $bdef) "
;;
esac
;;
esac
read bdir
case $bdir in
"") bdir=$bdef;;
esac
done
libdir='blurfl'
while test ! -d "$libdir" ; do
case $libdir in
blurfl)
echo " "
echo "Please type the full pathname of the directory"
echo "where you want to install the auxiliary binaries"
echo "and datafiles needed by the B system"
echo $n " (default $libdef) "
;;
*) echo "$libdir does not appear to exist."
echo $n "Are you sure you typed the right name? "
read ans
case $ans in
*|Y*) echo "Don't forget to make $libdir before 'make install'."
break
;;
*) echo " "
echo $n "Please try again (default $libdef) "
;;
esac
;;
esac
read libdir
case $libdir in
"") libdir=$libdef;;
esac
done
man1dir='blurfl'
while test ! -d "$man1dir" ; do
case $man1dir in
blurfl)
echo " "
echo "Please type the full pathname of the directory"
echo "where you want to install the 'b.1' manual page"
echo $n " (default $man1def) "
;;
*) echo "$man1dir does not appear to exist."
echo $n "Are you sure you typed the right name? "
read ans
case $ans in
y*|Y*) echo "Don't forget to make $man1dir before 'make install'."
break
;;
*) echo " "
echo $n "Please try again (default $man1def) "
;;
esac
;;
esac
read man1dir
case $man1dir in
"") man1dir=$man1def;;
esac
done
man5dir='blurfl'
while test ! -d "$man5dir" ; do
case $man5dir in
blurfl)
echo " "
echo "Please type the full pathname of the directory"
echo "where you want to install the 'bterminal.5' manual page"
echo $n " (default $man5def) "
;;
*) echo "$man5dir does not appear to exist."
echo $n "Are you sure you typed the right name? "
read ans
case $ans in
y*|Y*) echo "Don't forget to make $man5dir before 'make install'."
break
;;
*) echo " "
echo $n "Please try again (default $man5def) "
;;
esac
echo $n "Please try again "
;;
esac
read man5dir
case $man5dir in
"") man5dir=$man5def;;
esac
done
cat >answers <<EOF
bdef="$bdir"
libdef="$libdir"
man1def="$man1dir"
man5def="$man5dir"
EOF
;;
esac
echo " "
echo "End of configuration questions for the B system."
: 'Getting generic copies of makefiles and shellfiles.'
: 'Since some tar_s leave the owner of the tape as the owner of the files'
: 'this will make sure the edit scripts will not fail.'
makefiles="./Makefile src/b/Makefile src/bed/Makefile src/bint/Makefile src/bsmall/Makefile"
shellfiles="src/b/b.sh src/b/b_p.sh"
editor="ed -"
cat >mf.head <<EOF
# This file was generated and edited by the Setup command.
# To make lasting changes edit the file Makefile.gen and run Setup again.
#
EOF
for f in $makefiles
do
cat mf.head $f.gen >$f
chmod 644 $f
done
rm -f mf.head
for f in $shellfiles
do
cp $f.gen $f
chmod 755 $f
done
echo " "
echo $n "Editing Appropriate files ... "
case $machine in
pdp)
f=src/bed/Makefile
$editor $f <<EOF
/^LDFLAGS=/s?LDFLAGS=.*?LDFLAGS= -i?
w
q
EOF
f=src/bsmall/Makefile
$editor $f <<EOF
/^LDFLAGS=/s?LDFLAGS=.*?LDFLAGS= -i?
w
q
EOF
;;
esac
: 'Not all CFLAGS are used by all sources.'
: 'But for convenience and future use, we put them into all source Makefiles.'
cflags="-O $fflag -DNDEBUG"
for f in Makefile src/b/b.sh src/bed/Makefile
do
$editor $f <<EOF
/^BINT=/s?BINT=.*?BINT=$bint?
w
q
EOF
done
case $bint in
bsmall)
f=Makefile
$editor $f <<EOF
/examples$/s?make .*examples?make smallexamples?
w
q
EOF
cflags="$cflags -DSMALLSYS"
;;
esac
case $unix in
BSD|BSD4_2|PWB)
cflags="$cflags -D$unix"
;;
ATT)
cflags="$cflags -Dindex=strchr -Drindex=strrchr"
;;
esac
case $termio in
yes)
cflags="$cflags -DTERMIO"
;;
esac
for f in src/b/Makefile src/bed/Makefile src/$bint/Makefile
do
$editor $f <<EOF
/^CFLAGS=/s?CFLAGS=.*?CFLAGS= $cflags?
w
q
EOF
done
case $termlib in
-l*|/*)
f=src/bed/Makefile
$editor $f <<EOF
/^TERMLIB=/s?.*?TERMLIB= $termlib?
/^OWNTLIB=/s?.*?OWNTLIB=?
w
q
EOF
;;
libtermcap.a)
f=src/bed/Makefile
$editor $f <<EOF
/^TERMLIB=/s?.*?TERMLIB=?
/^OWNTLIB=/s?.*?OWNTLIB= libtermcap.a?
w
q
EOF
;;
esac
#case $termcap in
#no)
# f=src/b/Makefile
# $editor $f <<"EOF"
# /^install:/s?.*?install: all ldest termcap?
# w
# q
#EOF
# ;;
#esac
case $public in
yes)
f=Makefile
$editor $f <<EOF
/^BDIR=/s?BDIR=.*?BDIR=$bdir?
/^MAN1DIR=/s?MAN1DIR=.*?MAN1DIR=$man1dir?
/^MAN5DIR=/s?MAN5DIR=.*?MAN5DIR=$man5dir?
/^LIBDIR=/s?LIBDIR=.*?LIBDIR=$libdir?
w
q
EOF
;;
esac
echo "done."
echo " "
echo "This completes the setup of the B system."
echo "You can now try 'make all'."