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