]> git.proxmox.com Git - mirror_spl-debian.git/blob - config/spl-meta.m4
Merge branch 'upstream'
[mirror_spl-debian.git] / config / spl-meta.m4
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
9 # commit hash.
10 ###############################################################################
11
12 AC_DEFUN([SPL_AC_META], [
13 AC_MSG_CHECKING([metadata])
14
15 META="$srcdir/META"
16 _spl_ac_meta_type="none"
17 if test -f "$META"; then
18 _spl_ac_meta_type="META file"
19
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.]
24 )
25 AC_SUBST([SPL_META_NAME])
26 fi
27
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.]
32 )
33 AC_SUBST([SPL_META_VERSION])
34 fi
35
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"
44 fi
45 fi
46
47 if test -n "$SPL_META_RELEASE"; then
48 AC_DEFINE_UNQUOTED([SPL_META_RELEASE], ["$SPL_META_RELEASE"],
49 [Define the project release.]
50 )
51 AC_SUBST([SPL_META_RELEASE])
52
53 RELEASE="$SPL_META_RELEASE"
54 AC_SUBST([RELEASE])
55 fi
56
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],
62 ["$SPL_META_ALIAS"],
63 [Define the project alias string.]
64 )
65 AC_SUBST([SPL_META_ALIAS])
66 fi
67
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.]
72 )
73 AC_SUBST([SPL_META_DATA])
74 fi
75
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.]
80 )
81 AC_SUBST([SPL_META_AUTHOR])
82 fi
83
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'
97 version information.]
98 )
99 AC_DEFINE_UNQUOTED([SPL_META_LT_REVISION],
100 ["$SPL_META_LT_REVISION"],
101 [Define the libtool library 'revision'
102 version information.]
103 )
104 AC_DEFINE_UNQUOTED([SPL_META_LT_AGE], ["$SPL_META_LT_AGE"],
105 [Define the libtool library 'age'
106 version information.]
107 )
108 AC_SUBST([SPL_META_LT_CURRENT])
109 AC_SUBST([SPL_META_LT_REVISION])
110 AC_SUBST([SPL_META_LT_AGE])
111 fi
112 fi
113
114 AC_MSG_RESULT([$_spl_ac_meta_type])
115 ]
116 )
117
118 AC_DEFUN([_SPL_AC_META_GETVAL],
119 [`perl -n\
120 -e "BEGIN { \\$key=shift @ARGV; }"\
121 -e "next unless s/^\s*\\$key@<:@:=@:>@//i;"\
122 -e "s/^((?:@<:@^'\"#@:>@*(?:(@<:@'\"@:>@)@<:@^\2@:>@*\2)*)*)#.*/\\@S|@1/;"\
123 -e "s/^\s+//;"\
124 -e "s/\s+$//;"\
125 -e "s/^(@<:@'\"@:>@)(.*)\1/\\@S|@2/;"\
126 -e "\\$val=\\$_;"\
127 -e "END { print \\$val if defined \\$val; }"\
128 '$1' $META`]dnl
129 )