#!/bin/sh
#
# PostgreSQL Build Script
#
BUILDRUN=true

if echo '\c' | grep -s c >/dev/null 2>&1
then
        ECHO_N="echo -n"
        ECHO_C=""
else
        ECHO_N="echo"
        ECHO_C='\c'
fi

$ECHO_N "Additional directories to search for .h files []: $ECHO_C"
read a
if [ "$a." = "." ]
then
        ADD_INC_DIRS=
else
        ADD_INC_DIRS=`echo "$a" | sed 's@  *@ @g; s@^\([^ ]\)@-I\1@; s@ \([^ ]\)@ -I\1@g'`
        INC_CFLAGS="$ADD_INC_DIRS"
        CPPFLAGS="$ADD_INC_DIRS" ; export CPPFLAGS
fi

$ECHO_N "Additional directories to search for library files []: $ECHO_C"
read a
if [ "$a." != "." ]
then
        ADD_LIB_DIRS=`echo "$a" | sed 's@  *@ @g; s@^\([^ ]\)@-L\1@; s@ \([^ ]\)@ -L\1@g'`
        LDFLAGS="$ADD_LIB_DIRS" ; export LDFLAGS
fi

IDIR=/usr/local/pgsql
$ECHO_N "Installation directory [/usr/local/pgsql]: $ECHO_C"
read a
if [ "$a." != "." ]
then
        IDIR=${a}
fi

USE_LOCALE=no
echo "Define USE_LOCALE to get Postgres work (sort, search)"
$ECHO_N "with national alphabet. [no]: $ECHO_C"
read a
if [ "$a." != "." ]
then
	USE_LOCALE=${a}
fi

export BUILDRUN USE_LOCALE

./configure --prefix=${IDIR}

