Fix stupid accidental dependence on a bash quirk in previous
[mmh] / aclocal.m4
1
2 # Originally by John Hawkinson <jhawk@mit.edu>
3 # Under Solaris, those
4 # applications need to link with "-lsocket -lnsl".  Under IRIX, they
5 # need to link with "-lnsl" but should *not* link with "-lsocket"
6 # because libsocket.a breaks a number of things (for instance,
7 # gethostbyname() under IRIX 5.2, and snoop sockets under most versions
8 # of IRIX).
9 #
10 # The check for libresolv is in case you are attempting to link
11 # statically and happen to have a libresolv.a lying around (and no
12 # libnsl.a). An example of such a case would be Solaris with
13 # BIND 4.9.5 installed.
14
15 AC_DEFUN(AC_CHECK_NETLIBS,
16 [AC_CHECK_FUNC(gethostbyname, ,
17   AC_CHECK_LIB(nsl, gethostbyname, ,
18     AC_CHECK_LIB(resolv, gethostbyname)))
19 AC_CHECK_FUNC(socket, ,
20   AC_CHECK_LIB(socket, socket))
21 ])
22
23 dnl --------------
24 dnl CHECK FOR NDBM
25 dnl --------------
26 dnl
27 dnl NMH_CHECK_DBM(libname,action-if-true,action-if-false,other-libraries)
28 dnl Check for presence of dbm_open() in the specified library
29 dnl (if libname is the empty string then don't try to link against
30 dnl any particular library). If action-if-true is unspecified it
31 dnl defaults to adding "-llibname" to the beginning of LIBS.
32 dnl If other-libraries is specified then these are prepended to
33 dnl LIBS for the duration of the check.
34 dnl NB that the checks for the right dbm header files must
35 dnl be done before using this macro!
36 dnl
37 dnl We try to link our own code fragment (which includes the
38 dnl headers in the same way slocal.c does) rather than
39 dnl using AC_CHECK_LIB because on later versions of libdb
40 dnl the dbm_open() function is provided via a #define and
41 dnl we don't want to hardcode searching for the internal
42 dnl function that lies behind it. (AC_CHECK_LIB works by
43 dnl defining its own bogus prototype rather than pulling in
44 dnl the right header files.)
45 AC_DEFUN(NMH_CHECK_DBM,
46 [
47 if test "x$1" = "x"; then
48    nmh_libs=
49    dnl this is just for the benefit of AC_CACHE_CHECK's message
50    nmh_testname=libc
51 else
52    nmh_libs="-l$1 "
53    nmh_testname="$1"
54 fi
55 AC_CACHE_CHECK([for dbm in $nmh_testname], [nmh_cv_check_dbm_$1],[
56 nmh_saved_libs="$LIBS"
57 LIBS="$nmh_libs $4 $LIBS"
58 AC_LINK_IFELSE(AC_LANG_PROGRAM([[
59 #ifdef HAVE_DB1_NDBM_H
60 #include <db1/ndbm.h>
61 #else
62 #ifdef HAVE_GDBM_NDBM_H
63 #include <gdbm/ndbm.h>
64 #else
65 #if defined(HAVE_DB_H)
66 #define DB_DBM_HSEARCH 1
67 #include <db.h>
68 #else
69 #include <ndbm.h>
70 #endif
71 #endif
72 #endif
73 ]],
74 [[dbm_open("",0,0);]]),[nmh_cv_check_dbm_$1=yes],[
75 nmh_cv_check_dbm_$1=no])
76 LIBS="$nmh_saved_libs"
77 ])
78 if eval "test \"`echo '$nmh_cv_check_dbm_'$1`\" = yes"; then
79   nmh_tr_macro=HAVE_LIB`echo $1 | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
80   AC_DEFINE_UNQUOTED($nmh_tr_macro)
81   m4_if([$2],,[LIBS="$nmh_libs$LIBS"],[$2])
82 else
83   $3
84   :
85 fi
86 ])dnl