#!/bin/sh

x=`uname`
y=`uname -m`

PLAT=$x.$y

echo $PLAT

case $PLAT in
	Linux.ppc | \
	Linux.i586 | \
	Linux.i686)
		echo "Configuring for a Linux x86 platform"
		CPLUS='egcs'
		CCOMP=egcs
		LINKER='egcs'
		MACHDEFINES=-D__linux__
		THREADLIBS=-lpthread
		if [ -f /usr/include/socketbits.h ]; then
			NEED_SOCKETBITS=1
			export NEED_SOCKETBITS
		fi
		;;
	FreeBSD.i386)
		echo "Configuring for a FreeBSD platform"
		CPLUS=gcc
		CCOMP=gcc
		LINKER="gcc"
		THREADLIBS=-pthread
		MACHDEFINES="-D__FreeBSD__ -fhandle-exceptions"
		;;
	*)
		echo "I don't know your platform. I'll go with the defaults and hope
for the best!"
		;;
esac

echo Building for $PLAT with $CPLUS

export CPLUS
export CCOMP
export LINKER
export MACHDEFINES
export MUTEXKIND
export THREADLIBS

cd QTFile; make -f Makefile.POSIX $*

cd ..; cp QTFile/libQTRTPFile.a RhapServer/.

cd RhapServer; make -f Makefile.POSIX $*

cd ..

if [ ! -f /etc/QTSS.conf ]; then
	echo "#################################################################"
	echo
	echo "Make sure that you modify RhapServer/QTSS.conf and put it in your"
	echo "   /etc directory."
	echo "Items to change include 'movie_folder', 'request_logfile_dir',"
	echo "   and 'error_logfile_dir'."
	echo "Then, put hinted movie files into the 'movie_folder'."
	echo "Then, as root, run QuickTimeStreamingServer."
	echo
	echo "#################################################################"
fi


