1 ###############################################################################
2 # Written by Chris Dunlap <cdunlap@llnl.gov>.
3 # Modified by Brian Behlendorf <behlendorf1@llnl.gov>.
4 ###############################################################################
5 # SPL_AC_META: Read metadata from the META file. When building from a
6 # git repository the SPL_META_RELEASE field will be overwritten if there
7 # is an annotated tag matching the form SPL_META_NAME-SPL_META_VERSION-*.
8 # This allows for working builds to be uniquely identified using the git
10 ###############################################################################
12 AC_DEFUN([SPL_AC_META], [
13 AC_MSG_CHECKING([metadata])
16 _spl_ac_meta_type="none"
17 if test -f "$META"; then
18 _spl_ac_meta_type="META file"
20 SPL_META_NAME=_SPL_AC_META_GETVAL([(?:NAME|PROJECT|PACKAGE)]);
21 if test -n "$SPL_META_NAME"; then
22 AC_DEFINE_UNQUOTED([SPL_META_NAME], ["$SPL_META_NAME"],
23 [Define the project name.]
25 AC_SUBST([SPL_META_NAME])
28 SPL_META_VERSION=_SPL_AC_META_GETVAL([VERSION]);
29 if test -n "$SPL_META_VERSION"; then
30 AC_DEFINE_UNQUOTED([SPL_META_VERSION], ["$SPL_META_VERSION"],
31 [Define the project version.]
33 AC_SUBST([SPL_META_VERSION])
36 SPL_META_RELEASE=_SPL_AC_META_GETVAL([RELEASE]);
37 if git rev-parse --git-dir > /dev/null 2>&1; then
38 _match="${SPL_META_NAME}-${SPL_META_VERSION}*"
39 _alias=$(git describe --match=${_match} 2>/dev/null)
40 _release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g')
41 if test -n "${_release}"; then
42 SPL_META_RELEASE=${_release}
43 _spl_ac_meta_type="git describe"
47 if test -n "$SPL_META_RELEASE"; then
48 AC_DEFINE_UNQUOTED([SPL_META_RELEASE], ["$SPL_META_RELEASE"],
49 [Define the project release.]
51 AC_SUBST([SPL_META_RELEASE])
53 RELEASE="$SPL_META_RELEASE"
57 if test -n "$SPL_META_NAME" -a -n "$SPL_META_VERSION"; then
58 SPL_META_ALIAS="$SPL_META_NAME-$SPL_META_VERSION"
59 test -n "$SPL_META_RELEASE" &&
60 SPL_META_ALIAS="$SPL_META_ALIAS-$SPL_META_RELEASE"
61 AC_DEFINE_UNQUOTED([SPL_META_ALIAS],
63 [Define the project alias string.]
65 AC_SUBST([SPL_META_ALIAS])
68 SPL_META_DATA=_SPL_AC_META_GETVAL([DATE]);
69 if test -n "$SPL_META_DATA"; then
70 AC_DEFINE_UNQUOTED([SPL_META_DATA], ["$SPL_META_DATA"],
71 [Define the project release date.]
73 AC_SUBST([SPL_META_DATA])
76 SPL_META_AUTHOR=_SPL_AC_META_GETVAL([AUTHOR]);
77 if test -n "$SPL_META_AUTHOR"; then
78 AC_DEFINE_UNQUOTED([SPL_META_AUTHOR], ["$SPL_META_AUTHOR"],
79 [Define the project author.]
81 AC_SUBST([SPL_META_AUTHOR])
84 m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$])
85 SPL_META_LT_CURRENT=_SPL_AC_META_GETVAL([LT_CURRENT]);
86 SPL_META_LT_REVISION=_SPL_AC_META_GETVAL([LT_REVISION]);
87 SPL_META_LT_AGE=_SPL_AC_META_GETVAL([LT_AGE]);
88 if test -n "$SPL_META_LT_CURRENT" \
89 -o -n "$SPL_META_LT_REVISION" \
90 -o -n "$SPL_META_LT_AGE"; then
91 test -n "$SPL_META_LT_CURRENT" || SPL_META_LT_CURRENT="0"
92 test -n "$SPL_META_LT_REVISION" || SPL_META_LT_REVISION="0"
93 test -n "$SPL_META_LT_AGE" || SPL_META_LT_AGE="0"
94 AC_DEFINE_UNQUOTED([SPL_META_LT_CURRENT],
95 ["$SPL_META_LT_CURRENT"],
96 [Define the libtool library 'current'
99 AC_DEFINE_UNQUOTED([SPL_META_LT_REVISION],
100 ["$SPL_META_LT_REVISION"],
101 [Define the libtool library 'revision'
102 version information.]
104 AC_DEFINE_UNQUOTED([SPL_META_LT_AGE], ["$SPL_META_LT_AGE"],
105 [Define the libtool library 'age'
106 version information.]
108 AC_SUBST([SPL_META_LT_CURRENT])
109 AC_SUBST([SPL_META_LT_REVISION])
110 AC_SUBST([SPL_META_LT_AGE])
114 AC_MSG_RESULT([$_spl_ac_meta_type])
118 AC_DEFUN([_SPL_AC_META_GETVAL],
120 -e "BEGIN { \\$key=shift @ARGV; }"\
121 -e "next unless s/^\s*\\$key@<:@:=@:>@//i;"\
122 -e "s/^((?:@<:@^'\"#@:>@*(?:(@<:@'\"@:>@)@<:@^\2@:>@*\2)*)*)#.*/\\@S|@1/;"\
125 -e "s/^(@<:@'\"@:>@)(.*)\1/\\@S|@2/;"\
127 -e "END { print \\$val if defined \\$val; }"\