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
|
# libunistring-base.m4 serial 1
dnl Copyright (C) 2010 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl From Paolo Bonzini and Bruno Haible.
dnl gl_LIBUNISTRING_LIBSOURCE([VERSION], [SourceFile])
dnl Declares that SourceFile should be compiled, unless we are linking
dnl with libunistring and its version is >= the given VERSION.
dnl SourceFile should be relative to the lib directory and end in '.c'.
dnl This macro is to be used for public libunistring API, not for
dnl undocumented API.
dnl
dnl You have to bump the VERSION argument to the next projected version
dnl number each time you make a change that affects the behaviour of the
dnl functions defined in SourceFile (even if SourceFile itself does not
dnl change).
AC_DEFUN([gl_LIBUNISTRING_LIBSOURCE],
[
AC_REQUIRE([gl_LIBUNISTRING_LIB_PREPARE])
dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from
dnl gl_LIBUNISTRING_CORE if that macro has been run.
if gl_LIBUNISTRING_VERSION_CMP([$1])
then
m4_foreach_w([gl_source_file], [$2],
[AC_LIBOBJ(m4_bpatsubst(m4_defn([gl_source_file]), [\.c$], []))
])
fi
])
dnl gl_LIBUNISTRING_LIBHEADER([VERSION], [HeaderFile])
dnl Declares that HeaderFile should be created, unless we are linking
dnl with libunistring and its version is >= the given VERSION.
dnl HeaderFile should be relative to the lib directory and end in '.h'.
dnl Prepares for substituting LIBUNISTRING_HEADERFILE (to HeaderFile or empty).
dnl
dnl When we are linking with the already installed libunistring and its version
dnl is < VERSION, we create HeaderFile here, because we may compile functions
dnl (via gl_LIBUNISTRING_LIBSOURCE above) that are not contained in the
dnl installed version.
dnl When we are linking with the already installed libunistring and its version
dnl is > VERSION, we don't create HeaderFile here: it could cause compilation
dnl errors in other libunistring header files if some types are missing.
dnl
dnl You have to bump the VERSION argument to the next projected version
dnl number each time you make a non-comment change to the HeaderFile.
AC_DEFUN([gl_LIBUNISTRING_LIBHEADER],
[
AC_REQUIRE([gl_LIBUNISTRING_LIB_PREPARE])
dnl Use the variables HAVE_LIBUNISTRING, LIBUNISTRING_VERSION from
dnl gl_LIBUNISTRING_CORE if that macro has been run.
if gl_LIBUNISTRING_VERSION_CMP([$1])
then
LIBUNISTRING_[]AS_TR_CPP([$2])='$2'
else
LIBUNISTRING_[]AS_TR_CPP([$2])=
fi
AC_SUBST([LIBUNISTRING_]AS_TR_CPP([$2]))
])
dnl Miscellaneous preparations/initializations.
AC_DEFUN([gl_LIBUNISTRING_LIB_PREPARE],
[
AC_REQUIRE([AC_PROG_AWK])
dnl Sed expressions to extract the parts of a version number.
changequote(,)
gl_libunistring_sed_extract_major='/^[0-9]/{s/^\([0-9]*\).*/\1/p;q;}
i\
0
q
'
gl_libunistring_sed_extract_minor='/^[0-9][0-9]*[.][0-9]/{s/^[0-9]*[.]\([0-9]*\).*/\1/p;q;}
i\
0
q
'
gl_libunistring_sed_extract_subminor='/^[0-9][0-9]*[.][0-9][0-9]*[.][0-9]/{s/^[0-9]*[.][0-9]*[.]\([0-9]*\).*/\1/p;q;}
i\
0
q
'
changequote([,])
if test "$HAVE_LIBUNISTRING" = yes; then
LIBUNISTRING_VERSION_MAJOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_major"`
LIBUNISTRING_VERSION_MINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_minor"`
LIBUNISTRING_VERSION_SUBMINOR=`echo "$LIBUNISTRING_VERSION" | sed -n -e "$gl_libunistring_sed_extract_subminor"`
fi
])
dnl gl_LIBUNISTRING_VERSION_CMP([VERSION])
dnl Expands to a shell statement that evaluates to true if LIBUNISTRING_VERSION
dnl is less than the VERSION argument.
dnl This is the unoptimized variant:
AC_DEFUN([gl_LIBUNISTRING_VERSION_CMP_ORIG],
[ { test "$HAVE_LIBUNISTRING" != yes \
|| {
requested_version_major=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_major"`
requested_version_minor=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_minor"`
requested_version_subminor=`echo '$1' | sed -n -e "$gl_libunistring_sed_extract_subminor"`
test $LIBUNISTRING_VERSION_MAJOR -lt $requested_version_major \
|| { test $LIBUNISTRING_VERSION_MAJOR -eq $requested_version_major \
&& { test $LIBUNISTRING_VERSION_MINOR -lt $requested_version_minor \
|| { test $LIBUNISTRING_VERSION_MINOR -eq $requested_version_minor \
&& test $LIBUNISTRING_VERSION_SUBMINOR -lt $requested_version_subminor
}
}
}
}
}
])
dnl This is the optimized variant, that assumes the argument is a literal:
AC_DEFUN([gl_LIBUNISTRING_VERSION_CMP],
[ { test "$HAVE_LIBUNISTRING" != yes \
|| {
m4_pushdef([requested_version_major],
[gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^\([0-9]*\).*], [\1]), [])])
m4_pushdef([requested_version_minor],
[gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^[0-9]*[.]\([0-9]*\).*], [\1]), [$1])])
m4_pushdef([requested_version_subminor],
[gl_LIBUNISTRING_ARG_OR_ZERO(m4_bpatsubst([$1], [^[0-9]*[.][0-9]*[.]\([0-9]*\).*], [\1]), [$1])])
test $LIBUNISTRING_VERSION_MAJOR -lt requested_version_major \
|| { test $LIBUNISTRING_VERSION_MAJOR -eq requested_version_major \
&& { test $LIBUNISTRING_VERSION_MINOR -lt requested_version_minor \
|| { test $LIBUNISTRING_VERSION_MINOR -eq requested_version_minor \
&& test $LIBUNISTRING_VERSION_SUBMINOR -lt requested_version_subminor
}
}
}
m4_popdef([requested_version_subminor])
m4_popdef([requested_version_minor])
m4_popdef([requested_version_major])
}
}
])
dnl gl_LIBUNISTRING_ARG_OR_ZERO([ARG], [ORIG]) expands to ARG if it is not the
dnl same as ORIG, otherwise to 0.
m4_define([gl_LIBUNISTRING_ARG_OR_ZERO], [m4_if([$1], [$2], [0], [$1])])
|