494e7e23de19c30b0ac12a985beddb088d23808d
[awesomized/libmemcached] / m4 / pandora_vc_build.m4
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.
5
6 AC_DEFUN([PANDORA_TEST_VC_DIR],[
7 pandora_building_from_vc=no
8
9 if test -d ".bzr" ; then
10 pandora_building_from_bzr=yes
11 pandora_building_from_vc=yes
12 else
13 pandora_building_from_bzr=no
14 fi
15
16 if test -d ".svn" ; then
17 pandora_building_from_svn=yes
18 pandora_building_from_vc=yes
19 else
20 pandora_building_from_svn=no
21 fi
22
23 if test -d ".hg" ; then
24 pandora_building_from_hg=yes
25 pandora_building_from_vc=yes
26 else
27 pandora_building_from_hg=no
28 fi
29
30 if test -d ".git" ; then
31 pandora_building_from_git=yes
32 pandora_building_from_vc=yes
33 else
34 pandora_building_from_git=no
35 fi
36 ])
37
38 AC_DEFUN([PANDORA_BUILDING_FROM_VC],[
39 m4_syscmd(PANDORA_TEST_VC_DIR
40 m4_if(PCT_NO_VC_CHANGELOG,yes,[
41 vc_changelog=no
42 ],[
43 vc_changelog=yes
44 ])
45
46 [
47
48 PANDORA_RELEASE_DATE=`date +%Y.%m`
49 PANDORA_RELEASE_NODOTS_DATE=`date +%Y%m`
50
51 # Set some defaults
52 PANDORA_VC_REVNO="0"
53 PANDORA_VC_REVID="unknown"
54 PANDORA_VC_BRANCH="bzr-export"
55
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 if test "x${vc_changelog}" = "xyes"; then
65 bzr log --gnu > ChangeLog
66 fi
67 fi
68 fi
69
70 if ! test -d config ; then
71 mkdir -p config
72 fi
73
74 if test "${pandora_building_from_bzr}" = "yes" -o ! -f config/pandora_vc_revinfo ; then
75 cat > config/pandora_vc_revinfo.tmp <<EOF
76 PANDORA_VC_REVNO=${PANDORA_VC_REVNO}
77 PANDORA_VC_REVID=${PANDORA_VC_REVID}
78 PANDORA_VC_BRANCH=${PANDORA_VC_BRANCH}
79 PANDORA_VC_TAG=${PANDORA_VC_TAG}
80 PANDORA_RELEASE_DATE=${PANDORA_RELEASE_DATE}
81 PANDORA_RELEASE_NODOTS_DATE=${PANDORA_RELEASE_NODOTS_DATE}
82 EOF
83 if ! diff config/pandora_vc_revinfo.tmp config/pandora_vc_revinfo >/dev/null 2>&1 ; then
84 mv config/pandora_vc_revinfo.tmp config/pandora_vc_revinfo
85 fi
86 rm -f config/pandora_vc_revinfo.tmp
87 fi
88 ])
89 ])
90
91 AC_DEFUN([_PANDORA_READ_FROM_FILE],[
92 $1=`grep $1 $2 | cut -f2 -d=`
93 ])
94
95 AC_DEFUN([PANDORA_VC_VERSION],[
96 AC_REQUIRE([PANDORA_BUILDING_FROM_VC])
97
98 PANDORA_TEST_VC_DIR
99
100 AS_IF([test -f ${srcdir}/config/pandora_vc_revinfo],[
101 _PANDORA_READ_FROM_FILE([PANDORA_VC_REVNO],${srcdir}/config/pandora_vc_revinfo)
102 _PANDORA_READ_FROM_FILE([PANDORA_VC_REVID],${srcdir}/config/pandora_vc_revinfo)
103 _PANDORA_READ_FROM_FILE([PANDORA_VC_BRANCH],
104 ${srcdir}/config/pandora_vc_revinfo)
105 _PANDORA_READ_FROM_FILE([PANDORA_VC_TAG],
106 ${srcdir}/config/pandora_vc_revinfo)
107 _PANDORA_READ_FROM_FILE([PANDORA_RELEASE_DATE],
108 ${srcdir}/config/pandora_vc_revinfo)
109 _PANDORA_READ_FROM_FILE([PANDORA_RELEASE_NODOTS_DATE],
110 ${srcdir}/config/pandora_vc_revinfo)
111 ])
112 AS_IF([test "x${PANDORA_VC_BRANCH}" != x"${PACKAGE}"],[
113 PANDORA_RELEASE_COMMENT="${PANDORA_VC_BRANCH}"
114 ],[
115 PANDORA_RELEASE_COMMENT="trunk"
116 ])
117
118 AS_IF([test "x${PANDORA_VC_TAG}" = "x"],[
119 PANDORA_RELEASE_VERSION="${PANDORA_RELEASE_DATE}.${PANDORA_VC_REVNO}"
120 ],[
121 PANDORA_RELEASE_VERSION="${PANDORA_VC_TAG}"
122 ])
123 PANDORA_RELEASE_ID="${PANDORA_RELEASE_NODOTS_DATE}${PANDORA_VC_REVNO}"
124
125 VERSION="${PANDORA_RELEASE_VERSION}"
126 AC_DEFINE_UNQUOTED([PANDORA_RELEASE_VERSION],["${PANDORA_RELEASE_VERSION}"],
127 [The real version of the software])
128 AC_SUBST(PANDORA_VC_REVNO)
129 AC_SUBST(PANDORA_VC_REVID)
130 AC_SUBST(PANDORA_VC_BRANCH)
131 AC_SUBST(PANDORA_RELEASE_DATE)
132 AC_SUBST(PANDORA_RELEASE_NODOTS_DATE)
133 AC_SUBST(PANDORA_RELEASE_COMMENT)
134 AC_SUBST(PANDORA_RELEASE_VERSION)
135 AC_SUBST(PANDORA_RELEASE_ID)
136 ])
137
138 AC_DEFUN([PANDORA_VC_INFO_HEADER],[
139 AC_REQUIRE([PANDORA_VC_VERSION])
140 m4_define([PANDORA_VC_PREFIX],m4_toupper(m4_normalize(AC_PACKAGE_NAME))[_])
141
142 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[VC_REVNO], [$PANDORA_VC_REVNO], [Version control revision number])
143 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[VC_REVID], ["$PANDORA_VC_REVID"], [Version control revision ID])
144 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[VC_BRANCH], ["$PANDORA_VC_BRANCH"], [Version control branch name])
145 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[RELEASE_DATE], ["$PANDORA_RELEASE_DATE"], [Release date of version control checkout])
146 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[RELEASE_NODOTS_DATE], [$PANDORA_RELEASE_NODOTS_DATE], [Numeric formatted release date of checkout])
147 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[RELEASE_COMMENT], ["$PANDORA_RELEASE_COMMENT"], [Set to trunk if the branch is the main $PACKAGE branch])
148 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[RELEASE_VERSION], ["$PANDORA_RELEASE_VERSION"], [Release date and revision number of checkout])
149 AC_DEFINE_UNQUOTED(PANDORA_VC_PREFIX[RELEASE_ID], [$PANDORA_RELEASE_ID], [Numeric formatted release date and revision number of checkout])
150 ])