#!/bin/sh
#                             YIFF Sound Systems
#
#                      Building and Installation Script
#
#       Run this script to compile the YIFF Sound System components and
#       install them.
#

PROG_NAME="YIFF Sound Server"
YIFF_CONFIG_DIR=/usr/etc
YIFF_CONFIG_FILE=yiffrc
NOSERVER_STR=noserver

# Print usage?
if [ "$1" = "" ]; then
 echo "Usage: $0 <ostype> [$NOSERVER_STR]"
 echo " "
 echo "    Where <ostype> can be any of the following:"
 echo " "
 echo "        linux                   Linux"
 echo "        clean                   Removes any work in progress files"
 echo " "
 echo "    Add the option $NOSERVER_STR if you do not want to build the"
 echo "    sound server (for client-only installations)."
 echo " "
 echo "    Example: \"$0 linux\""
 echo " "
 exit
fi

# Clean?
if [ "$1" = "clean" ]; then  
 make clean
 exit
fi

# Linux?
if [ "$1" = "linux" ]; then
 if [ "$2" = "$NOSERVER_STR" ]; then
  make linux_noserver
 else
  make linux
 fi
fi


# About to install, check if EUID is root?
if test $EUID != 0; then
 echo "-------------------------------------------------------------------------"
 echo "To continue with installation, root privileges are required."
 echo "Enter password for root."
fi

# Install
if [ "$2" = "$NOSERVER_STR" ]; then
 su -c make\ install_noserver
else
 su -c make\ install
fi

# Done installation message
echo "$PROG_NAME build and installation complete."

# If complete installation, then advise user to manually install default
# yiff sound server configuration file
if [ "$2" != "$NOSERVER_STR" ]; then
 echo " "
 echo "Note that if you do not have a YIFF Sound Server configuration"
 echo "file (yiffrc) installed on your system (ie if this is your"
 echo "first installation) then you should manually install the"
 echo "default one found in yiff/yiffrc to either /usr/etc or /etc."
 echo " "
 echo "If no errors were encountered, then you should run yiffconfig to"
 echo "set up the configuration file for the YIFF Sound Server."
fi
