leo_sobral@2: dnl version.m4 0.0.5
leo_sobral@2: dnl autostars m4 macro for versioning
leo_sobral@2: dnl thomas@apestaart.org
leo_sobral@2: dnl
leo_sobral@2: dnl AS_VERSION(PACKAGE, PREFIX, MAJOR, MINOR, MICRO, NANO, ACTION_IF_NO_NANO, ACTION_IF_NANO)
leo_sobral@2: dnl example
leo_sobral@2: dnl AS_VERSION(gstreamer, GST_VERSION, 0, 3, 2,)
leo_sobral@2: dnl for a 0.3.2 release version
leo_sobral@2: dnl
leo_sobral@2: dnl this macro
leo_sobral@2: dnl - defines [$PREFIX]_MAJOR, MINOR and MICRO
leo_sobral@2: dnl - if NANO is empty, then we're in release mode, else in cvs/dev mode
leo_sobral@2: dnl - defines [$PREFIX], VERSION, and [$PREFIX]_RELEASE
leo_sobral@2: dnl - executes the relevant action
leo_sobral@2: dnl - AC_SUBST's PACKAGE, VERSION, [$PREFIX] and [$PREFIX]_RELEASE
leo_sobral@2: dnl   as well as the little ones
leo_sobral@2: dnl - doesn't call AM_INIT_AUTOMAKE anymore because it prevents
leo_sobral@2: dnl   maintainer mode from running ok
leo_sobral@2: dnl
leo_sobral@2: dnl don't forget to put #undef [$2] and [$2]_RELEASE in acconfig.h
leo_sobral@2: 
leo_sobral@2: AC_DEFUN([AS_VERSION],
leo_sobral@2: [
leo_sobral@2:   PACKAGE=[$1]
leo_sobral@2:   [$2]_MAJOR_VERSION=[$3]
leo_sobral@2:   [$2]_MINOR_VERSION=[$4]
leo_sobral@2:   [$2]_MICRO_VERSION=[$5]
leo_sobral@2:   NANO=[$6]
leo_sobral@2:   [$2]_NANO_VERSION=$NANO
leo_sobral@2:   if test "x$NANO" = "x" || test "x$NANO" = "x0";
leo_sobral@2:   then
leo_sobral@2:       AC_MSG_NOTICE(configuring [$1] for release)
leo_sobral@2:       VERSION=[$3].[$4].[$5]
leo_sobral@2:       [$2]_RELEASE=1
leo_sobral@2:       dnl execute action
leo_sobral@2:       ifelse([$7], , :, [$7])
leo_sobral@2:   else
leo_sobral@2:       AC_MSG_NOTICE(configuring [$1] for development with nano $NANO)
leo_sobral@2:       VERSION=[$3].[$4].[$5].$NANO
leo_sobral@2:       [$2]_RELEASE=`date +%Y%m%d_%H%M%S`
leo_sobral@2:       dnl execute action
leo_sobral@2:       ifelse([$8], , :, [$8])
leo_sobral@2:   fi
leo_sobral@2: 
leo_sobral@2:   [$2]_VERSION=$VERSION
leo_sobral@2:   AC_DEFINE_UNQUOTED([$2]_VERSION, "$[$2]_VERSION", [Define the version])
leo_sobral@2:   AC_SUBST([$2]_VERSION)
leo_sobral@2:   
leo_sobral@2:   AC_SUBST([$2]_RELEASE)
leo_sobral@2: 
leo_sobral@2:   AC_SUBST([$2]_MAJOR_VERSION)
leo_sobral@2:   AC_SUBST([$2]_MINOR_VERSION)
leo_sobral@2:   AC_SUBST([$2]_MICRO_VERSION)
leo_sobral@2:   AC_SUBST([$2]_NANO_VERSION)
leo_sobral@2:   AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Define the package name])
leo_sobral@2:   AC_SUBST(PACKAGE)
leo_sobral@2:   AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Define the version])
leo_sobral@2:   AC_SUBST(VERSION)
leo_sobral@2: ])