1
dnl as-ac-expand.m4 0.2.0
2
dnl autostars m4 macro for expanding directories using configure's prefix
3
dnl thomas@apestaart.org
6
dnl AS_AC_EXPAND(VAR, CONFIGURE_VAR)
8
dnl AS_AC_EXPAND(SYSCONFDIR, $sysconfdir)
9
dnl will set SYSCONFDIR to /usr/local/etc if prefix=/usr/local
11
AC_DEFUN([AS_AC_EXPAND],
16
dnl first expand prefix and exec_prefix if necessary
18
exec_prefix_save=$exec_prefix
20
dnl if no prefix given, then use /usr/local, the default prefix
21
if test "x$prefix" = "xNONE"; then
22
prefix="$ac_default_prefix"
24
dnl if no exec_prefix given, then use prefix
25
if test "x$exec_prefix" = "xNONE"; then
30
dnl loop until it doesn't change anymore
32
new_full_var="`eval echo $full_var`"
33
if test "x$new_full_var" = "x$full_var"; then break; fi
34
full_var=$new_full_var
38
full_var=$new_full_var
39
AC_SUBST([$1], "$full_var")
41
dnl restore prefix and exec_prefix
43
exec_prefix=$exec_prefix_save
46
dnl Available from the GNU Autoconf Macro Archive at:
47
dnl http://www.gnu.org/software/ac-archive/htmldoc/ax_compare_version.html
48
AC_DEFUN([AX_COMPARE_VERSION], [
49
# Used to indicate true or false condition
50
ax_compare_version=false
51
# Convert the two version strings to be compared into a format that
52
# allows a simple string comparison. The end result is that a version
53
# string of the form 1.12.5-r617 will be converted to the form
54
# 0001001200050617. In other words, each number is zero padded to four
55
# digits, and non digits are removed.
56
AS_VAR_PUSHDEF([A],[ax_compare_version_A])
57
A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
58
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
59
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
60
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
63
AS_VAR_PUSHDEF([B],[ax_compare_version_B])
64
B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
65
-e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
66
-e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
67
-e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
70
dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
71
dnl # then the first line is used to determine if the condition is true.
72
dnl # The sed right after the echo is to remove any indented white space.
73
m4_case(m4_tolower($2),
75
ax_compare_version=`echo "x$A
76
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
79
ax_compare_version=`echo "x$A
80
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
83
ax_compare_version=`echo "x$A
84
x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
87
ax_compare_version=`echo "x$A
88
x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
90
dnl Split the operator from the subversion count if present.
91
m4_bmatch(m4_substr($2,2),
93
# A count of zero means use the length of the shorter version.
94
# Determine the number of characters in A and B.
95
ax_compare_version_len_A=`echo "$A" | awk '{print(length)}'`
96
ax_compare_version_len_B=`echo "$B" | awk '{print(length)}'`
98
# Set A to no more than B's length and B to no more than A's length.
99
A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
100
B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
103
# A count greater than zero means use only that many subversions
104
A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
105
B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
109
[illegal OP numeric parameter: $2])
112
# Pad zeros at end of numbers to make same length.
113
ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
114
B="$B`echo $A | sed 's/./0/g'`"
115
A="$ax_compare_version_tmp_A"
117
# Check for equality or inequality as necessary.
118
m4_case(m4_tolower(m4_substr($2,0,2)),
120
test "x$A" = "x$B" && ax_compare_version=true
123
test "x$A" != "x$B" && ax_compare_version=true
125
AC_WARNING([illegal OP parameter: $2])
129
AS_VAR_POPDEF([A])dnl
130
AS_VAR_POPDEF([B])dnl
132
dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
133
if test "$ax_compare_version" = "true" ; then
134
m4_ifvaln([$4],[$4],[:])dnl
135
m4_ifvaln([$5],[else $5])dnl
137
]) dnl AX_COMPARE_VERSION