summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Makholm <henning@makholm.net>2006-01-27 18:00:00 (EST)
committer Julien Jorge <julien.jorge@stuff-o-matic.com>2013-01-10 16:00:40 (EST)
commit7b7cd6da61b1fcc0f2a3ecce2cb9e6c42782c717 (patch)
tree98d2772f50aaddb02ac94492d2b8b151aa3e9465
downloadxcftools-7b7cd6da61b1fcc0f2a3ecce2cb9e6c42782c717.zip
xcftools-7b7cd6da61b1fcc0f2a3ecce2cb9e6c42782c717.tar.gz
xcftools-7b7cd6da61b1fcc0f2a3ecce2cb9e6c42782c717.tar.bz2
Import of release 0.7
-rw-r--r--.cvsignore17
-rw-r--r--COPYING340
-rw-r--r--ChangeLog18
-rw-r--r--Makefile.in180
-rw-r--r--README69
-rw-r--r--TODO12
-rw-r--r--aclocal.m4934
-rwxr-xr-xconfig.guess1466
-rw-r--r--config.hin86
-rw-r--r--config.rpath2
-rwxr-xr-xconfig.sub1579
-rwxr-xr-xconfigure5895
-rw-r--r--configure.ac56
-rw-r--r--dist-generated4
-rw-r--r--flatspec.c339
-rw-r--r--flatten.c557
-rw-r--r--flatten.h72
-rw-r--r--gimp/base-enums.h146
-rw-r--r--gimp/gimpbaseenums.h196
-rw-r--r--gimp/xcf-private.h94
-rwxr-xr-xinstall-sh269
-rw-r--r--io-unix.c176
-rw-r--r--mancombine.pl56
-rw-r--r--mkenumsc.pl85
-rw-r--r--mkenumsh.pl60
-rw-r--r--mkopti.pl164
-rw-r--r--mktablec.pl67
-rw-r--r--options.i392
-rw-r--r--palette.c110
-rw-r--r--palette.h52
-rw-r--r--pixels.c483
-rw-r--r--pixels.h118
-rw-r--r--test/Makefile8
-rw-r--r--test/README27
-rw-r--r--test/answer/Addition.pngbin0 -> 1236 bytes
-rw-r--r--test/answer/Burn.pngbin0 -> 1501 bytes
-rw-r--r--test/answer/DarkenOnly.pngbin0 -> 1056 bytes
-rw-r--r--test/answer/Difference.pngbin0 -> 1823 bytes
-rw-r--r--test/answer/Divide.pngbin0 -> 1750 bytes
-rw-r--r--test/answer/Dodge.pngbin0 -> 2076 bytes
-rw-r--r--test/answer/GrainExtract.pngbin0 -> 1523 bytes
-rw-r--r--test/answer/GrainMerge.pngbin0 -> 1506 bytes
-rw-r--r--test/answer/Hardlight.pngbin0 -> 2142 bytes
-rw-r--r--test/answer/LightenOnly.pngbin0 -> 1035 bytes
-rw-r--r--test/answer/Multiply.pngbin0 -> 2255 bytes
-rw-r--r--test/answer/Overlay.pngbin0 -> 1364 bytes
-rw-r--r--test/answer/Screen.pngbin0 -> 2235 bytes
-rw-r--r--test/answer/Subtract.pngbin0 -> 1438 bytes
-rw-r--r--test/answer/burmid.pngbin0 -> 234 bytes
-rw-r--r--test/answer/comptest.pngbin0 -> 374 bytes
-rw-r--r--test/answer/comptestB.pngbin0 -> 692 bytes
-rw-r--r--test/answer/crisp1.pngbin0 -> 248 bytes
-rw-r--r--test/answer/crisp2.pngbin0 -> 118 bytes
-rw-r--r--test/answer/doodle.pngbin0 -> 559 bytes
-rw-r--r--test/answer/gray.pngbin0 -> 1725 bytes
-rw-r--r--test/answer/i255t.pngbin0 -> 1563 bytes
-rw-r--r--test/answer/i255tt.pngbin0 -> 1576 bytes
-rw-r--r--test/answer/index255.pngbin0 -> 1284 bytes
-rw-r--r--test/answer/index256.pngbin0 -> 1284 bytes
-rw-r--r--test/answer/index4.pngbin0 -> 309 bytes
-rw-r--r--test/answer/indextest.pngbin0 -> 438 bytes
-rw-r--r--test/answer/mid.pngbin0 -> 281 bytes
-rw-r--r--test/answer/misc1.pngbin0 -> 2182 bytes
-rw-r--r--test/answer/modeA.pngbin0 -> 243 bytes
-rw-r--r--test/answer/modeB.pngbin0 -> 491 bytes
-rw-r--r--test/answer/mono.pngbin0 -> 1004 bytes
-rw-r--r--test/answer/mono1.pngbin0 -> 307 bytes
-rw-r--r--test/answer/odoodle.pngbin0 -> 1036 bytes
-rw-r--r--test/answer/tiletest.pngbin0 -> 8542 bytes
-rwxr-xr-xtest/dotest506
-rw-r--r--test/pngtype.pl58
-rw-r--r--test/source/comptest.xcf.gzbin0 -> 1788 bytes
-rw-r--r--test/source/i255.xcf.gzbin0 -> 1211 bytes
-rw-r--r--test/source/i256.xcf.gzbin0 -> 1215 bytes
-rw-r--r--test/source/indextest.xcf.gzbin0 -> 941 bytes
-rw-r--r--test/source/mkbase.i60
-rw-r--r--test/source/mkgradient256.pl6
-rw-r--r--test/source/mkmodebase.c50
-rw-r--r--test/source/mktile0.pl15
-rw-r--r--test/source/mktile1.c35
-rw-r--r--test/source/modetest.xcf.gzbin0 -> 836 bytes
-rw-r--r--test/source/tiletest.xcf.gzbin0 -> 11130 bytes
-rw-r--r--utils.c164
-rw-r--r--xcf-general.c273
-rw-r--r--xcf2png.10161
-rw-r--r--xcf2png.c426
-rw-r--r--xcf2pnm.10199
-rw-r--r--xcf2pnm.c271
-rw-r--r--xcfinfo.10115
-rw-r--r--xcfinfo.c101
-rw-r--r--xcftools.h183
91 files changed, 16752 insertions, 0 deletions
diff --git a/.cvsignore b/.cvsignore
new file mode 100644
index 0000000..420576e
--- /dev/null
+++ b/.cvsignore
@@ -0,0 +1,17 @@
+Makefile
+autom4te.cache
+config.h
+config.hin
+config.log
+config.status
+aclocal.m4
+configure
+enums.[ch]
+table.c
+xcfinfo
+xcf2pnm
+xcf2png
+*.1i
+*.1il
+*.1
+*.oi
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..d60c31a
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,340 @@
+ 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) <year> <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) year 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.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..5352d5b
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,18 @@
+2006-01-28 Henning Makholm <henning@makholm.net>
+
+ * Version 0.7
+ * xcf2png added
+ * Test suite added
+ * Various bug fixes
+
+2006-01-24 Henning Makholm <henning@makholm.net>
+
+ * Version 0.6
+ * Allow X11 color names with -b option
+
+2006-01-22 Henning Makholm <henning@makholm.net>
+
+ * Version 0.5
+ * First public release
+ - xcfinfo
+ - xcf2pnm
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..57ea4f9
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,180 @@
+# Makefile(.in) for xcftools
+# Copyright (C) 2006 Henning Makholm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# 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
+
+all:
+
+@SET_MAKE@
+
+srcdir = @srcdir@
+prefix = @prefix@
+exec_prefix = @exec_prefix@
+bindir = @bindir@
+mandir = @mandir@
+sysconfdir = @sysconfdir@
+
+VERSION = @PACKAGE_VERSION@
+APPNAME = @PACKAGE_TARNAME@
+program_transform_name = @program_transform_name@
+
+CFLAGS = @CFLAGS@
+LDFLAGS = @LDFLAGS@
+LIBS = @LIBS@
+
+INSTALL = @INSTALL@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_DATA = @INSTALL_DATA@
+
+RM = rm -f
+SED = sed
+PERL = @PERL@
+
+o = @OBJEXT@
+e = @EXEEXT@
+
+#############################################################################
+
+FILEIO = io-unix
+
+BINARIES = xcfinfo$e xcf2pnm$e xcf2png$e
+MANPAGES = $(patsubst %$e,%.1,$(BINARIES))
+
+%.$o: %.c
+ $(CC) $(CFLAGS) -o $@ -c $<
+
+all: $(BINARIES) $(MANPAGES)
+
+xcfinfo$e: xcfinfo.$o $(FILEIO).$o enums.$o xcf-general.$o utils.$o
+ $(CC) $(LDFLAGS) $(LIBS) $^ -o $@
+
+xcf2pnm$e: xcf2pnm.$o $(FILEIO).$o enums.$o xcf-general.$o utils.$o \
+ pixels.$o flatten.$o flatspec.$o table.$o
+ $(CC) $(LDFLAGS) $(LIBS) $^ -o $@
+
+xcf2png$e: xcf2png.$o $(FILEIO).$o enums.$o xcf-general.$o utils.$o \
+ pixels.$o flatten.$o flatspec.$o table.$o palette.$o
+ $(CC) $(LDFLAGS) $(LIBS) -lpng $^ -o $@
+
+testscale$e: testscale.$o
+ $(CC) $(LDFLAGS) $(LIBS) $^ -o $@
+
+install: all
+ for p in $(BINARIES) ; do \
+ $(INSTALL_PROGRAM) -s $$p \
+ $(bindir)/`echo $$p | $(SED) $(program_transform_name)` ; \
+ done
+ for m in $(MANPAGES) ; do \
+ $(INSTALL_DATA) $$m \
+ $(mandir)/man1/`echo $$m | $(SED) $(program_transform_name)` ; \
+ done
+
+ENUMSOURCES = gimp/base-enums.h gimp/gimpbaseenums.h gimp/xcf-private.h
+enums.h: mkenumsh.pl $(ENUMSOURCES)
+ $(PERL) $< $(ENUMSOURCES) > $@
+enums.c: mkenumsc.pl enums.h
+ $(PERL) $< enums.h > $@
+table.c: mktablec.pl
+ $(PERL) $< > $@
+
+%.oi: options.i mkopti.pl config.h
+ $(PERL) mkopti.pl $*
+
+%.1: %.oi %.10 config.h mancombine.pl
+ $(PERL) mancombine.pl $*.10 > $@
+
+#############################################################################
+#
+# Dependency tracking, by hand
+
+COMMON_HEADERS = xcftools.h config.h enums.h
+enums.$o: enums.h
+table.$o: $(COMMON_HEADERS) pixels.h
+io-unix.$o: $(COMMON_HEADERS)
+xcf-general.$o: $(COMMON_HEADERS)
+utils.$o: $(COMMON_HEADERS)
+pixels.$o: $(COMMON_HEADERS) pixels.h
+palette.$o: $(COMMON_HEADERS) pixels.h flatten.h palette.h
+flatten.$o: $(COMMON_HEADERS) pixels.h flatten.h
+flatspec.$o: $(COMMON_HEADERS) pixels.h flatten.h
+xcfinfo.$o: $(COMMON_HEADERS) xcfinfo.oi
+xcf2pnm.$o: $(COMMON_HEADERS) pixels.h flatten.h xcf2pnm.oi
+xcf2png.$o: $(COMMON_HEADERS) pixels.h flatten.h xcf2png.oi palette.h
+
+#############################################################################
+#
+# Standard cleaning and other metarules
+
+check: $(BINARIES)
+ cd test && $(MAKE) check
+
+clean:
+ $(RM) *.$o *~ .*~ *.1i *.1il *.1 *.oi
+ $(RM) enums.h enums.c table.c $(BINARIES)
+ cd test && $(MAKE) clean
+
+distclean: clean
+ $(RM) Makefile config.log config.cache config.status config.h
+ $(RM) -r autom4te.cache
+
+realclean: distclean
+ $(RM) configure config.hin aclocal.m4
+
+.SUFFIXES: .c .$o
+
+.PHONY: clean distclean realclean dist all
+
+#############################################################################
+#
+# Tarball-making rule
+
+dist: ajour distclean
+ noncvs > notcvsfiles || cp dist-generated notcvsfiles
+ diff -u dist-generated notcvsfiles
+ $(RM) notcvsfiles
+ find . -type f -print | grep -v CVS | \
+ sed 's!^\./!$(APPNAME)-$(VERSION)/!' | sort -o tar-manifest
+ ln -s . $(APPNAME)-$(VERSION)
+ tar cvzf $(APPNAME)-$(VERSION).tar.gz `cat tar-manifest`
+ rm tar-manifest
+ rm $(APPNAME)-$(VERSION)
+
+#############################################################################
+#
+# Autofoo rules:
+
+aclocal.m4: configure.ac
+ aclocal
+
+$(srcdir)/configure: configure.ac aclocal.m4
+ cd $(srcdir) && autoconf
+
+$(srcdir)/config.hin: configure.ac aclocal.m4
+ cd $(srcdir) && autoheader
+ touch $@
+
+config.status: $(srcdir)/configure
+ ./config.status --recheck
+
+Makefile: Makefile.in config.status
+ ./config.status $@
+
+config.h: config.hin config.status
+ ./config.status $@
+ touch $@
+
+ajour: Makefile config.h config.sub config.guess
+
+config.sub config.guess:
+ -test -r /usr/share/misc/$@ && cp /usr/share/misc/$@ . \ No newline at end of file
diff --git a/README b/README
new file mode 100644
index 0000000..60eef04
--- /dev/null
+++ b/README
@@ -0,0 +1,69 @@
+What is this?
+=============
+
+Xcftools is a set of fast command-line tools for extracting
+information from the Gimp's native file format XCF. The tools
+are designed to allow efficient use of layered XCF files as
+sources in a build system that use 'make' and similar tools
+to manage automatic processing of the graphics. These tools
+work independently of the Gimp engine and do not require the
+Gimp to even be installed.
+
+ xcf2pnm converts XCF files to ppm, pgm or pbm format,
+ flattening layers if necessary. If the image
+ contains transparency, an alpha map can be written
+ to a separate file, or a background color can be
+ specified on the command line.
+
+ xcf2png converts XCF files to PNG format, flattening
+ layers if necessary. Transparency information
+ can be kept in the image, or a background color
+ can be specified on the command line.
+
+ xcfinfo lists information about layers in an XCF file.
+
+The tools can either flatten an XCF file as given, or extract specific
+layers named on the command line.
+
+Portability
+===========
+
+The software was developed on an Intel-based pc running Debian
+GNU/Linux. It ought to work on other Linux variants also. I would
+not be surprised if it ran on other unix systems too, but porting
+to non-unix platforms will require some work. Most of the code
+attempts to be prepared for porting, but this has not been
+explicitly tested.
+
+Installation
+============
+
+You need GNU make, a C compiler, and perl.
+
+After the source archive is extracted, the command sequence
+ ./configure
+ make all
+ make install
+should compile the tools and install them in /usr/local.
+
+The 'configure' script is generated by GNU autoconf, and accepts
+the arguments that such scripts commonly do.
+
+License
+=======
+
+Xcftools is written by Henning Makholm <henning@makholm.net>
+(Copyright 2006).
+
+Xcftools is free software; you can redistribute it and/or modify
+it under the terms of version 2 of the GNU General Public License as
+published by the Free Software Foundation.
+
+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
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..b182571
--- /dev/null
+++ b/TODO
@@ -0,0 +1,12 @@
+These are things I want to do before bumping the version
+number of Xcftools to 1.0:
+
+- Add tests of error reporting to the test suite.
+
+- Get the program tested on various architectures.
+
+- Finish localization infrastucture (some work has been done
+ but is not completely systematic).
+
+
+
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644
index 0000000..354f591
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,934 @@
+# aclocal.m4 generated automatically by aclocal 1.6.3 -*- Autoconf -*-
+
+# Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
+# Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+# iconv.m4 serial AM4 (gettext-0.11.3)
+dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
+[
+ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+
+ dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
+ dnl accordingly.
+ AC_LIB_LINKFLAGS_BODY([iconv])
+])
+
+AC_DEFUN([AM_ICONV_LINK],
+[
+ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
+ dnl those with the standalone portable GNU libiconv installed).
+
+ dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
+ dnl accordingly.
+ AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
+
+ dnl Add $INCICONV to CPPFLAGS before performing the following checks,
+ dnl because if the user has installed libiconv and not disabled its use
+ dnl via --without-libiconv-prefix, he wants to use it. The first
+ dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
+ am_save_CPPFLAGS="$CPPFLAGS"
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
+
+ AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
+ am_cv_func_iconv="no, consider installing GNU libiconv"
+ am_cv_lib_iconv=no
+ AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+ [iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ am_cv_func_iconv=yes)
+ if test "$am_cv_func_iconv" != yes; then
+ am_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBICONV"
+ AC_TRY_LINK([#include <stdlib.h>
+#include <iconv.h>],
+ [iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);],
+ am_cv_lib_iconv=yes
+ am_cv_func_iconv=yes)
+ LIBS="$am_save_LIBS"
+ fi
+ ])
+ if test "$am_cv_func_iconv" = yes; then
+ AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
+ fi
+ if test "$am_cv_lib_iconv" = yes; then
+ AC_MSG_CHECKING([how to link with libiconv])
+ AC_MSG_RESULT([$LIBICONV])
+ else
+ dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
+ dnl either.
+ CPPFLAGS="$am_save_CPPFLAGS"
+ LIBICONV=
+ LTLIBICONV=
+ fi
+ AC_SUBST(LIBICONV)
+ AC_SUBST(LTLIBICONV)
+])
+
+AC_DEFUN([AM_ICONV],
+[
+ AM_ICONV_LINK
+ if test "$am_cv_func_iconv" = yes; then
+ AC_MSG_CHECKING([for iconv declaration])
+ AC_CACHE_VAL(am_cv_proto_iconv, [
+ AC_TRY_COMPILE([
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
+ am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
+ am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+ AC_MSG_RESULT([$]{ac_t:-
+ }[$]am_cv_proto_iconv)
+ AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
+ [Define as const if the declaration of iconv() needs const.])
+ fi
+])
+
+# lib-prefix.m4 serial 4 (gettext-0.14.2)
+dnl Copyright (C) 2001-2005 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
+dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
+dnl require excessive bracketing.
+ifdef([AC_HELP_STRING],
+[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
+[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
+
+dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
+dnl to access previously installed libraries. The basic assumption is that
+dnl a user will want packages to use other packages he previously installed
+dnl with the same --prefix option.
+dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
+dnl libraries, but is otherwise very convenient.
+AC_DEFUN([AC_LIB_PREFIX],
+[
+ AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
+ AC_REQUIRE([AC_PROG_CC])
+ AC_REQUIRE([AC_CANONICAL_HOST])
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ dnl By default, look in $includedir and $libdir.
+ use_additional=yes
+ AC_LIB_WITH_FINAL_PREFIX([
+ eval additional_includedir=\"$includedir\"
+ eval additional_libdir=\"$libdir\"
+ ])
+ AC_LIB_ARG_WITH([lib-prefix],
+[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
+ --without-lib-prefix don't search for libraries in includedir and libdir],
+[
+ if test "X$withval" = "Xno"; then
+ use_additional=no
+ else
+ if test "X$withval" = "X"; then
+ AC_LIB_WITH_FINAL_PREFIX([
+ eval additional_includedir=\"$includedir\"
+ eval additional_libdir=\"$libdir\"
+ ])
+ else
+ additional_includedir="$withval/include"
+ additional_libdir="$withval/lib"
+ fi
+ fi
+])
+ if test $use_additional = yes; then
+ dnl Potentially add $additional_includedir to $CPPFLAGS.
+ dnl But don't add it
+ dnl 1. if it's the standard /usr/include,
+ dnl 2. if it's already present in $CPPFLAGS,
+ dnl 3. if it's /usr/local/include and we are using GCC on Linux,
+ dnl 4. if it doesn't exist as a directory.
+ if test "X$additional_includedir" != "X/usr/include"; then
+ haveit=
+ for x in $CPPFLAGS; do
+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+ if test "X$x" = "X-I$additional_includedir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test "X$additional_includedir" = "X/usr/local/include"; then
+ if test -n "$GCC"; then
+ case $host_os in
+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+ esac
+ fi
+ fi
+ if test -z "$haveit"; then
+ if test -d "$additional_includedir"; then
+ dnl Really add $additional_includedir to $CPPFLAGS.
+ CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
+ fi
+ fi
+ fi
+ fi
+ dnl Potentially add $additional_libdir to $LDFLAGS.
+ dnl But don't add it
+ dnl 1. if it's the standard /usr/lib,
+ dnl 2. if it's already present in $LDFLAGS,
+ dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
+ dnl 4. if it doesn't exist as a directory.
+ if test "X$additional_libdir" != "X/usr/lib"; then
+ haveit=
+ for x in $LDFLAGS; do
+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+ if test "X$x" = "X-L$additional_libdir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test "X$additional_libdir" = "X/usr/local/lib"; then
+ if test -n "$GCC"; then
+ case $host_os in
+ linux*) haveit=yes;;
+ esac
+ fi
+ fi
+ if test -z "$haveit"; then
+ if test -d "$additional_libdir"; then
+ dnl Really add $additional_libdir to $LDFLAGS.
+ LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
+ fi
+ fi
+ fi
+ fi
+ fi
+])
+
+dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
+dnl acl_final_exec_prefix, containing the values to which $prefix and
+dnl $exec_prefix will expand at the end of the configure script.
+AC_DEFUN([AC_LIB_PREPARE_PREFIX],
+[
+ dnl Unfortunately, prefix and exec_prefix get only finally determined
+ dnl at the end of configure.
+ if test "X$prefix" = "XNONE"; then
+ acl_final_prefix="$ac_default_prefix"
+ else
+ acl_final_prefix="$prefix"
+ fi
+ if test "X$exec_prefix" = "XNONE"; then
+ acl_final_exec_prefix='${prefix}'
+ else
+ acl_final_exec_prefix="$exec_prefix"
+ fi
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+ prefix="$acl_save_prefix"
+])
+
+dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
+dnl variables prefix and exec_prefix bound to the values they will have
+dnl at the end of the configure script.
+AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
+[
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ $1
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+])
+
+# lib-link.m4 serial 6 (gettext-0.14.3)
+dnl Copyright (C) 2001-2005 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_PREREQ(2.50)
+
+dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
+dnl the libraries corresponding to explicit and implicit dependencies.
+dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
+dnl augments the CPPFLAGS variable.
+AC_DEFUN([AC_LIB_LINKFLAGS],
+[
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+ define([Name],[translit([$1],[./-], [___])])
+ define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+ AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
+ AC_LIB_LINKFLAGS_BODY([$1], [$2])
+ ac_cv_lib[]Name[]_libs="$LIB[]NAME"
+ ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
+ ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
+ ])
+ LIB[]NAME="$ac_cv_lib[]Name[]_libs"
+ LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
+ INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
+ AC_SUBST([LIB]NAME)
+ AC_SUBST([LTLIB]NAME)
+ dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
+ dnl results of this search when this library appears as a dependency.
+ HAVE_LIB[]NAME=yes
+ undefine([Name])
+ undefine([NAME])
+])
+
+dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
+dnl searches for libname and the libraries corresponding to explicit and
+dnl implicit dependencies, together with the specified include files and
+dnl the ability to compile and link the specified testcode. If found, it
+dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
+dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
+dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
+dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
+AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
+[
+ AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
+ AC_REQUIRE([AC_LIB_RPATH])
+ define([Name],[translit([$1],[./-], [___])])
+ define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+
+ dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
+ dnl accordingly.
+ AC_LIB_LINKFLAGS_BODY([$1], [$2])
+
+ dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
+ dnl because if the user has installed lib[]Name and not disabled its use
+ dnl via --without-lib[]Name-prefix, he wants to use it.
+ ac_save_CPPFLAGS="$CPPFLAGS"
+ AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
+
+ AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
+ ac_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIB[]NAME"
+ AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
+ LIBS="$ac_save_LIBS"
+ ])
+ if test "$ac_cv_lib[]Name" = yes; then
+ HAVE_LIB[]NAME=yes
+ AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
+ AC_MSG_CHECKING([how to link with lib[]$1])
+ AC_MSG_RESULT([$LIB[]NAME])
+ else
+ HAVE_LIB[]NAME=no
+ dnl If $LIB[]NAME didn't lead to a usable library, we don't need
+ dnl $INC[]NAME either.
+ CPPFLAGS="$ac_save_CPPFLAGS"
+ LIB[]NAME=
+ LTLIB[]NAME=
+ fi
+ AC_SUBST([HAVE_LIB]NAME)
+ AC_SUBST([LIB]NAME)
+ AC_SUBST([LTLIB]NAME)
+ undefine([Name])
+ undefine([NAME])
+])
+
+dnl Determine the platform dependent parameters needed to use rpath:
+dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
+dnl hardcode_direct, hardcode_minus_L.
+AC_DEFUN([AC_LIB_RPATH],
+[
+ dnl Tell automake >= 1.10 to complain if config.rpath is missing.
+ m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
+ AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
+ AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
+ AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
+ AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
+ AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
+ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+ . ./conftest.sh
+ rm -f ./conftest.sh
+ acl_cv_rpath=done
+ ])
+ wl="$acl_cv_wl"
+ libext="$acl_cv_libext"
+ shlibext="$acl_cv_shlibext"
+ hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+ hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+ hardcode_direct="$acl_cv_hardcode_direct"
+ hardcode_minus_L="$acl_cv_hardcode_minus_L"
+ dnl Determine whether the user wants rpath handling at all.
+ AC_ARG_ENABLE(rpath,
+ [ --disable-rpath do not hardcode runtime library paths],
+ :, enable_rpath=yes)
+])
+
+dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
+dnl the libraries corresponding to explicit and implicit dependencies.
+dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
+AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
+[
+ define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
+ [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
+ dnl By default, look in $includedir and $libdir.
+ use_additional=yes
+ AC_LIB_WITH_FINAL_PREFIX([
+ eval additional_includedir=\"$includedir\"
+ eval additional_libdir=\"$libdir\"
+ ])
+ AC_LIB_ARG_WITH([lib$1-prefix],
+[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
+ --without-lib$1-prefix don't search for lib$1 in includedir and libdir],
+[
+ if test "X$withval" = "Xno"; then
+ use_additional=no
+ else
+ if test "X$withval" = "X"; then
+ AC_LIB_WITH_FINAL_PREFIX([
+ eval additional_includedir=\"$includedir\"
+ eval additional_libdir=\"$libdir\"
+ ])
+ else
+ additional_includedir="$withval/include"
+ additional_libdir="$withval/lib"
+ fi
+ fi
+])
+ dnl Search the library and its dependencies in $additional_libdir and
+ dnl $LDFLAGS. Using breadth-first-seach.
+ LIB[]NAME=
+ LTLIB[]NAME=
+ INC[]NAME=
+ rpathdirs=
+ ltrpathdirs=
+ names_already_handled=
+ names_next_round='$1 $2'
+ while test -n "$names_next_round"; do
+ names_this_round="$names_next_round"
+ names_next_round=
+ for name in $names_this_round; do
+ already_handled=
+ for n in $names_already_handled; do
+ if test "$n" = "$name"; then
+ already_handled=yes
+ break
+ fi
+ done
+ if test -z "$already_handled"; then
+ names_already_handled="$names_already_handled $name"
+ dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
+ dnl or AC_LIB_HAVE_LINKFLAGS call.
+ uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+ eval value=\"\$HAVE_LIB$uppername\"
+ if test -n "$value"; then
+ if test "$value" = yes; then
+ eval value=\"\$LIB$uppername\"
+ test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
+ eval value=\"\$LTLIB$uppername\"
+ test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
+ else
+ dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
+ dnl that this library doesn't exist. So just drop it.
+ :
+ fi
+ else
+ dnl Search the library lib$name in $additional_libdir and $LDFLAGS
+ dnl and the already constructed $LIBNAME/$LTLIBNAME.
+ found_dir=
+ found_la=
+ found_so=
+ found_a=
+ if test $use_additional = yes; then
+ if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+ found_dir="$additional_libdir"
+ found_so="$additional_libdir/lib$name.$shlibext"
+ if test -f "$additional_libdir/lib$name.la"; then
+ found_la="$additional_libdir/lib$name.la"
+ fi
+ else
+ if test -f "$additional_libdir/lib$name.$libext"; then
+ found_dir="$additional_libdir"
+ found_a="$additional_libdir/lib$name.$libext"
+ if test -f "$additional_libdir/lib$name.la"; then
+ found_la="$additional_libdir/lib$name.la"
+ fi
+ fi
+ fi
+ fi
+ if test "X$found_dir" = "X"; then
+ for x in $LDFLAGS $LTLIB[]NAME; do
+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+ case "$x" in
+ -L*)
+ dir=`echo "X$x" | sed -e 's/^X-L//'`
+ if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+ found_dir="$dir"
+ found_so="$dir/lib$name.$shlibext"
+ if test -f "$dir/lib$name.la"; then
+ found_la="$dir/lib$name.la"
+ fi
+ else
+ if test -f "$dir/lib$name.$libext"; then
+ found_dir="$dir"
+ found_a="$dir/lib$name.$libext"
+ if test -f "$dir/lib$name.la"; then
+ found_la="$dir/lib$name.la"
+ fi
+ fi
+ fi
+ ;;
+ esac
+ if test "X$found_dir" != "X"; then
+ break
+ fi
+ done
+ fi
+ if test "X$found_dir" != "X"; then
+ dnl Found the library.
+ LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
+ if test "X$found_so" != "X"; then
+ dnl Linking with a shared library. We attempt to hardcode its
+ dnl directory into the executable's runpath, unless it's the
+ dnl standard /usr/lib.
+ if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+ dnl No hardcoding is needed.
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+ else
+ dnl Use an explicit option to hardcode DIR into the resulting
+ dnl binary.
+ dnl Potentially add DIR to ltrpathdirs.
+ dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
+ haveit=
+ for x in $ltrpathdirs; do
+ if test "X$x" = "X$found_dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ ltrpathdirs="$ltrpathdirs $found_dir"
+ fi
+ dnl The hardcoding into $LIBNAME is system dependent.
+ if test "$hardcode_direct" = yes; then
+ dnl Using DIR/libNAME.so during linking hardcodes DIR into the
+ dnl resulting binary.
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+ else
+ if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+ dnl Use an explicit option to hardcode DIR into the resulting
+ dnl binary.
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+ dnl Potentially add DIR to rpathdirs.
+ dnl The rpathdirs will be appended to $LIBNAME at the end.
+ haveit=
+ for x in $rpathdirs; do
+ if test "X$x" = "X$found_dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ rpathdirs="$rpathdirs $found_dir"
+ fi
+ else
+ dnl Rely on "-L$found_dir".
+ dnl But don't add it if it's already contained in the LDFLAGS
+ dnl or the already constructed $LIBNAME
+ haveit=
+ for x in $LDFLAGS $LIB[]NAME; do
+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+ if test "X$x" = "X-L$found_dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
+ fi
+ if test "$hardcode_minus_L" != no; then
+ dnl FIXME: Not sure whether we should use
+ dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
+ dnl here.
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
+ else
+ dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
+ dnl here, because this doesn't fit in flags passed to the
+ dnl compiler. So give up. No hardcoding. This affects only
+ dnl very old systems.
+ dnl FIXME: Not sure whether we should use
+ dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
+ dnl here.
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
+ fi
+ fi
+ fi
+ fi
+ else
+ if test "X$found_a" != "X"; then
+ dnl Linking with a static library.
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
+ else
+ dnl We shouldn't come here, but anyway it's good to have a
+ dnl fallback.
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
+ fi
+ fi
+ dnl Assume the include files are nearby.
+ additional_includedir=
+ case "$found_dir" in
+ */lib | */lib/)
+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+ additional_includedir="$basedir/include"
+ ;;
+ esac
+ if test "X$additional_includedir" != "X"; then
+ dnl Potentially add $additional_includedir to $INCNAME.
+ dnl But don't add it
+ dnl 1. if it's the standard /usr/include,
+ dnl 2. if it's /usr/local/include and we are using GCC on Linux,
+ dnl 3. if it's already present in $CPPFLAGS or the already
+ dnl constructed $INCNAME,
+ dnl 4. if it doesn't exist as a directory.
+ if test "X$additional_includedir" != "X/usr/include"; then
+ haveit=
+ if test "X$additional_includedir" = "X/usr/local/include"; then
+ if test -n "$GCC"; then
+ case $host_os in
+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+ esac
+ fi
+ fi
+ if test -z "$haveit"; then
+ for x in $CPPFLAGS $INC[]NAME; do
+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+ if test "X$x" = "X-I$additional_includedir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test -d "$additional_includedir"; then
+ dnl Really add $additional_includedir to $INCNAME.
+ INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
+ fi
+ fi
+ fi
+ fi
+ fi
+ dnl Look for dependencies.
+ if test -n "$found_la"; then
+ dnl Read the .la file. It defines the variables
+ dnl dlname, library_names, old_library, dependency_libs, current,
+ dnl age, revision, installed, dlopen, dlpreopen, libdir.
+ save_libdir="$libdir"
+ case "$found_la" in
+ */* | *\\*) . "$found_la" ;;
+ *) . "./$found_la" ;;
+ esac
+ libdir="$save_libdir"
+ dnl We use only dependency_libs.
+ for dep in $dependency_libs; do
+ case "$dep" in
+ -L*)
+ additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+ dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
+ dnl But don't add it
+ dnl 1. if it's the standard /usr/lib,
+ dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
+ dnl 3. if it's already present in $LDFLAGS or the already
+ dnl constructed $LIBNAME,
+ dnl 4. if it doesn't exist as a directory.
+ if test "X$additional_libdir" != "X/usr/lib"; then
+ haveit=
+ if test "X$additional_libdir" = "X/usr/local/lib"; then
+ if test -n "$GCC"; then
+ case $host_os in
+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+ esac
+ fi
+ fi
+ if test -z "$haveit"; then
+ haveit=
+ for x in $LDFLAGS $LIB[]NAME; do
+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+ if test "X$x" = "X-L$additional_libdir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test -d "$additional_libdir"; then
+ dnl Really add $additional_libdir to $LIBNAME.
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
+ fi
+ fi
+ haveit=
+ for x in $LDFLAGS $LTLIB[]NAME; do
+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+ if test "X$x" = "X-L$additional_libdir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test -d "$additional_libdir"; then
+ dnl Really add $additional_libdir to $LTLIBNAME.
+ LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
+ fi
+ fi
+ fi
+ fi
+ ;;
+ -R*)
+ dir=`echo "X$dep" | sed -e 's/^X-R//'`
+ if test "$enable_rpath" != no; then
+ dnl Potentially add DIR to rpathdirs.
+ dnl The rpathdirs will be appended to $LIBNAME at the end.
+ haveit=
+ for x in $rpathdirs; do
+ if test "X$x" = "X$dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ rpathdirs="$rpathdirs $dir"
+ fi
+ dnl Potentially add DIR to ltrpathdirs.
+ dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
+ haveit=
+ for x in $ltrpathdirs; do
+ if test "X$x" = "X$dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ ltrpathdirs="$ltrpathdirs $dir"
+ fi
+ fi
+ ;;
+ -l*)
+ dnl Handle this in the next round.
+ names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+ ;;
+ *.la)
+ dnl Handle this in the next round. Throw away the .la's
+ dnl directory; it is already contained in a preceding -L
+ dnl option.
+ names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+ ;;
+ *)
+ dnl Most likely an immediate library name.
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
+ LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
+ ;;
+ esac
+ done
+ fi
+ else
+ dnl Didn't find the library; assume it is in the system directories
+ dnl known to the linker and runtime loader. (All the system
+ dnl directories known to the linker should also be known to the
+ dnl runtime loader, otherwise the system is severely misconfigured.)
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
+ LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
+ fi
+ fi
+ fi
+ done
+ done
+ if test "X$rpathdirs" != "X"; then
+ if test -n "$hardcode_libdir_separator"; then
+ dnl Weird platform: only the last -rpath option counts, the user must
+ dnl pass all path elements in one option. We can arrange that for a
+ dnl single library, but not when more than one $LIBNAMEs are used.
+ alldirs=
+ for found_dir in $rpathdirs; do
+ alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+ done
+ dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
+ acl_save_libdir="$libdir"
+ libdir="$alldirs"
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ libdir="$acl_save_libdir"
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
+ else
+ dnl The -rpath options are cumulative.
+ for found_dir in $rpathdirs; do
+ acl_save_libdir="$libdir"
+ libdir="$found_dir"
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ libdir="$acl_save_libdir"
+ LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
+ done
+ fi
+ fi
+ if test "X$ltrpathdirs" != "X"; then
+ dnl When using libtool, the option that works for both libraries and
+ dnl executables is -R. The -R options are cumulative.
+ for found_dir in $ltrpathdirs; do
+ LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
+ done
+ fi
+])
+
+dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
+dnl unless already present in VAR.
+dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
+dnl contains two or three consecutive elements that belong together.
+AC_DEFUN([AC_LIB_APPENDTOVAR],
+[
+ for element in [$2]; do
+ haveit=
+ for x in $[$1]; do
+ AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
+ if test "X$x" = "X$element"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ [$1]="${[$1]}${[$1]:+ }$element"
+ fi
+ done
+])
+
+# lib-ld.m4 serial 3 (gettext-0.13)
+dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Subroutines of libtool.m4,
+dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
+dnl with libtool.m4.
+
+dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
+AC_DEFUN([AC_LIB_PROG_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ acl_cv_prog_gnu_ld=yes ;;
+*)
+ acl_cv_prog_gnu_ld=no ;;
+esac])
+with_gnu_ld=$acl_cv_prog_gnu_ld
+])
+
+dnl From libtool-1.4. Sets the variable LD.
+AC_DEFUN([AC_LIB_PROG_LD],
+[AC_ARG_WITH(gnu-ld,
+[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ AC_MSG_CHECKING([for ld used by GCC])
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [[\\/]* | [A-Za-z]:[\\/]*)]
+ [re_direlt='/[^/][^/]*/\.\./']
+ # Canonicalize the path of ld
+ ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ AC_MSG_CHECKING([for GNU ld])
+else
+ AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(acl_cv_path_LD,
+[if test -z "$LD"; then
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ acl_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break ;;
+ *)
+ test "$with_gnu_ld" != yes && break ;;
+ esac
+ fi
+ done
+ IFS="$ac_save_ifs"
+else
+ acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+ AC_MSG_RESULT($LD)
+else
+ AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_LIB_PROG_LD_GNU
+])
+
diff --git a/config.guess b/config.guess
new file mode 100755
index 0000000..ad5281e
--- /dev/null
+++ b/config.guess
@@ -0,0 +1,1466 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+timestamp='2005-08-03'
+
+# 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., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, 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@bothner.com>.
+# Please send patches to <config-patches@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@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+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 ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # 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 ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@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 ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerppc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ 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 ;;
+ 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 ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@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 ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ 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 ;;
+ 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 ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ 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 ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # 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 ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ 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 &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ 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 ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????: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 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ 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 ;;
+ *: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
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ 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 ;;
+ *: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 ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 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
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 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 && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ 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 ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ 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 ;;
+ 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 ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ x86:Interix*:[34]*)
+ echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
+ exit ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ 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 ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *: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 ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ 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; }
+ ;;
+ 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; }
+ ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ 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 ;;
+ 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 ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit ;;
+ 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 ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit ;;
+ "")
+ # 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 ;;
+ 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
+ }
+ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+ ;;
+ 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 ;;
+ 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 ;;
+ 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 ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ 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 ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ 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 ;;
+ 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 ;;
+ 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 ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ 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 ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 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 | S7501*:*: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; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *: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 ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ 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 ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ *86) UNAME_PROCESSOR=i686 ;;
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *: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 ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *: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 ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+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\n"); 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 && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# 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 ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ 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
+
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+
+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@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:
diff --git a/config.hin b/config.hin
new file mode 100644
index 0000000..1690a7c
--- /dev/null
+++ b/config.hin
@@ -0,0 +1,86 @@
+/* config.hin. Generated from configure.ac by autoheader. */
+
+/* Define for CPUs that can read unaligned words without traps or faults */
+#undef CAN_DO_UNALIGNED_WORDS
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#undef HAVE_ARPA_INET_H
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the `getopt_long' function. */
+#undef HAVE_GETOPT_LONG
+
+/* Define to 1 if you have the `getpagesize' function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define if you have the iconv() function. */
+#undef HAVE_ICONV
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have a working `mmap' system call. */
+#undef HAVE_MMAP
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strcasecmp' function. */
+#undef HAVE_STRCASECMP
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define as const if the declaration of iconv() needs const. */
+#undef ICONV_CONST
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if your processor stores words with the most significant byte
+ first (like Motorola and SPARC, unlike Intel and VAX). */
+#undef WORDS_BIGENDIAN
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+ calls it, or to nothing if 'inline' is not supported under any name. */
+#ifndef __cplusplus
+#undef inline
+#endif
diff --git a/config.rpath b/config.rpath
new file mode 100644
index 0000000..39fef94
--- /dev/null
+++ b/config.rpath
@@ -0,0 +1,2 @@
+# I don't think this is actually used, but the configure script
+# bitches if it is not found. Sigh.
diff --git a/config.sub b/config.sub
new file mode 100755
index 0000000..1c366df
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1579 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+timestamp='2005-07-08'
+
+# 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., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, 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@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@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+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 ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # 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 ;;
+
+ * )
+ 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 | -knuth | -cray)
+ 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 \
+ | bfin \
+ | 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 | maxq | mcore \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | ms1 \
+ | msp430 \
+ | ns16k | ns32k \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b \
+ | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m32c)
+ 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-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | craynv-* | 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-* | maxq-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | ms1-* \
+ | msp430-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | 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-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ m32c-*)
+ ;;
+ # 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
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16c)
+ basic_machine=cr16c-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ 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
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ 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
+ ;;
+ 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
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ 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
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ 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
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ 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
+ ;;
+ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-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* \
+ | -skyos* | -haiku*)
+ # 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* | -haiku* \
+ | -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
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -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
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-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
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure b/configure
new file mode 100755
index 0000000..d189d8a
--- /dev/null
+++ b/configure
@@ -0,0 +1,5895 @@
+#! /bin/sh
+# From configure.ac Id: configure.ac.
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.59 for Xcftools 0.7.
+#
+# Report bugs to <henning@makholm.net>.
+#
+# Copyright (C) 2003 Free Software Foundation, Inc.
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+#
+# General copyright notice for Xcftools:
+# @COPYRIGHT@ Henning Makholm
+#
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+exec 6>&1
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_config_libobj_dir=.
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+# Maximum number of lines to put in a shell here document.
+# This variable seems obsolete. It should probably be removed, and
+# only ac_max_sed_lines should be used.
+: ${ac_max_here_lines=38}
+
+# Identity of this package.
+PACKAGE_NAME='Xcftools'
+PACKAGE_TARNAME='xcftools'
+PACKAGE_VERSION='0.7'
+PACKAGE_STRING='Xcftools 0.7'
+PACKAGE_BUGREPORT='henning@makholm.net'
+
+ac_unique_file="xcfinfo.c"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#if STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# if HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#if HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# if HAVE_STDINT_H
+# include <stdint.h>
+# endif
+#endif
+#if HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS SET_MAKE INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT build build_cpu build_vendor build_os host host_cpu host_vendor host_os CPP EGREP LIBICONV LTLIBICONV PERL LIBOBJS LTLIBOBJS'
+ac_subst_files=''
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+ac_prev=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'`
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_option in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ eval "enable_$ac_feature=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid feature name: $ac_feature" >&2
+ { (exit 1); exit 1; }; }
+ ac_feature=`echo $ac_feature | sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_$ac_feature='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case $ac_option in
+ *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_$ac_package='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid package name: $ac_package" >&2
+ { (exit 1); exit 1; }; }
+ ac_package=`echo $ac_package | sed 's/-/_/g'`
+ eval "with_$ac_package=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) { echo "$as_me: error: unrecognized option: $ac_option
+Try \`$0 --help' for more information." >&2
+ { (exit 1); exit 1; }; }
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&
+ { echo "$as_me: error: invalid variable name: $ac_envvar" >&2
+ { (exit 1); exit 1; }; }
+ ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`
+ eval "$ac_envvar='$ac_optarg'"
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ { echo "$as_me: error: missing argument to $ac_option" >&2
+ { (exit 1); exit 1; }; }
+fi
+
+# Be sure to have absolute paths.
+for ac_var in exec_prefix prefix
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* | NONE | '' ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# Be sure to have absolute paths.
+for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \
+ localstatedir libdir includedir oldincludedir infodir mandir
+do
+ eval ac_val=$`echo $ac_var`
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) ;;
+ *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+ If a cross compiler is detected then cross compile mode will be used." >&2
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_confdir=`(dirname "$0") 2>/dev/null ||
+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$0" : 'X\(//\)[^/]' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$0" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
+ { (exit 1); exit 1; }; }
+ else
+ { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2
+ { (exit 1); exit 1; }; }
+ fi
+fi
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
+ { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
+ { (exit 1); exit 1; }; }
+srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
+ac_env_build_alias_set=${build_alias+set}
+ac_env_build_alias_value=$build_alias
+ac_cv_env_build_alias_set=${build_alias+set}
+ac_cv_env_build_alias_value=$build_alias
+ac_env_host_alias_set=${host_alias+set}
+ac_env_host_alias_value=$host_alias
+ac_cv_env_host_alias_set=${host_alias+set}
+ac_cv_env_host_alias_value=$host_alias
+ac_env_target_alias_set=${target_alias+set}
+ac_env_target_alias_value=$target_alias
+ac_cv_env_target_alias_set=${target_alias+set}
+ac_cv_env_target_alias_value=$target_alias
+ac_env_CC_set=${CC+set}
+ac_env_CC_value=$CC
+ac_cv_env_CC_set=${CC+set}
+ac_cv_env_CC_value=$CC
+ac_env_CFLAGS_set=${CFLAGS+set}
+ac_env_CFLAGS_value=$CFLAGS
+ac_cv_env_CFLAGS_set=${CFLAGS+set}
+ac_cv_env_CFLAGS_value=$CFLAGS
+ac_env_LDFLAGS_set=${LDFLAGS+set}
+ac_env_LDFLAGS_value=$LDFLAGS
+ac_cv_env_LDFLAGS_set=${LDFLAGS+set}
+ac_cv_env_LDFLAGS_value=$LDFLAGS
+ac_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_env_CPPFLAGS_value=$CPPFLAGS
+ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set}
+ac_cv_env_CPPFLAGS_value=$CPPFLAGS
+ac_env_CPP_set=${CPP+set}
+ac_env_CPP_value=$CPP
+ac_cv_env_CPP_set=${CPP+set}
+ac_cv_env_CPP_value=$CPP
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat <<_ACEOF
+\`configure' configures Xcftools 0.7 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+_ACEOF
+
+ cat <<_ACEOF
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --infodir=DIR info documentation [PREFIX/info]
+ --mandir=DIR man documentation [PREFIX/man]
+_ACEOF
+
+ cat <<\_ACEOF
+
+Program names:
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM run sed PROGRAM on installed program names
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of Xcftools 0.7:";;
+ esac
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --disable-rpath do not hardcode runtime library paths
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-gnu-ld assume the C compiler uses GNU ld default=no
+ --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib
+ --without-libiconv-prefix don't search for libiconv in includedir and libdir
+
+Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ CPPFLAGS C/C++ preprocessor flags, e.g. -I<include dir> if you have
+ headers in a nonstandard directory <include dir>
+ CPP C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <henning@makholm.net>.
+_ACEOF
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ ac_popdir=`pwd`
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d $ac_dir || continue
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+ cd $ac_dir
+ # Check for guested configure; otherwise get Cygnus style configure.
+ if test -f $ac_srcdir/configure.gnu; then
+ echo
+ $SHELL $ac_srcdir/configure.gnu --help=recursive
+ elif test -f $ac_srcdir/configure; then
+ echo
+ $SHELL $ac_srcdir/configure --help=recursive
+ elif test -f $ac_srcdir/configure.ac ||
+ test -f $ac_srcdir/configure.in; then
+ echo
+ $ac_configure --help
+ else
+ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi
+ cd "$ac_popdir"
+ done
+fi
+
+test -n "$ac_init_help" && exit 0
+if $ac_init_version; then
+ cat <<\_ACEOF
+Xcftools configure 0.7
+generated by GNU Autoconf 2.59
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+
+General copyright notice for Xcftools:
+ @COPYRIGHT@ Henning Makholm
+
+_ACEOF
+ exit 0
+fi
+exec 5>config.log
+cat >&5 <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by Xcftools $as_me 0.7, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+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 || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+hostinfo = `(hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ echo "PATH: $as_dir"
+done
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_sep=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;
+ 2)
+ ac_configure_args1="$ac_configure_args1 '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'"
+ # Get rid of the leading space.
+ ac_sep=" "
+ ;;
+ esac
+ done
+done
+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }
+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Be sure not to use single quotes in there, as some shells,
+# such as our DU 5.0 friend, will then `close' the trap.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+{
+ (set) 2>&1 |
+ case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ sed -n \
+ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p"
+ ;;
+ *)
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+}
+ echo
+
+ cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ cat <<\_ASBOX
+## ------------- ##
+## Output files. ##
+## ------------- ##
+_ASBOX
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=$`echo $ac_var`
+ echo "$ac_var='"'"'$ac_val'"'"'"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+ echo
+ sed "/^$/d" confdefs.h | sort
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ echo "$as_me: caught signal $ac_signal"
+ echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core &&
+ rm -rf conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+ ' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo >confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5
+echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special
+ # files actually), so we avoid doing that.
+ if test -f "$cache_file"; then
+ { echo "$as_me:$LINENO: loading cache $cache_file" >&5
+echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . $cache_file;;
+ *) . ./$cache_file;;
+ esac
+ fi
+else
+ { echo "$as_me:$LINENO: creating cache $cache_file" >&5
+echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in `(set) 2>&1 |
+ sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val="\$ac_cv_env_${ac_var}_value"
+ eval ac_new_val="\$ac_env_${ac_var}_value"
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5
+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5
+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ { echo "$as_me:$LINENO: former value: $ac_old_val" >&5
+echo "$as_me: former value: $ac_old_val" >&2;}
+ { echo "$as_me:$LINENO: current value: $ac_new_val" >&5
+echo "$as_me: current value: $ac_new_val" >&2;}
+ ac_cache_corrupted=:
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*)
+ ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5
+echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5
+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6
+set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,:./+-,___p_,'`
+if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.make <<\_ACEOF
+all:
+ @echo 'ac_maketemp="$(MAKE)"'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=`
+if test -n "$ac_maketemp"; then
+ eval ac_cv_prog_make_${ac_make}_set=yes
+else
+ eval ac_cv_prog_make_${ac_make}_set=no
+fi
+rm -f conftest.make
+fi
+if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
+ echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+ SET_MAKE=
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f $ac_dir/shtool; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5
+echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"
+ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5
+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in
+ ./ | .// | /cC/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+done
+
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL=$ac_install_sh
+ fi
+fi
+echo "$as_me:$LINENO: result: $INSTALL" >&5
+echo "${ECHO_T}$INSTALL" >&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+test "$program_prefix" != NONE &&
+ program_transform_name="s,^,$program_prefix,;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s,\$,$program_suffix,;$program_transform_name"
+# Double any \ or $. echo might interpret backslashes.
+# By default was `s,x,x', remove it if useless.
+cat <<\_ACEOF >conftest.sed
+s/[\\$]/&&/g;s/;s,x,x,$//
+_ACEOF
+program_transform_name=`echo $program_transform_name | sed -f conftest.sed`
+rm conftest.sed
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ CC=$ac_ct_CC
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ echo "$as_me:$LINENO: result: $CC" >&5
+echo "${ECHO_T}$CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
+echo "${ECHO_T}$ac_ct_CC" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+ test -n "$ac_ct_CC" && break
+done
+
+ CC=$ac_ct_CC
+fi
+
+fi
+
+
+test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&5
+echo "$as_me: error: no acceptable C compiler found in \$PATH
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+
+# Provide some information about the compiler.
+echo "$as_me:$LINENO:" \
+ "checking for C compiler version" >&5
+ac_compiler=`set X $ac_compile; echo $2`
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
+ (eval $ac_compiler --version </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
+ (eval $ac_compiler -v </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
+ (eval $ac_compiler -V </dev/null >&5) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }
+
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+echo "$as_me:$LINENO: checking for C compiler default output file name" >&5
+echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6
+ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5
+ (eval $ac_link_default) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # Find the output, starting from the most likely. This scheme is
+# not robust to junk in `.', hence go to wildcards (a.*) only as a last
+# resort.
+
+# Be careful to initialize this variable, since it used to be cached.
+# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile.
+ac_cv_exeext=
+# b.out is created by i960 compilers.
+for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj )
+ ;;
+ conftest.$ac_ext )
+ # This is the source file.
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ # FIXME: I believe we export ac_cv_exeext for Libtool,
+ # but it would be cool to find out if it's true. Does anybody
+ # maintain Libtool? --akim.
+ export ac_cv_exeext
+ break;;
+ * )
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: C compiler cannot create executables
+See \`config.log' for more details." >&5
+echo "$as_me: error: C compiler cannot create executables
+See \`config.log' for more details." >&2;}
+ { (exit 77); exit 77; }; }
+fi
+
+ac_exeext=$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_file" >&5
+echo "${ECHO_T}$ac_file" >&6
+
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether the C compiler works" >&5
+echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6
+# FIXME: These cross compiler hacks should be removed for Autoconf 3.0
+# If not cross compiling, check that we can run a simple program.
+if test "$cross_compiling" != yes; then
+ if { ac_try='./$ac_file'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { echo "$as_me:$LINENO: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ fi
+fi
+echo "$as_me:$LINENO: result: yes" >&5
+echo "${ECHO_T}yes" >&6
+
+rm -f a.out a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+# Check the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+echo "$as_me:$LINENO: checking whether we are cross compiling" >&5
+echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6
+echo "$as_me:$LINENO: result: $cross_compiling" >&5
+echo "${ECHO_T}$cross_compiling" >&6
+
+echo "$as_me:$LINENO: checking for suffix of executables" >&5
+echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ export ac_cv_exeext
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest$ac_cv_exeext
+echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5
+echo "${ECHO_T}$ac_cv_exeext" >&6
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+echo "$as_me:$LINENO: checking for suffix of object files" >&5
+echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6
+if test "${ac_cv_objext+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; then
+ for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&5
+echo "$as_me: error: cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_objext" >&5
+echo "${ECHO_T}$ac_cv_objext" >&6
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
+echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
+if test "${ac_cv_c_compiler_gnu+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_compiler_gnu=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_compiler_gnu=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
+echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
+GCC=`test $ac_compiler_gnu = yes && echo yes`
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+CFLAGS="-g"
+echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
+echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_g+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_g=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_prog_cc_g=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
+echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
+if test "${ac_cv_prog_cc_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_prog_cc_stdc=no
+ac_save_CC=$CC
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std1 is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std1. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+# Don't try gcc -ansi; that turns off useful extensions and
+# breaks some systems' header files.
+# AIX -qlanglvl=ansi
+# Ultrix and OSF/1 -std1
+# HP-UX 10.20 and later -Ae
+# HP-UX older versions -Aa -D_HPUX_SOURCE
+# SVR4 -Xc -D__EXTENSIONS__
+for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_prog_cc_stdc=$ac_arg
+break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext
+done
+rm -f conftest.$ac_ext conftest.$ac_objext
+CC=$ac_save_CC
+
+fi
+
+case "x$ac_cv_prog_cc_stdc" in
+ x|xno)
+ echo "$as_me:$LINENO: result: none needed" >&5
+echo "${ECHO_T}none needed" >&6 ;;
+ *)
+ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
+echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
+ CC="$CC $ac_cv_prog_cc_stdc" ;;
+esac
+
+# Some people use a C++ compiler to compile C. Since we use `exit',
+# in C++ we need to declare it. In case someone uses the same compiler
+# for both compiling C and C++ we need to have the C++ compiler decide
+# the declaration of exit, since it's the most demanding environment.
+cat >conftest.$ac_ext <<_ACEOF
+#ifndef __cplusplus
+ choke me
+#endif
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ for ac_declaration in \
+ '' \
+ 'extern "C" void std::exit (int) throw (); using std::exit;' \
+ 'extern "C" void std::exit (int); using std::exit;' \
+ 'extern "C" void exit (int) throw ();' \
+ 'extern "C" void exit (int);' \
+ 'void exit (int);'
+do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+#include <stdlib.h>
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+continue
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_declaration
+int
+main ()
+{
+exit (42);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest*
+if test -n "$ac_declaration"; then
+ echo '#ifdef __cplusplus' >>confdefs.h
+ echo $ac_declaration >>confdefs.h
+ echo '#endif' >>confdefs.h
+fi
+
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+case $GCC::$CFLAGS in yes::*-Wall* ) ;;
+ yes::*) CFLAGS="$CFLAGS -Wall" ;;
+esac
+case $GCC::$CFLAGS in *-g* | *omit-frame-pointer* ) ;;
+ yes::*) CFLAGS="$CFLAGS -fomit-frame-pointer" ;;
+esac
+
+echo "$as_me:$LINENO: checking for inline" >&5
+echo $ECHO_N "checking for inline... $ECHO_C" >&6
+if test "${ac_cv_c_inline+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_c_inline=$ac_kw; break
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5
+echo "${ECHO_T}$ac_cv_c_inline" >&6
+
+
+case $ac_cv_c_inline in
+ inline | yes) ;;
+ *)
+ case $ac_cv_c_inline in
+ no) ac_val=;;
+ *) ac_val=$ac_cv_c_inline;;
+ esac
+ cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+ ;;
+esac
+
+
+echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5
+echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6
+if test "${ac_cv_c_bigendian+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # See if sys/param.h defines the BYTE_ORDER macro.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <sys/param.h>
+
+int
+main ()
+{
+#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
+ bogus endian macros
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ # It does; now see whether it defined to BIG_ENDIAN or not.
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <sys/param.h>
+
+int
+main ()
+{
+#if BYTE_ORDER != BIG_ENDIAN
+ not big endian
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_c_bigendian=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_c_bigendian=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+# It does not; compile a test program.
+if test "$cross_compiling" = yes; then
+ # try to guess the endianness by grepping values into an object file
+ ac_cv_c_bigendian=unknown
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; }
+short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }
+int
+main ()
+{
+ _ascii (); _ebcdic ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then
+ ac_cv_c_bigendian=yes
+fi
+if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+ if test "$ac_cv_c_bigendian" = unknown; then
+ ac_cv_c_bigendian=no
+ else
+ # finding both strings is unlikely to happen, but who knows?
+ ac_cv_c_bigendian=unknown
+ fi
+fi
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+int
+main ()
+{
+ /* Are we little or big endian? From Harbison&Steele. */
+ union
+ {
+ long l;
+ char c[sizeof (long)];
+ } u;
+ u.l = 1;
+ exit (u.c[sizeof (long) - 1] == 1);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_c_bigendian=no
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_c_bigendian=yes
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5
+echo "${ECHO_T}$ac_cv_c_bigendian" >&6
+case $ac_cv_c_bigendian in
+ yes)
+
+cat >>confdefs.h <<\_ACEOF
+#define WORDS_BIGENDIAN 1
+_ACEOF
+ ;;
+ no)
+ ;;
+ *)
+ { { echo "$as_me:$LINENO: error: unknown endianness
+presetting ac_cv_c_bigendian=no (or yes) will help" >&5
+echo "$as_me: error: unknown endianness
+presetting ac_cv_c_bigendian=no (or yes) will help" >&2;}
+ { (exit 1); exit 1; }; } ;;
+esac
+
+# Make sure we can run config.sub.
+$ac_config_sub sun4 >/dev/null 2>&1 ||
+ { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5
+echo "$as_me: error: cannot run $ac_config_sub" >&2;}
+ { (exit 1); exit 1; }; }
+
+echo "$as_me:$LINENO: checking build system type" >&5
+echo $ECHO_N "checking build system type... $ECHO_C" >&6
+if test "${ac_cv_build+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_build_alias=$build_alias
+test -z "$ac_cv_build_alias" &&
+ ac_cv_build_alias=`$ac_config_guess`
+test -z "$ac_cv_build_alias" &&
+ { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5
+echo "$as_me: error: cannot guess build type; you must specify one" >&2;}
+ { (exit 1); exit 1; }; }
+ac_cv_build=`$ac_config_sub $ac_cv_build_alias` ||
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_build" >&5
+echo "${ECHO_T}$ac_cv_build" >&6
+build=$ac_cv_build
+build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+echo "$as_me:$LINENO: checking host system type" >&5
+echo $ECHO_N "checking host system type... $ECHO_C" >&6
+if test "${ac_cv_host+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_cv_host_alias=$host_alias
+test -z "$ac_cv_host_alias" &&
+ ac_cv_host_alias=$ac_cv_build_alias
+ac_cv_host=`$ac_config_sub $ac_cv_host_alias` ||
+ { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5
+echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;}
+ { (exit 1); exit 1; }; }
+
+fi
+echo "$as_me:$LINENO: result: $ac_cv_host" >&5
+echo "${ECHO_T}$ac_cv_host" >&6
+host=$ac_cv_host
+host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+
+case $host_cpu in i?86 | x86_64 | powerpc)
+
+cat >>confdefs.h <<\_ACEOF
+#define CAN_DO_UNALIGNED_WORDS 1
+_ACEOF
+
+esac
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5
+echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if test "${ac_cv_prog_CPP+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+echo "$as_me:$LINENO: result: $CPP" >&5
+echo "${ECHO_T}$CPP" >&6
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ :
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether non-existent headers
+ # can be detected and how.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ # Broken: success on invalid input.
+continue
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then
+ :
+else
+ { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&5
+echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." >&2;}
+ { (exit 1); exit 1; }; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+echo "$as_me:$LINENO: checking for egrep" >&5
+echo $ECHO_N "checking for egrep... $ECHO_C" >&6
+if test "${ac_cv_prog_egrep+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+ then ac_cv_prog_egrep='grep -E'
+ else ac_cv_prog_egrep='egrep'
+ fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5
+echo "${ECHO_T}$ac_cv_prog_egrep" >&6
+ EGREP=$ac_cv_prog_egrep
+
+
+echo "$as_me:$LINENO: checking for ANSI C header files" >&5
+echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
+if test "${ac_cv_header_stdc+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_header_stdc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_header_stdc=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then
+ :
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then
+ :
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <ctype.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ exit(2);
+ exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ :
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_header_stdc=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5
+echo "${ECHO_T}$ac_cv_header_stdc" >&6
+if test $ac_cv_header_stdc = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define STDC_HEADERS 1
+_ACEOF
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+
+
+
+
+
+
+
+
+
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_Header=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_Header=no"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+
+
+for ac_header in inttypes.h netinet/in.h arpa/inet.h getopt.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to henning@makholm.net ##
+## ---------------------------------- ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+for ac_func in getopt_long strcasecmp
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+
+for ac_header in stdlib.h unistd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ---------------------------------- ##
+## Report this to henning@makholm.net ##
+## ---------------------------------- ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_func in getpagesize
+do
+as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+echo "$as_me:$LINENO: checking for $ac_func" >&5
+echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+if eval "test \"\${$as_ac_var+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $ac_func innocuous_$ac_func
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $ac_func
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+char (*f) () = $ac_func;
+#endif
+#ifdef __cplusplus
+}
+#endif
+
+int
+main ()
+{
+return f != $ac_func;
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ eval "$as_ac_var=yes"
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+eval "$as_ac_var=no"
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+if test `eval echo '${'$as_ac_var'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+echo "$as_me:$LINENO: checking for working mmap" >&5
+echo $ECHO_N "checking for working mmap... $ECHO_C" >&6
+if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_mmap_fixed_mapped=no
+else
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+/* malloc might have been renamed as rpl_malloc. */
+#undef malloc
+
+/* Thanks to Mike Haertel and Jim Avera for this test.
+ Here is a matrix of mmap possibilities:
+ mmap private not fixed
+ mmap private fixed at somewhere currently unmapped
+ mmap private fixed at somewhere already mapped
+ mmap shared not fixed
+ mmap shared fixed at somewhere currently unmapped
+ mmap shared fixed at somewhere already mapped
+ For private mappings, we should verify that changes cannot be read()
+ back from the file, nor mmap's back from the file at a different
+ address. (There have been systems where private was not correctly
+ implemented like the infamous i386 svr4.0, and systems where the
+ VM page cache was not coherent with the file system buffer cache
+ like early versions of FreeBSD and possibly contemporary NetBSD.)
+ For shared mappings, we should conversely verify that changes get
+ propagated back to all the places they're supposed to be.
+
+ Grep wants private fixed already mapped.
+ The main things grep needs to know about mmap are:
+ * does it exist and is it safe to write into the mmap'd area
+ * how to use it (BSD variants) */
+
+#include <fcntl.h>
+#include <sys/mman.h>
+
+#if !STDC_HEADERS && !HAVE_STDLIB_H
+char *malloc ();
+#endif
+
+/* This mess was copied from the GNU getpagesize.h. */
+#if !HAVE_GETPAGESIZE
+/* Assume that all systems that can run configure have sys/param.h. */
+# if !HAVE_SYS_PARAM_H
+# define HAVE_SYS_PARAM_H 1
+# endif
+
+# ifdef _SC_PAGESIZE
+# define getpagesize() sysconf(_SC_PAGESIZE)
+# else /* no _SC_PAGESIZE */
+# if HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# ifdef EXEC_PAGESIZE
+# define getpagesize() EXEC_PAGESIZE
+# else /* no EXEC_PAGESIZE */
+# ifdef NBPG
+# define getpagesize() NBPG * CLSIZE
+# ifndef CLSIZE
+# define CLSIZE 1
+# endif /* no CLSIZE */
+# else /* no NBPG */
+# ifdef NBPC
+# define getpagesize() NBPC
+# else /* no NBPC */
+# ifdef PAGESIZE
+# define getpagesize() PAGESIZE
+# endif /* PAGESIZE */
+# endif /* no NBPC */
+# endif /* no NBPG */
+# endif /* no EXEC_PAGESIZE */
+# else /* no HAVE_SYS_PARAM_H */
+# define getpagesize() 8192 /* punt totally */
+# endif /* no HAVE_SYS_PARAM_H */
+# endif /* no _SC_PAGESIZE */
+
+#endif /* no HAVE_GETPAGESIZE */
+
+int
+main ()
+{
+ char *data, *data2, *data3;
+ int i, pagesize;
+ int fd;
+
+ pagesize = getpagesize ();
+
+ /* First, make a file with some known garbage in it. */
+ data = (char *) malloc (pagesize);
+ if (!data)
+ exit (1);
+ for (i = 0; i < pagesize; ++i)
+ *(data + i) = rand ();
+ umask (0);
+ fd = creat ("conftest.mmap", 0600);
+ if (fd < 0)
+ exit (1);
+ if (write (fd, data, pagesize) != pagesize)
+ exit (1);
+ close (fd);
+
+ /* Next, try to mmap the file at a fixed address which already has
+ something else allocated at it. If we can, also make sure that
+ we see the same garbage. */
+ fd = open ("conftest.mmap", O_RDWR);
+ if (fd < 0)
+ exit (1);
+ data2 = (char *) malloc (2 * pagesize);
+ if (!data2)
+ exit (1);
+ data2 += (pagesize - ((long) data2 & (pagesize - 1))) & (pagesize - 1);
+ if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_FIXED, fd, 0L))
+ exit (1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data2 + i))
+ exit (1);
+
+ /* Finally, make sure that changes to the mapped area do not
+ percolate back to the file as seen by read(). (This is a bug on
+ some variants of i386 svr4.0.) */
+ for (i = 0; i < pagesize; ++i)
+ *(data2 + i) = *(data2 + i) + 1;
+ data3 = (char *) malloc (pagesize);
+ if (!data3)
+ exit (1);
+ if (read (fd, data3, pagesize) != pagesize)
+ exit (1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data3 + i))
+ exit (1);
+ close (fd);
+ exit (0);
+}
+_ACEOF
+rm -f conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } && { ac_try='./conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_func_mmap_fixed_mapped=yes
+else
+ echo "$as_me: program exited with status $ac_status" >&5
+echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+( exit $ac_status )
+ac_cv_func_mmap_fixed_mapped=no
+fi
+rm -f core *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5
+echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6
+if test $ac_cv_func_mmap_fixed_mapped = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_MMAP 1
+_ACEOF
+
+fi
+rm -f conftest.mmap
+
+
+ if test "X$prefix" = "XNONE"; then
+ acl_final_prefix="$ac_default_prefix"
+ else
+ acl_final_prefix="$prefix"
+ fi
+ if test "X$exec_prefix" = "XNONE"; then
+ acl_final_exec_prefix='${prefix}'
+ else
+ acl_final_exec_prefix="$exec_prefix"
+ fi
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+ prefix="$acl_save_prefix"
+
+
+# Check whether --with-gnu-ld or --without-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then
+ withval="$with_gnu_ld"
+ test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi;
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ echo "$as_me:$LINENO: checking for ld used by GCC" >&5
+echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | [A-Za-z]:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the path of ld
+ ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+ while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ echo "$as_me:$LINENO: checking for GNU ld" >&5
+echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6
+else
+ echo "$as_me:$LINENO: checking for non-GNU ld" >&5
+echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6
+fi
+if test "${acl_cv_path_LD+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -z "$LD"; then
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ acl_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some GNU ld's only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break ;;
+ *)
+ test "$with_gnu_ld" != yes && break ;;
+ esac
+ fi
+ done
+ IFS="$ac_save_ifs"
+else
+ acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+ echo "$as_me:$LINENO: result: $LD" >&5
+echo "${ECHO_T}$LD" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5
+echo "$as_me: error: no acceptable ld found in \$PATH" >&2;}
+ { (exit 1); exit 1; }; }
+echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5
+echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6
+if test "${acl_cv_prog_gnu_ld+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ acl_cv_prog_gnu_ld=yes ;;
+*)
+ acl_cv_prog_gnu_ld=no ;;
+esac
+fi
+echo "$as_me:$LINENO: result: $acl_cv_prog_gnu_ld" >&5
+echo "${ECHO_T}$acl_cv_prog_gnu_ld" >&6
+with_gnu_ld=$acl_cv_prog_gnu_ld
+
+
+
+
+ echo "$as_me:$LINENO: checking for shared library run path origin" >&5
+echo $ECHO_N "checking for shared library run path origin... $ECHO_C" >&6
+if test "${acl_cv_rpath+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+ . ./conftest.sh
+ rm -f ./conftest.sh
+ acl_cv_rpath=done
+
+fi
+echo "$as_me:$LINENO: result: $acl_cv_rpath" >&5
+echo "${ECHO_T}$acl_cv_rpath" >&6
+ wl="$acl_cv_wl"
+ libext="$acl_cv_libext"
+ shlibext="$acl_cv_shlibext"
+ hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+ hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+ hardcode_direct="$acl_cv_hardcode_direct"
+ hardcode_minus_L="$acl_cv_hardcode_minus_L"
+ # Check whether --enable-rpath or --disable-rpath was given.
+if test "${enable_rpath+set}" = set; then
+ enableval="$enable_rpath"
+ :
+else
+ enable_rpath=yes
+fi;
+
+
+
+
+
+
+
+ use_additional=yes
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+
+ eval additional_includedir=\"$includedir\"
+ eval additional_libdir=\"$libdir\"
+
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+
+# Check whether --with-libiconv-prefix or --without-libiconv-prefix was given.
+if test "${with_libiconv_prefix+set}" = set; then
+ withval="$with_libiconv_prefix"
+
+ if test "X$withval" = "Xno"; then
+ use_additional=no
+ else
+ if test "X$withval" = "X"; then
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+
+ eval additional_includedir=\"$includedir\"
+ eval additional_libdir=\"$libdir\"
+
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ else
+ additional_includedir="$withval/include"
+ additional_libdir="$withval/lib"
+ fi
+ fi
+
+fi;
+ LIBICONV=
+ LTLIBICONV=
+ INCICONV=
+ rpathdirs=
+ ltrpathdirs=
+ names_already_handled=
+ names_next_round='iconv '
+ while test -n "$names_next_round"; do
+ names_this_round="$names_next_round"
+ names_next_round=
+ for name in $names_this_round; do
+ already_handled=
+ for n in $names_already_handled; do
+ if test "$n" = "$name"; then
+ already_handled=yes
+ break
+ fi
+ done
+ if test -z "$already_handled"; then
+ names_already_handled="$names_already_handled $name"
+ uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+ eval value=\"\$HAVE_LIB$uppername\"
+ if test -n "$value"; then
+ if test "$value" = yes; then
+ eval value=\"\$LIB$uppername\"
+ test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value"
+ eval value=\"\$LTLIB$uppername\"
+ test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value"
+ else
+ :
+ fi
+ else
+ found_dir=
+ found_la=
+ found_so=
+ found_a=
+ if test $use_additional = yes; then
+ if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+ found_dir="$additional_libdir"
+ found_so="$additional_libdir/lib$name.$shlibext"
+ if test -f "$additional_libdir/lib$name.la"; then
+ found_la="$additional_libdir/lib$name.la"
+ fi
+ else
+ if test -f "$additional_libdir/lib$name.$libext"; then
+ found_dir="$additional_libdir"
+ found_a="$additional_libdir/lib$name.$libext"
+ if test -f "$additional_libdir/lib$name.la"; then
+ found_la="$additional_libdir/lib$name.la"
+ fi
+ fi
+ fi
+ fi
+ if test "X$found_dir" = "X"; then
+ for x in $LDFLAGS $LTLIBICONV; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ case "$x" in
+ -L*)
+ dir=`echo "X$x" | sed -e 's/^X-L//'`
+ if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+ found_dir="$dir"
+ found_so="$dir/lib$name.$shlibext"
+ if test -f "$dir/lib$name.la"; then
+ found_la="$dir/lib$name.la"
+ fi
+ else
+ if test -f "$dir/lib$name.$libext"; then
+ found_dir="$dir"
+ found_a="$dir/lib$name.$libext"
+ if test -f "$dir/lib$name.la"; then
+ found_la="$dir/lib$name.la"
+ fi
+ fi
+ fi
+ ;;
+ esac
+ if test "X$found_dir" != "X"; then
+ break
+ fi
+ done
+ fi
+ if test "X$found_dir" != "X"; then
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name"
+ if test "X$found_so" != "X"; then
+ if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
+ else
+ haveit=
+ for x in $ltrpathdirs; do
+ if test "X$x" = "X$found_dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ ltrpathdirs="$ltrpathdirs $found_dir"
+ fi
+ if test "$hardcode_direct" = yes; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
+ else
+ if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
+ haveit=
+ for x in $rpathdirs; do
+ if test "X$x" = "X$found_dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ rpathdirs="$rpathdirs $found_dir"
+ fi
+ else
+ haveit=
+ for x in $LDFLAGS $LIBICONV; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ if test "X$x" = "X-L$found_dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir"
+ fi
+ if test "$hardcode_minus_L" != no; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"
+ else
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
+ fi
+ fi
+ fi
+ fi
+ else
+ if test "X$found_a" != "X"; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a"
+ else
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name"
+ fi
+ fi
+ additional_includedir=
+ case "$found_dir" in
+ */lib | */lib/)
+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+ additional_includedir="$basedir/include"
+ ;;
+ esac
+ if test "X$additional_includedir" != "X"; then
+ if test "X$additional_includedir" != "X/usr/include"; then
+ haveit=
+ if test "X$additional_includedir" = "X/usr/local/include"; then
+ if test -n "$GCC"; then
+ case $host_os in
+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+ esac
+ fi
+ fi
+ if test -z "$haveit"; then
+ for x in $CPPFLAGS $INCICONV; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ if test "X$x" = "X-I$additional_includedir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test -d "$additional_includedir"; then
+ INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir"
+ fi
+ fi
+ fi
+ fi
+ fi
+ if test -n "$found_la"; then
+ save_libdir="$libdir"
+ case "$found_la" in
+ */* | *\\*) . "$found_la" ;;
+ *) . "./$found_la" ;;
+ esac
+ libdir="$save_libdir"
+ for dep in $dependency_libs; do
+ case "$dep" in
+ -L*)
+ additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+ if test "X$additional_libdir" != "X/usr/lib"; then
+ haveit=
+ if test "X$additional_libdir" = "X/usr/local/lib"; then
+ if test -n "$GCC"; then
+ case $host_os in
+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;
+ esac
+ fi
+ fi
+ if test -z "$haveit"; then
+ haveit=
+ for x in $LDFLAGS $LIBICONV; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ if test "X$x" = "X-L$additional_libdir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test -d "$additional_libdir"; then
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir"
+ fi
+ fi
+ haveit=
+ for x in $LDFLAGS $LTLIBICONV; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ if test "X$x" = "X-L$additional_libdir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ if test -d "$additional_libdir"; then
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir"
+ fi
+ fi
+ fi
+ fi
+ ;;
+ -R*)
+ dir=`echo "X$dep" | sed -e 's/^X-R//'`
+ if test "$enable_rpath" != no; then
+ haveit=
+ for x in $rpathdirs; do
+ if test "X$x" = "X$dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ rpathdirs="$rpathdirs $dir"
+ fi
+ haveit=
+ for x in $ltrpathdirs; do
+ if test "X$x" = "X$dir"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ ltrpathdirs="$ltrpathdirs $dir"
+ fi
+ fi
+ ;;
+ -l*)
+ names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+ ;;
+ *.la)
+ names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+ ;;
+ *)
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$dep"
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep"
+ ;;
+ esac
+ done
+ fi
+ else
+ LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"
+ fi
+ fi
+ fi
+ done
+ done
+ if test "X$rpathdirs" != "X"; then
+ if test -n "$hardcode_libdir_separator"; then
+ alldirs=
+ for found_dir in $rpathdirs; do
+ alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+ done
+ acl_save_libdir="$libdir"
+ libdir="$alldirs"
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ libdir="$acl_save_libdir"
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$flag"
+ else
+ for found_dir in $rpathdirs; do
+ acl_save_libdir="$libdir"
+ libdir="$found_dir"
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ libdir="$acl_save_libdir"
+ LIBICONV="${LIBICONV}${LIBICONV:+ }$flag"
+ done
+ fi
+ fi
+ if test "X$ltrpathdirs" != "X"; then
+ for found_dir in $ltrpathdirs; do
+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir"
+ done
+ fi
+
+
+
+
+
+
+
+ am_save_CPPFLAGS="$CPPFLAGS"
+
+ for element in $INCICONV; do
+ haveit=
+ for x in $CPPFLAGS; do
+
+ acl_save_prefix="$prefix"
+ prefix="$acl_final_prefix"
+ acl_save_exec_prefix="$exec_prefix"
+ exec_prefix="$acl_final_exec_prefix"
+ eval x=\"$x\"
+ exec_prefix="$acl_save_exec_prefix"
+ prefix="$acl_save_prefix"
+
+ if test "X$x" = "X$element"; then
+ haveit=yes
+ break
+ fi
+ done
+ if test -z "$haveit"; then
+ CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+ fi
+ done
+
+
+ echo "$as_me:$LINENO: checking for iconv" >&5
+echo $ECHO_N "checking for iconv... $ECHO_C" >&6
+if test "${am_cv_func_iconv+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ am_cv_func_iconv="no, consider installing GNU libiconv"
+ am_cv_lib_iconv=no
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <iconv.h>
+int
+main ()
+{
+iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ am_cv_func_iconv=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test "$am_cv_func_iconv" != yes; then
+ am_save_LIBS="$LIBS"
+ LIBS="$LIBS $LIBICONV"
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <iconv.h>
+int
+main ()
+{
+iconv_t cd = iconv_open("","");
+ iconv(cd,NULL,NULL,NULL,NULL);
+ iconv_close(cd);
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ am_cv_lib_iconv=yes
+ am_cv_func_iconv=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LIBS="$am_save_LIBS"
+ fi
+
+fi
+echo "$as_me:$LINENO: result: $am_cv_func_iconv" >&5
+echo "${ECHO_T}$am_cv_func_iconv" >&6
+ if test "$am_cv_func_iconv" = yes; then
+
+cat >>confdefs.h <<\_ACEOF
+#define HAVE_ICONV 1
+_ACEOF
+
+ fi
+ if test "$am_cv_lib_iconv" = yes; then
+ echo "$as_me:$LINENO: checking how to link with libiconv" >&5
+echo $ECHO_N "checking how to link with libiconv... $ECHO_C" >&6
+ echo "$as_me:$LINENO: result: $LIBICONV" >&5
+echo "${ECHO_T}$LIBICONV" >&6
+ else
+ CPPFLAGS="$am_save_CPPFLAGS"
+ LIBICONV=
+ LTLIBICONV=
+ fi
+
+
+
+ if test "$am_cv_func_iconv" = yes; then
+ echo "$as_me:$LINENO: checking for iconv declaration" >&5
+echo $ECHO_N "checking for iconv declaration... $ECHO_C" >&6
+ if test "${am_cv_proto_iconv+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+
+ cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+#include <stdlib.h>
+#include <iconv.h>
+extern
+#ifdef __cplusplus
+"C"
+#endif
+#if defined(__STDC__) || defined(__cplusplus)
+size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
+#else
+size_t iconv();
+#endif
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ am_cv_proto_iconv_arg1=""
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+am_cv_proto_iconv_arg1="const"
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"
+fi
+
+ am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
+ echo "$as_me:$LINENO: result: ${ac_t:-
+ }$am_cv_proto_iconv" >&5
+echo "${ECHO_T}${ac_t:-
+ }$am_cv_proto_iconv" >&6
+
+cat >>confdefs.h <<_ACEOF
+#define ICONV_CONST $am_cv_proto_iconv_arg1
+_ACEOF
+
+ fi
+
+
+# Extract the first word of "perl", so it can be a program name with args.
+set dummy perl; ac_word=$2
+echo "$as_me:$LINENO: checking for $ac_word" >&5
+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
+if test "${ac_cv_prog_PERL+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ if test -n "$PERL"; then
+ ac_cv_prog_PERL="$PERL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_PERL="perl"
+ echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+done
+
+fi
+fi
+PERL=$ac_cv_prog_PERL
+if test -n "$PERL"; then
+ echo "$as_me:$LINENO: result: $PERL" >&5
+echo "${ECHO_T}$PERL" >&6
+else
+ echo "$as_me:$LINENO: result: no" >&5
+echo "${ECHO_T}no" >&6
+fi
+
+
+ ac_config_headers="$ac_config_headers config.h:config.hin"
+
+ ac_config_files="$ac_config_files Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+{
+ (set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n \
+ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p"
+ ;;
+ esac;
+} |
+ sed '
+ t clear
+ : clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ : end' >>confcache
+if diff $cache_file confcache >/dev/null 2>&1; then :; else
+ if test -w $cache_file; then
+ test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file"
+ cat confcache >$cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=/{
+s/:*\$(srcdir):*/:/;
+s/:*\${srcdir}:*/:/;
+s/:*@srcdir@:*/:/;
+s/^\([^=]*=[ ]*\):*/\1/;
+s/:*$//;
+s/^[^=]*=[ ]*$//;
+}'
+fi
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_i=`echo "$ac_i" |
+ sed 's/\$U\././;s/\.o$//;s/\.obj$//'`
+ # 2. Add them.
+ ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext"
+ ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5
+echo "$as_me: creating $CONFIG_STATUS" >&6;}
+cat >$CONFIG_STATUS <<_ACEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+## --------------------- ##
+## M4sh Initialization. ##
+## --------------------- ##
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
+ set -o posix
+fi
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# Support unset when possible.
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ as_unset=unset
+else
+ as_unset=false
+fi
+
+
+# Work around bugs in pre-3.0 UWIN ksh.
+$as_unset ENV MAIL MAILPATH
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+for as_var in \
+ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \
+ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \
+ LC_TELEPHONE LC_TIME
+do
+ if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then
+ eval $as_var=C; export $as_var
+ else
+ $as_unset $as_var
+ fi
+done
+
+# Required to use basename.
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+
+# Name of the executable.
+as_me=`$as_basename "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)$' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; }
+ /^X\/\(\/\/\)$/{ s//\1/; q; }
+ /^X\/\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+
+
+# PATH needs CR, and LINENO needs CR and PATH.
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ echo "#! /bin/sh" >conf$$.sh
+ echo "exit 0" >>conf$$.sh
+ chmod +x conf$$.sh
+ if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+ PATH_SEPARATOR=';'
+ else
+ PATH_SEPARATOR=:
+ fi
+ rm -f conf$$.sh
+fi
+
+
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" || {
+ # Find who we are. Look in the path if we contain no path at all
+ # relative or not.
+ case $0 in
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+done
+
+ ;;
+ esac
+ # We did not find ourselves, most probably we were run as `sh COMMAND'
+ # in which case we are not to be found in the path.
+ if test "x$as_myself" = x; then
+ as_myself=$0
+ fi
+ if test ! -f "$as_myself"; then
+ { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5
+echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;}
+ { (exit 1); exit 1; }; }
+ fi
+ case $CONFIG_SHELL in
+ '')
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for as_base in sh bash ksh sh5; do
+ case $as_dir in
+ /*)
+ if ("$as_dir/$as_base" -c '
+ as_lineno_1=$LINENO
+ as_lineno_2=$LINENO
+ as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null`
+ test "x$as_lineno_1" != "x$as_lineno_2" &&
+ test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then
+ $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; }
+ $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; }
+ CONFIG_SHELL=$as_dir/$as_base
+ export CONFIG_SHELL
+ exec "$CONFIG_SHELL" "$0" ${1+"$@"}
+ fi;;
+ esac
+ done
+done
+;;
+ esac
+
+ # Create $as_me.lineno as a copy of $as_myself, but with $LINENO
+ # uniformly replaced by the line number. The first 'sed' inserts a
+ # line-number line before each line; the second 'sed' does the real
+ # work. The second script uses 'N' to pair each line-number line
+ # with the numbered line, and appends trailing '-' during
+ # substitution so that $LINENO is not a special case at line end.
+ # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the
+ # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-)
+ sed '=' <$as_myself |
+ sed '
+ N
+ s,$,-,
+ : loop
+ s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3,
+ t loop
+ s,-$,,
+ s,^['$as_cr_digits']*\n,,
+ ' >$as_me.lineno &&
+ chmod +x $as_me.lineno ||
+ { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5
+echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;}
+ { (exit 1); exit 1; }; }
+
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensible to this).
+ . ./$as_me.lineno
+ # Exit status is that of the last command.
+ exit
+}
+
+
+case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
+ *c*,-n*) ECHO_N= ECHO_C='
+' ECHO_T=' ' ;;
+ *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;;
+ *) ECHO_N= ECHO_C='\c' ECHO_T= ;;
+esac
+
+if expr a : '\(a\)' >/dev/null 2>&1; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+rm -f conf$$ conf$$.exe conf$$.file
+echo >conf$$.file
+if ln -s conf$$.file conf$$ 2>/dev/null; then
+ # We could just check for DJGPP; but this test a) works b) is more generic
+ # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04).
+ if test -f conf$$.exe; then
+ # Don't use ln at all; we don't have any links
+ as_ln_s='cp -p'
+ else
+ as_ln_s='ln -s'
+ fi
+elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+else
+ as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.file
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p=:
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_executable_p="test -f"
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.
+as_nl='
+'
+IFS=" $as_nl"
+
+# CDPATH.
+$as_unset CDPATH
+
+exec 6>&1
+
+# Open the log real soon, to keep \$[0] and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling. Logging --version etc. is OK.
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+cat >&5 <<_CSEOF
+
+This file was extended by Xcftools $as_me 0.7, which was
+generated by GNU Autoconf 2.59. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+_CSEOF
+echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5
+echo >&5
+_ACEOF
+
+# Files that config.status was made for.
+if test -n "$ac_config_files"; then
+ echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_headers"; then
+ echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_links"; then
+ echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS
+fi
+
+if test -n "$ac_config_commands"; then
+ echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+ac_cs_usage="\
+\`$as_me' instantiates files from templates according to the
+current configuration.
+
+Usage: $0 [OPTIONS] [FILE]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Report bugs to <bug-autoconf@gnu.org>."
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+ac_cs_version="\\
+Xcftools config.status 0.7
+configured by $0, generated by GNU Autoconf 2.59,
+ with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\"
+
+Copyright (C) 2003 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+srcdir=$srcdir
+INSTALL="$INSTALL"
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+# If no file are specified by the user, then we need to provide default
+# value. By we need to know if files were specified by the user.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=*)
+ ac_option=`expr "x$1" : 'x\([^=]*\)='`
+ ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ -*)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ *) # This is not an option, so the user has probably given explicit
+ # arguments.
+ ac_option=$1
+ ac_need_defaults=false;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --vers* | -V )
+ echo "$ac_cs_version"; exit 0 ;;
+ --he | --h)
+ # Conflict between --help and --header
+ { { echo "$as_me:$LINENO: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: ambiguous option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; };;
+ --help | --hel | -h )
+ echo "$ac_cs_usage"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ CONFIG_FILES="$CONFIG_FILES $ac_optarg"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg"
+ ac_need_defaults=false;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&5
+echo "$as_me: error: unrecognized option: $1
+Try \`$0 --help' for more information." >&2;}
+ { (exit 1); exit 1; }; } ;;
+
+ *) ac_config_targets="$ac_config_targets $1" ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+if \$ac_cs_recheck; then
+ echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6
+ exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+fi
+
+_ACEOF
+
+
+
+
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_config_target in $ac_config_targets
+do
+ case "$ac_config_target" in
+ # Handling of arguments.
+ "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.hin" ;;
+ *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
+ { (exit 1); exit 1; }; };;
+ esac
+done
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason to put it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Create a temporary directory, and hook for its removal unless debugging.
+$debug ||
+{
+ trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0
+ trap '{ (exit 1); exit 1; }' 1 2 13 15
+}
+
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` &&
+ test -n "$tmp" && test -d "$tmp"
+} ||
+{
+ tmp=./confstat$$-$RANDOM
+ (umask 077 && mkdir $tmp)
+} ||
+{
+ echo "$me: cannot create a temporary directory in ." >&2
+ { (exit 1); exit 1; }
+}
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<_ACEOF
+
+#
+# CONFIG_FILES section.
+#
+
+# No need to generate the scripts if there are no CONFIG_FILES.
+# This happens for instance when ./config.status config.h
+if test -n "\$CONFIG_FILES"; then
+ # Protect against being on the right side of a sed subst in config.status.
+ sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g;
+ s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF
+s,@SHELL@,$SHELL,;t t
+s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t
+s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t
+s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t
+s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t
+s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t
+s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t
+s,@exec_prefix@,$exec_prefix,;t t
+s,@prefix@,$prefix,;t t
+s,@program_transform_name@,$program_transform_name,;t t
+s,@bindir@,$bindir,;t t
+s,@sbindir@,$sbindir,;t t
+s,@libexecdir@,$libexecdir,;t t
+s,@datadir@,$datadir,;t t
+s,@sysconfdir@,$sysconfdir,;t t
+s,@sharedstatedir@,$sharedstatedir,;t t
+s,@localstatedir@,$localstatedir,;t t
+s,@libdir@,$libdir,;t t
+s,@includedir@,$includedir,;t t
+s,@oldincludedir@,$oldincludedir,;t t
+s,@infodir@,$infodir,;t t
+s,@mandir@,$mandir,;t t
+s,@build_alias@,$build_alias,;t t
+s,@host_alias@,$host_alias,;t t
+s,@target_alias@,$target_alias,;t t
+s,@DEFS@,$DEFS,;t t
+s,@ECHO_C@,$ECHO_C,;t t
+s,@ECHO_N@,$ECHO_N,;t t
+s,@ECHO_T@,$ECHO_T,;t t
+s,@LIBS@,$LIBS,;t t
+s,@SET_MAKE@,$SET_MAKE,;t t
+s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t
+s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t
+s,@INSTALL_DATA@,$INSTALL_DATA,;t t
+s,@CC@,$CC,;t t
+s,@CFLAGS@,$CFLAGS,;t t
+s,@LDFLAGS@,$LDFLAGS,;t t
+s,@CPPFLAGS@,$CPPFLAGS,;t t
+s,@ac_ct_CC@,$ac_ct_CC,;t t
+s,@EXEEXT@,$EXEEXT,;t t
+s,@OBJEXT@,$OBJEXT,;t t
+s,@build@,$build,;t t
+s,@build_cpu@,$build_cpu,;t t
+s,@build_vendor@,$build_vendor,;t t
+s,@build_os@,$build_os,;t t
+s,@host@,$host,;t t
+s,@host_cpu@,$host_cpu,;t t
+s,@host_vendor@,$host_vendor,;t t
+s,@host_os@,$host_os,;t t
+s,@CPP@,$CPP,;t t
+s,@EGREP@,$EGREP,;t t
+s,@LIBICONV@,$LIBICONV,;t t
+s,@LTLIBICONV@,$LTLIBICONV,;t t
+s,@PERL@,$PERL,;t t
+s,@LIBOBJS@,$LIBOBJS,;t t
+s,@LTLIBOBJS@,$LTLIBOBJS,;t t
+CEOF
+
+_ACEOF
+
+ cat >>$CONFIG_STATUS <<\_ACEOF
+ # Split the substitutions into bite-sized pieces for seds with
+ # small command number limits, like on Digital OSF/1 and HP-UX.
+ ac_max_sed_lines=48
+ ac_sed_frag=1 # Number of current file.
+ ac_beg=1 # First line for current file.
+ ac_end=$ac_max_sed_lines # Line after last line for current file.
+ ac_more_lines=:
+ ac_sed_cmds=
+ while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ else
+ sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag
+ fi
+ if test ! -s $tmp/subs.frag; then
+ ac_more_lines=false
+ else
+ # The purpose of the label and of the branching condition is to
+ # speed up the sed processing (if there are no `@' at all, there
+ # is no need to browse any of the substitutions).
+ # These are the two extra sed commands mentioned above.
+ (echo ':t
+ /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed"
+ fi
+ ac_sed_frag=`expr $ac_sed_frag + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_lines`
+ fi
+ done
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+ fi
+fi # test -n "$CONFIG_FILES"
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories.
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ ac_builddir=.
+
+if test "$ac_dir" != .; then
+ ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'`
+else
+ ac_dir_suffix= ac_top_builddir=
+fi
+
+case $srcdir in
+ .) # No --srcdir option. We are building in place.
+ ac_srcdir=.
+ if test -z "$ac_top_builddir"; then
+ ac_top_srcdir=.
+ else
+ ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'`
+ fi ;;
+ [\\/]* | ?:[\\/]* ) # Absolute path.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir ;;
+ *) # Relative path.
+ ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_builddir$srcdir ;;
+esac
+
+# Do not use `cd foo && pwd` to compute absolute paths, because
+# the directories may not exist.
+case `pwd` in
+.) ac_abs_builddir="$ac_dir";;
+*)
+ case "$ac_dir" in
+ .) ac_abs_builddir=`pwd`;;
+ [\\/]* | ?:[\\/]* ) ac_abs_builddir="$ac_dir";;
+ *) ac_abs_builddir=`pwd`/"$ac_dir";;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_builddir=${ac_top_builddir}.;;
+*)
+ case ${ac_top_builddir}. in
+ .) ac_abs_top_builddir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_builddir=${ac_top_builddir}.;;
+ *) ac_abs_top_builddir=$ac_abs_builddir/${ac_top_builddir}.;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_srcdir=$ac_srcdir;;
+*)
+ case $ac_srcdir in
+ .) ac_abs_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_srcdir=$ac_srcdir;;
+ *) ac_abs_srcdir=$ac_abs_builddir/$ac_srcdir;;
+ esac;;
+esac
+case $ac_abs_builddir in
+.) ac_abs_top_srcdir=$ac_top_srcdir;;
+*)
+ case $ac_top_srcdir in
+ .) ac_abs_top_srcdir=$ac_abs_builddir;;
+ [\\/]* | ?:[\\/]* ) ac_abs_top_srcdir=$ac_top_srcdir;;
+ *) ac_abs_top_srcdir=$ac_abs_builddir/$ac_top_srcdir;;
+ esac;;
+esac
+
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
+ esac
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ configure_input=
+ else
+ configure_input="$ac_file. "
+ fi
+ configure_input=$configure_input"Generated from `echo $ac_file_in |
+ sed 's,.*/,,'` by configure."
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+
+ if test x"$ac_file" != x-; then
+ { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+ rm -f "$ac_file"
+ fi
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF
+ sed "$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s,@configure_input@,$configure_input,;t t
+s,@srcdir@,$ac_srcdir,;t t
+s,@abs_srcdir@,$ac_abs_srcdir,;t t
+s,@top_srcdir@,$ac_top_srcdir,;t t
+s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t
+s,@builddir@,$ac_builddir,;t t
+s,@abs_builddir@,$ac_abs_builddir,;t t
+s,@top_builddir@,$ac_top_builddir,;t t
+s,@abs_top_builddir@,$ac_abs_top_builddir,;t t
+s,@INSTALL@,$ac_INSTALL,;t t
+" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out
+ rm -f $tmp/stdin
+ if test x"$ac_file" != x-; then
+ mv $tmp/out $ac_file
+ else
+ cat $tmp/out
+ rm -f $tmp/out
+ fi
+
+done
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+#
+# CONFIG_HEADER section.
+#
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='[ ].*$,\1#\2'
+ac_dC=' '
+ac_dD=',;t'
+# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='$,\1#\2define\3'
+ac_uC=' '
+ac_uD=',;t'
+
+for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case $ac_file in
+ - | *:- | *:-:* ) # input from stdin
+ cat >$tmp/stdin
+ ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'`
+ ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;;
+ * ) ac_file_in=$ac_file.in ;;
+ esac
+
+ test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+
+ # First look for the input files in the build tree, otherwise in the
+ # src tree.
+ ac_file_inputs=`IFS=:
+ for f in $ac_file_in; do
+ case $f in
+ -) echo $tmp/stdin ;;
+ [\\/$]*)
+ # Absolute (can't be DOS-style, as IFS=:)
+ test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ # Do quote $f, to prevent DOS paths from being IFS'd.
+ echo "$f";;
+ *) # Relative
+ if test -f "$f"; then
+ # Build tree
+ echo "$f"
+ elif test -f "$srcdir/$f"; then
+ # Source tree
+ echo "$srcdir/$f"
+ else
+ # /dev/null tree
+ { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5
+echo "$as_me: error: cannot find input file: $f" >&2;}
+ { (exit 1); exit 1; }; }
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+ # Remove the trailing spaces.
+ sed 's/[ ]*$//' $ac_file_inputs >$tmp/in
+
+_ACEOF
+
+# Transform confdefs.h into two sed scripts, `conftest.defines' and
+# `conftest.undefs', that substitutes the proper values into
+# config.h.in to produce config.h. The first handles `#define'
+# templates, and the second `#undef' templates.
+# And first: Protect against being on the right side of a sed subst in
+# config.status. Protect against being in an unquoted here document
+# in config.status.
+rm -f conftest.defines conftest.undefs
+# Using a here document instead of a string reduces the quoting nightmare.
+# Putting comments in sed scripts is not portable.
+#
+# `end' is used to avoid that the second main sed command (meant for
+# 0-ary CPP macros) applies to n-ary macro definitions.
+# See the Autoconf documentation for `clear'.
+cat >confdef2sed.sed <<\_ACEOF
+s/[\\&,]/\\&/g
+s,[\\$`],\\&,g
+t clear
+: clear
+s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp
+t end
+s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp
+: end
+_ACEOF
+# If some macros were called several times there might be several times
+# the same #defines, which is useless. Nevertheless, we may not want to
+# sort them, since we want the *last* AC-DEFINE to be honored.
+uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines
+sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs
+rm -f confdef2sed.sed
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >>conftest.undefs <<\_ACEOF
+s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */,
+_ACEOF
+
+# Break up conftest.defines because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS
+echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS
+echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS
+echo ' :' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.defines >/dev/null
+do
+ # Write a limited-size here document to $tmp/defines.sed.
+ echo ' cat >$tmp/defines.sed <<CEOF' >>$CONFIG_STATUS
+ # Speed up: don't consider the non `#define' lines.
+ echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS
+ # Work around the forget-to-reset-the-flag bug.
+ echo 't clr' >>$CONFIG_STATUS
+ echo ': clr' >>$CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS
+ echo 'CEOF
+ sed -f $tmp/defines.sed $tmp/in >$tmp/out
+ rm -f $tmp/in
+ mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail
+ rm -f conftest.defines
+ mv conftest.tail conftest.defines
+done
+rm -f conftest.defines
+echo ' fi # grep' >>$CONFIG_STATUS
+echo >>$CONFIG_STATUS
+
+# Break up conftest.undefs because some shells have a limit on the size
+# of here documents, and old seds have small limits too (100 cmds).
+echo ' # Handle all the #undef templates' >>$CONFIG_STATUS
+rm -f conftest.tail
+while grep . conftest.undefs >/dev/null
+do
+ # Write a limited-size here document to $tmp/undefs.sed.
+ echo ' cat >$tmp/undefs.sed <<CEOF' >>$CONFIG_STATUS
+ # Speed up: don't consider the non `#undef'
+ echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS
+ # Work around the forget-to-reset-the-flag bug.
+ echo 't clr' >>$CONFIG_STATUS
+ echo ': clr' >>$CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS
+ echo 'CEOF
+ sed -f $tmp/undefs.sed $tmp/in >$tmp/out
+ rm -f $tmp/in
+ mv $tmp/out $tmp/in
+' >>$CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail
+ rm -f conftest.undefs
+ mv conftest.tail conftest.undefs
+done
+rm -f conftest.undefs
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ if test x"$ac_file" = x-; then
+ echo "/* Generated by configure. */" >$tmp/config.h
+ else
+ echo "/* $ac_file. Generated by configure. */" >$tmp/config.h
+ fi
+ cat $tmp/in >>$tmp/config.h
+ rm -f $tmp/in
+ if test x"$ac_file" != x-; then
+ if diff $ac_file $tmp/config.h >/dev/null 2>&1; then
+ { echo "$as_me:$LINENO: $ac_file is unchanged" >&5
+echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ ac_dir=`(dirname "$ac_file") 2>/dev/null ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ { if $as_mkdir_p; then
+ mkdir -p "$ac_dir"
+ else
+ as_dir="$ac_dir"
+ as_dirs=
+ while test ! -d "$as_dir"; do
+ as_dirs="$as_dir $as_dirs"
+ as_dir=`(dirname "$as_dir") 2>/dev/null ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| \
+ . : '\(.\)' 2>/dev/null ||
+echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; }
+ /^X\(\/\/\)[^/].*/{ s//\1/; q; }
+ /^X\(\/\/\)$/{ s//\1/; q; }
+ /^X\(\/\).*/{ s//\1/; q; }
+ s/.*/./; q'`
+ done
+ test ! -n "$as_dirs" || mkdir $as_dirs
+ fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5
+echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;}
+ { (exit 1); exit 1; }; }; }
+
+ rm -f $ac_file
+ mv $tmp/config.h $ac_file
+ fi
+ else
+ cat $tmp/config.h
+ rm -f $tmp/config.h
+ fi
+done
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF
+
+{ (exit 0); exit 0; }
+_ACEOF
+chmod +x $CONFIG_STATUS
+ac_clean_files=$ac_clean_files_save
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || { (exit 1); exit 1; }
+fi
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..c337371
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,56 @@
+dnl Configure script for xcftools
+dnl
+dnl Copyright (C) 2006 Henning Makholm
+dnl
+dnl This program is free software; you can redistribute it and/or modify
+dnl it under the terms of version 2 of the GNU General Public License as
+dnl published by the Free Software Foundation.
+dnl
+dnl This program is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+dnl GNU General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU General Public License
+dnl along with this program; if not, write to the Free Software
+dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+dnl
+dnl ------------------------
+dnl The following line is the MASTER SOURCE for the version number
+AC_INIT(Xcftools,0.7,henning@makholm.net,xcftools)
+AC_COPYRIGHT(General copyright notice for AC_PACKAGE_NAME:
+ [@COPYRIGHT@ Henning Makholm]
+)
+AC_REVISION($Id: configure.ac,v 1.6 2006/01/28 21:02:16 makholm Exp $)
+AC_CONFIG_SRCDIR(xcfinfo.c)
+
+AC_PROG_MAKE_SET
+AC_PROG_INSTALL
+AC_ARG_PROGRAM
+
+AC_PROG_CC
+case $GCC::$CFLAGS in yes::*-Wall* ) ;;
+ yes::*) CFLAGS="$CFLAGS -Wall" ;;
+esac
+case $GCC::$CFLAGS in *-g* | *omit-frame-pointer* ) ;;
+ yes::*) CFLAGS="$CFLAGS -fomit-frame-pointer" ;;
+esac
+AC_C_INLINE
+
+AC_C_BIGENDIAN
+AC_CANONICAL_HOST
+case $host_cpu in i?86 | x86_64 | powerpc)
+ AC_DEFINE(CAN_DO_UNALIGNED_WORDS,1,
+ [Define for CPUs that can read unaligned words without traps or faults])
+esac
+AC_CHECK_HEADERS(inttypes.h netinet/in.h arpa/inet.h getopt.h)
+
+AC_CHECK_FUNCS(getopt_long strcasecmp)
+AC_FUNC_MMAP
+AM_ICONV
+
+AC_CHECK_PROG(PERL,perl,perl)
+
+AC_CONFIG_HEADERS(config.h:config.hin)
+AC_CONFIG_FILES(Makefile)
+AC_OUTPUT
diff --git a/dist-generated b/dist-generated
new file mode 100644
index 0000000..2656aed
--- /dev/null
+++ b/dist-generated
@@ -0,0 +1,4 @@
+aclocal.m4
+config.hin
+configure
+notcvsfiles
diff --git a/flatspec.c b/flatspec.c
new file mode 100644
index 0000000..e318458
--- /dev/null
+++ b/flatspec.c
@@ -0,0 +1,339 @@
+/* Flattening selections function for xcftools
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include "xcftools.h"
+#include "flatten.h"
+#include <string.h>
+#include <stdlib.h>
+
+void
+init_flatspec(struct FlattenSpec *spec)
+{
+ spec->dim.c.l = spec->dim.c.r = spec->dim.c.t = spec->dim.c.b = 0 ;
+ spec->dim.height = -1 ;
+ spec->dim.width = -1 ;
+ spec->default_pixel = PERHAPS_ALPHA_CHANNEL ;
+ spec->numLayers = 0 ;
+ spec->layers = NULL ;
+ spec->transmap_filename = NULL ;
+ spec->output_filename = "-" ;
+ spec->out_color_mode = COLOR_BY_CONTENTS ;
+ spec->partial_transparency_mode = ALLOW_PARTIAL_TRANSPARENCY ;
+ spec->process_in_memory = 0 ;
+ spec->gimpish_indexed = 1 ;
+}
+
+void
+add_layer_request(struct FlattenSpec *spec, const char *layer)
+{
+ spec->layers = realloc(spec->layers,
+ sizeof(struct xcfLayer) * (1+spec->numLayers));
+ if( spec->layers == NULL )
+ FatalUnexpected(_("Out of memory"));
+ spec->layers[spec->numLayers].name = layer ;
+ spec->layers[spec->numLayers].mode = (GimpLayerModeEffects)-1 ;
+ spec->layers[spec->numLayers].opacity = 9999 ;
+ spec->layers[spec->numLayers].hasMask = -1 ;
+ spec->numLayers++ ;
+}
+
+struct xcfLayer *
+lastlayerspec(struct FlattenSpec *spec,const char *option)
+{
+ if( spec->numLayers == 0 )
+ FatalGeneric(20,_("The %s option must follow a layer name on the "
+ "command line"),option);
+ return spec->layers + (spec->numLayers-1) ;
+}
+
+static int
+typeHasTransparency(GimpImageType type)
+{
+ switch( type ) {
+ case GIMP_RGB_IMAGE:
+ case GIMP_GRAY_IMAGE:
+ case GIMP_INDEXED_IMAGE:
+ return 0 ;
+ case GIMP_RGBA_IMAGE:
+ case GIMP_GRAYA_IMAGE:
+ case GIMP_INDEXEDA_IMAGE:
+ return 1 ;
+ }
+ return 1 ;
+}
+
+static enum out_color_mode
+color_by_layers(struct FlattenSpec *spec)
+{
+ int colormap_is_colored = 0 ;
+ enum out_color_mode grayish = COLOR_MONO ;
+ int i ;
+
+ if( degrayPixel(spec->default_pixel) < 0 )
+ return COLOR_RGB ;
+ for( i=0; i<colormapLength; i++ ) {
+ if( colormap[i] == NEWALPHA(0,0) || colormap[i] == NEWALPHA(-1,0) )
+ continue ;
+ if( degrayPixel(colormap[i]) == -1 ) {
+ colormap_is_colored = 1 ;
+ break ;
+ } else {
+ grayish = COLOR_GRAY ;
+ }
+ }
+ for( i=0; i<spec->numLayers; i++ )
+ switch( spec->layers[i].type ) {
+ case GIMP_RGB_IMAGE:
+ case GIMP_RGBA_IMAGE:
+ return COLOR_RGB ;
+ case GIMP_GRAY_IMAGE:
+ case GIMP_GRAYA_IMAGE:
+ grayish = COLOR_GRAY ;
+ break ;
+ case GIMP_INDEXED_IMAGE:
+ case GIMP_INDEXEDA_IMAGE:
+ if( colormap_is_colored ) return COLOR_RGB ;
+ break ;
+ }
+ return grayish ;
+}
+
+void
+complete_flatspec(struct FlattenSpec *spec, guesser guess_callback)
+{
+ unsigned i ;
+ int anyPartial ;
+
+ if( spec->dim.height == -1 ) {
+ spec->dim.height = XCF.height ;
+ spec->dim.width = XCF.width ;
+ }
+ computeDimensions(&spec->dim);
+
+ /* Find the layers to convert.
+ */
+ if( spec->numLayers == 0 ) {
+ spec->layers = XCF.layers ;
+ spec->numLayers = XCF.numLayers ;
+ } else {
+ for( i=0; i<spec->numLayers; i++ ) {
+ GimpLayerModeEffects mode ;
+ int opacity, hasMask ;
+ unsigned j ;
+
+ for( j=0; ; j++ ) {
+ if( j == XCF.numLayers )
+ FatalGeneric(22,_("The image has no layer called '%s'"),
+ spec->layers[i].name);
+ if( strcmp(spec->layers[i].name,XCF.layers[j].name) == 0 )
+ break ;
+ }
+ mode = spec->layers[i].mode == (GimpLayerModeEffects)-1 ?
+ XCF.layers[j].mode : spec->layers[i].mode ;
+ opacity = spec->layers[i].opacity == 9999 ?
+ XCF.layers[j].opacity : spec->layers[i].opacity ;
+ hasMask = spec->layers[i].hasMask == -1 ?
+ XCF.layers[j].hasMask : spec->layers[i].hasMask ;
+ if( hasMask && !XCF.layers[j].hasMask &&
+ XCF.layers[j].mask.hierarchy == 0 )
+ FatalGeneric(22,_("Layer '%s' has no layer mask to enable"),
+ spec->layers[i].name);
+ spec->layers[i] = XCF.layers[j] ;
+ spec->layers[i].mode = mode ;
+ spec->layers[i].opacity = opacity ;
+ spec->layers[i].hasMask = hasMask ;
+ spec->layers[i].isVisible = 1 ;
+ }
+ }
+
+ /* Force the mode of the lowest visible layer to be Normal or Dissolve.
+ * That may not be logical, but the Gimp does it
+ */
+ for( i=0; i < spec->numLayers; i++ ) {
+ if( spec->layers[i].isVisible ) {
+ if( spec->layers[i].mode != GIMP_DISSOLVE_MODE )
+ spec->layers[i].mode = GIMP_NORMAL_MODE ;
+ break ;
+ }
+ }
+
+ /* Mimic the Gimp's behavior on indexed layers */
+ if( XCF.type == GIMP_INDEXED && spec->gimpish_indexed ) {
+ for( i=0; i<spec->numLayers; i++ )
+ if( spec->layers[i].mode != GIMP_DISSOLVE_MODE )
+ spec->layers[i].mode = GIMP_NORMAL_NOPARTIAL_MODE ;
+ } else
+ spec->gimpish_indexed = 0 ;
+
+ /* Turn off layers that we don't hit at all */
+ for( i=0; i<spec->numLayers; i++ )
+ if( spec->layers[i].isVisible &&
+ disjointRects(spec->dim.c,spec->layers[i].dim.c) )
+ spec->layers[i].isVisible = 0 ;
+
+ /* See if there is a completely covering layer somewhere in the stack */
+ /* Also check if partial transparency is possible */
+ anyPartial = 0 ;
+ for( i=spec->numLayers; i-- ; ) {
+ if( !spec->layers[i].isVisible )
+ continue ;
+ if( typeHasTransparency(spec->layers[i].type) ) {
+ if( spec->layers[i].mode == GIMP_NORMAL_MODE )
+ anyPartial = 1;
+ } else if( isSubrect(spec->dim.c,spec->layers[i].dim.c) &&
+ (spec->layers[i].mode == GIMP_NORMAL_MODE ||
+ spec->layers[i].mode == GIMP_NORMAL_NOPARTIAL_MODE ||
+ spec->layers[i].mode == GIMP_DISSOLVE_MODE) ) {
+ /* This layer fills out the entire image.
+ * Turn off anly lower layers, and note that we cannot have
+ * transparency at all.
+ */
+ while(i) spec->layers[--i].isVisible = 0 ;
+ if( spec->default_pixel != FORCE_ALPHA_CHANNEL )
+ spec->default_pixel = NEWALPHA(colormap[0],255);
+ anyPartial = 0 ;
+ break ;
+ }
+ }
+ if( spec->partial_transparency_mode == ALLOW_PARTIAL_TRANSPARENCY &&
+ (!anyPartial || FULLALPHA(spec->default_pixel)) )
+ spec->partial_transparency_mode = PARTIAL_TRANSPARENCY_IMPOSSIBLE ;
+
+ /* Initialize layers and print overview if we're verbose */
+ for( i=spec->numLayers; i--; )
+ if( spec->layers[i].isVisible ) {
+ initLayer(&spec->layers[i]) ;
+ if( verboseFlag ) {
+ fprintf(stderr,"%dx%d%+d%+d %s %s",
+ spec->layers[i].dim.width, spec->layers[i].dim.height,
+ spec->layers[i].dim.c.l - spec->dim.c.l,
+ spec->layers[i].dim.c.t - spec->dim.c.t,
+ showGimpImageType(spec->layers[i].type),
+ showGimpLayerModeEffects(spec->layers[i].mode));
+ if( spec->layers[i].opacity < 255 )
+ fprintf(stderr,"/%02d%%",spec->layers[i].opacity * 100 / 255);
+ if( XCF.layers[i].hasMask )
+ fprintf(stderr,_("/mask"));
+ fprintf(stderr," %s\n",spec->layers[i].name);
+ }
+ }
+
+ /* Resolve color mode unless we wait until we have the entire image */
+ if( spec->out_color_mode == COLOR_BY_CONTENTS &&
+ !spec->process_in_memory ) {
+ if( guess_callback )
+ spec->out_color_mode = guess_callback(spec,NULL);
+ if( spec->out_color_mode == COLOR_BY_CONTENTS )
+ spec->out_color_mode = color_by_layers(spec) ;
+ }
+}
+
+void
+analyse_colormode(struct FlattenSpec *spec,rgba **allPixels,
+ guesser guess_callback)
+{
+ unsigned x,y ;
+ int status ;
+ /* 8 - looking for any transparency
+ * 4 - looking for partially transparent pixels
+ * 2 - looking for pixels other than black and white
+ * 1 - looking for colored pixels
+ */
+ int known_absent = 0 ;
+ int assume_present = 0 ;
+
+ if( spec->out_color_mode == COLOR_BY_CONTENTS && guess_callback )
+ spec->out_color_mode = guess_callback(spec,allPixels) ;
+
+ if( spec->out_color_mode == COLOR_RGB ) assume_present |= 3 ;
+ if( spec->out_color_mode == COLOR_INDEXED ) assume_present |= 3 ;
+ if( spec->out_color_mode == COLOR_GRAY ) assume_present |= 2 ;
+ switch( color_by_layers(spec) ) {
+ case COLOR_GRAY: known_absent |= 1 ; break ;
+ case COLOR_MONO: known_absent |= 3 ; break ;
+ default: break ;
+ }
+ if( spec->partial_transparency_mode == DISSOLVE_PARTIAL_TRANSPARENCY ||
+ spec->partial_transparency_mode == PARTIAL_TRANSPARENCY_IMPOSSIBLE )
+ known_absent |= 4 ;
+ if( FULLALPHA(spec->default_pixel) ) known_absent |= 12 ;
+ else if( spec->default_pixel == FORCE_ALPHA_CHANNEL ) assume_present |= 8 ;
+
+ status = 15 - (known_absent | assume_present) ;
+
+ for( y=0; status && y<spec->dim.height; y++ ) {
+ rgba *row = allPixels[y] ;
+ if( (status & 3) != 0 ) {
+ /* We're still interested in color */
+ for( x=0; status && x<spec->dim.width; x++ ) {
+ if( NULLALPHA(row[x]) )
+ status &= ~8 ;
+ else {
+ rgba full = row[x] | (255 << ALPHA_SHIFT) ;
+ if( !FULLALPHA(row[x]) ) status &= ~12 ;
+ if( full == NEWALPHA(0,255) || full == NEWALPHA(-1,255) )
+ /* Black or white */ ;
+ else if( degrayPixel(row[x]) != -1 )
+ status &= ~2 ; /* gray */
+ else
+ status &= ~3 ; /* color */
+ }
+ }
+ } else {
+ /* Not interested in color */
+ for( x=0; status && x<spec->dim.width; x++ ) {
+ if( NULLALPHA(row[x]) )
+ status &= ~8 ;
+ else if( !FULLALPHA(row[x]) )
+ status &= ~12 ;
+ }
+ }
+ }
+
+ status |= known_absent ;
+
+ switch( spec->out_color_mode ) {
+ case COLOR_INDEXED: /* The caller takes responsibility */
+ case COLOR_RGB: /* Everything is fine. */
+ break ;
+ case COLOR_GRAY:
+ if( (status & 1) == 0 )
+ FatalGeneric(103,
+ _("Grayscale output selected, but colored pixel(s) found"));
+ break ;
+ case COLOR_MONO:
+ if( (status & 2) == 0 )
+ FatalGeneric(103,_("Monochrome output selected, but not all pixels "
+ "are black or white"));
+ break ;
+ case COLOR_BY_FILENAME: /* Should not happen ... */
+ case COLOR_BY_CONTENTS:
+ if( (status & 1) == 0 )
+ spec->out_color_mode = COLOR_RGB ;
+ else if( (status & 2) == 0 )
+ spec->out_color_mode = COLOR_GRAY ;
+ else
+ spec->out_color_mode = COLOR_MONO ;
+ break ;
+ }
+
+ if( (status & 12) == 12 ) /* No transparency found */
+ spec->default_pixel = NEWALPHA(colormap[0],255);
+ else if( (status & 12) == 4 )
+ spec->partial_transparency_mode = PARTIAL_TRANSPARENCY_IMPOSSIBLE ;
+}
diff --git a/flatten.c b/flatten.c
new file mode 100644
index 0000000..9b148bb
--- /dev/null
+++ b/flatten.c
@@ -0,0 +1,557 @@
+/* Flattning functions for xcftools
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include "xcftools.h"
+#include "flatten.h"
+#include "pixels.h"
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+static rgba __ATTRIBUTE__((noinline,const))
+composite_one(rgba bot,rgba top)
+{
+ unsigned tfrac, alpha ;
+
+ tfrac = ALPHA(top) ;
+ alpha = 255 ;
+ if( !FULLALPHA(bot) ) {
+ alpha = 255 ^ scaletable[255-ALPHA(bot)][255-ALPHA(top)] ;
+ /* This peculiar combination of ^ and - makes the GCC code
+ * generator for i386 particularly happy.
+ */
+ tfrac = (256*ALPHA(top) - 1) / alpha ;
+ /* Tfrac is the fraction of the coposited pixel's covered area
+ * that comes from the top pixel.
+ * For mathematical accuracy we ought to scale by 255 and
+ * subtract alpha/2, but this is faster, and never misses the
+ * true value by more than one 1/255. This effect is completely
+ * overshadowed by the linear interpolation in the first place.
+ * (I.e. gamma is ignored when combining intensities).
+ * [In any case, complete fairness is not possible: if the
+ * bottom pixel had alpha=170 and the top has alpha=102,
+ * each should contribute equally to the color of the
+ * resulting alpha=204 pixel, which is not possible in general]
+ * Subtracting one helps the topfrac never be 256, which would
+ * be bad.
+ * On the other hand it means that we would get tfrac=-1 if the
+ * top pixel is completely transparent, and we get a division
+ * by zero if _both_ pixels are fully transparent. These cases
+ * must be handled by all callers.
+ */
+ }
+ return (alpha << ALPHA_SHIFT)
+ + ((uint32_t)scaletable[ tfrac ][255&(top>>RED_SHIFT )] << RED_SHIFT )
+ + ((uint32_t)scaletable[ tfrac ][255&(top>>GREEN_SHIFT)] << GREEN_SHIFT )
+ + ((uint32_t)scaletable[ tfrac ][255&(top>>BLUE_SHIFT )] << BLUE_SHIFT )
+ + ((uint32_t)scaletable[255^tfrac][255&(bot>>RED_SHIFT )] << RED_SHIFT )
+ + ((uint32_t)scaletable[255^tfrac][255&(bot>>GREEN_SHIFT)] << GREEN_SHIFT )
+ + ((uint32_t)scaletable[255^tfrac][255&(bot>>BLUE_SHIFT )] << BLUE_SHIFT )
+ ;
+}
+
+/* merge_normal() takes ownership of bot.
+ * merge_normal() will share ownership of top.
+ * Return: may be shared.
+ */
+static struct Tile * __ATTRIBUTE__((noinline))
+merge_normal(struct Tile *bot, struct Tile *top)
+{
+ unsigned i ;
+ assertTileCompatibility(bot,top);
+
+ /* See if there is an easy winner */
+ if( (bot->summary & TILESUMMARY_ALLNULL) ||
+ (top->summary & TILESUMMARY_ALLFULL) ) {
+ freeTile(bot);
+ return top ;
+ }
+ if( top->summary & TILESUMMARY_ALLNULL ) {
+ freeTile(top);
+ return bot ;
+ }
+
+ /* Try hard to make top win */
+ for( i=0; ; i++ ) {
+ if( i == top->count ) {
+ freeTile(bot);
+ return top ;
+ }
+ if( !(NULLALPHA(bot->pixels[i]) || FULLALPHA(top->pixels[i])) )
+ break ;
+ }
+
+ /* Otherwise bot wins, but is forever changed ... */
+ if( (top->summary & TILESUMMARY_ALLNULL) == 0 ) {
+ unsigned i ;
+ invalidateSummary(bot,0);
+ for( i=0 ; i < top->count ; i++ ) {
+ if( !NULLALPHA(top->pixels[i]) ) {
+ if( FULLALPHA(top->pixels[i]) || NULLALPHA(bot->pixels[i]) )
+ bot->pixels[i] = top->pixels[i] ;
+ else
+ bot->pixels[i] = composite_one(bot->pixels[i],top->pixels[i]);
+ }
+ }
+ }
+ freeTile(top);
+ return bot ;
+}
+
+#define exotic_combinator static inline unsigned __ATTRIBUTE__((const))
+
+
+
+exotic_combinator
+ucombine_ADDITION(uint8_t bot,uint8_t top)
+{
+ return bot+top > 255 ? 255 : bot+top ;
+}
+
+exotic_combinator
+ucombine_SUBTRACT(uint8_t bot,uint8_t top)
+{
+ return top>bot ? 0 : bot-top ;
+}
+
+exotic_combinator
+ucombine_LIGHTEN_ONLY(uint8_t bot,uint8_t top)
+{
+ return top > bot ? top : bot ;
+}
+
+exotic_combinator
+ucombine_DARKEN_ONLY(uint8_t bot,uint8_t top)
+{
+ return top < bot ? top : bot ;
+}
+
+exotic_combinator
+ucombine_DIFFERENCE(uint8_t bot,uint8_t top)
+{
+ return top > bot ? top-bot : bot-top ;
+}
+
+exotic_combinator
+ucombine_MULTIPLY(uint8_t bot,uint8_t top)
+{
+ return scaletable[bot][top] ;
+}
+
+exotic_combinator
+ucombine_DIVIDE(uint8_t bot,uint8_t top)
+{
+ int result = (int)bot*256 / (1+top) ;
+ return result >= 256 ? 255 : result ;
+}
+
+exotic_combinator
+ucombine_SCREEN(uint8_t bot,uint8_t top)
+{
+ /* An inverted version of "multiply" */
+ return 255 ^ scaletable[255-bot][255-top] ;
+}
+
+exotic_combinator
+ucombine_OVERLAY(uint8_t bot,uint8_t top)
+{
+ return scaletable[bot][bot] +
+ 2*scaletable[top][scaletable[bot][255-bot]] ;
+ /* This strange formula is equivalent to
+ * (1-top)*(bot^2) + top*(1-(1-top)^2)
+ * that is, the top value is used to interpolate between
+ * the self-multiply and the self-screen of the bottom.
+ */
+ /* Note: This is exactly what the "Soft light" effect also
+ * does, though with different code in the Gimp.
+ */
+}
+
+exotic_combinator
+ucombine_DODGE(uint8_t bot,uint8_t top)
+{
+ return ucombine_DIVIDE(bot,255-top);
+}
+
+exotic_combinator
+ucombine_BURN(uint8_t bot,uint8_t top)
+{
+ return 255 - ucombine_DIVIDE(255-bot,top);
+}
+
+exotic_combinator
+ucombine_HARDLIGHT(uint8_t bot,uint8_t top)
+{
+ if( top >= 128 )
+ return 255 ^ scaletable[255-bot][2*(255-top)] ;
+ else
+ return scaletable[bot][2*top];
+ /* The code that implements "hardlight" in Gimp 2.2.10 has some
+ * rounding errors, but this is undoubtedly what is meant.
+ */
+}
+
+exotic_combinator
+ucombine_GRAIN_EXTRACT(uint8_t bot,uint8_t top)
+{
+ int temp = (int)bot - (int)top + 128 ;
+ return temp < 0 ? 0 : temp >= 256 ? 255 : temp ;
+}
+
+exotic_combinator
+ucombine_GRAIN_MERGE(uint8_t bot,uint8_t top)
+{
+ int temp = (int)bot + (int)top - 128 ;
+ return temp < 0 ? 0 : temp >= 256 ? 255 : temp ;
+}
+
+
+
+/* merge_exotic() destructively updates bot.
+ * merge_exotoc() reads but does not free top.
+ */
+static void __ATTRIBUTE__((noinline))
+merge_exotic(struct Tile *bot, const struct Tile *top,
+ GimpLayerModeEffects mode)
+{
+ unsigned i ;
+ assertTileCompatibility(bot,top);
+ if( (bot->summary & TILESUMMARY_ALLNULL) != 0 ) return ;
+ if( (top->summary & TILESUMMARY_ALLNULL) != 0 ) return ;
+ assert( bot->refcount == 1 );
+ /* The transparency status of bot never changes */
+
+ for( i=0; i < top->count ; i++ ) {
+ uint32_t red, green, blue ;
+ if( NULLALPHA(bot->pixels[i]) || NULLALPHA(top->pixels[i]) )
+ continue ;
+#define UNIFORM(mode) case GIMP_ ## mode ## _MODE: \
+ red = ucombine_ ## mode (bot->pixels[i]>>RED_SHIFT , \
+ top->pixels[i]>>RED_SHIFT ); \
+ green = ucombine_ ## mode (bot->pixels[i]>>GREEN_SHIFT, \
+ top->pixels[i]>>GREEN_SHIFT); \
+ blue = ucombine_ ## mode (bot->pixels[i]>>BLUE_SHIFT , \
+ top->pixels[i]>>BLUE_SHIFT ); \
+ break ;
+ switch( mode ) {
+ case GIMP_NORMAL_MODE:
+ case GIMP_DISSOLVE_MODE:
+ FatalUnexpected("Normal and Dissolve mode can't happen here!");
+ UNIFORM(ADDITION);
+ UNIFORM(SUBTRACT);
+ UNIFORM(LIGHTEN_ONLY);
+ UNIFORM(DARKEN_ONLY);
+ UNIFORM(DIFFERENCE);
+ UNIFORM(MULTIPLY);
+ UNIFORM(DIVIDE);
+ UNIFORM(SCREEN);
+ case GIMP_SOFTLIGHT_MODE: /* A synonym for "overlay"! */
+ UNIFORM(OVERLAY);
+ UNIFORM(DODGE);
+ UNIFORM(BURN);
+ UNIFORM(HARDLIGHT);
+ UNIFORM(GRAIN_EXTRACT);
+ UNIFORM(GRAIN_MERGE);
+ default:
+ FatalUnsupportedXCF(_("'%s' layer mode"),showGimpLayerModeEffects(mode));
+ }
+ if( FULLALPHA(bot->pixels[i] & top->pixels[i]) )
+ bot->pixels[i] = (bot->pixels[i] & (255 << ALPHA_SHIFT)) +
+ (red << RED_SHIFT) +
+ (green << GREEN_SHIFT) +
+ (blue << BLUE_SHIFT) ;
+ else {
+ rgba bp = bot->pixels[i] ;
+ /* In a sane world, the alpha of the top pixel would simply be
+ * used to interpolate linearly between the bottom pixel's base
+ * color and the effect-computed color.
+ * But no! What the Gimp actually does is empirically
+ * described by the following (which borrows code from
+ * composite_one() that makes no theoretical sense here):
+ */
+ unsigned tfrac = ALPHA(top->pixels[i]) ;
+ if( !FULLALPHA(bp) ) {
+ unsigned pseudotop = (tfrac < ALPHA(bp) ? tfrac : ALPHA(bp));
+ unsigned alpha = 255 ^ scaletable[255-ALPHA(bp)][255-pseudotop] ;
+ tfrac = (256*pseudotop - 1) / alpha ;
+ }
+ bot->pixels[i] = (bp & (255 << ALPHA_SHIFT)) +
+ ((rgba)scaletable[ tfrac ][ red ] << RED_SHIFT ) +
+ ((rgba)scaletable[ tfrac ][ green ] << GREEN_SHIFT) +
+ ((rgba)scaletable[ tfrac ][ blue ] << BLUE_SHIFT ) +
+ ((rgba)scaletable[255^tfrac][255&(bp>>RED_SHIFT )] << RED_SHIFT ) +
+ ((rgba)scaletable[255^tfrac][255&(bp>>GREEN_SHIFT)] << GREEN_SHIFT) +
+ ((rgba)scaletable[255^tfrac][255&(bp>>BLUE_SHIFT )] << BLUE_SHIFT ) ;
+ }
+ }
+ return ;
+}
+
+static void
+dissolveTile(struct Tile *tile)
+{
+ unsigned i ;
+ summary_t summary ;
+ assert( tile->refcount == 1 );
+ if( (tile->summary & TILESUMMARY_CRISP) )
+ return ;
+ summary = TILESUMMARY_UPTODATE + TILESUMMARY_ALLNULL
+ + TILESUMMARY_ALLFULL + TILESUMMARY_CRISP ;
+ for( i = 0 ; i < tile->count ; i++ ) {
+ if( FULLALPHA(tile->pixels[i]) )
+ summary &= ~TILESUMMARY_ALLNULL ;
+ else if ( NULLALPHA(tile->pixels[i]) )
+ summary &= ~TILESUMMARY_ALLFULL ;
+ else if( ALPHA(tile->pixels[i]) > rand() % 0xFF ) {
+ tile->pixels[i] |= 255 << ALPHA_SHIFT ;
+ summary &= ~TILESUMMARY_ALLNULL ;
+ } else {
+ tile->pixels[i] = 0 ;
+ summary &= ~TILESUMMARY_ALLFULL ;
+ }
+ }
+ tile->summary = summary ;
+}
+
+static void
+roundAlpha(struct Tile *tile)
+{
+ unsigned i ;
+ summary_t summary ;
+ assert( tile->refcount == 1 );
+ if( (tile->summary & TILESUMMARY_CRISP) )
+ return ;
+ summary = TILESUMMARY_UPTODATE + TILESUMMARY_ALLNULL
+ + TILESUMMARY_ALLFULL + TILESUMMARY_CRISP ;
+ for( i = 0 ; i < tile->count ; i++ ) {
+ if( ALPHA(tile->pixels[i]) >= 128 ) {
+ tile->pixels[i] |= 255 << ALPHA_SHIFT ;
+ summary &= ~TILESUMMARY_ALLNULL ;
+ } else {
+ tile->pixels[i] = 0 ;
+ summary &= ~TILESUMMARY_ALLFULL ;
+ }
+ }
+ tile->summary = summary ;
+}
+
+/* flattenTopdown() shares ownership of top.
+ * The return value may be a shared tile.
+ */
+static struct Tile *
+flattenTopdown(struct FlattenSpec *spec, struct Tile *top,
+ unsigned nlayers, const struct rect *where)
+{
+ struct Tile *tile;
+
+ while( nlayers-- ) {
+ if( tileSummary(top) & TILESUMMARY_ALLFULL )
+ return top ;
+ if( !spec->layers[nlayers].isVisible )
+ continue ;
+
+ tile = getLayerTile(&spec->layers[nlayers],where);
+
+ if( tile->summary & TILESUMMARY_ALLNULL )
+ continue ; /* Simulate a tail call */
+
+ switch( spec->layers[nlayers].mode ) {
+ case GIMP_NORMAL_NOPARTIAL_MODE:
+ roundAlpha(tile) ;
+ /* fall through */
+ if(0) {
+ case GIMP_DISSOLVE_MODE:
+ dissolveTile(tile);
+ /* fall through */
+ }
+ case GIMP_NORMAL_MODE:
+ top = merge_normal(tile,top);
+ break ;
+ default:
+ {
+ struct Tile *below, *above ;
+ unsigned i ;
+ if( !(top->summary & TILESUMMARY_ALLNULL) ) {
+ rgba tile_or = 0 ;
+ invalidateSummary(tile,0);
+ for( i=0; i<top->count; i++ )
+ if( FULLALPHA(top->pixels[i]) )
+ tile->pixels[i] = 0 ;
+ else
+ tile_or |= tile->pixels[i] ;
+ /* If the tile only has pixels that will be covered by 'top' anyway,
+ * forget it anyway.
+ */
+ if( ALPHA(tile_or) == 0 ) {
+ freeTile(tile);
+ break ; /* from the switch, which will continue the while */
+ }
+ }
+ /* Create a dummy top for the layers below this */
+ if( top->summary & TILESUMMARY_CRISP ) {
+ above = forkTile(top);
+ } else {
+ summary_t summary = TILESUMMARY_ALLNULL ;
+ above = newTile(*where);
+ for( i=0; i<top->count; i++ )
+ if( FULLALPHA(top->pixels[i]) ) {
+ above->pixels[i] = -1 ;
+ summary = 0 ;
+ } else
+ above->pixels[i] = 0 ;
+ above->summary = TILESUMMARY_UPTODATE + TILESUMMARY_CRISP + summary;
+ }
+ below = flattenTopdown(spec, above, nlayers, where);
+ if( below->refcount > 1 ) {
+ assert( below == top );
+ /* This can only happen if 'below' is a copy of 'top'
+ * THROUGH 'above', which in turn means that none of all
+ * this is visible after all. So just free it and return 'top'.
+ */
+ freeTile(below);
+ return top ;
+ }
+ merge_exotic(below,tile,spec->layers[nlayers].mode);
+ freeTile(tile);
+ top = merge_normal(below,top);
+ return top ;
+ }
+ }
+ }
+ return top ;
+}
+
+static void
+addBackground(struct FlattenSpec *spec, struct Tile *tile)
+{
+ unsigned i ;
+
+ if( tileSummary(tile) & TILESUMMARY_ALLFULL )
+ return ;
+
+ switch( spec->partial_transparency_mode ) {
+ case FORBID_PARTIAL_TRANSPARENCY:
+ if( !(tileSummary(tile) & TILESUMMARY_CRISP) )
+ FatalGeneric(102,_("Flattened image has partially transparent pixels"));
+ break ;
+ case DISSOLVE_PARTIAL_TRANSPARENCY:
+ dissolveTile(tile);
+ break ;
+ case ALLOW_PARTIAL_TRANSPARENCY:
+ case PARTIAL_TRANSPARENCY_IMPOSSIBLE:
+ break ;
+ }
+
+ if( !FULLALPHA(spec->default_pixel) ) return ;
+ if( tileSummary(tile) & TILESUMMARY_ALLNULL ) {
+ fillTile(tile,spec->default_pixel);
+ } else {
+ for( i=0; i<tile->count; i++ )
+ if( NULLALPHA(tile->pixels[i]) )
+ tile->pixels[i] = spec->default_pixel ;
+ else if( FULLALPHA(tile->pixels[i]) )
+ ;
+ else
+ tile->pixels[i] = composite_one(spec->default_pixel,tile->pixels[i]);
+
+ tile->summary = TILESUMMARY_UPTODATE +
+ TILESUMMARY_ALLFULL + TILESUMMARY_CRISP ;
+ }
+}
+
+void
+flattenIncrementally(struct FlattenSpec *spec,lineCallback callback)
+{
+ rgba *rows[TILE_HEIGHT] ;
+ unsigned i, y, nrows, ncols ;
+ struct rect where ;
+ struct Tile *tile ;
+ static struct Tile toptile ;
+
+ toptile.count = TILE_HEIGHT * TILE_WIDTH ;
+ fillTile(&toptile,0);
+
+ for( where.t = spec->dim.c.t; where.t < spec->dim.c.b; where.t=where.b ) {
+ where.b = (where.t+TILE_HEIGHT) - where.t % TILE_HEIGHT ;
+ if( where.b > spec->dim.c.b ) where.b = spec->dim.c.b ;
+ nrows = where.b - where.t ;
+ for( y = 0; y < nrows ; y++ )
+ rows[y] = xcfmalloc(4*(spec->dim.c.r-spec->dim.c.l));
+
+ for( where.l = spec->dim.c.l; where.l < spec->dim.c.r; where.l=where.r ) {
+ where.r = (where.l+TILE_WIDTH) - where.l % TILE_WIDTH ;
+ if( where.r > spec->dim.c.r ) where.r = spec->dim.c.r ;
+ ncols = where.r - where.l ;
+
+ toptile.count = ncols * nrows ;
+ toptile.refcount = 2 ; /* For bug checking */
+ assert( toptile.summary == TILESUMMARY_UPTODATE +
+ TILESUMMARY_ALLNULL + TILESUMMARY_CRISP );
+ tile = flattenTopdown(spec,&toptile,spec->numLayers,&where) ;
+ toptile.refcount-- ; /* addBackground may change destructively */
+ addBackground(spec,tile);
+
+ for( i = 0 ; i < tile->count ; i++ )
+ if( NULLALPHA(tile->pixels[i]) )
+ tile->pixels[i] = 0 ;
+ for( y = 0 ; y < nrows ; y++ )
+ memcpy(rows[y] + (where.l - spec->dim.c.l),
+ tile->pixels + y * ncols, ncols*4);
+
+ if( tile == &toptile ) {
+ fillTile(&toptile,0);
+ } else {
+ freeTile(tile);
+ }
+ }
+ for( y = 0 ; y < nrows ; y++ )
+ callback(spec->dim.width,rows[y]);
+ }
+}
+
+static rgba **collectPointer ;
+
+static void
+collector(unsigned num,rgba *row)
+{
+ *collectPointer++ = row ;
+}
+
+rgba **
+flattenAll(struct FlattenSpec *spec)
+{
+ rgba **rows = xcfmalloc(spec->dim.height * sizeof(rgba*));
+ if( verboseFlag )
+ fprintf(stderr,_("Flattening image ..."));
+ collectPointer = rows ;
+ flattenIncrementally(spec,collector);
+ if( verboseFlag )
+ fprintf(stderr,"\n");
+ return rows ;
+}
+
+void
+shipoutWithCallback(struct FlattenSpec *spec, rgba **pixels,
+ lineCallback callback)
+{
+ unsigned i ;
+ for( i = 0; i < spec->dim.height; i++ ) {
+ callback(spec->dim.width,pixels[i]);
+ }
+ xcffree(pixels);
+}
diff --git a/flatten.h b/flatten.h
new file mode 100644
index 0000000..03aa435
--- /dev/null
+++ b/flatten.h
@@ -0,0 +1,72 @@
+/* Flattning functions for xcftools
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#ifndef FLATTEN_H
+#define FLATTEN_H
+
+#include "xcftools.h"
+#include "pixels.h"
+
+#define PERHAPS_ALPHA_CHANNEL (NEWALPHA(0,1))
+#define FORCE_ALPHA_CHANNEL (NEWALPHA(0,2))
+struct FlattenSpec {
+ struct tileDimensions dim ;
+ rgba default_pixel ;
+ int numLayers ;
+ struct xcfLayer *layers ;
+
+ const char * transmap_filename ;
+ const char * output_filename ;
+ enum out_color_mode {
+ COLOR_BY_FILENAME,
+ COLOR_BY_CONTENTS,
+ COLOR_INDEXED,
+ COLOR_RGB,
+ COLOR_GRAY,
+ COLOR_MONO
+ } out_color_mode ;
+ enum { ALLOW_PARTIAL_TRANSPARENCY,
+ DISSOLVE_PARTIAL_TRANSPARENCY,
+ FORBID_PARTIAL_TRANSPARENCY,
+ PARTIAL_TRANSPARENCY_IMPOSSIBLE
+ } partial_transparency_mode ;
+ int process_in_memory ;
+ int gimpish_indexed ;
+};
+
+/* From flatspec.c */
+
+void init_flatspec(struct FlattenSpec *);
+
+void add_layer_request(struct FlattenSpec *,const char *name);
+struct xcfLayer *lastlayerspec(struct FlattenSpec *,const char *option);
+
+typedef enum out_color_mode (*guesser) (struct FlattenSpec *,rgba **);
+
+/* Call this after processing options, and after opening the XCF file */
+void complete_flatspec(struct FlattenSpec *,guesser);
+void analyse_colormode(struct FlattenSpec *,rgba **allPixels,guesser);
+
+/* From flatten.c */
+
+typedef void (*lineCallback)(unsigned num,rgba *pixels);
+void flattenIncrementally(struct FlattenSpec *,lineCallback);
+rgba **flattenAll(struct FlattenSpec*);
+void shipoutWithCallback(struct FlattenSpec *,rgba **pixels,lineCallback);
+
+#endif /* FLATTEN_H */
diff --git a/gimp/base-enums.h b/gimp/base-enums.h
new file mode 100644
index 0000000..a5b2094
--- /dev/null
+++ b/gimp/base-enums.h
@@ -0,0 +1,146 @@
+/* The GIMP -- an image manipulation program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * 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.
+ */
+
+#ifndef __BASE_ENUMS_H__
+#define __BASE_ENUMS_H__
+
+#if 0
+ This file is parsed by two scripts, enumgen.pl in tools/pdbgen,
+ and gimp-mkenums. All enums that are not marked with
+ /*< pdb-skip >*/ are exported to libgimp and the PDB. Enums that are
+ not marked with /*< skip >*/ are registered with the GType system.
+ If you want the enum to be skipped by both scripts, you have to use
+ /*< pdb-skip, skip >*/.
+
+ The same syntax applies to enum values.
+#endif
+
+
+/*
+ * these enums that are registered with the type system
+ */
+
+#define GIMP_TYPE_CURVE_TYPE (gimp_curve_type_get_type ())
+
+GType gimp_curve_type_get_type (void) G_GNUC_CONST;
+
+typedef enum /*< pdb-skip >*/
+{
+ GIMP_CURVE_SMOOTH, /*< desc="Smooth" >*/
+ GIMP_CURVE_FREE /*< desc="Freehand" >*/
+} GimpCurveType;
+
+
+#define GIMP_TYPE_HISTOGRAM_CHANNEL (gimp_histogram_channel_get_type ())
+
+GType gimp_histogram_channel_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_HISTOGRAM_VALUE = 0, /*< desc="Value" >*/
+ GIMP_HISTOGRAM_RED = 1, /*< desc="Red" >*/
+ GIMP_HISTOGRAM_GREEN = 2, /*< desc="Green" >*/
+ GIMP_HISTOGRAM_BLUE = 3, /*< desc="Blue" >*/
+ GIMP_HISTOGRAM_ALPHA = 4, /*< desc="Alpha" >*/
+ GIMP_HISTOGRAM_RGB = 5 /*< desc="RGB", pdb-skip >*/
+} GimpHistogramChannel;
+
+
+#define GIMP_TYPE_INTERPOLATION_TYPE (gimp_interpolation_type_get_type ())
+
+GType gimp_interpolation_type_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_INTERPOLATION_NONE, /*< desc="None (Fastest)" >*/
+ GIMP_INTERPOLATION_LINEAR, /*< desc="Linear" >*/
+ GIMP_INTERPOLATION_CUBIC /*< desc="Cubic (Best)" >*/
+} GimpInterpolationType;
+
+
+#define GIMP_TYPE_LAYER_MODE_EFFECTS (gimp_layer_mode_effects_get_type ())
+
+GType gimp_layer_mode_effects_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_NORMAL_MODE,
+ GIMP_DISSOLVE_MODE,
+ GIMP_BEHIND_MODE,
+ GIMP_MULTIPLY_MODE,
+ GIMP_SCREEN_MODE,
+ GIMP_OVERLAY_MODE,
+ GIMP_DIFFERENCE_MODE,
+ GIMP_ADDITION_MODE,
+ GIMP_SUBTRACT_MODE,
+ GIMP_DARKEN_ONLY_MODE,
+ GIMP_LIGHTEN_ONLY_MODE,
+ GIMP_HUE_MODE,
+ GIMP_SATURATION_MODE,
+ GIMP_COLOR_MODE,
+ GIMP_VALUE_MODE,
+ GIMP_DIVIDE_MODE,
+ GIMP_DODGE_MODE,
+ GIMP_BURN_MODE,
+ GIMP_HARDLIGHT_MODE,
+ GIMP_SOFTLIGHT_MODE,
+ GIMP_GRAIN_EXTRACT_MODE,
+ GIMP_GRAIN_MERGE_MODE,
+ GIMP_COLOR_ERASE_MODE,
+ GIMP_ERASE_MODE, /*< pdb-skip, skip >*/
+ GIMP_REPLACE_MODE, /*< pdb-skip, skip >*/
+ GIMP_ANTI_ERASE_MODE /*< pdb-skip, skip >*/
+} GimpLayerModeEffects;
+
+
+#define GIMP_TYPE_TRANSFER_MODE (gimp_transfer_mode_get_type ())
+
+GType gimp_transfer_mode_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_SHADOWS, /*< desc="Shadows" >*/
+ GIMP_MIDTONES, /*< desc="Midtones" >*/
+ GIMP_HIGHLIGHTS /*< desc="Highlights" >*/
+} GimpTransferMode;
+
+
+/*
+ * non-registered enums; register them if needed
+ */
+
+typedef enum /*< skip >*/
+{
+ GIMP_NORMAL_CONVOL, /* Negative numbers truncated */
+ GIMP_ABSOLUTE_CONVOL, /* Absolute value */
+ GIMP_NEGATIVE_CONVOL /* add 127 to values */
+} GimpConvolutionType;
+
+typedef enum /*< skip >*/
+{
+ GIMP_ALL_HUES,
+ GIMP_RED_HUES,
+ GIMP_YELLOW_HUES,
+ GIMP_GREEN_HUES,
+ GIMP_CYAN_HUES,
+ GIMP_BLUE_HUES,
+ GIMP_MAGENTA_HUES
+} GimpHueRange;
+
+
+#endif /* __BASE_ENUMS_H__ */
diff --git a/gimp/gimpbaseenums.h b/gimp/gimpbaseenums.h
new file mode 100644
index 0000000..d41d75d
--- /dev/null
+++ b/gimp/gimpbaseenums.h
@@ -0,0 +1,196 @@
+/* LIBGIMP - The GIMP Library
+ * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GIMP_BASE_ENUMS_H__
+#define __GIMP_BASE_ENUMS_H__
+
+
+G_BEGIN_DECLS
+
+/* For information look into the C source or the html documentation */
+
+
+#define GIMP_TYPE_CHECK_SIZE (gimp_check_size_get_type ())
+
+GType gimp_check_size_get_type (void) G_GNUC_CONST;
+
+typedef enum /*< pdb-skip >*/
+{
+ GIMP_CHECK_SIZE_SMALL_CHECKS = 0, /*< desc="Small" >*/
+ GIMP_CHECK_SIZE_MEDIUM_CHECKS = 1, /*< desc="Medium" >*/
+ GIMP_CHECK_SIZE_LARGE_CHECKS = 2 /*< desc="Large" >*/
+} GimpCheckSize;
+
+
+#define GIMP_TYPE_CHECK_TYPE (gimp_check_type_get_type ())
+
+GType gimp_check_type_get_type (void) G_GNUC_CONST;
+
+typedef enum /*< pdb-skip >*/
+{
+ GIMP_CHECK_TYPE_LIGHT_CHECKS = 0, /*< desc="Light Checks" >*/
+ GIMP_CHECK_TYPE_GRAY_CHECKS = 1, /*< desc="Mid-Tone Checks" >*/
+ GIMP_CHECK_TYPE_DARK_CHECKS = 2, /*< desc="Dark Checks" >*/
+ GIMP_CHECK_TYPE_WHITE_ONLY = 3, /*< desc="White Only" >*/
+ GIMP_CHECK_TYPE_GRAY_ONLY = 4, /*< desc="Gray Only" >*/
+ GIMP_CHECK_TYPE_BLACK_ONLY = 5 /*< desc="Black Only" >*/
+} GimpCheckType;
+
+
+#define GIMP_TYPE_IMAGE_BASE_TYPE (gimp_image_base_type_get_type ())
+
+GType gimp_image_base_type_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_RGB, /*< desc="RGB color" >*/
+ GIMP_GRAY, /*< desc="Grayscale" >*/
+ GIMP_INDEXED /*< desc="Indexed color" >*/
+} GimpImageBaseType;
+
+
+#define GIMP_TYPE_IMAGE_TYPE (gimp_image_type_get_type ())
+
+GType gimp_image_type_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_RGB_IMAGE, /*< desc="RGB" >*/
+ GIMP_RGBA_IMAGE, /*< desc="RGB-alpha" >*/
+ GIMP_GRAY_IMAGE, /*< desc="Grayscale" >*/
+ GIMP_GRAYA_IMAGE, /*< desc="Grayscale-alpha" >*/
+ GIMP_INDEXED_IMAGE, /*< desc="Indexed" >*/
+ GIMP_INDEXEDA_IMAGE /*< desc="Indexed-alpha" >*/
+} GimpImageType;
+
+
+typedef enum /*< skip >*/
+{
+ GIMP_UNIT_PIXEL = 0,
+
+ GIMP_UNIT_INCH = 1,
+ GIMP_UNIT_MM = 2,
+ GIMP_UNIT_POINT = 3,
+ GIMP_UNIT_PICA = 4,
+
+ GIMP_UNIT_END = 5,
+
+ GIMP_UNIT_PERCENT = 65536 /*< pdb-skip >*/
+} GimpUnit;
+
+
+#define GIMP_TYPE_PDB_ARG_TYPE (gimp_pdb_arg_type_get_type ())
+
+GType gimp_pdb_arg_type_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_PDB_INT32,
+ GIMP_PDB_INT16,
+ GIMP_PDB_INT8,
+ GIMP_PDB_FLOAT,
+ GIMP_PDB_STRING,
+ GIMP_PDB_INT32ARRAY,
+ GIMP_PDB_INT16ARRAY,
+ GIMP_PDB_INT8ARRAY,
+ GIMP_PDB_FLOATARRAY,
+ GIMP_PDB_STRINGARRAY,
+ GIMP_PDB_COLOR,
+ GIMP_PDB_REGION,
+ GIMP_PDB_DISPLAY,
+ GIMP_PDB_IMAGE,
+ GIMP_PDB_LAYER,
+ GIMP_PDB_CHANNEL,
+ GIMP_PDB_DRAWABLE,
+ GIMP_PDB_SELECTION,
+ GIMP_PDB_BOUNDARY,
+ GIMP_PDB_PATH,
+ GIMP_PDB_PARASITE,
+ GIMP_PDB_STATUS,
+ GIMP_PDB_END
+} GimpPDBArgType;
+
+
+#define GIMP_TYPE_PDB_PROC_TYPE (gimp_pdb_proc_type_get_type ())
+
+GType gimp_pdb_proc_type_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_INTERNAL,
+ GIMP_PLUGIN,
+ GIMP_EXTENSION,
+ GIMP_TEMPORARY
+} GimpPDBProcType;
+
+
+#define GIMP_TYPE_PDB_STATUS_TYPE (gimp_pdb_status_type_get_type ())
+
+GType gimp_pdb_status_type_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_PDB_EXECUTION_ERROR,
+ GIMP_PDB_CALLING_ERROR,
+ GIMP_PDB_PASS_THROUGH,
+ GIMP_PDB_SUCCESS,
+ GIMP_PDB_CANCEL
+} GimpPDBStatusType;
+
+
+#define GIMP_TYPE_MESSAGE_HANDLER_TYPE (gimp_message_handler_type_get_type ())
+
+GType gimp_message_handler_type_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_MESSAGE_BOX,
+ GIMP_CONSOLE,
+ GIMP_ERROR_CONSOLE
+} GimpMessageHandlerType;
+
+
+#define GIMP_TYPE_STACK_TRACE_MODE (gimp_stack_trace_mode_get_type ())
+
+GType gimp_stack_trace_mode_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_STACK_TRACE_NEVER,
+ GIMP_STACK_TRACE_QUERY,
+ GIMP_STACK_TRACE_ALWAYS
+} GimpStackTraceMode;
+
+
+#define GIMP_TYPE_PROGRESS_COMMAND (gimp_progress_command_get_type ())
+
+GType gimp_progress_command_get_type (void) G_GNUC_CONST;
+
+typedef enum
+{
+ GIMP_PROGRESS_COMMAND_START,
+ GIMP_PROGRESS_COMMAND_END,
+ GIMP_PROGRESS_COMMAND_SET_TEXT,
+ GIMP_PROGRESS_COMMAND_SET_VALUE
+} GimpProgressCommand;
+
+
+G_END_DECLS
+
+#endif /* __GIMP_BASE_ENUMS_H__ */
diff --git a/gimp/xcf-private.h b/gimp/xcf-private.h
new file mode 100644
index 0000000..0a5749f
--- /dev/null
+++ b/gimp/xcf-private.h
@@ -0,0 +1,94 @@
+/* The GIMP -- an image manipulation program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * 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.
+ */
+
+#ifndef __XCF_PRIVATE_H__
+#define __XCF_PRIVATE_H__
+
+
+typedef enum
+{
+ PROP_END = 0,
+ PROP_COLORMAP = 1,
+ PROP_ACTIVE_LAYER = 2,
+ PROP_ACTIVE_CHANNEL = 3,
+ PROP_SELECTION = 4,
+ PROP_FLOATING_SELECTION = 5,
+ PROP_OPACITY = 6,
+ PROP_MODE = 7,
+ PROP_VISIBLE = 8,
+ PROP_LINKED = 9,
+ PROP_PRESERVE_TRANSPARENCY = 10,
+ PROP_APPLY_MASK = 11,
+ PROP_EDIT_MASK = 12,
+ PROP_SHOW_MASK = 13,
+ PROP_SHOW_MASKED = 14,
+ PROP_OFFSETS = 15,
+ PROP_COLOR = 16,
+ PROP_COMPRESSION = 17,
+ PROP_GUIDES = 18,
+ PROP_RESOLUTION = 19,
+ PROP_TATTOO = 20,
+ PROP_PARASITES = 21,
+ PROP_UNIT = 22,
+ PROP_PATHS = 23,
+ PROP_USER_UNIT = 24,
+ PROP_VECTORS = 25,
+ PROP_TEXT_LAYER_FLAGS = 26
+} PropType;
+
+typedef enum
+{
+ COMPRESS_NONE = 0,
+ COMPRESS_RLE = 1,
+ COMPRESS_ZLIB = 2, /* unused */
+ COMPRESS_FRACTAL = 3 /* unused */
+} XcfCompressionType;
+
+typedef enum
+{
+ XCF_ORIENTATION_HORIZONTAL = 1,
+ XCF_ORIENTATION_VERTICAL = 2
+} XcfOrientationType;
+
+typedef enum
+{
+ XCF_STROKETYPE_STROKE = 0,
+ XCF_STROKETYPE_BEZIER_STROKE = 1
+} XcfStrokeType;
+
+typedef struct _XcfInfo XcfInfo;
+
+struct _XcfInfo
+{
+ FILE *fp;
+ guint cp;
+ const gchar *filename;
+ GimpTattoo tattoo_state;
+ GimpLayer *active_layer;
+ GimpChannel *active_channel;
+ GimpDrawable *floating_sel_drawable;
+ GimpLayer *floating_sel;
+ guint floating_sel_offset;
+ gint swap_num;
+ gint *ref_count;
+ XcfCompressionType compression;
+ gint file_version;
+};
+
+
+#endif /* __XCF_PRIVATE_H__ */
diff --git a/install-sh b/install-sh
new file mode 100755
index 0000000..fca26e5
--- /dev/null
+++ b/install-sh
@@ -0,0 +1,269 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+#
+# 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=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ :
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -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 [ -f "$src" ] || [ -d "$src" ]
+ then
+ :
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ :
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ :
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -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 [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ :
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ :
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# 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.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/io-unix.c b/io-unix.c
new file mode 100644
index 0000000..d7c59ed
--- /dev/null
+++ b/io-unix.c
@@ -0,0 +1,176 @@
+/* OS-specific IO functions for xcftools
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include "xcftools.h"
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#if HAVE_MMAP
+#include <sys/mman.h>
+#endif
+
+static FILE *xcfstream = 0 ;
+
+void
+free_or_close_xcf(void)
+{
+ if( xcf_file ) {
+ if( xcfstream ) {
+ munmap(xcf_file,xcf_length) ;
+ fclose(xcfstream);
+ xcf_file = 0 ;
+ xcfstream = 0 ;
+ } else {
+ free(xcf_file) ;
+ xcf_file = 0 ;
+ }
+ }
+}
+
+void
+read_or_mmap_xcf(const char *filename,const char *unzipper)
+{
+ struct stat statbuf ;
+
+ free_or_close_xcf() ;
+
+ if( strcmp(filename,"-") != 0 ) {
+ if( access(filename,R_OK) != 0 )
+ FatalGeneric(21,"!%s",filename);
+ }
+
+ if( !unzipper ) {
+ const char *pc ;
+ pc = filename + strlen(filename) ;
+ if( pc-filename > 2 && strcmp(pc-2,"gz") == 0 )
+ unzipper = "zcat" ;
+ else if ( pc-filename > 3 && strcmp(pc-3,"bz2") == 0 )
+ unzipper = "bzcat" ;
+ else
+ unzipper = "" ;
+ } else if( strcmp(unzipper,"cat") == 0 )
+ unzipper = "" ;
+
+ if( *unzipper ) {
+ int pid, status, outfd ;
+#if HAVE_MMAP
+ xcfstream = tmpfile() ;
+ if( !xcfstream )
+ FatalUnexpected(_("!Cannot create temporary unzipped file"));
+ outfd = fileno(xcfstream) ;
+#else
+ int fh[2] ;
+ if( pipe(fh) < 0 )
+ FatalUnexpected(_("!Cannot create pipe for %s"),unzipper);
+ xcfstream = fdopen(fh[1],"rb") ;
+ if( !xcfstream )
+ FatalUnexpected(_("!Cannot fdopen() unzipper pipe"));
+ outfd = fh[0] ;
+#endif
+ if( (pid = fork()) == 0 ) {
+ /* We're the child */
+ if( dup2(outfd,1) < 0 ) {
+ perror(_("Cannot dup2 in unzip process"));
+ exit(127) ;
+ }
+ fclose(xcfstream) ;
+ execlp(unzipper,unzipper,filename,NULL) ;
+ fprintf(stderr,_("Cannot execute "));
+ perror(unzipper);
+ exit(126) ;
+ }
+#if HAVE_MMAP
+ while( wait(&status) != pid )
+ ;
+ if( WIFEXITED(status) ) {
+ status = WEXITSTATUS(status) ;
+ if( status > 0 ) {
+ fclose(xcfstream) ;
+ xcfstream = 0 ;
+ FatalGeneric(status,NULL);
+ }
+ } else {
+ fclose(xcfstream) ;
+ xcfstream = 0 ;
+ FatalGeneric(126,_("%s terminated abnormally"),unzipper);
+ }
+#else
+ close(fh[0]) ;
+#endif
+ } else if( strcmp(filename,"-") == 0 ) {
+ xcfstream = fdopen(dup(0),"rb") ;
+ if( !xcfstream )
+ FatalUnexpected(_("!Cannot dup stdin for input")) ;
+ } else {
+ xcfstream = fopen(filename,"rb") ;
+ if( !xcfstream )
+ FatalGeneric(21,_("!Cannot open %s"),filename);
+ }
+ /* OK, now we have an open stream ... */
+ if( fstat(fileno(xcfstream),&statbuf) == 0 &&
+ (statbuf.st_mode & S_IFMT) == S_IFREG ) {
+ xcf_length = statbuf.st_size ;
+#if HAVE_MMAP
+ xcf_file = mmap(0,xcf_length,PROT_READ,MAP_SHARED,fileno(xcfstream),0);
+ if( xcf_file != (void*)-1 )
+ return ;
+ if( errno != ENODEV ) {
+ int saved = errno ;
+ fclose(xcfstream) ;
+ xcf_file = 0 ;
+ errno = saved ;
+ FatalUnexpected(_("!Could not mmap input"));
+ }
+#endif
+ xcf_file = malloc(xcf_length);
+ if( xcf_file == 0 )
+ FatalUnexpected(_("Out of memory for xcf data"));
+ if( fread(xcf_file,1,xcf_length,xcfstream) != xcf_length ) {
+ if( feof(xcfstream) )
+ FatalUnexpected(_("XCF file shrunk while reading it"));
+ else
+ FatalUnexpected(_("!Could not read xcf data"));
+ }
+ fclose(xcfstream) ;
+ xcfstream = 0 ;
+ } else {
+ size_t blocksize = 0x80000 ; /* 512 KB */
+ xcf_length = 0 ;
+ xcf_file = 0 ;
+ while(1) {
+ xcf_file = realloc(xcf_file,blocksize) ;
+ if( xcf_file == 0 )
+ FatalUnexpected(_("Out of memory for xcf data"));
+ size_t actual = fread(xcf_file+xcf_length,1,blocksize-xcf_length,
+ xcfstream) ;
+ xcf_length += actual ;
+ if( feof(xcfstream) )
+ break ;
+ if( xcf_length < blocksize ) {
+ FatalUnexpected(_("Could not read xcf data")) ;
+ }
+ blocksize += (blocksize >> 1) & ~(size_t)0x3FFF ; /* 16 KB granularity */
+ }
+ fclose(xcfstream) ;
+ xcfstream = 0 ;
+ }
+}
diff --git a/mancombine.pl b/mancombine.pl
new file mode 100644
index 0000000..3de2919
--- /dev/null
+++ b/mancombine.pl
@@ -0,0 +1,56 @@
+#! /usr/bin/perl
+# This script compiles final manpages for xcftools
+# Copyright (C) 2006 Henning Makholm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# 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
+
+use strict ; use warnings ;
+
+my %defs ;
+
+if( open CONFIG, "<", "config.h" ) {
+ while( <CONFIG> ) {
+ if( /^#define\s+(\S*)/ ) {
+ $defs{$1} = 1 ;
+ }
+ }
+ close CONFIG ;
+}
+
+my $ignore = 0 ;
+
+while( <> ) {
+ if( /^\#else/ ) {
+ if( $ignore ) {
+ $ignore-- ;
+ } else {
+ $ignore = 1 ;
+ }
+ } elsif( /^\#endif/ ) {
+ $ignore-- if $ignore ;
+ } elsif( $ignore ) {
+ if( /^\#if/ ) {
+ $ignore++ ;
+ }
+ } elsif( /^\#ifdef\s+(\S+)/ ) {
+ $ignore = 1 unless $defs{$1} ;
+ } elsif( /^\s*.so\s*(.*)/ ) {
+ my $filename = $1 ;
+ open IN, "<", $filename or die "Cannot read $filename" ;
+ print <IN> ;
+ close IN ;
+ } else {
+ print ;
+ }
+}
diff --git a/mkenumsc.pl b/mkenumsc.pl
new file mode 100644
index 0000000..25542ac
--- /dev/null
+++ b/mkenumsc.pl
@@ -0,0 +1,85 @@
+#! /usr/bin/perl
+# This short script extracts enum definitions from files stolen
+# from the Gimp's sources.
+# Copyright (C) 2006 Henning Makholm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# 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
+
+use strict ; use warnings ;
+
+print "/* Autogenerated from ",@ARGV," */\n" ;
+print "#include \"enums.h\"\n" ;
+print "#include <stdio.h>\n" ;
+while(<>) {
+ if( /^\s*typedef\s+enum\s/ ) {
+ my @nodesc ;
+ my @all ;
+ my %desc ;
+ my $enum ;
+ $_ = <> ;
+ /^\{\s*$/ or die "Expected opening brace" ;
+ while( <> ) {
+ if( s/^\s*,?(\w+)\s*(=\s*\d+)?,?\s*// ) {
+ my $constant = $1 ;
+ push @all, $constant ;
+ if( m' desc="([^"]+)"' ) {
+ $desc{$constant} = $1 ;
+ } else {
+ push @nodesc, $constant ;
+ $desc{$constant} = $constant ;
+ }
+ } elsif( /^\}\s*(\w+)\s*;/ ) {
+ $enum = $1 ;
+ last ;
+ } else {
+ die "Unparseable line [$_]" ;
+ }
+ }
+ die "Unexpected EOF" unless defined $enum ;
+ if( @nodesc ) {
+ my $prefix = $nodesc[0] ;
+ $prefix =~ s/.$// ;
+ for( @desc{@nodesc} ) {
+ while( substr($_,0,length $prefix) ne $prefix ) {
+ $prefix =~ s/.$// ;
+ }
+ }
+ $prefix = length $prefix ;
+ for( @desc{@nodesc} ) {
+ $_ = substr($_,$prefix);
+ $_ = "\u\L$_" ;
+ s/_(.)/\U$1/g ;
+ s/^Rle/RLE/;
+ }
+ my $suffix = substr($desc{$nodesc[0]},1) ;
+ for( @desc{@nodesc} ) {
+ while( substr($_,-length($suffix)) ne $suffix ) {
+ goto nosuffix if $suffix eq "" ;
+ $suffix =~ s/^.// ;
+ }
+ }
+ $suffix = length $suffix ;
+ $_ = substr($_,0,-$suffix) for @desc{@nodesc} ;
+ nosuffix: ;
+ }
+ my $buflen = 15 + length($enum);
+ print "const char*\nshow$enum($enum x)\n{\n" ;
+ print " static char buf[$buflen];\n switch(x) {\n" ;
+ for my $c (@all) {
+ print " case $c: return \"$desc{$c}\";\n" ;
+ }
+ print " default: sprintf(buf,\"($enum:%d)\",(int)x);\n" ;
+ print " return buf;\n }\n}\n";
+ }
+}
diff --git a/mkenumsh.pl b/mkenumsh.pl
new file mode 100644
index 0000000..7ac52d3
--- /dev/null
+++ b/mkenumsh.pl
@@ -0,0 +1,60 @@
+#! /usr/bin/perl
+# This short script extracts enum definitions from files stolen
+# from the Gimp's sources.
+# Copyright (C) 2006 Henning Makholm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# 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
+
+use strict ; use warnings ;
+
+my @wantenums = qw( GimpImageBaseType
+ GimpImageType
+ GimpLayerModeEffects
+ PropType
+ XcfCompressionType
+ );
+my %wantenums ;
+@wantenums{@wantenums} = (-1) x @wantenums ;
+
+my $last ;
+my @collect ;
+print join("\n * ","/* Extracted from",@ARGV),"\n * by $0\n */\n" ;
+while( <> ) {
+ if( /^\s*typedef\s+enum\s/ ) {
+ @collect = ($_) ;
+ } elsif( /^\}\s+(\w+)\s*;/ && @collect ) {
+ my $enum = $1 ;
+ if( ++$wantenums{$enum} == 0 ) {
+ if( $enum eq 'GimpLayerModeEffects' ) {
+ push @collect, " ,GIMP_NORMAL_NOPARTIAL_MODE=-1\n" ;
+ }
+ push @collect, $_ ;
+ print @collect ;
+ print "const char *show$enum($enum);\n" ;
+ print "#define ${enum}_LAST $last\n" ;
+ }
+ @collect = () ;
+ } elsif( @collect ) {
+ push @collect, $_ ;
+ $last = $1 if /^\s*(\w+)/ ;
+ }
+}
+for my $enum ( @wantenums ) {
+ my $count = 1 + $wantenums{$enum} ;
+ if( $count != 1 ) {
+ print STDERR "$count definitions of $enum\n" ;
+ }
+}
+
+
diff --git a/mkopti.pl b/mkopti.pl
new file mode 100644
index 0000000..d2f7050
--- /dev/null
+++ b/mkopti.pl
@@ -0,0 +1,164 @@
+#! /usr/bin/perl
+# This script extracts option strings, longopt arrays and
+# manpage fragments for xcftools
+# Copyright (C) 2006 Henning Makholm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# 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
+
+use strict ; use warnings ;
+
+my $mastersource = "options.i" ;
+
+my $target = shift ;
+my @defines = ( "\U$target" ) ;
+push @defines, "\U$1foo" if $target =~ /^(xcf(2|to))/ ;
+
+open INFILE, "-|", join(" ","cpp -imacros config.h",
+ (map "-D$_",@defines),
+ "-DTHISPROGRAM=$target",$mastersource)
+ or die "Cannot preprocess options." ;
+
+open OUTFILE, ">", "$target.oi"
+ or die "Cannot write $target.oi" ;
+print OUTFILE "/* Autogenerated by $0 $target */\n" ;
+print OUTFILE "#define $_\n" for @defines ;
+print OUTFILE "#define OPTIONGROUP(a,b)\n" ;
+
+my %manstrings ;
+my $mansection = '1i' ;
+my @desc ;
+my $optstring = "" ;
+
+print OUTFILE "#ifdef HAVE_GETOPT_LONG\n" ;
+print OUTFILE "static const struct option longopts[] = {\n" ;
+
+my $manref = undef ;
+my $parskip ;
+while( <INFILE> ) {
+ next if /^#/ ;
+ if( /^OPTION\(([^,]+),([^,]+),(.*),\s*/ ) {
+ my ($short,$long,$desc) = ($1,$2,$3) ;
+ my $hasarg = '' ;
+ if( $desc =~ s/^\s*\(([^()]+)\)\s*// ) {
+ $hasarg = $1 ;
+ }
+ my @long = split / /,$long ;
+ my $longfordesc = $long[0] ;
+ for my $l ( @long ) {
+ my $long = $l ;
+ $long =~ s/^--//
+ or print STDERR "Long option $long should have dashes\n" ;
+ print OUTFILE "\t{ \"$long\", ",$hasarg ? 1 : 0,", 0, $short},\n" ;
+ }
+ if( $short =~ s/^\s*'(.)'\s*$/-$1/ ) {
+ unshift @long, $short ;
+ $optstring .= $1 . ($hasarg && ':') ;
+ } else {
+ undef $short ;
+ }
+ if( @long ) {
+ (my $descarg = $hasarg ) =~ s/\"//g ;
+ $manref = \$manstrings{$mansection}{$long[0]} ;
+ $long[0] =~ s/^(-[^-])/\\$1/ ;
+ $$manref = "" ;
+ my $next = ".TP 8\n" ;
+ $hasarg =~ s/"([^\"]*)"/\\fB$1\\fI/g ;
+ $hasarg = " \\fI$hasarg\\fR" if $hasarg ;
+ for my $long ( @long ) {
+ $$manref .= $next . "\\fB$long\\fR$hasarg" ;
+ $next = ", " ;
+ }
+ $$manref .= "\n" ;
+ $parskip = 1 ;
+ push @desc, [$short || $long[0],
+ $descarg,
+ $desc,
+ $short && $long[1] ] ;
+ }
+ } elsif( /^\s*\)\);/ ) {
+ $manref = undef ;
+ } elsif( defined $manref ) {
+ s/^\s*// ;
+ s/''/\'/g ;
+ s/^\(\s*// if $parskip ;
+ $$manref .= $_ ;
+ $parskip = 0 ;
+ } elsif( /^OPTIONGROUP\(([^(,)]+),([^(,)]*)\)/ ) {
+ push @desc,$2 unless $mansection eq $1 ;
+ $mansection = $1 ;
+ }
+}
+print OUTFILE "{0}};\n" ;
+print OUTFILE "#define LONGALT(s) \" (\" s \")\"\n" ;
+print OUTFILE "#else\n" ;
+print OUTFILE "#define LONGALT(s) \"\"\n" ;
+print OUTFILE "#endif\n" ;
+close INFILE ;
+
+print OUTFILE "static void\nopt_usage(FILE *f)\n{\n" ;
+my %d15plus ;
+my $longest = 2 ;
+for my $desc ( @desc ) {
+ next unless ref $desc ;
+ my $l = length $$desc[0] ;
+ my $x = $$desc[1] ;
+ if( $x ) {
+ next if exists($d15plus{$x}) && $d15plus{$x} >= $l+1 ;
+ $d15plus{$x} = $l+1 ;
+ } else {
+ $longest = $l if $longest < length $l ;
+ }
+}
+print OUTFILE " int i = $longest;\n int j;\n" ;
+
+for my $d15 ( sort keys %d15plus ) {
+ print OUTFILE " j=strlen(_(\"$d15\"))+$d15plus{$d15}; if( j>i ) i=j;\n" ;
+}
+for my $desc ( @desc ) {
+ unless( ref $desc ) {
+ print OUTFILE " fprintf(f,\"%s:\\n\",_(\"$desc\"));\n"
+ if $desc ;
+ next ;
+ }
+ my ($optname,$d15,$helptext,$alternative) = @$desc ;
+ my $d1l = length($optname) ;
+ print OUTFILE (" fprintf(f,\" ",$optname);
+ my $f2a = "i-$d1l,\"\"" ;
+ if( $d15 ) {
+ print OUTFILE " " ;
+ $f2a = "i-".($d1l+1).",_(\"$d15\")" ;
+ }
+ print OUTFILE "%-*s %s" ;
+ if( $alternative ) {
+ print OUTFILE "\" LONGALT(\"$alternative\") \"";
+ }
+ print OUTFILE "\\n\",$f2a,\n _(\"$helptext\"));\n" ;
+}
+print OUTFILE "}\n" ;
+print OUTFILE "#undef LONGALT\n" ;
+print OUTFILE "#define OPTSTRING \"$optstring\"\n" ;
+close OUTFILE
+ or die "Problems closing $target.oi" ;
+
+for $mansection ( keys %manstrings ) {
+ my $hash = $manstrings{$mansection} ;
+
+ open OUTFILE,">","$target.$mansection"
+ or die "Cannot write $target.$mansection" ;
+ print OUTFILE @$hash{sort { "\U$a" cmp "\U$b" or $b cmp $a }
+ keys %$hash} ;
+ close OUTFILE or die "Problems closing $target.$mansection" ;
+}
+
+
diff --git a/mktablec.pl b/mktablec.pl
new file mode 100644
index 0000000..32bb0d0
--- /dev/null
+++ b/mktablec.pl
@@ -0,0 +1,67 @@
+#! /usr/bin/perl
+# This short script creates fixed look-up tables for xcftools
+# Copyright (C) 2006 Henning Makholm
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of version 2 of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# 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
+
+use strict ; use warnings ;
+
+sub shipsubarray (@) {
+ while( @_ > 1 && $_[$#_] == 0 ) {
+ pop @_ ;
+ }
+ my $last = pop @_ ;
+ print " {" ;
+ my $left = 75 ;
+ for my $d ( (map{ $_ . "," } @_), "$last}," ) {
+ if( length($d) > $left ) {
+ print "\n " ;
+ $left = 75 ;
+ }
+ print $d ;
+ $left -= length($d) ;
+ }
+ print "\n" ;
+}
+
+print "/* Autogenerated by $0 */\n" ;
+print "#include \"pixels.h\"\n" ;
+print "const uint8_t scaletable[256][256] = {\n" ;
+for my $p ( 0..255 ) {
+ shipsubarray( map { int(($p*$_+127)/255) } ( 0 .. 255 ) );
+ # This formula has the property that
+ # scaletable[p][q] + scaletable[255-p][q] == q
+ # for all uint8_t values of p and q.
+ # This is important in order that a partially transparent
+ # pixel does not change the color of the underlying pixel
+ # unless the two pixels have different colors.
+}
+print "};\n" ;
+
+if(0) {
+
+print "const uint8_t divtable[256][256] = {\n" ;
+for my $p ( 0..255 ) {
+ shipsubarray( map { $_ >= $p ? 255 : int(0.5 + 255*$_/$p) }
+ ( 0 .. 255 ) );
+}
+print "};\n" ;
+
+}
+
+print "const rgba graytable[256] = {\n" ;
+for my $p ( 0..255 ) {
+ print " (rgba)$p << RED_SHIFT | (rgba)$p << GREEN_SHIFT | (rgba)$p << BLUE_SHIFT,\n" ;
+}
+print "};\n" ;
diff --git a/options.i b/options.i
new file mode 100644
index 0000000..07949a7
--- /dev/null
+++ b/options.i
@@ -0,0 +1,392 @@
+/* Option processing for xcftools -*- C -*-
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+OPTIONGROUP(1i,General options);
+
+OPTION('h',--help,show this message,
+ (Print an option summery to standard output and exit with a
+ return code of 0.
+ ));
+usage(stdout);
+exit(0);
+
+OPTION('V',--version,show version,
+ (Print the version numer of
+ .B xcftools
+ to standard output and exit with a return code of 0.
+ ));
+printf(PACKAGE_STRING "\n");
+exit(0);
+
+OPTION('v',--verbose,show progress messages,
+ (Print progress messages about the conversion to standard error.
+ ));
+verboseFlag = 1 ;
+break ;
+
+OPTION('j',--bzip,input is bzip2 compressed,
+ (Equivalent to
+ .BR "\-Z bzcat" .
+ Default if the filename ends with
+ .BR bz2 .
+ ));
+unzipper = "bzcat" ;
+break ;
+
+OPTION('z',--gzip,input is gzip compressed,
+ (Equivalent to
+ .BR "\-Z gzcat" .
+ Default if the filename ends with
+ .BR gz .
+ ));
+unzipper = "gzcat" ;
+break ;
+
+OPTION('Z',--unpack,(pgm) use 'pgm' to decompress input,
+ (Specify a command that the input file is filtered through
+ before being interpreted as an XCF file. The command is invoked as
+ .I command filename
+ and must produce output to its standard output.
+ Note that it is not possible to specify arguments as part of
+ .IR command .
+ An uncompressor is selected automatically if the filename ends
+ with
+ .B gz
+ or
+ .BR bz2 ;
+ to suppress this, use
+ .B \-Z cat
+ (which is implemented without actually starting a
+ .BR cat (1)
+ process).
+ ));
+unzipper = optarg ;
+break ;
+
+#ifdef XCF2FOO
+
+OPTION('o',--output,(filename) name output file,
+ (Write the converted picture to
+ .I filename
+ instead of to standard output.
+ ));
+flatspec.output_filename = optarg ;
+break ;
+
+#ifdef XCF2PNM
+OPTION('a',--alpha,(filename) write transparency map,
+ (Output a transparency mask for the flattened image to
+ .I filename
+ as a
+ .BR pgm (5)
+ file, in addition to the ordinary output.
+ If the flattened image is completely opaque, this will produce an
+ error message and exit status 101
+ (the alpha file may or may not be written); use
+ .B \-A
+ to suppress this.
+ ));
+flatspec.transmap_filename = optarg ;
+break ;
+#endif
+
+OPTION('b',--background,(color) select background color,
+ (Use this color for transparent pixels in the image.
+ The color can be given as
+ .B #rrggbb
+ or
+ .B #rgb
+ hexadecimal values,
+ or as an X11 color name that will be looked up in
+ .BR /usr/lib/X11/rgb.txt .
+ ));
+{
+ unsigned r,g,b ;
+ unsigned long hex ;
+ int met = 0 ;
+ if( *optarg == '#' )
+ sscanf(optarg+1,"%lx%n",&hex,&met);
+ if( met == 3 && strlen(optarg) == 4 ) {
+ r = ((hex >> 8) & 0xF) * 0x11 ;
+ g = ((hex >> 4) & 0xF) * 0x11 ;
+ b = ((hex >> 0) & 0xF) * 0x11 ;
+ } else if( met == 6 && strlen(optarg) == 7 ) {
+ r = ((hex >> 16) & 0xFF) ;
+ g = ((hex >> 8) & 0xFF) ;
+ b = ((hex >> 0) & 0xFF) ;
+ } else if( strcasecmp(optarg,"black") == 0 )
+ r = g = b = 0 ;
+ else if( strcasecmp(optarg,"white") == 0 )
+ r = g = b = 255 ;
+ else {
+ const char filename[] = "/usr/lib/X11/rgb.txt" ;
+ FILE *colortable = fopen(filename,"rt");
+ if( colortable ) {
+ int clen ;
+ char colorbuf[80] ;
+ do {
+ if( !fgets(colorbuf,sizeof colorbuf,colortable) ) {
+ r = (unsigned)-1 ;
+ break ;
+ }
+ clen = strlen(colorbuf);
+ while( clen && isspace(colorbuf[clen-1]) )
+ clen-- ;
+ colorbuf[clen] = '\0' ;
+ clen = 0 ;
+ sscanf(colorbuf," %u %u %u %n",&r,&g,&b,&clen);
+ } while( clen == 0 || strcasecmp(colorbuf+clen,optarg) != 0 );
+ } else {
+ fprintf(stderr,_("Could not open color database file %s\n"),filename);
+ }
+ }
+ if( r == (unsigned)-1 )
+ FatalGeneric(20,_("Unknown background color '%s'"),optarg);
+ flatspec.default_pixel = ((rgba)255 << ALPHA_SHIFT)
+ + ((rgba)r << RED_SHIFT)
+ + ((rgba)g << GREEN_SHIFT)
+ + ((rgba)b << BLUE_SHIFT);
+ break ;
+}
+
+OPTION('A',--force-alpha,force alpha channel in output,
+ (Invent a trivial alpha channel even if the flattened image is
+ completely opaque.
+ ));
+flatspec.default_pixel = FORCE_ALPHA_CHANNEL ;
+break ;
+
+OPTION('c',--color --colour,select color output,
+ (Force the output to use RGB color space even if it could be
+ represented.
+#ifdef XCF2PNM
+ This will be selected automatically if the output file''s name
+ ends with
+ .BR .ppm .
+#endif
+ ));
+flatspec.out_color_mode = COLOR_RGB ;
+break ;
+
+#if 0
+OPTION('i',--indexed,select indexed output,
+ (Force the output to used indexed color
+ .I with the palette of the XCF file.
+ If colors outside of the XCF file''s palette are produced
+ during flattening, exit with status XXX.
+ Beware that in PNG (unlike XCF) palette entries include
+ transparency information, so if the flattened image contains
+ any partial transparency, an error with status XXX will
+ result. (On the other hand,
+ .B xcf2png
+ will artificially add a palette entry for fully transparent
+ pixels or the the background color specified by
+ .BR \-b ,
+ if there is room in the palette).
+ ));
+flatspec.out_color_mode = COLOR_INDEXED ;
+break ;
+#endif
+
+OPTION('g',--gray --grey,select grayscale output,
+ (Force the output to be a grayscale image even if it may be monochrome.
+ If any colored pixels are encountered, exit with status 103.
+ This will be selected automatically if the output file''s name
+ ends with
+ .BR .pgm .
+ ));
+flatspec.out_color_mode = COLOR_GRAY ;
+break ;
+
+#ifdef XCF2PNM
+OPTION('m',--mono,select monochrome output,
+ (Force the output to be a monochrome image.
+ If any colors except black and white are encountered, exit with
+ status 103.
+ This will be selected automatically if the output file''s name
+ ends with
+ .BR .pbm .
+ ));
+flatspec.out_color_mode = COLOR_MONO ;
+break ;
+#endif
+
+#ifdef XCF2PNM
+OPTION('n',--pnm,select -c/-g/-m by image contents,
+ (Suppress the automatic choice of
+ .BR \-c ,
+ .BR \-g ,
+ or
+ .BR \-m
+ based on output filename, and instead select the output format
+ based on image contents. This is the default if the filename
+ is not recognized, and when writing to stdout.
+ ));
+flatspec.out_color_mode = COLOR_BY_CONTENTS ;
+break ;
+#endif
+
+OPTION('T',--truecolor,treat indexed images as RGB for flattening,
+ (Use standard RGB compositing for flattening indexed layers.
+ Without this option
+ .B THISPROGRAM
+ will mimic the Gimp''s current strategy of rounding each
+ alpha value to either full transparency or full opacity,
+ and interpret all layer modes as
+ .B Normal .
+ ));
+flatspec.gimpish_indexed = 0 ;
+break ;
+
+OPTION('G',--for-gif,disallow partial transparency,
+ (Assert that the flattened image will have no partial transparency
+ (allowing a more compact representation of the alpha output).
+ Exit with status 102 if the flattened image has any partial
+ transparency.
+ If
+ .B \-b
+ is also given, exit with status 102 if there is partial transparency
+ before applying the background color.
+ ));
+flatspec.partial_transparency_mode = FORBID_PARTIAL_TRANSPARENCY ;
+break ;
+
+OPTION('D',--dissolve,dissolve partial transparency,
+ (Do a "dissolve" step to eliminate partial transparency after
+ flattening.
+ If
+ .B \-b
+ is also given, this happens before the background color is applied.
+ ));
+flatspec.partial_transparency_mode = DISSOLVE_PARTIAL_TRANSPARENCY ;
+break ;
+
+OPTION('f',--full-image,flatten to memory; then analyse,
+ (First flatten the entire image to a memory buffer before writing
+ output. Then analyse the image to decide on the details of the
+ output format (e.g., whether a grayscale output is sufficient).
+ Without this option, the program flattens only a singe row of "tiles"
+ (height 64) at a time.
+ ));
+flatspec.process_in_memory = 1 ;
+break ;
+
+OPTION('S',--size,(w"x"h) crop image while converting,
+ (Crop the converted image to width \fIw\fP and height \fIh\fP.
+ ));
+{
+ unsigned w,h ;
+ int n = 0 ;
+ sscanf(optarg,"%ux%u%n",&w,&h,&n) ;
+ if( n && n == strlen(optarg) ) {
+ flatspec.dim.width = w ;
+ flatspec.dim.height = h ;
+ } else
+ FatalGeneric(20,_("-S option must have an argument of the form wxh"));
+ break ;
+}
+
+OPTION('O',--offset,(x","y) translate converted part of image,
+ (Offset the converted part of the image from the top-left corner
+ of the XCF canvas. Usually used with
+ .BR \-S .
+ ));
+{
+ int x,y ;
+ int n = 0 ;
+ sscanf(optarg,"%d,%d%n",&x,&y,&n) ;
+ if( n && n == strlen(optarg) ) {
+ flatspec.dim.c.l = x ;
+ flatspec.dim.c.t = y ;
+ } else
+ FatalGeneric(20,_("-O option must have an argument of the form x,y"));
+ break ;
+}
+
+OPTIONGROUP(1il,Layer-selection options);
+
+OPTION(300,--mode,(mode) set layer mode,
+ (Set the layer mode (e.g.,
+ .B Normal
+ or
+ .BR Multiply ).
+ ));
+{
+ GimpLayerModeEffects m ;
+ for( m = 0; strcmp(optarg,showGimpLayerModeEffects(m)) != 0 ; m++ ) {
+ if( m > GimpLayerModeEffects_LAST )
+ FatalGeneric(20,_("Layer mode '%s' is unknown"),optarg);
+ }
+ lastlayerspec(&flatspec,"--mode")->mode = m ;
+ break ;
+}
+
+OPTION(301,--percent,(n) set opacity in percent,
+ (Set the opacity on a scale from 0 to 100
+ (as in the Gimp user interface).
+ ));
+{
+ unsigned pct ;
+ int n ;
+ sscanf(optarg,"%u%n",&pct,&n) ;
+ if( n != strlen(optarg) || pct > 100 )
+ FatalGeneric(20,_("The argument to --pct is not a percentage"));
+ lastlayerspec(&flatspec,"--percent")->opacity = pct * 255 / 100 ;
+ break ;
+}
+
+OPTION(302,--opacity,(n) set opacity in 1/255 units,
+ (Set the opacity on a scale from 0 to 255 (as used internally)
+ ));
+{
+ unsigned alpha ;
+ int n ;
+ sscanf(optarg,"%u%n",&alpha,&n) ;
+ if( n != strlen(optarg) || alpha > 255 )
+ FatalGeneric(20,_("The argument to --opacity is not a number "
+ "between 0 and 255"));
+ lastlayerspec(&flatspec,"--percent")->opacity = alpha ;
+ break ;
+}
+
+OPTION(303,--mask,enable layer mask,
+ (Enable the layer mask.
+ ));
+lastlayerspec(&flatspec,"--mask")->hasMask = 1 ;
+break ;
+
+OPTION(304,--nomask,disable layer mask,
+ (Disable the layer mask.
+ ));
+lastlayerspec(&flatspec,"--nomask")->hasMask = 0 ;
+break ;
+
+#endif /* XCF2FOO */
+
+OPTIONGROUP(1i,)
+
+#if HAVE_ICONV
+OPTION('u',--utf8,use UTF-8 for layer names,
+ (Use the raw UTF-8 representation from the XCF file to compare
+ and display layer names.
+ Ordinarily, layer names will be converted to the character set
+ of the current locale.
+ ));
+use_utf8 = 1 ;
+break ;
+#endif
diff --git a/palette.c b/palette.c
new file mode 100644
index 0000000..20947cd
--- /dev/null
+++ b/palette.c
@@ -0,0 +1,110 @@
+/* Palette-manipulation functions functions for xcftools
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include "palette.h"
+#include <assert.h>
+
+#define HASH_SIZE 1711
+/* If I remember correctly, this size hash will be able to handle
+ * either of
+ * a) the Netscape cube with intensities 0x00, 0x33, 0x66, 0x99, 0xCC, xFF
+ * b) the EGA cube with intensities 0x00, 0x55, 0xAA, 0xFF
+ * c) the "CGA cube" with intensites 0x00, 0x80, 0xFF
+ * d) a full 256-step grayscale
+ * without collisions. It will also have a minimal number of collisions
+ * (4) on a full 16-to-a-side cube with intensities
+ * 0x00, 0x11, 0x22, ..., 0xDD, 0xEE, 0xFF.
+ */
+
+rgba palette[MAX_PALETTE] ;
+unsigned paletteSize ;
+static int masterhash[HASH_SIZE];
+static int bucketlinks[MAX_PALETTE];
+
+void
+init_palette_hash(void)
+{
+ unsigned i ;
+ for( i=0; i<HASH_SIZE; i++ )
+ masterhash[i] = -1 ;
+ for( i=0; i<MAX_PALETTE; i++ )
+ bucketlinks[i] = -1 ;
+ paletteSize = 0 ;
+}
+
+inline int
+lookup_or_intern(rgba color) {
+ int *target = &masterhash[color % HASH_SIZE];
+ while( *target >= 0 ) {
+ if( palette[*target] == color )
+ return *target ;
+ target = &bucketlinks[*target] ;
+ }
+#if 0
+ fprintf(stderr,"Palette[%u] = %08x (%u --> %d)\n",paletteSize,color,
+ color % HASH_SIZE, *target);
+#endif
+ if( paletteSize >= MAX_PALETTE )
+ return -1 ;
+ *target = paletteSize ;
+ palette[paletteSize] = color ;
+ return paletteSize++ ;
+}
+
+static inline void
+unpalettify_row(rgba *row,unsigned ncols)
+{
+ index_t *newrow = (index_t*) row ;
+ unsigned i ;
+ for( i=ncols; i--; ) {
+ row[i] = palette[newrow[i]] ;
+ }
+}
+
+int
+palettify_row(rgba *row,unsigned ncols)
+{
+ index_t *newrow = (index_t*)row ;
+ assert(sizeof(index_t) <= sizeof(rgba));
+ unsigned i ;
+ for( i=0; i<ncols; i++ ) {
+ int j = lookup_or_intern(row[i]) ;
+ if( j < 0 ) {
+ unpalettify_row(row,i);
+ return 0 ;
+ }
+ newrow[i] = j ;
+ }
+ return 1 ;
+}
+
+int
+palettify_rows (rgba *rows[],unsigned ncols,unsigned nlines)
+{
+ unsigned i ;
+ for( i=0; i<nlines; i++ ) {
+ if( !palettify_row(rows[i],ncols) ) {
+ while( i-- )
+ unpalettify_row(rows[i],ncols);
+ return 0 ;
+ }
+ }
+ return 1 ;
+}
+
+
diff --git a/palette.h b/palette.h
new file mode 100644
index 0000000..2453440
--- /dev/null
+++ b/palette.h
@@ -0,0 +1,52 @@
+/* Palette-manipulation functions functions for xcftools
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#ifndef PALETTE_H
+#define PALETTE_H
+
+#include "xcftools.h"
+#include "pixels.h"
+
+#define MAX_PALETTE 256
+extern rgba palette[MAX_PALETTE] ;
+extern unsigned paletteSize ;
+
+typedef uint8_t index_t ;
+
+void init_palette_hash(void);
+
+/* lookup_or_intern() returns a negative number if there is no room
+ * for the color in the palette.
+ */
+int lookup_or_intern(rgba color);
+
+/* palettify_row will convert a row of 'rgba' values into a packed row
+ * of 'uint8_t' indces. If it succeeds without running out of colormap
+ * entries, it returns nonzero. On the other hand if it does run out
+ * of colormap entries it returns zero _and_ undoes the conversions
+ * already done, so that the row is still a full row of 'rgba' values
+ * afterwards.
+ */
+int palettify_row(rgba *row,unsigned ncols);
+
+/* palettify_rows is like palettify_rows, but works on several
+ * rows at a time.
+ */
+int palettify_rows(rgba *rows[],unsigned ncols,unsigned nlines);
+
+#endif /* PALETTE_H */
diff --git a/pixels.c b/pixels.c
new file mode 100644
index 0000000..20e6c81
--- /dev/null
+++ b/pixels.c
@@ -0,0 +1,483 @@
+/* Pixel and tile functions for xcftools
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#define DEBUG
+#include "xcftools.h"
+#include "pixels.h"
+#include <assert.h>
+#include <string.h>
+
+rgba colormap[256] ;
+unsigned colormapLength=0 ;
+
+int
+degrayPixel(rgba pixel)
+{
+ if( ((pixel >> RED_SHIFT) & 255) == ((pixel >> GREEN_SHIFT) & 255) &&
+ ((pixel >> RED_SHIFT) & 255) == ((pixel >> BLUE_SHIFT) & 255) )
+ return (pixel >> RED_SHIFT) & 255 ;
+ return -1 ;
+}
+
+/* ****************************************************************** */
+
+typedef const struct _convertParams {
+ int bpp ;
+ int shift[4] ;
+ uint32_t base_pixel ;
+ const rgba *lookup ;
+} convertParams ;
+#define RGB_SHIFT RED_SHIFT, GREEN_SHIFT, BLUE_SHIFT
+#define OPAQUE (255 << ALPHA_SHIFT)
+static convertParams convertRGB = { 3, {RGB_SHIFT}, OPAQUE, 0 };
+static convertParams convertRGBA = { 4, {RGB_SHIFT, ALPHA_SHIFT}, 0,0 };
+static convertParams convertGRAY = { 1, {-1}, OPAQUE, graytable };
+static convertParams convertGRAYA = { 2, {-1,ALPHA_SHIFT}, 0, graytable };
+static convertParams convertINDEXED = { 1, {-1}, OPAQUE, colormap };
+static convertParams convertINDEXEDA = { 2, {-1,ALPHA_SHIFT}, 0, colormap };
+
+static convertParams convertColormap = { 3, {RGB_SHIFT}, 0, 0 };
+static convertParams convertChannel = { 1, {ALPHA_SHIFT}, 0, 0 };
+
+/* ****************************************************************** */
+
+static inline int
+tileDirectoryOneLevel(struct tileDimensions *dim,uint32_t ptr)
+{
+ if( ptr == 0 )
+ return 0 ;
+ if( xcfL(ptr ) != dim->c.r - dim->c.l ||
+ xcfL(ptr+4) != dim->c.b - dim->c.t )
+ FatalBadXCF("Drawable size mismatch at %" PRIX32, ptr);
+ return ptr += 8 ;
+}
+
+static void
+initTileDirectory(struct tileDimensions *dim,struct xcfTiles *tiles,
+ const char *type)
+{
+ uint32_t ptr ;
+ uint32_t data ;
+
+ ptr = tiles->hierarchy ;
+ tiles->hierarchy = 0 ;
+ if( (ptr = tileDirectoryOneLevel(dim,ptr)) == 0 ) return ;
+ if( tiles->params == &convertChannel ) {
+ /* A layer mask is a channel.
+ * Skip a name and a property list.
+ */
+ xcfString(ptr,&ptr);
+ while( xcfNextprop(&ptr,&data) != PROP_END )
+ ;
+ ptr = xcfOffset(ptr,4*4);
+ if( (ptr = tileDirectoryOneLevel(dim,ptr)) == 0 ) return ;
+ }
+ /* The XCF format has a dummy "hierarchy" level which was
+ * once meant to mean something, but never happened. It contains
+ * the bpp value and a list of "level" pointers; but only the
+ * first level actually contains data.
+ */
+ data = xcfL(ptr) ;
+ if( xcfL(ptr) != tiles->params->bpp )
+ FatalBadXCF("%"PRIu32" bytes per pixel for %s drawable",xcfL(ptr),type);
+ ptr = xcfOffset(ptr+4,3*4) ;
+ if( (ptr = tileDirectoryOneLevel(dim,ptr)) == 0 ) return ;
+
+ xcfCheckspace(ptr,dim->ntiles*4+4,"Tile directory at %" PRIX32,ptr);
+ if( xcfL(ptr + dim->ntiles*4) != 0 )
+ FatalBadXCF("Wrong sized tile directory at %" PRIX32,ptr);
+#define REUSE_RAW_DATA tiles->tileptrs = (uint32_t*)(xcf_file + ptr)
+#if defined(WORDS_BIGENDIAN) && defined(CAN_DO_UNALIGNED_WORDS)
+ REUSE_RAW_DATA;
+#else
+# if defined(WORDS_BIGENDIAN)
+ if( (ptr&3) == 0 ) REUSE_RAW_DATA; else
+# endif
+ {
+ unsigned i ;
+ tiles->tileptrs = xcfmalloc(dim->ntiles * sizeof(uint32_t)) ;
+ for( i = 0 ; i < dim->ntiles ; i++ )
+ tiles->tileptrs[i] = xcfL(ptr+i*4);
+ }
+#endif
+}
+
+void
+initLayer(struct xcfLayer *layer) {
+ if( layer->dim.ntiles == 0 ||
+ (layer->pixels.hierarchy == 0 && layer->mask.hierarchy == 0) )
+ return ;
+ switch(layer->type) {
+#define DEF(X) case GIMP_##X##_IMAGE: layer->pixels.params = &convert##X; break
+ DEF(RGB);
+ DEF(RGBA);
+ DEF(GRAY);
+ DEF(GRAYA);
+ DEF(INDEXED);
+ DEF(INDEXEDA);
+ default:
+ FatalUnsupportedXCF(_("Layer type %s"),showGimpImageType(layer->type));
+ }
+ initTileDirectory(&layer->dim,&layer->pixels,showGimpImageType(layer->type));
+ layer->mask.params = &convertChannel ;
+ initTileDirectory(&layer->dim,&layer->mask,"layer mask");
+}
+static void copyStraightPixels(rgba *dest,unsigned npixels,
+ uint32_t ptr,convertParams *params);
+void
+initColormap(void) {
+ uint32_t ncolors ;
+ if( XCF.colormapptr == 0 ) {
+ colormapLength = 0 ;
+ return ;
+ }
+ ncolors = xcfL(XCF.colormapptr) ;
+ if( ncolors > 256 )
+ FatalUnsupportedXCF(_("Color map has more than 256 entries"));
+ copyStraightPixels(colormap,ncolors,XCF.colormapptr+4,&convertColormap);
+ colormapLength = ncolors ;
+#ifdef xDEBUG
+ {
+ unsigned j ;
+ fprintf(stderr,"Colormap decoding OK\n");
+ for( j = 0 ; j < ncolors ; j++ ) {
+ if( j % 8 == 0 ) fprintf(stderr,"\n");
+ fprintf(stderr," %08x",colormap[j]);
+ }
+ fprintf(stderr,"\n");
+ }
+#endif
+}
+
+/* ****************************************************************** */
+
+struct Tile *
+newTile(struct rect r)
+{
+ unsigned npixels = (unsigned)(r.b-r.t) * (unsigned)(r.r-r.l) ;
+ struct Tile *data
+ = xcfmalloc(sizeof(struct Tile) -
+ sizeof(rgba)*(TILE_HEIGHT*TILE_WIDTH - npixels)) ;
+ data->count = npixels ;
+ data->refcount = 1 ;
+ data->summary = 0 ;
+ return data ;
+}
+
+struct Tile *
+forkTile(struct Tile* tile)
+{
+ if( ++tile->refcount <= 0 )
+ FatalUnsupportedXCF(_("Unbelievably many layers?"
+ "More likely to be a bug in %s"),progname);
+ return tile ;
+}
+
+void
+freeTile(struct Tile* tile)
+{
+ if( --tile->refcount == 0 )
+ xcffree(tile) ;
+}
+
+summary_t
+tileSummary(struct Tile *tile)
+{
+ unsigned i ;
+ summary_t summary ;
+ if( (tile->summary & TILESUMMARY_UPTODATE) != 0 )
+ return tile->summary ;
+ summary = TILESUMMARY_ALLNULL + TILESUMMARY_ALLFULL + TILESUMMARY_CRISP ;
+ for( i=0; summary && i<tile->count; i++ ) {
+ if( FULLALPHA(tile->pixels[i]) )
+ summary &= ~TILESUMMARY_ALLNULL ;
+ else if( NULLALPHA(tile->pixels[i]) )
+ summary &= ~TILESUMMARY_ALLFULL ;
+ else
+ summary = 0 ;
+ }
+ summary += TILESUMMARY_UPTODATE ;
+ tile->summary = summary ;
+ return summary ;
+}
+
+void
+fillTile(struct Tile *tile,rgba data)
+{
+ unsigned i ;
+ for( i = 0 ; i < tile->count ; i++ )
+ tile->pixels[i] = data ;
+ if( FULLALPHA(data) )
+ tile->summary = TILESUMMARY_UPTODATE+TILESUMMARY_ALLFULL+TILESUMMARY_CRISP;
+ else if (NULLALPHA(data) )
+ tile->summary = TILESUMMARY_UPTODATE+TILESUMMARY_ALLNULL+TILESUMMARY_CRISP;
+ else
+ tile->summary = TILESUMMARY_UPTODATE ;
+}
+
+/* ****************************************************************** */
+
+static void
+copyStraightPixels(rgba *dest,unsigned npixels,
+ uint32_t ptr,convertParams *params)
+{
+ unsigned bpp = params->bpp;
+ const rgba *lookup = params->lookup;
+ rgba base_pixel = params->base_pixel ;
+ uint8_t *bp = xcf_file + ptr ;
+ xcfCheckspace(ptr,bpp*npixels,
+ "pixel array (%u x %d bpp) at %"PRIX32,npixels,bpp,ptr);
+ while( npixels-- ) {
+ rgba pixel = base_pixel ;
+ unsigned i ;
+ for( i = 0 ; i < bpp ; i++ ) {
+ if( params->shift[i] < 0 ) {
+ pixel += lookup[*bp++] ;
+ } else {
+ pixel += *bp++ << params->shift[i] ;
+ }
+ }
+ *dest++ = pixel ;
+ }
+}
+
+static inline void
+copyRLEpixels(rgba *dest,unsigned npixels,uint32_t ptr,convertParams *params)
+{
+ unsigned i,j ;
+ rgba base_pixel = params->base_pixel ;
+
+#ifdef xDEBUG
+ fprintf(stderr,"RLE stream at %x, want %u x %u pixels, base %x\n",
+ ptr,params->bpp,npixels,base_pixel);
+#endif
+
+
+ /* This algorithm depends on the indexed byte always being the first one */
+ if( params->shift[0] < -1 )
+ base_pixel = 0 ;
+ for( j = npixels ; j-- ; )
+ dest[j] = base_pixel ;
+
+ for( i = 0 ; i < params->bpp ; i++ ) {
+ int shift = params->shift[i] ;
+ if( shift < 0 )
+ shift = 0 ;
+ for( j = 0 ; j < npixels ; ) {
+ int countspec ;
+ unsigned count ;
+ xcfCheckspace(ptr,2,"RLE data stream");
+ countspec = (int8_t) xcf_file[ptr++] ;
+ count = countspec >= 0 ? countspec+1 : -countspec ;
+ if( count == 128 ) {
+ xcfCheckspace(ptr,3,"RLE long count");
+ count = xcf_file[ptr++] << 8 ;
+ count += xcf_file[ptr++] ;
+ }
+ if( j + count > npixels )
+ FatalBadXCF("Overlong RLE run at %"PRIX32" (plane %u, %u left)",
+ ptr,i,npixels-j);
+ if( countspec >= 0 ) {
+ rgba data = (uint32_t) xcf_file[ptr++] << shift ;
+ while( count-- )
+ dest[j++] += data ;
+ } else {
+ while( count-- )
+ dest[j++] += (uint32_t) xcf_file[ptr++] << shift ;
+ }
+ }
+ if( i == 0 && params->shift[0] < 0 ) {
+ const rgba *lookup = params->lookup ;
+ base_pixel = params->base_pixel ;
+ for( j = npixels ; j-- ; ) {
+ dest[j] = lookup[dest[j]-base_pixel] + base_pixel ;
+ }
+ }
+ }
+#ifdef xDEBUG
+ fprintf(stderr,"RLE decoding OK at %"PRIX32"\n",ptr);
+ /*
+ for( j = 0 ; j < npixels ; j++ ) {
+ if( j % 8 == 0 ) fprintf(stderr,"\n");
+ fprintf(stderr," %8x",dest[j]);
+ }
+ fprintf(stderr,"\n");
+ */
+#endif
+}
+
+static inline void
+copyTilePixels(struct Tile *dest, uint32_t ptr,convertParams *params)
+{
+ if( FULLALPHA(params->base_pixel) )
+ dest->summary = TILESUMMARY_UPTODATE+TILESUMMARY_ALLFULL+TILESUMMARY_CRISP;
+ else
+ dest->summary = 0 ;
+ switch( XCF.compression ) {
+ case COMPRESS_NONE:
+ copyStraightPixels(dest->pixels,dest->count,ptr,params);
+ break ;
+ case COMPRESS_RLE:
+ copyRLEpixels(dest->pixels,dest->count,ptr,params);
+ break ;
+ default:
+ FatalUnsupportedXCF(_("%s compression"),
+ showXcfCompressionType(XCF.compression));
+ }
+}
+
+static struct Tile *
+getMaskOrLayerTile(struct tileDimensions *dim, struct xcfTiles *tiles,
+ struct rect want)
+{
+ struct Tile *tile = newTile(want);
+
+ assert( want.l < want.r && want.t < want.b );
+ if( tiles->tileptrs == 0 ) {
+ fillTile(tile,0);
+ return tile ;
+ }
+
+#ifdef xDEBUG
+ fprintf(stderr,"getMaskOrLayer: (%d-%d),(%d-%d)\n",left,right,top,bottom);
+#endif
+
+ if( isSubrect(want,dim->c) &&
+ (want.l - dim->c.l) % TILE_WIDTH == 0 &&
+ (want.t - dim->c.t) % TILE_HEIGHT == 0 ) {
+ unsigned tx = (want.l - dim->c.l) / TILE_WIDTH ;
+ unsigned ty = (want.t - dim->c.t) / TILE_WIDTH ;
+ if( want.r == TILEXn(*dim,tx+1) && want.b == TILEYn(*dim,ty+1) ) {
+ /* The common case? An entire single tile from the layer */
+ copyTilePixels(tile,tiles->tileptrs[tx + ty*dim->tilesx],tiles->params);
+ return tile ;
+ }
+ }
+
+ /* OK, we must construct the wanted tile as a jigsaw */
+ {
+ unsigned width = want.r-want.l ;
+ rgba *pixvert = tile->pixels ;
+ rgba *pixhoriz ;
+ unsigned y, ty, l0, l1, lstart, lnum ;
+ unsigned x, tx, c0, c1, cstart, cnum ;
+
+ if( !isSubrect(want,dim->c) ) {
+ if( want.l < dim->c.l ) pixvert += (dim->c.l - want.l),
+ want.l = dim->c.l ;
+ if( want.r > dim->c.r ) want.r = dim->c.r ;
+ if( want.t < dim->c.t ) pixvert += (dim->c.t - want.t) * width,
+ want.t = dim->c.t ;
+ if( want.b > dim->c.b ) want.b = dim->c.b ;
+ fillTile(tile,0);
+ } else {
+ tile->summary = -1 ; /* I.e. whatever the jigsaw pieces say */
+ }
+
+#ifdef xDEBUG
+ fprintf(stderr,"jig0 (%d-%d),(%d-%d)\n",left,right,top,bottom);
+#endif
+
+ for( y=want.t, ty=(want.t-dim->c.t)/TILE_HEIGHT, l0=TILEYn(*dim,ty);
+ y<want.b;
+ pixvert += lnum*width, ty++, y=l0=l1 ) {
+ l1 = TILEYn(*dim,ty+1) ;
+ lstart = y - l0 ;
+ lnum = (l1 > want.b ? want.b : l1) - y ;
+
+ pixhoriz = pixvert ;
+ for( x=want.l, tx=(want.l-dim->c.l)/TILE_WIDTH, c0=TILEXn(*dim,tx);
+ x<want.r;
+ pixhoriz += cnum, tx++, x=c0=c1 ) {
+ c1 = TILEXn(*dim,tx+1);
+ cstart = x - c0 ;
+ cnum = (c1 > want.r ? want.r : c1) - x ;
+
+ {
+ static struct Tile tmptile ;
+ unsigned dwidth = c1-c0 ;
+ unsigned i, j ;
+ tmptile.count = (c1-c0)*(l1-l0) ;
+#ifdef xDEBUG
+ fprintf(stderr,"jig ty=%u(%u-%u-%u)(%u+%u) tx=%u(%u-%u-%u)(%u+%u)\n",
+ ty,l0,y,l1,lstart,lnum,
+ tx,c0,x,c1,cstart,cnum);
+#endif
+ copyTilePixels(&tmptile,
+ tiles->tileptrs[tx+ty*dim->tilesx],tiles->params);
+ for(i=0; i<lnum; i++)
+ for(j=0; j<cnum; j++)
+ pixhoriz[i*width+j]
+ = tmptile.pixels[(i+lstart)*dwidth+(j+cstart)];
+ tile->summary &= tmptile.summary ;
+ }
+ }
+ }
+ }
+ return tile ;
+}
+
+void
+applyMask(struct Tile *tile, struct Tile *mask)
+{
+ unsigned i ;
+ assertTileCompatibility(tile,mask);
+ assert( tile->count == mask->count );
+ invalidateSummary(tile,0);
+ for( i=0; i < tile->count ;i++ )
+ tile->pixels[i] = NEWALPHA(tile->pixels[i],
+ scaletable[mask->pixels[i]>>ALPHA_SHIFT]
+ [ALPHA(tile->pixels[i])]);
+ freeTile(mask);
+}
+
+struct Tile *
+getLayerTile(struct xcfLayer *layer,const struct rect *where)
+{
+ struct Tile *data ;
+
+#ifdef xDEBUG
+ fprintf(stderr,"getLayerTile(%s): (%d-%d),(%d-%d)\n",
+ layer->name,where->l,where->r,where->t,where->b);
+#endif
+
+ if( disjointRects(*where,layer->dim.c) ||
+ layer->opacity == 0 ) {
+ data = newTile(*where);
+ fillTile(data,0);
+ return data ;
+ }
+
+ data = getMaskOrLayerTile(&layer->dim,&layer->pixels,*where);
+ if( (data->summary & TILESUMMARY_ALLNULL) != 0 )
+ return data ;
+ if( layer->hasMask ) {
+ struct Tile *mask = getMaskOrLayerTile(&layer->dim,&layer->mask,*where);
+ applyMask(data,mask);
+ }
+ if( layer->opacity < 255 ) {
+ const uint8_t *ourtable = scaletable[layer->opacity] ;
+ int i ;
+ invalidateSummary(data,~(TILESUMMARY_CRISP | TILESUMMARY_ALLFULL));
+ for( i=0; i < data->count; i++ )
+ data->pixels[i]
+ = NEWALPHA(data->pixels[i],ourtable[ALPHA(data->pixels[i])]) ;
+ }
+ return data ;
+}
+
diff --git a/pixels.h b/pixels.h
new file mode 100644
index 0000000..8d8ea2e
--- /dev/null
+++ b/pixels.h
@@ -0,0 +1,118 @@
+/* Pixel and tile functions for xcftools
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#ifndef PIXELS_H
+#define PIXELS_H
+
+#include "xcftools.h"
+
+/* MACROS FOR INTERNAL PIXEL ORDERING HERE */
+/*=========================================*/
+/* In principle the internal representation of pixels may change.
+ * - this was supposed to allow an optimization where a layer could
+ * be represented as a pointer into the mmapped xcf file, if
+ * alignment, bpp, and endianness agreed (the point was that the
+ * pixel representation had to agree with the endianness).
+ *
+ * However, it turns out that the current Gimp _always_ saves images
+ * with RLE encoding of tiles, so such an effort would be in vain.
+ *
+ * Just for modularity, nevertheless try to isolate knowledge of
+ * the RGBA-to-machine-word packing in this section of the
+ * header file. Define new macros if necessary.
+ *
+ * Given that we don't have to agree with the uncompressed
+ * RLE format, we choose to have the alpha in the _least_
+ * significant byte on all archs - it is tested and used more
+ * often than the visible channels.
+ */
+typedef uint32_t rgba ;
+
+#define ALPHA_SHIFT 0
+#define RED_SHIFT 8
+#define GREEN_SHIFT 16
+#define BLUE_SHIFT 24
+
+#define ALPHA(rgba) ((uint8_t)(rgba))
+#define FULLALPHA(rgba) ((uint8_t)(rgba) == 255)
+#define NULLALPHA(rgba) ((uint8_t)(rgba) == 0)
+#define NEWALPHA(rgb,a) (((rgba)(rgb) & 0xFFFFFF00) + (a))
+
+extern const uint8_t scaletable[256][256] ;
+extern const rgba graytable[256] ;
+extern rgba colormap[256] ;
+extern unsigned colormapLength ;
+void initLayer(struct xcfLayer *);
+void initColormap();
+
+int degrayPixel(rgba); /* returns -1 for non-gray pixels */
+
+/* ******************************************************* */
+
+#define TILEXn(dim,tx) \
+ ((tx)==(dim).tilesx ? (dim).c.r : (dim).c.l + ((tx)*TILE_WIDTH))
+#define TILEYn(dim,ty) \
+ ((ty)==(dim).tilesy ? (dim).c.b : (dim).c.t + ((ty)*TILE_HEIGHT))
+
+#if __i386__
+/* This is probably the only common architecture where small constants
+ * are more efficient for byte operations.
+ */
+typedef int8_t summary_t ;
+typedef short int refcount_t ;
+#else
+typedef int summary_t ;
+typedef int refcount_t ;
+#endif
+
+#define TILESUMMARY_UPTODATE 8
+#define TILESUMMARY_ALLNULL 4
+#define TILESUMMARY_ALLFULL 2
+#define TILESUMMARY_CRISP 1 /* everyting either null or full */
+struct Tile {
+ refcount_t refcount ;
+ summary_t summary ; /* a combination of TIMESUMMARY_FOO constatns */
+ unsigned count ;
+ rgba pixels[TILE_WIDTH * TILE_HEIGHT];
+};
+/* Actually, the Tile structures that get allocated many not have
+ * room for that many pixels. We subtract the space for those we don't
+ * use - which is Not Legal C, but ought to be portable.
+ * OTOH, one can also use a static struct Tile for temporary storage.
+ */
+
+
+#define assertTileCompatibility(t1,t2) assert((t1)->count==(t2)->count)
+
+struct Tile *newTile(struct rect);
+struct Tile *forkTile(struct Tile*);
+void freeTile(struct Tile*);
+#define invalidateSummary(tile,mask) \
+ do{ assert((tile)->refcount==1); (tile)->summary &= mask; } while(0)
+summary_t __ATTRIBUTE__((pure)) tileSummary(struct Tile *);
+
+void fillTile(struct Tile*,rgba);
+
+/* applyMask() destructively changes tile,
+ * applyMask() gets ownership of mask
+ */
+void applyMask(struct Tile *tile, struct Tile *mask);
+
+struct Tile *getLayerTile(struct xcfLayer *,const struct rect *);
+
+#endif /* FLATTEN_H */
diff --git a/test/Makefile b/test/Makefile
new file mode 100644
index 0000000..379e6c7
--- /dev/null
+++ b/test/Makefile
@@ -0,0 +1,8 @@
+check:
+ ./dotest -k
+ $(MAKE) clean
+test: check
+clean:
+ for a in * ; do case $$a in \
+ README | Makefile | dotest | pngtype.pl ) ;; \
+ * ) [ -d $$a ] || rm $$a ;; esac ; done
diff --git a/test/README b/test/README
new file mode 100644
index 0000000..d7d0006
--- /dev/null
+++ b/test/README
@@ -0,0 +1,27 @@
+This regression test requires perl, bash, and some programs from
+netpbm: pngtopnm, pnmdepth and pgmtoppm.
+
+The expected outputs are stored as PNG files, which compress better
+than just gzipped PxM, but the output from xcf2png is not compared
+byte-to-byte with the stored files, because different libpng and zlib
+versions may take different, but legitimate, decisions about IDAT
+chunk division and compression. Instead pixel comparisions are
+done with cmp(1) on PxM representations, which have less possibility
+for variations.
+
+The test of xcftopnm assumes that the layout of the ascii header
+in the output from xcftopnm matches byte-for-byte what netpbm produces.
+There is an undocumented -@ switch that does this, but if you have a
+wildly different version of netpbm you may need to fiddle with the
+implementation of -@ and/or insert filters in the test driver
+routines.
+
+
+
+There are yet no tests for correct reporting of errors.
+
+
+
+Note: display(1) from imagemagick 6.0.6.2 apparently does not display
+ PNG files with grayscale+alpha correctly - the alpha channel is
+ ignored. \ No newline at end of file
diff --git a/test/answer/Addition.png b/test/answer/Addition.png
new file mode 100644
index 0000000..93024de
--- /dev/null
+++ b/test/answer/Addition.png
Binary files differ
diff --git a/test/answer/Burn.png b/test/answer/Burn.png
new file mode 100644
index 0000000..b6e747e
--- /dev/null
+++ b/test/answer/Burn.png
Binary files differ
diff --git a/test/answer/DarkenOnly.png b/test/answer/DarkenOnly.png
new file mode 100644
index 0000000..58f71dd
--- /dev/null
+++ b/test/answer/DarkenOnly.png
Binary files differ
diff --git a/test/answer/Difference.png b/test/answer/Difference.png
new file mode 100644
index 0000000..9a1c5fb
--- /dev/null
+++ b/test/answer/Difference.png
Binary files differ
diff --git a/test/answer/Divide.png b/test/answer/Divide.png
new file mode 100644
index 0000000..a7668ec
--- /dev/null
+++ b/test/answer/Divide.png
Binary files differ
diff --git a/test/answer/Dodge.png b/test/answer/Dodge.png
new file mode 100644
index 0000000..05d274b
--- /dev/null
+++ b/test/answer/Dodge.png
Binary files differ
diff --git a/test/answer/GrainExtract.png b/test/answer/GrainExtract.png
new file mode 100644
index 0000000..c386af2
--- /dev/null
+++ b/test/answer/GrainExtract.png
Binary files differ
diff --git a/test/answer/GrainMerge.png b/test/answer/GrainMerge.png
new file mode 100644
index 0000000..616e232
--- /dev/null
+++ b/test/answer/GrainMerge.png
Binary files differ
diff --git a/test/answer/Hardlight.png b/test/answer/Hardlight.png
new file mode 100644
index 0000000..8a4739d
--- /dev/null
+++ b/test/answer/Hardlight.png
Binary files differ
diff --git a/test/answer/LightenOnly.png b/test/answer/LightenOnly.png
new file mode 100644
index 0000000..bb2200f
--- /dev/null
+++ b/test/answer/LightenOnly.png
Binary files differ
diff --git a/test/answer/Multiply.png b/test/answer/Multiply.png
new file mode 100644
index 0000000..17e43b1
--- /dev/null
+++ b/test/answer/Multiply.png
Binary files differ
diff --git a/test/answer/Overlay.png b/test/answer/Overlay.png
new file mode 100644
index 0000000..628d2b5
--- /dev/null
+++ b/test/answer/Overlay.png
Binary files differ
diff --git a/test/answer/Screen.png b/test/answer/Screen.png
new file mode 100644
index 0000000..9335e59
--- /dev/null
+++ b/test/answer/Screen.png
Binary files differ
diff --git a/test/answer/Subtract.png b/test/answer/Subtract.png
new file mode 100644
index 0000000..e5f03c5
--- /dev/null
+++ b/test/answer/Subtract.png
Binary files differ
diff --git a/test/answer/burmid.png b/test/answer/burmid.png
new file mode 100644
index 0000000..81f5371
--- /dev/null
+++ b/test/answer/burmid.png
Binary files differ
diff --git a/test/answer/comptest.png b/test/answer/comptest.png
new file mode 100644
index 0000000..7c6d6e2
--- /dev/null
+++ b/test/answer/comptest.png
Binary files differ
diff --git a/test/answer/comptestB.png b/test/answer/comptestB.png
new file mode 100644
index 0000000..197af42
--- /dev/null
+++ b/test/answer/comptestB.png
Binary files differ
diff --git a/test/answer/crisp1.png b/test/answer/crisp1.png
new file mode 100644
index 0000000..927308e
--- /dev/null
+++ b/test/answer/crisp1.png
Binary files differ
diff --git a/test/answer/crisp2.png b/test/answer/crisp2.png
new file mode 100644
index 0000000..934d9ab
--- /dev/null
+++ b/test/answer/crisp2.png
Binary files differ
diff --git a/test/answer/doodle.png b/test/answer/doodle.png
new file mode 100644
index 0000000..42c68e3
--- /dev/null
+++ b/test/answer/doodle.png
Binary files differ
diff --git a/test/answer/gray.png b/test/answer/gray.png
new file mode 100644
index 0000000..c917ae9
--- /dev/null
+++ b/test/answer/gray.png
Binary files differ
diff --git a/test/answer/i255t.png b/test/answer/i255t.png
new file mode 100644
index 0000000..d96416d
--- /dev/null
+++ b/test/answer/i255t.png
Binary files differ
diff --git a/test/answer/i255tt.png b/test/answer/i255tt.png
new file mode 100644
index 0000000..9e43321
--- /dev/null
+++ b/test/answer/i255tt.png
Binary files differ
diff --git a/test/answer/index255.png b/test/answer/index255.png
new file mode 100644
index 0000000..d4a5ba0
--- /dev/null
+++ b/test/answer/index255.png
Binary files differ
diff --git a/test/answer/index256.png b/test/answer/index256.png
new file mode 100644
index 0000000..0669aa5
--- /dev/null
+++ b/test/answer/index256.png
Binary files differ
diff --git a/test/answer/index4.png b/test/answer/index4.png
new file mode 100644
index 0000000..3de2398
--- /dev/null
+++ b/test/answer/index4.png
Binary files differ
diff --git a/test/answer/indextest.png b/test/answer/indextest.png
new file mode 100644
index 0000000..c8ff807
--- /dev/null
+++ b/test/answer/indextest.png
Binary files differ
diff --git a/test/answer/mid.png b/test/answer/mid.png
new file mode 100644
index 0000000..f4bcbe8
--- /dev/null
+++ b/test/answer/mid.png
Binary files differ
diff --git a/test/answer/misc1.png b/test/answer/misc1.png
new file mode 100644
index 0000000..277519d
--- /dev/null
+++ b/test/answer/misc1.png
Binary files differ
diff --git a/test/answer/modeA.png b/test/answer/modeA.png
new file mode 100644
index 0000000..597099b
--- /dev/null
+++ b/test/answer/modeA.png
Binary files differ
diff --git a/test/answer/modeB.png b/test/answer/modeB.png
new file mode 100644
index 0000000..d9836da
--- /dev/null
+++ b/test/answer/modeB.png
Binary files differ
diff --git a/test/answer/mono.png b/test/answer/mono.png
new file mode 100644
index 0000000..8b8b3be
--- /dev/null
+++ b/test/answer/mono.png
Binary files differ
diff --git a/test/answer/mono1.png b/test/answer/mono1.png
new file mode 100644
index 0000000..aa64ace
--- /dev/null
+++ b/test/answer/mono1.png
Binary files differ
diff --git a/test/answer/odoodle.png b/test/answer/odoodle.png
new file mode 100644
index 0000000..50e1800
--- /dev/null
+++ b/test/answer/odoodle.png
Binary files differ
diff --git a/test/answer/tiletest.png b/test/answer/tiletest.png
new file mode 100644
index 0000000..58854bc
--- /dev/null
+++ b/test/answer/tiletest.png
Binary files differ
diff --git a/test/dotest b/test/dotest
new file mode 100755
index 0000000..c444c98
--- /dev/null
+++ b/test/dotest
@@ -0,0 +1,506 @@
+#! /bin/bash
+
+# Regression test for Xcftools
+# Copyright (C) 2006 Henning Makholm
+#
+# This test script is free software; you can redistribute it and/or
+# modify it under the terms of version 2 of the GNU General Public
+# License as published by the Free Software Foundation.
+#
+# 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
+
+export LC_CTYPE=C
+export LC_MESSAGES=C
+
+TESTFROM=..
+
+totaltests=0
+failedtests=0
+lastfailed=0
+keepgoing=0
+if [ x"$1" = x"-k" ]
+then
+ keepgoing=1
+fi
+
+failed() {
+ if (( lastfailed != totaltests ))
+ then
+ echo FAILED
+ (( lastfailed = totaltests ))
+ (( failedtests++ ))
+ fi
+ (( keepgoing )) || exit 1
+}
+
+
+testrun() {
+ if [ x$1 == x--exit ]
+ then
+ want=$2 ;
+ shift ;
+ shift ;
+ else
+ want=0 ;
+ fi
+ (( totaltests++ ))
+ echo "===>" "$@"
+ "$@" > stdout.txt 2> stderr.txt
+ got=$?
+ if [ $want = $got ]
+ then
+ diff -u expected.stdout stdout.txt || failed
+ diff -u expected.stderr stderr.txt || failed
+ else
+ echo ===STDOUT===
+ cat stdout.txt
+ echo ===STDERR===
+ cat stderr.txt
+ echo ===EXIT STATUS===
+ echo $got
+ failed
+ fi
+}
+
+testinfo() {
+ testrun $TESTFROM/xcfinfo "$@"
+}
+
+testpnm() {
+ oanswer=''
+ aanswer=''
+ ofilter=cat
+ afilter=cat
+ oext=pnm
+ while true
+ do
+ arg="`echo $1 | cut -c 3-`"
+ case $arg in
+ -pgm) arg="pnmdepth 255" ;;
+ -ppm) arg="pgmtoppm 1,1,1" ;;
+ esac
+ case $1 in
+ o:*) oanswer="$arg" ;;
+ a:*) aanswer="$arg" ;;
+ O:*) ofilter="$arg" ;;
+ A:*) afilter="$arg" ;;
+ x:*) oext="$arg" ;;
+ *) break ;;
+ esac
+ shift
+ done
+ rm -f o.* a.*
+ [ "$oanswer" ] && pngtopnm answer/$oanswer.png | $ofilter > o.want
+ [ "$aanswer" ] && pngtopnm -alpha answer/$aanswer.png | $afilter > a.want
+ aopt=
+ if [ -n "$aanswer" ] ; then
+ aopt="-aa.pnm"
+ fi
+ source="$1"
+ shift
+ testrun $TESTFROM/xcf2pnm -@ -oo.$oext $aopt source/$source.xcf.gz "$@"
+ [ -z "$oanswer" ] || cmp o.want o.$oext || failed
+ [ -z "$aanswer" ] || cmp a.want a.pnm || failed
+}
+
+testpng() {
+ ofilter=cat
+ afilter=cat
+ oargs=""
+ aargs=""
+ while true
+ do
+ arg="`echo $1 | cut -c 3-`"
+ case $arg in
+ -pgm) arg="pnmdepth 255" ;;
+ -ppm) arg="pgmtoppm 1,1,1" ;;
+ esac
+ case $1 in
+ O:*) ofilter="$arg" ;;
+ A:*) afilter="$arg" ;;
+ b:*) oargs="-background $arg -mix" ;;
+ B:*) aargs="-background $arg -mix" ;;
+ *) answer="$1" ; shift ; break ;;
+ esac
+ shift
+ done
+ rm -f o.* a.*
+ [ -s pngtype.want ] || perl pngtype.pl < answer/$answer.png > pngtype.want
+ pngtopnm $aargs answer/$answer.png | $ofilter > o.want
+ pngtopnm -alpha answer/$answer.png | $afilter > a.want
+ source="$1"
+ shift
+ testrun $TESTFROM/xcf2png -oo.png source/$source.xcf.gz "$@"
+ perl pngtype.pl < o.png > pngtype
+ diff -u pngtype.want pngtype || failed
+ pngtopnm $oargs o.png > o.pnm
+ cmp o.want o.pnm || failed
+ if [ "$afilter" != : ] ; then
+ pngtopnm -alpha o.png > a.pnm
+ cmp a.want a.pnm || failed
+ fi
+ rm pngtype.want
+}
+rm -f pngtype.want
+
+S=source
+
+cp /dev/null expected.stderr
+
+#############################################################################
+#
+# Use all of the example XCF inputs as checks of xcfinfo
+#
+
+cat <<EOF > expected.stdout
+Version 0, 256x256 Grayscale, 2 layers, compressed RLE
++ 256x256+0+0 Grayscale-alpha Normal Partially transparent
++ 256x256+0+0 Grayscale Normal Background
+EOF
+testinfo $S/comptest.xcf.gz
+
+cat <<EOF > expected.stdout
+Version 0, 64x64 RGB color, 4 layers, compressed RLE
+- 10x10+27+27 RGB-alpha Normal AE=AE
++ 64x64+0+0 RGB-alpha Subtract B
++ 64x64+0+0 RGB-alpha Addition A
+- 64x64+0+0 RGB Normal Background
+EOF
+testinfo $S/modetest.xcf.gz
+
+cat <<EOF > expected.stdout
+Version 1, 64x64 Indexed color, 3 layers, compressed RLE
++ 64x64+0+0 Indexed-alpha Subtract/mask B
++ 64x64+0+0 Indexed-alpha Addition/mask A
+- 64x64+0+0 Indexed Normal Background
+EOF
+testinfo $S/indextest.xcf.gz
+
+cat <<EOF > expected.stdout
+Version 0, 161x161 RGB color, 10 layers, compressed RLE
++ 122x13+19+74 RGB-alpha Normal Long and low
++ 13x122+74+19 RGB-alpha Difference Tall and narrow
++ 118x118+38+47 RGB-alpha Normal/65% Displaced loop
+- 161x161+0+0 RGB-alpha Normal Doodle
++ 161x161+0+0 RGB-alpha Normal Straight loop
++ 50x50+100+105 RGB-alpha Normal/mask Crossed
++ 50x50+8+8 RGB-alpha Normal Mid
++ 50x50+8+102 RGB-alpha Normal/83%/mask Horiz
++ 50x50+101+7 RGB-alpha Normal Vert
++ 161x161+0+0 RGB Normal Background
+EOF
+testinfo $S/tiletest.xcf.gz
+
+cat <<EOF > expected.stdout
+Version 1, 64x64 Indexed color, 1 layers, compressed RLE
++ 64x64+0+0 Indexed Normal Background
+EOF
+testinfo $S/i256.xcf.gz
+testinfo $S/i255.xcf.gz
+
+cp /dev/null expected.stdout
+
+#############################################################################
+#############################################################################
+
+
+#############################################################################
+#
+# comptest.xcf.gz tests primarily that the scaling tables used during
+# flattening are internally consistent, such that two pixels of the
+# same color always composite to that color no matter what the
+# alpha of the upper one is.
+
+testpnm o:comptest comptest
+testpnm o:comptest comptest Background
+
+#############################################################################
+#
+# modetest.xcf.gz is the primary test of the various compositing modes.
+#
+
+testpnm o:Subtract a:modeA modetest
+testpnm o:Addition a:modeB modetest B A -f
+for mode in Multiply Screen Overlay Difference DarkenOnly \
+ LightenOnly Divide Dodge Burn GrainExtract GrainMerge \
+ Hardlight
+do
+ testpnm o:$mode a:modeA modetest A B --mode $mode
+done
+testpnm o:Overlay a:modeA modetest AE=AE A --mode Normal B --mode Softlight
+
+
+#############################################################################
+#
+# tiletest.xcf.gz tests various ways a layer can interact with the
+# tile boundaries, as well as layer selection, masks, global opacity.
+#
+
+testpnm o:tiletest tiletest
+
+#############################################################################
+#
+# Test output format selection for xcf2pnn with and without -f
+#
+
+testpnm o:mono O:-ppm tiletest Background 'Straight loop'
+testpnm o:mono O:-ppm tiletest Background 'Straight loop' -c
+testpnm o:mono O:-pgm tiletest Background 'Straight loop' -g
+testpnm o:mono tiletest Background 'Straight loop' -m
+
+testpnm x:ppm o:mono O:-ppm tiletest Background 'Straight loop'
+testpnm x:pgm o:mono O:-pgm tiletest Background 'Straight loop'
+testpnm x:pbm o:mono tiletest Background 'Straight loop'
+testpnm x:pbm o:mono O:-ppm tiletest Background 'Straight loop' -c
+testpnm o:gray O:-ppm tiletest Background 'Straight loop' 'Long and low'
+testpnm o:gray tiletest Background 'Straight loop' 'Long and low' -g
+
+testpnm o:mono tiletest Background 'Straight loop' -f
+testpnm o:mono O:-ppm tiletest Background 'Straight loop' -f -c
+testpnm o:gray tiletest Background 'Straight loop' 'Long and low' -f
+
+# Test -A flag
+
+testpnm o:mid tiletest -O17,17 -S32x32 Mid
+testpnm o:mid a:mid A:-pgm tiletest -O17,17 -S32x32 Mid
+testpnm o:mid tiletest -O17,17 -S32x32 Mid -f
+testpnm o:mid a:mid tiletest -O17,17 -S32x32 -A
+testpnm o:mid a:mid A:-pgm tiletest -O17,17 -S32x32 Mid
+testpnm o:mid a:mid tiletest -O17,17 -S32x32 -Af
+testpnm o:mid a:mid tiletest -O17,17 -S32x32 Mid -Af
+
+#############################################################################
+#
+# Test indexed images
+#
+
+testpnm o:indextest a:indextest indextest
+testpnm o:Subtract a:modeA indextest -T
+testpnm o:index4 indextest Background
+testpnm o:index256 i256
+
+#############################################################################
+#
+# Various tests of xcf2pnm
+#
+
+testpnm o:burmid tiletest Mid -S 27x25 -O 5,5 -b '#963'
+
+#############################################################################
+#############################################################################
+#
+# Tests of xcf2png
+#
+
+#############################################################################
+#
+# Basic functionality
+#
+
+testpng tiletest tiletest
+testpng modeA modetest A
+
+#############################################################################
+#
+# Output color-format selection
+#
+
+cat <<EOF > common
+161x161x8
+color
+z0 f0 i0
+EOF
+cp common pngtype.want
+testpng O:-ppm mono tiletest Background 'Straight loop'
+cp common pngtype.want
+testpng O:-ppm mono tiletest Background 'Straight loop' -c
+cp common pngtype.want
+testpng O:-ppm mono tiletest Background 'Straight loop' -f -c
+cp common pngtype.want
+testpng O:-ppm gray tiletest Background 'Straight loop' 'Long and low'
+
+cat <<EOF > common
+161x161x8
+gray
+z0 f0 i0
+EOF
+cp common pngtype.want
+testpng O:-pgm mono tiletest Background 'Straight loop' -g
+cp common pngtype.want
+testpng gray tiletest Background 'Straight loop' 'Long and low' -g
+
+cat <<EOF > pngtype.want
+161x161x1
+gray
+z0 f0 i0
+EOF
+testpng mono tiletest Background 'Straight loop' -f
+
+cat <<EOF > pngtype.want
+161x161x8
+color+index
+z0 f0 i0
+PLTE(60)
+ FF FF FF 00 00 00 B6 B6 B6 A1 A1 A1 81 81 81 51 51 51 2E 2E 2E 80 80 80
+ E2 E2 E2 41 41 41 30 30 30 12 12 12 0E 0E 0E 0B 0B 0B 13 13 13 2D 2D 2D
+ 7F 7F 7F 40 40 40 50 50 50 6A 6A 6A
+EOF
+testpng gray tiletest Background 'Straight loop' 'Long and low' -f
+
+#############################################################################
+#
+# Try all combinations of alpha and color modes
+#
+
+# gray
+testpng gray tiletest Background 'Straight loop' 'Long and low' -g
+testpng comptest comptest
+
+# RGB: many of the layer mode tests test this
+
+# gray+alpha
+testpng comptestB comptest 'Partially transparent' -f
+
+# RGB+alpha
+cat <<EOF > pngtype.want
+16x20x8
+color+alpha
+z0 f0 i0
+EOF
+testpng A:-pgm b:0,0,0 crisp1 modetest -S16x20 -O48,46 -c
+
+# gray, one transparent color
+testpng crisp2 comptest -S25x250 -O235,0 -f -g
+
+# RGB, one transparent color
+cat <<EOF > pngtype.want
+16x20x8
+color
+z0 f0 i0
+tRNS(6)
+ 00 01 00 01 00 01
+EOF
+testpng "b:0,0,0" crisp1 modetest -S16x20 -O48,46 -c -f
+
+# index, no transparency: palette selection tests test this
+
+# index, one transparent color
+testpng crisp1 modetest -S16x20 -O48,46 -f
+
+# index, various transparent colors
+testpng modeB modetest B -f
+
+#############################################################################
+#
+# Special tests for palette selection
+#
+
+# monochrome
+testpng mono tiletest Background 'Straight loop' -f
+
+# monochrome with black and white first met in the opposite order.
+testpng mono1 tiletest Background -S65x64 -O63,64 -f
+
+# 1 color plus transparency
+testpng doodle tiletest Doodle -f
+
+# 2 colors
+cat <<EOF > pngtype.want
+161x161x1
+color+index
+z0 f0 i0
+PLTE(6)
+ FF 00 00 EE 6F 00
+EOF
+testpng A:: B:1,0,0 doodle tiletest Doodle -b '#f00' -f
+
+# 2 colors plus transparency
+testpng odoodle tiletest Doodle 'Straight loop' -f
+
+# 3 colors
+cat <<EOF > pngtype.want
+161x161x2
+color+index
+z0 f0 i0
+PLTE(9)
+ 00 00 FF EE 6F 00 FF FF FF
+EOF
+testpng A:: B:0,0,1 odoodle tiletest Doodle 'Straight loop' -fb '#00F'
+
+# 4 colors
+cat <<EOF > pngtype.want
+64x64x2
+color+index
+z0 f0 i0
+PLTE(12)
+ DC 98 85 FF 00 77 10 36 38 FF B4 23
+EOF
+testpng index4 indextest Background -f
+
+# 16 colors, no transparency
+testpng mid tiletest -O17,17 -S32x32 -f
+
+# 17 colors, including a background
+testpng burmid tiletest Mid -O5,5 -S27x25 -b '#963' -f
+
+# 38 colors, original colormap
+testpng index4 indextest Background
+
+# 255 colors, original colormap
+testpng index255 i255
+
+# 255 colors plus transparency
+testpng i255t i255 -O0,2
+testpng i255t i255 -O0,2 -f
+testpng i255tt i255 -O2,0 -f
+perl pngtype.pl < answer/index256.png > pngtype.want
+testpng A:"tr '\377' '\0'" B:"#F4F4F4" i255t i255 -O0,2 -b "#F4F4F4"
+# 255 colors, background already in palette
+perl pngtype.pl < answer/index255.png > pngtype.want
+testpng A:"tr '\3' '\0'" B:"#66CC33" i255tt i255 -O2,0 -b "#6c3"
+
+# 256 colors, original colormap
+testpng index256 i256
+
+# 256 colors, no room for transparency
+cat <<EOF > pngtype.want
+64x64x8
+color+alpha
+z0 f0 i0
+EOF
+testpng A:-pgm index256 i256 -A
+
+#############################################################################
+#
+# Various tests for regression of bugs that slipped through the
+# systematic testing.
+#
+
+# Exotic modes with an opaque layer
+testpnm o:misc1 a:misc1 tiletest Mid Crossed \
+ Background --mode LightenOnly 'Straight loop' -f
+
+#############################################################################
+#
+# Report the final status
+
+echo =======================================================
+if (( failedtests ))
+then
+ echo $failedtests of $totaltests tests FAILED
+ echo =======================================================
+ exit 1
+else
+ echo All $totaltests tests PASSED
+ echo =======================================================
+ exit 0
+fi
+
+# End \ No newline at end of file
diff --git a/test/pngtype.pl b/test/pngtype.pl
new file mode 100644
index 0000000..d7577a8
--- /dev/null
+++ b/test/pngtype.pl
@@ -0,0 +1,58 @@
+use warnings ;
+use strict ;
+
+binmode(STDIN);
+
+my $a ;
+read STDIN,$a,8 ;
+if( $a ne "\x89PNG\x0d\x0a\x1a\x0a" ) {
+ die "Malformed PNG header\n" ;
+}
+sub bv($) {
+ ord(substr($a,$_[0],1)) ;
+}
+sub wv($) {
+ my $a = shift ;
+ return (bv($a) << 24) + (bv($a+1) << 16) + (bv($a+2)<<8) + bv($a+3);
+}
+my %all ;
+while( !eof STDIN ) {
+ read STDIN,$a,4 ;
+ my $len = wv(0);
+ read STDIN,$a,$len+8 ;
+ my $type = substr($a,0,4) ;
+ next if $type eq 'IDAT' ;
+ last if $type eq 'IEND' ;
+ if( $type eq 'IHDR' && $len == 13 ) {
+ print wv(4),"x",wv(8),"x",bv(12),"\n" ;
+ my $cmode = bv(13) ;
+ print $cmode & 3 ? "color" : "gray" ;
+ print "+index" if $cmode & 1 ;
+ print "+alpha" if $cmode & 4 ;
+ print "\nz",bv(14)," f",bv(15)," i",bv(16),"\n" ;
+ next ;
+ }
+ my $aref = ($all{$type} ||= []) ;
+ push @$aref, "$type($len)" ;
+ {
+ my $w = 16 ;
+ $w = 24 if $type eq 'PLTE' ;
+ $w = 8 if $type eq 'tRNS' ;
+ for my $i ( 0 .. $len - 1 ) {
+ push @$aref, sprintf("%s%02X", $i%$w ? " " : "\n ", bv($i+4) ) ;
+ push @$aref, " " if
+ $type eq 'PLTE' &&
+ $i%3 == 2 &&
+ ($i+1)%$w != 0 &&
+ $i != $len-1 ;
+ }
+ push @$aref, "\n" ;
+ }
+}
+for my $k ( sort keys %all ) {
+ print @{$all{$k}} ;
+}
+
+
+
+
diff --git a/test/source/comptest.xcf.gz b/test/source/comptest.xcf.gz
new file mode 100644
index 0000000..4a69918
--- /dev/null
+++ b/test/source/comptest.xcf.gz
Binary files differ
diff --git a/test/source/i255.xcf.gz b/test/source/i255.xcf.gz
new file mode 100644
index 0000000..086bafb
--- /dev/null
+++ b/test/source/i255.xcf.gz
Binary files differ
diff --git a/test/source/i256.xcf.gz b/test/source/i256.xcf.gz
new file mode 100644
index 0000000..38c23c4
--- /dev/null
+++ b/test/source/i256.xcf.gz
Binary files differ
diff --git a/test/source/indextest.xcf.gz b/test/source/indextest.xcf.gz
new file mode 100644
index 0000000..b782acf
--- /dev/null
+++ b/test/source/indextest.xcf.gz
Binary files differ
diff --git a/test/source/mkbase.i b/test/source/mkbase.i
new file mode 100644
index 0000000..ec408ef
--- /dev/null
+++ b/test/source/mkbase.i
@@ -0,0 +1,60 @@
+/* -*- C -*-
+ * This program is written by Henning Makholm, and is in the
+ * public domain.
+ */
+
+#include <png.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+static void
+error(png_structp png_ptr, png_const_charp errormsg)
+{
+ fprintf(stderr,"PNG error: %s\n",errormsg);
+ exit(1);
+}
+
+
+int
+main(void)
+{
+ png_structp libpng = NULL ;
+ png_infop libpng2 = NULL ;
+ unsigned char row[TEST_IMAGE_WIDTH*4] ;
+ unsigned x,y ;
+ int r,g,b,a ;
+
+ libpng = png_create_write_struct(PNG_LIBPNG_VER_STRING,
+ png_voidp_NULL,
+ error,
+ png_error_ptr_NULL);
+ if( !libpng )
+ error(libpng,"Couldn't initialize libpng library");
+
+ libpng2 = png_create_info_struct(libpng);
+ if( !libpng2 )
+ error(libpng,"Couldn't create PNG info structure");
+
+ png_init_io(libpng,stdout);
+
+ png_set_IHDR(libpng,libpng2,TEST_IMAGE_WIDTH,TEST_IMAGE_HEIGHT,
+ 8, PNG_COLOR_TYPE_RGB_ALPHA,
+ PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_DEFAULT,
+ PNG_FILTER_TYPE_DEFAULT);
+
+ png_write_info(libpng,libpng2);
+
+ for( y=0; y<TEST_IMAGE_HEIGHT; y++ ) {
+ for( x=0; x<TEST_IMAGE_WIDTH; x++ ) {
+ makepixel(x,y,&r,&g,&b,&a);
+ row[x*4+0] = r ;
+ row[x*4+1] = g ;
+ row[x*4+2] = b ;
+ row[x*4+3] = a ;
+ }
+ png_write_row(libpng,row);
+ }
+ png_write_end(libpng,libpng2);
+ return 0 ;
+}
diff --git a/test/source/mkgradient256.pl b/test/source/mkgradient256.pl
new file mode 100644
index 0000000..e03912c
--- /dev/null
+++ b/test/source/mkgradient256.pl
@@ -0,0 +1,6 @@
+print "P2 256 256 255\n" ;
+for $y ( 0 .. 255 ) {
+ for $x ( 0 .. 255 ) {
+ print "$x\n" ;
+ }
+}
diff --git a/test/source/mkmodebase.c b/test/source/mkmodebase.c
new file mode 100644
index 0000000..3e5c656
--- /dev/null
+++ b/test/source/mkmodebase.c
@@ -0,0 +1,50 @@
+/* This program is written by Henning Makholm, and is in the
+ * public domain.
+ */
+
+#define TEST_IMAGE_WIDTH 64
+#define TEST_IMAGE_HEIGHT 64
+
+void
+makepixel(int x,int y,int *r,int *g,int *b,int *a) {
+ if( y < 3 || y >= 61 ) {
+ *a = 0 ;
+ return ;
+ }
+ if( x < 3 || x >= 61 ||
+ y < 6 || y >= 58 ) {
+ *r=*g=*b=*a=255 ;
+ return ;
+ }
+ if( x < 6 || x >= 58 ) {
+ *a=0 ;
+ return ;
+ }
+ x -= 6 ;
+ if( x <= 17 ) {
+ *a = x*15 ;
+ *r = 255 ;
+ *g = 0 ;
+ *b = 17*7 ;
+ return ;
+ }
+ *a = 255 ;
+ x -= 17 ;
+ if( x <= 17 ) {
+ *r = 255 ;
+ *g = x*15 ;
+ *b = (17-x)*7 ;
+ return ;
+ }
+ x -= 17 ;
+ if( x <= 17 ) {
+ *r = (17-x)*15 ;
+ *g = 255 ;
+ *b = x*15 ;
+ return ;
+ }
+ *r=255 ;
+ *g=*b=0 ;
+}
+
+#include "mkbase.i"
diff --git a/test/source/mktile0.pl b/test/source/mktile0.pl
new file mode 100644
index 0000000..b932ed0
--- /dev/null
+++ b/test/source/mktile0.pl
@@ -0,0 +1,15 @@
+$L = 64 ;
+print "P3 $L $L 255\n" ;
+for $y ( 0 .. $L-1 ) {
+ for $x ( 0 .. $L-1 ) {
+ $m = int($y / 4)*16 + int($x/4) ;
+ if( $m < 216 ) {
+ print( 51 * ($m % 6), " ",
+ 51 * (int($m/6) % 6), " ",
+ 51 * (int($m/36)), "\n" );
+ } else {
+ $m = ($m-216) * 6 + 10 ;
+ print( "$m $m $m\n" );
+ }
+ }
+}
diff --git a/test/source/mktile1.c b/test/source/mktile1.c
new file mode 100644
index 0000000..50709df
--- /dev/null
+++ b/test/source/mktile1.c
@@ -0,0 +1,35 @@
+/* This program is written by Henning Makholm, and is in the
+ * public domain.
+ */
+
+#define TEST_IMAGE_WIDTH 50
+#define TEST_IMAGE_HEIGHT 50
+
+#include <math.h>
+#include <stdlib.h>
+
+void
+makepixel(int x,int y,int *r,int *g,int *b,int *a) {
+ double yy = 2*(double)y/(TEST_IMAGE_HEIGHT-1) - 1 ;
+ double xx = 2*(double)x/(TEST_IMAGE_WIDTH-1) - 1 ;
+ double rad = sqrt(xx*xx+yy*yy) ;
+ unsigned t = x + abs((y - TEST_IMAGE_HEIGHT/2)) ;
+ t = t / 10 + ((600 + y - TEST_IMAGE_HEIGHT/2) / 10)*77 ;
+ if( rad < 0.9 )
+ *a = 255 ;
+ else if( rad < 1 )
+ *a = 190 ;
+ else if( rad < 1.2 )
+ *a = 73 ;
+ else
+ *a = 0 ;
+
+ t *= 3847822 ;
+ t ^= 29938132 ;
+ t %= 2093847 ;
+ *r = 120 * ((t >> 3) % 3) + 3 ;
+ *g = 120 * ((t >> 7) % 3) + 3 ;
+ *b = 120 * ((t >> 10) % 3) + 3 ;
+}
+
+#include "mkbase.i"
diff --git a/test/source/modetest.xcf.gz b/test/source/modetest.xcf.gz
new file mode 100644
index 0000000..c2d7f8a
--- /dev/null
+++ b/test/source/modetest.xcf.gz
Binary files differ
diff --git a/test/source/tiletest.xcf.gz b/test/source/tiletest.xcf.gz
new file mode 100644
index 0000000..c2fbc45
--- /dev/null
+++ b/test/source/tiletest.xcf.gz
Binary files differ
diff --git a/utils.c b/utils.c
new file mode 100644
index 0000000..d7db8a8
--- /dev/null
+++ b/utils.c
@@ -0,0 +1,164 @@
+/* Generic support functions for Xcftools
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include "xcftools.h"
+#include <string.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <errno.h>
+
+const char *progname = "$0" ;
+int verboseFlag = 0 ;
+
+
+static void __ATTRIBUTE__((noreturn))
+vFatalGeneric(int status,const char *format,va_list args)
+{
+ if( format ) {
+ if( *format == '!' ) {
+ vfprintf(stderr,format+1,args);
+ fprintf(stderr,": %s\n",strerror(errno));
+ } else {
+ vfprintf(stderr,format,args);
+ fputc('\n',stderr);
+ }
+ }
+ exit(status);
+}
+
+void
+FatalGeneric(int status,const char* format,...)
+{
+ va_list v; va_start(v,format);
+ fprintf(stderr,"%s: ",progname);
+ vFatalGeneric(status,format,v);
+}
+
+void
+FatalUnexpected(const char* format,...)
+{
+ va_list v; va_start(v,format);
+ fprintf(stderr,"%s: ",progname);
+ vFatalGeneric(127,format,v) ;
+}
+
+void
+FatalBadXCF(const char* format,...)
+{
+ va_list v; va_start(v,format);
+ fprintf(stderr,"%s: %s:\n ",progname,_("Corrupted or malformed XCF file"));
+ vFatalGeneric(125,format,v) ;
+}
+
+void
+xcfCheckspace(uint32_t addr,int spaceafter,const char *format,...)
+{
+ if( xcf_length < spaceafter || addr > xcf_length - spaceafter ) {
+ va_list v; va_start(v,format);
+ fprintf(stderr,"%s: %s\n ",progname,_("Corrupted or truncated XCF file"));
+ fprintf(stderr,"(%" PRIXPTR " bytes): ",(uintptr_t)xcf_length);
+ vFatalGeneric(125,format,v) ;
+ }
+}
+
+
+void
+FatalUnsupportedXCF(const char* format,...)
+{
+ va_list v; va_start(v,format);
+ fprintf(stderr,"%s: %s\n ",progname,
+ _("The image contains features not understood by this program:"));
+ vFatalGeneric(123,format,v) ;
+}
+
+void
+gpl_blurb(void)
+{
+ fprintf(stderr,PACKAGE_STRING "\n");
+ fprintf(stderr,
+ _("This program is free software; you can modify and distribute it\n"
+ "under the terms of the GNU General Public License, version 2.\n"
+ "There is no warranty for %s.\n\n"),
+ PACKAGE_NAME);
+ fprintf(stderr,
+ _("Type \"%s -h\" to get an option summary.\n"),progname);
+ exit(1) ;
+}
+
+/* ******************************************************* */
+
+void *
+xcfmalloc(size_t size)
+{
+ void *ptr = malloc(size);
+ if( !ptr )
+ FatalUnexpected(_("Out of memory"));
+ return ptr ;
+}
+
+void
+xcffree(void *block)
+{
+ if( xcf_file &&
+ (uint8_t*)block >= xcf_file &&
+ (uint8_t*)block < xcf_file + xcf_length )
+ ;
+ else
+ free(block);
+}
+
+/* ******************************************************* */
+
+FILE *
+openout(const char *name)
+{
+ FILE *newfile ;
+ if( strcmp(name,"-") == 0 )
+ return stdout ;
+ newfile = fopen(name,"wb") ;
+ if( newfile == NULL )
+ FatalUnexpected(_("!Cannot create file %s"),name);
+ return newfile ;
+}
+
+void
+closeout(FILE *f,const char *name)
+{
+ if( f == NULL )
+ return ;
+ if( fflush(f) == 0 ) {
+ errno = 0 ;
+ if( !ferror(f) ) {
+ if( fclose(f) == 0 )
+ return ;
+ } else if( errno == 0 ) {
+ /* Attempt to coax a valid errno out of the standard library,
+ * following an idea by Bruno Haible
+ * http://lists.gnu.org/archive/html/bug-gnulib/2003-09/msg00157.html
+ */
+ if( fputc('\0', f) != EOF &&
+ fflush(f) == 0 )
+ errno = EIO ; /* Argh, everything succeds. Just call it an I/O error */
+ }
+ }
+ FatalUnexpected(_("!Error writing file %s"),name);
+}
+
+
+
+
diff --git a/xcf-general.c b/xcf-general.c
new file mode 100644
index 0000000..c1d7da9
--- /dev/null
+++ b/xcf-general.c
@@ -0,0 +1,273 @@
+/* Generic functions for reading XCF files
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include "xcftools.h"
+#include <string.h>
+#include <errno.h>
+#ifdef HAVE_ICONV
+# include <iconv.h>
+#elif !defined(ICONV_CONST)
+# define ICONV_CONST const
+#endif
+
+uint8_t *xcf_file = 0 ;
+size_t xcf_length ;
+int use_utf8 = 0 ;
+
+uint32_t
+xcfOffset(uint32_t addr,int spaceafter)
+{
+ uint32_t apparent ;
+ xcfCheckspace(addr,4,"(xcfOffset)");
+ apparent = xcfL(addr);
+ xcfCheckspace(apparent,spaceafter,
+ "Too large offset (%" PRIX32 ") at position %" PRIX32,
+ apparent,addr);
+ return apparent ;
+}
+
+int
+xcfNextprop(uint32_t *master,uint32_t *body)
+{
+ uint32_t ptr, length, total, minlength ;
+ PropType type ;
+ ptr = *master ;
+ xcfCheckspace(ptr,8,"(property header)");
+ type = xcfL(ptr);
+ length = xcfL(ptr+4);
+ *body = ptr+8 ;
+ *master = ptr+8+length ;
+ total = 8 + length + (type != PROP_END ? 8 : 0) ;
+ if( total < length ) /* Check overwrap */
+ FatalBadXCF("Overlong property at %" PRIX32, ptr);
+ xcfCheckspace(ptr,total,"Overlong property at %" PRIX32,ptr) ;
+
+ switch(type) {
+ case PROP_COLORMAP: minlength = 4+3*xcfL(ptr+8); break;
+ case PROP_COMPRESSION: minlength = 1; break;
+ case PROP_OPACITY: minlength = 4; break;
+ case PROP_APPLY_MASK: minlength = 4; break;
+ case PROP_OFFSETS: minlength = 8; break;
+ case PROP_MODE: minlength = 4; break;
+ default: minlength = 0; break;
+ }
+ if( length < minlength )
+ FatalBadXCF("Short %s property at %" PRIX32 " (%" PRIu32 "<%" PRIu32 ")",
+ showPropType(type),ptr,length,minlength);
+ return type ;
+}
+
+const char*
+xcfString(uint32_t ptr,uint32_t *after)
+{
+ uint32_t length ;
+ unsigned i ;
+ ICONV_CONST char *utf8master ;
+
+ xcfCheckspace(ptr,4,"(string length)");
+ length = xcfL(ptr) ;
+ ptr += 4 ;
+ xcfCheckspace(ptr,length,"(string)");
+ utf8master = (ICONV_CONST char*)(xcf_file+ptr) ;
+ if( after ) *after = ptr + length ;
+ if( length == 0 || utf8master[length-1] != 0 )
+ FatalBadXCF("String at %" PRIX32 " not zero-terminated",ptr-4);
+ length-- ;
+
+ if( use_utf8 ) return utf8master ;
+
+ /* We assume that the local character set includes ASCII...
+ * Check if conversion is needed at all
+ */
+ for( i=0 ; ; i++ ) {
+ if( i == length )
+ return utf8master ; /* Only ASCII after all */
+ if( utf8master[i] == 0 )
+ FatalBadXCF("String at %" PRIX32 " has embedded zeroes",ptr-4);
+ if( (int8_t) utf8master[i] < 0 )
+ break ;
+ }
+#ifdef HAVE_ICONV
+ {
+ size_t targetsize = length+1 ;
+ int sloppy_translation = 0 ;
+ iconv_t cd = iconv_open("//TRANSLIT","UTF-8");
+ if( cd == (iconv_t) -1 ) {
+ cd = iconv_open("","UTF-8");
+ sloppy_translation = 1 ;
+ }
+ if( cd == (iconv_t) -1 )
+ iconv_close(cd) ; /* Give up; perhaps iconv doesn't know UTF-8 */
+ else
+ while(1) {
+ char *buffer = xcfmalloc(targetsize) ;
+ ICONV_CONST char *inbuf = utf8master ;
+ char *outbuf = buffer ;
+ size_t incount = length ;
+ size_t outcount = targetsize ;
+ while(1) { /* Loop for systems without //ICONV support */
+ size_t result = iconv(cd,&inbuf,&incount,&outbuf,&outcount) ;
+ if( result == (size_t)-1 && errno == EILSEQ &&
+ sloppy_translation && outcount > 0 ) {
+ *outbuf++ = '?' ;
+ outcount-- ;
+ while( (int8_t)*inbuf < 0 ) inbuf++, incount-- ;
+ continue ;
+ }
+ if( result != (size_t)-1 ) {
+ if( outcount == 0 )
+ errno = E2BIG ;
+ else {
+ *outbuf = 0 ;
+ iconv_close(cd) ;
+ return buffer ;
+ }
+ }
+ break ;
+ }
+ if( errno == EILSEQ || errno == EINVAL )
+ FatalBadXCF("Bad UTF-8 encoding '%s' at %" PRIXPTR,
+ inbuf,(uintptr_t)((inbuf-utf8master)+ptr));
+ if( errno == E2BIG ) {
+ targetsize += 1+incount ;
+ xcffree(buffer) ;
+ continue ;
+ }
+ FatalUnexpected("!iconv on layer name at %"PRIX32,ptr);
+ }
+ }
+#endif
+ {
+ static int warned = 0 ;
+ if( !warned ) {
+ fprintf(stderr,_("Warning: one or more layer names could not be\n"
+ " translated to the local character set.\n"));
+ warned = 1 ;
+ }
+ }
+ return utf8master ;
+}
+
+/* ****************************************************************** */
+
+void
+computeDimensions(struct tileDimensions *d)
+{
+ d->c.r = d->c.l + d->width ;
+ d->c.b = d->c.t + d->height ;
+ d->tilesx = (d->width+TILE_WIDTH-1)/TILE_WIDTH ;
+ d->tilesy = (d->height+TILE_HEIGHT-1)/TILE_HEIGHT ;
+ d->ntiles = d->tilesx * d->tilesy ;
+}
+
+struct xcfImage XCF ;
+
+void
+getBasicXcfInfo(void)
+{
+ uint32_t ptr, data, layerfile ;
+ PropType type ;
+ int i ;
+
+ xcfCheckspace(0,14+7*4,"(very short)");
+ if( strcmp((char*)xcf_file,"gimp xcf file") == 0 )
+ XCF.version = 0 ;
+ else if( xcf_file[13] == 0 &&
+ sscanf((char*)xcf_file,"gimp xcf v%d",&XCF.version) == 1 )
+ ;
+ else
+ FatalBadXCF(_("Not an XCF file at all (magic not recognized)"));
+
+ if( XCF.version < 0 || XCF.version > 2 ) {
+ fprintf(stderr,
+ _("Warning: XCF version %d not supported (trying anyway...)\n"),
+ XCF.version);
+ }
+
+ XCF.compression = COMPRESS_NONE ;
+ XCF.colormapptr = 0 ;
+
+ ptr = 14 ;
+ XCF.width = xcfL(ptr); ptr += 4 ;
+ XCF.height = xcfL(ptr); ptr += 4 ;
+ XCF.type = xcfL(ptr); ptr += 4 ;
+ while( (type = xcfNextprop(&ptr,&data)) != PROP_END ) {
+ switch(type) {
+ case PROP_COLORMAP:
+ XCF.colormapptr = data ;
+ break ;
+ case PROP_COMPRESSION:
+ XCF.compression = xcf_file[data] ;
+ break ;
+ default:
+ /* Ignore unknown properties */
+ break ;
+ }
+ }
+
+ layerfile = ptr ;
+ for( XCF.numLayers = 0 ; xcfOffset(ptr,8*4) ; XCF.numLayers++, ptr+=4 )
+ ;
+ XCF.layers = xcfmalloc(XCF.numLayers * sizeof(struct xcfLayer)) ;
+ for( i = 0 ; i < XCF.numLayers ; i++ ) {
+ struct xcfLayer *L = XCF.layers + i ;
+ ptr = xcfL(layerfile+4*(XCF.numLayers-1-i)) ;
+ L->mode = GIMP_NORMAL_MODE ;
+ L->opacity = 255 ;
+ L->isVisible = 1 ;
+ L->hasMask = 0 ;
+ L->dim.width = xcfL(ptr); ptr+=4 ;
+ L->dim.height = xcfL(ptr); ptr+=4 ;
+ L->type = xcfL(ptr); ptr+=4 ;
+ L->name = xcfString(ptr,&ptr);
+ L->propptr = ptr ;
+ while( (type = xcfNextprop(&ptr,&data)) != PROP_END ) {
+ switch(type) {
+ case PROP_OPACITY:
+ L->opacity = xcfL(data);
+ if( L->opacity > 255 )
+ L->opacity = 255 ;
+ break ;
+ case PROP_VISIBLE:
+ L->isVisible = xcfL(data) != 0 ;
+ break ;
+ case PROP_APPLY_MASK:
+ L->hasMask = xcfL(data) != 0 ;
+ break ;
+ case PROP_OFFSETS:
+ L->dim.c.l = (int32_t)(xcfL(data )) ;
+ L->dim.c.t = (int32_t)(xcfL(data+4)) ;
+ break ;
+ case PROP_MODE:
+ L->mode = xcfL(data);
+ break ;
+ default:
+ /* Ignore unknown properties */
+ break ;
+ }
+ }
+ xcfCheckspace(ptr,8,"(end of layer %s)",L->name);
+ L->pixels.tileptrs = 0 ;
+ L->pixels.hierarchy = xcfOffset(ptr ,4*4);
+ L->mask.tileptrs = 0 ;
+ L->mask.hierarchy = xcfOffset(ptr+4,4*4);
+
+ computeDimensions(&L->dim);
+ }
+}
+
diff --git a/xcf2png.10 b/xcf2png.10
new file mode 100644
index 0000000..06312c0
--- /dev/null
+++ b/xcf2png.10
@@ -0,0 +1,161 @@
+\." Manual page for xcf2png
+\." Copyright (C) 2006 Henning Makholm
+\."
+\." This program is free software; you can redistribute it and/or modify
+\." it under the terms of version 2 of the GNU General Public License as
+\." published by the Free Software Foundation.
+\."
+\." 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
+.TH xcf2png 1 2006-01-25 "Xcftools" ""
+.SH NAME
+xcf2png \- convert from GIMP xcf files to png format
+.SH SYNOPSIS
+.B xcf2png
+[
+.I options
+]
+.I filename
+[
+.I layer names
+]
+.SH DESCRIPTION
+.B xcf2png
+is a command-line tool that converts image files in the XCF format used by
+.BR gimp (1)
+to the generic image format
+.BR png ,
+.BR ppm (5),
+flattening layers if necessary. It does not need to have
+the Gimp engine itself available.
+.SH GENERAL OPTIONS
+.so xcf2png.1i
+.P
+Several groups of options are mutually incompatible; in each group the
+one given last will win:
+.TP 4
+1)
+.B \-A
+and
+.BR \-b .
+.TP
+2)
+.BR \-g and
+.BR \-m .
+.TP
+3)
+.B \-D
+and
+.BR \-G .
+.TP
+4)
+.BR \-j ,
+.BR \-z ,
+and
+.BR \-Z .
+.SH LAYER SPECIFICATIONS
+If no
+.I layer name
+is given on the command line, all of the visible layers in
+the XCF file are merged to produce the output image.
+It is also possible to specify the layers to merge explicitly,
+by giving their names as separate arguments after the
+input filename. In that case, the output will contain
+.I only
+the named layers. The layers will be merged in the order
+they appear on the command line, with the leftmost being
+"at the bottom" \- that is, the layer ordering in the XCF file
+will be ignored.
+.P
+The following options can be given
+.I after
+a layer name to override the global properties of the layer:
+.so xcf2png.1il
+.SH EXIT STATUS
+The exit status of
+.B xcf2png
+is
+.TP 5
+0
+Success
+.TP
+20
+Problems parsing the command line, including unknown color names
+(or missing color name directory) for
+.BR \-b .
+.TP
+21
+The specified XCF file does not exist or cannot be read.
+.TP
+22
+A layer named on the command line was not found, or the
+.B --mask
+option was used for a layer that has no layer mask.
+.TP
+102
+The
+.B \-G
+option was given, yet partial transparency was found.
+.TP
+103
+.B \-g
+was given, yet colored
+pixels were found.
+.TP
+123
+The XCF file contains presumably valid features that
+.B xcftools
+does not support. (Certain layer modes, for example, cause
+this return).
+.TP
+125
+The XCF file is malformed.
+.TP
+126
+An uncompression program could not be executed or terminated
+abnormally.
+.TP
+127
+Unexpected I/O error, internal errors, or other "this can't happen"
+situations.
+.P
+If an uncompression program returns an error exit status, this will
+be returned from
+.B xcf2png
+too.
+.SH BUGS AND LIMITATIONS
+.P
+When several partially transparent layers are merged, the pixel
+values are interpolated without gamma correction. (The Gimp also
+does it this way). Some slight rounding errors in the interpolation
+are inevitable;
+.B xcf2png
+sometimes have different rounding errors than the Gimp itself,
+especially when more than two layers are involved, or in case of
+some of the more exotic layer modes.
+These differences are usually not visible to the eye.
+.P
+A few particularly exotic layer modes (which work in HSV space rather
+than RGB space) are not currently implemented.
+.P
+There are probably other bugs lurking in corner cases. If you discover
+one, please notify the author.
+
+.SH FILES
+.TP 8
+.B /usr/lib/X11/rgb.txt
+Color name database for
+.BR \-b .
+.SH AUTHOR
+.B xcf2pnm
+was written by Henning Makholm <henning@makholm.net>
+.P
+.SH SEE ALSO
+.BR xcfinfo (1),
+.BR xcf2pnm (1)
diff --git a/xcf2png.c b/xcf2png.c
new file mode 100644
index 0000000..025b148
--- /dev/null
+++ b/xcf2png.c
@@ -0,0 +1,426 @@
+/* Convert xcf files to png
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include "xcftools.h"
+#include "flatten.h"
+#include "palette.h"
+#include <png.h>
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include <ctype.h>
+#if HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include <unistd.h>
+#endif
+#ifndef HAVE_GETOPT_LONG
+#define getopt_long(argc,argv,optstring,l1,l2) getopt(argc,argv,optstring)
+#endif
+
+#include "xcf2png.oi"
+
+static void
+usage(FILE *where)
+{
+ fprintf(where,_("Usage: %s [options] filename.xcf[.gz] [layers]\n"),
+ progname) ;
+ fprintf(where,_("Options:\n"));
+ opt_usage(where);
+ if( where == stderr ) {
+ exit(1);
+ }
+}
+
+static struct FlattenSpec flatspec ;
+
+static FILE *outfile = NULL ;
+static png_structp libpng = NULL ;
+static png_infop libpng2 = NULL ;
+
+static void
+my_error_callback(png_structp png_ptr, png_const_charp errormsg)
+{
+ FatalUnexpected(_("Libpng error '%s'"),errormsg);
+}
+
+
+static void
+init_output(void)
+{
+ int bit_depth ;
+ int color_type ;
+ int invert_mono = 0 ;
+ png_colorp pngpalette = NULL ;
+ png_bytep ptrans = NULL ;
+
+ outfile = openout(flatspec.output_filename);
+ libpng = png_create_write_struct(PNG_LIBPNG_VER_STRING,
+ png_voidp_NULL,
+ my_error_callback,
+ png_error_ptr_NULL);
+ if( !libpng )
+ FatalUnexpected(_("Couldn't initialize libpng library"));
+
+ libpng2 = png_create_info_struct(libpng);
+ if( !libpng2 )
+ FatalUnexpected("Couldn't create PNG info structure");
+
+ png_init_io(libpng,outfile);
+
+ bit_depth = 8;
+ switch( flatspec.out_color_mode ) {
+ case COLOR_GRAY:
+ if( flatspec.default_pixel == PERHAPS_ALPHA_CHANNEL ||
+ flatspec.default_pixel == FORCE_ALPHA_CHANNEL )
+ color_type = PNG_COLOR_TYPE_GRAY_ALPHA ;
+ else
+ color_type = PNG_COLOR_TYPE_GRAY ;
+ break ;
+ case COLOR_RGB:
+ if( flatspec.default_pixel == PERHAPS_ALPHA_CHANNEL ||
+ flatspec.default_pixel == FORCE_ALPHA_CHANNEL )
+ color_type = PNG_COLOR_TYPE_RGB_ALPHA ;
+ else
+ color_type = PNG_COLOR_TYPE_RGB ;
+ break ;
+ case COLOR_INDEXED:
+ if( paletteSize == 2 &&
+ palette[0] == NEWALPHA(0,255) &&
+ palette[1] == NEWALPHA(-1,255) ) {
+ color_type = PNG_COLOR_TYPE_GRAY ;
+ bit_depth = 1 ;
+ } else if( paletteSize == 2 &&
+ palette[0] == NEWALPHA(-1,255) &&
+ palette[1] == NEWALPHA(0,255) ) {
+ color_type = PNG_COLOR_TYPE_GRAY ;
+ bit_depth = 1 ;
+ invert_mono = 1 ;
+ } else {
+ unsigned i ;
+ int need_trans = 0 ;
+ color_type = PNG_COLOR_TYPE_PALETTE ;
+ pngpalette = xcfmalloc(paletteSize*sizeof(png_color)) ;
+ ptrans = xcfmalloc(paletteSize);
+ for(i = 0; i<paletteSize; i++ ) {
+ pngpalette[i].red = 255 & (palette[i] >> RED_SHIFT);
+ pngpalette[i].green = 255 & (palette[i] >> GREEN_SHIFT);
+ pngpalette[i].blue = 255 & (palette[i] >> BLUE_SHIFT);
+ if( (ptrans[i] = ALPHA(palette[i])) != 255 )
+ need_trans = 1 ;
+ }
+ if( !need_trans ) {
+ xcffree(ptrans);
+ ptrans = NULL ;
+ }
+ if( paletteSize <= 2 )
+ bit_depth = 1 ;
+ else if( paletteSize <= 4 )
+ bit_depth = 2 ;
+ else if( paletteSize <= 16 )
+ bit_depth = 4 ;
+ else
+ bit_depth = 8;
+ }
+ break ;
+ default:
+ FatalUnexpected("This can't happen (unknown out_color_mode)");
+ }
+
+ if( verboseFlag ) {
+ fprintf(stderr,"Writing PNG: %s%s%s%s, %d bits",
+ color_type & PNG_COLOR_MASK_COLOR ? _("color") : _("grayscale"),
+ color_type & PNG_COLOR_MASK_PALETTE ? _("+palette") : "",
+ color_type & PNG_COLOR_MASK_ALPHA ? _("+alpha") : "",
+ ptrans || NULLALPHA(flatspec.default_pixel)
+ ? _("+transparency") : "",
+ bit_depth);
+ if( pngpalette )
+ fprintf(stderr,_(" (%d colors)"),paletteSize);
+ fprintf(stderr,"\n");
+ }
+
+ png_set_IHDR(libpng,libpng2,flatspec.dim.width,flatspec.dim.height,
+ bit_depth, color_type,
+ PNG_INTERLACE_NONE,
+ PNG_COMPRESSION_TYPE_DEFAULT,
+ PNG_FILTER_TYPE_DEFAULT);
+
+ if( invert_mono )
+ png_set_invert_mono(libpng);
+
+ if( pngpalette )
+ png_set_PLTE(libpng,libpng2,pngpalette,paletteSize);
+ if( ptrans )
+ png_set_tRNS(libpng,libpng2,ptrans,paletteSize,NULL);
+ else if ( !pngpalette &&
+ NULLALPHA(flatspec.default_pixel) ) {
+ static png_color_16 trans ;
+ trans.gray =
+ trans.red = 255 & (flatspec.default_pixel >> RED_SHIFT) ;
+ trans.green = 255 & (flatspec.default_pixel >> GREEN_SHIFT) ;
+ trans.blue = 255 & (flatspec.default_pixel >> BLUE_SHIFT) ;
+ png_set_tRNS(libpng,libpng2,NULL,0,&trans);
+ }
+
+ /* png_set_text here */
+
+ png_write_info(libpng,libpng2);
+
+ if( bit_depth < 8 )
+ png_set_packing(libpng);
+
+ switch( color_type ) {
+ case PNG_COLOR_TYPE_RGB:
+ case PNG_COLOR_TYPE_RGBA:
+#if (BLUE_SHIFT < RED_SHIFT) == !defined(WORDS_BIGENDIAN)
+ png_set_bgr(libpng);
+#endif
+ if( color_type == PNG_COLOR_TYPE_RGB )
+#if (ALPHA_SHIFT < RED_SHIFT) == !defined(WORDS_BIGENDIAN)
+ png_set_filler(libpng,0,PNG_FILLER_BEFORE);
+ else
+ png_set_swap_alpha(libpng);
+#else
+ png_set_filler(libpng,0,PNG_FILLER_AFTER);
+#endif
+ break ;
+ case PNG_COLOR_TYPE_GRAY:
+ png_set_filler(libpng,0,PNG_FILLER_AFTER);
+ break ;
+ case PNG_COLOR_TYPE_GRAY_ALPHA:
+ case PNG_COLOR_TYPE_PALETTE:
+ break ;
+ default:
+ FatalUnexpected("This can't happen (unexpected png color_type)");
+ }
+}
+
+
+static void
+raw_callback(unsigned num, rgba *pixels) {
+ if( libpng == NULL ) {
+ init_output() ;
+ }
+ png_write_row(libpng,(png_bytep)pixels);
+ xcffree(pixels);
+}
+
+static void
+graying_callback(unsigned num, rgba *pixels) {
+ png_bytep fillptr = (uint8_t *)pixels ;
+ unsigned i ;
+ for( i = 0 ; i < num ; i++ ) {
+ rgba pixel = pixels[i] ;
+ int g = degrayPixel(pixel) ;
+ if( g == -1 )
+ FatalGeneric(103,
+ _("Grayscale output selected, but colored pixel(s) found"));
+ *fillptr++ = g ;
+ *fillptr++ = ALPHA(pixel) ;
+ }
+ raw_callback(num,pixels);
+}
+
+static void
+optimistic_palette_callback(unsigned num,rgba *pixels) {
+ unsigned prev_size = paletteSize ;
+ if( !palettify_row(pixels,num) || paletteSize != prev_size )
+ FatalUnexpected("Oops! Somehow the precomputed palette does not suffice "
+ "after all...");
+ raw_callback(num,pixels);
+}
+
+static enum out_color_mode
+guessIndexed(struct FlattenSpec *spec,rgba *allPixels[])
+{
+ if( allPixels == NULL ) {
+ if (spec->gimpish_indexed && colormapLength ) {
+ unsigned i ;
+ init_palette_hash();
+ for( i=0; i<colormapLength; i++ )
+ lookup_or_intern(NEWALPHA(colormap[i],255));
+ if( lookup_or_intern( FULLALPHA(spec->default_pixel) ?
+ spec->default_pixel : 0 ) >= 0 )
+ return COLOR_INDEXED ;
+ }
+ } else {
+ init_palette_hash() ;
+ if( palettify_rows(allPixels,spec->dim.width,spec->dim.height) ) {
+ /* Might grayscale sometimes be preferred? No, that is what
+ * -g is for! */
+ return COLOR_INDEXED ;
+ }
+ }
+ return COLOR_BY_CONTENTS ;
+}
+
+static lineCallback
+selectCallback(void)
+{
+ switch( flatspec.out_color_mode ) {
+ default:
+ case COLOR_RGB: return &raw_callback ;
+ case COLOR_GRAY: return &graying_callback ;
+ case COLOR_INDEXED:
+ if( flatspec.process_in_memory )
+ return &raw_callback ;
+ else
+ return &optimistic_palette_callback ;
+ }
+}
+
+/* findUnusedColor() will prefer to find a gray pixel */
+static rgba
+findUnusedColor(rgba *pixels[],unsigned width,unsigned height)
+{
+ size_t freqtab[256] ;
+ unsigned x,y ;
+ unsigned i,j ;
+ rgba sofar ;
+
+ for( i=0; i<256; i++ )
+ freqtab[i] = 0 ;
+ for( y=0; y<height; y++ )
+ for( x=0; x<width; x++ )
+ if( pixels[y][x] )
+ freqtab[255 & (pixels[y][x] >> RED_SHIFT)] ++ ;
+ j = 0 ;
+ for( i=0; i<256; i++ ) {
+ if( freqtab[i] == 0 ) {
+ return ((rgba)i << RED_SHIFT) +
+ ((rgba)i << GREEN_SHIFT) +
+ ((rgba)i << BLUE_SHIFT) +
+ ((rgba)255 << ALPHA_SHIFT) ;
+ }
+ if( freqtab[i] < freqtab[j] ) {
+ j = i ;
+ }
+ }
+ sofar = ((rgba)255<<ALPHA_SHIFT) + ((rgba)j << RED_SHIFT) ;
+
+ for( i=0; i<256; i++ )
+ freqtab[i] = 0 ;
+ for( y=0; y<height; y++ )
+ for( x=0; x<width; x++ )
+ if( ((((rgba)255 << ALPHA_SHIFT) + ((rgba)255 << RED_SHIFT))
+ & pixels[y][x]) == sofar )
+ freqtab[255 & (pixels[y][x] >> GREEN_SHIFT)] ++ ;
+ j = 0 ;
+ for( i=0; i<256; i++ ) {
+ if( freqtab[i] == 0 ) {
+ return sofar + ((rgba)i << GREEN_SHIFT);
+ }
+ if( freqtab[i] < freqtab[j] ) {
+ j = i ;
+ }
+ }
+ sofar += (rgba)j << GREEN_SHIFT ;
+
+ for( i=0; i<256; i++ )
+ freqtab[i] = 0 ;
+ for( y=0; y<height; y++ )
+ for( x=0; x<width; x++ )
+ if( ((((rgba)255 << ALPHA_SHIFT) +
+ ((rgba)255 << RED_SHIFT) +
+ ((rgba)255 << GREEN_SHIFT))
+ & pixels[y][x]) == sofar )
+ freqtab[255 & (pixels[y][x] >> BLUE_SHIFT)] ++ ;
+ for( i=0; i<256; i++ ) {
+ if( freqtab[i] == 0 ) {
+ return sofar + ((rgba)i << BLUE_SHIFT);
+ }
+ }
+
+ return 0 ;
+}
+
+int
+main(int argc,char **argv)
+{
+ int option ;
+ const char *unzipper = NULL ;
+ const char *infile = NULL ;
+
+ setlocale(LC_ALL,"");
+ progname = argv[0] ;
+
+ if( argc <= 1 ) gpl_blurb() ;
+
+ init_flatspec(&flatspec) ;
+ while( (option=getopt_long(argc,argv,"-"OPTSTRING,longopts,NULL)) >= 0 )
+ switch(option) {
+ #define OPTION(char,long,desc,man) case char:
+ #include "options.i"
+ case 1:
+ if( infile )
+ add_layer_request(&flatspec,optarg);
+ else
+ infile = optarg ;
+ break ;
+ case '?':
+ usage(stderr);
+ default:
+ FatalUnexpected("Getopt(_long) unexpectedly returned '%c'",option);
+ }
+ if( infile == NULL ) {
+ usage(stderr);
+ }
+
+ read_or_mmap_xcf(infile,unzipper);
+ getBasicXcfInfo() ;
+ initColormap();
+
+ complete_flatspec(&flatspec,guessIndexed);
+ if( flatspec.process_in_memory ) {
+ rgba **allPixels = flattenAll(&flatspec);
+
+ analyse_colormode(&flatspec,allPixels,guessIndexed);
+
+ /* See if we can do alpha compaction.
+ */
+ if( flatspec.partial_transparency_mode != ALLOW_PARTIAL_TRANSPARENCY &&
+ !FULLALPHA(flatspec.default_pixel) &&
+ flatspec.out_color_mode != COLOR_INDEXED ) {
+ rgba unused = findUnusedColor(allPixels,
+ flatspec.dim.width,
+ flatspec.dim.height);
+ if( unused && (flatspec.out_color_mode == COLOR_RGB ||
+ degrayPixel(unused) >= 0) ) {
+ unsigned x,y ;
+ unused = NEWALPHA(unused,0) ;
+ for( y=0; y<flatspec.dim.height; y++)
+ for( x=0; x<flatspec.dim.width; x++)
+ if( allPixels[y][x] == 0 )
+ allPixels[y][x] = unused ;
+ flatspec.default_pixel = unused ;
+ }
+ }
+ shipoutWithCallback(&flatspec,allPixels,selectCallback());
+ } else {
+ flattenIncrementally(&flatspec,selectCallback());
+ }
+ if( libpng ) {
+ png_write_end(libpng,libpng2);
+ png_destroy_write_struct(&libpng,&libpng2);
+ }
+ if( outfile ) {
+ closeout(outfile,flatspec.output_filename);
+ }
+ return 0 ;
+}
diff --git a/xcf2pnm.10 b/xcf2pnm.10
new file mode 100644
index 0000000..311bef8
--- /dev/null
+++ b/xcf2pnm.10
@@ -0,0 +1,199 @@
+\." Manual page for xcf2pnm
+\." Copyright (C) 2006 Henning Makholm
+\."
+\." This program is free software; you can redistribute it and/or modify
+\." it under the terms of version 2 of the GNU General Public License as
+\." published by the Free Software Foundation.
+\."
+\." 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
+.TH xcf2pnm 1 2006-01-22 "Xcftools" ""
+.SH NAME
+xcf2pnm \- convert from GIMP xcf files to ppm/pgm/pbm format
+.SH SYNOPSIS
+.B xcf2pnm
+[
+.I options
+]
+.I filename
+[
+.I layer names
+]
+.SH DESCRIPTION
+.B xcf2pnm
+is a command-line tool that converts image files in the XCF format used by
+.BR gimp (1)
+to the generic image formats
+.BR pbm (5),
+.BR pgm (5),
+and
+.BR ppm (5),
+flattening layers if necessary. It does not need to have
+the Gimp engine itself available.
+.SH GENERAL OPTIONS
+.so xcf2pnm.1i
+.P
+Several groups of options are mutually incompatible; in each group the
+one given last will win:
+.TP 4
+1)
+.B \-A
+and
+.BR \-b .
+.TP
+2)
+.BR \-c ,
+.BR \-g ,
+.BR \-m ,
+and
+.BR \-n .
+.TP
+3)
+.B \-D
+and
+.BR \-G .
+.TP
+4)
+.BR \-j ,
+.BR \-z ,
+and
+.BR \-Z .
+.SH LAYER SPECIFICATIONS
+If no
+.I layer name
+is given on the command line, all of the visible layers in
+the XCF file are merged to produce the output image.
+It is also possible to specify the layers to merge explicitly,
+by giving their names as separate arguments after the
+input filename. In that case, the output will contain
+.I only
+the named layers. The layers will be merged in the order
+they appear on the command line, with the leftmost being
+"at the bottom" \- that is, the layer ordering in the XCF file
+will be ignored.
+.P
+The following options can be given
+.I after
+a layer name to override the global properties of the layer:
+.so xcf2pnm.1il
+.SH EXIT STATUS
+The exit status of
+.B xcf2pnm
+is
+.TP 5
+0
+Success
+.TP
+20
+Problems parsing the command line, including unknown color names
+(or missing color name directory) for
+.BR \-b .
+.TP
+21
+The specified XCF file does not exist or cannot be read.
+.TP
+22
+A layer named on the command line was not found, or the
+.B --mask
+option was used for a layer that has no layer mask.
+.TP
+100
+For
+.BR xcf2pnm ,
+transparent pixels were found, but neither
+.B \-a
+nor
+.B \-b
+was given.
+.TP
+101
+The
+.B \-a
+option was given yet the image has no transparency.
+(Use
+.B \-A
+to go on anyway).
+.TP
+102
+The
+.B \-G
+option was given, yet partial transparency was found.
+.TP
+103
+.B \-g
+(or
+.BR \-m )
+was given, yet colored (or gray) pixels were found.
+.TP
+123
+The XCF file contains presumably valid features that
+.B xcftools
+does not support. (Certain layer modes, for example, cause
+this return).
+.TP
+125
+The XCF file is malformed.
+.TP
+126
+An uncompression program could not be executed or terminated
+abnormally.
+.TP
+127
+Unexpected I/O error, internal errors, or other "this can't happen"
+situations.
+.P
+If an uncompression program returns an error exit status, this will
+be returned from
+.B xcf2pnm
+too.
+.SH EXAMPLES
+.IP
+.B xcf2pnm -b white foo.xcf > foo.ppm
+.IP
+.B xcf2pnm -a footrans.pgm -o foo.ppm foo.xcf Layer1 Layer2
+.P
+To test whether the flattened image has any transparency, use
+.IP
+.B xcf2pnm foo.xcf > /dev/null
+.P
+To test whether the flattened image has
+.I partially
+transparent pixels, use
+.IP
+.B xcf2pnm -b white -G > /dev/null
+.SH BUGS AND LIMITATIONS
+.P
+When several partially transparent layers are merged, the pixel
+values are interpolated without gamma correction. (The Gimp also
+does it this way). Some slight rounding errors in the interpolation
+are inevitable;
+.B xcf2pnm
+sometimes have different rounding errors than the Gimp itself,
+especially when more than two layers are involved, or in case of
+some of the more exotic layer modes.
+These differences are usually not visible to the eye.
+.P
+A few particularly exotic layer modes (which work in HSV space rather
+than RGB space) are not currently implemented.
+.P
+There are probably other bugs lurking in corner cases. If you discover
+one, please notify the author.
+
+.SH FILES
+.TP 8
+.B /usr/lib/X11/rgb.txt
+Color name database for
+.BR \-b .
+.SH AUTHOR
+.B xcf2pnm
+was written by Henning Makholm <henning@makholm.net>
+.P
+.SH SEE ALSO
+.BR xcfinfo (1),
+.BR xcf2png (1)
diff --git a/xcf2pnm.c b/xcf2pnm.c
new file mode 100644
index 0000000..f13c306
--- /dev/null
+++ b/xcf2pnm.c
@@ -0,0 +1,271 @@
+/* Convert xcf files to ppm
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include "xcftools.h"
+#include "flatten.h"
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#include <ctype.h>
+#if HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include <unistd.h>
+#endif
+#ifndef HAVE_GETOPT_LONG
+#define getopt_long(argc,argv,optstring,l1,l2) getopt(argc,argv,optstring)
+#endif
+
+#include "xcf2pnm.oi"
+
+static void
+usage(FILE *where)
+{
+ fprintf(where,_("Usage: %s [options] filename.xcf[.gz] [layers]\n"),
+ progname) ;
+ fprintf(where,_("Options:\n"));
+ opt_usage(where);
+ if( where == stderr ) {
+ exit(1);
+ }
+}
+
+static int suppress_byline ;
+static struct FlattenSpec flatspec ;
+static FILE *outfile = NULL ;
+static FILE *transfile = NULL ;
+
+static void
+start_writing(FILE **f,int version)
+{
+ const char *format[] = {"(format zero)",
+ "PBM-ascii",
+ "PGM-ascii",
+ "PPM-ascii",
+ "PBM",
+ "PGM",
+ "PPM" };
+
+ if( verboseFlag )
+ fprintf(stderr,f == &outfile ? _("Writing converted image as %s\n")
+ : _("Writing transparency map as %s\n"),
+ format[version]);
+
+ *f = openout( f == &outfile ? flatspec.output_filename
+ : flatspec.transmap_filename );
+ fprintf(*f,"P%d",version);
+ if( suppress_byline )
+ ;
+ else if( f == &outfile )
+ fprintf(*f,_(" # Converted by xcf2pnm %s"),PACKAGE_VERSION);
+ else
+ fprintf(*f,_(" # Transparency map by xcf2pnm %s"),PACKAGE_VERSION);
+ fprintf(*f,"\n%d %d\n%s",
+ flatspec.dim.width,
+ flatspec.dim.height,
+ version == 4 ? "" : "255\n");
+}
+
+int
+put_pbm_row(FILE *file,unsigned num,rgba *pixels,rgba mask) {
+ unsigned out ;
+ unsigned i ;
+ int bitsleft = 8 ;
+ out = 0 ;
+ for( i=0; i<num; i++ ) {
+ out <<= 1 ;
+ if( (pixels[i] & mask) == 0 )
+ out++ ; /* 1 is black */
+ else if( (pixels[i] & mask) == mask )
+ ; /* 0 is white */
+ else
+ return 0 ;
+ if( --bitsleft == 0 ) {
+ putc( out, file );
+ out = 0 ;
+ bitsleft = 8 ;
+ }
+ }
+ if( bitsleft < 8 )
+ putc( out << bitsleft, file );
+ return 1 ;
+}
+
+static void
+callback_common(unsigned num,rgba *pixels)
+{
+ if( flatspec.transmap_filename ) {
+ if( flatspec.partial_transparency_mode == ALLOW_PARTIAL_TRANSPARENCY ) {
+ unsigned i ;
+ if( transfile == NULL ) start_writing(&transfile,5);
+ for( i=0; i < num; i++ )
+ putc( ALPHA(pixels[i]), transfile );
+ } else {
+ if( transfile == NULL ) {
+ start_writing(&transfile,4);
+ }
+ /* Partial transparency should have been caught in the flattener,
+ * so just extract a single byte.
+ */
+ put_pbm_row(transfile,num,pixels,(rgba)1 << ALPHA_SHIFT);
+ }
+ } else if( !FULLALPHA(flatspec.default_pixel) ) {
+ unsigned i ;
+ for( i=0; i < num; i++ )
+ if( !FULLALPHA(pixels[i]) )
+ FatalGeneric(100,_("Transparency found, but -a option not given"));
+ }
+ xcffree(pixels) ;
+}
+
+static void
+ppm_callback(unsigned num,rgba *pixels)
+{
+ unsigned i ;
+ if( outfile == NULL ) start_writing(&outfile,6);
+ for( i=0; i < num; i++ ) {
+ putc( (pixels[i] >> RED_SHIFT) & 0xFF , outfile );
+ putc( (pixels[i] >> GREEN_SHIFT) & 0xFF , outfile );
+ putc( (pixels[i] >> BLUE_SHIFT) & 0xFF , outfile );
+ }
+ callback_common(num,pixels);
+}
+
+static void
+pgm_callback(unsigned num,rgba *pixels)
+{
+ unsigned i ;
+ if( outfile == NULL ) start_writing(&outfile,5);
+ for( i=0; i < num; i++ ) {
+ int gray = degrayPixel(pixels[i]) ;
+ if( gray == -1 )
+ FatalGeneric(103,
+ _("Grayscale output selected, but colored pixel(s) found %d=%x"),i,pixels[i] /*XXX*/);
+ putc( gray, outfile );
+ }
+ callback_common(num,pixels);
+}
+
+static void
+pbm_callback(unsigned num,rgba *pixels)
+{
+ if( outfile == NULL ) start_writing(&outfile,4);
+ if( !put_pbm_row(outfile,num,pixels,
+ ((rgba)255 << RED_SHIFT) +
+ ((rgba)255 << GREEN_SHIFT) +
+ ((rgba)255 << BLUE_SHIFT)) )
+ FatalGeneric(103,_("Monochrome output selected, but not all pixels "
+ "are black or white"));
+ callback_common(num,pixels);
+}
+
+static enum out_color_mode
+guess_color_mode(const char *string)
+{
+ if( strlen(string) >= 3 ) {
+ string += strlen(string)-3 ;
+ if( strcmp(string,"ppm")==0 ) return COLOR_RGB ;
+ if( strcmp(string,"pgm")==0 ) return COLOR_GRAY ;
+ if( strcmp(string,"pbm")==0 ) return COLOR_MONO ;
+ }
+ return COLOR_BY_FILENAME ;
+}
+
+static lineCallback
+selectCallback(void)
+{
+ if( flatspec.transmap_filename && FULLALPHA(flatspec.default_pixel) )
+ FatalGeneric(101,_("The -a option was given, "
+ "but the image has no transparency"));
+
+ switch( flatspec.out_color_mode ) {
+ default:
+ case COLOR_RGB: return &ppm_callback ;
+ case COLOR_GRAY: return &pgm_callback ;
+ case COLOR_MONO: return &pbm_callback ;
+ }
+}
+
+int
+main(int argc,char **argv)
+{
+ int option ;
+ const char *unzipper = NULL ;
+ const char *infile = NULL ;
+
+ setlocale(LC_ALL,"");
+ progname = argv[0] ;
+
+ if( argc <= 1 ) gpl_blurb() ;
+
+ init_flatspec(&flatspec) ;
+ flatspec.out_color_mode = COLOR_BY_FILENAME ;
+ while( (option=getopt_long(argc,argv,"-@"OPTSTRING,longopts,NULL)) >= 0 )
+ switch(option) {
+ #define OPTION(char,long,desc,man) case char:
+ #include "options.i"
+ case 1:
+ if( infile )
+ add_layer_request(&flatspec,optarg);
+ else
+ infile = optarg ;
+ break ;
+ case '?':
+ usage(stderr);
+ case '@':
+ /* Non-documented option for build-time test */
+ suppress_byline = 1 ;
+ break ;
+ default:
+ FatalUnexpected("Getopt(_long) unexpectedly returned '%c'",option);
+ }
+ if( infile == NULL ) {
+ usage(stderr);
+ }
+
+ if( flatspec.out_color_mode == COLOR_BY_FILENAME &&
+ strlen(flatspec.output_filename) > 4 &&
+ flatspec.output_filename[strlen(flatspec.output_filename)-4] == '.' )
+ flatspec.out_color_mode = guess_color_mode(flatspec.output_filename);
+
+ /* If the output filename was not enough cue, see if we're running
+ * through a symlink/hardlink that gives the required output format
+ */
+ if( flatspec.out_color_mode == COLOR_BY_FILENAME &&
+ strlen(progname) > 3 )
+ flatspec.out_color_mode = guess_color_mode(progname);
+
+ if( flatspec.out_color_mode == COLOR_BY_FILENAME )
+ flatspec.out_color_mode = COLOR_BY_CONTENTS ;
+
+ read_or_mmap_xcf(infile,unzipper);
+ getBasicXcfInfo() ;
+ initColormap();
+
+ complete_flatspec(&flatspec,NULL);
+ if( flatspec.process_in_memory ) {
+ rgba **allPixels = flattenAll(&flatspec);
+ analyse_colormode(&flatspec,allPixels,NULL);
+ shipoutWithCallback(&flatspec,allPixels,selectCallback());
+ } else {
+ flattenIncrementally(&flatspec,selectCallback());
+ }
+ closeout(outfile,flatspec.output_filename) ;
+ closeout(transfile,flatspec.transmap_filename) ;
+ return 0 ;
+}
diff --git a/xcfinfo.10 b/xcfinfo.10
new file mode 100644
index 0000000..f1fbaed
--- /dev/null
+++ b/xcfinfo.10
@@ -0,0 +1,115 @@
+\." Manual page for xcfinfo
+\." Copyright (C) 2006 Henning Makholm
+\."
+\." This program is free software; you can redistribute it and/or modify
+\." it under the terms of version 2 of the GNU General Public License as
+\." published by the Free Software Foundation.
+\."
+\." 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
+.TH xcfinfo 1 2006-01-22 "Xcftools" ""
+.SH NAME
+xcf2pnm \- display information about GIMP xcf files
+.SH SYNOPSIS
+.B info
+[
+.I options
+]
+.I filename
+.SH DESCRIPTION
+.B xcfinfo
+is a command-line tool that displays information about the contents of
+image files in the XCF format used by
+.BR gimp (1),
+particularly about the layers in the image.
+.SH OPTIONS
+.so xcfinfo.1i
+.SH OUTPUT
+Information about the image is displayed on standard output in a fixed format.
+The first line contains general information about the XCF file
+.TP 3
+\-
+The file format version
+.TP
+\-
+The canvas size
+.TP
+\-
+The image mode (color, grayscale or indexed)
+.TP
+\-
+The numer of layers
+.TP
+\-
+The internal compression algorithm
+.P
+Following this line there is a line for each layer:
+.TP 3
+1)
+The character
+.B +
+if the layer is visible and
+.B \-
+if it is not
+.TP
+2)
+The size and offset of the layer
+.TP
+3)
+The pixel format of the layer, including whether the
+layer has an alpha channel.
+.TP
+4)
+The layer mode, as well as the opacity of not 100%, and
+.B /mask
+if the layer has an active layer mask.
+.TP
+5)
+The name of the layer.
+.SH EXIT STATUS
+The exit status of
+.B xcfinfo
+is
+.TP 5
+0
+Success
+.TP
+20
+Problems parsing the command line.
+.TP
+21
+The specified XCF file does not exist or cannot be read.
+.TP
+123
+The XCF file contains presumably valid features that
+.B xcftools
+does not support.
+.TP
+125
+The XCF file is malformed.
+.TP
+126
+An uncompression program could not be executed or terminated
+abnormally.
+.TP
+127
+Unexpected I/O error, internal errors, or other "this can't happen"
+situations.
+.P
+If an uncompression program returns an error exit status, this will
+be returned from
+.B xcfinfo
+too.
+.SH AUTHOR
+.B xcf2pnm
+was written by Henning Makholm <henning@makholm.net>
+.P
+.SH SEE ALSO
+.BR xcf2pnm (1),
+.BR xcf2png (1)
diff --git a/xcfinfo.c b/xcfinfo.c
new file mode 100644
index 0000000..af16f7e
--- /dev/null
+++ b/xcfinfo.c
@@ -0,0 +1,101 @@
+/* A program that extracts metadata from an XCF file
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#include "xcftools.h"
+#include <stdlib.h>
+#include <string.h>
+#include <locale.h>
+#if HAVE_GETOPT_H
+#include <getopt.h>
+#else
+#include <unistd.h>
+#endif
+#ifndef HAVE_GETOPT_LONG
+#define getopt_long(argc,argv,optstring,l1,l2) getopt(argc,argv,optstring)
+#endif
+
+#include "xcfinfo.oi"
+
+static void
+usage(FILE *where)
+{
+ fprintf(where,_("Usage: %s [options] filename.xcf[.gz]\n"),progname) ;
+ fprintf(where,_("Options:\n"));
+ opt_usage(where) ;
+ if( where == stderr ) {
+ exit(1);
+ }
+}
+
+int
+main(int argc,char **argv)
+{
+ int i ;
+ int option ;
+ const char *unzipper = NULL ;
+ const char *infile = NULL ;
+
+ setlocale(LC_ALL,"");
+ progname = argv[0] ;
+
+ if( argc <= 1 ) gpl_blurb() ;
+
+ while( (option=getopt_long(argc,argv,"-"OPTSTRING,longopts,NULL)) >= 0 )
+ switch(option) {
+ #define OPTION(char,long,desc,man) case char:
+ #include "options.i"
+ case 1:
+ if( infile ) {
+ FatalGeneric
+ (20,_("Only one XCF file per command line, please"));
+ } else {
+ infile = optarg ;
+ break ;
+ }
+ case '?':
+ usage(stderr);
+ default:
+ FatalUnexpected("Getopt(_long) unexpectedly returned '%c'",option);
+ }
+ if( infile == NULL ) {
+ usage(stderr);
+ }
+
+ read_or_mmap_xcf(infile,unzipper);
+ getBasicXcfInfo() ;
+ printf(_("Version %d, %dx%d %s, %d layers, compressed %s\n"),
+ XCF.version,XCF.width,XCF.height,
+ showGimpImageBaseType(XCF.type),
+ XCF.numLayers,
+ showXcfCompressionType(XCF.compression));
+ for( i = XCF.numLayers ; i-- ; ) {
+ printf("%c %dx%d%+d%+d %s %s",
+ XCF.layers[i].isVisible ? '+' : '-',
+ XCF.layers[i].dim.width, XCF.layers[i].dim.height,
+ XCF.layers[i].dim.c.l, XCF.layers[i].dim.c.t,
+ showGimpImageType(XCF.layers[i].type),
+ showGimpLayerModeEffects(XCF.layers[i].mode));
+ if( XCF.layers[i].opacity < 255 )
+ printf("/%02d%%",XCF.layers[i].opacity * 100 / 255);
+ if( XCF.layers[i].hasMask )
+ printf(_("/mask"));
+ printf(" %s\n",XCF.layers[i].name);
+ }
+
+ return 0 ;
+}
diff --git a/xcftools.h b/xcftools.h
new file mode 100644
index 0000000..9ae1dff
--- /dev/null
+++ b/xcftools.h
@@ -0,0 +1,183 @@
+/* Generic functions and macros for reading XCF files
+ *
+ * Copyright (C) 2006 Henning Makholm
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * 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
+ */
+
+#ifndef XCFTOOLS_H
+#define XCFTOOLS_H
+
+#include "config.h"
+#include "enums.h"
+#include <stddef.h>
+#include <stdio.h>
+
+/* Change to gettext for l10n */
+#define _(s) (s)
+#define N_(s) (s)
+
+#if HAVE_INTTYPES_H
+# define __STDC_FORMAT_MACROS
+# include <inttypes.h>
+#else
+/* These legacy fall-backs will probably work on every system
+ * that does not supply a inttypes.h ... */
+typedef unsigned char uint8_t ;
+typedef unsigned long int uint32_t, uintptr_t ;
+typedef signed char int8_t ;
+typedef signed long int int32_t ;
+# define PRIX32 "lX"
+# define PRIu32 "lu"
+# define PRIXPTR "lX"
+#endif
+
+#if __GNUC__
+# define __ATTRIBUTE__ __attribute__
+#else
+# define __ATTRIBUTE__(x)
+#endif
+
+#if HAVE_NETINET_IN_H
+# include <netinet/in.h>
+#elif HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#elif WORDS_BIGENDIAN
+# define ntohl(x) (x)
+#else
+static inline uint32_t ntohl(uint32_t a) {
+ return (a << 24) + ((a & 0xFF00) << 8) + ((a >> 8) & 0xFF00) + (a >> 24) ;
+}
+#endif
+
+#ifndef HAVE_STRCASECMP
+#define strcasecmp strcmp
+#endif
+
+/* Read a single word value from the XCF file */
+
+/* Use + instead of | because that allows LEA instructions */
+#define xcfBE(a) ( ((uint32_t)xcf_file[(a) ] << 24) + \
+ ((uint32_t)xcf_file[(a)+1] << 16) + \
+ ((uint32_t)xcf_file[(a)+2] << 8 ) + \
+ ((uint32_t)xcf_file[(a)+3] ) )
+#define xcfLE(a) ( ((uint32_t)xcf_file[(a) ] ) + \
+ ((uint32_t)xcf_file[(a)+1] << 8 ) + \
+ ((uint32_t)xcf_file[(a)+2] << 16) + \
+ ((uint32_t)xcf_file[(a)+3] << 24) )
+
+#if CAN_DO_UNALIGNED_WORDS
+# define xcfL(a) ntohl(*(uint32_t *)(xcf_file + (a)))
+#else
+# define xcfL(a) ((a) & 3 ? xcfBE(a) : ntohl(*(uint32_t *)(xcf_file + (a))))
+#endif
+
+/* ****************************************************************** */
+
+/* The following are exported from am OS-specific source file;
+ * io-unix.c on unixish systems.
+ */
+void read_or_mmap_xcf(const char* filename, const char *unzipper);
+void free_or_close_xcf(void);
+
+/* ****************************************************************** */
+/* utils.c */
+
+extern const char *progname ;
+extern int verboseFlag ;
+
+void *xcfmalloc(size_t size);
+void xcffree(void*);
+
+void FatalGeneric(int status,const char* format,...)
+ __ATTRIBUTE__((format(printf,2,3),noreturn)) ;
+void FatalUnexpected(const char* format,...)
+ __ATTRIBUTE__((format(printf,1,2),noreturn)) ;
+void FatalBadXCF(const char* format,...)
+ __ATTRIBUTE__((format(printf,1,2),noreturn)) ;
+void FatalUnsupportedXCF(const char* format,...)
+ __ATTRIBUTE__((format(printf,1,2),noreturn)) ;
+
+void gpl_blurb(void) __ATTRIBUTE__((noreturn));
+
+FILE* openout(const char*);
+void closeout(FILE *,const char*);
+
+struct rect {
+ int t, b, l, r ;
+};
+
+#define isSubrect(A,B) \
+ ((A).l >= (B).l && (A).r <= (B).r && (A).t >= (B).t && (A).b <= (B).b)
+#define disjointRects(A,B) \
+ ((A).l >= (B).r || (A).r <= (B).l || (A).t >= (B).b || (A).b <= (B).t)
+
+/* ****************************************************************** */
+/* xcf-general.c */
+
+extern uint8_t *xcf_file ;
+extern size_t xcf_length ;
+extern int use_utf8 ;
+
+void xcfCheckspace(uint32_t addr,int spaceafter, const char *format,...)
+ __ATTRIBUTE__((format(printf,3,4)));
+uint32_t xcfOffset(uint32_t addr,int spaceafter);
+
+int xcfNextprop(uint32_t *master,uint32_t *body);
+const char* xcfString(uint32_t ptr,uint32_t *after);
+
+/* These are hardcoded in the Gimp sources: */
+#define TILE_WIDTH 64
+#define TILE_HEIGHT 64
+
+struct tileDimensions {
+ struct rect c ;
+ unsigned width, height ;
+ unsigned tilesx, tilesy ;
+ unsigned ntiles ;
+};
+/* computeDimensions assumes that width, height, c.l, and c.t are set */
+void computeDimensions(struct tileDimensions *);
+
+struct xcfTiles {
+ const struct _convertParams *params ;
+ uint32_t *tileptrs ;
+ uint32_t hierarchy ;
+};
+
+struct xcfLayer {
+ struct tileDimensions dim ;
+ const char *name ;
+ GimpLayerModeEffects mode ;
+ GimpImageType type ;
+ unsigned int opacity ;
+ int isVisible, hasMask ;
+ uint32_t propptr ;
+ struct xcfTiles pixels ;
+ struct xcfTiles mask ;
+};
+
+extern struct xcfImage {
+ int version ;
+ unsigned width, height ;
+ GimpImageBaseType type ;
+ XcfCompressionType compression ;
+ int numLayers ;
+ struct xcfLayer *layers ;
+ uint32_t colormapptr ;
+} XCF ;
+
+void getBasicXcfInfo(void);
+
+#endif /* XCFTOOLS_H */