#!/bin/sh
if [ "$GRASS_IN_GMAKEFILE" != "yes" ]
then
	echo "./doconfigure should be executed in Gmakefile." >&2
	exit 1
fi

if [ -n "$2" -a "$PGSQL" != "no" -a "$PGSQL" != "NO" ]
then
####### POSTGRESQL SUPPORTED #####################
	echo "*** PostgreSQL supported ***" >&2

	diff src/query_postgr_orig.c src/query_postgr.c > /dev/null
	if [ $? -ne 0 ]
	then
		cp src/query_postgr_orig.c src/query_postgr.c
	fi

	diff scripts/panel_query_pg.tcl scripts/panel_query.tcl > /dev/null
	if [ $? -ne 0 ]
	then
		cp scripts/panel_query_pg.tcl scripts/panel_query.tcl
	fi

##################################################
else
####### POSTGRESQL UNSUPPORTED ###################
	if [ -n "$PGSQL" -a "$PGSQL" != "no" -a "$PGSQL" != "NO" ]
	then
		echo "*** PostgreSQL library not found by global configure ***" >&2
	fi
	echo "*** PostgreSQL unsupported ***" >&2

	diff src/query_postgr_dummy.c src/query_postgr.c > /dev/null
	if [ $? -ne 0 ]
	then
		cp src/query_postgr_dummy.c src/query_postgr.c
	fi

	diff scripts/panel_query_orig.tcl scripts/panel_query.tcl > /dev/null
	if [ $? -ne 0 ]
	then
		cp scripts/panel_query_orig.tcl scripts/panel_query.tcl
	fi

##################################################
fi

