]> git.proxmox.com Git - mirror_zfs-debian.git/blame - config/zfs-meta.m4
Add modules-load conf
[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"
77 fi
78 fi
79
c9c0d073
BB
80 if test -n "$ZFS_META_RELEASE"; then
81 AC_DEFINE_UNQUOTED([ZFS_META_RELEASE], ["$ZFS_META_RELEASE"],
82 [Define the project release.]
83 )
84 AC_SUBST([ZFS_META_RELEASE])
f3757573
BB
85
86 RELEASE="$ZFS_META_RELEASE"
87 AC_SUBST([RELEASE])
c9c0d073
BB
88 fi
89
c06d4368 90 ZFS_META_LICENSE=_ZFS_AC_META_GETVAL([License]);
c9c0d073
BB
91 if test -n "$ZFS_META_LICENSE"; then
92 AC_DEFINE_UNQUOTED([ZFS_META_LICENSE], ["$ZFS_META_LICENSE"],
93 [Define the project license.]
94 )
95 AC_SUBST([ZFS_META_LICENSE])
96 fi
97
98 if test -n "$ZFS_META_NAME" -a -n "$ZFS_META_VERSION"; then
99 ZFS_META_ALIAS="$ZFS_META_NAME-$ZFS_META_VERSION"
100 test -n "$ZFS_META_RELEASE" &&
101 ZFS_META_ALIAS="$ZFS_META_ALIAS-$ZFS_META_RELEASE"
102 AC_DEFINE_UNQUOTED([ZFS_META_ALIAS],
103 ["$ZFS_META_ALIAS"],
104 [Define the project alias string.]
105 )
106 AC_SUBST([ZFS_META_ALIAS])
107 fi
108
c06d4368 109 ZFS_META_DATA=_ZFS_AC_META_GETVAL([Date]);
c9c0d073
BB
110 if test -n "$ZFS_META_DATA"; then
111 AC_DEFINE_UNQUOTED([ZFS_META_DATA], ["$ZFS_META_DATA"],
112 [Define the project release date.]
113 )
114 AC_SUBST([ZFS_META_DATA])
115 fi
116
c06d4368 117 ZFS_META_AUTHOR=_ZFS_AC_META_GETVAL([Author]);
c9c0d073
BB
118 if test -n "$ZFS_META_AUTHOR"; then
119 AC_DEFINE_UNQUOTED([ZFS_META_AUTHOR], ["$ZFS_META_AUTHOR"],
120 [Define the project author.]
121 )
122 AC_SUBST([ZFS_META_AUTHOR])
123 fi
124
125 m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$])
c06d4368
AX
126 ZFS_META_LT_CURRENT=_ZFS_AC_META_GETVAL([LT_Current]);
127 ZFS_META_LT_REVISION=_ZFS_AC_META_GETVAL([LT_Revision]);
128 ZFS_META_LT_AGE=_ZFS_AC_META_GETVAL([LT_Age]);
c9c0d073
BB
129 if test -n "$ZFS_META_LT_CURRENT" \
130 -o -n "$ZFS_META_LT_REVISION" \
131 -o -n "$ZFS_META_LT_AGE"; then
132 test -n "$ZFS_META_LT_CURRENT" || ZFS_META_LT_CURRENT="0"
133 test -n "$ZFS_META_LT_REVISION" || ZFS_META_LT_REVISION="0"
134 test -n "$ZFS_META_LT_AGE" || ZFS_META_LT_AGE="0"
135 AC_DEFINE_UNQUOTED([ZFS_META_LT_CURRENT],
136 ["$ZFS_META_LT_CURRENT"],
137 [Define the libtool library 'current'
138 version information.]
139 )
140 AC_DEFINE_UNQUOTED([ZFS_META_LT_REVISION],
141 ["$ZFS_META_LT_REVISION"],
142 [Define the libtool library 'revision'
143 version information.]
144 )
145 AC_DEFINE_UNQUOTED([ZFS_META_LT_AGE], ["$ZFS_META_LT_AGE"],
146 [Define the libtool library 'age'
147 version information.]
148 )
149 AC_SUBST([ZFS_META_LT_CURRENT])
150 AC_SUBST([ZFS_META_LT_REVISION])
151 AC_SUBST([ZFS_META_LT_AGE])
152 fi
153 fi
154
f6fb7651 155 AC_MSG_RESULT([$_zfs_ac_meta_type])
c9c0d073
BB
156 ]
157)
158
c06d4368
AX
159dnl # _ZFS_AC_META_GETVAL (KEY_NAME_OR_REGEX)
160dnl #
161dnl # Returns the META VALUE associated with the given KEY_NAME_OR_REGEX expr.
162dnl #
163dnl # Despite their resemblance to line noise,
164dnl # the "@<:@" and "@:>@" constructs are quadrigraphs for "[" and "]".
165dnl # <www.gnu.org/software/autoconf/manual/autoconf.html#Quadrigraphs>
166dnl #
167dnl # The "$[]1" and "$[]2" constructs prevent M4 parameter expansion
168dnl # so a literal $1 and $2 will be passed to the resulting awk script,
169dnl # whereas the "$1" will undergo M4 parameter expansion for the META key.
170dnl #
171AC_DEFUN([_ZFS_AC_META_GETVAL],
172 [`$AWK -F ':@<:@ \t@:>@+' '$[]1 ~ /^ *$1$/ { print $[]2; exit }' $META`]dnl
c9c0d073 173)