#!/bin/sh
#

for a in compiletc bash file squashfs-tools \
		openssl-dev
	do tce-load -i $a
done

EXT=libevent
TCZ=/tmp/$EXT/TCZ

sudo rm -rf /tmp/$EXT

export CC="gcc -mtune=generic -Os -pipe"
export CXX="g++ -mtune=generic -Os -pipe -fno-exceptions -fno-rtti"

#make clean
./configure \
	|| exit

make || exit

if [ $(grep -q '^install-strip:' Makefile) ]; then
	make install-strip DESTDIR=$TCZ-dev
else
	make install DESTDIR=$TCZ-dev
	for a in $(find $TCZ-dev -type f); do file -b $a | grep -q '^ELF .*not stripped$' && strip $a; done
fi

mkdir -p $TCZ/usr/local/lib
mv $TCZ-dev/usr/local/lib/*.so* $TCZ/usr/local/lib

sudo chown -R root.root $TCZ*

mksquashfs $TCZ /tmp/$EXT/$EXT.tcz -noappend
mksquashfs $TCZ-dev /tmp/$EXT/$EXT-dev.tcz -noappend

