#!/bin/sh -eu

output="${1:-local_params}"
: ${EXIM_VER:?Need the EXIM_VER environment variable}

nicedate="$(date +"%d %b %Y")"

if which locale >/dev/null; then
    charset="$(locale | grep ^LC_CTYPE=)"
else
    charset=unknown
fi

exec > "$output"
cat <<EOTEMPLATE
. # if this file changes, the build process will rebuild everything
. # locale's charset $charset
.macro version
${EXIM_VER}
.endmacro
.macro fulldate
${nicedate}
.endmacro
.macro year
$(date +%Y)
.endmacro
.macro versiondatexml
<revnumber>${EXIM_VER}</revnumber>
<date>${nicedate}</date>
.endmacro
EOTEMPLATE
