#!/bin/bash
make -f Makefile.rpi clean
make -f Makefile.rpi OPTS="-DLINKALL -DFFMPEG -DOPUS -DDSD -DVISEXPORT -DRESAMPLE -DIR -DGPIO -DRPI -DUSE_SSL -I./include -I./include/opus" LDFLAGS="-L./lib -lFLAC -lvorbisfile -lvorbis -logg -lmad -lfaad -lmpg123 -lopusfile -lopus -lavformat -lavcodec -lavutil -lsoxr -llirc_client /usr/lib/gcc/arm-linux-gnueabihf/4.9/libgomp.a /usr/lib/arm-linux-gnueabihf/libssl.a /usr/lib/arm-linux-gnueabihf/libcrypto.a /usr/lib/arm-linux-gnueabihf/libz.a -lpthread -ldl -lrt -lm -lasound"

strip squeezelite-rpi
mv squeezelite-rpi squeezelite

VERSION=$(./squeezelite -? | grep ^Squeezelite\ v | awk -F'[v,]' '{printf "%s", $2}' | sed -e 's/-/\./g')
TARFILE=squeezelite-$VERSION-armv6hf.tar.gz
if [ -f $TARFILE ]; then
	rm $TARFILE
fi
sudo chown root:root squeezelite LIBS.txt LICENSE.txt
tar -czf $TARFILE squeezelite LIBS.txt LICENSE.txt
sudo chown $LOGNAME:users squeezelite LIBS.txt LICENSE.txt
rm squeezelite

find . -name '*\.o' -exec rm {} \;
