#!/bin/sh
#

EXT=libnghttp2
TCZ=/tmp/$EXT/TCZ

sudo rm -rf /tmp/$EXT

# load the following .tcz's to build the full package
#		jemalloc-dev libxml2-dev openssl-dev libevent-dev

DEPS=""

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 \
	--enable-lib-only \
	--disable-python-bindings \
	|| exit

make || exit

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

mkdir -p $TCZ/usr/local/libexec
mkdir -p $TCZ/usr/local/lib
mv $TCZ-dev/usr/local/share/nghttp2 $TCZ/usr/local/libexec
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

