[postgis-commits] svn - r3571 - in spike: . wktraster wktraster/doc wktraster/macros wktraster/rt_core wktraster/rt_pg wktraster/rt_pg/test

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Tue Jan 27 08:26:57 PST 2009


Author: strk
Date: 2009-01-27 08:26:57 -0800 (Tue, 27 Jan 2009)
New Revision: 3571

Added:
   spike/wktraster/
   spike/wktraster/.vimrc
   spike/wktraster/COPYING
   spike/wktraster/CREDITS
   spike/wktraster/Makefile
   spike/wktraster/NEWS
   spike/wktraster/README
   spike/wktraster/README.debugging
   spike/wktraster/Version.config
   spike/wktraster/autogen.sh
   spike/wktraster/config.guess
   spike/wktraster/config.sub
   spike/wktraster/configure.ac
   spike/wktraster/doc/
   spike/wktraster/doc/RASTER_WKB
   spike/wktraster/install-sh
   spike/wktraster/macros/
   spike/wktraster/macros/ac_proj4_version.m4
   spike/wktraster/rt_core/
   spike/wktraster/rt_core/Makefile
   spike/wktraster/rt_core/Makefile.in
   spike/wktraster/rt_core/rt_api.c
   spike/wktraster/rt_core/rt_api.h
   spike/wktraster/rt_core/testapi.c
   spike/wktraster/rt_pg/
   spike/wktraster/rt_pg/Makefile
   spike/wktraster/rt_pg/Makefile.in
   spike/wktraster/rt_pg/rt_pg.c
   spike/wktraster/rt_pg/rt_pg.h
   spike/wktraster/rt_pg/rtpostgis.sql.in.c
   spike/wktraster/rt_pg/test/
   spike/wktraster/rt_pg/test/io.sql
Log:
Initial import of wktraster code

Added: spike/wktraster/.vimrc
===================================================================
--- spike/wktraster/.vimrc	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/.vimrc	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,3 @@
+set tabstop=4
+set shiftwidth=4
+set expandtab

Added: spike/wktraster/COPYING
===================================================================
--- spike/wktraster/COPYING	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/COPYING	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,341 @@
+
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.

Added: spike/wktraster/CREDITS
===================================================================
--- spike/wktraster/CREDITS	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/CREDITS	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,6 @@
+- The BAM project, University Laval, sponsored for project management
+  and kick-start.
+- Refractions Research Inc. provided svn repository 
+- Pierre Racine designed the functionality
+- Sandro Santilli wrote the in-memory api and build scripts
+

Added: spike/wktraster/Makefile
===================================================================
--- spike/wktraster/Makefile	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/Makefile	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,21 @@
+all: corelib pglib rtpostgis.sql
+
+corelib:
+	$(MAKE) -C rt_core
+
+rtpostgis.sql:
+	$(MAKE) -C rt_pg rtpostgis.sql
+
+pglib:
+	$(MAKE) -C rt_pg
+
+install: all
+	$(MAKE) -C rt_pg install
+
+clean:
+	$(MAKE) -C rt_core clean
+	$(MAKE) -C rt_pg clean
+
+check:
+	$(MAKE) -C rt_core check
+

Added: spike/wktraster/NEWS
===================================================================
--- spike/wktraster/NEWS	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/NEWS	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,5 @@
+
+Mon Jan 26 18:58:35 CET 2009
+
+First in-memory raster management api implemented,
+initial work on postgresql interface.

Added: spike/wktraster/README
===================================================================
--- spike/wktraster/README	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/README	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,19 @@
+PostGIS WKT Raster - Seamless operations between vector and raster layers
+-------------------------------------------------------------------------
+http://www.postgis.org/support/wiki/index.php?WKTRasterHomePage
+
+
+WKT Raster's goal is to implement the RASTER type as much as possible
+like the GEOMETRY type is implemented in PostGIS and to offer a single
+set of overlay SQL functions (like ST_Intersects) operating seamlessly
+on vector and raster coverages.
+
+
+This first draft only contains the primitives to deal with
+rasters in memory. You can see rt_core/testapi.c for example
+usage.
+
+To build and run the testapi (a test):
+
+    ./configure --with-postgis-sources=/usr/src/postgis-xxx
+    make && make check

Added: spike/wktraster/README.debugging
===================================================================
--- spike/wktraster/README.debugging	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/README.debugging	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,4 @@
+export PGHOST=$PWD/tmp
+
+/usr/lib/postgresql/8.3/bin/postgres --single  -k $PGHOST < test.sql
+psql 

Added: spike/wktraster/Version.config
===================================================================
--- spike/wktraster/Version.config	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/Version.config	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,8 @@
+# Version numbering central repository, to be included from various
+# places during the build process
+
+# See HOWTO_RELEASE file in SVN for definitions of those three.
+
+RT_MAJOR_VERSION=0
+RT_MINOR_VERSION=0
+RT_MICRO_VERSION=0

Added: spike/wktraster/autogen.sh
===================================================================
--- spike/wktraster/autogen.sh	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/autogen.sh	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,4 @@
+#!/bin/sh
+autoheader
+aclocal -I macros
+autoconf


Property changes on: spike/wktraster/autogen.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: spike/wktraster/config.guess
===================================================================
--- spike/wktraster/config.guess	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/config.guess	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,1459 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+timestamp='2004-03-12'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Per Bothner <per at bothner.com>.
+# Please send patches to <config-patches at gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+	for c in cc gcc c89 c99 ; do
+	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+	     CC_FOR_BUILD="$c"; break ;
+	  fi ;
+	done ;
+	if test x"$CC_FOR_BUILD" = x ; then
+	  CC_FOR_BUILD=no_compiler_found ;
+	fi
+	;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi at noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+	PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# NetBSD (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	#
+	# Note: NetBSD doesn't particularly care about the vendor
+	# portion of the name.  We always set it to "unknown".
+	sysctl="sysctl -n hw.machine_arch"
+	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+	case "${UNAME_MACHINE_ARCH}" in
+	    armeb) machine=armeb-unknown ;;
+	    arm*) machine=arm-unknown ;;
+	    sh3el) machine=shl-unknown ;;
+	    sh3eb) machine=sh-unknown ;;
+	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+	esac
+	# The Operating System including object format, if it has switched
+	# to ELF recently, or will in the future.
+	case "${UNAME_MACHINE_ARCH}" in
+	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+		eval $set_cc_for_build
+		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+			| grep __ELF__ >/dev/null
+		then
+		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+		    # Return netbsd for either.  FIX?
+		    os=netbsd
+		else
+		    os=netbsdelf
+		fi
+		;;
+	    *)
+	        os=netbsd
+		;;
+	esac
+	# The OS release
+	# Debian GNU/NetBSD machines have a different userland, and
+	# thus, need a distinct triplet. However, they do not need
+	# kernel version information, so it can be replaced with a
+	# suitable tag, in the style of linux-gnu.
+	case "${UNAME_VERSION}" in
+	    Debian*)
+		release='-gnu'
+		;;
+	    *)
+		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+		;;
+	esac
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit 0 ;;
+    amd64:OpenBSD:*:*)
+	echo x86_64-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    amiga:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    arc:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    cats:OpenBSD:*:*)
+	echo arm-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    hp300:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mac68k:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    macppc:OpenBSD:*:*)
+	echo powerpc-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvme68k:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvme88k:OpenBSD:*:*)
+	echo m88k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvmeppc:OpenBSD:*:*)
+	echo powerpc-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    pegasos:OpenBSD:*:*)
+	echo powerpc-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    pmax:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    sgi:OpenBSD:*:*)
+	echo mipseb-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    sun3:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    wgrisc:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:OpenBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:ekkoBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+	exit 0 ;;
+    macppc:MirBSD:*:*)
+	echo powerppc-unknown-mirbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:MirBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+	exit 0 ;;
+    alpha:OSF1:*:*)
+	case $UNAME_RELEASE in
+	*4.0)
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+		;;
+	*5.*)
+	        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+		;;
+	esac
+	# According to Compaq, /usr/sbin/psrinfo has been available on
+	# OSF/1 and Tru64 systems produced since 1995.  I hope that
+	# covers most systems running today.  This code pipes the CPU
+	# types through head -n 1, so we only detect the type of CPU 0.
+	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+	case "$ALPHA_CPU_TYPE" in
+	    "EV4 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV4.5 (21064)")
+		UNAME_MACHINE="alpha" ;;
+	    "LCA4 (21066/21068)")
+		UNAME_MACHINE="alpha" ;;
+	    "EV5 (21164)")
+		UNAME_MACHINE="alphaev5" ;;
+	    "EV5.6 (21164A)")
+		UNAME_MACHINE="alphaev56" ;;
+	    "EV5.6 (21164PC)")
+		UNAME_MACHINE="alphapca56" ;;
+	    "EV5.7 (21164PC)")
+		UNAME_MACHINE="alphapca57" ;;
+	    "EV6 (21264)")
+		UNAME_MACHINE="alphaev6" ;;
+	    "EV6.7 (21264A)")
+		UNAME_MACHINE="alphaev67" ;;
+	    "EV6.8CB (21264C)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8AL (21264B)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.8CX (21264D)")
+		UNAME_MACHINE="alphaev68" ;;
+	    "EV6.9A (21264/EV69A)")
+		UNAME_MACHINE="alphaev69" ;;
+	    "EV7 (21364)")
+		UNAME_MACHINE="alphaev7" ;;
+	    "EV7.9 (21364A)")
+		UNAME_MACHINE="alphaev79" ;;
+	esac
+	# A Pn.n version is a patched version.
+	# A Vn.n version is a released version.
+	# A Tn.n version is a released field test version.
+	# A Xn.n version is an unreleased experimental baselevel.
+	# 1.2 uses "1.2" for uname -r.
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit 0 ;;
+    Alpha*:OpenVMS:*:*)
+	echo alpha-hp-vms
+	exit 0 ;;
+    Alpha\ *:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# Should we change UNAME_MACHINE based on the output of uname instead
+	# of the specific Alpha model?
+	echo alpha-pc-interix
+	exit 0 ;;
+    21064:Windows_NT:50:3)
+	echo alpha-dec-winnt3.5
+	exit 0 ;;
+    Amiga*:UNIX_System_V:4.0:*)
+	echo m68k-unknown-sysv4
+	exit 0;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-amigaos
+	exit 0 ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-morphos
+	exit 0 ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit 0 ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+	exit 0 ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+	echo arm-acorn-riscix${UNAME_RELEASE}
+	exit 0;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+	echo hppa1.1-hitachi-hiuxmpp
+	exit 0;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+	# akee at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+	if test "`(/bin/universe) 2>/dev/null`" = att ; then
+		echo pyramid-pyramid-sysv3
+	else
+		echo pyramid-pyramid-bsd
+	fi
+	exit 0 ;;
+    NILE*:*:*:dcosx)
+	echo pyramid-pyramid-svr4
+	exit 0 ;;
+    DRS?6000:unix:4.0:6*)
+	echo sparc-icl-nx6
+	exit 0 ;;
+    DRS?6000:UNIX_SV:4.2*:7*)
+	case `/usr/bin/uname -p` in
+	    sparc) echo sparc-icl-nx7 && exit 0 ;;
+	esac ;;
+    sun4H:SunOS:5.*:*)
+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    i86pc:SunOS:5.*:*)
+	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:6*:*)
+	# According to config.sub, this is the proper way to canonicalize
+	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+	# it's likely to be more like Solaris than SunOS4.
+	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:*:*)
+	case "`/usr/bin/arch -k`" in
+	    Series*|S4*)
+		UNAME_RELEASE=`uname -v`
+		;;
+	esac
+	# Japanese Language versions have a version number like `4.1.3-JL'.
+	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+	exit 0 ;;
+    sun3*:SunOS:*:*)
+	echo m68k-sun-sunos${UNAME_RELEASE}
+	exit 0 ;;
+    sun*:*:4.2BSD:*)
+	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+	case "`/bin/arch`" in
+	    sun3)
+		echo m68k-sun-sunos${UNAME_RELEASE}
+		;;
+	    sun4)
+		echo sparc-sun-sunos${UNAME_RELEASE}
+		;;
+	esac
+	exit 0 ;;
+    aushp:SunOS:*:*)
+	echo sparc-auspex-sunos${UNAME_RELEASE}
+	exit 0 ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit 0 ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit 0 ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit 0 ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit 0 ;;
+    m68k:machten:*:*)
+	echo m68k-apple-machten${UNAME_RELEASE}
+	exit 0 ;;
+    powerpc:machten:*:*)
+	echo powerpc-apple-machten${UNAME_RELEASE}
+	exit 0 ;;
+    RISC*:Mach:*:*)
+	echo mips-dec-mach_bsd4.3
+	exit 0 ;;
+    RISC*:ULTRIX:*:*)
+	echo mips-dec-ultrix${UNAME_RELEASE}
+	exit 0 ;;
+    VAX*:ULTRIX*:*:*)
+	echo vax-dec-ultrix${UNAME_RELEASE}
+	exit 0 ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+	echo clipper-intergraph-clix${UNAME_RELEASE}
+	exit 0 ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+	#if defined (host_mips) && defined (MIPSEB)
+	#if defined (SYSTYPE_SYSV)
+	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_SVR4)
+	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+	#endif
+	#endif
+	  exit (-1);
+	}
+EOF
+	$CC_FOR_BUILD -o $dummy $dummy.c \
+	  && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+	  && exit 0
+	echo mips-mips-riscos${UNAME_RELEASE}
+	exit 0 ;;
+    Motorola:PowerMAX_OS:*:*)
+	echo powerpc-motorola-powermax
+	exit 0 ;;
+    Motorola:*:4.3:PL8-*)
+	echo powerpc-harris-powermax
+	exit 0 ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+	echo powerpc-harris-powermax
+	exit 0 ;;
+    Night_Hawk:Power_UNIX:*:*)
+	echo powerpc-harris-powerunix
+	exit 0 ;;
+    m88k:CX/UX:7*:*)
+	echo m88k-harris-cxux7
+	exit 0 ;;
+    m88k:*:4*:R4*)
+	echo m88k-motorola-sysv4
+	exit 0 ;;
+    m88k:*:3*:R3*)
+	echo m88k-motorola-sysv3
+	exit 0 ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
+		echo m88k-dg-dgux${UNAME_RELEASE}
+	    else
+		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
+	else
+	    echo i586-dg-dgux${UNAME_RELEASE}
+	fi
+ 	exit 0 ;;
+    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
+	echo m88k-dolphin-sysv3
+	exit 0 ;;
+    M88*:*:R3*:*)
+	# Delta 88k system running SVR3
+	echo m88k-motorola-sysv3
+	exit 0 ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+	echo m88k-tektronix-sysv3
+	exit 0 ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+	echo m68k-tektronix-bsd
+	exit 0 ;;
+    *:IRIX*:*:*)
+	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+	exit 0 ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
+	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+	echo i386-ibm-aix
+	exit 0 ;;
+    ia64:AIX:*:*)
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+	exit 0 ;;
+    *:AIX:2:3)
+	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+		eval $set_cc_for_build
+		sed 's/^		//' << EOF >$dummy.c
+		#include <sys/systemcfg.h>
+
+		main()
+			{
+			if (!__power_pc())
+				exit(1);
+			puts("powerpc-ibm-aix3.2.5");
+			exit(0);
+			}
+EOF
+		$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+		echo rs6000-ibm-aix3.2.5
+	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+		echo rs6000-ibm-aix3.2.4
+	else
+		echo rs6000-ibm-aix3.2
+	fi
+	exit 0 ;;
+    *:AIX:*:[45])
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+		IBM_ARCH=rs6000
+	else
+		IBM_ARCH=powerpc
+	fi
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+	exit 0 ;;
+    *:AIX:*:*)
+	echo rs6000-ibm-aix
+	exit 0 ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+	echo romp-ibm-bsd4.4
+	exit 0 ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+	exit 0 ;;                           # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+	echo rs6000-bull-bosx
+	exit 0 ;;
+    DPX/2?00:B.O.S.:*:*)
+	echo m68k-bull-sysv3
+	exit 0 ;;
+    9000/[34]??:4.3bsd:1.*:*)
+	echo m68k-hp-bsd
+	exit 0 ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+	echo m68k-hp-bsd4.4
+	exit 0 ;;
+    9000/[34678]??:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	case "${UNAME_MACHINE}" in
+	    9000/31? )            HP_ARCH=m68000 ;;
+	    9000/[34]?? )         HP_ARCH=m68k ;;
+	    9000/[678][0-9][0-9])
+		if [ -x /usr/bin/getconf ]; then
+		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+		fi
+		if [ "${HP_ARCH}" = "" ]; then
+		    eval $set_cc_for_build
+		    sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+              	{
+              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+              	case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+              	    switch (bits)
+              		{
+              		case 64: puts ("hppa2.0w"); break;
+              		case 32: puts ("hppa2.0n"); break;
+              		default: puts ("hppa2.0"); break;
+              		} break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+              	    puts ("hppa2.0"); break;
+              #endif
+              	default: puts ("hppa1.0"); break;
+              	}
+                  exit (0);
+              }
+EOF
+		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+		    test -z "$HP_ARCH" && HP_ARCH=hppa
+		fi ;;
+	esac
+	if [ ${HP_ARCH} = "hppa2.0w" ]
+	then
+	    # avoid double evaluation of $set_cc_for_build
+	    test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
+	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
+	    then
+		HP_ARCH="hppa2.0w"
+	    else
+		HP_ARCH="hppa64"
+	    fi
+	fi
+	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+	exit 0 ;;
+    ia64:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	echo ia64-hp-hpux${HPUX_REV}
+	exit 0 ;;
+    3050*:HI-UX:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <unistd.h>
+	int
+	main ()
+	{
+	  long cpu = sysconf (_SC_CPU_VERSION);
+	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+	     results, however.  */
+	  if (CPU_IS_PA_RISC (cpu))
+	    {
+	      switch (cpu)
+		{
+		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+		  default: puts ("hppa-hitachi-hiuxwe2"); break;
+		}
+	    }
+	  else if (CPU_IS_HP_MC68K (cpu))
+	    puts ("m68k-hitachi-hiuxwe2");
+	  else puts ("unknown-hitachi-hiuxwe2");
+	  exit (0);
+	}
+EOF
+	$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
+	echo unknown-hitachi-hiuxwe2
+	exit 0 ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+	echo hppa1.1-hp-bsd
+	exit 0 ;;
+    9000/8??:4.3bsd:*:*)
+	echo hppa1.0-hp-bsd
+	exit 0 ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit 0 ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+	echo hppa1.1-hp-osf
+	exit 0 ;;
+    hp8??:OSF1:*:*)
+	echo hppa1.0-hp-osf
+	exit 0 ;;
+    i*86:OSF1:*:*)
+	if [ -x /usr/sbin/sysversion ] ; then
+	    echo ${UNAME_MACHINE}-unknown-osf1mk
+	else
+	    echo ${UNAME_MACHINE}-unknown-osf1
+	fi
+	exit 0 ;;
+    parisc*:Lites*:*:*)
+	echo hppa1.1-hp-lites
+	exit 0 ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+	echo c1-convex-bsd
+        exit 0 ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+        exit 0 ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+	echo c34-convex-bsd
+        exit 0 ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+	echo c38-convex-bsd
+        exit 0 ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+	echo c4-convex-bsd
+        exit 0 ;;
+    CRAY*Y-MP:*:*:*)
+	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*[A-Z]90:*:*:*)
+	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+	      -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*TS:*:*:*)
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*T3E:*:*:*)
+	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    *:UNICOS/mp:*:*)
+	echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit 0 ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+	exit 0 ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    sparc*:BSD/OS:*:*)
+	echo sparc-unknown-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    *:FreeBSD:*:*)
+	# Determine whether the default compiler uses glibc.
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <features.h>
+	#if __GLIBC__ >= 2
+	LIBC=gnu
+	#else
+	LIBC=
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+	# GNU/KFreeBSD systems have a "k" prefix to indicate we are using
+	# FreeBSD's kernel, but not the complete OS.
+	case ${LIBC} in gnu) kernel_only='k' ;; esac
+	echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
+	exit 0 ;;
+    i*:CYGWIN*:*)
+	echo ${UNAME_MACHINE}-pc-cygwin
+	exit 0 ;;
+    i*:MINGW*:*)
+	echo ${UNAME_MACHINE}-pc-mingw32
+	exit 0 ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit 0 ;;
+    x86:Interix*:[34]*)
+	echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
+	exit 0 ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+	echo i${UNAME_MACHINE}-pc-mks
+	exit 0 ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+	# UNAME_MACHINE based on the output of uname instead of i386?
+	echo i586-pc-interix
+	exit 0 ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit 0 ;;
+    p*:CYGWIN*:*)
+	echo powerpcle-unknown-cygwin
+	exit 0 ;;
+    prep*:SunOS:5.*:*)
+	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    *:GNU:*:*)
+	# the GNU system
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	exit 0 ;;
+    *:GNU/*:*:*)
+	# other systems with GNU libc and userland
+	echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+	exit 0 ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit 0 ;;
+    arm*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    cris:Linux:*:*)
+	echo cris-axis-linux-gnu
+	exit 0 ;;
+    ia64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    m68*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    mips:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef mips
+	#undef mipsel
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=mipsel
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=mips
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+	test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+	;;
+    mips64:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef mips64
+	#undef mips64el
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=mips64el
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=mips64
+	#else
+	CPU=
+	#endif
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+	test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
+	;;
+    ppc:Linux:*:*)
+	echo powerpc-unknown-linux-gnu
+	exit 0 ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-gnu
+	exit 0 ;;
+    alpha:Linux:*:*)
+	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+	  EV5)   UNAME_MACHINE=alphaev5 ;;
+	  EV56)  UNAME_MACHINE=alphaev56 ;;
+	  PCA56) UNAME_MACHINE=alphapca56 ;;
+	  PCA57) UNAME_MACHINE=alphapca56 ;;
+	  EV6)   UNAME_MACHINE=alphaev6 ;;
+	  EV67)  UNAME_MACHINE=alphaev67 ;;
+	  EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+	objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	exit 0 ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+	# Look for CPU level
+	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
+	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
+	  *)    echo hppa-unknown-linux-gnu ;;
+	esac
+	exit 0 ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-gnu
+	exit 0 ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+	echo ${UNAME_MACHINE}-ibm-linux
+	exit 0 ;;
+    sh64*:Linux:*:*)
+    	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    sh*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    x86_64:Linux:*:*)
+	echo x86_64-unknown-linux-gnu
+	exit 0 ;;
+    i*86:Linux:*:*)
+	# The BFD linker knows what the default object file format is, so
+	# first see if it will tell us. cd to the root directory to prevent
+	# problems with other programs or directories called `ld' in the path.
+	# Set LC_ALL=C to ensure ld outputs messages in English.
+	ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+			 | sed -ne '/supported targets:/!d
+				    s/[ 	][ 	]*/ /g
+				    s/.*supported targets: *//
+				    s/ .*//
+				    p'`
+        case "$ld_supported_targets" in
+	  elf32-i386)
+		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+		;;
+	  a.out-i386-linux)
+		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+		exit 0 ;;
+	  coff-i386)
+		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+		exit 0 ;;
+	  "")
+		# Either a pre-BFD a.out linker (linux-gnuoldld) or
+		# one that does not give us useful --help.
+		echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+		exit 0 ;;
+	esac
+	# Determine whether the default compiler is a.out or elf
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#include <features.h>
+	#ifdef __ELF__
+	# ifdef __GLIBC__
+	#  if __GLIBC__ >= 2
+	LIBC=gnu
+	#  else
+	LIBC=gnulibc1
+	#  endif
+	# else
+	LIBC=gnulibc1
+	# endif
+	#else
+	#ifdef __INTEL_COMPILER
+	LIBC=gnu
+	#else
+	LIBC=gnuaout
+	#endif
+	#endif
+	#ifdef __dietlibc__
+	LIBC=dietlibc
+	#endif
+EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+	test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
+	test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+	;;
+    i*86:DYNIX/ptx:4*:*)
+	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+	# earlier versions are messed up and put the nodename in both
+	# sysname and nodename.
+	echo i386-sequent-sysv4
+	exit 0 ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+	# I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+	exit 0 ;;
+    i*86:OS/2:*:*)
+	# If we were able to find `uname', then EMX Unix compatibility
+	# is probably installed.
+	echo ${UNAME_MACHINE}-pc-os2-emx
+	exit 0 ;;
+    i*86:XTS-300:*:STOP)
+	echo ${UNAME_MACHINE}-unknown-stop
+	exit 0 ;;
+    i*86:atheos:*:*)
+	echo ${UNAME_MACHINE}-unknown-atheos
+	exit 0 ;;
+	i*86:syllable:*:*)
+	echo ${UNAME_MACHINE}-pc-syllable
+	exit 0 ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+	echo i386-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    i*86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit 0 ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+	else
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+	fi
+	exit 0 ;;
+    i*86:*:5:[78]*)
+	case `/bin/uname -X | grep "^Machine"` in
+	    *486*)	     UNAME_MACHINE=i486 ;;
+	    *Pentium)	     UNAME_MACHINE=i586 ;;
+	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+	esac
+	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+	exit 0 ;;
+    i*86:*:3.2:*)
+	if test -f /usr/options/cb.name; then
+		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+	elif /bin/uname -X 2>/dev/null >/dev/null ; then
+		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+			&& UNAME_MACHINE=i586
+		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+	else
+		echo ${UNAME_MACHINE}-pc-sysv32
+	fi
+	exit 0 ;;
+    pc:*:*:*)
+	# Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i386.
+	echo i386-pc-msdosdjgpp
+        exit 0 ;;
+    Intel:Mach:3*:*)
+	echo i386-pc-mach3
+	exit 0 ;;
+    paragon:*:*:*)
+	echo i860-intel-osf1
+	exit 0 ;;
+    i860:*:4.*:*) # i860-SVR4
+	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+	else # Add other i860-SVR4 vendors below as they are discovered.
+	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+	fi
+	exit 0 ;;
+    mini*:CTIX:SYS*5:*)
+	# "miniframe"
+	echo m68010-convergent-sysv
+	exit 0 ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+	echo m68k-convergent-sysv
+	exit 0 ;;
+    M680?0:D-NIX:5.3:*)
+	echo m68k-diab-dnix
+	exit 0 ;;
+    M68*:*:R3V[567]*:*)
+	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
+	OS_REL=''
+	test -r /etc/.relid \
+	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	  && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && echo i486-ncr-sysv4 && exit 0 ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+	echo m68k-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    mc68030:UNIX_System_V:4.*:*)
+	echo m68k-atari-sysv4
+	exit 0 ;;
+    TSUNAMI:LynxOS:2.*:*)
+	echo sparc-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    rs6000:LynxOS:2.*:*)
+	echo rs6000-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+	echo powerpc-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    SM[BE]S:UNIX_SV:*:*)
+	echo mips-dde-sysv${UNAME_RELEASE}
+	exit 0 ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit 0 ;;
+    RM*:SINIX-*:*:*)
+	echo mips-sni-sysv4
+	exit 0 ;;
+    *:SINIX-*:*:*)
+	if uname -p 2>/dev/null >/dev/null ; then
+		UNAME_MACHINE=`(uname -p) 2>/dev/null`
+		echo ${UNAME_MACHINE}-sni-sysv4
+	else
+		echo ns32k-sni-sysv
+	fi
+	exit 0 ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel at ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit 0 ;;
+    *:UNIX_System_V:4*:FTX*)
+	# From Gerald Hewes <hewes at openmarket.com>.
+	# How about differentiating between stratus architectures? -djm
+	echo hppa1.1-stratus-sysv4
+	exit 0 ;;
+    *:*:*:FTX*)
+	# From seanf at swdc.stratus.com.
+	echo i860-stratus-sysv4
+	exit 0 ;;
+    *:VOS:*:*)
+	# From Paul.Green at stratus.com.
+	echo hppa1.1-stratus-vos
+	exit 0 ;;
+    mc68*:A/UX:*:*)
+	echo m68k-apple-aux${UNAME_RELEASE}
+	exit 0 ;;
+    news*:NEWS-OS:6*:*)
+	echo mips-sony-newsos6
+	exit 0 ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+	if [ -d /usr/nec ]; then
+	        echo mips-nec-sysv${UNAME_RELEASE}
+	else
+	        echo mips-unknown-sysv${UNAME_RELEASE}
+	fi
+        exit 0 ;;
+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
+	echo powerpc-be-beos
+	exit 0 ;;
+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
+	echo powerpc-apple-beos
+	exit 0 ;;
+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
+	echo i586-pc-beos
+	exit 0 ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    SX-6:SUPER-UX:*:*)
+	echo sx6-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    Power*:Rhapsody:*:*)
+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Rhapsody:*:*)
+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Darwin:*:*)
+	case `uname -p` in
+	    *86) UNAME_PROCESSOR=i686 ;;
+	    powerpc) UNAME_PROCESSOR=powerpc ;;
+	esac
+	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+	exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	UNAME_PROCESSOR=`uname -p`
+	if test "$UNAME_PROCESSOR" = "x86"; then
+		UNAME_PROCESSOR=i386
+		UNAME_MACHINE=pc
+	fi
+	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+	exit 0 ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit 0 ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit 0 ;;
+    *:NonStop-UX:*:*)
+	echo mips-compaq-nonstopux
+	exit 0 ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit 0 ;;
+    *:Plan9:*:*)
+	# "uname -m" is not consistent, so use $cputype instead. 386
+	# is converted to i386 for consistency with other x86
+	# operating systems.
+	if test "$cputype" = "386"; then
+	    UNAME_MACHINE=i386
+	else
+	    UNAME_MACHINE="$cputype"
+	fi
+	echo ${UNAME_MACHINE}-unknown-plan9
+	exit 0 ;;
+    *:TOPS-10:*:*)
+	echo pdp10-unknown-tops10
+	exit 0 ;;
+    *:TENEX:*:*)
+	echo pdp10-unknown-tenex
+	exit 0 ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+	echo pdp10-dec-tops20
+	exit 0 ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+	echo pdp10-xkl-tops20
+	exit 0 ;;
+    *:TOPS-20:*:*)
+	echo pdp10-unknown-tops20
+	exit 0 ;;
+    *:ITS:*:*)
+	echo pdp10-unknown-its
+	exit 0 ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+	exit 0 ;;
+    *:DragonFly:*:*)
+	echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+	  ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+	printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+	printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+	echo c1-convex-bsd
+	exit 0 ;;
+    c2*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+	exit 0 ;;
+    c34*)
+	echo c34-convex-bsd
+	exit 0 ;;
+    c38*)
+	echo c38-convex-bsd
+	exit 0 ;;
+    c4*)
+	echo c4-convex-bsd
+	exit 0 ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+    ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches at gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:


Property changes on: spike/wktraster/config.guess
___________________________________________________________________
Name: svn:executable
   + *

Added: spike/wktraster/config.sub
===================================================================
--- spike/wktraster/config.sub	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/config.sub	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,1549 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+timestamp='2004-03-12'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Please send patches to <config-patches at gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit 0;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
+  kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+	-sun*os*)
+		# Prevent following clause from handling this invalid input.
+		;;
+	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+	-apple | -axis)
+		os=
+		basic_machine=$1
+		;;
+	-sim | -cisco | -oki | -wec | -winbond)
+		os=
+		basic_machine=$1
+		;;
+	-scout)
+		;;
+	-wrs)
+		os=-vxworks
+		basic_machine=$1
+		;;
+	-chorusos*)
+		os=-chorusos
+		basic_machine=$1
+		;;
+ 	-chorusrdb)
+ 		os=-chorusrdb
+		basic_machine=$1
+ 		;;
+	-hiux*)
+		os=-hiuxwe2
+		;;
+	-sco5)
+		os=-sco3.2v5
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco4)
+		os=-sco3.2v4
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2.[4-9]*)
+		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2v[4-9]*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco*)
+		os=-sco3.2v2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-udk*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-isc)
+		os=-isc2.2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-clix*)
+		basic_machine=clipper-intergraph
+		;;
+	-isc*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-lynx*)
+		os=-lynxos
+		;;
+	-ptx*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+		;;
+	-windowsnt*)
+		os=`echo $os | sed -e 's/windowsnt/winnt/'`
+		;;
+	-psos*)
+		os=-psos
+		;;
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+	# Recognize the basic CPU types without company name.
+	# Some are omitted here because they have special meanings below.
+	1750a | 580 \
+	| a29k \
+	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+	| am33_2.0 \
+	| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+	| c4x | clipper \
+	| d10v | d30v | dlx | dsp16xx \
+	| fr30 | frv \
+	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| i370 | i860 | i960 | ia64 \
+	| ip2k | iq2000 \
+	| m32r | m32rle | m68000 | m68k | m88k | mcore \
+	| mips | mipsbe | mipseb | mipsel | mipsle \
+	| mips16 \
+	| mips64 | mips64el \
+	| mips64vr | mips64vrel \
+	| mips64orion | mips64orionel \
+	| mips64vr4100 | mips64vr4100el \
+	| mips64vr4300 | mips64vr4300el \
+	| mips64vr5000 | mips64vr5000el \
+	| mipsisa32 | mipsisa32el \
+	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa64 | mipsisa64el \
+	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64sb1 | mipsisa64sb1el \
+	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipstx39 | mipstx39el \
+	| mn10200 | mn10300 \
+	| msp430 \
+	| ns16k | ns32k \
+	| openrisc | or32 \
+	| pdp10 | pdp11 | pj | pjl \
+	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+	| pyramid \
+	| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+	| sh64 | sh64le \
+	| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \
+	| strongarm \
+	| tahoe | thumb | tic4x | tic80 | tron \
+	| v850 | v850e \
+	| we32k \
+	| x86 | xscale | xstormy16 | xtensa \
+	| z8k)
+		basic_machine=$basic_machine-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12)
+		# Motorola 68HC11/12.
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+		;;
+
+	# We use `pc' rather than `unknown'
+	# because (1) that's what they normally are, and
+	# (2) the word "unknown" tends to confuse beginning users.
+	i*86 | x86_64)
+	  basic_machine=$basic_machine-pc
+	  ;;
+	# Object if more than one company name word.
+	*-*-*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+	# Recognize the basic CPU types with company name.
+	580-* \
+	| a29k-* \
+	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+	| avr-* \
+	| bs2000-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+	| clipper-* | cydra-* \
+	| d10v-* | d30v-* | dlx-* \
+	| elxsi-* \
+	| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+	| h8300-* | h8500-* \
+	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| i*86-* | i860-* | i960-* | ia64-* \
+	| ip2k-* | iq2000-* \
+	| m32r-* | m32rle-* \
+	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+	| m88110-* | m88k-* | mcore-* \
+	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+	| mips16-* \
+	| mips64-* | mips64el-* \
+	| mips64vr-* | mips64vrel-* \
+	| mips64orion-* | mips64orionel-* \
+	| mips64vr4100-* | mips64vr4100el-* \
+	| mips64vr4300-* | mips64vr4300el-* \
+	| mips64vr5000-* | mips64vr5000el-* \
+	| mipsisa32-* | mipsisa32el-* \
+	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa64-* | mipsisa64el-* \
+	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64sb1-* | mipsisa64sb1el-* \
+	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipstx39-* | mipstx39el-* \
+	| msp430-* \
+	| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
+	| orion-* \
+	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+	| pyramid-* \
+	| romp-* | rs6000-* \
+	| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+	| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+	| tahoe-* | thumb-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+	| tron-* \
+	| v850-* | v850e-* | vax-* \
+	| we32k-* \
+	| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
+	| xtensa-* \
+	| ymp-* \
+	| z8k-*)
+		;;
+	# Recognize the various machine names and aliases which stand
+	# for a CPU type and a company and sometimes even an OS.
+	386bsd)
+		basic_machine=i386-unknown
+		os=-bsd
+		;;
+	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+		basic_machine=m68000-att
+		;;
+	3b*)
+		basic_machine=we32k-att
+		;;
+	a29khif)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+    	abacus)
+		basic_machine=abacus-unknown
+		;;
+	adobe68k)
+		basic_machine=m68010-adobe
+		os=-scout
+		;;
+	alliant | fx80)
+		basic_machine=fx80-alliant
+		;;
+	altos | altos3068)
+		basic_machine=m68k-altos
+		;;
+	am29k)
+		basic_machine=a29k-none
+		os=-bsd
+		;;
+	amd64)
+		basic_machine=x86_64-pc
+		;;
+	amd64-*)
+		basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	amdahl)
+		basic_machine=580-amdahl
+		os=-sysv
+		;;
+	amiga | amiga-*)
+		basic_machine=m68k-unknown
+		;;
+	amigaos | amigados)
+		basic_machine=m68k-unknown
+		os=-amigaos
+		;;
+	amigaunix | amix)
+		basic_machine=m68k-unknown
+		os=-sysv4
+		;;
+	apollo68)
+		basic_machine=m68k-apollo
+		os=-sysv
+		;;
+	apollo68bsd)
+		basic_machine=m68k-apollo
+		os=-bsd
+		;;
+	aux)
+		basic_machine=m68k-apple
+		os=-aux
+		;;
+	balance)
+		basic_machine=ns32k-sequent
+		os=-dynix
+		;;
+	c90)
+		basic_machine=c90-cray
+		os=-unicos
+		;;
+	convex-c1)
+		basic_machine=c1-convex
+		os=-bsd
+		;;
+	convex-c2)
+		basic_machine=c2-convex
+		os=-bsd
+		;;
+	convex-c32)
+		basic_machine=c32-convex
+		os=-bsd
+		;;
+	convex-c34)
+		basic_machine=c34-convex
+		os=-bsd
+		;;
+	convex-c38)
+		basic_machine=c38-convex
+		os=-bsd
+		;;
+	cray | j90)
+		basic_machine=j90-cray
+		os=-unicos
+		;;
+	cr16c)
+		basic_machine=cr16c-unknown
+		os=-elf
+		;;
+	crds | unos)
+		basic_machine=m68k-crds
+		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
+	crx)
+		basic_machine=crx-unknown
+		os=-elf
+		;;
+	da30 | da30-*)
+		basic_machine=m68k-da30
+		;;
+	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+		basic_machine=mips-dec
+		;;
+	decsystem10* | dec10*)
+		basic_machine=pdp10-dec
+		os=-tops10
+		;;
+	decsystem20* | dec20*)
+		basic_machine=pdp10-dec
+		os=-tops20
+		;;
+	delta | 3300 | motorola-3300 | motorola-delta \
+	      | 3300-motorola | delta-motorola)
+		basic_machine=m68k-motorola
+		;;
+	delta88)
+		basic_machine=m88k-motorola
+		os=-sysv3
+		;;
+	dpx20 | dpx20-*)
+		basic_machine=rs6000-bull
+		os=-bosx
+		;;
+	dpx2* | dpx2*-bull)
+		basic_machine=m68k-bull
+		os=-sysv3
+		;;
+	ebmon29k)
+		basic_machine=a29k-amd
+		os=-ebmon
+		;;
+	elxsi)
+		basic_machine=elxsi-elxsi
+		os=-bsd
+		;;
+	encore | umax | mmax)
+		basic_machine=ns32k-encore
+		;;
+	es1800 | OSE68k | ose68k | ose | OSE)
+		basic_machine=m68k-ericsson
+		os=-ose
+		;;
+	fx2800)
+		basic_machine=i860-alliant
+		;;
+	genix)
+		basic_machine=ns32k-ns
+		;;
+	gmicro)
+		basic_machine=tron-gmicro
+		os=-sysv
+		;;
+	go32)
+		basic_machine=i386-pc
+		os=-go32
+		;;
+	h3050r* | hiux*)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	h8300hms)
+		basic_machine=h8300-hitachi
+		os=-hms
+		;;
+	h8300xray)
+		basic_machine=h8300-hitachi
+		os=-xray
+		;;
+	h8500hms)
+		basic_machine=h8500-hitachi
+		os=-hms
+		;;
+	harris)
+		basic_machine=m88k-harris
+		os=-sysv3
+		;;
+	hp300-*)
+		basic_machine=m68k-hp
+		;;
+	hp300bsd)
+		basic_machine=m68k-hp
+		os=-bsd
+		;;
+	hp300hpux)
+		basic_machine=m68k-hp
+		os=-hpux
+		;;
+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k2[0-9][0-9] | hp9k31[0-9])
+		basic_machine=m68000-hp
+		;;
+	hp9k3[2-9][0-9])
+		basic_machine=m68k-hp
+		;;
+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k78[0-9] | hp78[0-9])
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][13679] | hp8[0-9][13679])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][0-9] | hp8[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hppa-next)
+		os=-nextstep3
+		;;
+	hppaosf)
+		basic_machine=hppa1.1-hp
+		os=-osf
+		;;
+	hppro)
+		basic_machine=hppa1.1-hp
+		os=-proelf
+		;;
+	i370-ibm* | ibm*)
+		basic_machine=i370-ibm
+		;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+	i*86v32)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv32
+		;;
+	i*86v4*)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv4
+		;;
+	i*86v)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv
+		;;
+	i*86sol2)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-solaris2
+		;;
+	i386mach)
+		basic_machine=i386-mach
+		os=-mach
+		;;
+	i386-vsta | vsta)
+		basic_machine=i386-unknown
+		os=-vsta
+		;;
+	iris | iris4d)
+		basic_machine=mips-sgi
+		case $os in
+		    -irix*)
+			;;
+		    *)
+			os=-irix4
+			;;
+		esac
+		;;
+	isi68 | isi)
+		basic_machine=m68k-isi
+		os=-sysv
+		;;
+	m88k-omron*)
+		basic_machine=m88k-omron
+		;;
+	magnum | m3230)
+		basic_machine=mips-mips
+		os=-sysv
+		;;
+	merlin)
+		basic_machine=ns32k-utek
+		os=-sysv
+		;;
+	mingw32)
+		basic_machine=i386-pc
+		os=-mingw32
+		;;
+	miniframe)
+		basic_machine=m68000-convergent
+		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+	mips3*-*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+		;;
+	mips3*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+		;;
+	mmix*)
+		basic_machine=mmix-knuth
+		os=-mmixware
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	morphos)
+		basic_machine=powerpc-unknown
+		os=-morphos
+		;;
+	msdos)
+		basic_machine=i386-pc
+		os=-msdos
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
+	ncr3000)
+		basic_machine=i486-ncr
+		os=-sysv4
+		;;
+	netbsd386)
+		basic_machine=i386-unknown
+		os=-netbsd
+		;;
+	netwinder)
+		basic_machine=armv4l-rebel
+		os=-linux
+		;;
+	news | news700 | news800 | news900)
+		basic_machine=m68k-sony
+		os=-newsos
+		;;
+	news1000)
+		basic_machine=m68030-sony
+		os=-newsos
+		;;
+	news-3600 | risc-news)
+		basic_machine=mips-sony
+		os=-newsos
+		;;
+	necv70)
+		basic_machine=v70-nec
+		os=-sysv
+		;;
+	next | m*-next )
+		basic_machine=m68k-next
+		case $os in
+		    -nextstep* )
+			;;
+		    -ns2*)
+		      os=-nextstep2
+			;;
+		    *)
+		      os=-nextstep3
+			;;
+		esac
+		;;
+	nh3000)
+		basic_machine=m68k-harris
+		os=-cxux
+		;;
+	nh[45]000)
+		basic_machine=m88k-harris
+		os=-cxux
+		;;
+	nindy960)
+		basic_machine=i960-intel
+		os=-nindy
+		;;
+	mon960)
+		basic_machine=i960-intel
+		os=-mon960
+		;;
+	nonstopux)
+		basic_machine=mips-compaq
+		os=-nonstopux
+		;;
+	np1)
+		basic_machine=np1-gould
+		;;
+	nv1)
+		basic_machine=nv1-cray
+		os=-unicosmp
+		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
+	op50n-* | op60c-*)
+		basic_machine=hppa1.1-oki
+		os=-proelf
+		;;
+	or32 | or32-*)
+		basic_machine=or32-unknown
+		os=-coff
+		;;
+	os400)
+		basic_machine=powerpc-ibm
+		os=-os400
+		;;
+	OSE68000 | ose68000)
+		basic_machine=m68000-ericsson
+		os=-ose
+		;;
+	os68k)
+		basic_machine=m68k-none
+		os=-os68k
+		;;
+	pa-hitachi)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	paragon)
+		basic_machine=i860-intel
+		os=-osf
+		;;
+	pbd)
+		basic_machine=sparc-tti
+		;;
+	pbb)
+		basic_machine=m68k-tti
+		;;
+	pc532 | pc532-*)
+		basic_machine=ns32k-pc532
+		;;
+	pentium | p5 | k5 | k6 | nexgen | viac3)
+		basic_machine=i586-pc
+		;;
+	pentiumpro | p6 | 6x86 | athlon | athlon_*)
+		basic_machine=i686-pc
+		;;
+	pentiumii | pentium2 | pentiumiii | pentium3)
+		basic_machine=i686-pc
+		;;
+	pentium4)
+		basic_machine=i786-pc
+		;;
+	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentium4-*)
+		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pn)
+		basic_machine=pn-gould
+		;;
+	power)	basic_machine=power-ibm
+		;;
+	ppc)	basic_machine=powerpc-unknown
+		;;
+	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppcle | powerpclittle | ppc-le | powerpc-little)
+		basic_machine=powerpcle-unknown
+		;;
+	ppcle-* | powerpclittle-*)
+		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64)	basic_machine=powerpc64-unknown
+		;;
+	ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+		basic_machine=powerpc64le-unknown
+		;;
+	ppc64le-* | powerpc64little-*)
+		basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ps2)
+		basic_machine=i386-ibm
+		;;
+	pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	rm[46]00)
+		basic_machine=mips-siemens
+		;;
+	rtpc | rtpc-*)
+		basic_machine=romp-ibm
+		;;
+	s390 | s390-*)
+		basic_machine=s390-ibm
+		;;
+	s390x | s390x-*)
+		basic_machine=s390x-ibm
+		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	sb1)
+		basic_machine=mipsisa64sb1-unknown
+		;;
+	sb1el)
+		basic_machine=mipsisa64sb1el-unknown
+		;;
+	sei)
+		basic_machine=mips-sei
+		os=-seiux
+		;;
+	sequent)
+		basic_machine=i386-sequent
+		;;
+	sh)
+		basic_machine=sh-hitachi
+		os=-hms
+		;;
+	sh64)
+		basic_machine=sh64-unknown
+		;;
+	sparclite-wrs | simso-wrs)
+		basic_machine=sparclite-wrs
+		os=-vxworks
+		;;
+	sps7)
+		basic_machine=m68k-bull
+		os=-sysv2
+		;;
+	spur)
+		basic_machine=spur-unknown
+		;;
+	st2000)
+		basic_machine=m68k-tandem
+		;;
+	stratus)
+		basic_machine=i860-stratus
+		os=-sysv4
+		;;
+	sun2)
+		basic_machine=m68000-sun
+		;;
+	sun2os3)
+		basic_machine=m68000-sun
+		os=-sunos3
+		;;
+	sun2os4)
+		basic_machine=m68000-sun
+		os=-sunos4
+		;;
+	sun3os3)
+		basic_machine=m68k-sun
+		os=-sunos3
+		;;
+	sun3os4)
+		basic_machine=m68k-sun
+		os=-sunos4
+		;;
+	sun4os3)
+		basic_machine=sparc-sun
+		os=-sunos3
+		;;
+	sun4os4)
+		basic_machine=sparc-sun
+		os=-sunos4
+		;;
+	sun4sol2)
+		basic_machine=sparc-sun
+		os=-solaris2
+		;;
+	sun3 | sun3-*)
+		basic_machine=m68k-sun
+		;;
+	sun4)
+		basic_machine=sparc-sun
+		;;
+	sun386 | sun386i | roadrunner)
+		basic_machine=i386-sun
+		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
+	symmetry)
+		basic_machine=i386-sequent
+		os=-dynix
+		;;
+	t3e)
+		basic_machine=alphaev5-cray
+		os=-unicos
+		;;
+	t90)
+		basic_machine=t90-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
+	tic55x | c55x*)
+		basic_machine=tic55x-unknown
+		os=-coff
+		;;
+	tic6x | c6x*)
+		basic_machine=tic6x-unknown
+		os=-coff
+		;;
+	tx39)
+		basic_machine=mipstx39-unknown
+		;;
+	tx39el)
+		basic_machine=mipstx39el-unknown
+		;;
+	toad1)
+		basic_machine=pdp10-xkl
+		os=-tops20
+		;;
+	tower | tower-32)
+		basic_machine=m68k-ncr
+		;;
+	tpf)
+		basic_machine=s390x-ibm
+		os=-tpf
+		;;
+	udi29k)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	ultra3)
+		basic_machine=a29k-nyu
+		os=-sym1
+		;;
+	v810 | necv810)
+		basic_machine=v810-nec
+		os=-none
+		;;
+	vaxv)
+		basic_machine=vax-dec
+		os=-sysv
+		;;
+	vms)
+		basic_machine=vax-dec
+		os=-vms
+		;;
+	vpp*|vx|vx-*)
+		basic_machine=f301-fujitsu
+		;;
+	vxworks960)
+		basic_machine=i960-wrs
+		os=-vxworks
+		;;
+	vxworks68)
+		basic_machine=m68k-wrs
+		os=-vxworks
+		;;
+	vxworks29k)
+		basic_machine=a29k-wrs
+		os=-vxworks
+		;;
+	w65*)
+		basic_machine=w65-wdc
+		os=-none
+		;;
+	w89k-*)
+		basic_machine=hppa1.1-winbond
+		os=-proelf
+		;;
+	xps | xps100)
+		basic_machine=xps100-honeywell
+		;;
+	ymp)
+		basic_machine=ymp-cray
+		os=-unicos
+		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
+	none)
+		basic_machine=none-none
+		os=-none
+		;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+	w89k)
+		basic_machine=hppa1.1-winbond
+		;;
+	op50n)
+		basic_machine=hppa1.1-oki
+		;;
+	op60c)
+		basic_machine=hppa1.1-oki
+		;;
+	romp)
+		basic_machine=romp-ibm
+		;;
+	rs6000)
+		basic_machine=rs6000-ibm
+		;;
+	vax)
+		basic_machine=vax-dec
+		;;
+	pdp10)
+		# there are many clones, so DEC is not a safe bet
+		basic_machine=pdp10-unknown
+		;;
+	pdp11)
+		basic_machine=pdp11-dec
+		;;
+	we32k)
+		basic_machine=we32k-att
+		;;
+	sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
+		basic_machine=sh-unknown
+		;;
+	sh64)
+		basic_machine=sh64-unknown
+		;;
+	sparc | sparcv8 | sparcv9 | sparcv9b)
+		basic_machine=sparc-sun
+		;;
+	cydra)
+		basic_machine=cydra-cydrome
+		;;
+	orion)
+		basic_machine=orion-highlevel
+		;;
+	orion105)
+		basic_machine=clipper-highlevel
+		;;
+	mac | mpw | mac-mpw)
+		basic_machine=m68k-apple
+		;;
+	pmac | pmac-mpw)
+		basic_machine=powerpc-apple
+		;;
+	*-unknown)
+		# Make sure to match an already-canonicalized machine name.
+		;;
+	*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+	*-digital*)
+		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+		;;
+	*-commodore*)
+		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+		;;
+	*)
+		;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+	# -solaris* is a basic system type, with this one exception.
+	-solaris1 | -solaris1.*)
+		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+		;;
+	-solaris)
+		os=-solaris2
+		;;
+	-svr4*)
+		os=-sysv4
+		;;
+	-unixware*)
+		os=-sysv4.2uw
+		;;
+	-gnu/linux*)
+		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+		;;
+	# First accept the basic system types.
+	# The portable systems comes first.
+	# Each alternative MUST END IN A *, to match a version number.
+	# -sysv* is not here because it comes later, after sysvr4.
+	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+	      | -aos* \
+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
+	      | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+	      | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+	      | -chorusos* | -chorusrdb* \
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
+	# Remember, each alternative MUST END IN *, to match a version number.
+		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i*86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto-qnx*)
+		;;
+	-nto*)
+		os=`echo $os | sed -e 's|nto|nto-qnx|'`
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
+		;;
+	-linux-dietlibc)
+		os=-linux-dietlibc
+		;;
+	-linux*)
+		os=`echo $os | sed -e 's|linux|linux-gnu|'`
+		;;
+	-sunos5*)
+		os=`echo $os | sed -e 's|sunos5|solaris2|'`
+		;;
+	-sunos6*)
+		os=`echo $os | sed -e 's|sunos6|solaris3|'`
+		;;
+	-opened*)
+		os=-openedition
+		;;
+        -os400*)
+		os=-os400
+		;;
+	-wince*)
+		os=-wince
+		;;
+	-osfrose*)
+		os=-osfrose
+		;;
+	-osf*)
+		os=-osf
+		;;
+	-utek*)
+		os=-bsd
+		;;
+	-dynix*)
+		os=-bsd
+		;;
+	-acis*)
+		os=-aos
+		;;
+	-atheos*)
+		os=-atheos
+		;;
+	-syllable*)
+		os=-syllable
+		;;
+	-386bsd)
+		os=-bsd
+		;;
+	-ctix* | -uts*)
+		os=-sysv
+		;;
+	-nova*)
+		os=-rtmk-nova
+		;;
+	-ns2 )
+		os=-nextstep2
+		;;
+	-nsk*)
+		os=-nsk
+		;;
+	# Preserve the version number of sinix5.
+	-sinix5.*)
+		os=`echo $os | sed -e 's|sinix|sysv|'`
+		;;
+	-sinix*)
+		os=-sysv4
+		;;
+        -tpf*)
+		os=-tpf
+		;;
+	-triton*)
+		os=-sysv3
+		;;
+	-oss*)
+		os=-sysv3
+		;;
+	-svr4)
+		os=-sysv4
+		;;
+	-svr3)
+		os=-sysv3
+		;;
+	-sysvr4)
+		os=-sysv4
+		;;
+	# This must come after -sysvr4.
+	-sysv*)
+		;;
+	-ose*)
+		os=-ose
+		;;
+	-es1800*)
+		os=-ose
+		;;
+	-xenix)
+		os=-xenix
+		;;
+	-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+		os=-mint
+		;;
+	-aros*)
+		os=-aros
+		;;
+	-kaos*)
+		os=-kaos
+		;;
+	-none)
+		;;
+	*)
+		# Get rid of the `-' at the beginning of $os.
+		os=`echo $os | sed 's/[^-]*-//'`
+		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+		exit 1
+		;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+	*-acorn)
+		os=-riscix1.2
+		;;
+	arm*-rebel)
+		os=-linux
+		;;
+	arm*-semi)
+		os=-aout
+		;;
+    c4x-* | tic4x-*)
+        os=-coff
+        ;;
+	# This must come before the *-dec entry.
+	pdp10-*)
+		os=-tops20
+		;;
+	pdp11-*)
+		os=-none
+		;;
+	*-dec | vax-*)
+		os=-ultrix4.2
+		;;
+	m68*-apollo)
+		os=-domain
+		;;
+	i386-sun)
+		os=-sunos4.0.2
+		;;
+	m68000-sun)
+		os=-sunos3
+		# This also exists in the configure program, but was not the
+		# default.
+		# os=-sunos4
+		;;
+	m68*-cisco)
+		os=-aout
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
+	or32-*)
+		os=-coff
+		;;
+	*-tti)	# must be before sparc entry or we get the wrong os.
+		os=-sysv3
+		;;
+	sparc-* | *-sun)
+		os=-sunos4.1.1
+		;;
+	*-be)
+		os=-beos
+		;;
+	*-ibm)
+		os=-aix
+		;;
+	*-wec)
+		os=-proelf
+		;;
+	*-winbond)
+		os=-proelf
+		;;
+	*-oki)
+		os=-proelf
+		;;
+	*-hp)
+		os=-hpux
+		;;
+	*-hitachi)
+		os=-hiux
+		;;
+	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+		os=-sysv
+		;;
+	*-cbm)
+		os=-amigaos
+		;;
+	*-dg)
+		os=-dgux
+		;;
+	*-dolphin)
+		os=-sysv3
+		;;
+	m68k-ccur)
+		os=-rtu
+		;;
+	m88k-omron*)
+		os=-luna
+		;;
+	*-next )
+		os=-nextstep
+		;;
+	*-sequent)
+		os=-ptx
+		;;
+	*-crds)
+		os=-unos
+		;;
+	*-ns)
+		os=-genix
+		;;
+	i370-*)
+		os=-mvs
+		;;
+	*-next)
+		os=-nextstep3
+		;;
+	*-gould)
+		os=-sysv
+		;;
+	*-highlevel)
+		os=-bsd
+		;;
+	*-encore)
+		os=-bsd
+		;;
+	*-sgi)
+		os=-irix
+		;;
+	*-siemens)
+		os=-sysv4
+		;;
+	*-masscomp)
+		os=-rtu
+		;;
+	f30[01]-fujitsu | f700-fujitsu)
+		os=-uxpv
+		;;
+	*-rom68k)
+		os=-coff
+		;;
+	*-*bug)
+		os=-coff
+		;;
+	*-apple)
+		os=-macos
+		;;
+	*-atari*)
+		os=-mint
+		;;
+	*)
+		os=-none
+		;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+	*-unknown)
+		case $os in
+			-riscix*)
+				vendor=acorn
+				;;
+			-sunos*)
+				vendor=sun
+				;;
+			-aix*)
+				vendor=ibm
+				;;
+			-beos*)
+				vendor=be
+				;;
+			-hpux*)
+				vendor=hp
+				;;
+			-mpeix*)
+				vendor=hp
+				;;
+			-hiux*)
+				vendor=hitachi
+				;;
+			-unos*)
+				vendor=crds
+				;;
+			-dgux*)
+				vendor=dg
+				;;
+			-luna*)
+				vendor=omron
+				;;
+			-genix*)
+				vendor=ns
+				;;
+			-mvs* | -opened*)
+				vendor=ibm
+				;;
+			-os400*)
+				vendor=ibm
+				;;
+			-ptx*)
+				vendor=sequent
+				;;
+			-tpf*)
+				vendor=ibm
+				;;
+			-vxsim* | -vxworks* | -windiss*)
+				vendor=wrs
+				;;
+			-aux*)
+				vendor=apple
+				;;
+			-hms*)
+				vendor=hitachi
+				;;
+			-mpw* | -macos*)
+				vendor=apple
+				;;
+			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+				vendor=atari
+				;;
+			-vos*)
+				vendor=stratus
+				;;
+		esac
+		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+		;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:


Property changes on: spike/wktraster/config.sub
___________________________________________________________________
Name: svn:executable
   + *

Added: spike/wktraster/configure.ac
===================================================================
--- spike/wktraster/configure.ac	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/configure.ac	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,503 @@
+dnl **********************************************************************
+dnl * $Id: configure.ac 2797 2008-05-31 09:56:44Z mcayland $
+dnl *
+dnl * PostGIS - Spatial Types for PostgreSQL
+dnl * http://postgis.refractions.net
+dnl * Copyright 2008 Mark Cave-Ayland
+dnl *
+dnl * This is free software; you can redistribute and/or modify it under
+dnl * the terms of the GNU General Public Licence. See the COPYING file.
+dnl *
+dnl **********************************************************************
+
+AC_INIT()
+AC_CONFIG_HEADERS([wktraster_config.h])
+AC_CONFIG_MACRO_DIR([macros])
+
+dnl Invoke libtool: we do this as it is the easiest way to find the PIC
+dnl flags required to build the libs
+AC_PROG_LIBTOOL
+
+dnl
+dnl Compilers
+dnl
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_CXX
+
+dnl
+dnl Define PIC flags in PICFLAGS
+dnl (note: this variable is set as part of libtool initialisation above)
+dnl
+PICFLAGS="$lt_prog_compiler_pic"
+AC_SUBST([PICFLAGS])
+
+dnl
+dnl For GCC enable additional warning flags
+dnl -Wall and -Wmissing-prototypes (using macro included with libtool)
+dnl
+WARNFLAGS=""
+AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -Wall],
+    [dummy], [-Wall], [], [WARNFLAGS="$WARNFLAGS -Wall"], []) 
+AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -Wmissing-prototypes],
+    [dummy], [-Wmissing-prototypes], [],
+    [WARNFLAGS="$WARNFLAGS -Wmissing-prototypes"], []) 
+AC_SUBST([WARNFLAGS])
+
+dnl
+dnl Define executable suffix for use with the loader Makefiles
+dnl
+EXESUFFIX="$ac_cv_exeext"
+AC_SUBST([EXESUFFIX])
+
+dnl
+dnl Version Information imported from Version.config 
+dnl
+RT_MAJOR_VERSION=`cat Version.config | grep RT_MAJOR_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'`
+RT_MINOR_VERSION=`cat Version.config | grep RT_MINOR_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'`
+RT_MICRO_VERSION=`cat Version.config | grep RT_MICRO_VERSION | sed 's/[[^=]]*=\([[0-9]]\)/\1/g'`
+
+AC_DEFINE_UNQUOTED([RT_MAJOR_VERSION], ["$RT_MAJOR_VERSION"], [PostGIS major version])
+AC_DEFINE_UNQUOTED([RT_MINOR_VERSION], ["$RT_MINOR_VERSION"], [PostGIS minor version])
+AC_DEFINE_UNQUOTED([RT_MICRO_VERSION], ["$RT_MICRO_VERSION"], [PostGIS micro version])
+
+AC_SUBST([RT_MAJOR_VERSION])
+AC_SUBST([RT_MINOR_VERSION])
+AC_SUBST([RT_MICRO_VERSION])
+
+dnl
+dnl Search for flex/bison to build the parser
+dnl
+
+AC_PROG_LEX
+AC_PROG_YACC
+AC_SUBST([LEX])
+AC_SUBST([YACC])
+
+
+dnl ===========================================================================
+dnl Find components needed to build documentation
+dnl ===========================================================================
+dnl
+dnl Search for xsltproc which is required for building documentation
+dnl
+
+AC_PATH_PROG([XSLTPROC], [xsltproc], [])
+if test "x$XSLTPROC" = "x"; then
+	AC_MSG_WARN([xsltproc is not installed so documentation cannot be built])
+fi
+
+dnl
+dnl Search for db2pdf which is required for building PDF documentation
+dnl
+
+AC_PATH_PROG([DB2PDF], [db2pdf], [])
+if test "x$DB2PDF" = "x"; then
+	AC_MSG_WARN([db2pdf is not installed so PDF documentation cannot be built])
+fi
+
+dnl
+dnl Search for dblatex which is required for building PDF documentation
+dnl
+
+AC_PATH_PROG([DBLATEX], [dblatex], [])
+if test "x$DBLATEX" = "x"; then
+	AC_MSG_WARN([dblatex is not installed so PDF documentation cannot be built])
+fi
+
+dnl
+dnl Allow the user to specify the location of the html/docbook.xsl stylesheet
+dnl
+
+AC_ARG_WITH([xsldir], 
+	[AS_HELP_STRING([--with-xsldir=PATH], [specify the directory containing the docbook.xsl stylesheet])], 
+	[XSLBASE="$withval"], [XSLBASE=""])
+
+XSLBASE_AUTO=""
+if test "x$XSLBASE" = "x"; then
+	dnl If the user did not specify a directory for the docbook 
+	dnl stylesheet, choose the first directory
+	dnl that matches from the following list
+	SEARCHPATH="
+		/usr/share/sgml/docbook/xsl-stylesheets 
+		/usr/share/xml/docbook/stylesheet/nwalsh
+		/usr/share/sgml/docbook/stylesheet/xsl/nwalsh
+		"
+	for p in ${SEARCHPATH}; do
+		if test -r "${p}"/html/docbook.xsl; then
+			XSLBASE_AUTO="${p}"
+			break
+		fi
+	done
+
+	dnl Check to see if the automatically searched paths above located a 
+	dnl valid Docbook stylesheet
+	if test "x$XSLBASE_AUTO" = "x"; then
+		AC_MSG_WARN([could not locate Docbook stylesheets required to build the documentation])
+	fi
+else
+	dnl The user specified an alternate directory so make sure everything 
+	dnl looks sensible
+	if test ! -d "$XSLBASE"; then
+		AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not exist])
+	fi 
+
+	if test ! -f "$XSLBASE/html/docbook.xsl"; then
+		AC_MSG_ERROR([the docbook stylesheet directory specified using --with-xsldir does not contain the html/docbook.xsl file])
+	fi
+fi
+
+dnl
+dnl If XSLBASE has been set then at this point we know it must be 
+dnl valid and so we can just use it. If XSLBASE_AUTO has been set, and XSLBASE
+dnl is empty then a valid stylesheet was found in XSLBASE_AUTO so we 
+dnl should use that. Otherwise just continue silently with a blank XSLBASE
+dnl variable which will trigger the error message in the documentation Makefile
+dnl
+
+if test "x$XSLBASE" = "x"; then
+	if test ! "x$XSLBASE_AUTO" = "x"; then
+		XSLBASE="$XSLBASE_AUTO"
+	fi
+fi
+
+AC_SUBST([XSLBASE])
+
+
+dnl ===========================================================================
+dnl Detect CUnit if it is installed (used for unit testing)
+dnl
+dnl Note that we pass any specified CPPFLAGS and LDFLAGS into the Makefile 
+dnl as CUnit is the only compile-time dependency that cannot obtain any 
+dnl specialised flags using a --with-X parameter, and so we allow this 
+dnl information to be passed in if required.
+dnl ===========================================================================
+
+CUNIT_LDFLAGS=""
+AC_CHECK_HEADER([CUnit/CUnit.h], [
+	CUNIT_CPPFLAGS="$CPPFLAGS"
+	AC_CHECK_LIB([cunit], [CU_initialize_registry], [CUNIT_LDFLAGS="$LDFLAGS -lcunit"], [AC_MSG_WARN([could not locate CUnit required for liblwgeom unit tests])])
+	],
+	[
+	AC_MSG_WARN([could not locate CUnit required for liblwgeom unit tests])
+	])
+	
+AC_SUBST([CUNIT_CPPFLAGS])
+AC_SUBST([CUNIT_LDFLAGS])
+
+
+dnl ===========================================================================
+dnl Detect iconv if it is installed (used for shp2pgsql encoding conversion 
+dnl if available)
+dnl ===========================================================================
+
+HAVE_ICONV_H=0
+AC_CHECK_HEADER([iconv.h], [HAVE_ICONV_H=1], [])
+
+dnl If we find the header file, try and link against the library
+if test "x$HAVE_ICONV_H" != "x0"; then
+	dnl Check for iconv includes as part of libc
+	AC_CHECK_LIB([c], [iconv_open], [ICONV_LDFLAGS=-lc HAVE_ICONV=1], [])
+	if test "x$HAVE_ICONV" = "x"; then
+		dnl If not found, check for iconv included as part of libiconv
+		AC_CHECK_LIB([iconv], [iconv_open], [ICONV_LDFLAGS=-liconv HAVE_ICONV=1], [])
+		if test "x$HAVE_ICONV" = "x"; then
+			dnl If not found, check for Win32 iconv (some of them use a lib prefix for functions within the iconv DLLs)
+			AC_CHECK_LIB([iconv], [libiconv_open], [ICONV_LDFLAGS=-liconv HAVE_ICONV=1], [])
+			if test "x$HAVE_ICONV" = "x"; then
+				dnl No iconv library was found; issue a warning to the console
+				AC_MSG_WARN([could not find iconv library: no support for encoding conversion will be included])
+			fi
+		fi	
+	fi
+else
+	dnl No iconv header was found; issue a warning to the console
+	AC_MSG_WARN([could not find iconv.h header: no support for encoding conversion will be included])
+fi
+
+
+dnl Only define HAVE_ICONV in postgis_config.h if we detect iconv sucessfully
+if test "x$HAVE_ICONV" != "x"; then
+	AC_DEFINE_UNQUOTED([HAVE_ICONV], [$HAVE_ICONV], [Defined if libiconv headers and library are present])
+fi
+
+AC_SUBST([ICONV_LDFLAGS])
+
+
+dnl ===========================================================================
+dnl Detect the version of PostgreSQL installed on the system
+dnl ===========================================================================
+
+AC_ARG_WITH([pgconfig], 
+	[AS_HELP_STRING([--with-pgconfig=FILE], [specify an alternative pg_config file])], 
+	[PGCONFIG="$withval"], [PGCONFIG=""])
+
+if test "x$PGCONFIG" = "x"; then
+	dnl PGCONFIG was not specified, so search within the current path
+	AC_PATH_PROG([PGCONFIG], [pg_config])
+
+	dnl If we couldn't find pg_config, display an error
+	if test "x$PGCONFIG" = "x"; then
+		AC_MSG_ERROR([could not find pg_config within the current path. You may need to try re-running configure with a --with-pgconfig parameter.])
+	fi
+else
+	dnl PGCONFIG was specified; display a message to the user
+	if test "x$PGCONFIG" = "xyes"; then
+		AC_MSG_ERROR([you must specify a parameter to --with-pgconfig, e.g. --with-pgconfig=/path/to/pg_config])
+	else
+		if test -f $PGCONFIG; then
+			AC_MSG_RESULT([Using user-specified pg_config file: $PGCONFIG])
+		else
+			AC_MSG_ERROR([the user-specified pg_config file $PGCONFIG does not exist])
+		fi
+	fi
+fi
+
+
+dnl ===========================================================================
+dnl Ensure that $PG_CONFIG --pgxs points to a valid file. This is because some 
+dnl distributions such as Debian also include pg_config as part of libpq-dev 
+dnl packages, but don't install the Makefile it points to unless
+dnl the postgresql-server-dev packages are installed :)
+dnl ===========================================================================
+
+PGXS=`$PGCONFIG --pgxs`
+if test ! -f $PGXS; then
+	AC_MSG_ERROR([the PGXS Makefile $PGXS cannot be found. Please install the PostgreSQL server development packages and re-run configure.])
+fi
+
+AC_SUBST([PGXS])
+
+
+dnl Extract the version information from pg_config
+dnl Note: we extract the major & minor separately, ensure they are numeric, and then combine to give
+dnl the final version. This is to guard against user error... 
+PGSQL_MAJOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f1 | sed 's/[[^0-9]]//g'`	
+PGSQL_MINOR_VERSION=`$PGCONFIG --version | sed 's/[[A-Za-z ]]*//' | cut -d. -f2 | sed 's/[[^0-9]]//g'`	
+RT_PGSQL_VERSION="$PGSQL_MAJOR_VERSION$PGSQL_MINOR_VERSION"
+
+dnl Ensure that we are using PostgreSQL >= 8.1
+if test ! "$PGSQL_MAJOR_VERSION" -ge 8; then
+	AC_MSG_ERROR([PostGIS requires PostgreSQL >= 8.1])
+else
+	if test "$PGSQL_MAJOR_VERSION" -eq 8; then
+		if test ! "$PGSQL_MINOR_VERSION" -ge 1; then
+			AC_MSG_ERROR([PostGIS requires PostgreSQL >= 8.1])
+		fi	
+	fi
+fi	
+
+dnl Note: We don't need the server-side LDFLAGS or CPPFLAGS because we get these from PGXS 
+
+dnl Extract the linker and include flags for the frontend (for programs that use libpq)
+PGSQL_FE_LDFLAGS=-L`$PGCONFIG --libdir`" -lpq"
+PGSQL_FE_CPPFLAGS=-I`$PGCONFIG --includedir`
+
+AC_SUBST([PGSQL_FE_LDFLAGS])
+AC_SUBST([PGSQL_FE_CPPFLAGS])
+
+dnl Extract the documentation and man page directories
+PGSQL_DOCDIR=`$PGCONFIG --docdir`
+PGSQL_MANDIR=`$PGCONFIG --mandir`
+
+AC_SUBST([PGSQL_DOCDIR])
+AC_SUBST([PGSQL_MANDIR])
+
+dnl Extract the executable directory
+PGSQL_BINDIR=`$PGCONFIG --bindir`
+
+AC_SUBST([PGSQL_BINDIR])
+
+
+dnl Ensure that we can parse libpq-fe.h
+CPPFLAGS_SAVE="$CPPFLAGS"
+CPPFLAGS="$PGSQL_FE_CPPFLAGS"
+AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([could not find libpq-fe.h])])
+CPPFLAGS="$CPPFLAGS_SAVE"
+
+dnl Ensure we can link against libpq
+LIBS_SAVE="$LIBS"
+LIBS="$PGSQL_FE_LDFLAGS"
+AC_CHECK_LIB([pq], [PQserverVersion],
+	[],
+	[AC_MSG_ERROR([could not find libpq])],
+	[])
+LIBS="$LIBS_SAVE"
+
+AC_DEFINE_UNQUOTED([RT_PGSQL_VERSION], [$RT_PGSQL_VERSION], [PostgreSQL server version])	
+AC_SUBST([RT_PGSQL_VERSION])
+
+dnl ===========================================================================
+dnl Find postgis sources, as we rely on liblwgeom
+dnl ===========================================================================
+
+POSTGIS_SRCDIR=""
+AC_ARG_WITH([postgis-sources],
+    [AC_HELP_STRING([--with-postgis-sources=DIR],
+        [specify location of postgis sources])],
+    [POSTGIS_SRCDIR="$withval"], [POSTGIS_SRCDIR=""])
+
+if test ! -f "$POSTGIS_SRCDIR/liblwgeom/liblwgeom.h"; then
+    AC_MSG_ERROR([Please specify --with-postgis-sources=DIR so that DIR contains the liblwgeom/liblwgeom.h file])
+fi
+
+AC_SUBST([POSTGIS_SRCDIR])
+
+
+dnl ===========================================================================
+dnl Detect the version of GEOS installed on the system
+dnl ===========================================================================
+
+AC_ARG_WITH([geosconfig], 
+	[AS_HELP_STRING([--with-geosconfig=FILE], [specify an alternative geos-config file])], 
+	[GEOSCONFIG="$withval"], [GEOSCONFIG=""])
+
+if test "x$GEOSCONFIG" = "x"; then
+	dnl GEOSCONFIG was not specified, so search within the current path
+	AC_PATH_PROG([GEOSCONFIG], [geos-config])
+
+	dnl If we couldn't find geos-config, display an error
+	if test "x$GEOSCONFIG" = "x"; then
+		AC_MSG_ERROR([could not find geos-config within the current path. You may need to try re-running configure with a --with-geosconfig parameter.])
+	fi
+else
+	dnl GEOSCONFIG was specified; display a message to the user
+	if test "x$GEOSCONFIG" = "xyes"; then
+		AC_MSG_ERROR([you must specify a parameter to --with-geosconfig, e.g. --with-geosconfig=/path/to/geos-config])
+	else
+		if test -f $GEOSCONFIG; then
+			AC_MSG_RESULT([Using user-specified geos-config file: $GEOSCONFIG])
+		else
+			AC_MSG_ERROR([the user-specified geos-config file $GEOSCONFIG does not exist])
+		fi	
+	fi
+fi
+
+dnl Extract the version information from geos_config
+dnl Note: we extract the major & minor separately, ensure they are numeric, 
+dnl and then combine to give the final version. 
+dnl This is to guard against user error... 
+GEOS_MAJOR_VERSION=`$GEOSCONFIG --version | cut -d. -f1 | sed 's/[[^0-9]]//g'`
+GEOS_MINOR_VERSION=`$GEOSCONFIG --version | cut -d. -f2 | sed 's/[[^0-9]]//g'`
+RT_GEOS_VERSION="$GEOS_MAJOR_VERSION$GEOS_MINOR_VERSION"
+
+dnl Ensure that we are using GEOS >= 2.2.0 (requires CAPI) 
+if test ! "$GEOS_MAJOR_VERSION" -ge 2; then
+	AC_MSG_ERROR([PostGIS requires GEOS >= 2.2])
+else
+	if test "$GEOS_MAJOR_VERSION" -eq 2; then
+		if test ! "$GEOS_MINOR_VERSION" -ge 2; then
+			AC_MSG_ERROR([PostGIS requires GEOS >= 2.2])
+		fi
+	fi
+fi	
+
+dnl Extract the linker and include flags 
+GEOS_LDFLAGS=`$GEOSCONFIG --ldflags`
+GEOS_CPPFLAGS=-I`$GEOSCONFIG --includes`
+
+dnl Ensure that we can parse geos_c.h
+CPPFLAGS_SAVE="$CPPFLAGS"
+CPPFLAGS="$GEOS_CPPFLAGS"
+AC_CHECK_HEADER([geos_c.h], [], [AC_MSG_ERROR([could not find geos_c.h - you may need to specify the directory of a geos-config file using --with-geosconfig])])
+CPPFLAGS="$CPPFLAGS_SAVE"
+
+dnl Ensure we can link against libgeos_c
+LIBS_SAVE="$LIBS"
+LIBS="$GEOS_LDFLAGS"
+AC_CHECK_LIB([geos_c], [initGEOS],
+	[],
+	[AC_MSG_ERROR([could not find libgeos_c - you may need to specify the directory of a geos-config file using --with-geosconfig])],
+	[])
+LIBS="$LIBS_SAVE"
+
+AC_DEFINE_UNQUOTED([RT_GEOS_VERSION], [$RT_GEOS_VERSION], [GEOS library version])	
+AC_SUBST([RT_GEOS_VERSION])
+
+
+dnl ===========================================================================
+dnl Detect the version of PROJ.4 installed
+dnl ===========================================================================
+
+AC_ARG_WITH([projdir], 
+	[AS_HELP_STRING([--with-projdir=PATH], [specify the PROJ.4 installation directory])], 
+	[PROJDIR="$withval"], [PROJDIR=""])
+
+if test ! "x$PROJDIR" = "x"; then
+	dnl Make sure that the directory exists 
+	if test "x$PROJDIR" = "xyes"; then
+		AC_MSG_ERROR([you must specifiy a parameter to --with-projdir, e.g. --with-projdir=/path/to])
+	else
+		if test -d "$PROJDIR"; then
+			AC_MSG_RESULT([Using user-specified proj directory: $PROJDIR])
+
+			dnl Add the include directory to PROJ_CPPFLAGS	
+			PROJ_CPPFLAGS="-I$PROJDIR/include"	
+			PROJ_LDFLAGS="-L$PROJDIR/lib"
+		else
+			AC_MSG_ERROR([the --with-projdir directory "$PROJDIR" cannot be found]) 
+		fi
+	fi
+fi
+
+
+dnl Check that we can find the proj_api.h header file
+CPPFLAGS_SAVE="$CPPFLAGS"
+CPPFLAGS="$PROJ_CPPFLAGS"
+AC_CHECK_HEADER([proj_api.h], [], [AC_MSG_ERROR([could not find proj_api.h - you may need to specify the directory of a PROJ.4 installation using --with-projdir])])	
+
+dnl Return the PROJ.4 version number
+AC_PROJ_VERSION([RT_PROJ_VERSION])
+AC_DEFINE_UNQUOTED([RT_PROJ_VERSION], [$RT_PROJ_VERSION], [PROJ library version])
+AC_SUBST([RT_PROJ_VERSION])
+CPPFLAGS="$CPPFLAGS_SAVE"
+
+dnl Ensure that we are using PROJ >= 4.5.0 (requires pj_set_searchpath) 
+if test ! "$RT_PROJ_VERSION" -ge 45; then
+	AC_MSG_ERROR([PostGIS requires PROJ >= 4.5.0])
+fi
+
+dnl Ensure we can link against libproj
+LIBS_SAVE="$LIBS"
+LIBS="$PROJ_LDFLAGS"
+AC_CHECK_LIB([proj], [pj_get_release],
+	[],
+	[AC_MSG_ERROR([could not find libproj - you may need to specify the directory of a PROJ.4 installation using --with-projdir])],
+	[])
+LIBS="$LIBS_SAVE"
+
+
+dnl ===========================================================================
+dnl Define version macros
+dnl
+
+RT_VERSION="$RT_MAJOR_VERSION.$RT_MINOR_VERSION USE_GEOS=1 USE_PROJ=1 USE_STATS=1"
+RT_LIB_VERSION="$RT_MAJOR_VERSION.$RT_MINOR_VERSION.$RT_MICRO_VERSION"
+RT_BUILD_DATE=`date -u "+%Y-%m-%d %H:%M:%S"`
+RT_SCRIPTS_VERSION="$RT_LIB_VERSION"
+
+AC_DEFINE_UNQUOTED([RT_VERSION], ["$RT_VERSION"], [PostGIS version])
+AC_DEFINE_UNQUOTED([RT_LIB_VERSION], ["$RT_LIB_VERSION"], [PostGIS library version])
+AC_DEFINE_UNQUOTED([RT_BUILD_DATE], ["$RT_BUILD_DATE"], [PostGIS build date])
+AC_DEFINE_UNQUOTED([RT_SCRIPTS_VERSION], ["$RT_SCRIPTS_VERSION"], [PostGIS scripts version])
+
+AC_SUBST([RT_VERSION])
+AC_SUBST([RT_LIB_VERSION])
+AC_SUBST([RT_BUILD_DATE])
+AC_SUBST([RT_SCRIPTS_VERSION])
+
+
+dnl ===========================================================================
+dnl Other parameters 
+dnl
+
+CPPFLAGS="$PGSQL_CPPFLAGS $GEOS_CPPFLAGS $PROJ_CPPFLAGS"
+dnl AC_MSG_RESULT([CPPFLAGS: $CPPFLAGS])
+
+SHLIB_LINK="$PGSQL_LDFLAGS $GEOS_LDFLAGS $PROJ_LDFLAGS -lgeos_c -lproj"
+AC_SUBST([SHLIB_LINK])
+dnl AC_MSG_RESULT([SHLIB_LINK: $SHLIB_LINK])
+
+dnl Output the relevant files
+AC_OUTPUT([rt_core/Makefile rt_pg/Makefile])
+

Added: spike/wktraster/doc/RASTER_WKB
===================================================================
--- spike/wktraster/doc/RASTER_WKB	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/doc/RASTER_WKB	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,92 @@
+Well Known Binary format for RASTER type
+----------------------------------------
+
+// Basic Type definitions
+// byte : 1 byte
+// uint16 : 16 bit unsigned integer (2 bytes)
+// uint32 : 32 bit unsigned integer (4 bytes)
+// float16 : single precision floating point number (4 bytes)
+// float32 : double precision floating point number (8 bytes)
+
+ +-----------------------------------------------------------------+
+ | RASTERBAND                                                      |
+ +---------------+-------------+-----------------------------------+
+ | - name -      |  - type -   | - meaning -                       |
+ +---------------+-------------+-----------------------------------+
+ | pixtype       | byte        | 0: 1-bit boolean                  |
+ |               |             | 1: 2-bit unsigned integer         |
+ |               |             | 2: 4-bit unsigned integer         |
+ |               |             | 3: 8-bit signed integer           |
+ |               |             | 4: 8-bit unsigned integer         |
+ |               |             | 5: 16-bit signed integer          |
+ |               |             | 6: 16-bit unsigned signed integer |
+ |               |             | 7: 32-bit signed integer          |
+ |               |             | 8: 32-bit unsigned signed integer |
+ |               |             | 9: 16-bit float                   |
+ |               |             | 10: 32-bit float                  |
+ |               |             | 11: 64-bit float                  |
+ |               |             | 12: path string (null-terminated) |
+ +---------------+-------------+-----------------------------------+
+ | data          | RASTERDATA  | polymorphic data (see below)      |
+ +---------------+-------------+-----------------------------------+
+
+ +-----------------------------------------------------------------+
+ | RASTERDATA (pixtype != path string)                             |
+ +---------------+-------------+-----------------------------------+
+ | nodata        | (pixtype)   | Nodata value                      |
+ +---------------+-------------+-----------------------------------+
+ | pix[w*h]      | (pixtype)   | Pixels values, row after row,     |
+ |               |             | so pix[0] is upper-left, pix[w-1] |
+ |               |             | is upper-right.                   |
+ |               |             |                                   |
+ |               |             | As for endiannes, it is specified |
+ |               |             | at the start of WKB, and implicit |
+ |               |             | up to 8bits (bit-order is most    |
+ |               |             | significant first)                |
+ |               |             |                                   |
+ +---------------+-------------+-----------------------------------+
+
+ +-----------------------------------------------------------------+
+ | RASTERDATA (pixtype == path string)                             |
+ +---------------+-------------+-----------------------------------+
+ | path          | string      | null-terminated path to data file |
+ +---------------+-------------+-----------------------------------+
+
+ // Raster format
+
+ +------------------------------------------------------------+
+ | RASTER                                                     |
+ +---------------+-------------+------------------------------+
+ | - name -      |  - type -   | - meaning -                  |
+ +---------------+-------------+------------------------------+
+ | endiannes     | byte        | 0:ndr/le                     |
+ |               |             | 1:xdr/be                     |
+ +---------------+-------------+------------------------------+
+ | width         | uint16      | number of pixel columns      |
+ +---------------+-------------+------------------------------+
+ | height        | uint16      | number of pixel rows         |
+ +---------------+-------------+------------------------------+
+ | scaleX        | float16     | pixel width                  |
+ |               |             | in geographical units        |
+ +---------------+-------------+------------------------------+
+ | scaleY        | float16     | pixel height                 |
+ |               |             | in geographical units        |
+ +---------------+-------------+------------------------------+
+ | ipX           | float16     | X ordinate of upper-left     |
+ |               |             | pixel's center               |
+ |               |             | in geographical units        |
+ +---------------+-------------+------------------------------+
+ | ipY           | float16     | Y ordinate of upper-left     |
+ |               |             | pixel's center               |
+ |               |             | in geographical units        |
+ +---------------+-------------+------------------------------+
+ | skewX         | float16     | rotation about Y-axis        |
+ +---------------+-------------+------------------------------+
+ | skewY         | float16     | rotation about X-axis        |
+ +---------------+-------------+------------------------------+
+ | srid          | int32       | Spatial reference id         |
+ +---------------+-------------+------------------------------+
+ | nBands        | int32 (?)   | Number of bands              |
+ +---------------+-------------+------------------------------+
+ | bands[nBands] | RASTERBAND  | Bands data                   |
+ +---------------+-------------+------------------------------+

Added: spike/wktraster/install-sh
===================================================================
--- spike/wktraster/install-sh	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/install-sh	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,325 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2004-04-01.17
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=
+transform_arg=
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=
+chgrpcmd=
+stripcmd=
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=
+dst=
+dir_arg=
+
+usage="Usage: $0 [OPTION]... SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 -d DIRECTORIES...
+
+In the first form, install SRCFILE to DSTFILE, removing SRCFILE by default.
+In the second, create the directory path DIR.
+
+Options:
+-b=TRANSFORMBASENAME
+-c         copy source (using $cpprog) instead of moving (using $mvprog).
+-d         create directories instead of installing files.
+-g GROUP   $chgrp installed files to GROUP.
+-m MODE    $chmod installed files to MODE.
+-o USER    $chown installed files to USER.
+-s         strip installed files (using $stripprog).
+-t=TRANSFORM
+--help     display this help and exit.
+--version  display version info and exit.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
+"
+
+while test -n "$1"; do
+  case $1 in
+    -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+        shift
+        continue;;
+
+    -c) instcmd=$cpprog
+        shift
+        continue;;
+
+    -d) dir_arg=true
+        shift
+        continue;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+        shift
+        shift
+        continue;;
+
+    --help) echo "$usage"; exit 0;;
+
+    -m) chmodcmd="$chmodprog $2"
+        shift
+        shift
+        continue;;
+
+    -o) chowncmd="$chownprog $2"
+        shift
+        shift
+        continue;;
+
+    -s) stripcmd=$stripprog
+        shift
+        continue;;
+
+    -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+        shift
+        continue;;
+
+    --version) echo "$0 $scriptversion"; exit 0;;
+
+    *)  # When -d is used, all remaining arguments are directories to create.
+	test -n "$dir_arg" && break
+        # Otherwise, the last argument is the destination.  Remove it from $@.
+	for arg
+	do
+          if test -n "$dstarg"; then
+	    # $@ is not empty: it contains at least $arg.
+	    set fnord "$@" "$dstarg"
+	    shift # fnord
+	  fi
+	  shift # arg
+	  dstarg=$arg
+	done
+	break;;
+  esac
+done
+
+if test -z "$1"; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src ;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    src=
+
+    if test -d "$dst"; then
+      instcmd=:
+      chmodcmd=
+    else
+      instcmd=$mkdirprog
+    fi
+  else
+    # Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dstarg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dstarg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst ;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      dst=$dst/`basename "$src"`
+    fi
+  fi
+
+  # This sed command emulates the dirname command.
+  dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+  # Make sure that the destination directory exists.
+
+  # Skip lots of stat calls in the usual case.
+  if test ! -d "$dstdir"; then
+    defaultIFS='
+	 '
+    IFS="${IFS-$defaultIFS}"
+
+    oIFS=$IFS
+    # Some sh's can't handle IFS=/ for some reason.
+    IFS='%'
+    set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+    IFS=$oIFS
+
+    pathcomp=
+
+    while test $# -ne 0 ; do
+      pathcomp=$pathcomp$1
+      shift
+      if test ! -d "$pathcomp"; then
+        $mkdirprog "$pathcomp" || lasterr=$?
+	# mkdir can fail with a `File exist' error in case several
+	# install-sh are creating the directory concurrently.  This
+	# is OK.
+	test ! -d "$pathcomp" && { (exit ${lasterr-1}); exit; }
+      fi
+      pathcomp=$pathcomp/
+    done
+  fi
+
+  if test -n "$dir_arg"; then
+    $doit $instcmd "$dst" \
+      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
+      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
+      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
+      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
+
+  else
+    # If we're going to rename the final executable, determine the name now.
+    if test -z "$transformarg"; then
+      dstfile=`basename "$dst"`
+    else
+      dstfile=`basename "$dst" $transformbasename \
+               | sed $transformarg`$transformbasename
+    fi
+
+    # don't allow the sed command to completely eliminate the filename.
+    test -z "$dstfile" && dstfile=`basename "$dst"`
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
+    trap '(exit $?); exit' 1 2 13 15
+
+    # Move or copy the file name to the temp name
+    $doit $instcmd "$src" "$dsttmp" &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $instcmd $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
+      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
+      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
+      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
+
+    # Now rename the file to the real destination.
+    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
+      || {
+	   # The rename failed, perhaps because mv can't rename something else
+	   # to itself, or perhaps because mv is so ancient that it does not
+	   # support -f.
+
+	   # Now remove or move aside any old file at destination location.
+	   # We try this two ways since rm can't unlink itself on some
+	   # systems and the destination file might be busy for other
+	   # reasons.  In this case, the final cleanup might fail but the new
+	   # file should still install successfully.
+	   {
+	     if test -f "$dstdir/$dstfile"; then
+	       $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
+	       || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
+	       || {
+		 echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+		 (exit 1); exit
+	       }
+	     else
+	       :
+	     fi
+	   } &&
+
+	   # Now rename the file to the real destination.
+	   $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+	 }
+    }
+  fi || { (exit 1); exit; }
+done
+
+# The final little trick to "correctly" pass the exit status to the exit trap.
+{
+  (exit 0); exit
+}
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:


Property changes on: spike/wktraster/install-sh
___________________________________________________________________
Name: svn:executable
   + *

Added: spike/wktraster/macros/ac_proj4_version.m4
===================================================================
--- spike/wktraster/macros/ac_proj4_version.m4	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/macros/ac_proj4_version.m4	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,42 @@
+dnl **********************************************************************
+dnl * $Id: ac_proj4_version.m4 2797 2008-05-31 09:56:44Z mcayland $
+dnl *
+dnl * PostGIS - Spatial Types for PostgreSQL
+dnl * http://postgis.refractions.net
+dnl * Copyright 2008 Mark Cave-Ayland
+dnl *
+dnl * This is free software; you can redistribute and/or modify it under
+dnl * the terms of the GNU General Public Licence. See the COPYING file.
+dnl *
+dnl **********************************************************************
+
+dnl
+dnl Return the PROJ.4 version number
+dnl
+
+AC_DEFUN([AC_PROJ_VERSION], [
+	AC_RUN_IFELSE(
+        	[AC_LANG_PROGRAM([
+		#ifdef HAVE_STDINT_H
+        		#include <stdio.h>
+		#endif
+		#include "proj_api.h"
+	], 
+	[
+		FILE *fp; 
+
+		fp = fopen("conftest.out", "w"); 
+		fprintf(fp, "%d\n", PJ_VERSION); 
+		fclose(fp)])
+	],
+        [
+		dnl The program ran successfully, so return the version number in the form MAJORMINOR
+		$1=`cat conftest.out | sed 's/\([[0-9]]\)\([[0-9]]\)\([[0-9]]\)/\1\2/'`
+	],
+        [
+		dnl The program failed so return an empty variable
+		$1=""
+	]
+        )
+])
+

Added: spike/wktraster/rt_core/Makefile
===================================================================
--- spike/wktraster/rt_core/Makefile	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_core/Makefile	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,36 @@
+# **********************************************************************
+# *
+# * WKTRaster - Raster Types for PostGIS
+# * http://www.postgis.org/support/wiki/index.php?WKTRasterHomePage
+# *
+# * Copyright (c) 2009 Sandro Santilli <strk at keybit.net>
+# *
+# * This is free software; you can redistribute and/or modify it under
+# * the terms of the GNU General Public Licence. See the COPYING file.
+# *
+# **********************************************************************
+
+LDFLAGS = -L/usr/src/postgis/trunk/liblwgeom -llwgeom 
+CFLAGS = -g -O2  -fPIC -DPIC  -Wall -Wmissing-prototypes -I/usr/src/postgis/trunk/liblwgeom
+
+# Standalone RTCORE objects
+RT_OBJS = \
+	rt_api.o 
+
+SA_HEADERS = \
+	rt_api.h
+
+all: librtcore.a
+
+clean:
+	rm -f testapi $(RT_OBJS)
+	rm -f librtcore.a 
+
+testapi: testapi.c rt_api.h rt_api.c
+	$(CC) $(CFLAGS) -o testapi testapi.c rt_api.c -lm $(LDFLAGS) 
+
+librtcore.a: $(RT_OBJS) $(RT_HEADERS)
+	ar rs librtcore.a $(RT_OBJS)
+
+check: testapi
+	./testapi

Added: spike/wktraster/rt_core/Makefile.in
===================================================================
--- spike/wktraster/rt_core/Makefile.in	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_core/Makefile.in	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,36 @@
+# **********************************************************************
+# *
+# * WKTRaster - Raster Types for PostGIS
+# * http://www.postgis.org/support/wiki/index.php?WKTRasterHomePage
+# *
+# * Copyright (c) 2009 Sandro Santilli <strk at keybit.net>
+# *
+# * This is free software; you can redistribute and/or modify it under
+# * the terms of the GNU General Public Licence. See the COPYING file.
+# *
+# **********************************************************************
+
+LDFLAGS = -L at POSTGIS_SRCDIR@/liblwgeom -llwgeom 
+CFLAGS = @CFLAGS@ @PICFLAGS@ @WARNFLAGS@ -I at POSTGIS_SRCDIR@/liblwgeom
+
+# Standalone RTCORE objects
+RT_OBJS = \
+	rt_api.o 
+
+SA_HEADERS = \
+	rt_api.h
+
+all: librtcore.a
+
+clean:
+	rm -f testapi $(RT_OBJS)
+	rm -f librtcore.a 
+
+testapi: testapi.c rt_api.h rt_api.c
+	$(CC) $(CFLAGS) -o testapi testapi.c rt_api.c -lm $(LDFLAGS) 
+
+librtcore.a: $(RT_OBJS) $(RT_HEADERS)
+	ar rs librtcore.a $(RT_OBJS)
+
+check: testapi
+	./testapi

Added: spike/wktraster/rt_core/rt_api.c
===================================================================
--- spike/wktraster/rt_core/rt_api.c	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_core/rt_api.c	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,1215 @@
+/* 
+ * WKTRaster - Raster Types for PostGIS
+ * http://www.postgis.org/support/wiki/index.php?WKTRasterHomePage
+ *
+ * Copyright (C) 2009  Sandro Santilli <strk at keybit.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <math.h>
+#include <stdio.h>  /* for printf (default message handler) */
+#include <stdarg.h> /* for va_list, va_start etc */
+#include <string.h> /* for memcpy */
+#include <assert.h>
+
+#include "rt_api.h"
+
+#define RT_API_DEBUG
+//#define RT_WARN_ON_TRUNCATION 
+
+/*- rt_context -------------------------------------------------------*/
+
+static void
+default_error_handler(const char *fmt, ...)
+{
+    va_list ap;
+
+    static const char *label = "ERROR: ";
+    char newfmt[1024];
+    snprintf(newfmt, 1024, "%s%s\n", label, fmt);
+    newfmt[1023] = '\0';
+
+    va_start(ap, fmt);
+
+    vprintf(newfmt, ap);
+
+    va_end(ap);
+}
+
+static void
+default_warning_handler(const char *fmt, ...)
+{
+    va_list ap;
+
+    static const char *label = "WARNING: ";
+    char newfmt[1024];
+    snprintf(newfmt, 1024, "%s%s\n", label, fmt);
+    newfmt[1023] = '\0';
+
+    va_start(ap, fmt);
+
+    vprintf(newfmt, ap);
+
+    va_end(ap);
+}
+
+static void
+default_info_handler(const char *fmt, ...)
+{
+    va_list ap;
+
+    static const char *label = "INFO: ";
+    char newfmt[1024];
+    snprintf(newfmt, 1024, "%s%s\n", label, fmt);
+    newfmt[1023] = '\0';
+
+    va_start(ap, fmt);
+
+    vprintf(newfmt, ap);
+
+    va_end(ap);
+}
+
+
+
+struct rt_context_t {
+    rt_allocator alloc;
+    rt_reallocator realloc;
+    rt_deallocator dealloc;
+    rt_message_handler err;
+    rt_message_handler warn;
+    rt_message_handler info;
+};
+
+rt_context
+rt_context_new(rt_allocator allocator, rt_reallocator reallocator,
+               rt_deallocator deallocator)
+{
+    rt_context ret;
+
+    if ( ! allocator ) allocator = malloc;
+    if ( ! reallocator ) reallocator = realloc;
+    if ( ! deallocator ) deallocator = free;
+
+    ret = (rt_context)allocator(sizeof(struct rt_context_t));
+    if ( ! ret ) {
+        default_error_handler("Out of virtual memory creating an rt_context");
+        return 0;
+    }
+#ifdef RT_API_DEBUG
+    default_info_handler("Created rt_context @ %p", ret);
+#endif
+    ret->alloc = allocator;
+    ret->realloc = reallocator;
+    ret->dealloc = deallocator;
+    ret->err = default_error_handler;
+    ret->warn = default_warning_handler;
+    ret->info = default_info_handler;
+    return ret;
+}
+
+void
+rt_context_set_message_handlers(rt_context ctx,
+        rt_message_handler error_handler,
+        rt_message_handler warning_handler,
+        rt_message_handler info_handler)
+{
+    ctx->err = error_handler;
+    ctx->warn = warning_handler;
+    ctx->info = info_handler;
+}
+
+void
+rt_context_destroy(rt_context ctx)
+{
+#ifdef RT_API_DEBUG
+    ctx->info("Destroying rt_context @ %p", ctx);
+#endif
+    ctx->dealloc(ctx);
+}
+
+/*- rt_pixeltype -----------------------------------------------------*/
+
+/* 
+ * #define TYPEALIGN(ALIGNVAL,LEN)  \
+ *      (((long) (LEN) + ((ALIGNVAL) - 1)) & ~((long) ((ALIGNVAL) - 1)))
+ */
+
+int
+rt_pixtype_alignment(rt_context ctx, rt_pixtype pixtype)
+{
+    switch (pixtype)
+    {
+        default:
+            ctx->err("Unknown pixeltype %d", pixtype);
+            return -1;
+        case PT_1BB:
+        case PT_2BUI:
+        case PT_4BUI:
+        case PT_8BSI:
+        case PT_8BUI:
+            return 1;
+        case PT_16BSI:
+        case PT_16BUI:
+        case PT_16BF:
+            return 2;
+        case PT_32BSI:
+        case PT_32BUI:
+        case PT_32BF:
+            return 4;
+        case PT_64BF:
+            return 8;
+    }
+
+}
+
+const char*
+rt_pixtype_name(rt_context ctx, rt_pixtype pixtype)
+{
+    switch (pixtype)
+    {
+        default:
+            ctx->err("Unknown pixeltype %d", pixtype);
+            return "Unknown";
+        case PT_1BB:
+            return "1BB";
+        case PT_2BUI:
+            return "2BUI";
+        case PT_4BUI:
+            return "4BUI";
+        case PT_8BSI:
+            return "8BSI";
+        case PT_8BUI:
+            return "8BUI";
+        case PT_16BSI:
+            return "16BSI";
+        case PT_16BUI:
+            return "16BUI";
+        case PT_32BSI:
+            return "32BSI";
+        case PT_32BUI:
+            return "32BUI";
+        case PT_16BF:
+            return "16BF";
+        case PT_32BF:
+            return "32BF";
+        case PT_64BF:
+            return "64BF";
+    }
+}
+
+/*- rt_band ----------------------------------------------------------*/
+
+struct rt_band_t {
+
+    rt_pixtype pixtype;
+    uint16_t width;
+    uint16_t height;
+    void* data; /* actual data, externally owned */
+
+};
+
+rt_band
+rt_band_new(rt_context ctx, rt_pixtype pixtype, uint16_t width,
+                  uint16_t height)
+{
+    rt_band band;
+    band = ctx->alloc(sizeof(struct rt_band_t));
+    if ( ! band )
+    {
+        ctx->err("Out of memory allocating rt_band");
+        return 0;
+    }
+
+#ifdef RT_API_DEBUG
+    ctx->info("Created rt_band @ %p with pixtype %s",
+        band, rt_pixtype_name(ctx, pixtype));
+#endif
+
+    band->pixtype = pixtype;
+    band->width = width;
+    band->height = height;
+    band->data = 0;
+
+    return band;
+}
+
+void
+rt_band_destroy(rt_context ctx, rt_band band)
+{
+#ifdef RT_API_DEBUG
+    ctx->info("Destroying rt_band @ %p", band);
+#endif
+    /* band->data isexternally owned */
+    ctx->dealloc(band);
+}
+
+void *
+rt_band_get_data(rt_context ctx, rt_band band)
+{
+    return band->data;
+}
+
+rt_pixtype
+rt_band_get_pixtype(rt_context ctx, rt_band band)
+{
+    return band->pixtype;
+}
+
+uint16_t
+rt_band_get_width(rt_context ctx, rt_band band)
+{
+    return band->width;
+}
+
+uint16_t
+rt_band_get_height(rt_context ctx, rt_band band)
+{
+    return band->height;
+}
+
+size_t
+rt_band_get_data_size(rt_context ctx, rt_band band)
+{
+    size_t numValues = band->width*band->height + 1; /* +1 for nodata */
+    switch (band->pixtype)
+    {
+        default:
+            ctx->err("Unknown pixeltype %d", band->pixtype);
+            return 0;
+        case PT_1BB:
+            /* there are 8 values per byte */
+            return (size_t)ceil(numValues/8);
+        case PT_2BUI:
+            /* there are 4 values per byte */
+            return (size_t)ceil(numValues/4);
+        case PT_4BUI:
+            /* there are 2 values per byte */
+            return (size_t)ceil(numValues/2);
+        case PT_8BSI:
+        case PT_8BUI:
+            return numValues;
+        case PT_16BSI:
+        case PT_16BUI:
+        case PT_16BF:
+            return numValues*2;
+        case PT_32BSI:
+        case PT_32BUI:
+        case PT_32BF:
+            return numValues*4;
+        case PT_64BF:
+            return numValues*8;
+    }
+}
+
+void*
+rt_band_set_data(rt_context ctx, rt_band band, void* data)
+{
+    void* olddata;
+    int alignment;
+
+    alignment = rt_pixtype_alignment(ctx, band->pixtype);
+    ctx->info("data @ %llu, pixtype:%d, alignment:%d",
+        data, (long unsigned)band->pixtype, alignment);
+    if ( ((long unsigned)data%alignment) )
+    {
+        ctx->err("Band data not aligned to %d-bytes boundary "
+                 "as requested by pixel type %s",
+                 alignment,
+                 rt_pixtype_name(ctx, band->pixtype));
+    }
+
+    olddata = band->data;
+    band->data = data;
+    return olddata;
+}
+
+#ifdef OPTIMIZE_SPACE
+/*
+ * Set given number of bits of the given byte,
+ * starting from given bitOffset (from the first) 
+ * to the given value.
+ *
+ * Examples:
+ *   char ch;
+ *   ch=0; setBits(&ch, 1, 1, 0) -> ch==8
+ *   ch=0; setBits(&ch, 3, 2, 1) -> ch==96 (0x60)
+ *
+ * Note that number of bits set must be <= 8-bitOffset
+ *
+ */
+static void
+setBits(char* ch, double val, int bits, int bitOffset)
+{
+	char mask = 0xFF >> (8-bits);
+    char ival = val;
+
+	assert(8-bitOffset >= bits);
+
+#ifdef RT_DEBUG
+	printf("ival:%d bits:%d mask:%hhx bitoffset:%d\n",
+		ival, bits, mask, bitOffset);
+#endif
+
+	/* clear all but significant bits from ival */
+	ival &= mask;
+#ifdef RT_WARN_ON_TRUNCATION
+	if ( ival != val ) {
+		printf("Pixel value for %d-bits band got truncated"
+		" from %g to %hhu\n", bits, val, ival);
+	}
+#endif /* RT_WARN_ON_TRUNCATION */
+
+#ifdef RT_DEBUG
+	printf(" cleared ival:%hhx\n", ival);
+#endif
+
+	/* Shift ival so the significant bits start at
+	 * the first bit */
+	ival <<= (8-bitOffset-bits);
+
+#ifdef RT_DEBUG
+	printf(" ival shifted:%hhx\n", ival);
+	printf("  ch:%hhx\n", *ch);
+#endif
+
+	/* clear first bits of target */
+	*ch  &= ~(mask << (8-bits-bitOffset));
+
+#ifdef RT_DEBUG
+	printf("  ch cleared:%hhx\n", *ch);
+#endif
+
+	/* Set the first bit of target */
+	*ch |= ival;
+
+#ifdef RT_DEBUG
+	printf("  ch ored:%hhx\n", *ch);
+#endif
+
+}
+#endif /* OPTIMIZE_SPACE */
+
+int
+rt_band_set_nodata(rt_context ctx, rt_band band, double val)
+{
+    unsigned char* data = rt_band_get_data(ctx, band);
+    switch (band->pixtype)
+    {
+        default:
+        {
+            ctx->err("Unknown pixeltype %d", band->pixtype);
+            return 0;
+        }
+
+        case PT_1BB:
+        {
+#ifdef OPTIMIZE_SPACE
+            /* Bit to set is bitOffset into data */
+            setBits(data, val, 1, 0);
+#else
+            *data = (int)val&0x01;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *data != val ) {
+                ctx->warn("Pixel value for 8BSI or 8BUI band got truncated"
+                          " from %g to %hhu", val, *data);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+#endif
+            return 1;
+        }
+
+        case PT_2BUI:
+        {
+#ifdef OPTIMIZE_SPACE
+            /* The two highest bits are nodata */
+            setBits(data, val, 2, 0);
+#else
+            *data = (int)val&0x03;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *data != val ) {
+                ctx->warn("Pixel value for 8BSI or 8BUI band got truncated"
+                          " from %g to %hhu", val, *data);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+#endif
+            return 1;
+        }
+
+        case PT_4BUI:
+        {
+#ifdef OPTIMIZE_SPACE
+            /* The four highest bits are nodata */
+            setBits(data, val, 4, 0);
+#else
+            *data = (int)val&0x0F;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *data != val ) {
+                ctx->warn("Pixel value for 8BSI or 8BUI band got truncated"
+                          " from %g to %hhu", val, *data);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+#endif
+            return 1;
+        }
+
+        case PT_8BSI:
+        case PT_8BUI:
+        {
+            *data = val;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *data != val ) {
+                ctx->warn("Pixel value for 8BSI or 8BUI band got truncated"
+                          " from %g to %hhu", val, *data);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+
+            return 1;
+        }
+
+        case PT_16BSI:
+        case PT_16BUI:
+        {
+            uint16_t *ptr = (uint16_t*)data; /* we assume correct alignment */
+            *ptr = val;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *ptr != val ) {
+                ctx->warn("Pixel value for 16BSI or 16BUI band got truncated"
+                          " from %g to %hu", val, *ptr);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+
+            return 1;
+        }
+
+        case PT_16BF:
+        {
+            ctx->warn("16BF pixel type not supported yet");
+            return 0;
+        }
+
+        case PT_32BSI:
+        case PT_32BUI:
+        {
+            uint32_t *ptr = (uint32_t*)data; /* we assume correct alignment */
+            *ptr = val;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *ptr != val ) {
+                ctx->warn("Pixel value for 32BSI or 32BUI band got truncated"
+                          " from %g to %u", val, *ptr);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+
+            return 1;
+        }
+
+        case PT_32BF:
+        {
+            float *ptr = (float*)data; /* we assume correct alignment */
+            *ptr = val;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *ptr != val ) {
+                ctx->warn("Pixel value for 32BF band got truncated"
+                          " from %g to %u", val, *ptr);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+
+            return 1;
+        }
+        
+        case PT_64BF:
+        {
+            double *ptr = (double*)data; /* we assume correct alignment */
+            *ptr = val;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *ptr != val ) {
+                ctx->warn("Pixel value for 64BF band got truncated"
+                          " from %g to %u", val, *ptr);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+
+            return 1;
+        }
+    }
+}
+
+int
+rt_band_set_pixel(rt_context ctx, rt_band band, uint16_t x, uint16_t y,
+        double val)
+{
+    unsigned char* data;
+    uint32_t offset;
+
+	if ( x >= band->width || y >= band->height )
+	{
+		ctx->err("Coordinates ouf of range");
+		return 0;
+	}
+
+    data = rt_band_get_data(ctx, band);
+	offset = x+(y*band->width)+1; /* +1 for the nodata value */
+
+    switch (band->pixtype)
+    {
+        default:
+        {
+            ctx->err("Unknown pixeltype %d", band->pixtype);
+            return 0;
+        }
+
+        case PT_1BB:
+        {
+#ifdef OPTIMIZE_SPACE
+            int byteOffset = offset/8;
+            int bitOffset = offset%8;
+            data += byteOffset;
+
+            /* Bit to set is bitOffset into data */
+            setBits(data, val, 1, bitOffset);
+
+#else
+            *data = (int)val&0x01;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *data != val ) {
+                ctx->warn("Pixel value for 8BSI or 8BUI band got truncated"
+                          " from %g to %hhu", val, *data);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+#endif
+            return 1;
+        }
+
+        case PT_2BUI:
+        {
+#ifdef OPTIMIZE_SPACE
+            int byteOffset = offset/4;
+            int bitOffset = offset%4;
+            data += byteOffset;
+
+            /* Bits to set start at bitOffset into data */
+            setBits(data, val, 2, bitOffset);
+
+#else
+            *data = (int)val&0x03;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *data != val ) {
+                ctx->warn("Pixel value for 8BSI or 8BUI band got truncated"
+                          " from %g to %hhu", val, *data);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+#endif
+            return 1;
+        }
+
+        case PT_4BUI:
+        {
+#ifdef OPTIMIZE_SPACE
+            int byteOffset = offset/2;
+            int bitOffset = offset%2;
+            data += byteOffset;
+
+            /* Bits to set start at bitOffset into data */
+            setBits(data, val, 2, bitOffset);
+
+#else
+            *data = (int)val&0x0F;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *data != val ) {
+                ctx->warn("Pixel value for 8BSI or 8BUI band got truncated"
+                          " from %g to %hhu", val, *data);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+#endif
+            return 1;
+        }
+
+        case PT_8BSI:
+        case PT_8BUI:
+        {
+            *data = val;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *data != val ) {
+                ctx->warn("Pixel value for 8BSI or 8BUI band got truncated"
+                          " from %g to %hhu", val, *data);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+
+            return 1;
+        }
+
+        case PT_16BSI:
+        case PT_16BUI:
+        {
+            uint16_t *ptr = (uint16_t*)data; /* we assume correct alignment */
+            *ptr = val;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *ptr != val ) {
+                ctx->warn("Pixel value for 16BSI or 16BUI band got truncated"
+                          " from %g to %hu", val, *ptr);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+
+            return 1;
+        }
+
+        case PT_16BF:
+        {
+            ctx->warn("16BF pixel type not supported yet");
+            return 0;
+        }
+
+        case PT_32BSI:
+        case PT_32BUI:
+        {
+            uint32_t *ptr = (uint32_t*)data; /* we assume correct alignment */
+            *ptr = val;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *ptr != val ) {
+                ctx->warn("Pixel value for 32BSI or 32BUI band got truncated"
+                          " from %g to %u", val, *ptr);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+
+            return 1;
+        }
+
+        case PT_32BF:
+        {
+            float *ptr = (float*)data; /* we assume correct alignment */
+            *ptr = val;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *ptr != val ) {
+                ctx->warn("Pixel value for 32BF band got truncated"
+                          " from %g to %u", val, *ptr);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+
+            return 1;
+        }
+        
+        case PT_64BF:
+        {
+            double *ptr = (double*)data; /* we assume correct alignment */
+            *ptr = val;
+
+#ifdef RT_WARN_ON_TRUNCATION
+            /* Consistency checking */
+            if ( *ptr != val ) {
+                ctx->warn("Pixel value for 64BF band got truncated"
+                          " from %g to %u", val, *ptr);
+            }
+#endif /* RT_WARN_ON_TRUNCATION */
+
+            return 1;
+        }
+    }
+}
+
+double
+rt_band_get_pixel(rt_context ctx, rt_band band, uint16_t x, uint16_t y)
+{
+    unsigned char* data;
+    uint32_t offset;
+
+	if ( x >= band->width || y >= band->height )
+	{
+		ctx->err("Coordinates ouf of range");
+		return 0;
+	}
+
+    data = rt_band_get_data(ctx, band);
+	offset = x+(y*band->width)+1; /* +1 for the nodata value */
+
+    switch (band->pixtype)
+    {
+        default:
+        {
+            ctx->err("Unknown pixeltype %d", band->pixtype);
+            return 0;
+        }
+
+        case PT_1BB:
+#ifdef OPTIMIZE_SPACE
+        {
+            int byteOffset = offset/8;
+            int bitOffset = offset%8;
+            data += byteOffset;
+
+            /* Bit to set is bitOffset into data */
+            return getBits(data, val, 1, bitOffset);
+        }
+#endif
+
+        case PT_2BUI:
+#ifdef OPTIMIZE_SPACE
+        {
+            int byteOffset = offset/4;
+            int bitOffset = offset%4;
+            data += byteOffset;
+
+            /* Bits to set start at bitOffset into data */
+            return getBits(data, val, 2, bitOffset);
+        }
+#endif
+
+        case PT_4BUI:
+#ifdef OPTIMIZE_SPACE
+        {
+            int byteOffset = offset/2;
+            int bitOffset = offset%2;
+            data += byteOffset;
+
+            /* Bits to set start at bitOffset into data */
+            return getBits(data, val, 2, bitOffset);
+        }
+#endif
+
+        case PT_8BSI:
+        case PT_8BUI:
+        {
+            uint8_t val = *data;
+            return val;
+        }
+
+        case PT_16BSI:
+        case PT_16BUI:
+        {
+            uint16_t *ptr = (uint16_t*)data; /* we assume correct alignment */
+            return *ptr;
+        }
+
+        case PT_16BF:
+        {
+            ctx->warn("16BF pixel type not supported yet");
+            return 0;
+        }
+
+        case PT_32BSI:
+        case PT_32BUI:
+        {
+            uint32_t *ptr = (uint32_t*)data; /* we assume correct alignment */
+            return *ptr;
+        }
+
+        case PT_32BF:
+        {
+            float *ptr = (float*)data; /* we assume correct alignment */
+            return *ptr;
+        }
+        
+        case PT_64BF:
+        {
+            double *ptr = (double*)data; /* we assume correct alignment */
+            return *ptr;
+        }
+    }
+}
+
+double
+rt_band_get_nodata(rt_context ctx, rt_band band)
+{
+    unsigned char* data;
+    uint32_t offset;
+
+    data = rt_band_get_data(ctx, band);
+	offset = 0;
+
+    switch (band->pixtype)
+    {
+        default:
+        {
+            ctx->err("Unknown pixeltype %d", band->pixtype);
+            return 0;
+        }
+
+        case PT_1BB:
+#ifdef OPTIMIZE_SPACE
+        {
+            int byteOffset = offset/8;
+            int bitOffset = offset%8;
+            data += byteOffset;
+
+            /* Bit to set is bitOffset into data */
+            return getBits(data, val, 1, bitOffset);
+        }
+#endif
+
+        case PT_2BUI:
+#ifdef OPTIMIZE_SPACE
+        {
+            int byteOffset = offset/4;
+            int bitOffset = offset%4;
+            data += byteOffset;
+
+            /* Bits to set start at bitOffset into data */
+            return getBits(data, val, 2, bitOffset);
+        }
+#endif
+
+        case PT_4BUI:
+#ifdef OPTIMIZE_SPACE
+        {
+            int byteOffset = offset/2;
+            int bitOffset = offset%2;
+            data += byteOffset;
+
+            /* Bits to set start at bitOffset into data */
+            return getBits(data, val, 2, bitOffset);
+        }
+#endif
+
+        case PT_8BSI:
+        case PT_8BUI:
+        {
+            uint8_t val = *data;
+            return val;
+        }
+
+        case PT_16BSI:
+        case PT_16BUI:
+        {
+            uint16_t *ptr = (uint16_t*)data; /* we assume correct alignment */
+            return *ptr;
+        }
+
+        case PT_16BF:
+        {
+            ctx->warn("16BF pixel type not supported yet");
+            return 0;
+        }
+
+        case PT_32BSI:
+        case PT_32BUI:
+        {
+            uint32_t *ptr = (uint32_t*)data; /* we assume correct alignment */
+            return *ptr;
+        }
+
+        case PT_32BF:
+        {
+            float *ptr = (float*)data; /* we assume correct alignment */
+            return *ptr;
+        }
+        
+        case PT_64BF:
+        {
+            double *ptr = (double*)data; /* we assume correct alignment */
+            return *ptr;
+        }
+    }
+}
+
+
+/*- rt_raster --------------------------------------------------------*/
+
+struct rt_raster_t {
+
+    /* Raster dimensions: 32bit */
+    uint16_t width;  /* pixel columns - max 65535 */
+    uint16_t height; /* pixel rows - max 65535 */
+
+    /* Georeference (in projection units) */
+    float scaleX; /* pixel width */
+    float scaleY; /* pixel height */
+    float ipX;    /* geo x ordinate of the middle of upper-left pixel */
+    float ipY;    /* geo y ordinate of the middle of bottom-right pixel */
+    float skewX;  /* unused ? */
+    float skewY;  /* unused ? */
+
+    int32_t srid; /* spatial reference id */
+
+    /* 32 bytes up to here */
+
+    /* Number of bands, all share the same dimension
+     * and georeference */
+    uint16_t numBands; 
+
+    rt_band *bands; /* actual bands */
+
+};
+
+rt_raster
+rt_raster_new(rt_context ctx, uint16_t width, uint16_t height)
+{
+    rt_raster ret;
+
+    assert(ctx);
+    assert(ctx->alloc);
+
+    ret = (rt_raster)ctx->alloc(sizeof(struct rt_raster_t));
+    if ( ! ret ) {
+        ctx->err("Out of virtual memory creating an rt_raster");
+        return 0;
+    }
+
+#ifdef RT_API_DEBUG
+    ctx->info("Created rt_raster @ %p", ret);
+#endif
+
+    assert(ret);
+
+    ret->width = width;
+
+    ret->height = width;
+    ret->scaleX = 1;
+    ret->scaleY = 1;
+    ret->ipX = 0.5;
+    ret->ipY = 0.5;
+    ret->skewX = 0.0;
+    ret->skewY = 0.0;
+    ret->srid = -1;
+
+    ret->numBands = 0;
+    ret->bands = 0;
+
+
+    return ret;
+}
+
+void
+rt_raster_destroy(rt_context ctx, rt_raster raster)
+{
+#ifdef RT_API_DEBUG
+    ctx->info("Destroying rt_raster @ %p", raster);
+#endif
+    if ( raster->bands )
+    {
+        ctx->dealloc(raster->bands);
+    }
+    ctx->dealloc(raster);
+}
+
+uint16_t
+rt_raster_get_width(rt_context ctx, rt_raster raster)
+{
+    return raster->width;
+}
+
+uint16_t
+rt_raster_get_height(rt_context ctx, rt_raster raster)
+{
+    return raster->height;
+}
+
+void
+rt_raster_set_pixel_sizes(rt_context ctx, rt_raster raster,
+                          float scaleX, float scaleY)
+{
+    raster->scaleX = scaleX;
+    raster->scaleY = scaleY;
+}
+
+
+float
+rt_raster_get_pixel_width(rt_context ctx, rt_raster raster)
+{
+    return raster->scaleX;
+}
+
+float
+rt_raster_get_pixel_height(rt_context ctx, rt_raster raster)
+{
+    return raster->scaleY;
+}
+
+void
+rt_raster_set_rotations(rt_context ctx, rt_raster raster,
+                          float skewX, float skewY)
+{
+    raster->skewX = skewX;
+    raster->skewY = skewY;
+}
+
+float
+rt_raster_get_x_rotation(rt_context ctx, rt_raster raster)
+{
+    return raster->skewX;
+}
+
+float
+rt_raster_get_y_rotation(rt_context ctx, rt_raster raster)
+{
+    return raster->skewY;
+}
+
+float
+rt_raster_get_x_offset(rt_context ctx, rt_raster raster)
+{
+    return raster->ipX;
+}
+
+void
+rt_raster_set_offsets(rt_context ctx, rt_raster raster, float x, float y)
+{
+    raster->ipX = x;
+    raster->ipY = y;
+}
+
+float
+rt_raster_get_y_offset(rt_context ctx, rt_raster raster)
+{
+    return raster->ipY;
+}
+
+int32_t 
+rt_raster_get_srid(rt_context ctx, rt_raster raster)
+{
+    return raster->srid;
+}
+
+void
+rt_raster_set_srid(rt_context ctx, rt_raster raster, int32_t srid)
+{
+    raster->srid = srid;
+}
+
+int
+rt_raster_get_num_bands(rt_context ctx, rt_raster raster)
+{
+    return raster->numBands;
+}
+
+rt_band
+rt_raster_get_band(rt_context ctx, rt_raster raster, int n)
+{
+    if ( n >= raster->numBands ) return 0;
+    return raster->bands[n];
+}
+
+int32_t
+rt_raster_add_band(rt_context ctx, rt_raster raster, rt_band band)
+{
+    rt_band *oldbands;
+
+    ctx->info("Adding band %p to raster %p", band, raster);
+
+    if ( band->width != raster->width )
+    {
+        ctx->err("Can't add a %dx%d band to a %dx%d raster",
+            band->width, band->height, raster->width, raster->height);
+        return -1;
+    }
+
+    oldbands = raster->bands;
+
+    ctx->info("Oldbands at %p", oldbands);
+
+    raster->bands = (rt_band*)ctx->realloc(raster->bands, 
+        sizeof(struct rt_band_t*)*(raster->numBands+1)
+    );
+
+    ctx->info("realloc returned %p", raster->bands);
+
+    if ( ! raster->bands ) {
+        ctx->err("Out of virtual memory "
+            "reallocating band pointers");
+        raster->bands = oldbands;
+        return -1;
+    }
+
+    raster->bands[raster->numBands] = band;
+
+    return raster->numBands++;
+}
+
+void
+rt_raster_cell_to_geopoint(rt_context ctx, rt_raster raster,
+        unsigned int x, unsigned int y,
+        double* x1, double* y1)
+{
+    *x1 = raster->scaleX*x + raster->skewX*y + raster->ipX;
+    *y1 = raster->scaleY*y + raster->skewY*x + raster->ipY;
+
+    ctx->info("rt_raster_cell_to_geopoint(%d,%d)", x, y);
+    ctx->info(" ipx/y:%g/%g", raster->ipX, raster->ipY);
+
+    ctx->info("cell_to_geopoint: ipX:%d, ipY:%d, %d,%d -> %g,%g",
+        raster->ipX, raster->ipY, x, y, *x1, *y1);
+}
+
+LWPOLY*
+rt_raster_get_envelope(rt_context ctx, rt_raster raster)
+{
+    POINTARRAY **rings;
+    POINTARRAY *pts;
+    LWPOLY* ret;
+    POINT4D p4d;
+    
+    rings = ctx->alloc(sizeof(POINTARRAY*));
+    rings[0] = ptarray_construct(0, 0, 5);
+    pts = rings[0];
+
+    /* Upper-left corner (first and last points) */
+    rt_raster_cell_to_geopoint(ctx, raster,
+            0, 0,
+            &p4d.x, &p4d.y);
+    setPoint4d(pts, 0, &p4d);
+    setPoint4d(pts, 4, &p4d); /* needed for closing it? */
+
+    /* Upper-right corner (we go clockwise) */
+    rt_raster_cell_to_geopoint(ctx, raster,
+            raster->width-1, 0,
+            &p4d.x, &p4d.y);
+    setPoint4d(pts, 1, &p4d);
+
+    /* Lower-right corner */
+    rt_raster_cell_to_geopoint(ctx, raster,
+            raster->width-1, raster->height-1,
+            &p4d.x, &p4d.y);
+    setPoint4d(pts, 2, &p4d);
+
+    /* Lower-left corner */
+    rt_raster_cell_to_geopoint(ctx, raster,
+            0, raster->height-1,
+            &p4d.x, &p4d.y);
+    setPoint4d(pts, 3, &p4d);
+
+    ret = lwpoly_construct(raster->srid, 0, 1, rings);
+
+    return ret;
+}
+

Added: spike/wktraster/rt_core/rt_api.h
===================================================================
--- spike/wktraster/rt_core/rt_api.h	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_core/rt_api.h	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,330 @@
+/* 
+ * WKTRaster - Raster Types for PostGIS
+ * http://www.postgis.org/support/wiki/index.php?WKTRasterHomePage
+ *
+ * Copyright (C) 2009  Sandro Santilli <strk at keybit.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef RT_API_H
+#define RT_API_H
+
+#include <stdlib.h> /* For size_t */
+#include <stdint.h> /* For C99 int types */
+
+#include "liblwgeom.h"
+
+/*- rt_context -------------------------------------------------------*/
+
+typedef struct rt_context_t* rt_context;
+
+typedef void* (*rt_allocator)(size_t size);
+typedef void* (*rt_reallocator)(void *mem, size_t size);
+typedef void  (*rt_deallocator)(void *mem);
+typedef void  (*rt_message_handler)(const char* string, ...);
+
+/* Initialize a context object
+ * @param allocator memory allocator to use, 0 to use malloc
+ * @param reallocator memory reallocator to use, 0 to use realloc
+ * @param deallocator memory deallocator to use, 0 to use free
+ * @return an opaque rt_context, or 0 on failure (out of memory)
+ */
+rt_context rt_context_new(rt_allocator allocator,
+                          rt_reallocator reallocator,
+                          rt_deallocator deallocator);
+
+/* Destroy context */
+void rt_context_destroy(rt_context ctx);
+
+/* Set message handlers */
+void rt_context_set_message_handlers(rt_context ctx,
+                                    rt_message_handler error_handler,
+                                    rt_message_handler warning_handler,
+                                    rt_message_handler info_handler);
+
+/*- rt_pixtype --------------------------------------------------------*/
+
+/* Pixel types */
+typedef enum {
+    PT_1BB=0,     /* 1-bit boolean            */
+    PT_2BUI=1,    /* 2-bit unsigned integer   */
+    PT_4BUI=2,    /* 4-bit unsigned integer   */
+    PT_8BSI=3,    /* 8-bit signed integer     */
+    PT_8BUI=4,    /* 8-bit unsigned integer   */
+    PT_16BSI=5,   /* 16-bit signed integer    */
+    PT_16BUI=6,   /* 16-bit unsigned integer  */
+    PT_32BSI=7,   /* 32-bit signed integer    */
+    PT_32BUI=8,   /* 32-bit unsigned integer  */
+    PT_16BF=9,    /* 16-bit float             */
+    PT_32BF=10,   /* 32-bit float             */
+    PT_64BF=11,   /* 64-bit float             */
+    PT_END=13
+} rt_pixtype;
+
+/* Return alignment requirements for data in the given pixel type.
+ * Fast access to pixel values of this type must be aligned to as
+ * many bytes as returned by this function.
+ */
+int rt_pixtype_alignment(rt_context ctx, rt_pixtype pixtype);
+
+/* Return human-readable name of pixel type */
+const char* rt_pixtype_name(rt_context ctx, rt_pixtype pixtype);
+
+/*- rt_band ----------------------------------------------------------*/
+
+typedef struct rt_band_t* rt_band;
+
+/* Create an rt_band with no data */
+rt_band rt_band_new(rt_context ctx, rt_pixtype pixtype,
+                          uint16_t width, uint16_t height);
+
+/* Get pixeltype of this band */
+rt_pixtype rt_band_get_pixtype(rt_context ctx, rt_band band);
+
+/* Get width of this band */
+uint16_t rt_band_get_width(rt_context ctx, rt_band band);
+
+/* Get height of this band */
+uint16_t rt_band_get_height(rt_context ctx, rt_band band);
+
+/* Get the required minimum size in bytes of the band data
+ * which includes the nodata value plus a value for each
+ * pixel of the band's pixtype.
+ */
+size_t rt_band_get_data_size(rt_context ctx, rt_band band);
+
+/* Set rt_band data pointer 
+ *
+ * @param ctx : context, for thread safety
+ * @param data : start of data.
+ *               The pointer is expected to be aligned as required
+ *               by pixel type (see rt_pixtype_data_alignment).
+ *               The memory block pointed to must be big enough
+ *               to contain all data (see rt_band_get_data_size).
+ * @return old data pointer
+ */
+void* rt_band_set_data(rt_context ctx, rt_band band, void* data);
+
+/* Get pointer into the start of raster band data */
+void* rt_band_get_data(rt_context ctx, rt_band band);
+
+/* Destroy a raster band. Data will also be destroyed if owned. */
+void rt_band_destroy(rt_context ctx, rt_band band);
+
+/* Set nodata value
+ * @param ctx : context, for thread safety
+ * @param band : the band to set nodata value to
+ * @param val : the nodata value, will be appropriately
+ *              truncated to fit for the pixeltype.
+ * @return 1 on success, 0 on error.
+ *         Truncation won't be considered an error.
+ */
+int rt_band_set_nodata(rt_context ctx, rt_band band, double val);
+
+/* Get nodata value
+ * @param ctx : context, for thread safety
+ * @param band : the band to set nodata value to
+ * @return nodata value
+ */
+double rt_band_get_nodata(rt_context ctx, rt_band band);
+
+/* Set pixel value
+ * @param ctx : context, for thread safety
+ * @param band : the band to set nodata value to
+ * @param x : x ordinate
+ * @param y : x ordinate
+ * @param val : the pixel value, will be appropriately
+ *              truncated to fit for the pixeltype.
+ * @return 1 on success, 0 on error.
+ *         Truncation won't be considered an error.
+ */
+int rt_band_set_pixel(rt_context ctx, rt_band band,
+                      uint16_t x, uint16_t y, double val);
+
+/* Get pixel value
+ *
+ * @param ctx : context, for thread safety
+ * @param band : the band to set nodata value to
+ * @param x : x ordinate
+ * @param y : x ordinate
+ * @return the pixel value, as a double.
+ */
+double rt_band_get_pixel(rt_context ctx, rt_band band,
+                         uint16_t x, uint16_t y);
+
+/*- rt_raster --------------------------------------------------------*/
+
+typedef struct rt_raster_t* rt_raster;
+
+/* Construct a raster with given dimensions.
+ * Transform will be set to identity.
+ * Will contain no bands
+ * 
+ * @param ctx : context, for thread safety
+ * @param width : number of pixel columns
+ * @param height : number of pixel rows
+ * @return an rt_raster or 0 if out of memory
+ */
+rt_raster rt_raster_new(rt_context ctx, uint16_t width, uint16_t height);
+
+/* Release memory associated to a raster
+ * Note that this will not release data
+ * associated to the band themselves, but only
+ * the one associated with the pointers pointing
+ * at it.
+ *
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to destroy
+ */
+void rt_raster_destroy(rt_context ctx, rt_raster raster);
+
+/* Get number of bands */
+int rt_raster_get_num_bands(rt_context ctx, rt_raster raster);
+
+/* Return Nth band, or 0 if unavailable */
+rt_band rt_raster_get_band(rt_context ctx, rt_raster raster,
+    int bandNum);
+
+/* Get number of rows */
+uint16_t rt_raster_get_width(rt_context ctx, rt_raster raster);
+
+/* Get number of columns */
+uint16_t rt_raster_get_height(rt_context ctx, rt_raster raster);
+
+/* Add band data to a raster.
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to add a band to
+ * @param band : the band to add, ownership left to caller.
+ *               Band dimensions are required to match with raster ones.
+ * @return identifier for the just-added raster, or -1 on error
+ */
+int32_t rt_raster_add_band(rt_context ctx, rt_raster raster,
+    rt_band band);
+
+/* Set pixel size in projection units
+ *
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to set georeference of
+ * @param scaleX : pixel width in projection units
+ * @param scaleY : pixel height in projection units
+ *
+ * NOTE: doesn't recompute offsets
+ */
+void rt_raster_set_pixel_sizes(rt_context ctx, rt_raster raster,
+                               float scaleX, float scaleY);
+
+/* Get pixel width in projection units
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to get georeference of
+ * @return pixel width in projection units
+ */
+float rt_raster_get_pixel_width(rt_context ctx, rt_raster raster);
+
+/* Get pixel height in projection units
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to get georeference of
+ * @return pixel height in projection units
+ */
+float rt_raster_get_pixel_height(rt_context ctx, rt_raster raster);
+
+/* Set insertion points in projection units
+ *
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to set georeference of
+ * @param x : x ordinate of the center of upper-left pixel,
+ *            in projection units
+ * @param y : y ordinate of the center of upper-left pixel,
+ *            in projection units
+ */
+void rt_raster_set_offsets(rt_context ctx, rt_raster raster,
+                               float x, float y);
+
+/* Get raster x offset, in projection units
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to get georeference of
+ * @return  x ordinate of the center of upper-left pixel,
+ *          in projection units
+ */
+float rt_raster_get_x_offset(rt_context ctx, rt_raster raster);
+
+/* Get raster y offset, in projection units
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to get georeference of
+ * @return  y ordinate of the center of upper-left pixel,
+ *          in projection units
+ */
+float rt_raster_get_y_offset(rt_context ctx, rt_raster raster);
+
+/* Set rotations about the X and Y axis 
+ *
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to set georeference of
+ * @param skewX : rotation about the x axis
+ * @param skewY : rotation about the y axis
+ */
+void rt_raster_set_rotations(rt_context ctx, rt_raster raster,
+                               float skewX, float skewY);
+
+/* Get rotation about the X axis
+ *
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to set georeference of
+ * @return rotation about the Y axis
+ */
+float rt_raster_get_x_rotation(rt_context ctx, rt_raster raster);
+
+/* Get rotation about the Y axis
+ *
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to set georeference of
+ * @return rotation about the Y axis
+ */
+float rt_raster_get_y_rotation(rt_context ctx, rt_raster raster);
+
+/* Set raster's SRID 
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to set SRID of
+ * @param srid : the SRID to set for the raster
+ */
+void rt_raster_set_srid(rt_context ctx, rt_raster raster, int32_t srid);
+
+/* Get raster's SRID 
+ * @param ctx : context, for thread safety
+ * @param raster : the raster to set SRID of
+ * @return the raster's SRID
+ */
+int32_t rt_raster_get_srid(rt_context ctx, rt_raster raster);
+
+/* Convert an x,y cell on raster to an x1,y1 point on map
+ * @param ctx : context for thread safety
+ * @param raster : the raster to get info from
+ * @param x : the pixel's column
+ * @param y : the pixel's row
+ * @param x1 : output parameter, X ordinate of the geographical point
+ * @param y1 : output parameter, Y ordinate of the geographical point
+ */
+void rt_raster_cell_to_geopoint(rt_context ctx, rt_raster raster,
+        unsigned int x, unsigned int y, double* x1, double* y1);
+
+/* Get raster's polygon envelope.
+ * The envelope is a 4 vertices (5 to be closed) single
+ * ring polyogon bearing the raster's rotation 
+ * and using projection coordinates
+ */
+LWPOLY* rt_raster_get_envelope(rt_context ctx, rt_raster raster);
+
+#endif /* RT_API_H */

Added: spike/wktraster/rt_core/testapi.c
===================================================================
--- spike/wktraster/rt_core/testapi.c	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_core/testapi.c	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,678 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <math.h> /* for fabs */
+
+#include "rt_api.h"
+
+static rt_band addBand(rt_context ctx, rt_raster raster, rt_pixtype pixtype);
+static void deepRelease(rt_context ctx, rt_raster raster);
+static void testBand1BB(rt_context ctx, rt_band band);
+
+#define CHECK(exp) { if ( !exp ) { \
+    fprintf(stderr, "Check failed on line %d\n", __LINE__); \
+    exit(1); } }
+
+#define CHECK_EQUALS(obt, exp) { if ( obt != exp ) { \
+    fprintf(stderr, "Check failed on line %d\n", __LINE__); \
+    exit(1); } }
+
+#define CHECK_EQUALS_FLOAT(obt, exp) { if ( fabs(obt-exp) > 0.000001 ) { \
+    fprintf(stderr, "Check failed on line %d\n", __LINE__); \
+    exit(1); } }
+
+static rt_band
+addBand(rt_context ctx, rt_raster raster, rt_pixtype pixtype)
+{
+    void* mem;
+    int32_t bandNum;
+
+    rt_band band = rt_band_new(ctx, pixtype,
+                               rt_raster_get_width(ctx, raster),
+                               rt_raster_get_height(ctx, raster));
+    assert(band);
+    mem = malloc(rt_band_get_data_size(ctx, band));
+    assert(mem);
+    rt_band_set_data(ctx, band, mem);
+    bandNum = rt_raster_add_band(ctx, raster, band);
+    assert(bandNum>=0);
+    return band;
+}
+
+static void
+deepRelease(rt_context ctx, rt_raster raster)
+{
+    uint16_t i, nbands=rt_raster_get_num_bands(ctx, raster);
+    for (i=0; i<nbands; ++i)
+    {
+        rt_band band = rt_raster_get_band(ctx, raster, i);
+        void* mem = rt_band_get_data(ctx, band);
+        if ( mem ) free(mem);
+        rt_band_destroy(ctx, band);
+    }
+    rt_raster_destroy(ctx, raster);
+}
+
+static void testBand1BB(rt_context ctx, rt_band band)
+{
+    rt_band_set_nodata(ctx, band, 1);
+    //printf("1BB nodata is %g\n", rt_band_get_nodata(ctx, band));
+    CHECK_EQUALS(rt_band_get_nodata(ctx, band), 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    //printf("1BB nodata is %g\n", rt_band_get_nodata(ctx, band));
+    CHECK_EQUALS(rt_band_get_nodata(ctx, band), 0);
+
+    rt_band_set_nodata(ctx, band, 2);
+    //printf("1BB nodata is %g\n", rt_band_get_nodata(ctx, band));
+    CHECK_EQUALS(rt_band_get_nodata(ctx, band), 0);
+
+    rt_band_set_nodata(ctx, band, 3);
+    //printf("1BB nodata is %g\n", rt_band_get_nodata(ctx, band));
+    CHECK_EQUALS(rt_band_get_nodata(ctx, band), 1);
+
+    {
+        int x, y;
+        for (x=0; x<rt_band_get_width(ctx, band); ++x)
+        {
+            for (y=0; y<rt_band_get_height(ctx, band); ++y)
+            {
+    rt_band_set_pixel(ctx, band, x, y, 1);
+    //printf("1BB pixel @ 0,0 is %g\n", rt_band_get_pixel(ctx, band, x, y));
+    CHECK_EQUALS(rt_band_get_pixel(ctx, band, x, y), 1);
+
+    rt_band_set_pixel(ctx, band, x, y, 0);
+    //printf("1BB pixel @ 0,0 is %g\n", rt_band_get_pixel(ctx, band, x, y));
+    CHECK_EQUALS(rt_band_get_pixel(ctx, band, x, y), 0);
+
+    rt_band_set_pixel(ctx, band, x, y, 2);
+    //printf("1BB pixel @ 0,0 is %g\n", rt_band_get_pixel(ctx, band, x, y));
+    CHECK_EQUALS(rt_band_get_pixel(ctx, band, x, y), 0);
+
+    rt_band_set_pixel(ctx, band, x, y, 3);
+    //printf("1BB pixel @ 0,0 is %g\n", rt_band_get_pixel(ctx, band, x, y));
+    CHECK_EQUALS(rt_band_get_pixel(ctx, band, x, y), 1);
+            }
+        }
+    }
+
+}
+
+static void testBand2BUI(rt_context ctx, rt_band band)
+{
+    double val;
+
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 2);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 2);
+
+    rt_band_set_nodata(ctx, band, 3);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 3);
+
+    rt_band_set_nodata(ctx, band, 4); /* truncates */
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 5); /* truncates */
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    {
+        int x, y;
+        for (x=0; x<rt_band_get_width(ctx, band); ++x)
+        {
+            for (y=0; y<rt_band_get_height(ctx, band); ++y)
+            {
+    rt_band_set_pixel(ctx, band, x, y, 1);
+    val =  rt_band_get_pixel(ctx, band, x, y);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_pixel(ctx, band, x, y, 2);
+    val =  rt_band_get_pixel(ctx, band, x, y);
+    CHECK_EQUALS(val, 2);
+
+    rt_band_set_pixel(ctx, band, x, y, 3);
+    val =  rt_band_get_pixel(ctx, band, x, y);
+    CHECK_EQUALS(val, 3);
+
+    rt_band_set_pixel(ctx, band, x, y, 4);
+    val =  rt_band_get_pixel(ctx, band, x, y);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_pixel(ctx, band, x, y, 5);
+    val =  rt_band_get_pixel(ctx, band, x, y);
+    CHECK_EQUALS(val, 1);
+
+            }
+        }
+    }
+
+}
+
+static void testBand4BUI(rt_context ctx, rt_band band)
+{
+    double val;
+
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 2);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 2);
+
+    rt_band_set_nodata(ctx, band, 4); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 4);
+
+    rt_band_set_nodata(ctx, band, 8); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 8);
+
+    rt_band_set_nodata(ctx, band, 15); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 15);
+
+    rt_band_set_nodata(ctx, band, 16);  /* truncates */
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 17);  /* truncates */
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    {
+        int x, y;
+        for (x=0; x<rt_band_get_width(ctx, band); ++x)
+        {
+            for (y=0; y<rt_band_get_height(ctx, band); ++y)
+            {
+    rt_band_set_pixel(ctx, band, x, y, 1);
+    val =  rt_band_get_pixel(ctx, band, x, y);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_pixel(ctx, band, x, y, 3);
+    val =  rt_band_get_pixel(ctx, band, x, y);
+    CHECK_EQUALS(val, 3);
+
+    rt_band_set_pixel(ctx, band, x, y, 7);
+    val =  rt_band_get_pixel(ctx, band, x, y);
+    CHECK_EQUALS(val, 7);
+
+    rt_band_set_pixel(ctx, band, x, y, 15);
+    val =  rt_band_get_pixel(ctx, band, x, y);
+    CHECK_EQUALS(val, 15);
+
+    rt_band_set_pixel(ctx, band, x, y, 35); /* truncates */
+    val =  rt_band_get_pixel(ctx, band, x, y);
+    CHECK_EQUALS(val, 3);
+
+            }
+        }
+    }
+
+}
+
+static void testBand8BI(rt_context ctx, rt_band band)
+{
+    double val;
+
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 2);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 2);
+
+    rt_band_set_nodata(ctx, band, 4); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 4);
+
+    rt_band_set_nodata(ctx, band, 8); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 8);
+
+    rt_band_set_nodata(ctx, band, 15); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 15);
+
+    rt_band_set_nodata(ctx, band, 31);  
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 31);
+
+    rt_band_set_nodata(ctx, band, 255);  
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 255);
+
+    rt_band_set_nodata(ctx, band, 256);   /* truncates */
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    {
+        int x, y;
+        for (x=0; x<rt_band_get_width(ctx, band); ++x)
+        {
+            for (y=0; y<rt_band_get_height(ctx, band); ++y)
+            {
+    rt_band_set_nodata(ctx, band, 31);  
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 31);
+
+    rt_band_set_nodata(ctx, band, 255);  
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 255);
+
+    rt_band_set_nodata(ctx, band, 256);   /* truncates */
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+            }
+        }
+    }
+}
+
+static void testBand16BI(rt_context ctx, rt_band band)
+{
+    double val;
+
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 31);  
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 31);
+
+    rt_band_set_nodata(ctx, band, 255);  
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 255);
+
+    rt_band_set_nodata(ctx, band, 65535);   
+    val = rt_band_get_nodata(ctx, band);
+    //printf("set 65535 on %s band gets %g back\n", pixtypeName, val);
+    CHECK_EQUALS(val, 65535);
+
+    rt_band_set_nodata(ctx, band, 65536);   /* truncates */
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    {
+        int x, y;
+        for (x=0; x<rt_band_get_width(ctx, band); ++x)
+        {
+            for (y=0; y<rt_band_get_height(ctx, band); ++y)
+            {
+    rt_band_set_nodata(ctx, band, 255);  
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 255);
+
+    rt_band_set_nodata(ctx, band, 65535);   
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 65535);
+
+    rt_band_set_nodata(ctx, band, 65536);   /* truncates */
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+            }
+        }
+    }
+}
+
+static void testBand32BI(rt_context ctx, rt_band band)
+{
+    double val;
+
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 65535);   
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 65535);
+
+    rt_band_set_nodata(ctx, band, 4294967295); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 4294967295);
+
+    rt_band_set_nodata(ctx, band, 4294967296);   /* truncates */
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    {
+        int x, y;
+        for (x=0; x<rt_band_get_width(ctx, band); ++x)
+        {
+            for (y=0; y<rt_band_get_height(ctx, band); ++y)
+            {
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 65535);   
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 65535);
+
+    rt_band_set_nodata(ctx, band, 4294967295); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 4294967295);
+
+    rt_band_set_nodata(ctx, band, 4294967296);   /* truncates */
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+            }
+        }
+    }
+}
+
+static void testBand16BF(rt_context ctx, rt_band band)
+{
+    printf(" 16BF type not implemented yet\n");
+}
+
+static void testBand32BF(rt_context ctx, rt_band band)
+{
+    double val;
+
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS_FLOAT(val, 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS_FLOAT(val, 0);
+
+    rt_band_set_nodata(ctx, band, 65535.5);
+    val = rt_band_get_nodata(ctx, band);
+    //printf("set 65535.56 on %s band gets %g back\n", pixtypeName, val);
+    CHECK_EQUALS_FLOAT(val, 65535.5);
+
+    rt_band_set_nodata(ctx, band, 0.006); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS_FLOAT(val, 0.006);
+
+    {
+        int x, y;
+        for (x=0; x<rt_band_get_width(ctx, band); ++x)
+        {
+            for (y=0; y<rt_band_get_height(ctx, band); ++y)
+            {
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 65535.5);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS_FLOAT(val, 65535.5);
+
+    rt_band_set_nodata(ctx, band, 0.006); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS_FLOAT(val, 0.006);
+
+            }
+        }
+    }
+}
+
+static void testBand64BF(rt_context ctx, rt_band band)
+{
+    double val;
+
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 65535.56);   
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 65535.56);
+
+    rt_band_set_nodata(ctx, band, 0.006); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0.006);
+
+    {
+        int x, y;
+        for (x=0; x<rt_band_get_width(ctx, band); ++x)
+        {
+            for (y=0; y<rt_band_get_height(ctx, band); ++y)
+            {
+    rt_band_set_nodata(ctx, band, 1);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 1);
+
+    rt_band_set_nodata(ctx, band, 0);
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0);
+
+    rt_band_set_nodata(ctx, band, 65535.56);   
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 65535.56);
+
+    rt_band_set_nodata(ctx, band, 0.006); 
+    val = rt_band_get_nodata(ctx, band);
+    CHECK_EQUALS(val, 0.006);
+
+            }
+        }
+    }
+}
+
+int
+main()
+{
+    /* will use default allocators and message handlers */
+    rt_context ctx;
+    rt_raster raster;
+    rt_band band_1BB, band_2BUI, band_4BUI,
+            band_8BSI, band_8BUI, band_16BSI, band_16BUI,
+            band_32BSI, band_32BUI, band_16BF, band_32BF,
+            band_64BF;
+
+    ctx = rt_context_new(0, 0, 0);
+    raster = rt_raster_new(ctx, 256, 256);
+    assert(raster); /* or we're out of virtual memory */
+
+    { /* Check scale */
+        float scale;
+        scale = rt_raster_get_pixel_width(ctx, raster);
+        CHECK_EQUALS(scale, 1);
+        scale = rt_raster_get_pixel_height(ctx, raster);
+        CHECK_EQUALS(scale, 1);
+    }
+
+    { /* Check offsets */
+        float off;
+
+        off = rt_raster_get_x_offset(ctx, raster);
+        CHECK_EQUALS(off, 0.5);
+
+        off = rt_raster_get_y_offset(ctx, raster);
+        CHECK_EQUALS(off, 0.5);
+
+        rt_raster_set_offsets(ctx, raster, 30, 70);
+
+        off = rt_raster_get_x_offset(ctx, raster);
+        CHECK_EQUALS(off, 30);
+
+        off = rt_raster_get_y_offset(ctx, raster);
+        CHECK_EQUALS(off, 70);
+
+        rt_raster_set_offsets(ctx, raster, 0.5, 0.5);
+    }
+
+    { /* Check rotation */
+        float off;
+
+        off = rt_raster_get_x_rotation(ctx, raster);
+        CHECK_EQUALS(off, 0);
+
+        off = rt_raster_get_y_rotation(ctx, raster);
+        CHECK_EQUALS(off, 0);
+
+        rt_raster_set_rotations(ctx, raster, 4, 5);
+
+        off = rt_raster_get_x_rotation(ctx, raster);
+        CHECK_EQUALS(off, 4);
+
+        off = rt_raster_get_y_rotation(ctx, raster);
+        CHECK_EQUALS(off, 5);
+
+        rt_raster_set_rotations(ctx, raster, 0, 0);
+    }
+
+    { /* Check SRID */
+        int32_t srid;
+        srid = rt_raster_get_srid(ctx, raster);
+        CHECK_EQUALS(srid, -1);
+
+        rt_raster_set_srid(ctx, raster, 65546);
+        srid = rt_raster_get_srid(ctx, raster);
+        CHECK_EQUALS(srid, 65546);
+    }
+
+    printf("Raster starts with %d bands\n",
+        rt_raster_get_num_bands(ctx, raster));
+
+    { /* Check envelopes, based on offset, scale and rotation */
+        LWPOLY *envelope;
+        POINTARRAY *ring;
+        POINT4D pt;
+
+        envelope = rt_raster_get_envelope(ctx, raster);
+        CHECK_EQUALS(envelope->SRID, rt_raster_get_srid(ctx, raster));
+        CHECK_EQUALS(envelope->nrings, 1);
+        ring = envelope->rings[0];
+        CHECK(ring);
+        CHECK_EQUALS(ring->npoints, 5);
+
+        getPoint4d_p(ring, 0, &pt);
+        printf("First point on envelope ring is %g,%g\n", pt.x, pt.y);
+        CHECK_EQUALS(pt.x, 0.5);
+        CHECK_EQUALS(pt.y, 0.5);
+
+        getPoint4d_p(ring, 1, &pt);
+        printf("Second point on envelope ring is %g,%g\n", pt.x, pt.y);
+        CHECK_EQUALS(pt.x, 255.5);
+        CHECK_EQUALS(pt.y, 0.5);
+
+        getPoint4d_p(ring, 2, &pt);
+        printf("Third point on envelope ring is %g,%g\n", pt.x, pt.y);
+        CHECK_EQUALS(pt.x, 255.5);
+        CHECK_EQUALS(pt.y, 255.5);
+
+        getPoint4d_p(ring, 3, &pt);
+        printf("Fourth point on envelope ring is %g,%g\n", pt.x, pt.y);
+        CHECK_EQUALS(pt.x, 0.5);
+        CHECK_EQUALS(pt.y, 255.5);
+
+        getPoint4d_p(ring, 4, &pt);
+        printf("Fifth point on envelope ring is %g,%g\n", pt.x, pt.y);
+        CHECK_EQUALS(pt.x, 0.5);
+        CHECK_EQUALS(pt.y, 0.5);
+
+        lwpoly_free(envelope);
+    }
+
+    printf("Testing 1BB band\n");
+    band_1BB = addBand(ctx, raster, PT_1BB);
+    testBand1BB(ctx, band_1BB);
+
+    printf("Testing 2BB band\n");
+    band_2BUI = addBand(ctx, raster, PT_2BUI);
+    testBand2BUI(ctx, band_2BUI);
+
+    printf("Testing 4BUI band\n");
+    band_4BUI = addBand(ctx, raster, PT_4BUI);
+    testBand4BUI(ctx, band_4BUI);
+
+    printf("Testing 8BUI band\n");
+    band_8BUI = addBand(ctx, raster, PT_8BUI);
+    testBand8BI(ctx, band_8BUI);
+
+    printf("Testing 8BSI band\n");
+    band_8BSI = addBand(ctx, raster, PT_8BSI);
+    testBand8BI(ctx, band_8BSI);
+
+    printf("Testing 16BSI band\n");
+    band_16BSI = addBand(ctx, raster, PT_16BSI);
+    testBand16BI(ctx, band_16BSI);
+
+    printf("Testing 16BUI band\n");
+    band_16BUI = addBand(ctx, raster, PT_16BUI);
+    testBand16BI(ctx, band_16BUI);
+
+    printf("Testing 32BUI band\n");
+    band_32BUI = addBand(ctx, raster, PT_32BUI);
+    testBand32BI(ctx, band_32BUI);
+
+    printf("Testing 32BSI band\n");
+    band_32BSI = addBand(ctx, raster, PT_32BSI);
+    testBand32BI(ctx, band_32BSI);
+
+    printf("Testing 16BF band\n");
+    band_16BF = addBand(ctx, raster, PT_16BF);
+    testBand16BF(ctx, band_16BF);
+
+    printf("Testing 32BF band\n");
+    band_32BF = addBand(ctx, raster, PT_32BF);
+    testBand32BF(ctx, band_32BF);
+
+    printf("Testing 64BF band\n");
+    band_64BF = addBand(ctx, raster, PT_64BF);
+    testBand64BF(ctx, band_64BF);
+
+    deepRelease(ctx, raster);
+    rt_context_destroy(ctx);
+
+    return EXIT_SUCCESS;
+}
+
+/* This is needed by liblwgeom */
+void
+lwgeom_init_allocators(void)
+{
+    lwgeom_install_default_allocators();
+}

Added: spike/wktraster/rt_pg/Makefile
===================================================================
--- spike/wktraster/rt_pg/Makefile	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_pg/Makefile	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,48 @@
+# **********************************************************************
+# *
+# * WKTRaster - Raster Types for PostGIS
+# * http://www.postgis.org/support/wiki/index.php?WKTRasterHomePage
+# *
+# * Copyright (c) 2009 Sandro Santilli <strk at keybit.net>
+# *
+# * This is free software; you can redistribute and/or modify it under
+# * the terms of the GNU General Public Licence. See the COPYING file.
+# *
+# **********************************************************************
+
+MODULE_big=rtpostgis
+
+
+# Files to be copied to the contrib/ directory
+DATA_built=
+DATA=
+
+# SQL objects (files requiring C pre-processing)
+SQL_OBJS=rtpostgis.sql.in
+
+# Objects to build using PGXS
+OBJS=rt_pg.o
+
+# Libraries to link into the module (proj, geos)
+#
+# Note: we specify liblwgeom.a directly in SHLIB_LINK rather than using
+# -L... -l options to prevent issues with some platforms trying to link
+# to an existing liblwgeom.so in the PostgreSQL $libdir supplied by an
+# older version of PostGIS, rather than with the static liblwgeom.a 
+# supplied with newer versions of PostGIS
+#
+
+PG_CPPFLAGS+= -I/usr/include  -I/usr/src/postgis/trunk/liblwgeom -I../rt_core
+SHLIB_LINK+= -L/usr/lib  -lgeos_c -lproj ../rt_core/librtcore.a /usr/src/postgis/trunk/liblwgeom/liblwgeom.a
+
+# Extra files to remove during 'make clean'
+EXTRA_CLEAN=$(SQL_OBJS) rtpostgis.sql
+
+# PGXS information
+PG_CONFIG = /usr/bin/pg_config 
+PGXS := /usr/lib/postgresql/8.3/lib/pgxs/src/makefiles/pgxs.mk
+include $(PGXS)
+
+# Generate any .sql.in files from .sql.in.c files by running them through the C pre-processor 
+$(SQL_OBJS): %.in: %.in.c
+	$(CPP) -traditional-cpp $< | grep -v '^#' > $@

Added: spike/wktraster/rt_pg/Makefile.in
===================================================================
--- spike/wktraster/rt_pg/Makefile.in	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_pg/Makefile.in	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,48 @@
+# **********************************************************************
+# *
+# * WKTRaster - Raster Types for PostGIS
+# * http://www.postgis.org/support/wiki/index.php?WKTRasterHomePage
+# *
+# * Copyright (c) 2009 Sandro Santilli <strk at keybit.net>
+# *
+# * This is free software; you can redistribute and/or modify it under
+# * the terms of the GNU General Public Licence. See the COPYING file.
+# *
+# **********************************************************************
+
+MODULE_big=rtpostgis
+
+
+# Files to be copied to the contrib/ directory
+DATA_built=
+DATA=
+
+# SQL objects (files requiring C pre-processing)
+SQL_OBJS=rtpostgis.sql.in
+
+# Objects to build using PGXS
+OBJS=rt_pg.o
+
+# Libraries to link into the module (proj, geos)
+#
+# Note: we specify liblwgeom.a directly in SHLIB_LINK rather than using
+# -L... -l options to prevent issues with some platforms trying to link
+# to an existing liblwgeom.so in the PostgreSQL $libdir supplied by an
+# older version of PostGIS, rather than with the static liblwgeom.a 
+# supplied with newer versions of PostGIS
+#
+
+PG_CPPFLAGS+=@CPPFLAGS@ -I at POSTGIS_SRCDIR@/liblwgeom -I../rt_core
+SHLIB_LINK+=@SHLIB_LINK@ ../rt_core/librtcore.a @POSTGIS_SRCDIR@/liblwgeom/liblwgeom.a
+
+# Extra files to remove during 'make clean'
+EXTRA_CLEAN=$(SQL_OBJS) rtpostgis.sql
+
+# PGXS information
+PG_CONFIG = @PGCONFIG@ 
+PGXS := @PGXS@
+include $(PGXS)
+
+# Generate any .sql.in files from .sql.in.c files by running them through the C pre-processor 
+$(SQL_OBJS): %.in: %.in.c
+	$(CPP) -traditional-cpp $< | grep -v '^#' > $@

Added: spike/wktraster/rt_pg/rt_pg.c
===================================================================
--- spike/wktraster/rt_pg/rt_pg.c	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_pg/rt_pg.c	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,685 @@
+/* 
+ * WKTRaster - Raster Types for PostGIS
+ * http://www.postgis.org/support/wiki/index.php?WKTRasterHomePage
+ *
+ * Copyright (C) 2009  Sandro Santilli <strk at keybit.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#include <math.h>
+#include <float.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <assert.h>
+
+#include "postgres.h" /* for palloc */
+#include "access/gist.h"
+#include "access/itup.h"
+#include "fmgr.h"
+#include "utils/elog.h"
+#include "funcapi.h"
+
+/*#include "lwgeom_pg.h"*/
+#include "liblwgeom.h"
+#include "rt_pg.h"
+#include "rt_api.h"
+
+
+/* Define this to debug RASTER ops */
+//#define RT_DEBUG 1
+
+//#define RT_PG_DEBUG_MEM 1
+
+/*
+ * This is required for builds against pgsql 8.2
+ */
+#ifdef PG_MODULE_MAGIC
+PG_MODULE_MAGIC;
+#endif
+
+/* Static data */
+rt_context ctx = 0;
+
+/* Internal funcs */
+static void init_context(FunctionCallInfoData *fcinfo);
+static void swap_char(unsigned char *a, unsigned char *b);
+static void flip_endian_16(unsigned char *d);
+static void flip_endian_32(unsigned char *d);
+static void flip_endian_64(unsigned char *i);
+static void *rt_pgalloc(size_t size);
+static void *rt_pgrealloc(void *mem, size_t size);
+static void rt_pgfree(void *mem);
+static rt_pgraster* rt_pgraster_from_hexwkb(char* hexwkb);
+static rt_raster rt_pgraster_deserialize(rt_context ctx,
+                                         rt_pgraster *pgraster);
+
+
+/* Prototypes */
+Datum RASTER_in(PG_FUNCTION_ARGS);
+Datum RASTER_out(PG_FUNCTION_ARGS);
+Datum RASTER_to_LWGEOM(PG_FUNCTION_ARGS);
+Datum RASTER_getSRID(PG_FUNCTION_ARGS);
+Datum RASTER_getFactor(PG_FUNCTION_ARGS);
+Datum RASTER_setFactor(PG_FUNCTION_ARGS);
+Datum RASTER_getHeight(PG_FUNCTION_ARGS);
+Datum RASTER_getWidth(PG_FUNCTION_ARGS);
+Datum RASTER_setSRID(PG_FUNCTION_ARGS);
+Datum RASTER_send(PG_FUNCTION_ARGS);
+Datum RASTER_dump(PG_FUNCTION_ARGS);
+Datum RASTER_construct(PG_FUNCTION_ARGS);
+Datum RASTER_getpixel(PG_FUNCTION_ARGS);
+Datum RASTER_setpixel(PG_FUNCTION_ARGS);
+Datum RASTER_draw(PG_FUNCTION_ARGS);
+Datum RASTER_fill(PG_FUNCTION_ARGS);
+
+static void *
+rt_pgalloc(size_t size)
+{
+    void* ret;
+#ifdef RT_PG_DEBUG_MEM
+    elog(NOTICE, "rt_pgalloc(%ld) called", size);
+#endif
+    ret = palloc(size);
+#ifdef RT_PG_DEBUG_MEM
+    elog(NOTICE, "palloc(%ld) returned", size);
+#endif
+    return ret;
+}
+
+static void *
+rt_pgrealloc(void *mem, size_t size)
+{
+    void* ret;
+#ifdef RT_PG_DEBUG_MEM
+    elog(NOTICE, "rt_pgrealloc(%p, %ld) called", mem, size);
+#endif
+    if ( mem )
+    {
+#ifdef RT_PG_DEBUG_MEM
+        elog(NOTICE, "rt_pgrealloc calling repalloc(%p, %ld)", mem, size);
+#endif
+        ret = repalloc(mem, size);
+    }
+    else
+    {
+#ifdef RT_PG_DEBUG_MEM
+        elog(NOTICE, "rt_pgrealloc calling palloc(%ld)", size);
+#endif
+        ret = palloc(size);
+    }
+    return ret;
+}
+
+static void
+rt_pgfree(void *mem)
+{
+#ifdef RT_PG_DEBUG_MEM
+    elog(NOTICE, "rt_pgfree(%p) calling pfree", mem);
+#endif
+    pfree(mem);
+}
+
+static void
+rt_pgerr(const char *fmt, ...)
+{
+    va_list ap;
+    char msg[1024];
+
+    va_start(ap, fmt);
+
+    vsnprintf(msg, 1023, fmt, ap);
+
+    elog(ERROR, "%s", msg);
+
+    va_end(ap);
+}
+
+static void
+rt_pgwarn(const char *fmt, ...)
+{
+    va_list ap;
+    char msg[1024];
+
+    va_start(ap, fmt);
+
+    vsnprintf(msg, 1023, fmt, ap);
+
+    elog(WARNING, "%s", msg);
+
+    va_end(ap);
+}
+
+static void
+rt_pginfo(const char *fmt, ...)
+{
+    va_list ap;
+    char msg[1024];
+
+    va_start(ap, fmt);
+
+    vsnprintf(msg, 1023, fmt, ap);
+
+    elog(INFO, "%s", msg);
+
+    va_end(ap);
+}
+
+
+static void
+init_context(FunctionCallInfoData *fcinfo)
+{
+    MemoryContext old_context;
+
+    if ( ctx ) return;
+
+    /* We switch memory context info so the rt_context
+     * is not freed by the end of function call
+     * TODO: check _which_ context we should be using
+     * for a whole-plugin-lifetime persistence */
+    old_context = MemoryContextSwitchTo(fcinfo->flinfo->fn_mcxt);
+    ctx = rt_context_new(rt_pgalloc, rt_pgrealloc, rt_pgfree);
+    MemoryContextSwitchTo(old_context);
+
+    rt_context_set_message_handlers(ctx, rt_pgerr, rt_pgwarn, rt_pginfo);
+}
+
+static void
+swap_char(unsigned char *a, unsigned char *b)
+{
+        unsigned char c;
+
+        c = *a;
+        *a=*b;
+        *b=c;
+}
+
+static void
+flip_endian_16(unsigned char *d)
+{
+        swap_char(d, d+1);
+}
+
+static void
+flip_endian_32(unsigned char *d)
+{
+        swap_char(d, d+3);
+        swap_char(d+1, d+2);
+}
+
+static void
+flip_endian_64(unsigned char *d)
+{
+        swap_char(d+7, d);
+        swap_char(d+6, d+1);
+        swap_char(d+5, d+2);
+        swap_char(d+4, d+3);
+}
+
+static rt_pgraster*
+rt_pgraster_from_hexwkb(char* hexwkb)
+{
+    char *str = hexwkb;
+    char* inptr, *inptrend;
+    unsigned char *outptr, *outptrend;
+    rt_pgraster *result;
+    int inSize, outSize;
+    int input_str_len;
+    unsigned char endian;
+    int numValues;
+    int t;
+
+    for (input_str_len=0; str[input_str_len] != '\0'; ++input_str_len)
+    {
+        char ch = str[input_str_len];
+        if ( !((ch >= 48 && ch <= 57)||(ch >= 65 && ch <= 70)) )
+        {
+            lwerror("rt_pgraster_from_hexwkb: "
+                "input contains bad characters. "
+                "Should only have '0123456789ABCDEF'!");
+            return 0;
+        }
+    }
+#ifdef RT_DEBUG
+    lwnotice("rt_pgraster_from_hexwkb: input_str_len: %d", input_str_len);
+#endif
+
+    if  ( input_str_len % 2 )
+    {
+        lwerror("rt_pgraster_from_hexwkb: "
+            "should be even number of characters!");
+        return 0;
+    }
+
+    inSize = (input_str_len/2);
+    /* +1 for the endian byte, -4 for padding (data) */
+    if (inSize < sizeof(rt_pgraster_header)+1 )
+    {
+        lwnotice("sizeof(rt_pgraster_header):%lu", sizeof(rt_pgraster_header));
+        lwerror("rt_pgraster_from_hexwkb: expected at least %d bytes, "
+            "got only %d", sizeof(rt_pgraster_header)+1, inSize);
+        return 0;
+    }
+
+    outSize = inSize+4-1; /* - endian + size */
+#ifdef RT_DEBUG
+    lwnotice("rt_pgraster_from_hexwkb: outSize: %d", outSize);
+#endif
+    result = (rt_pgraster *) lwalloc(outSize);
+
+    /* zero-out, to be sure sub-byte pixeltypes are padded with zeroes */
+    memset(result, 0, outSize);
+
+    inptr = str;
+    inptrend = inptr + input_str_len;
+
+    endian = parse_hex( inptr ); inptr+=2; // 2 chars for a single byte
+#ifdef RT_DEBUG
+    lwnotice("rt_pgraster_from_hexwkb: endian byte: %d", endian);
+#endif
+
+    outptr = (uchar*)result;
+    outptrend = outptr + outSize;
+
+    /* start writing at 5th byte (first 4 are for size) */
+    SET_VARSIZE(result, outSize);
+    outptr += 4;
+
+    while (inptr < inptrend )
+    {
+        char b = parse_hex( inptr ); inptr+=2;
+        *outptr = b;
+#ifdef RT_DEBUG
+        lwnotice("Byte at %x is %d", outptr, b);
+#endif
+        outptr+=1;
+    }
+
+    /* if endian is wrong, flip it otherwise do nothing */
+    if ( endian != getMachineEndian() )
+    {
+#ifdef RT_DEBUG
+        lwnotice("rt_pgraster_from_hexwkb: endian mismatch, swapping");
+#endif
+
+        /* need to do an endian flip */
+
+        flip_endian_16( (uchar *)&result->header.width );
+        flip_endian_16( (uchar *)&result->header.height );
+
+        flip_endian_32( (uchar *)&result->header.scaleX );
+        flip_endian_32( (uchar *)&result->header.scaleY );
+        flip_endian_32( (uchar *)&result->header.ipX );
+        flip_endian_32( (uchar *)&result->header.ipY );
+        flip_endian_32( (uchar *)&result->header.skewX );
+        flip_endian_32( (uchar *)&result->header.skewY );
+
+        flip_endian_32( (uchar *)&result->header.srid );
+        flip_endian_16( (uchar *)&result->header.numBands );
+
+        /* +1 for nodata value */
+        numValues = result->header.width*result->header.height+1;
+#ifdef RT_DEBUG
+        lwnotice("numValues: %d", numValues);
+#endif
+
+        /* position outptr to start of first band */
+        outptr = (uchar*)&result->data;
+        for (t=0; t<result->header.numBands; t++)
+        {
+            uint8_t pixtype;
+
+            pixtype = *outptr; outptr+=1;
+
+            switch (pixtype) {
+                case PT_1BB:
+                    /* No flipping required, just increment pointer */
+                    /* 1/8 byte each value */
+                    outptr += (int)ceilf(numValues/8);
+                    break;
+
+                case PT_2BUI:
+                    /* No flipping required, just increment pointer */
+                    /* 2/8 bytes each value */
+                    outptr += (int)ceil(numValues/4);
+                    break;
+
+                case PT_4BUI:
+                    /* No flipping required, just increment pointer */
+                    /* 4/8 bytes each value */
+                    outptr += (int)ceil(numValues/2);
+                    break;
+
+                case PT_8BSI:
+                case PT_8BUI:
+                    /* Up to 8bit, we do no flipping */
+                    outptr += numValues; /* 1 byte each value */
+                    break;
+
+                case PT_16BSI:
+                case PT_16BUI:
+                case PT_16BF:
+                {
+                    int v;
+                    for (v=0; v<numValues; ++v)
+                    {
+                        flip_endian_16(outptr);
+                        outptr += 2;
+                    }
+                    break;
+                }
+
+                case PT_32BSI:
+                case PT_32BUI:
+                case PT_32BF:
+                {
+                    int v;
+                    for (v=0; v<numValues; ++v)
+                    {
+                        flip_endian_32(outptr);
+                        outptr += 4;
+                    }
+                    break;
+                }
+
+                case PT_64BF:
+                {
+                    int v;
+                    for (v=0; v<numValues; ++v)
+                    {
+                        flip_endian_64(outptr);
+                        outptr += 8;
+                    }
+                    break;
+                }
+
+                default:
+                    lwerror("rt_raster_from_hexwkb: "
+                        "unknown pixel type %d", pixtype);
+                    lwfree(result);
+                    return 0; /* lwfree ? */
+                    break;
+            }
+
+            if ( outptr > outptrend )
+            {
+                lwerror("Premature end of input "
+                    "(output pointer %p got past "
+                    "end of allocated memory %p)",
+                    outptr, outptrend);
+                return 0;
+            }
+        }
+    }
+
+#ifdef RT_DEBUG
+    lwnotice("rt_raster_from_hexwkb: Raster width @ %p",
+        &(result->width));
+    lwnotice("rt_raster_from_hexwkb: Raster height @ %p",
+        &(result->height));
+
+    lwnotice("rt_raster_from_hexwkb: Raster dims: %dx%d",
+        result->width, result->height);
+    lwnotice("rt_raster_from_hexwkb: Raster scale: %gx%g",
+        result->scaleX, result->scaleY);
+    lwnotice("rt_raster_from_hexwkb: Raster ip: %gx%g",
+        result->ipX, result->ipY);
+    lwnotice("rt_raster_from_hexwkb: Raster skew: %gx%g",
+        result->skewX, result->skewY );
+    lwnotice("rt_raster_from_hexwkb: Raster srid: %d",
+        result->srid);
+    lwnotice("rt_raster_from_hexwkb: Raster numBands: %d",
+        result->numBands);
+#endif
+
+    return result;
+}
+
+
+/*
+ * Input is a string with hex chars in it. 
+ * Convert to binary and put in the result
+ */
+PG_FUNCTION_INFO_V1(RASTER_in);
+Datum RASTER_in(PG_FUNCTION_ARGS)
+{
+    char *str = PG_GETARG_CSTRING(0);
+    rt_pgraster *result = rt_pgraster_from_hexwkb(str);
+#if 1 // testing
+    rt_raster raster;
+
+    init_context(fcinfo);
+    raster = rt_pgraster_deserialize(ctx, result); 
+#endif
+
+    if ( result ) PG_RETURN_POINTER(result);
+    else PG_RETURN_NULL();
+}
+
+/*given a RASTER structure, convert it to Hex and put it in a string */
+PG_FUNCTION_INFO_V1(RASTER_out);
+Datum RASTER_out(PG_FUNCTION_ARGS)
+{
+    rt_pgraster *pgraster = (rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
+
+    char *result;
+    int size_result;
+    unsigned char endian = getMachineEndian();
+    int i;
+    size_t size = VARSIZE(pgraster);
+
+#if 1 // testing
+    rt_raster raster;
+
+    init_context(fcinfo);
+    raster = rt_pgraster_deserialize(ctx, pgraster); 
+#endif
+
+    size_result = (size-4+1)*2; /* +1 for endian -4 for the size field */
+    ++size_result; /* this for the terminating NULL */
+    result = palloc (size_result);
+
+    /* zero-out, to be sure sub-byte pixeltypes are padded with zeroes */
+    memset(result, 0, size_result);
+
+#if RT_DEBUG
+    lwnotice("RASTER_out: %dx%d raster, %d in size "
+        "(becoming %d in hex + null)",
+        pgraster->width, pgraster->height,
+        size, size_result);
+#endif
+
+    /* First byte of serialized form is endian */
+    deparse_hex(endian, &result[0]);
+
+    /* first 4 bytes is VARLENA size, we skip that */
+    for (i=4; i<size; i++)
+    {
+        deparse_hex(((uchar *)pgraster)[i], &result[2+(i-4)*2]);
+    }
+
+    result[size_result-1] = '\0'; /*null terminate */
+
+    PG_RETURN_CSTRING(result);  
+}
+
+static rt_raster
+rt_pgraster_deserialize(rt_context ctx, rt_pgraster *pgraster)
+{
+    rt_raster raster;
+    uint16_t i;
+    unsigned char* ptr;
+    rt_pgraster_header* header = &pgraster->header;
+
+    raster = rt_raster_new(ctx, header->width,
+            header->height);
+    if ( ! raster ) {
+        lwerror("Could not create raster "
+                "during deserialization of rt_pgraster");
+        return 0;
+    }
+
+    rt_raster_set_pixel_sizes(ctx, raster, header->scaleX, header->scaleY);
+    rt_raster_set_offsets(ctx, raster, header->ipX, header->ipY);
+    rt_raster_set_rotations(ctx, raster, header->skewX, header->skewY);
+    rt_raster_set_srid(ctx, raster, header->srid);
+
+    ptr = pgraster->data;
+    for (i=0; i<header->numBands; ++i)
+    {
+        rt_pgband* pgband;
+        rt_band band;
+        rt_pixtype pixtype;
+
+        /* this cast is only safe if ptr is aligned to sizeof(rt_pgband)
+         * bytes. Since rt_pgband size is 2 bytes, we need rt_pgraster's
+         * data member to be aligned there, plus any band be padded 
+         * as much as required so that next rt_pgband is aligned too
+         *
+         */
+        pgband = (rt_pgband*)ptr;
+
+        pixtype = pgband->pixtype;
+        lwnotice("Pixtype of band %d is %d",i, pixtype);
+
+        band = rt_band_new(ctx, pixtype, header->width, header->height);
+        if ( ! band ) {
+            lwerror("Could not create band "
+                "during deserialization of rt_pgraster");
+            return 0;
+        }
+
+        switch (pixtype)
+        {
+            case PT_1BB:
+            case PT_2BUI:
+            case PT_4BUI:
+            case PT_8BSI:
+            case PT_8BUI:
+                rt_band_set_data(ctx, band, ((rt_pgband8*)pgband)->data);
+                break;
+            case PT_16BSI:
+            case PT_16BUI:
+            case PT_16BF:
+                rt_band_set_data(ctx, band, ((rt_pgband16*)pgband)->data);
+                break;
+            case PT_32BSI:
+            case PT_32BUI:
+            case PT_32BF:
+                rt_band_set_data(ctx, band, ((rt_pgband32*)pgband)->data);
+                break;
+            case PT_64BF:
+                rt_band_set_data(ctx, band, ((rt_pgband64*)pgband)->data);
+                break;
+            default:
+                lwerror("Unknown pixtype at %s:%d", __FILE__, __LINE__);
+                break;
+        }
+
+        ptr += rt_band_get_data_size(ctx, band);
+
+        /* This one currently reallocs */
+        rt_raster_add_band(ctx, raster, band);
+    }
+    
+
+    return raster;
+}
+
+/* ---------------------------------------------------------------- */
+/*  Memory allocation / error reporting hooks                       */
+/* ---------------------------------------------------------------- */
+
+static void *
+rt_pg_alloc(size_t size)
+{
+	void * result;
+
+	result = palloc(size);
+
+	if ( ! result )
+	{
+		ereport(ERROR, (errmsg_internal("Out of virtual memory")));
+		return NULL;
+	}
+	return result;
+}
+
+static void *
+rt_pg_realloc(void *mem, size_t size)
+{
+	void * result;
+
+	result = repalloc(mem, size);
+
+	return result;
+}
+
+static void
+rt_pg_free(void *ptr)
+{
+	pfree(ptr);
+}
+
+static void
+rt_pg_error(const char *fmt, va_list ap)
+{
+#define ERRMSG_MAXLEN 256
+
+	char errmsg[ERRMSG_MAXLEN+1];
+
+	vsnprintf (errmsg, ERRMSG_MAXLEN, fmt, ap);
+
+	errmsg[ERRMSG_MAXLEN]='\0';
+	ereport(ERROR, (errmsg_internal("%s", errmsg)));
+}
+
+static void
+rt_pg_notice(const char *fmt, va_list ap)
+{
+	char *msg;
+
+	/*
+	 * This is a GNU extension.
+	 * Dunno how to handle errors here.
+	 */
+	if (!lw_vasprintf (&msg, fmt, ap))
+	{
+		va_end (ap);
+		return;
+	}
+	ereport(NOTICE, (errmsg_internal("%s", msg)));
+	free(msg);
+}
+
+
+/* This is needed by liblwgeom */
+void
+lwgeom_init_allocators(void)
+{
+    /* liblwgeom callback - install PostgreSQL handlers */
+    lwalloc_var = rt_pg_alloc;
+    lwrealloc_var = rt_pg_realloc;
+    lwfree_var = rt_pg_free;
+
+    lwerror_var = rt_pg_error;
+    lwnotice_var = rt_pg_notice;
+}
+
+/* ---------------------------------------------------------------- */
+/*  Memory allocation / error reporting hooks                       */
+/* ---------------------------------------------------------------- */

Added: spike/wktraster/rt_pg/rt_pg.h
===================================================================
--- spike/wktraster/rt_pg/rt_pg.h	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_pg/rt_pg.h	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,95 @@
+/* 
+ * WKTRaster - Raster Types for PostGIS
+ * http://www.postgis.org/support/wiki/index.php?WKTRasterHomePage
+ *
+ * Copyright (C) 2009  Sandro Santilli <strk at keybit.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef RT_PG_H
+#define RT_PG_H
+
+#include <stdint.h> /* for int16_t and friends */
+
+#include "rt_api.h"
+
+typedef struct rt_pgband8_t {
+    uint8_t pixtype;
+    uint8_t data[1];
+} rt_pgband8;
+
+typedef struct rt_pgband16_t {
+    uint8_t pixtype;
+    uint8_t pad;
+    uint8_t data[1];
+} rt_pgband16;
+
+typedef struct rt_pgband32_t {
+    uint8_t pixtype;
+    uint8_t pad0;
+    uint8_t pad1;
+    uint8_t pad2;
+    uint8_t data[1];
+} rt_pgband32;
+
+typedef struct rt_pgband64_t {
+    uint8_t pixtype;
+    uint8_t pad[7];
+    uint8_t data[1];
+} rt_pgband64;
+
+typedef struct rt_pgband_t {
+    uint8_t pixtype;
+    uint8_t data[1];
+} rt_pgband;
+
+typedef struct rt_pgraster_header_t {
+    /* Raster dimensions: 4bytes */
+    uint16_t width;  /* pixel columns - max 65535 */
+    uint16_t height; /* pixel rows - max 65535 */
+
+    /* Georeference (in projection units) : 24bytes */
+    float scaleX; /* pixel width */
+    float scaleY; /* pixel height */
+    float ipX;    /* geo x ordinate of the middle of upper-left pixel */
+    float ipY;    /* geo y ordinate of the middle of bottom-right pixel */
+    float skewX;  /* unused ? */
+    float skewY;  /* unused ? */
+
+    int32_t srid; /* spatial reference id */
+
+    /* 32 bytes up to here */
+
+    /* Number of bands, all share the same dimension
+     * and georeference */
+    uint16_t numBands; 
+
+    uint16_t future; 
+} rt_pgraster_header;
+
+/* PostgreSQL-stored RASTER value, and binary representation of it */
+typedef struct rt_pgraster_t {
+    uint32_t size;     /* varlena header (do not touch directly!) */
+
+    struct rt_pgraster_header_t header;
+
+    /* The actual serialized form continues with all bands */
+    uint8_t data[1]; 
+
+} rt_pgraster;
+
+#endif /* RT_PG_H */

Added: spike/wktraster/rt_pg/rtpostgis.sql.in.c
===================================================================
--- spike/wktraster/rt_pg/rtpostgis.sql.in.c	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_pg/rtpostgis.sql.in.c	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,50 @@
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+-- 
+-- $Id$
+--
+-- WKTRaster - Raster Type for PostGIS 
+-- http://postgis.refractions.net/support/wiki/index.php?WKTRasterHomePage
+--
+-- Copyright (c) 2009 Sandro Santilli <strk at keybit.net>
+--
+-- This is free software; you can redistribute and/or modify it under
+-- the terms of the GNU General Public Licence. See the COPYING file.
+--  
+-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+#define CREATEFUNCTION CREATE OR REPLACE FUNCTION
+#define _IMMUTABLE_STRICT IMMUTABLE STRICT
+#define _IMMUTABLE IMMUTABLE
+#define _STABLE_STRICT STABLE STRICT
+#define _STABLE STABLE
+#define _VOLATILE_STRICT VOLATILE STRICT
+#define _VOLATILE VOLATILE
+#define _STRICT STRICT
+#define _SECURITY_DEFINER SECURITY DEFINER
+
+BEGIN;
+
+-------------------------------------------------------------------
+--  CHIP TYPE
+-------------------------------------------------------------------
+
+CREATEFUNCTION rt_raster_in(cstring)
+	RETURNS raster 
+	AS 'MODULE_PATHNAME','RASTER_in'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; 
+
+CREATEFUNCTION rt_raster_out(raster)
+	RETURNS cstring 
+	AS 'MODULE_PATHNAME','RASTER_out'
+	LANGUAGE 'C' _IMMUTABLE_STRICT; 
+
+CREATE TYPE raster (
+	alignment = double,
+	internallength = variable,
+	input = rt_raster_in,
+	output = rt_raster_out,
+	storage = extended
+);
+
+COMMIT;
+

Added: spike/wktraster/rt_pg/test/io.sql
===================================================================
--- spike/wktraster/rt_pg/test/io.sql	2009-01-27 05:30:40 UTC (rev 3570)
+++ spike/wktraster/rt_pg/test/io.sql	2009-01-27 16:26:57 UTC (rev 3571)
@@ -0,0 +1,705 @@
+DROP TABLE rt_test;
+
+CREATE TABLE rt_test (
+        id numeric,
+        name text,
+        hexwkb_ndr text,
+        hexwkb_xdr text,
+        rast raster
+    );
+
+-- 1x1, no bands,  no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 0, '1x1 no bands, no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0000' -- nBands (uint16 1)
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0000' -- nBands (uint16 1)
+));
+
+-- 1x1, single band of type 1BB, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 1, '1x1 single band (1BB) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'00' -- first band type (1BB)
+||
+'40' -- 0100.0000 -- novalue==0, pixat(1,1)==1
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'00' -- first band type (1BB)
+||
+'40' -- 0100.0000 -- novalue==0, pixat(1,1)==1
+) );
+
+-- 1x1, single band of type 2BUI, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 2, '1x1 single band (2BUI) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'01' -- first band type (2BUI)
+||
+'30' -- 0011.0000 -- novalue==0, pixel(1,1)==3
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'01' -- first band type (2BUI)
+||
+'30' -- 0011.0000 -- novalue==0, pixel(1,1)==3
+) );
+
+-- 1x1, single band of type 4BUI, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 3, '1x1 single band (4BUI) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'02' -- first band type (4BUI)
+||
+'0F' -- 0000.1111 -- novalue==0, pixel(1,1)=15
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'02' -- first band type (1BB)
+||
+'0F' -- 0000.1111 -- novalue==0, pixel(1,1)=15
+) );
+
+-- 1x1, single band of type 8BSI, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 4, '1x1 single band (8BSI) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'03' -- first band type (8BSI)
+||
+'00FF' -- 0000.0000 1111.1111 -- novalue==0, pixel(1,1)=-1
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'03' -- first band type (8BSI)
+||
+'00FF' -- 0000.0000 1111.1111 -- novalue==0, pixel(1,1)=-1
+) );
+
+-- 1x1, single band of type 8BUI, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 5, '1x1 single band (8BUI) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'04' -- first band type (8BUI)
+||
+'00FF' -- 0000.0000 1111.1111 -- novalue==0, pixel(1,1)=255
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'04' -- first band type (8BUI)
+||
+'00FF' -- 0000.0000 1111.1111 -- novalue==0, pixel(1,1)=255
+) );
+
+-- 1x1, single band of type 16BSI, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 6, '1x1 single band (16BSI) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'05' -- first band type (16BSI)
+||
+'0000FFFF' -- novalue==0, pixel(1,1)=-1
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'05' -- first band type (16BSI)
+||
+'0000FFFF' -- novalue==0, pixel(1,1)=-1
+) );
+
+-- 1x1, single band of type 16BUI, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 7, '1x1 single band (16BUI) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'06' -- first band type (16BUI)
+||
+'0000FFFF' -- novalue==0, pixel(1,1)=65535
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'06' -- first band type (16BUI)
+||
+'0000FFFF' -- novalue==0, pixel(1,1)=65535
+) );
+
+-- 1x1, single band of type 32BSI, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 8, '1x1 single band (32BSI) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'07' -- first band type (32BSI)
+||
+'00000000FFFFFFFF' -- novalue==0, pixel(1,1)=-1
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'07' -- first band type (32BSI)
+||
+'00000000FFFFFFFF' -- novalue==0, pixel(1,1)=-1
+) );
+
+-- 1x1, single band of type 32BUI, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 9, '1x1 single band (32BUI) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'08' -- first band type (32BUI)
+||
+'00000000FFFFFFFF' -- novalue==0, pixel(1,1)=4294967295
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'08' -- first band type (32BUI)
+||
+'00000000FFFFFFFF' -- novalue==0, pixel(1,1)=4294967295
+) );
+
+-- 1x1, single band of type 16BF, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 10, '1x1 single band (16BF) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'09' -- first band type (16BF)
+||
+'0000'||'8C3F' -- novalue==0, pixel(1,1)=??
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'09' -- first band type (16BF)
+||
+'0000'||'3F8C' -- novalue==0, pixel(1,1)=??
+) );
+
+-- 1x1, single band of type 32BF, no transform, scale 1:1
+INSERT INTO rt_test (id, name, hexwkb_ndr, hexwkb_xdr)
+VALUES ( 11, '1x1 single band (32BF) no transform',
+(
+'01' -- little endian (uint8 ndr)
+|| 
+'0100' -- width (uint16 1)
+||
+'0100' -- height (uint16 1)
+||
+'0000803F' -- scaleX (float32 1)
+||
+'0000803F' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0A000000' -- SRID (int32 10)
+||
+'0100' -- nBands (uint16 1)
+||
+'0B' -- first band type (64BF)
+||
+'0000000000000000'||'AE47E17A14AE1540' -- novalue==0, pixel(1,1)=5.42
+),
+(
+'00' -- big endian (uint8 xdr)
+|| 
+'0001' -- width (uint16 1)
+||
+'0001' -- height (uint16 1)
+||
+'3F800000' -- scaleX (float32 1)
+||
+'3F800000' -- scaleY (float32 1)
+||
+'00000000' -- ipX (float32 0)
+||
+'00000000' -- ipY (float32 0)
+||
+'00000000' -- skewX (float32 0)
+||
+'00000000' -- skewY (float32 0)
+||
+'0000000A' -- SRID (int32 10)
+||
+'0001' -- nBands (uint16 1)
+||
+'0B' -- first band type (64BF)
+||
+'0000000000000000'||'4015AE147AE147AE' -- novalue==0, pixel(1,1)=5.42
+) );
+
+-- TODO:
+-- * EXT
+
+SELECT name,
+    hexwkb_ndr::raster::text = hexwkb_ndr as ndr_io, 
+    hexwkb_xdr::raster::text = hexwkb_ndr as xdr_io
+FROM rt_test;



More information about the postgis-commits mailing list