forked from kanzure/nanoengineer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ac_utils.m4
148 lines (134 loc) · 4.9 KB
/
ac_utils.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#
# CHECK_VERSION(FOUND-VERSION, MINIMUM-VERSION)
#
# Handles versions of the forms x.y and x.y.z where z can be lowercase letters
# and numbers. If z has letters, everything from the first letter to the end of
# the string is thrown out.
#
# Sets CHECK_VERSION_RESULT to 0 if the found- and minimum-versions are the
# same; to 1 if the found-version is later than the minimum-version; to -1 if
# the found-version is earlier than the minimum-version.
#
AC_DEFUN([CHECK_VERSION], [
found_version=$1
min_version=$2
# Determine if we're of the form x.y or x.y.z
form=`echo $min_version | sed 's/[[0-9]]*\.[[0-9]]*\.[[0-9a-z]]*/DOT_DOT/'`
# Parse version strings
if test "$form" = "DOT_DOT"; then
found_major_version=`echo $found_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9a-z]]*\)/\1/'`
found_minor_version=`echo $found_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9a-z]]*\)/\2/'`
found_micro_version=`echo $found_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)[[0-9a-z]]*/\3/'`
min_major_version=`echo $min_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9a-z]]*\)/\1/'`
min_minor_version=`echo $min_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9a-z]]*\)/\2/'`
min_micro_version=`echo $min_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)[[0-9a-z]]*/\3/'`
else
found_major_version=`echo $found_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
found_minor_version=`echo $found_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
found_micro_version=0
min_major_version=`echo $min_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
min_minor_version=`echo $min_version | \
sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'`
min_micro_version=0
fi
# Compare versions
if test $found_major_version -eq $min_major_version && \
test $found_minor_version -eq $min_minor_version && \
test $found_micro_version -eq $min_micro_version; then
version_result=0
else
version_result=-1
if test $found_major_version -gt $min_major_version; then
version_result=1
elif test $found_major_version -eq $min_major_version && \
test $found_minor_version -gt $min_minor_version; then
version_result=1
elif test $found_major_version -eq $min_major_version && \
test $found_minor_version -eq $min_minor_version && \
test $found_micro_version -ge $min_micro_version; then
version_result=1
fi
fi
AC_SUBST(CHECK_VERSION_RESULT, $version_result)
])
#
# CHECK_DESIRED_VERSION(LIBRARY-NAME, DESIRED-VERSION, FOUND-VERSION)
#
AC_DEFUN([CHECK_DESIRED_VERSION], [
library_name=$1
desired_version=$2
found_version=$3
if test "$STRICT_LIBRARY_CHECK" = "yes"; then
AC_MSG_CHECKING(for $library_name version == $desired_version)
else
AC_MSG_CHECKING(for $library_name version >= $desired_version)
fi
CHECK_VERSION($found_version, $desired_version)
version_check=$CHECK_VERSION_RESULT
if test $version_check -lt 0; then
AC_MSG_RESULT(no)
echo "*** $library_name version $desired_version or later is required, but version $found_version "
echo "*** was found instead. Please update your $library_name to version $desired_version."
exit -1
elif test $version_check -gt 0; then
if test "$STRICT_LIBRARY_CHECK" = "yes"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
fi
echo "### $library_name version $found_version was found. That version may work, but the"
echo "### officially supported version is $desired_version."
if test "$STRICT_LIBRARY_CHECK" = "yes"; then
echo "*** Strict library check failed. Either install the officially supported"
echo "*** version, or don't use the --enable-strict-library-check option."
exit -1
fi
else
AC_MSG_RESULT(yes)
fi
])
#
# CHECK_DESIRED_VERSION(LIBRARY-NAME, DESIRED-VERSION, FOUND-VERSION)
#
AC_DEFUN([CHECK_DESIRED_VERSION], [
library_name=$1
desired_version=$2
found_version=$3
if test "$STRICT_LIBRARY_CHECK" = "yes"; then
AC_MSG_CHECKING(for $library_name version == $desired_version)
else
AC_MSG_CHECKING(for $library_name version >= $desired_version)
fi
CHECK_VERSION($found_version, $desired_version)
version_check=$CHECK_VERSION_RESULT
if test $version_check -lt 0; then
AC_MSG_RESULT(no)
echo "*** $library_name version $desired_version or later is required, but version $found_version "
echo "*** was found instead. Please update your $library_name to version $desired_version."
exit -1
elif test $version_check -gt 0; then
if test "$STRICT_LIBRARY_CHECK" = "yes"; then
AC_MSG_RESULT(no)
else
AC_MSG_RESULT(yes)
fi
echo "### $library_name version $found_version was found. That version may work, but the"
echo "### officially supported version is $desired_version."
if test "$STRICT_LIBRARY_CHECK" = "yes"; then
echo "*** Strict library check failed. Either install the officially supported"
echo "*** version, or don't use the --enable-strict-library-check option."
exit -1
fi
else
AC_MSG_RESULT(yes)
fi
])