#!/bin/bash
#
# $Id: nsb-config,v 1.3 2002/09/10 19:05:24 rstory Exp $
# 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 te path to this script
#
EXE_PATH=${0%nsb-config}
EXE_PATH=${EXE_PATH%/}
if [ -f $EXE_PATH/nsb-functions ];then
   source $EXE_PATH/nsb-functions
elif [ -f $HOME/bin/nsb-functions ]; then
   source $HOME/bin/nsb-functions
elif [ -f nsb-functions ];then
   source 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 [ -z "$SRCD" ]; then
   for x in . $HOME/src/net-snmp
   do
      if [ -f $x/configure ]; then
         SRCD=$x
         break
      fi
   done
   if [ -z "$SRCD" ]; 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
