dnl fs-version.m4 0.0.5
dnl m4 macro for versioning
dnl rob.taylor@collabora.co.uk
dnl
dnl AS_VERSION(PREFIX, RELEASE, ACTION_IF_NOT_RELEASE, ACTION_IF_RELEASE)
dnl example
dnl AS_VERSION(GST_VERSION, 1)
dnl
dnl this macro
dnl - defines and AC_SUBSTs [$PREFIX]_MAJOR, MINOR and MICRO, derived from version passed to
dnl AC_INIT
dnl - if RELEASE is 1, then we're in release mode, else in cvs/dev mode
dnl - defines and AC_SUBSTs [$PREFIX]_RELEASE, 1 if release, date otherwise
dnl - defines and AC_SUBSTs [$PREFIX]_IS_RELEASE, 1 if release, 0 otherwise
dnl - executes the relevant action
dnl
AC_DEFUN([FS_VERSION],
[
[$1]_VERSION_STRING=AC_PACKAGE_VERSION
[$1]_MAJOR=`echo $GNUCASH_VERSION_STRING | [ sed -e 's/^\([^\.]*\)\.\([^.]*\)\.\(.*\)$/\1/' ]`
[$1]_MINOR=`echo $GNUCASH_VERSION_STRING | [ sed -e 's/^\([^\.]*\)\.\([^.]*\)\.\(.*\)$/\2/' ]`
[$1]_MICRO=`echo $GNUCASH_VERSION_STRING | [ sed -e 's/^\([^\.]*\)\.\([^.]*\)\.\(.*\)$/\3/' ]`
[$1]_IS_RELEASE=[$2]
if test "x$[$1]_IS_RELEASE" == "x1";
then
AC_MSG_NOTICE(configuring [$1] for release)
[$1]_RELEASE=1
dnl execute action
ifelse([$7], , :, [$7])
else
AC_MSG_NOTICE(configuring [$1] for development with nano $NANO)
[$1]_RELEASE=`date +%Y%m%d_%H%M%S`
dnl execute action
ifelse([$8], , :, [$8])
fi
AC_DEFINE_UNQUOTED([$1]_RELEASE, "$[$1]_RELEASE", [Define the release version])
AC_DEFINE_UNQUOTED([$1]_IS_RELEASE, "$[$1]_DO_RELEASE", [Is a release])
AC_SUBST([$1]_RELEASE)
AC_SUBST([$1]_IS_RELEASE)
AC_DEFINE_UNQUOTED([$1]_MAJOR_VERSION, $[$1]_MAJOR_VERSION,
[$AC_PACKAGE_NAME Major version number])
AC_DEFINE_UNQUOTED(GNUCASH_MINOR_VERSION, $GNUCASH_MINOR_VERSION,
[$AC_PACKAGE_NAME Minor version number])
AC_DEFINE_UNQUOTED(GNUCASH_MICRO_VERSION, $GNUCASH_MICRO_VERSION,
[$AC_PACKAGE_NAME Micro version number])
AC_SUBST([$1]_MAJOR)
AC_SUBST([$1]_MINOR)
AC_SUBST([$1]_MICRO)
])