[librewms] 01/04: Imported Upstream version 1.0.0

Bas Couwenberg sebastic at xs4all.nl
Fri Nov 21 22:45:42 UTC 2014


This is an automated email from the git hooks/post-receive script.

sebastic-guest pushed a commit to branch master
in repository librewms.

commit ffb0a280770e2966d5704a0ee77d253d2091cd98
Author: Bas Couwenberg <sebastic at xs4all.nl>
Date:   Fri Nov 21 17:41:34 2014 +0100

    Imported Upstream version 1.0.0
---
 AUTHORS                         |     4 +
 COPYING                         |   674 ++
 ChangeLog                       |     0
 Classdef.h                      |  2807 ++++++
 Dialogs.cpp                     |  4396 +++++++++
 INSTALL                         |   183 +
 LayerTree.cpp                   |   740 ++
 Main.cpp                        |  1469 +++
 Makefile-static-MinGW           |    61 +
 Makefile.am                     |    20 +
 Makefile.in                     |   963 ++
 MapView.cpp                     |  4541 +++++++++
 NEWS                            |     0
 Printer.cpp                     |  1402 +++
 README                          |     1 +
 aclocal.m4                      |  1324 +++
 config.guess                    |  1558 ++++
 config.h.in                     |   150 +
 config.sub                      |  1788 ++++
 configure                       | 19207 ++++++++++++++++++++++++++++++++++++++
 configure.ac                    |    76 +
 depcomp                         |   791 ++
 gnome_resource/LibreWMS.desktop |    10 +
 gnome_resource/LibreWMS.png     |   Bin 0 -> 3679 bytes
 gnome_resource/Makefile.am      |     2 +
 gnome_resource/Makefile.in      |   438 +
 icons/Makefile.am               |     7 +
 icons/Makefile.in               |   443 +
 icons/about.xpm                 |    51 +
 icons/cache.xpm                 |   108 +
 icons/center.xpm                |   115 +
 icons/config.xpm                |   120 +
 icons/crosshair.xpm             |    22 +
 icons/crs.xpm                   |   201 +
 icons/exit.xpm                  |   197 +
 icons/group.xpm                 |   136 +
 icons/icon.xpm                  |    44 +
 icons/icon_info.xpm             |   372 +
 icons/identify.xpm              |   158 +
 icons/layer.xpm                 |   154 +
 icons/off.xpm                   |   111 +
 icons/on.xpm                    |   164 +
 icons/pan.xpm                   |    28 +
 icons/printer.xpm               |   152 +
 icons/remove.xpm                |   132 +
 icons/user_scale.xpm            |   223 +
 icons/wms.xpm                   |   112 +
 icons/wms_abort.xpm             |   123 +
 icons/zoom_in.xpm               |   103 +
 icons/zoom_out.xpm              |    93 +
 indent_me                       |     2 +
 install-sh                      |   527 ++
 ltmain.sh                       |  9655 +++++++++++++++++++
 m4/libtool.m4                   |  7992 ++++++++++++++++
 m4/ltoptions.m4                 |   384 +
 m4/ltsugar.m4                   |   123 +
 m4/ltversion.m4                 |    23 +
 m4/lt~obsolete.m4               |    98 +
 mac_resource/Makefile.am        |     2 +
 mac_resource/Makefile.in        |   438 +
 mac_resource/wxmac.icns         |   Bin 0 -> 232143 bytes
 missing                         |   215 +
 win_resource/LibreWMS-icon.png  |   Bin 0 -> 169266 bytes
 win_resource/LibreWMS.icns      |   Bin 0 -> 256772 bytes
 win_resource/Makefile.am        |     2 +
 win_resource/Makefile.in        |   438 +
 win_resource/icon.ico           |   Bin 0 -> 766 bytes
 win_resource/resource.rc        |     3 +
 68 files changed, 65876 insertions(+)

diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..3168245
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,4 @@
+Original Author:
+Alessandro Furieri <a.furieri at lqt.it>
+
+Contributors:
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..94a9ed0
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,674 @@
+                    GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  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
+them 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 prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  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.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey 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;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If 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 convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU 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 that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  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.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+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.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     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
+state 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 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    <program>  Copyright (C) <year>  <name of author>
+    This program 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, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+  The GNU 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 Lesser General
+Public License instead of this License.  But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..e69de29
diff --git a/Classdef.h b/Classdef.h
new file mode 100644
index 0000000..dfe07dc
--- /dev/null
+++ b/Classdef.h
@@ -0,0 +1,2807 @@
+/*
+/ Classdef.h
+/ class definitions for LibreWMS
+/
+/ version 1.0, 2013 July 28
+/
+/ Author: Sandro Furieri a-furieri at lqt.it
+/
+/ Copyright (C) 2013  Alessandro Furieri
+/
+/    This program is free software: you can redistribute it and/or modify
+/    it under the terms of the GNU General Public License as published by
+/    the Free Software Foundation, either version 3 of the License, or
+/    (at your option) any later version.
+/
+/    This program is distributed in the hope that it will be useful,
+/    but WITHOUT ANY WARRANTY; without even the implied warranty of
+/    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+/    GNU General Public License for more details.
+/
+/    You should have received a copy of the GNU General Public License
+/    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+/
+*/
+
+#include "wx/wx.h"
+#include "wx/graphics.h"
+#include "wx/aui/aui.h"
+#include "wx/treectrl.h"
+#include "wx/grid.h"
+#include "wx/html/htmlwin.h"
+#include "wx/spinctrl.h"
+
+#include "config.h"
+
+#include <sqlite3.h>
+#include <spatialite.h>
+
+#include <rasterlite2/rasterlite2.h>
+#include <rasterlite2/rl2wms.h>
+#include <rasterlite2/rl2tiff.h>
+#include <rasterlite2/rl2graphics.h>
+
+//
+// functions for threaded queries
+//
+#ifdef _WIN32
+DWORD WINAPI DoMapDownloadTilesThread(void *arg);
+DWORD WINAPI DoPdfDownloadTilesThread(void *arg);
+DWORD WINAPI DoTiffDownloadTilesThread(void *arg);
+#else
+void *DoMapDownloadTilesThread(void *arg);
+void *DoPdfDownloadTilesThread(void *arg);
+void *DoTiffDownloadTilesThread(void *arg);
+#endif
+enum
+{
+// control IDs for main window controls
+  ID_Wms = 1,
+  ID_Predefined,
+  ID_Center,
+  ID_Identify,
+  ID_ZoomIn,
+  ID_ZoomOut,
+  ID_UserScale,
+  ID_UserRatio,
+  ID_Pan,
+  ID_Cache,
+  ID_WmsAbort,
+  ID_Printer,
+  Tree_CRS,
+  Tree_RemoveAll,
+  Tree_ShowAll,
+  Tree_HideAll,
+  Tree_Visible,
+  Tree_RemoveLayer,
+  Tree_LayerInfo,
+  Tree_Configure,
+  Wms_Copy,
+  Wms_Layer,
+  Wms_Datasource
+};
+
+enum
+{
+// control IDs for dialogs
+  ID_WMS_URL = 10000,
+  ID_WMS_CATALOG,
+  ID_WMS_RESET,
+  ID_WMS_VERSION,
+  ID_WMS_TILED,
+  ID_WMS_WIDTH,
+  ID_WMS_HEIGHT,
+  ID_WMS_NAME,
+  ID_WMS_TITLE,
+  ID_WMS_ABSTRACT,
+  ID_WMS_CRS,
+  ID_WMS_FORMAT,
+  ID_WMS_STYLE,
+  ID_WMS_TRANSPARENT,
+  ID_WMS_SWAP,
+  ID_WMS_OK,
+  ID_WMS_COUNTRY,
+  ID_WMS_STATE,
+  ID_WMS_CATEGORY,
+  ID_WMS_ENABLE_PROXY,
+  ID_WMS_PROXY,
+  ID_FILTER_COUNTRY,
+  ID_FILTER_STATE,
+  ID_FILTER_CATEGORY,
+  ID_CACHE_ITEMS,
+  ID_CACHE_FLUSHED,
+  ID_CACHE_HIT,
+  ID_CACHE_MISS,
+  ID_CACHE_SIZE,
+  ID_CACHE_DOWNLOAD,
+  ID_CACHE_MAX,
+  ID_CACHE_RESET,
+  ID_USER_SCALE,
+  ID_USER_RATIO,
+  ID_TIFF_WIDTH,
+  ID_TIFF_HEIGHT,
+  ID_TIFF_GEO,
+  ID_TIFF_COMPR,
+  ID_TIFF_TILE_SZ,
+  ID_TIFF_COLORSPACE,
+  ID_PDF_PAGE,
+  ID_PDF_DPI,
+  ID_PDF_ORIENTATION,
+  ID_PDF_TIFF,
+  ID_PRINT_MODE,
+  ID_MAP_WMS_THREAD_FINISHED,
+  ID_PDF_WMS_THREAD_FINISHED,
+  ID_TIFF_WMS_THREAD_FINISHED
+};
+
+enum
+{
+// control IDs for timers
+  ID_WHEEL_TIMER = 20000,
+  ID_UPDATE_TIMER,
+  ID_PRINT_TIMER,
+  ID_DYNAMIC_TIMER,
+};
+
+//
+// functions for threaded WMS GetMap download
+//
+void WmsCallback(int rows, void *ptr);
+#ifdef _WIN32
+DWORD WINAPI DoExecuteWmsGetMap(void *arg);
+#else
+void *DoExecuteWmsGetMap(void *arg);
+#endif
+
+class MyApp:public wxApp
+{
+//
+// the main APP
+//
+  virtual bool OnInit();
+};
+
+class WmsFormat
+{
+//
+// a class wrapping a WMS format
+//
+private:
+  char *Name;
+  WmsFormat *Next;
+public:
+    WmsFormat(const char *name);
+   ~WmsFormat();
+  const char *GetName()
+  {
+    return Name;
+  }
+  void SetNext(WmsFormat * next)
+  {
+    Next = next;
+  }
+  WmsFormat *GetNext()
+  {
+    return Next;
+  }
+};
+
+class WmsStyle
+{
+//
+// a class wrapping a WMS style
+//
+private:
+  char *Name;
+  char *Title;
+  char *Abstract;
+  WmsStyle *Next;
+public:
+    WmsStyle(const char *name, const char *title, const char *abstract);
+   ~WmsStyle();
+  const char *GetName()
+  {
+    return Name;
+  }
+  const char *GetTitle()
+  {
+    return Title;
+  }
+  const char *GetAbstract()
+  {
+    return Abstract;
+  }
+  void SetNext(WmsStyle * next)
+  {
+    Next = next;
+  }
+  WmsStyle *GetNext()
+  {
+    return Next;
+  }
+};
+
+class WmsBBox
+{
+//
+// a class wrapping a WMS Bounding Box
+//
+private:
+  double MinX;
+  double MinY;
+  double MaxX;
+  double MaxY;
+public:
+    WmsBBox(double minx, double miny, double maxx, double maxy)
+  {
+    MinX = minx;
+    MinY = miny;
+    MaxX = maxx;
+    MaxY = maxy;
+  }
+   ~WmsBBox()
+  {;
+  }
+  double GetMinX()
+  {
+    return MinX;
+  }
+  double GetMinY()
+  {
+    return MinY;
+  }
+  double GetMaxX()
+  {
+    return MaxX;
+  }
+  double GetMaxY()
+  {
+    return MaxY;
+  }
+};
+
+class WmsCRS
+{
+//
+// a class wrapping a WMS CRS definition
+//
+private:
+  char *CRS;
+  WmsBBox *BBox;
+  WmsCRS *Next;
+public:
+    WmsCRS(const char *crs);
+   ~WmsCRS();
+  const char *GetCRS()
+  {
+    return CRS;
+  }
+  void SetBBox(WmsBBox * bbox)
+  {
+    BBox = bbox;
+  }
+  WmsBBox *GetBBox()
+  {
+    return BBox;
+  }
+  void SetNext(WmsCRS * next)
+  {
+    Next = next;
+  }
+  WmsCRS *GetNext()
+  {
+    return Next;
+  }
+};
+
+class WmsService
+{
+//
+// a class corresponding to a WMS service
+//
+private:
+  char *Version;
+  char *Name;
+  char *Title;
+  char *Abstract;
+  char *TileServiceName;
+  char *TileServiceTitle;
+  char *TileServiceAbstract;
+  char *URL_GetMap_Get;
+  char *URL_GetMap_Post;
+  char *URL_GetTileService_Get;
+  char *URL_GetTileService_Post;
+  char *URL_GetFeatureInfo_Get;
+  char *URL_GetFeatureInfo_Post;
+  char *GmlMimeType;
+  char *XmlMimeType;
+  char *ContactPerson;
+  char *ContactOrganization;
+  char *ContactPosition;
+  char *PostalAddress;
+  char *City;
+  char *StateProvince;
+  char *PostCode;
+  char *Country;
+  char *VoiceTelephone;
+  char *FaxTelephone;
+  char *EMailAddress;
+  char *Fees;
+  char *AccessConstraints;
+  int LayerLimit;
+  int MaxWidth;
+  int MaxHeight;
+  int RefCount;
+  WmsFormat *FirstFormat;
+  WmsFormat *LastFormat;
+  WmsService *Prev;
+  WmsService *Next;
+  bool FormatAlreadyDefined(const char *name);
+public:
+    WmsService(const char *version, const char *name, const char *title,
+               const char *abstract, const char *ts_name,
+               const char *ts_title, const char *ts_abstract,
+               const char *url_GetMap_get, const char *url_GetMap_post,
+               const char *url_GetTileService_get,
+               const char *url_GetTileService_post,
+               const char *url_GetFeatureInfo_get,
+               const char *url_GetFeatureInfo_post,
+               const char *gml_mime_type, const char *xml_mime_type,
+               const char *contact_person, const char *contact_organization,
+               const char *contact_position, const char *postal_address,
+               const char *city, const char *state_province,
+               const char *post_code, const char *country,
+               const char *voice_telephone, const char *fax_telephone,
+               const char *email_address, const char *fees,
+               const char *access_constraints, int layer_limit,
+               int max_width, int max_height);
+   ~WmsService();
+  const char *GetVersion()
+  {
+    return Version;
+  }
+  const char *GetName()
+  {
+    return Name;
+  }
+  const char *GetTitle()
+  {
+    return Title;
+  }
+  const char *GetAbstract()
+  {
+    return Abstract;
+  }
+  const char *GetTileServiceName()
+  {
+    return TileServiceName;
+  }
+  const char *GetTileServiceTitle()
+  {
+    return TileServiceTitle;
+  }
+  const char *GetTileServiceAbstract()
+  {
+    return TileServiceAbstract;
+  }
+  const char *GetURL_GetMap_Get()
+  {
+    return URL_GetMap_Get;
+  }
+  const char *GetURL_GetMap_Post()
+  {
+    return URL_GetMap_Post;
+  }
+  const char *GetURL_GetTileService_Get()
+  {
+    return URL_GetTileService_Get;
+  }
+  const char *GetURL_GetTileService_Post()
+  {
+    return URL_GetMap_Post;
+  }
+  const char *GetURL_GetFeatureInfo_Get()
+  {
+    return URL_GetFeatureInfo_Get;
+  }
+  const char *GetURL_GetFeatureInfo_Post()
+  {
+    return URL_GetFeatureInfo_Post;
+  }
+  const char *GetContactPerson()
+  {
+    return ContactPerson;
+  }
+  const char *GetContactOrganization()
+  {
+    return ContactOrganization;
+  }
+  const char *GetContactPosition()
+  {
+    return ContactPosition;
+  }
+  const char *GetPostalAddress()
+  {
+    return PostalAddress;
+  }
+  const char *GetCity()
+  {
+    return City;
+  }
+  const char *GetStateProvince()
+  {
+    return StateProvince;
+  }
+  const char *GetPostCode()
+  {
+    return PostCode;
+  }
+  const char *GetCountry()
+  {
+    return Country;
+  }
+  const char *GetVoiceTelephone()
+  {
+    return VoiceTelephone;
+  }
+  const char *GetFaxTelephone()
+  {
+    return FaxTelephone;
+  }
+  const char *GetEMailAddress()
+  {
+    return EMailAddress;
+  }
+  const char *GetFees()
+  {
+    return Fees;
+  }
+  const char *GetAccessConstraints()
+  {
+    return AccessConstraints;
+  }
+  int GetLayerLimit()
+  {
+    return LayerLimit;
+  }
+  int GetMaxWidth()
+  {
+    return MaxWidth;
+  }
+  int GetMaxHeight()
+  {
+    return MaxHeight;
+  }
+  int GetRefCount()
+  {
+    return RefCount;
+  }
+  void AddReference()
+  {
+    RefCount++;
+  }
+  void DeleteReference()
+  {
+    RefCount--;
+  }
+  void SetPrev(WmsService * prev)
+  {
+    Prev = prev;
+  }
+  WmsService *GetPrev()
+  {
+    return Prev;
+  }
+  void SetNext(WmsService * next)
+  {
+    Next = next;
+  }
+  WmsService *GetNext()
+  {
+    return Next;
+  }
+  bool Equals(WmsService * service);
+  void AddFormat(const char *name);
+  int CountFormats();
+  const char *GetFormatByIndex(int idx);
+  const char *GetGmlMimeType()
+  {
+    return GmlMimeType;
+  }
+  const char *GetXmlMimeType()
+  {
+    return XmlMimeType;
+  }
+};
+
+class WmsQueryableChildLayer
+{
+//
+// a class storing the name of some Child Layer
+// ensured to be of the queryable type
+//
+private:
+  char *Name;
+  char *Title;
+  WmsQueryableChildLayer *Next;
+public:
+    WmsQueryableChildLayer(const char *name, const char *title);
+   ~WmsQueryableChildLayer();
+  const char *GetName()
+  {
+    return Name;
+  }
+  const char *GetTitle()
+  {
+    return Title;
+  }
+  void SetNext(WmsQueryableChildLayer * next)
+  {
+    Next = next;
+  }
+  WmsQueryableChildLayer *GetNext()
+  {
+    return Next;
+  }
+};
+
+class WmsCRScandidate
+{
+// utility class: common CRS wrapper
+private:
+  char *CRS;
+  int Count;
+  WmsCRScandidate *Next;
+public:
+    WmsCRScandidate(const char *crs);
+   ~WmsCRScandidate();
+  const char *GetCRS()
+  {
+    return CRS;
+  }
+  int GetCount()
+  {
+    return Count;
+  }
+  void Increment()
+  {
+    Count++;
+  }
+  void SetNext(WmsCRScandidate * next)
+  {
+    Next = next;
+  }
+  WmsCRScandidate *GetNext()
+  {
+    return Next;
+  }
+};
+
+class WmsCRScandidates
+{
+// utility class: a list of CRSes candidates
+private:
+  WmsCRScandidate * First;
+  WmsCRScandidate *Last;
+  int Count;
+public:
+    WmsCRScandidates()
+  {
+    First = NULL;
+    Last = NULL;
+    Count = 0;
+  }
+   ~WmsCRScandidates();
+  int GetCount()
+  {
+    return Count;
+  }
+  void Increment()
+  {
+    Count++;
+  }
+  void AddCandidate(const char *crs);
+  WmsCRScandidate *GetFirst()
+  {
+    return First;
+  }
+};
+
+class WmsTilePattern
+{
+//
+// a class corresponding to a WMS TilePattern
+//
+private:
+  rl2WmsTilePatternPtr Handle;
+  char *SRS;
+  int TileWidth;
+  int TileHeight;
+  double TileBaseX;
+  double TileBaseY;
+  double TileExtentX;
+  double TileExtentY;
+  WmsTilePattern *Next;
+public:
+    WmsTilePattern(rl2WmsTilePatternPtr handle, const char *srs, int width,
+                   int height, double base_x, double base_y, double ext_x,
+                   double ext_y);
+   ~WmsTilePattern();
+  rl2WmsTilePatternPtr GetHandle()
+  {
+    return Handle;
+  }
+  const char *GetSRS()
+  {
+    return SRS;
+  }
+  int GetTileWidth()
+  {
+    return TileWidth;
+  }
+  int GetTileHeight()
+  {
+    return TileHeight;
+  }
+  double GetTileBaseX()
+  {
+    return TileBaseX;
+  }
+  double GetTileBaseY()
+  {
+    return TileBaseY;
+  }
+  double GetTileExtentX()
+  {
+    return TileExtentX;
+  }
+  double GetTileExtentY()
+  {
+    return TileExtentY;
+  }
+  void GetSampleURL(wxString & url);
+  void SetNext(WmsTilePattern * next)
+  {
+    Next = next;
+  }
+  WmsTilePattern *GetNext()
+  {
+    return Next;
+  }
+};
+
+class WmsTileServiceLayer
+{
+//
+// a class corresponding to a WMS TileService layer 
+//
+private:
+  char *Name;
+  char *Title;
+  char *Abstract;
+  double MinLat;
+  double MaxLat;
+  double MinLong;
+  double MaxLong;
+  char *Pad;
+  char *Bands;
+  char *DataType;
+  int WmsFixedScalesCount;
+  double *WmsFixedScales;
+  WmsTilePattern *First;
+  WmsTilePattern *Last;
+public:
+    WmsTileServiceLayer(const char *name, const char *title,
+                        const char *abstract, double min_lat,
+                        double min_long, double max_lat, double max_long,
+                        const char *pad, const char *bands,
+                        const char *data_type);
+   ~WmsTileServiceLayer();
+  const char *GetName()
+  {
+    return Name;
+  }
+  const char *GetTitle()
+  {
+    return Title;
+  }
+  const char *GetAbstract()
+  {
+    return Abstract;
+  }
+  double GetMinLat()
+  {
+    return MinLat;
+  }
+  double GetMinLong()
+  {
+    return MinLong;
+  }
+  double GetMaxLat()
+  {
+    return MaxLat;
+  }
+  double GetMaxLong()
+  {
+    return MaxLong;
+  }
+  const char *GetPad()
+  {
+    return Pad;
+  }
+  const char *GetBands()
+  {
+    return Bands;
+  }
+  const char *GetDataType()
+  {
+    return DataType;
+  }
+  void AddTilePattern(rl2WmsTilePatternPtr handle, const char *srs,
+                      int width, int height, double base_x, double base_y,
+                      double ext_x, double ext_y);
+  WmsTilePattern *GetFirst()
+  {
+    return First;
+  }
+  WmsTileServiceLayer *Clone();
+  void BuildFixedScales(void);
+  int GetFixedScalesCount()
+  {
+    return WmsFixedScalesCount;
+  }
+  double *GetFixedScales()
+  {
+    return WmsFixedScales;
+  }
+  bool CompareFixedScales(WmsTileServiceLayer * other);
+  bool Equals(WmsTileServiceLayer * other);
+  bool GetTileParams(double scale, double frame_minx, double frame_miny,
+                     int *tile_width, int *tile_height, double *tileW,
+                     double *tileH, double *baseX, double *baseY,
+                     WmsTilePattern ** tilepattern);
+};
+
+class WmsLayer
+{
+//
+// a class corresponding to a WMS layer 
+//
+private:
+  WmsService * Service;
+  WmsTileServiceLayer *TileLayer;
+  char *Name;
+  char *Title;
+  char *Abstract;
+  int Tiled;
+  int TileWidth;
+  int TileHeight;
+  int Queryable;
+  int Opaque;
+  char *Version;
+  char *StyleName;
+  char *StyleTitle;
+  char *StyleAbstract;
+  char *Format;
+  char *CRS;
+  int SwapXY;
+  double MinX;
+  double MaxX;
+  double MinY;
+  double MaxY;
+  double GeoMinX;
+  double GeoMaxX;
+  double GeoMinY;
+  double GeoMaxY;
+  double MinScaleDenominator;
+  double MaxScaleDenominator;
+  int Visible;
+  WmsStyle *FirstStyle;
+  WmsStyle *LastStyle;
+  WmsCRS *FirstCRS;
+  WmsCRS *LastCRS;
+  WmsQueryableChildLayer *FirstChild;
+  WmsQueryableChildLayer *LastChild;
+  WmsLayer *Prev;
+  WmsLayer *Next;
+  bool StyleAlreadyDefined(const char *name, const char *title,
+                           const char *abstract);
+  bool CrsAlreadyDefined(const char *crs);
+public:
+    WmsLayer(WmsService * service, const char *name, const char *title,
+             const char *abstract, int tiled, int tile_width,
+             int tile_height, int queryable, int opaque, const char *version,
+             const char *style, const char *style_title,
+             const char *style_abstract, const char *format, const char *crs,
+             int swap_xy, double min_x, double max_x, double min_y,
+             double max_y, double geo_min_x, double geo_max_x,
+             double geo_min_y, double geo_max_y,
+             double min_scale_denominator, double max_scale_denominator);
+    WmsLayer(WmsService * service, const char *name, const char *title,
+             const char *abstract, double min_long, double min_lat,
+             double max_long, double max_lat, const char *pad,
+             const char *bands, const char *data_type);
+   ~WmsLayer();
+  void Reconfigure(int tiled, int tile_width,
+                   int tile_height, int opaque, const char *version,
+                   const char *style, const char *style_title,
+                   const char *style_abstract, const char *format,
+                   const char *crs, int swap_xy, double min_x, double max_x,
+                   double min_y, double max_y);
+  WmsService *GetWmsService()
+  {
+    return Service;
+  }
+  WmsTileServiceLayer *GetTileServiceLayer()
+  {
+    return TileLayer;
+  }
+  bool IsTiled()
+  {
+    return Tiled;
+  }
+  int GetTileWidth()
+  {
+    return TileWidth;
+  }
+  int GetTileHeight()
+  {
+    return TileHeight;
+  }
+  bool IsQueryable()
+  {
+    if (Queryable)
+      return true;
+    else
+      return false;
+  }
+  bool HasQueryableChildren()
+  {
+    if (FirstChild != NULL)
+      return true;
+    else
+      return false;
+  }
+  bool IsOpaque()
+  {
+    return Opaque;
+  }
+  const char *GetName()
+  {
+    return Name;
+  }
+  const char *GetTitle()
+  {
+    return Title;
+  }
+  const char *GetAbstract()
+  {
+    return Abstract;
+  }
+  const char *GetVersion()
+  {
+    return Version;
+  }
+  const char *GetStyleName()
+  {
+    return StyleName;
+  }
+  const char *GetStyleTitle()
+  {
+    return StyleTitle;
+  }
+  const char *GetStyleAbstract()
+  {
+    return StyleAbstract;
+  }
+  const char *GetFormat()
+  {
+    return Format;
+  }
+  const char *GetCRS();
+  bool ChangeCRS(class MyFrame * MainFrame, const char *crs);
+  int IsSwapXY()
+  {
+    return SwapXY;
+  }
+  void ChangeSwapXY(void)
+  {
+    if (SwapXY == 0)
+      SwapXY = 1;
+    else
+      SwapXY = 0;
+  }
+  double GetMinX()
+  {
+    return MinX;
+  }
+  double GetMaxX()
+  {
+    return MaxX;
+  }
+  double GetMinY()
+  {
+    return MinY;
+  }
+  double GetMaxY()
+  {
+    return MaxY;
+  }
+  double GetGeoMinX()
+  {
+    return GeoMinX;
+  }
+  double GetGeoMaxX()
+  {
+    return GeoMaxX;
+  }
+  double GetGeoMinY()
+  {
+    return GeoMinY;
+  }
+  double GetGeoMaxY()
+  {
+    return GeoMaxY;
+  }
+  double GetMinScaleDenominator()
+  {
+    return MinScaleDenominator;
+  }
+  double GetMaxScaleDenominator()
+  {
+    return MaxScaleDenominator;
+  }
+  int IsVisible()
+  {
+    return Visible;
+  }
+  bool IsCovered(double minx, double miny, double maxx, double maxy);
+  void MaxLimits(double *maxx, double *maxy);
+  void Hide()
+  {
+    Visible = 0;
+  }
+  void Show()
+  {
+    Visible = 1;
+  }
+  void SetPrev(WmsLayer * prev)
+  {
+    Prev = prev;
+  }
+  WmsLayer *GetPrev()
+  {
+    return Prev;
+  }
+  void SetNext(WmsLayer * next)
+  {
+    Next = next;
+  }
+  WmsLayer *GetNext()
+  {
+    return Next;
+  }
+  WmsLayer *Clone();
+  bool Equals(WmsLayer * service);
+  void AddStyle(const char *name, const char *title, const char *abstract);
+  int CountStyles();
+  bool GetStyleByIndex(int idx, const char **name, const char **title,
+                       const char **abstract);
+  WmsCRS *AddCRS(const char *name);
+  int CountCRS();
+  const char *GetCrsByIndex(int idx);
+  bool HasBBox(const char *crs);
+  void GetBBox(const char *crs, double *minx, double *miny, double *maxx,
+               double *maxy);
+  void AddQueryableChild(const char *name, const char *title);
+  WmsQueryableChildLayer *GetFirstChild()
+  {
+    return FirstChild;
+  }
+  WmsStyle *GetFirstStyle()
+  {
+    return FirstStyle;
+  }
+};
+
+class LayerObject:public wxTreeItemData
+{
+//
+// a class to store TreeItemData - WMS Layer wrapper
+//
+private:
+  WmsLayer * Layer;
+public:
+  LayerObject(WmsLayer * lyr)
+  {
+    Layer = lyr;
+  }
+  virtual ~ LayerObject()
+  {;
+  }
+  WmsLayer *GetLayer()
+  {
+    return Layer;
+  }
+};
+
+class MyLayerTree:public wxTreeCtrl
+{
+//
+// a tree-control used for Map Layers
+//
+private:
+  class MyFrame * MainFrame;
+  bool Changed;
+  wxTreeItemId Root;            // the root node
+  wxImageList *Images;          // the images list
+  wxTreeItemId CurrentItem;     // the tree item holding the current context menu
+  wxTreeItemId DraggedItem;     // the tree item to be moved
+  void AddOnBitmap(wxBitmap & bitmap);
+  void AddOffBitmap(wxBitmap & bitmap);
+public:
+    MyLayerTree()
+  {;
+  }
+  MyLayerTree(class MyFrame * parent, wxWindowID id = wxID_ANY);
+  virtual ~ MyLayerTree();
+  void FlushAll()
+  {
+    DeleteChildren(Root);
+    Changed = true;
+  }
+  wxTreeItemId & GetRoot()
+  {
+    return Root;
+  }
+  void AddLayer(WmsLayer * layer);
+  void SetLayerIcons();
+  void MarkCurrentItem();
+  void UpdateDefault(wxTreeItemId item, wxImageList * imageList);
+  void OnSelChanged(wxTreeEvent & event);
+  void OnItemActivated(wxTreeEvent & event);
+  void OnRightClick(wxTreeEvent & event);
+  void OnCmdMapCRS(wxCommandEvent & event);
+  void OnCmdRemoveAll(wxCommandEvent & event);
+  void OnCmdShowAll(wxCommandEvent & event);
+  void OnCmdHideAll(wxCommandEvent & event);
+  void OnCmdVisible(wxCommandEvent & event);
+  void OnCmdConfigure(wxCommandEvent & event);
+  void OnCmdRemoveLayer(wxCommandEvent & event);
+  void OnCmdLayerInfo(wxCommandEvent & event);
+  void OnDragStart(wxTreeEvent & event);
+  void OnDragEnd(wxTreeEvent & event);
+};
+
+class CatalogObject:public wxTreeItemData
+{
+//
+// a class to store TreeItemData - WMS Catalog wrapper
+//
+private:
+  rl2WmsLayerPtr LayerHandle;
+  rl2WmsTiledLayerPtr TiledLayerHandle;
+  const char *LayerName;
+public:
+    CatalogObject(const char *lyr)
+  {
+    LayerHandle = NULL;
+    TiledLayerHandle = NULL;
+    LayerName = lyr;
+  }
+  CatalogObject(rl2WmsLayerPtr handle, const char *lyr)
+  {
+    LayerHandle = handle;
+    TiledLayerHandle = NULL;
+    LayerName = lyr;
+  }
+  CatalogObject(rl2WmsTiledLayerPtr handle, const char *lyr)
+  {
+    LayerHandle = NULL;
+    TiledLayerHandle = handle;
+    LayerName = lyr;
+  }
+  virtual ~ CatalogObject()
+  {;
+  }
+  rl2WmsLayerPtr GetHandle()
+  {
+    return LayerHandle;
+  }
+  rl2WmsTiledLayerPtr GetTiledHandle()
+  {
+    return TiledLayerHandle;
+  }
+  const char *GetLayerName()
+  {
+    return LayerName;
+  }
+};
+
+class MyCatalogTree:public wxTreeCtrl
+{
+//
+// a tree-control used for Service Layers
+//
+private:
+  class WmsDialog * MainDialog;
+  wxTreeItemId Root;            // the root node
+  wxImageList *Images;          // the images list
+  wxTreeItemId CurrentItem;     // the tree item holding the current context menu
+  void ExpandChildren(wxTreeItemId item, rl2WmsLayerPtr handle);
+  void ExpandChildren(wxTreeItemId item, rl2WmsTiledLayerPtr handle);
+public:
+    MyCatalogTree()
+  {;
+  }
+  MyCatalogTree(WmsDialog * parent, wxSize sz, wxWindowID id = wxID_ANY);
+  virtual ~ MyCatalogTree();
+  void FlushAll()
+  {
+    DeleteAllItems();
+    Root = wxTreeItemId();
+  }
+  void AddLayer(rl2WmsLayerPtr handle, const char *layer);
+  void AddTiledRoot(const char *name);
+  void AddTiledLayer(rl2WmsTiledLayerPtr handle, const char *layer);
+  void AddLayer(wxTreeItemId parent, rl2WmsLayerPtr handle, const char *layer);
+  void AddTiledLayer(wxTreeItemId parent, rl2WmsTiledLayerPtr handle,
+                     const char *layer);
+  void SetLayerIcons();
+  void MarkCurrentItem();
+  void RootAutoSelect(void);
+  void OnSelChanged(wxTreeEvent & event);
+  void OnCmdShowAll(wxCommandEvent & event);
+  void OnCmdHideAll(wxCommandEvent & event);
+};
+
+class WmsTileRequest
+{
+//
+// a class wrapping a single Tile request
+//
+private:
+  int Row;
+  int Col;
+  double MinX;
+  double MinY;
+  double MaxX;
+  double MaxY;
+  int ImageX;
+  int ImageY;
+  WmsTileRequest *Next;
+public:
+    WmsTileRequest(int row, int col, double minx, double miny, double maxx,
+                   double maxy, int image_x, int image_y)
+  {
+    Row = row;
+    Col = col;
+    MinX = minx;
+    MinY = miny;
+    MaxX = maxx;
+    MaxY = maxy;
+    ImageX = image_x;
+    ImageY = image_y;
+    Next = NULL;
+  }
+   ~WmsTileRequest()
+  {;
+  }
+  int GetRow()
+  {
+    return Row;
+  }
+  int GetCol()
+  {
+    return Col;
+  }
+  double GetMinX()
+  {
+    return MinX;
+  }
+  double GetMinY()
+  {
+    return MinY;
+  }
+  double GetMaxX()
+  {
+    return MaxX;
+  }
+  double GetMaxY()
+  {
+    return MaxY;
+  }
+  int GetImageX()
+  {
+    return ImageX;
+  }
+  int GetImageY()
+  {
+    return ImageY;
+  }
+  void SetNext(WmsTileRequest * next)
+  {
+    Next = next;
+  }
+  WmsTileRequest *GetNext()
+  {
+    return Next;
+  }
+};
+
+class WmsTileSet
+{
+//
+// a class wrapping a complex Tile-set
+//
+private:
+  double FrameMinX;
+  double FrameMinY;
+  double FrameMaxX;
+  double FrameMaxY;
+  double BaseX;
+  double BaseY;
+  double TileHorzSize;
+  double TileVertSize;
+  int ImageOriginX;
+  int ImageOriginY;
+  int ImageWidth;
+  int ImageHeight;
+  int TileWidth;
+  int TileHeight;
+  WmsTileRequest *First;
+  WmsTileRequest *Last;
+public:
+    WmsTileSet(double minx, double miny, double maxx, double maxy,
+               double base_x, double base_y, double tile_horz,
+               double tile_vert, int image_x, int image_y, int image_w,
+               int image_h, int tile_w, int tile_h);
+   ~WmsTileSet();
+  int GetTileWidth()
+  {
+    return TileWidth;
+  }
+  int GetTileHeight()
+  {
+    return TileHeight;
+  }
+  void AddTile(double minx, double miny, int row, int col);
+  WmsTileRequest *GetFirst()
+  {
+    return First;
+  }
+};
+
+class WmsGetMapRequest
+{
+// parameters for WMS GetMap download
+private:
+  int PosX;
+  int PosY;
+  rl2WmsCachePtr CacheHandle;
+  const char *Url;
+  const char *Proxy;
+  const char *Version;
+  const char *Layer;
+  const char *Crs;
+  int SwapXY;
+  double MinX;
+  double MinY;
+  double MaxX;
+  double MaxY;
+  int Width;
+  int Height;
+  const char *Style;
+  const char *Format;
+  int Opaque;
+  WmsTilePattern *TilePattern;
+  bool CacheHit;
+  wxImage Image;
+  unsigned char *RGBA;
+  bool ImageReady;
+  bool ImageDone;
+  bool Ignore;
+  WmsGetMapRequest *Next;
+public:
+    WmsGetMapRequest(int pos_x, int pos_y,
+                     rl2WmsCachePtr cache_handle, const char *url,
+                     const char *proxy, const char *version,
+                     const char *layer, const char *crs, int swap_xy,
+                     double minx, double miny, double maxx, double maxy,
+                     int width, int height, const char *style,
+                     const char *format, int opaque, int with_image);
+    WmsGetMapRequest(int pos_x, int pos_y,
+                     rl2WmsCachePtr cache_handle, const char *url,
+                     const char *proxy, const char *layer, int swap_xy,
+                     double minx, double miny, double maxx, double maxy,
+                     int width, int height, WmsTilePattern * tilepattern,
+                     int with_image);
+   ~WmsGetMapRequest()
+  {
+    if (RGBA != NULL)
+      free(RGBA);
+  }
+  bool ExecuteMap(int from_cache);
+  bool ExecutePrint(int from_cache);
+  const char *GetLayerName()
+  {
+    return Layer;
+  }
+  int GetPosX()
+  {
+    return PosX;
+  }
+  int GetPosY()
+  {
+    return PosY;
+  }
+  int GetWidth()
+  {
+    return Width;
+  }
+  int GetHeight()
+  {
+    return Height;
+  }
+  bool IsImageReady()
+  {
+    return ImageReady;
+  }
+  bool IsImageDone()
+  {
+    return ImageDone;
+  }
+  void Done();
+  wxImage & GetImage()
+  {
+    return Image;
+  }
+  unsigned char *GetRGBA()
+  {
+    return RGBA;
+  }
+  bool IsCacheHit()
+  {
+    return CacheHit;
+  }
+  bool IsTileService()
+  {
+    if (TilePattern != NULL)
+      return true;
+    else
+      return false;
+  }
+  bool ToBeIgnored()
+  {
+    return Ignore;
+  }
+  void Consider()
+  {
+    Ignore = false;
+  }
+  void SetNext(WmsGetMapRequest * next)
+  {
+    Next = next;
+  }
+  WmsGetMapRequest *GetNext()
+  {
+    return Next;
+  }
+};
+
+class GeometryRef
+{
+// a reference to some Geometry
+private:
+  int LayerId;
+  int LineNo;
+  int ColNo;
+  gaiaGeomCollPtr Geometry;
+  GeometryRef *Next;
+public:
+    GeometryRef(int layer_id, int line_no, int col_no, gaiaGeomCollPtr geom)
+  {
+    LayerId = layer_id;
+    LineNo = line_no;
+    ColNo = col_no;
+    Geometry = geom;
+    Next = NULL;
+  }
+   ~GeometryRef()
+  {;
+  }
+  int GetLayerId()
+  {
+    return LayerId;
+  }
+  int GetLineNo()
+  {
+    return LineNo;
+  }
+  int GetColNo()
+  {
+    return ColNo;
+  }
+  gaiaGeomCollPtr GetGeometry()
+  {
+    return Geometry;
+  }
+  void SetNext(GeometryRef * next)
+  {
+    Next = next;
+  }
+  GeometryRef *GetNext()
+  {
+    return Next;
+  }
+};
+
+class GeometryList
+{
+// a container for GetFeatureInfo Geometries
+private:
+  GeometryRef * First;
+  GeometryRef *Last;
+public:
+    GeometryList()
+  {
+    First = NULL;
+    Last = NULL;
+  }
+   ~GeometryList();
+  void Add(int layer_id, int line_no, int col_no, gaiaGeomCollPtr geom);
+  gaiaGeomCollPtr Find(int layer_id, int line_no, int col_no);
+};
+
+class WmsIdentifyPanel:public wxWindow
+{
+//
+// a panel for showing GetFeatureInfo returned by a WMS Layer
+//
+private:
+  class MyMapView * MapView;
+  rl2WmsFeatureCollectionPtr Collection;
+  GeometryList *List;
+  wxString Html;
+  wxHtmlWindow *HtmlCtrl;
+  void ParseHREF(wxString & href, int *layer_id, int *feature_id, int *col_no);
+public:
+    WmsIdentifyPanel(class MyMapView * map_view, wxString & html,
+                     rl2WmsFeatureCollectionPtr coll, GeometryList * list,
+                     int x, int y);
+    virtual ~ WmsIdentifyPanel()
+  {
+    Reset();
+  }
+  void Reset();
+  void Initialize(wxString & html, rl2WmsFeatureCollectionPtr coll,
+                  GeometryList * list, int x, int y);
+  void CreateControls();
+  void Resize();
+  void OnSize(wxSizeEvent & event);
+  void OnLinkClicked(wxHtmlLinkEvent & event);
+  void OnCancel(wxCommandEvent & event);
+};
+
+class MyMapView:public wxPanel
+{
+//
+// a panel used  to show the Map
+//
+private:
+  class MyFrame * MainFrame;
+  WmsIdentifyPanel *IdentifyPanel;
+  wxBitmap MapBitmap;
+  wxBitmap ScreenBitmap;
+  bool DynamicOddEven;
+  int BitmapWidth;
+  int BitmapHeight;
+  wxCursor CursorCross;
+  wxCursor CursorHand;
+  bool ValidMap;
+  double MapCX;
+  double MapCY;
+  double MapMinX;
+  double MapMaxX;
+  double MapMinY;
+  double MapMaxY;
+  double MapExtentX;
+  double MapExtentY;
+  int FrameWidth;
+  int FrameHeight;
+  double FrameCX;
+  double FrameCY;
+  double FrameExtentX;
+  double FrameExtentY;
+  double FrameMinX;
+  double FrameMinY;
+  double FrameMaxX;
+  double FrameMaxY;
+  double PixelRatio;
+  int DragStartX;
+  int DragStartY;
+  int LastDragX;
+  int LastDragY;
+  int CurrentScale;
+  WmsService *FirstService;
+  WmsService *LastService;
+  WmsLayer *FirstLayer;
+  WmsLayer *LastLayer;
+  WmsLayer *ActiveLayer;
+  WmsCRS *FirstCRS;
+  WmsCRS *LastCRS;
+  int WmsFixedScalesCount;
+  double *WmsFixedScales;
+// Timers
+  int MouseLastX;
+  int MouseLastY;
+  int WheelTics;
+  wxTimer *TimerMouseWheel;
+  int DynamicPhase;
+  wxTimer *TimerDynamic;
+  wxTimer *UpdateTimer;
+  wxTimer *PrintTimer;
+  WmsGetMapRequest *FirstRequest;
+  WmsGetMapRequest *LastRequest;
+  char *Proxy;
+  void CleanHtml(const char *dirty, wxString & clean);
+  wxGauge *ProgressControl;
+  bool DownloadInProgress;
+  bool PrintInProgress;
+  bool PendingRefresh;
+  bool PendingOnSize;
+  bool PendingWmsAbort;
+  void HtmlFromGetFeatureInfo(rl2WmsFeatureCollectionPtr coll, int idx,
+                              wxString & layer_name, wxString & html);
+  void AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                        const char *version,
+                        const char *layer,
+                        const char *crs, int swap_xy,
+                        double minx, double miny,
+                        double maxx, double maxy,
+                        int width, int height,
+                        const char *style, const char *format, int opaque);
+  void AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                        const char *layer, int swap_xy,
+                        double minx, double miny,
+                        double maxx, double maxy, int width, int height,
+                        WmsTilePattern * tilepattern);
+  void ResetGetMapRequests();
+  int CountGetMapRequests();
+  void UpdatePendingTiles();
+  void ResetCRSlist();
+  class PdfPrinter *Pdf;
+  class TiffWriter *Tiff;
+  wxImage ImageMarkerOdd;
+  wxImage ImageMarkerEven;
+public:
+    MyMapView()
+  {;
+  }
+  MyMapView(MyFrame * parent, wxWindowID id = wxID_ANY);
+  virtual ~ MyMapView();
+
+  WmsService *InsertWmsService(const char *version, const char *name,
+                               const char *title, const char *ts_name,
+                               const char *ts_title, const char *ts_service,
+                               const char *abstract,
+                               const char *url_GetMap_get,
+                               const char *url_GetMap_post,
+                               const char *url_GetTileService_get,
+                               const char *url_GetTileService_post,
+                               const char *url_GetFeatureInfo_get,
+                               const char *url_GetFeatureInfo_post,
+                               const char *gml_mime_type,
+                               const char *xml_mime_type,
+                               const char *contact_person,
+                               const char *contact_organization,
+                               const char *contact_position,
+                               const char *postal_address, const char *city,
+                               const char *state_province,
+                               const char *post_code, const char *country,
+                               const char *voice_telephone,
+                               const char *fax_telephone,
+                               const char *email_address, const char *fees,
+                               const char *access_constraints,
+                               int layer_limit, int max_width, int max_height);
+  void InsertWmsLayer(WmsLayer * layer);
+  void RemoveWmsLayer(WmsLayer * layer);
+  void RemoveWmsService(WmsService * service);
+  WmsService *FindAlreadyDefined(WmsService * service);
+  void CheckWmsLayer(WmsLayer * layer, bool * already_defined,
+                     bool * mixed_crs, bool * multiple_fixed_scales);
+  void ResetWmsLayers();
+  void SetWmsAbort()
+  {
+    PendingWmsAbort = true;
+  }
+  void SetPrintInProgress(PdfPrinter * pdf);
+  void SetPrintInProgress(TiffWriter * pdf);
+  bool IsPendingWmsAbort()
+  {
+    return PendingWmsAbort;
+  }
+  bool IsDownloadInProgress()
+  {
+    return DownloadInProgress;
+  }
+  bool IsPrintInProgress()
+  {
+    return PrintInProgress;
+  }
+  void BuildCRSlist();
+  int GetSridFromCRS(const char *crs);
+  void SetMapCRS(const char *crs);
+  WmsCRS *GetFirstCRS()
+  {
+    return FirstCRS;
+  }
+  void ReinsertWmsLayer(WmsLayer * layer);
+  int CountWmsLayers();
+  void BuildFixedScales();
+  void ResetScreenBitmap();
+  void UpdateTile(wxImage & Image, int pos_x, int pos_y, int width, int height);
+  void PrepareMap();
+  void SetFullExtent();
+  void Invalidate();
+  void SetActiveWmsLayer(WmsLayer * layer)
+  {
+    ActiveLayer = layer;
+  }
+  bool IsValidMap()
+  {
+    return ValidMap;
+  }
+  void DragMap(int x, int y);
+  void DoIdentify(int x, int y);
+  void DoIdentifyMultiLayer(int x, int y);
+  bool CanIdentify();
+  const char *GetMapCRS();
+  int GetCurrentScale()
+  {
+    return CurrentScale;
+  }
+  void SetCurrentScale(int scale);
+  WmsLayer *GetLastLayer()
+  {
+    return LastLayer;
+  }
+  WmsGetMapRequest *GetFirstRequest()
+  {
+    return FirstRequest;
+  }
+  void Consider(const char *layer_name);
+  void Consider(void);
+  double GetFrameCX()
+  {
+    return FrameCX;
+  }
+  double GetFrameCY()
+  {
+    return FrameCY;
+  }
+  double GetFrameMinX()
+  {
+    return FrameMinX;
+  }
+  double GetFrameMinY()
+  {
+    return FrameMinY;
+  }
+  double GetFrameMaxX()
+  {
+    return FrameMaxX;
+  }
+  double GetFrameMaxY()
+  {
+    return FrameMaxY;
+  }
+  double GetPixelRatio()
+  {
+    return PixelRatio;
+  }
+  bool IsWmsFixedScale(void)
+  {
+    if (WmsFixedScalesCount > 0)
+      return true;
+    return false;
+  }
+  double GetWmsBestResolution(double pixel_ratio);
+  void GetTileOrigin(double minx, double miny, double start_x,
+                     double start_y, double tile_width, double tile_height,
+                     double *base_x, double *base_y);
+  const char *GetProxy()
+  {
+    return Proxy;
+  }
+  void PopulateGeometryList(class GeometryList * list, int layer_no,
+                            rl2WmsFeatureCollectionPtr coll);
+  void MarkGeometry(gaiaGeomCollPtr geom);
+  void ResetMarker();
+  void BuildMarker(wxImage & image, bool odd_even, gaiaGeomCollPtr geom);
+
+  void OnSize(wxSizeEvent & event);
+  void OnPaint(wxPaintEvent & event);
+  void OnMouseMove(wxMouseEvent & event);
+  void OnMouseWheel(wxMouseEvent & event);
+  void OnTimerMouseWheel(wxTimerEvent & event);
+  void OnTimerDynamic(wxTimerEvent & event);
+  void OnTimerUpdate(wxTimerEvent & event);
+  void OnTimerPrint(wxTimerEvent & event);
+  void OnMouseClick(wxMouseEvent & event);
+  void OnMouseDoubleClick(wxMouseEvent & event);
+  void OnMouseDragStop(wxMouseEvent & event);
+  void OnEraseBackground(wxEraseEvent & WXUNUSED(event))
+  {;
+  }
+  void OnRefreshTimer(wxTimerEvent & event);
+  void OnMapWmsThreadFinished(wxCommandEvent & event);
+  void OnPdfWmsThreadFinished(wxCommandEvent & event);
+  void OnTiffWmsThreadFinished(wxCommandEvent & event);
+};
+
+class MyFrame:public wxFrame
+{
+//
+// the main GUI frame
+//
+private:
+  wxAuiManager Manager;         // the GUI manager
+  wxString ConfigLayout;        // PERSISTENCY - the layout configuration
+  int ConfigPaneX;              // PERSISTENCY - the main pane screen origin X
+  int ConfigPaneY;              // PERSISTENCY - the main pane screen origin Y
+  int ConfigPaneWidth;          // PERSISTENCY - the main pane screen width
+  int ConfigPaneHeight;         // PERSISTENCY - the main pane screen height
+  wxString HttpProxy;           // PERSISTENCY - the last used HTTP Proxy
+  MyLayerTree *LayerTree;       // the layer tree list
+  MyMapView *MapView;           // the map panel
+  wxString LastDirectory;       // path of directory used  
+  wxString CurrentWmsDatasource;
+  sqlite3 *SQLiteHandle;        // handle for SQLite DB
+  void *InternalCache;          // pointer to the InternalCache supporting the DB connection
+  wxBitmap *BtnWms;             // button icon for WMS add
+  wxBitmap *BtnCenter;          // button icon for Zoom to Full Extent
+  wxBitmap *BtnIdentify;        // buttom icon for Identify
+  wxBitmap *BtnZoomIn;          // button icon for Zoom In
+  wxBitmap *BtnZoomOut;         // buttom icon for Zoom Out
+  wxBitmap *BtnUserScale;       // buttom icon for User Scale
+  wxBitmap *BtnPan;             // button icon for Pan
+  wxBitmap *BtnCache;           // button icon for WMS Cache
+  wxBitmap *BtnWmsAbort;        // button icon for WMS Abort
+  wxBitmap *BtnPrinter;         // button icon for Printer
+  wxBitmap *BtnAbout;           // button icon for ABOUT
+  wxBitmap *BtnExit;            // button icon for EXIT
+  bool IsIdentify;              // current map click is: Identify
+  bool IsZoomIn;                // current map click is: ZoomIn
+  bool IsZoomOut;               // current map click is: ZoomOut
+  bool IsPan;                   // current map click is: Pan
+  rl2WmsCachePtr WmsCache;      // internal WMS Cache
+  void WmsSelection(bool immediate);
+  void AddQueryableChildren(WmsLayer * lyr, rl2WmsLayerPtr handle);
+public:
+    MyFrame(const wxString & title, const wxPoint & pos, const wxSize & size);
+    virtual ~ MyFrame();
+
+  void SaveConfig();
+  void LoadConfig();
+  void CreateMemoryDB();
+  void CloseMemoryDB();
+    wxString & GetCurrentWmsDatasource()
+  {
+    return CurrentWmsDatasource;
+  }
+  void InitializeSpatialMetadata();
+  void InitializeWmsList();
+  sqlite3 *GetSQLite()
+  {
+    return SQLiteHandle;
+  }
+  void SetLastDirectory(wxString & path)
+  {
+    LastDirectory = path;
+  }
+  wxString & GetLastDirectory()
+  {
+    return LastDirectory;
+  }
+  void AddPredefinedWMS(const char *country, const char *state_province,
+                        const char *category, const char *url);
+  void UpdateTools();
+  void UpdateWmsAbortTool(bool mode);
+  void UpdatePrinterTool(bool mode);
+  void ClearLayerTree();
+  bool IsModeIdentify()
+  {
+    return IsIdentify;
+  }
+  bool IsModeZoomIn()
+  {
+    return IsZoomIn;
+  }
+  bool IsModeZoomOut()
+  {
+    return IsZoomOut;
+  }
+  bool IsModePan()
+  {
+    return IsPan;
+  }
+  bool IsGeographicCRS(const char *crs);
+  bool IsSwapXYcrs(const char *crs);
+  bool BBoxFromLongLat(const char *crs_str, double *minx, double *maxx,
+                       double *miny, double *maxy);
+  char *GetProjParams(int srid);
+  wxString & GetHttpProxy()
+  {
+    return HttpProxy;
+  }
+  rl2WmsCachePtr GetWmsCache()
+  {
+    return WmsCache;
+  }
+
+  wxBitmap *GetBtnCenter()
+  {
+    return BtnCenter;
+  }
+  void SetFullExtent()
+  {
+    MapView->SetFullExtent();
+  }
+  void RefreshMap()
+  {
+    MapView->PrepareMap();
+  }
+
+  MyLayerTree *GetLayerTree()
+  {
+    return LayerTree;
+  }
+  MyMapView *GetMapView()
+  {
+    return MapView;
+  }
+  WmsCRS *GetFirstMapCRS()
+  {
+    return MapView->GetFirstCRS();
+  }
+  void SetActiveWmsLayer(WmsLayer * layer)
+  {
+    MapView->SetActiveWmsLayer(layer);
+    UpdateTools();
+  }
+
+  void SetMapCRS(const char *crs)
+  {
+    MapView->SetMapCRS(crs);
+  }
+  void UpdateMapCRS();
+  const char *GetMapCRS()
+  {
+    return MapView->GetMapCRS();
+  }
+  void UpdateMapScale();
+  void UpdateMapCoords(wxString & coords);
+  bool GetProgressRect(wxRect & rect);
+
+  void OnWms(wxCommandEvent & event);
+  void OnPredefinedWms(wxCommandEvent & event);
+  void OnCenter(wxCommandEvent & event);
+  void OnIdentify(wxCommandEvent & event);
+  void OnZoomIn(wxCommandEvent & event);
+  void OnZoomOut(wxCommandEvent & event);
+  void OnUserScale(wxCommandEvent & event);
+  void OnPan(wxCommandEvent & event);
+  void OnWmsCache(wxCommandEvent & event);
+  void OnWmsAbort(wxCommandEvent & event);
+  void OnPrinter(wxCommandEvent & event);
+  void OnQuit(wxCommandEvent & event);
+  void OnAbout(wxCommandEvent & event);
+  void OnClose(wxCloseEvent & event);
+};
+
+class PredefinedWmsDialog:public wxDialog
+{
+//
+// a dialog for selecting a pre-defines WMS datasource
+//
+private:
+  MyFrame * MainFrame;
+  sqlite3 *SQLiteHandle;
+  wxGrid *WmsView;
+  int CurrentEvtRow;
+  int CurrentEvtColumn;
+  wxComboBox *CountryList;
+  wxComboBox *StateList;
+  wxComboBox *CategoryList;
+  char *CountryFilter;
+  char *StateFilter;
+  char *CategoryFilter;
+  wxString URL;
+  void SelectWmsDatasource();
+  void PopulateCountries();
+  void PopulateStates();
+  void PopulateCategories();
+  void PopulateGrid();
+public:
+    PredefinedWmsDialog()
+  {
+    WmsView = NULL;
+    CountryList = NULL;
+    StateList = NULL;
+    CategoryList = NULL;
+    CountryFilter = NULL;
+    StateFilter = NULL;
+    CategoryFilter = NULL;
+  }
+  virtual ~ PredefinedWmsDialog()
+  {
+    if (CountryFilter)
+      delete[]CountryFilter;
+    if (StateFilter)
+      delete[]StateFilter;
+    if (CategoryFilter)
+      delete[]CategoryFilter;
+  }
+  bool Create(MyFrame * parent, sqlite3 * sqlite);
+  void CreateControls();
+  wxString & GetURL()
+  {
+    return URL;
+  }
+  void OnLeftClick(wxGridEvent & event);
+  void OnRightClick(wxGridEvent & event);
+  void OnOk(wxCommandEvent & event);
+  void OnCancel(wxCommandEvent & event);
+  void OnCmdCopy(wxCommandEvent & event);
+  void OnCmdSelectWmsDatasource(wxCommandEvent & event);
+  void OnCountrySelected(wxCommandEvent & event);
+  void OnStateSelected(wxCommandEvent & event);
+  void OnCategorySelected(wxCommandEvent & event);
+};
+
+class WmsDialog:public wxDialog
+{
+//
+// a dialog for selecting a WMS datasource
+//
+private:
+  MyFrame * MainFrame;
+  wxString URL;
+  MyCatalogTree *WmsTree;
+  rl2WmsCatalogPtr Catalog;
+  rl2WmsLayerPtr CurrentLayer;
+  rl2WmsTiledLayerPtr CurrentTiledLayer;
+  int MaxWidth;
+  int MaxHeight;
+  char *Version;
+  int SwapXY;
+  bool ProxyEnabled;
+  wxString HttpProxy;
+public:
+    WmsDialog()
+  {
+    Catalog = NULL;
+    WmsTree = NULL;
+    Version = NULL;
+    CurrentLayer = NULL;
+    CurrentTiledLayer = NULL;
+    ProxyEnabled = false;
+  }
+  virtual ~ WmsDialog()
+  {
+    if (Catalog != NULL)
+      destroy_wms_catalog(Catalog);
+    if (Version != NULL)
+      delete[]Version;
+  }
+  bool Create(MyFrame * parent, wxString & proxy, bool immediate);
+  void CreateControls();
+  void SelectLayer(void);
+  void SelectLayer(rl2WmsLayerPtr layer);
+  void SelectLayer(rl2WmsTiledLayerPtr layer);
+  int IsTiled();
+  int GetTileWidth();
+  int GetTileHeight();
+  rl2WmsLayerPtr GetLayerHandle()
+  {
+    return CurrentLayer;
+  }
+  rl2WmsTiledLayerPtr GetTiledLayerHandle()
+  {
+    return CurrentTiledLayer;
+  }
+  int IsQueryable()
+  {
+    if (is_wms_layer_queryable(CurrentLayer) > 0)
+      return 1;
+    return 0;
+  }
+  int IsOpaque();
+  wxString & GetURL()
+  {
+    return URL;
+  }
+  const char *GetServiceVersion()
+  {
+    return get_wms_version(Catalog);
+  }
+  const char *GetServiceName()
+  {
+    return get_wms_name(Catalog);
+  }
+  const char *GetServiceTitle()
+  {
+    return get_wms_title(Catalog);
+  }
+  const char *GetServiceAbstract()
+  {
+    return get_wms_abstract(Catalog);
+  }
+  const char *GetTileServiceName()
+  {
+    return get_wms_tile_service_name(Catalog);
+  }
+  const char *GetTileServiceTitle()
+  {
+    return get_wms_tile_service_title(Catalog);
+  }
+  const char *GetTileServiceAbstract()
+  {
+    return get_wms_tile_service_abstract(Catalog);
+  }
+  const char *GetURL_GetMap_Get()
+  {
+    return get_wms_url_GetMap_get(Catalog);
+  }
+  const char *GetURL_GetMap_Post()
+  {
+    return get_wms_url_GetTileService_post(Catalog);
+  }
+  const char *GetURL_GetTileService_Get()
+  {
+    return get_wms_url_GetTileService_get(Catalog);
+  }
+  const char *GetURL_GetTileService_Post()
+  {
+    return get_wms_url_GetTileService_post(Catalog);
+  }
+  const char *GetURL_GetFeatureInfo_Get()
+  {
+    return get_wms_url_GetFeatureInfo_get(Catalog);
+  }
+  const char *GetURL_GetFeatureInfo_Post()
+  {
+    return get_wms_url_GetFeatureInfo_post(Catalog);
+  }
+  const char *GetGmlMimeType()
+  {
+    return get_wms_gml_mime_type(Catalog);
+  }
+  const char *GetXmlMimeType()
+  {
+    return get_wms_xml_mime_type(Catalog);
+  }
+  const char *GetContactPerson()
+  {
+    return get_wms_contact_person(Catalog);
+  }
+  const char *GetContactOrganization()
+  {
+    return get_wms_contact_organization(Catalog);
+  }
+  const char *GetContactPosition()
+  {
+    return get_wms_contact_position(Catalog);
+  }
+  const char *GetPostalAddress()
+  {
+    return get_wms_contact_postal_address(Catalog);
+  }
+  const char *GetCity()
+  {
+    return get_wms_contact_city(Catalog);
+  }
+  const char *GetStateProvince()
+  {
+    return get_wms_contact_state_province(Catalog);
+  }
+  const char *GetPostCode()
+  {
+    return get_wms_contact_post_code(Catalog);
+  }
+  const char *GetCountry()
+  {
+    return get_wms_contact_country(Catalog);
+  }
+  const char *GetVoiceTelephone()
+  {
+    return get_wms_contact_voice_telephone(Catalog);
+  }
+  const char *GetFaxTelephone()
+  {
+    return get_wms_contact_fax_telephone(Catalog);
+  }
+  const char *GetEMailAddress()
+  {
+    return get_wms_contact_email_address(Catalog);
+  }
+  const char *GetFees()
+  {
+    return get_wms_fees(Catalog);
+  }
+  const char *GetAccessConstraints()
+  {
+    return get_wms_access_constraints(Catalog);
+  }
+  int GetLayerLimit()
+  {
+    return get_wms_layer_limit(Catalog);
+  }
+  int GetMaxWidth()
+  {
+    return get_wms_max_width(Catalog);
+  }
+  int GetMaxHeight()
+  {
+    return get_wms_max_height(Catalog);
+  }
+  const char *GetName()
+  {
+    return get_wms_layer_name(CurrentLayer);
+  }
+  const char *GetTitle()
+  {
+    return get_wms_layer_title(CurrentLayer);
+  }
+  const char *GetAbstract()
+  {
+    return get_wms_layer_abstract(CurrentLayer);
+  }
+  const char *GetVersion();
+  const char *GetStyleName();
+  const char *GetStyleTitle();
+  const char *GetStyleAbstract();
+  const char *GetFormat();
+  const char *GetCRS();
+  int IsSwapXY()
+  {
+    return SwapXY;
+  }
+  double GetMinX();
+  double GetMaxX();
+  double GetMinY();
+  double GetMaxY();
+  double GetGeoMinX();
+  double GetGeoMaxX();
+  double GetGeoMinY();
+  double GetGeoMaxY();
+  double GetMinScaleDenominator()
+  {
+    return get_wms_layer_min_scale_denominator(CurrentLayer);
+  }
+  double GetMaxScaleDenominator()
+  {
+    return get_wms_layer_max_scale_denominator(CurrentLayer);
+  }
+  int CountFormats()
+  {
+    return get_wms_format_count(Catalog, 1);
+  }
+  const char *GetFormatByIndex(int idx)
+  {
+    return get_wms_format(Catalog, idx, 1);
+  }
+  int CountStyles()
+  {
+    return get_wms_layer_style_count(CurrentLayer);
+  }
+  bool GetStyleByIndex(int idx, const char **name, const char **title,
+                       const char **abstract);
+  int CountCRS()
+  {
+    return get_wms_layer_crs_count(CurrentLayer);
+  }
+  const char *GetCrsByIndex(int idx)
+  {
+    return get_wms_layer_crs(CurrentLayer, idx);
+  }
+  WmsBBox *GetBBoxByCRS(const char *crs);
+  bool IsWmsTileService()
+  {
+    if (is_wms_tile_service(Catalog) == 1)
+      return true;
+    else
+      return false;
+  }
+  const char *GetTiledLayerName()
+  {
+    return get_wms_tiled_layer_name(CurrentTiledLayer);
+  }
+  const char *GetTiledLayerTitle()
+  {
+    return get_wms_tiled_layer_title(CurrentTiledLayer);
+  }
+  const char *GetTiledLayerAbstract()
+  {
+    return get_wms_tiled_layer_abstract(CurrentTiledLayer);
+  }
+  const char *GetTiledLayerPad()
+  {
+    return get_wms_tiled_layer_pad(CurrentTiledLayer);
+  }
+  const char *GetTiledLayerBands()
+  {
+    return get_wms_tiled_layer_bands(CurrentTiledLayer);
+  }
+  const char *GetTiledLayerDataType()
+  {
+    return get_wms_tiled_layer_data_type(CurrentTiledLayer);
+  }
+  int GetTilePatternCount()
+  {
+    return get_wms_tile_pattern_count(CurrentTiledLayer);
+  }
+  rl2WmsTilePatternPtr GetTilePatternHandle(int i);
+  const char *GetTilePatternSRS(int i);
+  int GetTilePatternWidth(int i);
+  int GetTilePatternHeight(int i);
+  double GetTilePatternBaseX(int i);
+  double GetTilePatternBaseY(int i);
+  double GetTilePatternExtentX(int i);
+  double GetTilePatternExtentY(int i);
+  double GetTiledLayerMinLong();
+  double GetTiledLayerMinLat();
+  double GetTiledLayerMaxLong();
+  double GetTiledLayerMaxLat();
+  wxString & GetHttpProxy()
+  {
+    return HttpProxy;
+  }
+  void PrepareCatalog(void);
+  void UpdateSwapXY(void);
+  void OnProxy(wxCommandEvent & event);
+  void OnCrsChanged(wxCommandEvent & event);
+  void OnVersionChanged(wxCommandEvent & event);
+  void OnSwapXYChanged(wxCommandEvent & event);
+  void OnTiledChanged(wxCommandEvent & event);
+  void OnCatalog(wxCommandEvent & event);
+  void OnReset(wxCommandEvent & event);
+  void OnWmsOk(wxCommandEvent & event);
+  void OnQuit(wxCommandEvent & event);
+};
+
+class WmsLayerDialog:public wxDialog
+{
+//
+// a dialog for configuring a WMS Layer
+//
+private:
+  MyFrame * MainFrame;
+  int MaxWidth;
+  int MaxHeight;
+  char *Version;
+  int SwapXY;
+  WmsLayer *Layer;
+public:
+    WmsLayerDialog()
+  {
+    Version = NULL;
+  }
+  virtual ~ WmsLayerDialog()
+  {
+    if (Version != NULL)
+      delete[]Version;
+  }
+  bool Create(MyFrame * parent, WmsLayer * lyr);
+  void CreateControls();
+  int IsTiled();
+  int GetTileWidth();
+  int GetTileHeight();
+  int IsOpaque();
+  const char *GetVersion();
+  const char *GetStyleName();
+  const char *GetStyleTitle();
+  const char *GetStyleAbstract();
+  const char *GetFormat();
+  const char *GetCRS();
+  double GetMinX();
+  double GetMaxX();
+  double GetMinY();
+  double GetMaxY();
+  int IsSwapXY()
+  {
+    return SwapXY;
+  }
+  void UpdateSwapXY(void);
+  void OnCrsChanged(wxCommandEvent & event);
+  void OnVersionChanged(wxCommandEvent & event);
+  void OnSwapXYChanged(wxCommandEvent & event);
+  void OnTiledChanged(wxCommandEvent & event);
+  void OnWmsOk(wxCommandEvent & event);
+  void OnQuit(wxCommandEvent & event);
+};
+
+class WmsMapCrsDialog:public wxDialog
+{
+//
+// a dialog for selecting the Map CRS
+//
+private:
+  MyFrame * MainFrame;
+  wxString CRS;
+public:
+    WmsMapCrsDialog()
+  {;
+  }
+  virtual ~ WmsMapCrsDialog()
+  {;
+  }
+  bool Create(MyFrame * parent);
+  void CreateControls();
+  wxString & GetCRS()
+  {
+    return CRS;
+  }
+  void OnOk(wxCommandEvent & event);
+};
+
+class WmsInfoDialog:public wxDialog
+{
+//
+// a dialog for showing infos about a WMS Layer
+//
+private:
+  MyFrame * MainFrame;
+  WmsLayer *Layer;
+  wxHtmlWindow *HtmlCtrl;
+public:
+    WmsInfoDialog()
+  {
+    Layer = NULL;
+  }
+  virtual ~ WmsInfoDialog()
+  {;
+  }
+  bool Create(MyFrame * parent, WmsLayer * layer);
+  void CreateControls();
+  void OnSize(wxSizeEvent & event);
+};
+
+class WmsCacheDialog:public wxDialog
+{
+//
+// a dialog for showing infos about the WMS internal Cache
+//
+private:
+  MyFrame * MainFrame;
+  rl2WmsCachePtr Cache;
+public:
+    WmsCacheDialog()
+  {
+    Cache = NULL;
+  }
+  virtual ~ WmsCacheDialog()
+  {;
+  }
+  bool Create(MyFrame * parent, rl2WmsCachePtr cache);
+  void CreateControls();
+  void OnCacheReset(wxCommandEvent & event);
+  void OnOk(wxCommandEvent & event);
+};
+
+class UserScaleDialog:public wxDialog
+{
+//
+// a dialog for selecting a precise Scale
+//
+private:
+  MyFrame * MainFrame;
+  int CurrentScale;
+  double PixelRatio;
+public:
+    UserScaleDialog()
+  {;
+  }
+  virtual ~ UserScaleDialog()
+  {;
+  }
+  bool Create(MyFrame * parent, int scale, double pixel_ratio);
+  void CreateControls();
+  int GetCurrentScale()
+  {
+    return CurrentScale;
+  }
+  void OnOk(wxCommandEvent & event);
+  void OnScaleChanged(wxSpinEvent & event);
+};
+
+class PrinterDialog:public wxDialog
+{
+//
+// a dialog for selecting a Printer
+//
+private:
+  MyFrame * MainFrame;
+  int Dpi;
+  double PageWidth;
+  double PageHeight;
+  double HorzMarginSize;
+  double VertMarginSize;
+  int Width;
+  int Height;
+  bool PreserveScale;
+  bool PreserveWidth;
+  bool PreserveHeight;
+  bool PDF;
+  bool TIFF;
+  bool GeoTiff;
+  bool Worldfile;
+  unsigned char Compression;
+  int TileSize;
+  int StripSize;
+public:
+    PrinterDialog()
+  {;
+  }
+  virtual ~ PrinterDialog()
+  {;
+  }
+  bool Create(MyFrame * parent);
+  void CreateControls();
+  int GetWidth()
+  {
+    return Width;
+  }
+  int GetHeight()
+  {
+    return Height;
+  }
+  int GetDPI()
+  {
+    return Dpi;
+  }
+  double GetPageWidth()
+  {
+    return PageWidth;
+  }
+  double GetPageHeight()
+  {
+    return PageHeight;
+  }
+  double GetHorzMarginSize()
+  {
+    return HorzMarginSize;
+  }
+  double GetVertMarginSize()
+  {
+    return VertMarginSize;
+  }
+  bool IsPreserveScale()
+  {
+    return PreserveScale;
+  }
+  bool IsPreserveWidth()
+  {
+    return PreserveWidth;
+  }
+  bool IsPreserveHeight()
+  {
+    return PreserveHeight;
+  }
+  bool IsPDF()
+  {
+    return PDF;
+  }
+  bool IsTIFF()
+  {
+    return TIFF;
+  }
+  bool IsGeoTiff()
+  {
+    return GeoTiff;
+  }
+  bool HasWorldfile()
+  {
+    return Worldfile;
+  }
+  unsigned char GetCompression()
+  {
+    return Compression;
+  }
+  bool IsTiled()
+  {
+    if (TileSize > 0)
+      return true;
+    else
+      return false;
+  }
+  int GetTileSize()
+  {
+    return TileSize;
+  }
+  int GetStripSize()
+  {
+    return StripSize;
+  }
+  void OnFormatChanged(wxCommandEvent & event);
+  void OnOk(wxCommandEvent & event);
+};
+
+class PdfPrinter
+{
+//
+// a class implementing the Map PDF printer
+//
+private:
+  MyFrame * MainFrame;
+  MyMapView *MapView;
+  char *Path;
+  rl2GraphicsContextPtr Ctx;
+  double FrameWidth;
+  double FrameHeight;
+  double FrameCX;
+  double FrameCY;
+  double FrameExtentX;
+  double FrameExtentY;
+  double FrameMinX;
+  double FrameMinY;
+  double FrameMaxX;
+  double FrameMaxY;
+  double PixelRatio;
+  wxGauge *ProgressControl;
+  WmsGetMapRequest *FirstRequest;
+  WmsGetMapRequest *LastRequest;
+  void InitPreserveScale();
+  void InitPreserveWidth();
+  void InitPreserveHeight();
+  void AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                        const char *version,
+                        const char *layer,
+                        const char *crs, int swap_xy,
+                        double minx, double miny,
+                        double maxx, double maxy,
+                        int width, int height,
+                        const char *style, const char *format, int opaque);
+  void AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                        const char *layer, int swap_xy,
+                        double minx, double miny,
+                        double maxx, double maxy, int width, int height,
+                        WmsTilePattern * tilepattern);
+  int CountGetMapRequests();
+public:
+    PdfPrinter(MyFrame * parent, const char *path, int dpi, double page_w,
+               double page_h, double horz_margin_sz, double vert_margin_sz,
+               bool preserve_scale, bool preserve_width, bool preserve_height);
+   ~PdfPrinter();
+  void Go();
+  MyMapView *GetMapView()
+  {
+    return MapView;
+  }
+  bool IsValid()
+  {
+    if (Ctx == NULL)
+      return false;
+    return true;
+  }
+  void Consider(void);
+  void UpdatePendingTiles();
+  void Consider(const char *layer_name);
+  void PrintTile(unsigned char *rgba, int pos_x, int pos_y, int width,
+                 int height);
+  WmsGetMapRequest *GetFirstRequest()
+  {
+    return FirstRequest;
+  }
+};
+
+class TiffWriter
+{
+//
+// a class implementing the Map TIFF printer
+//
+private:
+  MyFrame * MainFrame;
+  MyMapView *MapView;
+  char *Path;
+  int FrameWidth;
+  int FrameHeight;
+  unsigned char *Pixels;
+  unsigned int TotPixels;
+  unsigned int MonoPixels;
+  unsigned int GrayPixels;
+  unsigned char Red[256];
+  unsigned char Green[256];
+  unsigned char Blue[256];
+  int MaxPalette;
+  bool GeoTiff;
+  bool Worldfile;
+  unsigned char Compression;
+  int IsTiled;
+  int TileSize;
+  unsigned char ColorSpace;
+  double FrameCX;
+  double FrameCY;
+  double FrameExtentX;
+  double FrameExtentY;
+  double FrameMinX;
+  double FrameMinY;
+  double FrameMaxX;
+  double FrameMaxY;
+  double PixelRatio;
+  wxGauge *ProgressControl;
+  WmsGetMapRequest *FirstRequest;
+  WmsGetMapRequest *LastRequest;
+  void InitPreserveScale();
+  void InitPreserveWidth();
+  void InitPreserveHeight();
+  void AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                        const char *version,
+                        const char *layer,
+                        const char *crs, int swap_xy,
+                        double minx, double miny,
+                        double maxx, double maxy,
+                        int width, int height,
+                        const char *style, const char *format, int opaque);
+  void AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                        const char *layer, int swap_xy,
+                        double minx, double miny,
+                        double maxx, double maxy, int width, int height,
+                        WmsTilePattern * tilepattern);
+  int CountGetMapRequests();
+public:
+    TiffWriter(MyFrame * parent, const char *path, int width, int height,
+               bool geo_tiff, bool has_worldfile, unsigned char compression,
+               bool is_tiled, int tile_strip_size, bool preserve_scale,
+               bool preserve_width, bool preserve_height);
+   ~TiffWriter();
+  bool IsValid()
+  {
+    if (Pixels == NULL)
+      return false;
+    return true;
+  }
+  bool IsMonochrome()
+  {
+    if (MonoPixels == TotPixels)
+      return true;
+    else
+      return false;
+  }
+  bool IsGrayscale()
+  {
+    if (GrayPixels == TotPixels)
+      return true;
+    else
+      return false;
+  }
+  bool IsPalette()
+  {
+    if (MaxPalette <= 256)
+      return true;
+    else
+      return false;
+  }
+  unsigned char FindPaletteIndex(unsigned char red, unsigned char green,
+                                 unsigned char blue);
+  void SetColorSpace(unsigned char cs)
+  {
+    ColorSpace = cs;
+  }
+  unsigned char GetCompression()
+  {
+    return Compression;
+  }
+  void SetCompression(unsigned char compression)
+  {
+    Compression = compression;
+  }
+  int GetSrid();
+  void Go();
+  MyMapView *GetMapView()
+  {
+    return MapView;
+  }
+  void Consider(void);
+  void UpdatePendingTiles();
+  void Consider(const char *layer_name);
+  void PrintTile(unsigned char *rgba, int pos_x, int pos_y, int width,
+                 int height);
+  WmsGetMapRequest *GetFirstRequest()
+  {
+    return FirstRequest;
+  }
+  rl2PalettePtr BuildPalette();
+  void ExportImage();
+};
+
+class TiffMonochromeDialog:public wxDialog
+{
+//
+// a dialog supporting Monochrome TIFF export
+//
+private:
+  MyMapView * Parent;
+  bool Monochrome;
+  unsigned char Compression;
+public:
+    TiffMonochromeDialog()
+  {;
+  }
+  virtual ~ TiffMonochromeDialog()
+  {;
+  }
+  bool Create(MyMapView * parent);
+  void CreateControls();
+  bool IsMonochrome()
+  {
+    return Monochrome;
+  }
+  unsigned char GetCompression()
+  {
+    return Compression;
+  }
+  void OnColorspaceChanged(wxCommandEvent & event);
+  void OnOk(wxCommandEvent & event);
+};
+
+class TiffGrayscaleDialog:public wxDialog
+{
+//
+// a dialog supporting Grayscale TIFF export
+//
+private:
+  MyMapView * Parent;
+  bool Grayscale;
+  unsigned char Compression;
+public:
+    TiffGrayscaleDialog()
+  {;
+  }
+  virtual ~ TiffGrayscaleDialog()
+  {;
+  }
+  bool Create(MyMapView * parent, unsigned char compression);
+  void CreateControls();
+  bool IsGrayscale()
+  {
+    return Grayscale;
+  }
+  unsigned char GetCompression()
+  {
+    return Compression;
+  }
+  void OnColorspaceChanged(wxCommandEvent & event);
+  void OnOk(wxCommandEvent & event);
+};
+
+class TiffPaletteDialog:public wxDialog
+{
+//
+// a dialog supporting Palette TIFF export
+//
+private:
+  MyMapView * Parent;
+  bool Palette;
+  unsigned char Compression;
+public:
+    TiffPaletteDialog()
+  {;
+  }
+  virtual ~ TiffPaletteDialog()
+  {;
+  }
+  bool Create(MyMapView * parent, unsigned char compression);
+  void CreateControls();
+  bool IsPalette()
+  {
+    return Palette;
+  }
+  unsigned char GetCompression()
+  {
+    return Compression;
+  }
+  void OnColorspaceChanged(wxCommandEvent & event);
+  void OnOk(wxCommandEvent & event);
+};
diff --git a/Dialogs.cpp b/Dialogs.cpp
new file mode 100644
index 0000000..d43acae
--- /dev/null
+++ b/Dialogs.cpp
@@ -0,0 +1,4396 @@
+/*
+/ Dialogs.cpp
+/ misc dialogs
+/
+/ version 1.0, 2013 July 28
+/
+/ Author: Sandro Furieri a-furieri at lqt.it
+/
+/ Copyright (C) 2013  Alessandro Furieri
+/
+/    This program is free software: you can redistribute it and/or modify
+/    it under the terms of the GNU General Public License as published by
+/    the Free Software Foundation, either version 3 of the License, or
+/    (at your option) any later version.
+/
+/    This program is distributed in the hope that it will be useful,
+/    but WITHOUT ANY WARRANTY; without even the implied warranty of
+/    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+/    GNU General Public License for more details.
+/
+/    You should have received a copy of the GNU General Public License
+/    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+/
+*/
+
+#include <float.h>
+
+#include "Classdef.h"
+
+#include "wx/clipbrd.h"
+
+bool PredefinedWmsDialog::Create(MyFrame * parent, sqlite3 * sqlite)
+{
+//
+// creating the dialog
+//
+  MainFrame = parent;
+  SQLiteHandle = sqlite;
+  CurrentEvtRow = -1;
+  CurrentEvtColumn = -1;
+  if (wxDialog::Create(parent, wxID_ANY,
+                       wxT("Select a pre-defined WMS datasource")) == false)
+    return false;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  return true;
+}
+
+void PredefinedWmsDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// filters group box
+  wxBoxSizer *filterSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(filterSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *filterBox = new wxStaticBox(this, wxID_STATIC,
+                                           wxT("Filters"),
+                                           wxDefaultPosition,
+                                           wxDefaultSize);
+  wxBoxSizer *filterBoxSizer = new wxStaticBoxSizer(filterBox, wxHORIZONTAL);
+  filterSizer->Add(filterBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+// Filter by Country
+  wxStaticBox *countryFilterBox = new wxStaticBox(this, wxID_STATIC,
+                                                  wxT("by Country"),
+                                                  wxDefaultPosition,
+                                                  wxDefaultSize);
+  wxBoxSizer *countryFilterBoxSizer =
+    new wxStaticBoxSizer(countryFilterBox, wxHORIZONTAL);
+  filterBoxSizer->Add(countryFilterBoxSizer, 0,
+                      wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  CountryList =
+    new wxComboBox(this, ID_FILTER_COUNTRY, wxT(""), wxDefaultPosition,
+                   wxSize(150, 21), 0, NULL, wxCB_DROPDOWN | wxCB_READONLY);
+  PopulateCountries();
+  countryFilterBoxSizer->Add(CountryList, 0, wxALIGN_CENTER_HORIZONTAL | wxALL,
+                             0);
+// Filter by State or Province
+  filterBoxSizer->AddSpacer(10);
+  wxStaticBox *stateFilterBox = new wxStaticBox(this, wxID_STATIC,
+                                                wxT("by State or Province"),
+                                                wxDefaultPosition,
+                                                wxDefaultSize);
+  wxBoxSizer *stateFilterBoxSizer =
+    new wxStaticBoxSizer(stateFilterBox, wxHORIZONTAL);
+  filterBoxSizer->Add(stateFilterBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL,
+                      0);
+  StateList =
+    new wxComboBox(this, ID_FILTER_STATE, wxT(""), wxDefaultPosition,
+                   wxSize(150, 21), 0, NULL, wxCB_DROPDOWN | wxCB_READONLY);
+  PopulateStates();
+  stateFilterBoxSizer->Add(StateList, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+// Filter by Category
+  filterBoxSizer->AddSpacer(10);
+  wxStaticBox *categFilterBox = new wxStaticBox(this, wxID_STATIC,
+                                                wxT("by Category"),
+                                                wxDefaultPosition,
+                                                wxDefaultSize);
+  wxBoxSizer *categFilterBoxSizer =
+    new wxStaticBoxSizer(categFilterBox, wxHORIZONTAL);
+  filterBoxSizer->Add(categFilterBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL,
+                      0);
+  CategoryList =
+    new wxComboBox(this, ID_FILTER_CATEGORY, wxT(""), wxDefaultPosition,
+                   wxSize(150, 21), 0, NULL, wxCB_DROPDOWN | wxCB_READONLY);
+  PopulateCategories();
+  categFilterBoxSizer->Add(CategoryList, 0, wxALIGN_CENTER_HORIZONTAL | wxALL,
+                           0);
+// the pre-defined datasources Grid
+  wxBoxSizer *gridSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(gridSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  WmsView = new wxGrid(this, wxID_ANY, wxPoint(5, 5), wxSize(700, 300));
+  WmsView->CreateGrid(1, 4);
+  WmsView->EnableEditing(false);
+  WmsView->SetColLabelValue(0, wxT("Country"));
+  WmsView->SetColLabelValue(1, wxT("State or Province"));
+  WmsView->SetColLabelValue(2, wxT("Category"));
+  WmsView->SetColLabelValue(3, wxT("WMS GetCapabilities URL"));
+  gridSizer->Add(WmsView, 0, wxALIGN_RIGHT | wxALL, 5);
+  PopulateGrid();
+// selected WMS datasource group box
+  wxBoxSizer *kkSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(kkSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *dsBox = new wxStaticBox(this, wxID_STATIC,
+                                       wxT("Selected WMS Datasource"),
+                                       wxDefaultPosition,
+                                       wxDefaultSize);
+  wxBoxSizer *dsBox0Sizer = new wxStaticBoxSizer(dsBox, wxHORIZONTAL);
+  kkSizer->Add(dsBox0Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+// Second row: datasource info
+  wxBoxSizer *dsBoxSizer = new wxBoxSizer(wxVERTICAL);
+  dsBox0Sizer->Add(dsBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxBoxSizer *countrySizer = new wxBoxSizer(wxHORIZONTAL);
+  dsBoxSizer->Add(countrySizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxStaticText *countryLabel =
+    new wxStaticText(this, wxID_STATIC, wxT("&Country:"));
+  countrySizer->Add(countryLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxTextCtrl *countryCtrl = new wxTextCtrl(this, ID_WMS_COUNTRY, wxT(""),
+                                           wxDefaultPosition, wxSize(150, 22),
+                                           wxTE_READONLY);
+  countrySizer->Add(countryCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  countrySizer->AddSpacer(10);
+  wxStaticText *stateLabel =
+    new wxStaticText(this, wxID_STATIC, wxT("&State or Province:"));
+  countrySizer->Add(stateLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxTextCtrl *stateCtrl = new wxTextCtrl(this, ID_WMS_STATE, wxT(""),
+                                         wxDefaultPosition, wxSize(150, 22),
+                                         wxTE_READONLY);
+  countrySizer->Add(stateCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  countrySizer->AddSpacer(10);
+  wxStaticText *ctgLabel =
+    new wxStaticText(this, wxID_STATIC, wxT("&Category:"));
+  countrySizer->Add(ctgLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxTextCtrl *ctgCtrl = new wxTextCtrl(this, ID_WMS_CATEGORY, wxT(""),
+                                       wxDefaultPosition, wxSize(150, 22),
+                                       wxTE_READONLY);
+  countrySizer->Add(ctgCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxBoxSizer *urlSizer = new wxBoxSizer(wxHORIZONTAL);
+  dsBoxSizer->Add(urlSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxTextCtrl *urlCtrl = new wxTextCtrl(this, ID_WMS_URL, wxT(""),
+                                       wxDefaultPosition, wxSize(700, 22),
+                                       wxTE_READONLY);
+  urlSizer->Add(urlCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// OK-Cancel buttons
+  wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
+  dsBoxSizer->Add(btnSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *okBtn = new wxButton(this, wxID_OK, wxT("&OK"));
+  okBtn->Enable(false);
+  btnSizer->Add(okBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxButton *cancelBtn = new wxButton(this, wxID_CANCEL, wxT("&Cancel"));
+  btnSizer->Add(cancelBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// appends event handlers
+  Connect(wxID_ANY, wxEVT_GRID_CELL_LEFT_CLICK,
+          (wxObjectEventFunction) & PredefinedWmsDialog::OnLeftClick);
+  Connect(wxID_ANY, wxEVT_GRID_CELL_RIGHT_CLICK,
+          (wxObjectEventFunction) & PredefinedWmsDialog::OnRightClick);
+  Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & PredefinedWmsDialog::OnOk);
+  Connect(wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & PredefinedWmsDialog::OnCancel);
+  Connect(Wms_Copy, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & PredefinedWmsDialog::OnCmdCopy);
+  Connect(Wms_Datasource, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) &
+          PredefinedWmsDialog::OnCmdSelectWmsDatasource);
+  Connect(ID_FILTER_COUNTRY, wxEVT_COMMAND_COMBOBOX_SELECTED,
+          (wxObjectEventFunction) & PredefinedWmsDialog::OnCountrySelected);
+  Connect(ID_FILTER_STATE, wxEVT_COMMAND_COMBOBOX_SELECTED,
+          (wxObjectEventFunction) & PredefinedWmsDialog::OnStateSelected);
+  Connect(ID_FILTER_CATEGORY, wxEVT_COMMAND_COMBOBOX_SELECTED,
+          (wxObjectEventFunction) & PredefinedWmsDialog::OnCategorySelected);
+}
+
+void PredefinedWmsDialog::PopulateCountries()
+{
+//
+// populating the Countries list
+//
+  int ret;
+  const char *sql;
+  char **results;
+  int rows;
+  int columns;
+  CountryList->Clear();
+  CountryList->Append(wxT(""));
+
+  sql = "SELECT DISTINCT country FROM wms_list ORDER BY country";
+  ret = sqlite3_get_table(SQLiteHandle, sql, &results, &rows, &columns, NULL);
+  if (ret != SQLITE_OK)
+    goto skip;
+
+  for (int i = 1; i <= rows; i++)
+    {
+      // populating the list
+      wxString country = wxString::FromUTF8(results[(i * columns) + 0]);
+      CountryList->Append(country);
+    }
+  sqlite3_free_table(results);
+skip:
+  CountryList->SetSelection(0);
+}
+
+void PredefinedWmsDialog::PopulateStates()
+{
+//
+// populating the States list
+//
+  int ret;
+  char *sql;
+  char *filter = NULL;
+  char **results;
+  int rows;
+  int columns;
+  StateList->Clear();
+  StateList->Append(wxT(""));
+
+// preparing the filter clause
+  if (CountryFilter != NULL)
+    filter = sqlite3_mprintf("country = %Q", CountryFilter);
+
+// preparing the SQL query
+  if (filter == NULL)
+    sql =
+      sqlite3_mprintf
+      ("SELECT DISTINCT state_province FROM wms_list ORDER BY state_province");
+  else
+    {
+      sql = sqlite3_mprintf("SELECT DISTINCT state_province  "
+                            "FROM wms_list WHERE %s ORDER BY state_province",
+                            filter);
+      sqlite3_free(filter);
+    }
+  ret = sqlite3_get_table(SQLiteHandle, sql, &results, &rows, &columns, NULL);
+  sqlite3_free(sql);
+  if (ret != SQLITE_OK)
+    goto skip;
+
+  for (int i = 1; i <= rows; i++)
+    {
+      // populating the list
+      wxString country = wxString::FromUTF8(results[(i * columns) + 0]);
+      StateList->Append(country);
+    }
+  sqlite3_free_table(results);
+skip:
+  StateList->SetSelection(0);
+  if (StateFilter != NULL)
+    delete[]StateFilter;
+  StateFilter = NULL;
+}
+
+void PredefinedWmsDialog::PopulateCategories()
+{
+//
+// populating the Categories list
+//
+  int ret;
+  char *sql;
+  char *filter = NULL;
+  char **results;
+  int rows;
+  int columns;
+  CategoryList->Clear();
+  CategoryList->Append(wxT(""));
+
+// preparing the filter clause
+  if (CountryFilter != NULL && StateFilter != NULL)
+    filter =
+      sqlite3_mprintf("country = %Q AND state_province = %Q", CountryFilter,
+                      StateFilter);
+  else if (CountryFilter != NULL)
+    filter = sqlite3_mprintf("country = %Q", CountryFilter);
+  else if (StateFilter != NULL)
+    filter = sqlite3_mprintf("state_province = %Q", StateFilter);
+
+// preparing the SQL query
+  if (filter == NULL)
+    sql =
+      sqlite3_mprintf
+      ("SELECT DISTINCT category FROM wms_list ORDER BY category");
+  else
+    {
+      sql = sqlite3_mprintf("SELECT DISTINCT category  "
+                            "FROM wms_list WHERE %s ORDER BY category", filter);
+      sqlite3_free(filter);
+    }
+  ret = sqlite3_get_table(SQLiteHandle, sql, &results, &rows, &columns, NULL);
+  sqlite3_free(sql);
+  if (ret != SQLITE_OK)
+    goto skip;
+
+  for (int i = 1; i <= rows; i++)
+    {
+      // populating the list
+      wxString country = wxString::FromUTF8(results[(i * columns) + 0]);
+      CategoryList->Append(country);
+    }
+  sqlite3_free_table(results);
+skip:
+  CategoryList->SetSelection(0);
+  if (CategoryFilter != NULL)
+    delete[]CategoryFilter;
+  CategoryFilter = NULL;
+}
+
+void PredefinedWmsDialog::PopulateGrid()
+{
+//
+// populating the Grid
+//
+  int ret;
+  char *sql;
+  char *filter = NULL;
+  char **results;
+  int rows;
+  int columns;
+
+  WmsView->ClearGrid();
+  WmsView->Show(false);
+  WmsView->ClearSelection();
+  CurrentEvtRow = -1;
+  CurrentEvtColumn = -1;
+  int nr = WmsView->GetNumberRows();
+  WmsView->DeleteRows(0, nr);
+
+// preparing the filter clause
+  if (CountryFilter != NULL && StateFilter != NULL && CategoryFilter != NULL)
+    filter =
+      sqlite3_mprintf("country = %Q AND state_province = %Q AND category = %Q",
+                      CountryFilter, StateFilter, CategoryFilter);
+  else if (CountryFilter != NULL && StateFilter != NULL)
+    filter =
+      sqlite3_mprintf("country = %Q AND state_province = %Q", CountryFilter,
+                      StateFilter);
+  else if (StateFilter != NULL && CategoryFilter != NULL)
+    filter =
+      sqlite3_mprintf("state_province = %Q AND category = %Q", StateFilter,
+                      CategoryFilter);
+  else if (CountryFilter != NULL && CategoryFilter != NULL)
+    filter =
+      sqlite3_mprintf("country = %Q AND category = %Q", CountryFilter,
+                      CategoryFilter);
+  else if (CountryFilter != NULL)
+    filter = sqlite3_mprintf("country = %Q", CountryFilter);
+  else if (StateFilter != NULL)
+    filter = sqlite3_mprintf("state_province = %Q", StateFilter);
+  else if (CategoryFilter != NULL)
+    filter = sqlite3_mprintf("category = %Q", CategoryFilter);
+
+// preparing the SQL query
+  if (filter == NULL)
+    sql = sqlite3_mprintf("SELECT country, state_province, category, url "
+                          "FROM wms_list ORDER BY country, state_province, category");
+  else
+    {
+      sql = sqlite3_mprintf("SELECT country, state_province, category, url "
+                            "FROM wms_list WHERE %s "
+                            "ORDER BY country, state_province, category",
+                            filter);
+      sqlite3_free(filter);
+    }
+  ret = sqlite3_get_table(SQLiteHandle, sql, &results, &rows, &columns, NULL);
+  sqlite3_free(sql);
+  if (ret != SQLITE_OK)
+    goto skip;
+
+  if (rows >= 1)
+    WmsView->AppendRows(rows);
+  for (int i = 1; i <= rows; i++)
+    {
+      // populating the WMS List
+      wxString country = wxString::FromUTF8(results[(i * columns) + 0]);
+      wxString state = wxString::FromUTF8(results[(i * columns) + 1]);
+      wxString category = wxString::FromUTF8(results[(i * columns) + 2]);
+      wxString url = wxString::FromUTF8(results[(i * columns) + 3]);
+      WmsView->SetCellValue(i - 1, 0, country);
+      WmsView->SetCellValue(i - 1, 1, state);
+      WmsView->SetCellValue(i - 1, 2, category);
+      WmsView->SetCellValue(i - 1, 3, url);
+    }
+  sqlite3_free_table(results);
+
+skip:
+  WmsView->SetRowLabelSize(wxGRID_AUTOSIZE);
+  WmsView->AutoSize();
+  WmsView->SetSize(700, 300);
+  WmsView->Show(true);
+}
+
+void PredefinedWmsDialog::OnCountrySelected(wxCommandEvent & WXUNUSED(event))
+{
+//
+// Country Filter selection changed
+//
+  wxString filter = CountryList->GetValue();
+  if (filter.Len() == 0)
+    {
+      if (CountryFilter != NULL)
+        delete[]CountryFilter;
+      CountryFilter = NULL;
+  } else
+    {
+      if (CountryFilter != NULL)
+        delete[]CountryFilter;
+      CountryFilter = new char[filter.Len() + 1];
+      strcpy(CountryFilter, filter.ToUTF8());
+    }
+  PopulateStates();
+  PopulateCategories();
+  PopulateGrid();
+}
+
+void PredefinedWmsDialog::OnStateSelected(wxCommandEvent & WXUNUSED(event))
+{
+//
+// State Filter selection changed
+//
+  wxString filter = StateList->GetValue();
+  if (filter.Len() == 0)
+    {
+      if (StateFilter != NULL)
+        delete[]StateFilter;
+      StateFilter = NULL;
+  } else
+    {
+      if (StateFilter != NULL)
+        delete[]StateFilter;
+      StateFilter = new char[filter.Len() + 1];
+      strcpy(StateFilter, filter.ToUTF8());
+    }
+  PopulateCategories();
+  PopulateGrid();
+}
+
+void PredefinedWmsDialog::OnCategorySelected(wxCommandEvent & WXUNUSED(event))
+{
+//
+// Category Filter selection changed
+//
+  wxString filter = CategoryList->GetValue();
+  if (filter.Len() == 0)
+    {
+      if (CategoryFilter != NULL)
+        delete[]CategoryFilter;
+      CategoryFilter = NULL;
+  } else
+    {
+      if (CategoryFilter != NULL)
+        delete[]CategoryFilter;
+      CategoryFilter = new char[filter.Len() + 1];
+      strcpy(CategoryFilter, filter.ToUTF8());
+    }
+  PopulateGrid();
+}
+
+void PredefinedWmsDialog::OnLeftClick(wxGridEvent & event)
+{
+//
+// left click on some cell [mouse action]
+//
+  int previous = CurrentEvtRow;
+  CurrentEvtRow = event.GetRow();
+  CurrentEvtColumn = event.GetCol();
+  if (CurrentEvtRow != previous)
+    SelectWmsDatasource();
+}
+
+void PredefinedWmsDialog::OnRightClick(wxGridEvent & event)
+{
+//
+// right click on some cell [mouse action]
+//
+  wxMenu *menu = new wxMenu();
+  wxMenuItem *menuItem;
+  wxPoint pt = event.GetPosition();
+  CurrentEvtRow = event.GetRow();
+  CurrentEvtColumn = event.GetCol();
+  menuItem =
+    new wxMenuItem(menu, Wms_Datasource,
+                   wxT("Select as the current WMS &Datasource"));
+  menu->Append(menuItem);
+  menu->AppendSeparator();
+  menuItem =
+    new wxMenuItem(menu, Wms_Copy, wxT("&Copy the whole pre-defined WMS List"));
+  menu->Append(menuItem);
+  WmsView->PopupMenu(menu, pt);
+}
+
+void PredefinedWmsDialog::OnCmdCopy(wxCommandEvent & WXUNUSED(event))
+{
+//
+// copying all WMS Datasources definitions into the clipboard
+//
+  wxString copyData;
+  int row;
+  int col;
+  for (row = 0; row < WmsView->GetNumberRows(); row++)
+    {
+      for (col = 0; col < WmsView->GetNumberCols(); col++)
+        {
+          if (col != 0)
+            copyData += wxT("\t");
+          copyData += WmsView->GetCellValue(row, col);
+        }
+      copyData += wxT("\n");
+    }
+  if (wxTheClipboard->Open())
+    {
+      wxTheClipboard->SetData(new wxTextDataObject(copyData));
+      wxTheClipboard->Close();
+    }
+}
+
+void PredefinedWmsDialog::
+OnCmdSelectWmsDatasource(wxCommandEvent & WXUNUSED(event))
+{
+//
+// setting the currently selected WMS Layer
+//
+  SelectWmsDatasource();
+}
+
+void PredefinedWmsDialog::SelectWmsDatasource()
+{
+//
+// setting the currently selected WMS Datasource
+//
+  WmsView->Show(false);
+  WmsView->ClearSelection();
+  WmsView->SelectRow(CurrentEvtRow);
+  WmsView->Show(true);
+  wxString country = WmsView->GetCellValue(CurrentEvtRow, 0);
+  wxTextCtrl *countryCtrl = (wxTextCtrl *) FindWindow(ID_WMS_COUNTRY);
+  countryCtrl->SetValue(country);
+  wxString state = WmsView->GetCellValue(CurrentEvtRow, 1);
+  wxTextCtrl *stateCtrl = (wxTextCtrl *) FindWindow(ID_WMS_STATE);
+  stateCtrl->SetValue(state);
+  wxString category = WmsView->GetCellValue(CurrentEvtRow, 2);
+  wxTextCtrl *categoryCtrl = (wxTextCtrl *) FindWindow(ID_WMS_CATEGORY);
+  categoryCtrl->SetValue(category);
+  wxString url = WmsView->GetCellValue(CurrentEvtRow, 3);
+  wxTextCtrl *urlCtrl = (wxTextCtrl *) FindWindow(ID_WMS_URL);
+  urlCtrl->SetValue(url);
+  wxButton *btn = (wxButton *) FindWindow(wxID_OK);
+  btn->Enable(true);
+}
+
+void PredefinedWmsDialog::OnCancel(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxDialog::EndModal(wxID_CANCEL);
+}
+
+void PredefinedWmsDialog::OnOk(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxTextCtrl *urlCtrl = (wxTextCtrl *) FindWindow(ID_WMS_URL);
+  URL = urlCtrl->GetValue();
+  wxDialog::EndModal(wxID_OK);
+}
+
+bool WmsDialog::Create(MyFrame * parent, wxString & proxy, bool immediate)
+{
+//
+// creating the dialog
+//
+  MainFrame = parent;
+  SwapXY = 0;
+  HttpProxy = proxy;
+  if (HttpProxy.Len() == 0)
+    ProxyEnabled = false;
+  else
+    ProxyEnabled = true;
+  if (wxDialog::Create(parent, wxID_ANY, wxT("Open a WMS datasource")) == false)
+    return false;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  if (immediate == true)
+    {
+      ::wxBeginBusyCursor();
+      PrepareCatalog();
+      ::wxEndBusyCursor();
+      UpdateSwapXY();
+    }
+  return true;
+}
+
+void WmsDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// HTTP Proxy
+  wxStaticBox *proxyBox = new wxStaticBox(this, wxID_STATIC,
+                                          wxT("HTTP Proxy"),
+                                          wxDefaultPosition,
+                                          wxDefaultSize);
+  wxBoxSizer *proxyBoxSizer = new wxStaticBoxSizer(proxyBox, wxHORIZONTAL);
+  boxSizer->Add(proxyBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 2);
+  wxCheckBox *enableProxyCtrl = new wxCheckBox(this, ID_WMS_ENABLE_PROXY,
+                                               wxT("Enable"),
+                                               wxDefaultPosition,
+                                               wxDefaultSize);
+  enableProxyCtrl->SetValue(ProxyEnabled);
+  proxyBoxSizer->Add(enableProxyCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxTextCtrl *proxyCtrl = new wxTextCtrl(this, ID_WMS_PROXY, HttpProxy,
+                                         wxDefaultPosition, wxSize(600, 22));
+  proxyBoxSizer->Add(proxyCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  proxyCtrl->Enable(ProxyEnabled);
+// URL group box
+  wxStaticBox *urlBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("WMS URL - GetCapabilities"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *urlBoxSizer = new wxStaticBoxSizer(urlBox, wxVERTICAL);
+  boxSizer->Add(urlBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+// First row: GetCapabilities URL
+  wxBoxSizer *urlSizer = new wxBoxSizer(wxVERTICAL);
+  urlBoxSizer->Add(urlSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxTextCtrl *urlCtrl = new wxTextCtrl(this, ID_WMS_URL, wxT("http://"),
+                                       wxDefaultPosition, wxSize(680, 22));
+  urlSizer->Add(urlCtrl, 0, wxALIGN_RIGHT | wxALL, 5);
+  urlCtrl->SetValue(MainFrame->GetCurrentWmsDatasource());
+// command buttons
+  wxBoxSizer *url2Sizer = new wxBoxSizer(wxHORIZONTAL);
+  urlSizer->Add(url2Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxStaticBox *catBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("WMS Catalog"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *catBoxSizer = new wxStaticBoxSizer(catBox, wxVERTICAL);
+  url2Sizer->Add(catBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+  wxBoxSizer *okCancelBox = new wxBoxSizer(wxHORIZONTAL);
+  catBoxSizer->Add(okCancelBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *query = new wxButton(this, ID_WMS_CATALOG, wxT("&Load"));
+  okCancelBox->Add(query, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxButton *reset = new wxButton(this, ID_WMS_RESET, wxT("&Reset"));
+  reset->Enable(false);
+  okCancelBox->Add(reset, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxButton *quit = new wxButton(this, wxID_CANCEL, wxT("&Quit"));
+  okCancelBox->Add(quit, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+// the Catalog tree view
+  wxBoxSizer *treeSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(treeSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  WmsTree = new MyCatalogTree(this, wxSize(330, 250));
+  treeSizer->Add(WmsTree, 0, wxALIGN_LEFT | wxALL, 5);
+// Title / Abstract panel
+  wxBoxSizer *title0BoxSizer = new wxBoxSizer(wxVERTICAL);
+  treeSizer->Add(title0BoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxStaticBox *titleBox = new wxStaticBox(this, wxID_ANY,
+                                          wxT("Layer Title"),
+                                          wxDefaultPosition,
+                                          wxDefaultSize);
+  wxBoxSizer *titleBoxSizer = new wxStaticBoxSizer(titleBox, wxHORIZONTAL);
+  title0BoxSizer->Add(titleBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxHtmlWindow *titleCtrl = new wxHtmlWindow(this, ID_WMS_TITLE,
+                                             wxDefaultPosition, wxSize(350,
+                                                                       75));
+  titleBoxSizer->Add(titleCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxStaticBox *abstractBox = new wxStaticBox(this, wxID_ANY,
+                                             wxT("Layer Abstract"),
+                                             wxDefaultPosition,
+                                             wxDefaultSize);
+  wxBoxSizer *abstractBoxSizer =
+    new wxStaticBoxSizer(abstractBox, wxHORIZONTAL);
+  title0BoxSizer->Add(abstractBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxHtmlWindow *abstractCtrl = new wxHtmlWindow(this, ID_WMS_ABSTRACT,
+                                                wxDefaultPosition, wxSize(350,
+                                                                          120));
+  abstractBoxSizer->Add(abstractCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+// selected Layer group box
+  wxBoxSizer *kkSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(kkSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *lyrBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("Selected WMS Layer"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *lyrBox0Sizer = new wxStaticBoxSizer(lyrBox, wxHORIZONTAL);
+  kkSizer->Add(lyrBox0Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+// Second row: Layer name
+  wxBoxSizer *lyrBoxSizer = new wxBoxSizer(wxVERTICAL);
+  lyrBox0Sizer->Add(lyrBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxBoxSizer *nameSizer = new wxBoxSizer(wxHORIZONTAL);
+  lyrBoxSizer->Add(nameSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxStaticBox *nameBox = new wxStaticBox(this, wxID_ANY,
+                                         wxT("Layer Name"),
+                                         wxDefaultPosition,
+                                         wxDefaultSize);
+  wxBoxSizer *nameBoxSizer = new wxStaticBoxSizer(nameBox, wxHORIZONTAL);
+  nameSizer->Add(nameBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxTextCtrl *nameCtrl = new wxTextCtrl(this, ID_WMS_NAME, wxT(""),
+                                        wxDefaultPosition, wxSize(570, 22),
+                                        wxTE_READONLY);
+  nameBoxSizer->Add(nameCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxStaticBox *swapBox = new wxStaticBox(this, wxID_ANY,
+                                         wxT("Swap Axes"),
+                                         wxDefaultPosition,
+                                         wxDefaultSize);
+  wxBoxSizer *swapBoxSizer = new wxStaticBoxSizer(swapBox, wxHORIZONTAL);
+  nameSizer->Add(swapBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxCheckBox *swapCtrl = new wxCheckBox(this, ID_WMS_SWAP,
+                                        wxT("Swap Y,X"),
+                                        wxDefaultPosition, wxDefaultSize);
+  swapCtrl->SetValue(false);
+  swapCtrl->Enable(false);
+  swapBoxSizer->Add(swapCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// First row: WMS options
+  wxBoxSizer *wmsSizer = new wxBoxSizer(wxHORIZONTAL);
+  lyrBoxSizer->Add(wmsSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxString ver[4];
+  ver[0] = wxT("WMS &1.0.0");
+  ver[1] = wxT("WMS &1.1.0");
+  ver[2] = wxT("WMS &1.1.1");
+  ver[3] = wxT("WMS &1.3.0");
+  wxRadioBox *versionBox = new wxRadioBox(this, ID_WMS_VERSION,
+                                          wxT("WMS &Version"),
+                                          wxDefaultPosition,
+                                          wxDefaultSize, 4,
+                                          ver, 4,
+                                          wxRA_SPECIFY_ROWS);
+  versionBox->Enable(false);
+  versionBox->SetSelection(3);
+  wmsSizer->Add(versionBox, 0, wxALIGN_TOP | wxALL, 5);
+  wxBoxSizer *xxSizer = new wxBoxSizer(wxVERTICAL);
+  wmsSizer->Add(xxSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *crsBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("Reference System"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *crsBoxSizer = new wxStaticBoxSizer(crsBox, wxVERTICAL);
+  xxSizer->Add(crsBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxComboBox *crsList =
+    new wxComboBox(this, ID_WMS_CRS, wxT(""), wxDefaultPosition,
+                   wxSize(150, 21), 0, NULL,
+                   wxCB_DROPDOWN | wxCB_SORT | wxCB_READONLY);
+  crsList->Enable(false);
+  crsBoxSizer->Add(crsList, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxStaticBox *stlBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("Style"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *stlBoxSizer = new wxStaticBoxSizer(stlBox, wxVERTICAL);
+  xxSizer->Add(stlBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxComboBox *stlList =
+    new wxComboBox(this, ID_WMS_STYLE, wxT(""), wxDefaultPosition,
+                   wxSize(150, 21), 0, NULL,
+                   wxCB_DROPDOWN | wxCB_SORT | wxCB_READONLY);
+  stlList->Enable(false);
+  stlBoxSizer->Add(stlList, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxBoxSizer *yySizer = new wxBoxSizer(wxVERTICAL);
+  wmsSizer->Add(yySizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *fmtBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("Image Format"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *fmtBoxSizer = new wxStaticBoxSizer(fmtBox, wxVERTICAL);
+  yySizer->Add(fmtBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxComboBox *fmtList =
+    new wxComboBox(this, ID_WMS_FORMAT, wxT(""), wxDefaultPosition,
+                   wxSize(150, 21), 0, NULL,
+                   wxCB_DROPDOWN | wxCB_SORT | wxCB_READONLY);
+  fmtList->Enable(false);
+  fmtBoxSizer->Add(fmtList, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxString trans[2];
+  trans[0] = wxT("yes");
+  trans[1] = wxT("opaque");
+  wxRadioBox *transBox = new wxRadioBox(this, ID_WMS_TRANSPARENT,
+                                        wxT("Transparent Layer"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize, 2,
+                                        trans, 2,
+                                        wxRA_SPECIFY_COLS);
+  transBox->Enable(false);
+  transBox->SetSelection(1);
+  yySizer->Add(transBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 2);
+  wxStaticBox *tileBox = new wxStaticBox(this, wxID_STATIC,
+                                         wxT("Tile size"),
+                                         wxDefaultPosition,
+                                         wxDefaultSize);
+  wxBoxSizer *tileBoxSizer = new wxStaticBoxSizer(tileBox, wxVERTICAL);
+  wmsSizer->Add(tileBoxSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxCheckBox *tiledCtrl = new wxCheckBox(this, ID_WMS_TILED,
+                                         wxT("enable Tiles"),
+                                         wxDefaultPosition, wxDefaultSize);
+  tiledCtrl->SetValue(false);
+  tiledCtrl->Enable(false);
+  tileBoxSizer->Add(tiledCtrl, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+  wxBoxSizer *tile1BoxSizer = new wxBoxSizer(wxHORIZONTAL);
+  tileBoxSizer->Add(tile1BoxSizer, 0, wxALIGN_RIGHT | wxALL, 0);
+  wxStaticText *wLabel = new wxStaticText(this, wxID_ANY, wxT("&Width:"),
+                                          wxDefaultPosition, wxDefaultSize,
+                                          wxALIGN_RIGHT);
+  tile1BoxSizer->Add(wLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxSpinCtrl *wCtrl = new wxSpinCtrl(this, ID_WMS_WIDTH, wxEmptyString,
+                                     wxDefaultPosition, wxSize(80, 20),
+                                     wxSP_ARROW_KEYS,
+                                     0, 0, 0);
+  wCtrl->Enable(false);
+  wCtrl->SetValue(wxT(""));
+  tile1BoxSizer->Add(wCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxBoxSizer *tile2BoxSizer = new wxBoxSizer(wxHORIZONTAL);
+  tileBoxSizer->Add(tile2BoxSizer, 0, wxALIGN_RIGHT | wxALL, 0);
+  wxStaticText *hLabel = new wxStaticText(this, wxID_ANY, wxT("&Height:"),
+                                          wxDefaultPosition, wxDefaultSize,
+                                          wxALIGN_RIGHT);
+  tile2BoxSizer->Add(hLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxSpinCtrl *hCtrl = new wxSpinCtrl(this, ID_WMS_HEIGHT, wxEmptyString,
+                                     wxDefaultPosition, wxSize(80, 20),
+                                     wxSP_ARROW_KEYS,
+                                     0, 0, 0);
+  tile2BoxSizer->Add(hCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  hCtrl->Enable(false);
+  hCtrl->SetValue(wxT(""));
+  wxButton *wms_ok = new wxButton(this, ID_WMS_OK, wxT("&Open"));
+  wms_ok->Enable(false);
+  wmsSizer->Add(wms_ok, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// appends event handlers
+  Connect(ID_WMS_ENABLE_PROXY, wxEVT_COMMAND_CHECKBOX_CLICKED,
+          (wxObjectEventFunction) & WmsDialog::OnProxy);
+  Connect(ID_WMS_CRS, wxEVT_COMMAND_COMBOBOX_SELECTED,
+          (wxObjectEventFunction) & WmsDialog::OnCrsChanged);
+  Connect(ID_WMS_VERSION, wxEVT_COMMAND_RADIOBOX_SELECTED,
+          (wxObjectEventFunction) & WmsDialog::OnVersionChanged);
+  Connect(ID_WMS_SWAP, wxEVT_COMMAND_CHECKBOX_CLICKED,
+          (wxObjectEventFunction) & WmsDialog::OnSwapXYChanged);
+  Connect(ID_WMS_TILED, wxEVT_COMMAND_CHECKBOX_CLICKED,
+          (wxObjectEventFunction) & WmsDialog::OnTiledChanged);
+  Connect(ID_WMS_CATALOG, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & WmsDialog::OnCatalog);
+  Connect(ID_WMS_RESET, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & WmsDialog::OnReset);
+  Connect(ID_WMS_OK, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & WmsDialog::OnWmsOk);
+  Connect(wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & WmsDialog::OnQuit);
+}
+
+void WmsDialog::OnProxy(wxCommandEvent & WXUNUSED(event))
+{
+//
+// enabling/disabling HTTP Proxy
+//
+  wxTextCtrl *proxy = (wxTextCtrl *) FindWindow(ID_WMS_PROXY);
+  if (ProxyEnabled == false)
+    ProxyEnabled = true;
+  else
+    ProxyEnabled = false;
+  proxy->Enable(ProxyEnabled);
+  if (ProxyEnabled == false)
+    {
+      HttpProxy = wxT("");
+      proxy->SetValue(wxT(""));
+    }
+}
+
+void WmsDialog::OnCrsChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// CRS changed: updating SWAP XY
+//
+  UpdateSwapXY();
+}
+
+void WmsDialog::OnVersionChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// Version changed: updating SWAP XY
+//
+  UpdateSwapXY();
+}
+
+void WmsDialog::UpdateSwapXY()
+{
+//
+// updating SWAP XY
+//
+  wxCheckBox *swapBox = (wxCheckBox *) FindWindow(ID_WMS_SWAP);
+  wxRadioBox *versionBox = (wxRadioBox *) FindWindow(ID_WMS_VERSION);
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  if (versionBox->GetSelection() != 3)
+    {
+      swapBox->SetValue(false);
+      SwapXY = 0;
+      return;
+    };
+  wxString value = comboCtrl->GetValue();
+  char *crs = new char[value.Len() + 1];
+  strcpy(crs, value.ToUTF8());
+  if (MainFrame->IsSwapXYcrs(crs) == true)
+    {
+      swapBox->SetValue(true);
+      SwapXY = 1;
+  } else
+    {
+      swapBox->SetValue(false);
+      SwapXY = 0;
+    }
+  delete[]crs;
+}
+
+void WmsDialog::SelectLayer()
+{
+//
+// setting the currently selected WMS Layer [NULL type]
+//
+  CurrentLayer = NULL;
+  CurrentTiledLayer = NULL;
+  wxTextCtrl *nameCtrl = (wxTextCtrl *) FindWindow(ID_WMS_NAME);
+  wxHtmlWindow *titleCtrl = (wxHtmlWindow *) FindWindow(ID_WMS_TITLE);
+  wxHtmlWindow *abstractCtrl = (wxHtmlWindow *) FindWindow(ID_WMS_ABSTRACT);
+  nameCtrl->SetValue(wxT(""));
+  nameCtrl->Enable(false);
+  titleCtrl->SetPage(wxT("<html><body></body></html>"));
+  titleCtrl->Enable(false);
+  abstractCtrl->SetPage(wxT("<html><body></body></html>"));
+  abstractCtrl->Enable(false);
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  comboCtrl->Clear();
+  comboCtrl->Enable(false);
+  comboCtrl = (wxComboBox *) FindWindow(ID_WMS_FORMAT);
+  comboCtrl->Clear();
+  comboCtrl->Enable(false);
+  comboCtrl = (wxComboBox *) FindWindow(ID_WMS_STYLE);
+  comboCtrl->Clear();
+  comboCtrl->Enable(false);
+  wxRadioBox *trans = (wxRadioBox *) FindWindow(ID_WMS_TRANSPARENT);
+  trans->Enable(false);
+  wxCheckBox *tiled = (wxCheckBox *) FindWindow(ID_WMS_TILED);
+  tiled->Enable(false);
+  wxRadioBox *versionBox = (wxRadioBox *) FindWindow(ID_WMS_VERSION);
+  versionBox->Enable(false);
+  wxCheckBox *swapBox = (wxCheckBox *) FindWindow(ID_WMS_SWAP);
+  swapBox->Enable(false);
+  wxButton *btn = (wxButton *) FindWindow(ID_WMS_OK);
+  btn->Enable(false);
+}
+
+void WmsDialog::SelectLayer(rl2WmsLayerPtr layer)
+{
+//
+// setting the currently selected WMS Layer [ordinary WMS layer]
+//
+  bool enabledLayer = true;
+  if (get_wms_layer_name(layer) == NULL)
+    enabledLayer = false;
+  CurrentLayer = layer;
+  CurrentTiledLayer = NULL;
+  wxTextCtrl *nameCtrl = (wxTextCtrl *) FindWindow(ID_WMS_NAME);
+  wxHtmlWindow *titleCtrl = (wxHtmlWindow *) FindWindow(ID_WMS_TITLE);
+  wxHtmlWindow *abstractCtrl = (wxHtmlWindow *) FindWindow(ID_WMS_ABSTRACT);
+  wxString lyr_name;
+  const char *x_name = get_wms_layer_name(layer);
+  lyr_name = wxString::FromUTF8(x_name);
+  nameCtrl->SetValue(lyr_name);
+  x_name = get_wms_layer_title(layer);
+  lyr_name = wxString::FromUTF8(x_name);
+  lyr_name.Replace(wxT("\n"), wxT("<br>"));
+  titleCtrl->SetPage(wxT("<html><body>") + lyr_name + wxT("</body></html>"));
+  x_name = get_wms_layer_abstract(layer);
+  lyr_name = wxString::FromUTF8(x_name);
+  lyr_name.Replace(wxT("\n"), wxT("<br>"));
+  abstractCtrl->SetPage(wxT("<html><body>") + lyr_name + wxT("</body></html>"));
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  comboCtrl->Clear();
+  int max = get_wms_layer_crs_count(layer);
+  if (max > 0)
+    {
+      for (int s = 0; s < max; s++)
+        {
+          wxString str = wxString::FromUTF8(get_wms_layer_crs(layer, s));
+          if (comboCtrl->FindString(str) == wxNOT_FOUND)
+            comboCtrl->Append(str);
+        }
+      wxString str = wxString::FromUTF8(MainFrame->GetMapCRS());
+      if (comboCtrl->SetStringSelection(str) == false)
+        {
+          str = wxString::FromUTF8(get_wms_layer_crs(layer, 0));
+          int sel = comboCtrl->FindString(str);
+          if (sel == wxNOT_FOUND)
+            comboCtrl->SetSelection(0);
+          else
+            comboCtrl->SetSelection(sel);
+        }
+      comboCtrl->Enable(enabledLayer);
+    }
+  comboCtrl = (wxComboBox *) FindWindow(ID_WMS_FORMAT);
+  comboCtrl->Clear();
+  max = get_wms_format_count(Catalog, 1);
+  if (max > 0)
+    {
+      for (int s = 0; s < max; s++)
+        {
+          wxString str = wxString::FromUTF8(get_wms_format(Catalog, s, 1));
+          if (comboCtrl->FindString(str) == wxNOT_FOUND)
+            comboCtrl->Append(str);
+        }
+      wxString str = wxString::FromUTF8(get_wms_format(Catalog, 0, 1));
+      int sel = comboCtrl->FindString(str);
+      if (sel == wxNOT_FOUND)
+        comboCtrl->SetSelection(0);
+      else
+        comboCtrl->SetSelection(sel);
+      comboCtrl->Enable(enabledLayer);
+    }
+  comboCtrl = (wxComboBox *) FindWindow(ID_WMS_STYLE);
+  comboCtrl->Clear();
+  max = get_wms_layer_style_count(layer);
+  if (max > 0)
+    {
+      for (int s = 0; s < max; s++)
+        {
+          wxString str = wxString::FromUTF8(get_wms_layer_style_name(layer, s));
+          if (comboCtrl->FindString(str) == wxNOT_FOUND)
+            comboCtrl->Append(str);
+        }
+      wxString str = wxString::FromUTF8(get_wms_layer_style_name(layer, 0));
+      int sel = comboCtrl->FindString(str);
+      if (sel == wxNOT_FOUND)
+        comboCtrl->SetSelection(0);
+      else
+        comboCtrl->SetSelection(sel);
+      comboCtrl->Enable(enabledLayer);
+    }
+  wxRadioBox *trans = (wxRadioBox *) FindWindow(ID_WMS_TRANSPARENT);
+  if (is_wms_layer_opaque(layer) <= 0)
+    {
+      trans->SetSelection(0);
+      trans->Enable(enabledLayer);
+  } else
+    {
+      trans->SetSelection(1);
+      trans->Enable(false);
+    }
+  wxCheckBox *tiled = (wxCheckBox *) FindWindow(ID_WMS_TILED);
+  tiled->SetValue(false);
+  tiled->Enable(enabledLayer);
+  wxRadioBox *versionBox = (wxRadioBox *) FindWindow(ID_WMS_VERSION);
+  versionBox->Enable(enabledLayer);
+  wxCheckBox *swapBox = (wxCheckBox *) FindWindow(ID_WMS_SWAP);
+  swapBox->Enable(enabledLayer);
+  wxButton *btn = (wxButton *) FindWindow(ID_WMS_OK);
+  btn->Enable(enabledLayer);
+  const char *version = get_wms_version(Catalog);
+  if (version == NULL)
+    {
+      versionBox->Enable(0, enabledLayer);
+      versionBox->Enable(1, false);
+      versionBox->Enable(2, false);
+      versionBox->Enable(3, false);
+      versionBox->SetSelection(0);
+  } else
+    {
+      if (strcmp(version, "1.3.0") == 0)
+        {
+          versionBox->Enable(0, enabledLayer);
+          versionBox->Enable(1, enabledLayer);
+          versionBox->Enable(2, enabledLayer);
+          versionBox->Enable(3, enabledLayer);
+          versionBox->SetSelection(3);
+      } else if (strcmp(version, "1.1.1") == 0)
+        {
+          versionBox->Enable(0, enabledLayer);
+          versionBox->Enable(1, enabledLayer);
+          versionBox->Enable(2, enabledLayer);
+          versionBox->Enable(3, false);
+          versionBox->SetSelection(2);
+      } else if (strcmp(version, "1.1.0") == 0)
+        {
+          versionBox->Enable(0, enabledLayer);
+          versionBox->Enable(1, enabledLayer);
+          versionBox->Enable(2, false);
+          versionBox->Enable(3, false);
+          versionBox->SetSelection(1);
+      } else
+        {
+          versionBox->Enable(0, enabledLayer);
+          versionBox->Enable(1, false);
+          versionBox->Enable(2, false);
+          versionBox->Enable(3, false);
+          versionBox->SetSelection(0);
+        }
+    }
+  UpdateSwapXY();
+}
+
+void WmsDialog::SelectLayer(rl2WmsTiledLayerPtr layer)
+{
+//
+// setting the currently selected WMS TiledLayer [TileService]
+//
+  bool enabledLayer = true;
+  if (get_wms_tiled_layer_name(layer) == NULL)
+    enabledLayer = false;
+  if (get_wms_tiled_layer_data_type(layer) != NULL)
+    {
+      // some Grid-Data layer [not directly visible]
+      enabledLayer = false;
+    }
+  CurrentLayer = NULL;
+  CurrentTiledLayer = layer;
+  wxTextCtrl *nameCtrl = (wxTextCtrl *) FindWindow(ID_WMS_NAME);
+  wxHtmlWindow *titleCtrl = (wxHtmlWindow *) FindWindow(ID_WMS_TITLE);
+  wxHtmlWindow *abstractCtrl = (wxHtmlWindow *) FindWindow(ID_WMS_ABSTRACT);
+  wxString lyr_name;
+  const char *x_name = get_wms_tiled_layer_name(layer);
+  lyr_name = wxString::FromUTF8(x_name);
+  nameCtrl->SetValue(lyr_name);
+  x_name = get_wms_tiled_layer_title(layer);
+  lyr_name = wxString::FromUTF8(x_name);
+  lyr_name.Replace(wxT("\n"), wxT("<br>"));
+  titleCtrl->SetPage(wxT("<html><body>") + lyr_name + wxT("</body></html>"));
+  x_name = get_wms_tiled_layer_abstract(layer);
+  lyr_name = wxString::FromUTF8(x_name);
+  lyr_name.Replace(wxT("\n"), wxT("<br>"));
+  abstractCtrl->SetPage(wxT("<html><body>") + lyr_name + wxT("</body></html>"));
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  comboCtrl->Clear();
+  wxString str = wxString::FromUTF8(get_wms_tiled_layer_crs(layer));
+  comboCtrl->Append(str);
+  comboCtrl->SetSelection(0);
+  comboCtrl->Enable(false);
+  comboCtrl = (wxComboBox *) FindWindow(ID_WMS_FORMAT);
+  comboCtrl->Clear();
+  str = wxString::FromUTF8(get_wms_tiled_layer_format(layer));
+  comboCtrl->Append(str);
+  comboCtrl->SetSelection(0);
+  comboCtrl->Enable(false);
+  comboCtrl = (wxComboBox *) FindWindow(ID_WMS_STYLE);
+  comboCtrl->Clear();
+  str = wxString::FromUTF8(get_wms_tiled_layer_style(layer));
+  comboCtrl->Append(str);
+  comboCtrl->SetSelection(0);
+  comboCtrl->Enable(false);
+  wxRadioBox *trans = (wxRadioBox *) FindWindow(ID_WMS_TRANSPARENT);
+  trans->SetSelection(1);
+  trans->Enable(false);
+  wxCheckBox *tiled = (wxCheckBox *) FindWindow(ID_WMS_TILED);
+  tiled->SetValue(true);
+  tiled->Enable(false);
+  wxSpinCtrl *wCtrl = (wxSpinCtrl *) FindWindow(ID_WMS_WIDTH);
+  wxSpinCtrl *hCtrl = (wxSpinCtrl *) FindWindow(ID_WMS_HEIGHT);
+  int tile_width;
+  int tile_height;
+  get_wms_tiled_layer_tile_size(layer, &tile_width, &tile_height);
+  char dummy[64];
+  sprintf(dummy, "%d", tile_width);
+  wxString tilex = wxString::FromUTF8(dummy);
+  wCtrl->SetRange(tile_width, tile_width);
+  wCtrl->SetValue(tilex);
+  wCtrl->Enable(true);
+  hCtrl->SetRange(tile_height, tile_height);
+  sprintf(dummy, "%d", tile_height);
+  tilex = wxString::FromUTF8(dummy);
+  hCtrl->SetValue(tilex);
+  hCtrl->Enable(true);
+  wxRadioBox *versionBox = (wxRadioBox *) FindWindow(ID_WMS_VERSION);
+  versionBox->Enable(enabledLayer);
+  wxCheckBox *swapBox = (wxCheckBox *) FindWindow(ID_WMS_SWAP);
+  swapBox->Enable(false);
+  wxButton *btn = (wxButton *) FindWindow(ID_WMS_OK);
+  btn->Enable(enabledLayer);
+  const char *version = get_wms_version(Catalog);
+  if (version == NULL)
+    {
+      versionBox->Enable(0, enabledLayer);
+      versionBox->Enable(1, false);
+      versionBox->Enable(2, false);
+      versionBox->Enable(3, false);
+      versionBox->SetSelection(0);
+  } else
+    {
+      if (strcmp(version, "1.3.0") == 0)
+        {
+          versionBox->Enable(0, enabledLayer);
+          versionBox->Enable(1, enabledLayer);
+          versionBox->Enable(2, enabledLayer);
+          versionBox->Enable(3, enabledLayer);
+          versionBox->SetSelection(3);
+      } else if (strcmp(version, "1.1.1") == 0)
+        {
+          versionBox->Enable(0, enabledLayer);
+          versionBox->Enable(1, enabledLayer);
+          versionBox->Enable(2, enabledLayer);
+          versionBox->Enable(3, false);
+          versionBox->SetSelection(2);
+      } else if (strcmp(version, "1.1.0") == 0)
+        {
+          versionBox->Enable(0, enabledLayer);
+          versionBox->Enable(1, enabledLayer);
+          versionBox->Enable(2, false);
+          versionBox->Enable(3, false);
+          versionBox->SetSelection(1);
+      } else
+        {
+          versionBox->Enable(0, enabledLayer);
+          versionBox->Enable(1, false);
+          versionBox->Enable(2, false);
+          versionBox->Enable(3, false);
+          versionBox->SetSelection(0);
+        }
+    }
+  UpdateSwapXY();
+}
+
+void WmsDialog::OnSwapXYChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// Swap XY selection changed
+//
+  if (SwapXY == 0)
+    SwapXY = 1;
+  else
+    SwapXY = 0;
+}
+
+void WmsDialog::OnTiledChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// Monolithic / Tiled selection changed
+//
+  wxCheckBox *tiledCtrl = (wxCheckBox *) FindWindow(ID_WMS_TILED);
+  wxSpinCtrl *wCtrl = (wxSpinCtrl *) FindWindow(ID_WMS_WIDTH);
+  wxSpinCtrl *hCtrl = (wxSpinCtrl *) FindWindow(ID_WMS_HEIGHT);
+  if (tiledCtrl->GetValue() == false)
+    {
+      wCtrl->SetRange(0, 0);
+      wCtrl->SetValue(wxT(""));
+      wCtrl->Enable(false);
+      hCtrl->SetRange(0, 0);
+      hCtrl->SetValue(wxT(""));
+      hCtrl->Enable(false);
+  } else
+    {
+      wCtrl->SetRange(256, MaxWidth);
+      wCtrl->SetValue(wxT("512"));
+      wCtrl->Enable(true);
+      hCtrl->SetRange(256, MaxHeight);
+      hCtrl->SetValue(wxT("512"));
+      hCtrl->Enable(true);
+    }
+}
+
+void WmsDialog::OnCatalog(wxCommandEvent & WXUNUSED(event))
+{
+//
+// event handler
+//
+  ::wxBeginBusyCursor();
+  PrepareCatalog();
+  ::wxEndBusyCursor();
+}
+
+void WmsDialog::PrepareCatalog()
+{
+//
+// attempting to create a WMS Catalog from GetCapabilities
+//
+  wxTextCtrl *proxyCtrl = (wxTextCtrl *) FindWindow(ID_WMS_PROXY);
+  wxTextCtrl *urlCtrl = (wxTextCtrl *) FindWindow(ID_WMS_URL);
+  wxButton *catalogBtn = (wxButton *) FindWindow(ID_WMS_CATALOG);
+  wxButton *resetBtn = (wxButton *) FindWindow(ID_WMS_RESET);
+  if (ProxyEnabled == true)
+    {
+      HttpProxy = proxyCtrl->GetValue();
+      if (HttpProxy.Len() == 0)
+        {
+          wxMessageBox(wxT("You must specify some HTTP Proxy URL !!!"),
+                       wxT("LibreWMS"), wxOK | wxICON_WARNING, this);
+          return;
+        }
+    }
+  wxString url = urlCtrl->GetValue();
+  if (url.Len() < 1)
+    {
+      wxMessageBox(wxT("You must specify some WMS GetCapabilities URL !!!"),
+                   wxT("LibreWMS"), wxOK | wxICON_WARNING, this);
+      return;
+    }
+  char xurl[1024];
+  char *err_msg = NULL;
+  strcpy(xurl, url.ToUTF8());
+  char *proxy = NULL;
+  if (ProxyEnabled == true && HttpProxy.Len() > 0)
+    {
+      proxy = new char[HttpProxy.Len() + 1];
+      strcpy(proxy, HttpProxy.ToUTF8());
+    }
+  Catalog = create_wms_catalog(MainFrame->GetWmsCache(), xurl, proxy, &err_msg);
+  if (proxy != NULL)
+    delete[]proxy;
+  if (Catalog == NULL)
+    {
+      wxString msg = wxString::FromUTF8(err_msg);
+      wxMessageBox(wxT("unable to get a WMS Catalog\n\n") + msg,
+                   wxT("LibreWMS"), wxOK | wxICON_ERROR, this);
+  } else
+    {
+      MaxWidth = get_wms_max_width(Catalog);
+      MaxHeight = get_wms_max_height(Catalog);
+      if (MaxWidth <= 0)
+        MaxWidth = 2048;
+      if (MaxHeight <= 0)
+        MaxHeight = 2048;
+      if (is_wms_tile_service(Catalog))
+        {
+          int nLayers = get_wms_tile_service_count(Catalog);
+          WmsTree->Show(false);
+          WmsTree->FlushAll();
+          const char *ts_name = get_wms_tile_service_name(Catalog);
+          const char *ts_title = get_wms_tile_service_title(Catalog);
+          if (ts_name != NULL)
+            WmsTree->AddTiledRoot(ts_name);
+          else if (ts_title != NULL)
+            WmsTree->AddTiledRoot(ts_title);
+          else
+            WmsTree->AddTiledRoot("TileService");
+          for (int i = 0; i < nLayers; i++)
+            {
+              // populating the WMS Catalog [TileService]
+              rl2WmsTiledLayerPtr layer =
+                get_wms_catalog_tiled_layer(Catalog, i);
+              const char *x_name = get_wms_tiled_layer_name(layer);
+              WmsTree->AddTiledLayer(layer, x_name);
+            }
+      } else
+        {
+          int nLayers = get_wms_catalog_count(Catalog);
+          WmsTree->Show(false);
+          WmsTree->FlushAll();
+          for (int i = 0; i < nLayers; i++)
+            {
+              // populating the WMS Catalog [ordinary layers]
+              rl2WmsLayerPtr layer = get_wms_catalog_layer(Catalog, i);
+              const char *x_name = get_wms_layer_title(layer);
+              WmsTree->AddLayer(layer, x_name);
+            }
+        }
+      WmsTree->ExpandAll();
+      WmsTree->Show(true);
+      WmsTree->RootAutoSelect();
+      urlCtrl->Enable(false);
+      catalogBtn->Enable(false);
+      resetBtn->Enable(true);
+    }
+  if (err_msg != NULL)
+    free(err_msg);
+}
+
+void WmsDialog::OnReset(wxCommandEvent & WXUNUSED(event))
+{
+//
+// resetting to initial empty state
+//
+  CurrentLayer = NULL;
+  wxTextCtrl *urlCtrl = (wxTextCtrl *) FindWindow(ID_WMS_URL);
+  wxButton *catalogBtn = (wxButton *) FindWindow(ID_WMS_CATALOG);
+  wxButton *resetBtn = (wxButton *) FindWindow(ID_WMS_RESET);
+  if (Catalog != NULL)
+    destroy_wms_catalog(Catalog);
+  Catalog = NULL;
+  urlCtrl->Enable(true);
+  catalogBtn->Enable(true);
+  resetBtn->Enable(false);
+  WmsTree->FlushAll();
+  wxHtmlWindow *titleCtrl = (wxHtmlWindow *) FindWindow(ID_WMS_TITLE);
+  titleCtrl->SetPage(wxT(""));
+  wxHtmlWindow *abstractCtrl = (wxHtmlWindow *) FindWindow(ID_WMS_ABSTRACT);
+  abstractCtrl->SetPage(wxT(""));
+  wxTextCtrl *nameCtrl = (wxTextCtrl *) FindWindow(ID_WMS_NAME);
+  nameCtrl->SetValue(wxT(""));
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  comboCtrl->Clear();
+  comboCtrl->SetSelection(wxNOT_FOUND);
+  comboCtrl->Enable(false);
+  comboCtrl = (wxComboBox *) FindWindow(ID_WMS_FORMAT);
+  comboCtrl->Clear();
+  comboCtrl->SetSelection(wxNOT_FOUND);
+  comboCtrl->Enable(false);
+  comboCtrl = (wxComboBox *) FindWindow(ID_WMS_STYLE);
+  comboCtrl->Clear();
+  comboCtrl->SetSelection(wxNOT_FOUND);
+  comboCtrl->Enable(false);
+  wxRadioBox *trans = (wxRadioBox *) FindWindow(ID_WMS_TRANSPARENT);
+  trans->SetSelection(1);
+  trans->Enable(false);
+  wxCheckBox *tiled = (wxCheckBox *) FindWindow(ID_WMS_TILED);
+  tiled->SetValue(false);
+  tiled->Enable(false);
+  wxRadioBox *versionBox = (wxRadioBox *) FindWindow(ID_WMS_VERSION);
+  versionBox->Enable(false);
+  wxCheckBox *swapBox = (wxCheckBox *) FindWindow(ID_WMS_SWAP);
+  swapBox->Enable(false);
+  wxButton *load = (wxButton *) FindWindow(ID_WMS_OK);
+  load->Enable(false);
+}
+
+int WmsDialog::IsTiled()
+{
+// return the Tiled mode
+  wxCheckBox *tiled = (wxCheckBox *) FindWindow(ID_WMS_TILED);
+  if (tiled->GetValue() == false)
+    return 0;
+  return 1;
+}
+
+int WmsDialog::GetTileWidth()
+{
+// return the TileWidth
+  wxSpinCtrl *wCtrl = (wxSpinCtrl *) FindWindow(ID_WMS_WIDTH);
+  return wCtrl->GetValue();
+}
+
+int WmsDialog::GetTileHeight()
+{
+// return the TileHeight
+  wxSpinCtrl *hCtrl = (wxSpinCtrl *) FindWindow(ID_WMS_HEIGHT);
+  return hCtrl->GetValue();
+}
+
+int WmsDialog::IsOpaque()
+{
+// return the Opaque mode
+  wxRadioBox *trans = (wxRadioBox *) FindWindow(ID_WMS_TRANSPARENT);
+  if (trans->GetSelection() == 0)
+    return 0;
+  return 1;
+}
+
+const char *WmsDialog::GetVersion()
+{
+// return the Version string
+  wxRadioBox *versionBox = (wxRadioBox *) FindWindow(ID_WMS_VERSION);
+  if (Version != NULL)
+    delete[]Version;
+  Version = new char[6];
+  switch (versionBox->GetSelection())
+    {
+      case 0:
+        strcpy(Version, "1.0.0");
+        break;
+      case 1:
+        strcpy(Version, "1.1.0");
+        break;
+      case 2:
+        strcpy(Version, "1.1.1");
+        break;
+      default:
+        strcpy(Version, "1.3.0");
+        break;
+    };
+  return Version;
+}
+
+const char *WmsDialog::GetStyleName()
+{
+// return the Style Name string
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_STYLE);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return NULL;
+  int cnt = get_wms_layer_style_count(CurrentLayer);
+  for (int i = 0; i < cnt; i++)
+    {
+      const char *str = get_wms_layer_style_name(CurrentLayer, i);
+      wxString style = wxString::FromUTF8(str);
+      if (style == value)
+        return str;
+    }
+  return NULL;
+}
+
+const char *WmsDialog::GetStyleTitle()
+{
+// return the Style Title string
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_STYLE);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return NULL;
+  int cnt = get_wms_layer_style_count(CurrentLayer);
+  for (int i = 0; i < cnt; i++)
+    {
+      const char *stl = get_wms_layer_style_name(CurrentLayer, i);
+      const char *str = get_wms_layer_style_title(CurrentLayer, i);
+      wxString style = wxString::FromUTF8(stl);
+      if (style == value)
+        return str;
+    }
+  return NULL;
+}
+
+const char *WmsDialog::GetStyleAbstract()
+{
+// return the Style Abstract string
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_STYLE);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return NULL;
+  int cnt = get_wms_layer_style_count(CurrentLayer);
+  for (int i = 0; i < cnt; i++)
+    {
+      const char *stl = get_wms_layer_style_name(CurrentLayer, i);
+      const char *str = get_wms_layer_style_abstract(CurrentLayer, i);
+      wxString style = wxString::FromUTF8(stl);
+      if (style == value)
+        return str;
+    }
+  return NULL;
+}
+
+const char *WmsDialog::GetFormat()
+{
+// return the Format string
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_FORMAT);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return NULL;
+  int cnt = get_wms_format_count(Catalog, 1);
+  for (int i = 0; i < cnt; i++)
+    {
+      const char *str = get_wms_format(Catalog, i, 1);
+      wxString fmt = wxString::FromUTF8(str);
+      if (fmt == value)
+        return str;
+    }
+  return NULL;
+}
+
+const char *WmsDialog::GetCRS()
+{
+// return the CRS string
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return NULL;
+  int cnt = get_wms_layer_crs_count(CurrentLayer);
+  for (int i = 0; i < cnt; i++)
+    {
+      const char *str = get_wms_layer_crs(CurrentLayer, i);
+      wxString crs = wxString::FromUTF8(str);
+      if (crs == value)
+        return str;
+    }
+  return NULL;
+}
+
+bool WmsDialog::GetStyleByIndex(int idx, const char **name, const char **title,
+                                const char **abstract)
+{
+// return some WMS Format (retrieved by its Index)
+  *name = get_wms_layer_style_name(CurrentLayer, idx);
+  *title = get_wms_layer_style_title(CurrentLayer, idx);
+  *abstract = get_wms_layer_style_abstract(CurrentLayer, idx);
+  if (*name == NULL)
+    return false;
+  return true;
+}
+
+WmsBBox *WmsDialog::GetBBoxByCRS(const char *crs)
+{
+// return some CRS BBox (retrieved by CRS name)
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  if (get_wms_layer_bbox(CurrentLayer, crs, &minx, &maxx, &miny, &maxy))
+    return new WmsBBox(minx, miny, maxx, maxy);
+  return NULL;
+}
+
+double WmsDialog::GetGeoMinX()
+{
+// return the WMS Geographic MinX
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  if (!get_wms_layer_geo_bbox(CurrentLayer, &minx, &maxx, &miny, &maxy))
+    return DBL_MAX;
+  return minx;
+}
+
+double WmsDialog::GetGeoMaxX()
+{
+// return the WMS Geographic MaxX
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  if (!get_wms_layer_geo_bbox(CurrentLayer, &minx, &maxx, &miny, &maxy))
+    return DBL_MAX;
+  return maxx;
+}
+
+double WmsDialog::GetGeoMinY()
+{
+// return the WMS Geographic MinY
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  if (!get_wms_layer_geo_bbox(CurrentLayer, &minx, &maxx, &miny, &maxy))
+    return DBL_MAX;
+  return miny;
+}
+
+double WmsDialog::GetGeoMaxY()
+{
+// return the WMS Geographic MaxY
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  if (!get_wms_layer_geo_bbox(CurrentLayer, &minx, &maxx, &miny, &maxy))
+    return DBL_MAX;
+  return maxy;
+}
+
+double WmsDialog::GetMinX()
+{
+// return the WMS CRS MinX
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  const char *crs_str = NULL;
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return DBL_MAX;
+  int cnt = get_wms_layer_crs_count(CurrentLayer);
+  for (int i = 0; i < cnt; i++)
+    {
+      const char *str = get_wms_layer_crs(CurrentLayer, i);
+      wxString crs = wxString::FromUTF8(str);
+      if (crs == value)
+        {
+          crs_str = str;
+          break;
+        }
+    }
+  if (crs_str == NULL)
+    return DBL_MAX;
+  if (!get_wms_layer_bbox(CurrentLayer, crs_str, &minx, &maxx, &miny, &maxy))
+    {
+      if (!get_wms_layer_geo_bbox(CurrentLayer, &minx, &maxx, &miny, &maxy))
+        return DBL_MAX;
+      if (MainFrame->BBoxFromLongLat(crs_str, &minx, &maxx, &miny, &maxy) ==
+          true)
+        {
+          if (IsSwapXY() == true)
+            return miny;
+          else
+            return minx;
+      } else
+        return DBL_MAX;
+    }
+  return minx;
+}
+
+double WmsDialog::GetMaxX()
+{
+// return the WMS CRS MaxX
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  const char *crs_str = NULL;
+  wxTextCtrl *nameCtrl = (wxTextCtrl *) FindWindow(ID_WMS_NAME);
+  wxString name = nameCtrl->GetValue();
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return DBL_MAX;
+  int cnt = get_wms_layer_crs_count(CurrentLayer);
+  for (int i = 0; i < cnt; i++)
+    {
+      const char *str = get_wms_layer_crs(CurrentLayer, i);
+      wxString crs = wxString::FromUTF8(str);
+      if (crs == value)
+        {
+          crs_str = str;
+          break;
+        }
+    }
+  if (crs_str == NULL)
+    return DBL_MAX;
+  if (!get_wms_layer_bbox(CurrentLayer, crs_str, &minx, &maxx, &miny, &maxy))
+    {
+      if (!get_wms_layer_geo_bbox(CurrentLayer, &minx, &maxx, &miny, &maxy))
+        return DBL_MAX;
+      if (MainFrame->BBoxFromLongLat(crs_str, &minx, &maxx, &miny, &maxy) ==
+          true)
+        {
+          if (IsSwapXY() == true)
+            return maxy;
+          else
+            return maxx;
+      } else
+        return DBL_MAX;
+    }
+  return maxx;
+}
+
+double WmsDialog::GetMinY()
+{
+// return the WMS CRS MinY
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  const char *crs_str = NULL;
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return DBL_MAX;
+  int cnt = get_wms_layer_crs_count(CurrentLayer);
+  for (int i = 0; i < cnt; i++)
+    {
+      const char *str = get_wms_layer_crs(CurrentLayer, i);
+      wxString crs = wxString::FromUTF8(str);
+      if (crs == value)
+        {
+          crs_str = str;
+          break;
+        }
+    }
+  if (crs_str == NULL)
+    return DBL_MAX;
+  if (!get_wms_layer_bbox(CurrentLayer, crs_str, &minx, &maxx, &miny, &maxy))
+    {
+      if (!get_wms_layer_geo_bbox(CurrentLayer, &minx, &maxx, &miny, &maxy))
+        return DBL_MAX;
+      if (MainFrame->BBoxFromLongLat(crs_str, &minx, &maxx, &miny, &maxy) ==
+          true)
+        {
+          if (IsSwapXY() == true)
+            return minx;
+          else
+            return miny;
+      } else
+        return DBL_MAX;
+    }
+  return miny;
+}
+
+double WmsDialog::GetMaxY()
+{
+// return the WMS CRS MaxY
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  const char *crs_str = NULL;
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return DBL_MAX;
+  int cnt = get_wms_layer_crs_count(CurrentLayer);
+  for (int i = 0; i < cnt; i++)
+    {
+      const char *str = get_wms_layer_crs(CurrentLayer, i);
+      wxString crs = wxString::FromUTF8(str);
+      if (crs == value)
+        {
+          crs_str = str;
+          break;
+        }
+    }
+  if (crs_str == NULL)
+    return DBL_MAX;
+  if (!get_wms_layer_bbox(CurrentLayer, crs_str, &minx, &maxx, &miny, &maxy))
+    {
+      if (!get_wms_layer_geo_bbox(CurrentLayer, &minx, &maxx, &miny, &maxy))
+        return DBL_MAX;
+      if (MainFrame->BBoxFromLongLat(crs_str, &minx, &maxx, &miny, &maxy) ==
+          true)
+        {
+          if (IsSwapXY() == true)
+            return maxx;
+          else
+            return maxy;
+      } else
+        return DBL_MAX;
+    }
+  return maxy;
+}
+
+double WmsDialog::GetTiledLayerMinLong()
+{
+// return the MinLong for a Tiled Layer [TileService]
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  if (get_wms_tiled_layer_bbox(CurrentTiledLayer, &minx, &miny, &maxx, &maxy))
+    return minx;
+  return DBL_MAX;
+}
+
+double WmsDialog::GetTiledLayerMinLat()
+{
+// return the MinLat for a Tiled Layer [TileService]
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  if (get_wms_tiled_layer_bbox(CurrentTiledLayer, &minx, &miny, &maxx, &maxy))
+    return miny;
+  return DBL_MAX;
+}
+
+double WmsDialog::GetTiledLayerMaxLong()
+{
+// return the MaxLong for a Tiled Layer [TileService]
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  if (get_wms_tiled_layer_bbox(CurrentTiledLayer, &minx, &miny, &maxx, &maxy))
+    return maxx;
+  return DBL_MAX;
+}
+
+double WmsDialog::GetTiledLayerMaxLat()
+{
+// return the MaxLat for a Tiled Layer [TileService]
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+  if (get_wms_tiled_layer_bbox(CurrentTiledLayer, &minx, &miny, &maxx, &maxy))
+    return maxy;
+  return DBL_MAX;
+}
+
+const char *WmsDialog::GetTilePatternSRS(int i)
+{
+// return the SRS from some TilePattern defined within a TiledLayer
+  int nPatterns = get_wms_tile_pattern_count(CurrentTiledLayer);
+  if (i >= 0 && i < nPatterns)
+    return get_wms_tile_pattern_srs(CurrentTiledLayer, i);
+  return NULL;
+}
+
+int WmsDialog::GetTilePatternWidth(int i)
+{
+// return the TileWidth from some TilePattern defined within a TiledLayer
+  int nPatterns = get_wms_tile_pattern_count(CurrentTiledLayer);
+  if (i >= 0 && i < nPatterns)
+    return get_wms_tile_pattern_tile_width(CurrentTiledLayer, i);
+  return -1;
+}
+
+int WmsDialog::GetTilePatternHeight(int i)
+{
+// return the TileEight from some TilePattern defined within a TiledLayer
+  int nPatterns = get_wms_tile_pattern_count(CurrentTiledLayer);
+  if (i >= 0 && i < nPatterns)
+    return get_wms_tile_pattern_tile_height(CurrentTiledLayer, i);
+  return -1;
+}
+
+double WmsDialog::GetTilePatternBaseX(int i)
+{
+// return the BaseX from some TilePattern defined within a TiledLayer
+  int nPatterns = get_wms_tile_pattern_count(CurrentTiledLayer);
+  if (i >= 0 && i < nPatterns)
+    return get_wms_tile_pattern_base_x(CurrentTiledLayer, i);
+  return DBL_MAX;
+}
+
+double WmsDialog::GetTilePatternBaseY(int i)
+{
+// return the BaseY from some TilePattern defined within a TiledLayer
+  int nPatterns = get_wms_tile_pattern_count(CurrentTiledLayer);
+  if (i >= 0 && i < nPatterns)
+    return get_wms_tile_pattern_base_y(CurrentTiledLayer, i);
+  return DBL_MAX;
+}
+
+double WmsDialog::GetTilePatternExtentX(int i)
+{
+// return the ExtentX from some TilePattern defined within a TiledLayer
+  int nPatterns = get_wms_tile_pattern_count(CurrentTiledLayer);
+  if (i >= 0 && i < nPatterns)
+    return get_wms_tile_pattern_extent_x(CurrentTiledLayer, i);
+  return DBL_MAX;
+}
+
+double WmsDialog::GetTilePatternExtentY(int i)
+{
+// return the ExtentY from some TilePattern defined within a TiledLayer
+  int nPatterns = get_wms_tile_pattern_count(CurrentTiledLayer);
+  if (i >= 0 && i < nPatterns)
+    return get_wms_tile_pattern_extent_y(CurrentTiledLayer, i);
+  return DBL_MAX;
+}
+
+rl2WmsTilePatternPtr WmsDialog::GetTilePatternHandle(int i)
+{
+// return the Handle from some TilePattern defined within a TiledLayer
+  int nPatterns = get_wms_tile_pattern_count(CurrentTiledLayer);
+  if (i >= 0 && i < nPatterns)
+    return get_wms_tile_pattern_handle(CurrentTiledLayer, i);
+  return NULL;
+}
+
+void WmsDialog::OnQuit(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxDialog::EndModal(wxID_CANCEL);
+}
+
+void WmsDialog::OnWmsOk(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxTextCtrl *proxyCtrl = (wxTextCtrl *) FindWindow(ID_WMS_PROXY);
+  if (ProxyEnabled == false)
+    HttpProxy = wxT("");
+  else
+    HttpProxy = proxyCtrl->GetValue();
+  wxTextCtrl *urlCtrl = (wxTextCtrl *) FindWindow(ID_WMS_URL);
+  URL = urlCtrl->GetValue();
+  wxDialog::EndModal(wxID_OK);
+}
+
+bool WmsLayerDialog::Create(MyFrame * parent, WmsLayer * lyr)
+{
+//
+// creating the dialog
+//
+  MainFrame = parent;
+  Layer = lyr;
+  SwapXY = 0;
+  MaxWidth = Layer->GetWmsService()->GetMaxWidth();
+  MaxHeight = Layer->GetWmsService()->GetMaxHeight();
+  if (MaxWidth <= 0)
+    MaxWidth = 2048;
+  if (MaxHeight <= 0)
+    MaxHeight = 2048;
+  if (wxDialog::Create(parent, wxID_ANY, wxT("WMS Layer configuration")) ==
+      false)
+    return false;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  UpdateSwapXY();
+  return true;
+}
+
+void WmsLayerDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// selected Layer group box
+  wxBoxSizer *kkSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(kkSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *lyrBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("WMS Layer Configuration"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *lyrBox0Sizer = new wxStaticBoxSizer(lyrBox, wxHORIZONTAL);
+  kkSizer->Add(lyrBox0Sizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+// Second row: Layer name
+  wxBoxSizer *lyrBoxSizer = new wxBoxSizer(wxVERTICAL);
+  lyrBox0Sizer->Add(lyrBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxBoxSizer *nameSizer = new wxBoxSizer(wxHORIZONTAL);
+  lyrBoxSizer->Add(nameSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxStaticBox *nameBox = new wxStaticBox(this, wxID_ANY,
+                                         wxT("WMS Layer"),
+                                         wxDefaultPosition,
+                                         wxDefaultSize);
+  wxBoxSizer *nameBoxSizer = new wxStaticBoxSizer(nameBox, wxHORIZONTAL);
+  nameSizer->Add(nameBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxString lyrName = wxString::FromUTF8(Layer->GetName());
+  wxTextCtrl *nameCtrl = new wxTextCtrl(this, ID_WMS_NAME, lyrName,
+                                        wxDefaultPosition, wxSize(570, 22),
+                                        wxTE_READONLY);
+  nameBoxSizer->Add(nameCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxStaticBox *swapBox = new wxStaticBox(this, wxID_ANY,
+                                         wxT("Swap Axes"),
+                                         wxDefaultPosition,
+                                         wxDefaultSize);
+  wxBoxSizer *swapBoxSizer = new wxStaticBoxSizer(swapBox, wxHORIZONTAL);
+  nameSizer->Add(swapBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxCheckBox *swapCtrl = new wxCheckBox(this, ID_WMS_SWAP,
+                                        wxT("Swap Y,X"),
+                                        wxDefaultPosition, wxDefaultSize);
+  if (Layer->IsSwapXY() == 0)
+    swapCtrl->SetValue(false);
+  else
+    swapCtrl->SetValue(true);
+  swapBoxSizer->Add(swapCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// First row: WMS options
+  wxBoxSizer *wmsSizer = new wxBoxSizer(wxHORIZONTAL);
+  lyrBoxSizer->Add(wmsSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxString ver[4];
+  ver[0] = wxT("WMS &1.0.0");
+  ver[1] = wxT("WMS &1.1.0");
+  ver[2] = wxT("WMS &1.1.1");
+  ver[3] = wxT("WMS &1.3.0");
+  wxRadioBox *versionBox = new wxRadioBox(this, ID_WMS_VERSION,
+                                          wxT("WMS &Version"),
+                                          wxDefaultPosition,
+                                          wxDefaultSize, 4,
+                                          ver, 4,
+                                          wxRA_SPECIFY_ROWS);
+  const char *version = Layer->GetWmsService()->GetVersion();
+  if (version == NULL)
+    {
+      versionBox->Enable(1, false);
+      versionBox->Enable(2, false);
+      versionBox->Enable(3, false);
+  } else
+    {
+      if (strcmp(version, "1.1.0") == 0)
+        {
+          versionBox->Enable(2, false);
+          versionBox->Enable(3, false);
+      } else if (strcmp(version, "1.1.1") == 0)
+        {
+          versionBox->Enable(3, false);
+      } else if (strcmp(version, "1.3.0") == 0)
+        ;
+      else
+        {
+          versionBox->Enable(1, false);
+          versionBox->Enable(2, false);
+          versionBox->Enable(3, false);
+        }
+    }
+  if (strcmp(Layer->GetVersion(), "1.0.0") == 0)
+    versionBox->SetSelection(0);
+  else if (strcmp(Layer->GetVersion(), "1.1.0") == 0)
+    versionBox->SetSelection(1);
+  else if (strcmp(Layer->GetVersion(), "1.1.1") == 0)
+    versionBox->SetSelection(2);
+  else
+    versionBox->SetSelection(3);
+  wmsSizer->Add(versionBox, 0, wxALIGN_TOP | wxALL, 5);
+  wxBoxSizer *xxSizer = new wxBoxSizer(wxVERTICAL);
+  wmsSizer->Add(xxSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *crsBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("Reference System"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *crsBoxSizer = new wxStaticBoxSizer(crsBox, wxVERTICAL);
+  xxSizer->Add(crsBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxComboBox *crsList =
+    new wxComboBox(this, ID_WMS_CRS, wxT(""), wxDefaultPosition,
+                   wxSize(150, 21), 0, NULL, wxCB_DROPDOWN | wxCB_READONLY);
+  for (int s = 0; s < Layer->CountCRS(); s++)
+    {
+      const char *crs = Layer->GetCrsByIndex(s);
+      wxString str = wxString::FromUTF8(crs);
+      crsList->Append(str);
+      if (strcmp(Layer->GetCRS(), crs) == 0)
+        crsList->SetSelection(s);
+    }
+  crsBoxSizer->Add(crsList, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxStaticBox *stlBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("Style"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *stlBoxSizer = new wxStaticBoxSizer(stlBox, wxVERTICAL);
+  xxSizer->Add(stlBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxComboBox *stlList =
+    new wxComboBox(this, ID_WMS_STYLE, wxT(""), wxDefaultPosition,
+                   wxSize(150, 21), 0, NULL, wxCB_DROPDOWN | wxCB_READONLY);
+  for (int s = 0; s < Layer->CountStyles(); s++)
+    {
+      const char *name;
+      const char *title;
+      const char *abstract;
+      Layer->GetStyleByIndex(s, &name, &title, &abstract);
+      wxString str = wxString::FromUTF8(name);
+      stlList->Append(str);
+      if (strcmp(Layer->GetStyleName(), name) == 0)
+        stlList->SetSelection(s);
+    }
+  stlBoxSizer->Add(stlList, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxBoxSizer *yySizer = new wxBoxSizer(wxVERTICAL);
+  wmsSizer->Add(yySizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *fmtBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("Image Format"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *fmtBoxSizer = new wxStaticBoxSizer(fmtBox, wxVERTICAL);
+  yySizer->Add(fmtBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxComboBox *fmtList =
+    new wxComboBox(this, ID_WMS_FORMAT, wxT(""), wxDefaultPosition,
+                   wxSize(150, 21), 0, NULL, wxCB_DROPDOWN | wxCB_READONLY);
+  for (int s = 0; s < Layer->GetWmsService()->CountFormats(); s++)
+    {
+      const char *fmt = Layer->GetWmsService()->GetFormatByIndex(s);
+      wxString str = wxString::FromUTF8(fmt);
+      fmtList->Append(str);
+      if (strcmp(Layer->GetFormat(), fmt) == 0)
+        fmtList->SetSelection(s);
+    }
+  fmtBoxSizer->Add(fmtList, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxString trans[2];
+  trans[0] = wxT("yes");
+  trans[1] = wxT("opaque");
+  wxRadioBox *transBox = new wxRadioBox(this, ID_WMS_TRANSPARENT,
+                                        wxT("Transparent Layer"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize, 2,
+                                        trans, 2,
+                                        wxRA_SPECIFY_COLS);
+  if (Layer->IsOpaque() == 0)
+    transBox->SetSelection(0);
+  else
+    transBox->SetSelection(1);
+  yySizer->Add(transBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 2);
+  wxStaticBox *tileBox = new wxStaticBox(this, wxID_STATIC,
+                                         wxT("Tile size"),
+                                         wxDefaultPosition,
+                                         wxDefaultSize);
+  wxBoxSizer *tileBoxSizer = new wxStaticBoxSizer(tileBox, wxVERTICAL);
+  wmsSizer->Add(tileBoxSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxCheckBox *tiledCtrl = new wxCheckBox(this, ID_WMS_TILED,
+                                         wxT("enable Tiles"),
+                                         wxDefaultPosition, wxDefaultSize);
+  if (Layer->IsTiled() == 0)
+    tiledCtrl->SetValue(false);
+  else
+    tiledCtrl->SetValue(true);
+  tileBoxSizer->Add(tiledCtrl, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+  wxBoxSizer *tile1BoxSizer = new wxBoxSizer(wxHORIZONTAL);
+  tileBoxSizer->Add(tile1BoxSizer, 0, wxALIGN_RIGHT | wxALL, 0);
+  wxStaticText *wLabel = new wxStaticText(this, wxID_ANY, wxT("&Width:"),
+                                          wxDefaultPosition, wxDefaultSize,
+                                          wxALIGN_RIGHT);
+  tile1BoxSizer->Add(wLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxSpinCtrl *wCtrl = new wxSpinCtrl(this, ID_WMS_WIDTH, wxEmptyString,
+                                     wxDefaultPosition, wxSize(80, 20),
+                                     wxSP_ARROW_KEYS,
+                                     0, 0, 0);
+  if (Layer->IsTiled() == 0)
+    {
+      wCtrl->Enable(false);
+      wCtrl->SetValue(wxT(""));
+  } else
+    {
+      wCtrl->SetRange(256, MaxWidth);
+      char t_w[64];
+      sprintf(t_w, "%d", Layer->GetTileWidth());
+      wxString tW = wxString::FromUTF8(t_w);
+      wCtrl->SetValue(tW);
+    }
+  tile1BoxSizer->Add(wCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxBoxSizer *tile2BoxSizer = new wxBoxSizer(wxHORIZONTAL);
+  tileBoxSizer->Add(tile2BoxSizer, 0, wxALIGN_RIGHT | wxALL, 0);
+  wxStaticText *hLabel = new wxStaticText(this, wxID_ANY, wxT("&Height:"),
+                                          wxDefaultPosition, wxDefaultSize,
+                                          wxALIGN_RIGHT);
+  tile2BoxSizer->Add(hLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxSpinCtrl *hCtrl = new wxSpinCtrl(this, ID_WMS_HEIGHT, wxEmptyString,
+                                     wxDefaultPosition, wxSize(80, 20),
+                                     wxSP_ARROW_KEYS,
+                                     0, 0, 0);
+  tile2BoxSizer->Add(hCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  if (Layer->IsTiled() == 0)
+    {
+      hCtrl->Enable(false);
+      hCtrl->SetValue(wxT(""));
+  } else
+    {
+      hCtrl->SetRange(256, MaxHeight);
+      char t_h[64];
+      sprintf(t_h, "%d", Layer->GetTileHeight());
+      wxString tH = wxString::FromUTF8(t_h);
+      hCtrl->SetValue(tH);
+    }
+  wxBoxSizer *buttonSizer = new wxBoxSizer(wxVERTICAL);
+  wmsSizer->Add(buttonSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxButton *wms_ok = new wxButton(this, ID_WMS_OK, wxT("&Apply Changes"));
+  buttonSizer->Add(wms_ok, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+  wxButton *wms_quit = new wxButton(this, wxID_CANCEL, wxT("&Quit"));
+  buttonSizer->Add(wms_quit, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// appends event handlers
+  Connect(ID_WMS_CRS, wxEVT_COMMAND_COMBOBOX_SELECTED,
+          (wxObjectEventFunction) & WmsLayerDialog::OnCrsChanged);
+  Connect(ID_WMS_VERSION, wxEVT_COMMAND_RADIOBOX_SELECTED,
+          (wxObjectEventFunction) & WmsLayerDialog::OnVersionChanged);
+  Connect(ID_WMS_SWAP, wxEVT_COMMAND_CHECKBOX_CLICKED,
+          (wxObjectEventFunction) & WmsLayerDialog::OnSwapXYChanged);
+  Connect(ID_WMS_TILED, wxEVT_COMMAND_CHECKBOX_CLICKED,
+          (wxObjectEventFunction) & WmsLayerDialog::OnTiledChanged);
+  Connect(ID_WMS_OK, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & WmsLayerDialog::OnWmsOk);
+  Connect(wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & WmsLayerDialog::OnQuit);
+}
+
+void WmsLayerDialog::OnCrsChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// CRS changed: updating SWAP XY
+//
+  UpdateSwapXY();
+}
+
+void WmsLayerDialog::OnVersionChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// Version changed: updating SWAP XY
+//
+  UpdateSwapXY();
+}
+
+void WmsLayerDialog::UpdateSwapXY()
+{
+//
+// updating SWAP XY
+//
+  wxCheckBox *swapBox = (wxCheckBox *) FindWindow(ID_WMS_SWAP);
+  wxRadioBox *versionBox = (wxRadioBox *) FindWindow(ID_WMS_VERSION);
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  if (versionBox->GetSelection() != 3)
+    {
+      swapBox->SetValue(false);
+      SwapXY = 0;
+      return;
+    };
+  wxString value = comboCtrl->GetValue();
+  char *crs = new char[value.Len() + 1];
+  strcpy(crs, value.ToUTF8());
+  if (MainFrame->IsSwapXYcrs(crs) == true)
+    {
+      swapBox->SetValue(true);
+      SwapXY = 1;
+  } else
+    {
+      swapBox->SetValue(false);
+      SwapXY = 0;
+    }
+  delete[]crs;
+}
+
+void WmsLayerDialog::OnSwapXYChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// Swap XY selection changed
+//
+  if (SwapXY == 0)
+    SwapXY = 1;
+  else
+    SwapXY = 0;
+}
+
+void WmsLayerDialog::OnTiledChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// Monolithic / Tiled selection changed
+//
+  wxCheckBox *tiledCtrl = (wxCheckBox *) FindWindow(ID_WMS_TILED);
+  wxSpinCtrl *wCtrl = (wxSpinCtrl *) FindWindow(ID_WMS_WIDTH);
+  wxSpinCtrl *hCtrl = (wxSpinCtrl *) FindWindow(ID_WMS_HEIGHT);
+  if (tiledCtrl->GetValue() == false)
+    {
+      wCtrl->SetRange(0, 0);
+      wCtrl->SetValue(wxT(""));
+      wCtrl->Enable(false);
+      hCtrl->SetRange(0, 0);
+      hCtrl->SetValue(wxT(""));
+      hCtrl->Enable(false);
+  } else
+    {
+      wCtrl->SetRange(256, MaxWidth);
+      wCtrl->SetValue(wxT("512"));
+      wCtrl->Enable(true);
+      hCtrl->SetRange(256, MaxHeight);
+      hCtrl->SetValue(wxT("512"));
+      hCtrl->Enable(true);
+    }
+}
+
+int WmsLayerDialog::IsTiled()
+{
+// return the Tiled mode
+  wxCheckBox *tiled = (wxCheckBox *) FindWindow(ID_WMS_TILED);
+  if (tiled->GetValue() == false)
+    return 0;
+  return 1;
+}
+
+int WmsLayerDialog::GetTileWidth()
+{
+// return the TileWidth
+  wxSpinCtrl *wCtrl = (wxSpinCtrl *) FindWindow(ID_WMS_WIDTH);
+  return wCtrl->GetValue();
+}
+
+int WmsLayerDialog::GetTileHeight()
+{
+// return the TileHeight
+  wxSpinCtrl *hCtrl = (wxSpinCtrl *) FindWindow(ID_WMS_HEIGHT);
+  return hCtrl->GetValue();
+}
+
+int WmsLayerDialog::IsOpaque()
+{
+// return the Opaque mode
+  wxRadioBox *trans = (wxRadioBox *) FindWindow(ID_WMS_TRANSPARENT);
+  if (trans->GetSelection() == 0)
+    return 0;
+  return 1;
+}
+
+const char *WmsLayerDialog::GetVersion()
+{
+// return the Version string
+  wxRadioBox *versionBox = (wxRadioBox *) FindWindow(ID_WMS_VERSION);
+  if (Version != NULL)
+    delete[]Version;
+  Version = new char[6];
+  switch (versionBox->GetSelection())
+    {
+      case 0:
+        strcpy(Version, "1.0.0");
+        break;
+      case 1:
+        strcpy(Version, "1.1.0");
+        break;
+      case 2:
+        strcpy(Version, "1.1.1");
+        break;
+      default:
+        strcpy(Version, "1.3.0");
+        break;
+    };
+  return Version;
+}
+
+const char *WmsLayerDialog::GetStyleName()
+{
+// return the Style Name string
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_STYLE);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return NULL;
+  for (int i = 0; i < Layer->CountStyles(); i++)
+    {
+      const char *name;
+      const char *title;
+      const char *abstract;
+      Layer->GetStyleByIndex(i, &name, &title, &abstract);
+      wxString str = wxString::FromUTF8(name);
+      if (str == value)
+        return name;
+    }
+  return NULL;
+}
+
+const char *WmsLayerDialog::GetStyleTitle()
+{
+// return the Style Title string
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_STYLE);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return NULL;
+  for (int i = 0; i < Layer->CountStyles(); i++)
+    {
+      const char *name;
+      const char *title;
+      const char *abstract;
+      Layer->GetStyleByIndex(i, &name, &title, &abstract);
+      wxString str = wxString::FromUTF8(name);
+      if (str == value)
+        return title;
+    }
+  return NULL;
+}
+
+const char *WmsLayerDialog::GetStyleAbstract()
+{
+// return the Style Abstract string
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_STYLE);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return NULL;
+  for (int i = 0; i < Layer->CountStyles(); i++)
+    {
+      const char *name;
+      const char *title;
+      const char *abstract;
+      Layer->GetStyleByIndex(i, &name, &title, &abstract);
+      wxString str = wxString::FromUTF8(name);
+      if (str == value)
+        return abstract;
+    }
+  return NULL;
+}
+
+const char *WmsLayerDialog::GetFormat()
+{
+// return the Format string
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_FORMAT);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return NULL;
+  int cnt = Layer->GetWmsService()->CountFormats();
+  for (int i = 0; i < cnt; i++)
+    {
+      const char *str = Layer->GetWmsService()->GetFormatByIndex(i);
+      wxString fmt = wxString::FromUTF8(str);
+      if (fmt == value)
+        return str;
+    }
+  return NULL;
+}
+
+const char *WmsLayerDialog::GetCRS()
+{
+// return the CRS string
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return NULL;
+  for (int i = 0; i < Layer->CountCRS(); i++)
+    {
+      const char *str = Layer->GetCrsByIndex(i);
+      wxString crs = wxString::FromUTF8(str);
+      if (crs == value)
+        return str;
+    }
+  return NULL;
+}
+
+double WmsLayerDialog::GetMinX()
+{
+// return the WMS CRS MinX
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return DBL_MAX;
+  for (int i = 0; i < Layer->CountCRS(); i++)
+    {
+      const char *str = Layer->GetCrsByIndex(i);
+      wxString crs = wxString::FromUTF8(str);
+      if (crs == value)
+        {
+          double minx;
+          double miny;
+          double maxx;
+          double maxy;
+          if (Layer->HasBBox(str) == true)
+            {
+              Layer->GetBBox(str, &minx, &miny, &maxx, &maxy);
+              return minx;
+            }
+          minx = Layer->GetGeoMinX();
+          miny = Layer->GetGeoMinY();
+          maxx = Layer->GetGeoMaxX();
+          maxy = Layer->GetGeoMaxY();
+          if (MainFrame->BBoxFromLongLat(str, &minx, &maxx, &miny, &maxy) ==
+              true)
+            {
+              if (IsSwapXY() == true)
+                return miny;
+              else
+                return minx;
+            }
+        }
+    }
+  return DBL_MAX;
+}
+
+double WmsLayerDialog::GetMinY()
+{
+// return the WMS CRS MinY
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return DBL_MAX;
+  for (int i = 0; i < Layer->CountCRS(); i++)
+    {
+      const char *str = Layer->GetCrsByIndex(i);
+      wxString crs = wxString::FromUTF8(str);
+      if (crs == value)
+        {
+          double minx;
+          double miny;
+          double maxx;
+          double maxy;
+          if (Layer->HasBBox(str) == true)
+            {
+              Layer->GetBBox(str, &minx, &miny, &maxx, &maxy);
+              return miny;
+            }
+          minx = Layer->GetGeoMinX();
+          miny = Layer->GetGeoMinY();
+          maxx = Layer->GetGeoMaxX();
+          maxy = Layer->GetGeoMaxY();
+          if (MainFrame->BBoxFromLongLat(str, &minx, &maxx, &miny, &maxy) ==
+              true)
+            {
+              if (IsSwapXY() == true)
+                return minx;
+              else
+                return miny;
+            }
+        }
+    }
+  return DBL_MAX;
+}
+
+double WmsLayerDialog::GetMaxX()
+{
+// return the WMS CRS MaxX
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return DBL_MAX;
+  for (int i = 0; i < Layer->CountCRS(); i++)
+    {
+      const char *str = Layer->GetCrsByIndex(i);
+      wxString crs = wxString::FromUTF8(str);
+      if (crs == value)
+        {
+          double minx;
+          double miny;
+          double maxx;
+          double maxy;
+          if (Layer->HasBBox(str) == true)
+            {
+              Layer->GetBBox(str, &minx, &miny, &maxx, &maxy);
+              return maxx;
+            }
+          minx = Layer->GetGeoMinX();
+          miny = Layer->GetGeoMinY();
+          maxx = Layer->GetGeoMaxX();
+          maxy = Layer->GetGeoMaxY();
+          if (MainFrame->BBoxFromLongLat(str, &minx, &maxx, &miny, &maxy) ==
+              true)
+            {
+              if (IsSwapXY() == true)
+                return maxy;
+              else
+                return maxx;
+            }
+        }
+    }
+  return DBL_MAX;
+}
+
+double WmsLayerDialog::GetMaxY()
+{
+// return the WMS CRS MaxY
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString value = comboCtrl->GetValue();
+  if (value.Len() == 0)
+    return DBL_MAX;
+  for (int i = 0; i < Layer->CountCRS(); i++)
+    {
+      const char *str = Layer->GetCrsByIndex(i);
+      wxString crs = wxString::FromUTF8(str);
+      if (crs == value)
+        {
+          double minx;
+          double miny;
+          double maxx;
+          double maxy;
+          if (Layer->HasBBox(str) == true)
+            {
+              Layer->GetBBox(str, &minx, &miny, &maxx, &maxy);
+              return maxy;
+            }
+          minx = Layer->GetGeoMinX();
+          miny = Layer->GetGeoMinY();
+          maxx = Layer->GetGeoMaxX();
+          maxy = Layer->GetGeoMaxY();
+          if (MainFrame->BBoxFromLongLat(str, &minx, &maxx, &miny, &maxy) ==
+              true)
+            {
+              if (IsSwapXY() == true)
+                return maxx;
+              else
+                return maxy;
+            }
+        }
+    }
+  return DBL_MAX;
+}
+
+void WmsLayerDialog::OnQuit(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxDialog::EndModal(wxID_CANCEL);
+}
+
+void WmsLayerDialog::OnWmsOk(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxDialog::EndModal(wxID_OK);
+}
+
+bool WmsInfoDialog::Create(MyFrame * parent, WmsLayer * layer)
+{
+//
+// creating the dialog
+//
+  MainFrame = parent;
+  Layer = layer;
+  if (wxDialog::Create(parent, wxID_ANY, wxT("WMS Layer Infos"),
+                       wxDefaultPosition, wxDefaultSize,
+                       wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER) == false)
+    return false;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  return true;
+}
+
+void WmsInfoDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+  HtmlCtrl = new wxHtmlWindow(this, wxID_ANY,
+                              wxDefaultPosition, wxSize(680, 400));
+  boxSizer->Add(HtmlCtrl, 0, wxALIGN_RIGHT | wxALL, 5);
+  WmsService *service = Layer->GetWmsService();
+  wxString html =
+    wxT("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
+  html += wxT("<html>");
+  html += wxT("<head>");
+  html +=
+    wxT
+    ("<meta content=\"text/html; charset=UTF-8\" http-equiv=\"content-type\">");
+  html += wxT("<title>WMS Metadata</title>");
+  html += wxT("</head>");
+  html += wxT("<body bgcolor=\"#f8f8e8\">");
+  html += wxT("<h2>Service info</h2>\n");
+  html += wxT("<table>\n");
+  wxString str = wxString::FromUTF8(service->GetName());
+  html += wxT("<tr><td><b>Name</b></td><td>") + str + wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetTitle());
+  html += wxT("<tr><td><b>Title</b></td><td>") + str + wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetAbstract());
+  html += wxT("<tr><td><b>Abstract</b></td><td>") + str + wxT("</td></tr>\n");
+  html += wxT("<tr><td></td><td><hr></td></tr>\n");
+  html += wxT("<tr><td>Request</td><td><b>GetMap</b></td></tr>\n");
+  str = wxString::FromUTF8(service->GetURL_GetMap_Get());
+  html +=
+    wxT("<tr><td><b>GET</b></td><td><a href=\"") + str + wxT("\">") + str +
+    wxT("</a></td></tr>\n");
+  str = wxString::FromUTF8(service->GetURL_GetMap_Post());
+  html +=
+    wxT("<tr><td><b>POST</b></td><td><a href=\"") + str + wxT("\">") + str +
+    wxT("</a></td></tr>\n");
+  if (service->GetURL_GetTileService_Get() != NULL
+      || service->GetURL_GetTileService_Post())
+    {
+      // TileService
+      html += wxT("<tr><td></td><td><hr></td></tr>\n");
+      html += wxT("<tr><td>Request</td><td><b>GetTileService</b></td></tr>\n");
+      str = wxString::FromUTF8(service->GetURL_GetTileService_Get());
+      html +=
+        wxT("<tr><td><b>GET</b></td><td><a href=\"") + str + wxT("\">") + str +
+        wxT("</a></td></tr>\n");
+      str = wxString::FromUTF8(service->GetURL_GetTileService_Post());
+      html +=
+        wxT("<tr><td><b>POST</b></td><td><a href=\"") + str + wxT("\">") + str +
+        wxT("</a></td></tr>\n");
+    }
+  html += wxT("<tr><td></td><td><hr></td></tr>\n");
+  html += wxT("<tr><td>Request</td><td><b>GetFeatureInfo</b></td></tr>\n");
+  str = wxString::FromUTF8(service->GetURL_GetFeatureInfo_Get());
+  html +=
+    wxT("<tr><td><b>GET</b></td><td><a href=\"") + str + wxT("\">") + str +
+    wxT("</a></td></tr>\n");
+  str = wxString::FromUTF8(service->GetURL_GetFeatureInfo_Post());
+  html +=
+    wxT("<tr><td><b>POST</b></td><td><a href=\"") + str + wxT("\">") + str +
+    wxT("</a></td></tr>\n");
+  html += wxT("<tr><td></td><td><hr></td></tr>\n");
+  html += wxT("<tr><td></td><td><b>Contact Information</b></td></tr>\n");
+  str = wxString::FromUTF8(service->GetContactPerson());
+  html +=
+    wxT("<tr><td><b>Contact Person</b></td><td>") + str + wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetContactOrganization());
+  html +=
+    wxT("<tr><td><b>Contact Organization</b></td><td>") + str +
+    wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetContactPosition());
+  html +=
+    wxT("<tr><td><b>Contact Position</b></td><td>") + str + wxT("</td></tr>\n");
+  html += wxT("<tr><td></td><td><hr></td></tr>\n");
+  html += wxT("<tr><td></td><td><b>Contact Address</b></td></tr>\n");
+  str = wxString::FromUTF8(service->GetPostalAddress());
+  html +=
+    wxT("<tr><td><b>Postal Address</b></td><td>") + str + wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetCity());
+  html += wxT("<tr><td><b>City</b></td><td>") + str + wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetStateProvince());
+  html +=
+    wxT("<tr><td><b>State / Province</b></td><td>") + str + wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetPostCode());
+  html += wxT("<tr><td><b>Post Code</b></td><td>") + str + wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetCountry());
+  html += wxT("<tr><td><b>Country</b></td><td>") + str + wxT("</td></tr>\n");
+  html += wxT("<tr><td></td><td><hr></td></tr>\n");
+  str = wxString::FromUTF8(service->GetVoiceTelephone());
+  html +=
+    wxT("<tr><td><b>Voice Telephone</b></td><td>") + str + wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetFaxTelephone());
+  html +=
+    wxT("<tr><td><b>Fax Telephone</b></td><td>") + str + wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetEMailAddress());
+  html +=
+    wxT("<tr><td><b>e-mail Address</b></td><td>") + str + wxT("</td></tr>\n");
+  html += wxT("<tr><td></td><td><hr></td></tr>\n");
+  str = wxString::FromUTF8(service->GetFees());
+  html += wxT("<tr><td><b>Fees</b></td><td>") + str + wxT("</td></tr>\n");
+  str = wxString::FromUTF8(service->GetAccessConstraints());
+  html +=
+    wxT("<tr><td><b>Access Constraints</b></td><td>") + str +
+    wxT("</td></tr>\n");
+  char dummy[1024];
+  int max = service->GetLayerLimit();
+  if (max > 0)
+    sprintf(dummy, "%d", max);
+  else
+    *dummy = '\0';
+  str = wxString::FromUTF8(dummy);
+  html +=
+    wxT("<tr><td><b>Layer Limit</b></td><td>") + str + wxT("</td></tr>\n");
+  max = service->GetMaxWidth();
+  if (max > 0)
+    sprintf(dummy, "%d", max);
+  else
+    *dummy = '\0';
+  str = wxString::FromUTF8(dummy);
+  html += wxT("<tr><td><b>Max Width</b></td><td>") + str + wxT("</td></tr>\n");
+  max = service->GetMaxHeight();
+  if (max > 0)
+    sprintf(dummy, "%d", max);
+  else
+    *dummy = '\0';
+  html += wxT("<tr><td><b>Max Height</b></td><td>") + str + wxT("</td></tr>\n");
+  html += wxT("</table>\n");
+  if (Layer->GetTileServiceLayer() != NULL)
+    {
+      // TileService info
+      html += wxT("<hr><h2>Tile Service info</h2>\n");
+      html += wxT("<table>\n");
+      html +=
+        wxT
+        ("<tr><td colspan=\"2\" align=\"center\"><h3>Tile Service</h3></td></tr>\n");
+      str = wxString::FromUTF8(service->GetTileServiceName());
+      html += wxT("<tr><td><b>Name</b></td><td>") + str + wxT("</td></tr>\n");
+      str = wxString::FromUTF8(service->GetTileServiceTitle());
+      html += wxT("<tr><td><b>Title</b></td><td>") + str + wxT("</td></tr>\n");
+      str = wxString::FromUTF8(service->GetTileServiceAbstract());
+      html +=
+        wxT("<tr><td><b>Abstract</b></td><td>") + str + wxT("</td></tr>\n");
+      html +=
+        wxT
+        ("<tr><td colspan=\"2\" align=\"center\"><h3>Tiled Group</h3></td></tr>\n");
+      str = wxString::FromUTF8(Layer->GetTileServiceLayer()->GetName());
+      html += wxT("<tr><td><b>Name</b></td><td>") + str + wxT("</td></tr>\n");
+      str = wxString::FromUTF8(Layer->GetTileServiceLayer()->GetTitle());
+      html += wxT("<tr><td><b>Title</b></td><td>") + str + wxT("</td></tr>\n");
+      str = wxString::FromUTF8(Layer->GetTileServiceLayer()->GetAbstract());
+      html +=
+        wxT("<tr><td><b>Abstract</b></td><td>") + str + wxT("</td></tr>\n");
+      str = wxString::FromUTF8(Layer->GetTileServiceLayer()->GetPad());
+      html += wxT("<tr><td><b>Pad</b></td><td>") + str + wxT("</td></tr>\n");
+      str = wxString::FromUTF8(Layer->GetTileServiceLayer()->GetBands());
+      html += wxT("<tr><td><b>Bands</b></td><td>") + str + wxT("</td></tr>\n");
+      str = wxString::FromUTF8(Layer->GetTileServiceLayer()->GetDataType());
+      html +=
+        wxT("<tr><td><b>DataType</b></td><td>") + str + wxT("</td></tr>\n");
+      html +=
+        wxT
+        ("<tr><td colspan=\"2\" align=\"center\"><h3>LatLon Bounding Box</h3></td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetTileServiceLayer()->GetMinLong());
+      str = wxString::FromUTF8(dummy);
+      html += wxT("<tr><td><b>MinX</b></td><td>") + str + wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetTileServiceLayer()->GetMinLat());
+      str = wxString::FromUTF8(dummy);
+      html += wxT("<tr><td><b>MinY</b></td><td>") + str + wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetTileServiceLayer()->GetMaxLong());
+      str = wxString::FromUTF8(dummy);
+      html += wxT("<tr><td><b>MaxX</b></td><td>") + str + wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetTileServiceLayer()->GetMaxLat());
+      str = wxString::FromUTF8(dummy);
+      html += wxT("<tr><td><b>MaxY</b></td><td>") + str + wxT("</td></tr>\n");
+      html +=
+        wxT
+        ("<tr><td colspan=\"2\" align=\"center\"><h3>Tiled Patterns</h3></td></tr>\n");
+      WmsTilePattern *pattern = Layer->GetTileServiceLayer()->GetFirst();
+      int n = 1;
+      while (pattern != NULL)
+        {
+          char xnum[64];
+          sprintf(xnum, "%d", n++);
+          wxString num = wxString::FromUTF8(xnum);
+          pattern->GetSampleURL(str);
+          html +=
+            wxT("<tr><td align=\"right\"><b>") + num + wxT("</b></td><td>") +
+            str + wxT("</td></tr>\n");
+          pattern = pattern->GetNext();
+        }
+      html += wxT("</table>\n");
+  } else
+    {
+      // ordinary WMS layer
+      html += wxT("<hr><h2>Layer info</h2>\n");
+      html += wxT("<table>\n");
+      str = wxString::FromUTF8(Layer->GetName());
+      html += wxT("<tr><td><b>Name</b></td><td>") + str + wxT("</td></tr>\n");
+      str = wxString::FromUTF8(Layer->GetTitle());
+      html += wxT("<tr><td><b>Title</b></td><td>") + str + wxT("</td></tr>\n");
+      str = wxString::FromUTF8(Layer->GetAbstract());
+      html +=
+        wxT("<tr><td><b>Abstract</b></td><td>") + str + wxT("</td></tr>\n");
+      if (Layer->IsOpaque() == 0)
+        str = wxT("no");
+      else
+        str = wxT("yes");
+      html += wxT("<tr><td><b>Opaque</b></td><td>") + str + wxT("</td></tr>\n");
+      if (Layer->IsQueryable() == 0)
+        str = wxT("no");
+      else
+        str = wxT("yes");
+      html +=
+        wxT("<tr><td><b>Queryable</b></td><td>") + str + wxT("</td></tr>\n");
+      str = wxString::FromUTF8(Layer->GetFormat());
+      html += wxT("<tr><td><b>Format</b></td><td>") + str + wxT("</td></tr>\n");
+      if (Layer->IsTiled() == 0)
+        html += wxT("<tr><td><b>Tiled</b></td><td>no</td></tr>\n");
+      else
+        {
+          char tile[1024];
+          sprintf(tile,
+                  "<tr><td><b>Tile Width</b></td><td>%dpx</td></tr>\n<tr><td><b>Tile Height</b></td><td>%dpx</td></tr>\n",
+                  Layer->GetTileWidth(), Layer->GetTileHeight());
+          html += wxString::FromUTF8(tile);
+        }
+      html += wxT("<tr><td></td><td><hr></td></tr>\n");
+      html +=
+        wxT("<tr><td></td><td><b>Geographic Bounding Box</b></td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetGeoMinX());
+      str = wxString::FromUTF8(dummy);
+      html +=
+        wxT("<tr><td><b>West Longitude</b></td><td>") + str +
+        wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetGeoMaxX());
+      str = wxString::FromUTF8(dummy);
+      html +=
+        wxT("<tr><td><b>East Longitude</b></td><td>") + str +
+        wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetGeoMaxY());
+      str = wxString::FromUTF8(dummy);
+      html +=
+        wxT("<tr><td><b>North Latitude</b></td><td>") + str +
+        wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetGeoMinY());
+      str = wxString::FromUTF8(dummy);
+      html +=
+        wxT("<tr><td><b>South Latitude</b></td><td>") + str +
+        wxT("</td></tr>\n");
+      html += wxT("<tr><td></td><td><hr></td></tr>\n");
+      html += wxT("<tr><td></td><td><b>CRS Bounding Box</b></td></tr>\n");
+      str = wxString::FromUTF8(Layer->GetCRS());
+      html += wxT("<tr><td><b>CRS</b></td><td>") + str + wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetMinX());
+      str = wxString::FromUTF8(dummy);
+      html += wxT("<tr><td><b>Min X</b></td><td>") + str + wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetMaxX());
+      str = wxString::FromUTF8(dummy);
+      html += wxT("<tr><td><b>Max X</b></td><td>") + str + wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetMinY());
+      str = wxString::FromUTF8(dummy);
+      html += wxT("<tr><td><b>Min Y</b></td><td>") + str + wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetMaxY());
+      str = wxString::FromUTF8(dummy);
+      html += wxT("<tr><td><b>Max Y</b></td><td>") + str + wxT("</td></tr>\n");
+      html += wxT("<tr><td></td><td><hr></td></tr>\n");
+      int denom = Layer->GetMinScaleDenominator();
+      if (denom <= 0)
+        str = wxT("");
+      else
+        {
+          sprintf(dummy, "%d", denom);
+          str = wxString::FromUTF8(dummy);
+        }
+      html +=
+        wxT("<tr><td><b>Min Scale Denominator</b></td><td>") + str +
+        wxT("</td></tr>\n");
+      sprintf(dummy, "%1.6f", Layer->GetMaxY());
+      denom = Layer->GetMinScaleDenominator();
+      if (denom <= 0)
+        str = wxT("");
+      else
+        {
+          sprintf(dummy, "%d", denom);
+          str = wxString::FromUTF8(dummy);
+        }
+      denom = Layer->GetMaxScaleDenominator();
+      if (denom <= 0)
+        str = wxT("");
+      else
+        {
+          sprintf(dummy, "%d", denom);
+          str = wxString::FromUTF8(dummy);
+        }
+      html +=
+        wxT("<tr><td><b>Max Scale Denominator</b></td><td>") + str +
+        wxT("</td></tr>\n");
+      html += wxT("<tr><td></td><td><hr></td></tr>\n");
+      WmsStyle *Style = Layer->GetFirstStyle();
+      while (Style != NULL)
+        {
+          // reporting all Styles
+          html += wxT("<tr><td></td><td><b>Style</b></td></tr>\n");
+          str = wxString::FromUTF8(Style->GetName());
+          html +=
+            wxT("<tr><td><b>Name</b></td><td>") + str + wxT("</td></tr>\n");
+          str = wxString::FromUTF8(Style->GetTitle());
+          html +=
+            wxT("<tr><td><b>Title</b></td><td>") + str + wxT("</td></tr>\n");
+          str = wxString::FromUTF8(Style->GetAbstract());
+          html +=
+            wxT("<tr><td><b>Abstract</b></td><td>") + str + wxT("</td></tr>\n");
+          Style = Style->GetNext();
+        }
+      html += wxT("</table>\n");
+    }
+  html += wxT("</body>");
+  html += wxT("</html>");
+  HtmlCtrl->SetPage(html);
+// QUIT button
+  wxBoxSizer *quitBox = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(quitBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *quit = new wxButton(this, wxID_CANCEL, wxT("&Quit"));
+  quitBox->Add(quit, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// setting up the event handlers
+  Connect(wxID_ANY, wxEVT_SIZE,
+          (wxObjectEventFunction) & WmsInfoDialog::OnSize);
+}
+
+void WmsInfoDialog::OnSize(wxSizeEvent & WXUNUSED(event))
+{
+//
+// this window has changed its size
+//
+  wxSize sz = GetClientSize();
+  wxButton *quit = (wxButton *) FindWindow(wxID_CANCEL);
+  wxSize btnSz = quit->GetSize();
+  HtmlCtrl->SetSize(sz.GetWidth() - 6, sz.GetHeight() - 20 - btnSz.GetHeight());
+  int x = (sz.GetWidth() - btnSz.GetWidth()) / 2;
+  int y = sz.GetHeight() - 6 - btnSz.GetHeight();
+  quit->SetSize(x, y, btnSz.GetWidth(), btnSz.GetHeight());
+}
+
+WmsIdentifyPanel::WmsIdentifyPanel(MyMapView * parent, wxString & html,
+                                   rl2WmsFeatureCollectionPtr coll,
+                                   GeometryList * list, int x,
+                                   int y):wxWindow(parent, wxID_ANY,
+                                                   wxDefaultPosition,
+                                                   wxDefaultSize,
+                                                   wxBORDER_DOUBLE |
+                                                   wxBORDER_SUNKEN)
+{
+//
+// creating the dialog
+//
+  MapView = parent;
+  Html = wxT("");
+  Collection = NULL;
+  List = NULL;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+  Initialize(html, coll, list, x, y);
+}
+
+void WmsIdentifyPanel::Reset()
+{
+// clean up - resetting to an empty initial state
+  if (List != NULL)
+    delete List;
+  if (Collection != NULL)
+    destroy_wms_feature_collection(Collection);
+  List = NULL;
+  Collection = NULL;
+  Hide();
+}
+
+void WmsIdentifyPanel::Initialize(wxString & html,
+                                  rl2WmsFeatureCollectionPtr coll,
+                                  GeometryList * list, int x, int y)
+{
+//
+// initializing the dialog
+//
+  if (x == y)
+    x = y;                      // silencing warning about unused args
+  Html = html;
+  HtmlCtrl->SetPage(Html);
+  Reset();
+  Collection = coll;
+  List = list;
+// positioning the dialog window
+  wxRect rect = MapView->GetClientRect();
+  if (y < rect.GetHeight() / 2)
+    SetSize(rect.GetX(),
+            rect.GetY() + (rect.GetHeight() - (rect.GetHeight() / 4)),
+            rect.GetWidth(), rect.GetHeight() / 4);
+  else
+    SetSize(rect.GetX(), rect.GetY(), rect.GetWidth(), rect.GetHeight() / 4);
+}
+
+void WmsIdentifyPanel::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  HtmlCtrl = new wxHtmlWindow(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
+  topSizer->Add(HtmlCtrl, 0, wxALIGN_RIGHT | wxALL, 0);
+  HtmlCtrl->SetPage(Html);
+// QUIT button
+  wxButton *quit =
+    new wxButton(this, wxID_CANCEL, wxT("&Hide"), wxDefaultPosition,
+                 wxSize(100, 20));
+  topSizer->Add(quit, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+// setting up the event handlers
+  Connect(wxID_ANY, wxEVT_SIZE,
+          (wxObjectEventFunction) & WmsIdentifyPanel::OnSize);
+  Connect(wxID_ANY, wxEVT_COMMAND_HTML_LINK_CLICKED,
+          (wxObjectEventFunction) & WmsIdentifyPanel::OnLinkClicked);
+  Connect(wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & WmsIdentifyPanel::OnCancel);
+}
+
+void WmsIdentifyPanel::ParseHREF(wxString & href, int *layer_id, int *row_no,
+                                 int *col_no)
+{
+// attempting to parse an HREF into an ID and a layer name
+  *layer_id = -1;
+  *row_no = -1;
+  *col_no = -1;
+  char *in = new char[href.Len() + 1];
+  strcpy(in, href.ToUTF8());
+  const char *p_in = in;
+  char buf[1024];
+  char *p_out = buf;
+  int count = 0;
+  while (1)
+    {
+      if (*p_in >= '0' && *p_in <= '9')
+        *p_out++ = *p_in++;
+      else if (*p_in == '_')
+        {
+          *p_out = '\0';
+          if (count == 0)
+            *layer_id = atoi(buf);
+          else
+            *row_no = atoi(buf);
+          count++;
+          p_in++;
+          p_out = buf;
+      } else
+        {
+          *p_out = '\0';
+          *col_no = atoi(buf);
+          break;
+        }
+    }
+  delete[]in;
+}
+
+void WmsIdentifyPanel::OnLinkClicked(wxHtmlLinkEvent & event)
+{
+//
+// some link was clicked
+//
+  wxHtmlLinkInfo lnk = event.GetLinkInfo();
+  int layer_id;
+  int row_no;
+  int col_no;
+  wxString href = lnk.GetHref();
+  ParseHREF(href, &layer_id, &row_no, &col_no);
+  gaiaGeomCollPtr geom = List->Find(layer_id, row_no, col_no);
+  if (geom != NULL)
+    MapView->MarkGeometry(geom);
+}
+
+void WmsIdentifyPanel::OnSize(wxSizeEvent & WXUNUSED(event))
+{
+//
+// this window has changed its size
+//
+  wxSize sz = GetClientSize();
+  wxButton *quit = (wxButton *) FindWindow(wxID_CANCEL);
+  wxSize btnSz = quit->GetSize();
+  HtmlCtrl->SetSize(sz.GetWidth() - 6,
+                    sz.GetHeight() - (4 + btnSz.GetHeight()));
+  int x = (sz.GetWidth() - btnSz.GetWidth()) / 2;
+  int y = sz.GetHeight() - (2 + btnSz.GetHeight());
+  quit->SetSize(x, y, btnSz.GetWidth(), btnSz.GetHeight());
+}
+
+void WmsIdentifyPanel::OnCancel(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  MapView->ResetMarker();
+  Reset();
+}
+
+bool WmsCacheDialog::Create(MyFrame * parent, rl2WmsCachePtr cache)
+{
+//
+// creating the dialog
+//
+  MainFrame = parent;
+  Cache = cache;
+  if (wxDialog::Create(parent, wxID_ANY, wxT("WMS internal Cache")) == false)
+    return false;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  return true;
+}
+
+void WmsCacheDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// Cache Statistics
+  wxBoxSizer *itemsSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(itemsSizer, 0, wxALIGN_RIGHT | wxALL, 5);
+  wxStaticText *itemsLabel =
+    new wxStaticText(this, wxID_STATIC, wxT("&Cached Items:"));
+  itemsSizer->Add(itemsLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  int cnt = get_wms_cache_items_count(Cache);
+  char dummy[128];
+  sprintf(dummy, "%d", cnt);
+  wxString count = wxString::FromUTF8(dummy);
+  wxTextCtrl *itemsCtrl = new wxTextCtrl(this, ID_CACHE_ITEMS, count,
+                                         wxDefaultPosition, wxSize(100, 22),
+                                         wxTE_RIGHT | wxTE_READONLY);
+  itemsSizer->Add(itemsCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxBoxSizer *flushSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(flushSizer, 0, wxALIGN_RIGHT | wxALL, 5);
+  wxStaticText *flushLabel =
+    new wxStaticText(this, wxID_STATIC, wxT("&Flushed Items:"));
+  flushSizer->Add(flushLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  cnt = get_wms_cache_flushed_count(Cache);
+  sprintf(dummy, "%d", cnt);
+  count = wxString::FromUTF8(dummy);
+  wxTextCtrl *flushCtrl = new wxTextCtrl(this, ID_CACHE_FLUSHED, count,
+                                         wxDefaultPosition, wxSize(100, 22),
+                                         wxTE_RIGHT | wxTE_READONLY);
+  flushSizer->Add(flushCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxBoxSizer *hitSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(hitSizer, 0, wxALIGN_RIGHT | wxALL, 5);
+  wxStaticText *hitLabel =
+    new wxStaticText(this, wxID_STATIC, wxT("Total Cache &Hits:"));
+  hitSizer->Add(hitLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  cnt = get_wms_cache_hit_count(Cache);
+  sprintf(dummy, "%d", cnt);
+  count = wxString::FromUTF8(dummy);
+  wxTextCtrl *hitCtrl = new wxTextCtrl(this, ID_CACHE_HIT, count,
+                                       wxDefaultPosition, wxSize(100, 22),
+                                       wxTE_RIGHT | wxTE_READONLY);
+  hitSizer->Add(hitCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxBoxSizer *missSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(missSizer, 0, wxALIGN_RIGHT | wxALL, 5);
+  wxStaticText *missLabel =
+    new wxStaticText(this, wxID_STATIC, wxT("Total Cache &Misses:"));
+  missSizer->Add(missLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  cnt = get_wms_cache_miss_count(Cache);
+  sprintf(dummy, "%d", cnt);
+  count = wxString::FromUTF8(dummy);
+  wxTextCtrl *missCtrl = new wxTextCtrl(this, ID_CACHE_MISS, count,
+                                        wxDefaultPosition, wxSize(100, 22),
+                                        wxTE_RIGHT | wxTE_READONLY);
+  missSizer->Add(missCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxBoxSizer *szSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(szSizer, 0, wxALIGN_RIGHT | wxALL, 5);
+  wxStaticText *szLabel =
+    new wxStaticText(this, wxID_STATIC, wxT("Current &Size (bytes):"));
+  szSizer->Add(szLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  cnt = get_wms_cache_current_size(Cache);
+  sprintf(dummy, "%d", cnt);
+  count = wxString::FromUTF8(dummy);
+  wxTextCtrl *szCtrl = new wxTextCtrl(this, ID_CACHE_SIZE, count,
+                                      wxDefaultPosition, wxSize(100, 22),
+                                      wxTE_RIGHT | wxTE_READONLY);
+  szSizer->Add(szCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+  wxBoxSizer *downSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(downSizer, 0, wxALIGN_RIGHT | wxALL, 5);
+  wxStaticText *downLabel =
+    new wxStaticText(this, wxID_STATIC, wxT("Total &Download Size:"));
+  downSizer->Add(downLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  double dblcnt = get_wms_total_download_size(Cache);
+  if (dblcnt >= (double) (1024 * 1024 * 1024))
+    sprintf(dummy, "%1.2f GB", dblcnt / (double) (1024 * 1024 * 1024));
+  else if (dblcnt >= (double) (1024 * 1024))
+    sprintf(dummy, "%1.2f MB", dblcnt / (double) (1024 * 1024));
+  else
+    sprintf(dummy, "%1.2f KB", dblcnt / (double) (1024));
+  count = wxString::FromUTF8(dummy);
+  wxTextCtrl *downCtrl = new wxTextCtrl(this, ID_CACHE_DOWNLOAD, count,
+                                        wxDefaultPosition, wxSize(100, 22),
+                                        wxTE_RIGHT | wxTE_READONLY);
+  downSizer->Add(downCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+// Reset button
+  wxBoxSizer *resetSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(resetSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *resetBtn =
+    new wxButton(this, ID_CACHE_RESET, wxT("&Reset WMS Cache"));
+  resetSizer->Add(resetBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// max size slider
+  wxBoxSizer *maxSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(maxSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *maxBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("Max WMS Cache Size"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *maxBoxSizer = new wxStaticBoxSizer(maxBox, wxHORIZONTAL);
+  maxSizer->Add(maxBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  cnt = get_wms_cache_max_size(Cache);
+  int cur = cnt / (1024 * 1024);
+  wxSlider *maxCtrl =
+    new wxSlider(this, ID_CACHE_MAX, cur, 4, 256, wxDefaultPosition,
+                 wxSize(252, 50),
+                 wxSL_HORIZONTAL | wxSL_AUTOTICKS | wxSL_LABELS);
+  maxBoxSizer->Add(maxCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 0);
+// OK-Cancel buttons
+  wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(btnSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *okBtn = new wxButton(this, wxID_OK, wxT("&OK"));
+  btnSizer->Add(okBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxButton *cancelBtn = new wxButton(this, wxID_CANCEL, wxT("&Cancel"));
+  btnSizer->Add(cancelBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// appends event handlers
+  Connect(ID_CACHE_RESET, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & WmsCacheDialog::OnCacheReset);
+  Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & WmsCacheDialog::OnOk);
+}
+
+void WmsCacheDialog::OnCacheReset(wxCommandEvent & WXUNUSED(event))
+{
+//
+// resetting WMS Cache
+//
+  reset_wms_cache(Cache);
+  int cnt = get_wms_cache_items_count(Cache);
+  char dummy[128];
+  sprintf(dummy, "%d", cnt);
+  wxString count = wxString::FromUTF8(dummy);
+  wxTextCtrl *itemsCtrl = (wxTextCtrl *) FindWindow(ID_CACHE_ITEMS);
+  itemsCtrl->SetValue(count);
+  cnt = get_wms_cache_flushed_count(Cache);
+  count = wxString::FromUTF8(dummy);
+  wxTextCtrl *flushCtrl = (wxTextCtrl *) FindWindow(ID_CACHE_FLUSHED);
+  flushCtrl->SetValue(count);
+  cnt = get_wms_cache_hit_count(Cache);
+  count = wxString::FromUTF8(dummy);
+  wxTextCtrl *hitCtrl = (wxTextCtrl *) FindWindow(ID_CACHE_HIT);
+  hitCtrl->SetValue(count);
+  cnt = get_wms_cache_miss_count(Cache);
+  count = wxString::FromUTF8(dummy);
+  wxTextCtrl *missCtrl = (wxTextCtrl *) FindWindow(ID_CACHE_MISS);
+  missCtrl->SetValue(count);
+  cnt = get_wms_cache_current_size(Cache);
+  count = wxString::FromUTF8(dummy);
+  wxTextCtrl *sizeCtrl = (wxTextCtrl *) FindWindow(ID_CACHE_SIZE);
+  sizeCtrl->SetValue(count);
+  return;
+}
+
+void WmsCacheDialog::OnOk(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxSlider *maxCtrl = (wxSlider *) FindWindow(ID_CACHE_MAX);
+  set_wms_cache_max_size(Cache, maxCtrl->GetValue() * 1024 * 1024);
+  wxDialog::EndModal(wxID_OK);
+}
+
+bool WmsMapCrsDialog::Create(MyFrame * parent)
+{
+//
+// creating the dialog
+//
+  MainFrame = parent;
+  if (wxDialog::Create(parent, wxID_ANY, wxT("WMS Map CRS selection")) == false)
+    return false;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  return true;
+}
+
+void WmsMapCrsDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// CRS combo box
+  wxBoxSizer *crsSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(crsSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *crsBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("Reference System"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *crsBoxSizer = new wxStaticBoxSizer(crsBox, wxVERTICAL);
+  crsSizer->Add(crsBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxComboBox *crsList =
+    new wxComboBox(this, ID_WMS_CRS, wxT(""), wxDefaultPosition,
+                   wxSize(150, 21), 0, NULL,
+                   wxCB_DROPDOWN | wxCB_SORT | wxCB_READONLY);
+  WmsCRS *crs = MainFrame->GetFirstMapCRS();
+  while (crs != NULL)
+    {
+      wxString crs_def = wxString::FromUTF8(crs->GetCRS());
+      crsList->Append(crs_def);
+      crs = crs->GetNext();
+    }
+  wxString curCrs = wxString::FromUTF8(MainFrame->GetMapCRS());
+  if (crsList->SetStringSelection(curCrs) == false)
+    crsList->SetSelection(0);
+  crsBoxSizer->Add(crsList, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+// OK-Cancel buttons
+  wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(btnSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *okBtn = new wxButton(this, wxID_OK, wxT("&OK"));
+  btnSizer->Add(okBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxButton *cancelBtn = new wxButton(this, wxID_CANCEL, wxT("&Cancel"));
+  btnSizer->Add(cancelBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// appends event handlers
+  Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & WmsMapCrsDialog::OnOk);
+}
+
+void WmsMapCrsDialog::OnOk(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxComboBox *comboCtrl = (wxComboBox *) FindWindow(ID_WMS_CRS);
+  wxString crs = comboCtrl->GetValue();
+  if (crs.Len() == 0)
+    {
+      wxMessageBox(wxT("You must select some CRS !!!"),
+                   wxT("LibreWMS"), wxOK | wxICON_WARNING, this);
+      return;
+    }
+  CRS = crs;
+  wxDialog::EndModal(wxID_OK);
+}
+
+bool UserScaleDialog::Create(MyFrame * parent, int scale, double pixel_ratio)
+{
+//
+// creating the dialog
+//
+  MainFrame = parent;
+  if (wxDialog::Create(parent, wxID_ANY, wxT("WMS Map User Scale selection")) ==
+      false)
+    return false;
+  CurrentScale = scale;
+  PixelRatio = pixel_ratio;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  return true;
+}
+
+void UserScaleDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// User Selected Scale
+  wxBoxSizer *scaleSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(scaleSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *scaleBox = new wxStaticBox(this, wxID_STATIC,
+                                          wxT("User Selected Scale"),
+                                          wxDefaultPosition,
+                                          wxDefaultSize);
+  wxBoxSizer *scaleBoxSizer = new wxStaticBoxSizer(scaleBox, wxHORIZONTAL);
+  scaleSizer->Add(scaleBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxStaticText *scaleLabel = new wxStaticText(this, wxID_ANY, wxT("&1 :"),
+                                              wxDefaultPosition, wxDefaultSize,
+                                              wxALIGN_RIGHT);
+  scaleBoxSizer->Add(scaleLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxSpinCtrl *scaleCtrl = new wxSpinCtrl(this, ID_USER_SCALE, wxEmptyString,
+                                         wxDefaultPosition, wxSize(120, 20),
+                                         wxSP_ARROW_KEYS,
+                                         1, 100000000, CurrentScale);
+  scaleBoxSizer->Add(scaleCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+// Pixel - MapUnits ratio
+  wxBoxSizer *ratioSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(ratioSizer, 0, wxALIGN_TOP | wxALL, 5);
+  wxStaticBox *ratioBox = new wxStaticBox(this, wxID_STATIC,
+                                          wxT("MapUnits per Pixel"),
+                                          wxDefaultPosition,
+                                          wxDefaultSize);
+  wxBoxSizer *ratioBoxSizer = new wxStaticBoxSizer(ratioBox, wxHORIZONTAL);
+  ratioSizer->Add(ratioBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  char buf[128];
+  sprintf(buf, "%1.12f", PixelRatio);
+  wxString ratio = wxString::FromUTF8(buf);
+  wxTextCtrl *ratioCtrl = new wxTextCtrl(this, ID_USER_RATIO, ratio,
+                                         wxDefaultPosition, wxSize(150, 22),
+                                         wxTE_READONLY | wxTE_RIGHT);
+  ratioCtrl->Enable(false);
+  ratioBoxSizer->Add(ratioCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+// OK-Cancel buttons
+  wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(btnSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *okBtn = new wxButton(this, wxID_OK, wxT("&OK"));
+  btnSizer->Add(okBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxButton *cancelBtn = new wxButton(this, wxID_CANCEL, wxT("&Cancel"));
+  btnSizer->Add(cancelBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// appends event handlers
+  Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & UserScaleDialog::OnOk);
+  Connect(ID_USER_SCALE, wxEVT_COMMAND_SPINCTRL_UPDATED,
+          (wxObjectEventFunction) & UserScaleDialog::OnScaleChanged);
+  Connect(ID_USER_SCALE, wxEVT_COMMAND_TEXT_UPDATED,
+          (wxObjectEventFunction) & UserScaleDialog::OnScaleChanged);
+}
+
+void UserScaleDialog::OnScaleChanged(wxSpinEvent & WXUNUSED(event))
+{
+//
+// updating the current MapUnits - Pixel ratio: 
+//
+  wxSpinCtrl *scaleCtrl = (wxSpinCtrl *) FindWindow(ID_USER_SCALE);
+  int scale = scaleCtrl->GetValue();
+  double current_ratio = (double) scale * PixelRatio / (double) CurrentScale;
+  char buf[128];
+  sprintf(buf, "%1.12f", current_ratio);
+  wxString ratio = wxString::FromUTF8(buf);
+  wxTextCtrl *ratioCtrl = (wxTextCtrl *) FindWindow(ID_USER_RATIO);
+  ratioCtrl->SetValue(ratio);
+}
+
+void UserScaleDialog::OnOk(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxSpinCtrl *scaleCtrl = (wxSpinCtrl *) FindWindow(ID_USER_SCALE);
+  CurrentScale = scaleCtrl->GetValue();
+  wxDialog::EndModal(wxID_OK);
+}
+
+bool PrinterDialog::Create(MyFrame * parent)
+{
+//
+// creating the dialog
+//
+  MainFrame = parent;
+  if (wxDialog::Create(parent, wxID_ANY, wxT("WMS Map Printer")) == false)
+    return false;
+  Width = 2048;
+  Height = 2048;
+  PDF = false;
+  TIFF = true;
+  GeoTiff = false;
+  TileSize = 0;
+  StripSize = 0;
+  Compression = RL2_COMPRESSION_NONE;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  return true;
+}
+
+void PrinterDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// general parameters
+  wxBoxSizer *genSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(genSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+  wxStaticBox *genBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("Export Mode Selection"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *genBoxSizer = new wxStaticBoxSizer(genBox, wxHORIZONTAL);
+  genSizer->Add(genBoxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 2);
+  wxString format[2];
+  format[0] = wxT("Export Map as PDF");
+  format[1] = wxT("Export Map as TIFF");
+  wxRadioBox *formatBox = new wxRadioBox(this, ID_PDF_TIFF,
+                                         wxT("Export Format"),
+                                         wxDefaultPosition,
+                                         wxDefaultSize, 2,
+                                         format, 2,
+                                         wxRA_SPECIFY_ROWS);
+  formatBox->SetSelection(1);
+  genBoxSizer->Add(formatBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxString mode[3];
+  mode[0] = wxT("Preserve Scale");
+  mode[1] = wxT("Preserve Width");
+  mode[2] = wxT("Preserve Height");
+  wxRadioBox *modeBox = new wxRadioBox(this, ID_PRINT_MODE,
+                                       wxT("Map Scale and Viewport"),
+                                       wxDefaultPosition,
+                                       wxDefaultSize, 3,
+                                       mode, 3,
+                                       wxRA_SPECIFY_ROWS);
+  modeBox->SetSelection(2);
+  genBoxSizer->Add(modeBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxBoxSizer *printSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(printSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// PDF parameters
+  wxBoxSizer *pdfSizer = new wxBoxSizer(wxHORIZONTAL);
+  printSizer->Add(pdfSizer, 0, wxALIGN_TOP | wxALL, 0);
+  wxStaticBox *pdfBox = new wxStaticBox(this, wxID_STATIC,
+                                        wxT("PDF Options"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize);
+  wxBoxSizer *pdfBoxSizer = new wxStaticBoxSizer(pdfBox, wxVERTICAL);
+  pdfSizer->Add(pdfBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxBoxSizer *pdf1BoxSizer = new wxBoxSizer(wxHORIZONTAL);
+  pdfBoxSizer->Add(pdf1BoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxString page[5];
+  page[0] = wxT("A4");
+  page[1] = wxT("A3");
+  page[2] = wxT("A2");
+  page[3] = wxT("A1");
+  page[4] = wxT("A0");
+  wxRadioBox *pageBox = new wxRadioBox(this, ID_PDF_PAGE,
+                                       wxT("Page Size"),
+                                       wxDefaultPosition,
+                                       wxDefaultSize, 5,
+                                       page, 5,
+                                       wxRA_SPECIFY_ROWS);
+  pageBox->SetSelection(0);
+  pageBox->Enable(false);
+  pdf1BoxSizer->Add(pageBox, 0, wxALIGN_TOP | wxALL, 2);
+  wxString dpi[5];
+  dpi[0] = wxT("72 DPI");
+  dpi[1] = wxT("150 DPI");
+  dpi[2] = wxT("300 DPI");
+  dpi[3] = wxT("600 DPI");
+  wxRadioBox *dpiBox = new wxRadioBox(this, ID_PDF_DPI,
+                                      wxT("Resolution"),
+                                      wxDefaultPosition,
+                                      wxDefaultSize, 4,
+                                      dpi, 4,
+                                      wxRA_SPECIFY_ROWS);
+  dpiBox->SetSelection(2);
+  dpiBox->Enable(false);
+  pdf1BoxSizer->Add(dpiBox, 0, wxALIGN_TOP | wxALL, 2);
+  wxBoxSizer *pdf2BoxSizer = new wxBoxSizer(wxVERTICAL);
+  pdfBoxSizer->Add(pdf2BoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxString orient[2];
+  orient[0] = wxT("Landscape");
+  orient[1] = wxT("Portrait");
+  wxRadioBox *orientBox = new wxRadioBox(this, ID_PDF_ORIENTATION,
+                                         wxT("Page Orientation"),
+                                         wxDefaultPosition,
+                                         wxDefaultSize, 2,
+                                         orient, 2,
+                                         wxRA_SPECIFY_COLS);
+  orientBox->SetSelection(0);
+  orientBox->Enable(false);
+  pdf2BoxSizer->Add(orientBox, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 2);
+// TIFF parameters
+  wxBoxSizer *tiffSizer = new wxBoxSizer(wxVERTICAL);
+  printSizer->Add(tiffSizer, 0, wxALIGN_TOP | wxALL, 0);
+  wxStaticBox *tiffBox = new wxStaticBox(this, wxID_STATIC,
+                                         wxT("TIFF Options"),
+                                         wxDefaultPosition,
+                                         wxDefaultSize);
+  wxBoxSizer *tiffBoxSizer = new wxStaticBoxSizer(tiffBox, wxVERTICAL);
+  tiffSizer->Add(tiffBoxSizer, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxBoxSizer *dimSizer = new wxBoxSizer(wxHORIZONTAL);
+  tiffBoxSizer->Add(dimSizer, 0, wxALIGN_TOP | wxALL, 2);
+  wxBoxSizer *dim1Sizer = new wxBoxSizer(wxVERTICAL);
+  dimSizer->Add(dim1Sizer, 0, wxALIGN_TOP | wxALL, 2);
+  wxBoxSizer *wSizer = new wxBoxSizer(wxHORIZONTAL);
+  dim1Sizer->Add(wSizer, 0, wxALIGN_RIGHT | wxALL, 2);
+  wxStaticText *wLabel = new wxStaticText(this, wxID_ANY, wxT("&Width:"),
+                                          wxDefaultPosition, wxDefaultSize,
+                                          wxALIGN_RIGHT);
+  wSizer->Add(wLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxSpinCtrl *wCtrl = new wxSpinCtrl(this, ID_TIFF_WIDTH, wxT("2048"),
+                                     wxDefaultPosition, wxSize(80, 20),
+                                     wxSP_ARROW_KEYS,
+                                     512, 21600, 2048);
+  wSizer->Add(wCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxBoxSizer *hSizer = new wxBoxSizer(wxHORIZONTAL);
+  dim1Sizer->Add(hSizer, 0, wxALIGN_RIGHT | wxALL, 2);
+  wxStaticText *hLabel = new wxStaticText(this, wxID_ANY, wxT("&Height:"),
+                                          wxDefaultPosition, wxDefaultSize,
+                                          wxALIGN_RIGHT);
+  hSizer->Add(hLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxSpinCtrl *hCtrl = new wxSpinCtrl(this, ID_TIFF_HEIGHT, wxT("2048"),
+                                     wxDefaultPosition, wxSize(80, 20),
+                                     wxSP_ARROW_KEYS,
+                                     512, 21600, 2048);
+  hSizer->Add(hCtrl, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+  wxString geo[4];
+  geo[0] = wxT("GeoTIFF");
+  geo[1] = wxT("Worldfile");
+  geo[2] = wxT("Both");
+  geo[3] = wxT("None");
+  wxRadioBox *geoBox = new wxRadioBox(this, ID_TIFF_GEO,
+                                      wxT("Georeferencing"),
+                                      wxDefaultPosition,
+                                      wxDefaultSize, 4,
+                                      geo, 2,
+                                      wxRA_SPECIFY_COLS);
+  geoBox->SetSelection(2);
+  dimSizer->Add(geoBox, 0, wxALIGN_TOP | wxALL, 2);
+  wxBoxSizer *dim2Sizer = new wxBoxSizer(wxHORIZONTAL);
+  tiffBoxSizer->Add(dim2Sizer, 0, wxALIGN_RIGHT | wxALL, 2);
+  wxString tile_sz[7];
+  tile_sz[0] = wxT("64");
+  tile_sz[1] = wxT("128");
+  tile_sz[2] = wxT("256");
+  tile_sz[3] = wxT("512");
+  tile_sz[4] = wxT("1024");
+  tile_sz[5] = wxT("2048");
+  tile_sz[6] = wxT("by Strip");
+  wxRadioBox *tileSzBox = new wxRadioBox(this, ID_TIFF_TILE_SZ,
+                                         wxT("Tile Size"),
+                                         wxDefaultPosition,
+                                         wxDefaultSize, 7,
+                                         tile_sz, 2,
+                                         wxRA_SPECIFY_COLS);
+  tileSzBox->SetSelection(2);
+  dim2Sizer->Add(tileSzBox, 0, wxALIGN_TOP | wxALL, 2);
+  wxString compression[5];
+  compression[0] = wxT("None");
+  compression[1] = wxT("LZW");
+  compression[2] = wxT("DEFLATE");
+  compression[3] = wxT("LZMA");
+  compression[4] = wxT("JPEG");
+  wxRadioBox *compressionBox = new wxRadioBox(this, ID_TIFF_COMPR,
+                                              wxT("Compression"),
+                                              wxDefaultPosition,
+                                              wxDefaultSize, 5,
+                                              compression, 2,
+                                              wxRA_SPECIFY_COLS);
+  compressionBox->SetSelection(0);
+  dim2Sizer->Add(compressionBox, 0, wxALIGN_TOP | wxALL, 2);
+// OK-Cancel buttons
+  wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(btnSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *okBtn = new wxButton(this, wxID_OK, wxT("&OK"));
+  btnSizer->Add(okBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxButton *cancelBtn = new wxButton(this, wxID_CANCEL, wxT("&Cancel"));
+  btnSizer->Add(cancelBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// appends event handlers
+  Connect(ID_PDF_TIFF, wxEVT_COMMAND_RADIOBOX_SELECTED,
+          (wxObjectEventFunction) & PrinterDialog::OnFormatChanged);
+  Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & PrinterDialog::OnOk);
+}
+
+void PrinterDialog::OnFormatChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// Map Export Format changed
+//
+  wxRadioBox *modeBox = (wxRadioBox *) FindWindow(ID_PDF_TIFF);
+  wxRadioBox *pageBox = (wxRadioBox *) FindWindow(ID_PDF_PAGE);
+  wxRadioBox *dpiBox = (wxRadioBox *) FindWindow(ID_PDF_DPI);
+  wxRadioBox *orientBox = (wxRadioBox *) FindWindow(ID_PDF_ORIENTATION);
+  wxRadioBox *geoBox = (wxRadioBox *) FindWindow(ID_TIFF_GEO);
+  wxRadioBox *compressionBox = (wxRadioBox *) FindWindow(ID_TIFF_COMPR);
+  wxRadioBox *tileSzBox = (wxRadioBox *) FindWindow(ID_TIFF_TILE_SZ);
+  wxSpinCtrl *wCtrl = (wxSpinCtrl *) FindWindow(ID_TIFF_WIDTH);
+  wxSpinCtrl *hCtrl = (wxSpinCtrl *) FindWindow(ID_TIFF_HEIGHT);
+  if (modeBox->GetSelection() == 0)
+    {
+      pageBox->Enable(true);
+      dpiBox->Enable(true);
+      orientBox->Enable(true);
+      geoBox->Enable(false);
+      compressionBox->Enable(false);
+      tileSzBox->Enable(false);
+      wCtrl->Enable(false);
+      hCtrl->Enable(false);
+  } else
+    {
+      pageBox->Enable(false);
+      dpiBox->Enable(false);
+      orientBox->Enable(false);
+      geoBox->Enable(true);
+      compressionBox->Enable(true);
+      tileSzBox->Enable(true);
+      wCtrl->Enable(true);
+      hCtrl->Enable(true);
+    }
+}
+
+void PrinterDialog::OnOk(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxRadioBox *formatBox = (wxRadioBox *) FindWindow(ID_PDF_TIFF);
+  wxRadioBox *modeBox = (wxRadioBox *) FindWindow(ID_PRINT_MODE);
+  wxRadioBox *pageBox = (wxRadioBox *) FindWindow(ID_PDF_PAGE);
+  wxRadioBox *dpiBox = (wxRadioBox *) FindWindow(ID_PDF_DPI);
+  wxRadioBox *orientBox = (wxRadioBox *) FindWindow(ID_PDF_ORIENTATION);
+  wxRadioBox *geoBox = (wxRadioBox *) FindWindow(ID_TIFF_GEO);
+  wxRadioBox *compressionBox = (wxRadioBox *) FindWindow(ID_TIFF_COMPR);
+  wxRadioBox *tileSzBox = (wxRadioBox *) FindWindow(ID_TIFF_TILE_SZ);
+  wxSpinCtrl *wCtrl = (wxSpinCtrl *) FindWindow(ID_TIFF_WIDTH);
+  wxSpinCtrl *hCtrl = (wxSpinCtrl *) FindWindow(ID_TIFF_HEIGHT);
+  if (modeBox->GetSelection() == 2)
+    {
+      PreserveScale = false;
+      PreserveWidth = false;
+      PreserveHeight = true;
+  } else if (modeBox->GetSelection() == 1)
+    {
+      PreserveScale = false;
+      PreserveWidth = true;
+      PreserveHeight = false;
+  } else
+    {
+      PreserveScale = true;
+      PreserveWidth = false;
+      PreserveHeight = false;
+    }
+  if (formatBox->GetSelection() == 0)
+    {
+      // PDF options
+      PDF = true;
+      TIFF = false;
+      GeoTiff = false;
+      Compression = RL2_COMPRESSION_NONE;
+      switch (dpiBox->GetSelection())
+        {
+          case 1:
+            Dpi = 150;
+            break;
+          case 2:
+            Dpi = 300;
+            break;
+          case 3:
+            Dpi = 600;
+            break;
+          default:
+            Dpi = 72;
+            break;
+        };
+      switch (pageBox->GetSelection())
+        {
+          case 1:
+            if (orientBox->GetSelection() == 0)
+              {
+                // A3 landscape
+                PageWidth = 16.5;
+                PageHeight = 11.7;
+            } else
+              {
+                // A3 portrait
+                PageWidth = 11.7;
+                PageHeight = 16.5;
+              }
+            break;
+          case 2:
+            if (orientBox->GetSelection() == 0)
+              {
+                // A2 landscape
+                PageWidth = 23.4;
+                PageHeight = 16.5;
+            } else
+              {
+                // A2 portrait
+                PageWidth = 16.5;
+                PageHeight = 23.4;
+              }
+            break;
+          case 3:
+            if (orientBox->GetSelection() == 0)
+              {
+                // A1 landscape
+                PageWidth = 33.1;
+                PageHeight = 23.4;
+            } else
+              {
+                // A1 portrait
+                PageWidth = 23.4;
+                PageHeight = 33.1;
+              }
+            break;
+          case 4:
+            if (orientBox->GetSelection() == 0)
+              {
+                // A0 landscape
+                PageWidth = 46.8;
+                PageHeight = 33.1;
+            } else
+              {
+                // A0 portrait
+                PageWidth = 33.1;
+                PageHeight = 46.8;
+              }
+            break;
+          default:
+            if (orientBox->GetSelection() == 0)
+              {
+                // A4 landscape
+                PageWidth = 11.7;
+                PageHeight = 8.3;
+            } else
+              {
+                // A4 portrait
+                PageWidth = 8.3;
+                PageHeight = 11.7;
+              }
+            break;
+        };
+      HorzMarginSize = 1.0;
+      VertMarginSize = 1.0;
+  } else
+    {
+      // TIFF options
+      PDF = false;
+      TIFF = true;
+      GeoTiff = false;
+      Worldfile = false;
+      if (geoBox->GetSelection() == 0 || geoBox->GetSelection() == 2)
+        GeoTiff = true;
+      if (geoBox->GetSelection() == 1 || geoBox->GetSelection() == 2)
+        Worldfile = true;
+      switch (compressionBox->GetSelection())
+        {
+          case 1:
+            Compression = RL2_COMPRESSION_LZW;
+            break;
+          case 2:
+            Compression = RL2_COMPRESSION_DEFLATE;
+            break;
+          case 3:
+            Compression = RL2_COMPRESSION_LZMA;
+            break;
+          case 4:
+            Compression = RL2_COMPRESSION_JPEG;
+            break;
+          default:
+            Compression = RL2_COMPRESSION_NONE;
+            break;
+        };
+      switch (tileSzBox->GetSelection())
+        {
+          case 0:
+            TileSize = 64;
+            break;
+          case 1:
+            TileSize = 128;
+            break;
+          case 2:
+            TileSize = 256;
+            break;
+          case 3:
+            TileSize = 512;
+            break;
+          case 4:
+            TileSize = 1024;
+            break;
+          case 5:
+            TileSize = 2048;
+            break;
+          default:
+            StripSize = 1;
+            break;
+        }
+      Width = wCtrl->GetValue();
+      Height = hCtrl->GetValue();
+    }
+  wxDialog::EndModal(wxID_OK);
+}
+
+bool TiffMonochromeDialog::Create(MyMapView * parent)
+{
+//
+// creating the dialog
+//
+  Parent = parent;
+  if (wxDialog::Create(parent, wxID_ANY, wxT("Monochrome TIFF")) == false)
+    return false;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  return true;
+}
+
+void TiffMonochromeDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// message
+  wxString msg = wxT("The current image could be safely exported using a\n");
+  msg += wxT("Monochrome/Bilevel color space; a Monochrome image simply\n");
+  msg += wxT("requires 1-bit for each pixel, thus requiring much less space\n");
+  msg += wxT("than a 24-bit RGB image\n\n");
+  msg += wxT("Exporting this image as Monochrome is strongly suggested:\n");
+  msg += wxT("please confirm\n");
+  wxStaticText *label = new wxStaticText(this, wxID_ANY, msg,
+                                         wxDefaultPosition, wxDefaultSize,
+                                         wxALIGN_LEFT);
+  boxSizer->Add(label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+// general parameters
+  wxString color[2];
+  color[0] = wxT("Export as Monochrome");
+  color[1] = wxT("Export as RGB");
+  wxRadioBox *colorBox = new wxRadioBox(this, ID_TIFF_COLORSPACE,
+                                        wxT("Colorspace Selection"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize, 2,
+                                        color, 1,
+                                        wxRA_SPECIFY_ROWS);
+  colorBox->SetSelection(0);
+  boxSizer->Add(colorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// TIFF parameters
+  wxString compression[3];
+  compression[0] = wxT("None");
+  compression[1] = wxT("CCITT FAX3");
+  compression[2] = wxT("CCITT FAX4");
+  wxRadioBox *compressionBox = new wxRadioBox(this, ID_TIFF_COMPR,
+                                              wxT("Compression"),
+                                              wxDefaultPosition,
+                                              wxDefaultSize, 3,
+                                              compression, 1,
+                                              wxRA_SPECIFY_ROWS);
+  compressionBox->SetSelection(2);
+  boxSizer->Add(compressionBox, 0, wxALIGN_CENTER | wxALL, 2);
+// OK-Cancel buttons
+  wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(btnSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *okBtn = new wxButton(this, wxID_OK, wxT("&OK"));
+  btnSizer->Add(okBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxButton *cancelBtn = new wxButton(this, wxID_CANCEL, wxT("&Abort"));
+  btnSizer->Add(cancelBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// appends event handlers
+  Connect(ID_TIFF_COLORSPACE, wxEVT_COMMAND_RADIOBOX_SELECTED,
+          (wxObjectEventFunction) & TiffMonochromeDialog::OnColorspaceChanged);
+  Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & TiffMonochromeDialog::OnOk);
+}
+
+
+void TiffMonochromeDialog::OnColorspaceChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// TIFF Colorspace changed
+//
+  wxRadioBox *colorBox = (wxRadioBox *) FindWindow(ID_TIFF_COLORSPACE);
+  wxRadioBox *compressionBox = (wxRadioBox *) FindWindow(ID_TIFF_COMPR);
+  if (colorBox->GetSelection() == 0)
+    compressionBox->Enable(true);
+  else
+    compressionBox->Enable(false);
+}
+
+void TiffMonochromeDialog::OnOk(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxRadioBox *colorBox = (wxRadioBox *) FindWindow(ID_TIFF_COLORSPACE);
+  wxRadioBox *compressionBox = (wxRadioBox *) FindWindow(ID_TIFF_COMPR);
+  Monochrome = false;
+  if (colorBox->GetSelection() == 0)
+    {
+      Monochrome = true;
+      switch (compressionBox->GetSelection())
+        {
+          case 1:
+            Compression = RL2_COMPRESSION_CCITTFAX3;
+            break;
+          case 2:
+            Compression = RL2_COMPRESSION_CCITTFAX4;
+            break;
+          default:
+            Compression = RL2_COMPRESSION_NONE;
+            break;
+        };
+    }
+  wxDialog::EndModal(wxID_OK);
+}
+
+bool TiffGrayscaleDialog::Create(MyMapView * parent, unsigned char compression)
+{
+//
+// creating the dialog
+//
+  Parent = parent;
+  Compression = compression;
+  if (wxDialog::Create(parent, wxID_ANY, wxT("Grayscale TIFF")) == false)
+    return false;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  return true;
+}
+
+void TiffGrayscaleDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// message
+  wxString msg =
+    wxT("The current image could be safely exported using a Grayscale \n");
+  msg +=
+    wxT("color space; a Grayscale image simply requires 8-bits for each\n");
+  msg +=
+    wxT("pixel, thus requiring much less space than a 24-bit RGB image\n\n");
+  msg += wxT("Exporting this image as Grayscale is strongly suggested:\n");
+  msg += wxT("please confirm\n");
+  wxStaticText *label = new wxStaticText(this, wxID_ANY, msg,
+                                         wxDefaultPosition, wxDefaultSize,
+                                         wxALIGN_LEFT);
+  boxSizer->Add(label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+// general parameters
+  wxString color[2];
+  color[0] = wxT("Export as Grayscale");
+  color[1] = wxT("Export as RGB");
+  wxRadioBox *colorBox = new wxRadioBox(this, ID_TIFF_COLORSPACE,
+                                        wxT("Colorspace Selection"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize, 2,
+                                        color, 1,
+                                        wxRA_SPECIFY_ROWS);
+  colorBox->SetSelection(0);
+  boxSizer->Add(colorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// TIFF parameters
+  wxString compression[5];
+  compression[0] = wxT("None");
+  compression[1] = wxT("LZW");
+  compression[2] = wxT("DEFLATE");
+  compression[3] = wxT("LZMA");
+  compression[4] = wxT("JPEG");
+  wxRadioBox *compressionBox = new wxRadioBox(this, ID_TIFF_COMPR,
+                                              wxT("Compression"),
+                                              wxDefaultPosition,
+                                              wxDefaultSize, 5,
+                                              compression, 2,
+                                              wxRA_SPECIFY_ROWS);
+  switch (Compression)
+    {
+      case RL2_COMPRESSION_LZW:
+        compressionBox->SetSelection(1);
+        break;
+      case RL2_COMPRESSION_DEFLATE:
+        compressionBox->SetSelection(2);
+        break;
+      case RL2_COMPRESSION_LZMA:
+        compressionBox->SetSelection(3);
+        break;
+      case RL2_COMPRESSION_JPEG:
+        compressionBox->SetSelection(4);
+        break;
+      default:
+        compressionBox->SetSelection(0);
+        break;
+    };
+  boxSizer->Add(compressionBox, 0, wxALIGN_CENTER | wxALL, 2);
+// OK-Cancel buttons
+  wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(btnSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *okBtn = new wxButton(this, wxID_OK, wxT("&OK"));
+  btnSizer->Add(okBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxButton *cancelBtn = new wxButton(this, wxID_CANCEL, wxT("&Abort"));
+  btnSizer->Add(cancelBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// appends event handlers
+  Connect(ID_TIFF_COLORSPACE, wxEVT_COMMAND_RADIOBOX_SELECTED,
+          (wxObjectEventFunction) & TiffGrayscaleDialog::OnColorspaceChanged);
+  Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & TiffGrayscaleDialog::OnOk);
+}
+
+
+void TiffGrayscaleDialog::OnColorspaceChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// TIFF Colorspace changed
+//
+  wxRadioBox *colorBox = (wxRadioBox *) FindWindow(ID_TIFF_COLORSPACE);
+  wxRadioBox *compressionBox = (wxRadioBox *) FindWindow(ID_TIFF_COMPR);
+  if (colorBox->GetSelection() == 0)
+    compressionBox->Enable(true);
+  else
+    compressionBox->Enable(false);
+}
+
+void TiffGrayscaleDialog::OnOk(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxRadioBox *colorBox = (wxRadioBox *) FindWindow(ID_TIFF_COLORSPACE);
+  wxRadioBox *compressionBox = (wxRadioBox *) FindWindow(ID_TIFF_COMPR);
+  Grayscale = false;
+  if (colorBox->GetSelection() == 0)
+    {
+      Grayscale = true;
+      switch (compressionBox->GetSelection())
+        {
+          case 1:
+            Compression = RL2_COMPRESSION_LZW;
+            break;
+          case 2:
+            Compression = RL2_COMPRESSION_DEFLATE;
+            break;
+          case 3:
+            Compression = RL2_COMPRESSION_LZMA;
+            break;
+          case 4:
+            Compression = RL2_COMPRESSION_JPEG;
+            break;
+          default:
+            Compression = RL2_COMPRESSION_NONE;
+            break;
+        };
+    }
+  wxDialog::EndModal(wxID_OK);
+}
+
+
+bool TiffPaletteDialog::Create(MyMapView * parent, unsigned char compression)
+{
+//
+// creating the dialog
+//
+  Parent = parent;
+  Compression = compression;
+  if (wxDialog::Create(parent, wxID_ANY, wxT("Palette TIFF")) == false)
+    return false;
+// populates individual controls
+  CreateControls();
+// sets dialog sizer
+  GetSizer()->Fit(this);
+  GetSizer()->SetSizeHints(this);
+// centers the dialog window
+  Centre();
+  return true;
+}
+
+void TiffPaletteDialog::CreateControls()
+{
+//
+// creating individual control and setting initial values
+//
+  wxBoxSizer *topSizer = new wxBoxSizer(wxVERTICAL);
+  this->SetSizer(topSizer);
+  wxBoxSizer *boxSizer = new wxBoxSizer(wxVERTICAL);
+  topSizer->Add(boxSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
+// message
+  wxString msg =
+    wxT("The current image could be safely exported using a Palette \n");
+  msg += wxT("color space; a Palette image simply requires 8-bits for each\n");
+  msg +=
+    wxT("pixel, thus requiring much less space than a 24-bit RGB image\n\n");
+  msg += wxT("Exporting this image as Palette is strongly suggested:\n");
+  msg += wxT("please confirm\n");
+  wxStaticText *label = new wxStaticText(this, wxID_ANY, msg,
+                                         wxDefaultPosition, wxDefaultSize,
+                                         wxALIGN_LEFT);
+  boxSizer->Add(label, 0, wxALIGN_CENTER_VERTICAL | wxALL, 2);
+// general parameters
+  wxString color[2];
+  color[0] = wxT("Export as Palette");
+  color[1] = wxT("Export as RGB");
+  wxRadioBox *colorBox = new wxRadioBox(this, ID_TIFF_COLORSPACE,
+                                        wxT("Colorspace Selection"),
+                                        wxDefaultPosition,
+                                        wxDefaultSize, 2,
+                                        color, 1,
+                                        wxRA_SPECIFY_ROWS);
+  colorBox->SetSelection(0);
+  boxSizer->Add(colorBox, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// TIFF parameters
+  wxString compression[4];
+  compression[0] = wxT("None");
+  compression[1] = wxT("LZW");
+  compression[2] = wxT("DEFLATE");
+  compression[3] = wxT("LZMA");
+  wxRadioBox *compressionBox = new wxRadioBox(this, ID_TIFF_COMPR,
+                                              wxT("Compression"),
+                                              wxDefaultPosition,
+                                              wxDefaultSize, 4,
+                                              compression, 2,
+                                              wxRA_SPECIFY_ROWS);
+  switch (Compression)
+    {
+      case RL2_COMPRESSION_LZW:
+        compressionBox->SetSelection(1);
+        break;
+      case RL2_COMPRESSION_DEFLATE:
+        compressionBox->SetSelection(2);
+        break;
+      case RL2_COMPRESSION_LZMA:
+        compressionBox->SetSelection(3);
+        break;
+      default:
+        compressionBox->SetSelection(0);
+        break;
+    };
+  boxSizer->Add(compressionBox, 0, wxALIGN_CENTER | wxALL, 2);
+// OK-Cancel buttons
+  wxBoxSizer *btnSizer = new wxBoxSizer(wxHORIZONTAL);
+  boxSizer->Add(btnSizer, 0, wxALIGN_CENTER_HORIZONTAL | wxALL, 0);
+  wxButton *okBtn = new wxButton(this, wxID_OK, wxT("&OK"));
+  btnSizer->Add(okBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+  wxButton *cancelBtn = new wxButton(this, wxID_CANCEL, wxT("&Abort"));
+  btnSizer->Add(cancelBtn, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5);
+// appends event handlers
+  Connect(ID_TIFF_COLORSPACE, wxEVT_COMMAND_RADIOBOX_SELECTED,
+          (wxObjectEventFunction) & TiffPaletteDialog::OnColorspaceChanged);
+  Connect(wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & TiffPaletteDialog::OnOk);
+}
+
+
+void TiffPaletteDialog::OnColorspaceChanged(wxCommandEvent & WXUNUSED(event))
+{
+//
+// TIFF Colorspace changed
+//
+  wxRadioBox *colorBox = (wxRadioBox *) FindWindow(ID_TIFF_COLORSPACE);
+  wxRadioBox *compressionBox = (wxRadioBox *) FindWindow(ID_TIFF_COMPR);
+  if (colorBox->GetSelection() == 0)
+    compressionBox->Enable(true);
+  else
+    compressionBox->Enable(false);
+}
+
+void TiffPaletteDialog::OnOk(wxCommandEvent & WXUNUSED(event))
+{
+//
+// all done: 
+//
+  wxRadioBox *colorBox = (wxRadioBox *) FindWindow(ID_TIFF_COLORSPACE);
+  wxRadioBox *compressionBox = (wxRadioBox *) FindWindow(ID_TIFF_COMPR);
+  Palette = false;
+  if (colorBox->GetSelection() == 0)
+    {
+      Palette = true;
+      switch (compressionBox->GetSelection())
+        {
+          case 1:
+            Compression = RL2_COMPRESSION_LZW;
+            break;
+          case 2:
+            Compression = RL2_COMPRESSION_DEFLATE;
+            break;
+          case 3:
+            Compression = RL2_COMPRESSION_LZMA;
+            break;
+          default:
+            Compression = RL2_COMPRESSION_NONE;
+            break;
+        };
+    }
+  wxDialog::EndModal(wxID_OK);
+}
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..50dbe43
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,183 @@
+Basic Installation
+==================
+
+   These are generic installation instructions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+   The file `configure.in' is used to create `configure' by a program
+called `autoconf'.  You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.  If you're
+     using `csh' on an old version of System V, you might need to type
+     `sh ./configure' instead to prevent `csh' from trying to execute
+     `configure' itself.
+
+     Running `configure' takes awhile.  While running, it prints some
+     messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  You can give `configure'
+initial values for variables by setting them in the environment.  Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+     CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+     env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory.  After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+   By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc.  You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on.  Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+     CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+   If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+     Use and save the results of the tests in FILE instead of
+     `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
+     debugging `configure'.
+
+`--help'
+     Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--version'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
+
diff --git a/LayerTree.cpp b/LayerTree.cpp
new file mode 100644
index 0000000..c05f824
--- /dev/null
+++ b/LayerTree.cpp
@@ -0,0 +1,740 @@
+/*
+/ LayerTree.cpp
+/ tree control to handle map layers
+/
+/ version 1.0, 2013 July 31
+/
+/ Author: Sandro Furieri a-furieri at lqt.it
+/
+/ Copyright (C) 2013  Alessandro Furieri
+/
+/    This program is free software: you can redistribute it and/or modify
+/    it under the terms of the GNU General Public License as published by
+/    the Free Software Foundation, either version 3 of the License, or
+/    (at your option) any later version.
+/
+/    This program is distributed in the hope that it will be useful,
+/    but WITHOUT ANY WARRANTY; without even the implied warranty of
+/    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+/    GNU General Public License for more details.
+/
+/    You should have received a copy of the GNU General Public License
+/    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+/
+*/
+
+#include "Classdef.h"
+
+#include "wx/filename.h"
+#include "wx/imaglist.h"
+
+//
+// ICONs in XPM format [universally portable]
+//
+#include "icons/wms.xpm"
+#include "icons/on.xpm"
+#include "icons/off.xpm"
+#include "icons/about.xpm"
+#include "icons/remove.xpm"
+#include "icons/crs.xpm"
+#include "icons/config.xpm"
+#include "icons/group.xpm"
+#include "icons/layer.xpm"
+
+MyLayerTree::MyLayerTree(MyFrame * parent, wxWindowID id):wxTreeCtrl(parent, id)
+{
+//
+// constructor: TREE control to manage Map Layers
+//
+  MainFrame = parent;
+  Changed = true;
+  CurrentItem = wxTreeItemId();
+  DraggedItem = wxTreeItemId();
+  Root = AddRoot(wxT("WMS Layers"));
+// setting up icons 
+  Images = new wxImageList(16, 16, true);
+  wxIcon icons[3];
+  icons[0] = wxIcon(wms_xpm);
+  icons[1] = wxIcon(on_xpm);
+  icons[2] = wxIcon(off_xpm);
+  Images->Add(icons[0]);
+  Images->Add(icons[1]);
+  Images->Add(icons[2]);
+  SetImageList(Images);
+  SetItemImage(Root, 0);
+
+// setting up event handlers 
+  Connect(wxID_ANY, wxEVT_COMMAND_TREE_SEL_CHANGED,
+          (wxObjectEventFunction) & MyLayerTree::OnSelChanged);
+  Connect(wxID_ANY, wxEVT_COMMAND_TREE_ITEM_ACTIVATED,
+          (wxObjectEventFunction) & MyLayerTree::OnItemActivated);
+  Connect(wxID_ANY, wxEVT_COMMAND_TREE_ITEM_RIGHT_CLICK,
+          (wxObjectEventFunction) & MyLayerTree::OnRightClick);
+  Connect(Tree_CRS, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyLayerTree::OnCmdMapCRS);
+  Connect(Tree_RemoveAll, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyLayerTree::OnCmdRemoveAll);
+  Connect(Tree_ShowAll, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyLayerTree::OnCmdShowAll);
+  Connect(Tree_HideAll, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyLayerTree::OnCmdHideAll);
+  Connect(Tree_Visible, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyLayerTree::OnCmdVisible);
+  Connect(Tree_Configure, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyLayerTree::OnCmdConfigure);
+  Connect(Tree_LayerInfo, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyLayerTree::OnCmdLayerInfo);
+  Connect(Tree_RemoveLayer, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyLayerTree::OnCmdRemoveLayer);
+// Drag & Drop event handlers
+  Connect(wxID_ANY, wxEVT_COMMAND_TREE_BEGIN_DRAG,
+          (wxObjectEventFunction) & MyLayerTree::OnDragStart);
+  Connect(wxID_ANY, wxEVT_COMMAND_TREE_BEGIN_RDRAG,
+          (wxObjectEventFunction) & MyLayerTree::OnDragStart);
+  Connect(wxID_ANY, wxEVT_COMMAND_TREE_END_DRAG,
+          (wxObjectEventFunction) & MyLayerTree::OnDragEnd);
+}
+
+MyLayerTree::~MyLayerTree()
+{
+// destructor
+  if (Images)
+    delete Images;
+}
+
+void MyLayerTree::AddLayer(WmsLayer * layer)
+{
+//
+// adds a layer to the TREE list
+//
+  wxTreeItemId item;
+  wxString name;
+  if (layer->GetTileServiceLayer() != NULL)
+    name = wxString::FromUTF8(layer->GetTileServiceLayer()->GetTitle());
+  else
+    name = wxString::FromUTF8(layer->GetTitle());
+  if (GetChildrenCount(Root) == 0)
+    item = AppendItem(Root, name, 1);
+  else
+    item = InsertItem(Root, 0, name, 1);
+  LayerObject *obj = new LayerObject(layer);
+  SetItemData(item, (wxTreeItemData *) obj);
+  Expand(Root);
+}
+
+void MyLayerTree::MarkCurrentItem()
+{
+//
+// setting the Current Item as BOLD
+//
+  wxTreeItemId item;
+  wxTreeItemIdValue cookie;
+// unsetting the currently active WMS Layer
+  MainFrame->SetActiveWmsLayer(NULL);
+  item = GetFirstChild(GetRoot(), cookie);
+  while (item.IsOk() == true)
+    {
+      if (item == CurrentItem)
+        {
+          SetItemBold(item, true);
+          LayerObject *obj = (LayerObject *) GetItemData(item);
+          if (obj != NULL)
+            {
+              WmsLayer *layer = obj->GetLayer();
+              if (layer->IsVisible() == 1)
+                {
+                  // making this WMS Layer to be currently active
+                  MainFrame->SetActiveWmsLayer(layer);
+                }
+            }
+      } else
+        SetItemBold(item, false);
+      item = GetNextChild(GetRoot(), cookie);
+    }
+}
+
+void MyLayerTree::OnSelChanged(wxTreeEvent & event)
+{
+//
+// selecting some node [mouse action]
+//
+  wxTreeItemId item = event.GetItem();
+  if (item == Root)
+    {
+      CurrentItem = wxTreeItemId();
+      MarkCurrentItem();
+      return;
+    }
+  CurrentItem = item;
+  MarkCurrentItem();
+}
+
+void MyLayerTree::OnItemActivated(wxTreeEvent & event)
+{
+//
+// activating some node [mouse action]
+//
+  int idx = 1;
+  wxColour color(0, 0, 0);
+  wxTreeItemId item = event.GetItem();
+  if (item == Root)
+    return;
+  LayerObject *obj = (LayerObject *) GetItemData(item);
+  if (obj == NULL)
+    return;
+  WmsLayer *layer = obj->GetLayer();
+  if (layer->IsVisible() == 1)
+    {
+      layer->Hide();
+      idx = 2;
+      color = wxColour(192, 192, 192);
+  } else
+    layer->Show();
+  SetItemImage(item, idx);
+  SetItemTextColour(item, color);
+  MainFrame->RefreshMap();
+}
+
+void MyLayerTree::OnRightClick(wxTreeEvent & event)
+{
+//
+// right click on some node [mouse action]
+//
+  wxMenuItem *menuItem;
+  wxMenu *menu = new wxMenu;
+  wxTreeItemId item = event.GetItem();
+  SelectItem(item);
+  wxPoint pt = event.GetPoint();
+  if (item == Root)
+    {
+      CurrentItem = wxTreeItemId();
+      MarkCurrentItem();
+      menuItem = new wxMenuItem(menu, Tree_HideAll, wxT("Hide All"));
+      menuItem->SetBitmap(wxBitmap(off_xpm));
+      menu->Append(menuItem);
+      menuItem = new wxMenuItem(menu, Tree_ShowAll, wxT("Show All"));
+      menuItem->SetBitmap(wxBitmap(on_xpm));
+      menu->Append(menuItem);
+      menuItem = new wxMenuItem(menu, Tree_RemoveAll, wxT("Remove All"));
+      menuItem->SetBitmap(wxBitmap(remove_xpm));
+      menu->Append(menuItem);
+      menuItem =
+        new wxMenuItem(menu, Tree_CRS, wxT("Map Reference System [CRS]"));
+      menuItem->SetBitmap(wxBitmap(crs_xpm));
+      menu->Append(menuItem);
+      PopupMenu(menu, pt);
+      return;
+    }
+  LayerObject *obj = (LayerObject *) GetItemData(item);
+  if (obj == NULL)
+    {
+      CurrentItem = wxTreeItemId();
+      MarkCurrentItem();
+      menuItem = new wxMenuItem(menu, Tree_HideAll, wxT("Hide All"));
+      menuItem->SetBitmap(wxBitmap(off_xpm));
+      menu->Append(menuItem);
+      menuItem = new wxMenuItem(menu, Tree_ShowAll, wxT("Show All"));
+      menuItem->SetBitmap(wxBitmap(on_xpm));
+      menu->Append(menuItem);
+      menuItem = new wxMenuItem(menu, Tree_RemoveAll, wxT("Remove All"));
+      menuItem->SetBitmap(wxBitmap(remove_xpm));
+      menu->Append(menuItem);
+      menuItem =
+        new wxMenuItem(menu, Tree_CRS, wxT("Map Reference System [CRS]"));
+      menuItem->SetBitmap(wxBitmap(crs_xpm));
+      menu->Append(menuItem);
+      PopupMenu(menu, pt);
+      return;
+  } else
+    {
+      CurrentItem = item;
+      MarkCurrentItem();
+      WmsLayer *layer = obj->GetLayer();
+      wxString name;
+      if (layer->GetTileServiceLayer() != NULL)
+        name = wxString::FromUTF8(layer->GetTileServiceLayer()->GetTitle());
+      else
+        name = wxString::FromUTF8(layer->GetTitle());
+      menu->SetTitle(name);
+      if (layer->IsVisible() == true)
+        {
+          menuItem = new wxMenuItem(menu, Tree_Visible, wxT("Hide"));
+          menuItem->SetBitmap(wxBitmap(off_xpm));
+          menu->Append(menuItem);
+      } else
+        {
+          menuItem = new wxMenuItem(menu, Tree_Visible, wxT("Show"));
+          menuItem->SetBitmap(wxBitmap(on_xpm));
+          menu->Append(menuItem);
+        }
+      if (layer->GetTileServiceLayer() == NULL)
+        {
+          menuItem = new wxMenuItem(menu, Tree_Configure, wxT("Configure"));
+          menuItem->SetBitmap(wxBitmap(config_xpm));
+          menu->Append(menuItem);
+        }
+      menuItem = new wxMenuItem(menu, Tree_LayerInfo, wxT("WMS Metadata"));
+      menuItem->SetBitmap(wxBitmap(about_xpm));
+      menu->Append(menuItem);
+      menuItem = new wxMenuItem(menu, Tree_RemoveLayer, wxT("Remove"));
+      menuItem->SetBitmap(wxBitmap(remove_xpm));
+      menu->Append(menuItem);
+      menu->AppendSeparator();
+      menuItem =
+        new wxMenuItem(menu, Tree_CRS, wxT("Map Reference System [CRS]"));
+      menuItem->SetBitmap(wxBitmap(crs_xpm));
+      menu->Append(menuItem);
+      PopupMenu(menu, pt);
+      return;
+    }
+}
+
+void MyLayerTree::OnCmdLayerInfo(wxCommandEvent & WXUNUSED(event))
+{
+//
+// menu event - metadata from some WMS layer
+//
+  LayerObject *obj = (LayerObject *) GetItemData(CurrentItem);
+  if (obj == NULL)
+    return;
+  WmsLayer *layer = obj->GetLayer();
+  WmsInfoDialog dlg;
+  dlg.Create(MainFrame, layer);
+  dlg.ShowModal();
+}
+
+void MyLayerTree::OnCmdRemoveLayer(wxCommandEvent & WXUNUSED(event))
+{
+//
+// menu event - removing some WMS layer
+//
+  LayerObject *obj = (LayerObject *) GetItemData(CurrentItem);
+  if (obj == NULL)
+    return;
+  WmsLayer *layer = obj->GetLayer();
+  Delete(CurrentItem);
+  CurrentItem = wxTreeItemId();
+  MainFrame->GetMapView()->RemoveWmsLayer(layer);
+  MainFrame->RefreshMap();
+  MainFrame->UpdateTools();
+}
+
+void MyLayerTree::OnCmdRemoveAll(wxCommandEvent & WXUNUSED(event))
+{
+//
+// menu event - removing all WMS layers [Remove ALL]
+//
+  LayerObject *obj;
+  wxTreeItemId layer;
+  wxTreeItemIdValue cookie;
+  ::wxBeginBusyCursor();
+  Hide();
+  layer = GetFirstChild(Root, cookie);
+  while (layer.IsOk() == true)
+    {
+      // making a Layer to be visible
+      obj = (LayerObject *) GetItemData(layer);
+      WmsLayer *lyr = obj->GetLayer();
+      if (obj == NULL)
+        return;
+      MainFrame->GetMapView()->RemoveWmsLayer(lyr);
+      layer = GetNextChild(Root, cookie);
+    }
+  DeleteChildren(Root);
+  Show();
+  ::wxEndBusyCursor();
+  CurrentItem = wxTreeItemId();
+  MainFrame->RefreshMap();
+}
+
+void MyLayerTree::OnCmdShowAll(wxCommandEvent & WXUNUSED(event))
+{
+//
+// menu event - changing the visibility state [SHOW ALL]
+//
+  LayerObject *obj;
+  wxTreeItemId layer;
+  wxTreeItemIdValue cookie;
+  ::wxBeginBusyCursor();
+  Hide();
+  layer = GetFirstChild(Root, cookie);
+  while (layer.IsOk() == true)
+    {
+      // making a Layer to be visible
+      obj = (LayerObject *) GetItemData(layer);
+      WmsLayer *lyr = obj->GetLayer();
+      lyr->Show();
+      SetItemImage(layer, 1);
+      SetItemTextColour(layer, wxColour(0, 0, 0));
+      layer = GetNextChild(Root, cookie);
+    }
+  Show();
+  ::wxEndBusyCursor();
+  MainFrame->RefreshMap();
+}
+
+void MyLayerTree::OnCmdHideAll(wxCommandEvent & WXUNUSED(event))
+{
+//
+// menu event - changing the visibility state [HIDE ALL]
+//
+  LayerObject *obj;
+  wxTreeItemId layer;
+  wxTreeItemIdValue cookie;
+  wxTreeItemId subClass;
+  ::wxBeginBusyCursor();
+  Hide();
+  layer = GetFirstChild(Root, cookie);
+  while (layer.IsOk() == true)
+    {
+      // making a Layer to be invisible
+      obj = (LayerObject *) GetItemData(layer);
+      WmsLayer *lyr = obj->GetLayer();
+      lyr->Hide();
+      SetItemImage(layer, 2);
+      SetItemTextColour(layer, wxColour(192, 192, 192));
+      layer = GetNextChild(Root, cookie);
+    }
+  Show();
+  ::wxEndBusyCursor();
+  MainFrame->RefreshMap();
+}
+
+void MyLayerTree::OnCmdMapCRS(wxCommandEvent & WXUNUSED(event))
+{
+//
+// menu event - setting the Map CRS
+//
+  WmsMapCrsDialog dlg;
+  dlg.Create(MainFrame);
+  int ret = dlg.ShowModal();
+  if (ret == wxID_OK)
+    {
+      if (dlg.GetCRS().Len() > 0)
+        {
+          char *crs = new char[dlg.GetCRS().Len() + 1];
+          strcpy(crs, dlg.GetCRS().ToUTF8());
+          MainFrame->SetMapCRS(crs);
+          delete[]crs;
+        }
+    }
+}
+
+void MyLayerTree::OnCmdVisible(wxCommandEvent & WXUNUSED(event))
+{
+//
+// menu event - changing the visibility state
+//
+  int idx = 1;
+  wxColour color(0, 0, 0);
+  LayerObject *obj = (LayerObject *) GetItemData(CurrentItem);
+  if (obj == NULL)
+    return;
+  WmsLayer *layer = obj->GetLayer();
+  if (layer->IsVisible() == 1)
+    {
+      layer->Hide();
+      color = wxColour(192, 192, 192);
+      idx = 2;
+  } else
+    layer->Show();
+
+  SetItemImage(CurrentItem, idx);
+  SetItemTextColour(CurrentItem, color);
+
+  MainFrame->RefreshMap();
+}
+
+void MyLayerTree::OnCmdConfigure(wxCommandEvent & WXUNUSED(event))
+{
+//
+// menu event - changing the Layer Configuration
+//
+  LayerObject *obj = (LayerObject *) GetItemData(CurrentItem);
+  if (obj == NULL)
+    return;
+  WmsLayer *layer = obj->GetLayer();
+  WmsLayerDialog dlg;
+  dlg.Create(MainFrame, layer);
+  int ret = dlg.ShowModal();
+  if (ret == wxID_OK)
+    {
+      bool bboxChanged = false;
+      if (layer->GetMinX() != dlg.GetMinX())
+        bboxChanged = true;
+      if (layer->GetMaxX() != dlg.GetMaxX())
+        bboxChanged = true;
+      if (layer->GetMinY() != dlg.GetMinY())
+        bboxChanged = true;
+      if (layer->GetMaxY() != dlg.GetMaxY())
+        bboxChanged = true;
+      layer->Reconfigure(dlg.IsTiled(), dlg.GetTileWidth(), dlg.GetTileHeight(),
+                         dlg.IsOpaque(), dlg.GetVersion(), dlg.GetStyleName(),
+                         dlg.GetStyleTitle(), dlg.GetStyleAbstract(),
+                         dlg.GetFormat(), dlg.GetCRS(), dlg.IsSwapXY(),
+                         dlg.GetMinX(), dlg.GetMaxX(), dlg.GetMinY(),
+                         dlg.GetMaxY());
+      if (bboxChanged == true)
+        MainFrame->SetFullExtent();
+      MainFrame->RefreshMap();
+    }
+}
+
+void MyLayerTree::OnDragStart(wxTreeEvent & event)
+{
+//
+// user event: starting DRAG [drag&drop]
+//
+  DraggedItem = event.GetItem();
+  LayerObject *obj = (LayerObject *) GetItemData(DraggedItem);
+  if (obj == NULL)
+    {
+      DraggedItem = wxTreeItemId();
+      return;
+    }
+  event.Allow();
+}
+
+void MyLayerTree::OnDragEnd(wxTreeEvent & event)
+{
+//
+// user event: DRAG ended [drag&drop]
+//
+  LayerObject *obj = (LayerObject *) GetItemData(DraggedItem);
+  if (obj == NULL)
+    return;
+  wxTreeItemId currentItem = event.GetItem();
+  WmsLayer *layer = obj->GetLayer();
+  int idx = 1;
+  if (layer->IsVisible() == 0)
+    idx = 2;
+// 
+// creating the new node
+//
+  wxTreeItemId position;
+  wxString name = wxString::FromUTF8(layer->GetName());
+  if (currentItem == Root)
+    position = PrependItem(Root, name, idx);
+  else if (currentItem == GetLastChild(Root))
+    position = AppendItem(Root, name, idx);
+  else
+    position = InsertItem(Root, currentItem, name, idx);
+  obj = new LayerObject(layer);
+  SetItemData(position, (wxTreeItemData *) obj);
+  Delete(DraggedItem);
+  DraggedItem = wxTreeItemId();
+// updating the WMS Layer list
+  MainFrame->GetMapView()->ResetWmsLayers();
+  wxTreeItemIdValue cookie;
+  wxTreeItemId lyr = GetFirstChild(Root, cookie);
+  while (lyr.IsOk() == true)
+    {
+      obj = (LayerObject *) GetItemData(lyr);
+      layer = obj->GetLayer();
+      MainFrame->GetMapView()->ReinsertWmsLayer(layer);
+      lyr = GetNextChild(Root, cookie);
+    }
+  MainFrame->RefreshMap();
+}
+
+MyCatalogTree::MyCatalogTree(WmsDialog * parent, wxSize sz, wxWindowID id):wxTreeCtrl(parent, id, wxDefaultPosition,
+           sz)
+{
+//
+// constructor: TREE control to manage Map Layers
+//
+  MainDialog = parent;
+  CurrentItem = wxTreeItemId();
+// setting up icons 
+  Images = new wxImageList(16, 16, true);
+  wxIcon icons[3];
+  icons[0] = wxIcon(wms_xpm);
+  icons[1] = wxIcon(group_xpm);
+  icons[2] = wxIcon(layer_xpm);
+  Images->Add(icons[0]);
+  Images->Add(icons[1]);
+  Images->Add(icons[2]);
+  SetImageList(Images);
+  SetItemImage(Root, 0);
+
+// setting up event handlers 
+  Connect(wxID_ANY, wxEVT_COMMAND_TREE_SEL_CHANGED,
+          (wxObjectEventFunction) & MyCatalogTree::OnSelChanged);
+  Connect(Tree_ShowAll, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyLayerTree::OnCmdShowAll);
+  Connect(Tree_HideAll, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyLayerTree::OnCmdHideAll);
+}
+
+MyCatalogTree::~MyCatalogTree()
+{
+// destructor
+  if (Images)
+    delete Images;
+}
+
+void MyCatalogTree::AddLayer(rl2WmsLayerPtr handle, const char *layer)
+{
+//
+// adds a layer to the Catalog TREE list
+//
+  if (Root.IsOk() == true)
+    {
+      AddLayer(Root, handle, layer);
+      return;
+    }
+  int icon = 2;
+  wxString name = wxString::FromUTF8(layer);
+  CatalogObject *obj = new CatalogObject(handle, layer);
+  if (wms_layer_has_children(handle))
+    icon = 1;
+  Root = AddRoot(name, icon);
+  SetItemData(Root, (wxTreeItemData *) obj);
+  if (wms_layer_has_children(handle))
+    {
+      // expanding Root's Children
+      int nLayers = get_wms_layer_children_count(handle);
+      for (int i = 0; i < nLayers; i++)
+        {
+          rl2WmsLayerPtr layer = get_wms_child_layer(handle, i);
+          const char *x_name = get_wms_layer_title(layer);
+          AddLayer(Root, layer, x_name);
+        }
+    }
+}
+
+void MyCatalogTree::AddLayer(wxTreeItemId parent, rl2WmsLayerPtr handle,
+                             const char *layer)
+{
+//
+// adds a child layer to its parent
+//
+  wxTreeItemId item;
+  int icon = 2;
+  wxString name = wxString::FromUTF8(layer);
+  CatalogObject *obj = new CatalogObject(handle, layer);
+  if (wms_layer_has_children(handle))
+    icon = 1;
+  item = AppendItem(parent, name, icon);
+  SetItemData(item, (wxTreeItemData *) obj);
+  ExpandChildren(item, handle);
+}
+
+void MyCatalogTree::AddTiledRoot(const char *layer)
+{
+//
+// adds a tiled layer Root to the Catalog TREE list
+//
+  wxString name = wxString::FromUTF8(layer);
+  CatalogObject *obj = new CatalogObject(layer);
+  Root = AddRoot(name, 1);
+  SetItemData(Root, (wxTreeItemData *) obj);
+}
+
+void MyCatalogTree::AddTiledLayer(rl2WmsTiledLayerPtr handle, const char *layer)
+{
+//
+// adds a tiled layer to the Catalog TREE list
+//
+  AddTiledLayer(Root, handle, layer);
+}
+
+void MyCatalogTree::AddTiledLayer(wxTreeItemId parent,
+                                  rl2WmsTiledLayerPtr handle, const char *layer)
+{
+//
+// adds a child tiled layer to its parent
+//
+  wxTreeItemId item;
+  int icon = 2;
+  wxString name = wxString::FromUTF8(layer);
+  CatalogObject *obj = new CatalogObject(handle, layer);
+  if (wms_tiled_layer_has_children(handle))
+    icon = 1;
+  item = AppendItem(parent, name, icon);
+  SetItemData(item, (wxTreeItemData *) obj);
+  ExpandChildren(item, handle);
+}
+
+void MyCatalogTree::OnSelChanged(wxTreeEvent & event)
+{
+//
+// selecting some node [mouse action]
+//
+  wxTreeItemId item = event.GetItem();
+  CurrentItem = item;
+  MarkCurrentItem();
+  CatalogObject *obj = (CatalogObject *) GetItemData(item);
+  if (obj->GetHandle() != NULL)
+    MainDialog->SelectLayer(obj->GetHandle());
+  else if (obj->GetTiledHandle() != NULL)
+    MainDialog->SelectLayer(obj->GetTiledHandle());
+  else
+    MainDialog->SelectLayer();
+}
+
+void MyCatalogTree::RootAutoSelect()
+{
+//
+// auto-selecting the Root node
+//
+  if (Root.IsOk() == false)
+    return;
+  CurrentItem = Root;
+  SetItemBold(Root, true);
+  SelectItem(Root);
+  MarkCurrentItem();
+  CatalogObject *obj = (CatalogObject *) GetItemData(Root);
+  MainDialog->SelectLayer(obj->GetHandle());
+}
+
+void MyCatalogTree::MarkCurrentItem()
+{
+//
+// setting the Current Item as BOLD
+//
+  wxTreeItemId item;
+  wxTreeItemIdValue cookie;
+  item = GetFirstChild(Root, cookie);
+  while (item.IsOk() == true)
+    {
+      if (item == CurrentItem)
+        SetItemBold(item, true);
+      else
+        SetItemBold(item, false);
+      item = GetNextChild(Root, cookie);
+    }
+}
+
+void MyCatalogTree::ExpandChildren(wxTreeItemId parent, rl2WmsLayerPtr handle)
+{
+//
+// expanding Children Layers
+//
+  if (parent.IsOk() == false)
+    return;
+  int nLayers = get_wms_layer_children_count(handle);
+  for (int i = 0; i < nLayers; i++)
+    {
+      rl2WmsLayerPtr layer = get_wms_child_layer(handle, i);
+      const char *x_name = get_wms_layer_title(layer);
+      AddLayer(parent, layer, x_name);
+    }
+}
+
+void MyCatalogTree::ExpandChildren(wxTreeItemId parent,
+                                   rl2WmsTiledLayerPtr handle)
+{
+//
+// expanding Children Tiled Layers
+//
+  if (parent.IsOk() == false)
+    return;
+  int nLayers = get_wms_tiled_layer_children_count(handle);
+  for (int i = 0; i < nLayers; i++)
+    {
+      rl2WmsTiledLayerPtr layer = get_wms_child_tiled_layer(handle, i);
+      const char *x_name = get_wms_tiled_layer_name(layer);
+      AddTiledLayer(parent, layer, x_name);
+    }
+}
diff --git a/Main.cpp b/Main.cpp
new file mode 100644
index 0000000..882c57c
--- /dev/null
+++ b/Main.cpp
@@ -0,0 +1,1469 @@
+/*
+/ Main.cpp
+/ the main core of LibreWMS
+/
+/ version 1.0, 2013 July 28
+/
+/ Author: Sandro Furieri a-furieri at lqt.it
+/
+/ Copyright (C) 2013  Alessandro Furieri
+/
+/    This program is free software: you can redistribute it and/or modify
+/    it under the terms of the GNU General Public License as published by
+/    the Free Software Foundation, either version 3 of the License, or
+/    (at your option) any later version.
+/
+/    This program is distributed in the hope that it will be useful,
+/    but WITHOUT ANY WARRANTY; without even the implied warranty of
+/    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+/    GNU General Public License for more details.
+/
+/    You should have received a copy of the GNU General Public License
+/    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+/
+*/
+
+#include "Classdef.h"
+
+#include "wx/menu.h"
+#include "wx/aboutdlg.h"
+#include "wx/config.h"
+
+//
+// ICONs in XPM format [universally portable]
+//
+#include "icons/icon.xpm"
+#include "icons/icon_info.xpm"
+#include "icons/wms.xpm"
+#include "icons/center.xpm"
+#include "icons/identify.xpm"
+#include "icons/zoom_in.xpm"
+#include "icons/zoom_out.xpm"
+#include "icons/user_scale.xpm"
+#include "icons/pan.xpm"
+#include "icons/cache.xpm"
+#include "icons/wms_abort.xpm"
+#include "icons/printer.xpm"
+#include "icons/about.xpm"
+#include "icons/exit.xpm"
+
+IMPLEMENT_APP(MyApp)
+     bool MyApp::OnInit()
+{
+//
+// main APP implementation
+//
+  MyFrame *frame = new MyFrame(wxT("LibreWMS      [free WMS viewer]"),
+                               wxPoint(0, 0), wxSize(800, 600));
+  frame->Show(true);
+  SetTopWindow(frame);
+  frame->CreateMemoryDB();
+  frame->LoadConfig();
+  return true;
+}
+
+MyFrame::MyFrame(const wxString & title, const wxPoint & pos, const wxSize & size):
+wxFrame((wxFrame *) NULL, -1, title, pos,
+        size)
+{
+//
+// main GUI frame constructor
+//
+
+// forcing DECIMAL POINT IS COMMA
+  setlocale(LC_NUMERIC, "C");
+
+// creating the internal WMS Cache
+  WmsCache = create_wms_cache();
+
+  ::wxInitAllImageHandlers();
+
+  IsIdentify = false;
+  IsZoomIn = false;
+  IsZoomOut = false;
+  IsPan = false;
+
+  BtnWms = new wxBitmap(wms_xpm);
+  BtnCenter = new wxBitmap(center_xpm);
+  BtnIdentify = new wxBitmap(identify_xpm);
+  BtnZoomIn = new wxBitmap(zoom_in_xpm);
+  BtnZoomOut = new wxBitmap(zoom_out_xpm);
+  BtnUserScale = new wxBitmap(user_scale_xpm);
+  BtnPan = new wxBitmap(pan_xpm);
+  BtnCache = new wxBitmap(cache_xpm);
+  BtnWmsAbort = new wxBitmap(wms_abort_xpm);
+  BtnPrinter = new wxBitmap(printer_xpm);
+  BtnAbout = new wxBitmap(about_xpm);
+  BtnExit = new wxBitmap(exit_xpm);
+
+//
+// setting up the application icon
+//      
+  wxIcon MyIcon(icon_xpm);
+  SetIcon(MyIcon);
+
+//
+// setting up panes
+//
+  LayerTree = new MyLayerTree(this);
+  MapView = new MyMapView(this);
+  Manager.SetManagedWindow(this);
+  wxAuiPaneInfo paneView = wxAuiPaneInfo().Centre();
+  paneView.Name(wxT("map_view"));
+  paneView.CaptionVisible(false);
+  paneView.Floatable(true);
+  paneView.Dockable(true);
+  paneView.Movable(true);
+  paneView.Gripper(false);
+  paneView.CloseButton(false);
+  Manager.AddPane(MapView, paneView);
+  wxAuiPaneInfo paneTree = wxAuiPaneInfo().Left();
+  paneTree.Name(wxT("tree_view"));
+  paneTree.DefaultPane();
+  paneTree.CaptionVisible(false);
+  paneTree.Floatable(true);
+  paneTree.Dockable(true);
+  paneTree.Movable(true);
+  paneTree.Gripper(true);
+  paneTree.CloseButton(false);
+  paneTree.BestSize(wxSize(200, 480));
+  Manager.AddPane(LayerTree, paneTree, wxPoint(0, 10));
+  Manager.Update();
+  Centre();
+  ClearLayerTree();
+
+//
+// setting up the status bar
+//
+  wxStatusBar *statusBar = new wxStatusBar(this);
+  statusBar->SetFieldsCount(4);
+  int fldWidth[4];
+  fldWidth[0] = -1;
+  fldWidth[1] = -1;
+  fldWidth[2] = -1;
+  fldWidth[3] = -1;
+  statusBar->SetStatusWidths(4, fldWidth);
+  SetStatusBar(statusBar);
+
+//
+// setting up the menu bar
+//
+  wxMenu *menuFile = new wxMenu;
+  wxMenuItem *menuItem;
+  menuItem =
+    new wxMenuItem(menuFile, ID_Predefined, wxT("&Predefined WMS services"));
+  menuFile->Append(menuItem);
+  menuItem = new wxMenuItem(menuFile, ID_Wms, wxT("&Add a WMS datasource"));
+  menuItem->SetBitmap(*BtnWms);
+  menuFile->Append(menuItem);
+  menuFile->AppendSeparator();
+  menuItem = new wxMenuItem(menuFile, ID_Center, wxT("Zoom to &Full Extent"));
+  menuItem->SetBitmap(*BtnCenter);
+  menuFile->Append(menuItem);
+  menuItem =
+    new wxMenuItem(menuFile, ID_ZoomIn, wxT("Zoom &In"), wxT(""), wxITEM_RADIO);
+  menuFile->Append(menuItem);
+  menuItem =
+    new wxMenuItem(menuFile, ID_ZoomOut,
+                   wxT("Zoom &Out"), wxT(""), wxITEM_RADIO);
+  menuFile->Append(menuItem);
+  menuItem = new wxMenuItem(menuFile, ID_UserScale, wxT("User defined &Scale"));
+  menuItem->SetBitmap(*BtnUserScale);
+  menuFile->Append(menuItem);
+  menuItem =
+    new wxMenuItem(menuFile, ID_Pan, wxT("&Pan"), wxT(""), wxITEM_RADIO);
+  menuFile->Append(menuItem);
+  menuItem =
+    new wxMenuItem(menuFile, ID_Identify,
+                   wxT("Identify"), wxT(""), wxITEM_RADIO);
+  menuFile->Append(menuItem);
+  menuFile->AppendSeparator();
+  menuItem = new wxMenuItem(menuFile, ID_Cache, wxT("&WMS Cache"));
+  menuItem->SetBitmap(*BtnCache);
+  menuFile->Append(menuItem);
+  menuFile->AppendSeparator();
+  menuItem = new wxMenuItem(menuFile, ID_WmsAbort, wxT("WMS &Abort Refresh"));
+  menuItem->SetBitmap(*BtnWmsAbort);
+  menuFile->Append(menuItem);
+  menuFile->AppendSeparator();
+  menuItem = new wxMenuItem(menuFile, ID_Printer, wxT("&Printer"));
+  menuItem->SetBitmap(*BtnPrinter);
+  menuFile->Append(menuItem);
+  menuFile->AppendSeparator();
+  menuItem = new wxMenuItem(menuFile, wxID_ABOUT, wxT("&About ..."));
+  menuItem->SetBitmap(*BtnAbout);
+  menuFile->Append(menuItem);
+  menuFile->AppendSeparator();
+  menuItem = new wxMenuItem(menuFile, wxID_EXIT, wxT("&Quit"));
+  menuItem->SetBitmap(*BtnExit);
+  menuFile->Append(menuItem);
+  wxMenuBar *menuBar = new wxMenuBar;
+  menuBar->Append(menuFile, wxT("&Files"));
+  SetMenuBar(menuBar);
+
+//
+// setting up menu initial state 
+//
+  menuBar->Enable(ID_Center, false);
+  menuBar->Enable(ID_Identify, false);
+  menuBar->Enable(ID_ZoomIn, false);
+  menuBar->Enable(ID_ZoomOut, false);
+  menuBar->Enable(ID_UserScale, false);
+  menuBar->Enable(ID_Pan, false);
+  menuBar->Enable(ID_WmsAbort, false);
+  menuBar->Enable(ID_Printer, false);
+
+//
+// setting up the toolbar
+//      
+  wxToolBar *toolBar = CreateToolBar();
+  toolBar->AddTool(ID_Wms, wxT("Add a WMS Layer"),
+                   *BtnWms, wxNullBitmap, wxITEM_NORMAL,
+                   wxT("Add a WMS Layer"));
+  toolBar->AddSeparator();
+  toolBar->AddTool(ID_Center, wxT("Zoom to Full Extent"),
+                   *BtnCenter, wxNullBitmap, wxITEM_NORMAL,
+                   wxT("Zoom to Full Extent"));
+  toolBar->AddTool(ID_ZoomIn, wxT("Zoom In"), *BtnZoomIn, wxNullBitmap,
+                   wxITEM_RADIO, wxT("Zoom In"));
+  toolBar->AddTool(ID_ZoomOut, wxT("Zoom Out"), *BtnZoomOut, wxNullBitmap,
+                   wxITEM_RADIO, wxT("Zoom Out"));
+  toolBar->AddTool(ID_UserScale, wxT("User defined Scale"), *BtnUserScale,
+                   wxNullBitmap, wxITEM_RADIO, wxT("User defined Scale"));
+  toolBar->AddTool(ID_Pan, wxT("Pan"), *BtnPan, wxNullBitmap, wxITEM_RADIO,
+                   wxT("Pan"));
+  toolBar->AddTool(ID_Identify, wxT("Identify"), *BtnIdentify, wxNullBitmap,
+                   wxITEM_RADIO, wxT("Identify"));
+  toolBar->AddSeparator();
+  toolBar->AddTool(ID_Cache, wxT("WMS Cache"),
+                   *BtnCache, wxNullBitmap, wxITEM_NORMAL, wxT("WMS Cache"));
+  toolBar->AddSeparator();
+  toolBar->AddTool(ID_WmsAbort, wxT("WMS Abort Refresh"),
+                   *BtnWmsAbort, wxNullBitmap, wxITEM_NORMAL,
+                   wxT("WMS Abort Refresh"));
+  toolBar->AddSeparator();
+  toolBar->AddTool(ID_Printer, wxT("Printer"),
+                   *BtnPrinter, wxNullBitmap, wxITEM_NORMAL, wxT("Printer"));
+  toolBar->AddSeparator();
+  toolBar->AddTool(wxID_ABOUT, wxT("About ..."), *BtnAbout, wxNullBitmap,
+                   wxITEM_NORMAL, wxT("About ..."));
+  toolBar->AddSeparator();
+  toolBar->AddTool(wxID_EXIT, wxT("Quit"), *BtnExit, wxNullBitmap,
+                   wxITEM_NORMAL, wxT("Quit"));
+  toolBar->Realize();
+  SetToolBar(toolBar);
+
+//
+// setting up the toolbar initial state
+//
+  toolBar->EnableTool(ID_Center, false);
+  toolBar->EnableTool(ID_Identify, false);
+  toolBar->EnableTool(ID_ZoomIn, false);
+  toolBar->EnableTool(ID_ZoomOut, false);
+  toolBar->EnableTool(ID_UserScale, false);
+  toolBar->EnableTool(ID_Pan, false);
+  toolBar->EnableTool(ID_WmsAbort, false);
+  toolBar->EnableTool(ID_Printer, false);
+
+//
+// setting up event handlers for menu and toolbar
+//
+  Connect(ID_Wms, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnWms);
+  Connect(ID_Predefined, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnPredefinedWms);
+  Connect(ID_Center, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnCenter);
+  Connect(ID_Identify, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnIdentify);
+  Connect(ID_ZoomIn, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnZoomIn);
+  Connect(ID_ZoomOut, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnZoomOut);
+  Connect(ID_UserScale, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnUserScale);
+  Connect(ID_Pan, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnPan);
+  Connect(ID_Cache, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnWmsCache);
+  Connect(ID_WmsAbort, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnWmsAbort);
+  Connect(ID_Printer, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnPrinter);
+  Connect(wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnAbout);
+  Connect(wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED,
+          (wxObjectEventFunction) & MyFrame::OnQuit);
+  Connect(wxID_ANY, wxEVT_CLOSE_WINDOW,
+          (wxObjectEventFunction) & MyFrame::OnClose);
+}
+
+MyFrame::~MyFrame()
+{
+//
+// main GUI frame destructor
+//
+  ConfigLayout = Manager.SavePerspective();
+  GetPosition(&ConfigPaneX, &ConfigPaneY);
+  GetSize(&ConfigPaneWidth, &ConfigPaneHeight);
+  SaveConfig();
+  Manager.UnInit();
+  CloseMemoryDB();
+  if (WmsCache != NULL)
+    destroy_wms_cache(WmsCache);
+  if (BtnCenter != NULL)
+    delete BtnCenter;
+  if (BtnIdentify != NULL)
+    delete BtnIdentify;
+  if (BtnZoomIn != NULL)
+    delete BtnZoomIn;
+  if (BtnZoomOut != NULL)
+    delete BtnZoomOut;
+  if (BtnUserScale != NULL)
+    delete BtnUserScale;
+  if (BtnPan != NULL)
+    delete BtnPan;
+  if (BtnCache != NULL)
+    delete BtnCache;
+  if (BtnWmsAbort != NULL)
+    delete BtnWmsAbort;
+  if (BtnPrinter != NULL)
+    delete BtnPrinter;
+  if (BtnAbout != NULL)
+    delete BtnAbout;
+  if (BtnExit != NULL)
+    delete BtnExit;
+}
+
+void MyFrame::CreateMemoryDB()
+{
+//
+// creating a Memory DB (SQlite/Spatialite)
+//
+  char *errMsg = NULL;
+  int ret = sqlite3_open_v2(":memory:", &SQLiteHandle,
+                            SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
+  if (ret)
+    {
+      // an error occurred
+      wxString errCause;
+      errCause = wxString::FromUTF8(sqlite3_errmsg(SQLiteHandle));
+      sqlite3_close(SQLiteHandle);
+      wxMessageBox(wxT("An error occurred\n\n") + errCause + wxT("\n"),
+                   wxT("LibreWMS"), wxOK | wxICON_ERROR, this);
+      SQLiteHandle = NULL;
+      InternalCache = NULL;
+      return;
+    }
+// setting up the internal cache
+  InternalCache = spatialite_alloc_connection();
+  spatialite_init_ex(SQLiteHandle, InternalCache, 0);
+// activating Foreign Key constraints
+  ret = sqlite3_exec(SQLiteHandle, "PRAGMA foreign_keys = 1", NULL, 0, &errMsg);
+  if (ret != SQLITE_OK)
+    {
+      wxMessageBox(wxT("Unable to activate FOREIGN_KEY constraints"),
+                   wxT("LibreWMS"), wxOK | wxICON_INFORMATION, this);
+      sqlite3_free(errMsg);
+      SQLiteHandle = NULL;
+      return;
+    }
+  InitializeSpatialMetadata();
+  InitializeWmsList();
+}
+
+void MyFrame::InitializeSpatialMetadata()
+{
+// attempting to perform self-initialization for Memory DB
+  int ret;
+  char *errMsg = NULL;
+  if (!SQLiteHandle)
+    return;
+  ret =
+    sqlite3_exec(SQLiteHandle, "SELECT InitSpatialMetadata(1)", NULL, NULL,
+                 &errMsg);
+  if (ret != SQLITE_OK)
+    {
+      wxMessageBox(wxT("Unable to initialite SpatialMetadata: ") +
+                   wxString::FromUTF8(errMsg), wxT("LibreWMS"),
+                   wxOK | wxICON_ERROR, this);
+      sqlite3_free(errMsg);
+      return;
+    }
+}
+
+void MyFrame::CloseMemoryDB()
+{
+//
+// disconnecting the SQLite Memory DB
+//
+  if (!SQLiteHandle)
+    return;
+  sqlite3_close(SQLiteHandle);
+  SQLiteHandle = NULL;
+  spatialite_cleanup_ex(InternalCache);
+  InternalCache = NULL;
+}
+
+void MyFrame::UpdateTools()
+{
+//
+// updating the Tools State
+//
+  wxMenuBar *menuBar = GetMenuBar();
+  if (MapView->IsValidMap() == false)
+    {
+      menuBar->Enable(ID_Center, false);
+      menuBar->Enable(ID_ZoomIn, false);
+      menuBar->Enable(ID_ZoomOut, false);
+      menuBar->Enable(ID_UserScale, false);
+      menuBar->Enable(ID_Pan, false);
+      menuBar->Enable(ID_Identify, false);
+      menuBar->Enable(ID_Printer, false);
+  } else
+    {
+      menuBar->Enable(ID_Center, true);
+      menuBar->Enable(ID_ZoomIn, true);
+      menuBar->Enable(ID_ZoomOut, true);
+      menuBar->Enable(ID_UserScale, true);
+      menuBar->Enable(ID_Pan, true);
+      if (MapView->CanIdentify() == true)
+        menuBar->Enable(ID_Identify, true);
+      else
+        menuBar->Enable(ID_Identify, false);
+      menuBar->Enable(ID_Printer, true);
+    }
+
+  wxToolBar *toolBar = GetToolBar();
+  if (MapView->IsValidMap() == false)
+    {
+      toolBar->EnableTool(ID_Center, false);
+      toolBar->EnableTool(ID_ZoomIn, false);
+      toolBar->EnableTool(ID_ZoomOut, false);
+      toolBar->EnableTool(ID_UserScale, false);
+      toolBar->EnableTool(ID_Pan, false);
+      toolBar->EnableTool(ID_Identify, false);
+      toolBar->EnableTool(ID_Printer, false);
+  } else
+    {
+      toolBar->EnableTool(ID_Center, true);
+      toolBar->EnableTool(ID_ZoomIn, true);
+      toolBar->EnableTool(ID_ZoomOut, true);
+      toolBar->EnableTool(ID_UserScale, true);
+      toolBar->EnableTool(ID_Pan, true);
+      if (MapView->CanIdentify() == true)
+        toolBar->EnableTool(ID_Identify, true);
+      else
+        toolBar->EnableTool(ID_Identify, false);
+      toolBar->EnableTool(ID_Printer, true);
+    }
+
+  if (MapView->IsValidMap() == false)
+    {
+      IsIdentify = false;
+      IsZoomIn = false;
+      IsZoomOut = false;
+      IsPan = false;
+  } else
+    {
+      if (IsIdentify == false && IsPan == false && IsZoomOut == false)
+        IsZoomIn = true;
+      if (IsIdentify == true)
+        {
+          menuBar->Check(ID_Identify, true);
+          toolBar->ToggleTool(ID_Identify, true);
+        }
+      if (IsPan == true)
+        {
+          menuBar->Check(ID_Pan, true);
+          toolBar->ToggleTool(ID_Pan, true);
+        }
+      if (IsZoomIn == true)
+        {
+          menuBar->Check(ID_ZoomIn, true);
+          toolBar->ToggleTool(ID_ZoomIn, true);
+        }
+      if (IsZoomOut == true)
+        {
+          menuBar->Check(ID_ZoomOut, true);
+          toolBar->ToggleTool(ID_ZoomOut, true);
+        }
+    }
+}
+
+void MyFrame::UpdateWmsAbortTool(bool mode)
+{
+//
+// updating the WMS Abort Tool State
+//
+  wxMenuBar *menuBar = GetMenuBar();
+  menuBar->Enable(ID_WmsAbort, mode);
+
+  wxToolBar *toolBar = GetToolBar();
+  toolBar->EnableTool(ID_WmsAbort, mode);
+}
+
+void MyFrame::UpdatePrinterTool(bool mode)
+{
+//
+// updating the Printer Tool State
+//
+  wxMenuBar *menuBar = GetMenuBar();
+  menuBar->Enable(ID_Printer, mode);
+
+  wxToolBar *toolBar = GetToolBar();
+  toolBar->EnableTool(ID_Printer, mode);
+}
+
+void MyFrame::OnWmsCache(wxCommandEvent & WXUNUSED(event))
+{
+//
+// WMS Cache dialog
+//
+  WmsCacheDialog dlg;
+  dlg.Create(this, WmsCache);
+  dlg.ShowModal();
+}
+
+void MyFrame::OnWmsAbort(wxCommandEvent & WXUNUSED(event))
+{
+//
+// WMS Abort Refresh request
+//
+  MapView->SetWmsAbort();
+}
+
+void MyFrame::OnCenter(wxCommandEvent & WXUNUSED(event))
+{
+//
+// resetting to Full Extent
+//
+  MapView->SetFullExtent();
+  MapView->PrepareMap();
+}
+
+void MyFrame::OnIdentify(wxCommandEvent & WXUNUSED(event))
+{
+//
+// current map click is: Identify
+//
+  wxMenuBar *menuBar = GetMenuBar();
+  wxToolBar *toolBar = GetToolBar();
+  if (IsIdentify == false)
+    {
+      if (menuBar)
+        menuBar->Check(ID_Identify, true);
+      if (toolBar)
+        toolBar->ToggleTool(ID_Identify, true);
+      IsIdentify = true;
+      IsZoomIn = false;
+      IsZoomOut = false;
+      IsPan = false;
+    }
+}
+
+void MyFrame::OnZoomIn(wxCommandEvent & WXUNUSED(event))
+{
+//
+// current map click is: ZoomIn
+//
+  wxMenuBar *menuBar = GetMenuBar();
+  wxToolBar *toolBar = GetToolBar();
+  if (IsZoomIn == false)
+    {
+      menuBar->Check(ID_ZoomIn, true);
+      if (toolBar)
+        toolBar->ToggleTool(ID_ZoomIn, true);
+      IsIdentify = false;
+      IsZoomIn = true;
+      IsZoomOut = false;
+      IsPan = false;
+    }
+}
+
+void MyFrame::OnZoomOut(wxCommandEvent & WXUNUSED(event))
+{
+//
+// current map click is: ZoomOut
+//
+  wxMenuBar *menuBar = GetMenuBar();
+  wxToolBar *toolBar = GetToolBar();
+  if (IsZoomOut == false)
+    {
+      if (menuBar)
+        menuBar->Check(ID_ZoomOut, true);
+      if (toolBar)
+        toolBar->ToggleTool(ID_ZoomOut, true);
+      IsIdentify = false;
+      IsZoomIn = false;
+      IsZoomOut = true;
+      IsPan = false;
+    }
+}
+
+void MyFrame::OnUserScale(wxCommandEvent & WXUNUSED(event))
+{
+//
+// User selected Scale
+//
+  UserScaleDialog dlg;
+  int scale = MapView->GetCurrentScale();
+  dlg.Create(this, scale, MapView->GetPixelRatio());
+  int ret = dlg.ShowModal();
+  if (ret == wxID_OK)
+    {
+      if (scale != dlg.GetCurrentScale())
+        MapView->SetCurrentScale(dlg.GetCurrentScale());
+    }
+}
+
+void MyFrame::OnPrinter(wxCommandEvent & WXUNUSED(event))
+{
+//
+// Printer
+//
+  PrinterDialog dlg;
+  dlg.Create(this);
+  int ret = dlg.ShowModal();
+  if (ret == wxID_OK)
+    {
+      if (dlg.IsPDF())
+        {
+          wxFileDialog fileDialog(this, wxT("PDF output file"),
+                                  wxT(""), wxT("map.pdf"),
+                                  wxT("PDF document (*.pdf)|*.pdf"),
+                                  wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
+                                  wxDefaultPosition, wxDefaultSize,
+                                  wxT("filedlg"));
+          wxString lastDir = GetLastDirectory();
+          if (lastDir.Len() >= 1)
+            fileDialog.SetDirectory(lastDir);
+          ret = fileDialog.ShowModal();
+          if (ret == wxID_OK)
+            {
+              // exporting the output PDF file
+              ::wxBeginBusyCursor();
+              int len = fileDialog.GetPath().Len();
+              char *path = new char[len + 1];
+              strcpy(path, fileDialog.GetPath().ToUTF8());
+              PdfPrinter *printer = new
+                PdfPrinter(this, path, dlg.GetDPI(), dlg.GetPageWidth(),
+                           dlg.GetPageHeight(),
+                           dlg.GetHorzMarginSize(), dlg.GetVertMarginSize(),
+                           dlg.IsPreserveScale(), dlg.IsPreserveWidth(),
+                           dlg.IsPreserveHeight());
+              if (printer->IsValid() != true)
+                {
+                  wxMessageBox(wxT("Invalid PDF Printer !!!"),
+                               wxT("LibreWMS"), wxOK | wxICON_ERROR, this);
+              } else
+                printer->Go();
+              delete[]path;
+            }
+      } else
+        {
+          wxFileDialog fileDialog(this, wxT("TIFF output file"), wxT(""),
+                                  wxT("map.tif"),
+                                  wxT("TIFF image (*.tif)|*.tif"),
+                                  wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
+                                  wxDefaultPosition, wxDefaultSize,
+                                  wxT("filedlg"));
+          wxString lastDir = GetLastDirectory();
+          if (lastDir.Len() >= 1)
+            fileDialog.SetDirectory(lastDir);
+          ret = fileDialog.ShowModal();
+          if (ret == wxID_OK)
+            {
+              // exporting the output TIFF file
+              ::wxBeginBusyCursor();
+              int len = fileDialog.GetPath().Len();
+              char *path = new char[len + 1];
+              strcpy(path, fileDialog.GetPath().ToUTF8());
+              bool is_tiled = dlg.IsTiled();
+              int tile_strip_size;
+              if (is_tiled)
+                tile_strip_size = dlg.GetTileSize();
+              else
+                tile_strip_size = dlg.GetStripSize();
+              TiffWriter *writer = new
+                TiffWriter(this, path, dlg.GetWidth(), dlg.GetHeight(),
+                           dlg.IsGeoTiff(), dlg.HasWorldfile(),
+                           dlg.GetCompression(),
+                           is_tiled, tile_strip_size, dlg.IsPreserveScale(),
+                           dlg.IsPreserveWidth(),
+                           dlg.IsPreserveHeight());
+              if (writer->IsValid() != true)
+                {
+                  wxMessageBox(wxT
+                               ("Invalid TIFF Writer - Insufficient Memory !!!"),
+                               wxT("LibreWMS"), wxOK | wxICON_ERROR, this);
+              } else
+                writer->Go();
+              delete[]path;
+            }
+        }
+    }
+}
+
+void MyFrame::OnPan(wxCommandEvent & WXUNUSED(event))
+{
+//
+// current map click is: Pan
+//
+  wxMenuBar *menuBar = GetMenuBar();
+  wxToolBar *toolBar = GetToolBar();
+  if (IsPan == false)
+    {
+      if (menuBar)
+        menuBar->Check(ID_Pan, true);
+      if (toolBar)
+        toolBar->ToggleTool(ID_Pan, true);
+      IsIdentify = false;
+      IsZoomIn = false;
+      IsZoomOut = false;
+      IsPan = true;
+    }
+}
+
+void MyFrame::UpdateMapCRS()
+{
+//
+// updating the status bar - CRS
+//
+  if (GetStatusBar() == NULL)
+    return;
+  const char *crs = MapView->GetMapCRS();
+  if (crs == NULL)
+    GetStatusBar()->SetStatusText(wxT("no current WMS Layer"), 0);
+  else
+    {
+      wxString str = wxT("CRS ") + wxString::FromUTF8(crs);
+      GetStatusBar()->SetStatusText(str, 0);
+    }
+}
+
+void MyFrame::UpdateMapScale()
+{
+//
+// updating the status bar - Current Scale
+//
+  if (GetStatusBar() == NULL)
+    return;
+  wxString scale;
+  if (MapView->IsValidMap())
+    {
+      char dummy[256];
+      sprintf(dummy, "Scale 1:%d", MapView->GetCurrentScale());
+      scale = wxString::FromUTF8(dummy);
+    }
+  GetStatusBar()->SetStatusText(scale, 1);
+}
+
+void MyFrame::UpdateMapCoords(wxString & coords)
+{
+//
+// updating the status bar [Coordinates]
+//
+  if (GetStatusBar() == NULL)
+    return;
+  GetStatusBar()->SetStatusText(coords, 2);
+}
+
+bool MyFrame::GetProgressRect(wxRect & rect)
+{
+//
+// retrieving the status bar Progress rect
+//
+  if (GetStatusBar() == NULL)
+    return false;
+  return GetStatusBar()->GetFieldRect(3, rect);
+}
+
+void MyFrame::SaveConfig()
+{
+//
+// saves layout configuration
+//
+
+  wxConfig *config = new wxConfig(wxT("LibreWMS"));
+  config->Write(wxT("Layout"), ConfigLayout);
+  config->Write(wxT("PaneX"), ConfigPaneX);
+  config->Write(wxT("PaneY"), ConfigPaneY);
+  config->Write(wxT("PaneWidth"), ConfigPaneWidth);
+  config->Write(wxT("PaneHeight"), ConfigPaneHeight);
+  config->Write(wxT("HttpProxy"), HttpProxy);
+  config->Write(wxT("LastDirectory"), LastDirectory);
+  delete config;
+}
+
+void MyFrame::LoadConfig()
+{
+//
+// loads layout configuration
+//
+  ConfigLayout = wxT("");
+  wxConfig *config = new wxConfig(wxT("LibreWMS"));
+  config->Read(wxT("Layout"), &ConfigLayout);
+  config->Read(wxT("PaneX"), &ConfigPaneX, -1);
+  config->Read(wxT("PaneY"), &ConfigPaneY, -1);
+  config->Read(wxT("PaneWidth"), &ConfigPaneWidth, -1);
+  config->Read(wxT("PaneHeight"), &ConfigPaneHeight, -1);
+  config->Read(wxT("HttpProxy"), &HttpProxy);
+  config->Read(wxT("LastDirectory"), &LastDirectory);
+  delete config;
+  if (ConfigLayout.Len() > 0)
+    Manager.LoadPerspective(ConfigLayout, true);
+  if (ConfigPaneX >= 0 && ConfigPaneY >= 0 && ConfigPaneWidth > 0
+      && ConfigPaneHeight > 0)
+    SetSize(ConfigPaneX, ConfigPaneY, ConfigPaneWidth, ConfigPaneHeight);
+}
+
+void MyFrame::OnPredefinedWms(wxCommandEvent & WXUNUSED(event))
+{
+//
+// selecting a pre-defined WMS datasource
+//
+  PredefinedWmsDialog dlg;
+  dlg.Create(this, SQLiteHandle);
+  int ret = dlg.ShowModal();
+  if (ret == wxID_OK)
+    {
+      CurrentWmsDatasource = dlg.GetURL();
+      WmsSelection(true);
+    }
+}
+
+void MyFrame::WmsSelection(bool immediate)
+{
+//
+// opening a WMS layer
+//
+  WmsDialog dlg;
+  dlg.Create(this, HttpProxy, immediate);
+  int ret = dlg.ShowModal();
+  if (ret == wxID_OK)
+    {
+      HttpProxy = dlg.GetHttpProxy();
+      CurrentWmsDatasource = dlg.GetURL();
+      WmsService *service =
+        MapView->InsertWmsService(dlg.GetServiceVersion(), dlg.GetServiceName(),
+                                  dlg.GetServiceTitle(),
+                                  dlg.GetServiceAbstract(),
+                                  dlg.GetTileServiceName(),
+                                  dlg.GetTileServiceTitle(),
+                                  dlg.GetTileServiceAbstract(),
+                                  dlg.GetURL_GetMap_Get(),
+                                  dlg.GetURL_GetMap_Post(),
+                                  dlg.GetURL_GetTileService_Get(),
+                                  dlg.GetURL_GetTileService_Post(),
+                                  dlg.GetURL_GetFeatureInfo_Get(),
+                                  dlg.GetURL_GetFeatureInfo_Post(),
+                                  dlg.GetGmlMimeType(), dlg.GetXmlMimeType(),
+                                  dlg.GetContactPerson(),
+                                  dlg.GetContactOrganization(),
+                                  dlg.GetContactPosition(),
+                                  dlg.GetPostalAddress(), dlg.GetCity(),
+                                  dlg.GetStateProvince(), dlg.GetPostCode(),
+                                  dlg.GetCountry(), dlg.GetVoiceTelephone(),
+                                  dlg.GetFaxTelephone(), dlg.GetEMailAddress(),
+                                  dlg.GetFees(), dlg.GetAccessConstraints(),
+                                  dlg.GetLayerLimit(),
+                                  dlg.GetMaxWidth(), dlg.GetMaxHeight());
+      for (int s = 0; s < dlg.CountFormats(); s++)
+        service->AddFormat(dlg.GetFormatByIndex(s));
+      WmsLayer *lyr;
+      if (dlg.IsWmsTileService())
+        {
+          // special WMS TileService Layer
+          lyr = new WmsLayer(service, dlg.GetTiledLayerName(),
+                             dlg.GetTiledLayerTitle(),
+                             dlg.GetTiledLayerAbstract(),
+                             dlg.GetTiledLayerMinLong(),
+                             dlg.GetTiledLayerMinLat(),
+                             dlg.GetTiledLayerMaxLong(),
+                             dlg.GetTiledLayerMaxLat(),
+                             dlg.GetTiledLayerPad(),
+                             dlg.GetTiledLayerBands(),
+                             dlg.GetTiledLayerDataType());
+          if (lyr != NULL)
+            {
+              int nPatterns = dlg.GetTilePatternCount();
+              for (int i = 0; i < nPatterns; i++)
+                {
+                  rl2WmsTilePatternPtr handle = dlg.GetTilePatternHandle(i);
+                  const char *srs = dlg.GetTilePatternSRS(i);
+                  int width = dlg.GetTilePatternWidth(i);
+                  int height = dlg.GetTilePatternHeight(i);
+                  double base_x = dlg.GetTilePatternBaseX(i);
+                  double base_y = dlg.GetTilePatternBaseY(i);
+                  double ext_x = dlg.GetTilePatternExtentX(i);
+                  double ext_y = dlg.GetTilePatternExtentY(i);
+                  lyr->GetTileServiceLayer()->AddTilePattern(handle, srs, width,
+                                                             height, base_x,
+                                                             base_y, ext_x,
+                                                             ext_y);
+                }
+              lyr->GetTileServiceLayer()->BuildFixedScales();
+              MapView->InsertWmsLayer(lyr);
+              MapView->BuildCRSlist();
+            }
+      } else
+        {
+          // ordinary WMS Layer
+          lyr = new WmsLayer(service, dlg.GetName(), dlg.GetTitle(),
+                             dlg.GetAbstract(), dlg.IsTiled(),
+                             dlg.GetTileWidth(), dlg.GetTileHeight(),
+                             dlg.IsQueryable(), dlg.IsOpaque(),
+                             dlg.GetVersion(), dlg.GetStyleName(),
+                             dlg.GetStyleTitle(), dlg.GetStyleAbstract(),
+                             dlg.GetFormat(), dlg.GetCRS(),
+                             dlg.IsSwapXY(), dlg.GetMinX(),
+                             dlg.GetMaxX(), dlg.GetMinY(), dlg.GetMaxY(),
+                             dlg.GetGeoMinX(), dlg.GetGeoMaxX(),
+                             dlg.GetGeoMinY(), dlg.GetGeoMaxY(),
+                             dlg.GetMinScaleDenominator(),
+                             dlg.GetMaxScaleDenominator());
+          if (lyr != NULL)
+            {
+              for (int s = 0; s < dlg.CountStyles(); s++)
+                {
+                  const char *name;
+                  const char *title;
+                  const char *abstract;
+                  dlg.GetStyleByIndex(s, &name, &title, &abstract);
+                  lyr->AddStyle(name, title, abstract);
+                }
+              for (int s = 0; s < dlg.CountCRS(); s++)
+                {
+                  WmsCRS *crs = lyr->AddCRS(dlg.GetCrsByIndex(s));
+                  if (crs != NULL)
+                    crs->SetBBox(dlg.GetBBoxByCRS(crs->GetCRS()));
+                }
+              if (lyr->IsQueryable() == false)
+                {
+                  // attempting to identify queryable children 
+                  rl2WmsLayerPtr lyr_handle = dlg.GetLayerHandle();
+                  AddQueryableChildren(lyr, lyr_handle);
+                }
+              MapView->InsertWmsLayer(lyr);
+              MapView->BuildCRSlist();
+            }
+        }
+    }
+}
+
+void MyFrame::AddQueryableChildren(WmsLayer * lyr, rl2WmsLayerPtr handle)
+{
+//
+// recursively adding Queryable children Layers
+//
+  int count = get_wms_layer_children_count(handle);
+  for (int i = 0; i < count; i++)
+    {
+      // testing for Queryable children
+      const char *name = NULL;
+      const char *title = NULL;
+      rl2WmsLayerPtr child = get_wms_child_layer(handle, i);
+      if (child == NULL)
+        continue;
+      if (is_wms_layer_queryable(child))
+        {
+          name = get_wms_layer_name(child);
+          title = get_wms_layer_title(child);
+        }
+      if (name != NULL)
+        lyr->AddQueryableChild(name, title);
+      else
+        AddQueryableChildren(lyr, child);
+    }
+}
+
+void MyFrame::OnWms(wxCommandEvent & WXUNUSED(event))
+{
+//
+// opening a WMS datasource
+  WmsSelection(false);
+}
+
+void MyFrame::ClearLayerTree()
+{
+// resets the layer TREE list to the empty state
+  LayerTree->Show(false);
+  LayerTree->FlushAll();
+  LayerTree->Show(true);
+}
+
+void MyFrame::OnQuit(wxCommandEvent & WXUNUSED(event))
+{
+//
+// EXIT - event handler
+//
+  Close(true);
+}
+
+void MyFrame::OnClose(wxCloseEvent & event)
+{
+//
+// immedtiately before closing the main window
+//
+  if (MapView->IsDownloadInProgress() == true)
+    {
+      MapView->SetWmsAbort();
+      event.Veto();
+      return;
+    }
+  if (MapView->IsPrintInProgress() == true)
+    {
+      MapView->SetWmsAbort();
+      event.Veto();
+      return;
+    }
+  Destroy();
+}
+
+void MyFrame::OnAbout(wxCommandEvent & WXUNUSED(event))
+{
+//
+// ABOUT dialog - event handler
+//
+  char ver[128];
+  wxAboutDialogInfo dlg;
+  dlg.SetIcon(wxIcon(icon_info_xpm));
+  dlg.SetName(wxT("LibreWMS"));
+  const char *version = VERSION;
+  dlg.SetVersion(wxString::FromUTF8(version));
+  wxString str = wxT("a free WMS viewer built on the top of RasterLite2\n\n");
+  sprintf(ver, "%d.%d.%d", wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER);
+  str += wxT("wxWidgets version ") + wxString::FromUTF8(ver) + wxT("\n");
+  strcpy(ver, rl2_version());
+  str += wxT("RasterLite2 version ") + wxString::FromUTF8(ver) + wxT("\n");
+  dlg.SetDescription(str);
+  dlg.SetCopyright(wxT("by Alessandro Furieri - 2014"));
+  dlg.SetWebSite(wxT("http://www.gaia-gis.it"));
+  wxString license =
+    wxT("This program is free software; you can redistribute it\n");
+  license +=
+    wxT("and/or modify it under the terms of the GNU General Public License\n");
+  license += wxT("(GPL) as published by the Free Software Foundation\n\n");
+  license +=
+    wxT
+    ("A copy of the GPL can be found at\nhttp://www.gnu.org/licenses/gpl.txt");
+  dlg.SetLicense(license);
+  ::wxAboutBox(dlg);
+}
+
+void MyFrame::InitializeWmsList()
+{
+//
+// initializing the pre-defined WMS List
+//
+  int ret;
+  char *errMsg = NULL;
+  if (!SQLiteHandle)
+    return;
+// creating the WMS_LIST table
+  ret = sqlite3_exec(SQLiteHandle, "CREATE TABLE wms_list ("
+                     "country TEXT NOT NULL,\n"
+                     "state_province TEXT NOT NULL,\n"
+                     "category TEXT NOT NULL,\n"
+                     "url TEXT NOT NULL)", NULL, NULL, &errMsg);
+  if (ret != SQLITE_OK)
+    {
+      wxMessageBox(wxT("Unable to CREATE TABLE wms_list: ") +
+                   wxString::FromUTF8(errMsg), wxT("LibreWMS"),
+                   wxOK | wxICON_ERROR, this);
+      sqlite3_free(errMsg);
+      return;
+    }
+// starting a TRANSACTION
+  ret = sqlite3_exec(SQLiteHandle, "BEGIN", NULL, NULL, &errMsg);
+  if (ret != SQLITE_OK)
+    {
+      wxMessageBox(wxT("BEGIN error: ") +
+                   wxString::FromUTF8(errMsg), wxT("LibreWMS"),
+                   wxOK | wxICON_ERROR, this);
+      sqlite3_free(errMsg);
+      return;
+    }
+// populating the pre-defined WMS list
+  AddPredefinedWMS("", "WmsLite", "localhost WMS server",
+                   "http://127.0.0.1:8080/wmslite?service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "ortophoto",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsofc&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "land registry",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmscatasto&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "admin boundaries",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsambamm&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "zoning",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsambprogr&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "land use",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsucs&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "census",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsambcens&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "speleology",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsspeleologia&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "trekking",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmssentieristica&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "hydrography",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsidrogr&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "roads",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsitnt&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "map",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmsctr&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Toscana", "historical",
+                   "http://www502.regione.toscana.it/wmsraster/com.rt.wms.RTmap/wms?map=wmscastore&service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Emilia Romagna", "ortophoto",
+                   "http://servizigis.regione.emilia-romagna.it/wms/agea2011_rgb?service=wms&request=getcapabilities&version=130");
+  AddPredefinedWMS("Italy", "Emilia Romagna", "map",
+                   "http://servizigis.regione.emilia-romagna.it/wms/dbtr2008_ctr5?service=wms&request=getcapabilities&version=130");
+  AddPredefinedWMS("Italy", "Emilia Romagna", "miscellaneous",
+                   "http://servizigis.regione.emilia-romagna.it/wms/dbtr2008?service=wms&request=getcapabilities&version=130");
+  AddPredefinedWMS("Italy", "Sardegna", "ortophoto",
+                   "http://webgis.regione.sardegna.it/wmsconnector/com.esri.wms.Esrimap/ras_wms?service=WMS&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Sardegna", "miscellaneous",
+                   "http://webgis.regione.sardegna.it/geoserver/ows?service=WMS&request=GetCapabilities ");
+  AddPredefinedWMS("Italy", "Piemonte", "ortophoto",
+                   "http://geomap.reteunitaria.piemonte.it/ws/taims/rp-01/taimsortoregp/wms_ortoregp2010?service=WMS&request=getCapabilities");
+  AddPredefinedWMS("Italy", "Piemonte", "map",
+                   "http://geomap.reteunitaria.piemonte.it/ws/taims/rp-01/taimssfwms/CatalogoSfondoRegione?service=WMS&request=getCapabilities");
+  AddPredefinedWMS("Italy", "Piemonte", "admin boundaries",
+                   "http://geomap.reteunitaria.piemonte.it/ws/taims/rp-01/taimslimammwms/wms_limitiAmm?service=WMS&request=getCapabilities");
+  AddPredefinedWMS("Italy", "Umbria", "ortophoto",
+                   "http://geo.umbriaterritorio.it/arcgis/services/public/ORTOFOTO_2011_GB/MapServer/WMSServer?service=WMS&request=getCapabilities");
+  AddPredefinedWMS("Italy", "Abruzzo", "ortophoto",
+                   "http://geoportale2.regione.abruzzo.it/ecwp/ecw_wms.dll?service=WMS&request=getCapabilities");
+  AddPredefinedWMS("Italy", "Campania", "miscellaneous",
+                   "http://sit.regione.campania.it:80/arcgis/services/cartografia_base/MapServer/WMSServer?service=WMS&request=getCapabilities");
+  AddPredefinedWMS("Italy", "Sicilia", "ortophoto",
+                   "http://map.sitr.regione.sicilia.it/ArcGIS/services/Ortofoto_ATA20072008/MapServer/WMSServer?service=WMS&request=getCapabilities");
+  AddPredefinedWMS("Italy", "Bolzano / Bozen", "niscellaneous",
+                   "http://sdi.provincia.bz.it/geoserver/inspire/wms?service=wms&version=1.3.0&request=GetCapabilities");
+  AddPredefinedWMS("Italy", "Torino", "map",
+                   "http://geomap.reteunitaria.piemonte.it/ws/siccms/coto-01/wmsg01/wms_sicc31_carta_tecnica_bn?service=WMS&request=getCapabilities");
+  AddPredefinedWMS("Italy", "ISPRA 25k", "geological map",
+                   "http://sgi1.isprambiente.it/ArcGIS/services/servizi/geologia25k/mapserver/WMSServer?Request=GetCapabilities");
+  AddPredefinedWMS("Italy", "ISPRA 100k", "geological map",
+                   "http://sgi1.isprambiente.it/ArcGIS/services/servizi/geologia100k/mapserver/WMSServer?Request=GetCapabilities");
+  AddPredefinedWMS("USA", "USGS Alabama", "geological map",
+                   "http://mrdata.usgs.gov/services/al?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Alaska", "geological map",
+                   "http://mrdata.usgs.gov/services/akgeol?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Arkansas", "geological map",
+                   "http://mrdata.usgs.gov/services/ar?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Arizona", "geological map",
+                   "http://mrdata.usgs.gov/services/az?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS California", "geological map",
+                   "http://mrdata.usgs.gov/services/ca?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Colorado", "geological map",
+                   "http://mrdata.usgs.gov/services/co?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Connecticut", "geological map",
+                   "http://mrdata.usgs.gov/services/ct?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Delaware", "geological map",
+                   "http://mrdata.usgs.gov/services/de?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Florida", "geological map",
+                   "http://mrdata.usgs.gov/services/fl?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Georgia", "geological map",
+                   "http://mrdata.usgs.gov/services/ga?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Hawaii", "geological map",
+                   "http://mrdata.usgs.gov/services/hi?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Iowa", "geological map",
+                   "http://mrdata.usgs.gov/services/ia?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Idaho", "geological map",
+                   "http://mrdata.usgs.gov/services/id?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Illinois", "geological map",
+                   "http://mrdata.usgs.gov/services/il?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Indiana", "geological map",
+                   "http://mrdata.usgs.gov/services/in?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Kansas", "geological map",
+                   "http://mrdata.usgs.gov/services/ks?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Kentucky", "geological map",
+                   "http://mrdata.usgs.gov/services/ky?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Louisiana", "geological map",
+                   "http://mrdata.usgs.gov/services/la?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Massachussets", "geological map",
+                   "http://mrdata.usgs.gov/services/ma?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Maryland", "geological map",
+                   "http://mrdata.usgs.gov/services/md?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Maine", "geological map",
+                   "http://mrdata.usgs.gov/services/me?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Michigan", "geological map",
+                   "http://mrdata.usgs.gov/services/mi?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Minnesota", "geological map",
+                   "http://mrdata.usgs.gov/services/mn?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Missouri", "geological map",
+                   "http://mrdata.usgs.gov/services/mo?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Mississippi", "geological map",
+                   "http://mrdata.usgs.gov/services/ms?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Montana", "geological map",
+                   "http://mrdata.usgs.gov/services/mt?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS North Carolina", "geological map",
+                   "http://mrdata.usgs.gov/services/nc?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS North Dakota", "geological map",
+                   "http://mrdata.usgs.gov/services/nd?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Nebraska", "geological map",
+                   "http://mrdata.usgs.gov/services/ne?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS New Hampshire", "geological map",
+                   "http://mrdata.usgs.gov/services/nh?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS New Jersey", "geological map",
+                   "http://mrdata.usgs.gov/services/nj?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS New Mexico", "geological map",
+                   "http://mrdata.usgs.gov/services/nm?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Nevada", "geological map",
+                   "http://mrdata.usgs.gov/services/nv?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS New York", "geological map",
+                   "http://mrdata.usgs.gov/services/ny?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Ohio", "geological map",
+                   "http://mrdata.usgs.gov/services/oh?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Oklahoma", "geological map",
+                   "http://mrdata.usgs.gov/services/ok?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Oregon", "geological map",
+                   "http://mrdata.usgs.gov/services/or?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Pennsylvania", "geological map",
+                   "http://mrdata.usgs.gov/services/pa?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Rhode Island", "geological map",
+                   "http://mrdata.usgs.gov/services/ri?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS South Carolina", "geological map",
+                   "http://mrdata.usgs.gov/services/sc?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS South Dakota", "geological map",
+                   "http://mrdata.usgs.gov/services/sd?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Tennessee", "geological map",
+                   "http://mrdata.usgs.gov/services/tn?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Texas", "geological map",
+                   "http://mrdata.usgs.gov/services/tx?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Utah", "geological map",
+                   "http://mrdata.usgs.gov/services/ut?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Virginia", "geological map",
+                   "http://mrdata.usgs.gov/services/va?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Vermont", "geological map",
+                   "http://mrdata.usgs.gov/services/vt?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Washington", "geological map",
+                   "http://mrdata.usgs.gov/services/wa?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Wisconsin", "geological map",
+                   "http://mrdata.usgs.gov/services/wi?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS West Virginia", "geological map",
+                   "http://mrdata.usgs.gov/services/wv?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS Wyoming", "geological map",
+                   "http://mrdata.usgs.gov/services/wy?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("USA", "USGS active-mines", "geological map",
+                   "http://mrdata.usgs.gov/services/active-mines?request=getcapabilities&service=WMS&version=1.1.1&");
+  AddPredefinedWMS("Earth", "NASA/JPL OnEarth", "satellite",
+                   "http://wms.jpl.nasa.gov/wms.cgi?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1");
+  AddPredefinedWMS("Moon", "NASA/JPL OnMoon", "satellite",
+                   "http://onmoon.jpl.nasa.gov/wms.cgi?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1");
+  AddPredefinedWMS("Mars", "NASA/JPL OnMars", "satellite",
+                   "http://onmars.jpl.nasa.gov/wms.cgi?SERVICE=WMS&REQUEST=GetCapabilities&VERSION=1.1.1");
+
+// committing the still pending TRANSACTION
+  ret = sqlite3_exec(SQLiteHandle, "COMMIT", NULL, NULL, &errMsg);
+  if (ret != SQLITE_OK)
+    {
+      wxMessageBox(wxT("COMMIT error: ") +
+                   wxString::FromUTF8(errMsg), wxT("LibreWMS"),
+                   wxOK | wxICON_ERROR, this);
+      sqlite3_free(errMsg);
+      return;
+    }
+}
+
+void MyFrame::AddPredefinedWMS(const char *country, const char *state_province,
+                               const char *category, const char *url)
+{
+//
+// inserting a WMS service into the pre-defined catalog
+//
+  int ret;
+  char *sql;
+  char *errMsg = NULL;
+  if (!SQLiteHandle)
+    return;
+// preparing the INSERT statement
+  sql =
+    sqlite3_mprintf
+    ("INSERT INTO wms_list (country, state_province, category, url) "
+     "VALUES (%Q, %Q, %Q, %Q)", country, state_province, category, url);
+// inserting into the table
+  ret = sqlite3_exec(SQLiteHandle, sql, NULL, NULL, &errMsg);
+  if (ret != SQLITE_OK)
+    {
+      wxMessageBox(wxT("Unable to INSERT INTO wms_list: ") +
+                   wxString::FromUTF8(errMsg), wxT("LibreWMS"),
+                   wxOK | wxICON_ERROR, this);
+      sqlite3_free(errMsg);
+    }
+  sqlite3_free(sql);
+}
+
+bool MyFrame::IsGeographicCRS(const char *crs)
+{
+// testing if some CRS is of the Geographic [Long/Lat] type
+  if (IsSwapXYcrs(crs) == true)
+    return true;
+  if (crs == NULL)
+    return false;
+  if (strcmp(crs, "CRS:84") == 0)
+    return true;
+  if (strcmp(crs, "IAU2000:30100") == 0)
+    return true;
+  if (strcmp(crs, "IAU2000:49900") == 0)
+    return true;
+  return false;
+}
+
+bool MyFrame::IsSwapXYcrs(const char *crs)
+{
+// testing if some CRS requires swapped axes 
+  int ret;
+  char *sql;
+  char **results;
+  int rows;
+  int columns;
+  int i;
+  int len;
+  int srid = -1;
+  int geo = -1;
+  if (crs == NULL)
+    return false;
+  if (strcmp(crs, "CRS:84") == 0)
+    return false;
+  len = strlen(crs);
+  for (i = 0; i < len; i++)
+    {
+      if (*(crs + i) == ':')
+        {
+          // delimiter found
+          if (i == 4 && memcmp(crs, "EPSG", 4) == 0)
+            {
+              srid = atoi(crs + i + 1);
+              break;
+            }
+        }
+    }
+  if (srid <= 0)
+    return false;
+
+  sql = sqlite3_mprintf("SELECT Count(*) FROM spatial_ref_sys "
+                        "WHERE srid = %d AND proj4text LIKE '%%+proj=longlat%%'",
+                        srid);
+  ret = sqlite3_get_table(SQLiteHandle, sql, &results, &rows, &columns, NULL);
+  sqlite3_free(sql);
+  if (ret != SQLITE_OK)
+    goto skip;
+
+  for (i = 1; i <= rows; i++)
+    geo = atoi(results[(i * columns) + 0]);
+  sqlite3_free_table(results);
+skip:
+  if (geo > 0)
+    return true;
+  return false;
+}
+
+bool MyFrame::BBoxFromLongLat(const char *crs, double *minx, double *maxx,
+                              double *miny, double *maxy)
+{
+// converting a BBox into some CRS from Long/Lat coords
+  int srid = -1;
+  char *proj_from;
+  char *proj_to;
+  gaiaGeomCollPtr g_min_in;
+  gaiaGeomCollPtr g_min_out;
+  gaiaGeomCollPtr g_max_in;
+  gaiaGeomCollPtr g_max_out;
+  gaiaPointPtr pt;
+  if (crs == NULL)
+    return false;
+  if (strcmp(crs, "CRS:84") == 0)
+    srid = 4326;
+  else
+    {
+      int i;
+      int len = strlen(crs);
+      for (i = 0; i < len; i++)
+        {
+          if (*(crs + i) == ':')
+            {
+              // delimiter found
+              if (i == 4 && memcmp(crs, "EPSG", 4) == 0)
+                {
+                  srid = atoi(crs + i + 1);
+                  break;
+                }
+            }
+        }
+    }
+  if (srid <= 0)
+    return false;
+
+// attempting to reproject from Long/Lat into the given CRS
+  proj_from = GetProjParams(4326);
+  proj_to = GetProjParams(srid);
+  if (proj_to == NULL || proj_from == NULL)
+    {
+      if (proj_from)
+        free(proj_from);
+      if (proj_to)
+        free(proj_to);
+      return false;
+    }
+
+  g_min_in = gaiaAllocGeomColl();
+  gaiaAddPointToGeomColl(g_min_in, *minx, *miny);
+  g_max_in = gaiaAllocGeomColl();
+  gaiaAddPointToGeomColl(g_max_in, *maxx, *maxy);
+  g_min_out = gaiaTransform(g_min_in, proj_from, proj_to);
+  g_max_out = gaiaTransform(g_max_in, proj_from, proj_to);
+  free(proj_from);
+  free(proj_to);
+  gaiaFreeGeomColl(g_min_in);
+  gaiaFreeGeomColl(g_max_in);
+  pt = g_min_out->FirstPoint;
+  *minx = pt->X;
+  *miny = pt->Y;
+  gaiaFreeGeomColl(g_min_out);
+  pt = g_max_out->FirstPoint;
+  *maxx = pt->X;
+  *maxy = pt->Y;
+  gaiaFreeGeomColl(g_max_out);
+  return true;
+}
+
+char *MyFrame::GetProjParams(int srid)
+{
+// attempting to retrieving PROJ4 geodetic definitions
+
+  sqlite3 *sqlite = SQLiteHandle;
+  char *sql;
+  char **results;
+  int rows;
+  int columns;
+  int i;
+  int ret;
+  int len;
+  const char *proj4text;
+  char *proj_params = NULL;
+  char *errMsg = NULL;
+  sql = sqlite3_mprintf
+    ("SELECT proj4text FROM spatial_ref_sys WHERE srid = %d", srid);
+  ret = sqlite3_get_table(sqlite, sql, &results, &rows, &columns, &errMsg);
+  sqlite3_free(sql);
+  if (ret != SQLITE_OK)
+    {
+      fprintf(stderr, "unknown SRID: %d\t<%s>\n", srid, errMsg);
+      sqlite3_free(errMsg);
+      return NULL;
+    }
+  for (i = 1; i <= rows; i++)
+    {
+      proj4text = results[(i * columns)];
+      if (proj4text != NULL)
+        {
+          len = strlen(proj4text);
+          proj_params = (char *) malloc(len + 1);
+          strcpy(proj_params, proj4text);
+        }
+    }
+  if (proj_params == NULL)
+    fprintf(stderr, "unknown SRID: %d\n", srid);
+  sqlite3_free_table(results);
+  return proj_params;
+}
diff --git a/Makefile-static-MinGW b/Makefile-static-MinGW
new file mode 100644
index 0000000..b78707d
--- /dev/null
+++ b/Makefile-static-MinGW
@@ -0,0 +1,61 @@
+# SandroFurieri (c) 2008
+# Makefile ( Mingw & wxwidgets) for spatialite-GUI
+
+SRC = Main.cpp LayerTree.cpp MapView.cpp Dialogs.cpp Printer.cpp win_resource/resource.rc
+OBJ = Main.o LayerTree.o MapView.o Dialogs.o Printer.o win_resource/resource.o
+EXE = ./static_bin/LibreWMS.exe
+INCLUDE = Classdef.h 
+
+# Define default flags:
+CFLAGS = -I/usr/local/include -I/usr/local/include/libxml2
+CXXFLAGS = $(shell wx-config --cxxflags)
+LIB = -Wl,--subsystem,windows /usr/local/lib/libwx_mswu-3.0.a 
+EXTRAFLAGS = -Wall -Wextra -Wno-ctor-dtor-privacy \
+	-fno-strict-aliasing -I/usr/local/include -D_LARGE_FILE=1 \
+	-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1
+REZ = $(shell wx-config --rescomp)
+EXTRALIBS = /usr/local/lib/librasterlite2.a \
+	/usr/local/lib/libspatialite.a /usr/local/lib/liblwgeom.a \
+	/usr/local/lib/libgeos_c.a /usr/local/lib/libiconv.a \
+	/usr/local/lib/libgeos.a /usr/local/lib/libproj.a \
+	/usr/local/lib/libgif.a /usr/local/lib/libgeotiff.a \
+	/usr/local/lib/libtiff.a /usr/local/lib/libjpeg.a \
+	/usr/local/lib/libfreexl.a /usr/local/lib/libsqlite3.a \
+	/usr/local/lib/libcurl.a /usr/local/lib/libssl.a \
+	/usr/local/lib/libcrypto.a /usr/local/lib/libcairo.a \
+	/usr/local/lib/libpixman-1.a /usr/local/lib/libfontconfig.a \
+	/usr/local/lib/libfreetype.a /usr/local/lib/libpng.a \
+	/usr/local/lib/libxml2.a /usr/local/lib/libz.a \
+	/usr/local/lib/liblzma.a /usr/local/lib/libexpat.a \
+	/usr/local/lib/libwebp.a
+EXTRALIB2 = -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool \
+	-lwinmm -lshell32 -lcomctl32 -lcomdlg32 -ladvapi32 \
+	-lwsock32 -lgdi32 -lmsimg32 -lws2_32 -lwldap32 -lgdiplus
+
+all: $(EXE)
+
+$(EXE): $(OBJ) $(EXTRALIBS)
+	$(CXX) $(OBJ) -o $(EXE) $(LIB) $(EXTRALIBS) $(EXTRALIB2) \
+	-static-libstdc++ -static-libgcc
+	strip --strip-all  $(EXE)
+
+clean :
+	$(RM) $(OBJ) $(EXE)
+		
+Main.o: Main.cpp $(INCLUDE)
+	$(CXX) -c Main.cpp $(CXXFLAGS) $(EXTRAFLAGS)
+
+MapView.o: MapView.cpp $(INCLUDE)
+	$(CXX) -c MapView.cpp $(CXXFLAGS) $(EXTRAFLAGS)
+
+LayerTree.o: LayerTree.cpp $(INCLUDE)
+	$(CXX) -c LayerTree.cpp $(CXXFLAGS) $(EXTRAFLAGS)
+	
+Dialogs.o: Dialogs.cpp $(INCLUDE)
+	$(CXX) -c Dialogs.cpp $(CXXFLAGS) $(EXTRAFLAGS)
+	
+Printer.o: Printer.cpp $(INCLUDE)
+	$(CXX) -c Printer.cpp $(CXXFLAGS) $(EXTRAFLAGS)
+			
+win_resource/resource.o: win_resource/resource.rc
+	$(REZ) -i win_resource/resource.rc -o win_resource/resource.o 
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..6c71199
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,20 @@
+ACLOCAL_AMFLAGS = -I m4
+
+bin_PROGRAMS = LibreWMS
+
+AM_CPPFLAGS = @CFLAGS@
+AM_CPPFLAGS += -I$(top_srcdir)
+
+LibreWMS_SOURCES = Classdef.h Main.cpp \
+	Dialogs.cpp MapView.cpp \
+	LayerTree.cpp Printer.cpp 
+
+LDADD = @WX_LIBS@ @LIBRASTERLITE2_LIBS@ @LIBSPATIALITE_LIBS@ 
+
+EXTRA_DIST = Makefile-static-MinGW \
+	indent_me
+
+AUTOMAKE_OPTIONS = dist-zip
+
+SUBDIRS = icons win_resource mac_resource gnome_resource
+
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..4740643
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,963 @@
+# Makefile.in generated by automake 1.13.4 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in 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.
+
+ at SET_MAKE@
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = LibreWMS$(EXEEXT)
+subdir = .
+DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
+	$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+	$(top_srcdir)/configure $(am__configure_deps) \
+	$(srcdir)/config.h.in depcomp COPYING config.guess config.sub \
+	install-sh missing ltmain.sh
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
+	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+	$(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+PROGRAMS = $(bin_PROGRAMS)
+am_LibreWMS_OBJECTS = Main.$(OBJEXT) Dialogs.$(OBJEXT) \
+	MapView.$(OBJEXT) LayerTree.$(OBJEXT) Printer.$(OBJEXT)
+LibreWMS_OBJECTS = $(am_LibreWMS_OBJECTS)
+LibreWMS_LDADD = $(LDADD)
+LibreWMS_DEPENDENCIES =
+AM_V_lt = $(am__v_lt_ at AM_V@)
+am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+AM_V_P = $(am__v_P_ at AM_V@)
+am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_ at AM_V@)
+am__v_GEN_ = $(am__v_GEN_ at AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_ at AM_V@)
+am__v_at_ = $(am__v_at_ at AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I. at am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+	$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_ at AM_V@)
+am__v_CXX_ = $(am__v_CXX_ at AM_DEFAULT_V@)
+am__v_CXX_0 = @echo "  CXX     " $@;
+am__v_CXX_1 = 
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+	$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_ at AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_ at AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo "  CXXLD   " $@;
+am__v_CXXLD_1 = 
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_ at AM_V@)
+am__v_CC_ = $(am__v_CC_ at AM_DEFAULT_V@)
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_ at AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_ at AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(LibreWMS_SOURCES)
+DIST_SOURCES = $(LibreWMS_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+	ctags-recursive dvi-recursive html-recursive info-recursive \
+	install-data-recursive install-dvi-recursive \
+	install-exec-recursive install-html-recursive \
+	install-info-recursive install-pdf-recursive \
+	install-ps-recursive install-recursive installcheck-recursive \
+	installdirs-recursive pdf-recursive ps-recursive \
+	tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+  $(RECURSIVE_TARGETS) \
+  $(RECURSIVE_CLEAN_TARGETS) \
+  $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+	cscope distdir dist dist-all distcheck
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
+	$(LISP)config.h.in
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+CSCOPE = cscope
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  if test -d "$(distdir)"; then \
+    find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+      && rm -rf "$(distdir)" \
+      || { sleep 5 && rm -rf "$(distdir)"; }; \
+  else :; fi
+am__post_remove_distdir = $(am__remove_distdir)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz $(distdir).zip
+GZIP_ENV = --best
+DIST_TARGETS = dist-gzip dist-zip
+distuninstallcheck_listfiles = find . -type f -print
+am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
+  | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBRASTERLITE2_CFLAGS = @LIBRASTERLITE2_CFLAGS@
+LIBRASTERLITE2_LIBS = @LIBRASTERLITE2_LIBS@
+LIBS = @LIBS@
+LIBSPATIALITE_CFLAGS = @LIBSPATIALITE_CFLAGS@
+LIBSPATIALITE_LIBS = @LIBSPATIALITE_LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+WX_CONFIG = @WX_CONFIG@
+WX_LIBS = @WX_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+ACLOCAL_AMFLAGS = -I m4
+AM_CPPFLAGS = @CFLAGS@ -I$(top_srcdir)
+LibreWMS_SOURCES = Classdef.h Main.cpp \
+	Dialogs.cpp MapView.cpp \
+	LayerTree.cpp Printer.cpp 
+
+LDADD = @WX_LIBS@ @LIBRASTERLITE2_LIBS@ @LIBSPATIALITE_LIBS@ 
+EXTRA_DIST = Makefile-static-MinGW \
+	indent_me
+
+AUTOMAKE_OPTIONS = dist-zip
+SUBDIRS = icons win_resource mac_resource gnome_resource
+all: config.h
+	$(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+am--refresh: Makefile
+	@:
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
+	      $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --gnu Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    echo ' $(SHELL) ./config.status'; \
+	    $(SHELL) ./config.status;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	$(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+	$(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+config.h: stamp-h1
+	@if test ! -f $@; then rm -f stamp-h1; else :; fi
+	@if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+	@rm -f stamp-h1
+	cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) 
+	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+	rm -f stamp-h1
+	touch $@
+
+distclean-hdr:
+	-rm -f config.h stamp-h1
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+	fi; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p \
+	 || test -f $$p1 \
+	  ; then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' \
+	    -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	    echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	    $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' \
+	`; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+	@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+	echo " rm -f" $$list; \
+	rm -f $$list || exit $$?; \
+	test -n "$(EXEEXT)" || exit 0; \
+	list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+	echo " rm -f" $$list; \
+	rm -f $$list
+
+LibreWMS$(EXEEXT): $(LibreWMS_OBJECTS) $(LibreWMS_DEPENDENCIES) $(EXTRA_LibreWMS_DEPENDENCIES) 
+	@rm -f LibreWMS$(EXEEXT)
+	$(AM_V_CXXLD)$(CXXLINK) $(LibreWMS_OBJECTS) $(LibreWMS_LDADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Dialogs.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/LayerTree.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Main.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/MapView.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/Printer.Po at am__quote@
+
+.cpp.o:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+ at am__fastdepCXX_TRUE@	$(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+ at am__fastdepCXX_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	$(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCXX_FALSE@	DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCXX_FALSE@	$(AM_V_CXX at am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool config.lt
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+#     (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+	@fail=; \
+	if $(am__make_keepgoing); then \
+	  failcom='fail=yes'; \
+	else \
+	  failcom='exit 1'; \
+	fi; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	set x; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	$(am__define_uniq_tagged_files); \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscope: cscope.files
+	test ! -s cscope.files \
+	  || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+clean-cscope:
+	-rm -f cscope.files
+cscope.files: clean-cscope cscopelist
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
+
+distdir: $(DISTFILES)
+	$(am__remove_distdir)
+	test -d "$(distdir)" || mkdir "$(distdir)"
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    $(am__make_dryrun) \
+	      || test -d "$(distdir)/$$subdir" \
+	      || $(MKDIR_P) "$(distdir)/$$subdir" \
+	      || exit 1; \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+		am__skip_mode_fix=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+	-test -n "$(am__skip_mode_fix)" \
+	|| find "$(distdir)" -type d ! -perm -755 \
+		-exec chmod u+rwx,go+rx {} \; -o \
+	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+	|| chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+	tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+	$(am__post_remove_distdir)
+
+dist-bzip2: distdir
+	tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+	$(am__post_remove_distdir)
+
+dist-lzip: distdir
+	tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
+	$(am__post_remove_distdir)
+
+dist-xz: distdir
+	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
+	$(am__post_remove_distdir)
+
+dist-tarZ: distdir
+	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+	$(am__post_remove_distdir)
+
+dist-shar: distdir
+	shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+	$(am__post_remove_distdir)
+dist-zip: distdir
+	-rm -f $(distdir).zip
+	zip -rq $(distdir).zip $(distdir)
+	$(am__post_remove_distdir)
+
+dist dist-all:
+	$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+	$(am__post_remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+	case '$(DIST_ARCHIVES)' in \
+	*.tar.gz*) \
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+	*.tar.bz2*) \
+	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+	*.tar.lz*) \
+	  lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
+	*.tar.xz*) \
+	  xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+	*.tar.Z*) \
+	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+	*.shar.gz*) \
+	  GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+	*.zip*) \
+	  unzip $(distdir).zip ;;\
+	esac
+	chmod -R a-w $(distdir)
+	chmod u+w $(distdir)
+	mkdir $(distdir)/_build $(distdir)/_inst
+	chmod a-w $(distdir)
+	test -d $(distdir)/_build || exit 0; \
+	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+	  && am__cwd=`pwd` \
+	  && $(am__cd) $(distdir)/_build \
+	  && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
+	    $(DISTCHECK_CONFIGURE_FLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
+	  && $(MAKE) $(AM_MAKEFLAGS) check \
+	  && $(MAKE) $(AM_MAKEFLAGS) install \
+	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+	        distuninstallcheck \
+	  && chmod -R a-w "$$dc_install_base" \
+	  && ({ \
+	       (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+	            distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+	      } || { rm -rf "$$dc_destdir"; exit 1; }) \
+	  && rm -rf "$$dc_destdir" \
+	  && $(MAKE) $(AM_MAKEFLAGS) dist \
+	  && rm -rf $(DIST_ARCHIVES) \
+	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+	  && cd "$$am__cwd" \
+	  || exit 1
+	$(am__post_remove_distdir)
+	@(echo "$(distdir) archives ready for distribution: "; \
+	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+	@test -n '$(distuninstallcheck_dir)' || { \
+	  echo 'ERROR: trying to run $@ with an empty' \
+	       '$$(distuninstallcheck_dir)' >&2; \
+	  exit 1; \
+	}; \
+	$(am__cd) '$(distuninstallcheck_dir)' || { \
+	  echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
+	  exit 1; \
+	}; \
+	test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
+	   || { echo "ERROR: files left after uninstall:" ; \
+	        if test -n "$(DESTDIR)"; then \
+	          echo "  (check DESTDIR support)"; \
+	        fi ; \
+	        $(distuninstallcheck_listfiles) ; \
+	        exit 1; } >&2
+distcleancheck: distclean
+	@if test '$(srcdir)' = . ; then \
+	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+	  exit 1 ; \
+	fi
+	@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+	  || { echo "ERROR: files left in build directory after distclean:" ; \
+	       $(distcleancheck_listfiles) ; \
+	       exit 1; } >&2
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(PROGRAMS) config.h
+installdirs: installdirs-recursive
+installdirs-am:
+	for dir in "$(DESTDIR)$(bindir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-hdr distclean-libtool distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf $(top_srcdir)/autom4te.cache
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: $(am__recursive_targets) all install-am install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
+	am--refresh check check-am clean clean-binPROGRAMS \
+	clean-cscope clean-generic clean-libtool cscope cscopelist-am \
+	ctags ctags-am dist dist-all dist-bzip2 dist-gzip dist-lzip \
+	dist-shar dist-tarZ dist-xz dist-zip distcheck distclean \
+	distclean-compile distclean-generic distclean-hdr \
+	distclean-libtool distclean-tags distcleancheck distdir \
+	distuninstallcheck dvi dvi-am html html-am info info-am \
+	install install-am install-binPROGRAMS install-data \
+	install-data-am install-dvi install-dvi-am install-exec \
+	install-exec-am install-html install-html-am install-info \
+	install-info-am install-man install-pdf install-pdf-am \
+	install-ps install-ps-am install-strip installcheck \
+	installcheck-am installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+	tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/MapView.cpp b/MapView.cpp
new file mode 100644
index 0000000..10c3de0
--- /dev/null
+++ b/MapView.cpp
@@ -0,0 +1,4541 @@
+/*
+/ MapView.cpp
+/ a panel to show the Map of LibreWMS
+/
+/ version 1.0, 2013 July 28
+/
+/ Author: Sandro Furieri a-furieri at lqt.it
+/
+/ Copyright (C) 2013  Alessandro Furieri
+/
+/    This program is free software: you can redistribute it and/or modify
+/    it under the terms of the GNU General Public License as published by
+/    the Free Software Foundation, either version 3 of the License, or
+/    (at your option) any later version.
+/
+/    This program is distributed in the hope that it will be useful,
+/    but WITHOUT ANY WARRANTY; without even the implied warranty of
+/    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+/    GNU General Public License for more details.
+/
+/    You should have received a copy of the GNU General Public License
+/    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+/
+*/
+
+#include "Classdef.h"
+#include "wx/image.h"
+
+#include <float.h>
+
+#include "icons/crosshair.xpm"
+
+#ifdef _WIN32
+#include <windows.h>
+#include <process.h>
+#include <io.h>
+#else
+#include <pthread.h>
+#include <unistd.h>
+#endif
+
+MyMapView::MyMapView(MyFrame * parent, wxWindowID id):
+wxPanel(parent, id, wxDefaultPosition, wxSize(440, 480),
+        wxBORDER_SUNKEN | wxWANTS_CHARS)
+{
+//
+// constructor: a frame to show the Map
+//
+  MainFrame = parent;
+  Pdf = NULL;
+  Tiff = NULL;
+  FrameMinX = DBL_MAX;
+  FrameMaxY = DBL_MAX;
+  FirstRequest = NULL;
+  LastRequest = NULL;
+  Proxy = NULL;
+  PixelRatio = DBL_MAX;
+  TimerMouseWheel = NULL;
+  TimerDynamic = NULL;
+  UpdateTimer = NULL;
+  PrintTimer = NULL;
+  FirstService = NULL;
+  LastService = NULL;
+  FirstLayer = NULL;
+  LastLayer = NULL;
+  FirstCRS = NULL;
+  LastCRS = NULL;
+  WmsFixedScalesCount = 0;
+  WmsFixedScales = NULL;
+  ProgressControl = NULL;
+  DownloadInProgress = false;
+  PrintInProgress = false;
+  PendingRefresh = false;
+  PendingOnSize = false;
+  PendingWmsAbort = false;
+  IdentifyPanel = NULL;
+  Invalidate();
+
+  BitmapWidth = wxSystemSettings::GetMetric(wxSYS_SCREEN_X);
+  BitmapHeight = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y);
+  MapBitmap = wxBitmap(BitmapWidth, BitmapHeight, -1);
+  ScreenBitmap = wxBitmap(BitmapWidth, BitmapHeight, -1);
+
+  wxImage crossImage = wxBitmap(crosshair_xpm).ConvertToImage();
+#ifdef __WXMSW__
+// setting up a WINDOWS cursor
+  crossImage.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, 8);
+  crossImage.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, 8);
+  CursorCross = wxCursor(crossImage);
+#else
+#ifdef __WXMAC__
+// setting up a MacOsX cursor
+  crossImage.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_X, 8);
+  crossImage.SetOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y, 8);
+  CursorCross = wxCursor(crossImage);
+#else
+// setting up an UNIX -likecursor
+  int row;
+  int col;
+  unsigned short bits[16];
+  unsigned short mask[16];
+  for (row = 0; row < 16; row++)
+    {
+      bits[row] = 0x0000;
+      mask[row] = 0x0000;
+      for (col = 0; col < 16; col++)
+        {
+          unsigned char pixel = crossImage.GetRed(col, row);
+          if (pixel == 0)
+            {
+              switch (col)
+                {
+                  case 0:
+                    bits[row] |= 0x8000;
+                    break;
+                  case 1:
+                    bits[row] |= 0x4000;
+                    break;
+                  case 2:
+                    bits[row] |= 0x2000;
+                    break;
+                  case 3:
+                    bits[row] |= 0x1000;
+                    break;
+                  case 4:
+                    bits[row] |= 0x0800;
+                    break;
+                  case 5:
+                    bits[row] |= 0x0400;
+                    break;
+                  case 6:
+                    bits[row] |= 0x0200;
+                    break;
+                  case 7:
+                    bits[row] |= 0x0100;
+                    break;
+                  case 8:
+                    bits[row] |= 0x0080;
+                    break;
+                  case 9:
+                    bits[row] |= 0x0040;
+                    break;
+                  case 10:
+                    bits[row] |= 0x0020;
+                    break;
+                  case 11:
+                    bits[row] |= 0x0010;
+                    break;
+                  case 12:
+                    bits[row] |= 0x0008;
+                    break;
+                  case 13:
+                    bits[row] |= 0x0004;
+                    break;
+                  case 14:
+                    bits[row] |= 0x0002;
+                    break;
+                  case 15:
+                    bits[row] |= 0x0001;
+                    break;
+                };
+              switch (col)
+                {
+                  case 0:
+                    mask[row] |= 0x8000;
+                    break;
+                  case 1:
+                    mask[row] |= 0x4000;
+                    break;
+                  case 2:
+                    mask[row] |= 0x2000;
+                    break;
+                  case 3:
+                    mask[row] |= 0x1000;
+                    break;
+                  case 4:
+                    mask[row] |= 0x0800;
+                    break;
+                  case 5:
+                    mask[row] |= 0x0400;
+                    break;
+                  case 6:
+                    mask[row] |= 0x0200;
+                    break;
+                  case 7:
+                    mask[row] |= 0x0100;
+                    break;
+                  case 8:
+                    mask[row] |= 0x0080;
+                    break;
+                  case 9:
+                    mask[row] |= 0x0040;
+                    break;
+                  case 10:
+                    mask[row] |= 0x0020;
+                    break;
+                  case 11:
+                    mask[row] |= 0x0010;
+                    break;
+                  case 12:
+                    mask[row] |= 0x0008;
+                    break;
+                  case 13:
+                    mask[row] |= 0x0004;
+                    break;
+                  case 14:
+                    mask[row] |= 0x0002;
+                    break;
+                  case 15:
+                    mask[row] |= 0x0001;
+                    break;
+                };
+            }
+          if (pixel == 255)
+            {
+              switch (col)
+                {
+                  case 0:
+                    mask[row] |= 0x8000;
+                    break;
+                  case 1:
+                    mask[row] |= 0x4000;
+                    break;
+                  case 2:
+                    mask[row] |= 0x2000;
+                    break;
+                  case 3:
+                    mask[row] |= 0x1000;
+                    break;
+                  case 4:
+                    mask[row] |= 0x0800;
+                    break;
+                  case 5:
+                    mask[row] |= 0x0400;
+                    break;
+                  case 6:
+                    mask[row] |= 0x0200;
+                    break;
+                  case 7:
+                    mask[row] |= 0x0100;
+                    break;
+                  case 8:
+                    mask[row] |= 0x0080;
+                    break;
+                  case 9:
+                    mask[row] |= 0x0040;
+                    break;
+                  case 10:
+                    mask[row] |= 0x0020;
+                    break;
+                  case 11:
+                    mask[row] |= 0x0010;
+                    break;
+                  case 12:
+                    mask[row] |= 0x0008;
+                    break;
+                  case 13:
+                    mask[row] |= 0x0004;
+                    break;
+                  case 14:
+                    mask[row] |= 0x0002;
+                    break;
+                  case 15:
+                    mask[row] |= 0x0001;
+                    break;
+                };
+            }
+        }
+    }
+  CursorCross =
+    wxCursor((char *) bits, 16, 16, 8, 8, (char *) mask, wxWHITE, wxBLACK);
+#endif
+#endif
+  CursorHand = wxCursor(wxCURSOR_HAND);
+  SetCursor(CursorCross);
+
+// setting up event handlers
+  Connect(wxID_ANY, wxEVT_ERASE_BACKGROUND,
+          (wxObjectEventFunction) & MyMapView::OnEraseBackground);
+  Connect(wxID_ANY, wxEVT_SIZE, (wxObjectEventFunction) & MyMapView::OnSize);
+  Connect(wxID_ANY, wxEVT_PAINT, (wxObjectEventFunction) & MyMapView::OnPaint);
+  Connect(wxID_ANY, wxEVT_MOTION, wxMouseEventHandler(MyMapView::OnMouseMove),
+          NULL, this);
+  Connect(wxID_ANY, wxEVT_LEFT_DOWN,
+          wxMouseEventHandler(MyMapView::OnMouseClick), NULL, this);
+  Connect(wxID_ANY, wxEVT_LEFT_DCLICK,
+          wxMouseEventHandler(MyMapView::OnMouseDoubleClick), NULL, this);
+  Connect(wxID_ANY, wxEVT_MOUSEWHEEL,
+          wxMouseEventHandler(MyMapView::OnMouseWheel), NULL, this);
+  Connect(ID_WHEEL_TIMER, wxEVT_TIMER,
+          wxTimerEventHandler(MyMapView::OnTimerMouseWheel), NULL, this);
+  Connect(ID_UPDATE_TIMER, wxEVT_TIMER,
+          wxTimerEventHandler(MyMapView::OnTimerUpdate), NULL, this);
+  Connect(ID_PRINT_TIMER, wxEVT_TIMER,
+          wxTimerEventHandler(MyMapView::OnTimerPrint), NULL, this);
+  Connect(wxID_ANY, wxEVT_LEFT_UP,
+          wxMouseEventHandler(MyMapView::OnMouseDragStop), NULL, this);
+  Connect(wxID_ANY, wxEVT_LEAVE_WINDOW,
+          wxMouseEventHandler(MyMapView::OnMouseDragStop), NULL, this);
+  Connect(ID_DYNAMIC_TIMER, wxEVT_TIMER,
+          wxTimerEventHandler(MyMapView::OnTimerDynamic), NULL, this);
+  Connect(ID_MAP_WMS_THREAD_FINISHED, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & MyMapView::OnMapWmsThreadFinished);
+  Connect(ID_PDF_WMS_THREAD_FINISHED, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & MyMapView::OnPdfWmsThreadFinished);
+  Connect(ID_TIFF_WMS_THREAD_FINISHED, wxEVT_COMMAND_BUTTON_CLICKED,
+          (wxObjectEventFunction) & MyMapView::OnTiffWmsThreadFinished);
+}
+
+MyMapView::~MyMapView()
+{
+  WmsLayer *pw;
+  WmsLayer *pwn;
+  WmsService *ps;
+  WmsService *psn;
+  if (WmsFixedScales != NULL)
+    delete[]WmsFixedScales;
+  ResetCRSlist();
+  ResetGetMapRequests();
+  if (UpdateTimer != NULL)
+    {
+      UpdateTimer->Stop();
+      delete UpdateTimer;
+    }
+  if (PrintTimer != NULL)
+    {
+      PrintTimer->Stop();
+      delete PrintTimer;
+    }
+  if (TimerMouseWheel)
+    {
+      TimerMouseWheel->Stop();
+      delete TimerMouseWheel;
+    }
+  if (TimerDynamic)
+    {
+      TimerDynamic->Stop();
+      delete TimerDynamic;
+    }
+  if (Proxy != NULL)
+    delete[]Proxy;
+  pw = FirstLayer;
+  while (pw != NULL)
+    {
+      pwn = pw->GetNext();
+      delete pw;
+      pw = pwn;
+    }
+  ps = FirstService;
+  while (ps != NULL)
+    {
+      psn = ps->GetNext();
+      delete ps;
+      ps = psn;
+    }
+}
+
+void MyMapView::Invalidate()
+{
+// resetting to initial state
+  ValidMap = false;
+  ActiveLayer = NULL;
+  DragStartX = -1;
+  DragStartY = -1;
+  LastDragX = -1;
+  LastDragY = -1;
+  if (UpdateTimer)
+    {
+      UpdateTimer->Stop();
+      delete UpdateTimer;
+    }
+  UpdateTimer = NULL;
+  if (TimerMouseWheel)
+    {
+      TimerMouseWheel->Stop();
+      delete TimerMouseWheel;
+    }
+  TimerMouseWheel = NULL;
+  if (TimerDynamic)
+    {
+      TimerDynamic->Stop();
+      delete TimerDynamic;
+    }
+  TimerDynamic = NULL;
+  WheelTics = 0;
+}
+
+void MyMapView::OnSize(wxSizeEvent & WXUNUSED(event))
+{
+//
+// this window has changed its size
+//
+
+// refreshing the map
+  if (PrintInProgress == true)
+    return;
+  if (DownloadInProgress == true)
+    PendingWmsAbort = true;
+  PendingOnSize = true;
+  if (ProgressControl != NULL)
+    {
+      // resizing the Progress control
+      wxRect rect;
+      if (MainFrame->GetProgressRect(rect) == true)
+        ProgressControl->SetSize(rect);
+    }
+  PrepareMap();
+  ResetMarker();
+  if (IdentifyPanel != NULL)
+    IdentifyPanel->Reset();
+}
+
+void MyMapView::OnPaint(wxPaintEvent & WXUNUSED(event))
+{
+//
+// this window needs to be repainted
+//
+  wxPaintDC dc(this);
+  if (ValidMap == false)
+    {
+      // no map: black background
+      wxSize sz = GetClientSize();
+      dc.SetBrush(wxBrush(wxColour(128, 110, 96), wxSOLID));
+      dc.SetPen(wxPen(wxColour(0, 0, 0), 1));
+      dc.DrawRectangle(0, 0, sz.GetWidth(), sz.GetHeight());
+      dc.SetBrush(wxNullBrush);
+      dc.SetPen(wxNullPen);
+  } else if (dc.IsOk() && ScreenBitmap.IsOk())
+    {
+      wxMemoryDC *memDC = new wxMemoryDC(ScreenBitmap);
+      dc.Blit(0, 0, BitmapWidth, BitmapHeight, memDC, 0, 0);
+      delete memDC;
+    }
+  MainFrame->UpdateMapCRS();
+}
+
+void MyMapView::OnMouseMove(wxMouseEvent & event)
+{
+//
+// MOUSE motion - event handler
+// 
+  double x;
+  double y;
+  char *dummy;
+  wxString coords;
+  bool busy = wxIsBusy();
+  if (busy == true && PrintInProgress == true)
+    return;
+  if (event.LeftIsDown() == true && MainFrame->IsModePan() == true && !busy)
+    {
+      SetCursor(CursorHand);
+      if (abs(LastDragX - event.GetX()) > 25
+          || abs(LastDragY - event.GetY()) > 25)
+        DragMap(event.GetX(), event.GetY());
+      return;
+    }
+  if (event.LeftIsDown() == true && MainFrame->IsModeZoomIn() == true && !busy)
+    {
+      // marking the Zoom-in rectangle
+      ResetScreenBitmap();
+      wxMemoryDC *memDC = new wxMemoryDC(ScreenBitmap);
+      memDC->SetPen(wxPen(wxColour(255, 0, 0), 2));
+      memDC->SetBrush(wxBrush(wxColour(0, 0, 0), wxTRANSPARENT));
+      int xx;
+      int yy;
+      int width;
+      int height;
+      if (event.GetX() > DragStartX)
+        {
+          xx = DragStartX;
+          width = event.GetX() - DragStartX;
+      } else
+        {
+          xx = event.GetX();
+          width = DragStartX - event.GetX();
+        }
+      if (event.GetY() > DragStartY)
+        {
+          yy = DragStartY;
+          height = event.GetY() - DragStartY;
+      } else
+        {
+          yy = event.GetY();
+          height = DragStartY - event.GetY();
+        }
+      memDC->DrawRectangle(xx, yy, width + 1, height + 1);
+      delete memDC;
+      Refresh();
+    }
+  SetCursor(CursorCross);
+
+  if (FrameMinX == DBL_MAX || FrameMaxY == DBL_MAX || PixelRatio == DBL_MAX)
+    dummy = sqlite3_mprintf("#err#     #err#");
+  else
+    {
+      x = FrameMinX + ((double) (event.GetX()) * PixelRatio);
+      y = FrameMaxY - ((double) (event.GetY()) * PixelRatio);
+      if (MainFrame->IsGeographicCRS(GetMapCRS()) == true)
+        dummy = sqlite3_mprintf("%1.6f     %1.6f", x, y);
+      else
+        dummy = sqlite3_mprintf("%1.3f     %1.3f", x, y);
+    }
+  coords = wxString::FromUTF8(dummy);
+  sqlite3_free(dummy);
+
+  MainFrame->UpdateMapScale();
+  MainFrame->UpdateMapCoords(coords);
+  MainFrame->UpdateMapCRS();
+}
+
+void MyMapView::OnTimerDynamic(wxTimerEvent & WXUNUSED(event))
+{
+//
+// Dynamic Timer event handler
+// 
+// marking the Current Geometry
+//
+  DynamicPhase++;
+  if (DynamicPhase % 2 == 0)
+    DynamicOddEven = true;
+  else
+    DynamicOddEven = false;
+  ResetScreenBitmap();
+  if (DynamicPhase < 60)
+    {
+      if (!TimerDynamic)
+        TimerDynamic = new wxTimer(this, ID_DYNAMIC_TIMER);
+      TimerDynamic->Start(250, wxTIMER_ONE_SHOT);
+  } else
+    {
+      ImageMarkerOdd.Destroy();
+      ImageMarkerEven.Destroy();
+      ResetScreenBitmap();
+    }
+}
+
+void MyMapView::OnTimerUpdate(wxTimerEvent & WXUNUSED(event))
+{
+//
+// Update Timer event handler
+// 
+  UpdatePendingTiles();
+  //
+  // restarting the timer
+  //
+  UpdateTimer->Start(125, wxTIMER_ONE_SHOT);
+}
+
+void MyMapView::OnTimerPrint(wxTimerEvent & WXUNUSED(event))
+{
+//
+// Print Timer event handler
+// 
+  if (Pdf != NULL)
+    Pdf->UpdatePendingTiles();
+  if (Tiff != NULL)
+    Tiff->UpdatePendingTiles();
+  //
+  // restarting the timer
+  //
+  PrintTimer->Start(125, wxTIMER_ONE_SHOT);
+}
+
+void MyMapView::OnMouseWheel(wxMouseEvent & event)
+{
+//
+// MOUSE wheel rotation - event handler
+//
+  if (wxIsBusy())
+    return;
+  int tics = event.GetWheelRotation() / event.GetWheelDelta();
+  if (!TimerMouseWheel)
+    TimerMouseWheel = new wxTimer(this, ID_WHEEL_TIMER);
+  WheelTics += tics;
+  TimerMouseWheel->Start(100, wxTIMER_ONE_SHOT);
+}
+
+void MyMapView::OnTimerMouseWheel(wxTimerEvent & WXUNUSED(event))
+{
+//
+// MOUSE wheel rotation - Timer event handler
+// 
+  if (wxIsBusy())
+    return;
+  if (WheelTics > 0)
+    {
+      // zoom in
+      double factor = 1.0 - ((double) WheelTics * 0.025);
+      PixelRatio /= factor;
+  } else
+    {
+      // zoom out
+      double factor = 1.0 - ((double) (WheelTics * -1) * 0.025);
+      PixelRatio *= factor;
+    }
+  WheelTics = 0;
+  PrepareMap();
+}
+
+void MyMapView::OnMouseClick(wxMouseEvent & event)
+{
+//
+// MOUSE Click - event handler
+// 
+  SetFocus();
+  if (wxIsBusy())
+    {
+      if (PrintInProgress == true)
+        return;
+      PendingWmsAbort = true;
+      PendingRefresh = true;
+    }
+
+  if (MainFrame->IsModeIdentify() == true)
+    {
+      // identify
+      if (ActiveLayer->HasQueryableChildren())
+        DoIdentifyMultiLayer(event.GetX(), event.GetY());
+      else
+        DoIdentify(event.GetX(), event.GetY());
+      return;
+    }
+  if (MainFrame->IsModeZoomIn() == true)
+    {
+      // zoom in - Rect
+      DragStartX = event.GetX();
+      DragStartY = event.GetY();
+      LastDragX = event.GetX();
+      LastDragY = event.GetY();
+      return;
+    }
+  if (MainFrame->IsModeZoomOut() == true)
+    {
+      // zoom out
+      FrameCX = (FrameMinX + (event.GetX() * PixelRatio));
+      FrameCY = (FrameMaxY - (event.GetY() * PixelRatio));
+      PixelRatio *= 2.0;
+      PrepareMap();
+      return;
+    }
+
+  if (MainFrame->IsModePan() == true)
+    {
+      DragStartX = event.GetX();
+      DragStartY = event.GetY();
+      LastDragX = event.GetX();
+      LastDragY = event.GetY();
+    }
+}
+
+void MyMapView::OnMouseDoubleClick(wxMouseEvent & event)
+{
+//
+// MOUSE Double Click - event handler
+// 
+  SetFocus();
+  if (wxIsBusy())
+    {
+      if (PrintInProgress == true)
+        return;
+      PendingWmsAbort = true;
+      PendingRefresh = true;
+    }
+
+  if (MainFrame->IsModeIdentify() == true)
+    {
+      // identify
+      if (ActiveLayer->HasQueryableChildren())
+        DoIdentifyMultiLayer(event.GetX(), event.GetY());
+      else
+        DoIdentify(event.GetX(), event.GetY());
+      return;
+    }
+  if (MainFrame->IsModeZoomIn() == true)
+    {
+      FrameCX = (FrameMinX + (event.GetX() * PixelRatio));
+      FrameCY = (FrameMaxY - (event.GetY() * PixelRatio));
+      PixelRatio /= 4.0;
+      PrepareMap();
+      DragStartX = -1;
+      DragStartY = -1;
+      LastDragX = -1;
+      LastDragY = -1;
+      return;
+    }
+  if (MainFrame->IsModeZoomOut() == true)
+    {
+      // zoom out
+      FrameCX = (FrameMinX + (event.GetX() * PixelRatio));
+      FrameCY = (FrameMaxY - (event.GetY() * PixelRatio));
+      PixelRatio *= 4.0;
+      PrepareMap();
+      DragStartX = -1;
+      DragStartY = -1;
+      LastDragX = -1;
+      LastDragY = -1;
+      return;
+    }
+}
+
+void MyMapView::SetCurrentScale(int scale)
+{
+//
+// User Selected Scale
+//
+  FrameCX = FrameMinX + ((FrameMaxX - FrameMinX) / 2.0);
+  FrameCY = FrameMinY + ((FrameMaxY - FrameMinY) / 2.0);
+  double old = PixelRatio;
+  PixelRatio = (double) scale *old / (double) CurrentScale;
+  PrepareMap();
+}
+
+void MyMapView::OnMouseDragStop(wxMouseEvent & event)
+{
+//
+// MOUSE left button up - event handler
+// 
+  if (wxIsBusy())
+    return;
+  if (DragStartX < 0 || DragStartY < 0)
+    return;
+  LastDragX = event.GetX();
+  LastDragY = event.GetY();
+  if (MainFrame->IsModePan() == true)
+    {
+      // computing the new Map position
+      if (DragStartX == LastDragX && DragStartY == LastDragY)
+        goto none;
+      double shiftX = (double) (LastDragX - DragStartX) * PixelRatio;
+      double shiftY = (double) (LastDragY - DragStartY) * PixelRatio;
+      FrameCX -= shiftX;
+      FrameCY += shiftY;
+      PrepareMap();
+    }
+  if (MainFrame->IsModeZoomIn() == true)
+    {
+      // computing the new Map position 
+      if (DragStartX < 0 || DragStartY < 0)
+        goto none;
+      if (DragStartX == LastDragX && DragStartY == LastDragY)
+        {
+          FrameCX = (FrameMinX + (event.GetX() * PixelRatio));
+          FrameCY = (FrameMaxY - (event.GetY() * PixelRatio));
+          PixelRatio /= 2.0;
+          PrepareMap();
+          DragStartX = -1;
+          DragStartY = -1;
+          LastDragX = -1;
+          LastDragY = -1;
+          return;
+        }
+      // computing the new Zoom
+      wxSize sz = GetClientSize();
+      FrameWidth = sz.GetWidth();
+      FrameHeight = sz.GetHeight();
+      // computing the current PixelRatio
+      double x0 = FrameMinX + ((double) DragStartX * PixelRatio);
+      double y0 = FrameMaxY - ((double) DragStartY * PixelRatio);
+      double x1 = FrameMinX + ((double) LastDragX * PixelRatio);
+      double y1 = FrameMaxY - ((double) LastDragY * PixelRatio);
+      double extentX;
+      double extentY;
+      if (x0 > x1)
+        {
+          extentX = x0 - x1;
+          FrameCX = x1 + (extentX / 2.0);
+      } else
+        {
+          extentX = x1 - x0;
+          FrameCX = x0 + (extentX / 2.0);
+        }
+      if (y0 > y1)
+        {
+          extentY = y0 - y1;
+          FrameCY = y1 + (extentY / 2.0);
+      } else
+        {
+          extentY = y1 - y0;
+          FrameCY = y0 + (extentY / 2.0);
+        }
+      double x_ratio = extentX / (double) (FrameWidth);
+      double y_ratio = extentY / (double) (FrameHeight);
+      if (extentX / x_ratio <= FrameWidth && extentY / x_ratio <= FrameHeight)
+        PixelRatio = x_ratio;
+      else if (extentX / y_ratio <= FrameWidth
+               && extentY / y_ratio <= FrameHeight)
+        PixelRatio = y_ratio;
+      else
+        {
+          if (x_ratio > y_ratio)
+            PixelRatio = x_ratio;
+          else
+            PixelRatio = y_ratio;
+        }
+      PrepareMap();
+    }
+none:
+  SetCursor(CursorCross);
+  DragStartX = -1;
+  DragStartY = -1;
+  LastDragX = -1;
+  LastDragY = -1;
+}
+
+void MyMapView::DragMap(int end_x, int end_y)
+{
+//
+// Map dragging
+//
+  if (wxIsBusy())
+    return;
+  int width = FrameWidth;
+  int height = FrameHeight;
+  int baseX = 0;
+  int baseY = 0;
+  baseX = end_x - DragStartX;
+  baseY = end_y - DragStartY;
+
+  wxClientDC dc(this);
+  dc.SetBrush(wxBrush(wxColour(192, 192, 192)));
+  dc.DrawRectangle(-1, -1, width + 1, height + 1);
+// copying the ScreenImage - dragged
+  wxMemoryDC bmpDc(ScreenBitmap);
+  int eff_width = width;
+  int eff_height = height;
+  int sx = 0;
+  int sy = 0;
+  int ix = 0;
+  int iy = 0;
+  if (baseX < 0)
+    {
+      ix = 0;
+      sx = 0 - baseX;
+      eff_width = width + baseX;
+  } else
+    {
+      ix = baseX;
+      eff_width = width - baseX;
+    }
+  if (baseY < 0)
+    {
+      iy = 0;
+      sy = 0 - baseY;
+      eff_height = height + baseY;
+  } else
+    {
+      iy = baseY;
+      eff_height = height - baseY;
+    }
+  dc.Blit(ix, iy, eff_width, eff_height, &bmpDc, sx, sy);
+  LastDragX = end_x;
+  LastDragY = end_y;
+}
+
+void MyMapView::SetFullExtent()
+{
+//
+// setting the Frame to full extent
+//
+  WmsLayer *lyr = FirstLayer;
+  if (lyr == NULL)
+    {
+      ValidMap = false;
+      return;
+  } else
+    {
+      ValidMap = true;
+      if (lyr->GetTileServiceLayer() != NULL)
+        {
+          // TileService Layer
+          MapMinX = lyr->GetTileServiceLayer()->GetMinLong();
+          MapMinY = lyr->GetTileServiceLayer()->GetMinLat();
+          MapMaxX = lyr->GetTileServiceLayer()->GetMaxLong();
+          MapMaxY = lyr->GetTileServiceLayer()->GetMaxLat();
+      } else
+        {
+          // Ordinary Layer
+          if (lyr->IsSwapXY() == true)
+            {
+              MapMinY = lyr->GetMinX();
+              MapMaxY = lyr->GetMaxX();
+              MapMinX = lyr->GetMinY();
+              MapMaxX = lyr->GetMaxY();
+          } else
+            {
+              MapMinX = lyr->GetMinX();
+              MapMaxX = lyr->GetMaxX();
+              MapMinY = lyr->GetMinY();
+              MapMaxY = lyr->GetMaxY();
+            }
+        }
+    }
+  while (lyr != NULL)
+    {
+      if (lyr->GetTileServiceLayer() != NULL)
+        {
+          // TileService Layer
+          if (lyr->GetTileServiceLayer()->GetMinLong() < MapMinX)
+            MapMinX = lyr->GetTileServiceLayer()->GetMinLong();
+          if (lyr->GetTileServiceLayer()->GetMinLat() < MapMinY)
+            MapMinY = lyr->GetTileServiceLayer()->GetMinLat();
+          if (lyr->GetTileServiceLayer()->GetMaxLong() > MapMaxX)
+            MapMaxX = lyr->GetTileServiceLayer()->GetMaxLong();
+          if (lyr->GetTileServiceLayer()->GetMaxLat() > MapMaxY)
+            MapMaxY = lyr->GetTileServiceLayer()->GetMaxLat();
+      } else
+        {
+          // Ordinary Layer
+          if (lyr->IsSwapXY() == true)
+            {
+              if (lyr->GetMinX() < MapMinY)
+                MapMinY = lyr->GetMinX();
+              if (lyr->GetMaxX() > MapMaxY)
+                MapMaxY = lyr->GetMaxX();
+              if (lyr->GetMinY() < MapMinX)
+                MapMinX = lyr->GetMinY();
+              if (lyr->GetMaxY() > MapMaxX)
+                MapMaxX = lyr->GetMaxY();
+          } else
+            {
+              if (lyr->GetMinX() < MapMinX)
+                MapMinX = lyr->GetMinX();
+              if (lyr->GetMaxX() > MapMaxX)
+                MapMaxX = lyr->GetMaxX();
+              if (lyr->GetMinY() < MapMinY)
+                MapMinY = lyr->GetMinY();
+              if (lyr->GetMaxY() > MapMaxY)
+                MapMaxY = lyr->GetMaxY();
+            }
+        }
+      lyr = lyr->GetNext();
+    }
+  MapExtentX = MapMaxX - MapMinX;
+  MapExtentY = MapMaxY - MapMinY;
+  MapCX = MapMinX + (MapExtentX / 2.0);
+  MapCY = MapMinY + (MapExtentY / 2.0);
+// computig the Frame Extent
+  FrameCX = MapCX;
+  FrameCY = MapCY;
+  wxSize sz = GetClientSize();
+  FrameWidth = sz.GetWidth();
+  FrameHeight = sz.GetHeight();
+// computing the current PixelRatio
+  double x_ratio = MapExtentX / (double) (FrameWidth);
+  double y_ratio = MapExtentY / (double) (FrameHeight);
+  if (MapExtentX / x_ratio <= FrameWidth && MapExtentY / x_ratio <= FrameHeight)
+    PixelRatio = x_ratio;
+  else if (MapExtentX / y_ratio <= FrameWidth
+           && MapExtentY / y_ratio <= FrameHeight)
+    PixelRatio = y_ratio;
+  else
+    {
+      if (x_ratio > y_ratio)
+        PixelRatio = x_ratio;
+      else
+        PixelRatio = y_ratio;
+    }
+}
+
+bool MyMapView::CanIdentify()
+{
+//
+// test if Identify could be currently be enabled
+//
+  bool queryable = false;
+  bool xml_gml = false;
+  if (ActiveLayer == NULL)
+    return false;
+  if (ActiveLayer->IsVisible() == 0)
+    return false;
+  if (ActiveLayer->IsQueryable() == true)
+    queryable = true;
+  if (ActiveLayer->HasQueryableChildren() == true)
+    queryable = true;
+  if (queryable == false)
+    return false;
+  if (ActiveLayer->GetWmsService()->GetGmlMimeType() != NULL)
+    xml_gml = true;
+  if (ActiveLayer->GetWmsService()->GetXmlMimeType() != NULL)
+    xml_gml = true;
+  if (xml_gml == false)
+    return false;
+  return true;
+}
+
+void MyMapView::GetTileOrigin(double min_x, double min_y, double start_x,
+                              double start_y, double tile_width,
+                              double tile_height, double *base_x,
+                              double *base_y)
+{
+//
+// computing the Tile Origin
+//
+  double x = min_x;
+  double y = min_y;
+  if (start_x > min_x)
+    {
+      while (x + tile_width < start_x)
+        x += tile_width;
+  } else
+    {
+      while (x - tile_width > start_x)
+        x -= tile_width;
+    }
+  if (start_y > min_y)
+    {
+      while (y + tile_height < start_y)
+        y += tile_height;
+  } else
+    {
+      while (y - tile_height > start_y)
+        y -= tile_height;
+    }
+  *base_x = x;
+  *base_y = y;
+}
+
+#ifdef _WIN32
+DWORD WINAPI DoMapDownloadTilesThread(void *arg)
+#else
+void *DoMapDownloadTilesThread(void *arg)
+#endif
+{
+//
+// threaded function: downloading WMS tiles
+//
+  MyMapView *MapView = (MyMapView *) arg;
+  WmsLayer *layer = MapView->GetLastLayer();
+  while (layer != NULL)
+    {
+      if (MapView->IsPendingWmsAbort() == true)
+        break;
+      if (layer->GetTileServiceLayer() != NULL)
+        MapView->Consider(layer->GetTileServiceLayer()->GetName());
+      else
+        MapView->Consider(layer->GetName());
+      WmsGetMapRequest *req = MapView->GetFirstRequest();
+      while (req != NULL)
+        {
+          // attempting first to display already cached tiles
+          if (MapView->IsPendingWmsAbort() == true)
+            break;
+          if (req->IsTileService() == true
+              && layer->GetTileServiceLayer() != NULL)
+            {
+              if (MapView->IsPendingWmsAbort() == true)
+                break;
+              if (strcmp
+                  (layer->GetTileServiceLayer()->GetName(),
+                   req->GetLayerName()) == 0)
+                req->ExecuteMap(1);
+            }
+          if (req->IsTileService() == false
+              && layer->GetTileServiceLayer() == NULL)
+            {
+              if (MapView->IsPendingWmsAbort() == true)
+                break;
+              if (strcmp(layer->GetName(), req->GetLayerName()) == 0)
+                req->ExecuteMap(1);
+            }
+          req = req->GetNext();
+        }
+      for (int retry_count = 0; retry_count < 5; retry_count++)
+        {
+          bool retry = false;
+          req = MapView->GetFirstRequest();
+          while (req != NULL)
+            {
+              // downloading any not already cached tile
+              bool ret = true;
+              if (MapView->IsPendingWmsAbort() == true)
+                break;
+              if (req->IsTileService() == true
+                  && layer->GetTileServiceLayer() != NULL)
+                {
+                  if (MapView->IsPendingWmsAbort() == true)
+                    break;
+                  if (strcmp
+                      (layer->GetTileServiceLayer()->GetName(),
+                       req->GetLayerName()) == 0
+                      && req->IsImageReady() == false)
+                    ret = req->ExecuteMap(0);
+                }
+              if (req->IsTileService() == false
+                  && layer->GetTileServiceLayer() == NULL)
+                {
+                  if (MapView->IsPendingWmsAbort() == true)
+                    break;
+                  if (strcmp(layer->GetName(), req->GetLayerName()) == 0
+                      && req->IsImageReady() == false)
+                    ret = req->ExecuteMap(0);
+                }
+              if (ret == false)
+                retry = true;
+              req = req->GetNext();
+            }
+          if (retry == false)
+            break;
+        }
+      layer = layer->GetPrev();
+    }
+  wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED,
+                       ID_MAP_WMS_THREAD_FINISHED);
+  MapView->GetEventHandler()->AddPendingEvent(event);
+#ifdef _WIN32
+  return 0;
+#else
+  pthread_exit(NULL);
+#endif
+}
+
+double MyMapView::GetWmsBestResolution(double pixel_ratio)
+{
+// adjusting the current scale so to match a Fixed Scale
+  double best_resolution = *(WmsFixedScales + 0);
+  double max_resolution = *(WmsFixedScales + (WmsFixedScalesCount - 1));
+  if (pixel_ratio <= max_resolution)
+    return max_resolution;
+  for (int i = 1; i < WmsFixedScalesCount; i++)
+    {
+      if (pixel_ratio > *(WmsFixedScales + i))
+        {
+          best_resolution = *(WmsFixedScales + i - 1);
+          break;
+        }
+    }
+  return best_resolution;
+}
+
+void MyMapView::PrepareMap()
+{
+//
+// draws the MapBitmap
+//
+  if (PrintInProgress == true)
+    {
+      PendingRefresh = true;
+      return;
+    }
+  if (DownloadInProgress == true)
+    {
+      PendingRefresh = true;
+      return;
+    }
+  PendingRefresh = false;
+  if (FirstLayer == NULL)
+    ValidMap = false;
+  if (!ValidMap)
+    {
+      // displaying an empty map
+      Invalidate();
+      Refresh();
+      return;
+    }
+  MainFrame->UpdateTools();
+  wxMemoryDC *dc = NULL;
+  dc = new wxMemoryDC(MapBitmap);
+  if (dc->IsOk() == false)
+    {
+      delete dc;
+      return;
+    }
+
+  wxSize sz = GetClientSize();
+  FrameWidth = sz.GetWidth();
+  FrameHeight = sz.GetHeight();
+  BuildFixedScales();
+  if (IsWmsFixedScale() == true)
+    {
+      // adjusting the current scale so to match a Fixed Scale
+      PixelRatio = GetWmsBestResolution(PixelRatio);
+    }
+
+  dc->SetBrush(wxBrush(wxColour(255, 255, 255), wxSOLID));
+  dc->SetPen(wxPen(wxColour(255, 255, 255), wxSOLID));
+// initializing the bitmap background
+  dc->DrawRectangle(0, 0, FrameWidth, FrameHeight);
+
+// computing the current Frame
+  FrameMinX = FrameCX - ((FrameWidth / 2.0) * PixelRatio);
+  FrameMaxX = FrameCX + ((FrameWidth / 2.0) * PixelRatio);
+  FrameMinY = FrameCY - ((FrameHeight / 2.0) * PixelRatio);
+  FrameMaxY = FrameCY + ((FrameHeight / 2.0) * PixelRatio);
+  FrameExtentX = FrameMaxX - FrameMinX;
+  FrameExtentY = FrameMaxY - FrameMinY;
+
+  if (MainFrame->IsGeographicCRS(GetMapCRS()) == true)
+    {
+      // LongLat: computing the Scale [WMS standard pixel always corresponds to 0.28 mm]
+      double extent = FrameExtentX * 111319.4907932455;
+      CurrentScale = extent / (FrameWidth * 0.00028);
+  } else
+    {
+      // planar: computing the Scale [WMS standard pixel always corresponds to 0.28 mm]
+      CurrentScale = FrameExtentX / (FrameWidth * 0.00028);
+    }
+  MainFrame->UpdateMapScale();
+
+  dc->SetBrush(wxNullBrush);
+  dc->SetPen(wxNullPen);
+  delete dc;
+  ResetScreenBitmap();
+
+  ::wxBeginBusyCursor();
+  if (Proxy != NULL)
+    delete[]Proxy;
+  Proxy = NULL;
+  if (MainFrame->GetHttpProxy().Len() > 0)
+    {
+      Proxy = new char[MainFrame->GetHttpProxy().Len() + 1];
+      strcpy(Proxy, MainFrame->GetHttpProxy().ToUTF8());
+    }
+  ResetGetMapRequests();
+
+  WmsLayer *layer = LastLayer;
+  while (layer != NULL)
+    {
+      if (layer->IsVisible()
+          && layer->IsCovered(FrameMinX, FrameMinY, FrameMaxX, FrameMaxY))
+        {
+          double baseX;
+          double baseY;
+          double tileW = FrameMaxX - FrameMinX;
+          double tileH = FrameMaxY - FrameMinY;
+          int tile_width = FrameWidth;
+          int tile_height = FrameHeight;
+          WmsTilePattern *tilepattern = NULL;
+          bool tileservice_layer = false;
+          if (layer->GetTileServiceLayer() != NULL)
+            {
+              // TileService layer
+              WmsTileServiceLayer *pTL = layer->GetTileServiceLayer();
+              tileservice_layer = true;
+              if (pTL->GetTileParams(PixelRatio, FrameMinX,
+                                     FrameMinY,
+                                     &tile_width,
+                                     &tile_height, &tileW,
+                                     &tileH, &baseX,
+                                     &baseY, &tilepattern) == false)
+                {
+                  layer = layer->GetPrev();
+                  continue;
+                }
+          } else
+            {
+              // ordinary WMS layer
+              if (layer->IsTiled())
+                {
+                  // tiled layer
+                  tileW = (double) (layer->GetTileWidth()) * PixelRatio;
+                  tileH = (double) (layer->GetTileHeight()) * PixelRatio;
+                  tile_width = layer->GetTileWidth();
+                  tile_height = layer->GetTileHeight();
+                  if (layer->IsSwapXY())
+                    GetTileOrigin(layer->GetMinY(), layer->GetMinX(), FrameMinX,
+                                  FrameMinY, tileW, tileH, &baseX, &baseY);
+                  else
+                    GetTileOrigin(layer->GetMinX(), layer->GetMinY(), FrameMinX,
+                                  FrameMinY, tileW, tileH, &baseX, &baseY);
+              } else
+                {
+                  // untiled layer
+                  tileW = (double) FrameWidth *PixelRatio;
+                  tileH = (double) FrameHeight *PixelRatio;
+                  tile_width = FrameWidth;
+                  tile_height = FrameHeight;
+                  baseX = FrameMinX;
+                  baseY = FrameMinY;
+                }
+            }
+          int image_x = (baseX - FrameMinX) / PixelRatio;
+          int image_y = FrameHeight + ((FrameMinY - baseY) / PixelRatio);
+          WmsTileSet *tileSet;
+          tileSet =
+            new WmsTileSet(FrameMinX, FrameMinY, FrameMaxX, FrameMaxY,
+                           baseX, baseY, tileW, tileH, image_x, image_y,
+                           FrameWidth, FrameHeight, tile_width, tile_height);
+
+          // preparing the Tile Requests
+          double pos_y = baseY;
+          int row_no = 0;
+          double lim_x = FrameMaxX;
+          double lim_y = FrameMaxY;
+          layer->MaxLimits(&lim_x, &lim_y);
+          while (pos_y < lim_y)
+            {
+              // looping on tile-rows (bottom-up)
+              double pos_x = baseX;
+              int col_no = 0;
+              while (pos_x < lim_x)
+                {
+                  // looping on tile-cols (left-right)
+                  int pxW = (int) ((lim_x - pos_x) / PixelRatio);
+                  int pxH = (int) ((lim_y - pos_y) / PixelRatio);
+                  if (pxW < 1 || pxH < 1)
+                    {
+                      // avoiding to request useless/invisible tiles
+                      ;
+                  } else
+                    tileSet->AddTile(pos_x, pos_y, row_no, col_no);
+                  pos_x += tileW;
+                  col_no++;
+                }
+              pos_y += tileH;
+              row_no++;
+            }
+
+          WmsTileRequest *tile = tileSet->GetFirst();
+          while (tile != NULL)
+            {
+              // looping on tile requests   
+              if (tileservice_layer == true)
+                {
+                  WmsTileServiceLayer *pTL = layer->GetTileServiceLayer();
+                  AddGetMapRequest(tile->GetImageX(), tile->GetImageY(),
+                                   layer->GetWmsService()->GetURL_GetMap_Get(),
+                                   pTL->GetName(), layer->IsSwapXY(),
+                                   tile->GetMinX(), tile->GetMinY(),
+                                   tile->GetMaxX(), tile->GetMaxY(),
+                                   tileSet->GetTileWidth(),
+                                   tileSet->GetTileHeight(), tilepattern);
+              } else
+                {
+                  AddGetMapRequest(tile->GetImageX(), tile->GetImageY(),
+                                   layer->GetWmsService()->GetURL_GetMap_Get(),
+                                   layer->GetVersion(), layer->GetName(),
+                                   layer->GetCRS(), layer->IsSwapXY(),
+                                   tile->GetMinX(), tile->GetMinY(),
+                                   tile->GetMaxX(), tile->GetMaxY(),
+                                   tileSet->GetTileWidth(),
+                                   tileSet->GetTileHeight(),
+                                   layer->GetStyleName(), layer->GetFormat(),
+                                   layer->IsOpaque());
+                }
+              tile = tile->GetNext();
+            }
+          delete tileSet;
+        }
+      layer = layer->GetPrev();
+    }
+
+// creating the Progress control
+  if (ProgressControl != NULL)
+    {
+      delete ProgressControl;
+      ProgressControl = NULL;
+    }
+  wxRect rect;
+  if (MainFrame->GetProgressRect(rect) == true)
+    {
+      wxPoint pt = wxPoint(rect.GetX(), rect.GetY());
+      wxSize sz = wxSize(rect.GetWidth(), rect.GetHeight());
+      ProgressControl =
+        new wxGauge(MainFrame->GetStatusBar(), wxID_ANY, CountGetMapRequests(),
+                    pt, sz);
+    }
+  UpdateTimer = new wxTimer(this, ID_UPDATE_TIMER);
+  UpdateTimer->Start(125, wxTIMER_ONE_SHOT);
+  DownloadInProgress = true;
+  PendingRefresh = false;
+  PendingOnSize = false;
+  PendingWmsAbort = false;
+  MainFrame->UpdateWmsAbortTool(true);
+
+#ifdef _WIN32
+  HANDLE thread_handle;
+  DWORD dwThreadId;
+  thread_handle =
+    CreateThread(NULL, 0, DoMapDownloadTilesThread, this, 0, &dwThreadId);
+  SetThreadPriority(thread_handle, THREAD_PRIORITY_IDLE);
+#else
+  pthread_t thread_id;
+  int ok_prior = 0;
+  int policy;
+  int min_prio;
+  pthread_attr_t attr;
+  struct sched_param sp;
+  pthread_attr_init(&attr);
+  if (pthread_attr_setschedpolicy(&attr, SCHED_RR) == 0)
+    {
+      // attempting to set the lowest priority  
+      if (pthread_attr_getschedpolicy(&attr, &policy) == 0)
+        {
+          min_prio = sched_get_priority_min(policy);
+          sp.sched_priority = min_prio;
+          if (pthread_attr_setschedparam(&attr, &sp) == 0)
+            {
+              // ok, setting the lowest priority  
+              ok_prior = 1;
+              pthread_create(&thread_id, &attr, DoMapDownloadTilesThread, this);
+            }
+        }
+    }
+  if (!ok_prior)
+    {
+      // failure: using standard priority
+      pthread_create(&thread_id, NULL, DoMapDownloadTilesThread, this);
+    }
+#endif
+}
+
+void MyMapView::OnMapWmsThreadFinished(wxCommandEvent & WXUNUSED(event))
+{
+//
+// the WMS download thread (Map refresh) signals termination
+//
+  if (UpdateTimer != NULL)
+    {
+      UpdateTimer->Stop();
+      delete UpdateTimer;
+    }
+  UpdateTimer = NULL;
+  Consider();
+  UpdatePendingTiles();
+  ResetGetMapRequests();
+  ::wxEndBusyCursor();
+  if (ProgressControl != NULL)
+    delete ProgressControl;
+  ProgressControl = NULL;
+  ResetScreenBitmap();
+  DownloadInProgress = false;
+  if (PendingOnSize == true || PendingRefresh == true)
+    PrepareMap();
+  PendingOnSize = false;
+  PendingWmsAbort = false;
+  MainFrame->UpdateWmsAbortTool(false);
+}
+
+void MyMapView::OnPdfWmsThreadFinished(wxCommandEvent & WXUNUSED(event))
+{
+//
+// the WMS download thread (PDF Printer) signals termination
+//
+  if (PrintTimer != NULL)
+    {
+      PrintTimer->Stop();
+      delete PrintTimer;
+    }
+  PrintTimer = NULL;
+  if (Pdf != NULL)
+    {
+      Pdf->Consider();
+      Pdf->UpdatePendingTiles();
+      delete Pdf;
+    }
+  Pdf = NULL;
+  PrintInProgress = false;
+  PendingWmsAbort = false;
+  ::wxEndBusyCursor();
+  MainFrame->UpdateWmsAbortTool(false);
+  MainFrame->UpdatePrinterTool(true);
+}
+
+void MyMapView::OnTiffWmsThreadFinished(wxCommandEvent & WXUNUSED(event))
+{
+//
+// the WMS download thread (TIFF Writer) signals termination
+//
+  if (PrintTimer != NULL)
+    {
+      PrintTimer->Stop();
+      delete PrintTimer;
+    }
+  PrintTimer = NULL;
+  if (Tiff != NULL)
+    {
+      Tiff->Consider();
+      Tiff->UpdatePendingTiles();
+      if (Tiff->IsMonochrome() == true)
+        {
+          TiffMonochromeDialog dlg;
+          dlg.Create(this);
+          if (dlg.ShowModal() == wxID_OK)
+            {
+              if (dlg.IsMonochrome() == true)
+                {
+                  Tiff->SetColorSpace(RL2_PIXEL_MONOCHROME);
+                  Tiff->SetCompression(dlg.GetCompression());
+                }
+              goto export_img;
+          } else
+            goto end;
+        }
+      if (Tiff->IsGrayscale() == true)
+        {
+          TiffGrayscaleDialog dlg;
+          dlg.Create(this, Tiff->GetCompression());
+          if (dlg.ShowModal() == wxID_OK)
+            {
+              if (dlg.IsGrayscale() == true)
+                {
+                  Tiff->SetColorSpace(RL2_PIXEL_GRAYSCALE);
+                  Tiff->SetCompression(dlg.GetCompression());
+                }
+              goto export_img;
+          } else
+            goto end;
+        }
+      if (Tiff->IsPalette() == true)
+        {
+          TiffPaletteDialog dlg;
+          dlg.Create(this, Tiff->GetCompression());
+          if (dlg.ShowModal() == wxID_OK)
+            {
+              if (dlg.IsPalette() == true)
+                {
+                  Tiff->SetColorSpace(RL2_PIXEL_PALETTE);
+                  Tiff->SetCompression(dlg.GetCompression());
+                }
+              goto export_img;
+          } else
+            goto end;
+        }
+
+    export_img:
+      Tiff->ExportImage();
+    end:
+      delete Tiff;
+    }
+  Tiff = NULL;
+  PrintInProgress = false;
+  PendingWmsAbort = false;
+  ::wxEndBusyCursor();
+  MainFrame->UpdateWmsAbortTool(false);
+  MainFrame->UpdatePrinterTool(true);
+}
+
+void MyMapView::SetPrintInProgress(PdfPrinter * pdf)
+{
+//
+// stating some Printing process
+//
+  Pdf = pdf;
+  PrintTimer = new wxTimer(this, ID_PRINT_TIMER);
+  PrintTimer->Start(125, wxTIMER_ONE_SHOT);
+  PrintInProgress = true;
+  PendingWmsAbort = false;
+  MainFrame->UpdateWmsAbortTool(false);
+}
+
+void MyMapView::SetPrintInProgress(TiffWriter * tiff)
+{
+//
+// stating some Printing process
+//
+  Tiff = tiff;
+  PrintTimer = new wxTimer(this, ID_PRINT_TIMER);
+  PrintTimer->Start(125, wxTIMER_ONE_SHOT);
+  PrintInProgress = true;
+  PendingWmsAbort = false;
+  MainFrame->UpdateWmsAbortTool(false);
+}
+
+void MyMapView::UpdatePendingTiles()
+{
+// updating any available tile on the screen
+  int count = 0;
+  WmsLayer *layer = LastLayer;
+  while (layer != NULL)
+    {
+      WmsGetMapRequest *req = FirstRequest;
+      while (req != NULL)
+        {
+          if (req->ToBeIgnored() == true)
+            {
+              req = req->GetNext();
+              continue;
+            }
+          bool skip = true;
+          if (req->IsTileService() == true
+              && layer->GetTileServiceLayer() != NULL)
+            {
+              if (strcmp
+                  (layer->GetTileServiceLayer()->GetName(),
+                   req->GetLayerName()) == 0)
+                skip = false;
+            }
+          if (req->IsTileService() == false
+              && layer->GetTileServiceLayer() == NULL)
+            {
+              if (strcmp(layer->GetName(), req->GetLayerName()) == 0)
+                skip = false;
+            }
+          if (skip == true)
+            {
+              req = req->GetNext();
+              continue;
+            }
+          if (req->IsImageReady() == true && req->IsImageDone() == false
+              && req->GetImage().IsOk() == true)
+            {
+              UpdateTile(req->GetImage(), req->GetPosX(), req->GetPosY(),
+                         req->GetWidth(), req->GetHeight());
+              req->Done();
+            }
+          if (req->IsImageDone() == true)
+            count++;
+          req = req->GetNext();
+        }
+      layer = layer->GetPrev();
+    }
+// updating the Progress control
+  if (ProgressControl != NULL)
+    {
+      ProgressControl->Show();
+      if (count == 0)
+        ProgressControl->Pulse();
+      else
+        ProgressControl->SetValue(count);
+    }
+}
+
+void MyMapView::UpdateTile(wxImage & Image, int pos_x, int pos_y, int width,
+                           int height)
+{
+// drawing some WMS tile
+  if (PendingOnSize == true)
+    return;
+  wxMemoryDC *dc = new wxMemoryDC(MapBitmap);
+  wxBitmap bmp = wxBitmap(Image);
+  wxMemoryDC *memDC = new wxMemoryDC(bmp);
+  dc->Blit(pos_x, pos_y, width, height, memDC, 0, 0, wxCOPY, true);
+  delete dc;
+  ResetScreenBitmap();
+}
+
+void MyMapView::ResetScreenBitmap()
+{
+// copying the MapBitmap into the ScreenBitmap
+  wxMemoryDC *screenDc = new wxMemoryDC(ScreenBitmap);
+  wxGraphicsContext *gr = wxGraphicsContext::Create(*screenDc);
+  gr->DrawBitmap(MapBitmap, 0, 0, BitmapWidth, BitmapHeight);
+  if (ImageMarkerOdd.IsOk() == true && DynamicOddEven == true)
+    gr->DrawBitmap(ImageMarkerOdd, 0, 0, ImageMarkerOdd.GetWidth(),
+                   ImageMarkerOdd.GetHeight());
+  if (ImageMarkerEven.IsOk() == true && DynamicOddEven == false)
+    gr->DrawBitmap(ImageMarkerEven, 0, 0, ImageMarkerEven.GetWidth(),
+                   ImageMarkerEven.GetHeight());
+  delete gr;
+  delete screenDc;
+  Refresh();
+  Update();
+}
+
+void MyMapView::DoIdentify(int mouse_x, int mouse_y)
+{
+//
+// Identify (Single Layer)
+//
+  char *err_msg;
+  WmsLayer *layer = ActiveLayer;
+  if (layer == NULL)
+    return;
+  char *proxy = NULL;
+  if (MainFrame->GetHttpProxy().Len() > 0)
+    {
+      proxy = new char[MainFrame->GetHttpProxy().Len() + 1];
+      strcpy(proxy, MainFrame->GetHttpProxy().ToUTF8());
+    }
+  const char *xmlMimeType = layer->GetWmsService()->GetGmlMimeType();
+  if (xmlMimeType == NULL)
+    xmlMimeType = layer->GetWmsService()->GetXmlMimeType();
+  ::wxBeginBusyCursor();
+  rl2WmsFeatureCollectionPtr coll =
+    do_wms_GetFeatureInfo_get(layer->
+                              GetWmsService()->GetURL_GetFeatureInfo_Get(),
+                              proxy,
+                              layer->GetVersion(),
+                              xmlMimeType,
+                              layer->GetName(),
+                              layer->GetCRS(), layer->IsSwapXY(), FrameMinX,
+                              FrameMinY, FrameMaxX,
+                              FrameMaxY, FrameWidth, FrameHeight, mouse_x,
+                              mouse_y, &err_msg);
+  ::wxEndBusyCursor();
+  if (proxy != NULL)
+    delete[]proxy;
+
+  if (coll != NULL)
+    {
+      // showing the GetFeatureInfo results
+      double mx = FrameMinX + ((double) mouse_x * PixelRatio);
+      double my = FrameMaxY - ((double) mouse_y * PixelRatio);
+      wms_feature_collection_parse_geometries(coll,
+                                              GetSridFromCRS(layer->GetCRS()),
+                                              mx, my, MainFrame->GetSQLite());
+      wxString lyrname = wxString::FromUTF8(layer->GetTitle());
+      CleanHtml(layer->GetTitle(), lyrname);
+      wxString html_table;
+      HtmlFromGetFeatureInfo(coll, 0, lyrname, html_table);
+      wxString html = wxT("<html><body>") + html_table + wxT("</body></html>");
+      GeometryList *list = new GeometryList();
+      PopulateGeometryList(list, 0, coll);
+      if (IdentifyPanel == NULL)
+        IdentifyPanel =
+          new WmsIdentifyPanel(this, html, coll, list, mouse_x, mouse_y);
+      else
+        IdentifyPanel->Initialize(html, coll, list, mouse_x, mouse_y);
+      IdentifyPanel->Show();
+    }
+}
+
+void MyMapView::DoIdentifyMultiLayer(int mouse_x, int mouse_y)
+{
+//
+// Identify (Multiple Layers)
+//
+  bool ok = false;
+  char *err_msg;
+  WmsLayer *layer = ActiveLayer;
+  GeometryList *list = NULL;
+  if (layer == NULL)
+    return;
+  char *proxy = NULL;
+  rl2WmsFeatureCollectionPtr coll = NULL;
+  if (MainFrame->GetHttpProxy().Len() > 0)
+    {
+      proxy = new char[MainFrame->GetHttpProxy().Len() + 1];
+      strcpy(proxy, MainFrame->GetHttpProxy().ToUTF8());
+    }
+  list = new GeometryList();
+
+  wxString html = wxT("<html><body>");
+  ::wxBeginBusyCursor();
+  WmsQueryableChildLayer *child = ActiveLayer->GetFirstChild();
+  int idx = 0;
+  while (child != NULL)
+    {
+      // querying children layers one at each time
+      const char *xmlMimeType = layer->GetWmsService()->GetGmlMimeType();
+      if (xmlMimeType == NULL)
+        xmlMimeType = layer->GetWmsService()->GetXmlMimeType();
+      coll =
+        do_wms_GetFeatureInfo_get(layer->
+                                  GetWmsService()->GetURL_GetFeatureInfo_Get(),
+                                  proxy, layer->GetVersion(), xmlMimeType,
+                                  child->GetName(), layer->GetCRS(),
+                                  layer->IsSwapXY(), FrameMinX, FrameMinY,
+                                  FrameMaxX, FrameMaxY, FrameWidth, FrameHeight,
+                                  mouse_x, mouse_y, &err_msg);
+      if (coll != NULL)
+        {
+          // showing the GetFeatureInfo results
+          double mx = FrameMinX + ((double) mouse_x * PixelRatio);
+          double my = FrameMaxY - ((double) mouse_y * PixelRatio);
+          wms_feature_collection_parse_geometries(coll,
+                                                  GetSridFromCRS(layer->GetCRS
+                                                                 ()), mx, my,
+                                                  MainFrame->GetSQLite());
+          wxString lyrname;
+          CleanHtml(child->GetTitle(), lyrname);
+          wxString html_table;
+          HtmlFromGetFeatureInfo(coll, idx, lyrname, html_table);
+          html += html_table + wxT("<br>");
+          PopulateGeometryList(list, idx, coll);
+          ok = true;
+        }
+      idx++;
+      child = child->GetNext();
+    }
+  ::wxEndBusyCursor();
+  html += wxT("</body></html>");
+  if (proxy != NULL)
+    delete[]proxy;
+  if (ok == false)
+    {
+      if (list != NULL)
+        delete list;
+      if (coll != NULL)
+        destroy_wms_feature_collection(coll);
+      return;
+    }
+
+  if (IdentifyPanel == NULL)
+    IdentifyPanel =
+      new WmsIdentifyPanel(this, html, coll, list, mouse_x, mouse_y);
+  else
+    IdentifyPanel->Initialize(html, coll, list, mouse_x, mouse_y);
+}
+
+void MyMapView::CleanHtml(const char *dirty, wxString & clean)
+{
+//
+// ensuring that every HTML string should be well formatted
+//
+  clean = wxT("");
+  const char *p = dirty;
+  while (*p != '\0')
+    {
+      if (*p == ' ')
+        clean += wxT(" ");
+      else if (*p == '<')
+        clean += wxT("<");
+      else if (*p == '>')
+        clean += wxT(">");
+      else if (*p == '&')
+        clean += wxT("&");
+      else if (*p == '"')
+        clean += wxT(""");
+      else
+        {
+          char buf[16];
+          sprintf(buf, "%c", *p);
+          clean += wxString::FromUTF8(buf);
+        }
+      p++;
+    }
+}
+
+void MyMapView::PopulateGeometryList(GeometryList * list, int layer_id,
+                                     rl2WmsFeatureCollectionPtr coll)
+{
+//
+// creating a Geometry List
+//
+  for (int row = 0; row < get_wms_feature_members_count(coll); row++)
+    {
+      rl2WmsFeatureMemberPtr feature = get_wms_feature_member(coll, row);
+      for (int col = 0; col < get_wms_feature_attributes_count(feature); col++)
+        {
+          gaiaGeomCollPtr geom =
+            get_wms_feature_attribute_geometry(feature, col);
+          if (geom != NULL)
+            list->Add(layer_id, row, col, geom);
+        }
+    }
+}
+
+void MyMapView::HtmlFromGetFeatureInfo(rl2WmsFeatureCollectionPtr coll, int idx,
+                                       wxString & layer_name, wxString & html)
+{
+//
+// building an HTML page corresponding to GetFeatureInfo results
+//
+  char href[128];
+  html = wxT("Layer: <b>") + layer_name + wxT("</b><br><table border=\"\1\">");
+  for (int row = 0; row < get_wms_feature_members_count(coll); row++)
+    {
+      rl2WmsFeatureMemberPtr feature = get_wms_feature_member(coll, row);
+      if (row == 0)
+        {
+          // titles
+          html += wxT("<tr>");
+          for (int col = 0; col < get_wms_feature_attributes_count(feature);
+               col++)
+            {
+              html += wxT("<th bgcolor=\"#b0b0b0\">");
+              wxString name;
+              CleanHtml(get_wms_feature_attribute_name(feature, col), name);
+              html += name;
+              html += wxT("</th>");
+            }
+          html += wxT("</tr>");
+        }
+      html += wxT("<tr>");
+      if ((row % 2) == 0)
+        {
+          // even rows
+          for (int col = 0; col < get_wms_feature_attributes_count(feature);
+               col++)
+            {
+              html += wxT("<td>");
+              if (get_wms_feature_attribute_geometry(feature, col) != NULL)
+                {
+                  sprintf(href, "<a href=\"%d_%d_%d", idx, row, col);
+                  html += wxString::FromUTF8(href) + wxT("\">GEOMETRY</a>");
+              } else
+                {
+                  wxString value;
+                  CleanHtml(get_wms_feature_attribute_value(feature, col),
+                            value);
+                  html += value;
+                }
+              html += wxT("</td>");
+            }
+      } else
+        {
+          // odd rows
+          for (int col = 0; col < get_wms_feature_attributes_count(feature);
+               col++)
+            {
+              html += wxT("<td bgcolor=\"#d0d0d0\">");
+              if (get_wms_feature_attribute_geometry(feature, col) != NULL)
+                {
+                  sprintf(href, "<a href=\"%d_%d_%d", idx, row, col);
+                  html += wxString::FromUTF8(href) + wxT("\">GEOMETRY</a>");
+              } else
+                {
+                  wxString value;
+                  CleanHtml(get_wms_feature_attribute_value(feature, col),
+                            value);
+                  html += value;
+                }
+              html += wxT("</td>");
+            }
+        }
+      html += wxT("</tr>");
+    }
+  html += wxT("</table><br>");
+}
+
+WmsService *MyMapView::InsertWmsService(const char *version, const char *name,
+                                        const char *title, const char *abstract,
+                                        const char *tile_service_name,
+                                        const char *tile_service_title,
+                                        const char *tile_service_abstract,
+                                        const char *url_GetMap_get,
+                                        const char *url_GetMap_post,
+                                        const char *url_GetTileService_get,
+                                        const char *url_GetTileService_post,
+                                        const char *url_GetFeatureInfo_get,
+                                        const char *url_GetFeatureInfo_post,
+                                        const char *gml_mime_type,
+                                        const char *xml_mime_type,
+                                        const char *contact_person,
+                                        const char *contact_organization,
+                                        const char *contact_position,
+                                        const char *postal_address,
+                                        const char *city,
+                                        const char *state_province,
+                                        const char *post_code,
+                                        const char *country,
+                                        const char *voice_telephone,
+                                        const char *fax_telephone,
+                                        const char *email_address,
+                                        const char *fees,
+                                        const char *access_constraints,
+                                        int layer_limit, int max_width,
+                                        int max_height)
+{
+//
+//  adding a new WMS Service (if not already defined)
+//
+  WmsService *service =
+    new WmsService(version, name, title, abstract, tile_service_name,
+                   tile_service_title, tile_service_abstract, url_GetMap_get,
+                   url_GetMap_post, url_GetTileService_get,
+                   url_GetTileService_post,
+                   url_GetFeatureInfo_get,
+                   url_GetFeatureInfo_post, gml_mime_type, xml_mime_type,
+                   contact_person,
+                   contact_organization, contact_position, postal_address,
+                   city, state_province, post_code, country, voice_telephone,
+                   fax_telephone, email_address,
+                   fees, access_constraints, layer_limit, max_width,
+                   max_height);
+  WmsService *service2 = FindAlreadyDefined(service);
+  if (service2 != NULL)
+    {
+      delete service;
+      return service2;
+    }
+  if (FirstService == NULL)
+    FirstService = service;
+  service->SetPrev(LastService);
+  if (LastService != NULL)
+    LastService->SetNext(service);
+  LastService = service;
+  return service;
+}
+
+void MyMapView::InsertWmsLayer(WmsLayer * lyr)
+{
+//
+// adding a new WMS layer [ordinary WMS layer]
+//
+  bool already_defined;
+  bool mixed_crs;
+  bool multiple_fixed_scales;
+  CheckWmsLayer(lyr, &already_defined, &mixed_crs, &multiple_fixed_scales);
+  if (already_defined)
+    {
+      wxMessageBox(wxT
+                   ("WARNING: the same WMS Layer is already defined; rejected"),
+                   wxT("LibreWMS"), wxOK | wxICON_WARNING, this);
+      delete lyr;
+      return;
+    }
+  if (mixed_crs)
+    wxMessageBox(wxT
+                 ("WARNING: there are WMS Layers using different CRS definitions !!!"),
+                 wxT("LibreWMS"), wxOK | wxICON_WARNING, this);
+  if (multiple_fixed_scales)
+    {
+      wxMessageBox(wxT
+                   ("WARNING: there are WMS Layers requiring different zoom factors: rejected"),
+                   wxT("LibreWMS"), wxOK | wxICON_WARNING, this);
+      delete lyr;
+      return;
+    }
+  if (LastLayer == NULL)
+    LastLayer = lyr;
+  lyr->SetNext(FirstLayer);
+  if (FirstLayer != NULL)
+    FirstLayer->SetPrev(lyr);
+  FirstLayer = lyr;
+  MainFrame->GetLayerTree()->AddLayer(lyr);
+  if (CountWmsLayers() == 1)
+    {
+      // initializing the Map
+      SetFullExtent();
+    }
+  PrepareMap();
+}
+
+void MyMapView::ResetWmsLayers()
+{
+//
+// resetting the WMS Layer list
+//
+  FirstLayer = NULL;
+  LastLayer = NULL;
+}
+
+void MyMapView::ReinsertWmsLayer(WmsLayer * lyr)
+{
+//
+// reinserting yet again a WMS Layer (Tree new order)
+//
+  lyr->SetPrev(NULL);
+  lyr->SetNext(NULL);
+  if (FirstLayer == NULL)
+    FirstLayer = lyr;
+  lyr->SetPrev(LastLayer);
+  if (LastLayer != NULL)
+    LastLayer->SetNext(lyr);
+  LastLayer = lyr;
+}
+
+void MyMapView::RemoveWmsLayer(WmsLayer * layer)
+{
+//
+// removing a WMS layer
+//
+  WmsService *serv;
+  WmsService *serv_x = layer->GetWmsService();
+  if (ActiveLayer == layer)
+    ActiveLayer = NULL;
+  if (layer->GetPrev() != NULL)
+    layer->GetPrev()->SetNext(layer->GetNext());
+  if (layer->GetNext() != NULL)
+    layer->GetNext()->SetPrev(layer->GetPrev());
+  if (FirstLayer == layer)
+    FirstLayer = layer->GetNext();
+  if (LastLayer == layer)
+    LastLayer = layer->GetPrev();
+  delete layer;
+  serv = FirstService;
+  while (serv != NULL)
+    {
+      if (serv == serv_x)
+        {
+          if (serv->GetRefCount() <= 0)
+            RemoveWmsService(serv);
+          return;
+        }
+      serv = serv->GetNext();
+    }
+  BuildCRSlist();
+}
+
+void MyMapView::RemoveWmsService(WmsService * service)
+{
+//
+// removing a WMS Servuce
+//
+  if (service->GetPrev() != NULL)
+    service->GetPrev()->SetNext(service->GetNext());
+  if (service->GetNext() != NULL)
+    service->GetNext()->SetPrev(service->GetPrev());
+  if (FirstService == service)
+    FirstService = service->GetNext();
+  if (LastService == service)
+    LastService = service->GetPrev();
+  delete service;
+}
+
+WmsService *MyMapView::FindAlreadyDefined(WmsService * service)
+{
+//
+// attempting to identify an already defined WMS Service
+//
+  WmsService *service2 = FirstService;
+  while (service2 != NULL)
+    {
+      if (service2->Equals(service))
+        return service2;
+      service2 = service2->GetNext();
+    }
+  return NULL;
+}
+
+void MyMapView::CheckWmsLayer(WmsLayer * layer, bool * already_defined,
+                              bool * mixed_crs, bool * multiple_fixed_scales)
+{
+// checks a new WMS layer for consistency before adding into the list
+  *already_defined = false;
+  *mixed_crs = false;
+  *multiple_fixed_scales = false;
+  WmsLayer *lyr = FirstLayer;
+  while (lyr != NULL)
+    {
+      if (lyr->Equals(layer))
+        *already_defined = true;
+      if (strcmp(lyr->GetCRS(), layer->GetCRS()) != 0)
+        *mixed_crs = true;
+      if (lyr->GetTileServiceLayer() != NULL
+          && layer->GetTileServiceLayer() != NULL)
+        {
+          if (lyr->
+              GetTileServiceLayer()->CompareFixedScales(layer->
+                                                        GetTileServiceLayer())
+              == false)
+            *multiple_fixed_scales = true;
+        }
+      lyr = lyr->GetNext();
+    }
+}
+
+int MyMapView::CountWmsLayers()
+{
+// counting how many WMS Layers are currently set
+  int count = 0;
+  WmsLayer *lyr = FirstLayer;
+  while (lyr != NULL)
+    {
+      count++;
+      lyr = lyr->GetNext();
+    }
+  return count;
+}
+
+const char *MyMapView::GetMapCRS()
+{
+// retrieving the Map CRS
+  if (LastLayer == NULL)
+    return NULL;
+  if (LastLayer->GetTileServiceLayer() != NULL)
+    {
+      // TileService layer
+      WmsTilePattern *pP = LastLayer->GetTileServiceLayer()->GetFirst();
+      if (pP == NULL)
+        return NULL;
+      return pP->GetSRS();
+    }
+  return LastLayer->GetCRS();
+}
+
+WmsFormat::WmsFormat(const char *name)
+{
+//
+// WMS Format - constructor
+//
+  int len = strlen(name);
+  Name = new char[len + 1];
+  strcpy(Name, name);
+  Next = NULL;
+}
+
+WmsFormat::~WmsFormat()
+{
+//
+// WMS Format - destructor
+//
+  if (Name != NULL)
+    delete[]Name;
+}
+
+WmsStyle::WmsStyle(const char *name, const char *title, const char *abstract)
+{
+//
+// WMS Style - constructor
+//
+  int len = strlen(name);
+  Name = new char[len + 1];
+  strcpy(Name, name);
+  Title = NULL;
+  if (title != NULL)
+    {
+      len = strlen(title);
+      Title = new char[len + 1];
+      strcpy(Title, title);
+    }
+  Abstract = NULL;
+  if (abstract != NULL)
+    {
+      len = strlen(abstract);
+      Abstract = new char[len + 1];
+      strcpy(Abstract, abstract);
+    }
+  Next = NULL;
+}
+
+WmsStyle::~WmsStyle()
+{
+//
+// WMS Style - destructor
+//
+  if (Name != NULL)
+    delete[]Name;
+  if (Title != NULL)
+    delete[]Title;
+  if (Abstract != NULL)
+    delete[]Abstract;
+}
+
+WmsCRS::WmsCRS(const char *crs)
+{
+//
+// WMS CRS - constructor
+//
+  int len = strlen(crs);
+  CRS = new char[len + 1];
+  strcpy(CRS, crs);
+  BBox = NULL;
+  Next = NULL;
+}
+
+WmsCRS::~WmsCRS()
+{
+//
+// WMS CRS - destructor
+//
+  if (CRS != NULL)
+    delete[]CRS;
+  if (BBox != NULL)
+    delete BBox;
+}
+
+WmsService::WmsService(const char *version, const char *name, const char *title,
+                       const char *abstract, const char *tile_service_name,
+                       const char *tile_service_title,
+                       const char *tile_service_abstract,
+                       const char *url_GetMap_get, const char *url_GetMap_post,
+                       const char *url_GetTileService_get,
+                       const char *url_GetTileService_post,
+                       const char *url_GetFeatureInfo_get,
+                       const char *url_GetFeatureInfo_post,
+                       const char *gml_mime_type, const char *xml_mime_type,
+                       const char *contact_person,
+                       const char *contact_organization,
+                       const char *contact_position, const char *postal_address,
+                       const char *city, const char *state_province,
+                       const char *post_code, const char *country,
+                       const char *voice_telephone, const char *fax_telephone,
+                       const char *email_address, const char *fees,
+                       const char *access_constraints, int layer_limit,
+                       int max_width, int max_height)
+{
+//
+// WMS Service - constructor
+//
+  int len = strlen(name);
+  Name = new char[len + 1];
+  strcpy(Name, name);
+  Version = NULL;
+  if (version != NULL)
+    {
+      len = strlen(version);
+      Version = new char[len + 1];
+      strcpy(Version, version);
+    }
+  Title = NULL;
+  if (title != NULL)
+    {
+      len = strlen(title);
+      Title = new char[len + 1];
+      strcpy(Title, title);
+    }
+  Abstract = NULL;
+  if (abstract != NULL)
+    {
+      len = strlen(abstract);
+      Abstract = new char[len + 1];
+      strcpy(Abstract, abstract);
+    }
+  TileServiceName = NULL;
+  if (tile_service_name != NULL)
+    {
+      len = strlen(tile_service_name);
+      TileServiceName = new char[len + 1];
+      strcpy(TileServiceName, tile_service_name);
+    }
+  TileServiceTitle = NULL;
+  if (tile_service_title != NULL)
+    {
+      len = strlen(tile_service_title);
+      TileServiceTitle = new char[len + 1];
+      strcpy(TileServiceTitle, tile_service_title);
+    }
+  TileServiceAbstract = NULL;
+  if (tile_service_abstract != NULL)
+    {
+      len = strlen(tile_service_abstract);
+      TileServiceAbstract = new char[len + 1];
+      strcpy(TileServiceAbstract, tile_service_abstract);
+    }
+  URL_GetMap_Get = NULL;
+  if (url_GetMap_get != NULL)
+    {
+      len = strlen(url_GetMap_get);
+      URL_GetMap_Get = new char[len + 1];
+      strcpy(URL_GetMap_Get, url_GetMap_get);
+    }
+  URL_GetMap_Post = NULL;
+  if (url_GetMap_post != NULL)
+    {
+      len = strlen(url_GetMap_post);
+      URL_GetMap_Post = new char[len + 1];
+      strcpy(URL_GetMap_Post, url_GetMap_post);
+    }
+  URL_GetTileService_Get = NULL;
+  if (url_GetTileService_get != NULL)
+    {
+      len = strlen(url_GetTileService_get);
+      URL_GetTileService_Get = new char[len + 1];
+      strcpy(URL_GetTileService_Get, url_GetTileService_get);
+    }
+  URL_GetTileService_Post = NULL;
+  if (url_GetTileService_post != NULL)
+    {
+      len = strlen(url_GetTileService_post);
+      URL_GetTileService_Post = new char[len + 1];
+      strcpy(URL_GetTileService_Post, url_GetTileService_post);
+    }
+  URL_GetFeatureInfo_Get = NULL;
+  if (url_GetFeatureInfo_get != NULL)
+    {
+      len = strlen(url_GetFeatureInfo_get);
+      URL_GetFeatureInfo_Get = new char[len + 1];
+      strcpy(URL_GetFeatureInfo_Get, url_GetFeatureInfo_get);
+    }
+  GmlMimeType = NULL;
+  if (gml_mime_type != NULL)
+    {
+      len = strlen(gml_mime_type);
+      GmlMimeType = new char[len + 1];
+      strcpy(GmlMimeType, gml_mime_type);
+    }
+  XmlMimeType = NULL;
+  if (xml_mime_type != NULL)
+    {
+      len = strlen(xml_mime_type);
+      XmlMimeType = new char[len + 1];
+      strcpy(XmlMimeType, xml_mime_type);
+    }
+  URL_GetFeatureInfo_Post = NULL;
+  if (url_GetFeatureInfo_post != NULL)
+    {
+      len = strlen(url_GetFeatureInfo_post);
+      URL_GetFeatureInfo_Post = new char[len + 1];
+      strcpy(URL_GetFeatureInfo_Post, url_GetFeatureInfo_post);
+    }
+  ContactPerson = NULL;
+  if (contact_person != NULL)
+    {
+      len = strlen(contact_person);
+      ContactPerson = new char[len + 1];
+      strcpy(ContactPerson, contact_person);
+    }
+  ContactOrganization = NULL;
+  if (contact_organization != NULL)
+    {
+      len = strlen(contact_organization);
+      ContactOrganization = new char[len + 1];
+      strcpy(ContactOrganization, contact_organization);
+    }
+  ContactPosition = NULL;
+  if (contact_position != NULL)
+    {
+      len = strlen(contact_position);
+      ContactPosition = new char[len + 1];
+      strcpy(ContactPosition, contact_position);
+    }
+  PostalAddress = NULL;
+  if (postal_address != NULL)
+    {
+      len = strlen(postal_address);
+      PostalAddress = new char[len + 1];
+      strcpy(PostalAddress, postal_address);
+    }
+  City = NULL;
+  if (city != NULL)
+    {
+      len = strlen(city);
+      City = new char[len + 1];
+      strcpy(City, city);
+    }
+  StateProvince = NULL;
+  if (state_province != NULL)
+    {
+      len = strlen(state_province);
+      StateProvince = new char[len + 1];
+      strcpy(StateProvince, state_province);
+    }
+  PostCode = NULL;
+  if (post_code != NULL)
+    {
+      len = strlen(post_code);
+      PostCode = new char[len + 1];
+      strcpy(PostCode, post_code);
+    }
+  Country = NULL;
+  if (country != NULL)
+    {
+      len = strlen(country);
+      Country = new char[len + 1];
+      strcpy(Country, country);
+    }
+  VoiceTelephone = NULL;
+  if (voice_telephone != NULL)
+    {
+      len = strlen(voice_telephone);
+      VoiceTelephone = new char[len + 1];
+      strcpy(VoiceTelephone, voice_telephone);
+    }
+  FaxTelephone = NULL;
+  if (fax_telephone != NULL)
+    {
+      len = strlen(fax_telephone);
+      FaxTelephone = new char[len + 1];
+      strcpy(FaxTelephone, fax_telephone);
+    }
+  EMailAddress = NULL;
+  if (email_address != NULL)
+    {
+      len = strlen(email_address);
+      EMailAddress = new char[len + 1];
+      strcpy(EMailAddress, email_address);
+    }
+  Fees = NULL;
+  if (fees != NULL)
+    {
+      len = strlen(fees);
+      Fees = new char[len + 1];
+      strcpy(Fees, fees);
+    }
+  AccessConstraints = NULL;
+  if (access_constraints != NULL)
+    {
+      len = strlen(access_constraints);
+      AccessConstraints = new char[len + 1];
+      strcpy(AccessConstraints, access_constraints);
+    }
+  LayerLimit = layer_limit;
+  MaxWidth = max_width;
+  MaxHeight = max_height;
+  RefCount = 0;
+  Prev = NULL;
+  Next = NULL;
+  FirstFormat = NULL;
+  LastFormat = NULL;
+}
+
+WmsService::~WmsService()
+{
+//
+// WMS Service - destructor
+//
+  WmsFormat *pF;
+  WmsFormat *pFn;
+  if (Version != NULL)
+    delete[]Version;
+  if (Name != NULL)
+    delete[]Name;
+  if (Title != NULL)
+    delete[]Title;
+  if (Abstract != NULL)
+    delete[]Abstract;
+  if (TileServiceName != NULL)
+    delete[]TileServiceName;
+  if (TileServiceTitle != NULL)
+    delete[]TileServiceTitle;
+  if (TileServiceAbstract != NULL)
+    delete[]TileServiceAbstract;
+  if (URL_GetMap_Get != NULL)
+    delete[]URL_GetMap_Get;
+  if (URL_GetMap_Post != NULL)
+    delete[]URL_GetMap_Post;
+  if (URL_GetTileService_Get != NULL)
+    delete[]URL_GetTileService_Get;
+  if (URL_GetTileService_Post != NULL)
+    delete[]URL_GetTileService_Post;
+  if (URL_GetFeatureInfo_Get != NULL)
+    delete[]URL_GetFeatureInfo_Get;
+  if (URL_GetFeatureInfo_Post != NULL)
+    delete[]URL_GetFeatureInfo_Post;
+  if (GmlMimeType != NULL)
+    delete[]GmlMimeType;
+  if (XmlMimeType != NULL)
+    delete[]XmlMimeType;
+  if (ContactPerson != NULL)
+    delete[]ContactPerson;
+  if (ContactOrganization != NULL)
+    delete[]ContactOrganization;
+  if (ContactPosition != NULL)
+    delete[]ContactPosition;
+  if (PostalAddress != NULL)
+    delete[]PostalAddress;
+  if (City != NULL)
+    delete[]City;
+  if (StateProvince != NULL)
+    delete[]StateProvince;
+  if (PostCode != NULL)
+    delete[]PostCode;
+  if (Country != NULL)
+    delete[]Country;
+  if (VoiceTelephone != NULL)
+    delete[]VoiceTelephone;
+  if (FaxTelephone != NULL)
+    delete[]FaxTelephone;
+  if (EMailAddress != NULL)
+    delete[]EMailAddress;
+  if (Fees != NULL)
+    delete[]Fees;
+  if (AccessConstraints != NULL)
+    delete[]AccessConstraints;
+  pF = FirstFormat;
+  while (pF != NULL)
+    {
+      pFn = pF->GetNext();
+      delete pF;
+      pF = pFn;
+    }
+}
+
+bool WmsService::FormatAlreadyDefined(const char *name)
+{
+//
+// checks if a Format is already defined 
+//
+  WmsFormat *fmt = FirstFormat;
+  while (fmt != NULL)
+    {
+      if (strcmp(fmt->GetName(), name) == 0)
+        return true;
+      fmt = fmt->GetNext();
+    }
+  return false;
+}
+
+void WmsService::AddFormat(const char *name)
+{
+//
+// adding a Format definition
+//
+  if (FormatAlreadyDefined(name))
+    return;
+  WmsFormat *fmt = new WmsFormat(name);
+  if (FirstFormat == NULL)
+    FirstFormat = fmt;
+  if (LastFormat != NULL)
+    LastFormat->SetNext(fmt);
+  LastFormat = fmt;
+}
+
+int WmsService::CountFormats()
+{
+//
+// counting how many Format definitions are there
+//
+  int count = 0;
+  WmsFormat *pF = FirstFormat;
+  while (pF != NULL)
+    {
+      count++;
+      pF = pF->GetNext();
+    }
+  return count;
+}
+
+const char *WmsService::GetFormatByIndex(int idx)
+{
+//
+// return a Format as identified by its index
+//
+  int count = 0;
+  WmsFormat *pF = FirstFormat;
+  while (pF != NULL)
+    {
+      if (count == idx)
+        return pF->GetName();
+      count++;
+      pF = pF->GetNext();
+    }
+  return NULL;
+}
+
+bool WmsService::Equals(WmsService * other)
+{
+//
+// check if two WMS Services are the same
+//
+  int valid = 0;
+  if (this->Name == NULL && other->Name == NULL)
+    valid++;
+  else if (this->Name != NULL && other->Name != NULL)
+    {
+      if (strcmp(this->Name, other->Name) == 0)
+        valid++;
+    }
+  if (this->Title == NULL && other->Title == NULL)
+    valid++;
+  else if (this->Title != NULL && other->Title != NULL)
+    {
+      if (strcmp(this->Title, other->Title) == 0)
+        valid++;
+    }
+  if (this->Abstract == NULL && other->Abstract == NULL)
+    valid++;
+  else if (this->Abstract != NULL && other->Abstract != NULL)
+    {
+      if (strcmp(this->Abstract, other->Abstract) == 0)
+        valid++;
+    }
+  if (this->URL_GetMap_Get == NULL && other->URL_GetMap_Get == NULL)
+    valid++;
+  else if (this->URL_GetMap_Get != NULL && other->URL_GetMap_Get != NULL)
+    {
+      if (strcmp(this->URL_GetMap_Get, other->URL_GetMap_Get) == 0)
+        valid++;
+    }
+  if (this->URL_GetMap_Post == NULL && other->URL_GetMap_Post == NULL)
+    valid++;
+  else if (this->URL_GetMap_Post != NULL && other->URL_GetMap_Post != NULL)
+    {
+      if (strcmp(this->URL_GetMap_Post, other->URL_GetMap_Post) == 0)
+        valid++;
+    }
+  if (this->URL_GetFeatureInfo_Get == NULL
+      && other->URL_GetFeatureInfo_Get == NULL)
+    valid++;
+  else if (this->URL_GetFeatureInfo_Get != NULL
+           && other->URL_GetFeatureInfo_Get != NULL)
+    {
+      if (strcmp(this->URL_GetFeatureInfo_Get, other->URL_GetFeatureInfo_Get) ==
+          0)
+        valid++;
+    }
+  if (this->URL_GetFeatureInfo_Post == NULL
+      && other->URL_GetFeatureInfo_Post == NULL)
+    valid++;
+  else if (this->URL_GetFeatureInfo_Post != NULL
+           && other->URL_GetFeatureInfo_Post != NULL)
+    {
+      if (strcmp(this->URL_GetFeatureInfo_Post, other->URL_GetFeatureInfo_Post)
+          == 0)
+        valid++;
+    }
+  if (this->LayerLimit == other->LayerLimit)
+    valid++;
+  if (this->MaxWidth == other->MaxWidth)
+    valid++;
+  if (this->MaxHeight == other->MaxHeight)
+    valid++;
+  if (valid == 10)
+    return true;
+  return false;
+}
+
+WmsLayer::WmsLayer(WmsService * service, const char *name, const char *title,
+                   const char *abstract, int tiled, int tile_width,
+                   int tile_height, int queryable, int opaque,
+                   const char *version, const char *style_name,
+                   const char *style_title, const char *style_abstract,
+                   const char *format, const char *crs, int swap_xy,
+                   double min_x, double max_x, double min_y, double max_y,
+                   double geo_min_x, double geo_max_x, double geo_min_y,
+                   double geo_max_y, double min_scale_denominator,
+                   double max_scale_denominator)
+{
+//
+// WMS Layer - constructor [ordinary WMS Layer]
+//
+  int len;
+  TileLayer = NULL;
+  Service = service;
+  service->AddReference();
+  if (name == NULL)
+    {
+      Name = new char[1];
+      *Name = '\0';
+  } else
+    {
+      len = strlen(name);
+      Name = new char[len + 1];
+      strcpy(Name, name);
+    }
+  Title = NULL;
+  if (title != NULL)
+    {
+      len = strlen(title);
+      Title = new char[len + 1];
+      strcpy(Title, title);
+    }
+  Abstract = NULL;
+  if (abstract != NULL)
+    {
+      len = strlen(abstract);
+      Abstract = new char[len + 1];
+      strcpy(Abstract, abstract);
+    }
+  Tiled = tiled;
+  TileWidth = tile_width;
+  TileHeight = tile_height;
+  Queryable = queryable;
+  Opaque = opaque;
+  Version = NULL;
+  if (version != NULL)
+    {
+      len = strlen(version);
+      Version = new char[len + 1];
+      strcpy(Version, version);
+    }
+  StyleName = NULL;
+  if (style_name != NULL)
+    {
+      len = strlen(style_name);
+      StyleName = new char[len + 1];
+      strcpy(StyleName, style_name);
+    }
+  StyleTitle = NULL;
+  if (style_title != NULL)
+    {
+      len = strlen(style_title);
+      StyleTitle = new char[len + 1];
+      strcpy(StyleTitle, style_title);
+    }
+  StyleAbstract = NULL;
+  if (style_abstract != NULL)
+    {
+      len = strlen(style_abstract);
+      StyleAbstract = new char[len + 1];
+      strcpy(StyleAbstract, style_abstract);
+    }
+  Format = NULL;
+  if (format != NULL)
+    {
+      len = strlen(format);
+      Format = new char[len + 1];
+      strcpy(Format, format);
+    }
+  CRS = NULL;
+  if (crs != NULL)
+    {
+      len = strlen(crs);
+      CRS = new char[len + 1];
+      strcpy(CRS, crs);
+    }
+  SwapXY = swap_xy;
+  MinX = min_x;
+  MaxX = max_x;
+  MinY = min_y;
+  MaxY = max_y;
+  GeoMinX = geo_min_x;
+  GeoMaxX = geo_max_x;
+  GeoMinY = geo_min_y;
+  GeoMaxY = geo_max_y;
+  MinScaleDenominator = min_scale_denominator;
+  MaxScaleDenominator = max_scale_denominator;
+  Visible = 1;
+  Prev = NULL;
+  Next = NULL;
+  FirstStyle = NULL;
+  LastStyle = NULL;
+  FirstCRS = NULL;
+  LastCRS = NULL;
+  FirstChild = NULL;
+  LastChild = NULL;
+}
+
+WmsLayer::WmsLayer(WmsService * service, const char *name, const char *title,
+                   const char *abstract, double min_long, double min_lat,
+                   double max_long, double max_lat, const char *pad,
+                   const char *bands, const char *data_type)
+{
+//
+// WMS Layer - constructor [special TileService Layer]
+//
+  TileLayer = new WmsTileServiceLayer(name, title, abstract, min_lat, min_long,
+                                      max_lat, max_long, pad, bands, data_type);
+  Service = service;
+  service->AddReference();
+  Name = NULL;
+  Title = NULL;
+  Abstract = NULL;
+  Version = NULL;
+  StyleName = NULL;
+  StyleTitle = NULL;
+  StyleAbstract = NULL;
+  Format = NULL;
+  CRS = NULL;
+  Visible = 1;
+  Prev = NULL;
+  Next = NULL;
+  FirstStyle = NULL;
+  LastStyle = NULL;
+  FirstCRS = NULL;
+  LastCRS = NULL;
+  Queryable = 0;
+
+  FirstChild = NULL;
+  LastChild = NULL;
+}
+
+WmsLayer::~WmsLayer()
+{
+//
+// WMS Layer - destructor
+//
+  WmsStyle *pS;
+  WmsStyle *pSn;
+  WmsCRS *pC;
+  WmsCRS *pCn;
+  WmsQueryableChildLayer *pQ;
+  WmsQueryableChildLayer *pQn;
+  if (TileLayer != NULL)
+    delete TileLayer;
+  if (Name != NULL)
+    delete[]Name;
+  if (Title != NULL)
+    delete[]Title;
+  if (Abstract != NULL)
+    delete[]Abstract;
+  if (Version != NULL)
+    delete[]Version;
+  if (StyleName != NULL)
+    delete[]StyleName;
+  if (StyleTitle != NULL)
+    delete[]StyleTitle;
+  if (StyleAbstract != NULL)
+    delete[]StyleAbstract;
+  if (Format != NULL)
+    delete[]Format;
+  if (CRS != NULL)
+    delete[]CRS;
+  pS = FirstStyle;
+  while (pS != NULL)
+    {
+      pSn = pS->GetNext();
+      delete pS;
+      pS = pSn;
+    }
+  pC = FirstCRS;
+  while (pC != NULL)
+    {
+      pCn = pC->GetNext();
+      delete pC;
+      pC = pCn;
+    }
+  pQ = FirstChild;
+  while (pQ != NULL)
+    {
+      pQn = pQ->GetNext();
+      delete pQ;
+      pQ = pQn;
+    }
+  Service->DeleteReference();
+}
+
+bool WmsLayer::ChangeCRS(MyFrame * MainFrame, const char *crs)
+{
+// attempting to change the CRS for a WmsLayer
+  double minx;
+  double miny;
+  double maxx;
+  double maxy;
+
+  if (CRS != NULL)
+    {
+      if (strcmp(CRS, crs) == 0)
+        {
+          // unchanged
+          return false;
+        }
+    }
+// attempting to reproject the Geographic BBox into the CRS
+  minx = GeoMinX;
+  miny = GeoMinY;
+  maxx = GeoMaxX;
+  maxy = GeoMaxY;
+  if (MainFrame->BBoxFromLongLat(crs, &minx, &maxx, &miny, &maxy) == false)
+    {
+      // invalid reprojection: leaving unchanged
+      return false;
+    }
+
+  if (CRS != NULL)
+    delete[]CRS;
+  CRS = NULL;
+  int len = strlen(crs);
+  CRS = new char[len + 1];
+  strcpy(CRS, crs);
+
+// XY axes relative order
+  bool check_axes = false;
+  if (Service->GetVersion() != NULL)
+    {
+      if (strcmp(Service->GetVersion(), "1.3.0") == 0)
+        check_axes = true;
+    }
+  if (check_axes == true)
+    {
+      if (MainFrame->IsSwapXYcrs(crs) == true)
+        SwapXY = 1;
+      else
+        SwapXY = 0;
+  } else
+    SwapXY = 0;
+  if (SwapXY == true)
+    {
+      MinY = minx;
+      MaxY = maxx;
+      MinX = miny;
+      MaxX = maxy;
+  } else
+    {
+      MinX = minx;
+      MaxX = maxx;
+      MinY = miny;
+      MaxY = maxy;
+    }
+  return true;
+}
+
+void WmsLayer::Reconfigure(int tiled, int tile_width,
+                           int tile_height, int opaque,
+                           const char *version, const char *style_name,
+                           const char *style_title, const char *style_abstract,
+                           const char *format, const char *crs, int swap_xy,
+                           double min_x, double max_x, double min_y,
+                           double max_y)
+{
+//
+// WMS Layer - reconfiguring
+//
+  int len;
+  if (Version != NULL)
+    delete[]Version;
+  if (StyleName != NULL)
+    delete[]StyleName;
+  if (StyleTitle != NULL)
+    delete[]StyleTitle;
+  if (StyleAbstract != NULL)
+    delete[]StyleAbstract;
+  if (Format != NULL)
+    delete[]Format;
+  if (CRS != NULL)
+    delete[]CRS;
+  Tiled = tiled;
+  TileWidth = tile_width;
+  TileHeight = tile_height;
+  Opaque = opaque;
+  Version = NULL;
+  if (version != NULL)
+    {
+      len = strlen(version);
+      Version = new char[len + 1];
+      strcpy(Version, version);
+    }
+  StyleName = NULL;
+  if (style_name != NULL)
+    {
+      len = strlen(style_name);
+      StyleName = new char[len + 1];
+      strcpy(StyleName, style_name);
+    }
+  StyleTitle = NULL;
+  if (style_title != NULL)
+    {
+      len = strlen(style_title);
+      StyleTitle = new char[len + 1];
+      strcpy(StyleTitle, style_title);
+    }
+  StyleAbstract = NULL;
+  if (style_abstract != NULL)
+    {
+      len = strlen(style_abstract);
+      StyleAbstract = new char[len + 1];
+      strcpy(StyleAbstract, style_abstract);
+    }
+  Format = NULL;
+  if (format != NULL)
+    {
+      len = strlen(format);
+      Format = new char[len + 1];
+      strcpy(Format, format);
+    }
+  CRS = NULL;
+  if (crs != NULL)
+    {
+      len = strlen(crs);
+      CRS = new char[len + 1];
+      strcpy(CRS, crs);
+    }
+  SwapXY = swap_xy;
+  MinX = min_x;
+  MaxX = max_x;
+  MinY = min_y;
+  MaxY = max_y;
+}
+
+bool WmsLayer::StyleAlreadyDefined(const char *name, const char *title,
+                                   const char *abstract)
+{
+//
+// checks if a Style is already defined 
+//
+  WmsStyle *stl = FirstStyle;
+  while (stl != NULL)
+    {
+      bool ok_name = false;
+      bool ok_title = false;
+      bool ok_abstract = false;
+      if (stl->GetName() == NULL && name == NULL)
+        ok_name = true;
+      if (stl->GetName() != NULL && name != NULL)
+        {
+          if (strcmp(stl->GetName(), name) == 0)
+            ok_name = true;
+        }
+      if (stl->GetTitle() == NULL && title == NULL)
+        ok_title = true;
+      if (stl->GetTitle() != NULL && title != NULL)
+        {
+          if (strcmp(stl->GetTitle(), title) == 0)
+            ok_title = true;
+        }
+      if (stl->GetAbstract() == NULL && abstract == NULL)
+        ok_abstract = true;
+      if (stl->GetAbstract() != NULL && abstract != NULL)
+        {
+          if (strcmp(stl->GetAbstract(), abstract) == 0)
+            ok_abstract = true;
+        }
+      if (ok_name && ok_title && ok_abstract)
+        return true;
+      stl = stl->GetNext();
+    }
+  return false;
+}
+
+void WmsLayer::AddStyle(const char *name, const char *title,
+                        const char *abstract)
+{
+//
+// adding a Style definition
+//
+  if (StyleAlreadyDefined(name, title, abstract))
+    return;
+  WmsStyle *stl = new WmsStyle(name, title, abstract);
+  if (FirstStyle == NULL)
+    FirstStyle = stl;
+  if (LastStyle != NULL)
+    LastStyle->SetNext(stl);
+  LastStyle = stl;
+}
+
+int WmsLayer::CountStyles()
+{
+//
+// counting how many Style definitions are there
+//
+  int count = 0;
+  WmsStyle *pS = FirstStyle;
+  while (pS != NULL)
+    {
+      count++;
+      pS = pS->GetNext();
+    }
+  return count;
+}
+
+bool WmsLayer::GetStyleByIndex(int idx, const char **name, const char **title,
+                               const char **abstract)
+{
+//
+// return a Style as identified by its index
+//
+  int count = 0;
+  WmsStyle *pS = FirstStyle;
+  while (pS != NULL)
+    {
+      if (count == idx)
+        {
+          *name = pS->GetName();
+          *title = pS->GetTitle();
+          *abstract = pS->GetAbstract();
+          return true;
+        }
+      count++;
+      pS = pS->GetNext();
+    }
+  *name = NULL;
+  *title = NULL;
+  *abstract = NULL;
+  return false;
+}
+
+bool WmsLayer::CrsAlreadyDefined(const char *str)
+{
+//
+// checks if a CRS is already defined 
+//
+  WmsCRS *crs = FirstCRS;
+  while (crs != NULL)
+    {
+      if (strcmp(crs->GetCRS(), str) == 0)
+        return true;
+      crs = crs->GetNext();
+    }
+  return false;
+}
+
+WmsCRS *WmsLayer::AddCRS(const char *name)
+{
+//
+// adding a CRS definition
+//
+  if (CrsAlreadyDefined(name))
+    return NULL;
+  WmsCRS *crs = new WmsCRS(name);
+  if (FirstCRS == NULL)
+    FirstCRS = crs;
+  if (LastCRS != NULL)
+    LastCRS->SetNext(crs);
+  LastCRS = crs;
+  return crs;
+}
+
+int WmsLayer::CountCRS()
+{
+//
+// counting how many CRS definitions are there
+//
+  int count = 0;
+  WmsCRS *pC = FirstCRS;
+  while (pC != NULL)
+    {
+      count++;
+      pC = pC->GetNext();
+    }
+  return count;
+}
+
+const char *WmsLayer::GetCrsByIndex(int idx)
+{
+//
+// return a CRS name as identified by its index
+//
+  int count = 0;
+  WmsCRS *pC = FirstCRS;
+  while (pC != NULL)
+    {
+      if (count == idx)
+        return pC->GetCRS();
+      count++;
+      pC = pC->GetNext();
+    }
+  return NULL;
+}
+
+const char *WmsLayer::GetCRS()
+{
+//
+// return the current Layer CRS
+//
+  if (TileLayer != NULL)
+    {
+      // TileService layer
+      WmsTilePattern *pP = TileLayer->GetFirst();
+      if (pP == NULL)
+        return NULL;
+      return pP->GetSRS();
+    }
+  return CRS;
+}
+
+bool WmsLayer::HasBBox(const char *crs)
+{
+//
+// checks if a CRS really has a BBox
+//
+  WmsCRS *pC = FirstCRS;
+  while (pC != NULL)
+    {
+      if (strcmp(pC->GetCRS(), crs) == 0)
+        {
+          if (pC->GetBBox() != NULL)
+            return true;
+          else
+            return false;
+        }
+      pC = pC->GetNext();
+    }
+  return false;
+}
+
+void WmsLayer::GetBBox(const char *crs, double *minx, double *miny,
+                       double *maxx, double *maxy)
+{
+//
+// return a CRS BBox (if any)
+//
+  *minx = DBL_MAX;
+  *miny = DBL_MAX;
+  *maxx = DBL_MAX;
+  *maxy = DBL_MAX;
+  WmsCRS *pC = FirstCRS;
+  while (pC != NULL)
+    {
+      if (strcmp(pC->GetCRS(), crs) == 0)
+        {
+          if (pC->GetBBox() != NULL)
+            {
+              *minx = pC->GetBBox()->GetMinX();
+              *maxx = pC->GetBBox()->GetMaxX();
+              *miny = pC->GetBBox()->GetMinY();
+              *maxy = pC->GetBBox()->GetMaxY();
+              return;
+            }
+        }
+      pC = pC->GetNext();
+    }
+}
+
+WmsLayer *WmsLayer::Clone()
+{
+//
+// WMS Layer - Clone constructor
+//
+  WmsStyle *pS;
+  WmsCRS *pC;
+  WmsQueryableChildLayer *pQ;
+  WmsLayer *cloned =
+    new WmsLayer(this->Service, this->Name, this->Title, this->Abstract,
+                 this->Tiled, this->TileWidth, this->TileHeight,
+                 this->Queryable, this->Opaque, this->Version,
+                 this->StyleName, this->StyleTitle, this->StyleAbstract,
+                 this->Format, this->CRS, this->SwapXY,
+                 this->MinX, this->MaxX, this->MinY, this->MaxY, this->GeoMinX,
+                 this->GeoMaxX,
+                 this->GeoMinY, this->GeoMaxY, this->MinScaleDenominator,
+                 this->MaxScaleDenominator);
+  if (this->TileLayer != NULL)
+    cloned->TileLayer = this->TileLayer->Clone();
+  pS = FirstStyle;
+  while (pS != NULL)
+    {
+      cloned->AddStyle(pS->GetName(), pS->GetTitle(), pS->GetAbstract());
+      pS = pS->GetNext();
+    }
+  pC = FirstCRS;
+  while (pC != NULL)
+    {
+      cloned->AddCRS(pC->GetCRS());
+      pC = pC->GetNext();
+    }
+  pQ = FirstChild;
+  while (pQ != NULL)
+    {
+      cloned->AddQueryableChild(pQ->GetName(), pQ->GetTitle());
+      pQ = pQ->GetNext();
+    }
+  return cloned;
+}
+
+bool WmsLayer::Equals(WmsLayer * other)
+{
+//
+// checks if two WMS Layers are the same
+//
+  int valid = 0;
+  if (this->Service == other->Service)
+    valid++;
+  if (this->Name == NULL && other->Name == NULL)
+    valid++;
+  else if (this->Name != NULL && other->Name != NULL)
+    {
+      if (strcmp(this->Name, other->Name) == 0)
+        valid++;
+    }
+  if (this->Title == NULL && other->Title == NULL)
+    valid++;
+  else if (this->Title != NULL && other->Title != NULL)
+    {
+      if (strcmp(this->Title, other->Title) == 0)
+        valid++;
+    }
+  if (this->Abstract == NULL && other->Abstract == NULL)
+    valid++;
+  else if (this->Abstract != NULL && other->Abstract != NULL)
+    {
+      if (strcmp(this->Abstract, other->Abstract) == 0)
+        valid++;
+    }
+  if (valid == 4)
+    {
+      if (this->TileLayer != NULL && other->TileLayer != NULL)
+        return this->TileLayer->Equals(other->TileLayer);
+      return true;
+    }
+  return false;
+}
+
+bool WmsLayer::IsCovered(double minx, double miny, double maxx, double maxy)
+{
+//
+// checks if a Layer is (partially) covered by a Bounding Box
+//
+  if (TileLayer != NULL)
+    {
+      // TileService Layer
+      if (TileLayer->GetMinLong() > maxx)
+        return false;
+      if (TileLayer->GetMinLat() > maxy)
+        return false;
+      if (TileLayer->GetMaxLong() < minx)
+        return false;
+      if (TileLayer->GetMaxLat() < miny)
+        return false;
+  } else
+    {
+      // Ordinary Layer
+      if (SwapXY == true)
+        {
+          if (MinY > maxx)
+            return false;
+          if (MinX > maxy)
+            return false;
+          if (MaxY < minx)
+            return false;
+          if (MaxX < miny)
+            return false;
+      } else
+        {
+          if (MinX > maxx)
+            return false;
+          if (MinY > maxy)
+            return false;
+          if (MaxX < minx)
+            return false;
+          if (MaxY < miny)
+            return false;
+        }
+    }
+  return true;
+}
+
+void WmsLayer::MaxLimits(double *maxx, double *maxy)
+{
+//
+// checks the Max Limits
+//
+  if (TileLayer != NULL)
+    {
+      // TileService Layer
+      if (*maxx > TileLayer->GetMaxLong())
+        *maxx = TileLayer->GetMaxLong();
+      if (*maxy > TileLayer->GetMaxLat())
+        *maxy = TileLayer->GetMaxLat();
+  } else
+    {
+      // Ordinary Layer
+      if (SwapXY == true)
+        {
+          if (*maxy > MaxX)
+            *maxy = MaxX;
+          if (*maxx > MaxY)
+            *maxx = MaxY;
+      } else
+        {
+          if (*maxx > MaxX)
+            *maxx = MaxX;
+          if (*maxy > MaxY)
+            *maxy = MaxY;
+        }
+    }
+}
+
+void WmsLayer::AddQueryableChild(const char *name, const char *title)
+{
+//
+// adding a child queryable layer
+//
+  WmsQueryableChildLayer *child = new WmsQueryableChildLayer(name, title);
+  if (FirstChild == NULL)
+    FirstChild = child;
+  if (LastChild != NULL)
+    LastChild->SetNext(child);
+  LastChild = child;
+}
+
+WmsQueryableChildLayer::WmsQueryableChildLayer(const char *name,
+                                               const char *title)
+{
+// constructor
+  int len;
+  Name = NULL;
+  if (name != NULL)
+    {
+      len = strlen(name);
+      Name = new char[len + 1];
+      strcpy(Name, name);
+    }
+  Title = NULL;
+  if (title != NULL)
+    {
+      len = strlen(title);
+      Title = new char[len + 1];
+      strcpy(Title, title);
+    }
+  Next = NULL;
+}
+
+WmsQueryableChildLayer::~WmsQueryableChildLayer()
+{
+// destructor
+  if (Name != NULL)
+    delete[]Name;
+  if (Title != NULL)
+    delete[]Title;
+}
+
+WmsTileSet::WmsTileSet(double minx, double miny, double maxx, double maxy,
+                       double base_x, double base_y, double tile_horz,
+                       double tile_vert, int image_x, int image_y, int image_w,
+                       int image_h, int tile_w, int tile_h)
+{
+//
+// creating a WMS TileSet object
+//
+  FrameMinX = minx;
+  FrameMinY = miny;
+  FrameMaxX = maxx;
+  FrameMaxY = maxy;
+  BaseX = base_x;
+  BaseY = base_y;
+  TileHorzSize = tile_horz;
+  TileVertSize = tile_vert;
+  ImageOriginX = image_x;
+  ImageOriginY = image_y;
+  ImageWidth = image_w;
+  ImageHeight = image_h;
+  TileWidth = tile_w;
+  TileHeight = tile_h;
+  First = NULL;
+  Last = NULL;
+}
+
+WmsTileSet::~WmsTileSet()
+{
+//
+// memory cleanup - destroying a WMS TileSet object
+//
+  WmsTileRequest *pR;
+  WmsTileRequest *pRn;
+  pR = First;
+  while (pR != NULL)
+    {
+      pRn = pR->GetNext();
+      delete pR;
+      pR = pRn;
+    }
+}
+
+void WmsTileSet::AddTile(double pos_x, double pos_y, int row, int col)
+{
+//
+// adding a tile into the tileSet
+//
+  double minx = pos_x;
+  double miny = pos_y;
+  double maxx = pos_x + TileHorzSize;
+  double maxy = pos_y + TileVertSize;
+  int image_x = ImageOriginX + (TileWidth * col);
+  int image_y = ImageOriginY - (TileHeight * row) - TileHeight;
+  WmsTileRequest *tile =
+    new WmsTileRequest(row, col, minx, miny, maxx, maxy, image_x, image_y);
+  if (First == NULL)
+    First = tile;
+  if (Last != NULL)
+    Last->SetNext(tile);
+  Last = tile;
+}
+
+WmsTileServiceLayer::WmsTileServiceLayer(const char *name, const char *title,
+                                         const char *abstract, double min_lat,
+                                         double min_long, double max_lat,
+                                         double max_long, const char *pad,
+                                         const char *bands,
+                                         const char *data_type)
+{
+//
+// WMS TileService Layer - constructor
+//
+  int len;
+  if (name == NULL)
+    {
+      Name = new char[1];
+      *Name = '\0';
+  } else
+    {
+      len = strlen(name);
+      Name = new char[len + 1];
+      strcpy(Name, name);
+    }
+  Title = NULL;
+  if (title != NULL)
+    {
+      len = strlen(title);
+      Title = new char[len + 1];
+      strcpy(Title, title);
+    }
+  Abstract = NULL;
+  if (abstract != NULL)
+    {
+      len = strlen(abstract);
+      Abstract = new char[len + 1];
+      strcpy(Abstract, abstract);
+    }
+  MinLong = min_long;
+  MinLat = min_lat;
+  MaxLong = max_long;
+  MaxLat = max_lat;
+  Pad = NULL;
+  if (pad != NULL)
+    {
+      len = strlen(pad);
+      Pad = new char[len + 1];
+      strcpy(Pad, pad);
+    }
+  Bands = NULL;
+  if (bands != NULL)
+    {
+      len = strlen(bands);
+      Bands = new char[len + 1];
+      strcpy(Bands, bands);
+    }
+  DataType = NULL;
+  if (data_type != NULL)
+    {
+      len = strlen(data_type);
+      DataType = new char[len + 1];
+      strcpy(DataType, data_type);
+    }
+  WmsFixedScalesCount = 0;
+  WmsFixedScales = NULL;
+  First = NULL;
+  Last = NULL;
+}
+
+WmsTileServiceLayer::~WmsTileServiceLayer()
+{
+//
+// WMS TileService Layer - destructor
+//
+  WmsTilePattern *pP;
+  WmsTilePattern *pPn;
+  if (Name != NULL)
+    delete[]Name;
+  if (Title != NULL)
+    delete[]Title;
+  if (Abstract != NULL)
+    delete[]Abstract;
+  if (Pad != NULL)
+    delete[]Pad;
+  if (Bands != NULL)
+    delete[]Bands;
+  if (DataType != NULL)
+    delete[]DataType;
+  pP = First;
+  while (pP != NULL)
+    {
+      pPn = pP->GetNext();
+      delete pP;
+      pP = pPn;
+    }
+  if (WmsFixedScales != NULL)
+    delete[]WmsFixedScales;
+}
+
+void WmsTileServiceLayer::BuildFixedScales()
+{
+// building the Fixed Scales array
+  WmsTilePattern *pP;
+  if (WmsFixedScales != NULL)
+    delete[]WmsFixedScales;
+  WmsFixedScales = NULL;
+  WmsFixedScalesCount = 0;
+  pP = First;
+  while (pP != NULL)
+    {
+      // counting how many TilePatterns are there
+      WmsFixedScalesCount++;
+      pP = pP->GetNext();
+    }
+  if (WmsFixedScalesCount <= 0)
+    return;
+  WmsFixedScales = new double[WmsFixedScalesCount];
+  int i = 0;
+  pP = First;
+  while (pP != NULL)
+    {
+      // computing Fixed Scales
+      *(WmsFixedScales + i++) =
+        pP->GetTileExtentX() / (double) (pP->GetTileWidth());
+      pP = pP->GetNext();
+    }
+}
+
+bool WmsTileServiceLayer::CompareFixedScales(WmsTileServiceLayer * other)
+{
+// checks if two TileService layers share the same fixed scales
+  int i;
+  if (this->WmsFixedScalesCount != other->WmsFixedScalesCount)
+    return false;
+  for (i = 0; i < this->WmsFixedScalesCount; i++)
+    {
+      if (*(this->WmsFixedScales + i) != *(other->WmsFixedScales + i))
+        return false;
+    }
+  return true;
+}
+
+WmsTileServiceLayer *WmsTileServiceLayer::Clone()
+{
+//
+// WMS TileService Layer - Clone constructor
+//
+  WmsTilePattern *pP;
+  WmsTileServiceLayer *cloned =
+    new WmsTileServiceLayer(this->Name, this->Title, this->Abstract,
+                            this->MinLong, this->MinLat, this->MaxLong,
+                            this->MaxLat, this->Pad, this->Bands,
+                            this->DataType);
+  pP = First;
+  while (pP != NULL)
+    {
+      cloned->AddTilePattern(pP->GetHandle(), pP->GetSRS(), pP->GetTileWidth(),
+                             pP->GetTileHeight(), pP->GetTileBaseX(),
+                             pP->GetTileBaseY(), pP->GetTileExtentX(),
+                             pP->GetTileExtentY());
+      pP = pP->GetNext();
+    }
+  return cloned;
+}
+
+void WmsTileServiceLayer::AddTilePattern(rl2WmsTilePatternPtr handle,
+                                         const char *srs, int width, int height,
+                                         double base_x, double base_y,
+                                         double ext_x, double ext_y)
+{
+// inserts a TilePattern into a TileService Layer
+  WmsTilePattern *pattern =
+    new WmsTilePattern(handle, srs, width, height, base_x, base_y, ext_x,
+                       ext_y);
+  if (First == NULL)
+    First = pattern;
+  if (Last != NULL)
+    Last->SetNext(pattern);
+  Last = pattern;
+}
+
+bool WmsTileServiceLayer::Equals(WmsTileServiceLayer * other)
+{
+//
+// checks if two WMS TileService Layers are the same
+//
+  int valid = 0;
+  if (this->Name == NULL && other->Name == NULL)
+    valid++;
+  else if (this->Name != NULL && other->Name != NULL)
+    {
+      if (strcmp(this->Name, other->Name) == 0)
+        valid++;
+    }
+  if (this->Title == NULL && other->Title == NULL)
+    valid++;
+  else if (this->Title != NULL && other->Title != NULL)
+    {
+      if (strcmp(this->Title, other->Title) == 0)
+        valid++;
+    }
+  if (this->Abstract == NULL && other->Abstract == NULL)
+    valid++;
+  else if (this->Abstract != NULL && other->Abstract != NULL)
+    {
+      if (strcmp(this->Abstract, other->Abstract) == 0)
+        valid++;
+    }
+  if (valid == 3)
+    return true;
+  return false;
+}
+
+bool WmsTileServiceLayer::GetTileParams(double scale, double frame_minx,
+                                        double frame_miny, int *tile_width,
+                                        int *tile_height, double *tileW,
+                                        double *tileH, double *baseX,
+                                        double *baseY,
+                                        WmsTilePattern ** tilepattern)
+{
+// computing Tile Params for a TileService layer request
+  *tile_width = -1;
+  *tile_height = -1;
+  *tileW = DBL_MAX;
+  *tileH = DBL_MAX;
+  *baseX = DBL_MAX;
+  *baseY = DBL_MAX;
+  *tilepattern = NULL;
+  WmsTilePattern *pP = First;
+  while (pP != NULL)
+    {
+      double pix_scale = pP->GetTileExtentX() / (double) (pP->GetTileWidth());
+      if (pix_scale == scale)
+        {
+          *tilepattern = pP;
+          *tile_width = pP->GetTileWidth();
+          *tile_height = pP->GetTileHeight();
+          *tileW = pP->GetTileExtentX();
+          *tileH = pP->GetTileExtentY();
+          double x = pP->GetTileBaseX();
+          double y = pP->GetTileBaseY();
+          while (y > MinLat)
+            y -= pP->GetTileExtentY();
+          if (frame_minx > pP->GetTileBaseX())
+            {
+              while (x + pP->GetTileExtentX() < frame_minx)
+                x += pP->GetTileExtentX();
+          } else
+            {
+              while (x - pP->GetTileExtentX() > frame_minx)
+                x -= pP->GetTileExtentX();
+            }
+          if (frame_miny > y)
+            {
+              while (y + pP->GetTileExtentY() < frame_miny)
+                y += pP->GetTileExtentY();
+          } else
+            {
+              while (y - pP->GetTileExtentY() > frame_miny)
+                y -= pP->GetTileExtentY();
+            }
+          *baseX = x;
+          *baseY = y;
+          break;
+        }
+      pP = pP->GetNext();
+    }
+  if (*tile_width <= 0 || *tile_height <= 0)
+    return false;
+  if (*tileW == DBL_MAX || *tileH == DBL_MAX)
+    return false;
+  if (*tilepattern == NULL)
+    return false;
+  return true;
+}
+
+WmsTilePattern::WmsTilePattern(rl2WmsTilePatternPtr handle, const char *srs,
+                               int width, int height, double base_x,
+                               double base_y, double ext_x, double ext_y)
+{
+//
+// WMS Tile Pattern - constructor
+//
+  int len = strlen(srs);
+  SRS = new char[len + 1];
+  strcpy(SRS, srs);
+  Handle = clone_wms_tile_pattern(handle);
+  TileWidth = width;
+  TileHeight = height;
+  TileBaseX = base_x;
+  TileBaseY = base_y;
+  TileExtentX = ext_x;
+  TileExtentY = ext_y;
+  Next = NULL;
+}
+
+WmsTilePattern::~WmsTilePattern()
+{
+//
+// WMS Tile Pattern - destructor
+//
+  if (SRS != NULL)
+    delete[]SRS;
+  if (Handle != NULL)
+    destroy_wms_tile_pattern(Handle);
+}
+
+void WmsTilePattern::GetSampleURL(wxString & url)
+{
+//
+// return the sample URL corresponding to this TilePattern
+//
+  char *xurl = get_wms_tile_pattern_sample_url(Handle);
+  url = wxString::FromUTF8(xurl);
+  if (xurl != NULL)
+    sqlite3_free(xurl);
+}
+
+void MyMapView::ResetGetMapRequests()
+{
+// cleaning the GetMap requests list
+  WmsGetMapRequest *pR;
+  WmsGetMapRequest *pRn;
+  pR = FirstRequest;
+  while (pR != NULL)
+    {
+      pRn = pR->GetNext();
+      delete pR;
+      pR = pRn;
+    }
+  FirstRequest = NULL;
+  LastRequest = NULL;
+}
+
+void MyMapView::Consider()
+{
+// enabling the whole GetMap requests list
+  WmsGetMapRequest *pR = FirstRequest;
+  while (pR != NULL)
+    {
+      pR->Consider();
+      pR = pR->GetNext();
+    }
+}
+
+void MyMapView::Consider(const char *layer_name)
+{
+// enabling the GetMap requests list for a selected layer
+  WmsGetMapRequest *pR = FirstRequest;
+  while (pR != NULL)
+    {
+      if (strcmp(pR->GetLayerName(), layer_name) == 0)
+        pR->Consider();
+      pR = pR->GetNext();
+    }
+}
+
+int MyMapView::CountGetMapRequests()
+{
+// counting how many pending GetMap requests are queued
+  int count = 0;
+  WmsGetMapRequest *pR = FirstRequest;
+  while (pR != NULL)
+    {
+      count++;
+      pR = pR->GetNext();
+    }
+  return count;
+}
+
+WmsCRScandidate::WmsCRScandidate(const char *crs)
+{
+// constructor
+  int len = strlen(crs);
+  CRS = new char[len + 1];
+  strcpy(CRS, crs);
+  Count = 1;
+  Next = NULL;
+}
+
+WmsCRScandidate::~WmsCRScandidate()
+{
+// destructor
+  if (CRS != NULL)
+    delete[]CRS;
+}
+
+WmsCRScandidates::~WmsCRScandidates()
+{
+// destructor
+  WmsCRScandidate *pC;
+  WmsCRScandidate *pCn;
+  pC = First;
+  while (pC != NULL)
+    {
+      pCn = pC->GetNext();
+      delete pC;
+      pC = pCn;
+    }
+}
+
+void WmsCRScandidates::AddCandidate(const char *crs)
+{
+// evaluating a new CRS candidate
+  WmsCRScandidate *pC = First;
+  while (pC != NULL)
+    {
+      if (strcmp(pC->GetCRS(), crs) == 0)
+        {
+          // already defined
+          pC->Increment();
+          return;
+        }
+      pC = pC->GetNext();
+    }
+// not yet defined
+  pC = new WmsCRScandidate(crs);
+  if (First == NULL)
+    First = pC;
+  if (Last != NULL)
+    Last->SetNext(pC);
+  Last = pC;
+}
+
+int MyMapView::GetSridFromCRS(const char *crs)
+{
+// attempting to return the current Map SRID
+  int i;
+  if (crs == NULL)
+    return -1;
+  i = strlen(crs) - 1;
+  for (; i >= 0; i--)
+    {
+      if (*(crs + i) == ':')
+        return atoi(crs + i + 1);
+    }
+  return -1;
+}
+
+void MyMapView::SetMapCRS(const char *crs)
+{
+// setting a new Map CRS
+  bool changed = false;
+  WmsLayer *lyr = FirstLayer;
+  while (lyr != NULL)
+    {
+      if (lyr->ChangeCRS(MainFrame, crs) == true)
+        changed = true;
+      lyr = lyr->GetNext();
+    }
+  if (changed == true)
+    SetFullExtent();
+  PrepareMap();
+}
+
+void MyMapView::ResetCRSlist()
+{
+// resetting the CRS list to the initial empty state
+  WmsCRS *pC;
+  WmsCRS *pCn;
+  pC = FirstCRS;
+  while (pC != NULL)
+    {
+      pCn = pC->GetNext();
+      delete pC;
+      pC = pCn;
+    }
+  FirstCRS = NULL;
+  LastCRS = NULL;
+}
+
+void MyMapView::BuildCRSlist()
+{
+// building a list of CRSes supported by any currently defined WMS layer
+  WmsCRScandidate *pC;
+  WmsCRScandidates cand;
+  ResetCRSlist();
+  WmsLayer *lyr = FirstLayer;
+  while (lyr != NULL)
+    {
+      // testing all candidates
+      if (lyr->GetTileServiceLayer() != NULL)
+        {
+          // TileService WMS layer
+          cand.Increment();
+          WmsTilePattern *pT = lyr->GetTileServiceLayer()->GetFirst();
+          if (pT != NULL)
+            cand.AddCandidate(pT->GetSRS());
+      } else
+        {
+          // ordinary WMS layer
+          cand.Increment();
+          for (int s = 0; s < lyr->CountCRS(); s++)
+            {
+              const char *crs = lyr->GetCrsByIndex(s);
+              cand.AddCandidate(crs);
+        }}
+      lyr = lyr->GetNext();
+    }
+
+// creating the list of common CRSes
+  pC = cand.GetFirst();
+  while (pC != NULL)
+    {
+      if (pC->GetCount() == cand.GetCount())
+        {
+          WmsCRS *crs = new WmsCRS(pC->GetCRS());
+          if (FirstCRS == NULL)
+            FirstCRS = crs;
+          if (LastCRS != NULL)
+            LastCRS->SetNext(crs);
+          LastCRS = crs;
+        }
+      pC = pC->GetNext();
+    }
+}
+
+void MyMapView::BuildFixedScales()
+{
+// building the Fixed Scales array
+  if (WmsFixedScales != NULL)
+    delete[]WmsFixedScales;
+  WmsFixedScales = NULL;
+  WmsFixedScalesCount = 0;
+  WmsLayer *lyr = FirstLayer;
+  while (lyr != NULL)
+    {
+      if (lyr->GetTileServiceLayer() != NULL)
+        {
+          // found a TileService layer
+          int cnt = lyr->GetTileServiceLayer()->GetFixedScalesCount();
+          if (cnt > 0)
+            {
+              // allocating and initializing the Map Fixed Scales array
+              double *src = lyr->GetTileServiceLayer()->GetFixedScales();
+              WmsFixedScalesCount = cnt;
+              WmsFixedScales = new double[cnt];
+              for (int i = 0; i < cnt; i++)
+                *(WmsFixedScales + i) = *(src + i);
+            }
+          return;
+        }
+      lyr = lyr->GetNext();
+    }
+}
+
+void MyMapView::AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                                 const char *version,
+                                 const char *layer,
+                                 const char *crs, int swap_xy,
+                                 double minx, double miny,
+                                 double maxx, double maxy,
+                                 int width, int height,
+                                 const char *style,
+                                 const char *format, int opaque)
+{
+// appending a GetMap request into the list [Ordinary]
+  rl2WmsCachePtr cache_handle = MainFrame->GetWmsCache();
+  WmsGetMapRequest *req = new WmsGetMapRequest(pos_x, pos_y, cache_handle, url,
+                                               Proxy, version, layer, crs,
+                                               swap_xy, minx, miny,
+                                               maxx, maxy, width, height, style,
+                                               format, opaque, 1);
+  if (FirstRequest == NULL)
+    FirstRequest = req;
+  if (LastRequest != NULL)
+    LastRequest->SetNext(req);
+  LastRequest = req;
+}
+
+void MyMapView::AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                                 const char *layer, int swap_xy,
+                                 double minx, double miny,
+                                 double maxx, double maxy, int width,
+                                 int height, WmsTilePattern * tilepattern)
+{
+// appending a GetMap request into the list [TileService]
+  rl2WmsCachePtr cache_handle = MainFrame->GetWmsCache();
+  WmsGetMapRequest *req = new WmsGetMapRequest(pos_x, pos_y, cache_handle, url,
+                                               Proxy, layer, swap_xy, minx,
+                                               miny,
+                                               maxx, maxy, width, height,
+                                               tilepattern, 1);
+  if (FirstRequest == NULL)
+    FirstRequest = req;
+  if (LastRequest != NULL)
+    LastRequest->SetNext(req);
+  LastRequest = req;
+}
+
+WmsGetMapRequest::WmsGetMapRequest(int pos_x, int pos_y,
+                                   rl2WmsCachePtr cache_handle, const char *url,
+                                   const char *proxy, const char *version,
+                                   const char *layer, const char *crs,
+                                   int swap_xy, double minx, double miny,
+                                   double maxx, double maxy, int width,
+                                   int height, const char *style,
+                                   const char *format, int opaque,
+                                   int with_image)
+{
+// constructor
+  PosX = pos_x;
+  PosY = pos_y;
+  CacheHandle = cache_handle;
+  Url = url;
+  Proxy = proxy;
+  Version = version;
+  Layer = layer;
+  Crs = crs;
+  SwapXY = swap_xy;
+  MinX = minx;
+  MinY = miny;
+  MaxX = maxx;
+  MaxY = maxy;
+  Width = width;
+  Height = height;
+  Style = style;
+  Format = format;
+  Opaque = opaque;
+  TilePattern = NULL;
+  CacheHit = false;
+  if (with_image)
+    {
+      Image = wxImage(Width, Height);
+      Image.SetAlpha();
+    }
+  RGBA = NULL;
+  ImageReady = false;
+  ImageDone = false;
+  Ignore = true;
+  Next = NULL;
+}
+
+WmsGetMapRequest::WmsGetMapRequest(int pos_x, int pos_y,
+                                   rl2WmsCachePtr cache_handle, const char *url,
+                                   const char *proxy, const char *layer,
+                                   int swap_xy, double minx, double miny,
+                                   double maxx, double maxy, int width,
+                                   int height, WmsTilePattern * tilepattern,
+                                   int with_image)
+{
+// constructor
+  PosX = pos_x;
+  PosY = pos_y;
+  CacheHandle = cache_handle;
+  Url = url;
+  Proxy = proxy;
+  Version = NULL;
+  Layer = layer;
+  Crs = NULL;
+  SwapXY = swap_xy;
+  MinX = minx;
+  MinY = miny;
+  MaxX = maxx;
+  MaxY = maxy;
+  Width = width;
+  Height = height;
+  Style = NULL;
+  Format = NULL;
+  TilePattern = tilepattern;
+  CacheHit = false;
+  if (with_image)
+    {
+      Image = wxImage(Width, Height);
+      Image.SetAlpha();
+    }
+  RGBA = NULL;
+  ImageReady = false;
+  ImageDone = false;
+  Ignore = true;
+  Next = NULL;
+}
+
+void WmsGetMapRequest::Done()
+{
+// finalizing a tile request
+  RGBA = NULL;
+  ImageReady = false;
+  ImageDone = true;
+}
+
+bool WmsGetMapRequest::ExecuteMap(int from_cache)
+{
+// executing a WMS GetMap request
+  char *err_msg = NULL;
+  unsigned char *rgba;
+  bool ret = false;
+  if (TilePattern != NULL)
+    {
+      char *url =
+        get_wms_tile_pattern_request_url(TilePattern->GetHandle(), Url, MinX,
+                                         MinY);
+      if (url != NULL)
+        {
+          rgba =
+            do_wms_GetMap_TileService_get(CacheHandle, url, Proxy, Width,
+                                          Height, from_cache, &err_msg);
+          sqlite3_free(url);
+      } else
+        rgba = NULL;
+  } else
+    rgba =
+      do_wms_GetMap_get(CacheHandle, Url, Proxy, Version, Layer, Crs, SwapXY,
+                        MinX, MinY, MaxX, MaxY,
+                        Width, Height, Style, Format, Opaque, from_cache,
+                        &err_msg);
+  if (rgba == NULL)
+    return false;
+  if (from_cache)
+    CacheHit = true;
+
+  if (rgba != NULL)
+    {
+      // WMS tile
+      unsigned char *p = rgba;
+      for (int y = 0; y < Height; y++)
+        {
+          for (int x = 0; x < Width; x++)
+            {
+              unsigned char r = *p++;
+              unsigned char g = *p++;
+              unsigned char b = *p++;
+              unsigned char alpha = *p++;
+              Image.SetRGB(x, y, r, g, b);
+              Image.SetAlpha(x, y, alpha);
+            }
+        }
+      free(rgba);
+      ImageReady = true;
+      ret = true;
+  } else
+    {
+      // default white tile
+      for (int y = 0; y < Height; y++)
+        {
+          for (int x = 0; x < Width; x++)
+            {
+              Image.SetRGB(x, y, 255, 255, 255);
+              if (Opaque == 0)
+                Image.SetAlpha(x, y, 128);
+              else
+                Image.SetAlpha(x, y, 255);
+            }
+        }
+      ret = false;
+    }
+  return ret;
+}
+
+bool WmsGetMapRequest::ExecutePrint(int from_cache)
+{
+// executing a WMS GetMap request
+  char *err_msg = NULL;
+  unsigned char *rgba;
+  bool ret = false;
+  if (TilePattern != NULL)
+    {
+      char *url =
+        get_wms_tile_pattern_request_url(TilePattern->GetHandle(), Url, MinX,
+                                         MinY);
+      if (url != NULL)
+        {
+          rgba =
+            do_wms_GetMap_TileService_get(CacheHandle, url, Proxy, Width,
+                                          Height, from_cache, &err_msg);
+          sqlite3_free(url);
+      } else
+        rgba = NULL;
+  } else
+    rgba =
+      do_wms_GetMap_get(CacheHandle, Url, Proxy, Version, Layer, Crs, SwapXY,
+                        MinX, MinY, MaxX, MaxY,
+                        Width, Height, Style, Format, Opaque, from_cache,
+                        &err_msg);
+  if (rgba == NULL)
+    return false;
+  if (from_cache)
+    CacheHit = true;
+
+  if (rgba != NULL)
+    {
+      RGBA = rgba;
+      ImageReady = true;
+      ret = true;
+  } else
+    ret = false;
+  return ret;
+}
+
+GeometryList::~GeometryList()
+{
+// destructor
+  GeometryRef *pG;
+  GeometryRef *pGn;
+  pG = First;
+  while (pG != NULL)
+    {
+      pGn = pG->GetNext();
+      delete pG;
+      pG = pGn;
+    }
+}
+
+void GeometryList::Add(int layer_id, int line_no, int col_no,
+                       gaiaGeomCollPtr geom)
+{
+// adding a Geometry ref into the list
+  GeometryRef *ptr = new GeometryRef(layer_id, line_no, col_no, geom);
+  if (First == NULL)
+    First = ptr;
+  if (Last != NULL)
+    Last->SetNext(ptr);
+  Last = ptr;
+}
+
+gaiaGeomCollPtr GeometryList::Find(int layer_id, int line_no, int col_no)
+{
+// retrieving some Geometry from the list
+
+  GeometryRef *pG = First;
+  while (pG != NULL)
+    {
+      if (pG->GetLayerId() == layer_id && pG->GetLineNo() == line_no
+          && pG->GetColNo() == col_no)
+        return pG->GetGeometry();
+      pG = pG->GetNext();
+    }
+  return NULL;
+}
+
+void MyMapView::MarkGeometry(gaiaGeomCollPtr geom)
+{
+// starts the Dynamic Marker
+  ResetMarker();
+  BuildMarker(ImageMarkerOdd, true, geom);
+  BuildMarker(ImageMarkerEven, false, geom);
+  DynamicOddEven = true;
+  DynamicPhase = 0;
+  TimerDynamic = new wxTimer(this, ID_DYNAMIC_TIMER);
+  TimerDynamic->Start(250, wxTIMER_ONE_SHOT);
+}
+
+void MyMapView::BuildMarker(wxImage & image, bool odd_even,
+                            gaiaGeomCollPtr geom)
+{
+// building a Geometry Marker
+  rl2GraphicsContextPtr ctx = rl2_graph_create_context(FrameWidth, FrameHeight);
+// background initialization - full transparent
+  rl2_graph_set_brush(ctx, 255, 255, 255, 0);
+  rl2_graph_draw_rectangle(ctx, -1, -1, FrameWidth + 2, FrameHeight + 2);
+
+// drawing the geometric entity
+  int x;
+  int y;
+// setting standard graphic setting for Polygons
+  if (odd_even == false)
+    {
+      rl2_graph_set_pen(ctx, 0, 0, 255, 255, 1, RL2_PENSTYLE_SOLID);
+      rl2_graph_set_brush(ctx, 255, 255, 0, 128);
+  } else
+    {
+      rl2_graph_set_pen(ctx, 255, 0, 0, 255, 1, RL2_PENSTYLE_SOLID);
+      rl2_graph_set_brush(ctx, 0, 255, 255, 128);
+    }
+  gaiaPolygonPtr pg = geom->FirstPolygon;
+  while (pg)
+    {
+      // drawing a POLYGON
+      int iv;
+      double dx;
+      double dy;
+      double z;
+      double m;
+      int x;
+      int y;
+      int lastX = 0;
+      int lastY = 0;
+      int ib;
+      gaiaRingPtr ring = pg->Exterior;
+      // exterior border
+      for (iv = 0; iv < ring->Points; iv++)
+        {
+          if (ring->DimensionModel == GAIA_XY_Z)
+            {
+              gaiaGetPointXYZ(ring->Coords, iv, &dx, &dy, &z);
+          } else if (ring->DimensionModel == GAIA_XY_M)
+            {
+              gaiaGetPointXYM(ring->Coords, iv, &dx, &dy, &m);
+          } else if (ring->DimensionModel == GAIA_XY_Z_M)
+            {
+              gaiaGetPointXYZM(ring->Coords, iv, &dx, &dy, &z, &m);
+          } else
+            {
+              gaiaGetPoint(ring->Coords, iv, &dx, &dy);
+            }
+          x = (int) ((dx - FrameMinX) / PixelRatio);
+          y = FrameHeight - (int) ((dy - FrameMinY) / PixelRatio);
+          if (iv == 0)
+            {
+              rl2_graph_move_to_point(ctx, x, y);
+              lastX = x;
+              lastY = y;
+          } else
+            {
+              if (x == lastX && y == lastY)
+                ;
+              else
+                {
+                  rl2_graph_add_line_to_path(ctx, x, y);
+                  lastX = x;
+                  lastY = y;
+                }
+            }
+        }
+      rl2_graph_close_subpath(ctx);
+      for (ib = 0; ib < pg->NumInteriors; ib++)
+        {
+          // interior borders
+          ring = pg->Interiors + ib;
+          for (iv = 0; iv < ring->Points; iv++)
+            {
+              if (ring->DimensionModel == GAIA_XY_Z)
+                {
+                  gaiaGetPointXYZ(ring->Coords, iv, &dx, &dy, &z);
+              } else if (ring->DimensionModel == GAIA_XY_M)
+                {
+                  gaiaGetPointXYM(ring->Coords, iv, &dx, &dy, &m);
+              } else if (ring->DimensionModel == GAIA_XY_Z_M)
+                {
+                  gaiaGetPointXYZM(ring->Coords, iv, &dx, &dy, &z, &m);
+              } else
+                {
+                  gaiaGetPoint(ring->Coords, iv, &dx, &dy);
+                }
+              x = (int) ((dx - FrameMinX) / PixelRatio);
+              y = FrameHeight - (int) ((dy - FrameMinY) / PixelRatio);
+              if (iv == 0)
+                {
+                  rl2_graph_move_to_point(ctx, x, y);
+                  lastX = x;
+                  lastY = y;
+              } else
+                {
+                  if (x == lastX && y == lastY)
+                    ;
+                  else
+                    {
+                      rl2_graph_add_line_to_path(ctx, x, y);
+                      lastX = x;
+                      lastY = y;
+                    }
+                }
+            }
+          rl2_graph_close_subpath(ctx);
+        }
+      rl2_graph_fill_path(ctx, 1);
+      rl2_graph_stroke_path(ctx, 0);
+      pg = pg->Next;
+    }
+
+// setting standard graphic setting for Linestrings
+  if (odd_even == false)
+    rl2_graph_set_pen(ctx, 0, 0, 255, 255, 4, RL2_PENSTYLE_SOLID);
+  else
+    rl2_graph_set_pen(ctx, 255, 0, 0, 255, 4, RL2_PENSTYLE_SOLID);
+  gaiaLinestringPtr ln = geom->FirstLinestring;
+  while (ln)
+    {
+      // drawing a LINESTRING
+      int iv;
+      double dx;
+      double dy;
+      double z;
+      double m;
+      int x;
+      int y;
+      int lastX = 0;
+      int lastY = 0;
+      for (iv = 0; iv < ln->Points; iv++)
+        {
+          if (ln->DimensionModel == GAIA_XY_Z)
+            {
+              gaiaGetPointXYZ(ln->Coords, iv, &dx, &dy, &z);
+          } else if (ln->DimensionModel == GAIA_XY_M)
+            {
+              gaiaGetPointXYM(ln->Coords, iv, &dx, &dy, &m);
+          } else if (ln->DimensionModel == GAIA_XY_Z_M)
+            {
+              gaiaGetPointXYZM(ln->Coords, iv, &dx, &dy, &z, &m);
+          } else
+            {
+              gaiaGetPoint(ln->Coords, iv, &dx, &dy);
+            }
+          x = (int) ((dx - FrameMinX) / PixelRatio);
+          y = FrameHeight - (int) ((dy - FrameMinY) / PixelRatio);
+          if (iv == 0)
+            {
+              rl2_graph_move_to_point(ctx, x, y);
+              lastX = x;
+              lastY = y;
+          } else
+            {
+              if (x == lastX && y == lastY)
+                ;
+              else
+                {
+                  rl2_graph_add_line_to_path(ctx, x, y);
+                  lastX = x;
+                  lastY = y;
+                }
+            }
+        }
+      rl2_graph_stroke_path(ctx, 0);
+      ln = ln->Next;
+    }
+
+// setting standard graphic setting for Points
+  if (odd_even == false)
+    {
+      rl2_graph_set_pen(ctx, 0, 0, 255, 255, 1, RL2_PENSTYLE_SOLID);
+      rl2_graph_set_brush(ctx, 255, 255, 0, 128);
+  } else
+    {
+      rl2_graph_set_pen(ctx, 255, 0, 0, 255, 1, RL2_PENSTYLE_SOLID);
+      rl2_graph_set_brush(ctx, 0, 255, 255, 128);
+    }
+  gaiaPointPtr pt = geom->FirstPoint;
+  while (pt)
+    {
+      // drawing a POINT
+      x = (int) ((pt->X - FrameMinX) / PixelRatio);
+      y = FrameHeight - (int) ((pt->Y - FrameMinY) / PixelRatio);
+      rl2_graph_draw_ellipse(ctx, x - 10, y - 10, 20, 20);
+      pt = pt->Next;
+    }
+
+// preparing the Marker image
+  unsigned char *rgb = rl2_graph_get_context_rgb_array(ctx);
+  unsigned char *alpha = rl2_graph_get_context_alpha_array(ctx);
+  image = wxImage(FrameWidth, FrameHeight);
+  image.SetData(rgb);
+  image.SetAlpha(alpha);
+  rl2_graph_destroy_context(ctx);
+}
+
+void MyMapView::ResetMarker()
+{
+// stops the Dynamic Marker
+  if (TimerDynamic)
+    {
+      TimerDynamic->Stop();
+      delete TimerDynamic;
+    }
+  TimerDynamic = NULL;
+  ImageMarkerOdd.Destroy();
+  ImageMarkerEven.Destroy();
+  ResetScreenBitmap();
+}
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..e69de29
diff --git a/Printer.cpp b/Printer.cpp
new file mode 100644
index 0000000..bebf7fb
--- /dev/null
+++ b/Printer.cpp
@@ -0,0 +1,1402 @@
+/*
+/ Printer.cpp
+/ PDF / TIFF export modules
+/
+/ version 1.0, 2013 October 1
+/
+/ Author: Sandro Furieri a-furieri at lqt.it
+/
+/ Copyright (C) 2013  Alessandro Furieri
+/
+/    This program is free software: you can redistribute it and/or modify
+/    it under the terms of the GNU General Public License as published by
+/    the Free Software Foundation, either version 3 of the License, or
+/    (at your option) any later version.
+/
+/    This program is distributed in the hope that it will be useful,
+/    but WITHOUT ANY WARRANTY; without even the implied warranty of
+/    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+/    GNU General Public License for more details.
+/
+/    You should have received a copy of the GNU General Public License
+/    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+/
+*/
+
+#include "Classdef.h"
+
+PdfPrinter::PdfPrinter(MyFrame * parent, const char *path, int dpi,
+                       double page_w, double page_h, double horz_margin_sz,
+                       double vert_margin_sz, bool preserve_scale,
+                       bool preserve_width, bool preserve_height)
+{
+// constructor
+  MainFrame = parent;
+  MapView = parent->GetMapView();
+  int len = strlen(path);
+  Path = new char[len + 1];
+  strcpy(Path, path);
+  FrameWidth = (page_w - (horz_margin_sz * 2.0)) * (double) dpi;
+  FrameHeight = (page_h - (vert_margin_sz * 2.0)) * (double) dpi;
+  Ctx =
+    rl2_graph_create_pdf_context(Path, dpi, page_w, page_h, horz_margin_sz,
+                                 vert_margin_sz);
+  if (preserve_scale == true)
+    InitPreserveScale();
+  if (preserve_width == true)
+    InitPreserveWidth();
+  if (preserve_height == true)
+    InitPreserveHeight();
+  ProgressControl = NULL;
+  FirstRequest = NULL;
+  LastRequest = NULL;
+}
+
+PdfPrinter::~PdfPrinter()
+{
+// destructor
+  WmsGetMapRequest *pR;
+  WmsGetMapRequest *pRn;
+  pR = FirstRequest;
+  while (pR != NULL)
+    {
+      pRn = pR->GetNext();
+      delete pR;
+      pR = pRn;
+    }
+  if (ProgressControl != NULL)
+    delete ProgressControl;
+  if (Path != NULL)
+    delete[]Path;
+  if (Ctx != NULL)
+    rl2_graph_destroy_context(Ctx);
+}
+
+void PdfPrinter::InitPreserveScale()
+{
+// initializing the Map preserving the current Scale
+  FrameCX = MapView->GetFrameCX();
+  FrameCY = MapView->GetFrameCY();
+  PixelRatio = MapView->GetPixelRatio();
+  FrameExtentX = FrameWidth * PixelRatio;
+  FrameExtentY = FrameHeight * PixelRatio;
+  FrameMinX = FrameCX - (FrameExtentX / 2.0);
+  FrameMinY = FrameCY - (FrameExtentY / 2.0);
+  FrameMaxX = FrameCX + (FrameExtentX / 2.0);
+  FrameMaxY = FrameCY + (FrameExtentY / 2.0);
+}
+
+void PdfPrinter::InitPreserveWidth()
+{
+// initializing the Map preserving the current Width
+  FrameCX = MapView->GetFrameCX();
+  FrameCY = MapView->GetFrameCY();
+  double minx = MapView->GetFrameMinX();
+  double maxx = MapView->GetFrameMaxX();
+  double extx = maxx - minx;
+// computing the current PixelRatio
+  PixelRatio = extx / FrameWidth;
+  if (MapView->IsWmsFixedScale())
+    {
+      // adjusting the current scale so to match a Fixed Scale
+      PixelRatio = MapView->GetWmsBestResolution(PixelRatio);
+    }
+  FrameExtentX = FrameWidth * PixelRatio;
+  FrameExtentY = FrameHeight * PixelRatio;
+  FrameMinX = FrameCX - (FrameExtentX / 2.0);
+  FrameMinY = FrameCY - (FrameExtentY / 2.0);
+  FrameMaxX = FrameCX + (FrameExtentX / 2.0);
+  FrameMaxY = FrameCY + (FrameExtentY / 2.0);
+}
+
+void PdfPrinter::InitPreserveHeight()
+{
+// initializing the Map preserving the current Height
+  FrameCX = MapView->GetFrameCX();
+  FrameCY = MapView->GetFrameCY();
+  double miny = MapView->GetFrameMinY();
+  double maxy = MapView->GetFrameMaxY();
+  double exty = maxy - miny;
+// computing the current PixelRatio
+  PixelRatio = exty / FrameHeight;
+  if (MapView->IsWmsFixedScale())
+    {
+      // adjusting the current scale so to match a Fixed Scale
+      PixelRatio = MapView->GetWmsBestResolution(PixelRatio);
+    }
+  FrameExtentX = FrameWidth * PixelRatio;
+  FrameExtentY = FrameHeight * PixelRatio;
+  FrameMinX = FrameCX - (FrameExtentX / 2.0);
+  FrameMinY = FrameCY - (FrameExtentY / 2.0);
+  FrameMaxX = FrameCX + (FrameExtentX / 2.0);
+  FrameMaxY = FrameCY + (FrameExtentY / 2.0);
+}
+
+void PdfPrinter::Go()
+{
+// preparing to print the PDF map
+  WmsLayer *layer = MapView->GetLastLayer();
+  while (layer != NULL)
+    {
+      if (layer->IsVisible()
+          && layer->IsCovered(FrameMinX, FrameMinY, FrameMaxX, FrameMaxY))
+        {
+          double baseX;
+          double baseY;
+          double tileW = FrameMaxX - FrameMinX;
+          double tileH = FrameMaxY - FrameMinY;
+          int tile_width = FrameWidth;
+          int tile_height = FrameHeight;
+          WmsTilePattern *tilepattern = NULL;
+          bool tileservice_layer = false;
+          if (layer->GetTileServiceLayer() != NULL)
+            {
+              // TileService layer
+              WmsTileServiceLayer *pTL = layer->GetTileServiceLayer();
+              tileservice_layer = true;
+              if (pTL->GetTileParams(PixelRatio, FrameMinX,
+                                     FrameMinY,
+                                     &tile_width,
+                                     &tile_height, &tileW,
+                                     &tileH, &baseX,
+                                     &baseY, &tilepattern) == false)
+                {
+                  layer = layer->GetPrev();
+                  continue;
+                }
+          } else
+            {
+              // ordinary WMS layer
+              if (layer->IsTiled())
+                {
+                  tileW = (double) (layer->GetTileWidth()) * PixelRatio;
+                  tileH = (double) (layer->GetTileHeight()) * PixelRatio;
+                  tile_width = layer->GetTileWidth();
+                  tile_height = layer->GetTileHeight();
+                }
+              if (layer->IsSwapXY())
+                MapView->GetTileOrigin(layer->GetMinY(), layer->GetMinX(),
+                                       FrameMinX, FrameMinY, tileW, tileH,
+                                       &baseX, &baseY);
+              else
+                MapView->GetTileOrigin(layer->GetMinX(), layer->GetMinY(),
+                                       FrameMinX, FrameMinY, tileW, tileH,
+                                       &baseX, &baseY);
+            }
+          int image_x = (baseX - FrameMinX) / PixelRatio;
+          int image_y = FrameHeight + ((FrameMinY - baseY) / PixelRatio);
+          WmsTileSet *tileSet;
+          tileSet =
+            new WmsTileSet(FrameMinX, FrameMinY, FrameMaxX, FrameMaxY,
+                           baseX, baseY, tileW, tileH, image_x, image_y,
+                           FrameWidth, FrameHeight, tile_width, tile_height);
+
+          // preparing the Tile Requests
+          double pos_y = baseY;
+          int row_no = 0;
+          double lim_x = FrameMaxX;
+          double lim_y = FrameMaxY;
+          layer->MaxLimits(&lim_x, &lim_y);
+          while (pos_y < lim_y)
+            {
+              // looping on tile-rows (bottom-up)
+              double pos_x = baseX;
+              int col_no = 0;
+              while (pos_x < lim_x)
+                {
+                  // looping on tile-cols (left-right)
+                  tileSet->AddTile(pos_x, pos_y, row_no, col_no);
+                  pos_x += tileW;
+                  col_no++;
+                }
+              pos_y += tileH;
+              row_no++;
+            }
+
+          WmsTileRequest *tile = tileSet->GetFirst();
+          while (tile != NULL)
+            {
+              // looping on tile requests   
+              if (tileservice_layer == true)
+                {
+                  WmsTileServiceLayer *pTL = layer->GetTileServiceLayer();
+                  AddGetMapRequest(tile->GetImageX(), tile->GetImageY(),
+                                   layer->GetWmsService()->GetURL_GetMap_Get(),
+                                   pTL->GetName(), layer->IsSwapXY(),
+                                   tile->GetMinX(), tile->GetMinY(),
+                                   tile->GetMaxX(), tile->GetMaxY(),
+                                   tileSet->GetTileWidth(),
+                                   tileSet->GetTileHeight(), tilepattern);
+              } else
+                {
+                  AddGetMapRequest(tile->GetImageX(), tile->GetImageY(),
+                                   layer->GetWmsService()->GetURL_GetMap_Get(),
+                                   layer->GetVersion(), layer->GetName(),
+                                   layer->GetCRS(), layer->IsSwapXY(),
+                                   tile->GetMinX(), tile->GetMinY(),
+                                   tile->GetMaxX(), tile->GetMaxY(),
+                                   tileSet->GetTileWidth(),
+                                   tileSet->GetTileHeight(),
+                                   layer->GetStyleName(), layer->GetFormat(),
+                                   layer->IsOpaque());
+                }
+              tile = tile->GetNext();
+            }
+          delete tileSet;
+        }
+      layer = layer->GetPrev();
+    }
+
+// creating the Progress control
+  if (ProgressControl != NULL)
+    {
+      delete ProgressControl;
+      ProgressControl = NULL;
+    }
+  wxRect rect;
+  if (MainFrame->GetProgressRect(rect) == true)
+    {
+      wxPoint pt = wxPoint(rect.GetX(), rect.GetY());
+      wxSize sz = wxSize(rect.GetWidth(), rect.GetHeight());
+      ProgressControl =
+        new wxGauge(MainFrame->GetStatusBar(), wxID_ANY, CountGetMapRequests(),
+                    pt, sz);
+    }
+  MapView->SetPrintInProgress(this);
+  MainFrame->UpdateWmsAbortTool(true);
+
+#ifdef _WIN32
+  HANDLE thread_handle;
+  DWORD dwThreadId;
+  thread_handle =
+    CreateThread(NULL, 0, DoPdfDownloadTilesThread, this, 0, &dwThreadId);
+  SetThreadPriority(thread_handle, THREAD_PRIORITY_IDLE);
+#else
+  pthread_t thread_id;
+  int ok_prior = 0;
+  int policy;
+  int min_prio;
+  pthread_attr_t attr;
+  struct sched_param sp;
+  pthread_attr_init(&attr);
+  if (pthread_attr_setschedpolicy(&attr, SCHED_RR) == 0)
+    {
+      // attempting to set the lowest priority  
+      if (pthread_attr_getschedpolicy(&attr, &policy) == 0)
+        {
+          min_prio = sched_get_priority_min(policy);
+          sp.sched_priority = min_prio;
+          if (pthread_attr_setschedparam(&attr, &sp) == 0)
+            {
+              // ok, setting the lowest priority  
+              ok_prior = 1;
+              pthread_create(&thread_id, &attr, DoPdfDownloadTilesThread, this);
+            }
+        }
+    }
+  if (!ok_prior)
+    {
+      // failure: using standard priority
+      pthread_create(&thread_id, NULL, DoPdfDownloadTilesThread, this);
+    }
+#endif
+}
+
+#ifdef _WIN32
+DWORD WINAPI DoPdfDownloadTilesThread(void *arg)
+#else
+void *DoPdfDownloadTilesThread(void *arg)
+#endif
+{
+//
+// threaded function: downloading WMS tiles
+//
+  PdfPrinter *Pdf = (PdfPrinter *) arg;
+  MyMapView *MapView = Pdf->GetMapView();
+  WmsLayer *layer = MapView->GetLastLayer();
+  while (layer != NULL)
+    {
+      if (MapView->IsPendingWmsAbort() == true)
+        break;
+      if (layer->GetTileServiceLayer() != NULL)
+        Pdf->Consider(layer->GetTileServiceLayer()->GetName());
+      else
+        Pdf->Consider(layer->GetName());
+      WmsGetMapRequest *req = Pdf->GetFirstRequest();
+      while (req != NULL)
+        {
+          // attempting first to display already cached tiles
+          if (MapView->IsPendingWmsAbort() == true)
+            break;
+          if (req->IsTileService() == true
+              && layer->GetTileServiceLayer() != NULL)
+            {
+              if (MapView->IsPendingWmsAbort() == true)
+                break;
+              if (strcmp
+                  (layer->GetTileServiceLayer()->GetName(),
+                   req->GetLayerName()) == 0)
+                req->ExecutePrint(1);
+            }
+          if (req->IsTileService() == false
+              && layer->GetTileServiceLayer() == NULL)
+            {
+              if (MapView->IsPendingWmsAbort() == true)
+                break;
+              if (strcmp(layer->GetName(), req->GetLayerName()) == 0)
+                req->ExecutePrint(1);
+            }
+          req = req->GetNext();
+        }
+      for (int retry_count = 0; retry_count < 5; retry_count++)
+        {
+          bool retry = false;
+          req = Pdf->GetFirstRequest();
+          while (req != NULL)
+            {
+              // downloading any not already cached tile
+              bool ret = true;
+              if (MapView->IsPendingWmsAbort() == true)
+                break;
+              if (req->IsTileService() == true
+                  && layer->GetTileServiceLayer() != NULL)
+                {
+                  if (MapView->IsPendingWmsAbort() == true)
+                    break;
+                  if (strcmp
+                      (layer->GetTileServiceLayer()->GetName(),
+                       req->GetLayerName()) == 0
+                      && req->IsImageReady() == false)
+                    ret = req->ExecutePrint(0);
+                }
+              if (req->IsTileService() == false
+                  && layer->GetTileServiceLayer() == NULL)
+                {
+                  if (MapView->IsPendingWmsAbort() == true)
+                    break;
+                  if (strcmp(layer->GetName(), req->GetLayerName()) == 0
+                      && req->IsImageReady() == false)
+                    ret = req->ExecutePrint(0);
+                }
+              if (ret == false)
+                retry = true;
+              req = req->GetNext();
+            }
+          if (retry == false)
+            break;
+        }
+      layer = layer->GetPrev();
+    }
+  wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED,
+                       ID_PDF_WMS_THREAD_FINISHED);
+  MapView->GetEventHandler()->AddPendingEvent(event);
+#ifdef _WIN32
+  return 0;
+#else
+  pthread_exit(NULL);
+#endif
+}
+
+void PdfPrinter::AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                                  const char *version,
+                                  const char *layer,
+                                  const char *crs, int swap_xy,
+                                  double minx, double miny,
+                                  double maxx, double maxy,
+                                  int width, int height,
+                                  const char *style,
+                                  const char *format, int opaque)
+{
+// appending a GetMap request into the list [Ordinary]
+  rl2WmsCachePtr cache_handle = MainFrame->GetWmsCache();
+  WmsGetMapRequest *req = new WmsGetMapRequest(pos_x, pos_y, cache_handle, url,
+                                               MapView->GetProxy(), version,
+                                               layer, crs, swap_xy, minx, miny,
+                                               maxx, maxy, width, height, style,
+                                               format, opaque, 0);
+  if (FirstRequest == NULL)
+    FirstRequest = req;
+  if (LastRequest != NULL)
+    LastRequest->SetNext(req);
+  LastRequest = req;
+}
+
+void PdfPrinter::AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                                  const char *layer, int swap_xy,
+                                  double minx, double miny,
+                                  double maxx, double maxy, int width,
+                                  int height, WmsTilePattern * tilepattern)
+{
+// appending a GetMap request into the list [TileService]
+  rl2WmsCachePtr cache_handle = MainFrame->GetWmsCache();
+  WmsGetMapRequest *req = new WmsGetMapRequest(pos_x, pos_y, cache_handle, url,
+                                               MapView->GetProxy(), layer,
+                                               swap_xy, minx, miny,
+                                               maxx, maxy, width, height,
+                                               tilepattern, 0);
+  if (FirstRequest == NULL)
+    FirstRequest = req;
+  if (LastRequest != NULL)
+    LastRequest->SetNext(req);
+  LastRequest = req;
+}
+
+int PdfPrinter::CountGetMapRequests()
+{
+// counting how many pending GetMap requests are queued
+  int count = 0;
+  WmsGetMapRequest *pR = FirstRequest;
+  while (pR != NULL)
+    {
+      count++;
+      pR = pR->GetNext();
+    }
+  return count;
+}
+
+void PdfPrinter::Consider()
+{
+// enabling the whole GetMap requests list
+  WmsGetMapRequest *pR = FirstRequest;
+  while (pR != NULL)
+    {
+      pR->Consider();
+      pR = pR->GetNext();
+    }
+}
+
+void PdfPrinter::Consider(const char *layer_name)
+{
+// enabling the GetMap requests list for a selected layer
+  WmsGetMapRequest *pR = FirstRequest;
+  while (pR != NULL)
+    {
+      if (strcmp(pR->GetLayerName(), layer_name) == 0)
+        pR->Consider();
+      pR = pR->GetNext();
+    }
+}
+
+void PdfPrinter::UpdatePendingTiles()
+{
+// updating any available tile on the PDF canvass
+  int count = 0;
+  WmsLayer *layer = MapView->GetLastLayer();
+  while (layer != NULL)
+    {
+      WmsGetMapRequest *req = FirstRequest;
+      while (req != NULL)
+        {
+          if (req->ToBeIgnored() == true)
+            {
+              req = req->GetNext();
+              continue;
+            }
+          bool skip = true;
+          if (req->IsTileService() == true
+              && layer->GetTileServiceLayer() != NULL)
+            {
+              if (strcmp
+                  (layer->GetTileServiceLayer()->GetName(),
+                   req->GetLayerName()) == 0)
+                skip = false;
+            }
+          if (req->IsTileService() == false
+              && layer->GetTileServiceLayer() == NULL)
+            {
+              if (strcmp(layer->GetName(), req->GetLayerName()) == 0)
+                skip = false;
+            }
+          if (skip == true)
+            {
+              req = req->GetNext();
+              continue;
+            }
+          if (req->IsImageReady() == true && req->IsImageDone() == false
+              && req->GetRGBA() != NULL)
+            {
+              PrintTile(req->GetRGBA(), req->GetPosX(), req->GetPosY(),
+                        req->GetWidth(), req->GetHeight());
+              req->Done();
+            }
+          if (req->IsImageDone() == true)
+            count++;
+          req = req->GetNext();
+        }
+      layer = layer->GetPrev();
+    }
+// updating the Progress control
+  if (ProgressControl != NULL)
+    {
+      ProgressControl->Show();
+      if (count == 0)
+        ProgressControl->Pulse();
+      else
+        ProgressControl->SetValue(count);
+    }
+}
+
+void PdfPrinter::PrintTile(unsigned char *rgba, int pos_x, int pos_y, int width,
+                           int height)
+{
+// printing some WMS tile
+  if (rgba == NULL)
+    return;
+
+// creating a Graphics Bitmap 
+  rl2GraphicsBitmapPtr bmp = rl2_graph_create_bitmap(rgba, width, height);
+  if (bmp == NULL)
+    return;
+// rendering the Bitmap 
+  if (Ctx != NULL)
+    rl2_graph_draw_bitmap(Ctx, bmp, pos_x, pos_y);
+  rl2_graph_destroy_bitmap(bmp);
+}
+
+TiffWriter::TiffWriter(MyFrame * parent, const char *path, int width,
+                       int height, bool geo_tiff, bool has_worldfile,
+                       unsigned char compression, bool is_tiled,
+                       int tile_size, bool preserve_scale,
+                       bool preserve_width, bool preserve_height)
+{
+// constructor
+  MainFrame = parent;
+  MapView = parent->GetMapView();
+  int len = strlen(path);
+  Path = new char[len + 1];
+  strcpy(Path, path);
+  FrameWidth = width;
+  FrameHeight = height;
+  Pixels = (unsigned char *) malloc(width * height * 3);
+  if (Pixels != NULL)
+    memset(Pixels, 255, width * height * 3);
+  TotPixels = 0;
+  MonoPixels = 0;
+  GrayPixels = 0;
+  MaxPalette = 0;
+  IsTiled = is_tiled;
+  TileSize = tile_size;
+  GeoTiff = geo_tiff;
+  Worldfile = has_worldfile;
+  Compression = compression;
+  ColorSpace = RL2_PIXEL_RGB;
+  if (preserve_scale == true)
+    InitPreserveScale();
+  if (preserve_width == true)
+    InitPreserveWidth();
+  if (preserve_height == true)
+    InitPreserveHeight();
+  ProgressControl = NULL;
+  FirstRequest = NULL;
+  LastRequest = NULL;
+}
+
+TiffWriter::~TiffWriter()
+{
+// destructor
+  WmsGetMapRequest *pR;
+  WmsGetMapRequest *pRn;
+  if (Pixels != NULL)
+    free(Pixels);
+  pR = FirstRequest;
+  while (pR != NULL)
+    {
+      pRn = pR->GetNext();
+      delete pR;
+      pR = pRn;
+    }
+  if (ProgressControl != NULL)
+    delete ProgressControl;
+  if (Path != NULL)
+    delete[]Path;
+}
+
+void TiffWriter::InitPreserveScale()
+{
+// initializing the Map preserving the current Scale
+  FrameCX = MapView->GetFrameCX();
+  FrameCY = MapView->GetFrameCY();
+  PixelRatio = MapView->GetPixelRatio();
+  FrameExtentX = (double) FrameWidth *PixelRatio;
+  FrameExtentY = (double) FrameHeight *PixelRatio;
+  FrameMinX = FrameCX - (FrameExtentX / 2.0);
+  FrameMinY = FrameCY - (FrameExtentY / 2.0);
+  FrameMaxX = FrameCX + (FrameExtentX / 2.0);
+  FrameMaxY = FrameCY + (FrameExtentY / 2.0);
+}
+
+void TiffWriter::InitPreserveWidth()
+{
+// initializing the Map preserving the current Width
+  FrameCX = MapView->GetFrameCX();
+  FrameCY = MapView->GetFrameCY();
+  double minx = MapView->GetFrameMinX();
+  double maxx = MapView->GetFrameMaxX();
+  double extx = maxx - minx;
+// computing the current PixelRatio
+  PixelRatio = extx / (double) (FrameWidth);
+  FrameExtentX = (double) FrameWidth *PixelRatio;
+  FrameExtentY = (double) FrameHeight *PixelRatio;
+  FrameMinX = FrameCX - (FrameExtentX / 2.0);
+  FrameMinY = FrameCY - (FrameExtentY / 2.0);
+  FrameMaxX = FrameCX + (FrameExtentX / 2.0);
+  FrameMaxY = FrameCY + (FrameExtentY / 2.0);
+  if (MapView->IsWmsFixedScale())
+    {
+      // adjusting the current scale so to match a Fixed Scale
+      PixelRatio = MapView->GetWmsBestResolution(PixelRatio);
+    }
+}
+
+void TiffWriter::InitPreserveHeight()
+{
+// initializing the Map preserving the current Height
+  FrameCX = MapView->GetFrameCX();
+  FrameCY = MapView->GetFrameCY();
+  double miny = MapView->GetFrameMinY();
+  double maxy = MapView->GetFrameMaxY();
+  double exty = maxy - miny;
+// computing the current PixelRatio
+  PixelRatio = exty / (double) (FrameHeight);
+  FrameExtentX = (double) FrameWidth *PixelRatio;
+  FrameExtentY = (double) FrameHeight *PixelRatio;
+  FrameMinX = FrameCX - (FrameExtentX / 2.0);
+  FrameMinY = FrameCY - (FrameExtentY / 2.0);
+  FrameMaxX = FrameCX + (FrameExtentX / 2.0);
+  FrameMaxY = FrameCY + (FrameExtentY / 2.0);
+  if (MapView->IsWmsFixedScale())
+    {
+      // adjusting the current scale so to match a Fixed Scale
+      PixelRatio = MapView->GetWmsBestResolution(PixelRatio);
+    }
+}
+
+int TiffWriter::GetSrid()
+{
+// returning the current SRID
+  int srid = MapView->GetSridFromCRS(MapView->GetLastLayer()->GetCRS());
+  if (srid == 84)
+    srid = 4326;
+  return srid;
+}
+
+void TiffWriter::Go()
+{
+// preparing to print the TIFF image
+  WmsLayer *layer = MapView->GetLastLayer();
+  while (layer != NULL)
+    {
+      if (layer->IsVisible()
+          && layer->IsCovered(FrameMinX, FrameMinY, FrameMaxX, FrameMaxY))
+        {
+          double baseX;
+          double baseY;
+          double tileW = FrameMaxX - FrameMinX;
+          double tileH = FrameMaxY - FrameMinY;
+          int tile_width = FrameWidth;
+          int tile_height = FrameHeight;
+          WmsTilePattern *tilepattern = NULL;
+          bool tileservice_layer = false;
+          if (layer->GetTileServiceLayer() != NULL)
+            {
+              // TileService layer
+              WmsTileServiceLayer *pTL = layer->GetTileServiceLayer();
+              tileservice_layer = true;
+              if (pTL->GetTileParams(PixelRatio, FrameMinX,
+                                     FrameMinY,
+                                     &tile_width,
+                                     &tile_height, &tileW,
+                                     &tileH, &baseX,
+                                     &baseY, &tilepattern) == false)
+                {
+                  layer = layer->GetPrev();
+                  continue;
+                }
+          } else
+            {
+              // ordinary WMS layer
+              if (layer->IsTiled())
+                {
+                  tileW = (double) (layer->GetTileWidth()) * PixelRatio;
+                  tileH = (double) (layer->GetTileHeight()) * PixelRatio;
+                  tile_width = layer->GetTileWidth();
+                  tile_height = layer->GetTileHeight();
+                }
+              if (layer->IsSwapXY())
+                MapView->GetTileOrigin(layer->GetMinY(), layer->GetMinX(),
+                                       FrameMinX, FrameMinY, tileW, tileH,
+                                       &baseX, &baseY);
+              else
+                MapView->GetTileOrigin(layer->GetMinX(), layer->GetMinY(),
+                                       FrameMinX, FrameMinY, tileW, tileH,
+                                       &baseX, &baseY);
+            }
+          int image_x = (baseX - FrameMinX) / PixelRatio;
+          int image_y = FrameHeight + ((FrameMinY - baseY) / PixelRatio);
+          WmsTileSet *tileSet;
+          tileSet =
+            new WmsTileSet(FrameMinX, FrameMinY, FrameMaxX, FrameMaxY,
+                           baseX, baseY, tileW, tileH, image_x, image_y,
+                           FrameWidth, FrameHeight, tile_width, tile_height);
+
+          // preparing the Tile Requests
+          double pos_y = baseY;
+          int row_no = 0;
+          double lim_x = FrameMaxX;
+          double lim_y = FrameMaxY;
+          layer->MaxLimits(&lim_x, &lim_y);
+          while (pos_y < lim_y)
+            {
+              // looping on tile-rows (bottom-up)
+              double pos_x = baseX;
+              int col_no = 0;
+              while (pos_x < lim_x)
+                {
+                  // looping on tile-cols (left-right)
+                  tileSet->AddTile(pos_x, pos_y, row_no, col_no);
+                  pos_x += tileW;
+                  col_no++;
+                }
+              pos_y += tileH;
+              row_no++;
+            }
+
+          WmsTileRequest *tile = tileSet->GetFirst();
+          while (tile != NULL)
+            {
+              // looping on tile requests   
+              if (tileservice_layer == true)
+                {
+                  WmsTileServiceLayer *pTL = layer->GetTileServiceLayer();
+                  AddGetMapRequest(tile->GetImageX(), tile->GetImageY(),
+                                   layer->GetWmsService()->GetURL_GetMap_Get(),
+                                   pTL->GetName(), layer->IsSwapXY(),
+                                   tile->GetMinX(), tile->GetMinY(),
+                                   tile->GetMaxX(), tile->GetMaxY(),
+                                   tileSet->GetTileWidth(),
+                                   tileSet->GetTileHeight(), tilepattern);
+              } else
+                {
+                  AddGetMapRequest(tile->GetImageX(), tile->GetImageY(),
+                                   layer->GetWmsService()->GetURL_GetMap_Get(),
+                                   layer->GetVersion(), layer->GetName(),
+                                   layer->GetCRS(), layer->IsSwapXY(),
+                                   tile->GetMinX(), tile->GetMinY(),
+                                   tile->GetMaxX(), tile->GetMaxY(),
+                                   tileSet->GetTileWidth(),
+                                   tileSet->GetTileHeight(),
+                                   layer->GetStyleName(), layer->GetFormat(),
+                                   layer->IsOpaque());
+                }
+              tile = tile->GetNext();
+            }
+          delete tileSet;
+        }
+      layer = layer->GetPrev();
+    }
+
+// creating the Progress control
+  if (ProgressControl != NULL)
+    {
+      delete ProgressControl;
+      ProgressControl = NULL;
+    }
+  wxRect rect;
+  if (MainFrame->GetProgressRect(rect) == true)
+    {
+      wxPoint pt = wxPoint(rect.GetX(), rect.GetY());
+      wxSize sz = wxSize(rect.GetWidth(), rect.GetHeight());
+      ProgressControl =
+        new wxGauge(MainFrame->GetStatusBar(), wxID_ANY, CountGetMapRequests(),
+                    pt, sz);
+    }
+  MapView->SetPrintInProgress(this);
+  MainFrame->UpdateWmsAbortTool(true);
+
+#ifdef _WIN32
+  HANDLE thread_handle;
+  DWORD dwThreadId;
+  thread_handle =
+    CreateThread(NULL, 0, DoTiffDownloadTilesThread, this, 0, &dwThreadId);
+  SetThreadPriority(thread_handle, THREAD_PRIORITY_IDLE);
+#else
+  pthread_t thread_id;
+  int ok_prior = 0;
+  int policy;
+  int min_prio;
+  pthread_attr_t attr;
+  struct sched_param sp;
+  pthread_attr_init(&attr);
+  if (pthread_attr_setschedpolicy(&attr, SCHED_RR) == 0)
+    {
+      // attempting to set the lowest priority  
+      if (pthread_attr_getschedpolicy(&attr, &policy) == 0)
+        {
+          min_prio = sched_get_priority_min(policy);
+          sp.sched_priority = min_prio;
+          if (pthread_attr_setschedparam(&attr, &sp) == 0)
+            {
+              // ok, setting the lowest priority  
+              ok_prior = 1;
+              pthread_create(&thread_id, &attr, DoTiffDownloadTilesThread,
+                             this);
+            }
+        }
+    }
+  if (!ok_prior)
+    {
+      // failure: using standard priority
+      pthread_create(&thread_id, NULL, DoTiffDownloadTilesThread, this);
+    }
+#endif
+}
+
+#ifdef _WIN32
+DWORD WINAPI DoTiffDownloadTilesThread(void *arg)
+#else
+void *DoTiffDownloadTilesThread(void *arg)
+#endif
+{
+//
+// threaded function: downloading WMS tiles
+//
+  TiffWriter *Tiff = (TiffWriter *) arg;
+  MyMapView *MapView = Tiff->GetMapView();
+  WmsLayer *layer = MapView->GetLastLayer();
+  while (layer != NULL)
+    {
+      if (MapView->IsPendingWmsAbort() == true)
+        break;
+      if (layer->GetTileServiceLayer() != NULL)
+        Tiff->Consider(layer->GetTileServiceLayer()->GetName());
+      else
+        Tiff->Consider(layer->GetName());
+      WmsGetMapRequest *req = Tiff->GetFirstRequest();
+      while (req != NULL)
+        {
+          // attempting first to display already cached tiles
+          if (MapView->IsPendingWmsAbort() == true)
+            break;
+          if (req->IsTileService() == true
+              && layer->GetTileServiceLayer() != NULL)
+            {
+              if (MapView->IsPendingWmsAbort() == true)
+                break;
+              if (strcmp
+                  (layer->GetTileServiceLayer()->GetName(),
+                   req->GetLayerName()) == 0)
+                req->ExecutePrint(1);
+            }
+          if (req->IsTileService() == false
+              && layer->GetTileServiceLayer() == NULL)
+            {
+              if (MapView->IsPendingWmsAbort() == true)
+                break;
+              if (strcmp(layer->GetName(), req->GetLayerName()) == 0)
+                req->ExecutePrint(1);
+            }
+          req = req->GetNext();
+        }
+      for (int retry_count = 0; retry_count < 5; retry_count++)
+        {
+          bool retry = false;
+          req = Tiff->GetFirstRequest();
+          while (req != NULL)
+            {
+              // downloading any not already cached tile
+              bool ret = true;
+              if (MapView->IsPendingWmsAbort() == true)
+                break;
+              if (req->IsTileService() == true
+                  && layer->GetTileServiceLayer() != NULL)
+                {
+                  if (MapView->IsPendingWmsAbort() == true)
+                    break;
+                  if (strcmp
+                      (layer->GetTileServiceLayer()->GetName(),
+                       req->GetLayerName()) == 0
+                      && req->IsImageReady() == false)
+                    ret = req->ExecutePrint(0);
+                }
+              if (req->IsTileService() == false
+                  && layer->GetTileServiceLayer() == NULL)
+                {
+                  if (MapView->IsPendingWmsAbort() == true)
+                    break;
+                  if (strcmp(layer->GetName(), req->GetLayerName()) == 0
+                      && req->IsImageReady() == false)
+                    ret = req->ExecutePrint(0);
+                }
+              if (ret == false)
+                retry = true;
+              req = req->GetNext();
+            }
+          if (retry == false)
+            break;
+        }
+      layer = layer->GetPrev();
+    }
+  wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED,
+                       ID_TIFF_WMS_THREAD_FINISHED);
+  MapView->GetEventHandler()->AddPendingEvent(event);
+#ifdef _WIN32
+  return 0;
+#else
+  pthread_exit(NULL);
+#endif
+}
+
+void TiffWriter::AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                                  const char *version,
+                                  const char *layer,
+                                  const char *crs, int swap_xy,
+                                  double minx, double miny,
+                                  double maxx, double maxy,
+                                  int width, int height,
+                                  const char *style,
+                                  const char *format, int opaque)
+{
+// appending a GetMap request into the list [Ordinary]
+  rl2WmsCachePtr cache_handle = MainFrame->GetWmsCache();
+  WmsGetMapRequest *req = new WmsGetMapRequest(pos_x, pos_y, cache_handle, url,
+                                               MapView->GetProxy(), version,
+                                               layer, crs, swap_xy, minx, miny,
+                                               maxx, maxy, width, height, style,
+                                               format, opaque, 0);
+  if (FirstRequest == NULL)
+    FirstRequest = req;
+  if (LastRequest != NULL)
+    LastRequest->SetNext(req);
+  LastRequest = req;
+}
+
+void TiffWriter::AddGetMapRequest(int pos_x, int pos_y, const char *url,
+                                  const char *layer, int swap_xy,
+                                  double minx, double miny,
+                                  double maxx, double maxy, int width,
+                                  int height, WmsTilePattern * tilepattern)
+{
+// appending a GetMap request into the list [TileService]
+  rl2WmsCachePtr cache_handle = MainFrame->GetWmsCache();
+  WmsGetMapRequest *req = new WmsGetMapRequest(pos_x, pos_y, cache_handle, url,
+                                               MapView->GetProxy(), layer,
+                                               swap_xy, minx, miny,
+                                               maxx, maxy, width, height,
+                                               tilepattern, 0);
+  if (FirstRequest == NULL)
+    FirstRequest = req;
+  if (LastRequest != NULL)
+    LastRequest->SetNext(req);
+  LastRequest = req;
+}
+
+int TiffWriter::CountGetMapRequests()
+{
+// counting how many pending GetMap requests are queued
+  int count = 0;
+  WmsGetMapRequest *pR = FirstRequest;
+  while (pR != NULL)
+    {
+      count++;
+      pR = pR->GetNext();
+    }
+  return count;
+}
+
+void TiffWriter::Consider()
+{
+// enabling the whole GetMap requests list
+  WmsGetMapRequest *pR = FirstRequest;
+  while (pR != NULL)
+    {
+      pR->Consider();
+      pR = pR->GetNext();
+    }
+}
+
+void TiffWriter::Consider(const char *layer_name)
+{
+// enabling the GetMap requests list for a selected layer
+  WmsGetMapRequest *pR = FirstRequest;
+  while (pR != NULL)
+    {
+      if (strcmp(pR->GetLayerName(), layer_name) == 0)
+        pR->Consider();
+      pR = pR->GetNext();
+    }
+}
+
+void TiffWriter::UpdatePendingTiles()
+{
+// updating any available tile on the TIFF canvass
+  int count = 0;
+  WmsLayer *layer = MapView->GetLastLayer();
+  while (layer != NULL)
+    {
+      WmsGetMapRequest *req = FirstRequest;
+      while (req != NULL)
+        {
+          if (req->ToBeIgnored() == true)
+            {
+              req = req->GetNext();
+              continue;
+            }
+          bool skip = true;
+          if (req->IsTileService() == true
+              && layer->GetTileServiceLayer() != NULL)
+            {
+              if (strcmp
+                  (layer->GetTileServiceLayer()->GetName(),
+                   req->GetLayerName()) == 0)
+                skip = false;
+            }
+          if (req->IsTileService() == false
+              && layer->GetTileServiceLayer() == NULL)
+            {
+              if (strcmp(layer->GetName(), req->GetLayerName()) == 0)
+                skip = false;
+            }
+          if (skip == true)
+            {
+              req = req->GetNext();
+              continue;
+            }
+          if (req->IsImageReady() == true && req->IsImageDone() == false
+              && req->GetRGBA() != NULL)
+            {
+              PrintTile(req->GetRGBA(), req->GetPosX(), req->GetPosY(),
+                        req->GetWidth(), req->GetHeight());
+              req->Done();
+            }
+          if (req->IsImageDone() == true)
+            count++;
+          req = req->GetNext();
+        }
+      layer = layer->GetPrev();
+    }
+// updating the Progress control
+  if (ProgressControl != NULL)
+    {
+      ProgressControl->Show();
+      if (count == 0)
+        ProgressControl->Pulse();
+      else
+        ProgressControl->SetValue(count);
+    }
+}
+
+void TiffWriter::PrintTile(unsigned char *rgba, int pos_x, int pos_y, int width,
+                           int height)
+{
+// printing some WMS tile
+  if (rgba == NULL)
+    return;
+
+  for (int y = 0; y < height; y++)
+    {
+      int img_y = pos_y + y;
+      unsigned char *p_in = rgba + (y * width * 4);
+      unsigned char *p_line = Pixels + (img_y * (FrameWidth * 3));
+      if (img_y < 0 || img_y >= FrameHeight)
+        continue;
+      for (int x = 0; x < width; x++)
+        {
+          int img_x = pos_x + x;
+          unsigned char *p_out = p_line + (img_x * 3);
+          unsigned char r = *p_in++;
+          unsigned char g = *p_in++;
+          unsigned char b = *p_in++;
+          unsigned char alpha = *p_in++;
+          if (alpha < 192)
+            {
+              /* skipping mostly transparent pixels */
+              continue;
+            }
+          if (img_x < 0 || img_x > FrameWidth)
+            continue;
+          *p_out++ = r;
+          *p_out++ = g;
+          *p_out++ = b;
+          TotPixels++;
+          if (r == g && r == b)
+            {
+              /* Gray pixel */
+              GrayPixels++;
+            }
+          if ((r == 0 && g == 0 && b == 0)
+              || (r == 255 && g == 255 && b == 255))
+            {
+              /* Monochrome pixel */
+              MonoPixels++;
+            }
+          if (MaxPalette <= 256)
+            {
+              /* testing for Palette colorspace */
+              int ok = 0;
+              for (int i = 0; i < MaxPalette; i++)
+                {
+                  if (Red[i] == r && Green[i] == g && Blue[i] == b)
+                    {
+                      /* matches an already defined entry */
+                      ok = 1;
+                      break;
+                    }
+                }
+              if (!ok)
+                {
+                  if (MaxPalette == 256)
+                    {
+                      /* surely not a Palette - invalidating */
+                      MaxPalette = 257;
+                  } else
+                    {
+                      /* inserting a new Palette entry */
+                      Red[MaxPalette] = r;
+                      Green[MaxPalette] = g;
+                      Blue[MaxPalette] = b;
+                      MaxPalette++;
+                    }
+                }
+            }
+        }
+    }
+}
+
+rl2PalettePtr TiffWriter::BuildPalette()
+{
+// building a Palette
+  rl2PalettePtr palette = rl2_create_palette(MaxPalette);
+  for (int i = 0; i < MaxPalette; i++)
+    rl2_set_palette_color(palette, i, Red[i], Green[i], Blue[i]);
+  return palette;
+}
+
+unsigned char TiffWriter::FindPaletteIndex(unsigned char red,
+                                           unsigned char green,
+                                           unsigned char blue)
+{
+// retrieving a Palette index matching an RGB color
+  int index;
+  for (index = 0; index < MaxPalette; index++)
+    {
+      if (Red[index] == red && Green[index] == green && Blue[index] == blue)
+        return index;
+    }
+  return 0;
+}
+
+void TiffWriter::ExportImage()
+{
+// exporting the TIFF Image
+  rl2TiffDestinationPtr tiff;
+  int n_samples = 1;
+  unsigned char sample = RL2_SAMPLE_UINT8;
+  unsigned char *bufpix;
+  int bufpix_size;
+  rl2PalettePtr palette;
+  rl2PalettePtr palette2;
+  int x;
+  int y;
+  const unsigned char *p_in;
+  unsigned char *p_out;
+
+  if (ColorSpace == RL2_PIXEL_PALETTE)
+    palette = BuildPalette();
+  else
+    palette = NULL;
+  if (ColorSpace == RL2_PIXEL_RGB)
+    n_samples = 3;
+  if (ColorSpace == RL2_PIXEL_MONOCHROME)
+    sample = RL2_SAMPLE_1_BIT;
+
+// creating the TIFF destination
+  if (GeoTiff == true)
+    tiff =
+      rl2_create_geotiff_destination(Path, MainFrame->GetSQLite(), FrameWidth,
+                                     FrameHeight, sample, ColorSpace, n_samples,
+                                     palette, Compression,
+                                     (IsTiled == true) ? 1 : 0, TileSize,
+                                     GetSrid(), FrameMinX, FrameMinY, FrameMaxX,
+                                     FrameMaxY, PixelRatio, PixelRatio,
+                                     (Worldfile == true) ? 1 : 0);
+  else if (Worldfile == true)
+    tiff =
+      rl2_create_tiff_worldfile_destination(Path, FrameWidth, FrameHeight,
+                                            sample, ColorSpace, n_samples,
+                                            palette, Compression,
+                                            (IsTiled == true) ? 1 : 0, TileSize,
+                                            GetSrid(), FrameMinX, FrameMinY,
+                                            FrameMaxX, FrameMaxY, PixelRatio,
+                                            PixelRatio);
+  else
+    tiff =
+      rl2_create_tiff_destination(Path, FrameWidth, FrameHeight, sample,
+                                  ColorSpace, n_samples, palette, Compression,
+                                  (IsTiled == true) ? 1 : 0, TileSize);
+  if (tiff == NULL)
+    goto error;
+
+  if (IsTiled)
+    {
+      // Tiled TIFF
+      for (int row = 0; row < FrameHeight; row += TileSize)
+        {
+          for (int col = 0; col < FrameWidth; col += TileSize)
+            {
+              // inserting a TIFF tile
+              if (ColorSpace == RL2_PIXEL_PALETTE)
+                palette2 = BuildPalette();
+              else
+                palette2 = NULL;
+              bufpix_size = TileSize * TileSize * n_samples;
+              bufpix = (unsigned char *) malloc(bufpix_size);
+              p_out = bufpix;
+              for (y = 0; y < TileSize; y++)
+                {
+                  if (row + y >= FrameHeight)
+                    {
+                      for (x = 0; x < TileSize; x++)
+                        {
+                          *p_out++ = 0;
+                          *p_out++ = 0;
+                          *p_out++ = 0;
+                        }
+                    }
+                  p_in = Pixels + ((row + y) * FrameWidth * 3) + (col * 3);
+                  for (x = 0; x < TileSize; x++)
+                    {
+                      if (ColorSpace == RL2_PIXEL_RGB)
+                        {
+                          if (col + x >= FrameWidth)
+                            {
+                              *p_out++ = 0;
+                              *p_out++ = 0;
+                              *p_out++ = 0;
+                              continue;
+                            }
+                          *p_out++ = *p_in++;
+                          *p_out++ = *p_in++;
+                          *p_out++ = *p_in++;
+                      } else if (ColorSpace == RL2_PIXEL_GRAYSCALE)
+                        {
+                          if (col + x >= FrameWidth)
+                            {
+                              *p_out++ = 0;
+                              continue;
+                            }
+                          *p_out++ = *p_in++;
+                          p_in += 2;
+                      } else if (ColorSpace == RL2_PIXEL_PALETTE)
+                        {
+                          if (col + x >= FrameWidth)
+                            {
+                              *p_out++ = 0;
+                              continue;
+                            }
+                          unsigned char r = *p_in++;
+                          unsigned char g = *p_in++;
+                          unsigned char b = *p_in++;
+                          unsigned char idx = FindPaletteIndex(r, g, b);
+                          *p_out++ = idx;
+                      } else if (ColorSpace == RL2_PIXEL_MONOCHROME)
+                        {
+                          if (col + x >= FrameWidth)
+                            {
+                              *p_out++ = 0;
+                              continue;
+                            }
+                          if (*p_in++ < 128)
+                            *p_out++ = 1;
+                          else
+                            *p_out++ = 0;
+                          p_in += 2;
+                        }
+                    }
+                }
+              rl2RasterPtr raster = rl2_create_raster(TileSize, TileSize,
+                                                      sample, ColorSpace,
+                                                      n_samples,
+                                                      bufpix, bufpix_size,
+                                                      palette2, NULL, 0, NULL);
+              if (raster == NULL)
+                goto error;
+              if (rl2_write_tiff_tile(tiff, raster, row, col) != RL2_OK)
+                {
+                  rl2_destroy_raster(raster);
+                  goto error;
+                }
+              rl2_destroy_raster(raster);
+            }
+        }
+  } else
+    {
+      // Striped TIFF
+      for (int row = 0; row < FrameHeight; row++)
+        {
+          // inserting a TIFF strip
+          if (ColorSpace == RL2_PIXEL_PALETTE)
+            palette2 = BuildPalette();
+          else
+            palette2 = NULL;
+          bufpix_size = FrameWidth * n_samples;
+          bufpix = (unsigned char *) malloc(bufpix_size);
+          p_in = Pixels + (row * FrameWidth * 3);
+          p_out = bufpix;
+          for (x = 0; x < FrameWidth; x++)
+            {
+              /* feeding the scanline buffer */
+              if (ColorSpace == RL2_PIXEL_RGB)
+                {
+                  *p_out++ = *p_in++;
+                  *p_out++ = *p_in++;
+                  *p_out++ = *p_in++;
+              } else if (ColorSpace == RL2_PIXEL_GRAYSCALE)
+                {
+                  *p_out++ = *p_in++;
+                  p_in += 2;
+              } else if (ColorSpace == RL2_PIXEL_PALETTE)
+                {
+                  unsigned char r = *p_in++;
+                  unsigned char g = *p_in++;
+                  unsigned char b = *p_in++;
+                  unsigned char idx = FindPaletteIndex(r, g, b);
+                  *p_out++ = idx;
+              } else if (ColorSpace == RL2_PIXEL_MONOCHROME)
+                {
+                  if (*p_in++ < 128)
+                    *p_out++ = 1;
+                  else
+                    *p_out++ = 0;
+                  p_in += 2;
+                }
+            }
+          rl2RasterPtr raster = rl2_create_raster(FrameWidth, 1,
+                                                  sample, ColorSpace, n_samples,
+                                                  bufpix, bufpix_size, palette2,
+                                                  NULL, 0, NULL);
+          if (raster == NULL)
+            goto error;
+          if (rl2_write_tiff_scanline(tiff, raster, row) != RL2_OK)
+            {
+              rl2_destroy_raster(raster);
+              goto error;
+            }
+          rl2_destroy_raster(raster);
+        }
+    }
+
+  if (Worldfile == true)
+    rl2_write_tiff_worldfile(tiff);
+
+// destroying the TIFF destination
+  rl2_destroy_tiff_destination(tiff);
+  if (palette != NULL)
+    rl2_destroy_palette(palette);
+  return;
+error:
+  fprintf(stderr, "Unable to export an image: \"%s\"\n", Path);
+  if (tiff != NULL)
+    rl2_destroy_tiff_destination(tiff);
+  if (palette != NULL)
+    rl2_destroy_palette(palette);
+}
diff --git a/README b/README
new file mode 100644
index 0000000..98ed355
--- /dev/null
+++ b/README
@@ -0,0 +1 @@
+If you get build (compilation) errors about missing symbols or types starting with wx, then try installing the GTK version of the WxWidgets packages (if any).
\ No newline at end of file
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644
index 0000000..f209970
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,1324 @@
+# generated automatically by aclocal 1.13.4 -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 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.
+
+m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
+[m4_warning([this file was generated for autoconf 2.69.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically 'autoreconf'.])])
+
+# pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
+# serial 1 (pkg-config-0.24)
+# 
+# Copyright © 2004 Scott James Remnant <scott at netsplit.com>.
+#
+# 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.
+#
+# 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.
+
+# PKG_PROG_PKG_CONFIG([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
+m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])
+AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path])
+AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path])
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+	AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+	_pkg_min_version=m4_default([$1], [0.9.0])
+	AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+	if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+		AC_MSG_RESULT([yes])
+	else
+		AC_MSG_RESULT([no])
+		PKG_CONFIG=""
+	fi
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG
+
+# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# Check to see whether a particular set of modules exists.  Similar
+# to PKG_CHECK_MODULES(), but does not set variables or print errors.
+#
+# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+# only at the first occurence in configure.ac, so if the first place
+# it's called might be skipped (such as if it is within an "if", you
+# have to call PKG_CHECK_EXISTS manually
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_EXISTS],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+if test -n "$PKG_CONFIG" && \
+    AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
+  m4_default([$2], [:])
+m4_ifvaln([$3], [else
+  $3])dnl
+fi])
+
+# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
+# ---------------------------------------------
+m4_define([_PKG_CONFIG],
+[if test -n "$$1"; then
+    pkg_cv_[]$1="$$1"
+ elif test -n "$PKG_CONFIG"; then
+    PKG_CHECK_EXISTS([$3],
+                     [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`
+		      test "x$?" != "x0" && pkg_failed=yes ],
+		     [pkg_failed=yes])
+ else
+    pkg_failed=untried
+fi[]dnl
+])# _PKG_CONFIG
+
+# _PKG_SHORT_ERRORS_SUPPORTED
+# -----------------------------
+AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
+if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+        _pkg_short_errors_supported=yes
+else
+        _pkg_short_errors_supported=no
+fi[]dnl
+])# _PKG_SHORT_ERRORS_SUPPORTED
+
+
+# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
+# [ACTION-IF-NOT-FOUND])
+#
+#
+# Note that if there is a possibility the first call to
+# PKG_CHECK_MODULES might not happen, you should be sure to include an
+# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
+#
+#
+# --------------------------------------------------------------
+AC_DEFUN([PKG_CHECK_MODULES],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
+AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
+
+pkg_failed=no
+AC_MSG_CHECKING([for $1])
+
+_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
+_PKG_CONFIG([$1][_LIBS], [libs], [$2])
+
+m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
+and $1[]_LIBS to avoid the need to call pkg-config.
+See the pkg-config man page for more details.])
+
+if test $pkg_failed = yes; then
+   	AC_MSG_RESULT([no])
+        _PKG_SHORT_ERRORS_SUPPORTED
+        if test $_pkg_short_errors_supported = yes; then
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
+        else 
+	        $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
+        fi
+	# Put the nasty error message in config.log where it belongs
+	echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
+
+	m4_default([$4], [AC_MSG_ERROR(
+[Package requirements ($2) were not met:
+
+$$1_PKG_ERRORS
+
+Consider adjusting the PKG_CONFIG_PATH environment variable if you
+installed software in a non-standard prefix.
+
+_PKG_TEXT])[]dnl
+        ])
+elif test $pkg_failed = untried; then
+     	AC_MSG_RESULT([no])
+	m4_default([$4], [AC_MSG_FAILURE(
+[The pkg-config script could not be found or is too old.  Make sure it
+is in your PATH or set the PKG_CONFIG environment variable to the full
+path to pkg-config.
+
+_PKG_TEXT
+
+To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
+        ])
+else
+	$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
+	$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
+        AC_MSG_RESULT([yes])
+	$3
+fi[]dnl
+])# PKG_CHECK_MODULES
+
+
+# PKG_INSTALLDIR(DIRECTORY)
+# -------------------------
+# Substitutes the variable pkgconfigdir as the location where a module
+# should install pkg-config .pc files. By default the directory is
+# $libdir/pkgconfig, but the default can be changed by passing
+# DIRECTORY. The user can override through the --with-pkgconfigdir
+# parameter.
+AC_DEFUN([PKG_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([pkgconfigdir],
+    [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],,
+    [with_pkgconfigdir=]pkg_default)
+AC_SUBST([pkgconfigdir], [$with_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+]) dnl PKG_INSTALLDIR
+
+
+# PKG_NOARCH_INSTALLDIR(DIRECTORY)
+# -------------------------
+# Substitutes the variable noarch_pkgconfigdir as the location where a
+# module should install arch-independent pkg-config .pc files. By
+# default the directory is $datadir/pkgconfig, but the default can be
+# changed by passing DIRECTORY. The user can override through the
+# --with-noarch-pkgconfigdir parameter.
+AC_DEFUN([PKG_NOARCH_INSTALLDIR],
+[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])])
+m4_pushdef([pkg_description],
+    [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@])
+AC_ARG_WITH([noarch-pkgconfigdir],
+    [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],,
+    [with_noarch_pkgconfigdir=]pkg_default)
+AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir])
+m4_popdef([pkg_default])
+m4_popdef([pkg_description])
+]) dnl PKG_NOARCH_INSTALLDIR
+
+
+# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------
+# Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])# PKG_CHECK_VAR
+
+# Copyright (C) 2002-2013 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.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.13'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.13.4], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.13.4])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 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.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to '$srcdir/foo'.  In other projects, it is set to
+# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is '.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997-2013 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.
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999-2013 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.
+
+
+# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+m4_if([$1], [CC],   [depcc="$CC"   am_compiler_list=],
+      [$1], [CXX],  [depcc="$CXX"  am_compiler_list=],
+      [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+      [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
+      [$1], [UPC],  [depcc="$UPC"  am_compiler_list=],
+      [$1], [GCJ],  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                    [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok '-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE([dependency-tracking], [dnl
+AS_HELP_STRING(
+  [--enable-dependency-tracking],
+  [do not reject slow dependency extractors])
+AS_HELP_STRING(
+  [--disable-dependency-tracking],
+  [speeds up one-time build])])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+  am__nodep='_no'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+AC_SUBST([am__nodep])dnl
+_AM_SUBST_NOTMAKE([am__nodep])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999-2013 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.
+
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+  # Older Autoconf quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named 'Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running 'make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "$am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each '.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 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 macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.65])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[AC_DIAGNOSE([obsolete],
+             [$0: two- and three-arguments forms are deprecated.])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(
+  m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+  [ok:ok],,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+ AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
+AM_MISSING_PROG([AUTOCONF], [autoconf])
+AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
+AM_MISSING_PROG([AUTOHEADER], [autoheader])
+AM_MISSING_PROG([MAKEINFO], [makeinfo])
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+	      [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+			     [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+		  [_AM_DEPENDENCIES([CC])],
+		  [m4_define([AC_PROG_CC],
+			     m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+		  [_AM_DEPENDENCIES([CXX])],
+		  [m4_define([AC_PROG_CXX],
+			     m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+		  [_AM_DEPENDENCIES([OBJC])],
+		  [m4_define([AC_PROG_OBJC],
+			     m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+		  [_AM_DEPENDENCIES([OBJCXX])],
+		  [m4_define([AC_PROG_OBJCXX],
+			     m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
+])
+AC_REQUIRE([AM_SILENT_RULES])dnl
+dnl The testsuite driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
+dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+])
+
+dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001-2013 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.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+AC_SUBST([install_sh])])
+
+# Copyright (C) 2003-2013 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.
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
+# From Jim Meyering
+
+# Copyright (C) 1996-2013 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.
+
+# AM_MAINTAINER_MODE([DEFAULT-MODE])
+# ----------------------------------
+# Control maintainer-specific portions of Makefiles.
+# Default is to disable them, unless 'enable' is passed literally.
+# For symmetry, 'disable' may be passed as well.  Anyway, the user
+# can override the default with the --enable/--disable switch.
+AC_DEFUN([AM_MAINTAINER_MODE],
+[m4_case(m4_default([$1], [disable]),
+       [enable], [m4_define([am_maintainer_other], [disable])],
+       [disable], [m4_define([am_maintainer_other], [enable])],
+       [m4_define([am_maintainer_other], [enable])
+        m4_warn([syntax], [unexpected argument to AM@&t at _MAINTAINER_MODE: $1])])
+AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
+  dnl maintainer-mode's default is 'disable' unless 'enable' is passed
+  AC_ARG_ENABLE([maintainer-mode],
+    [AS_HELP_STRING([--]am_maintainer_other[-maintainer-mode],
+      am_maintainer_other[ make rules and dependencies not useful
+      (and sometimes confusing) to the casual installer])],
+    [USE_MAINTAINER_MODE=$enableval],
+    [USE_MAINTAINER_MODE=]m4_if(am_maintainer_other, [enable], [no], [yes]))
+  AC_MSG_RESULT([$USE_MAINTAINER_MODE])
+  AM_CONDITIONAL([MAINTAINER_MODE], [test $USE_MAINTAINER_MODE = yes])
+  MAINT=$MAINTAINER_MODE_TRUE
+  AC_SUBST([MAINT])dnl
+]
+)
+
+# Check to see how 'make' treats includes.	            -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 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.
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+	@echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997-2013 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.
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it is modern enough.
+# If it is, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
+else
+  am_missing_run=
+  AC_MSG_WARN(['missing' script is too old or missing])
+fi
+])
+
+#  -*- Autoconf -*-
+# Obsolete and "removed" macros, that must however still report explicit
+# error messages when used, to smooth transition.
+#
+# Copyright (C) 1996-2013 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.
+
+AC_DEFUN([AM_CONFIG_HEADER],
+[AC_DIAGNOSE([obsolete],
+['$0': this macro is obsolete.
+You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl
+AC_CONFIG_HEADERS($@)])
+
+AC_DEFUN([AM_PROG_CC_STDC],
+[AC_PROG_CC
+am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc
+AC_DIAGNOSE([obsolete],
+['$0': this macro is obsolete.
+You should simply use the 'AC][_PROG_CC' macro instead.
+Also, your code should no longer depend upon 'am_cv_prog_cc_stdc',
+but upon 'ac_cv_prog_cc_stdc'.])])
+
+AC_DEFUN([AM_C_PROTOTYPES],
+         [AC_FATAL([automatic de-ANSI-fication support has been removed])])
+AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 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.
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# --------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 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.
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \	]]*)
+    AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$[*]" = "X"; then
+	# -L didn't work.
+	set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$[*]" != "X $srcdir/configure conftest.file" \
+	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+	# If neither matched, then we have a broken ls.  This can happen
+	# if, for instance, CONFIG_SHELL is bash and it inherits a
+	# broken ls alias from the environment.  This has actually
+	# happened.  Such a system could not be considered "sane".
+	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment])
+     fi
+     if test "$[2]" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT([yes])
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+AC_CONFIG_COMMANDS_PRE(
+  [AC_MSG_CHECKING([that generated files are newer than configure])
+   if test -n "$am_sleep_pid"; then
+     # Hide warnings about reused PIDs.
+     wait $am_sleep_pid 2>/dev/null
+   fi
+   AC_MSG_RESULT([done])])
+rm -f conftest.file
+])
+
+# Copyright (C) 2009-2013 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.
+
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# ("yes" being less verbose, "no" or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules], [dnl
+AS_HELP_STRING(
+  [--enable-silent-rules],
+  [less verbose build output (undo: "make V=1")])
+AS_HELP_STRING(
+  [--disable-silent-rules],
+  [verbose build output (undo: "make V=0")])dnl
+])
+case $enable_silent_rules in @%:@ (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+dnl
+dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
+dnl do not support nested variable expansions.
+dnl See automake bug#9928 and bug#10237.
+am_make=${MAKE-make}
+AC_CACHE_CHECK([whether $am_make supports nested variables],
+   [am_cv_make_support_nested_variables],
+   [if AS_ECHO([['TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi])
+if test $am_cv_make_support_nested_variables = yes; then
+  dnl Using '$V' instead of '$(V)' breaks IRIX make.
+  AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AC_SUBST([AM_V])dnl
+AM_SUBST_NOTMAKE([AM_V])dnl
+AC_SUBST([AM_DEFAULT_V])dnl
+AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
+
+# Copyright (C) 2001-2013 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.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor 'install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in "make install-strip", and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006-2013 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.
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# --------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004-2013 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.
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of 'v7', 'ustar', or 'pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+#
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.  Yes, it's still used
+# in the wild :-(  We should find a proper way to deprecate it ...
+AC_SUBST([AMTAR], ['$${TAR-tar}'])
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+
+m4_if([$1], [v7],
+  [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
+
+  [m4_case([$1],
+    [ustar],
+     [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
+      # There is notably a 21 bits limit for the UID and the GID.  In fact,
+      # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
+      # and bug#13588).
+      am_max_uid=2097151 # 2^21 - 1
+      am_max_gid=$am_max_uid
+      # The $UID and $GID variables are not portable, so we need to resort
+      # to the POSIX-mandated id(1) utility.  Errors in the 'id' calls
+      # below are definitely unexpected, so allow the users to see them
+      # (that is, avoid stderr redirection).
+      am_uid=`id -u || echo unknown`
+      am_gid=`id -g || echo unknown`
+      AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
+      if test $am_uid -le $am_max_uid; then
+         AC_MSG_RESULT([yes])
+      else
+         AC_MSG_RESULT([no])
+         _am_tools=none
+      fi
+      AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
+      if test $am_gid -le $am_max_gid; then
+         AC_MSG_RESULT([yes])
+      else
+        AC_MSG_RESULT([no])
+        _am_tools=none
+      fi],
+
+  [pax],
+    [],
+
+  [m4_fatal([Unknown tar format])])
+
+  AC_MSG_CHECKING([how to create a $1 tar archive])
+
+  # Go ahead even if we have the value already cached.  We do so because we
+  # need to set the values for the 'am__tar' and 'am__untar' variables.
+  _am_tools=${am_cv_prog_tar_$1-$_am_tools}
+
+  for _am_tool in $_am_tools; do
+    case $_am_tool in
+    gnutar)
+      for _am_tar in tar gnutar gtar; do
+        AM_RUN_LOG([$_am_tar --version]) && break
+      done
+      am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+      am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+      am__untar="$_am_tar -xf -"
+      ;;
+    plaintar)
+      # Must skip GNU tar: if it does not support --format= it doesn't create
+      # ustar tarball either.
+      (tar --version) >/dev/null 2>&1 && continue
+      am__tar='tar chf - "$$tardir"'
+      am__tar_='tar chf - "$tardir"'
+      am__untar='tar xf -'
+      ;;
+    pax)
+      am__tar='pax -L -x $1 -w "$$tardir"'
+      am__tar_='pax -L -x $1 -w "$tardir"'
+      am__untar='pax -r'
+      ;;
+    cpio)
+      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+      am__untar='cpio -i -H $1 -d'
+      ;;
+    none)
+      am__tar=false
+      am__tar_=false
+      am__untar=false
+      ;;
+    esac
+
+    # If the value was cached, stop now.  We just wanted to have am__tar
+    # and am__untar set.
+    test -n "${am_cv_prog_tar_$1}" && break
+
+    # tar/untar a dummy directory, and stop if the command works.
+    rm -rf conftest.dir
+    mkdir conftest.dir
+    echo GrepMe > conftest.dir/file
+    AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+    rm -rf conftest.dir
+    if test -s conftest.tar; then
+      AM_RUN_LOG([$am__untar <conftest.tar])
+      AM_RUN_LOG([cat conftest.dir/file])
+      grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+    fi
+  done
+  rm -rf conftest.dir
+
+  AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+  AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([m4/libtool.m4])
+m4_include([m4/ltoptions.m4])
+m4_include([m4/ltsugar.m4])
+m4_include([m4/ltversion.m4])
+m4_include([m4/lt~obsolete.m4])
diff --git a/config.guess b/config.guess
new file mode 100755
index 0000000..b79252d
--- /dev/null
+++ b/config.guess
@@ -0,0 +1,1558 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright 1992-2013 Free Software Foundation, Inc.
+
+timestamp='2013-06-10'
+
+# 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 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# 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.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+#
+# Originally written by Per Bothner.
+#
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+#
+# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright 1992-2013 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 "$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 at noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+	PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+case "${UNAME_SYSTEM}" in
+Linux|GNU|GNU/*)
+	# If the system lacks a compiler, then just pick glibc.
+	# We could probably try harder.
+	LIBC=gnu
+
+	eval $set_cc_for_build
+	cat <<-EOF > $dummy.c
+	#include <features.h>
+	#if defined(__UCLIBC__)
+	LIBC=uclibc
+	#elif defined(__dietlibc__)
+	LIBC=dietlibc
+	#else
+	LIBC=gnu
+	#endif
+	EOF
+	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+	;;
+esac
+
+# 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 tuples: *-*-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 ;;
+	    sh5el) machine=sh5le-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 -q __ELF__
+		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 ;;
+    *:Bitrig:*:*)
+	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
+	echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_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 ;;
+    *:SolidBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+	exit ;;
+    macppc:MirBSD:*:*)
+	echo powerpc-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'`
+	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
+	exitcode=$?
+	trap '' 0
+	exit $exitcode ;;
+    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 at wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+	if test "`(/bin/universe) 2>/dev/null`" = att ; then
+		echo pyramid-pyramid-sysv3
+	else
+		echo pyramid-pyramid-bsd
+	fi
+	exit ;;
+    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 ;;
+    s390x:SunOS:*:*)
+	echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit ;;
+    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:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
+	echo i386-pc-auroraux${UNAME_RELEASE}
+	exit ;;
+    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+	eval $set_cc_for_build
+	SUN_ARCH="i386"
+	# If there is a compiler, see if it is configured for 64-bit objects.
+	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
+	# This test works for both compilers.
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		grep IS_64BIT_ARCH >/dev/null
+	    then
+		SUN_ARCH="x86_64"
+	    fi
+	fi
+	echo ${SUN_ARCH}-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:*:[4567])
+	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 -q __LP64__
+	    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:*:*)
+	UNAME_PROCESSOR=`/usr/bin/uname -p`
+	case ${UNAME_PROCESSOR} in
+	    amd64)
+		echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	    *)
+		echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+	esac
+	exit ;;
+    i*:CYGWIN*:*)
+	echo ${UNAME_MACHINE}-pc-cygwin
+	exit ;;
+    *:MINGW64*:*)
+	echo ${UNAME_MACHINE}-pc-mingw64
+	exit ;;
+    *:MINGW*:*)
+	echo ${UNAME_MACHINE}-pc-mingw32
+	exit ;;
+    i*:MSYS*:*)
+	echo ${UNAME_MACHINE}-pc-msys
+	exit ;;
+    i*:windows32*:*)
+	# uname -m includes "-pc" on this system.
+	echo ${UNAME_MACHINE}-mingw32
+	exit ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit ;;
+    *:Interix*:*)
+	case ${UNAME_MACHINE} in
+	    x86)
+		echo i586-pc-interix${UNAME_RELEASE}
+		exit ;;
+	    authenticamd | genuineintel | EM64T)
+		echo x86_64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	    IA64)
+		echo ia64-unknown-interix${UNAME_RELEASE}
+		exit ;;
+	esac ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+	echo i${UNAME_MACHINE}-pc-mks
+	exit ;;
+    8664:Windows_NT:*)
+	echo x86_64-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-${LIBC}`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/[-(].*//'`-${LIBC}
+	exit ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit ;;
+    aarch64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    aarch64_be:Linux:*:*)
+	UNAME_MACHINE=aarch64_be
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	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 -q ld.so.1
+	if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    arc:Linux:*:* | arceb:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    arm*:Linux:*:*)
+	eval $set_cc_for_build
+	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+	    | grep -q __ARM_EABI__
+	then
+	    echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	else
+	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
+		| grep -q __ARM_PCS_VFP
+	    then
+		echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+	    else
+		echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+	    fi
+	fi
+	exit ;;
+    avr32*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    cris:Linux:*:*)
+	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+	exit ;;
+    crisv32:Linux:*:*)
+	echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+	exit ;;
+    frv:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    hexagon:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    i*86:Linux:*:*)
+	echo ${UNAME_MACHINE}-pc-linux-${LIBC}
+	exit ;;
+    ia64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    m32r*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    m68*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    mips:Linux:*:* | mips64:Linux:*:*)
+	eval $set_cc_for_build
+	sed 's/^	//' << EOF >$dummy.c
+	#undef CPU
+	#undef ${UNAME_MACHINE}
+	#undef ${UNAME_MACHINE}el
+	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+	CPU=${UNAME_MACHINE}el
+	#else
+	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+	CPU=${UNAME_MACHINE}
+	#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-${LIBC}"; exit; }
+	;;
+    or1k:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    or32:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    padre:Linux:*:*)
+	echo sparc-unknown-linux-${LIBC}
+	exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-${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-${LIBC} ;;
+	  PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
+	  *)    echo hppa-unknown-linux-${LIBC} ;;
+	esac
+	exit ;;
+    ppc64:Linux:*:*)
+	echo powerpc64-unknown-linux-${LIBC}
+	exit ;;
+    ppc:Linux:*:*)
+	echo powerpc-unknown-linux-${LIBC}
+	exit ;;
+    ppc64le:Linux:*:*)
+	echo powerpc64le-unknown-linux-${LIBC}
+	exit ;;
+    ppcle:Linux:*:*)
+	echo powerpcle-unknown-linux-${LIBC}
+	exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+	echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+	exit ;;
+    sh64*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    sh*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    tile*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    vax:Linux:*:*)
+	echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+	exit ;;
+    x86_64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	exit ;;
+    xtensa*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+	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.[02]*:*)
+	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 i586.
+	# Note: whatever this is, it MUST be the same as what config.sub
+	# prints for the "djgpp" host, or else GDB configury will decide that
+	# this is a cross-build.
+	echo i586-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; } ;;
+    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
+	OS_REL='.3'
+	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; }
+	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
+	    && { echo i586-ncr-sysv4.3${OS_REL}; 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.[02]*:*)
+	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 at ccMail.Census.GOV>
+	echo i586-unisys-sysv4
+	exit ;;
+    *:UNIX_System_V:4*:FTX*)
+	# From Gerald Hewes <hewes at openmarket.com>.
+	# How about differentiating between stratus architectures? -djm
+	echo hppa1.1-stratus-sysv4
+	exit ;;
+    *:*:*:FTX*)
+	# From seanf at swdc.stratus.com.
+	echo i860-stratus-sysv4
+	exit ;;
+    i*86:VOS:*:*)
+	# From Paul.Green at stratus.com.
+	echo ${UNAME_MACHINE}-stratus-vos
+	exit ;;
+    *:VOS:*:*)
+	# From Paul.Green at 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 ;;
+    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
+	echo i586-pc-haiku
+	exit ;;
+    x86_64:Haiku:*:*)
+	echo x86_64-unknown-haiku
+	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 ;;
+    SX-7:SUPER-UX:*:*)
+	echo sx7-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8:SUPER-UX:*:*)
+	echo sx8-nec-superux${UNAME_RELEASE}
+	exit ;;
+    SX-8R:SUPER-UX:*:*)
+	echo sx8r-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
+	eval $set_cc_for_build
+	if test "$UNAME_PROCESSOR" = unknown ; then
+	    UNAME_PROCESSOR=powerpc
+	fi
+	if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
+		(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+		grep IS_64BIT_ARCH >/dev/null
+	    then
+		case $UNAME_PROCESSOR in
+		    i386) UNAME_PROCESSOR=x86_64 ;;
+		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
+		esac
+	    fi
+	fi
+	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 ;;
+    NEO-?:NONSTOP_KERNEL:*:*)
+	echo neo-tandem-nsk${UNAME_RELEASE}
+	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 ;;
+    i*86:rdos:*:*)
+	echo ${UNAME_MACHINE}-pc-rdos
+	exit ;;
+    i*86:AROS:*:*)
+	echo ${UNAME_MACHINE}-pc-aros
+	exit ;;
+    x86_64:VMkernel:*:*)
+	echo ${UNAME_MACHINE}-unknown-esx
+	exit ;;
+esac
+
+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://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+and
+  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches at gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..435bc24
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,150 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the `fdatasync' function. */
+#undef HAVE_FDATASYNC
+
+/* Define to 1 if you have the <float.h> header file. */
+#undef HAVE_FLOAT_H
+
+/* Define to 1 if you have the `ftruncate' function. */
+#undef HAVE_FTRUNCATE
+
+/* Define to 1 if you have the `getcwd' function. */
+#undef HAVE_GETCWD
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `localtime_r' function. */
+#undef HAVE_LOCALTIME_R
+
+/* Define to 1 if `lstat' has the bug that it succeeds when given the
+   zero-length file name argument. */
+#undef HAVE_LSTAT_EMPTY_STRING_BUG
+
+/* Define to 1 if you have the <math.h> header file. */
+#undef HAVE_MATH_H
+
+/* Define to 1 if you have the `memmove' function. */
+#undef HAVE_MEMMOVE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the `sqrt' function. */
+#undef HAVE_SQRT
+
+/* Define to 1 if `stat' has the bug that it succeeds when given the
+   zero-length file name argument. */
+#undef HAVE_STAT_EMPTY_STRING_BUG
+
+/* Define to 1 if you have the <stddef.h> header file. */
+#undef HAVE_STDDEF_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdio.h> header file. */
+#undef HAVE_STDIO_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 `strerror' function. */
+#undef HAVE_STRERROR
+
+/* Define to 1 if you have the `strftime' function. */
+#undef HAVE_STRFTIME
+
+/* 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 `strncasecmp' function. */
+#undef HAVE_STRNCASECMP
+
+/* Define to 1 if you have the `strstr' function. */
+#undef HAVE_STRSTR
+
+/* 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/time.h> header file. */
+#undef HAVE_SYS_TIME_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 to 1 if `lstat' dereferences a symlink specified with a trailing
+   slash. */
+#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+   */
+#undef LT_OBJDIR
+
+/* Name of package */
+#undef PACKAGE
+
+/* 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 home page for this package. */
+#undef PACKAGE_URL
+
+/* 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 you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
+/* Version number of package */
+#undef VERSION
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `long int' if <sys/types.h> does not define. */
+#undef off_t
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define to empty if the keyword `volatile' does not work. Warning: valid
+   code using `volatile' can become incorrect without. Disable with care. */
+#undef volatile
diff --git a/config.sub b/config.sub
new file mode 100755
index 0000000..c765b34
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1788 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright 1992-2013 Free Software Foundation, Inc.
+
+timestamp='2013-04-24'
+
+# 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 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+# 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.  This Exception is an additional permission under section 7
+# of the GNU General Public License, version 3 ("GPLv3").
+
+
+# Please send patches with a ChangeLog entry to config-patches at gnu.org.
+#
+# 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.
+
+# You can get the latest version of this script from:
+# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches at gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright 1992-2013 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-android* | linux-dietlibc | linux-newlib* | \
+  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
+  knetbsd*-gnu* | netbsd*-gnu* | \
+  kopensolaris*-gnu* | \
+  storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  android-linux)
+    os=-linux-android
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
+    ;;
+  *)
+    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 | -microblaze*)
+		os=
+		basic_machine=$1
+		;;
+	-bluegene*)
+		os=-cnk
+		;;
+	-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
+		;;
+	-sco6)
+		os=-sco5v6
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-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/'`
+		;;
+	-sco5v6*)
+		# 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*178)
+		os=-lynxos178
+		;;
+	-lynx*5)
+		os=-lynxos5
+		;;
+	-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 \
+	| aarch64 | aarch64_be \
+	| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+	| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+	| am33_2.0 \
+	| arc | arceb \
+	| arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+	| avr | avr32 \
+	| be32 | be64 \
+	| bfin \
+	| c4x | clipper \
+	| d10v | d30v | dlx | dsp16xx \
+	| epiphany \
+	| fido | fr30 | frv \
+	| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+	| hexagon \
+	| i370 | i860 | i960 | ia64 \
+	| ip2k | iq2000 \
+	| le32 | le64 \
+	| lm32 \
+	| m32c | m32r | m32rle | m68000 | m68k | m88k \
+	| maxq | mb | microblaze | microblazeel | mcore | mep | metag \
+	| mips | mipsbe | mipseb | mipsel | mipsle \
+	| mips16 \
+	| mips64 | mips64el \
+	| mips64octeon | mips64octeonel \
+	| mips64orion | mips64orionel \
+	| mips64r5900 | mips64r5900el \
+	| mips64vr | mips64vrel \
+	| mips64vr4100 | mips64vr4100el \
+	| mips64vr4300 | mips64vr4300el \
+	| mips64vr5000 | mips64vr5000el \
+	| mips64vr5900 | mips64vr5900el \
+	| mipsisa32 | mipsisa32el \
+	| mipsisa32r2 | mipsisa32r2el \
+	| mipsisa64 | mipsisa64el \
+	| mipsisa64r2 | mipsisa64r2el \
+	| mipsisa64sb1 | mipsisa64sb1el \
+	| mipsisa64sr71k | mipsisa64sr71kel \
+	| mipsr5900 | mipsr5900el \
+	| mipstx39 | mipstx39el \
+	| mn10200 | mn10300 \
+	| moxie \
+	| mt \
+	| msp430 \
+	| nds32 | nds32le | nds32be \
+	| nios | nios2 | nios2eb | nios2el \
+	| ns16k | ns32k \
+	| open8 \
+	| or1k | or32 \
+	| pdp10 | pdp11 | pj | pjl \
+	| powerpc | powerpc64 | powerpc64le | powerpcle \
+	| pyramid \
+	| rl78 | rx \
+	| score \
+	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+	| sh64 | sh64le \
+	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+	| spu \
+	| tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \
+	| ubicom32 \
+	| v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
+	| we32k \
+	| x86 | xc16x | xstormy16 | xtensa \
+	| z8k | z80)
+		basic_machine=$basic_machine-unknown
+		;;
+	c54x)
+		basic_machine=tic54x-unknown
+		;;
+	c55x)
+		basic_machine=tic55x-unknown
+		;;
+	c6x)
+		basic_machine=tic6x-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | picochip)
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+		;;
+	ms1)
+		basic_machine=mt-unknown
+		;;
+
+	strongarm | thumb | xscale)
+		basic_machine=arm-unknown
+		;;
+	xgate)
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	xscaleeb)
+		basic_machine=armeb-unknown
+		;;
+
+	xscaleel)
+		basic_machine=armel-unknown
+		;;
+
+	# 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-* \
+	| aarch64-* | aarch64_be-* \
+	| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+	| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+	| alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
+	| arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+	| avr-* | avr32-* \
+	| be32-* | be64-* \
+	| bfin-* | bs2000-* \
+	| c[123]* | c30-* | [cjt]90-* | c4x-* \
+	| clipper-* | craynv-* | cydra-* \
+	| d10v-* | d30v-* | dlx-* \
+	| elxsi-* \
+	| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+	| h8300-* | h8500-* \
+	| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+	| hexagon-* \
+	| i*86-* | i860-* | i960-* | ia64-* \
+	| ip2k-* | iq2000-* \
+	| le32-* | le64-* \
+	| lm32-* \
+	| m32c-* | m32r-* | m32rle-* \
+	| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+	| m88110-* | m88k-* | maxq-* | mcore-* | metag-* \
+	| microblaze-* | microblazeel-* \
+	| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+	| mips16-* \
+	| mips64-* | mips64el-* \
+	| mips64octeon-* | mips64octeonel-* \
+	| mips64orion-* | mips64orionel-* \
+	| mips64r5900-* | mips64r5900el-* \
+	| mips64vr-* | mips64vrel-* \
+	| mips64vr4100-* | mips64vr4100el-* \
+	| mips64vr4300-* | mips64vr4300el-* \
+	| mips64vr5000-* | mips64vr5000el-* \
+	| mips64vr5900-* | mips64vr5900el-* \
+	| mipsisa32-* | mipsisa32el-* \
+	| mipsisa32r2-* | mipsisa32r2el-* \
+	| mipsisa64-* | mipsisa64el-* \
+	| mipsisa64r2-* | mipsisa64r2el-* \
+	| mipsisa64sb1-* | mipsisa64sb1el-* \
+	| mipsisa64sr71k-* | mipsisa64sr71kel-* \
+	| mipsr5900-* | mipsr5900el-* \
+	| mipstx39-* | mipstx39el-* \
+	| mmix-* \
+	| mt-* \
+	| msp430-* \
+	| nds32-* | nds32le-* | nds32be-* \
+	| nios-* | nios2-* | nios2eb-* | nios2el-* \
+	| none-* | np1-* | ns16k-* | ns32k-* \
+	| open8-* \
+	| orion-* \
+	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+	| pyramid-* \
+	| rl78-* | romp-* | rs6000-* | rx-* \
+	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+	| sparclite-* \
+	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+	| tahoe-* \
+	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+	| tile*-* \
+	| tron-* \
+	| ubicom32-* \
+	| v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
+	| vax-* \
+	| we32k-* \
+	| x86-* | x86_64-* | xc16x-* | xps100-* \
+	| xstormy16-* | xtensa*-* \
+	| ymp-* \
+	| z8k-* | z80-*)
+		;;
+	# Recognize the basic CPU types without company name, with glob match.
+	xtensa*)
+		basic_machine=$basic_machine-unknown
+		;;
+	# 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
+		;;
+	aros)
+		basic_machine=i386-pc
+		os=-aros
+		;;
+	aux)
+		basic_machine=m68k-apple
+		os=-aux
+		;;
+	balance)
+		basic_machine=ns32k-sequent
+		os=-dynix
+		;;
+	blackfin)
+		basic_machine=bfin-unknown
+		os=-linux
+		;;
+	blackfin-*)
+		basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	bluegene*)
+		basic_machine=powerpc-ibm
+		os=-cnk
+		;;
+	c54x-*)
+		basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	c55x-*)
+		basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	c6x-*)
+		basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	c90)
+		basic_machine=c90-cray
+		os=-unicos
+		;;
+	cegcc)
+		basic_machine=arm-unknown
+		os=-cegcc
+		;;
+	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
+		;;
+	cr16 | cr16-*)
+		basic_machine=cr16-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
+		;;
+	dicos)
+		basic_machine=i686-pc
+		os=-dicos
+		;;
+	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*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
+		;;
+	m68knommu)
+		basic_machine=m68k-unknown
+		os=-linux
+		;;
+	m68knommu-*)
+		basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	m88k-omron*)
+		basic_machine=m88k-omron
+		;;
+	magnum | m3230)
+		basic_machine=mips-mips
+		os=-sysv
+		;;
+	merlin)
+		basic_machine=ns32k-utek
+		os=-sysv
+		;;
+	microblaze*)
+		basic_machine=microblaze-xilinx
+		;;
+	mingw64)
+		basic_machine=x86_64-pc
+		os=-mingw64
+		;;
+	mingw32)
+		basic_machine=i386-pc
+		os=-mingw32
+		;;
+	mingw32ce)
+		basic_machine=arm-unknown
+		os=-mingw32ce
+		;;
+	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
+		;;
+	ms1-*)
+		basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+		;;
+	msys)
+		basic_machine=i386-pc
+		os=-msys
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
+	nacl)
+		basic_machine=le32-unknown
+		os=-nacl
+		;;
+	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
+		;;
+	neo-tandem)
+		basic_machine=neo-tandem
+		;;
+	nse-tandem)
+		basic_machine=nse-tandem
+		;;
+	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
+		;;
+	parisc)
+		basic_machine=hppa-unknown
+		os=-linux
+		;;
+	parisc-*)
+		basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+		os=-linux
+		;;
+	pbd)
+		basic_machine=sparc-tti
+		;;
+	pbb)
+		basic_machine=m68k-tti
+		;;
+	pc532 | pc532-*)
+		basic_machine=ns32k-pc532
+		;;
+	pc98)
+		basic_machine=i386-pc
+		;;
+	pc98-*)
+		basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	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 | ppcbe)	basic_machine=powerpc-unknown
+		;;
+	ppc-* | ppcbe-*)
+		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-* | ppc64p7-*) 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
+		;;
+	rdos | rdos64)
+		basic_machine=x86_64-pc
+		os=-rdos
+		;;
+	rdos32)
+		basic_machine=i386-pc
+		os=-rdos
+		;;
+	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
+		;;
+	sde)
+		basic_machine=mipsisa32-sde
+		os=-elf
+		;;
+	sei)
+		basic_machine=mips-sei
+		os=-seiux
+		;;
+	sequent)
+		basic_machine=i386-sequent
+		;;
+	sh)
+		basic_machine=sh-hitachi
+		os=-hms
+		;;
+	sh5el)
+		basic_machine=sh5le-unknown
+		;;
+	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
+		;;
+	strongarm-* | thumb-*)
+		basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	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
+		;;
+	tile*)
+		basic_machine=$basic_machine-unknown
+		os=-linux-gnu
+		;;
+	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
+		;;
+	xscale-* | xscalee[bl]-*)
+		basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
+		;;
+	ymp)
+		basic_machine=ymp-cray
+		os=-unicos
+		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
+	z80-*-coff)
+		basic_machine=z80-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[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+		basic_machine=sh-unknown
+		;;
+	sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+		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.
+	-auroraux)
+		os=-auroraux
+		;;
+	-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* | -cnk* | -sunos | -sunos[34]*\
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
+	      | -sym* | -kopensolaris* | -plan9* \
+	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+	      | -aos* | -aros* \
+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+	      | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+	      | -bitrig* | -openbsd* | -solidbsd* \
+	      | -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* | -cegcc* \
+	      | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
+	      | -linux-newlib* | -linux-musl* | -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* | -rdos* | -toppers* | -drops* | -es*)
+	# 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
+		;;
+	-zvmoe)
+		os=-zvmoe
+		;;
+	-dicos*)
+		os=-dicos
+		;;
+	-nacl*)
+		;;
+	-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
+	score-*)
+		os=-elf
+		;;
+	spu-*)
+		os=-elf
+		;;
+	*-acorn)
+		os=-riscix1.2
+		;;
+	arm*-rebel)
+		os=-linux
+		;;
+	arm*-semi)
+		os=-aout
+		;;
+	c4x-* | tic4x-*)
+		os=-coff
+		;;
+	hexagon-*)
+		os=-elf
+		;;
+	tic54x-*)
+		os=-coff
+		;;
+	tic55x-*)
+		os=-coff
+		;;
+	tic6x-*)
+		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
+		;;
+	m68*-cisco)
+		os=-aout
+		;;
+	mep-*)
+		os=-elf
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
+	or1k-*)
+		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
+				;;
+			-cnk*|-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..1a796a3
--- /dev/null
+++ b/configure
@@ -0,0 +1,19207 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.69 for LibreWMS 1.0.0.
+#
+# Report bugs to <a.furieri at lqt.it>.
+#
+#
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+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
+IFS=$as_save_IFS
+
+     ;;
+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
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# Use a proper internal environment variable to ensure we don't fall
+  # into an infinite loop, continuously re-executing ourselves.
+  if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+    _as_can_reexec=no; export _as_can_reexec;
+    # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+  fi
+  # We don't want this to propagate to other subprocesses.
+          { _as_can_reexec=; unset _as_can_reexec;}
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+
+  test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (
+    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+    ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
+    ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO
+    PATH=/empty FPATH=/empty; export PATH FPATH
+    test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\
+      || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+	 /*)
+	   for as_base in sh bash ksh sh5; do
+	     # Try only shells that exist, to save several forks.
+	     as_shell=$as_dir/$as_base
+	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+	   done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  export CONFIG_SHELL
+             # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+  *v*x* | *x*v* ) as_opts=-vx ;;
+  *v* ) as_opts=-v ;;
+  *x* ) as_opts=-x ;;
+  * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    $as_echo "$0: Please tell bug-autoconf at gnu.org and a.furieri at lqt.it
+$0: about your system, including any error possibly output
+$0: before this message. Then install a modern shell, or
+$0: manually run the script under such a shell if you do
+$0: have one."
+  fi
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+  test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; 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
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# 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
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+  # already done that, so ensure we don't try to do so again and fall
+  # in an infinite loop.  This has already happened in practice.
+  _as_can_reexec=no; export _as_can_reexec
+  # 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 sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -pR'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -pR'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -pR'
+  fi
+else
+  as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# 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'"
+
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='LibreWMS'
+PACKAGE_TARNAME='librewms'
+PACKAGE_VERSION='1.0.0'
+PACKAGE_STRING='LibreWMS 1.0.0'
+PACKAGE_BUGREPORT='a.furieri at lqt.it'
+PACKAGE_URL=''
+
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBSPATIALITE_LIBS
+LIBSPATIALITE_CFLAGS
+LIBRASTERLITE2_LIBS
+LIBRASTERLITE2_CFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
+LIBOBJS
+WX_LIBS
+WX_CONFIG
+CXXCPP
+OTOOL64
+OTOOL
+LIPO
+NMEDIT
+DSYMUTIL
+MANIFEST_TOOL
+RANLIB
+ac_ct_AR
+AR
+NM
+ac_ct_DUMPBIN
+DUMPBIN
+LD
+FGREP
+EGREP
+GREP
+SED
+LIBTOOL
+OBJDUMP
+DLLTOOL
+AS
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+LN_S
+CPP
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+ac_ct_CC
+CFLAGS
+CC
+am__fastdepCXX_FALSE
+am__fastdepCXX_TRUE
+CXXDEPMODE
+am__nodep
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CXX
+CPPFLAGS
+LDFLAGS
+CXXFLAGS
+CXX
+MAINT
+MAINTAINER_MODE_FALSE
+MAINTAINER_MODE_TRUE
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+AM_DEFAULT_V
+AM_V
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_silent_rules
+enable_maintainer_mode
+enable_dependency_tracking
+enable_shared
+enable_static
+with_pic
+enable_fast_install
+with_gnu_ld
+with_sysroot
+enable_libtool_lock
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CXX
+CXXFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CCC
+CC
+CFLAGS
+CPP
+CXXCPP
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR
+LIBRASTERLITE2_CFLAGS
+LIBRASTERLITE2_LIBS
+LIBSPATIALITE_CFLAGS
+LIBSPATIALITE_LIBS'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# 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.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+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
+
+  case $ac_option in
+  *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *=)   ac_optarg= ;;
+  *)    ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -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)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$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 ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$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 ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    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 ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$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_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error $? "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+	 ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=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 ;;
+
+  -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_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'`
+  as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
+		datadir sysconfdir sharedstatedir localstatedir includedir \
+		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+		libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+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
+  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
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error $? "pwd does not report name of working directory"
+
+
+# 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 the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_myself" : 'X\(//\)[^/]' \| \
+	 X"$as_myself" : 'X\(//\)$' \| \
+	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    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
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+	pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# 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 LibreWMS 1.0.0 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 \`..']
+
+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]
+  --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]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/librewms]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_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 LibreWMS 1.0.0:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-silent-rules   less verbose build output (undo: "make V=1")
+  --disable-silent-rules  verbose build output (undo: "make V=0")
+  --enable-maintainer-mode
+                          enable make rules and dependencies not useful (and
+                          sometimes confusing) to the casual installer
+  --enable-dependency-tracking
+                          do not reject slow dependency extractors
+  --disable-dependency-tracking
+                          speeds up one-time build
+  --enable-shared[=PKGS]  build shared libraries [default=yes]
+  --enable-static[=PKGS]  build static libraries [default=yes]
+  --enable-fast-install[=PKGS]
+                          optimize for fast installation [default=yes]
+  --disable-libtool-lock  avoid locking (might break parallel builds)
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
+                          both]
+  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-sysroot=DIR Search for dependent libraries within DIR
+                        (or the compiler's sysroot if not specified).
+
+Some influential environment variables:
+  CXX         C++ compiler command
+  CXXFLAGS    C++ compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  CPP         C preprocessor
+  CXXCPP      C++ preprocessor
+  PKG_CONFIG  path to pkg-config utility
+  PKG_CONFIG_PATH
+              directories to add to pkg-config's search path
+  PKG_CONFIG_LIBDIR
+              path overriding pkg-config's built-in search path
+  LIBRASTERLITE2_CFLAGS
+              C compiler flags for LIBRASTERLITE2, overriding pkg-config
+  LIBRASTERLITE2_LIBS
+              linker flags for LIBRASTERLITE2, overriding pkg-config
+  LIBSPATIALITE_CFLAGS
+              C compiler flags for LIBSPATIALITE, overriding pkg-config
+  LIBSPATIALITE_LIBS
+              linker flags for LIBSPATIALITE, overriding pkg-config
+
+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 <a.furieri at lqt.it>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested 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
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+LibreWMS configure 1.0.0
+generated by GNU Autoconf 2.69
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_compile
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } > conftest.i && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); 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 $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* 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_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_func
+
+# ac_fn_cxx_try_cpp LINENO
+# ------------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } > conftest.i && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_cpp
+
+# ac_fn_cxx_try_link LINENO
+# -------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 test -x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_link
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if eval \${$3+:} false; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ------------------------------- ##
+## Report this to a.furieri at lqt.it ##
+## ------------------------------- ##"
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+	 return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+	    return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_type
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by LibreWMS $as_me 1.0.0, which was
+generated by GNU Autoconf 2.69.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+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`
+/usr/bin/hostinfo      = `(/usr/bin/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=.
+    $as_echo "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&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_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=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append 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
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset 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: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    $as_echo "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+	"s/'\''/'\''\\\\'\'''\''/g;
+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    $as_echo "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      $as_echo "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+      echo
+      for ac_var in $ac_subst_files
+      do
+	eval ac_val=\$$ac_var
+	case $ac_val in
+	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+	esac
+	$as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      $as_echo "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > 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
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  # We do not want a PATH search for config.site.
+  case $CONFIG_SITE in #((
+    -*)  ac_site_file1=./$CONFIG_SITE;;
+    */*) ac_site_file1=$CONFIG_SITE;;
+    *)   ac_site_file1=./$CONFIG_SITE;;
+  esac
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file" \
+      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
+  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.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_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 $ac_precious_vars; 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,)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_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
+	# differences in whitespace do not lead to failure.
+	ac_old_val_w=`echo x $ac_old_val`
+	ac_new_val_w=`echo x $ac_new_val`
+	if test "$ac_old_val_w" != "$ac_new_val_w"; then
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+	  ac_cache_corrupted=:
+	else
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+	  eval $ac_var=\$ac_old_val
+	fi
+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_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.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+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
+
+
+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
+
+
+
+am__api_version='1.13'
+
+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
+  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+# 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.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if ${ac_cv_path_install+:} false; then :
+  $as_echo_n "(cached) " >&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_fn_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
+	    rm -rf conftest.one conftest.two conftest.dir
+	    echo one > conftest.one
+	    echo two > conftest.two
+	    mkdir conftest.dir
+	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+	      test -s conftest.one && test -s conftest.two &&
+	      test -s conftest.dir/conftest.one &&
+	      test -s conftest.dir/conftest.two
+	    then
+	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+	      break 3
+	    fi
+	  fi
+	fi
+      done
+    done
+    ;;
+esac
+
+  done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+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.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$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'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[\\\"\#\$\&\'\`$am_lf]*)
+    as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \	]*)
+    as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   am_has_slept=no
+   for am_try in 1 2; do
+     echo "timestamp, slept: $am_has_slept" > conftest.file
+     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+     if test "$*" = "X"; then
+	# -L didn't work.
+	set X `ls -t "$srcdir/configure" conftest.file`
+     fi
+     if test "$*" != "X $srcdir/configure conftest.file" \
+	&& test "$*" != "X conftest.file $srcdir/configure"; then
+
+	# If neither matched, then we have a broken ls.  This can happen
+	# if, for instance, CONFIG_SHELL is bash and it inherits a
+	# broken ls alias from the environment.  This has actually
+	# happened.  Such a system could not be considered "sane".
+	as_fn_error $? "ls -t appears to fail.  Make sure there is not a broken
+  alias in your environment" "$LINENO" 5
+     fi
+     if test "$2" = conftest.file || test $am_try -eq 2; then
+       break
+     fi
+     # Just in case.
+     sleep 1
+     am_has_slept=yes
+   done
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   as_fn_error $? "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+  ( sleep 1 ) &
+  am_sleep_pid=$!
+fi
+
+rm -f conftest.file
+
+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 $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+  am_missing_run="$MISSING "
+else
+  am_missing_run=
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\	*)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip".  However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+  if ${ac_cv_path_mkdir+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in mkdir gmkdir; do
+	 for ac_exec_ext in '' $ac_executable_extensions; do
+	   as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
+	   case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+	     'mkdir (GNU coreutils) '* | \
+	     'mkdir (coreutils) '* | \
+	     'mkdir (fileutils) '4.1*)
+	       ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+	       break 3;;
+	   esac
+	 done
+       done
+  done
+IFS=$as_save_IFS
+
+fi
+
+  test -d ./--version && rmdir ./--version
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AWK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+	@echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+  enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in # (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+    *) AM_DEFAULT_VERBOSITY=1;;
+esac
+am_make=${MAKE-make}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
+if ${am_cv_make_support_nested_variables+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if $as_echo 'TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+	@$(TRUE)
+.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
+  am_cv_make_support_nested_variables=yes
+else
+  am_cv_make_support_nested_variables=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+$as_echo "$am_cv_make_support_nested_variables" >&6; }
+if test $am_cv_make_support_nested_variables = yes; then
+    AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AM_BACKSLASH='\'
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='librewms'
+ VERSION='1.0.0'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# For better backward compatibility.  To be removed once Automake 1.9.x
+# dies out for good.  For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+mkdir_p='$(MKDIR_P)'
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.  Yes, it's still used
+# in the wild :-(  We should find a proper way to deprecate it ...
+AMTAR='$${TAR-tar}'
+
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar  pax cpio none'
+
+am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
+$as_echo_n "checking whether to enable maintainer-specific portions of Makefiles... " >&6; }
+    # Check whether --enable-maintainer-mode was given.
+if test "${enable_maintainer_mode+set}" = set; then :
+  enableval=$enable_maintainer_mode; USE_MAINTAINER_MODE=$enableval
+else
+  USE_MAINTAINER_MODE=no
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $USE_MAINTAINER_MODE" >&5
+$as_echo "$USE_MAINTAINER_MODE" >&6; }
+   if test $USE_MAINTAINER_MODE = yes; then
+  MAINTAINER_MODE_TRUE=
+  MAINTAINER_MODE_FALSE='#'
+else
+  MAINTAINER_MODE_TRUE='#'
+  MAINTAINER_MODE_FALSE=
+fi
+
+  MAINT=$MAINTAINER_MODE_TRUE
+
+
+ac_config_headers="$ac_config_headers config.h"
+
+
+# Checks for programs.
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CXX" && break
+done
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+fi
+
+  fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM 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.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5
+$as_echo_n "checking whether the C++ compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+	;;
+    [ab].out )
+	# We found the default executable, but exeext='' is most
+	# certainly right.
+	break;;
+    *.* )
+	if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+	then :; else
+	   ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	fi
+	# We set ac_cv_exeext here because the later test for it is not
+	# safe: cross compilers may not add the suffix if given an `-o'
+	# argument, so we may need to know it at that point already.
+	# Even if this section looks crufty: it has the advantage of
+	# actually working.
+	break;;
+    * )
+	break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C++ compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5
+$as_echo_n "checking for C++ compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; 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 | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+	  break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+	cross_compiling=yes
+    else
+	{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C++ compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if ${ac_cv_cxx_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GXX=yes
+else
+  GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if ${ac_cv_prog_cxx_g+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+else
+  CXXFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
+else
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
+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
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+	@echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+  am__nodep='_no'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+depcc="$CXX"  am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok '-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
+else
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
+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
+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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&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_fn_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"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+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
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+	 CFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* 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 -std 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 -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 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
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+	-Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+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
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CC_dependencies_compiler_type+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok '-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if ${ac_cv_prog_CPP+:} false; then :
+  $as_echo_n "(cached) " >&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 confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i 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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$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 confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+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
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+	@echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if ${ac_cv_build+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if ${ac_cv_host+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
+set dummy ${ac_tool_prefix}as; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AS+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AS"; then
+  ac_cv_prog_AS="$AS" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AS="${ac_tool_prefix}as"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AS=$ac_cv_prog_AS
+if test -n "$AS"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5
+$as_echo "$AS" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AS"; then
+  ac_ct_AS=$AS
+  # Extract the first word of "as", so it can be a program name with args.
+set dummy as; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AS+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AS"; then
+  ac_cv_prog_ac_ct_AS="$ac_ct_AS" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_AS="as"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AS=$ac_cv_prog_ac_ct_AS
+if test -n "$ac_ct_AS"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5
+$as_echo "$ac_ct_AS" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_AS" = x; then
+    AS="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AS=$ac_ct_AS
+  fi
+else
+  AS="$ac_cv_prog_AS"
+fi
+
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DLLTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DLLTOOL"; then
+  ac_cv_prog_DLLTOOL="$DLLTOOL" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
+$as_echo "$DLLTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+  ac_ct_DLLTOOL=$DLLTOOL
+  # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DLLTOOL"; then
+  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
+$as_echo "$ac_ct_DLLTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_DLLTOOL" = x; then
+    DLLTOOL="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DLLTOOL=$ac_ct_DLLTOOL
+  fi
+else
+  DLLTOOL="$ac_cv_prog_DLLTOOL"
+fi
+
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OBJDUMP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OBJDUMP"; then
+  ac_cv_prog_OBJDUMP="$OBJDUMP" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+  ac_ct_OBJDUMP=$OBJDUMP
+  # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OBJDUMP"; then
+  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_OBJDUMP="objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OBJDUMP" = x; then
+    OBJDUMP="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OBJDUMP=$ac_ct_OBJDUMP
+  fi
+else
+  OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+  ;;
+esac
+
+test -z "$AS" && AS=as
+
+
+
+
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+
+
+
+
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+
+case `pwd` in
+  *\ * | *\	*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.4.2'
+macro_revision='1.3337'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
+$as_echo_n "checking how to print strings... " >&6; }
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='printf %s\n'
+else
+  # Use this function as a fallback that always works.
+  func_fallback_echo ()
+  {
+    eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+  }
+  ECHO='func_fallback_echo'
+fi
+
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO ""
+}
+
+case "$ECHO" in
+  printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
+$as_echo "printf" >&6; } ;;
+  print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
+$as_echo "print -r" >&6; } ;;
+  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
+$as_echo "cat" >&6; } ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if ${ac_cv_path_SED+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+     { ac_script=; unset ac_script;}
+     if test -z "$SED"; then
+  ac_path_SED_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  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_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_SED" || continue
+# Check for GNU ac_path_SED and select it if it is found.
+  # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo '' >> "conftest.nl"
+    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_SED_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_SED="$ac_path_SED"
+      ac_path_SED_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_SED_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_SED"; then
+    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+  fi
+else
+  ac_cv_path_SED=$SED
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+  rm -f conftest.sed
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+$as_echo_n "checking for fgrep... " >&6; }
+if ${ac_cv_path_FGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+   then ac_cv_path_FGREP="$GREP -F"
+   else
+     if test -z "$FGREP"; then
+  ac_path_FGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in fgrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+      as_fn_executable_p "$ac_path_FGREP" || continue
+# Check for GNU ac_path_FGREP and select it if it is found.
+  # Check for GNU $ac_path_FGREP
+case `"$ac_path_FGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'FGREP' >> "conftest.nl"
+    "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_FGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_FGREP="$ac_path_FGREP"
+      ac_path_FGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_FGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_FGREP"; then
+    as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_FGREP=$FGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
+$as_echo "$ac_cv_path_FGREP" >&6; }
+ FGREP="$ac_cv_path_FGREP"
+
+
+test -z "$GREP" && GREP=grep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-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
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&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.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname 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
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_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="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if ${lt_cv_path_NM+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
+  fi
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  if test -n "$DUMPBIN"; then :
+    # Let the user override the test.
+  else
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in dumpbin "link -dump"
+  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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DUMPBIN+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DUMPBIN"; then
+  ac_cv_prog_DUMPBIN="$DUMPBIN" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
+$as_echo "$DUMPBIN" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$DUMPBIN" && break
+  done
+fi
+if test -z "$DUMPBIN"; then
+  ac_ct_DUMPBIN=$DUMPBIN
+  for ac_prog in dumpbin "link -dump"
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DUMPBIN"; then
+  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
+$as_echo "$ac_ct_DUMPBIN" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_DUMPBIN" && break
+done
+
+  if test "x$ac_ct_DUMPBIN" = x; then
+    DUMPBIN=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DUMPBIN=$ac_ct_DUMPBIN
+  fi
+fi
+
+    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    *COFF*)
+      DUMPBIN="$DUMPBIN -symbols"
+      ;;
+    *)
+      DUMPBIN=:
+      ;;
+    esac
+  fi
+
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+$as_echo_n "checking the name lister ($NM) interface... " >&6; }
+if ${lt_cv_nm_interface+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:$LINENO: output\"" >&5)
+  cat conftest.out >&5
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
+$as_echo "$lt_cv_nm_interface" >&6; }
+
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if ${lt_cv_sys_max_cmd_len+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+    i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw* | cegcc*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  mint*)
+    # On MiNT this can take a long time and run out of memory.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
+
+  os2*)
+    # The test takes a long time on OS/2.
+    lt_cv_sys_max_cmd_len=8192
+    ;;
+
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[	 ]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
+$as_echo "none" >&6; }
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+
+
+
+
+
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
+$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,b/c, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
+$as_echo "$xsi_shell" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
+$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
+$as_echo "$lt_shell_append" >&6; }
+
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
+else
+  lt_unset=false
+fi
+
+
+
+
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
+$as_echo_n "checking how to convert $build file names to $host format... " >&6; }
+if ${lt_cv_to_host_file_cmd+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
+        ;;
+    esac
+    ;;
+  *-*-cygwin* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_noop
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+        ;;
+    esac
+    ;;
+  * ) # unhandled hosts (and "normal" native builds)
+    lt_cv_to_host_file_cmd=func_convert_file_noop
+    ;;
+esac
+
+fi
+
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
+$as_echo "$lt_cv_to_host_file_cmd" >&6; }
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
+$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; }
+if ${lt_cv_to_tool_file_cmd+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  #assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+        ;;
+    esac
+    ;;
+esac
+
+fi
+
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
+$as_echo "$lt_cv_to_tool_file_cmd" >&6; }
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if ${lt_cv_ld_reload_flag+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_reload_flag='-r'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    if test "$GCC" != yes; then
+      reload_cmds=false
+    fi
+    ;;
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OBJDUMP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OBJDUMP"; then
+  ac_cv_prog_OBJDUMP="$OBJDUMP" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+  ac_ct_OBJDUMP=$OBJDUMP
+  # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OBJDUMP"; then
+  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_OBJDUMP="objdump"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OBJDUMP" = x; then
+    OBJDUMP="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OBJDUMP=$ac_ct_OBJDUMP
+  fi
+else
+  OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+$as_echo_n "checking how to recognize dependent libraries... " >&6; }
+if ${lt_cv_deplibs_check_method+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[4-9]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[45]*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
+  else
+    # Keep this pattern in sync with the one in func_win32_libid.
+    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
+  fi
+  ;;
+
+cegcc*)
+  # use the weaker test based on 'objdump'. See mingw*.
+  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+haiku*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[3-9]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+  case $host_os in
+  mingw* | pw32*)
+    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+      want_nocaseglob=yes
+    else
+      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`
+    fi
+    ;;
+  esac
+fi
+
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DLLTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DLLTOOL"; then
+  ac_cv_prog_DLLTOOL="$DLLTOOL" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
+$as_echo "$DLLTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DLLTOOL"; then
+  ac_ct_DLLTOOL=$DLLTOOL
+  # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DLLTOOL"; then
+  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
+$as_echo "$ac_ct_DLLTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_DLLTOOL" = x; then
+    DLLTOOL="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DLLTOOL=$ac_ct_DLLTOOL
+  fi
+else
+  DLLTOOL="$ac_cv_prog_DLLTOOL"
+fi
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
+$as_echo_n "checking how to associate runtime and link libraries... " >&6; }
+if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_sharedlib_from_linklib_cmd='unknown'
+
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+  # two different shell functions defined in ltmain.sh
+  # decide which to use based on capabilities of $DLLTOOL
+  case `$DLLTOOL --help 2>&1` in
+  *--identify-strict*)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+    ;;
+  *)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
+    ;;
+  esac
+  ;;
+*)
+  # fallback: assume linklib IS sharedlib
+  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
+$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in ar
+  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
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$AR" && break
+  done
+fi
+if test -z "$AR"; then
+  ac_ct_AR=$AR
+  for ac_prog in ar
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_AR="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_AR" && break
+done
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+fi
+
+: ${AR=ar}
+: ${AR_FLAGS=cru}
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
+$as_echo_n "checking for archiver @FILE support... " >&6; }
+if ${lt_cv_ar_at_file+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ar_at_file=no
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  echo conftest.$ac_objext > conftest.lst
+      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
+      { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+  (eval $lt_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+      if test "$ac_status" -eq 0; then
+	# Ensure the archiver fails upon bogus file names.
+	rm -f conftest.$ac_objext libconftest.a
+	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+  (eval $lt_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+	if test "$ac_status" -ne 0; then
+          lt_cv_ar_at_file=@
+        fi
+      fi
+      rm -f conftest.* libconftest.a
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
+$as_echo "$lt_cv_ar_at_file" >&6; }
+
+if test "x$lt_cv_ar_at_file" = xno; then
+  archiver_list_spec=
+else
+  archiver_list_spec=$lt_cv_ar_at_file
+fi
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+test -z "$STRIP" && STRIP=:
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RANLIB+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+test -z "$RANLIB" && RANLIB=:
+
+
+
+
+
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
+fi
+
+case $host_os in
+  darwin*)
+    lock_old_archive_extraction=yes ;;
+  *)
+    lock_old_archive_extraction=no ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if ${lt_cv_sys_global_symbol_pipe+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw* | pw32* | cegcc*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDEGRST]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris*)
+  symcode='[BDRT]'
+  ;;
+sco3.2v5*)
+  symcode='[DT]'
+  ;;
+sysv4.2uw2*)
+  symcode='[DT]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[ABDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK '"\
+"     {last_section=section; section=\$ 3};"\
+"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
+  (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+   relocations are performed -- see ld's documentation on pseudo-relocs.  */
+# define LT_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data.  */
+# define LT_DLSYM_CONST
+#else
+# define LT_DLSYM_CONST const
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+	  cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols.  */
+LT_DLSYM_CONST struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_globsym_save_LIBS=$LIBS
+	  lt_globsym_save_CFLAGS=$CFLAGS
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+	    pipe_works=yes
+	  fi
+	  LIBS=$lt_globsym_save_LIBS
+	  CFLAGS=$lt_globsym_save_CFLAGS
+	else
+	  echo "cannot find nm_test_func in $nlist" >&5
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
+
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then
+  nm_file_list_spec='@'
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
+$as_echo_n "checking for sysroot... " >&6; }
+
+# Check whether --with-sysroot was given.
+if test "${with_sysroot+set}" = set; then :
+  withval=$with_sysroot;
+else
+  with_sysroot=no
+fi
+
+
+lt_sysroot=
+case ${with_sysroot} in #(
+ yes)
+   if test "$GCC" = yes; then
+     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+   fi
+   ;; #(
+ /*)
+   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+   ;; #(
+ no|'')
+   ;; #(
+ *)
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
+$as_echo "${with_sysroot}" >&6; }
+   as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
+   ;;
+esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
+$as_echo "${lt_sysroot:-no}" >&6; }
+
+
+
+
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+  enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+	HPUX_IA64_MODE="32"
+	;;
+      *ELF-64*)
+	HPUX_IA64_MODE="64"
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -melf32bsmip"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -melf32bmipn32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -melf64bmip"
+	;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -32"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -n32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -64"
+	  ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_i386_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_i386"
+	    ;;
+	  powerpcle-*linux*)
+	    LD="${LD-ld} -m elf32lppclinux"
+	    ;;
+	  powerpc-*linux*)
+	    LD="${LD-ld} -m elf32ppclinux"
+	    ;;
+	  s390x-*linux*)
+	    LD="${LD-ld} -m elf_s390"
+	    ;;
+	  sparc64-*linux*)
+	    LD="${LD-ld} -m elf32_sparc"
+	    ;;
+	esac
+	;;
+      *64-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_x86_64_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_x86_64"
+	    ;;
+	  powerpcle-*linux*)
+	    LD="${LD-ld} -m elf64lppc"
+	    ;;
+	  powerpc-*linux*)
+	    LD="${LD-ld} -m elf64ppc"
+	    ;;
+	  s390*-*linux*|s390*-*tpf*)
+	    LD="${LD-ld} -m elf64_s390"
+	    ;;
+	  sparc*-*linux*)
+	    LD="${LD-ld} -m elf64_sparc"
+	    ;;
+	esac
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if ${lt_cv_cc_needs_belf+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  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
+
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_cc_needs_belf=yes
+else
+  lt_cv_cc_needs_belf=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext 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
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*)
+        case $host in
+        i?86-*-solaris*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        sparc*-*-solaris*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+        esac
+        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
+        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+          LD="${LD-ld}_sol2"
+        fi
+        ;;
+      *)
+	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+esac
+
+need_locks="$enable_libtool_lock"
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
+set dummy ${ac_tool_prefix}mt; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_MANIFEST_TOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$MANIFEST_TOOL"; then
+  ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
+if test -n "$MANIFEST_TOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
+$as_echo "$MANIFEST_TOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
+  ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
+  # Extract the first word of "mt", so it can be a program name with args.
+set dummy mt; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_MANIFEST_TOOL"; then
+  ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
+if test -n "$ac_ct_MANIFEST_TOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
+$as_echo "$ac_ct_MANIFEST_TOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_MANIFEST_TOOL" = x; then
+    MANIFEST_TOOL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
+  fi
+else
+  MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"
+fi
+
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
+$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
+if ${lt_cv_path_mainfest_tool+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_path_mainfest_tool=no
+  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
+  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+  cat conftest.err >&5
+  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+    lt_cv_path_mainfest_tool=yes
+  fi
+  rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
+$as_echo "$lt_cv_path_mainfest_tool" >&6; }
+if test "x$lt_cv_path_mainfest_tool" != xyes; then
+  MANIFEST_TOOL=:
+fi
+
+
+
+
+
+
+  case $host_os in
+    rhapsody* | darwin*)
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DSYMUTIL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
+$as_echo "$DSYMUTIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+  ac_ct_DSYMUTIL=$DSYMUTIL
+  # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DSYMUTIL"; then
+  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
+$as_echo "$ac_ct_DSYMUTIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_DSYMUTIL" = x; then
+    DSYMUTIL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DSYMUTIL=$ac_ct_DSYMUTIL
+  fi
+else
+  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_NMEDIT+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
+$as_echo "$NMEDIT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+  ac_ct_NMEDIT=$NMEDIT
+  # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_NMEDIT"; then
+  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_NMEDIT="nmedit"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
+$as_echo "$ac_ct_NMEDIT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_NMEDIT" = x; then
+    NMEDIT=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    NMEDIT=$ac_ct_NMEDIT
+  fi
+else
+  NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_LIPO+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$LIPO"; then
+  ac_cv_prog_LIPO="$LIPO" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+$as_echo "$LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+  ac_ct_LIPO=$LIPO
+  # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_LIPO"; then
+  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_LIPO="lipo"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
+$as_echo "$ac_ct_LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_LIPO" = x; then
+    LIPO=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    LIPO=$ac_ct_LIPO
+  fi
+else
+  LIPO="$ac_cv_prog_LIPO"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OTOOL"; then
+  ac_cv_prog_OTOOL="$OTOOL" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+  ac_ct_OTOOL=$OTOOL
+  # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OTOOL"; then
+  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_OTOOL="otool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
+$as_echo "$ac_ct_OTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL" = x; then
+    OTOOL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL=$ac_ct_OTOOL
+  fi
+else
+  OTOOL="$ac_cv_prog_OTOOL"
+fi
+
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL64+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OTOOL64"; then
+  ac_cv_prog_OTOOL64="$OTOOL64" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
+$as_echo "$OTOOL64" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+  ac_ct_OTOOL64=$OTOOL64
+  # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OTOOL64"; then
+  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # 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_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_ac_ct_OTOOL64="otool64"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
+$as_echo "$ac_ct_OTOOL64" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_OTOOL64" = x; then
+    OTOOL64=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL64=$ac_ct_OTOOL64
+  fi
+else
+  OTOOL64="$ac_cv_prog_OTOOL64"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+$as_echo_n "checking for -single_module linker flag... " >&6; }
+if ${lt_cv_apple_cc_single_mod+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+	# By default we will add the -single_module flag. You can override
+	# by either setting the environment variable LT_MULTI_MODULE
+	# non-empty at configure time, or by adding -multi_module to the
+	# link flags.
+	rm -rf libconftest.dylib*
+	echo "int foo(void){return 1;}" > conftest.c
+	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+	# If there is a non-empty error log, and "single_module"
+	# appears in it, assume the flag caused a linker warning
+        if test -s conftest.err && $GREP single_module conftest.err; then
+	  cat conftest.err >&5
+	# Otherwise, if the output was created with a 0 exit code from
+	# the compiler, it worked.
+	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	  lt_cv_apple_cc_single_mod=yes
+	else
+	  cat conftest.err >&5
+	fi
+	rm -rf libconftest.dylib*
+	rm -f conftest.*
+      fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
+$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
+if ${lt_cv_ld_exported_symbols_list+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_ld_exported_symbols_list=yes
+else
+  lt_cv_ld_exported_symbols_list=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+	LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
+$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
+$as_echo_n "checking for -force_load linker flag... " >&6; }
+if ${lt_cv_ld_force_load+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_force_load=no
+      cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
+      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
+      echo "$AR cru libconftest.a conftest.o" >&5
+      $AR cru libconftest.a conftest.o 2>&5
+      echo "$RANLIB libconftest.a" >&5
+      $RANLIB libconftest.a 2>&5
+      cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
+      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+      _lt_result=$?
+      if test -s conftest.err && $GREP force_load conftest.err; then
+	cat conftest.err >&5
+      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+	lt_cv_ld_force_load=yes
+      else
+	cat conftest.err >&5
+      fi
+        rm -f conftest.err libconftest.a conftest conftest.c
+        rm -rf conftest.dSYM
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
+$as_echo "$lt_cv_ld_force_load" >&6; }
+    case $host_os in
+    rhapsody* | darwin1.[012])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	10.[012]*)
+	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	10.*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core 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 confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* 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 confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* 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 confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.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))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+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=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in dlfcn.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+func_stripname_cnf ()
+{
+  case ${2} in
+  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  esac
+} # func_stripname_cnf
+
+
+
+
+
+# Set options
+
+
+
+        enable_dlopen=no
+
+
+
+            # Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+  enableval=$enable_shared; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_shared=yes
+fi
+
+
+
+
+
+
+
+
+
+  # Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then :
+  enableval=$enable_static; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_static=yes
+fi
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then :
+  withval=$with_pic; lt_p=${PACKAGE-default}
+    case $withval in
+    yes|no) pic_mode=$withval ;;
+    *)
+      pic_mode=default
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for lt_pkg in $withval; do
+	IFS="$lt_save_ifs"
+	if test "X$lt_pkg" = "X$lt_p"; then
+	  pic_mode=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  pic_mode=default
+fi
+
+
+test -z "$pic_mode" && pic_mode=default
+
+
+
+
+
+
+
+  # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+  enableval=$enable_fast_install; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_fast_install=yes
+fi
+
+
+
+
+
+
+
+
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if ${lt_cv_objdir+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
+
+
+
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/${ac_tool_prefix}file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  else
+    MAGIC_CMD=:
+  fi
+fi
+
+  fi
+  ;;
+esac
+
+# Use C for the default configuration in the libtool script
+
+lt_save_CC="$CC"
+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 $CPP