#!/bin/sh
# IRCD installer, called by make install at top level

DPATH=`grep '#define.DPATH' include/options.h|awk '{print $3}'|tr -d \"`;
if [ "x$DPATH" = "x" ] ; then
DPATH=`grep '#define.DPATH' include/config.h|awk '{print $3}'|tr -d \"`;
fi
SPATH=`grep '#define.SPATH' include/options.h|awk '{print $3}'|tr -d \"`;
if [ "x$SPATH" = "x" ] ; then
SPATH=`grep '#define.SPATH' include/config.h|awk '{print $3}'|tr -d \"`;
fi

base_SPATH=`basename $SPATH`;

if [ $base_SPATH = $SPATH ] ; then
  if [ ! -f ${DPATH}${SPATH} ] ; then
    echo installing ircd as ${DPATH}${SPATH};
    ./install-sh -c src/ircd ${DPATH};
  else
    echo installing ircd as ${DPATH}${SPATH};
    echo previous ircd saved as ircd.old;
    mv ${DPATH}${SPATH} ${DPATH}${SPATH}.old;
    ./install-sh -c src/ircd ${DPATH};
  fi;
else
  if [ ! -f $SPATH ] ; then
     echo installing ircd as ${SPATH};
     ./install-sh -c src/ircd `dirname $SPATH`;
  else
     echo installing ircd as ${SPATH};
     echo previous ircd saved as ircd.old;
     mv ${SPATH} ${SPATH}.old;
     ./install-sh -c src/ircd `dirname $SPATH`;
  fi;
fi;

