-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathacinclude.m4
More file actions
378 lines (355 loc) · 13.5 KB
/
acinclude.m4
File metadata and controls
378 lines (355 loc) · 13.5 KB
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
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# Copyright 2011 Sergey Kolotsey.
#
# This file is part of libexpression library.
#
# libexpression is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# libexpression is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public Licenise
# along with libexpression. If not, see <http://www.gnu.org/licenses/>.
# This file is a M4 script file that defines extra functions
# required by configure script
dnl EQ_SET_MATHLIBS()
dnl Checks for required math libraries and headers. This function sets MATHLIBS
dnl variable to a name of the library that needs to be prepended to LIBS and
dnl adds HAVE_MATH_H to config.h header file if math.h is found
AC_DEFUN([EQ_SET_MATHLIBS], [
ac_save_libs=$LIBS
AC_SEARCH_LIBS(sqrt, m, [ac_lib_found=true], [ac_lib_found=false])
AC_CHECK_HEADERS([math.h])
LIBS=$ac_save_libs
if test "X$ac_lib_found" = "Xtrue"; then
if test "X$ac_cv_search_sqrt" != "Xnone required"; then
MATHLIBS="$MATHLIBS $ac_cv_search_sqrt"
fi
else
AC_MSG_ERROR([
Required math library was not found in a set of standard library paths. If you
have this library (libm or other) installed in a nonstandard lib directory,
or the name of the library is other than libm, provide path to that directory
and name of the library in LDFLAGS, e.g. LDFLAGS=-L<lib dir> -l<lib name>])
fi
AC_SUBST(MATHLIBS)
])
dnl EQ_SET_DLLIBS()
dnl Checks for required dl libraries and headers. This function sets DLLIBS
dnl variable to a name of the library that needs to be prepended to LIBS and
dnl adds HAVE_DLFCN_H to config.h header file if dlfcn.h is found
AC_DEFUN([EQ_SET_DLLIBS], [
ac_save_libs=$LIBS
AC_SEARCH_LIBS(dlopen, [dl dld], [ac_lib_found=true], [ac_lib_found=false])
AC_CHECK_HEADERS([dlfcn.h])
LIBS=$ac_save_libs
if test "X$ac_lib_found" = "Xtrue"; then
if test "X$ac_cv_search_dlopen" != "Xnone required"; then
DLLIBS="$DLLIBS $ac_cv_search_dlopen"
fi
else
AC_MSG_ERROR([
Required dl library was not found in a set of standard library paths. If you
have this library (libdl or other) installed in a nonstandard lib directory,
or the name of the library is other than libdl, provide path to that directory
and name of the library in LDFLAGS, e.g. LDFLAGS=-L<lib dir> -l<lib name>])
fi
AC_SUBST(DLLIBS)
])
dnl EQ_SET_SOCKETLIBS()
dnl Checks for required socket libraries and headers. This function sets
dnl SOCKETLIBS variable to a name of the library(es) that needs to be prepended
dnl to LIBS and adds HAVE_SOCKET_H to config.h header file if socket.h is found
AC_DEFUN([EQ_SET_SOCKETLIBS], [
ac_save_libs=$LIBS
AC_SEARCH_LIBS(getservbyname, nsl socket, [ac_nsl_lib_found=true], [ac_nsl_lib_found=false])
AC_SEARCH_LIBS(connect, socket, [ac_socket_lib_found=true], [ac_socket_lib_found=false])
AC_CHECK_HEADERS([socket.h sys/socket.h])
LIBS=$ac_save_libs
if test "X$ac_nsl_lib_found" = "Xtrue" && test "X$ac_socket_lib_found" = "Xtrue"; then
if test "X$ac_cv_search_getservbyname" != "Xnone required"; then
SOCKETLIBS="$SOCKETLIBS $ac_cv_search_getservbyname"
fi
if test "X$ac_cv_search_connect" != "Xnone required"; then
SOCKETLIBS="$SOCKETLIBS $ac_cv_search_connect"
fi
dnl remove dublicates
ac_socket_libs_ret=
for ac_socketlibs_i in $SOCKETLIBS; do
ac_socketlibs_found=false
for ac_socketlibs_j in $ac_socketlibs_ret; do
if test "X$ac_socketlibs_i" = "X$ac_socketlibs_j"; then
ac_socketlibs_found=true
break
fi
done
if test "X$ac_socketlibs_found" = "Xfalse"; then
ac_socketlibs_ret="$ac_socketlibs_ret $ac_socketlibs_i"
fi
done
SOCKETLIBS=$ac_socketlibs_ret
else
AC_MSG_ERROR([
Required libraries were not found in a set of standard library paths. Calls to
connect() and/or getservbyname() functons are impossible to make. If you
have these libraries (libsocket, libnsl) installed in a nonstandard lib
directory, provide path to that directory and name of the library in LDFLAGS,
e.g. LDFLAGS=-L<lib dir> -l<lib name>])
fi
AC_SUBST(SOCKETLIBS)
])
dnl EQ_SET_THREADLIBS()
dnl Test for pthreads support
dnl Taken from ICU FreeBSD Port configure script
AC_DEFUN([EQ_PTHREAD_FREEBSD],[
dnl FreeBSD: Try ports/linuxthreads first - Mammad Zadeh <mammad@yahoo-inc.com>
dnl FreeBSD -pthread check - Jonathan McDowell <noodles@earth.li>
AC_CHECK_LIB(lthread, pthread_create,
[CFLAGS="-D_THREAD_SAFE -I/usr/local/include/pthread/linuxthreads -I/usr/include $CFLAGS"
THREADLIBS="-L/usr/local/lib -llthread -llgcc_r"],
[AC_MSG_CHECKING([if we need -pthread for threads])
AC_CACHE_VAL(ac_cv_ldflag_pthread,[
ac_save_LDFLAGS="$LDFLAGS"
LDFLAGS="-pthread $LDFLAGS"
AC_TRY_LINK([char pthread_create();],
pthread_create();,
eval "ac_cv_ldflag_pthread=yes",
eval "ac_cv_ldflag_pthread=no"
),
THREADLIBS="$ac_save_LDFLAGS"
])
if eval "test \"`echo $ac_cv_ldflag_pthread`\" = yes"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
fi
],-L/usr/local/lib)
])
AC_DEFUN([EQ_SET_THREADLIBS], [
have_pthreads="no"
dnl Test for HPUX cma threads first
AC_CHECK_LIB(cma,pthread_create,THREADLIBS="$THREADLIBS -lpthread")
if test $ac_cv_lib_cma_pthread_create = yes; then
have_pthreads="yes"
fi
dnl special pthread handling
dnl AIX uses pthreads instead of pthread, and HP/UX uses cma
dnl FreeBSD users -pthread
AC_CHECK_LIB(pthread,pthread_create,THREADLIBS="$THREADLIBS -lpthread")
if test $ac_cv_lib_pthread_pthread_create = yes; then
have_pthreads="yes"
else
dnl For HP 11
AC_CHECK_LIB(pthread,pthread_mutex_init,THREADLIBS="$THREADLIBS -lpthread")
if test $ac_cv_lib_pthread_pthread_mutex_init = yes; then
have_pthreads="yes"
fi
fi
dnl AIX uses pthreads instead of pthread
if test $have_pthreads = "no"; then
AC_CHECK_LIB(pthreads,pthread_create,THREADLIBS="$THREADLIBS -lpthreads")
if test $ac_cv_lib_pthreads_pthread_create = yes; then
have_pthreads="yes"
fi
fi
dnl all other thread tests fail, try BSD's -pthread
if test $have_pthreads = "no"; then
EQ_PTHREAD_FREEBSD
fi
AC_SUBST(THREADLIBS)
])
dnl EQ_CHECK_PACKAGE(flags-prefix, package-name [,check-libs [,check-headers]])
dnl Check for specific library and header files for required package. Names of
dnl the package libraries and specific functions in that libraries are provided
dnl as `check-libs' argument of the macro call. Names of the package header
dnl files are provided as `check-headers' argument. The macro substitutes
dnl flags-prefix_LIBS and flags-prefix_CFLAGS variables
dnl for example:
dnl EQ_CHECK_PACKAGE( ZLIB, zlib)
dnl will result in ZLIB_LIBS and ZLIB_CFLAGS variables set to libs and cflags
dnl for the package zlib. Another example:
dnl EQ_CHECK_PACKAGE( PKG, packagename, [pkglib1:function1 pkglib2:function2], [header1.h header2.h])
AC_DEFUN([EQ_CHECK_PACKAGE],[
ac_new_cflags=
ac_new_libs=
ac_cflags_given=false
ac_libs_given=false
ac_cflags_found=false
ac_libs_found=false
ac_pakage_cflags_found=false
ac_package_libs_found=false
if test "X$4" != "X"; then
AC_ARG_WITH([$2-inc], [AS_HELP_STRING([--with-$2-inc], [location of `$2' header files @<:@directories provided in CFLAGS@:>@])], [ac_new_cflags=-I$withval; ac_cflags_given=true])
fi
AC_ARG_WITH([$2-lib], [AS_HELP_STRING([--with-$2-lib], [location of `$2' library files @<:@directories provided in LIBS or LDFLAGS@:>@])], [ac_new_libs=-L$withval; ac_libs_given=true])
dnl try using pkg-config
if test "X$ac_cflags_given" != "Xtrue" && test "X$ac_libs_given" != "Xtrue"; then
PKG_CHECK_MODULES( [$1], [$2], [ac_package_cflags_found=true; ac_package_libs_found=true], [ac_package_cflags_found=false; ac_package_libs_found=false])
fi
dnl if pkg-config did not provide us with correct result, try other tests
ac_save_cflags=$CFLAGS
ac_save_cppflags=$CPPFLAGS
ac_save_ldflags=$LDFLAGS
ac_save_libs=$LIBS
CPPFLAGS="$CPPFLAGS $ac_new_cflags $$1_CFLAGS"
LIBS="$LIBS $ac_new_libs $$1_LIBS"
if test "X$4" = "X"; then
if test "X$ac_package_cflags_found" = "Xtrue"; then
ac_header_found=true
else
ac_header_found=false
fi
else
AC_CHECK_HEADERS([$4], [ac_header_found=true], [ac_header_found=false])
fi
if test "X$ac_header_found" = "Xtrue"; then
if test "X$3" = "X"; then
if test "X$ac_package_libs_found" = "Xtrue"; then
ac_libs_found=true
else
ac_libs_found=false
fi
else
ac_libs_found=true
for ac_ii in $3; do
ac_library=${ac_ii%%:*}
ac_function=${ac_ii#*:}
AC_SEARCH_LIBS( [$ac_function], [$ac_library], [ac_libs_found=true], [ac_libs_found=false])
if test "X$ac_libs_found" = "Xtrue"; then
eval "ac_cv_search_function=\$ac_cv_search_$ac_function"
if test "X$ac_cv_search_function" != "Xnone required"; then
ac_new_libs="$ac_new_libs $ac_cv_search_function";
fi
else
break
fi
done
fi
fi
CFLAGS=$ac_save_cflags
CPPFLAGS=$ac_save_cppflags
LDFLAGS=$ac_save_ldflags
LIBS=$ac_save_libs
if test "X$ac_header_found" = "Xtrue" && test "X$ac_libs_found" = "Xtrue" ; then
$1_CFLAGS="$$1_CFLAGS $ac_new_cflags"
$1_LIBS="$$1_LIBS $ac_new_libs"
AC_SUBST($1_CFLAGS)
AC_SUBST($1_LIBS)
else
AC_MSG_ERROR([
Required library and/or headers files from required package `$2'
were not found in a set of standard library paths. If you have this package
installed in a nonstandard directory, provide path to include and lib
directories using command line arguments:
--with-$2-inc=<include dir>
--with-$2-lib=<lib dir>
See
$as_me --help
for more information])
fi
])
dnl EQ_PACKAGE_ENABLED(flags-prefix, package-name [,check-libs [,check-headers]])
dnl Check for specific library and header files for required package. Checks if
dnl user enabled this package or if it could be enabled by default. Names of
dnl the package libraries and specific functions in that libraries are provided
dnl as `check-libs' argument of the macro call. Names of the package header
dnl files are provided as `check-headers' argument. The macro substitutes
dnl flags-prefix_LIBS and flags-prefix_CFLAGS and flags-prfix_ENABLED variables
dnl for example:
dnl EQ_PACKAGE_ENABLED( ZLIB, zlib)
dnl will result in ZLIB_LIBS and ZLIB_CFLAGS variables set to libs and cflags
dnl for the package zlib and ZLIB_ENABLED set to true if package is installed.
AC_DEFUN([EQ_PACKAGE_ENABLED],[
ac_new_cflags=
ac_new_libs=
ac_cflags_given=false
ac_libs_given=false
ac_cflags_found=false
ac_libs_found=false
AC_ARG_WITH([$2], [AS_HELP_STRING([--with-$2], [enable package `$2' support, @<:@default=check@:>@])], [ac_with_package=$withval], [ac_with_package=check])
if test "X$4" != "X"; then
AC_ARG_WITH([$2-inc], [AS_HELP_STRING([--with-$2-inc], [location of package `$2' header files @<:@directories provided in CFLAGS@:>@])], [ac_new_cflags=-I$withval; ac_cflags_given=true; ac_with_package=yes])
fi
AC_ARG_WITH([$2-lib], [AS_HELP_STRING([--with-$2-lib], [location of package `$2' library files @<:@directories provided in LIBS and LDFLAGS@:>@])], [ac_new_libs=-L$withval; ac_libs_given=true; ac_with_package=yes])
if test "X$ac_with_package" != "Xno"; then
dnl try using pkg-config
if test "X$ac_cflags_given" != "Xtrue" && test "X$ac_libs_given" != "Xtrue"; then
PKG_CHECK_MODULES( [$1], [$2], [ac_package_cflags_found=true; ac_package_libs_found=true], [ac_package_cflags_found=false; ac_package_libs_found=false])
fi
ac_save_cflags=$CFLAGS
ac_save_cppflags=$CPPFLAGS
ac_save_ldflags=$LDFLAGS
ac_save_libs=$LIBS
CPPFLAGS="$CPPFLAGS $ac_new_cflags $$1_CFLAGS"
LIBS="$LDFLAGS $ac_new_libs $$1_LIBS"
if test "X$4" = "X"; then
if test "X$ac_cflags_given" = "Xtrue" || test "X$ac_package_cflags_found" = "Xtrue"; then
ac_header_found=true
else
ac_header_found=false
fi
else
AC_CHECK_HEADERS([$4], [ac_header_found=true], [ac_header_found=false])
fi
if test "X$ac_header_found" = "Xtrue"; then
if test "X$3" = "X"; then
if test "X$ac_libs_given" = "Xtrue" || test "X$ac_package_libs_found" = "Xtrue"; then
ac_libs_found=true
else
ac_libs_found=false
fi
else
ac_libs_found=true
for ac_ii in $3; do
ac_library=${ac_ii%%:*}
ac_function=${ac_ii#*:}
AC_SEARCH_LIBS( [$ac_function], [$ac_library], [ac_libs_found=true], [ac_libs_found=false])
if test "X$ac_libs_found" = "Xtrue"; then
eval "ac_cv_search_function=\$ac_cv_search_$ac_function"
if test "X$ac_cv_search_function" != "Xnone required"; then
ac_new_libs="$ac_new_libs $ac_cv_search_function";
fi
else
break
fi
done
fi
fi
CFLAGS=$ac_save_cflags
CPPFLAGS=$ac_save_cppflags
LDFLAGS=$ac_save_ldflags
LIBS=$ac_save_libs
if test "X$ac_header_found" = "Xtrue" && test "X$ac_libs_found" = "Xtrue" ; then
$1_ENABLED=true
$1_CFLAGS="$$1_CFLAGS $ac_new_cflags"
$1_LIBS="$$1_LIBS $ac_new_libs"
elif test "X$ac_with_package" = "Xyes"; then
AC_MSG_ERROR([
Could not find library and/or headers files for package `$2'
This package was set as required in command line arguments. If you want to
enable this package, install it. If you have this package installed in a
nonstandard directory, provide path to include and lib directories using command
line arguments:
--with-$2-inc=<include dir>
--with-$2-lib=<lib dir>
See
$as_me --help
for more information])
else
$1_ENABLED=false
$1_CFLAGS=
$1_LIBS=
fi
else
$1_ENABLED=false
$1_CFLAGS=
$1_LIBS=
fi
AC_SUBST($1_ENABLED)
AC_SUBST($1_CFLAGS)
AC_SUBST($1_LIBS)
])