* h/mh.h, h/prototypes.h, uip/mhbuildsbr.c, uip/send.c,
[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(include,library,action-if-found,action-if-not)
28
29 dnl Check for presence of dbm_open() in the specified library
30 dnl and with the specified include file (if libname is the empty
31 dnl string then don't try to link against any particular library).
32
33 dnl We set nmh_ndbm_found to 'yes' or 'no'; if found we set
34 dnl nmh_ndbmheader to the first arg and nmh_ndbm to the second.
35
36 dnl If this macro accepted a list of include,library tuples
37 dnl to test in order that would be cleaner than the current
38 dnl nest of calls in configure.in.
39
40 dnl We try to link our own code fragment (which includes the
41 dnl headers in the same way slocal.c does) rather than
42 dnl using AC_CHECK_LIB because on later versions of libdb
43 dnl the dbm_open() function is provided via a #define and
44 dnl we don't want to hardcode searching for the internal
45 dnl function that lies behind it. (AC_CHECK_LIB works by
46 dnl defining its own bogus prototype rather than pulling in
47 dnl the right header files.)
48
49 dnl An oddity (bug) of this macro is that if you haven't
50 dnl done AC_PROG_CC or something that implies it before
51 dnl using this macro autoconf complains about a recursive
52 dnl expansion.
53
54 AC_DEFUN(NMH_CHECK_NDBM,
55 [
56 if test "x$2" = "x"; then
57   nmh_libs=
58   AC_MSG_CHECKING([for dbm in $1])
59 else
60   nmh_libs="-l$2 "
61   AC_MSG_CHECKING([for dbm in $1 and $2])
62 fi
63
64 dnl We don't try to cache the result, because that exceeds
65 dnl my autoconf skills -- feel free to put it in :-> -- PMM
66
67 nmh_saved_libs="$LIBS"
68 LIBS="$nmh_libs $5 $LIBS"
69 AC_LINK_IFELSE(AC_LANG_PROGRAM([[
70 #define DB_DBM_HSEARCH 1
71 #include <$1>
72 ]],
73 [[dbm_open("",0,0);]]),[nmh_ndbm_found=yes],[nmh_ndbm_found=no])
74 LIBS="$nmh_saved_libs"
75
76 if test "$nmh_ndbm_found" = "yes"; then
77   AC_MSG_RESULT(yes)
78   nmh_ndbmheader="$1"
79   nmh_ndbm="$2"
80   $3
81 else
82   AC_MSG_RESULT(no)
83   $4
84   :
85 fi
86 ])dnl