#!/bin/sh
#

EXT=lighttpd
TCZ=/tmp/$EXT/TCZ

sudo rm -rf /tmp/$EXT

DEPS="openssl-dev gdbm-dev pcre-dev pcre"

NOTFOUND=""
for a in compiletc bash file squashfs-tools $DEPS
         do tce-load -i $a || tce-load -iwl $a || NOTFOUND=x
done
test -z "$NOTFOUND" || exit

#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

make install DESTDIR=$TCZ || exit
for a in $(find $TCZ -type f); do file -b $a | grep -q '^ELF .*not stripped$' && strip --strip-unneeded $a; done

sudo chown -R root.root $TCZ*

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

