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