#!/bin/sh

source ../Config.sh

# This is a debug tool: Do not build it for a final firmware
[ "$PP_BUILD_TYPE" = "final" ] && exit 0

pp_build_local () {
    # force configure
    if [ "$PP_FORCE_FULL_BUILD" = "1" ]; then
	rm -f Makefile
    fi

    # some variables for configure/make
    export LSOF_CC="${CROSS}gcc"
    export LINUX_CLIB="-DGLIBCV=2"
    export LSOF_DEBUG="${FW_CFLAGS_3RDPARTY}"

    # configure
    if [ ! -f Makefile ]; then
	echo "Running configure ..."
	./Configure -n linux
    fi

    # make / install
    echo "Running make ..."
    make
    ${INSTALL} -d ${DESTDIR}/bin.debug
    ${INSTALL} -m 755 lsof ${DESTDIR}/bin.debug/
}

pp_do "$@"
