summaryrefslogtreecommitdiffstats
path: root/src/modules/rlm_sql/drivers/rlm_sql_postgresql/configure.ac
blob: 01c3c85194c4af56651d60bbc55619979b63173b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
AC_PREREQ([2.68])
AC_INIT(rlm_sql_postgresql.c)
AC_REVISION($Revision$)
FR_INIT_MODULE([rlm_sql_postgresql])

fail=
SMART_LIBS=
SMART_CLFAGS=

if test x$with_[]modname != xno; then

	AC_PROG_CC

	dnl extra argument: --with-rlm-sql-postgresql-lib-dir
	rlm_sql_postgresql_lib_dir=
	AC_ARG_WITH(rlm-sql-postgresql-lib-dir,
	[  --with-rlm-sql-postgresql-lib-dir=DIR       Directory for PostgreSQL library files []],
	[ case "$withval" in
	    no)
		AC_MSG_ERROR(Need rlm-sql-postgresql-lib-dir)
		;;
	    yes)
		;;
	    *)
		rlm_sql_postgresql_lib_dir="$withval"
		;;
	  esac ]
	)

	dnl extra argument: --with-rlm-sql-postgresql-include-dir
	rlm_sql_postgresql_include_dir=
	AC_ARG_WITH(rlm-sql-postgresql-include-dir,
	[  --with-rlm-sql-postgresql-include-dir=DIR   Directory for PostgreSQL include files []],
	[ case "$withval" in
	    no)
		AC_MSG_ERROR(Need rlm-sql-postgresql-include-dir)
		;;
	    yes)
		;;
	    *)
		rlm_sql_postgresql_include_dir="$withval"
		;;
	  esac ]
	)

	smart_try_dir="$rlm_sql_postgresql_include_dir /usr/include/postgresql /usr/local/pgsql/include /usr/include/pgsql"
	FR_SMART_CHECK_INCLUDE(libpq-fe.h)
	if test "x$ac_cv_header_libpqmfe_h" != "xyes"; then
		fail="$fail libpq-fe.h"
	else
		CPPFLAGS="$SMART_CPPFLAGS"
		AC_MSG_CHECKING([for PGRES_SINGLE_TUPLE])
		AC_COMPILE_IFELSE(
		  [AC_LANG_PROGRAM([#include <libpq-fe.h>], [[
		    if (PGRES_SINGLE_TUPLE) return 0;
		    return 1;
		  ]])],
		  [
		    AC_DEFINE([HAVE_PGRES_SINGLE_TUPLE], [1], [Whether the PGRES_SINGLE_TUPLE constant is defined])
		    AC_MSG_RESULT(yes)
		  ],
		  [
		    AC_MSG_RESULT(no)
		  ])

		AC_MSG_CHECKING([for PGRES_COPY_BOTH])
		AC_COMPILE_IFELSE(
		  [AC_LANG_PROGRAM([#include <libpq-fe.h>], [[
		    if (PGRES_COPY_BOTH) return 0;
		    return 1;
		  ]])],
		  [
		    AC_DEFINE([HAVE_PGRES_COPY_BOTH], [1], [Whether the PGRES_COPY_BOTH constant is defined])
		    AC_MSG_RESULT(yes)
		  ],
		  [
		    AC_MSG_RESULT(no)
		  ])

		AC_MSG_CHECKING([for PGRES_PIPELINE_SYNC])
		AC_COMPILE_IFELSE(
		  [AC_LANG_PROGRAM([#include <libpq-fe.h>], [[
		    if (PGRES_PIPELINE_SYNC) return 0;
		    return 1;
		  ]])],
		  [
		    AC_DEFINE([HAVE_PGRES_PIPELINE_SYNC], [1], [Whether the PGRES_PIPELINE_SYNC constant is defined])
		    AC_MSG_RESULT(yes)
		  ],
		  [
		    AC_MSG_RESULT(no)
		  ])
	fi

	smart_try_dir="$rlm_sql_postgresql_lib_dir /usr/lib /usr/local/pgsql/lib"
	FR_SMART_CHECK_LIB(pq, PQconnectdb)
	if test "x$ac_cv_lib_pq_PQconnectdb" != "xyes"; then
		fail="$fail libpq"
	fi
	AC_CHECK_FUNCS(\
		PQinitOpenSSL \
		PQinitSSL \
	)
	targetname=modname
else
	targetname=
	echo \*\*\* module modname is disabled.
fi

if test x"$fail" != x""; then
	if test x"${enable_strict_dependencies}" = x"yes"; then
		AC_MSG_ERROR([set --without-]modname[ to disable it explicitly.])
	else
		AC_MSG_WARN([silently not building ]modname[.])
		AC_MSG_WARN([FAILURE: ]modname[ requires: $fail.])
		if test x"$headersuggestion" != x; then
			AC_MSG_WARN([$headersuggestion])
		fi
		if test x"$libsuggestion" != x; then
			AC_MSG_WARN([$libsuggestion])
		fi
		targetname=""
	fi
fi

mod_ldflags="$SMART_LIBS"
mod_cflags="$SMART_CPPFLAGS"
AC_SUBST(mod_ldflags)
AC_SUBST(mod_cflags)
AC_SUBST(targetname)
AC_CONFIG_HEADER(config.h)
AC_OUTPUT(all.mk)