
--- postgis-1.3.2/README.postgis	2007-12-02 15:37:13.000000000 -0500
+++ postgis-1.3.2-new/README.postgis	2007-12-12 08:50:57.000000000 -0500
@@ -143,8 +143,8 @@
 
 So, as postgres run:
 
-  createlang plpgsql yourdatabase
-  psql -f lwpostgis.sql -d your_database
+  createlang-@FINKPGRAWVERSION@ plpgsql yourdatabase
+  psql-@FINKPGRAWVERSION@ -f lwpostgis.sql -d your_database
 
 Your database should now be spatially enabled.
 
@@ -166,7 +166,7 @@
 Soft upgrade consists of sourcing the lwpostgis_upgrade.sql
 script in your spatial database:
 
-  psql -f lwpostgis_upgrade.sql -d your_spatial_database
+  psql-@FINKPGRAWVERSION@ -f lwpostgis_upgrade.sql -d your_spatial_database
 
 If a soft upgrade is not possible the script will abort and 
 you will be warned about HARD UPGRADE being required,
@@ -187,7 +187,7 @@
 
 	# Create a "custom-format" dump of the database you want
 	# to upgrade (let's call it "olddb")
-	$ pg_dump -Fc olddb olddb.dump
+	$ pg_dump-@FINKPGRAWVERSION@ -Fc olddb olddb.dump
 
 	# Restore the dump while upgrading postgis into
 	# a new database. 
@@ -204,9 +204,9 @@
 	# drop the attrelid, varattnum and stats columns in the geometry_columns
 	# table, which are no-more needed. Keeping them won't hurt.
 	# !!! DROPPING THEM WHEN REALLY NEEDED WILL DO HARM !!!!
-	$ psql newdb -c "ALTER TABLE geometry_columns DROP attrelid"
-	$ psql newdb -c "ALTER TABLE geometry_columns DROP varattnum"
-	$ psql newdb -c "ALTER TABLE geometry_columns DROP stats"
+	$ psql-@FINKPGRAWVERSION@ newdb -c "ALTER TABLE geometry_columns DROP attrelid"
+	$ psql-@FINKPGRAWVERSION@ newdb -c "ALTER TABLE geometry_columns DROP varattnum"
+	$ psql-@FINKPGRAWVERSION@ newdb -c "ALTER TABLE geometry_columns DROP stats"
 
 	# The spatial_ref_sys table is restored from the dump, to 
         # ensure your custom additions are kept, but the distributed 
@@ -214,7 +214,7 @@
         # entries, drop the table and source the new one.
 	# If you did make additions we assume you know how to backup them before
 	# upgrading the table. Replace it with the new like this:
-	$ psql newdb
+	$ psql-@FINKPGRAWVERSION@ newdb
 	newdb=> DELETE FROM spatial_ref_sys;
 	DROP
 	newdb=> \i spatial_ref_sys.sql
--- postgis-1.3.2/extras/template_gis/createdb.postgis.1	2006-05-31 02:43:12.000000000 -0400
+++ postgis-1.3.2-new/extras/template_gis/createdb.postgis.1	2007-12-12 08:46:50.000000000 -0500
@@ -43,7 +43,7 @@
 .LP
 The environment variables for template_gis creation, removal and usage may be stored in files, as follows:
 .TP
-.B /etc/default/postgis
+.B @FINKPREFIX@/etc/default/postgis
 will designate default values for the whole system.
 .TP
 .B $HOME/.postgis/profile
--- postgis-1.3.2/extras/template_gis/mktemplate_gis.1	2006-05-31 02:43:12.000000000 -0400
+++ postgis-1.3.2-new/extras/template_gis/mktemplate_gis.1	2007-12-12 08:46:43.000000000 -0500
@@ -89,7 +89,7 @@
 .LP
 The environment variables for template_gis creation, removal and usage may be stored in files, as follows:
 .TP
-.B /etc/default/postgis
+.B @FINKPREFIX@/etc/default/postgis
 will designate default values for the whole system.
 .TP
 .B $HOME/.postgis/profile
--- postgis-1.3.2/extras/template_gis/postgis_env.sh.in	2006-05-31 02:43:12.000000000 -0400
+++ postgis-1.3.2-new/extras/template_gis/postgis_env.sh.in	2007-12-12 08:46:32.000000000 -0500
@@ -3,7 +3,7 @@
 # environment variables for postgis
 
 #read optional configuration files. last prevails
-for file in "/etc/default/postgis" "$HOME/.postgis/profile" ; do
+for file in "@FINKPREFIX@/etc/default/postgis" "$HOME/.postgis/profile" ; do
 	if [ -f "$file" ]; then
 		tmpval=`grep "^TEMPLATEDB=" $file | cut -d= -f2`
 		if [ -n "$tmpval" ]; then
@@ -25,12 +25,12 @@
 done
 
 #cluster information should be set separately
-if [ -x @prefix@/bin/pg_lsclusters ]; then
+if [ -x @prefix@/bin/pg_lsclusters-@FINKPGRAWVERSION@ ]; then
 #	PGCLUSTER=`pg_lsclusters | awk '{if ($3 == ENVIRON["PGPORT"]) {print $1"/"$2;}}'`
 #	export PGCLUSTER
 #
 	if [ -z $DBAUSER ]; then
-		DBAUSER=`pg_lsclusters | awk '{if ($3 == ENVIRON["PGPORT"]) {print $5;}}'`
+		DBAUSER=`pg_lsclusters-@FINKPGRAWVERSION@ | awk '{if ($3 == ENVIRON["PGPORT"]) {print $5;}}'`
 	fi
 fi
 
--- postgis-1.3.2/extras/template_gis/postgres_lib.sh.in	2006-05-31 02:43:12.000000000 -0400
+++ postgis-1.3.2-new/extras/template_gis/postgres_lib.sh.in	2007-12-12 08:51:30.000000000 -0500
@@ -39,9 +39,9 @@
 		echo "you may be not allowed to do so (maybe wrong password)."
 		exit 1
 	fi
-	ISDBAPGUSER=`psql -At -d template1 -c "select usename from pg_user where usesuper = true and usename = '$DBAUSER';" 2>&1`
+	ISDBAPGUSER=`psql-@FINKPGRAWVERSION@ -At -d template1 -c "select usename from pg_user where usesuper = true and usename = '$DBAUSER';" 2>&1`
 	if [ ! "$ISDBAPGUSER" = "$DBAUSER" ]; then
-		MAYPOSTGRES=`psql -l`
+		MAYPOSTGRES=`psql-@FINKPGRAWVERSION@ -l`
 		if [ -z "$MAYPOSTGRES" ]; then
 			echo "either postgresql $PGCLUSTER is not running,"
 			echo "or $DBAUSER doesn't have privileges on cluster $PGCLUSTER."
@@ -59,9 +59,9 @@
 function template_rm()
 {
 	TDB=$1
-	db_update=`psql -d template1 -c "UPDATE pg_database SET datistemplate = FALSE WHERE datname = '$TDB';" 2>&1`
+	db_update=`psql-@FINKPGRAWVERSION@ -d template1 -c "UPDATE pg_database SET datistemplate = FALSE WHERE datname = '$TDB';" 2>&1`
 	if [ "$db_update" = "UPDATE 1" ]; then
-		dropdb $TDB 2>&1 | cat > /dev/null
+		dropdb-@FINKPGRAWVERSION@ $TDB 2>&1 | cat > /dev/null
 	else
 		echo "$TDB could not be accessed. it may not exist"
 	fi
@@ -75,50 +75,50 @@
 	TDB=$1
 	GRUSER=$2
 	#of course it could be better to create as the $GRUSER where system user
-	db_create=`createdb $TDB 2>&1`
+	db_create=`createdb-@FINKPGRAWVERSION@ $TDB 2>&1`
 	if [ "$db_create" = "CREATE DATABASE" ]; then
-		GRID=`psql -d template1 -At -c "select usesysid from pg_user where usename='$GRUSER';"`
+		GRID=`psql-@FINKPGRAWVERSION@ -d template1 -At -c "select usesysid from pg_user where usename='$GRUSER';"`
 	    if [ -n "$GRID" ]; then
-			psql -d $TDB -c "UPDATE pg_database SET datdba = $GRID WHERE datname = '$TDB';" 2>&1 | cat > /dev/null
+			psql-@FINKPGRAWVERSION@ -d $TDB -c "UPDATE pg_database SET datdba = $GRID WHERE datname = '$TDB';" 2>&1 | cat > /dev/null
 	    fi
-		if [ -x @bindir@/createlang ]; then
-			@bindir@/createlang plpgsql $TDB 2>&1 | cat > /dev/null
+		if [ -x @bindir@/createlang-@FINKPGRAWVERSION@ ]; then
+			@bindir@/createlang-@FINKPGRAWVERSION@ plpgsql $TDB 2>&1 | cat > /dev/null
 		fi
 		for script in $SCRIPTS ; do
-			psql -d $TDB -f $script 2>&1 | cat > /dev/null
+			psql-@FINKPGRAWVERSION@ -d $TDB -f $script 2>&1 | cat > /dev/null
 		done
 		#pseudo tables for postgresql 7.2 and 7.4. feel free to add more, for other postgresql versions
 		PSEUDO_TABLES="'pg_xactlock', 'sql_features', 'sql_implementation_info', 'sql_languages', 
 					   'sql_packages', 'sql_sizing', 'sql_sizing_profiles'"
-		TABLES=`psql -d $TDB -At -c "select tablename from pg_tables where tablename not in ($PSEUDO_TABLES);"`
+		TABLES=`psql-@FINKPGRAWVERSION@ -d $TDB -At -c "select tablename from pg_tables where tablename not in ($PSEUDO_TABLES);"`
 	    if [ -n "$GRID" ]; then
 			for table in $TABLES ; do
-		        psql -d $TDB -c "alter table $table owner to $GRUSER;" 2>&1 | cat > /dev/null
+		        psql-@FINKPGRAWVERSION@ -d $TDB -c "alter table $table owner to $GRUSER;" 2>&1 | cat > /dev/null
 			done
-			psql -d $TDB -c "update pg_class set relowner=$GRID where relkind = 'S';" 2>&1 | cat > /dev/null
+			psql-@FINKPGRAWVERSION@ -d $TDB -c "update pg_class set relowner=$GRID where relkind = 'S';" 2>&1 | cat > /dev/null
 	    else #maybe public, or group
 			for grtable in $GRTABLES ; do
-		        psql -d $TDB -c "grant all privileges on table $grtable to $GRUSER;" 2>&1 | cat > /dev/null
+		        psql-@FINKPGRAWVERSION@ -d $TDB -c "grant all privileges on table $grtable to $GRUSER;" 2>&1 | cat > /dev/null
 			done
 	    fi
 		for grschema in $GRSCHEMAS ; do
-	        psql -d $TDB -c "alter schema $grschema owner to $GRUSER;" 2>&1 | cat > /dev/null
-	        psql -d $TDB -c "grant all privileges on schema $grschema to $GRUSER;" 2>&1 | cat > /dev/null
-			STABLES=`psql -d $TDB -At -c "select tablename from pg_tables where schemaname = '$grschema';"`
+	        psql-@FINKPGRAWVERSION@ -d $TDB -c "alter schema $grschema owner to $GRUSER;" 2>&1 | cat > /dev/null
+	        psql-@FINKPGRAWVERSION@ -d $TDB -c "grant all privileges on schema $grschema to $GRUSER;" 2>&1 | cat > /dev/null
+			STABLES=`psql-@FINKPGRAWVERSION@ -d $TDB -At -c "select tablename from pg_tables where schemaname = '$grschema';"`
 		    if [ -n "$GRID" ]; then
 				for table in $STABLES ; do
-			        psql -d $TDB -c "alter table $grschema.$table owner to $GRUSER;" 2>&1 | cat > /dev/null
+			        psql-@FINKPGRAWVERSION@ -d $TDB -c "alter table $grschema.$table owner to $GRUSER;" 2>&1 | cat > /dev/null
 				done
 	  		else #maybe public, or group
 				for grtable in $GRTABLES ; do #contain specific schema
-		      		psql -d $TDB -c "grant all privileges on table $grtable to $GRUSER;" 2>&1 | cat > /dev/null
+		      		psql-@FINKPGRAWVERSION@ -d $TDB -c "grant all privileges on table $grtable to $GRUSER;" 2>&1 | cat > /dev/null
 				done
 	  		fi
 		done
-		psql -d $TDB -c "VACUUM FULL;" 2>&1 | cat > /dev/null
-		psql -d $TDB -c "VACUUM FREEZE;" 2>&1 | cat > /dev/null
-		psql -d $TDB -c "UPDATE pg_database SET datistemplate = TRUE WHERE datname = '$TDB';" 2>&1 | cat > /dev/null
-		psql -d $TDB -c "UPDATE pg_database SET datallowconn = FALSE WHERE datname = '$TDB';" 2>&1 | cat > /dev/null
+		psql-@FINKPGRAWVERSION@ -d $TDB -c "VACUUM FULL;" 2>&1 | cat > /dev/null
+		psql-@FINKPGRAWVERSION@ -d $TDB -c "VACUUM FREEZE;" 2>&1 | cat > /dev/null
+		psql-@FINKPGRAWVERSION@ -d $TDB -c "UPDATE pg_database SET datistemplate = TRUE WHERE datname = '$TDB';" 2>&1 | cat > /dev/null
+		psql-@FINKPGRAWVERSION@ -d $TDB -c "UPDATE pg_database SET datallowconn = FALSE WHERE datname = '$TDB';" 2>&1 | cat > /dev/null
 	else
 		echo "$db_create"
 	fi
--- postgis-1.3.2/extras/template_gis/profile	2006-06-09 02:03:59.000000000 -0400
+++ postgis-1.3.2-new/extras/template_gis/profile	2007-12-12 08:43:29.000000000 -0500
@@ -1,6 +1,6 @@
 
 #those are the default variables for postgresql-postgis.
-#this file will be scanned from /etc/default/postgis,
+#this file will be scanned from @FINKPREFIX@/etc/default/postgis,
 #and then from $HOME/postgis/profile
 
 #values should NOT be in quotes
--- postgis-1.3.2/extras/template_gis/rmtemplate_gis.1	2006-05-31 02:43:12.000000000 -0400
+++ postgis-1.3.2-new/extras/template_gis/rmtemplate_gis.1	2007-12-12 08:43:15.000000000 -0500
@@ -45,7 +45,7 @@
 .LP
 The environment variables for template_gis creation, removal and usage may be stored in files, as follows:
 .TP
-.B /etc/default/postgis
+.B @FINKPREFIX@/etc/default/postgis
 will designate default values for the whole system.
 .TP
 .B $HOME/.postgis/profile
--- postgis-1.3.2/lwgeom/lwgeom_gml.c	2007-10-10 17:27:51.000000000 -0400
+++ postgis-1.3.2-new/lwgeom/lwgeom_gml.c	2007-12-12 09:15:30.000000000 -0500
@@ -51,10 +51,10 @@
 static char *getSRSbySRID(int SRID);
 
 /* Add dot, sign, exponent sign, 'e', exponent digits */
-#define SHOW_DIGS (precision + 8)
+#define SHOW_DIGS (gml_precision + 8)
 
 /* Globals */
-int precision;
+int gml_precision;
 
 
 /**
@@ -85,8 +85,8 @@
 	geom = (PG_LWGEOM *)PG_DETOAST_DATUM(PG_GETARG_DATUM(1));
 
 	/* Get precision  */
-	precision = PG_GETARG_INT32(2);
-	if ( precision < 1 || precision > 15 )
+	gml_precision = PG_GETARG_INT32(2);
+	if ( gml_precision < 1 || gml_precision > 15 )
 	{
 		elog(ERROR, "Precision out of range 1..15");
 		PG_RETURN_NULL();
@@ -440,8 +440,8 @@
 			getPoint2d_p(pa, i, &pt);
 			if ( i ) ptr += sprintf(ptr, " ");
 			ptr += sprintf(ptr, "%.*g,%.*g",
-				precision, pt.x,
-				precision, pt.y);
+				gml_precision, pt.x,
+				gml_precision, pt.y);
 		}
 	}
 	else 
@@ -452,9 +452,9 @@
 			getPoint4d_p(pa, i, &pt);
 			if ( i ) ptr += sprintf(ptr, " ");
 			ptr += sprintf(ptr, "%.*g,%.*g,%.*g",
-				precision, pt.x,
-				precision, pt.y,
-				precision, pt.z);
+				gml_precision, pt.x,
+				gml_precision, pt.y,
+				gml_precision, pt.z);
 		}
 	}
 
@@ -798,8 +798,8 @@
 			getPoint2d_p(pa, i, &pt);
 			if ( i ) ptr += sprintf(ptr, " ");
 			ptr += sprintf(ptr, "%.*g %.*g",
-				precision, pt.x,
-				precision, pt.y);
+				gml_precision, pt.x,
+				gml_precision, pt.y);
 		}
 	}
 	else 
@@ -810,9 +810,9 @@
 			getPoint4d_p(pa, i, &pt);
 			if ( i ) ptr += sprintf(ptr, " ");
 			ptr += sprintf(ptr, "%.*g %.*g,%.*g",
-				precision, pt.x,
-				precision, pt.y,
-				precision, pt.z);
+				gml_precision, pt.x,
+				gml_precision, pt.y,
+				gml_precision, pt.z);
 		}
 	}
 
--- postgis-1.3.2/lwgeom/lwgeom_kml.c	2007-10-22 20:19:54.000000000 -0400
+++ postgis-1.3.2-new/lwgeom/lwgeom_kml.c	2007-12-12 09:14:49.000000000 -0500
@@ -40,10 +40,10 @@
 
 #define DEF_PRECISION 15
 /* Add dot, sign, exponent sign, 'e', exponent digits */
-#define SHOW_DIGS (precision + 8)
+#define SHOW_DIGS (kml_precision + 8)
 
 /* Globals */
-int precision;
+int kml_precision;
 
 
 /**
@@ -60,7 +60,7 @@
 	char *srs;
 	int SRID;
 
-	precision = DEF_PRECISION;
+	kml_precision = DEF_PRECISION;
 
 	if ( PG_ARGISNULL(0) ) PG_RETURN_NULL();
 
@@ -68,9 +68,9 @@
 
 	/* Get precision (if provided)  */
 	if ( PG_NARGS() > 1 && ! PG_ARGISNULL(1) )
-			precision = PG_GETARG_INT32(1);
+			kml_precision = PG_GETARG_INT32(1);
 	
-	if ( precision < 1 || precision > 15 )
+	if ( kml_precision < 1 || kml_precision > 15 )
 	{
 		elog(ERROR, "Precision out of range 1..15");
 		PG_RETURN_NULL();
@@ -411,8 +411,8 @@
 			getPoint2d_p(pa, i, &pt);
 			if ( i ) ptr += sprintf(ptr, " ");
 			ptr += sprintf(ptr, "%.*g,%.*g,0",
-				precision, pt.x,
-				precision, pt.y);
+				kml_precision, pt.x,
+				kml_precision, pt.y);
 		}
 	}
 	else 
@@ -423,9 +423,9 @@
 			getPoint4d_p(pa, i, &pt);
 			if ( i ) ptr += sprintf(ptr, " ");
 			ptr += sprintf(ptr, "%.*g,%.*g,%.*g",
-				precision, pt.x,
-				precision, pt.y,
-				precision, pt.z);
+				kml_precision, pt.x,
+				kml_precision, pt.y,
+				kml_precision, pt.z);
 		}
 	}
 
--- postgis-1.3.2/utils/postgis_restore.pl	2006-11-20 07:59:55.000000000 -0500
+++ postgis-1.3.2-new/utils/postgis_restore.pl	2007-12-12 08:48:53.000000000 -0500
@@ -375,7 +375,7 @@
 #
 print "Scanning $dump list\n"; 
 open( OUTPUT, ">$dumplist") || die "Can't write to ".$dump.".list\n";
-open( INPUT, "pg_restore -l $dump |") || die "Couldn't run pg_restore -l $dump\n";
+open( INPUT, "pg_restore-@FINKPGRAWVERSION@ -l $dump |") || die "Couldn't run pg_restore-@FINKPGRAWVERSION@ -l $dump\n";
 while( my $line = <INPUT> )
 {
 	next if $line =~ /^;/;
@@ -613,7 +613,7 @@
 close(OUTPUT);
 
 print "Producing ascii dump $dumpascii\n"; 
-open( INPUT, "pg_restore -L $dumplist $dump |") || die "Can't run pg_restore\n";
+open( INPUT, "pg_restore-@FINKPGRAWVERSION@ -L $dumplist $dump |") || die "Can't run pg_restore\n";
 open( OUTPUT, ">$dumpascii") || die "Can't write to $dumpascii\n";
 while( my $line = <INPUT> )
 {
@@ -673,7 +673,7 @@
 	#  when implemented operators skip must be disabled
 	#  in the first scan of ToC
 }
-close(INPUT) || die "pg_restore call failed\n";
+close(INPUT) || die "pg_restore-@FINKPGRAWVERSION@ call failed\n";
 close(OUTPUT);
 
 #exit(1);
@@ -682,15 +682,15 @@
 # Create the new db and install plpgsql language
 #
 print "Creating db ($dbname)\n";
-`createdb $createdb_opt $dbname`;
+`createdb-@FINKPGRAWVERSION@ $createdb_opt $dbname`;
 die "Database creation failed\n" if ($?);
 print "Adding plpgsql\n";
-`createlang plpgsql $dbname`;
+`createlang-@FINKPGRAWVERSION@ plpgsql $dbname`;
 
 #
 # Open a pipe to the SQL monitor
 #
-open( PSQL, "| psql -a $dbname") || die "Can't run psql\n";
+open( PSQL, "| psql-@FINKPGRAWVERSION@ -a $dbname") || die "Can't run psql\n";
 
 #
 # Source new postgis.sql
@@ -717,4 +717,4 @@
 open(INPUT, "<$dumpascii") || die "Can't read $postgissql\n";
 while(<INPUT>) { print PSQL; }
 close(INPUT);
-close(PSQL) || die "psql run failed\n"
+close(PSQL) || die "psql-@FINKPGRAWVERSION@ run failed\n"
