#!/bin/sh
#
ME=$(readlink -f "$0")
MEDIR=${ME%/*}

EXT=openldap

. $MEDIR/phase-default-init.sh

DEPS="openssl-dev libltdl groff unixODBC-dev unixODBC cyrus-sasl-lite-dev cyrus-sasl-lite
 libtool-dev perl5"

. $MEDIR/phase-default-deps.sh
. $MEDIR/phase-cc-opts-no-flto.sh

#make clean
./configure \
	--prefix=/usr/local \
	--localstatedir=/var \
	--with-threads \
	--with-tls=openssl \
	--with-cyrus-sasl \
	--enable-dynamic \
	--enable-shared \
	--enable-syslog \
	--enable-slapd \
	--enable-spasswd \
	--enable-modules \
	--enable-backends=mod \
	--enable-overlays=mod \
	--disable-bdb \
	--disable-hdb \
	--disable-ndb \
	--with-odbc=unixodbc \
	|| exit

make depend || exit

. $MEDIR/phase-default-make.sh
. $MEDIR/phase-default-make-install.sh

rm -rf $TCZ/opt/run

mkdir -m 775 -p $TCZ/usr/local/tce.installed
cat >$TCZ/usr/local/tce.installed/$EXT <<EOF
#!/bin/sh
#
[ -e /usr/local/etc/$EXT/ldap.conf ] || cp /usr/local/etc/$EXT/ldap.conf.default /usr/local/etc/$EXT/ldap.conf
[ -e /usr/local/etc/$EXT/slapd.conf ] || cp /usr/local/etc/$EXT/slapd.conf.default /usr/local/etc/$EXT/slapd.conf
[ -e /usr/local/etc/$EXT/slapd.ldif ] || cp /usr/local/etc/$EXT/slapd.ldif.default /usr/local/etc/$EXT/slapd.ldif
EOF

mkdir -p $TCZ-dev/usr/local/lib
mv $TCZ/usr/local/include $TCZ-dev/usr/local
mv $TCZ/usr/local/lib/*.a $TCZ-dev/usr/local/lib
mv $TCZ/usr/local/lib/*.la $TCZ-dev/usr/local/lib

mkdir -p $TCZ-doc/usr/local
mv $TCZ/usr/local/share $TCZ-doc/usr/local

rm $TCZ/usr/local/etc/$EXT/ldap.conf
rm $TCZ/usr/local/etc/$EXT/slapd.conf
rm $TCZ/usr/local/etc/$EXT/slapd.ldif

. $MEDIR/phase-default-strip.sh
. $MEDIR/phase-set-perms-installed.sh
. $MEDIR/phase-default-squash-tcz.sh

