#! /bin/sh

##  $Id: mkversion,v 1.1 2000/04/03 06:41:56 rra Exp $
##
##  Create version.c from INN version information.
##
##  Makefile.global contains the INN version number and extra version
##  information (if any).  This is passed to use by lib/Makefile as our
##  first and second arguments.  Generate version.c with const variables
##  containing that information in convenient forms, and include
##  INNVersion() for backwards compatibility with old users of libinn.

version="$1"
extra="$2"
string="INN $version"
if [ x"$extra" = x"CVS prerelease" ] ; then
    date=`date +%Y%m%d`
    extra="$date $extra"
fi
if [ -n "$extra" ] ; then
    string="$string ($extra)"
fi
array=`echo "$version" | sed 's/\./, /g'`

cat > version.c <<EOF
/* Automatically generated by mkversion, edit Makefile.global to change. */

const int inn_version[3]        = { $array };
const char inn_version_extra[]  = "$extra";
const char inn_version_string[] = "$string";

/* This function is deprecated, and is provided solely for backwards
   compatibility for non-INN users of libinn.  Callers should reference
   inn_version_string directly instead. */
const char *
INNVersion(void)
{
    return inn_version_string;
}
EOF
