#!/bin/sh
#
# This script is used to build proxy plugins in the workspace
#

# This should get replaced by build script with the actual
# PTP build version number. The script can also be run out of CVS,
# in which case there is no version.
VERSION="_4.0.0.201003160939"
if [ `expr "$VERSION" : "_@[^@]*@"` -gt 0 ]; then
	VERSION=
fi

KNOWN_PLUGINS="\
	org.eclipse.ptp.utils$VERSION\
	org.eclipse.ptp.proxy$VERSION\
	org.eclipse.ptp.debug.sdm$VERSION\
	org.eclipse.ptp.rm.ibm.ll.proxy$VERSION\
	org.eclipse.ptp.rm.ibm.pe.proxy$VERSION\
	org.eclipse.ptp.rm.pbs.proxy$VERSION\
	org.eclipse.ptp.rm.slurm.proxy$VERSION"
	
UTILS_CONFIGURE_OPTIONS=""
PROXY_CONFIGURE_OPTIONS=""
SDM_CONFIGURE_OPTIONS=""
IBM_LL_CONFIGURE_OPTIONS=""
IBM_PE_CONFIGURE_OPTIONS=""
PBS_CONFIGURE_OPTIONS="--with-pbs=/usr/local/torque"
SLURM_CONFIGURE_OPTIONS="--with-slurm=/usr/local/slurm"

set "$UTILS_CONFIGURE_OPTIONS"\
    "$PROXY_CONFIGURE_OPTIONS"\
    "$SDM_CONFIGURE_OPTIONS"\
    "$IBM_LL_CONFIGURE_OPTIONS"\
    "$IBM_PE_CONFIGURE_OPTIONS"\
    "$PBS_CONFIGURE_OPTIONS"\
    "$SLURM_CONFIGURE_OPTIONS"
		
PARENT=`dirname $PWD`
PLUGIN=`basename $PWD`
PREFIX=$PARENT/$PLUGIN

if [ ! -d bin ]; then
	mkdir bin
fi

cd $PARENT

for plugin in `echo $KNOWN_PLUGINS`
do
	if [ -e $plugin/configure ]; then
		echo "Building $plugin..."
		(cd $plugin; \
		sh configure --prefix=$PREFIX $1 && \
		chmod +x install-sh && \
		make install)
		echo; echo
	fi
	shift
done

exit 0

