]> git.proxmox.com Git - mirror_zfs-debian.git/blame - config/zfs-meta.m4
Add dpkg-dev to Depends of zfs-dkms (Closes: #900714)
[mirror_zfs-debian.git] / config / zfs-meta.m4
CommitLineData
c06d4368
AX
1dnl #
2dnl # DESCRIPTION:
3dnl # Read meta data from the META file. When building from a git repository
4dnl # the ZFS_META_RELEASE field will be overwritten if there is an annotated
5dnl # tag matching the form ZFS_META_NAME-ZFS_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 #
c9c0d073
BB
33AC_DEFUN([ZFS_AC_META], [
34
35 AH_BOTTOM([
36#undef PACKAGE
37#undef PACKAGE_BUGREPORT
38#undef PACKAGE_NAME
39#undef PACKAGE_STRING
40#undef PACKAGE_TARNAME
41#undef PACKAGE_VERSION
42#undef STDC_HEADERS
43#undef VERSION])
44
c06d4368 45 AC_PROG_AWK
c9c0d073
BB
46 AC_MSG_CHECKING([metadata])
47
48 META="$srcdir/META"
f6fb7651 49 _zfs_ac_meta_type="none"
c9c0d073 50 if test -f "$META"; then
f6fb7651 51 _zfs_ac_meta_type="META file"
c9c0d073 52
c06d4368 53 ZFS_META_NAME=_ZFS_AC_META_GETVAL([(Name|Project|Package)]);
c9c0d073
BB
54 if test -n "$ZFS_META_NAME"; then
55 AC_DEFINE_UNQUOTED([ZFS_META_NAME], ["$ZFS_META_NAME"],
56 [Define the project name.]
57 )
58 AC_SUBST([ZFS_META_NAME])
59 fi
60
c06d4368 61 ZFS_META_VERSION=_ZFS_AC_META_GETVAL([Version]);
c9c0d073
BB
62 if test -n "$ZFS_META_VERSION"; then
63 AC_DEFINE_UNQUOTED([ZFS_META_VERSION], ["$ZFS_META_VERSION"],
64 [Define the project version.]
65 )
66 AC_SUBST([ZFS_META_VERSION])
67 fi
68
c06d4368
AX
69 ZFS_META_RELEASE=_ZFS_AC_META_GETVAL([Release]);
70 if test ! -f ".nogitrelease" && git rev-parse --git-dir > /dev/null 2>&1; then
ea04106b 71 _match="${ZFS_META_NAME}-${ZFS_META_VERSION}"
f6fb7651
BB
72 _alias=$(git describe --match=${_match} 2>/dev/null)
73 _release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g')
74 if test -n "${_release}"; then
75 ZFS_META_RELEASE=${_release}
76 _zfs_ac_meta_type="git describe"
cae5b340
AX
77 else
78 _match="${ZFS_META_NAME}-${ZFS_META_VERSION}-${ZFS_META_RELEASE}"
79 _alias=$(git describe --match=${_match} 2>/dev/null)
80 _release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g')
81 if test -n "${_release}"; then
82 ZFS_META_RELEASE=${_release}
83 _zfs_ac_meta_type="git describe"
84 fi
f6fb7651
BB
85 fi
86 fi
87
c9c0d073
BB
88 if test -n "$ZFS_META_RELEASE"; then
89 AC_DEFINE_UNQUOTED([ZFS_META_RELEASE], ["$ZFS_META_RELEASE"],
90 [Define the project release.]
91 )
92 AC_SUBST([ZFS_META_RELEASE])
f3757573
BB
93
94 RELEASE="$ZFS_META_RELEASE"
95 AC_SUBST([RELEASE])
c9c0d073
BB
96 fi
97
c06d4368 98 ZFS_META_LICENSE=_ZFS_AC_META_GETVAL([License]);
c9c0d073
BB
99 if test -n "$ZFS_META_LICENSE"; then
100 AC_DEFINE_UNQUOTED([ZFS_META_LICENSE], ["$ZFS_META_LICENSE"],
101 [Define the project license.]
102 )
103 AC_SUBST([ZFS_META_LICENSE])
104 fi
105
106 if test -n "$ZFS_META_NAME" -a -n "$ZFS_META_VERSION"; then
107 ZFS_META_ALIAS="$ZFS_META_NAME-$ZFS_META_VERSION"
108 test -n "$ZFS_META_RELEASE" &&
109 ZFS_META_ALIAS="$ZFS_META_ALIAS-$ZFS_META_RELEASE"
110 AC_DEFINE_UNQUOTED([ZFS_META_ALIAS],
111 ["$ZFS_META_ALIAS"],
112 [Define the project alias string.]
113 )
114 AC_SUBST([ZFS_META_ALIAS])
115 fi
116
c06d4368 117 ZFS_META_DATA=_ZFS_AC_META_GETVAL([Date]);
c9c0d073
BB
118 if test -n "$ZFS_META_DATA"; then
119 AC_DEFINE_UNQUOTED([ZFS_META_DATA], ["$ZFS_META_DATA"],
120 [Define the project release date.]
121 )
122 AC_SUBST([ZFS_META_DATA])
123 fi
124
c06d4368 125 ZFS_META_AUTHOR=_ZFS_AC_META_GETVAL([Author]);
c9c0d073
BB
126 if test -n "$ZFS_META_AUTHOR"; then
127 AC_DEFINE_UNQUOTED([ZFS_META_AUTHOR], ["$ZFS_META_AUTHOR"],
128 [Define the project author.]
129 )
130 AC_SUBST([ZFS_META_AUTHOR])
131 fi
132
133 m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$])
c06d4368
AX
134 ZFS_META_LT_CURRENT=_ZFS_AC_META_GETVAL([LT_Current]);
135 ZFS_META_LT_REVISION=_ZFS_AC_META_GETVAL([LT_Revision]);
136 ZFS_META_LT_AGE=_ZFS_AC_META_GETVAL([LT_Age]);
c9c0d073
BB
137 if test -n "$ZFS_META_LT_CURRENT" \
138 -o -n "$ZFS_META_LT_REVISION" \
139 -o -n "$ZFS_META_LT_AGE"; then
140 test -n "$ZFS_META_LT_CURRENT" || ZFS_META_LT_CURRENT="0"
141 test -n "$ZFS_META_LT_REVISION" || ZFS_META_LT_REVISION="0"
142 test -n "$ZFS_META_LT_AGE" || ZFS_META_LT_AGE="0"
143 AC_DEFINE_UNQUOTED([ZFS_META_LT_CURRENT],
144 ["$ZFS_META_LT_CURRENT"],
145 [Define the libtool library 'current'
146 version information.]
147 )
148 AC_DEFINE_UNQUOTED([ZFS_META_LT_REVISION],
149 ["$ZFS_META_LT_REVISION"],
150 [Define the libtool library 'revision'
151 version information.]
152 )
153 AC_DEFINE_UNQUOTED([ZFS_META_LT_AGE], ["$ZFS_META_LT_AGE"],
154 [Define the libtool library 'age'
155 version information.]
156 )
157 AC_SUBST([ZFS_META_LT_CURRENT])
158 AC_SUBST([ZFS_META_LT_REVISION])
159 AC_SUBST([ZFS_META_LT_AGE])
160 fi
161 fi
162
f6fb7651 163 AC_MSG_RESULT([$_zfs_ac_meta_type])
c9c0d073
BB
164 ]
165)
166
c06d4368
AX
167dnl # _ZFS_AC_META_GETVAL (KEY_NAME_OR_REGEX)
168dnl #
169dnl # Returns the META VALUE associated with the given KEY_NAME_OR_REGEX expr.
170dnl #
171dnl # Despite their resemblance to line noise,
172dnl # the "@<:@" and "@:>@" constructs are quadrigraphs for "[" and "]".
173dnl # <www.gnu.org/software/autoconf/manual/autoconf.html#Quadrigraphs>
174dnl #
175dnl # The "$[]1" and "$[]2" constructs prevent M4 parameter expansion
176dnl # so a literal $1 and $2 will be passed to the resulting awk script,
177dnl # whereas the "$1" will undergo M4 parameter expansion for the META key.
178dnl #
179AC_DEFUN([_ZFS_AC_META_GETVAL],
180 [`$AWK -F ':@<:@ \t@:>@+' '$[]1 ~ /^ *$1$/ { print $[]2; exit }' $META`]dnl
c9c0d073 181)