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 # 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 45 AC_PROG_AWK 46 AC_MSG_CHECKING([metadata]) 47 48 META="$srcdir/META" 49 _zfs_ac_meta_type="none" 50 if test -f "$META"; then 51 _zfs_ac_meta_type="META file" 52 53 ZFS_META_NAME=_ZFS_AC_META_GETVAL([(Name|Project|Package)]); 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 61 ZFS_META_VERSION=_ZFS_AC_META_GETVAL([Version]); 62 if test -n "$ZFS_META_VERSION"; then 63 AC_DEFINE_UNQUOTED([ZFS_META_VERSION], 64 ["$ZFS_META_VERSION"], 65 [Define the project version.]) 66 AC_DEFINE_UNQUOTED([SPL_META_VERSION], 67 [ZFS_META_VERSION], 68 [Defined for legacy compatibility.]) 69 AC_SUBST([ZFS_META_VERSION]) 70 fi 71 72 ZFS_META_RELEASE=_ZFS_AC_META_GETVAL([Release]); 73 if test ! -f ".nogitrelease" && git rev-parse --git-dir > /dev/null 2>&1; then 74 _match="${ZFS_META_NAME}-${ZFS_META_VERSION}" 75 _alias=$(git describe --match=${_match} 2>/dev/null) 76 _release=$(echo ${_alias}|sed "s/${ZFS_META_NAME}//"|cut -f3- -d'-'|tr - _) 77 if test -n "${_release}"; then 78 ZFS_META_RELEASE=${_release} 79 _zfs_ac_meta_type="git describe" 80 else 81 _match="${ZFS_META_NAME}-${ZFS_META_VERSION}-${ZFS_META_RELEASE}" 82 _alias=$(git describe --match=${_match} 2>/dev/null) 83 _release=$(echo ${_alias}|sed 's/${ZFS_META_NAME}//'|cut -f3- -d'-'|tr - _) 84 if test -n "${_release}"; then 85 ZFS_META_RELEASE=${_release} 86 _zfs_ac_meta_type="git describe" 87 fi 88 fi 89 fi 90 91 if test -n "$ZFS_META_RELEASE"; then 92 AC_DEFINE_UNQUOTED([ZFS_META_RELEASE], 93 ["$ZFS_META_RELEASE"], 94 [Define the project release.]) 95 AC_DEFINE_UNQUOTED([SPL_META_RELEASE], 96 [ZFS_META_RELEASE], 97 [Defined for legacy compatibility.]) 98 AC_SUBST([ZFS_META_RELEASE]) 99 100 RELEASE="$ZFS_META_RELEASE" 101 AC_SUBST([RELEASE]) 102 fi 103 104 ZFS_META_LICENSE=_ZFS_AC_META_GETVAL([License]); 105 if test -n "$ZFS_META_LICENSE"; then 106 AC_DEFINE_UNQUOTED([ZFS_META_LICENSE], ["$ZFS_META_LICENSE"], 107 [Define the project license.] 108 ) 109 AC_SUBST([ZFS_META_LICENSE]) 110 fi 111 112 if test -n "$ZFS_META_NAME" -a -n "$ZFS_META_VERSION"; then 113 ZFS_META_ALIAS="$ZFS_META_NAME-$ZFS_META_VERSION" 114 test -n "$ZFS_META_RELEASE" && 115 ZFS_META_ALIAS="$ZFS_META_ALIAS-$ZFS_META_RELEASE" 116 AC_DEFINE_UNQUOTED([ZFS_META_ALIAS], 117 ["$ZFS_META_ALIAS"], 118 [Define the project alias string.]) 119 AC_DEFINE_UNQUOTED([SPL_META_ALIAS], 120 [ZFS_META_ALIAS], 121 [Defined for legacy compatibility.]) 122 AC_SUBST([ZFS_META_ALIAS]) 123 fi 124 125 ZFS_META_DATA=_ZFS_AC_META_GETVAL([Date]); 126 if test -n "$ZFS_META_DATA"; then 127 AC_DEFINE_UNQUOTED([ZFS_META_DATA], ["$ZFS_META_DATA"], 128 [Define the project release date.] 129 ) 130 AC_SUBST([ZFS_META_DATA]) 131 fi 132 133 ZFS_META_AUTHOR=_ZFS_AC_META_GETVAL([Author]); 134 if test -n "$ZFS_META_AUTHOR"; then 135 AC_DEFINE_UNQUOTED([ZFS_META_AUTHOR], ["$ZFS_META_AUTHOR"], 136 [Define the project author.] 137 ) 138 AC_SUBST([ZFS_META_AUTHOR]) 139 fi 140 141 ZFS_META_KVER_MIN=_ZFS_AC_META_GETVAL([Linux-Minimum]); 142 if test -n "$ZFS_META_KVER_MIN"; then 143 AC_DEFINE_UNQUOTED([ZFS_META_KVER_MIN], 144 ["$ZFS_META_KVER_MIN"], 145 [Define the minimum compatible kernel version.] 146 ) 147 AC_SUBST([ZFS_META_KVER_MIN]) 148 fi 149 150 ZFS_META_KVER_MAX=_ZFS_AC_META_GETVAL([Linux-Maximum]); 151 if test -n "$ZFS_META_KVER_MAX"; then 152 AC_DEFINE_UNQUOTED([ZFS_META_KVER_MAX], 153 ["$ZFS_META_KVER_MAX"], 154 [Define the maximum compatible kernel version.] 155 ) 156 AC_SUBST([ZFS_META_KVER_MAX]) 157 fi 158 159 m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$]) 160 ZFS_META_LT_CURRENT=_ZFS_AC_META_GETVAL([LT_Current]); 161 ZFS_META_LT_REVISION=_ZFS_AC_META_GETVAL([LT_Revision]); 162 ZFS_META_LT_AGE=_ZFS_AC_META_GETVAL([LT_Age]); 163 if test -n "$ZFS_META_LT_CURRENT" \ 164 -o -n "$ZFS_META_LT_REVISION" \ 165 -o -n "$ZFS_META_LT_AGE"; then 166 test -n "$ZFS_META_LT_CURRENT" || ZFS_META_LT_CURRENT="0" 167 test -n "$ZFS_META_LT_REVISION" || ZFS_META_LT_REVISION="0" 168 test -n "$ZFS_META_LT_AGE" || ZFS_META_LT_AGE="0" 169 AC_DEFINE_UNQUOTED([ZFS_META_LT_CURRENT], 170 ["$ZFS_META_LT_CURRENT"], 171 [Define the libtool library 'current' 172 version information.] 173 ) 174 AC_DEFINE_UNQUOTED([ZFS_META_LT_REVISION], 175 ["$ZFS_META_LT_REVISION"], 176 [Define the libtool library 'revision' 177 version information.] 178 ) 179 AC_DEFINE_UNQUOTED([ZFS_META_LT_AGE], ["$ZFS_META_LT_AGE"], 180 [Define the libtool library 'age' 181 version information.] 182 ) 183 AC_SUBST([ZFS_META_LT_CURRENT]) 184 AC_SUBST([ZFS_META_LT_REVISION]) 185 AC_SUBST([ZFS_META_LT_AGE]) 186 fi 187 fi 188 189 AC_MSG_RESULT([$_zfs_ac_meta_type]) 190 ] 191) 192 193dnl # _ZFS_AC_META_GETVAL (KEY_NAME_OR_REGEX) 194dnl # 195dnl # Returns the META VALUE associated with the given KEY_NAME_OR_REGEX expr. 196dnl # 197dnl # Despite their resemblance to line noise, 198dnl # the "@<:@" and "@:>@" constructs are quadrigraphs for "[" and "]". 199dnl # <www.gnu.org/software/autoconf/manual/autoconf.html#Quadrigraphs> 200dnl # 201dnl # The "$[]1" and "$[]2" constructs prevent M4 parameter expansion 202dnl # so a literal $1 and $2 will be passed to the resulting awk script, 203dnl # whereas the "$1" will undergo M4 parameter expansion for the META key. 204dnl # 205AC_DEFUN([_ZFS_AC_META_GETVAL], 206 [`$AWK -F ':@<:@ \t@:>@+' '$[]1 ~ /^ *$1$/ { print $[]2; exit }' $META`]dnl 207) 208