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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
|
dnl #
dnl # /usr/share/aclocal/libmpu.m4
dnl #
dnl # Configure paths for libmpu
dnl # Andrey V.Kosteltsev
dnl ============================================================
dnl
dnl Synopsis:
dnl AC_CHECK_LIBMPU([MIN-VERSION [, # minimum libmpu version, e.g. 1.0.15
dnl DEFAULT-WITH-LIBMPU [, # default value for --with-libmpu option
dnl ACTION-IF-FOUND [, # action to perform if libmpu was found
dnl ACTION-IF-NOT-FOUND # action to perform if libmpu was not found
dnl ]]]])
dnl Examples:
dnl AC_CHECK_LIBMPU(1.0.15)
dnl AC_CHECK_LIBMPU(1.0.15,,,CFLAGS="$CFLAGS -DHAVE_LIBMPU $LIBMPU_CFLAGS")
dnl AC_CHECK_LIBMPU(1.0.15,yes,CFLAGS="$CFLAGS -DHAVE_LIBMPU")
dnl
dnl
dnl If you have to change prefix returned by mpu-config script or change
dnl location of mpu-config, you may set environment variable LIBMPU_CONFIG,
dnl for example:
dnl
dnl # export LIBMPU_CONFIG="/usr/bin/mpu-config"
dnl
dnl ============================================================
dnl
dnl ============================================================
dnl auxilliary macros
dnl ============================================================
AC_DEFUN([_AC_LIBMPU_ERROR], [dnl
AC_MSG_RESULT([*FAILED*])
cat <<EOT | sed -e 's/^[[ ]]*/ | /' -e 's/>>/ /' 1>&2
$1
EOT
exit 1
])
AC_DEFUN([_AC_LIBMPU_VERBOSE], [dnl
if test "x$verbose" = "xyes"; then
AC_MSG_RESULT([ $1])
fi
])
dnl ============================================================
dnl the user macro
dnl ============================================================
AC_DEFUN([AC_CHECK_LIBMPU], [dnl
dnl
dnl ============================================================
dnl prerequisites
dnl ============================================================
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_PROG_CPP])dnl
dnl
dnl ============================================================
dnl set LIBMPU_CONFIG variable
dnl ============================================================
if test -z "$LIBMPU_CONFIG"; then
LIBMPU_CONFIG='mpu-config'
fi
dnl
LIBMPU_CPPFLAGS=''
LIBMPU_CFLAGS=''
LIBMPU_LDFLAGS=''
LIBMPU_LIBS=''
LIBMPU_REAL_IO_DATA_LIMIT=''
LIBMPU_MATH_FN_DATA_LIMIT=''
LIBMPU_REAL_MAX_WIDTH=''
AC_SUBST(LIBMPU_CPPFLAGS)
AC_SUBST(LIBMPU_CFLAGS)
AC_SUBST(LIBMPU_LDFLAGS)
AC_SUBST(LIBMPU_LIBS)
AC_SUBST(LIBMPU_REAL_IO_DATA_LIMIT)
AC_SUBST(LIBMPU_MATH_FN_DATA_LIMIT)
AC_SUBST(LIBMPU_REAL_MAX_WIDTH)
dnl
dnl ============================================================
dnl command line options
dnl ============================================================
AC_MSG_CHECKING(for libmpu)
_AC_LIBMPU_VERBOSE([])
AC_ARG_WITH(libmpu,dnl
[ --with-libmpu[=ARG] Build with libmpu Library (default=]ifelse([$2],,yes,$2)[)],dnl
,dnl
with_libmpu="ifelse([$2],,yes,$2)"
)dnl
_AC_LIBMPU_VERBOSE([+ Command Line Options:])
_AC_LIBMPU_VERBOSE([ o --with-libmpu=$with_libmpu])
dnl
dnl ============================================================
dnl configuration
dnl ============================================================
if test "x$with_libmpu" != "xno"; then
libmpu_version=""
libmpu_location=""
libmpu_type=""
libmpu_cppflags=""
libmpu_cflags=""
libmpu_ldflags=""
libmpu_libs=""
libmpu_real_io_data_limit=""
libmpu_math_fn_data_limit=""
libmpu_real_max_width=""
if test "x$with_libmpu" = "xyes"; then
# via config script in $PATH
changequote(, )dnl
libmpu_version=`($LIBMPU_CONFIG --version) 2>/dev/null |\
sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'`
changequote([, ])dnl
if test "x$libmpu_version" != "x"; then
libmpu_location=`$LIBMPU_CONFIG --prefix`
libmpu_type='installed'
libmpu_cppflags=`$LIBMPU_CONFIG --cppflags`
libmpu_cflags=`$LIBMPU_CONFIG --cflags`
libmpu_ldflags=`$LIBMPU_CONFIG --ldflags`
libmpu_libs=`$LIBMPU_CONFIG --libs`
libmpu_real_io_data_limit=`$LIBMPU_CONFIG --real-io-data-limit`
libmpu_math_fn_data_limit=`$LIBMPU_CONFIG --math-fn-data-limit`
libmpu_real_max_width=`$LIBMPU_CONFIG --real-max-width`
fi
fi
dnl ========================================================
dnl Check whether the found version is sufficiently new
dnl ========================================================
_req_version="ifelse([$1],,1.0.0,$1)"
for _var in libmpu_version _req_version; do
eval "_val=\"\$${_var}\""
_major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'`
_minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'`
_rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'`
_micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'`
case $_rtype in
"a" ) _rtype=0 ;;
"b" ) _rtype=1 ;;
"." ) _rtype=2 ;;
esac
_hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \
"major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"`
eval "${_var}_hex=\"\$_hex\""
done
_AC_LIBMPU_VERBOSE([+ Determined Versions:])
_AC_LIBMPU_VERBOSE([ o existing: $libmpu_version -> 0x$libmpu_version_hex])
_AC_LIBMPU_VERBOSE([ o required: $_req_version -> 0x$_req_version_hex])
_ok=0
if test "x$libmpu_version_hex" != "x"; then
if test "x$_req_version_hex" != "x"; then
if test $libmpu_version_hex -ge $_req_version_hex; then
_ok=1
fi
fi
fi
if test "x$_ok" = "x0"; then
_AC_LIBMPU_ERROR([dnl
Found libmpu version $libmpu_version, but required at least version $_req_version.
Upgrade libmpu under $libmpu_location to $_req_version or higher first, please.])
fi
dnl ========================================================
dnl Perform libmpu Sanity Compile Check
dnl ========================================================
_ac_save_CPPFLAGS="$CPPFLAGS"
_ac_save_CFLAGS="$CFLAGS"
_ac_save_LDFLAGS="$LDFLAGS"
_ac_save_LIBS="$LIBS"
CPPFLAGS="$CPPFLAGS $libmpu_cppflags"
CFLAGS="$CFLAGS $libmpu_cflags"
LDFLAGS="$LDFLAGS $libmpu_ldflags"
LIBS="$LIBS $libmpu_libs"
_AC_LIBMPU_VERBOSE([+ Test Build Environment:])
_AC_LIBMPU_VERBOSE([ o CPPFLAGS="$CPPFLAGS"])
_AC_LIBMPU_VERBOSE([ o CFLAGS="$CFLAGS"])
_AC_LIBMPU_VERBOSE([ o LDFLAGS="$LDFLAGS"])
_AC_LIBMPU_VERBOSE([ o LIBS="$LIBS"])
cross_compile=no
_AC_LIBMPU_VERBOSE([+ Performing Sanity Checks:])
_AC_LIBMPU_VERBOSE([ o pre-processor test])
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
#include <libmpu.h>
]])], _ok=yes, _ok=no)
if test "x$_ok" != "xyes"; then
_AC_LIBMPU_ERROR([dnl
Found libmpu $libmpu_version under $libmpu_location, but
was unable to perform a sanity pre-processor check. This means
the libmpu header libmpu.h was not found.
We used the following build environment:
>> CPP="$CPP"
>> CPPFLAGS="$CPPFLAGS"
See config.log for possibly more details.])
fi
_AC_LIBMPU_VERBOSE([ o link check])
AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <libmpu.h>
int main()
{
__mpu_init();
__mpu_free_context();
return( 0 );
}
]])], _ok=yes, _ok=no)
if test "x$_ok" != "xyes"; then
_AC_LIBMPU_ERROR([dnl
Found libmpu $libmpu_version under $libmpu_location, but
was unable to perform a sanity linker check. This means
the libmpu library libmpu.a was not found.
We used the following build environment:
>> CC="$CC"
>> CFLAGS="$CFLAGS"
>> LDFLAGS="$LDFLAGS"
>> LIBS="$LIBS"
See config.log for possibly more details.])
fi
CPPFLAGS="$_ac_save_CPPFLAGS"
CFLAGS="$_ac_save_CFLAGS"
LDFLAGS="$_ac_save_LDFLAGS"
LIBS="$_ac_save_LIBS"
LIBMPU_CPPFLAGS="$libmpu_cppflags"
LIBMPU_CFLAGS="$libmpu_cflags"
LIBMPU_LDFLAGS="$libmpu_ldflags"
LIBMPU_LIBS="$libmpu_libs"
LIBMPU_REAL_IO_DATA_LIMIT="$libmpu_real_io_data_limit"
LIBMPU_MATH_FN_DATA_LIMIT="$libmpu_math_fn_data_limit"
LIBMPU_REAL_MAX_WIDTH="$libmpu_real_max_width"
AC_SUBST(LIBMPU_CPPFLAGS)
AC_SUBST(LIBMPU_CFLAGS)
AC_SUBST(LIBMPU_LDFLAGS)
AC_SUBST(LIBMPU_LIBS)
AC_SUBST(LIBMPU_REAL_IO_DATA_LIMIT)
AC_SUBST(LIBMPU_MATH_FN_DATA_LIMIT)
AC_SUBST(LIBMPU_REAL_MAX_WIDTH)
_AC_LIBMPU_VERBOSE([+ Final Results:])
_AC_LIBMPU_VERBOSE([ o LIBMPU_CPPFLAGS="$LIBMPU_CPPFLAGS"])
_AC_LIBMPU_VERBOSE([ o LIBMPU_CFLAGS="$LIBMPU_CFLAGS"])
_AC_LIBMPU_VERBOSE([ o LIBMPU_LDFLAGS="$LIBMPU_LDFLAGS"])
_AC_LIBMPU_VERBOSE([ o LIBMPU_LIBS="$LIBMPU_LIBS"])
_AC_LIBMPU_VERBOSE([ o LIBMPU_REAL_IO_DATA_LIMIT="$LIBMPU_REAL_IO_DATA_LIMIT"])
_AC_LIBMPU_VERBOSE([ o LIBMPU_MATH_FN_DATA_LIMIT="$LIBMPU_MATH_FN_DATA_LIMIT"])
_AC_LIBMPU_VERBOSE([ o LIBMPU_REAL_MAX_WIDTH="$LIBMPU_REAL_MAX_WIDTH"])
fi
if test "x$with_libmpu" != "xno"; then
AC_MSG_RESULT([version $libmpu_version, $libmpu_type under $libmpu_location])
ifelse([$3], , :, [$3])
else
AC_MSG_RESULT([no])
ifelse([$4], , :, [$4])
fi
])
|