1 dnl Copyright (C) 2009 Sun Microsystems, Inc.
2 dnl This file is free software; Sun Microsystems, Inc.
3 dnl gives unlimited permission to copy and/or distribute it,
4 dnl with or without modifications, as long as this notice is preserved.
6 AC_DEFUN([PANDORA_TEST_VC_DIR],[
7 pandora_building_from_vc=no
9 if test -d ".bzr" ; then
10 pandora_building_from_bzr=yes
11 pandora_building_from_vc=yes
13 pandora_building_from_bzr=no
16 if test -d ".svn" ; then
17 pandora_building_from_svn=yes
18 pandora_building_from_vc=yes
20 pandora_building_from_svn=no
23 if test -d ".hg" ; then
24 pandora_building_from_hg=yes
25 pandora_building_from_vc=yes
27 pandora_building_from_hg=no
30 if test -d ".git" ; then
31 pandora_building_from_git=yes
32 pandora_building_from_vc=yes
34 pandora_building_from_git=no
38 AC_DEFUN([PANDORA_BUILDING_FROM_VC],[
39 m4_syscmd(PANDORA_TEST_VC_DIR
40 m4_if(PCT_NO_VC_CHANGELOG,yes,[
48 PANDORA_RELEASE_DATE=`date +%Y.%m`
49 PANDORA_RELEASE_NODOTS_DATE=`date +%Y%m`
53 PANDORA_VC_REVID="unknown"
54 PANDORA_VC_BRANCH="bzr-export"
56 if test "${pandora_building_from_bzr}" = "yes"; then
57 echo "# Grabbing changelog and version information from bzr"
58 PANDORA_BZR_REVNO=`bzr revno`
59 if test "x$PANDORA_BZR_REVNO" != "x${PANDORA_VC_REVNO}" ; then
60 PANDORA_VC_REVNO="${PANDORA_BZR_REVNO}"
61 PANDORA_VC_REVID=`bzr log -r-1 --show-ids | grep revision-id | cut -f2 -d' ' | head -1`
62 PANDORA_VC_BRANCH=`bzr nick`
63 PANDORA_VC_TAG=`bzr tags -r-1 | cut -f1 -d' ' | head -1`
64 PANDORA_VC_LATEST_TAG=`bzr tags --sort=time | grep -v '\?'| cut -f1 -d' ' | tail -1`
65 if test "x${vc_changelog}" = "xyes"; then
66 bzr log --gnu > ChangeLog
69 elif test "${pandora_building_from_git}" = "yes"; then
70 echo "# Grabbing changelog and version information from git"
71 PANDORA_GIT_REVID=`git --no-pager log --max-count=1 | cut -f2 -d' ' | head -1`
72 if test "x$PANDORA_GIT_REVID" != "x${PANDORA_VC_REVNO}" ; then
73 PANDORA_VC_REVID="${PANDORA_GIT_REVID}"
74 PANDORA_VC_BRANCH=`git branch | grep -Ei "\* (.*)" | cut -f2 -d' '`
78 if ! test -d config ; then
82 if test "${pandora_building_from_bzr}" = "yes" -o ! -f config/pandora_vc_revinfo ; then
83 cat > config/pandora_vc_revinfo.tmp <<EOF
84 PANDORA_VC_REVNO=${PANDORA_VC_REVNO}
85 PANDORA_VC_REVID=${PANDORA_VC_REVID}
86 PANDORA_VC_BRANCH=${PANDORA_VC_BRANCH}
87 PANDORA_VC_TAG=${PANDORA_VC_TAG}
88 PANDORA_VC_LATEST_TAG=${PANDORA_VC_LATEST_TAG}
89 PANDORA_RELEASE_DATE=${PANDORA_RELEASE_DATE}
90 PANDORA_RELEASE_NODOTS_DATE=${PANDORA_RELEASE_NODOTS_DATE}
92 if ! diff config/pandora_vc_revinfo.tmp config/pandora_vc_revinfo >/dev/null 2>&1 ; then
93 mv config/pandora_vc_revinfo.tmp config/pandora_vc_revinfo
95 rm -f config/pandora_vc_revinfo.tmp
100 AC_DEFUN([_PANDORA_READ_FROM_FILE],[
101 $1=`grep $1 $2 | cut -f2 -d=`
104 AC_DEFUN([PANDORA_VC_VERSION],[
105 AC_REQUIRE([PANDORA_BUILDING_FROM_VC])
109 AS_IF([test -f ${srcdir}/config/pandora_vc_revinfo],[
110 _PANDORA_READ_FROM_FILE([PANDORA_VC_REVNO],${srcdir}/config/pandora_vc_revinfo)
111 _PANDORA_READ_FROM_FILE([PANDORA_VC_REVID],${srcdir}/config/pandora_vc_revinfo)
112 _PANDORA_READ_FROM_FILE([PANDORA_VC_BRANCH],
113 ${srcdir}/config/pandora_vc_revinfo)
114 _PANDORA_READ_FROM_FILE([PANDORA_VC_TAG],
115 ${srcdir}/config/pandora_vc_revinfo)
116 _PANDORA_READ_FROM_FILE([PANDORA_VC_LATEST_TAG],
117 ${srcdir}/config/pandora_vc_revinfo)
118 _PANDORA_READ_FROM_FILE([PANDORA_RELEASE_DATE],
119 ${srcdir}/config/pandora_vc_revinfo)
120 _PANDORA_READ_FROM_FILE([PANDORA_RELEASE_NODOTS_DATE],
121 ${srcdir}/config/pandora_vc_revinfo)
123 AS_IF([test "x${PANDORA_VC_BRANCH}" != x"${PACKAGE}"],[
124 PANDORA_RELEASE_COMMENT="${PANDORA_VC_BRANCH}"
126 PANDORA_RELEASE_COMMENT="trunk"
129 AS_IF([test "x${PANDORA_VC_TAG}" != "x"],[
130 PANDORA_RELEASE_VERSION="${PANDORA_VC_TAG}"
132 AS_IF([test "x${PANDORA_VC_LATEST_TAG}" != "x"],[
133 PANDORA_RELEASE_VERSION="${PANDORA_VC_LATEST_TAG}.${PANDORA_VC_REVNO}"
135 PANDORA_RELEASE_VERSION="${PANDORA_RELEASE_DATE}.${PANDORA_VC_REVNO}"
138 changequote(<<, >>)dnl
139 PANDORA_RELEASE_ID=`echo ${PANDORA_RELEASE_VERSION} | sed 's/[^0-9]//g'`
143 VERSION="${PANDORA_RELEASE_VERSION}"
144 AC_DEFINE_UNQUOTED([PANDORA_RELEASE_VERSION],["${PANDORA_RELEASE_VERSION}"],
145 [The real version of the software])
146 AC_SUBST(PANDORA_VC_REVNO)
147 AC_SUBST(PANDORA_VC_REVID)
148 AC_SUBST(PANDORA_VC_BRANCH)
149 AC_SUBST(PANDORA_RELEASE_DATE)
150 AC_SUBST(PANDORA_RELEASE_NODOTS_DATE)
151 AC_SUBST(PANDORA_RELEASE_COMMENT)
152 AC_SUBST(PANDORA_RELEASE_VERSION)
153 AC_SUBST(PANDORA_RELEASE_ID)
156 AC_DEFUN([PANDORA_VC_INFO_HEADER],[
157 AC_REQUIRE([PANDORA_VC_VERSION])
158 m4_define([PANDORA_VC_PREFIX],m4_toupper(m4_normalize(AC_PACKAGE_NAME))[_])
160 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[VC_REVNO], [$PANDORA_VC_REVNO], [Version control revision number])
161 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[VC_REVID], ["$PANDORA_VC_REVID"], [Version control revision ID])
162 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[VC_BRANCH], ["$PANDORA_VC_BRANCH"], [Version control branch name])
163 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[RELEASE_DATE], ["$PANDORA_RELEASE_DATE"], [Release date of version control checkout])
164 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[RELEASE_NODOTS_DATE], [$PANDORA_RELEASE_NODOTS_DATE], [Numeric formatted release date of checkout])
165 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[RELEASE_COMMENT], ["$PANDORA_RELEASE_COMMENT"], [Set to trunk if the branch is the main $PACKAGE branch])
166 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[RELEASE_VERSION], ["$PANDORA_RELEASE_VERSION"], [Release date and revision number of checkout])
167 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[RELEASE_ID], [$PANDORA_RELEASE_ID], [Numeric formatted release date and revision number of checkout])