#!/bin/bash

# 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
source ./setup >& /dev/null

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

echo -n "--distro=$DISTRO";
if test -d $OOBUILDDIR/binfilter; then
    echo -n " --distro=Binfilter";
fi
if test -d $OOBUILDDIR/zlib; then
    echo -n " --distro=System";
fi
if test -d $OOBUILDDIR/sdk_oo; then
    echo -n " --distro=Sdk";
fi
if test -d $OOBUILDDIR/swext -o -d $OOBUILDDIR/sdext -o -d $OOBUILDDIR/reportbuilder; then
    echo -n " --distro=Extensions";
fi
if grep localize.sdf $OOBUILDDIR/sw/source/ui/app/localize.sdf > /dev/null 2>&1 ; then
    echo -n " --distro=Localize";
fi
if test "$UNSTABLE_WP" = "YES" ; then
    echo -n " --distro=UnstableWP";
fi
if test -n "$OOO_ADDITIONAL_SECTIONS" ; then
    echo -n " --additional-sections=$OOO_ADDITIONAL_SECTIONS";
fi
if test "z$PIECE" != "z"; then
    echo -n " --pieces --distro=Piece";
fi ;
if test "$DEFUZZ_PATCHES" = "YES"; then
    echo -n " --defuzz"
fi ;
if test "$ENABLE_GRAPHITE" = "TRUE"; then
    echo -n "--distro=Graphite";
fi
