3 dnl # Read meta data from the META file or the debian/changelog file if it
4 dnl # exists. When building from a git repository the ZFS_META_RELEASE field
5 dnl # will be overwritten if there is an annotated tag matching the form
6 dnl # ZFS_META_NAME-ZFS_META_VERSION-*. This allows for working builds to be
7 dnl # uniquely identified using the git commit hash.
9 dnl # The META file format is as follows:
10 dnl # ^[ ]*KEY:[ \t]+VALUE$
13 dnl # - KEY is separated from VALUE by a colon and one or more spaces/tabs.
14 dnl # - KEY and VALUE are case sensitive.
15 dnl # - Leading spaces are ignored.
16 dnl # - First match wins for duplicate keys.
18 dnl # A line can be commented out by preceding it with a '#' (or technically
19 dnl # any non-space character since that will prevent the regex from
23 dnl # Placing a colon followed by a space or tab (ie, ":[ \t]+") within the
24 dnl # VALUE will prematurely terminate the string since that sequence is
25 dnl # used as the awk field separator.
28 dnl # The following META keys are recognized:
29 dnl # Name, Version, Release, Date, Author, LT_Current, LT_Revision, LT_Age
31 dnl # Written by Chris Dunlap <cdunlap@llnl.gov>.
32 dnl # Modified by Brian Behlendorf <behlendorf1@llnl.gov>.
34 AC_DEFUN([ZFS_AC_META], [
38 #undef PACKAGE_BUGREPORT
41 #undef PACKAGE_TARNAME
42 #undef PACKAGE_VERSION
47 AC_MSG_CHECKING([metadata])
50 _zfs_ac_meta_type="none"
51 if test -f "$META"; then
52 _zfs_ac_meta_type="META file"
53 _dpkg_parsechangelog=$(dpkg-parsechangelog 2>/dev/null)
55 ZFS_META_NAME=_ZFS_AC_META_GETVAL([(Name|Project|Package)]);
56 if test -n "$ZFS_META_NAME"; then
57 AC_DEFINE_UNQUOTED([ZFS_META_NAME], ["$ZFS_META_NAME"],
58 [Define the project name.]
60 AC_SUBST([ZFS_META_NAME])
63 ZFS_META_VERSION=_ZFS_AC_META_GETVAL([Version]);
64 if test -n "$ZFS_META_VERSION"; then
65 AC_DEFINE_UNQUOTED([ZFS_META_VERSION], ["$ZFS_META_VERSION"],
66 [Define the project version.]
68 AC_SUBST([ZFS_META_VERSION])
71 if test -n "${_dpkg_parsechangelog}"; then
72 _dpkg_version=$(echo "${_dpkg_parsechangelog}" \
73 | $AWK '$[]1 == "Version:" { print $[]2; }' \
75 if test "${_dpkg_version}" != "$ZFS_META_VERSION"; then
77 *** Version $ZFS_META_VERSION in the META file is different than
78 *** version $_dpkg_version in the debian/changelog file. DKMS and DEB
79 *** packaging require that these files have the same version.
84 ZFS_META_RELEASE=_ZFS_AC_META_GETVAL([Release]);
86 if test -n "${_dpkg_parsechangelog}"; then
87 _dpkg_release=$(echo "${_dpkg_parsechangelog}" \
88 | $AWK '$[]1 == "Version:" { print $[]2; }' \
90 if test -n "${_dpkg_release}"; then
91 ZFS_META_RELEASE=${_dpkg_release}
92 _zfs_ac_meta_type="dpkg-parsechangelog"
94 elif test ! -f ".nogitrelease" && git rev-parse --git-dir > /dev/null 2>&1; then
95 _match="${ZFS_META_NAME}-${ZFS_META_VERSION}"
96 _alias=$(git describe --match=${_match} 2>/dev/null)
97 _release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g')
98 if test -n "${_release}"; then
99 ZFS_META_RELEASE=${_release}
100 _zfs_ac_meta_type="git describe"
104 if test -n "$ZFS_META_RELEASE"; then
105 AC_DEFINE_UNQUOTED([ZFS_META_RELEASE], ["$ZFS_META_RELEASE"],
106 [Define the project release.]
108 AC_SUBST([ZFS_META_RELEASE])
110 RELEASE="$ZFS_META_RELEASE"
114 ZFS_META_LICENSE=_ZFS_AC_META_GETVAL([License]);
115 if test -n "$ZFS_META_LICENSE"; then
116 AC_DEFINE_UNQUOTED([ZFS_META_LICENSE], ["$ZFS_META_LICENSE"],
117 [Define the project license.]
119 AC_SUBST([ZFS_META_LICENSE])
122 if test -n "$ZFS_META_NAME" -a -n "$ZFS_META_VERSION"; then
123 ZFS_META_ALIAS="$ZFS_META_NAME-$ZFS_META_VERSION"
124 test -n "$ZFS_META_RELEASE" &&
125 ZFS_META_ALIAS="$ZFS_META_ALIAS-$ZFS_META_RELEASE"
126 AC_DEFINE_UNQUOTED([ZFS_META_ALIAS],
128 [Define the project alias string.]
130 AC_SUBST([ZFS_META_ALIAS])
133 ZFS_META_DATA=_ZFS_AC_META_GETVAL([Date]);
134 if test -n "$ZFS_META_DATA"; then
135 AC_DEFINE_UNQUOTED([ZFS_META_DATA], ["$ZFS_META_DATA"],
136 [Define the project release date.]
138 AC_SUBST([ZFS_META_DATA])
141 ZFS_META_AUTHOR=_ZFS_AC_META_GETVAL([Author]);
142 if test -n "$ZFS_META_AUTHOR"; then
143 AC_DEFINE_UNQUOTED([ZFS_META_AUTHOR], ["$ZFS_META_AUTHOR"],
144 [Define the project author.]
146 AC_SUBST([ZFS_META_AUTHOR])
149 m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$])
150 ZFS_META_LT_CURRENT=_ZFS_AC_META_GETVAL([LT_Current]);
151 ZFS_META_LT_REVISION=_ZFS_AC_META_GETVAL([LT_Revision]);
152 ZFS_META_LT_AGE=_ZFS_AC_META_GETVAL([LT_Age]);
153 if test -n "$ZFS_META_LT_CURRENT" \
154 -o -n "$ZFS_META_LT_REVISION" \
155 -o -n "$ZFS_META_LT_AGE"; then
156 test -n "$ZFS_META_LT_CURRENT" || ZFS_META_LT_CURRENT="0"
157 test -n "$ZFS_META_LT_REVISION" || ZFS_META_LT_REVISION="0"
158 test -n "$ZFS_META_LT_AGE" || ZFS_META_LT_AGE="0"
159 AC_DEFINE_UNQUOTED([ZFS_META_LT_CURRENT],
160 ["$ZFS_META_LT_CURRENT"],
161 [Define the libtool library 'current'
162 version information.]
164 AC_DEFINE_UNQUOTED([ZFS_META_LT_REVISION],
165 ["$ZFS_META_LT_REVISION"],
166 [Define the libtool library 'revision'
167 version information.]
169 AC_DEFINE_UNQUOTED([ZFS_META_LT_AGE], ["$ZFS_META_LT_AGE"],
170 [Define the libtool library 'age'
171 version information.]
173 AC_SUBST([ZFS_META_LT_CURRENT])
174 AC_SUBST([ZFS_META_LT_REVISION])
175 AC_SUBST([ZFS_META_LT_AGE])
179 AC_MSG_RESULT([$_zfs_ac_meta_type])
183 dnl # _ZFS_AC_META_GETVAL (KEY_NAME_OR_REGEX)
185 dnl # Returns the META VALUE associated with the given KEY_NAME_OR_REGEX expr.
187 dnl # Despite their resemblance to line noise,
188 dnl # the "@<:@" and "@:>@" constructs are quadrigraphs for "[" and "]".
189 dnl # <www.gnu.org/software/autoconf/manual/autoconf.html#Quadrigraphs>
191 dnl # The "$[]1" and "$[]2" constructs prevent M4 parameter expansion
192 dnl # so a literal $1 and $2 will be passed to the resulting awk script,
193 dnl # whereas the "$1" will undergo M4 parameter expansion for the META key.
195 AC_DEFUN([_ZFS_AC_META_GETVAL],
196 [`$AWK -F ':@<:@ \t@:>@+' '$[]1 ~ /^ *$1$/ { print $[]2; exit }' $META`]dnl