2
dnl Improved version of AC_CHECK_LIB
4
dnl Thanks to John Hawkinson (jhawk@mit.edu)
8
dnl AC_LBL_CHECK_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [,
9
dnl ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]])
16
define(AC_LBL_CHECK_LIB,
17
[AC_MSG_CHECKING([for $2 in -l$1])
18
dnl Use a cache variable name containing both the library and function name,
19
dnl because the test really is for library $1 defining function $2, not
20
dnl just for library $1. Separate tests with the same $1 and different $2's
21
dnl may have different results.
22
ac_lib_var=`echo $1['_']$2['_']$5 | sed 'y%./+- %__p__%'`
23
AC_CACHE_VAL(ac_cv_lbl_lib_$ac_lib_var,
27
ifelse([$2], [main], , dnl Avoid conflicting decl of main.
28
[/* Override any gcc2 internal prototype to avoid an error. */
33
[/* We use char because int might match the return type of a gcc2
34
builtin and then its argument prototype would still apply. */
38
eval "ac_cv_lbl_lib_$ac_lib_var=yes",
39
eval "ac_cv_lbl_lib_$ac_lib_var=no")
42
if eval "test \"`echo '$ac_cv_lbl_lib_'$ac_lib_var`\" = yes"; then
46
ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \
47
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'`
49
AC_DEFINE_UNQUOTED($ac_tr_lib)
60
dnl AC_LBL_LIBRARY_NET
62
dnl This test is for network applications that need socket() and
63
dnl gethostbyname() -ish functions. Under Solaris, those applications
64
dnl need to link with "-lsocket -lnsl". Under IRIX, they need to link
65
dnl with "-lnsl" but should *not* link with "-lsocket" because
66
dnl libsocket.a breaks a number of things (for instance:
67
dnl gethostbyname() under IRIX 5.2, and snoop sockets under most
68
dnl versions of IRIX).
70
dnl Unfortunately, many application developers are not aware of this,
71
dnl and mistakenly write tests that cause -lsocket to be used under
72
dnl IRIX. It is also easy to write tests that cause -lnsl to be used
73
dnl under operating systems where neither are necessary (or useful),
74
dnl such as SunOS 4.1.4, which uses -lnsl for TLI.
76
dnl This test exists so that every application developer does not test
77
dnl this in a different, and subtly broken fashion.
79
dnl It has been argued that this test should be broken up into two
80
dnl seperate tests, one for the resolver libraries, and one for the
81
dnl libraries necessary for using Sockets API. Unfortunately, the two
82
dnl are carefully intertwined and allowing the autoconf user to use
83
dnl them independantly potentially results in unfortunate ordering
84
dnl dependancies -- as such, such component macros would have to
85
dnl carefully use indirection and be aware if the other components were
86
dnl executed. Since other autoconf macros do not go to this trouble,
87
dnl and almost no applications use sockets without the resolver, this
88
dnl complexity has not been implemented.
90
dnl The check for libresolv is in case you are attempting to link
91
dnl statically and happen to have a libresolv.a lying around (and no
94
AC_DEFUN(AC_LBL_LIBRARY_NET, [
95
# Most operating systems have gethostbyname() in the default searched
96
# libraries (i.e. libc):
97
AC_CHECK_FUNC(gethostbyname, ,
98
# Some OSes (eg. Solaris) place it in libnsl:
99
AC_LBL_CHECK_LIB(nsl, gethostbyname, ,
100
# Some strange OSes (SINIX) have it in libsocket:
101
AC_LBL_CHECK_LIB(socket, gethostbyname, ,
102
# Unfortunately libsocket sometimes depends on libnsl.
103
# AC_CHECK_LIB's API is essentially broken so the
104
# following ugliness is necessary:
105
AC_LBL_CHECK_LIB(socket, gethostbyname,
106
LIBS="-lsocket -lnsl $LIBS",
107
AC_CHECK_LIB(resolv, gethostbyname),
109
AC_CHECK_FUNC(socket, , AC_CHECK_LIB(socket, socket, ,
110
AC_LBL_CHECK_LIB(socket, socket, LIBS="-lsocket -lnsl $LIBS", ,
112
# DLPI needs putmsg under HPUX so test for -lstr while we're at it
113
AC_CHECK_LIB(str, putmsg)
117
dnl Checks to see if struct tm has the BSD tm_gmtoff member
121
dnl AC_ACME_TM_GMTOFF
125
dnl HAVE_TM_GMTOFF (defined)
127
AC_DEFUN(AC_ACME_TM_GMTOFF,
128
[AC_MSG_CHECKING(if struct tm has tm_gmtoff member)
129
AC_CACHE_VAL(ac_cv_acme_tm_has_tm_gmtoff,
131
# include <sys/types.h>
133
[u_int i = sizeof(((struct tm *)0)->tm_gmtoff)],
134
ac_cv_acme_tm_has_tm_gmtoff=yes,
135
ac_cv_acme_tm_has_tm_gmtoff=no))
136
AC_MSG_RESULT($ac_cv_acme_tm_has_tm_gmtoff)
137
if test $ac_cv_acme_tm_has_tm_gmtoff = yes ; then
138
AC_DEFINE(HAVE_TM_GMTOFF, 1, [define if struct tm has the BSD tm_gmtoff member])
142
dnl Checks to see if int64_t exists
150
dnl HAVE_INT64T (defined)
152
AC_DEFUN(AC_ACME_INT64T,
153
[AC_MSG_CHECKING(if int64_t exists)
154
AC_CACHE_VAL(ac_cv_acme_int64_t,
156
# include <sys/types.h>],
158
ac_cv_acme_int64_t=yes,
159
ac_cv_acme_int64_t=no))
160
AC_MSG_RESULT($ac_cv_acme_int64_t)
161
if test $ac_cv_acme_int64_t = yes ; then
162
AC_DEFINE(HAVE_INT64T, 1, [define it the type int67_t exists])