#!/bin/sh

# set -x

if test -x /usr/xpg4/bin/m4
then
    # solaris m4 has no searchpath support. Be sure ./csbs.m4 exists, e.g. by
    # running bootstrap.
    M4=/usr/xpg4/bin/m4
else
    # assume GNU m4
    M4="m4 -I ~/.csbs -I /usr/local/share/csbs -I /opt/csbs -I /usr/share/csbs"
fi

# we'd like to use date --rfc .  However, that'd need GNU date.
# /usr/bin/id doesn't grok -un.  Not all shells set $USER.  Therefore: let's
#  hope the xpg4 one helps us.
$M4 -DCSBS_DATE="[`date`]" -DCSBS_ID="`/usr/xpg4/bin/id -un`" \
  -DCSBS_HOSTNAME="`hostname`" Makefile.m4 > Makefile

# set +x

echo "Run 'make -f solaris/Makefile' to create a binary package.  Alternative"
echo "popular make targets: 'Makefile' and 'source'."