
echo "Setting up Open Sound System....please wait"

if test -f /etc/oss.conf
then
  . /etc/oss.conf
else
  OSSLIBDIR=/usr/lib/oss
fi

rm -f /etc/rc3.d/S80ossinstall # Remove temporary installer

# Remove previous sound drivers
rem_drv oss > /dev/null 2>&1
rem_drv audioens > /dev/null 2>&1
rem_drv audiots > /dev/null 2>&1
rem_drv audio1575 > /dev/null 2>&1
rem_drv audiovia823x > /dev/null 2>&1
rem_drv audiohd > /dev/null 2>&1
rem_drv audio810 > /dev/null 2>&1
rem_drv audioixp > /dev/null 2>&1
rem_drv usb_ac > /dev/null 2>&1
rem_drv usb_as > /dev/null 2>&1
rem_drv ossaudios > /dev/null 2>&1 # Old name for sadasupport

# Remove previous OSS and SADA devices
rm -f /dev/sound/*
rm -f /dev/audio*
rm -f /dev/dsp*
rm -f /dev/mixer*
rm -f /dev/midi*
rm -f /dev/sndstat 
rm -f /dev/sequencer 
rm -f /dev/music

# Remove the vmix driver if the CPU doesn't support SSE instructions.
# For the time being the FP support code doesn't work with older CPUs that
# don't support SSE.
#
# Solaris 9 and earlier don't report CPU capabilities so skip this test.

if test "`uname -r` " = "5.10 " || test "`uname -r` " = "5.11 "
then
   if test "`/usr/bin/isainfo -v|grep ' sse '` " = " "
   then
	rm -f /platform/i86pc/kernel/drv/vmix
   fi
fi

sync

if test ! -f /usr/lib/oss/etc/forceload.conf && test -f /usr/lib/oss/etc_templates/forceload.conf
then
  cp /usr/lib/oss/etc_templates/forceload.conf /usr/lib/oss/etc/forceload.conf
fi

rm -f /tmp/osspkg.tmp
grep -v type=oss_ /etc/devlink.tab > /tmp/osspkg.tmp
cat /tmp/osspkg.tmp > /etc/devlink.tab
cat >> /etc/devlink.tab <<EOF
type=oss_sysdev	\M0
type=oss_audio	oss/\M1/\M2
EOF

if test ! -f $OSSLIBDIR/etc/userdefs
then
  echo "autosave_mixer yes" > $OSSLIBDIR/etc/userdefs
fi

if /usr/xpg4/bin/grep -q 'install_imux yes' $OSSLIBDIR/etc/userdefs
then
	# Install the imux driver
	/usr/sbin/ossdetect -i
else
	/usr/sbin/ossdetect 
fi

/usr/sbin/devlinks

# Symlink the config files to $OSSLIBDIR/conf
cd $OSSLIBDIR/conf
ARCH=`uname -m`
for n in `grep -l 'Open Sound System configuration file' /platform/$ARCH/kernel/drv/*.conf`
do
  ln -s $n .
done

/usr/sbin/ossdevlinks

echo ""
echo "Adding OSS startup scripts to /etc/rc3.d and /etc/init.d"
rm -f /etc/rc3.d/S89oss /etc/rc3.d/S99oss /etc/init.d/oss

cp $OSSLIBDIR/etc/S89oss /etc/init.d/oss
chmod 744 /etc/init.d/oss

ln -s ../init.d/oss /etc/rc3.d/S89oss
ln -s ../init.d/oss /etc/rc3.d/K89oss

echo ""
echo "Setting up Adobe Flash audio support"
/usr/sfw/bin/gcc -shared -fPIC -O2 -Wall -Werror -lssl $OSSLIBDIR/lib/flashsupport.c -o /usr/sfw/lib/libflashsupport.so > /dev/null 2>&1
echo ""
echo ""
echo ""
echo Thank you for installing Open Sound System
echo ""
echo You can use the osstest command to test audio playback in your system.
echo ""
echo It may be necessary to reboot the system before all devices get properly
echo detected by the system.

exit 0
