#!/bin/sh

# generate flags for apply.pl - from various pieces ...
# highly dependent on a custom environment ...

bindir=$1
# optional to force another OOBUILDDIR in the split build
builddir=$2

if test "z$bindir" = "z"; then
    echo "Serious error - requires path to bindir"
    exit 1
fi

cd $bindir
. ./setup >/dev/null 2>&1

SECTIONS="$OOO_ADDITIONAL_SECTIONS"

# do we use another builddir?
test -n "$builddir" && OOBUILDDIR=$builddir

echo -n "--distro=$DISTRO"

if test -d $OOBUILDDIR/ct2n ; then
    SECTIONS="$SECTIONS,CT2N"
fi
if test -d $OOBUILDDIR/nlpsolver ; then
    SECTIONS="$SECTIONS,NLPSolver"
fi

# The localize.sdf's are created during the build when they do not exits.
# Additionally, they are created using something like echo > localize.sdf, so
# even test -s is not helpful here :-(
if test -d $OOBUILDDIR/l10n; then
    SECTIONS="$SECTIONS,Localize"
fi

if test "$UNSTABLE_WP" = "YES" ; then
    SECTIONS="$SECTIONS,UnstableWP"
fi
if test "z$PIECE" != "z"; then
    echo -n " --pieces"
    SECTIONS="$SECTIONS,Piece"
fi
if test "$ENABLE_GRAPHITE" = "TRUE"; then
    SECTIONS="$SECTIONS,Graphite"
fi

SECTIONS=`echo $SECTIONS | sed 's/^,//'`

if test -n "$SECTIONS" ; then
    echo -n " --additional-sections=$SECTIONS"
fi

if test "$DEFUZZ_PATCHES" = "YES"; then
    echo -n " --defuzz"
fi
