#!/bin/sh

source ../Config.sh

PP_PUBLIC_INCLUDES="include/lber.h include/lber_types.h include/ldap.h
		    include/ldap_cdefs.h include/ldap_schema.h
		    include/ldap_utf8.h  include/ldap_features.h"

pp_clean_local () {
    pp_clean_default
    # force autoreconf
    rm -f configure
}

pp_build_local () {
    # force configure
    if [ ! -f configure -o "$PP_FORCE_FULL_BUILD" = "1" ]; then
	echo "Running autoreconf ..."
	libtoolize --copy --force
	autoreconf -f -i
	rm -f Makefile
    fi

    # some variables for configure/make
    export CFLAGS="$FW_CFLAGS_3RDPARTY -ffunction-sections -fdata-sections"

    # configure
    if [ ! -f Makefile ]; then
	echo "Running configure ..."
	./configure \
		--host="$HOST_SYSTEM" \
		--prefix=/ \
		--disable-debug \
		--disable-proctitle \
		--enable-ipv6 \
		--disable-local \
		--without-readline \
		--with-threads \
		--disable-slapd \
		--disable-slurpd \
		--disable-shared \
		--enable-static \
		--enable-x-compile \
		--with-tls \
		--with-yielding_select=yes
	sed -i -e "s,^\(sys_lib_search_path_spec=\).*,\1\"$DESTDIR/lib $DESTDIR/usr/lib\"," libtool
    fi

    # make / install
    echo "Running make ..."
    make all install

    # delete installed libtool files
    for f in `find . -name \*.la`; do
	rm -f $DESTDIR/lib/`basename $f`
    done
}

pp_do "$@"
