#!/bin/sh
#
# $Id$
# Author: Robert Story <rstory@freesnmp.com>
#
########################################################################
########################################################################

usage()
{
   echo "Usage: $0  [-d|-x] [-s SRCD]"
   echo ""
   echo " -s SRCDIR  : soure directory [$HOME/src/net-snmp-VERSION]"
   echo ""
   echo " -x : configure extra features for pre-release testing"
   echo " -d : configure for binary distribution"
   exit 1
}

#set -x


#
# find nsb-platform based on the path to this script
#
EXE_PATH=`dirname $0`
if [ -f $EXE_PATH/nsb-functions ];then
   . $EXE_PATH/nsb-functions
elif [ -f $HOME/bin/nsb-functions ]; then
   . $HOME/bin/nsb-functions
elif [ -f nsb-functions ];then
   . nsb-functions
else
   echo "Cannot find nsb-functions in $EXE_PATH, $HOME/bin or $PWD"
   exit 1
fi


########################################################################
########################################################################
NSB_CONFIG_ALL=2

#      x)  x=$OPTARG ;;
while getopts ds:x opt
do
    case "$opt" in
      d)  NSB_CONFIG_ALL=0;;
      s)  SRCD=$OPTARG ;;
      x)  NSB_CONFIG_ALL=1;;
      \?)# unknown flag
        usage;;
    esac
done
shift `expr $OPTIND - 1`

if [ $NSB_CONFIG_ALL -eq 2 ]; then
   echo "You must specify -d or -x"
   usage
fi

if [ "x$SRCD" = "x" ]; then
   for x in . $HOME/src/net-snmp
   do
      if [ -f $x/configure ]; then
         SRCD=$x
         break
      fi
   done
   if [ "x$SRCD" = "x" ]; then
      echo "Couldn't find a source directory. Please specify one for me."
      usage
   fi
fi


########################################################################
########################################################################
if [ $NSB_CONFIG_ALL -eq 0 ];then
    nsb_config_dist $SRCD
else
    nsb_config_all $SRCD
fi
