renatofilho@610: dnl as-version.m4 0.1.0
renatofilho@610: 
renatofilho@610: dnl autostars m4 macro for versioning
renatofilho@610: 
renatofilho@610: dnl Thomas Vander Stichele <thomas at apestaart dot org>
renatofilho@610: 
renatofilho@610: dnl $Id: as-version.m4,v 1.1 2005/06/18 18:02:46 burgerman Exp $
renatofilho@610: 
renatofilho@610: dnl AS_VERSION(PACKAGE, PREFIX, MAJOR, MINOR, MICRO, NANO,
renatofilho@610: dnl            ACTION-IF-NO-NANO, [ACTION-IF-NANO])
renatofilho@610: 
renatofilho@610: dnl example
renatofilho@610: dnl AS_VERSION(gstreamer, GST_VERSION, 0, 3, 2,)
renatofilho@610: dnl for a 0.3.2 release version
renatofilho@610: 
renatofilho@610: dnl this macro
renatofilho@610: dnl - defines [$PREFIX]_MAJOR, MINOR and MICRO
renatofilho@610: dnl - if NANO is empty, then we're in release mode, else in cvs/dev mode
renatofilho@610: dnl - defines [$PREFIX], VERSION, and [$PREFIX]_RELEASE
renatofilho@610: dnl - executes the relevant action
renatofilho@610: dnl - AC_SUBST's PACKAGE, VERSION, [$PREFIX] and [$PREFIX]_RELEASE
renatofilho@610: dnl   as well as the little ones
renatofilho@610: dnl - doesn't call AM_INIT_AUTOMAKE anymore because it prevents
renatofilho@610: dnl   maintainer mode from running ok
renatofilho@610: dnl
renatofilho@610: dnl don't forget to put #undef [$2] and [$2]_RELEASE in acconfig.h
renatofilho@610: dnl if you use acconfig.h
renatofilho@610: 
renatofilho@610: AC_DEFUN([AS_VERSION],
renatofilho@610: [
renatofilho@610:   PACKAGE=[$1]
renatofilho@610:   [$2]_MAJOR=[$3]
renatofilho@610:   [$2]_MINOR=[$4]
renatofilho@610:   [$2]_MICRO=[$5]
renatofilho@610:   NANO=[$6]
renatofilho@610:   [$2]_NANO=$NANO
renatofilho@610:   if test "x$NANO" = "x" || test "x$NANO" = "x0";
renatofilho@610:   then
renatofilho@610:       AC_MSG_NOTICE(configuring [$1] for release)
renatofilho@610:       VERSION=[$3].[$4].[$5]
renatofilho@610:       [$2]_RELEASE=1
renatofilho@610:       dnl execute action
renatofilho@610:       ifelse([$7], , :, [$7])
renatofilho@610:   else
renatofilho@610:       AC_MSG_NOTICE(configuring [$1] for development with nano $NANO)
renatofilho@610:       VERSION=[$3].[$4].[$5].$NANO
renatofilho@610:       [$2]_RELEASE=0.`date +%Y%m%d.%H%M%S`
renatofilho@610:       dnl execute action
renatofilho@610:       ifelse([$8], , :, [$8])
renatofilho@610:   fi
renatofilho@610: 
renatofilho@610:   [$2]=$VERSION
renatofilho@610:   AC_DEFINE_UNQUOTED([$2], "$[$2]", [Define the version])
renatofilho@610:   AC_SUBST([$2])
renatofilho@610:   AC_DEFINE_UNQUOTED([$2]_RELEASE, "$[$2]_RELEASE", [Define the release version])
renatofilho@610:   AC_SUBST([$2]_RELEASE)
renatofilho@610: 
renatofilho@610:   AC_SUBST([$2]_MAJOR)
renatofilho@610:   AC_SUBST([$2]_MINOR)
renatofilho@610:   AC_SUBST([$2]_MICRO)
renatofilho@610:   AC_SUBST([$2]_NANO)
renatofilho@610:   AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Define the package name])
renatofilho@610:   AC_SUBST(PACKAGE)
renatofilho@610:   AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Define the version])
renatofilho@610:   AC_SUBST(VERSION)
renatofilho@610: ])
renatofilho@610: