#!/bin/sh
#
EXT=lighttpd
TCZ=/tmp/$EXT/TCZ

sudo rm -rf /tmp/$EXT

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

#make clean
./configure \
	--libdir=/usr/local/lib/lighttpd \
	--sysconfdir=/usr/local/etc/lighttpd \
	--localstatedir=/var \
	--enable-shared \
	--with-openssl \
	--with-pcre \
	--with-zlib \
	--with-bzip2 \
	--with-gdbm \
	|| exit

make || exit

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

sudo chown -R root.root $TCZ*

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

