]> git.proxmox.com Git - mirror_spl-debian.git/blame - config/spl-meta.m4
Imported Upstream version 0.6.3+git20140731
[mirror_spl-debian.git] / config / spl-meta.m4
CommitLineData
80093b6f
AX
1dnl #
2dnl # DESCRIPTION:
3dnl # Read meta data from the META file. When building from a git repository
4dnl # the SPL_META_RELEASE field will be overwritten if there is an annotated
5dnl # tag matching the form SPL_META_NAME-SPL_META_VERSION-*. This allows
6dnl # for working builds to be uniquely identified using the git commit hash.
7dnl #
8dnl # The META file format is as follows:
9dnl # ^[ ]*KEY:[ \t]+VALUE$
10dnl #
11dnl # In other words:
12dnl # - KEY is separated from VALUE by a colon and one or more spaces/tabs.
13dnl # - KEY and VALUE are case sensitive.
14dnl # - Leading spaces are ignored.
15dnl # - First match wins for duplicate keys.
16dnl #
17dnl # A line can be commented out by preceding it with a '#' (or technically
18dnl # any non-space character since that will prevent the regex from
19dnl # matching).
20dnl #
21dnl # WARNING:
22dnl # Placing a colon followed by a space or tab (ie, ":[ \t]+") within the
23dnl # VALUE will prematurely terminate the string since that sequence is
24dnl # used as the awk field separator.
25dnl #
26dnl # KEYS:
27dnl # The following META keys are recognized:
28dnl # Name, Version, Release, Date, Author, LT_Current, LT_Revision, LT_Age
29dnl #
30dnl # Written by Chris Dunlap <cdunlap@llnl.gov>.
31dnl # Modified by Brian Behlendorf <behlendorf1@llnl.gov>.
32dnl #
dd529a30 33AC_DEFUN([SPL_AC_META], [
80093b6f 34 AC_PROG_AWK
dd529a30 35 AC_MSG_CHECKING([metadata])
36
37 META="$srcdir/META"
c14183ad 38 _spl_ac_meta_type="none"
dd529a30 39 if test -f "$META"; then
c14183ad 40 _spl_ac_meta_type="META file"
dd529a30 41
80093b6f 42 SPL_META_NAME=_SPL_AC_META_GETVAL([(Name|Project|Package)]);
abc3ca14
BB
43 if test -n "$SPL_META_NAME"; then
44 AC_DEFINE_UNQUOTED([SPL_META_NAME], ["$SPL_META_NAME"],
dd529a30 45 [Define the project name.]
46 )
abc3ca14 47 AC_SUBST([SPL_META_NAME])
dd529a30 48 fi
49
80093b6f 50 SPL_META_VERSION=_SPL_AC_META_GETVAL([Version]);
abc3ca14
BB
51 if test -n "$SPL_META_VERSION"; then
52 AC_DEFINE_UNQUOTED([SPL_META_VERSION], ["$SPL_META_VERSION"],
dd529a30 53 [Define the project version.]
54 )
abc3ca14 55 AC_SUBST([SPL_META_VERSION])
dd529a30 56 fi
57
80093b6f
AX
58 SPL_META_RELEASE=_SPL_AC_META_GETVAL([Release]);
59 if test ! -f ".nogitrelease" && git rev-parse --git-dir > /dev/null 2>&1; then
9e4fb5c2 60 _match="${SPL_META_NAME}-${SPL_META_VERSION}"
c14183ad
BB
61 _alias=$(git describe --match=${_match} 2>/dev/null)
62 _release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g')
63 if test -n "${_release}"; then
64 SPL_META_RELEASE=${_release}
65 _spl_ac_meta_type="git describe"
66 fi
67 fi
68
abc3ca14
BB
69 if test -n "$SPL_META_RELEASE"; then
70 AC_DEFINE_UNQUOTED([SPL_META_RELEASE], ["$SPL_META_RELEASE"],
dd529a30 71 [Define the project release.]
72 )
abc3ca14 73 AC_SUBST([SPL_META_RELEASE])
493972c8
BB
74
75 RELEASE="$SPL_META_RELEASE"
76 AC_SUBST([RELEASE])
dd529a30 77 fi
78
abc3ca14 79 if test -n "$SPL_META_NAME" -a -n "$SPL_META_VERSION"; then
72e7de60 80 SPL_META_ALIAS="$SPL_META_NAME-$SPL_META_VERSION"
abc3ca14 81 test -n "$SPL_META_RELEASE" &&
72e7de60
BB
82 SPL_META_ALIAS="$SPL_META_ALIAS-$SPL_META_RELEASE"
83 AC_DEFINE_UNQUOTED([SPL_META_ALIAS],
84 ["$SPL_META_ALIAS"],
dd529a30 85 [Define the project alias string.]
86 )
72e7de60 87 AC_SUBST([SPL_META_ALIAS])
dd529a30 88 fi
89
80093b6f 90 SPL_META_DATA=_SPL_AC_META_GETVAL([Date]);
abc3ca14
BB
91 if test -n "$SPL_META_DATA"; then
92 AC_DEFINE_UNQUOTED([SPL_META_DATA], ["$SPL_META_DATA"],
dd529a30 93 [Define the project release date.]
94 )
abc3ca14 95 AC_SUBST([SPL_META_DATA])
dd529a30 96 fi
97
80093b6f 98 SPL_META_AUTHOR=_SPL_AC_META_GETVAL([Author]);
abc3ca14
BB
99 if test -n "$SPL_META_AUTHOR"; then
100 AC_DEFINE_UNQUOTED([SPL_META_AUTHOR], ["$SPL_META_AUTHOR"],
dd529a30 101 [Define the project author.]
102 )
abc3ca14 103 AC_SUBST([SPL_META_AUTHOR])
dd529a30 104 fi
105
106 m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$])
80093b6f
AX
107 SPL_META_LT_CURRENT=_SPL_AC_META_GETVAL([LT_Current]);
108 SPL_META_LT_REVISION=_SPL_AC_META_GETVAL([LT_Revision]);
109 SPL_META_LT_AGE=_SPL_AC_META_GETVAL([LT_Age]);
abc3ca14
BB
110 if test -n "$SPL_META_LT_CURRENT" \
111 -o -n "$SPL_META_LT_REVISION" \
112 -o -n "$SPL_META_LT_AGE"; then
113 test -n "$SPL_META_LT_CURRENT" || SPL_META_LT_CURRENT="0"
114 test -n "$SPL_META_LT_REVISION" || SPL_META_LT_REVISION="0"
115 test -n "$SPL_META_LT_AGE" || SPL_META_LT_AGE="0"
116 AC_DEFINE_UNQUOTED([SPL_META_LT_CURRENT],
117 ["$SPL_META_LT_CURRENT"],
dd529a30 118 [Define the libtool library 'current'
119 version information.]
120 )
abc3ca14
BB
121 AC_DEFINE_UNQUOTED([SPL_META_LT_REVISION],
122 ["$SPL_META_LT_REVISION"],
dd529a30 123 [Define the libtool library 'revision'
124 version information.]
125 )
abc3ca14 126 AC_DEFINE_UNQUOTED([SPL_META_LT_AGE], ["$SPL_META_LT_AGE"],
dd529a30 127 [Define the libtool library 'age'
128 version information.]
129 )
abc3ca14
BB
130 AC_SUBST([SPL_META_LT_CURRENT])
131 AC_SUBST([SPL_META_LT_REVISION])
132 AC_SUBST([SPL_META_LT_AGE])
dd529a30 133 fi
134 fi
135
c14183ad 136 AC_MSG_RESULT([$_spl_ac_meta_type])
dd529a30 137 ]
138)
139
80093b6f
AX
140dnl # _SPL_AC_META_GETVAL (KEY_NAME_OR_REGEX)
141dnl #
142dnl # Returns the META VALUE associated with the given KEY_NAME_OR_REGEX expr.
143dnl #
144dnl # Despite their resemblance to line noise,
145dnl # the "@<:@" and "@:>@" constructs are quadrigraphs for "[" and "]".
146dnl # <www.gnu.org/software/autoconf/manual/autoconf.html#Quadrigraphs>
147dnl #
148dnl # The "$[]1" and "$[]2" constructs prevent M4 parameter expansion
149dnl # so a literal $1 and $2 will be passed to the resulting awk script,
150dnl # whereas the "$1" will undergo M4 parameter expansion for the META key.
151dnl #
152AC_DEFUN([_SPL_AC_META_GETVAL],
153 [`$AWK -F ':@<:@ \t@:>@+' '$[]1 ~ /^ *$1$/ { print $[]2; exit }' $META`]dnl
dd529a30 154)