#!/bin/sh
#
# This script attempts to automatically configure for the host system.
#
MKDEV=
MACROS=
MALLOC=

if [ -f /usr/include/sys/mkdev.h ]
then
MKDEV=-DHASMKDEV
fi

if [ -f /usr/include/sys/sysmacros.h ]
then
MACROS=-DHASSYSMACROS
fi

if [ -f /usr/include/malloc.h ]
then
MALLOC=-DHASMALLOC_H
fi

#
# OK, we have all of the configuration stuff done.  Now generate the Makefile.
#

echo XCFLAGS=${MKDEV} ${MACROS} ${MALLOC} > Makefrag

sed -e "/XCFLAGS=/  r Makefrag" Makefile.in > Makefile
rm -f Makefrag

#
# Now generate config.h
#
rm -rf config.h
touch config.h
if [ -f /usr/include/termios.h ]
then
echo "#define USE_TERMIOS" >> config.h
fi

echo "The Makefile is now properly configured for your system."
