#!/bin/sh

#Darwin BuildTarball script

PLAT=`uname`

case $PLAT in
	"Darwin")
        echo "Do not use this script for building on MacOS X."
        echo "Use the 'Buildit' or 'Buildit install' command instead."
        exit 1
	;;
			
	*)
        echo "Preparing for the Darwin "$PLAT" platform"
	;;		
esac

echo removing DarwinStreamingSrvr$1-$PLAT.tar.gz
if rm -f DarwinStreamingSrvr$1-$PLAT.tar.gz; 
then :
fi

echo removing DarwinStreamingSrvr$1-$PLAT
if rm -rf DarwinStreamingSrvr$1-$PLAT; 
then :
fi

echo removing StreamingProxy-$1-$PLAT.tar.gz
if rm -f StreamingProxy-$1-$PLAT.tar.gz; 
then :
fi

echo removing StreamingProxy-$1-$PLAT
if rm -rf StreamingProxy-$1-$PLAT 
then :
fi

./Buildit clean
./Buildit

if [ ! -f DarwinStreamingServer ];
then 
	echo "DarwinStreamingServer failed to build!"
	echo Buildit Failed. Exiting!
	exit 1
fi

if [ ! -f PlaylistBroadcaster.tproj/PlaylistBroadcaster ];
then 
	echo "PlaylistBroadcaster failed to build!"
	echo Buildit Failed. Exiting!
	exit 1
fi

if [ ! -f MP3Broadcaster/MP3Broadcaster ];
then 
	echo "MP3Broadcaster failed to build!"
	echo Buildit FAILED. Exiting!
	exit 1
fi

if [ ! -f qtpasswd.tproj/qtpasswd ];
then 
	echo "qtpasswd failed to build!"
	echo Buildit FAILED. Exiting!
	exit 1
fi

    if [ ! -d StreamingLoadTool ];
    then 
        echo "FYI: There is no StreamingLoadTool folder."
    fi
    
    if [ -d StreamingLoadTool ];
    then
        if [ ! -f StreamingLoadTool/StreamingLoadTool ];
        then
            echo "StreamingLoadTool failed to build!"
        fi
    fi

./DSS_MakeRoot -f DarwinStreamingSrvr$1-$PLAT $1
tar cvf DarwinStreamingSrvr$1-$PLAT.tar DarwinStreamingSrvr$1-$PLAT
gzip DarwinStreamingSrvr$1-$PLAT.tar

./DSS_MakeProxyRoot StreamingProxy-$1-$PLAT
tar cvf StreamingProxy-$1-$PLAT.tar StreamingProxy-$1-$PLAT
gzip StreamingProxy-$1-$PLAT.tar

echo Success!

