#!/bin/sh
PATH=/usr/ucb:$PATH
export PATH
cd `dirname $0`
if [ ! -f ./antibadmail.h ]; then
  echo Locate this script in antibadmail source directory.
  exit 2
fi
if [ x"$1" = x"" -o ! -f PREFIX ]; then
  dcontrol=`awk '/^#define[ \t]*CONTROLDIR/{print $3}' antibadmail.h \
	  | sed -e 's/^"//' -e 's/"$//' `
  dprefix=`dirname $dcontrol`

  [ -d /var/abm -o ! -d $dprefix ] && dprefix=/var/abm
  dcontrol=$dprefix/control

  cat<<_EOF_
Define antibadmail installation prefix.
  If your system is running qmail, using "/var/qmail" as antibadmail prefix
  is reasonable.
  If you do not have /var/qmail on your system, /var/abm is recommendable.

_EOF_
  echo -n "antibadmail prefix(default $dprefix): "
  read ans
  prefix=${ans:-$dprefix}

  echo $prefix > PREFIX
fi

grep '^D_FLAGS' Makefile | sed -e 's/[^=]*=//' > CFLAGS
if [ x"$dprefix" != x"$prefix" ]; then
  echo "-DCONTROLDIR=\"$prefix/control\"" >> CFLAGS
fi
