1dnl ==================================================================
2dnl Checks for library functions.
3dnl ==================================================================
4
5AC_FUNC_ALLOCA
6AC_FUNC_MEMCMP
7AC_FUNC_MMAP
8AC_TYPE_SIGNAL
9AC_FUNC_VPRINTF
10AC_FUNC_VA_COPY
11AC_FUNC__VA_COPY
12AC_CHECK_FUNCS(
13	access _access connect dlopen execvp fcntl ftime _ftime getaddrinfo \
14	gethostbyname gethostname getnameinfo getpagesize gettimeofday getuid \
15	getwd ioctl mkdir _mkdir mprotect putenv select snprintf _snprintf \
16	socket stat strcasestr strerror strnlen strsep strstr vsnprintf \
17	_vsnprintf wait
18)
19
20DL_LIBS=""
21if test "x$ac_cv_func_dlopen" != "xyes"; then
22	AC_CHECK_LIB(dl, dlopen,
23		AC_DEFINE(HAVE_DLOPEN, 1, [Define if you have the dlopen function.])
24		DL_LIBS="-ldl"
25	)
26fi
27AC_SUBST(DL_LIBS)
28
29dnl Checks for stricmp/strcasecmp
30#AC_CHECK_FUNC(strcasecmp,
31#	,
32#	AC_CHECK_FUNC(stricmp,
33#		AC_DEFINE(strcasecmp,	stricmp)
34#	)
35#)
36AC_CHECK_FUNC(strcasecmp, strcasecmp=yes, strcasecmp=no)
37if test "x$strcasecmp" = xno; then
38	AC_CHECK_FUNC(stricmp,
39		AC_DEFINE(strcasecmp, stricmp, [Define strcasecmp as stricmp if you have one but not the other]),
40		AC_MSG_ERROR([Neither stricmp nor strcasecmp found])
41	)
42fi
43
44dnl Check for vsnprintf
45if test "x$ac_cv_func_vsnprintf" = "xno" -a \
46	"x$ac_cv_func__vsnprintf" = "xno"; then
47	dnl libdb may have this
48	AC_CHECK_LIB(db,vsnprintf)
49fi
50
51AC_CHECK_FUNCS(usleep)
52
53AC_MSG_CHECKING(for fnmatch)
54AC_TRY_LINK(
55	[],
56	[fnmatch();],
57	BUILD_FNMATCH=no
58	AC_MSG_RESULT(yes),
59	BUILD_FNMATCH=yes
60	AC_MSG_RESULT(no)
61)
62AM_CONDITIONAL(BUILD_FNMATCH, test "x$BUILD_FNMATCH" = "xyes")
63
64AC_MSG_CHECKING(for opendir)
65AC_TRY_LINK(
66	[],
67	[opendir();],
68	BUILD_DIRENT=no
69	AC_MSG_RESULT(yes),
70	BUILD_DIRENT=yes
71	AC_MSG_RESULT(no)
72)
73AM_CONDITIONAL(BUILD_DIRENT, test "x$BUILD_DIRENT" = "xyes")
74
75AC_MSG_CHECKING(for getopt_long)
76AC_TRY_LINK(
77	[],
78	[getopt_long();],
79	BUILD_GETOPT=no
80	AC_MSG_RESULT(yes),
81	BUILD_GETOPT=yes
82	AC_MSG_RESULT(no)
83)
84AM_CONDITIONAL(BUILD_GETOPT, test "x$BUILD_GETOPT" = "xyes")
85
86AC_MSG_CHECKING(for log2f)
87AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
88	[[#include <math.h>]], [float (*foo)(float) = log2f;])],
89	AC_DEFINE(HAVE_LOG2F, 1, [Define if you have log2f.])
90	[HAVE_LOG2F=yes],
91	[HAVE_LOG2F=no])
92AC_MSG_RESULT($HAVE_LOG2F)
93