]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - zfs/config/zfs-meta.m4
UBUNTU: SAUCE: (noup) Update spl to 0.6.5.9-1, zfs to 0.6.5.9-2
[mirror_ubuntu-artful-kernel.git] / zfs / config / zfs-meta.m4
1 dnl #
2 dnl # DESCRIPTION:
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.
8 dnl #
9 dnl # The META file format is as follows:
10 dnl # ^[ ]*KEY:[ \t]+VALUE$
11 dnl #
12 dnl # In other words:
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.
17 dnl #
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
20 dnl # matching).
21 dnl #
22 dnl # WARNING:
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.
26 dnl #
27 dnl # KEYS:
28 dnl # The following META keys are recognized:
29 dnl # Name, Version, Release, Date, Author, LT_Current, LT_Revision, LT_Age
30 dnl #
31 dnl # Written by Chris Dunlap <cdunlap@llnl.gov>.
32 dnl # Modified by Brian Behlendorf <behlendorf1@llnl.gov>.
33 dnl #
34 AC_DEFUN([ZFS_AC_META], [
35
36 AH_BOTTOM([
37 #undef PACKAGE
38 #undef PACKAGE_BUGREPORT
39 #undef PACKAGE_NAME
40 #undef PACKAGE_STRING
41 #undef PACKAGE_TARNAME
42 #undef PACKAGE_VERSION
43 #undef STDC_HEADERS
44 #undef VERSION])
45
46 AC_PROG_AWK
47 AC_MSG_CHECKING([metadata])
48
49 META="$srcdir/META"
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)
54
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.]
59 )
60 AC_SUBST([ZFS_META_NAME])
61 fi
62
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.]
67 )
68 AC_SUBST([ZFS_META_VERSION])
69 fi
70
71 if test -n "${_dpkg_parsechangelog}"; then
72 _dpkg_version=$(echo "${_dpkg_parsechangelog}" \
73 | $AWK '$[]1 == "Version:" { print $[]2; }' \
74 | cut -d- -f1)
75 if test "${_dpkg_version}" != "$ZFS_META_VERSION"; then
76 AC_MSG_ERROR([
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.
80 ])
81 fi
82 fi
83
84 ZFS_META_RELEASE=_ZFS_AC_META_GETVAL([Release]);
85
86 if test -n "${_dpkg_parsechangelog}"; then
87 _dpkg_release=$(echo "${_dpkg_parsechangelog}" \
88 | $AWK '$[]1 == "Version:" { print $[]2; }' \
89 | cut -d- -f2-)
90 if test -n "${_dpkg_release}"; then
91 ZFS_META_RELEASE=${_dpkg_release}
92 _zfs_ac_meta_type="dpkg-parsechangelog"
93 fi
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"
101 fi
102 fi
103
104 if test -n "$ZFS_META_RELEASE"; then
105 AC_DEFINE_UNQUOTED([ZFS_META_RELEASE], ["$ZFS_META_RELEASE"],
106 [Define the project release.]
107 )
108 AC_SUBST([ZFS_META_RELEASE])
109
110 RELEASE="$ZFS_META_RELEASE"
111 AC_SUBST([RELEASE])
112 fi
113
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.]
118 )
119 AC_SUBST([ZFS_META_LICENSE])
120 fi
121
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],
127 ["$ZFS_META_ALIAS"],
128 [Define the project alias string.]
129 )
130 AC_SUBST([ZFS_META_ALIAS])
131 fi
132
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.]
137 )
138 AC_SUBST([ZFS_META_DATA])
139 fi
140
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.]
145 )
146 AC_SUBST([ZFS_META_AUTHOR])
147 fi
148
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.]
163 )
164 AC_DEFINE_UNQUOTED([ZFS_META_LT_REVISION],
165 ["$ZFS_META_LT_REVISION"],
166 [Define the libtool library 'revision'
167 version information.]
168 )
169 AC_DEFINE_UNQUOTED([ZFS_META_LT_AGE], ["$ZFS_META_LT_AGE"],
170 [Define the libtool library 'age'
171 version information.]
172 )
173 AC_SUBST([ZFS_META_LT_CURRENT])
174 AC_SUBST([ZFS_META_LT_REVISION])
175 AC_SUBST([ZFS_META_LT_AGE])
176 fi
177 fi
178
179 AC_MSG_RESULT([$_zfs_ac_meta_type])
180 ]
181 )
182
183 dnl # _ZFS_AC_META_GETVAL (KEY_NAME_OR_REGEX)
184 dnl #
185 dnl # Returns the META VALUE associated with the given KEY_NAME_OR_REGEX expr.
186 dnl #
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>
190 dnl #
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.
194 dnl #
195 AC_DEFUN([_ZFS_AC_META_GETVAL],
196 [`$AWK -F ':@<:@ \t@:>@+' '$[]1 ~ /^ *$1$/ { print $[]2; exit }' $META`]dnl
197 )