# Install the driver files

PRONAME="RTL PCI"
BRDNAME="RTL PCI"
INCLUDE="macstat.h"
IOS="0"
IOE="0"
IRQ="0"
CFG="N"

if [ "$1" = "" -o "$1" = "0" ]
then
	# Board0
	if [ -f /usr/options/cb.name ]
	then
		OBJECT="Driver.isc"
	else
		OBJECT="driver.o"
	fi
	cp space.c Space.c
	BRDNUM="0"
	DRVNAME="pci0"
	INIT="I"
	PREFIX="pci"
else
	# Board1-3
	OBJECT="Dummy.o"
	echo "/* No Space.c */ " > Space.c
	BRDNUM=$1
	DRVNAME="pci${BRDNUM}"
	INIT="-"
	PREFIX=${DRVNAME}
fi


# Check for second argument for CFG flag
if [ "$2" = "Y" -o "$2" = "y" ]
then
	CFG="Y"
fi


# Make Master, System and Node files





echo "${DRVNAME}\t${INIT}\tiScH\t${PREFIX}\t0\t38\t1\t256\t-1" >Master

echo "${DRVNAME}\t${CFG}\t4\t5\t0\t0\t0\t0\t0\t0" >System

cat << PROST >Node
clone	${DRVNAME}	c	${DRVNAME}
PROST

rm Driver.o >/dev/null 2>&1
ln ${OBJECT} Driver.o

if [ -d /etc/conf/pack.d/${DRVNAME} ]
then
	# Update the ${BRDNAME} driver
	echo "Updating existing ${BRDNAME} driver ${DRVNAME} ..."
	/etc/conf/bin/idinstall -u -k ${DRVNAME}
else
	# New installation
	echo "Installing the ${BRDNAME} driver ${DRVNAME} ..."
	/etc/conf/bin/idinstall -a -k ${DRVNAME}
fi

# rm Master System Node Space.c Driver.o

# Copy header file
cp ${INCLUDE} /usr/include/sys

