+
+if test x$support_batch_insert = xyes; then
+
+$as_echo "#define USE_BATCH_FILE_INSERT 1" >>confdefs.h
+
+fi
+
+
+uncomment_dbi="#"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PostgreSQL support" >&5
+$as_echo_n "checking for PostgreSQL support... " >&6; }
+
+# Check whether --with-postgresql was given.
+if test "${with_postgresql+set}" = set; then :
+ withval=$with_postgresql;
+ if test "$withval" != "no"; then
+ if test "$withval" = "yes"; then
+ PG_CONFIG=`which pg_config 2>/dev/null`
+ if test -n "$PG_CONFIG"; then
+ POSTGRESQL_INCDIR=`"$PG_CONFIG" --includedir`
+ POSTGRESQL_LIBDIR=`"$PG_CONFIG" --libdir`
+ POSTGRESQL_BINDIR=`"$PG_CONFIG" --bindir`
+ elif test -f /usr/local/include/libpq-fe.h; then
+ POSTGRESQL_INCDIR=/usr/local/include
+ if test -d /usr/local/lib64; then
+ POSTGRESQL_LIBDIR=/usr/local/lib64
+ else
+ POSTGRESQL_LIBDIR=/usr/local/lib
+ fi
+ POSTGRESQL_BINDIR=/usr/local/bin
+ elif test -f /usr/include/libpq-fe.h; then
+ POSTGRESQL_INCDIR=/usr/include
+ if test -d /usr/lib64; then
+ POSTGRESQL_LIBDIR=/usr/lib64
+ else
+ POSTGRESQL_LIBDIR=/usr/lib
+ fi
+ POSTGRESQL_BINDIR=/usr/bin
+ elif test -f /usr/include/pgsql/libpq-fe.h; then
+ POSTGRESQL_INCDIR=/usr/include/pgsql
+ if test -d /usr/lib64/pgsql; then
+ POSTGRESQL_LIBDIR=/usr/lib64/pgsql
+ else
+ POSTGRESQL_LIBDIR=/usr/lib/pgsql
+ fi
+ POSTGRESQL_BINDIR=/usr/bin
+ elif test -f /usr/include/postgresql/libpq-fe.h; then
+ POSTGRESQL_INCDIR=/usr/include/postgresql
+ if test -d /usr/lib64/postgresql; then
+ POSTGRESQL_LIBDIR=/usr/lib64/postgresql
+ else
+ POSTGRESQL_LIBDIR=/usr/lib/postgresql
+ fi
+ POSTGRESQL_BINDIR=/usr/bin
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ as_fn_error $? "Unable to find libpq-fe.h in standard locations" "$LINENO" 5
+ fi
+ elif test -f $withval/include/libpq-fe.h; then
+ POSTGRESQL_INCDIR=$withval/include
+ POSTGRESQL_LIBDIR=$withval/lib
+ POSTGRESQL_BINDIR=$withval/bin
+ elif test -f $withval/include/postgresql/libpq-fe.h; then
+ POSTGRESQL_INCDIR=$withval/include/postgresql
+ if test -d $withval/lib64; then
+ POSTGRESQL_LIBDIR=$withval/lib64
+ else
+ POSTGRESQL_LIBDIR=$withval/lib
+ fi
+ POSTGRESQL_BINDIR=$withval/bin
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ as_fn_error $? "Invalid PostgreSQL directory $withval - unable to find libpq-fe.h under $withval" "$LINENO" 5
+ fi
+
+$as_echo "#define HAVE_POSTGRESQL 1" >>confdefs.h
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+ POSTGRESQL_INCLUDE=-I$POSTGRESQL_INCDIR
+ if test x$use_libtool != xno; then
+ POSTGRESQL_LIBS="-R $POSTGRESQL_LIBDIR -L$POSTGRESQL_LIBDIR -lpq"
+ else
+ POSTGRESQL_LIBS="-L$POSTGRESQL_LIBDIR -lpq"
+ fi
+ ac_fn_c_check_func "$LINENO" "crypt" "ac_cv_func_crypt"
+if test "x$ac_cv_func_crypt" = xyes; then :
+
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for crypt in -lcrypt" >&5
+$as_echo_n "checking for crypt in -lcrypt... " >&6; }
+if ${ac_cv_lib_crypt_crypt+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcrypt $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char crypt ();
+int
+main ()
+{
+return crypt ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_crypt_crypt=yes
+else
+ ac_cv_lib_crypt_crypt=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_crypt_crypt" >&5
+$as_echo "$ac_cv_lib_crypt_crypt" >&6; }
+if test "x$ac_cv_lib_crypt_crypt" = xyes; then :
+ POSTGRESQL_LIBS="$POSTGRESQL_LIBS -lcrypt"
+fi
+
+fi
+
+ POSTGRESQL_LIB=$POSTGRESQL_LIBDIR/libpq.a
+ DB_LIBS="${DB_LIBS} ${POSTGRESQL_LIBS}"
+
+ if test -z "${db_backends}"; then
+ db_backends="PostgreSQL"
+ else
+ db_backends="${db_backends} PostgreSQL"
+ fi
+ if test -z "${DB_BACKENDS}"; then
+ DB_BACKENDS="postgresql"
+ else
+ DB_BACKENDS="${DB_BACKENDS} postgresql"
+ fi
+
+ if test "x$support_batch_insert" = "xyes"; then
+ saved_LDFLAGS="${LDFLAGS}"
+ LDFLAGS="${saved_LDFLAGS} -L$POSTGRESQL_LIBDIR"
+ saved_LIBS="${LIBS}"
+ if test "x$ac_cv_lib_crypt_crypt" = "xyes" ; then
+ LIBS="${saved_LIBS} -lcrypt"
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQisthreadsafe in -lpq" >&5
+$as_echo_n "checking for PQisthreadsafe in -lpq... " >&6; }
+if ${ac_cv_lib_pq_PQisthreadsafe+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpq $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char PQisthreadsafe ();
+int
+main ()
+{
+return PQisthreadsafe ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_pq_PQisthreadsafe=yes
+else
+ ac_cv_lib_pq_PQisthreadsafe=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQisthreadsafe" >&5
+$as_echo "$ac_cv_lib_pq_PQisthreadsafe" >&6; }
+if test "x$ac_cv_lib_pq_PQisthreadsafe" = xyes; then :
+
+$as_echo "#define HAVE_PQISTHREADSAFE 1" >>confdefs.h