#!/bin/bash
# Copyright (c) 2000-2019 Synology Inc. All rights reserved.

if [ "x$NOSTRIP" = "xNOSTRIP" ]; then
	make DESTDIR=$TmpInstDir install
	make -C contrib/cube DESTDIR=$TmpInstDir install
else
	make DESTDIR=$TmpInstDir install-strip
	make -C contrib/cube DESTDIR=$TmpInstDir install-strip
fi

rm -rf $TmpInstDir/usr/share/pgsql/9.3/32/lib/{*.*a,pkgconfig,libecpg*,libpgtypes*,pgxs}
rm -rf $TmpInstDir/usr/share/pgsql/9.3/32/{include,man,share}
rm -rf $TmpInstDir/usr/share/pgsql/9.3/share

find $TmpInstDir/usr/share/pgsql/9.3/32/lib/* -name "*.so" | grep -vE '(libpq|plpgsql|libpqwalreceiver|cube)' | xargs rm -f
find $TmpInstDir/usr/share/pgsql/9.3/32/bin/* | grep -vE '(\/postgres|pg_controldata|pg_ctl|pg_dump)' | xargs rm -f
