#!/bin/sh

source ../Config.sh

pp_linkincl_local () {
    mkdir -p "$FW_TOPDIR/include" || return 1
    rm -f "$FW_TOPDIR/include/oem"
    if [ -d "$FW_TOPDIR/${REL_OEMDIR}/includes" ]; then
	ln -s "../${REL_OEMDIR}/includes" "$FW_TOPDIR/include/oem" || return 1
    fi
    return 0
}

pp_copyincl_local () {
    incl_destdir="$1"
    if [ -z "$incl_destdir" ]; then
	echo "No include destination directory specified!"
	return 1
    elif ! $(echo "$incl_destdir" | grep -q '^[[:space:]]*/') ; then
	echo "The include destination must be absolute!"
	return 1
    fi
    mkdir -p "$incl_destdir/oem" || return 1

    dirname="$FW_TOPDIR/${REL_OEMDIR}/includes"
    if [ -d "$dirname" ]; then
	pushd "$dirname" > /dev/null
	    e=`find '(' -name CVS -o -name '*~' -o -name '.?*' ')' -prune -o ! -type d \
		'(' -exec cp -p --parent --remove-destination "{}" "$incl_destdir/oem" ';' \
		    -o -print ')' || echo error`
	popd > /dev/null
	[ -n "$e" ] && return 1
    else
	echo "'$dirname' dos not exist!"
	return 1
    fi
    return 0
}

pp_do "$@"
