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