fcc5fbd7225e4e7cd41045ea5c648269e83c1f1c
[mmh] / aclocal.m4
1
2 #
3 # Updated for more modern systems.  Check to see if we need to link against
4 # optional libraries for networking functions.
5 #
6
7 AC_DEFUN([AC_CHECK_NETLIBS],
8 [AC_SEARCH_LIBS([gethostbyname], [nsl], ,
9                 [AC_MSG_ERROR([gethostbyname not found])])
10  AC_SEARCH_LIBS([connect], [socket], , [AC_MSG_ERROR([connect not found])])
11 ])dnl
12
13 dnl --------------
14 dnl CHECK FOR NDBM
15 dnl --------------
16 dnl
17 dnl NMH_CHECK_DBM(include,library,action-if-found,action-if-not)
18
19 dnl Check for presence of dbm_open() in the specified library
20 dnl and with the specified include file (if libname is the empty
21 dnl string then don't try to link against any particular library).
22
23 dnl We set nmh_ndbm_found to 'yes' or 'no'; if found we set
24 dnl nmh_ndbmheader to the first arg and nmh_ndbm to the second.
25
26 dnl If this macro accepted a list of include,library tuples
27 dnl to test in order that would be cleaner than the current
28 dnl nest of calls in configure.ac.
29
30 dnl We try to link our own code fragment (which includes the
31 dnl headers in the same way slocal.c does) rather than
32 dnl using AC_CHECK_LIB because on later versions of libdb
33 dnl the dbm_open() function is provided via a #define and
34 dnl we don't want to hardcode searching for the internal
35 dnl function that lies behind it. (AC_CHECK_LIB works by
36 dnl defining its own bogus prototype rather than pulling in
37 dnl the right header files.)
38
39 dnl An oddity (bug) of this macro is that if you haven't
40 dnl done AC_PROG_CC or something that implies it before
41 dnl using this macro autoconf complains about a recursive
42 dnl expansion.
43
44 AC_DEFUN(NMH_CHECK_NDBM,
45 [
46 if test "x$2" = "x"; then
47   nmh_libs=
48   AC_MSG_CHECKING([for dbm in $1])
49 else
50   nmh_libs="-l$2 "
51   AC_MSG_CHECKING([for dbm in $1 and $2])
52 fi
53
54 dnl We don't try to cache the result, because that exceeds
55 dnl my autoconf skills -- feel free to put it in :-> -- PMM
56
57 nmh_saved_libs="$LIBS"
58 LIBS="$nmh_libs $5 $LIBS"
59 AC_LINK_IFELSE(AC_LANG_PROGRAM([[
60 #define DB_DBM_HSEARCH 1
61 #include <$1>
62 ]],
63 [[dbm_open("",0,0);]]),[nmh_ndbm_found=yes],[nmh_ndbm_found=no])
64 LIBS="$nmh_saved_libs"
65
66 if test "$nmh_ndbm_found" = "yes"; then
67   AC_MSG_RESULT(yes)
68   nmh_ndbmheader="$1"
69   nmh_ndbm="$2"
70   $3
71 else
72   AC_MSG_RESULT(no)
73   $4
74   :
75 fi
76 ])dnl
77
78 dnl ----------------
79 dnl CHECK FOR d_type
80 dnl ----------------
81 dnl
82 dnl From Jim Meyering.
83 dnl
84 dnl Check whether struct dirent has a member named d_type.
85 dnl
86
87 # Copyright (C) 1997, 1999, 2000, 2001, 2002, 2003, 2004 Free Software
88 # Foundation, Inc.
89 #
90 # This file is free software; the Free Software Foundation
91 # gives unlimited permission to copy and/or distribute it,
92 # with or without modifications, as long as this notice is preserved.
93
94 AC_DEFUN([CHECK_TYPE_STRUCT_DIRENT_D_TYPE],
95   [AC_REQUIRE([AC_HEADER_DIRENT])dnl
96    AC_CACHE_CHECK([for d_type member in directory struct],
97                   jm_cv_struct_dirent_d_type,
98      [AC_TRY_LINK(dnl
99        [
100 #include <sys/types.h>
101 #ifdef HAVE_DIRENT_H
102 # include <dirent.h>
103 #else /* not HAVE_DIRENT_H */
104 # define dirent direct
105 # ifdef HAVE_SYS_NDIR_H
106 #  include <sys/ndir.h>
107 # endif /* HAVE_SYS_NDIR_H */
108 # ifdef HAVE_SYS_DIR_H
109 #  include <sys/dir.h>
110 # endif /* HAVE_SYS_DIR_H */
111 # ifdef HAVE_NDIR_H
112 #  include <ndir.h>
113 # endif /* HAVE_NDIR_H */
114 #endif /* HAVE_DIRENT_H */
115        ],
116        [struct dirent dp; dp.d_type = 0;],
117
118        jm_cv_struct_dirent_d_type=yes,
119        jm_cv_struct_dirent_d_type=no)
120      ]
121    )
122    if test $jm_cv_struct_dirent_d_type = yes; then
123      AC_DEFINE(HAVE_STRUCT_DIRENT_D_TYPE, 1,
124        [Define if there is a member named d_type in the struct describing
125         directory headers.])
126    fi
127   ]
128 )