]>
Commit | Line | Data |
---|---|---|
70e083d2 TG |
1 | dnl # |
2 | dnl # DESCRIPTION: | |
3 | dnl # Read meta data from the META file. When building from a git repository | |
4 | dnl # the SPL_META_RELEASE field will be overwritten if there is an annotated | |
5 | dnl # tag matching the form SPL_META_NAME-SPL_META_VERSION-*. This allows | |
6 | dnl # for working builds to be uniquely identified using the git commit hash. | |
7 | dnl # | |
8 | dnl # The META file format is as follows: | |
9 | dnl # ^[ ]*KEY:[ \t]+VALUE$ | |
10 | dnl # | |
11 | dnl # In other words: | |
12 | dnl # - KEY is separated from VALUE by a colon and one or more spaces/tabs. | |
13 | dnl # - KEY and VALUE are case sensitive. | |
14 | dnl # - Leading spaces are ignored. | |
15 | dnl # - First match wins for duplicate keys. | |
16 | dnl # | |
17 | dnl # A line can be commented out by preceding it with a '#' (or technically | |
18 | dnl # any non-space character since that will prevent the regex from | |
19 | dnl # matching). | |
20 | dnl # | |
21 | dnl # WARNING: | |
22 | dnl # Placing a colon followed by a space or tab (ie, ":[ \t]+") within the | |
23 | dnl # VALUE will prematurely terminate the string since that sequence is | |
24 | dnl # used as the awk field separator. | |
25 | dnl # | |
26 | dnl # KEYS: | |
27 | dnl # The following META keys are recognized: | |
28 | dnl # Name, Version, Release, Date, Author, LT_Current, LT_Revision, LT_Age | |
29 | dnl # | |
30 | dnl # Written by Chris Dunlap <cdunlap@llnl.gov>. | |
31 | dnl # Modified by Brian Behlendorf <behlendorf1@llnl.gov>. | |
32 | dnl # | |
33 | AC_DEFUN([SPL_AC_META], [ | |
34 | AC_PROG_AWK | |
35 | AC_MSG_CHECKING([metadata]) | |
36 | ||
37 | META="$srcdir/META" | |
38 | _spl_ac_meta_type="none" | |
39 | if test -f "$META"; then | |
40 | _spl_ac_meta_type="META file" | |
41 | ||
42 | SPL_META_NAME=_SPL_AC_META_GETVAL([(Name|Project|Package)]); | |
43 | if test -n "$SPL_META_NAME"; then | |
44 | AC_DEFINE_UNQUOTED([SPL_META_NAME], ["$SPL_META_NAME"], | |
45 | [Define the project name.] | |
46 | ) | |
47 | AC_SUBST([SPL_META_NAME]) | |
48 | fi | |
49 | ||
50 | SPL_META_VERSION=_SPL_AC_META_GETVAL([Version]); | |
51 | if test -n "$SPL_META_VERSION"; then | |
52 | AC_DEFINE_UNQUOTED([SPL_META_VERSION], ["$SPL_META_VERSION"], | |
53 | [Define the project version.] | |
54 | ) | |
55 | AC_SUBST([SPL_META_VERSION]) | |
56 | fi | |
57 | ||
58 | SPL_META_RELEASE=_SPL_AC_META_GETVAL([Release]); | |
59 | if test ! -f ".nogitrelease" && git rev-parse --git-dir > /dev/null 2>&1; then | |
60 | _match="${SPL_META_NAME}-${SPL_META_VERSION}" | |
61 | _alias=$(git describe --match=${_match} 2>/dev/null) | |
62 | _release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g') | |
63 | if test -n "${_release}"; then | |
64 | SPL_META_RELEASE=${_release} | |
65 | _spl_ac_meta_type="git describe" | |
86e3c28a CIK |
66 | else |
67 | _match="${SPL_META_NAME}-${SPL_META_VERSION}-${SPL_META_RELEASE}" | |
68 | _alias=$(git describe --match=${_match} 2>/dev/null) | |
69 | _release=$(echo ${_alias}|cut -f3- -d'-'|sed 's/-/_/g') | |
70 | if test -n "${_release}"; then | |
71 | SPL_META_RELEASE=${_release} | |
72 | _spl_ac_meta_type="git describe" | |
73 | fi | |
70e083d2 TG |
74 | fi |
75 | fi | |
76 | ||
77 | if test -n "$SPL_META_RELEASE"; then | |
78 | AC_DEFINE_UNQUOTED([SPL_META_RELEASE], ["$SPL_META_RELEASE"], | |
79 | [Define the project release.] | |
80 | ) | |
81 | AC_SUBST([SPL_META_RELEASE]) | |
82 | ||
83 | RELEASE="$SPL_META_RELEASE" | |
84 | AC_SUBST([RELEASE]) | |
85 | fi | |
86 | ||
87 | SPL_META_LICENSE=_SPL_AC_META_GETVAL([License]); | |
88 | if test -n "$SPL_META_LICENSE"; then | |
89 | AC_DEFINE_UNQUOTED([SPL_META_LICENSE], ["$SPL_META_LICENSE"], | |
90 | [Define the project license.] | |
91 | ) | |
92 | AC_SUBST([SPL_META_LICENSE]) | |
93 | fi | |
94 | ||
95 | if test -n "$SPL_META_NAME" -a -n "$SPL_META_VERSION"; then | |
96 | SPL_META_ALIAS="$SPL_META_NAME-$SPL_META_VERSION" | |
97 | test -n "$SPL_META_RELEASE" && | |
98 | SPL_META_ALIAS="$SPL_META_ALIAS-$SPL_META_RELEASE" | |
99 | AC_DEFINE_UNQUOTED([SPL_META_ALIAS], | |
100 | ["$SPL_META_ALIAS"], | |
101 | [Define the project alias string.] | |
102 | ) | |
103 | AC_SUBST([SPL_META_ALIAS]) | |
104 | fi | |
105 | ||
106 | SPL_META_DATA=_SPL_AC_META_GETVAL([Date]); | |
107 | if test -n "$SPL_META_DATA"; then | |
108 | AC_DEFINE_UNQUOTED([SPL_META_DATA], ["$SPL_META_DATA"], | |
109 | [Define the project release date.] | |
110 | ) | |
111 | AC_SUBST([SPL_META_DATA]) | |
112 | fi | |
113 | ||
114 | SPL_META_AUTHOR=_SPL_AC_META_GETVAL([Author]); | |
115 | if test -n "$SPL_META_AUTHOR"; then | |
116 | AC_DEFINE_UNQUOTED([SPL_META_AUTHOR], ["$SPL_META_AUTHOR"], | |
117 | [Define the project author.] | |
118 | ) | |
119 | AC_SUBST([SPL_META_AUTHOR]) | |
120 | fi | |
121 | ||
122 | m4_pattern_allow([^LT_(CURRENT|REVISION|AGE)$]) | |
123 | SPL_META_LT_CURRENT=_SPL_AC_META_GETVAL([LT_Current]); | |
124 | SPL_META_LT_REVISION=_SPL_AC_META_GETVAL([LT_Revision]); | |
125 | SPL_META_LT_AGE=_SPL_AC_META_GETVAL([LT_Age]); | |
126 | if test -n "$SPL_META_LT_CURRENT" \ | |
127 | -o -n "$SPL_META_LT_REVISION" \ | |
128 | -o -n "$SPL_META_LT_AGE"; then | |
129 | test -n "$SPL_META_LT_CURRENT" || SPL_META_LT_CURRENT="0" | |
130 | test -n "$SPL_META_LT_REVISION" || SPL_META_LT_REVISION="0" | |
131 | test -n "$SPL_META_LT_AGE" || SPL_META_LT_AGE="0" | |
132 | AC_DEFINE_UNQUOTED([SPL_META_LT_CURRENT], | |
133 | ["$SPL_META_LT_CURRENT"], | |
134 | [Define the libtool library 'current' | |
135 | version information.] | |
136 | ) | |
137 | AC_DEFINE_UNQUOTED([SPL_META_LT_REVISION], | |
138 | ["$SPL_META_LT_REVISION"], | |
139 | [Define the libtool library 'revision' | |
140 | version information.] | |
141 | ) | |
142 | AC_DEFINE_UNQUOTED([SPL_META_LT_AGE], ["$SPL_META_LT_AGE"], | |
143 | [Define the libtool library 'age' | |
144 | version information.] | |
145 | ) | |
146 | AC_SUBST([SPL_META_LT_CURRENT]) | |
147 | AC_SUBST([SPL_META_LT_REVISION]) | |
148 | AC_SUBST([SPL_META_LT_AGE]) | |
149 | fi | |
150 | fi | |
151 | ||
152 | AC_MSG_RESULT([$_spl_ac_meta_type]) | |
153 | ] | |
154 | ) | |
155 | ||
156 | dnl # _SPL_AC_META_GETVAL (KEY_NAME_OR_REGEX) | |
157 | dnl # | |
158 | dnl # Returns the META VALUE associated with the given KEY_NAME_OR_REGEX expr. | |
159 | dnl # | |
160 | dnl # Despite their resemblance to line noise, | |
161 | dnl # the "@<:@" and "@:>@" constructs are quadrigraphs for "[" and "]". | |
162 | dnl # <www.gnu.org/software/autoconf/manual/autoconf.html#Quadrigraphs> | |
163 | dnl # | |
164 | dnl # The "$[]1" and "$[]2" constructs prevent M4 parameter expansion | |
165 | dnl # so a literal $1 and $2 will be passed to the resulting awk script, | |
166 | dnl # whereas the "$1" will undergo M4 parameter expansion for the META key. | |
167 | dnl # | |
168 | AC_DEFUN([_SPL_AC_META_GETVAL], | |
169 | [`$AWK -F ':@<:@ \t@:>@+' '$[]1 ~ /^ *$1$/ { print $[]2; exit }' $META`]dnl | |
170 | ) |