autotools revamp:
[freeradius.git] / src / modules / rlm_sql / drivers / rlm_sql_postgresql / configure.in
1 AC_INIT(sql_postgresql.c)
2 AC_REVISION($Revision$)
3 AC_DEFUN(modname,[rlm_sql_postgresql])
4
5 fail=
6 SMART_LIBS=
7 SMART_CLFAGS=
8 if test x$with_[]modname != xno; then
9
10         AC_PROG_CC
11
12         dnl extra argument: --with-rlm-sql-postgresql-lib-dir
13         rlm_sql_postgresql_lib_dir=
14         AC_ARG_WITH(rlm-sql-postgresql-lib-dir,
15         [  --with-rlm-sql-postgresql-lib-dir=DIR       Directory for PostgreSQL library files []],
16         [ case "$withval" in
17             no)
18                 AC_MSG_ERROR(Need rlm-sql-postgresql-lib-dir)
19                 ;;
20             yes)
21                 ;;
22             *)
23                 rlm_sql_postgresql_lib_dir="$withval"
24                 ;;
25           esac ]
26         )
27
28         dnl extra argument: --with-rlm-sql-postgresql-include-dir
29         rlm_sql_postgresql_include_dir=
30         AC_ARG_WITH(rlm-sql-postgresql-include-dir,
31         [  --with-rlm-sql-postgresql-include-dir=DIR   Directory for PostgreSQL include files []],
32         [ case "$withval" in
33             no)
34                 AC_MSG_ERROR(Need rlm-sql-postgresql-include-dir)
35                 ;;
36             yes)
37                 ;;
38             *)
39                 rlm_sql_postgresql_include_dir="$withval"
40                 ;;
41           esac ]
42         )
43
44         smart_try_dir="$rlm_sql_postgresql_include_dir /usr/include/postgresql /usr/local/pgsql/include /usr/include/pgsql"
45         FR_SMART_CHECK_INCLUDE(libpq-fe.h)
46         if test "x$ac_cv_header_libpqmfe_h" != "xyes"; then
47           fail="$fail libpq-fe.h"
48         fi
49
50         smart_try_dir="$rlm_sql_postgresql_lib_dir /usr/lib /usr/local/pgsql/lib"
51         FR_SMART_CHECK_LIB(pq, PQconnectdb)
52         if test "x$ac_cv_lib_pq_PQconnectdb" != "xyes"; then
53           fail="$fail libpq"
54         fi
55
56         targetname=modname
57 else
58         targetname=
59         echo \*\*\* module modname is disabled.
60 fi
61
62 if test x"$fail" != x""; then
63         if test x"${enable_strict_dependencies}" = x"yes"; then
64                 AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
65         else
66                 AC_MSG_WARN([silently not building ]modname[.])
67                 AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.])
68                 if test x"$headersuggestion" != x; then
69                         AC_MSG_WARN([$headersuggestion]) 
70                 fi
71                 if test x"$libsuggestion" != x; then
72                         AC_MSG_WARN([$libsuggestion]) 
73                 fi
74                 targetname=""
75         fi
76 fi
77
78 postgresql_ldflags=$SMART_LIBS
79 postgresql_cflags=$SMART_CFLAGS
80 AC_SUBST(postgresql_ldflags)
81 AC_SUBST(postgresql_cflags)
82 AC_SUBST(targetname)
83 AC_OUTPUT(Makefile)