#!/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_clean_local () {
    rm -rf build-target
}

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

    # configure
    if [ ! -f build-target/Makefile ]; then
	echo "Running configure ..."
	mkdir -p build-target
	cd build-target
	/bin/sh ../gdb/gdbserver/configure \
		--host="${HOST_SYSTEM}" \
		--prefix=/ \
		--bindir=/bin.debug
	cd "$OLDPWD"
    fi

    # make / install
    echo "Running make ..."
    make -C build-target all install
}

pp_do "$@"
