#!/bin/sh
# SPDX-License-Identifier: BSD-3-Clause-CMU
# See COPYING file at the root of the distribution for more details.
#
# This program takes a shell script and configures for the following
# variables:    @DIR@
#               @AWK@
#               @SED@
#
# Usage: config_script <filename> [<awk>] [<sed>]
#

FILE=$1
AWK=$2
SED=$3

# Grr.... not all Unix's have the dirname command
TMP=`echo  $1 | sed -e 's;[^/]*$;;' -e 's/^$/./'`
DIR=`cd ${TMP}; pwd`

if test "${AWK}x" = "x" ; then
        AWK=awk
fi
if test "${SED}x" = "x" ; then
        SED=sed
fi
sed -e "s;@DIR@;${DIR};" -e "s;@AWK@;${AWK};" -e "s;@SED@;${SED};" $FILE
