
# (C) Copyright 1984 by Third Eye Software, Inc. - All Rights Reserved
# $Header: Configure,v 6.3 86/09/14 20:24:23 peter Exp $
#
# In order to install CDB you need to have write permission to
# the directory you will be installing into AND write permission
# for directory /usr/lib (probably this means being 'root').

n=''
c=''
contains=grep

: first determine how to suppress newline on echo command
(echo "hi there\c" ; echo " ") >.echotmp
if $contains c .echotmp >/dev/null 2>&1 ; then
    n='-n'
    c=''
    pager=more
else
    n=''
    c='\c'
    pager=pg
fi
rm .echotmp

echo "CDB Configuration Program"
echo " "

HFILE="SYS.h"
MFILE="SYS.make"
MKFILE="Makefile"

rm -f $HFILE $MFILE $MKFILE

until test -r $HFILE
do
    echo "The following systems are available:"
    echo " "
    awk -f config.awk config.db | $pager
    echo " "
    echo $n "Please type the letter of your system > $c"
    read sysnum
    awk -F${sysnum} -f config.awk config.db
done

# Create the Makefile
echo "# WARNING! This file is automatically overwritten by the" > $MKFILE
echo "# Configure shell script.  Anything you change in here will" >> $MKFILE
echo "# be lost the next time you get an update to the debugger." >> $MKFILE
echo "#" >> $MKFILE
cat $MFILE >> $MKFILE
rm -f $MFILE

grammars=""
libs=""
o_extras=""
c_extras=""

if test -r cgram.y; then
    grammars="$grammars cgram.o"
    echo "#define LANG_C 1" >> $HFILE
fi

if test -r fsupport.c; then
#    grammars="$grammars fgram.o"
    o_extras="$o_extras fsupport.o"
    c_extras="$c_extras fsupport.c"
    echo "#define LANG_FORTRAN 1" >> $HFILE
fi

if test -r ww.c; then
    o_extras="$o_extras ww.o"
    c_extras="$c_extras ww.c"
    echo "WM	= wm" >> $MKFILE
    echo "WMINSTALL	= wminstall" >> $MKFILE
    libs="$libs -ltermcap"
    echo "#define WINDOWS 1" >> $HFILE
    if test -r /usr/include/vt.h
    then
	if $contains ISI $HFILE > /dev/null
	then
	    libs="$libs -ltools -lvt"
	    echo "#define HAS_GRAPHICS 1" >> $HFILE
	fi
    fi
fi

man=man1
if test -r /usr/man/p_man/man1; then
    man=p_man/man1
fi
echo "MAN	= $man" >> $MKFILE

echo "LIBS	= $libs" >> $MKFILE
echo "O_EXTRAS	= $o_extras" >> $MKFILE
echo "C_EXTRAS	= $c_extras" >> $MKFILE
echo "GRAMMARS	= $grammars" >> $MKFILE
echo " " >> $MKFILE
echo "##########  END OF CONFIGURATION PARAMETERS ##########" >> $MKFILE
echo " " >> $MKFILE
echo " " >> $MKFILE

# Finally the rest of the $MKFILE
cat Make.Cdb >> $MKFILE

if test -d THIRDI
then
    echo "CFLAGS=$(DEBUGFLAGS)" >> $MKFILE
    echo "#define THIRDI 1" >> $HFILE
fi

cat << "MeSsAgE"

Your system is now ready to be built. In order to:

  - Build cdb, type "make all"
  - Install locally (you MUST be root), type "make "BASE=/" install"
  - Create a directory for distribution to customers, type "make distinstall"
  - Create a demo directory for ditribution, type "make demoinstall"

MeSsAgE
exit 0
