	patch -p0 -i $SRC/$isim-config.patch
	patch -p0 -i $SRC/bdb.yama
    patch -p1 -i "${SRC}"/openldap-ntlm.patch
  sed -i 's|-m 644 $(LIBRARY)|-m 755 $(LIBRARY)|' libraries/{liblber,libldap,libldap_r}/Makefile.in
  sed -i 's|#define LDAPI_SOCK LDAP_RUNDIR LDAP_DIRSEP "run" LDAP_DIRSEP "ldapi"|#define LDAPI_SOCK LDAP_DIRSEP "run" LDAP_DIRSEP "openldap" LDAP_DIRSEP "ldapi"|' include/ldap_defaults.h
  sed -i 's|%LOCALSTATEDIR%/run|/run/openldap|' servers/slapd/slapd.{conf,ldif}
  sed -i 's|-$(MKDIR) $(DESTDIR)$(localstatedir)/run|-$(MKDIR) $(DESTDIR)/run/openldap|' servers/slapd/Makefile.in
	./configure --prefix=/usr \
		--sysconfdir=/etc \
		--libexecdir=/usr/sbin \
		--localstatedir=/var/openldap \
		--enable-syslog \
		--with-threads \
		--with-tls \
		--with-cyrus-sasl \
		--enable-spasswd \
		--enable-dynamic \
		--enable-ipv6 \
		--enable-modules \
		--enable-crypt \
		--enable-rewrite \
		--enable-bdb \
		--enable-hdb \
		--enable-ldap \
		--enable-meta \
		--enable-monitor \
		--enable-dnssrv \
		--enable-null \
		--enable-perl \
		--enable-aci \
		--enable-shared

 sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool

  make

  make -C contrib/slapd-modules/nssov OPT="$CFLAGS $CPPFLAGS" prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap
  make -C contrib/slapd-modules/autogroup OPT="$CFLAGS $CPPFLAGS" prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap
  make -C contrib/slapd-modules/lastbind OPT="$CFLAGS $CPPFLAGS" prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap
  make -C contrib/slapd-modules/passwd/sha2 OPT="$CFLAGS $CPPFLAGS" prefix=/usr libexecdir=/usr/lib sysconfdir=/etc/openldap