1aa534052c5c2af6b1d284ab8ab65fe2bd75d7f1
[freeradius.git] / src / modules / rlm_dbm / configure.in
1 AC_INIT(rlm_dbm.c)
2 AC_REVISION($Revision$)
3 AC_DEFUN(modname,[rlm_dbm])
4
5 if test x$with_[]modname != xno; then
6
7         AC_PROG_CC
8         AC_PROG_CPP
9
10         dnl extra argument: --with-rlm-dbm-lib-dir
11         rlm_dbm_lib_dir=
12         AC_ARG_WITH(rlm-dbm-lib-dir,
13         [  --with-rlm-dbm-lib-dir=DIR       Directory for DBM library files []],
14         [ case "$withval" in
15             no)
16                 AC_MSG_ERROR(Need rlm-dbm-lib-dir)
17                 ;;
18             yes)
19                 ;;
20             *)
21                 rlm_dbm_lib_dir="$withval"
22                 ;;
23           esac ]
24         )
25
26         dnl extra argument: --with-rlm-dbm-include-dir
27         rlm_dbm_inc_dir=
28         AC_ARG_WITH(rlm-dbm-include-dir,
29         [  --with-rlm-dbm-include-dir=DIR   Directory for DBM include files []],
30         [ case "$withval" in
31             no)
32                 AC_MSG_ERROR(Need rlm-dbm-include-dir)
33                 ;;
34             yes)
35                 ;;
36             *)
37                 rlm_dbm_include_dir="$withval"
38                 ;;
39           esac ]
40         )
41
42         smart_try_dir=$rlm_dbm_include_dir
43         AC_SMART_CHECK_INCLUDE(ndbm.h)
44         if test "x$ac_cv_header_ndbm_h" = "xyes"; then
45           SMART_CFLAGS="${SMART_CFLAGS} -DHAVE_NDBM_H"
46         else
47                 AC_SMART_CHECK_INCLUDE(gdbm/ndbm.h)
48                 if test "x$ac_cv_header_gdbm_ndbm_h" = "xyes"; then
49                         SMART_CFLAGS="${SMART_CFLAGS} -DHAVE_GDBM_NDBM_H"
50                 else
51                         ac_cv_header_gdbm_ndbm_h="bad autoconf assumption"
52                         AC_SMART_CHECK_INCLUDE(gdbm-ndbm.h)
53                         if test "x$ac_cv_header_gdbmmndbm_h" = "xyes"; then
54                                 SMART_CFLAGS="${SMART_CFLAGS} -DHAVE_GDBMNDBM_H"
55                         else
56                                 fail="$fail (ndbm.h or gdbm/ndbm.h or gdbm-ndbm.h)"
57                         fi
58                 fi
59         fi
60         AC_MSG_CHECKING([for dbm in default lib])
61         AC_TRY_LINK([extern void* dbm_open();],dbm_open(),[ac_cv_lib_default_dbm_open=yes
62                 AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
63         if test "x$ac_cv_lib_default_dbm_open" != "xyes"; then
64                 smart_try_dir=$rlm_dbm_lib_dir
65                 AC_SMART_CHECK_LIB(ndbm, dbm_open)
66                 if test "x$ac_cv_lib_ndbm_dbm_open" != "xyes"; then
67                         dnl GNU DBM < 1.8.1
68                         AC_SMART_CHECK_LIB(gdbm, dbm_open)
69                         if test "x$ac_cv_lib_gdbm_dbm_open" != "xyes"; then
70                                 dnl GNU DBM >= 1.8.1
71                                 AC_SMART_CHECK_LIB(gdbm_compat, dbm_open)
72                                 if test "x$ac_cv_lib_gdbm_compat_dbm_open" != "xyes"; then
73                                         fail="$fail (libndbm or libgdbm or libgdbm_compat)"
74                                 fi
75                         fi
76                 fi
77         fi
78
79         targetname=modname
80 else
81         targetname=
82         echo \*\*\* module modname is disabled.
83 fi
84
85 if test x"$fail" != x""; then
86         AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.]); 
87         if test x"${enable_strict_dependencies}" = x"yes"; then
88                 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
89         else
90                 AC_MSG_WARN([silently not building ]modname[.])
91                 targetname=""
92         fi
93 fi
94
95 if test "x$targetname" != "x"; then
96         dbm_utils="rlm_dbm_parser rlm_dbm_cat"
97         dbm_install="rlm_dbm_install"
98 fi
99
100 dbm_ldflags=$SMART_LIBS
101 dbm_cflags=$SMART_CFLAGS
102 AC_SUBST(dbm_ldflags)
103 AC_SUBST(dbm_cflags)
104 AC_SUBST(targetname)
105 AC_SUBST(dbm_utils)
106 AC_SUBST(dbm_install)
107 AC_OUTPUT(Makefile)