#!/bin/zsh
if [ -e /usr/i686-w64-mingw32/bin/libao-4.dll ];then
sleep .01
else
export missingreqs=$missingreqs" "mingw-w64-libao
fi
if [ -e /usr/i686-w64-mingw32/bin/libssp-0.dll ];then
sleep .01
else
export missingreqs=$missingreqs" "mingw-w64-gcc
fi
if which zip > /dev/null;then
sleep .01
else
export missingreqs=$missingreqs" "zip
fi
if [ -z $missingreqs ];then
sleep .01
else
echo some requirements for this script to function are present. The missing requirements are: 
echo $missingreqs
exit 48
fi
git clone https://github.com/juhovh/shairplay
cd shairplay
autoreconf -i
./configure --prefix=/usr --host=i686-w64-mingw32 --with-playfair
make -j $(($(nproc)*2))
mkdir build
make DESTDIR=$PWD/build install
cp airport.key build/usr/bin
cp /usr/i686-w64-mingw32/bin/libssp-0.dll build/usr/bin
cp /usr/i686-w64-mingw32/bin/libao-4.dll build/usr/bin
curl -Lo pservice.exe https://download.info.apple.com/Mac_OS_X/061-8098.20100603.gthyu/BonjourPSSetup.exe
zip -r shairplay.zip build pservice.exe
