#!/bin/sh
#

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

EXT=psqlodbc
TCZ=/tmp/$EXT/TCZ

sudo rm -rf /tmp/$EXT

#make clean
./configure \
	--with-unixodbc \
	--with-libpq=/usr/local/pgsql95 \
	|| exit

make || exit

if [ $(grep -q '^install-strip:' Makefile) ]; then
	make install-strip DESTDIR=$TCZ
else
	make install DESTDIR=$TCZ
	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

