#!/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/11/32/{include,man,share}
rm -rf $TmpInstDir/usr/share/pgsql/11/32/lib/{*.*a,pkgconfig,pgxs,libecpg*,libpgtypes*}
rm -rf $TmpInstDir/usr/share/postgresql

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

