#!/bin/ksh93
#
# Copyright (c) 2013 Jens Elkner.
# License: CDDL 1.0
#
# Print m4 comments about who, where, when using which m4 mail directory and
# define the __HOST__ macro accordingly.

if [[ $1 == '-q' ]]; then
	printf "##### built on %T\n"
else
	PATH="/opt/ast/bin:/bin:/usr/bin"		# yes, we allow trickery
	_WHO=${ logname ; }
	[[ -z ${_WHO} ]] && _WHO="${LOGNAME}"
	_HOST=${ uname -n ; }
	[[ -z ${_HOST} ]] && _HOST=${ hostname; }
	if [[ -n ${_WHO} ]]; then
		printf "##### built by ${_WHO}@${_HOST} on %T\n"
	else
		printf "##### built automatically @${_HOST} on %T\n"
	fi
	print "##### in ${PWD/\/tmp_mnt}" \
		"\n##### using ${1/\/tmp_mnt} as configuration include directory" \
		"\ndefine(\`__HOST__', ${_HOST})dnl"
fi
