From: H.G. Muller Date: Thu, 9 Jun 2011 07:17:41 +0000 (+0200) Subject: Check in polyglot-1.4w10UCIb15 X-Git-Url: http://winboard.nl/cgi-bin?p=polyglot.git;a=commitdiff_plain;h=64f72f31685ea1dff12b19b22cfaf7a53ccc079f Check in polyglot-1.4w10UCIb15 This was the oldes version on http://alpha.uhasselt.be/Research/Algebra/Toga . --- 64f72f31685ea1dff12b19b22cfaf7a53ccc079f diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..1445a8f --- /dev/null +++ b/AUTHORS @@ -0,0 +1,4 @@ +Main author: Fabien Letouzey +Native Windows port: Huang Chen ("Morning Yellow") +Various enhancements: Fonzy Bleumers +UCI port: Michel Van den Bergh diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..45645b4 --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..319af6b --- /dev/null +++ b/ChangeLog @@ -0,0 +1,102 @@ +=========1.4w10UCIb15=========== +- Due to refactoring time stamps in Windows would be written twice. +This has been fixed. +- More refactoring; the number of #ifdef _WIN32's has again been +drastically reduced. +=========1.4w10UCIb14=========== +- option to alter priority now also works on windows +(Eric Mullins) +- refactoring so that posix and win32 part share more +code +- a number of potential busy loop scenarios have been eliminated +in the Windows code (Windows uses polling) +- the return value of CreateProcess is now checked +=========1.4w10UCIb13=========== +- perft mode exposed. +=========1.4w10UCIb12=========== +- Replaced %lld everywhere by S64_FORMAT. +=========1.4w10UCIb11=========== +- Crash bug fix (wrong parentheses in instruction that checked for help +option). +=========1.4w10UCIb10=========== +- It is now possible to do "make rpm" to make an rpm binary package. +- Trivial bug fixes. +- Documentation added for epd-test functionality (man page). +- Cosmetic cleanups of output of epd-test. +- "polyglot --help" output added. +- Added polyglot book format specification to distribution. +=========1.4w10UCIb9=========== +- Trivial cosmetic fixes +- Some engines do not support the "Hash" options. +So we do not send memory=1 in that case. +=========1.4w10UCIb8=========== +- Support for egtpath command in xboard protocol +=========1.4w10UCIb7=========== +- Debianization: it is now possible to do "make deb" to build a Debian/Ubuntu +package. +=========1.4w10UCIb6=========== +- UCI GUI support added. This makes it possible to use PG as a book engine +on GUI's like ChessBase and Arena which normally only support their +own proprietary format. + +- Support for new xboard "cores N" and "memory N" commands. See here +for a complete description + + http://home.hccnet.nl/h.g.muller/engine-intf.html + +- Some work arounds for engines like Toga which only allow some settings +to be set before the first "isready" command. + +- Autotooled distribution. + +- Proper manual page. The README file is generated automatically from this. + +- More sane naming of README files. + +- If BookLearn is false (the default) PG will open the book read only. + +- Windows and non-Windows log file formats are now the same. + +- Proper ChangeLog (you are reading it!). +=========1.4w10================ +fixed analysis output for toga +=========1.4w9================= +fixed bug in 1.4w8 +added RepeatPV workaround + fixed disappearing output in engine-output window while in multipv mode + when an engine sends its move to polyglot, + polyglot normally repeats the last pv string(which also contains score,depth and time usage) it got from the engine. + Some engines however do not send a new pv string just before sending the move and the now old pv string + find might confuse debugtools that parse the winboard debug files. + Adding "RepeatPV = false" to the [POLYGLOT] section of the ini file stops this repetition. + +=========1.4w8================= +fixed multipv output +note that the pv with the worst score will be on top of the engine-output window. +added timestamp in logfile (Jaap Weidemann) + +=========1.4w7================= +compiles under linux/unix again +=========1.4w6================= +access to winboard draw/drawoffer and resign + + 1:to activate draw offers the engine has + to define the "UCI_DrawOffers" parameter with the 'option" command at startup. + 2:to offer a draw or accept a draw offer:just send "info string DrawOffer" to polyglot. + 3:if winboard sends "draw" polyglot sends "setoption DrawOffer draw" to the engine. + 4.to resign: send "info string Resign" to polyglot. + please check the winboard documentation for the draw/drawoffer and resign commands. + +=========1.4w5:================ +Fixed errors in SyncStop handling. +book building: the error message now also contains the game number +added Affinity option: +In the [PolyGlot] section(ini file): +- "Affinity" mask +mask is a bit vector in which each bit represents the processors that a process is allowed to run on. + +some minor bugs fixed + +checks if child did really quit. + + diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..d3c5b40 --- /dev/null +++ b/INSTALL @@ -0,0 +1,237 @@ +Installation Instructions +************************* + +Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005, +2006, 2007 Free Software Foundation, Inc. + +This file is free documentation; the Free Software Foundation gives +unlimited permission to copy, distribute and modify it. + +Basic Installation +================== + +Briefly, the shell commands `./configure; make; make install' should +configure, build, and install this package. The following +more-detailed instructions are generic; see the `README' file for +instructions specific to this package. + + 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, and a +file `config.log' containing compiler output (useful mainly for +debugging `configure'). + + It can also use an optional file (typically called `config.cache' +and enabled with `--cache-file=config.cache' or simply `-C') that saves +the results of its tests to speed up reconfiguring. Caching is +disabled by default to prevent problems with accidental use of stale +cache files. + + 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 you are using the cache, and at +some point `config.cache' contains results you don't want to keep, you +may remove or edit it. + + The file `configure.ac' (or `configure.in') is used to create +`configure' by a program called `autoconf'. You need `configure.ac' 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. + + Running `configure' might take a while. 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. + + 6. Often, you can also type `make uninstall' to remove the installed + files again. + +Compilers and Options +===================== + +Some systems require unusual options for compilation or linking that the +`configure' script does not know about. Run `./configure --help' for +details on some of the pertinent environment variables. + + You can give `configure' initial values for configuration parameters +by setting variables in the command line or in the environment. Here +is an example: + + ./configure CC=c99 CFLAGS=-g LIBS=-lposix + + *Note Defining Variables::, for more details. + +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 can use 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 `..'. + + With a non-GNU `make', it is safer 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' installs the package's commands under +`/usr/local/bin', include files under `/usr/local/include', etc. You +can specify an installation prefix other than `/usr/local' by giving +`configure' the option `--prefix=PREFIX'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +pass the option `--exec-prefix=PREFIX' to `configure', the package uses +PREFIX as the prefix for installing programs and libraries. +Documentation and other data files still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=DIR' 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' cannot figure out automatically, +but needs to determine by the type of machine the package will run on. +Usually, assuming the package is built to be run on the _same_ +architectures, `configure' can figure that out, but if it prints a +message saying it cannot guess the machine type, give it the +`--build=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name which has the form: + + CPU-COMPANY-SYSTEM + +where SYSTEM can have one of these forms: + + OS KERNEL-OS + + 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 machine type. + + If you are _building_ compiler tools for cross-compiling, you should +use the option `--target=TYPE' to select the type of system they will +produce code for. + + If you want to _use_ a cross compiler, that generates code for a +platform different from the build platform, you should specify the +"host" platform (i.e., that on which the generated programs will +eventually be run) with `--host=TYPE'. + +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. + +Defining Variables +================== + +Variables not defined in a site shell script can be set in the +environment passed to `configure'. However, some packages may run +configure again during the build, and the customized values of these +variables may be lost. In order to avoid this problem, you should set +them in the `configure' command line, using `VAR=value'. For example: + + ./configure CC=/usr/local2/bin/gcc + +causes the specified `gcc' to be used as the C compiler (unless it is +overridden in the site shell script). + +Unfortunately, this technique does not work for `CONFIG_SHELL' due to +an Autoconf bug. Until the bug is fixed you can use this workaround: + + CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash + +`configure' Invocation +====================== + +`configure' recognizes the following options to control how it operates. + +`--help' +`-h' + Print a summary of the options to `configure', and exit. + +`--version' +`-V' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`--cache-file=FILE' + Enable the cache: use and save the results of the tests in FILE, + traditionally `config.cache'. FILE defaults to `/dev/null' to + disable caching. + +`--config-cache' +`-C' + Alias for `--cache-file=config.cache'. + +`--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. + +`configure' also accepts some other, not widely useful, options. Run +`configure --help' for more details. + diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..49e424b --- /dev/null +++ b/Makefile.am @@ -0,0 +1,25 @@ +#AM_CPPFLAGS=-DDEBUG +#AM_CXXFLAGS=-g + +bin_PROGRAMS = polyglot +polyglot_SOURCES = adapter.cpp attack.cpp board.cpp book.cpp book_make.cpp book_merge.cpp colour.cpp engine.cpp epd.cpp fen.cpp gui.cpp game.cpp hash.cpp io.cpp line.cpp list.cpp main.cpp move.cpp move_do.cpp move_gen.cpp move_legal.cpp option.cpp parse.cpp pgn.cpp piece.cpp pipe.cpp posix.cpp random.cpp san.cpp search.cpp square.cpp uci.cpp uci2uci.cpp util.cpp adapter.h colour.h hash.h move_gen.h piece.h uci2uci.h attack.h config.h gui.h io.h move.h pipe.h posix.h uci.h board.h engine.h line.h move_legal.h random.h util.h book.h epd.h list.h option.h san.h book_make.h fen.h main.h parse.h search.h book_merge.h game.h move_do.h pgn.h square.h + +dist_doc_DATA = README README1.3 README1.4 README1.4w README1.4w10UCI book_format.html + +man6_MANS = polyglot.man + +polyglot.man: polyglot.pod + pod2man -c "" -r "" -s 6 polyglot.pod > polyglot.man + +README: polyglot.man + groff -t -e -mandoc -Tascii polyglot.man| col -bx > README + +deb: + dpkg-buildpackage + +rpm: + make dist + rpmbuild -ta polyglot-@VERSION@.tar.gz + +EXTRA_DIST=makefile.gcc polyglot.man polyglot.pod polyglot.spec debian/changelog debian/control debian/docs debian/README debian/compat debian/copyright debian/files debian/polyglot.substvars debian/rules + diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 0000000..3dc2037 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,705 @@ +# Makefile.in generated by automake 1.10.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008 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. + +@SET_MAKE@ + +#AM_CPPFLAGS=-DDEBUG +#AM_CXXFLAGS=-g + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@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 = : +bin_PROGRAMS = polyglot$(EXEEXT) +subdir = . +DIST_COMMON = README $(am__configure_deps) $(dist_doc_DATA) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ + $(srcdir)/config.h.in $(top_srcdir)/configure AUTHORS COPYING \ + ChangeLog INSTALL NEWS TODO config.guess config.sub depcomp \ + install-sh missing +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(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 = +am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)" \ + "$(DESTDIR)$(docdir)" +binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) +PROGRAMS = $(bin_PROGRAMS) +am_polyglot_OBJECTS = adapter.$(OBJEXT) attack.$(OBJEXT) \ + board.$(OBJEXT) book.$(OBJEXT) book_make.$(OBJEXT) \ + book_merge.$(OBJEXT) colour.$(OBJEXT) engine.$(OBJEXT) \ + epd.$(OBJEXT) fen.$(OBJEXT) gui.$(OBJEXT) game.$(OBJEXT) \ + hash.$(OBJEXT) io.$(OBJEXT) line.$(OBJEXT) list.$(OBJEXT) \ + main.$(OBJEXT) move.$(OBJEXT) move_do.$(OBJEXT) \ + move_gen.$(OBJEXT) move_legal.$(OBJEXT) option.$(OBJEXT) \ + parse.$(OBJEXT) pgn.$(OBJEXT) piece.$(OBJEXT) pipe.$(OBJEXT) \ + posix.$(OBJEXT) random.$(OBJEXT) san.$(OBJEXT) \ + search.$(OBJEXT) square.$(OBJEXT) uci.$(OBJEXT) \ + uci2uci.$(OBJEXT) util.$(OBJEXT) +polyglot_OBJECTS = $(am_polyglot_OBJECTS) +polyglot_LDADD = $(LDADD) +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +SOURCES = $(polyglot_SOURCES) +DIST_SOURCES = $(polyglot_SOURCES) +man6dir = $(mandir)/man6 +NROFF = nroff +MANS = $(man6_MANS) +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = `echo $$p | sed -e 's|^.*/||'`; +dist_docDATA_INSTALL = $(INSTALL_DATA) +DATA = $(dist_doc_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) +am__remove_distdir = \ + { test ! -d $(distdir) \ + || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ + && rm -fr $(distdir); }; } +DIST_ARCHIVES = $(distdir).tar.gz +GZIP_ENV = --best +distuninstallcheck_listfiles = find . -type f -print +distcleancheck_listfiles = find . -type f -print +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LDFLAGS = @LDFLAGS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +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_alias = @build_alias@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host_alias = @host_alias@ +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_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +polyglot_SOURCES = adapter.cpp attack.cpp board.cpp book.cpp book_make.cpp book_merge.cpp colour.cpp engine.cpp epd.cpp fen.cpp gui.cpp game.cpp hash.cpp io.cpp line.cpp list.cpp main.cpp move.cpp move_do.cpp move_gen.cpp move_legal.cpp option.cpp parse.cpp pgn.cpp piece.cpp pipe.cpp posix.cpp random.cpp san.cpp search.cpp square.cpp uci.cpp uci2uci.cpp util.cpp adapter.h colour.h hash.h move_gen.h piece.h uci2uci.h attack.h config.h gui.h io.h move.h pipe.h posix.h uci.h board.h engine.h line.h move_legal.h random.h util.h book.h epd.h list.h option.h san.h book_make.h fen.h main.h parse.h search.h book_merge.h game.h move_do.h pgn.h square.h +dist_doc_DATA = README README1.3 README1.4 README1.4w README1.4w10UCI book_format.html +man6_MANS = polyglot.man +EXTRA_DIST = makefile.gcc polyglot.man polyglot.pod polyglot.spec debian/changelog debian/control debian/docs debian/README debian/compat debian/copyright debian/files debian/polyglot.substvars debian/rules +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-am + +.SUFFIXES: +.SUFFIXES: .cpp .o .obj +am--refresh: + @: +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \ + cd $(srcdir) && $(AUTOMAKE) --gnu \ + && exit 0; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ + 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: $(am__configure_deps) + cd $(srcdir) && $(AUTOCONF) +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) + +config.h: stamp-h1 + @if test ! -f $@; then \ + rm -f stamp-h1; \ + $(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: $(am__configure_deps) + cd $(top_srcdir) && $(AUTOHEADER) + rm -f stamp-h1 + touch $@ + +distclean-hdr: + -rm -f config.h stamp-h1 +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + ; then \ + f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ + $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ + rm -f "$(DESTDIR)$(bindir)/$$f"; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +polyglot$(EXEEXT): $(polyglot_OBJECTS) $(polyglot_DEPENDENCIES) + @rm -f polyglot$(EXEEXT) + $(CXXLINK) $(polyglot_OBJECTS) $(polyglot_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adapter.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/attack.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/board.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/book.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/book_make.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/book_merge.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/colour.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/engine.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gui.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/line.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/move.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/move_do.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/move_gen.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/move_legal.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/option.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pgn.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/piece.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pipe.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/posix.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/san.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/search.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/square.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uci.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uci2uci.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ + +.cpp.o: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< + +.cpp.obj: +@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ mv -f $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` +install-man6: $(man6_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + test -z "$(man6dir)" || $(MKDIR_P) "$(DESTDIR)$(man6dir)" + @list='$(man6_MANS) $(dist_man6_MANS) $(nodist_man6_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.6*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 6*) ;; \ + *) ext='6' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man6dir)/$$inst'"; \ + $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man6dir)/$$inst"; \ + done +uninstall-man6: + @$(NORMAL_UNINSTALL) + @list='$(man6_MANS) $(dist_man6_MANS) $(nodist_man6_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.6*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + case "$$ext" in \ + 6*) ;; \ + *) ext='6' ;; \ + esac; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f '$(DESTDIR)$(man6dir)/$$inst'"; \ + rm -f "$(DESTDIR)$(man6dir)/$$inst"; \ + done +install-dist_docDATA: $(dist_doc_DATA) + @$(NORMAL_INSTALL) + test -z "$(docdir)" || $(MKDIR_P) "$(DESTDIR)$(docdir)" + @list='$(dist_doc_DATA)'; for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + f=$(am__strip_dir) \ + echo " $(dist_docDATA_INSTALL) '$$d$$p' '$(DESTDIR)$(docdir)/$$f'"; \ + $(dist_docDATA_INSTALL) "$$d$$p" "$(DESTDIR)$(docdir)/$$f"; \ + done + +uninstall-dist_docDATA: + @$(NORMAL_UNINSTALL) + @list='$(dist_doc_DATA)'; for p in $$list; do \ + f=$(am__strip_dir) \ + echo " rm -f '$(DESTDIR)$(docdir)/$$f'"; \ + rm -f "$(DESTDIR)$(docdir)/$$f"; \ + done + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$tags $$unique; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$tags$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$tags $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +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 $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ + fi; \ + cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -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__remove_distdir) + +dist-bzip2: distdir + tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 + $(am__remove_distdir) + +dist-lzma: distdir + tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma + $(am__remove_distdir) + +dist-tarZ: distdir + tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z + $(am__remove_distdir) + +dist-shar: distdir + shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz + $(am__remove_distdir) + +dist-zip: distdir + -rm -f $(distdir).zip + zip -rq $(distdir).zip $(distdir) + $(am__remove_distdir) + +dist dist-all: distdir + tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + $(am__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) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ + *.tar.bz2*) \ + bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ + *.tar.lzma*) \ + unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ + *.tar.Z*) \ + uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ + *.shar.gz*) \ + GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ + *.zip*) \ + unzip $(distdir).zip ;;\ + esac + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/_build + mkdir $(distdir)/_inst + chmod a-w $(distdir) + dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ + && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ + && cd $(distdir)/_build \ + && ../configure --srcdir=.. --prefix="$$dc_install_base" \ + $(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 + $(am__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: + @cd $(distuninstallcheck_dir) \ + && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ + || { 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-am +all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) config.h +installdirs: + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)" "$(DESTDIR)$(docdir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_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-am + +clean-am: clean-binPROGRAMS clean-generic mostlyclean-am + +distclean: distclean-am + -rm -f $(am__CONFIG_DISTCLEAN_FILES) + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-hdr distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +info: info-am + +info-am: + +install-data-am: install-dist_docDATA install-man + +install-dvi: install-dvi-am + +install-exec-am: install-binPROGRAMS + +install-html: install-html-am + +install-info: install-info-am + +install-man: install-man6 + +install-pdf: install-pdf-am + +install-ps: install-ps-am + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -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-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-binPROGRAMS uninstall-dist_docDATA \ + uninstall-man + +uninstall-man: uninstall-man6 + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ + clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \ + dist-gzip dist-lzma dist-shar dist-tarZ dist-zip distcheck \ + distclean distclean-compile distclean-generic distclean-hdr \ + 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-dist_docDATA install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-man6 install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-dist_docDATA \ + uninstall-man uninstall-man6 + + +polyglot.man: polyglot.pod + pod2man -c "" -r "" -s 6 polyglot.pod > polyglot.man + +README: polyglot.man + groff -t -e -mandoc -Tascii polyglot.man| col -bx > README + +deb: + dpkg-buildpackage + +rpm: + make dist + rpmbuild -ta polyglot-@VERSION@.tar.gz +# 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/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..0fcb8b7 --- /dev/null +++ b/README @@ -0,0 +1,414 @@ +POLYGLOT(6) POLYGLOT(6) + + + +NAME + PolyGlot - Winboard protocol to UCI protocol adapter + - book engine for Polyglot books + - a collection of utilities for creating opening books + - a utility for analyzing epd files + - a perft counter + +SYNOPSIS + polyglot [configfile] + + polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply] + [-min-game games] [-min-score score] [-only-white] [-only-black] [-uni- + form] + + polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile] + + polyglot [configfile] epd-test [-epd inputfile] [-min-depth depth] + [-max-depth depth] [-max-time time] [-depth-delta delta] + + polyglot perft [-fen fen] [-max-depth depth] + +DESCRIPTION + PolyGlot as adapter and book engine + + PolyGlot is a "UCI adapter". It connects a GUI interface (such as + XBoard, Winboard, Arena or Chessbase) to a UCI chess engine. + + By specifying an opening book (in PolyGlot book format) chess engines + can transparently use such books. + + PolyGlot understands the two main GUI protocols: UCI and xboard. Nor- + mally the protocol will be auto detected but this can be overridden in + the configuration file. + + In xboard mode PolyGlot fully translates between the xboard and UCI + protocols. In addition it tries to solve known problems with other + adapters. For instance, it detects and reports draws by fifty-move + rule, repetition, etc ... It also supports Chess960. + + When in UCI mode PolyGlot mostly passes commands from the GUI to the + engine and vice versa, except that it will play book moves on behalf of + the engine when the occasion arises. + + Book making utilities + + PolyGlot supports the "PolyGlot opening book format". This is the + defacto standard non-proprietary opening book format. It is fully docu- + mented here + + http://alpha.uhasselt.be/Research/Algebra/Toga/book_format.html + + Roughly speaking a PolyGlot opening book is a collection of triples + (position, move, weight). A "position" is represented by a 64-bit + Zobrist hash key. The weight is proportional to the probability the + move should be played. + + Other opening book formats such as ChessBase's .ctg format and Arena's + .abk format are undocumented and proprietary. They can only be used by + their own GUIs. + + PolyGlot can compile a pgn file into a binary PolyGlot book and fur- + thermore it can merge two such binary books into a third one. + + Epd test mode + + In epd test mode, PolyGlot will search positions in an epd file and + record the number of times the right best move was found. The argu- + ments specify when to stop the search in any given position. + + Perft counts + + A perft count is the number of legal move sequence in a given position + up to a given depth. PolyGlot can perform such perft counts. It is how- + ever much slower than other more dedicated programs. + +OPTIONS + When invoked without options or with a config file as argument PolyGlot + acts as an adapter. The config file format is documented below. The + default config file is "polyglot.ini". + + When invoked as + + polyglot make-book + + PolyGlot supports the following options + + -pgn (default: "book.pgn") + Input file in pgn format. + + -bin (default: "book.bin") + Output file in PolyGlot format. + + -max-ply (default: 1024) + Specifies the maximum ply-depth of lines included in the book. + + -min-game (default: 3) + Specifies the minimum number of games that have to contain this + move for it to be included in the book. + + -min-score (default: 0.0) + Specifies the minimum score (or weight) this move should have + received for it to be included in the book. The score is + 2*(wins)+(draws), globally scaled to fit into 16 bits. + + -only-white + Include only moves for white in the book. + + -only-black + Include only moves for black in the book. + + -uniform + Set all weights to 1. In other words, all moves will be selected + with equal probability. + + When invoked as + + polyglot merge-book + + PolyGlot supports the following options + + -in1 + First input file (in PolyGlot book format). + + -in2 + Second input file (in PolyGlot book format). + + -out (default: out.bin) + Output file (in PolyGlot book format). + + Input files are not symmetrical, "in1" has priority over "in2". In + other words when a position occurs both in "in1" and "in2" only the + moves and weights from "in1" will be retained in "out". + + When invoked as + + polyglot epd-test + + (possibly with a config file as first argument) PolyGlot supports the + following options + + -max-depth (default: 63) + Unconditionally stop the search when this depth has been reached. + + -max-time (default: 5.0) + Unconditionally stop the seach after this amount of time. + + -depth-delta (default: 3) + Stop the search if the best move has been constant for this many + depths, on condition that the mininal depth and minimal time have + been reached. + + -min-depth (default: 8) + Minimal search depth when the search is stopped using + "-depth-delta". + + -min-time (default: 1.0) + Minimal search time when the search is stopped using + "-depth-delta". + + When invoked as + + polyglot perft + + PolyGlot supports the following options + + -fen (default: starting position) + Fen at which to start searching. + + -max-depth (default: 1) + Maximum depth to search. + +CONFIG FILE FORMAT + There should be a different config file for each engine. + + The config file is in the traditional INI format. + + [PolyGLot] + option = value + ... + [Engine] + option = value + ... + + Lines starting with "#" are ignored. + + NOTE: There can be spaces in option names or values. Do not use + quotes. Boolean values are written as "true" or "false". + + [PolyGlot] section + + This section is used by PolyGlot only. The engine is unaware of these + options. The list of available options is detailed below. + + EngineName (default: UCI name) + This is the name that will appear in the GUI. It is cosmetic only. + You can use different names for tweaked versions of the same + engine. + + EngineDir (default: ".") + Full path of the directory where the engine is installed. You can + use "." (without the quotes) if you know that PolyGlot will be + launched in the engine directory or the engine is in the "path" and + does not need any data file. + + EngineCommand + Put here the name of the engine executable file. You can also add + command-line arguments. Path searching is used and the current + directory will be "EngineDir". + + Log (default: false) + Whether PolyGlot should log all transactions with the interface and + the engine. This should be necessary only to locate problems. + + LogFile (default: polyglot.log) + The name of the log file. Note that it is put where PolyGlot was + launched from, not into the engine directory. + + WARNING: Log files are not cleared between sessions, and can become + very large. It is safe to remove them though. + + Resign (default: false) + Set this to "true" if you want PolyGlot to resign on behalf of the + engine. + + NOTE: Some engines display buggy scores from time to time although + the best move is correct. Use this option only if you know what + you are doing (e.g. you always check the final position of games). + + ResignMoves (default: 3) + Number of consecutive moves with "resign" score (see below) before + PolyGlot resigns for the engine. Positions with only one legal + move are ignored. + + ResignScore (default: 600) + This is the score in centipawns that will trigger resign "count- + ing". + + ShowPonder (default: true) + Show search information during engine pondering. Turning this off + might be better for interactive use in some interfaces. + + KibitzMove (default: false) + Whether to kibitz when playing a move. + + KibitzPV (default: false) + Whether to kibitz when the PV is changed (new iteration or new best + move). + + KibitzCommand (default: "tellall") + xboard command to use for kibitzing, normally "tellall" for kibitz- + ing or "tellothers" for whispering. + + KibitzDelay (default: 5) + How many seconds to wait before starting kibitzing. This has an + effect only if "KibitzPV" is selected, move kibitzes are always + sent regardless of the delay. + + UCI (default: false) + If true PolyGlot will not understand xboard commands. + + Book (default: false) + Indicates whether a PolyGlot book should be used. This has no + effect on the engine own book (which can be controlled with the UCI + option "OwnBook" in the [Engine] section). In particular, it is + possible to use both a PolyGlot book and an engine book. In that + case, the engine book will be used whenever PolyGlot is out of + book. Remember that PolyGlot is unaware of whether the engine is + itself using a book or not. + + Chess960 (default: false) + Play Chess960 (also called Fischer Random Chess or FRC), + + MateScore (default: 10000) + Mate score reported to GUI when in xboard mode. + + BookFile (default: book.bin) + The name of the (binary) book file. Note that PolyGlot will look + for it in the directory it was launched from, not in the engine + directory. Of course, full path can be used in which case the cur- + rent directory does not matter. + + NOTE: When using PolyGlot with a UCI GUI this parameter can be set + via the UCI option "Polyglot BookFile". + + BookRandom (default: true) + Select moves according to their weights in the book. If false the + move with the highest weight is selected. + + BookLearn (default: false) + Record learning information in the opening book. Naturally this + requires the opening book to be writable. + + UseNice (default: false) + Run the engine at nice level 5, or "NiceValue" if it set. On some + operating systems it may be necessary to run the engine at lower + priority for it to be responsive to commands from PolyGlot while + searching. + + NiceValue (default: 5) + Nice levels go from -20 to 20 with 20 being the lowest priority. + On Unix only root can set negative nice levels. On Windows the + standard Win32 priority levels are mapped in a sensible way to Unix + nice levels. + + Affinity (default: -1) + This a bit vector in which each bit represents the processors that + a process is allowed to run on. This option works only on Windows. + + Work arounds + + Work arounds are identical to options except that they should be used + only when necessary. Their purpose is to try to hide problems with + various software (not just engines). The default value is always cor- + rect for bug-free software. + + IMPORTANT: Any of these work arounds might be removed in future ver- + sions of PolyGlot. You are strongly recommended to contact the author + of faulty software and truly fix the problem. + + PolyGlot supports the following work arounds: + + UCIVersion (default: 2) + The default value of 2 corresponds to UCI+. Use 1 to select plain + UCI for engines that have problems with UCI+. + + CanPonder (default: false) + PolyGlot now conforms to the documented UCI behaviour: the engine + will be allowed to ponder only if it (the engine) declares the + "Ponder" UCI option. However some engines which can actually pon- + der do not declare the option. This work around lets PolyGlot know + that they can ponder. + + SyncStop (default: false) + When a ponder miss occurs, Polyglot interrupts the engine and IMME- + DIATELY launches a new search. While there should be no problem + with this, some engines seem confused and corrupt their search + board. "SyncStop" forces PolyGlot to wait for the (now useless) + ponder search to finish before launching the new search. + + PromoteWorkAround (default: false) + Some engines do not specify a promotion piece, e.g. they send + "e7e8" instead of the correct "e7e8q". This work around enables + the incorrect form (and of course promotes into a queen). + + RepeatPV (default: true) + When true, PolyGlot repeats the last pv string (which also contains + score,depth and time usage) it got from the engine. Some engines + however do not send a new pv string just before sending the move + and the now old pv string might confuse debugtools that parse the + winboard debug files. + + [Engine] section + + This section contains engine UCI options. PolyGlot does not understand + them, but sends the information to the engine at startup (converted to + UCI form). You can add any UCI option that makes sense to the engine + (not just the common options about hash-table size and tablebases). + + NOTE: use INI syntax, not UCI. For example "OwnBook = true" is cor- + rect. It will be replaced by PolyGlot with "setoption name OwnBook + value true" at engine startup. + + Standard UCI options are + + Hash + NalimovPath + NalimovCache + OwnBook + + Hidden options like "Ponder" or "UCI_xxx" are automatic and should not + be put in an INI file. + + The other options are engine-specific. Check their name using a UCI + GUI or launch the engine in a console and type "uci". + +EXAMPLES + Compile "games.pgn" into a book "book.bin" retaining all lines of at + most 30 plies. + + polyglot make-book -pgn games.pgn -bin book.bin -max-ply 30 + + Merge books "in1.bin" and "in2.bin" into a book "out.bin". + + polyglot merge-book -in1 w1.bin -in2 w2.bin -out w.bin + + Here is a minimal config file + + [PolyGlot] + EngineCommand = fruit + [Engine] + +EXIT STATUS + PolyGlot always returns 0 on exit. + +AUTHORS + Main author: Fabien Letouzey + + Native Windows port: Huang Chen ("Morning + Yellow") + + Various enhancements: Fonzy Bleumers + + UCI port: Michel Van den Bergh + +SEE ALSO + xboard(6) + + + + 2009-01-10 POLYGLOT(6) diff --git a/README1.3 b/README1.3 new file mode 100644 index 0000000..fb06d38 --- /dev/null +++ b/README1.3 @@ -0,0 +1,434 @@ + +Legal details +------------- + +PolyGlot 1.3 Copyright 2004-2005 Fabien Letouzey. + +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 + +See the file "copying.txt" for details. + + +General +------- + +PolyGlot 1.3 (2005/06/03). + +PolyGlot is a "UCI adapter". It connects a UCI chess engine to an +xboard interface such as WinBoard. UCI2WB is another such adapter +(for Windows). + +PolyGlot tries to solve known problems with other adapters. For +instance, it detects and reports draws by fifty-move rule, repetition, +etc ... + + +Official distribution URL +------------------------- + +The official distribution web site is Leo Dijksman's WBEC Ridderkerk: +http://wbec-ridderkerk.nl/ This is where you should be looking for +PolyGlot updates in the future. + + +Install +------- + +PolyGlot should have its own directory. The INI files for engines +should also be put there. Dirtier solutions are needed when +BookThinker is used though. + +On Windows the files "polyglot.exe" and "cygwin1.dll" (which you can +download from http://wbec-ridderkerk.nl/) are needed. On Linux and +Mac OS X only the file "polyglot_linux" or "polyglot_mac" is required. + + +Compiling +--------- + +The distribution comes up with Windows, Linux and Mac OS X binaries. +Compiling is therefore not necessary on those systems unless you want +to make a change in the program. In any case this section describes +the compiling procedure, it is safe to skip it. + +PolyGlot is a POSIX application (Unix compatible), and was developed +on Linux using g++ (the GNU C++ compiler). + +1) Unix + +You should be able to compile it on any POSIX-compliant operating +system (*not* Windows) with the following command line (or similar): + +> g++ -O2 -o polyglot *.cpp + +IMPORTANT: In "io.cpp", the variable "UseCR" should be set to "false". + +A Makefile is provided but might not work on your system ... + +2) Windows + +On Windows, you *must* use Cygnus GCC to compile PolyGlot. + +IMPORTANT: In "io.cpp", the variable "UseCR" should be set to "true". + + +Usage +----- + +PolyGlot acts as an xboard engine. There should be no difference with +a normal chess program as far as the interface (e.g. WinBoard) is +concerned. + +PolyGlot is invoked using "polyglot ". Note that PolyGlot +will look for the INI file in the current directory. If no +is given, "polyglot.ini" is selected. + +To use PolyGlot with XBoard, you would type something like this: +> xboard -fd 'polyglot_dir' -fcp 'polyglot engine.ini' + +Quotes are important when there is a space in the argument. + + +INI file +-------- + +There should be a different INI file for each engine. Sections are +composed of "variable = value" lines. See the sample INI files in the +"example" directory. + +NOTE: There can be spaces in variable names or values. Do not use +quotes. + +1) [PolyGlot] section + +This section is used by PolyGlot only. The engine is unaware of these +options. The list of available options is detailed below in this +document. + +2) [Engine] section + +This section contains engine UCI options. PolyGlot does not +understand them, but sends the information to the engine at startup +(converted to UCI form). You can add any UCI option that makes sense +to the engine (not just the common options about hash-table size and +tablebases). + +NOTE: use INI syntax, not UCI. For example "OwnBook = true" is +correct. It will be replaced by PolyGlot with "setoption name OwnBook +value true" at engine startup. + +Standard UCI options are "Hash", "NalimovPath", "NalimovCache" and +"OwnBook". Hidden options like "Ponder" or "UCI_xxx" are automatic +and should not be put in an INI file. + +The other options are engine-specific. Check their name using a UCI +GUI or launch the engine in a console and type "uci". + + +Options +------- + +These should be put in the [PolyGlot] section. + +- "EngineName" (default: UCI name) + +This is the name that will appear in the xboard interface. It is +cosmetic only. You can use different names for tweaked versions of +the same engine. + +If no "Engine Name" is given, the UCI name will be used. + +- "EngineDir" (default: ".") + +Full path of the directory where the engine is installed. You can use +"." (without the quotes) if you know that PolyGlot will be launched in +the engine directory or the engine is in the "path" and does not need +any data file. + +- "EngineCommand" + +Put here the name of the engine executable file. You can also add +command-line arguments. Path searching is used and the current +directory will be "EngineDir". + +NOTE: Unix users are recommended to prepend "./"; this is required on +some secure systems. + +- "Log" (default: false) + +Whether PolyGlot should log all transactions with the interface and +the engine. This should be necessary only to locate problems. + +- "LogFile" + +The name of the log file. Note that it is put where PolyGlot was +launched from, not into the engine directory. + +WARNING: Log files are not cleared between sessions, and can become +very large. It is safe to remove them though. + +- "Resign" (default: false) + +Set this to "true" if you want PolyGlot to resign on behalf of the +engine. + +NOTE: Some engines display buggy scores from time to time although the +best move is correct. Use this option only if you know what you are +doing (e.g. you always check the final position of games). + +- "ResignMoves" (default: 3) + +Number of consecutive moves with "resign" score (see below) before +PolyGlot resigns for the engine. Positions with only one legal move +are ignored. + +- "ResignScore" (default: 600) + +This is the score in centipawns that will trigger resign "counting". + +- "ShowPonder" (*** NEW ***, default: true) + +Show search information during engine pondering. Turning this off +might be better for interactive use in some interfaces. + +- "KibitzMove" (*** NEW ***, default: false) + +Whether to kibitz when playing a move. + +- "KibitzPV" (*** NEW ***, default: false) + +Whether to kibitz when the PV is changed (new iteration or new best move). + +- "KibitzCommand" (*** NEW ***, default: "tellall") + +xboard command to use for kibitzing, normally "tellall" for kibitzing +or "tellothers" for whispering. + +- "KibitzDelay" (*** NEW ***, default: 5) + +How many seconds to wait before starting kibitzing. This has an +affect only if "KibitzPV" is selected, move kibitzes are always sent +regardless of the delay. + + +Work arounds +------------ + +Work arounds are identical to options except that they should be used +only when necessary. Their purpose is to try to hide problems with +various software (not just engines). The default value is always +correct for bug-free software. + +IMPORTANT: Any of these work arounds might be removed in future +versions of PolyGlot. You are strongly recommended to contact the +author of faulty software and truly fix the problem. + +In PolyGlot 1.3 there is only one optional work around: + +- "UCIVersion" (default: 2) + +The default value of 2 corresponds to UCI+. Use 1 to select plain +UCI for engines that have problems with UCI+. + + +Opening Book +------------ + +*** NEW *** + +PolyGlot 1.3 provides a minimal opening-book implementation. + +New options can be added to the [PolyGlot] section: + +- "Book" (default: false) + +Indicates whether a PolyGlot book should be used. This has no effect +on the engine own book (which can be controlled with the UCI option +"OwnBook" in the [Engine] section). In particular, it is possible to +use both a PolyGlot book and an engine book. In that case, the engine +book will be used whenever PolyGlot is out of book. Remember that +PolyGlot is unaware of whether the engine is itself using a book or +not. + +- "BookFile" + +The name of the (binary) book file. Note that PolyGlot will look for +it in the directory it was launched from, not in the engine directory. +Of course, full path can be used in which case the current directory +does not matter. + +Note that there is no option to control book usage. All parameters +are fixed when compiling a PGN file into a binary book (see below). +This is purposeful and is not likely to change. + +Using a book does not require any additional memory, this can be +important for memory-limited tournaments. + +A default book "fruit.bin" is provided in the archive. Note that this +book is very small and should probably not be used in serious games. +I hope that users will make other books available in the future. + + +Book Making +----------- + +*** NEW *** + +You can compile a PGN file into a binary book using PolyGlot on the +command line. At the moment, only a main (random) book is provided. +It is not yet possible to control opening lines manually. I am +working on it though. + +Usage: "polyglot make-book ". + +"make-book" options are: + +- "-pgn" + +Name of the input PGN file. PolyGlot should support any +standard-conforming file. Let me know if you encounter a problem. + +- "-bin" + +Name of the output binary file. I suggest ".bin" as the extension but +in fact PolyGlot does not care. + +- "-max-ply" (default: infinite) + +How many plies (half moves) to read for each game. E.g. if set to +"20", only the first 10 full moves of each game will be scanned. + +- "-min-game" (default: 3) + +How many times must a move be played to be kept in the book. In other +words, moves that were played too rarely will be left out. If you +scan full games "2" seems a minimum, but if you selected lines +manually "1" will make sense. + +Example: "polyglot make-book -pgn games.pgn -bin book.bin -max-ply 30". + +Building a book is usually very fast (a few minutes at most). Note +however that a lot of memory may be required. To reduce memory usage, +select a ply limit. + + +History +------- + +2004/04/30: PolyGlot 1.0 + +- first public release. + +2004/10/01: PolyGlot 1.1 + +- added "StartupWait" and "PonderWorkAround" ("AutoQuit" was available + in version 1.0 but not documented). + +- fixed a minor bug that could prevent "AutoQuit" from working with + some engines. + +2005/01/29: PolyGlot 1.2 + +- rewrote engine initialisation and UCI parsing to increase + UCI-standard compliance + +- added multi-move resign + +- added an internal work around for engines hanging with WinBoard + +2005/06/03: PolyGlot 1.3 + +- added opening book + +- added kibitzing + +- added "ShowPonder" option + + + +Known bugs +---------- + +*** IMPORTANT *** + +There is a bug (!) in the xboard automaton. The bug is related to +searching in draw positions (e.g. 50-move rule or repetition). I had +only been able to make PolyGlot crash by using analysis mode and +performing manual takebacks. I believe that this bug can only happen +in highly-interactive use (e.g. manual analysis). It is present in +all versions of PolyGlot, including this one. + +I attempted a work around in February. I vaguely remember the change +prevents crashing (not sure) but it is possible that PolyGlot now gets +stuck in some rare case, i.e. it refuses to produce a move. In any +case, the bug cannot occur silently, e.g. in a game that terminated +normally. + +Because of the small expected impact (nobody ever reported it to me) +and because fixing the bug would require a whole redesign of the +xboard module, I have no intention of working on it at the moment (!). + +Make sure to let me know if it appeared in any circounstance, thanks! +In particular if the bug ever occurs during a non-interactive session +(e.g. engine vs. engine game), then I will do something. + + +Thanks +------ + +Big thanks go to: + +- Dann Corbit for spending a lot of time compiling, testing, making + files available, etc ... + +- Leo Dijksman for hosting the PolyGlot distribution on his web site + (see Links) and also for thorough testing + +- Tord Romstad, Joshua Shriver and George Sobala for compiling and + testing on Mac OS X + +- users in the WinBoard forum for their feedback and encouraging + words: Roger Brown, Leo Dijksman, Igor Gorelikov, Mogens Larsen, + Volker Pittlik, Norm Pollock, Günther Simon and Salvo Spitaleri + in particular + + +Links +----- + +- Tim Mann's Chess Pages: http://www.tim-mann.org/xboard.html +- Leo Dijksman's WBEC Ridderkerk: http://wbec-ridderkerk.nl/ +- Volker Pittlik's Winboard Forum: http://wbforum.volker-pittlik.name/ + + +Contact me +---------- + +You can contact me at fabien_letouzey@hotmail.com + +If I am not available, you can discuss PolyGlot issues in Volker +Pittlik's Winboard Forum: http://wbforum.volker-pittlik.name/ + +In fact for questions regarding specific Windows-only engines, you are +advised to ask directly in the WinBoard forum, as I don't have Windows +myself. + + +The end +------- + +Fabien Letouzey, 2005/06/03. + diff --git a/README1.4 b/README1.4 new file mode 100644 index 0000000..edd4e8f --- /dev/null +++ b/README1.4 @@ -0,0 +1,615 @@ + +Legal details +------------- + +PolyGlot 1.4 Copyright 2004-2006 Fabien Letouzey. + +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 + +See the file "copying.txt" for details. + + +General +------- + +PolyGlot 1.4 (2006/01/16). + +PolyGlot is a "UCI adapter". It connects a UCI chess engine to an +xboard interface such as WinBoard. UCI2WB is another such adapter +(for Windows). + +PolyGlot tries to solve known problems with other adapters. For +instance, it detects and reports draws by fifty-move rule, repetition, +etc ... + + +Official distribution URL +------------------------- + +The official distribution web site is Leo Dijksman's WBEC Ridderkerk: +http://wbec-ridderkerk.nl/ This is where you should be looking for +PolyGlot updates in the future. + + +Install +------- + +PolyGlot can be placed in its own directory, or anywhere it can access +the DLL file from (on Windows). + +On Windows the files "polyglot.exe" and "cygwin1.dll" (which you can +download from http://wbec-ridderkerk.nl/) are needed. On Linux and +Mac OS X only the file "polyglot_linux" or "polyglot_mac" is required. + + +Compiling +--------- + +The distribution comes up with Windows, Linux and Mac OS X binaries. +Compiling should therefore not be necessary on those systems unless +you want to make a change in the program. In any case this section +describes the compiling procedure, it is safe to skip it. + +PolyGlot is a POSIX application (Unix compatible), and was developed +on Linux using g++ (the GNU C++ compiler). + +1) Unix + +You should be able to compile it on any POSIX-compliant operating +system (*not* Windows) with the following command line (or similar): + +> g++ -O2 -o polyglot *.cpp + +IMPORTANT: In "io.cpp", the variable "UseCR" should be set to "false". + +A Makefile is provided but might not work on your system ... + +2) Windows + +On Windows, you *must* use Cygnus GCC to compile PolyGlot. + +IMPORTANT: In "io.cpp", the variable "UseCR" should be set to "true". + + +Usage +----- + +PolyGlot acts as an xboard engine. There should be no difference with +a normal chess program as far as the interface (e.g. WinBoard) is +concerned. + +PolyGlot is invoked using "polyglot ". Note that PolyGlot +will look for the INI file in the current directory. If no +is given, "polyglot.ini" is selected. + +To use PolyGlot with XBoard, you would type something like this: +> xboard -fd 'ini_dir' -fcp 'polyglot engine.ini' + +Quotes are important when there is a space in the argument. + +IMPORTANT: some users seem confused by the concept of "current +directory". PolyGlot needs to know where to read (INI file) and write +(log file) files. Although it's possible to specify the full path to +each file, a better solution is to provide a directory when launching +PolyGlot, e.g. with the "-fd" XBoard option above. The directory +should be where the INI file is. + + +INI file +-------- + +There should be a different INI file for each engine. Sections are +composed of "variable = value" lines. See the sample INI files in the +"example" directory. + +NOTE: There can be spaces in variable names or values. Do not use +quotes. + +1) [PolyGlot] section + +This section is used by PolyGlot only. The engine is unaware of these +options. The list of available options is detailed below in this +document. + +2) [Engine] section + +This section contains engine UCI options. PolyGlot does not +understand them, but sends the information to the engine at startup +(converted to UCI form). You can add any UCI option that makes sense +to the engine (not just the common options about hash-table size and +tablebases). + +NOTE: use INI syntax, not UCI. For example "OwnBook = true" is +correct. It will be replaced by PolyGlot with "setoption name OwnBook +value true" at engine startup. + +Standard UCI options are "Hash", "NalimovPath", "NalimovCache" and +"OwnBook". Hidden options like "Ponder" or "UCI_xxx" are automatic +and should not be put in an INI file. + +The other options are engine-specific. Check their name using a UCI +GUI or launch the engine in a console and type "uci". + + +Options +------- + +These should be put in the [PolyGlot] section. + +- "EngineName" (default: UCI name) + +This is the name that will appear in the xboard interface. It is +cosmetic only. You can use different names for tweaked versions of +the same engine. + +If no "Engine Name" is given, the UCI name will be used. + +- "EngineDir" (default: ".") + +Full path of the directory where the engine is installed. You can use +"." (without the quotes) if you know that PolyGlot will be launched in +the engine directory or the engine is in the "path" and does not need +any data file. + +- "EngineCommand" + +Put here the name of the engine executable file. You can also add +command-line arguments. Path searching is used and the current +directory will be "EngineDir". + +NOTE: Unix users are recommended to prepend "./"; this is required on +some secure systems. + +- "Log" (default: false) + +Whether PolyGlot should log all transactions with the interface and +the engine. This should be necessary only to locate problems. + +- "LogFile" + +The name of the log file. Note that it is put where PolyGlot was +launched from, not into the engine directory. + +WARNING: Log files are not cleared between sessions, and can become +very large. It is safe to remove them though. + +- "Resign" (default: false) + +Set this to "true" if you want PolyGlot to resign on behalf of the +engine. + +NOTE: Some engines display buggy scores from time to time although the +best move is correct. Use this option only if you know what you are +doing (e.g. you always check the final position of games). + +- "ResignMoves" (default: 3) + +Number of consecutive moves with "resign" score (see below) before +PolyGlot resigns for the engine. Positions with only one legal move +are ignored. + +- "ResignScore" (default: 600) + +This is the score in centipawns that will trigger resign "counting". + +- "ShowPonder" (default: true) + +Show search information during engine pondering. Turning this off +might be better for interactive use in some interfaces. + +- "KibitzMove" (default: false) + +Whether to kibitz when playing a move. + +- "KibitzPV" (default: false) + +Whether to kibitz when the PV is changed (new iteration or new best move). + +- "KibitzCommand" (default: "tellall") + +xboard command to use for kibitzing, normally "tellall" for kibitzing +or "tellothers" for whispering. + + +- "KibitzDelay" (default: 5) + +How many seconds to wait before starting kibitzing. This has an +affect only if "KibitzPV" is selected, move kibitzes are always sent +regardless of the delay. + + +Work arounds +------------ + +Work arounds are identical to options except that they should be used +only when necessary. Their purpose is to try to hide problems with +various software (not just engines). The default value is always +correct for bug-free software. + +IMPORTANT: Any of these work arounds might be removed in future +versions of PolyGlot. You are strongly recommended to contact the +author of faulty software and truly fix the problem. + +PolyGlot 1.4 supports the following work arounds: + +- "UCIVersion" (default: 2) + +The default value of 2 corresponds to UCI+. Use 1 to select plain +UCI for engines that have problems with UCI+. + +- "CanPonder" (*** NEW ***, default: false) + +PolyGlot now conforms to the documented UCI behaviour: the engine will +be allowed to ponder only if it (the engine) declares the "Ponder" UCI +option. However some engines which can actually ponder do not declare +the option. This work around lets PolyGlot know that they can ponder. + +- "SyncStop" (*** NEW ***, default: false) + +When a ponder miss occurs, Polyglot interrupts the engine and +IMMEDIATELY launches a new search. While there should be no problem +with this, some engines seem confused and corrupt their search board. +"SyncStop" forces PolyGlot to wait for the (now useless) ponder search +to finish before launching the new search. + +- "PromoteWorkAround" (*** NEW ***, default: false) + +Some engines do not specify a promotion piece, e.g. they send "e7e8" +instead of the correct "e7e8q". This work around enables the +incorrect form (and of course promotes into a queen). + + +Opening Book +------------ + +PolyGlot 1.4 provides a simplistic opening-book implementation. + +The following options can be added to the [PolyGlot] section: + +- "Book" (default: false) + +Indicates whether a PolyGlot book should be used. This has no effect +on the engine own book (which can be controlled with the UCI option +"OwnBook" in the [Engine] section). In particular, it is possible to +use both a PolyGlot book and an engine book. In that case, the engine +book will be used whenever PolyGlot is out of book. Remember that +PolyGlot is unaware of whether the engine is itself using a book or +not. + +- "BookFile" + +The name of the (binary) book file. Note that PolyGlot will look for +it in the directory it was launched from, not in the engine directory. +Of course, full path can be used in which case the current directory +does not matter. + +Note that there is no option to control book usage. All parameters +are fixed when compiling a PGN file into a binary book (see below). +This is purposeful and is not likely to change. + +Using a book does not require any additional memory, this can be +important for memory-limited tournaments. + +A default book "fruit.bin" is provided in the archive. Note that this +book is very small and should probably not be used in serious games. +I hope that users will make other books available in the future. + + +Book Making +----------- + +You can compile a PGN file into a binary book using PolyGlot on the +command line. At the moment, only a main (random) book is provided. +It is not yet possible to control opening lines manually. I am +working on it though. + +Usage: "polyglot make-book ". + +"make-book" options are: + +- "-pgn" + +Name of the input PGN file. PolyGlot should support any +standard-conforming file. Let me know if you encounter a problem. + +- "-bin" + +Name of the output binary file. I suggest ".bin" as the extension but +in fact PolyGlot does not care. + +- "-max-ply" (default: infinite) + +How many plies (half moves) to read for each game. E.g. if set to +"20", only the first 10 full moves of each game will be scanned. + +- "-min-game" (default: 3) + +How many times must a move be played to be kept in the book. In other +words, moves that were played too rarely will be left out. If you +scan full games "2" seems a minimum, but if you selected lines +manually "1" will make sense. + +- "-only-white" *** NEW *** + +Save only white moves. This allows to use different parameters for +white and black books, and merge them into a single file with the +"merge-book" command, see below. + +- "-only-black" *** NEW *** + +Same for black moves. + +- "-uniform" *** NEW *** + +By default, a probability is calculated by PolyGlot for each move +depending on how popular it is (how often it was playing in the +provided PGN file) and how much it "scored". This option bypasses the +default mechanism and affects equal probability to all moves. This +allows more variety of play. + +This option is normally used only with hand-selected lines (e.g. "user +books"). + +--- + +Example: "polyglot make-book -pgn games.pgn -bin book.bin -max-ply 30". + +Building a book is usually very fast (a few minutes at most). Note +however that a lot of memory may be required. To reduce memory usage, +select a ply limit. + + +Book Merging +------------ + +*** NEW *** + +Usage: "polyglot merge-book -in1 -in2 -out " + +Merge two bin files into a single one. has "priority"; this +means that if a position is present in both input books, data from + will be ignored for this position. + +The two main applications are: + +1) combine a white book and a black book (in which case priority does + not matter) + +2) combine a "user book" of manually-selected lines with a broader one + from a large game set + +What follows is an admitedly complicated example of how this can be +used. DO NOT MAILBOMB ME IF YOU DO NOT UNDERSTAND! + +My hope is that at least one advanced user will get what I mean and +writes a better explanation on a web page or forum thread (yes, that's +YOU, thanks by the way) ... + +--- + +Imagine that we've got 4 PGN files as follows: + +w1.pgn: fixed white lines, all moves manually checked +w2.pgn: selected games (for random book as with PolyGlot 1.3) + +b1.pgn and b2.pgn: same for black + +The first step is to build 4 .bin files with appropriate options. +Lines starting with "> " indicate what is typed on the command line. + +> polyglot make-book -min-game 1 -uniform -only-white -pgn w1.pgn -bin w1.bin + +I added "-uniform" because it allows randomness in the fixed lines +(e.g. d4+e4 at 50%). It has no effect if lines are deterministic +(only one move for a given position). + +"-min-game 1" is characteristic for user books. All moves are supposed +to be safe so there is no reason to filter them with other heuristics. + +> polyglot make-book -min-score 50 -only-white -pgn w2.pgn -bin w2.bin + +This shows how min-score can actually be different for white and black +(as with multiple books). I don't use "max-ply" because "min-game" +default value of 3 will limit depth somewhat. You are of course free +to use it. + +Same for black: + +> polyglot make-book -min-game 1 -uniform -only-black -pgn b1.pgn -bin b1.bin +> polyglot make-book -min-score 40 -only-black -pgn b2.pgn -bin b2.bin + +At this point we have 4 .bin files. Notice that different parameters +were used for white and for black (not to mention that different PGN +files can be used). + +--- + +Let's now merge the white books. + +> polyglot merge-book -in1 w1.bin -in2 w2.bin -out w.bin + +Input files are not symmetrical, "in1" has priority over "in2". + +"skipped xxx entries." message from PolyGlot means there were some +position conflicts. This is normal since we want to overwrite some +random moves with fixed lines instead. + +Same for black: + +> polyglot merge-book -in1 b1.bin -in2 b2.bin -out b.bin + +Now we can finally merge the white and black books. + +> polyglot merge-book -in1 w.bin -in2 b.bin -out book.bin + +It's important to check that there are no conflicts, otherwise +something went wrong. + +Note that this last operation was only made possible thanks to colour +filtering, otherwise nearly all positions would lead to conflicts. +For this reason, it does not make much sense to mix old .bin files +(which contain moves for both colours). + +All these command lines might seem numerous and complicated but they +can be put together into batch files. + + +Chess 960 +--------- + +*** NEW *** + +PolyGlot now supports Chess 960. + +However note that most xboard interfaces like WinBoard do not (except +perhaps on an Internet chess server)! + +Here are pointers to modified XBoard/WinBoard versions that are known +to work with PolyGlot in Chess960 mode: + +http://www.ascotti.org/programming/chess/winboard_x.htm (Windows) +http://www.glaurungchess.com/xboard-960.tar.bz2 (Unix) +http://www.milix.net/aice (?) + +It is also possible that PolyGlot is useful in combination with +Arena(!): Arena Chess960 works correctly in xboard mode but it seems +not compatible with the official UCI standard. With PolyGlot it is +possible to include Chess960 UCI engines by using the xboard protocol +instead. + + +History +------- + +2004/04/30: PolyGlot 1.0 + +- first public release. + +2004/10/01: PolyGlot 1.1 + +- added "StartupWait" and "PonderWorkAround" ("AutoQuit" was available + in version 1.0 but not documented). + +- fixed a minor bug that could prevent "AutoQuit" from working with + some engines. + +2005/01/29: PolyGlot 1.2 + +- rewrote engine initialisation and UCI parsing to increase + UCI-standard compliance + +- added multi-move resign + +- added an internal work around for engines hanging with WinBoard + +2005/06/03: PolyGlot 1.3 + +- added opening book + +- added kibitzing + +- added "ShowPonder" option + +2006/01/16: PolyGlot 1.4 + +- added Chess960 (requires "fischerandom" xboard variant) + +- added "-only-white", "-only-black" and "-uniform" book-making + options + +- added "merge-book" command + +- added "CanPonder", "SyncStop" and "PromoteWorkAround" work arounds + +- fixed "Move Now" (the engine was interrupted but the move was + ignored) + +- fixed an UCI+draw problem that could occur with some engines after a + draw by 50 moves or repetition + +- fixed pondering behaviour: the engine will ponder only if it + declares the "Ponder" UCI option + + +Known problems +-------------- + +The addition of Chess960 support lead to a change in internal-move +representation for castling. This slightly affected the opening-book +format. I recommend that you recompile books with this version. + +Fruit 2.2 and above handle both book formats though. + +--- + +Several users reported engines losing on time. The playing conditions +always mixed playing on an Internet server with pondering. Early +log-file analysis did not reveal any misbehaviour by PolyGlot, but I +have others to study. + +It is not yet clear what the source of the problem is, but let me +state one more time that there is a forever incompatibility between +the xboard and UCI protocol regarding a complex +pondering/remaining-time relation. I suspect this might be related to +the problem described above and if so, it is possible that there is no +clean solution to it! + +In any case I have other log file to study that might reveal +something, stay tuned! + + +Thanks +------ + +Big thanks go to: + +- Leo Dijksman for compiling, hosting the PolyGlot distribution on his web site + (see Links) and also for thorough testing + +- Tord Romstad, Joshua Shriver and George Sobala for compiling and + testing on Mac OS X + +- all those who reported problems or proposed improvements; I am not + well organised enough to provide their names! + + +Links +----- + +- Tim Mann's Chess Pages: http://www.tim-mann.org/xboard.html +- Leo Dijksman's WBEC Ridderkerk: http://wbec-ridderkerk.nl/ +- Volker Pittlik's Winboard Forum: http://wbforum.volker-pittlik.name/ + + +Contact me +---------- + +You can contact me at fabien_letouzey@hotmail.com; expect SLOW answer, +if at all! + +If I am not available, you can discuss PolyGlot issues in Volker +Pittlik's Winboard Forum: http://wbforum.volker-pittlik.name/ + +In fact for questions regarding specific Windows-only engines, you are +advised to ask directly in the WinBoard forum, as I don't have Windows +myself. + + +The end +------- + +Fabien Letouzey, 2006/01/16. + diff --git a/README1.4w b/README1.4w new file mode 100644 index 0000000..1567e9f --- /dev/null +++ b/README1.4w @@ -0,0 +1,69 @@ +=== PolyGlot 1.4W ==== +Polyglot 1.4W is a modified polyglot 1.4 from Fabien Letouzy. +Just like polyglot 1.3w(see below) it can be compiled and run under windows without +the need for a cygwin1.dll + +Best +Fonzy +www.geenvis.net +=========1.4w10================ +fixed analysis output for toga +=========1.4w9================= +fixed bug in 1.4w8 +added RepeatPV workaround + fixed disappearing output in engine-output window while in multipv mode + when an engine sends its move to polyglot, + polyglot normally repeats the last pv string(which also contains score,depth and time usage) it got from the engine. + Some engines however do not send a new pv string just before sending the move and the now old pv string + find might confuse debugtools that parse the winboard debug files. + Adding "RepeatPV = false" to the [POLYGLOT] section of the ini file stops this repetition. + +=========1.4w8================= +fixed multipv output +note that the pv with the worst score will be on top of the engine-output window. +added timestamp in logfile (Jaap Weidemann) + +=========1.4w7================= +compiles under linux/unix again +=========1.4w6================= +access to winboard draw/drawoffer and resign + + 1:to activate draw offers the engine has + to define the "UCI_DrawOffers" parameter with the 'option" command at startup. + 2:to offer a draw or accept a draw offer:just send "info string DrawOffer" to polyglot. + 3:if winboard sends "draw" polyglot sends "setoption DrawOffer draw" to the engine. + 4.to resign: send "info string Resign" to polyglot. + please check the winboard documentation for the draw/drawoffer and resign commands. + +=========1.4w5:================ +Fixed errors in SyncStop handling. +book building: the error message now also contains the game number +added Affinity option: +In the [PolyGlot] section(ini file): +- "Affinity" mask +mask is a bit vector in which each bit represents the processors that a process is allowed to run on. + +some minor bugs fixed + +checks if child did really quit. + +********************************************************* +=== PolyGlot 1.3W ReadMe === + +PolyGlot - a UCI-to-WinBoard Adapter for UCI Chess Engines +Designed by Fabien Letouzey and Morning Yellow +Version: 1.3W, Last Modified: Jan. 2006 + +PolyGlot 1.3W is the modified version of 1.3 by Fabien Letouzey, +which can be compiled and run under Windows without CygWin. + +The version of 1.3W has the following modifications: +1. Added a module, "pipe.h/pipe.cpp". +2. Removed two modules, "io.h/io.cpp" and "engine.h/engine.cpp". +3. Modified all statements related on these modules. +4. fixed "Move Now" (the bug fixed in PolyGlot 1.4). + +PolyGlot 1.3W can be downloaded from: +http://www.elephantbase.net/download/polyglot.rar +For information of "PolyGlot 1.3", see "readme.txt" +For legal information, see "copying.txt" diff --git a/README1.4w10UCI b/README1.4w10UCI new file mode 100644 index 0000000..85945bc --- /dev/null +++ b/README1.4w10UCI @@ -0,0 +1,50 @@ +Description +=========== + +This is an enhanced version of Polyglot 1.4w10 which can be used as a book +engine for Polyglot books on UCI GUIs. It also has some additional features +(see below). + +Some GUIs like ChessBase do not support Winboard engines at all. Other +GUIs do support the Winboard protocol (like Arena) but you still lose +the convenience of setting UCI options through the GUI. + +This new version of Polyglot is fully backward compatible and will in +fact under normal circumstances autodetect the protocol. + +The following is a minimal polyglot.ini file to make an engine use +Polyglot books. + +[Polyglot] +EngineCommand = +[Engine] + +By default this does not use any book but you can set the Polyglot book +in the GUI through the exported UCI option "Polyglot BookFile". + +Any normal polyglot.ini file can be used with this version. The UCI +options you set in the [Engine] section will be honored and the +results will be shown in the GUI as "defaults". + +If you want to override the protocol autodetection (which should +normally not be necessary) you can put + +UCI = true + +in the [Polyglot] section. + +Just like 1.4w10, this version of Polyglot compiles both under Linux +and Windows. + +Some notes on Arena +=================== + +Up to version 1.99b5 Arena contained a bug with drive letters in UCI +options. This bug has been fixed in 2.00. + +If you let Arena autodetect the engine type then it will use Polyglot +in Winboard mode. So either configure the Polyglot adapter explicitly +as a UCI engine in the Arena GUI, or else put UCI = true in the +[Polyglot] section of polyglot.ini. + + diff --git a/TODO b/TODO new file mode 100644 index 0000000..0bb84e1 --- /dev/null +++ b/TODO @@ -0,0 +1,6 @@ +Better check for legality of arguments (i.e. stuff after [configfile]). +Implementation of new wb/xb options +GUI mode +Allow buttons in UCI mode +Set book [none] instead of nothing as it is now. +Implementation of Marc Lacrosse's utility \ No newline at end of file diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 0000000..eb3b99a --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,868 @@ +# generated automatically by aclocal 1.10.1 -*- Autoconf -*- + +# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2007, 2008 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_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +m4_if(AC_AUTOCONF_VERSION, [2.61],, +[m4_warning([this file was generated for autoconf 2.61. +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'.])]) + +# Copyright (C) 2002, 2003, 2005, 2006, 2007 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.10' +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.10.1], [], + [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 AC_INIT_AUTOMAKE. +AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], +[AM_AUTOMAKE_VERSION([1.10.1])dnl +m4_ifndef([AC_AUTOCONF_VERSION], + [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl +_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)]) + +# AM_AUX_DIR_EXPAND -*- Autoconf -*- + +# Copyright (C) 2001, 2003, 2005 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, 2000, 2001, 2003, 2004, 2005, 2006 +# 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. + +# serial 8 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +AC_DEFUN([AM_CONDITIONAL], +[AC_PREREQ(2.52)dnl + ifelse([$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 +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, 2000, 2001, 2002, 2003, 2004, 2005, 2006 +# 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. + +# serial 9 + +# 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", "GCJ", or "OBJC". +# 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 + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" 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'. + 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 + 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 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + 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 + ;; + none) break ;; + esac + # 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. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} 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 sub/conftest.${OBJEXT-o} 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, +[ --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +AC_SUBST([AMDEPBACKSLASH])dnl +_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl +]) + +# Generate code to set up dependency tracking. -*- Autoconf -*- + +# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 +# 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. + +#serial 3 + +# _AM_OUTPUT_DEPENDENCY_COMMANDS +# ------------------------------ +AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], +[for mf in $CONFIG_FILES; 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"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //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' -e 's/\$U/'"$U"'/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, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, +# 2005, 2006, 2008 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. + +# serial 13 + +# 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.60])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], +[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], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, + [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) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +AC_REQUIRE([AM_PROG_MKDIR_P])dnl +# 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)], + [define([AC_PROG_CC], + defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_CXX], + defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_OBJC], + [_AM_DEPENDENCIES(OBJC)], + [define([AC_PROG_OBJC], + defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl +]) +]) + + +# 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, 2003, 2005 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 +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# Copyright (C) 2003, 2005 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. + +# serial 2 + +# 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])]) + +# Check to see how 'make' treats includes. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 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. + +# serial 3 + +# 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 done +.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 +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +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, 1999, 2000, 2001, 2003, 2004, 2005 +# 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. + +# serial 5 + +# 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 supports --run. +# If it does, 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 +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + AC_MSG_WARN([`missing' script is too old or missing]) +fi +]) + +# Copyright (C) 2003, 2004, 2005, 2006 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_MKDIR_P +# --------------- +# Check for `mkdir -p'. +AC_DEFUN([AM_PROG_MKDIR_P], +[AC_PREREQ([2.60])dnl +AC_REQUIRE([AC_PROG_MKDIR_P])dnl +dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, +dnl while keeping a definition of mkdir_p for backward compatibility. +dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. +dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of +dnl Makefile.ins that do not define MKDIR_P, so we do our own +dnl adjustment using top_builddir (which is defined more often than +dnl MKDIR_P). +AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl +case $mkdir_p in + [[\\/$]]* | ?:[[\\/]]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac +]) + +# Helper functions for option handling. -*- Autoconf -*- + +# Copyright (C) 2001, 2002, 2003, 2005 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. + +# serial 3 + +# _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], +[AC_FOREACH([_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, 1997, 2000, 2001, 2003, 2005 +# 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. + +# serial 4 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# 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 ( + 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 + rm -f conftest.file + 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 + + 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)]) + +# Copyright (C) 2001, 2003, 2005 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 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]) + +# Check how to create a tarball. -*- Autoconf -*- + +# Copyright (C) 2004, 2005 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. + +# serial 2 + +# _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. +AM_MISSING_PROG([AMTAR], [tar]) +m4_if([$1], [v7], + [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], + [m4_case([$1], [ustar],, [pax],, + [m4_fatal([Unknown tar format])]) +AC_MSG_CHECKING([how to create a $1 tar archive]) +# Loop over all known methods to create a tar archive until one works. +_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' +_am_tools=${am_cv_prog_tar_$1-$_am_tools} +# Do not fold the above two line into one, because Tru64 sh and +# Solaris sh will not grok spaces in the rhs of `-'. +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 /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 + diff --git a/adapter.cpp b/adapter.cpp new file mode 100644 index 0000000..d51cc25 --- /dev/null +++ b/adapter.cpp @@ -0,0 +1,1534 @@ + +// adapter.cpp + +// includes + +#include +#include +#include +#include + +#ifndef _WIN32 +#include +#include // Mac OS X needs this one +#include +#endif + +#include "adapter.h" +#include "board.h" +#include "book.h" +#include "colour.h" +#include "engine.h" +#include "fen.h" +#include "game.h" +#include "gui.h" +#include "line.h" +#include "main.h" +#include "move.h" +#include "move_do.h" +#include "move_legal.h" +#include "option.h" +#include "parse.h" +#include "san.h" +#include "uci.h" +#include "util.h" +#include "posix.h" + + +// constants + +static const bool UseDebug = false; +static const bool DelayPong = false; + +static const int StringSize = 4096; + +// types + +struct state_t { + int state; + bool computer[ColourNb]; + int exp_move; + int resign_nb; + my_timer_t timer[1]; +}; + +struct xb_t { + bool has_feature_memory; + bool has_feature_smp; + bool has_feature_egt; + bool analyse; + bool computer; + const char * name; + bool ics; + bool new_hack; // "new" is a C++ keyword + bool ponder; + int ping; + bool post; + int proto_ver; + bool result; + + int mps; + double base; + double inc; + + bool time_limit; + double time_max; + + bool depth_limit; + int depth_max; + + double my_time; + double opp_time; +}; + +enum dummy_state_t { WAIT, THINK, PONDER, ANALYSE }; + +// variables + +static state_t State[1]; +static xb_t XB[1]; + +// prototypes + + +static void xboard_step (char string[]); +static void engine_step (char string[]); + +static void comp_move (int move); +static void move_step (int move); +static void board_update (); + +static void mess (); +static void no_mess (int move); + +static void search_update (); +static void search_clear (); +static void update_remaining_time(); +static void start_protected_command(); +static void end_protected_command(); + +static bool active (); +static bool ponder (); +static bool ponder_ok (int ponder_move); + +static void stop_search (); + +static void send_board (int extra_move); +static void send_pv (); + + +static void learn (int result); + +static void adapter_step (); + +// functions + +// adapter_loop() + +void adapter_loop() { + + // init + + game_clear(Game); + + // state + + State->state = WAIT; + + State->computer[White] = false; + State->computer[Black] = true; + + State->exp_move = MoveNone; + State->resign_nb = 0; + my_timer_reset(State->timer); + + // yes there are engines that do not have the "Hash" option.... + XB->has_feature_memory= uci_option_exist(Uci,"Hash"); + XB->has_feature_smp = uci_thread_option_exist(Uci); + // TODO: support for other types of table bases + XB->has_feature_egt = uci_option_exist(Uci,"NalimovPath"); + XB->analyse = false; + XB->computer = false; + XB->name = NULL; + my_string_set(&XB->name,""); + XB->ics = false; + XB->new_hack = true; + XB->ping = -1; + XB->ponder = false; + XB->post = false; + XB->proto_ver = 1; + XB->result = false; + + XB->mps = 0; + XB->base = 300.0; + XB->inc = 0.0; + + XB->time_limit = false; + XB->time_max = 5.0; + + XB->depth_limit = false; + XB->depth_max = 127; + + XB->my_time = 300.0; + XB->opp_time = 300.0; + while (true) adapter_step(); +} + +// adapter_step() + +#ifdef _WIN32 +static void adapter_step(){ // polling! + bool xin,ein; + char string[StringSize]; + if(option_get_bool("UCI")){ + xin=gui_get_non_blocking(GUI,string,StringSize); + if(xin) uci_gui_step(string); + ein=engine_get_non_blocking(Engine,string,StringSize); + if(ein) uci_engine_step(string); + }else{ + xin=gui_get_non_blocking(GUI,string,StringSize); + if(xin) xboard_step(string); + ein=engine_get_non_blocking(Engine,string,StringSize); + if(ein) engine_step(string); + } + if(xin==false && ein==false) Idle();//nobody wants me,lets have a beauty nap +} +#else +static void adapter_step() { + + fd_set set[1]; + int fd_max; + int val; + char string[StringSize]; + + // process buffered lines + + while (io_line_ready(GUI->io)){ + gui_get(GUI,string,StringSize); + if(option_get_bool("UCI")){ + uci_gui_step(string); + }else{ + xboard_step(string); // process available xboard lines + } + } + while (io_line_ready(Engine->io)){ + engine_get(Engine,string,StringSize); + if(option_get_bool("UCI")){ + uci_engine_step(string); // process available engine lines + }else{ + engine_step(string); + } + } + + // init + + FD_ZERO(set); + fd_max = -1; // HACK + + // add xboard input + + ASSERT(GUI->io->in_fd>=0); + + FD_SET(GUI->io->in_fd,set); + if (GUI->io->in_fd > fd_max) fd_max = GUI->io->in_fd; + + // add engine input + + ASSERT(Engine->io->in_fd>=0); + + FD_SET(Engine->io->in_fd,set); + if (Engine->io->in_fd > fd_max) fd_max = Engine->io->in_fd; + + // wait for something to read (no timeout) + + ASSERT(fd_max>=0); + + val = select(fd_max+1,set,NULL,NULL,NULL); + if (val == -1 && errno != EINTR) my_fatal("adapter_step(): select(): %s\n",strerror(errno)); + + if (val > 0) { + if (FD_ISSET(GUI->io->in_fd,set)) io_get_update(GUI->io); // read some xboard input + if (FD_ISSET(Engine->io->in_fd,set)) io_get_update(Engine->io); // read some engine input + } +} +#endif + +static void xboard_step(char string[]) { + + int move; + char move_string[256]; + board_t board[1]; + static bool firsttime=true; + + if(firsttime){ + if((match(string,"uci"))){ + my_log("POLYGLOT *** Switching to UCI mode ***\n"); + send_uci_options(); + option_set("UCI","true"); + return; + }else{ + if(!book_is_open() && option_get_bool("Book")){ + // restore old behaviour in xboard mode + // missing book is fatal + my_fatal("xboard_step(): can't open file \"%s\": %s\n", + option_get_string("BookFile"),strerror(errno)); + } + //uci_send_isready(Uci); // In UCI mode this done by the GUI + //Grrr...Toga can fixes the number of threads after "isready" + //So we delay "isready" + } + firsttime=false; + } + if (false) { + + } else if (match(string,"accepted *")) { + + // ignore + + } else if (match(string,"analyze")) { + + State->computer[White] = false; + State->computer[Black] = false; + + XB->analyse = true; + XB->new_hack = false; + ASSERT(!XB->result); + XB->result = false; + + mess(); + + } else if (match(string,"bk")) { + + if (option_get_bool("Book")) { + game_get_board(Game,board); + book_disp(board); + } + + } else if (match(string,"black")) { + + if (colour_is_black(game_turn(Game))) { + + State->computer[White] = true; + State->computer[Black] = false; + + XB->new_hack = true; + XB->result = false; + + mess(); + } + + } else if (match(string,"computer")) { + + XB->computer = true; + + } else if (match(string,"draw")) { + if(uci_option_exist(Uci,"UCI_DrawOffers")){ + my_log("POLYGLOT draw from XB received"); + uci_send_option(Uci,"DrawOffer","%s","draw");} + } else if (match(string,"easy")) { + + XB->ponder = false; + + mess(); + + } else if (match(string,"edit")) { + + // refuse + + gui_send(GUI,"Error (unknown command): %s",string); + + } else if (match(string,"exit")) { + + State->computer[White] = false; + State->computer[Black] = false; + + XB->analyse = false; + + mess(); + + } else if (match(string,"force")) { + + State->computer[White] = false; + State->computer[Black] = false; + + mess(); + + } else if (match(string,"go")) { + + State->computer[game_turn(Game)] = true; + State->computer[colour_opp(game_turn(Game))] = false; + + XB->new_hack = false; + ASSERT(!XB->result); + XB->result = false; + + mess(); + + } else if (match(string,"hard")) { + + XB->ponder = true; + + mess(); + + } else if (match(string,"hint")) { + + if (option_get_bool("Book")) { + + game_get_board(Game,board); + move = book_move(board,false); + + if (move != MoveNone && move_is_legal(move,board)) { + move_to_san(move,board,move_string,256); + gui_send(GUI,"Hint: %s",move_string); + } + } + + } else if (match(string,"ics *")) { + + XB->ics = true; + + } else if (match(string,"level * *:* *")) { + + XB->mps = atoi(Star[0]); + XB->base = double(atoi(Star[1])) * 60.0 + double(atoi(Star[2])); + XB->inc = double(atoi(Star[3])); + + } else if (match(string,"level * * *")) { + + XB->mps = atoi(Star[0]); + XB->base = double(atoi(Star[1])) * 60.0; + XB->inc = double(atoi(Star[2])); + + } else if (match(string,"name *")) { + + my_string_set(&XB->name,Star[0]); + + } else if (match(string,"new")) { + + uci_send_isready(Uci); + my_log("POLYGLOT NEW GAME\n"); + + option_set("Chess960","false"); + + game_clear(Game); + + if (XB->analyse) { + State->computer[White] = false; + State->computer[Black] = false; + } else { + State->computer[White] = false; + State->computer[Black] = true; + } + + XB->new_hack = true; + XB->result = false; + + XB->depth_limit = false; + + XB->computer = false; + my_string_set(&XB->name,""); + + board_update(); + mess(); + + uci_send_ucinewgame(Uci); + + } else if (match(string,"nopost")) { + + XB->post = false; + + } else if (match(string,"otim *")) { + + XB->opp_time = double(atoi(Star[0])) / 100.0; + if (XB->opp_time < 0.0) XB->opp_time = 0.0; + + } else if (match(string,"pause")) { + + // refuse + + gui_send(GUI,"Error (unknown command): %s",string); + + } else if (match(string,"ping *")) { + + // HACK; TODO: answer only after an engine move + + if (DelayPong) { + if (XB->ping >= 0) gui_send(GUI,"pong %d",XB->ping); // HACK: get rid of old ping + XB->ping = atoi(Star[0]); + uci_send_isready(Uci); + } else { + ASSERT(XB->ping==-1); + gui_send(GUI,"pong %s",Star[0]); + } + + } else if (match(string,"playother")) { + + State->computer[game_turn(Game)] = false; + State->computer[colour_opp(game_turn(Game))] = true; + + XB->new_hack = false; + ASSERT(!XB->result); + XB->result = false; + + mess(); + + } else if (match(string,"post")) { + + XB->post = true; + + } else if (match(string,"protover *")) { + + XB->proto_ver = atoi(Star[0]); + ASSERT(XB->proto_ver>=2); + + gui_send(GUI,"feature done=0"); + + gui_send(GUI,"feature analyze=1"); + gui_send(GUI,"feature colors=0"); + gui_send(GUI,"feature draw=1"); + gui_send(GUI,"feature ics=1"); + gui_send(GUI,"feature myname=\"%s\"",option_get_string("EngineName")); + gui_send(GUI,"feature name=1"); + gui_send(GUI,"feature pause=0"); + gui_send(GUI,"feature ping=1"); + gui_send(GUI,"feature playother=1"); + gui_send(GUI,"feature reuse=1"); + gui_send(GUI,"feature san=0"); + gui_send(GUI,"feature setboard=1"); + gui_send(GUI,"feature sigint=0"); + gui_send(GUI,"feature sigterm=0"); + gui_send(GUI,"feature time=1"); + gui_send(GUI,"feature usermove=1"); + if (XB->has_feature_memory){ + gui_send(GUI,"feature memory=1"); + } + if (XB->has_feature_smp){ + gui_send(GUI,"feature smp=1"); + } + if (XB->has_feature_egt){ + // TODO: support for other types of table bases + gui_send(GUI,"feature egt=\"nalimov\""); + } + + if (uci_option_exist(Uci,"UCI_Chess960")) { + gui_send(GUI,"feature variants=\"normal,fischerandom\""); + } else { + gui_send(GUI,"feature variants=\"normal\""); + } + gui_send(GUI,"feature done=1"); // moved from engine_step + + + //if (Uci->ready) xboard_send(XBoard,"feature done=1"); + + // otherwise "feature done=1" will be sent when the engine is ready + + } else if (match(string,"quit")) { + my_log("POLYGLOT *** \"quit\" from GUI ***\n"); + quit(); + } else if (match(string,"random")) { + + // ignore + + } else if (match(string,"rating * *")) { + + // ignore + + } else if (match(string,"remove")) { + + if (game_pos(Game) >= 2) { + + game_goto(Game,game_pos(Game)-2); + + ASSERT(!XB->new_hack); + XB->new_hack = false; // HACK? + XB->result = false; + + board_update(); + mess(); + } + + } else if (match(string,"rejected *")) { + + // ignore + + } else if (match(string,"reset")) { // protover 3? + + // refuse + + gui_send(GUI,"Error (unknown command): %s",string); + + } else if (false + || match(string,"result * {*}") + || match(string,"result * {* }") + || match(string,"result * { *}") + || match(string,"result * { * }")) { + + my_log("POLYGLOT GAME END\n"); + + XB->result = true; + + mess(); + + // book learning + + if (option_get_bool("Book") && option_get_bool("BookLearn")) { + + if (false) { + } else if (my_string_equal(Star[0],"1-0")) { + learn(+1); + } else if (my_string_equal(Star[0],"0-1")) { + learn(-1); + } else if (my_string_equal(Star[0],"1/2-1/2")) { + learn(0); + } + } + } else if (match(string,"resume")) { + + // refuse + + gui_send(GUI,"Error (unknown command): %s",string); + + } else if (XB->has_feature_smp && match(string,"cores *")){ + int cores=atoi(Star[0]); + if(cores>=1){ + // updating the number of cores + my_log("POLYGLOT setting the number of cores to %d\n",cores); + start_protected_command(); + uci_set_threads(Uci,cores); + end_protected_command(); + } else{ + // refuse + gui_send(GUI,"Error (unknown command): %s",string); + } + } else if (XB->has_feature_egt && match(string,"egtpath * *")){ + char *type=Star[0]; + char *path=Star[1]; + if(!my_string_case_equal(Star[0],"nalimov")){ + // refuse + gui_send(GUI,"Error (unsupported table base format): %s",string); + }else if(my_string_empty(path)){ + // refuse + gui_send(GUI,"Error (unknown command): %s",string); + }else{ + // updating NalimovPath + my_log("POLYGLOT setting the Nalimov path to %s\n",path); + start_protected_command(); + uci_send_option(Uci,"NalimovPath","%s",path); + end_protected_command(); + } + } else if (XB->has_feature_memory && match(string,"memory *")){ + int memory = atoi(Star[0]); + int nalimov_cache; + int real_memory; + if(memory>=1){ + // updating the available memory + my_log("POLYGLOT setting the amount of memory to %dMb\n",memory); + if(uci_get_option(Uci,"NalimovCache")>=0){ + nalimov_cache=atoi(Uci->option[uci_get_option(Uci,"NalimovCache")].value); + }else{ + nalimov_cache=0; + } + my_log("POLYGLOT Nalimov Cache is %dMb\n",nalimov_cache); + real_memory=memory-nalimov_cache; + if(real_memory>0){ + start_protected_command(); + uci_send_option(Uci,"Hash", "%d", real_memory); + end_protected_command(); + } + }else{ + // refuse + gui_send(GUI,"Error (unknown command): %s",string); + } + + } else if (match(string,"sd *")) { + + XB->depth_limit = true; + XB->depth_max = atoi(Star[0]); + + } else if (match(string,"setboard *")) { + + my_log("POLYGLOT FEN %s\n",Star[0]); + + if (!game_init(Game,Star[0])) my_fatal("xboard_step(): bad FEN \"%s\"\n",Star[0]); + + State->computer[White] = false; + State->computer[Black] = false; + + XB->new_hack = true; // HACK? + XB->result = false; + + board_update(); + mess(); + + } else if (match(string,"st *")) { + + XB->time_limit = true; + XB->time_max = double(atoi(Star[0])); + + } else if (match(string,"time *")) { + + XB->my_time = double(atoi(Star[0])) / 100.0; + if (XB->my_time < 0.0) XB->my_time = 0.0; + + } else if (match(string,"undo")) { + + if (game_pos(Game) >= 1) { + + game_goto(Game,game_pos(Game)-1); + + ASSERT(!XB->new_hack); + XB->new_hack = false; // HACK? + XB->result = false; + + board_update(); + mess(); + } + + } else if (match(string,"usermove *")) { + + game_get_board(Game,board); + move = move_from_san(Star[0],board); + + if (move != MoveNone && move_is_legal(move,board)) { + + XB->new_hack = false; + ASSERT(!XB->result); + XB->result = false; + + move_step(move); + no_mess(move); + + } else { + + gui_send(GUI,"Illegal move: %s",Star[0]); + } + + } else if (match(string,"variant *")) { + + if (my_string_equal(Star[0],"fischerandom")) { + option_set("Chess960","true"); + } else { + option_set("Chess960","false"); + } + + } else if (match(string,"white")) { + + if (colour_is_white(game_turn(Game))) { + + State->computer[White] = false; + State->computer[Black] = true; + + XB->new_hack = true; + XB->result = false; + + mess(); + } + + } else if (match(string,"xboard")) { + + // ignore + + } else if (match(string,".")) { // analyse info + + if (State->state == ANALYSE) { + int depth=Uci->best_depth;//HACK: don't clear engine-output window... + + ASSERT(Uci->searching); + ASSERT(Uci->pending_nb>=1); + + if (Uci->root_move != MoveNone && move_is_legal(Uci->root_move,Uci->board)) { + move_to_san(Uci->root_move,Uci->board,move_string,256); + gui_send(GUI,"stat01: %.0f "S64_FORMAT" %d %d %d %s",Uci->time*100.0,Uci->node_nb,/*Uci->*/depth,Uci->root_move_nb-(Uci->root_move_pos+1),Uci->root_move_nb,move_string); + } else { + gui_send(GUI,"stat01: %.0f "S64_FORMAT" %d %d %d",Uci->time*100.0,Uci->node_nb,/*Uci->*/depth,0,0); // HACK + } + } + + } else if (match(string,"?")) { // move now + + if (State->state == THINK) { + + ASSERT(Uci->searching); + ASSERT(Uci->pending_nb>=1); + + // HACK: just send "stop" to the engine + + if (Uci->searching) { + my_log("POLYGLOT STOP SEARCH\n"); + engine_send(Engine,"stop"); + } + } + + } else { // unknown command, maybe a move? + + game_get_board(Game,board); + move = move_from_san(string,board); + + if (move != MoveNone && move_is_legal(move,board)) { + + XB->new_hack = false; + ASSERT(!XB->result); + XB->result = false; + + move_step(move); + no_mess(move); + + } else if (move != MoveNone) { + + gui_send(GUI,"Illegal move: %s",string); + + } else { + + gui_send(GUI,"Error (unknown command): %s",string); + } + } + return; +} + +// engine_step() + +static void engine_step(char string[]) { + + int event; + event = uci_parse(Uci,string); + + // react to events + + if ((event & EVENT_READY) != 0) { + + // the engine is now ready + + if (!Uci->ready) { + Uci->ready = true; + // if (XB->proto_ver >= 2) xboard_send(XBoard,"feature done=1"); + } + + if (!DelayPong && XB->ping >= 0) { + gui_send(GUI,"pong %d",XB->ping); + XB->ping = -1; + } + } + + if ((event & EVENT_MOVE) != 0 && State->state == THINK) { + + // the engine is playing a move + + // MEGA HACK: estimate remaining time because XBoard won't send it! + + my_timer_stop(State->timer); + + XB->my_time -= my_timer_elapsed_real(State->timer); + XB->my_time += XB->inc; + if (XB->mps != 0 && (game_move_nb(Game) + 1) % XB->mps == 0) XB->my_time += XB->base; + + if (XB->my_time < 0.0) XB->my_time = 0.0; + + // play the engine move + + comp_move(Uci->best_move); + } + + if ((event & EVENT_PV) != 0) { + + // the engine has sent a new PV + + send_pv(); + } + if((event & (EVENT_DRAW|EVENT_RESIGN))!=0){ + my_log("POYGLOT draw offer/resign from engine\n"); + if(uci_option_exist(Uci,"UCI_DrawOffers")){ + if(event & EVENT_DRAW) + gui_send(GUI,"offer draw"); + else + gui_send(GUI,"resign"); + } + } +} + +// comp_move() + +static void comp_move(int move) { + + board_t board[1]; + char string[256]; + + ASSERT(move_is_ok(move)); + + ASSERT(State->state==THINK); + ASSERT(!XB->analyse); + + if(option_get_bool("RepeatPV")==true) + send_pv(); // to update time and nodes + + // send the move + + game_get_board(Game,board); + + if (move_is_castle(move,board) && option_get_bool("Chess960")) { + if (!move_to_san(move,board,string,256)) my_fatal("comp_move(): move_to_san() failed\n"); // O-O/O-O-O + } else { + if (!move_to_can(move,board,string,256)) my_fatal("comp_move(): move_to_can() failed\n"); + } + + gui_send(GUI,"move %s",string); + + // resign? + + if (option_get_bool("Resign") && Uci->root_move_nb > 1) { + + if (Uci->best_score <= -abs(option_get_int("ResignScore"))) { + + State->resign_nb++; + my_log("POLYGLOT %d move%s with resign score\n",State->resign_nb,(State->resign_nb>1)?"s":""); + + if (State->resign_nb >= option_get_int("ResignMoves")) { + my_log("POLYGLOT *** RESIGN ***\n"); + gui_send(GUI,"resign"); + } + + } else { + + if (State->resign_nb > 0) my_log("POLYGLOT resign reset (State->resign_nb=%d)\n",State->resign_nb); + State->resign_nb = 0; + } + } + + // play the move + + move_step(move); + no_mess(move); +} + +// move_step() + +static void move_step(int move) { + + board_t board[1]; + char move_string[256]; + + ASSERT(move_is_ok(move)); + + // log + + game_get_board(Game,board); + + if (move != MoveNone && move_is_legal(move,board)) { + + move_to_san(move,board,move_string,256); + my_log("POLYGLOT MOVE %s\n",move_string); + + } else { + + move_to_can(move,board,move_string,256); + my_log("POLYGLOT ILLEGAL MOVE \"%s\"\n",move_string); + board_disp(board); + + my_fatal("move_step(): illegal move \"%s\"\n",move_string); + } + + // play the move + + game_add_move(Game,move); + board_update(); +} + +// board_update() + +static void board_update() { + + // handle game end + + ASSERT(!XB->result); + + switch (game_status(Game)) { + case PLAYING: + break; + case WHITE_MATES: + gui_send(GUI,"1-0 {White mates}"); + break; + case BLACK_MATES: + gui_send(GUI,"0-1 {Black mates}"); + break; + case STALEMATE: + gui_send(GUI,"1/2-1/2 {Stalemate}"); + break; + case DRAW_MATERIAL: + gui_send(GUI,"1/2-1/2 {Draw by insufficient material}"); + break; + case DRAW_FIFTY: + gui_send(GUI,"1/2-1/2 {Draw by fifty-move rule}"); + break; + case DRAW_REPETITION: + gui_send(GUI,"1/2-1/2 {Draw by repetition}"); + break; + default: + ASSERT(false); + break; + } +} + +// mess() + +static void mess() { + + // clear state variables + + State->resign_nb = 0; + State->exp_move = MoveNone; + my_timer_reset(State->timer); + + // abort a possible search + + stop_search(); + + // calculate the new state + + if (false) { + } else if (!active()) { + State->state = WAIT; + my_log("POLYGLOT WAIT\n"); + } else if (XB->analyse) { + State->state = ANALYSE; + my_log("POLYGLOT ANALYSE\n"); + } else if (State->computer[game_turn(Game)]) { + State->state = THINK; + my_log("POLYGLOT THINK\n"); + } else { + State->state = WAIT; + my_log("POLYGLOT WAIT\n"); + } + + search_update(); +} + +// no_mess() + +static void no_mess(int move) { + + ASSERT(move_is_ok(move)); + + // just received a move, calculate the new state + + if (false) { + + } else if (!active()) { + + stop_search(); // abort a possible search + + State->state = WAIT; + State->exp_move = MoveNone; + + my_log("POLYGLOT WAIT\n"); + + } else if (State->state == WAIT) { + + ASSERT(State->computer[game_turn(Game)]); + ASSERT(!State->computer[colour_opp(game_turn(Game))]); + ASSERT(!XB->analyse); + + my_log("POLYGLOT WAIT -> THINK\n"); + + State->state = THINK; + State->exp_move = MoveNone; + + } else if (State->state == THINK) { + + ASSERT(!State->computer[game_turn(Game)]); + ASSERT(State->computer[colour_opp(game_turn(Game))]); + ASSERT(!XB->analyse); + + if (ponder() && ponder_ok(Uci->ponder_move)) { + + my_log("POLYGLOT THINK -> PONDER\n"); + + State->state = PONDER; + State->exp_move = Uci->ponder_move; + + } else { + + my_log("POLYGLOT THINK -> WAIT\n"); + + State->state = WAIT; + State->exp_move = MoveNone; + } + + } else if (State->state == PONDER) { + + ASSERT(State->computer[game_turn(Game)]); + ASSERT(!State->computer[colour_opp(game_turn(Game))]); + ASSERT(!XB->analyse); + + if (move == State->exp_move && Uci->searching) { + + ASSERT(Uci->searching); + ASSERT(Uci->pending_nb>=1); + + my_timer_start(State->timer);//also resets + + my_log("POLYGLOT PONDER -> THINK (*** HIT ***)\n"); + engine_send(Engine,"ponderhit"); + + State->state = THINK; + State->exp_move = MoveNone; + + send_pv(); // update display + + return; // do not launch a new search + + } else { + + my_log("POLYGLOT PONDER -> THINK (miss)\n"); + + stop_search(); + + State->state = THINK; + State->exp_move = MoveNone; + } + + } else if (State->state == ANALYSE) { + + ASSERT(XB->analyse); + + my_log("POLYGLOT ANALYSE -> ANALYSE\n"); + + stop_search(); + + } else { + + ASSERT(false); + } + + search_update(); +} + +// start_protected_command() + +static void start_protected_command(){ + stop_search(); +} + +static void end_protected_command(){ + if(Uci->ready){ // not init faze + uci_send_isready_sync(Uci); // gobble up spurious "bestmove" + } + update_remaining_time(); + search_update(); // relaunch search if necessary +} + +// update_remaining_time() + +static void update_remaining_time(){ + double reduce; + if(State->timer->running){ + my_timer_stop(State->timer); + reduce = my_timer_elapsed_real(State->timer); + my_log("POLYGLOT reducing remaing time by %f seconds\n",reduce); + XB->my_time -= reduce; + if(XB->my_time<0.0){ + XB->my_time=0.0; + } + } +} + + +// search_update() + +static void search_update() { + + int move; + int move_nb; + board_t board[1]; + int nalimov_cache; + int real_memory; + + ASSERT(!Uci->searching); + + + + + // launch a new search if needed + + + + if (State->state == THINK || State->state == PONDER || State->state == ANALYSE) { + + // opening book + + if (State->state == THINK && option_get_bool("Book")) { + + game_get_board(Game,Uci->board); + + move = book_move(Uci->board,option_get_bool("BookRandom")); + + if (move != MoveNone && move_is_legal(move,Uci->board)) { + + my_log("POLYGLOT *BOOK MOVE*\n"); + + search_clear(); // clears Uci->ponder_move + Uci->best_move = move; + + board_copy(board,Uci->board); + move_do(board,move); + Uci->ponder_move = book_move(board,false); // expected move = best book move + + Uci->best_pv[0] = Uci->best_move; + Uci->best_pv[1] = Uci->ponder_move; // can be MoveNone + Uci->best_pv[2] = MoveNone; + + comp_move(Uci->best_move); + + return; + } + } + + // engine search + + my_log("POLYGLOT START SEARCH\n"); + + // options + + uci_send_option(Uci,"UCI_Chess960","%s",option_get_bool("Chess960")?"true":"false"); + + if (option_get_int("UCIVersion") >= 2) { + uci_send_option(Uci,"UCI_Opponent","none none %s %s",(XB->computer)?"computer":"human",XB->name); + uci_send_option(Uci,"UCI_AnalyseMode","%s",(XB->analyse)?"true":"false"); + } + + uci_send_option(Uci,"Ponder","%s",ponder()?"true":"false"); + + // position + + move = (State->state == PONDER) ? State->exp_move : MoveNone; + send_board(move); // updates Uci->board global variable + + // search + + if (State->state == THINK || State->state == PONDER) { + + engine_send_queue(Engine,"go"); + + if (XB->time_limit) { + + // fixed time per move + + engine_send_queue(Engine," movetime %.0f",XB->time_max*1000.0); + + } else { + + // time controls + + if (colour_is_white(Uci->board->turn)) { + engine_send_queue(Engine," wtime %.0f btime %.0f",XB->my_time*1000.0,XB->opp_time*1000.0); + } else { + engine_send_queue(Engine," wtime %.0f btime %.0f",XB->opp_time*1000.0,XB->my_time*1000.0); + } + + if (XB->inc != 0.0) engine_send_queue(Engine," winc %.0f binc %.0f",XB->inc*1000.0,XB->inc*1000.0); + + if (XB->mps != 0) { + + move_nb = XB->mps - (Uci->board->move_nb % XB->mps); + ASSERT(move_nb>=1&&move_nb<=XB->mps); + + engine_send_queue(Engine," movestogo %d",move_nb); + } + } + + if (XB->depth_limit) engine_send_queue(Engine," depth %d",XB->depth_max); + + if (State->state == PONDER) engine_send_queue(Engine," ponder"); + + engine_send(Engine,""); // newline + + } else if (State->state == ANALYSE) { + + engine_send(Engine,"go infinite"); + + } else { + + ASSERT(false); + } + + // init search info + + ASSERT(!Uci->searching); + + search_clear(); + + Uci->searching = true; + Uci->pending_nb++; + } +} + +// search_clear() + +static void search_clear() { + + uci_clear(Uci); + + // TODO: MOVE ME + + my_timer_start(State->timer);//also resets +} + +// active() + +static bool active() { + + // position state + + if (game_status(Game) != PLAYING) return false; // game ended + + // xboard state + + if (XB->analyse) return true; // analysing + if (!State->computer[White] && !State->computer[Black]) return false; // force mode + if (XB->new_hack || XB->result) return false; // unstarted or ended game + + return true; // playing +} + +// ponder() + +static bool ponder() { + + return XB->ponder && (option_get_bool("CanPonder") || uci_option_exist(Uci,"Ponder")); +} +// ponder_ok() + +static bool ponder_ok(int move) { + int status; + board_t board[1]; + + ASSERT(move==MoveNone||move_is_ok(move)); + + // legal ponder move? + + if (move == MoveNone) return false; + + game_get_board(Game,board); + if (!move_is_legal(move,board)) return false; + + // UCI-legal resulting position? + + game_add_move(Game,move); + + game_get_board(Game,board); + status = game_status(Game); + + game_rem_move(Game); + + if (status != PLAYING) return false; // game ended + + if (option_get_bool("Book") && is_in_book(board)) { + return false; + } + + return true; +} + +// stop_search() + +static void stop_search() { + + if (Uci->searching) { + + ASSERT(Uci->searching); + ASSERT(Uci->pending_nb>=1); + + my_log("POLYGLOT STOP SEARCH\n"); + +/* + engine_send(Engine,"stop"); + Uci->searching = false; +*/ + + if (option_get_bool("SyncStop")) { + uci_send_stop_sync(Uci); + } else { + uci_send_stop(Uci); + } + } +} + +// send_board() + +static void send_board(int extra_move) { + + char fen[256]; + int start, end; + board_t board[1]; + int pos; + int move; + char string[256]; + + ASSERT(extra_move==MoveNone||move_is_ok(extra_move)); + + ASSERT(!Uci->searching); + + // init + + game_get_board(Game,Uci->board); + if (extra_move != MoveNone) move_do(Uci->board,extra_move); + + board_to_fen(Uci->board,fen,256); + my_log("POLYGLOT FEN %s\n",fen); + + ASSERT(board_can_play(Uci->board)); + + // more init + + start = 0; + end = game_pos(Game); + ASSERT(end>=start); + + // position + + game_get_board(Game,board,start); + board_to_fen(board,string,256); + + engine_send_queue(Engine,"position"); + + if (my_string_equal(string,StartFen)) { + engine_send_queue(Engine," startpos"); + } else { + engine_send_queue(Engine," fen %s",string); + } + + // move list + + if (end > start || extra_move != MoveNone) engine_send_queue(Engine," moves"); + + for (pos = start; pos < end; pos++) { // game moves + + move = game_move(Game,pos); + + move_to_can(move,board,string,256); + engine_send_queue(Engine," %s",string); + + move_do(board,move); + } + + if (extra_move != MoveNone) { // move to ponder on + move_to_can(extra_move,board,string,256); + engine_send_queue(Engine," %s",string); + } + + // end + + engine_send(Engine,""); // newline +} + +// send_pv() + +static void send_pv() { + + char pv_string[StringSize]; + board_t board[1]; + int move; + char move_string[StringSize]; + + ASSERT(State->state!=WAIT); + + if (Uci->best_depth == 0) return; + + // xboard search information + + if (XB->post) { + + if (State->state == THINK || State->state == ANALYSE) { + + line_to_san(Uci->best_pv,Uci->board,pv_string,StringSize); + + if(Uci->depth==-1) //hack to clear the engine output window + gui_send(GUI,"%d %+d %.0f "S64_FORMAT" ",0,Uci->best_score,Uci->time*100.0,Uci->node_nb); + + gui_send(GUI,"%d %+d %.0f "S64_FORMAT" %s",Uci->best_depth,Uci->best_score,Uci->time*100.0,Uci->node_nb,pv_string); + + } else if (State->state == PONDER && option_get_bool("ShowPonder")) { + + game_get_board(Game,board); + move = State->exp_move; + + if (move != MoveNone && move_is_legal(move,board)) { + move_to_san(move,board,move_string,256); + line_to_san(Uci->best_pv,Uci->board,pv_string,StringSize); + gui_send(GUI,"%d %+d %.0f "S64_FORMAT" (%s) %s",Uci->best_depth,Uci->best_score,Uci->time*100.0,Uci->node_nb,move_string,pv_string); + } + } + } + + // kibitz + + if ((Uci->searching && option_get_bool("KibitzPV") && Uci->time >= option_get_double("KibitzDelay")) + || (!Uci->searching && option_get_bool("KibitzMove"))) { + + if (State->state == THINK || State->state == ANALYSE) { + + line_to_san(Uci->best_pv,Uci->board,pv_string,StringSize); + gui_send(GUI,"%s depth=%d time=%.2f node="S64_FORMAT" speed=%.0f score=%+.2f pv=\"%s\"",option_get_string("KibitzCommand"),Uci->best_depth,Uci->time,Uci->node_nb,Uci->speed,double(Uci->best_score)/100.0,pv_string); + + } else if (State->state == PONDER) { + + game_get_board(Game,board); + move = State->exp_move; + + if (move != MoveNone && move_is_legal(move,board)) { + move_to_san(move,board,move_string,256); + line_to_san(Uci->best_pv,Uci->board,pv_string,StringSize); + gui_send(GUI,"%s depth=%d time=%.2f node="S64_FORMAT" speed=%.0f score=%+.2f pv=\"(%s) %s\"",option_get_string("KibitzCommand"),Uci->best_depth,Uci->time,Uci->node_nb,Uci->speed,double(Uci->best_score)/100.0,move_string,pv_string); + } + } + } +} + +// learn() + +static void learn(int result) { + + int pos; + board_t board[1]; + int move; + + ASSERT(result>=-1&&result<=+1); + + ASSERT(XB->result); + ASSERT(State->computer[White]||State->computer[Black]); + + // init + + pos = 0; + + if (false) { + } else if (State->computer[White]) { + pos = 0; + } else if (State->computer[Black]) { + pos = 1; + result = -result; + } else { + my_fatal("learn(): unknown side\n"); + } + + if (false) { + } else if (result > 0) { + my_log("POLYGLOT *LEARN WIN*\n"); + } else if (result < 0) { + my_log("POLYGLOT *LEARN LOSS*\n"); + } else { + my_log("POLYGLOT *LEARN DRAW*\n"); + } + + // loop + + for (; pos < Game->size; pos += 2) { + + game_get_board(Game,board,pos); + move = game_move(Game,pos); + + book_learn_move(board,move,result); + } + + book_flush(); +} + +// end of adapter.cpp diff --git a/adapter.h b/adapter.h new file mode 100644 index 0000000..4f6e85b --- /dev/null +++ b/adapter.h @@ -0,0 +1,26 @@ + +// adapter.h + +#ifndef ADAPTER_H +#define ADAPTER_H + +// includes + +#include "util.h" +#include "uci2uci.h" + +// types + + + + + +// functions + +extern void adapter_loop (); + + +#endif // !defined ADAPTER_H + +// end of adapter.h + diff --git a/attack.cpp b/attack.cpp new file mode 100644 index 0000000..b1ce1f5 --- /dev/null +++ b/attack.cpp @@ -0,0 +1,224 @@ + +// attack.cpp + +// includes + +#include "board.h" +#include "colour.h" +#include "move.h" +#include "attack.h" +#include "piece.h" +#include "util.h" + +// macros + +#define DELTA_INC(delta) (DeltaInc[128+(delta)]) +#define DELTA_MASK(delta) (DeltaMask[128+(delta)]) + +// "constants" + +const sint8 KnightInc[8+1] = { + -33, -31, -18, -14, +14, +18, +31, +33, 0 +}; + +const sint8 BishopInc[4+1] = { + -17, -15, +15, +17, 0 +}; + +const sint8 RookInc[4+1] = { + -16, -1, +1, +16, 0 +}; + +const sint8 QueenInc[8+1] = { + -17, -16, -15, -1, +1, +15, +16, +17, 0 +}; + +const sint8 KingInc[8+1] = { + -17, -16, -15, -1, +1, +15, +16, +17, 0 +}; + +// variables + +static sint8 DeltaInc[256]; +static uint8 DeltaMask[256]; + +// prototypes + +static bool delta_is_ok (int delta); +static bool inc_is_ok (int inc); + +// functions + +// attack_init() + +void attack_init() { + + int delta; + int dir, inc, dist; + + for (delta = -128; delta < +128; delta++) { + DeltaInc[128+delta] = IncNone; + DeltaMask[128+delta] = 0; + } + + DeltaMask[128-17] |= BlackPawnFlag; + DeltaMask[128-15] |= BlackPawnFlag; + + DeltaMask[128+15] |= WhitePawnFlag; + DeltaMask[128+17] |= WhitePawnFlag; + + for (dir = 0; dir < 8; dir++) { + delta = KnightInc[dir]; + ASSERT(delta_is_ok(delta)); + DeltaMask[128+delta] |= KnightFlag; + } + + for (dir = 0; dir < 4; dir++) { + inc = BishopInc[dir]; + ASSERT(inc!=IncNone); + for (dist = 1; dist < 8; dist++) { + delta = inc*dist; + ASSERT(delta_is_ok(delta)); + ASSERT(DeltaInc[128+delta]==IncNone); + DeltaInc[128+delta] = inc; + DeltaMask[128+delta] |= BishopFlag; + } + } + + for (dir = 0; dir < 4; dir++) { + inc = RookInc[dir]; + ASSERT(inc!=IncNone); + for (dist = 1; dist < 8; dist++) { + delta = inc*dist; + ASSERT(delta_is_ok(delta)); + ASSERT(DeltaInc[128+delta]==IncNone); + DeltaInc[128+delta] = inc; + DeltaMask[128+delta] |= RookFlag; + } + } + + for (dir = 0; dir < 8; dir++) { + delta = KingInc[dir]; + ASSERT(delta_is_ok(delta)); + DeltaMask[128+delta] |= KingFlag; + } +} + +// delta_is_ok() + +static bool delta_is_ok(int delta) { + + if (delta < -119 || delta > +119) return false; + + return true; +} + +// inc_is_ok() + +static bool inc_is_ok(int inc) { + + int dir; + + for (dir = 0; dir < 8; dir++) { + if (KingInc[dir] == inc) return true; + } + + return false; +} + +// is_in_check() + +bool is_in_check(const board_t * board, int colour) { + + ASSERT(board_is_ok(board)); + ASSERT(colour_is_ok(colour)); + + return is_attacked(board,king_pos(board,colour),colour_opp(colour)); +} + +// is_attacked() + +bool is_attacked(const board_t * board, int to, int colour) { + + const uint8 * ptr; + int from, piece; + + ASSERT(board_is_ok(board)); + ASSERT(square_is_ok(to)); + ASSERT(colour_is_ok(colour)); + + for (ptr = board->list[colour]; (from=*ptr) != SquareNone; ptr++) { + + piece = board->square[from]; + ASSERT(colour_equal(piece,colour)); + + if (piece_attack(board,piece,from,to)) return true; + } + + return false; +} + +// piece_attack() + +bool piece_attack(const board_t * board, int piece, int from, int to) { + + int delta; + int inc, sq; + + ASSERT(board_is_ok(board)); + ASSERT(piece_is_ok(piece)); + ASSERT(square_is_ok(from)); + ASSERT(square_is_ok(to)); + + delta = to - from; + ASSERT(delta_is_ok(delta)); + + if ((piece & DELTA_MASK(delta)) == 0) return false; // no pseudo-attack + + if (!piece_is_slider(piece)) return true; + + inc = DELTA_INC(delta); + ASSERT(inc_is_ok(inc)); + + for (sq = from+inc; sq != to; sq += inc) { + ASSERT(square_is_ok(sq)); + if (board->square[sq] != Empty) return false; // blocker + } + + return true; +} + +// is_pinned() + +bool is_pinned(const board_t * board, int from, int to, int colour) { + + int king; + int inc; + int sq, piece; + + ASSERT(board!=NULL); + ASSERT(square_is_ok(from)); + ASSERT(square_is_ok(to)); + ASSERT(colour_is_ok(colour)); + + king = king_pos(board,colour); + + inc = DELTA_INC(king-from); + if (inc == IncNone) return false; // not a line + + sq = from; + do sq += inc; while (board->square[sq] == Empty); + + if (sq != king) return false; // blocker + + sq = from; + do sq -= inc; while ((piece=board->square[sq]) == Empty); + + return square_is_ok(sq) + && (piece & DELTA_MASK(king-sq)) != 0 + && piece_colour(piece) == colour_opp(colour) + && DELTA_INC(king-to) != inc; +} + +// end of attack.cpp + diff --git a/attack.h b/attack.h new file mode 100644 index 0000000..7e664a6 --- /dev/null +++ b/attack.h @@ -0,0 +1,37 @@ + +// attack.h + +#ifndef ATTACK_H +#define ATTACK_H + +// includes + +#include "board.h" +#include "util.h" + +// constants + +const int IncNone = 0; + +// "constants" + +extern const sint8 KnightInc[8+1]; +extern const sint8 BishopInc[4+1]; +extern const sint8 RookInc[4+1]; +extern const sint8 QueenInc[8+1]; +extern const sint8 KingInc[8+1]; + +// functions + +extern void attack_init (); + +extern bool is_in_check (const board_t * board, int colour); +extern bool is_attacked (const board_t * board, int to, int colour); +extern bool piece_attack (const board_t * board, int piece, int from, int to); + +extern bool is_pinned (const board_t * board, int from, int to, int colour); + +#endif // !defined ATTACK_H + +// end of attack.h + diff --git a/board.cpp b/board.cpp new file mode 100644 index 0000000..6e04900 --- /dev/null +++ b/board.cpp @@ -0,0 +1,492 @@ + +// board.cpp + +// includes + +#include + +#include "attack.h" +#include "board.h" +#include "colour.h" +#include "fen.h" +#include "hash.h" +#include "list.h" +#include "move.h" +#include "move_do.h" +#include "move_gen.h" +#include "move_legal.h" +#include "piece.h" +#include "util.h" + +// constants + +static const bool UseSlowDebug = false; + +// functions + +// board_is_ok() + +bool board_is_ok(const board_t * board) { + + int sq, piece; + int colour, pos; + int king, rook; + + if (board == NULL) return false; + + // optional heavy DEBUG mode + + if (!UseSlowDebug) return true; + + // squares + + for (sq = 0; sq < SquareNb; sq++) { + piece = board->square[sq]; + if (square_is_ok(sq)) { + pos = board->pos[sq]; + if (piece == Empty) { + if (pos != -1) return false; + } else { + if (pos < 0) return false; + if (board->list[piece_colour(piece)][pos] != sq) return false; + } + } else { + if (piece != Knight64) return false; + } + } + + // white piece list + + colour = White; + pos = 0; + + if (board->list_size[colour] <= 0 || board->list_size[colour] > 16) return false; + + sq = board->list[colour][pos]; + if (sq == SquareNone) return false; + if (board->pos[sq] != pos) return false; + piece = board->square[sq]; + if (!colour_equal(piece,colour) || !piece_is_king(piece)) return false; + + for (pos++; pos < board->list_size[colour]; pos++) { + sq = board->list[colour][pos]; + if (sq == SquareNone) return false; + if (board->pos[sq] != pos) return false; + if (!colour_equal(board->square[sq],colour)) return false; + } + + sq = board->list[colour][pos]; + if (sq != SquareNone) return false; + + // black piece list + + colour = Black; + pos = 0; + + if (board->list_size[colour] <= 0 || board->list_size[colour] > 16) return false; + + sq = board->list[colour][pos]; + if (sq == SquareNone) return false; + if (board->pos[sq] != pos) return false; + piece = board->square[sq]; + if (!colour_equal(piece,colour) || !piece_is_king(piece)) return false; + + for (pos++; pos < board->list_size[colour]; pos++) { + sq = board->list[colour][pos]; + if (sq == SquareNone) return false; + if (board->pos[sq] != pos) return false; + if (!colour_equal(board->square[sq],colour)) return false; + } + + sq = board->list[colour][pos]; + if (sq != SquareNone) return false; + + // TODO: material + + if (board->number[WhiteKing12] != 1) return false; + if (board->number[BlackKing12] != 1) return false; + + if (!colour_is_ok(board->turn)) return false; + + // castling status + + if (board->castle[White][SideH] != SquareNone) { + + king = board->list[White][0]; + if (king < A1 || king > H1) return false; + if (board->square[king] != WhiteKing256) return false; + + rook = board->castle[White][SideH]; + if (rook < A1 || rook > H1) return false; + if (board->square[rook] != WhiteRook256) return false; + + if (rook <= king) return false; + } + + if (board->castle[White][SideA] != SquareNone) { + + king = board->list[White][0]; + if (king < A1 || king > H1) return false; + if (board->square[king] != WhiteKing256) return false; + + rook = board->castle[White][SideA]; + if (rook < A1 || rook > H1) return false; + if (board->square[rook] != WhiteRook256) return false; + + if (rook >= king) return false; + } + + if (board->castle[Black][SideH] != SquareNone) { + + king = board->list[Black][0]; + if (king < A8 || king > H8) return false; + if (board->square[king] != BlackKing256) return false; + + rook = board->castle[Black][SideH]; + if (rook < A8 || rook > H8) return false; + if (board->square[rook] != BlackRook256) return false; + + if (rook <= king) return false; + } + + if (board->castle[Black][SideA] != SquareNone) { + + king = board->list[Black][0]; + if (king < A8 || king > H8) return false; + if (board->square[king] != BlackKing256) return false; + + rook = board->castle[Black][SideA]; + if (rook < A8 || rook > H8) return false; + if (board->square[rook] != BlackRook256) return false; + + if (rook >= king) return false; + } + + return true; +} + +// board_clear() + +void board_clear(board_t * board) { + + int file, rank, sq; + int colour, pos; + int piece; + + ASSERT(board!=NULL); + + // edge squares + + for (sq = 0; sq < SquareNb; sq++) { + board->square[sq] = Knight64; // HACK: uncoloured knight + board->pos[sq] = -1; + } + + // empty squares + + for (rank = 0; rank < 8; rank++) { + for (file = 0; file < 8; file++) { + sq = square_make(file,rank); + board->square[sq] = Empty; + } + } + + // piece lists + + for (colour = 0; colour < 3; colour++) { + for (pos = 0; pos < 32; pos++) { // HACK + board->list[colour][pos] = SquareNone; + } + board->list_size[colour] = 0; + } + + // material + + for (piece = 0; piece < 12; piece++) { + board->number[piece] = 0; + } + + // rest + + board->turn = ColourNone; + board->castle[White][SideH] = SquareNone; + board->castle[White][SideA] = SquareNone; + board->castle[Black][SideH] = SquareNone; + board->castle[Black][SideA] = SquareNone; + board->ep_square = SquareNone; + + board->ply_nb = 0; + board->move_nb = 0; + + board->key = 0; +} + +// board_start() + +void board_start(board_t * board) { + + ASSERT(board!=NULL); + + if (!board_from_fen(board,StartFen)) ASSERT(false); +} + +// board_copy() + +void board_copy(board_t * dst, const board_t * src) { + + ASSERT(dst!=NULL); + ASSERT(board_is_ok(src)); + + *dst = *src; +} + +// board_equal() + +bool board_equal(const board_t * board_1, const board_t * board_2) { + + int sq_64, sq; + + ASSERT(board_is_ok(board_1)); + ASSERT(board_is_ok(board_2)); + + // fast comparison + + if (board_1->key != board_2->key) return false; + + // slow comparison + + for (sq_64 = 0; sq_64 < 64; sq_64++) { + sq = square_from_64(sq_64); + if (board_1->square[sq] != board_2->square[sq]) return false; + } + + if (board_1->turn != board_2->turn) return false; + if (board_1->castle[White][SideH] != board_2->castle[White][SideH]) return false; + if (board_1->castle[White][SideA] != board_2->castle[White][SideA]) return false; + if (board_1->castle[Black][SideH] != board_2->castle[Black][SideH]) return false; + if (board_1->castle[Black][SideA] != board_2->castle[Black][SideA]) return false; + if (board_1->ep_square != board_2->ep_square) return false; + + return true; +} + +// board_init_list() + +void board_init_list(board_t * board) { + + int sq_64, sq, piece; + int colour, pos; + + ASSERT(board!=NULL); + + // init + + for (sq_64 = 0; sq_64 < 64; sq_64++) { + sq = square_from_64(sq_64); + board->pos[sq] = -1; + } + + for (piece = 0; piece < 12; piece++) board->number[piece] = 0; + + // white piece list + + colour = White; + pos = 0; + + for (sq_64 = 0; sq_64 < 64; sq_64++) { + sq = square_from_64(sq_64); + piece = board->square[sq]; + ASSERT(pos>=0&&pos<=16); + if (colour_equal(piece,colour) && piece_is_king(piece)) { + board->pos[sq] = pos; + board->list[colour][pos] = sq; + pos++; + board->number[piece_to_12(piece)]++; + } + } + ASSERT(pos==1); + + for (sq_64 = 0; sq_64 < 64; sq_64++) { + sq = square_from_64(sq_64); + piece = board->square[sq]; + ASSERT(pos>=0&&pos<=16); + if (colour_equal(piece,colour) && !piece_is_king(piece)) { + board->pos[sq] = pos; + board->list[colour][pos] = sq; + pos++; + board->number[piece_to_12(piece)]++; + } + } + + ASSERT(pos>=1&&pos<=16); + board->list[colour][pos] = SquareNone; + board->list_size[colour] = pos; + + // black piece list + + colour = Black; + pos = 0; + + for (sq_64 = 0; sq_64 < 64; sq_64++) { + sq = square_from_64(sq_64); + piece = board->square[sq]; + ASSERT(pos>=0&&pos<=16); + if (colour_equal(piece,colour) && piece_is_king(piece)) { + board->pos[sq] = pos; + board->list[colour][pos] = sq; + pos++; + board->number[piece_to_12(piece)]++; + } + } + ASSERT(pos==1); + + for (sq_64 = 0; sq_64 < 64; sq_64++) { + sq = square_from_64(sq_64); + piece = board->square[sq]; + ASSERT(pos>=1&&pos<=16); + if (colour_equal(piece,colour) && !piece_is_king(piece)) { + board->pos[sq] = pos; + board->list[colour][pos] = sq; + pos++; + board->number[piece_to_12(piece)]++; + } + } + + ASSERT(pos>=1&&pos<=16); + board->list[colour][pos] = SquareNone; + board->list_size[colour] = pos; + + // hash key + + board->key = hash_key(board); +} + +// board_flags() + +int board_flags(const board_t * board) { + + int flags; + + flags = 0; + + if (board->castle[White][SideH] != SquareNone) flags |= 1 << 0; + if (board->castle[White][SideA] != SquareNone) flags |= 1 << 1; + if (board->castle[Black][SideH] != SquareNone) flags |= 1 << 2; + if (board->castle[Black][SideA] != SquareNone) flags |= 1 << 3; + + return flags; +} + +// board_can_play() + +bool board_can_play(const board_t * board) { + + list_t list[1]; + int i, move; + + ASSERT(board_is_ok(board)); + + gen_moves(list,board); + + for (i = 0; i < list_size(list); i++) { + move = list_move(list,i); + if (pseudo_is_legal(move,board)) return true; + } + + return false; // no legal move +} + +// board_mobility() + +int board_mobility(const board_t * board) { + + list_t list[1]; + + ASSERT(board_is_ok(board)); + + gen_legal_moves(list,board); + + return list_size(list); +} + +// board_is_check() + +bool board_is_check(const board_t * board) { + + ASSERT(board_is_ok(board)); + + return is_in_check(board,board->turn); +} + +// board_is_mate() + +bool board_is_mate(const board_t * board) { + + ASSERT(board_is_ok(board)); + + if (!board_is_check(board)) return false; + if (board_can_play(board)) return false; + + return true; +} + +// board_is_stalemate() + +bool board_is_stalemate(const board_t * board) { + + ASSERT(board_is_ok(board)); + + if (board_is_check(board)) return false; + if (board_can_play(board)) return false; + + return true; +} + +// king_pos() + +int king_pos(const board_t * board, int colour) { + + ASSERT(board_is_ok(board)); + ASSERT(colour_is_ok(colour)); + + return board->list[colour][0]; +} + +// board_disp() + +void board_disp(const board_t * board) { + + int file, rank, sq; + int piece, c; + char fen[256]; + + ASSERT(board!=NULL); + + if (!board_to_fen(board,fen,256)) ASSERT(false); + my_log("POLYGLOT %s\n",fen); + my_log("POLYGLOT\n"); + + for (rank = 7; rank >= 0; rank--) { + + my_log("POLYGLOT "); + + for (file = 0; file < 8; file++) { + + sq = square_make(file,rank); + piece = board->square[sq]; + + c = (piece != Empty) ? piece_to_char(piece) : '-'; + my_log("%c ",c); + } + + my_log("\n"); + } + + my_log("POLYGLOT\n"); + + my_log("POLYGLOT %s to play\n",(colour_is_black(board->turn))?"black":"white"); + my_log("POLYGLOT\n"); +} + +// end of board.cpp + diff --git a/board.h b/board.h new file mode 100644 index 0000000..9a9a503 --- /dev/null +++ b/board.h @@ -0,0 +1,71 @@ + +// board.h + +#ifndef BOARD_H +#define BOARD_H + +// includes + +#include "colour.h" +#include "square.h" +#include "util.h" + +// constants + +const int Empty = 0; + +const int SideH = 0; +const int SideA = 1; +const int SideNb = 2; + +// types + +struct board_t { + + uint8 square[SquareNb]; + sint8 pos[SquareNb]; + + uint8 list[ColourNb][32]; + sint8 list_size[ColourNb]; + + sint8 number[12]; + + sint8 turn; + uint8 castle[ColourNb][SideNb]; + uint8 ep_square; + + sint16 ply_nb; + sint16 move_nb; + + uint64 key; +}; + +// functions + +extern bool board_is_ok (const board_t * board); + +extern void board_clear (board_t * board); +extern void board_start (board_t * board); + +extern void board_copy (board_t * dst, const board_t * src); +extern bool board_equal (const board_t * board_1, const board_t * board_2); + +extern void board_init_list (board_t * board); + +extern int board_flags (const board_t * board); + +extern bool board_can_play (const board_t * board); +extern int board_mobility (const board_t * board); + +extern bool board_is_check (const board_t * board); +extern bool board_is_mate (const board_t * board); +extern bool board_is_stalemate (const board_t * board); + +extern int king_pos (const board_t * board, int colour); + +extern void board_disp (const board_t * board); + +#endif // !defined BOARD_H + +// end of board.h + diff --git a/book.cpp b/book.cpp new file mode 100644 index 0000000..1dab50a --- /dev/null +++ b/book.cpp @@ -0,0 +1,384 @@ + +// book.cpp + +// includes + +#include +#include +#include +#include + +#include "board.h" +#include "book.h" +#include "move.h" +#include "move_legal.h" +#include "san.h" +#include "util.h" +#include "option.h" + +// types + +struct entry_t { + uint64 key; + uint16 move; + uint16 count; + uint16 n; + uint16 sum; +}; + +// variables + +static FILE * BookFile; +static int BookSize; + +// prototypes + +static int find_pos (uint64 key); + +static void read_entry (entry_t * entry, int n); +static void write_entry (const entry_t * entry, int n); + +static uint64 read_integer (FILE * file, int size); +static void write_integer (FILE * file, int size, uint64 n); + +// functions + +// book_clear() + +void book_clear() { + + BookFile = NULL; + BookSize = 0; +} + +bool book_is_open(){ + return BookFile!=NULL; +} + +// book_open() + +void book_open(const char file_name[]) { + + ASSERT(file_name!=NULL); + if(option_get_bool("BookLearn")){ + BookFile = fopen(file_name,"rb+"); + }else{ + BookFile = fopen(file_name,"rb"); + } + +// if (BookFile == NULL) my_fatal("book_open(): can't open file \"%s\": %s\n",file_name,strerror(errno)); + if (BookFile == NULL) return; + + if (fseek(BookFile,0,SEEK_END) == -1) { + my_fatal("book_open(): fseek(): %s\n",strerror(errno)); + } + + BookSize = ftell(BookFile) / 16; +// if (BookSize == 0) my_fatal("book_open(): empty file\n"); + if (BookSize == 0) { + book_close(); + book_clear(); + }; +} + +// book_close() + +void book_close() { + + if(BookFile==NULL) return; + + if (fclose(BookFile) == EOF) { + my_fatal("book_close(): fclose(): %s\n",strerror(errno)); + } +} + +// is_in_book() + +bool is_in_book(const board_t * board) { + + int pos; + entry_t entry[1]; + + if(BookFile==NULL) return false; + + ASSERT(board!=NULL); + + for (pos = find_pos(board->key); pos < BookSize; pos++) { + read_entry(entry,pos); + if (entry->key == board->key) return true; + } + + return false; +} + +// book_move() + +int book_move(const board_t * board, bool random) { + + int best_move; + int best_score; + int pos; + entry_t entry[1]; + int move; + int score; + + if(BookFile==NULL) return MoveNone; + + ASSERT(board!=NULL); + ASSERT(random==true||random==false); + + + best_move = MoveNone; + best_score = 0; + for (pos = find_pos(board->key); pos < BookSize; pos++) { + + read_entry(entry,pos); + if (entry->key != board->key) break; + + move = entry->move; + score = entry->count; + + if (move != MoveNone && move_is_legal(move,board)) { + + // pick this move? + + ASSERT(score>0); + + if (random) { + best_score += score; + if (my_random_int(best_score) < score) best_move = move; + } else { + if (score > best_score) { + best_move = move; + best_score = score; + } + } + + } else { + + ASSERT(false); + } + } + + return best_move; +} + +// book_disp() + +void book_disp(const board_t * board) { + + int first_pos; + int sum; + int pos; + entry_t entry[1]; + int move; + int score; + char move_string[256]; + + ASSERT(board!=NULL); + + if(BookFile==NULL) return; + + first_pos = find_pos(board->key); + + // sum + + sum = 0; + + for (pos = first_pos; pos < BookSize; pos++) { + + read_entry(entry,pos); + if (entry->key != board->key) break; + + sum += entry->count; + } + + // disp + + for (pos = first_pos; pos < BookSize; pos++) { + + read_entry(entry,pos); + if (entry->key != board->key) break; + + move = entry->move; + score = entry->count; + + if (score > 0 && move != MoveNone && move_is_legal(move,board)) { + move_to_san(move,board,move_string,256); + printf(" %s (%.0f%%)\n",move_string,(double(score)/double(sum))*100.0); + } + } + + printf("\n"); +} + +// book_learn_move() + +void book_learn_move(const board_t * board, int move, int result) { + + int pos; + entry_t entry[1]; + + if(BookFile==NULL) return; + + ASSERT(board!=NULL); + ASSERT(move_is_ok(move)); + ASSERT(result>=-1&&result<=+1); + + ASSERT(move_is_legal(move,board)); + + for (pos = find_pos(board->key); pos < BookSize; pos++) { + + read_entry(entry,pos); + if (entry->key != board->key) break; + + if (entry->move == move) { + + entry->n++; + entry->sum += result+1; + + write_entry(entry,pos); + + break; + } + } +} + +// book_flush() + +void book_flush() { + + if(BookFile==NULL) return; + + if (fflush(BookFile) == EOF) { + my_fatal("book_flush(): fflush(): %s\n",strerror(errno)); + } +} + +// find_pos() + +static int find_pos(uint64 key) { + + int left, right, mid; + entry_t entry[1]; + + // binary search (finds the leftmost entry) + + left = 0; + right = BookSize-1; + + ASSERT(left<=right); + + while (left < right) { + + mid = (left + right) / 2; + ASSERT(mid>=left&&midkey) { + right = mid; + } else { + left = mid+1; + } + } + + ASSERT(left==right); + + read_entry(entry,left); + + return (entry->key == key) ? left : BookSize; +} + +// read_entry() + +static void read_entry(entry_t * entry, int n) { + + ASSERT(entry!=NULL); + ASSERT(n>=0&&nkey = read_integer(BookFile,8); + entry->move = read_integer(BookFile,2); + entry->count = read_integer(BookFile,2); + entry->n = read_integer(BookFile,2); + entry->sum = read_integer(BookFile,2); +} + +// write_entry() + +static void write_entry(const entry_t * entry, int n) { + + ASSERT(entry!=NULL); + ASSERT(n>=0&&nkey); + write_integer(BookFile,2,entry->move); + write_integer(BookFile,2,entry->count); + write_integer(BookFile,2,entry->n); + write_integer(BookFile,2,entry->sum); +} + +// read_integer() + +static uint64 read_integer(FILE * file, int size) { + + uint64 n; + int i; + int b; + + ASSERT(file!=NULL); + ASSERT(size>0&&size<=8); + + n = 0; + + for (i = 0; i < size; i++) { + + b = fgetc(file); + + if (b == EOF) { + if (feof(file)) { + my_fatal("read_integer(): fgetc(): EOF reached\n"); + } else { // error + my_fatal("read_integer(): fgetc(): %s\n",strerror(errno)); + } + } + + ASSERT(b>=0&&b<256); + n = (n << 8) | b; + } + + return n; +} + +// write_integer() + +static void write_integer(FILE * file, int size, uint64 n) { + + int i; + int b; + + ASSERT(file!=NULL); + ASSERT(size>0&&size<=8); + ASSERT(size==8||n>>(size*8)==0); + + for (i = size-1; i >= 0; i--) { + + b = (n >> (i*8)) & 0xFF; + ASSERT(b>=0&&b<256); + + if (fputc(b,file) == EOF) { + my_fatal("write_integer(): fputc(): %s\n",strerror(errno)); + } + } +} + +// end of book.cpp + diff --git a/book.h b/book.h new file mode 100644 index 0000000..0883fc3 --- /dev/null +++ b/book.h @@ -0,0 +1,30 @@ + +// book.h + +#ifndef BOOK_H +#define BOOK_H + +// includes + +#include "board.h" +#include "util.h" + +// functions + +extern void book_clear (); + +extern void book_open (const char file_name[]); +extern bool book_is_open (); +extern void book_close (); + +extern bool is_in_book (const board_t * board); +extern int book_move (const board_t * board, bool random); +extern void book_disp (const board_t * board); + +extern void book_learn_move (const board_t * board, int move, int result); +extern void book_flush (); + +#endif // !defined BOOK_H + +// end of book.h + diff --git a/book_format.html b/book_format.html new file mode 100644 index 0000000..c030282 --- /dev/null +++ b/book_format.html @@ -0,0 +1,522 @@ + + +Polyglot book format + + +

Polyglot book format

+The following description of the Polyglot book format is obtained +by inspecting the freely available source code of Polyglot. +

A note on copyright

I believe that the algorithm described +below may be freely implemented by all GUIs, adapters and engines, +including closed source ones. Polyglot itself is GPL but the GPL only +covers actual code and not algorithms. +

+The array of 781 random numbers is of course taken from the Polyglot +source code but I am pretty sure that a table of random numbers +cannot be covered by copyright. +

+Look below for some sample code which is released +in the public domain. +

+At the end of this document we discuss an extension of the Polyglot +opening book format for Chess960. This extension is implemented in +upcoming versions of xboard/winboard. +

Outline

+A Polyglot book is a series of "entries" of 16 bytes +

+

+key    uint64
+move   uint16 
+weight uint16
+learn  uint32
+
+

+All integers are stored highest byte first (regardless of size) +

+The entries are ordered according to key. Lowest key first. +

+

key

+"key" is a 64 bit hash of a board position. Its computation +is explained below. +

+The starting point is given by the following declaration + +

+
+#ifdef _MSC_VER
+#  define U64(u) (u##ui64)
+#else
+#  define U64(u) (u##ULL)
+#endif
+
+const uint64 Random64[781] = {
+   U64(0x9D39247E33776D41), U64(0x2AF7398005AAA5C7), U64(0x44DB015024623547), U64(0x9C15F73E62A76AE2),
+   U64(0x75834465489C0C89), U64(0x3290AC3A203001BF), U64(0x0FBBAD1F61042279), U64(0xE83A908FF2FB60CA),
+   U64(0x0D7E765D58755C10), U64(0x1A083822CEAFE02D), U64(0x9605D5F0E25EC3B0), U64(0xD021FF5CD13A2ED5),
+   U64(0x40BDF15D4A672E32), U64(0x011355146FD56395), U64(0x5DB4832046F3D9E5), U64(0x239F8B2D7FF719CC),
+   U64(0x05D1A1AE85B49AA1), U64(0x679F848F6E8FC971), U64(0x7449BBFF801FED0B), U64(0x7D11CDB1C3B7ADF0),
+   U64(0x82C7709E781EB7CC), U64(0xF3218F1C9510786C), U64(0x331478F3AF51BBE6), U64(0x4BB38DE5E7219443),
+   U64(0xAA649C6EBCFD50FC), U64(0x8DBD98A352AFD40B), U64(0x87D2074B81D79217), U64(0x19F3C751D3E92AE1),
+   U64(0xB4AB30F062B19ABF), U64(0x7B0500AC42047AC4), U64(0xC9452CA81A09D85D), U64(0x24AA6C514DA27500),
+   U64(0x4C9F34427501B447), U64(0x14A68FD73C910841), U64(0xA71B9B83461CBD93), U64(0x03488B95B0F1850F),
+   U64(0x637B2B34FF93C040), U64(0x09D1BC9A3DD90A94), U64(0x3575668334A1DD3B), U64(0x735E2B97A4C45A23),
+   U64(0x18727070F1BD400B), U64(0x1FCBACD259BF02E7), U64(0xD310A7C2CE9B6555), U64(0xBF983FE0FE5D8244),
+   U64(0x9F74D14F7454A824), U64(0x51EBDC4AB9BA3035), U64(0x5C82C505DB9AB0FA), U64(0xFCF7FE8A3430B241),
+   U64(0x3253A729B9BA3DDE), U64(0x8C74C368081B3075), U64(0xB9BC6C87167C33E7), U64(0x7EF48F2B83024E20),
+   U64(0x11D505D4C351BD7F), U64(0x6568FCA92C76A243), U64(0x4DE0B0F40F32A7B8), U64(0x96D693460CC37E5D),
+   U64(0x42E240CB63689F2F), U64(0x6D2BDCDAE2919661), U64(0x42880B0236E4D951), U64(0x5F0F4A5898171BB6),
+   U64(0x39F890F579F92F88), U64(0x93C5B5F47356388B), U64(0x63DC359D8D231B78), U64(0xEC16CA8AEA98AD76),
+   U64(0x5355F900C2A82DC7), U64(0x07FB9F855A997142), U64(0x5093417AA8A7ED5E), U64(0x7BCBC38DA25A7F3C),
+   U64(0x19FC8A768CF4B6D4), U64(0x637A7780DECFC0D9), U64(0x8249A47AEE0E41F7), U64(0x79AD695501E7D1E8),
+   U64(0x14ACBAF4777D5776), U64(0xF145B6BECCDEA195), U64(0xDABF2AC8201752FC), U64(0x24C3C94DF9C8D3F6),
+   U64(0xBB6E2924F03912EA), U64(0x0CE26C0B95C980D9), U64(0xA49CD132BFBF7CC4), U64(0xE99D662AF4243939),
+   U64(0x27E6AD7891165C3F), U64(0x8535F040B9744FF1), U64(0x54B3F4FA5F40D873), U64(0x72B12C32127FED2B),
+   U64(0xEE954D3C7B411F47), U64(0x9A85AC909A24EAA1), U64(0x70AC4CD9F04F21F5), U64(0xF9B89D3E99A075C2),
+   U64(0x87B3E2B2B5C907B1), U64(0xA366E5B8C54F48B8), U64(0xAE4A9346CC3F7CF2), U64(0x1920C04D47267BBD),
+   U64(0x87BF02C6B49E2AE9), U64(0x092237AC237F3859), U64(0xFF07F64EF8ED14D0), U64(0x8DE8DCA9F03CC54E),
+   U64(0x9C1633264DB49C89), U64(0xB3F22C3D0B0B38ED), U64(0x390E5FB44D01144B), U64(0x5BFEA5B4712768E9),
+   U64(0x1E1032911FA78984), U64(0x9A74ACB964E78CB3), U64(0x4F80F7A035DAFB04), U64(0x6304D09A0B3738C4),
+   U64(0x2171E64683023A08), U64(0x5B9B63EB9CEFF80C), U64(0x506AACF489889342), U64(0x1881AFC9A3A701D6),
+   U64(0x6503080440750644), U64(0xDFD395339CDBF4A7), U64(0xEF927DBCF00C20F2), U64(0x7B32F7D1E03680EC),
+   U64(0xB9FD7620E7316243), U64(0x05A7E8A57DB91B77), U64(0xB5889C6E15630A75), U64(0x4A750A09CE9573F7),
+   U64(0xCF464CEC899A2F8A), U64(0xF538639CE705B824), U64(0x3C79A0FF5580EF7F), U64(0xEDE6C87F8477609D),
+   U64(0x799E81F05BC93F31), U64(0x86536B8CF3428A8C), U64(0x97D7374C60087B73), U64(0xA246637CFF328532),
+   U64(0x043FCAE60CC0EBA0), U64(0x920E449535DD359E), U64(0x70EB093B15B290CC), U64(0x73A1921916591CBD),
+   U64(0x56436C9FE1A1AA8D), U64(0xEFAC4B70633B8F81), U64(0xBB215798D45DF7AF), U64(0x45F20042F24F1768),
+   U64(0x930F80F4E8EB7462), U64(0xFF6712FFCFD75EA1), U64(0xAE623FD67468AA70), U64(0xDD2C5BC84BC8D8FC),
+   U64(0x7EED120D54CF2DD9), U64(0x22FE545401165F1C), U64(0xC91800E98FB99929), U64(0x808BD68E6AC10365),
+   U64(0xDEC468145B7605F6), U64(0x1BEDE3A3AEF53302), U64(0x43539603D6C55602), U64(0xAA969B5C691CCB7A),
+   U64(0xA87832D392EFEE56), U64(0x65942C7B3C7E11AE), U64(0xDED2D633CAD004F6), U64(0x21F08570F420E565),
+   U64(0xB415938D7DA94E3C), U64(0x91B859E59ECB6350), U64(0x10CFF333E0ED804A), U64(0x28AED140BE0BB7DD),
+   U64(0xC5CC1D89724FA456), U64(0x5648F680F11A2741), U64(0x2D255069F0B7DAB3), U64(0x9BC5A38EF729ABD4),
+   U64(0xEF2F054308F6A2BC), U64(0xAF2042F5CC5C2858), U64(0x480412BAB7F5BE2A), U64(0xAEF3AF4A563DFE43),
+   U64(0x19AFE59AE451497F), U64(0x52593803DFF1E840), U64(0xF4F076E65F2CE6F0), U64(0x11379625747D5AF3),
+   U64(0xBCE5D2248682C115), U64(0x9DA4243DE836994F), U64(0x066F70B33FE09017), U64(0x4DC4DE189B671A1C),
+   U64(0x51039AB7712457C3), U64(0xC07A3F80C31FB4B4), U64(0xB46EE9C5E64A6E7C), U64(0xB3819A42ABE61C87),
+   U64(0x21A007933A522A20), U64(0x2DF16F761598AA4F), U64(0x763C4A1371B368FD), U64(0xF793C46702E086A0),
+   U64(0xD7288E012AEB8D31), U64(0xDE336A2A4BC1C44B), U64(0x0BF692B38D079F23), U64(0x2C604A7A177326B3),
+   U64(0x4850E73E03EB6064), U64(0xCFC447F1E53C8E1B), U64(0xB05CA3F564268D99), U64(0x9AE182C8BC9474E8),
+   U64(0xA4FC4BD4FC5558CA), U64(0xE755178D58FC4E76), U64(0x69B97DB1A4C03DFE), U64(0xF9B5B7C4ACC67C96),
+   U64(0xFC6A82D64B8655FB), U64(0x9C684CB6C4D24417), U64(0x8EC97D2917456ED0), U64(0x6703DF9D2924E97E),
+   U64(0xC547F57E42A7444E), U64(0x78E37644E7CAD29E), U64(0xFE9A44E9362F05FA), U64(0x08BD35CC38336615),
+   U64(0x9315E5EB3A129ACE), U64(0x94061B871E04DF75), U64(0xDF1D9F9D784BA010), U64(0x3BBA57B68871B59D),
+   U64(0xD2B7ADEEDED1F73F), U64(0xF7A255D83BC373F8), U64(0xD7F4F2448C0CEB81), U64(0xD95BE88CD210FFA7),
+   U64(0x336F52F8FF4728E7), U64(0xA74049DAC312AC71), U64(0xA2F61BB6E437FDB5), U64(0x4F2A5CB07F6A35B3),
+   U64(0x87D380BDA5BF7859), U64(0x16B9F7E06C453A21), U64(0x7BA2484C8A0FD54E), U64(0xF3A678CAD9A2E38C),
+   U64(0x39B0BF7DDE437BA2), U64(0xFCAF55C1BF8A4424), U64(0x18FCF680573FA594), U64(0x4C0563B89F495AC3),
+   U64(0x40E087931A00930D), U64(0x8CFFA9412EB642C1), U64(0x68CA39053261169F), U64(0x7A1EE967D27579E2),
+   U64(0x9D1D60E5076F5B6F), U64(0x3810E399B6F65BA2), U64(0x32095B6D4AB5F9B1), U64(0x35CAB62109DD038A),
+   U64(0xA90B24499FCFAFB1), U64(0x77A225A07CC2C6BD), U64(0x513E5E634C70E331), U64(0x4361C0CA3F692F12),
+   U64(0xD941ACA44B20A45B), U64(0x528F7C8602C5807B), U64(0x52AB92BEB9613989), U64(0x9D1DFA2EFC557F73),
+   U64(0x722FF175F572C348), U64(0x1D1260A51107FE97), U64(0x7A249A57EC0C9BA2), U64(0x04208FE9E8F7F2D6),
+   U64(0x5A110C6058B920A0), U64(0x0CD9A497658A5698), U64(0x56FD23C8F9715A4C), U64(0x284C847B9D887AAE),
+   U64(0x04FEABFBBDB619CB), U64(0x742E1E651C60BA83), U64(0x9A9632E65904AD3C), U64(0x881B82A13B51B9E2),
+   U64(0x506E6744CD974924), U64(0xB0183DB56FFC6A79), U64(0x0ED9B915C66ED37E), U64(0x5E11E86D5873D484),
+   U64(0xF678647E3519AC6E), U64(0x1B85D488D0F20CC5), U64(0xDAB9FE6525D89021), U64(0x0D151D86ADB73615),
+   U64(0xA865A54EDCC0F019), U64(0x93C42566AEF98FFB), U64(0x99E7AFEABE000731), U64(0x48CBFF086DDF285A),
+   U64(0x7F9B6AF1EBF78BAF), U64(0x58627E1A149BBA21), U64(0x2CD16E2ABD791E33), U64(0xD363EFF5F0977996),
+   U64(0x0CE2A38C344A6EED), U64(0x1A804AADB9CFA741), U64(0x907F30421D78C5DE), U64(0x501F65EDB3034D07),
+   U64(0x37624AE5A48FA6E9), U64(0x957BAF61700CFF4E), U64(0x3A6C27934E31188A), U64(0xD49503536ABCA345),
+   U64(0x088E049589C432E0), U64(0xF943AEE7FEBF21B8), U64(0x6C3B8E3E336139D3), U64(0x364F6FFA464EE52E),
+   U64(0xD60F6DCEDC314222), U64(0x56963B0DCA418FC0), U64(0x16F50EDF91E513AF), U64(0xEF1955914B609F93),
+   U64(0x565601C0364E3228), U64(0xECB53939887E8175), U64(0xBAC7A9A18531294B), U64(0xB344C470397BBA52),
+   U64(0x65D34954DAF3CEBD), U64(0xB4B81B3FA97511E2), U64(0xB422061193D6F6A7), U64(0x071582401C38434D),
+   U64(0x7A13F18BBEDC4FF5), U64(0xBC4097B116C524D2), U64(0x59B97885E2F2EA28), U64(0x99170A5DC3115544),
+   U64(0x6F423357E7C6A9F9), U64(0x325928EE6E6F8794), U64(0xD0E4366228B03343), U64(0x565C31F7DE89EA27),
+   U64(0x30F5611484119414), U64(0xD873DB391292ED4F), U64(0x7BD94E1D8E17DEBC), U64(0xC7D9F16864A76E94),
+   U64(0x947AE053EE56E63C), U64(0xC8C93882F9475F5F), U64(0x3A9BF55BA91F81CA), U64(0xD9A11FBB3D9808E4),
+   U64(0x0FD22063EDC29FCA), U64(0xB3F256D8ACA0B0B9), U64(0xB03031A8B4516E84), U64(0x35DD37D5871448AF),
+   U64(0xE9F6082B05542E4E), U64(0xEBFAFA33D7254B59), U64(0x9255ABB50D532280), U64(0xB9AB4CE57F2D34F3),
+   U64(0x693501D628297551), U64(0xC62C58F97DD949BF), U64(0xCD454F8F19C5126A), U64(0xBBE83F4ECC2BDECB),
+   U64(0xDC842B7E2819E230), U64(0xBA89142E007503B8), U64(0xA3BC941D0A5061CB), U64(0xE9F6760E32CD8021),
+   U64(0x09C7E552BC76492F), U64(0x852F54934DA55CC9), U64(0x8107FCCF064FCF56), U64(0x098954D51FFF6580),
+   U64(0x23B70EDB1955C4BF), U64(0xC330DE426430F69D), U64(0x4715ED43E8A45C0A), U64(0xA8D7E4DAB780A08D),
+   U64(0x0572B974F03CE0BB), U64(0xB57D2E985E1419C7), U64(0xE8D9ECBE2CF3D73F), U64(0x2FE4B17170E59750),
+   U64(0x11317BA87905E790), U64(0x7FBF21EC8A1F45EC), U64(0x1725CABFCB045B00), U64(0x964E915CD5E2B207),
+   U64(0x3E2B8BCBF016D66D), U64(0xBE7444E39328A0AC), U64(0xF85B2B4FBCDE44B7), U64(0x49353FEA39BA63B1),
+   U64(0x1DD01AAFCD53486A), U64(0x1FCA8A92FD719F85), U64(0xFC7C95D827357AFA), U64(0x18A6A990C8B35EBD),
+   U64(0xCCCB7005C6B9C28D), U64(0x3BDBB92C43B17F26), U64(0xAA70B5B4F89695A2), U64(0xE94C39A54A98307F),
+   U64(0xB7A0B174CFF6F36E), U64(0xD4DBA84729AF48AD), U64(0x2E18BC1AD9704A68), U64(0x2DE0966DAF2F8B1C),
+   U64(0xB9C11D5B1E43A07E), U64(0x64972D68DEE33360), U64(0x94628D38D0C20584), U64(0xDBC0D2B6AB90A559),
+   U64(0xD2733C4335C6A72F), U64(0x7E75D99D94A70F4D), U64(0x6CED1983376FA72B), U64(0x97FCAACBF030BC24),
+   U64(0x7B77497B32503B12), U64(0x8547EDDFB81CCB94), U64(0x79999CDFF70902CB), U64(0xCFFE1939438E9B24),
+   U64(0x829626E3892D95D7), U64(0x92FAE24291F2B3F1), U64(0x63E22C147B9C3403), U64(0xC678B6D860284A1C),
+   U64(0x5873888850659AE7), U64(0x0981DCD296A8736D), U64(0x9F65789A6509A440), U64(0x9FF38FED72E9052F),
+   U64(0xE479EE5B9930578C), U64(0xE7F28ECD2D49EECD), U64(0x56C074A581EA17FE), U64(0x5544F7D774B14AEF),
+   U64(0x7B3F0195FC6F290F), U64(0x12153635B2C0CF57), U64(0x7F5126DBBA5E0CA7), U64(0x7A76956C3EAFB413),
+   U64(0x3D5774A11D31AB39), U64(0x8A1B083821F40CB4), U64(0x7B4A38E32537DF62), U64(0x950113646D1D6E03),
+   U64(0x4DA8979A0041E8A9), U64(0x3BC36E078F7515D7), U64(0x5D0A12F27AD310D1), U64(0x7F9D1A2E1EBE1327),
+   U64(0xDA3A361B1C5157B1), U64(0xDCDD7D20903D0C25), U64(0x36833336D068F707), U64(0xCE68341F79893389),
+   U64(0xAB9090168DD05F34), U64(0x43954B3252DC25E5), U64(0xB438C2B67F98E5E9), U64(0x10DCD78E3851A492),
+   U64(0xDBC27AB5447822BF), U64(0x9B3CDB65F82CA382), U64(0xB67B7896167B4C84), U64(0xBFCED1B0048EAC50),
+   U64(0xA9119B60369FFEBD), U64(0x1FFF7AC80904BF45), U64(0xAC12FB171817EEE7), U64(0xAF08DA9177DDA93D),
+   U64(0x1B0CAB936E65C744), U64(0xB559EB1D04E5E932), U64(0xC37B45B3F8D6F2BA), U64(0xC3A9DC228CAAC9E9),
+   U64(0xF3B8B6675A6507FF), U64(0x9FC477DE4ED681DA), U64(0x67378D8ECCEF96CB), U64(0x6DD856D94D259236),
+   U64(0xA319CE15B0B4DB31), U64(0x073973751F12DD5E), U64(0x8A8E849EB32781A5), U64(0xE1925C71285279F5),
+   U64(0x74C04BF1790C0EFE), U64(0x4DDA48153C94938A), U64(0x9D266D6A1CC0542C), U64(0x7440FB816508C4FE),
+   U64(0x13328503DF48229F), U64(0xD6BF7BAEE43CAC40), U64(0x4838D65F6EF6748F), U64(0x1E152328F3318DEA),
+   U64(0x8F8419A348F296BF), U64(0x72C8834A5957B511), U64(0xD7A023A73260B45C), U64(0x94EBC8ABCFB56DAE),
+   U64(0x9FC10D0F989993E0), U64(0xDE68A2355B93CAE6), U64(0xA44CFE79AE538BBE), U64(0x9D1D84FCCE371425),
+   U64(0x51D2B1AB2DDFB636), U64(0x2FD7E4B9E72CD38C), U64(0x65CA5B96B7552210), U64(0xDD69A0D8AB3B546D),
+   U64(0x604D51B25FBF70E2), U64(0x73AA8A564FB7AC9E), U64(0x1A8C1E992B941148), U64(0xAAC40A2703D9BEA0),
+   U64(0x764DBEAE7FA4F3A6), U64(0x1E99B96E70A9BE8B), U64(0x2C5E9DEB57EF4743), U64(0x3A938FEE32D29981),
+   U64(0x26E6DB8FFDF5ADFE), U64(0x469356C504EC9F9D), U64(0xC8763C5B08D1908C), U64(0x3F6C6AF859D80055),
+   U64(0x7F7CC39420A3A545), U64(0x9BFB227EBDF4C5CE), U64(0x89039D79D6FC5C5C), U64(0x8FE88B57305E2AB6),
+   U64(0xA09E8C8C35AB96DE), U64(0xFA7E393983325753), U64(0xD6B6D0ECC617C699), U64(0xDFEA21EA9E7557E3),
+   U64(0xB67C1FA481680AF8), U64(0xCA1E3785A9E724E5), U64(0x1CFC8BED0D681639), U64(0xD18D8549D140CAEA),
+   U64(0x4ED0FE7E9DC91335), U64(0xE4DBF0634473F5D2), U64(0x1761F93A44D5AEFE), U64(0x53898E4C3910DA55),
+   U64(0x734DE8181F6EC39A), U64(0x2680B122BAA28D97), U64(0x298AF231C85BAFAB), U64(0x7983EED3740847D5),
+   U64(0x66C1A2A1A60CD889), U64(0x9E17E49642A3E4C1), U64(0xEDB454E7BADC0805), U64(0x50B704CAB602C329),
+   U64(0x4CC317FB9CDDD023), U64(0x66B4835D9EAFEA22), U64(0x219B97E26FFC81BD), U64(0x261E4E4C0A333A9D),
+   U64(0x1FE2CCA76517DB90), U64(0xD7504DFA8816EDBB), U64(0xB9571FA04DC089C8), U64(0x1DDC0325259B27DE),
+   U64(0xCF3F4688801EB9AA), U64(0xF4F5D05C10CAB243), U64(0x38B6525C21A42B0E), U64(0x36F60E2BA4FA6800),
+   U64(0xEB3593803173E0CE), U64(0x9C4CD6257C5A3603), U64(0xAF0C317D32ADAA8A), U64(0x258E5A80C7204C4B),
+   U64(0x8B889D624D44885D), U64(0xF4D14597E660F855), U64(0xD4347F66EC8941C3), U64(0xE699ED85B0DFB40D),
+   U64(0x2472F6207C2D0484), U64(0xC2A1E7B5B459AEB5), U64(0xAB4F6451CC1D45EC), U64(0x63767572AE3D6174),
+   U64(0xA59E0BD101731A28), U64(0x116D0016CB948F09), U64(0x2CF9C8CA052F6E9F), U64(0x0B090A7560A968E3),
+   U64(0xABEEDDB2DDE06FF1), U64(0x58EFC10B06A2068D), U64(0xC6E57A78FBD986E0), U64(0x2EAB8CA63CE802D7),
+   U64(0x14A195640116F336), U64(0x7C0828DD624EC390), U64(0xD74BBE77E6116AC7), U64(0x804456AF10F5FB53),
+   U64(0xEBE9EA2ADF4321C7), U64(0x03219A39EE587A30), U64(0x49787FEF17AF9924), U64(0xA1E9300CD8520548),
+   U64(0x5B45E522E4B1B4EF), U64(0xB49C3B3995091A36), U64(0xD4490AD526F14431), U64(0x12A8F216AF9418C2),
+   U64(0x001F837CC7350524), U64(0x1877B51E57A764D5), U64(0xA2853B80F17F58EE), U64(0x993E1DE72D36D310),
+   U64(0xB3598080CE64A656), U64(0x252F59CF0D9F04BB), U64(0xD23C8E176D113600), U64(0x1BDA0492E7E4586E),
+   U64(0x21E0BD5026C619BF), U64(0x3B097ADAF088F94E), U64(0x8D14DEDB30BE846E), U64(0xF95CFFA23AF5F6F4),
+   U64(0x3871700761B3F743), U64(0xCA672B91E9E4FA16), U64(0x64C8E531BFF53B55), U64(0x241260ED4AD1E87D),
+   U64(0x106C09B972D2E822), U64(0x7FBA195410E5CA30), U64(0x7884D9BC6CB569D8), U64(0x0647DFEDCD894A29),
+   U64(0x63573FF03E224774), U64(0x4FC8E9560F91B123), U64(0x1DB956E450275779), U64(0xB8D91274B9E9D4FB),
+   U64(0xA2EBEE47E2FBFCE1), U64(0xD9F1F30CCD97FB09), U64(0xEFED53D75FD64E6B), U64(0x2E6D02C36017F67F),
+   U64(0xA9AA4D20DB084E9B), U64(0xB64BE8D8B25396C1), U64(0x70CB6AF7C2D5BCF0), U64(0x98F076A4F7A2322E),
+   U64(0xBF84470805E69B5F), U64(0x94C3251F06F90CF3), U64(0x3E003E616A6591E9), U64(0xB925A6CD0421AFF3),
+   U64(0x61BDD1307C66E300), U64(0xBF8D5108E27E0D48), U64(0x240AB57A8B888B20), U64(0xFC87614BAF287E07),
+   U64(0xEF02CDD06FFDB432), U64(0xA1082C0466DF6C0A), U64(0x8215E577001332C8), U64(0xD39BB9C3A48DB6CF),
+   U64(0x2738259634305C14), U64(0x61CF4F94C97DF93D), U64(0x1B6BACA2AE4E125B), U64(0x758F450C88572E0B),
+   U64(0x959F587D507A8359), U64(0xB063E962E045F54D), U64(0x60E8ED72C0DFF5D1), U64(0x7B64978555326F9F),
+   U64(0xFD080D236DA814BA), U64(0x8C90FD9B083F4558), U64(0x106F72FE81E2C590), U64(0x7976033A39F7D952),
+   U64(0xA4EC0132764CA04B), U64(0x733EA705FAE4FA77), U64(0xB4D8F77BC3E56167), U64(0x9E21F4F903B33FD9),
+   U64(0x9D765E419FB69F6D), U64(0xD30C088BA61EA5EF), U64(0x5D94337FBFAF7F5B), U64(0x1A4E4822EB4D7A59),
+   U64(0x6FFE73E81B637FB3), U64(0xDDF957BC36D8B9CA), U64(0x64D0E29EEA8838B3), U64(0x08DD9BDFD96B9F63),
+   U64(0x087E79E5A57D1D13), U64(0xE328E230E3E2B3FB), U64(0x1C2559E30F0946BE), U64(0x720BF5F26F4D2EAA),
+   U64(0xB0774D261CC609DB), U64(0x443F64EC5A371195), U64(0x4112CF68649A260E), U64(0xD813F2FAB7F5C5CA),
+   U64(0x660D3257380841EE), U64(0x59AC2C7873F910A3), U64(0xE846963877671A17), U64(0x93B633ABFA3469F8),
+   U64(0xC0C0F5A60EF4CDCF), U64(0xCAF21ECD4377B28C), U64(0x57277707199B8175), U64(0x506C11B9D90E8B1D),
+   U64(0xD83CC2687A19255F), U64(0x4A29C6465A314CD1), U64(0xED2DF21216235097), U64(0xB5635C95FF7296E2),
+   U64(0x22AF003AB672E811), U64(0x52E762596BF68235), U64(0x9AEBA33AC6ECC6B0), U64(0x944F6DE09134DFB6),
+   U64(0x6C47BEC883A7DE39), U64(0x6AD047C430A12104), U64(0xA5B1CFDBA0AB4067), U64(0x7C45D833AFF07862),
+   U64(0x5092EF950A16DA0B), U64(0x9338E69C052B8E7B), U64(0x455A4B4CFE30E3F5), U64(0x6B02E63195AD0CF8),
+   U64(0x6B17B224BAD6BF27), U64(0xD1E0CCD25BB9C169), U64(0xDE0C89A556B9AE70), U64(0x50065E535A213CF6),
+   U64(0x9C1169FA2777B874), U64(0x78EDEFD694AF1EED), U64(0x6DC93D9526A50E68), U64(0xEE97F453F06791ED),
+   U64(0x32AB0EDB696703D3), U64(0x3A6853C7E70757A7), U64(0x31865CED6120F37D), U64(0x67FEF95D92607890),
+   U64(0x1F2B1D1F15F6DC9C), U64(0xB69E38A8965C6B65), U64(0xAA9119FF184CCCF4), U64(0xF43C732873F24C13),
+   U64(0xFB4A3D794A9A80D2), U64(0x3550C2321FD6109C), U64(0x371F77E76BB8417E), U64(0x6BFA9AAE5EC05779),
+   U64(0xCD04F3FF001A4778), U64(0xE3273522064480CA), U64(0x9F91508BFFCFC14A), U64(0x049A7F41061A9E60),
+   U64(0xFCB6BE43A9F2FE9B), U64(0x08DE8A1C7797DA9B), U64(0x8F9887E6078735A1), U64(0xB5B4071DBFC73A66),
+   U64(0x230E343DFBA08D33), U64(0x43ED7F5A0FAE657D), U64(0x3A88A0FBBCB05C63), U64(0x21874B8B4D2DBC4F),
+   U64(0x1BDEA12E35F6A8C9), U64(0x53C065C6C8E63528), U64(0xE34A1D250E7A8D6B), U64(0xD6B04D3B7651DD7E),
+   U64(0x5E90277E7CB39E2D), U64(0x2C046F22062DC67D), U64(0xB10BB459132D0A26), U64(0x3FA9DDFB67E2F199),
+   U64(0x0E09B88E1914F7AF), U64(0x10E8B35AF3EEAB37), U64(0x9EEDECA8E272B933), U64(0xD4C718BC4AE8AE5F),
+   U64(0x81536D601170FC20), U64(0x91B534F885818A06), U64(0xEC8177F83F900978), U64(0x190E714FADA5156E),
+   U64(0xB592BF39B0364963), U64(0x89C350C893AE7DC1), U64(0xAC042E70F8B383F2), U64(0xB49B52E587A1EE60),
+   U64(0xFB152FE3FF26DA89), U64(0x3E666E6F69AE2C15), U64(0x3B544EBE544C19F9), U64(0xE805A1E290CF2456),
+   U64(0x24B33C9D7ED25117), U64(0xE74733427B72F0C1), U64(0x0A804D18B7097475), U64(0x57E3306D881EDB4F),
+   U64(0x4AE7D6A36EB5DBCB), U64(0x2D8D5432157064C8), U64(0xD1E649DE1E7F268B), U64(0x8A328A1CEDFE552C),
+   U64(0x07A3AEC79624C7DA), U64(0x84547DDC3E203C94), U64(0x990A98FD5071D263), U64(0x1A4FF12616EEFC89),
+   U64(0xF6F7FD1431714200), U64(0x30C05B1BA332F41C), U64(0x8D2636B81555A786), U64(0x46C9FEB55D120902),
+   U64(0xCCEC0A73B49C9921), U64(0x4E9D2827355FC492), U64(0x19EBB029435DCB0F), U64(0x4659D2B743848A2C),
+   U64(0x963EF2C96B33BE31), U64(0x74F85198B05A2E7D), U64(0x5A0F544DD2B1FB18), U64(0x03727073C2E134B1),
+   U64(0xC7F6AA2DE59AEA61), U64(0x352787BAA0D7C22F), U64(0x9853EAB63B5E0B35), U64(0xABBDCDD7ED5C0860),
+   U64(0xCF05DAF5AC8D77B0), U64(0x49CAD48CEBF4A71E), U64(0x7A4C10EC2158C4A6), U64(0xD9E92AA246BF719E),
+   U64(0x13AE978D09FE5557), U64(0x730499AF921549FF), U64(0x4E4B705B92903BA4), U64(0xFF577222C14F0A3A),
+   U64(0x55B6344CF97AAFAE), U64(0xB862225B055B6960), U64(0xCAC09AFBDDD2CDB4), U64(0xDAF8E9829FE96B5F),
+   U64(0xB5FDFC5D3132C498), U64(0x310CB380DB6F7503), U64(0xE87FBB46217A360E), U64(0x2102AE466EBB1148),
+   U64(0xF8549E1A3AA5E00D), U64(0x07A69AFDCC42261A), U64(0xC4C118BFE78FEAAE), U64(0xF9F4892ED96BD438),
+   U64(0x1AF3DBE25D8F45DA), U64(0xF5B4B0B0D2DEEEB4), U64(0x962ACEEFA82E1C84), U64(0x046E3ECAAF453CE9),
+   U64(0xF05D129681949A4C), U64(0x964781CE734B3C84), U64(0x9C2ED44081CE5FBD), U64(0x522E23F3925E319E),
+   U64(0x177E00F9FC32F791), U64(0x2BC60A63A6F3B3F2), U64(0x222BBFAE61725606), U64(0x486289DDCC3D6780),
+   U64(0x7DC7785B8EFDFC80), U64(0x8AF38731C02BA980), U64(0x1FAB64EA29A2DDF7), U64(0xE4D9429322CD065A),
+   U64(0x9DA058C67844F20C), U64(0x24C0E332B70019B0), U64(0x233003B5A6CFE6AD), U64(0xD586BD01C5C217F6),
+   U64(0x5E5637885F29BC2B), U64(0x7EBA726D8C94094B), U64(0x0A56A5F0BFE39272), U64(0xD79476A84EE20D06),
+   U64(0x9E4C1269BAA4BF37), U64(0x17EFEE45B0DEE640), U64(0x1D95B0A5FCF90BC6), U64(0x93CBE0B699C2585D),
+   U64(0x65FA4F227A2B6D79), U64(0xD5F9E858292504D5), U64(0xC2B5A03F71471A6F), U64(0x59300222B4561E00),
+   U64(0xCE2F8642CA0712DC), U64(0x7CA9723FBB2E8988), U64(0x2785338347F2BA08), U64(0xC61BB3A141E50E8C),
+   U64(0x150F361DAB9DEC26), U64(0x9F6A419D382595F4), U64(0x64A53DC924FE7AC9), U64(0x142DE49FFF7A7C3D),
+   U64(0x0C335248857FA9E7), U64(0x0A9C32D5EAE45305), U64(0xE6C42178C4BBB92E), U64(0x71F1CE2490D20B07),
+   U64(0xF1BCC3D275AFE51A), U64(0xE728E8C83C334074), U64(0x96FBF83A12884624), U64(0x81A1549FD6573DA5),
+   U64(0x5FA7867CAF35E149), U64(0x56986E2EF3ED091B), U64(0x917F1DD5F8886C61), U64(0xD20D8C88C8FFE65F),
+   U64(0x31D71DCE64B2C310), U64(0xF165B587DF898190), U64(0xA57E6339DD2CF3A0), U64(0x1EF6E6DBB1961EC9),
+   U64(0x70CC73D90BC26E24), U64(0xE21A6B35DF0C3AD7), U64(0x003A93D8B2806962), U64(0x1C99DED33CB890A1),
+   U64(0xCF3145DE0ADD4289), U64(0xD0E4427A5514FB72), U64(0x77C621CC9FB3A483), U64(0x67A34DAC4356550B),
+   U64(0xF8D626AAAF278509),
+};
+
+The array Random64 is in fact a concatenation of four subarrays +
+RandomPiece     (offset:   0, length: 768)
+RandomCastle    (offset: 768, length:   4) 
+RandomEnPassant (offset: 772, length:   8)
+RandomTurn      (offset: 780, length:   1)
+
+"key" is a so-called "Zobrist hash function". In other words it is +the exclusive or of entries taken from each of the +subarrays described above. + +Thus we have +
+key=piece^castle^enpassant^turn;
+
+ +

piece

+"piece" is the exclusive or of entries from +RandomPiece, one for each piece on the board. The offset of the entry +in RandomPiece corresponding to a piece is computed as follows. +
+offset_piece=64*kind_of_piece+8*row+file;
+
+"row" and "file" are counted from 0 to 7. With this convention one has +
+square      file   row
+======================
+a1             0     0
+h1             7     0
+a8             0     7
+h8             7     7
+
+ +"kind_of_piece" is encoded as follows +
+black pawn    0
+white pawn    1
+black knight  2
+white knight  3
+black bishop  4
+white bishop  5
+black rook    6
+white rook    7
+black queen   8
+white queen   9
+black king   10
+white king   11
+
+ +

castle

+"castle" is the exclusive or of entries from +RandomCastle. The offsets are computed as follows. +
+white can castle short     0
+white can castle long      1
+black can castle short     2
+black can castle long      3
+
+If none of these flags apply then castle=0. +

+Note that these flags represent "potential future castling" as in the +FEN standard even if such castling is currently not possible due to blocking +pieces or enemy attacks. +

+In other words these flags are all true in the starting position and are +only updated after the appropriate king, rook or castling moves. + + + +

enpassent

If the opponent has performed a double pawn push +and there is now a pawn next to it belonging to the player to move then +"enpassant" is the entry from RandomEnPassant whose offset is the file +of the pushed pawn (counted from 0(=a) to 7(=h)). If this does not +apply then enpassant=0. +

+Note that this is different from the FEN standard. In the FEN standard +the presence of an "en passant target square" after a double pawn push +is unconditional. +

Also note that it is irrelevant if the potential en passant +capturing move is legal or not (examples where it would not be legal are +when the capturing pawn is pinned or when the double pawn push was a +discovered check). + + +

turn

+If white is to move then "turn" is the sole entry of RandomTurn. +If not then "turn" is zero. + +

Test data

+Here are some test keys. They were computed using Toga II +and checked using the algorithm described above. + +
+starting position
+FEN=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
+key=463b96181691fc9c
+
+position after e2e4
+FEN=rnbqkbnr/pppppppp/8/8/4P3/8/PPPP1PPP/RNBQKBNR b KQkq e3 0 1
+key=823c9b50fd114196
+
+position after e2e4 d75
+FEN=rnbqkbnr/ppp1pppp/8/3p4/4P3/8/PPPP1PPP/RNBQKBNR w KQkq d6 0 2
+key=0756b94461c50fb0
+
+position after e2e4 d7d5 e4e5
+FEN=rnbqkbnr/ppp1pppp/8/3pP3/8/8/PPPP1PPP/RNBQKBNR b KQkq - 0 2
+key=662fafb965db29d4
+
+position after e2e4 d7d5 e4e5 f7f5
+FEN=rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPP1PPP/RNBQKBNR w KQkq f6 0 3
+key=22a48b5a8e47ff78
+
+position after e2e4 d7d5 e4e5 f7f5 e1e2
+FEN=rnbqkbnr/ppp1p1pp/8/3pPp2/8/8/PPPPKPPP/RNBQ1BNR b kq - 0 3
+key=652a607ca3f242c1
+
+position after e2e4 d7d5 e4e5 f7f5 e1e2 e8f7
+FEN=rnbq1bnr/ppp1pkpp/8/3pPp2/8/8/PPPPKPPP/RNBQ1BNR w - - 0 4
+key=00fdd303c946bdd9
+
+position after a2a4 b7b5 h2h4 b5b4 c2c4
+FEN=rnbqkbnr/p1pppppp/8/8/PpP4P/8/1P1PPPP1/RNBQKBNR b KQkq c3 0 3
+key=3c8123ea7b067637
+
+position after a2a4 b7b5 h2h4 b5b4 c2c4 b4c3 a1a3
+FEN=rnbqkbnr/p1pppppp/8/8/P6P/R1p5/1P1PPPP1/1NBQKBNR b Kkq - 0 4
+key=5c3f9b829b279560
+
+ + +

move

+"move" is a bit field with the following meaning (bit 0 is the least +significant bit) +
+bits                meaning
+===================================
+0,1,2               to file
+3,4,5               to row
+6,7,8               from file
+9,10,11             from row
+12,13,14            promotion piece
+
+"promotion piece" is encoded as follows +
+none       0
+knight     1
+bishop     2
+rook       3
+queen      4
+
+If the move is "0" (a1a1) then it should simply be ignored. It seems to me that +in that case one might as well delete the entry from the book. + +

Castling moves

Castling moves are represented somewhat +unconventially as follows (this convention is related to Chess960, see +below). +
+white short      e1h1
+white long       e1a1
+black short      e8h8
+black long       e8a8
+
+It is technically possible that these moves are legal non-castling +moves. So before deciding that these are really castling moves the +implementation may for example verify that there is really a king +present on e1/e8. +

weight

+In the Polyglot source code this field is called "count" but it is in fact +a measure for the quality of the move. It should be at least one. +

+The Polyglot book generator sets it to 2*(wins)+(draws), globally +scaled to fit into 16 bits. A move with a weight of zero is deleted +from the book. This is just a convention and book authors +are free to set this field according to their taste (as long as it is at least one). +

+If random play is enabled in Polyglot then the probability that +a move is selected is its weight divided by the sum of the weights +of all the moves in the given position. +

A note on zero weights

+Polyglot assumes that weights are at least one since a zero +weight means the move should not be played, and hence you might as +well delete the entry from the book (which the Polyglot book generator does). + +Nonetheless, if you really insist, an entry with zero weight can be +approximated by giving it very low probability. This is what Scid does. + +

learn

"learn" is set to zero by the Polyglot book generator. +If you set "BookLearn=true" in polyglot.ini then this field +is used to record learning information. However I do not know of any +program that uses this information. Also this means the Polyglot should +have write access to the opening book which on Unix systems will probably +not be the case if the book has been installed centrally. +

+

Sample code

+The following sample code is released in the public domain. +
    +
  • +pg_key.c: This little utility computes the PG key +of a FEN. Note that it does ZERO error checking on the legality +of the FEN and hence will segfault if something is wrong. +
  • +
  • +pg_show.c: This utility looks up a PG key in a PG book +and prints out the moves and their (relative) weights. +
  • +
+

Utilities

+Here are a few utilities: pg_utils-0.2.tar.gz. They are released under the FreeBSD license. +

Extension to Chess960

+We assume that the reader is familar +with the rules of Chess960 (also called Fisher Random Chess or +FRC). See e.g. +http://en.wikipedia.org/wiki/Fischer_Random_Chess. +

+The Zobrist hash function used in Polyglot does not keep track of +which rook has castling rights if there are multiple rooks present on +the same side of the king. However it is rather unlikely that this +situation would occur in the opening. So the ambiguity can be resolved +in a satisfactory way by making the following convention. +

+ Positions in which a rook has castling rights which is not an outer +rook (closest to a or h file) should not be included in the book. +

+Nonetheless this is an unsatisfactory situation. Therefore the +upcoming versions of xboard/winboard extend the Polyglot hash function +in such a way that it takes into account the full castling rights in +Chess960, therefore +removing the need of the above disambiguating convention. This is done in a backward compatible way. I.e. ordinary +chess positions or Chess960 positions in which there is no castling +ambiguity will keep their old hash key. +

+The above declaration of RandomCastle is replaced by +

+const uint64 RandomCastle[16]={
+< to be filled in >
+}
+
+In this case "castle" will be the exclusive or of entries taken from +RandomCastle, one for each rook that has castling rights (so at most +four offsets). + +The offset for a rook that has castling rights is computed as follows. +
    +
  • If the rook is an outer rook (i.e. closest to the a or h file) then +the offset is +
    +0    if the rook is white and on the king side
    +1    if the rook is white and on the queen side
    +2    if the rook is black and on the king side
    +3    if the rook is black and on the queen side
    +
    +(this is like in ordinary chess) +
  • +
  • If the rook is not an outer rook then the offset is +
    +3+file    if the rook is white
    +9+file    if the rook is black
    +
    +where "file" denotes the file the rook is on, encoded in the usual way, i.e. +b=1,c=2,d=3,e=4,f=5,g=6. +
  • +
+

Encoding of moves

A castling move is encoded as a usual move +(see above) in which the "from square" is the position of the king and +the "to square" is the position of the rook. This is to maintain +compatibility with various Fruit derivatives. + + + + + diff --git a/book_make.cpp b/book_make.cpp new file mode 100644 index 0000000..ffffc9b --- /dev/null +++ b/book_make.cpp @@ -0,0 +1,540 @@ + +// book_make.cpp + +// includes + +#include +#include +#include +#include +#include + +#include "board.h" +#include "book_make.h" +#include "move.h" +#include "move_do.h" +#include "move_legal.h" +#include "pgn.h" +#include "san.h" +#include "util.h" + +// constants + +static const int COUNT_MAX = 16384; + +static const int NIL = -1; + +// types + +struct entry_t { + uint64 key; + uint16 move; + uint16 n; + uint16 sum; + uint16 colour; +}; + +struct book_t { + int size; + int alloc; + uint32 mask; + entry_t * entry; + sint32 * hash; +}; + +// variables + +static int MaxPly; +static int MinGame; +static double MinScore; +static bool RemoveWhite, RemoveBlack; +static bool Uniform; + +static book_t Book[1]; + +// prototypes + +static void book_clear (); +static void book_insert (const char file_name[]); +static void book_filter (); +static void book_sort (); +static void book_save (const char file_name[]); + +static int find_entry (const board_t * board, int move); +static void resize (); +static void halve_stats (uint64 key); + +static bool keep_entry (int pos); + +static int entry_score (const entry_t * entry); + +static int key_compare (const void * p1, const void * p2); + +static void write_integer (FILE * file, int size, uint64 n); + +// functions + +// book_make() + +void book_make(int argc, char * argv[]) { + + int i; + const char * pgn_file; + const char * bin_file; + + pgn_file = NULL; + my_string_set(&pgn_file,"book.pgn"); + + bin_file = NULL; + my_string_set(&bin_file,"book.bin"); + + MaxPly = 1024; + MinGame = 3; + MinScore = 0.0; + RemoveWhite = false; + RemoveBlack = false; + Uniform = false; + + for (i = 1; i < argc; i++) { + + if (false) { + + } else if (my_string_equal(argv[i],"make-book")) { + + // skip + + } else if (my_string_equal(argv[i],"-pgn")) { + + i++; + if (argv[i] == NULL) my_fatal("book_make(): missing argument\n"); + + my_string_set(&pgn_file,argv[i]); + + } else if (my_string_equal(argv[i],"-bin")) { + + i++; + if (argv[i] == NULL) my_fatal("book_make(): missing argument\n"); + + my_string_set(&bin_file,argv[i]); + + } else if (my_string_equal(argv[i],"-max-ply")) { + + i++; + if (argv[i] == NULL) my_fatal("book_make(): missing argument\n"); + + MaxPly = atoi(argv[i]); + ASSERT(MaxPly>=0); + + } else if (my_string_equal(argv[i],"-min-game")) { + + i++; + if (argv[i] == NULL) my_fatal("book_make(): missing argument\n"); + + MinGame = atoi(argv[i]); + ASSERT(MinGame>0); + + } else if (my_string_equal(argv[i],"-min-score")) { + + i++; + if (argv[i] == NULL) my_fatal("book_make(): missing argument\n"); + + MinScore = atof(argv[i]) / 100.0; + ASSERT(MinScore>=0.0&&MinScore<=1.0); + + } else if (my_string_equal(argv[i],"-only-white")) { + + RemoveWhite = false; + RemoveBlack = true; + + } else if (my_string_equal(argv[i],"-only-black")) { + + RemoveWhite = true; + RemoveBlack = false; + + } else if (my_string_equal(argv[i],"-uniform")) { + + Uniform = true; + + } else { + + my_fatal("book_make(): unknown option \"%s\"\n",argv[i]); + } + } + + book_clear(); + + printf("inserting games ...\n"); + book_insert(pgn_file); + + printf("filtering entries ...\n"); + book_filter(); + + printf("sorting entries ...\n"); + book_sort(); + + printf("saving entries ...\n"); + book_save(bin_file); + + printf("all done!\n"); +} + +// book_clear() + +static void book_clear() { + + int index; + + Book->alloc = 1; + Book->mask = (Book->alloc * 2) - 1; + + Book->entry = (entry_t *) my_malloc(Book->alloc*sizeof(entry_t)); + Book->size = 0; + + Book->hash = (sint32 *) my_malloc((Book->alloc*2)*sizeof(sint32)); + for (index = 0; index < Book->alloc*2; index++) { + Book->hash[index] = NIL; + } +} + +// book_insert() + +static void book_insert(const char file_name[]) { + + pgn_t pgn[1]; + board_t board[1]; + int ply; + int result; + char string[256]; + int move; + int pos; + + ASSERT(file_name!=NULL); + + // init + + pgn->game_nb=1; + // scan loop + + pgn_open(pgn,file_name); + + while (pgn_next_game(pgn)) { + + board_start(board); + ply = 0; + result = 0; + + if (false) { + } else if (my_string_equal(pgn->result,"1-0")) { + result = +1; + } else if (my_string_equal(pgn->result,"0-1")) { + result = -1; + } + + while (pgn_next_move(pgn,string,256)) { + + if (ply < MaxPly) { + + move = move_from_san(string,board); + + if (move == MoveNone || !move_is_legal(move,board)) { + my_fatal("book_insert(): illegal move \"%s\" at line %d, column %d,game %d\n",string,pgn->move_line,pgn->move_column,pgn->game_nb); + } + + pos = find_entry(board,move); + + Book->entry[pos].n++; + Book->entry[pos].sum += result+1; + + if (Book->entry[pos].n >= COUNT_MAX) { + halve_stats(board->key); + } + + move_do(board,move); + ply++; + result = -result; + } + } + pgn->game_nb++; + if (pgn->game_nb % 10000 == 0) printf("%d games ...\n",pgn->game_nb); + } + + pgn_close(pgn); + + printf("%d game%s.\n",pgn->game_nb,(pgn->game_nb>2)?"s":""); + printf("%d entries.\n",Book->size); + + return; +} + +// book_filter() + +static void book_filter() { + + int src, dst; + + // entry loop + + dst = 0; + + for (src = 0; src < Book->size; src++) { + if (keep_entry(src)) Book->entry[dst++] = Book->entry[src]; + } + + ASSERT(dst>=0&&dst<=Book->size); + Book->size = dst; + + printf("%d entries.\n",Book->size); +} + +// book_sort() + +static void book_sort() { + + // sort keys for binary search + + qsort(Book->entry,Book->size,sizeof(entry_t),&key_compare); +} + +// book_save() + +static void book_save(const char file_name[]) { + + FILE * file; + int pos; + + ASSERT(file_name!=NULL); + + file = fopen(file_name,"wb"); + if (file == NULL) my_fatal("book_save(): can't open file \"%s\" for writing: %s\n",file_name,strerror(errno)); + + // entry loop + + for (pos = 0; pos < Book->size; pos++) { + + ASSERT(keep_entry(pos)); + + write_integer(file,8,Book->entry[pos].key); + write_integer(file,2,Book->entry[pos].move); + write_integer(file,2,entry_score(&Book->entry[pos])); + write_integer(file,2,0); + write_integer(file,2,0); + } + + fclose(file); +} + +// find_entry() + +static int find_entry(const board_t * board, int move) { + + uint64 key; + int index; + int pos; + + ASSERT(board!=NULL); + ASSERT(move_is_ok(move)); + + ASSERT(move_is_legal(move,board)); + + // init + + key = board->key; + + // search + + for (index = key & Book->mask; (pos=Book->hash[index]) != NIL; index = (index+1) & Book->mask) { + + ASSERT(pos>=0&&possize); + + if (Book->entry[pos].key == key && Book->entry[pos].move == move) { + return pos; // found + } + } + + // not found + + ASSERT(Book->size<=Book->alloc); + + if (Book->size == Book->alloc) { + + // allocate more memory + + resize(); + + for (index = key & Book->mask; Book->hash[index] != NIL; index = (index+1) & Book->mask) + ; + } + + // create a new entry + + ASSERT(Book->sizealloc); + pos = Book->size++; + + Book->entry[pos].key = key; + Book->entry[pos].move = move; + Book->entry[pos].n = 0; + Book->entry[pos].sum = 0; + Book->entry[pos].colour = board->turn; + + // insert into the hash table + + ASSERT(index>=0&&indexalloc*2); + ASSERT(Book->hash[index]==NIL); + Book->hash[index] = pos; + + ASSERT(pos>=0&&possize); + + return pos; +} + +// resize() + +static void resize() { + + int size; + int pos; + int index; + + ASSERT(Book->size==Book->alloc); + + Book->alloc *= 2; + Book->mask = (Book->alloc * 2) - 1; + + size = 0; + size += Book->alloc * sizeof(entry_t); + size += (Book->alloc*2) * sizeof(sint32); + if (size >= 1048576) printf("allocating %gMB ...\n",double(size)/1048576.0); + // resize arrays + + Book->entry = (entry_t *) my_realloc(Book->entry,Book->alloc*sizeof(entry_t)); + Book->hash = (sint32 *) my_realloc(Book->hash,(Book->alloc*2)*sizeof(sint32)); + + // rebuild hash table + + for (index = 0; index < Book->alloc*2; index++) { + Book->hash[index] = NIL; + } + + for (pos = 0; pos < Book->size; pos++) { + + for (index = Book->entry[pos].key & Book->mask; Book->hash[index] != NIL; index = (index+1) & Book->mask) + ; + + ASSERT(index>=0&&indexalloc*2); + Book->hash[index] = pos; + } +} + +// halve_stats() + +static void halve_stats(uint64 key) { + + int index; + int pos; + + // search + + for (index = key & Book->mask; (pos=Book->hash[index]) != NIL; index = (index+1) & Book->mask) { + + ASSERT(pos>=0&&possize); + + if (Book->entry[pos].key == key) { + Book->entry[pos].n = (Book->entry[pos].n + 1) / 2; + Book->entry[pos].sum = (Book->entry[pos].sum + 1) / 2; + } + } +} + +// keep_entry() + +static bool keep_entry(int pos) { + + const entry_t * entry; + int colour; + double score; + + ASSERT(pos>=0&&possize); + + entry = &Book->entry[pos]; + + // if (entry->n == 0) return false; + if (entry->n < MinGame) return false; + + if (entry->sum == 0) return false; + + score = (double(entry->sum) / double(entry->n)) / 2.0; + ASSERT(score>=0.0&&score<=1.0); + + if (score < MinScore) return false; + + colour = entry->colour; + + if ((RemoveWhite && colour_is_white(colour)) + || (RemoveBlack && colour_is_black(colour))) { + return false; + } + + if (entry_score(entry) == 0) return false; // REMOVE ME? + + return true; +} + +// entry_score() + +static int entry_score(const entry_t * entry) { + + int score; + + ASSERT(entry!=NULL); + + // score = entry->n; // popularity + score = entry->sum; // "expectancy" + + if (Uniform) score = 1; + + ASSERT(score>=0); + + return score; +} + +// key_compare() + +static int key_compare(const void * p1, const void * p2) { + + const entry_t * entry_1, * entry_2; + + ASSERT(p1!=NULL); + ASSERT(p2!=NULL); + + entry_1 = (const entry_t *) p1; + entry_2 = (const entry_t *) p2; + + if (entry_1->key > entry_2->key) { + return +1; + } else if (entry_1->key < entry_2->key) { + return -1; + } else { + return entry_score(entry_2) - entry_score(entry_1); // highest score first + } +} + +// write_integer() + +static void write_integer(FILE * file, int size, uint64 n) { + + int i; + int b; + + ASSERT(file!=NULL); + ASSERT(size>0&&size<=8); + ASSERT(size==8||n>>(size*8)==0); + + for (i = size-1; i >= 0; i--) { + b = (n >> (i*8)) & 0xFF; + ASSERT(b>=0&&b<256); + fputc(b,file); + } +} + +// end of book_make.cpp + diff --git a/book_make.h b/book_make.h new file mode 100644 index 0000000..3302db4 --- /dev/null +++ b/book_make.h @@ -0,0 +1,18 @@ + +// book_make.h + +#ifndef BOOK_MAKE_H +#define BOOK_MAKE_H + +// includes + +#include "util.h" + +// functions + +extern void book_make (int argc, char * argv[]); + +#endif // !defined BOOK_MAKE_H + +// end of book_make.h + diff --git a/book_merge.cpp b/book_merge.cpp new file mode 100644 index 0000000..6d9c847 --- /dev/null +++ b/book_merge.cpp @@ -0,0 +1,304 @@ + +// book_merge.cpp + +// includes + +#include +#include +#include +#include + +#include "book_merge.h" +#include "util.h" + +// types + +struct book_t { + FILE * file; + int size; +}; + +struct entry_t { + uint64 key; + uint16 move; + uint16 count; + uint16 n; + uint16 sum; +}; + +// variables + +static book_t In1[1]; +static book_t In2[1]; +static book_t Out[1]; + +// prototypes + +static void book_clear (book_t * book); + +static void book_open (book_t * book, const char file_name[], const char mode[]); +static void book_close (book_t * book); + +static bool read_entry (book_t * book, entry_t * entry, int n); +static void write_entry (book_t * book, const entry_t * entry); + +static uint64 read_integer (FILE * file, int size); +static void write_integer (FILE * file, int size, uint64 n); + +// functions + +// book_merge() + +void book_merge(int argc, char * argv[]) { + + int i; + const char * in_file_1; + const char * in_file_2; + const char * out_file; + int i1, i2; + bool b1, b2; + entry_t e1[1], e2[1]; + int skip; + + in_file_1 = NULL; + my_string_clear(&in_file_1); + + in_file_2 = NULL; + my_string_clear(&in_file_2); + + out_file = NULL; + my_string_set(&out_file,"out.bin"); + + for (i = 1; i < argc; i++) { + + if (false) { + + } else if (my_string_equal(argv[i],"merge-book")) { + + // skip + + } else if (my_string_equal(argv[i],"-in1")) { + + i++; + if (argv[i] == NULL) my_fatal("book_merge(): missing argument\n"); + + my_string_set(&in_file_1,argv[i]); + + } else if (my_string_equal(argv[i],"-in2")) { + + i++; + if (argv[i] == NULL) my_fatal("book_merge(): missing argument\n"); + + my_string_set(&in_file_2,argv[i]); + + } else if (my_string_equal(argv[i],"-out")) { + + i++; + if (argv[i] == NULL) my_fatal("book_merge(): missing argument\n"); + + my_string_set(&out_file,argv[i]); + + } else { + + my_fatal("book_merge(): unknown option \"%s\"\n",argv[i]); + } + } + + book_clear(In1); + book_clear(In2); + book_clear(Out); + + book_open(In1,in_file_1,"rb"); + book_open(In2,in_file_2,"rb"); + book_open(Out,out_file,"wb"); + + skip = 0; + + i1 = 0; + i2 = 0; + + while (true) { + + b1 = read_entry(In1,e1,i1); + b2 = read_entry(In2,e2,i2); + + if (false) { + + } else if (!b1 && !b2) { + + break; + + } else if (b1 && !b2) { + + write_entry(Out,e1); + i1++; + + } else if (b2 && !b1) { + + write_entry(Out,e2); + i2++; + + } else { + + ASSERT(b1); + ASSERT(b2); + + if (false) { + } else if (e1->key < e2->key) { + write_entry(Out,e1); + i1++; + } else if (e1->key > e2->key) { + write_entry(Out,e2); + i2++; + } else { + ASSERT(e1->key==e2->key); + skip++; + i2++; + } + } + } + + book_close(In1); + book_close(In2); + book_close(Out); + + if (skip != 0) { + printf("skipped %d entr%s.\n",skip,(skip>1)?"ies":"y"); + } + + printf("done!\n"); +} + +// book_clear() + +static void book_clear(book_t * book) { + + ASSERT(book!=NULL); + + book->file = NULL; + book->size = 0; +} + +// book_open() + +static void book_open(book_t * book, const char file_name[], const char mode[]) { + + ASSERT(book!=NULL); + ASSERT(file_name!=NULL); + ASSERT(mode!=NULL); + + book->file = fopen(file_name,mode); + if (book->file == NULL) my_fatal("book_open(): can't open file \"%s\": %s\n",file_name,strerror(errno)); + + if (fseek(book->file,0,SEEK_END) == -1) { + my_fatal("book_open(): fseek(): %s\n",strerror(errno)); + } + + book->size = ftell(book->file) / 16; +} + +// book_close() + +static void book_close(book_t * book) { + + ASSERT(book!=NULL); + + if (fclose(book->file) == EOF) { + my_fatal("book_close(): fclose(): %s\n",strerror(errno)); + } +} + +// read_entry() + +static bool read_entry(book_t * book, entry_t * entry, int n) { + + ASSERT(book!=NULL); + ASSERT(entry!=NULL); + + if (n < 0 || n >= book->size) return false; + + ASSERT(n>=0&&nsize); + + if (fseek(book->file,n*16,SEEK_SET) == -1) { + my_fatal("read_entry(): fseek(): %s\n",strerror(errno)); + } + + entry->key = read_integer(book->file,8); + entry->move = read_integer(book->file,2); + entry->count = read_integer(book->file,2); + entry->n = read_integer(book->file,2); + entry->sum = read_integer(book->file,2); + + return true; +} + +// write_entry() + +static void write_entry(book_t * book, const entry_t * entry) { + + ASSERT(book!=NULL); + ASSERT(entry!=NULL); + + write_integer(book->file,8,entry->key); + write_integer(book->file,2,entry->move); + write_integer(book->file,2,entry->count); + write_integer(book->file,2,entry->n); + write_integer(book->file,2,entry->sum); +} + +// read_integer() + +static uint64 read_integer(FILE * file, int size) { + + uint64 n; + int i; + int b; + + ASSERT(file!=NULL); + ASSERT(size>0&&size<=8); + + n = 0; + + for (i = 0; i < size; i++) { + + b = fgetc(file); + + if (b == EOF) { + if (feof(file)) { + my_fatal("read_integer(): fgetc(): EOF reached\n"); + } else { // error + my_fatal("read_integer(): fgetc(): %s\n",strerror(errno)); + } + } + + ASSERT(b>=0&&b<256); + n = (n << 8) | b; + } + + return n; +} + +// write_integer() + +static void write_integer(FILE * file, int size, uint64 n) { + + int i; + int b; + + ASSERT(file!=NULL); + ASSERT(size>0&&size<=8); + ASSERT(size==8||n>>(size*8)==0); + + for (i = size-1; i >= 0; i--) { + + b = (n >> (i*8)) & 0xFF; + ASSERT(b>=0&&b<256); + + if (fputc(b,file) == EOF) { + my_fatal("write_integer(): fputc(): %s\n",strerror(errno)); + } + } +} + +// end of book_merge.cpp + diff --git a/book_merge.h b/book_merge.h new file mode 100644 index 0000000..d53e3d0 --- /dev/null +++ b/book_merge.h @@ -0,0 +1,18 @@ + +// book_merge.h + +#ifndef BOOK_MERGE_H +#define BOOK_MERGE_H + +// includes + +#include "util.h" + +// functions + +extern void book_merge (int argc, char * argv[]); + +#endif // !defined BOOK_MERGE_H + +// end of book_merge.h + diff --git a/colour.cpp b/colour.cpp new file mode 100644 index 0000000..42b12b2 --- /dev/null +++ b/colour.cpp @@ -0,0 +1,55 @@ + +// colour.cpp + +// includes + +#include "colour.h" +#include "util.h" + +// functions + +// colour_is_ok() + +bool colour_is_ok(int colour) { + + return colour == Black || colour == White; +} + +// colour_is_white() + +bool colour_is_white(int colour) { + + ASSERT(colour_is_ok(colour)); + + return colour == White; +} + +// colour_is_black() + +bool colour_is_black(int colour) { + + ASSERT(colour_is_ok(colour)); + + return colour == Black; +} + +// colour_equal() + +bool colour_equal(int colour_1, int colour_2) { + + ASSERT(colour_is_ok(colour_2)); + + return (colour_1 & colour_2) != 0; +} + +// colour_opp() + +int colour_opp(int colour) { + + ASSERT(colour_is_ok(colour)); + + return colour ^ (BlackFlag^WhiteFlag); +} + +// end of colour.cpp + diff --git a/colour.h b/colour.h new file mode 100644 index 0000000..5cb7b02 --- /dev/null +++ b/colour.h @@ -0,0 +1,34 @@ + +// colour.h + +#ifndef COLOUR_H +#define COLOUR_H + +// includes + +#include "util.h" + +// constants + +const int BlackFlag = 1 << 0; +const int WhiteFlag = 1 << 1; + +const int ColourNone = 0; +const int Black = BlackFlag; +const int White = WhiteFlag; +const int ColourNb = 3; + +// functions + +extern bool colour_is_ok (int colour); + +extern bool colour_is_white (int colour); +extern bool colour_is_black (int colour); +extern bool colour_equal (int colour_1, int colour_2); + +extern int colour_opp (int colour); + +#endif // !defined COLOUR_H + +// end of colour.h + diff --git a/config.guess b/config.guess new file mode 100755 index 0000000..278f9e9 --- /dev/null +++ b/config.guess @@ -0,0 +1,1516 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. + +timestamp='2007-07-22' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Originally written by Per Bothner . +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + 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 __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *: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'` + exit ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* 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 + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + 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:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:[3456]*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T | authenticamd) + echo x86_64-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 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + cris:Linux:*:*) + echo cris-axis-linux-gnu + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + mips:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips + #undef mipsel + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mipsel + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef mips64 + #undef mips64el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=mips64el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=mips64 + #else + CPU= + #endif + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } + ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit ;; + xtensa:Linux:*:*) + echo xtensa-unknown-linux-gnu + exit ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + # Set LC_ALL=C to ensure ld outputs messages in English. + ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit ;; + esac + # Determine whether the default compiler is a.out or elf + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + #ifdef __ELF__ + # ifdef __GLIBC__ + # if __GLIBC__ >= 2 + LIBC=gnu + # else + LIBC=gnulibc1 + # endif + # else + LIBC=gnulibc1 + # endif + #else + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) + LIBC=gnu + #else + LIBC=gnuaout + #endif + #endif + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + 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 + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +eval $set_cc_for_build +cat >$dummy.c < +# include +#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 + 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 +# 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 < 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 b/config.h new file mode 100644 index 0000000..70c6937 --- /dev/null +++ b/config.h @@ -0,0 +1,180 @@ +/* config.h. Generated from config.h.in by configure. */ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +/* #undef HAVE_DOPRNT */ + +/* Define to 1 if you have the `dup2' function. */ +#define HAVE_DUP2 1 + +/* Define to 1 if you have the `floor' function. */ +#define HAVE_FLOOR 1 + +/* Define to 1 if you have the `fork' function. */ +#define HAVE_FORK 1 + +/* Define to 1 if you have the `gettimeofday' function. */ +#define HAVE_GETTIMEOFDAY 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the `m' library (-lm). */ +#define HAVE_LIBM 1 + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#define HAVE_MALLOC 1 + +/* Define to 1 if you have the `memchr' function. */ +#define HAVE_MEMCHR 1 + +/* Define to 1 if you have the `memmove' function. */ +#define HAVE_MEMMOVE 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if your system has a GNU libc compatible `realloc' function, + and to 0 otherwise. */ +#define HAVE_REALLOC 1 + +/* Define to 1 if you have the `select' function. */ +#define HAVE_SELECT 1 + +/* Define to 1 if stdbool.h conforms to C99. */ +#define HAVE_STDBOOL_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the `strchr' function. */ +#define HAVE_STRCHR 1 + +/* Define to 1 if you have the `strdup' function. */ +#define HAVE_STRDUP 1 + +/* Define to 1 if you have the `strerror' function. */ +#define HAVE_STRERROR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the `strstr' function. */ +#define HAVE_STRSTR 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SELECT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_SOCKET_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the `vfork' function. */ +#define HAVE_VFORK 1 + +/* Define to 1 if you have the header file. */ +/* #undef HAVE_VFORK_H */ + +/* Define to 1 if you have the `vprintf' function. */ +#define HAVE_VPRINTF 1 + +/* Define to 1 if `fork' works. */ +#define HAVE_WORKING_FORK 1 + +/* Define to 1 if `vfork' works. */ +#define HAVE_WORKING_VFORK 1 + +/* Define to 1 if the system has the type `_Bool'. */ +#define HAVE__BOOL 1 + +/* Name of package */ +#define PACKAGE "polyglot" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "michel.vandenbergh@uhasselt.be" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "polyglot" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "polyglot 1.4w10UCIb15" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "polyglot" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "1.4w10UCIb15" + +/* Define to 1 if the C compiler supports function prototypes. */ +#define PROTOTYPES 1 + +/* Define as the return type of signal handlers (`int' or `void'). */ +#define RETSIGTYPE void + +/* Define to the type of arg 1 for `select'. */ +#define SELECT_TYPE_ARG1 int + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#define SELECT_TYPE_ARG234 (fd_set *) + +/* Define to the type of arg 5 for `select'. */ +#define SELECT_TYPE_ARG5 (struct timeval *) + +/* Define to 1 if the `setvbuf' function takes the buffering type as its + second argument and the buffer pointer as the third, as on System V before + release 3. */ +/* #undef SETVBUF_REVERSED */ + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you can safely include both and . */ +#define TIME_WITH_SYS_TIME 1 + +/* Version number of package */ +#define VERSION "1.4w10UCIb15" + +/* Define like PROTOTYPES; this can be used by system headers. */ +#define __PROTOTYPES 1 + +/* Define to empty if `const' does not conform to ANSI C. */ +/* #undef const */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to rpl_malloc if the replacement function should be used. */ +/* #undef malloc */ + +/* Define to `int' if does not define. */ +/* #undef pid_t */ + +/* Define to rpl_realloc if the replacement function should be used. */ +/* #undef realloc */ + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ + +/* Define as `fork' if `vfork' does not work. */ +/* #undef vfork */ diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..1eebc88 --- /dev/null +++ b/config.h.in @@ -0,0 +1,179 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ +#undef HAVE_DOPRNT + +/* Define to 1 if you have the `dup2' function. */ +#undef HAVE_DUP2 + +/* Define to 1 if you have the `floor' function. */ +#undef HAVE_FLOOR + +/* Define to 1 if you have the `fork' function. */ +#undef HAVE_FORK + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `m' library (-lm). */ +#undef HAVE_LIBM + +/* Define to 1 if your system has a GNU libc compatible `malloc' function, and + to 0 otherwise. */ +#undef HAVE_MALLOC + +/* Define to 1 if you have the `memchr' function. */ +#undef HAVE_MEMCHR + +/* Define to 1 if you have the `memmove' function. */ +#undef HAVE_MEMMOVE + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if your system has a GNU libc compatible `realloc' function, + and to 0 otherwise. */ +#undef HAVE_REALLOC + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if stdbool.h conforms to C99. */ +#undef HAVE_STDBOOL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the `strdup' function. */ +#undef HAVE_STRDUP + +/* Define to 1 if you have the `strerror' function. */ +#undef HAVE_STRERROR + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strstr' function. */ +#undef HAVE_STRSTR + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SELECT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the `vfork' function. */ +#undef HAVE_VFORK + +/* Define to 1 if you have the header file. */ +#undef HAVE_VFORK_H + +/* Define to 1 if you have the `vprintf' function. */ +#undef HAVE_VPRINTF + +/* Define to 1 if `fork' works. */ +#undef HAVE_WORKING_FORK + +/* Define to 1 if `vfork' works. */ +#undef HAVE_WORKING_VFORK + +/* Define to 1 if the system has the type `_Bool'. */ +#undef HAVE__BOOL + +/* 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 version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if the C compiler supports function prototypes. */ +#undef PROTOTYPES + +/* Define as the return type of signal handlers (`int' or `void'). */ +#undef RETSIGTYPE + +/* Define to the type of arg 1 for `select'. */ +#undef SELECT_TYPE_ARG1 + +/* Define to the type of args 2, 3 and 4 for `select'. */ +#undef SELECT_TYPE_ARG234 + +/* Define to the type of arg 5 for `select'. */ +#undef SELECT_TYPE_ARG5 + +/* Define to 1 if the `setvbuf' function takes the buffering type as its + second argument and the buffer pointer as the third, as on System V before + release 3. */ +#undef SETVBUF_REVERSED + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Define like PROTOTYPES; this can be used by system headers. */ +#undef __PROTOTYPES + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to rpl_malloc if the replacement function should be used. */ +#undef malloc + +/* Define to `int' if does not define. */ +#undef pid_t + +/* Define to rpl_realloc if the replacement function should be used. */ +#undef realloc + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* Define as `fork' if `vfork' does not work. */ +#undef vfork diff --git a/config.sub b/config.sub new file mode 100755 index 0000000..1761d8b --- /dev/null +++ b/config.sub @@ -0,0 +1,1626 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. + +timestamp='2007-06-28' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + + +# Please send patches to . Submit a context +# diff and a properly formatted ChangeLog entry. +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -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*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ + | c4x | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | fido | fr30 | frv \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore | mep \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64vr | mips64vrel \ + | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | mt \ + | msp430 \ + | nios | nios2 \ + | ns16k | ns32k \ + | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | score \ + | sh | sh[1234] | sh[24]a | 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 | strongarm \ + | tahoe | thumb | tic4x | tic80 | tron \ + | v850 | v850e \ + | we32k \ + | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-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-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | 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-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ + | tahoe-* | thumb-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tron-* \ + | v850-* | v850e-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + 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 + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + 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-/'` + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + 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) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos) + 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 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tic55x | c55x*) + basic_machine=tic55x-unknown + os=-coff + ;; + tic6x | c6x*) + basic_machine=tic6x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | 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. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -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* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -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*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -kaos*) + os=-kaos + ;; + -zvmoe) + os=-zvmoe + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure b/configure new file mode 100755 index 0000000..5e682b1 --- /dev/null +++ b/configure @@ -0,0 +1,8265 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.61 for polyglot 1.4w10UCIb15. +# +# Report bugs to . +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 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=: + # Zsh 3.x and 4.x performs 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 + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +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.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +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 + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. 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" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +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 +fi +echo >conf$$.file +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 -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# 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'" + + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME='polyglot' +PACKAGE_TARNAME='polyglot' +PACKAGE_VERSION='1.4w10UCIb15' +PACKAGE_STRING='polyglot 1.4w10UCIb15' +PACKAGE_BUGREPORT='michel.vandenbergh@uhasselt.be' + +ac_unique_file="adapter.cpp" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +INSTALL_PROGRAM +INSTALL_SCRIPT +INSTALL_DATA +am__isrc +CYGPATH_W +PACKAGE +VERSION +ACLOCAL +AUTOCONF +AUTOMAKE +AUTOHEADER +MAKEINFO +install_sh +STRIP +INSTALL_STRIP_PROGRAM +mkdir_p +AWK +SET_MAKE +am__leading_dot +AMTAR +am__tar +am__untar +CXX +CXXFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CXX +EXEEXT +OBJEXT +DEPDIR +am__include +am__quote +AMDEP_TRUE +AMDEP_FALSE +AMDEPBACKSLASH +CXXDEPMODE +am__fastdepCXX_TRUE +am__fastdepCXX_FALSE +CC +CFLAGS +ac_ct_CC +CCDEPMODE +am__fastdepCC_TRUE +am__fastdepCC_FALSE +CPP +GREP +EGREP +LIBOBJS +LTLIBOBJS' +ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CXX +CXXFLAGS +LDFLAGS +LIBS +CPPFLAGS +CCC +CC +CFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (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=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_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -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_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -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_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +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 + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# 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 -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + 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 polyglot 1.4w10UCIb15 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/polyglot] + --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 +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of polyglot 1.4w10UCIb15:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + +Some influential environment variables: + CXX C++ compiler command + CXXFLAGS C++ compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CC C compiler command + CFLAGS C compiler flags + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +_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" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`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 + 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 +polyglot configure 1.4w10UCIb15 +generated by GNU Autoconf 2.61 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 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 +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 polyglot $as_me 1.4w10UCIb15, which was +generated by GNU Autoconf 2.61. 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=. + 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=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: 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 + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + 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_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_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 + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + 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'; { (exit 1); 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 + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" +fi +shift +for ac_site_file +do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $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,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + + + + + + + + + + + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +am__api_version='1.10' + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 +echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} + { (exit 1); exit 1; }; } +fi + +# 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. +{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done +IFS=$as_save_IFS + + +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 +{ echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +{ echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } +# Just in case +sleep 1 +echo timestamp > conftest.file +# 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 ( + 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 + rm -f conftest.file + 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". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } +test "$program_prefix" != NONE && + program_transform_name="s&^&$program_prefix&;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s&\$&$program_suffix&;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm -f conftest.sed + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 +echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} +fi + +{ echo "$as_me:$LINENO: checking for a thread-safe mkdir -p" >&5 +echo $ECHO_N "checking for a thread-safe mkdir -p... $ECHO_C" >&6; } +if test -z "$MKDIR_P"; then + if test "${ac_cv_path_mkdir+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 + { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$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 + + 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. + test -d ./--version && rmdir ./--version + MKDIR_P="$ac_install_sh -d" + fi +fi +{ echo "$as_me:$LINENO: result: $MKDIR_P" >&5 +echo "${ECHO_T}$MKDIR_P" >&6; } + +mkdir_p="$MKDIR_P" +case $mkdir_p in + [\\/$]* | ?:[\\/]*) ;; + */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; +esac + +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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$AWK" && break +done + +{ echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } +set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` +if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&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 + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + SET_MAKE= +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } + SET_MAKE="MAKE=${MAKE-make}" +fi + +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 + +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 + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } + 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='polyglot' + VERSION='1.4w10UCIb15' + + +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"} + +install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"} + +# 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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_STRIP="${ac_tool_prefix}strip" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $STRIP" >&5 +echo "${ECHO_T}$STRIP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_STRIP="strip" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 +echo "${ECHO_T}$ac_ct_STRIP" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_STRIP" = x; then + STRIP=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&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" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +# Always define AMTAR for backward compatibility. + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' + + + + + + +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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $CXX" >&5 +echo "${ECHO_T}$CXX" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CXX="$ac_prog" + echo "$as_me:$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 + { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 +echo "${ECHO_T}$ac_ct_CXX" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}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:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CXX=$ac_ct_CXX + fi +fi + + fi +fi +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C++ compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ echo "$as_me:$LINENO: checking for C++ compiler default output file name" >&5 +echo $ECHO_N "checking for C++ compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; 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 | *.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 + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C++ compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C++ compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether the C++ compiler works" >&5 +echo $ECHO_N "checking whether the C++ compiler works... $ECHO_C" >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C++ compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; 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 ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; } +if test "${ac_cv_cxx_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_cxx_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; } +GXX=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CXXFLAGS=${CXXFLAGS+set} +ac_save_CXXFLAGS=$CXXFLAGS +{ echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 +echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cxx_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CXXFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cxx_werror_flag=$ac_save_cxx_werror_flag + CXXFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cxx_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +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 +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 +echo "${ECHO_T}$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 done +.PHONY: am__doit +END +# If we don't find an include directive, just comment out the code. +{ echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } +am__include="#" +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote="\"" + _am_result=BSD + fi +fi + + +{ echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_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='\' +fi + if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + +depcc="$CXX" am_compiler_list= + +{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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'. + 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 + 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 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + 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 + ;; + none) break ;; + esac + # 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. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} 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 sub/conftest.${OBJEXT-o} 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 +{ echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 +echo "${ECHO_T}$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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +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 + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.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 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +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 +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* 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" + 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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +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) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +{ echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&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'. + 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 + 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 8's {/usr,}/bin/sh. + touch sub/conftst$i.h + done + echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf + + case $depmode in + 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 + ;; + none) break ;; + esac + # 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. + if depmode=$depmode \ + source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ + depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ + $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} 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 sub/conftest.${OBJEXT-o} 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 +{ echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$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 + + + +# Checks for libraries. +# FIXME: Replace `main' with a function in `-lm': + + +{ echo "$as_me:$LINENO: checking for sin in -lm" >&5 +echo $ECHO_N "checking for sin in -lm... $ECHO_C" >&6; } +if test "${ac_cv_lib_m_sin+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* 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 sin (); +int +main () +{ +return sin (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_lib_m_sin=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_lib_m_sin=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_lib_m_sin" >&5 +echo "${ECHO_T}$ac_cv_lib_m_sin" >&6; } +if test $ac_cv_lib_m_sin = yes; then + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBM 1 +_ACEOF + + LIBS="-lm $LIBS" + +fi + + +# Checks for header files. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + 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" + { test -f "$ac_path_GREP" && $as_test_x "$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 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + 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 + ac_count=`expr $ac_count + 1` + 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 + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + 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" + { test -f "$ac_path_EGREP" && $as_test_x "$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 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + 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 + ac_count=`expr $ac_count + 1` + 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 + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f 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 >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#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 +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + +for ac_header in stdlib.h string.h sys/time.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## --------------------------------------------- ## +## Report this to michel.vandenbergh@uhasselt.be ## +## --------------------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Checks for typedefs, structures, and compiler characteristics. +{ echo "$as_me:$LINENO: checking for stdbool.h that conforms to C99" >&5 +echo $ECHO_N "checking for stdbool.h that conforms to C99... $ECHO_C" >&6; } +if test "${ac_cv_header_stdbool_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +#include +#ifndef bool + "error: bool is not defined" +#endif +#ifndef false + "error: false is not defined" +#endif +#if false + "error: false is not 0" +#endif +#ifndef true + "error: true is not defined" +#endif +#if true != 1 + "error: true is not 1" +#endif +#ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" +#endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + bool e = &s; + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; +# if defined __xlc__ || defined __GNUC__ + /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0 + reported by James Lemley on 2005-10-05; see + http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html + This test is not quite right, since xlc is allowed to + reject this program, as the initializer for xlcbug is + not one of the forms that C requires support for. + However, doing the test right would require a runtime + test, and that would make cross-compilation harder. + Let us hope that IBM fixes the xlc bug, and also adds + support for this kind of constant expression. In the + meantime, this test will reject xlc, which is OK, since + our stdbool.h substitute should suffice. We also test + this with GCC, where it should work, to detect more + quickly whether someone messes up the test in the + future. */ + char digs[] = "0123456789"; + int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1); +# endif + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; + +int +main () +{ + + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdbool_h=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdbool_h=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdbool_h" >&5 +echo "${ECHO_T}$ac_cv_header_stdbool_h" >&6; } +{ echo "$as_me:$LINENO: checking for _Bool" >&5 +echo $ECHO_N "checking for _Bool... $ECHO_C" >&6; } +if test "${ac_cv_type__Bool+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef _Bool ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type__Bool=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type__Bool=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type__Bool" >&5 +echo "${ECHO_T}$ac_cv_type__Bool" >&6; } +if test $ac_cv_type__Bool = yes; then + +cat >>confdefs.h <<_ACEOF +#define HAVE__BOOL 1 +_ACEOF + + +fi + +if test $ac_cv_header_stdbool_h = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_STDBOOL_H 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_const=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for inline" >&5 +echo $ECHO_N "checking for inline... $ECHO_C" >&6; } +if test "${ac_cv_c_inline+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_inline=$ac_kw +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 +echo "${ECHO_T}$ac_cv_c_inline" >&6; } + + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + +{ echo "$as_me:$LINENO: checking for pid_t" >&5 +echo $ECHO_N "checking for pid_t... $ECHO_C" >&6; } +if test "${ac_cv_type_pid_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef pid_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_pid_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_pid_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5 +echo "${ECHO_T}$ac_cv_type_pid_t" >&6; } +if test $ac_cv_type_pid_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define pid_t int +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6; } +if test "${ac_cv_type_size_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef size_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_size_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_size_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6; } +if test $ac_cv_type_size_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; } +if test "${ac_cv_header_time+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_time=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_time=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +echo "${ECHO_T}$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +cat >>confdefs.h <<\_ACEOF +#define TIME_WITH_SYS_TIME 1 +_ACEOF + +fi + + +# Checks for library functions. + +for ac_header in vfork.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## --------------------------------------------- ## +## Report this to michel.vandenbergh@uhasselt.be ## +## --------------------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_func in fork vfork +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* 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 $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + +if test "x$ac_cv_func_fork" = xyes; then + { echo "$as_me:$LINENO: checking for working fork" >&5 +echo $ECHO_N "checking for working fork... $ECHO_C" >&6; } +if test "${ac_cv_func_fork_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_fork_works=cross +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* By Ruediger Kuhlmann. */ + return fork () < 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_fork_works=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_fork_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_fork_works" >&5 +echo "${ECHO_T}$ac_cv_func_fork_works" >&6; } + +else + ac_cv_func_fork_works=$ac_cv_func_fork +fi +if test "x$ac_cv_func_fork_works" = xcross; then + case $host in + *-*-amigaos* | *-*-msdosdjgpp*) + # Override, as these systems have only a dummy fork() stub + ac_cv_func_fork_works=no + ;; + *) + ac_cv_func_fork_works=yes + ;; + esac + { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&5 +echo "$as_me: WARNING: result $ac_cv_func_fork_works guessed because of cross compilation" >&2;} +fi +ac_cv_func_vfork_works=$ac_cv_func_vfork +if test "x$ac_cv_func_vfork" = xyes; then + { echo "$as_me:$LINENO: checking for working vfork" >&5 +echo $ECHO_N "checking for working vfork... $ECHO_C" >&6; } +if test "${ac_cv_func_vfork_works+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_vfork_works=cross +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Thanks to Paul Eggert for this test. */ +$ac_includes_default +#include +#ifdef HAVE_VFORK_H +# include +#endif +/* On some sparc systems, changes by the child to local and incoming + argument registers are propagated back to the parent. The compiler + is told about this with #include , but some compilers + (e.g. gcc -O) don't grok . Test for this by using a + static variable whose address is put into a register that is + clobbered by the vfork. */ +static void +#ifdef __cplusplus +sparc_address_test (int arg) +# else +sparc_address_test (arg) int arg; +#endif +{ + static pid_t child; + if (!child) { + child = vfork (); + if (child < 0) { + perror ("vfork"); + _exit(2); + } + if (!child) { + arg = getpid(); + write(-1, "", 0); + _exit (arg); + } + } +} + +int +main () +{ + pid_t parent = getpid (); + pid_t child; + + sparc_address_test (0); + + child = vfork (); + + if (child == 0) { + /* Here is another test for sparc vfork register problems. This + test uses lots of local variables, at least as many local + variables as main has allocated so far including compiler + temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris + 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should + reuse the register of parent for one of the local variables, + since it will think that parent can't possibly be used any more + in this routine. Assigning to the local variable will thus + munge parent in the parent process. */ + pid_t + p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), + p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); + /* Convince the compiler that p..p7 are live; otherwise, it might + use the same hardware register for all 8 local variables. */ + if (p != p1 || p != p2 || p != p3 || p != p4 + || p != p5 || p != p6 || p != p7) + _exit(1); + + /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent + from child file descriptors. If the child closes a descriptor + before it execs or exits, this munges the parent's descriptor + as well. Test for this by closing stdout in the child. */ + _exit(close(fileno(stdout)) != 0); + } else { + int status; + struct stat st; + + while (wait(&status) != child) + ; + return ( + /* Was there some problem with vforking? */ + child < 0 + + /* Did the child fail? (This shouldn't happen.) */ + || status + + /* Did the vfork/compiler bug occur? */ + || parent != getpid() + + /* Did the file descriptor bug occur? */ + || fstat(fileno(stdout), &st) != 0 + ); + } +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_vfork_works=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_vfork_works=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_vfork_works" >&5 +echo "${ECHO_T}$ac_cv_func_vfork_works" >&6; } + +fi; +if test "x$ac_cv_func_fork_works" = xcross; then + ac_cv_func_vfork_works=$ac_cv_func_vfork + { echo "$as_me:$LINENO: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&5 +echo "$as_me: WARNING: result $ac_cv_func_vfork_works guessed because of cross compilation" >&2;} +fi + +if test "x$ac_cv_func_vfork_works" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WORKING_VFORK 1 +_ACEOF + +else + +cat >>confdefs.h <<\_ACEOF +#define vfork fork +_ACEOF + +fi +if test "x$ac_cv_func_fork_works" = xyes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_WORKING_FORK 1 +_ACEOF + +fi + + +for ac_header in stdlib.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## --------------------------------------------- ## +## Report this to michel.vandenbergh@uhasselt.be ## +## --------------------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +{ echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 +echo $ECHO_N "checking for GNU libc compatible malloc... $ECHO_C" >&6; } +if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_malloc_0_nonnull=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#if defined STDC_HEADERS || defined HAVE_STDLIB_H +# include +#else +char *malloc (); +#endif + +int +main () +{ +return ! malloc (0); + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_malloc_0_nonnull=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_malloc_0_nonnull=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 +echo "${ECHO_T}$ac_cv_func_malloc_0_nonnull" >&6; } +if test $ac_cv_func_malloc_0_nonnull = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_MALLOC 1 +_ACEOF + +else + cat >>confdefs.h <<\_ACEOF +#define HAVE_MALLOC 0 +_ACEOF + + case " $LIBOBJS " in + *" malloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS malloc.$ac_objext" + ;; +esac + + +cat >>confdefs.h <<\_ACEOF +#define malloc rpl_malloc +_ACEOF + +fi + + + + +for ac_header in stdlib.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## --------------------------------------------- ## +## Report this to michel.vandenbergh@uhasselt.be ## +## --------------------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +{ echo "$as_me:$LINENO: checking for GNU libc compatible realloc" >&5 +echo $ECHO_N "checking for GNU libc compatible realloc... $ECHO_C" >&6; } +if test "${ac_cv_func_realloc_0_nonnull+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + ac_cv_func_realloc_0_nonnull=no +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#if defined STDC_HEADERS || defined HAVE_STDLIB_H +# include +#else +char *realloc (); +#endif + +int +main () +{ +return ! realloc (0, 0); + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_realloc_0_nonnull=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_func_realloc_0_nonnull=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_realloc_0_nonnull" >&5 +echo "${ECHO_T}$ac_cv_func_realloc_0_nonnull" >&6; } +if test $ac_cv_func_realloc_0_nonnull = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_REALLOC 1 +_ACEOF + +else + cat >>confdefs.h <<\_ACEOF +#define HAVE_REALLOC 0 +_ACEOF + + case " $LIBOBJS " in + *" realloc.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS realloc.$ac_objext" + ;; +esac + + +cat >>confdefs.h <<\_ACEOF +#define realloc rpl_realloc +_ACEOF + +fi + + + + + +for ac_header in sys/select.h sys/socket.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + ( cat <<\_ASBOX +## --------------------------------------------- ## +## Report this to michel.vandenbergh@uhasselt.be ## +## --------------------------------------------- ## +_ASBOX + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +{ echo "$as_me:$LINENO: checking types of arguments for select" >&5 +echo $ECHO_N "checking types of arguments for select... $ECHO_C" >&6; } +if test "${ac_cv_func_select_args+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + for ac_arg234 in 'fd_set *' 'int *' 'void *'; do + for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do + for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#ifdef HAVE_SYS_SELECT_H +# include +#endif +#ifdef HAVE_SYS_SOCKET_H +# include +#endif + +int +main () +{ +extern int select ($ac_arg1, + $ac_arg234, $ac_arg234, $ac_arg234, + $ac_arg5); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done + done +done +# Provide a safe default value. +: ${ac_cv_func_select_args='int,int *,struct timeval *'} + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_select_args" >&5 +echo "${ECHO_T}$ac_cv_func_select_args" >&6; } +ac_save_IFS=$IFS; IFS=',' +set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` +IFS=$ac_save_IFS +shift + +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG1 $1 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG234 ($2) +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define SELECT_TYPE_ARG5 ($3) +_ACEOF + +rm -f conftest* + +{ echo "$as_me:$LINENO: checking for function prototypes" >&5 +echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6; } +if test "$ac_cv_prog_cc_c89" != no; then + { echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +cat >>confdefs.h <<\_ACEOF +#define PROTOTYPES 1 +_ACEOF + + +cat >>confdefs.h <<\_ACEOF +#define __PROTOTYPES 1 +_ACEOF + +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + +{ echo "$as_me:$LINENO: checking whether setvbuf arguments are reversed" >&5 +echo $ECHO_N "checking whether setvbuf arguments are reversed... $ECHO_C" >&6; } +if test "${ac_cv_func_setvbuf_reversed+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_func_setvbuf_reversed=no + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +# ifdef PROTOTYPES + int (setvbuf) (FILE *, int, char *, size_t); +# endif +int +main () +{ +char buf; return setvbuf (stdout, _IOLBF, &buf, 1); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +# ifdef PROTOTYPES + int (setvbuf) (FILE *, int, char *, size_t); +# endif +int +main () +{ +char buf; return setvbuf (stdout, &buf, _IOLBF, 1); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + # It compiles and links either way, so it must not be declared + # with a prototype and most likely this is a K&R C compiler. + # Try running it. + if test "$cross_compiling" = yes; then + : # Assume setvbuf is not reversed when cross-compiling. +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +/* This call has the arguments reversed. + A reversed system may check and see that the address of buf + is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */ + char buf; + if (setvbuf (stdout, _IOLBF, &buf, 1) != 0) + return 1; + putchar ('\r'); + return 0; /* Non-reversed systems SEGV here. */ + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_func_setvbuf_reversed=yes +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + + ac_cv_func_setvbuf_reversed=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func_setvbuf_reversed" >&5 +echo "${ECHO_T}$ac_cv_func_setvbuf_reversed" >&6; } +if test $ac_cv_func_setvbuf_reversed = yes; then + +cat >>confdefs.h <<\_ACEOF +#define SETVBUF_REVERSED 1 +_ACEOF + +fi + +{ echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; } +if test "${ac_cv_type_signal+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +return *(signal (0, 0)) (0) == 1; + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_signal=int +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_signal=void +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +echo "${ECHO_T}$ac_cv_type_signal" >&6; } + +cat >>confdefs.h <<_ACEOF +#define RETSIGTYPE $ac_cv_type_signal +_ACEOF + + + +for ac_func in vprintf +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* 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 $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +{ echo "$as_me:$LINENO: checking for _doprnt" >&5 +echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6; } +if test "${ac_cv_func__doprnt+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define _doprnt to an innocuous variant, in case declares _doprnt. + For example, HP-UX 11i declares gettimeofday. */ +#define _doprnt innocuous__doprnt + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char _doprnt (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef _doprnt + +/* 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 _doprnt (); +/* 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__doprnt || defined __stub____doprnt +choke me +#endif + +int +main () +{ +return _doprnt (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_func__doprnt=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_func__doprnt=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 +echo "${ECHO_T}$ac_cv_func__doprnt" >&6; } +if test $ac_cv_func__doprnt = yes; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE_DOPRNT 1 +_ACEOF + +fi + +fi +done + + + + + + + + + + + + +for ac_func in dup2 floor gettimeofday memchr memmove select strchr strdup strerror strstr +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* Define $ac_func to an innocuous variant, in case declares $ac_func. + For example, HP-UX 11i declares gettimeofday. */ +#define $ac_func innocuous_$ac_func + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $ac_func + +/* 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 $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$ac_func || defined __stub___$ac_func +choke me +#endif + +int +main () +{ +return $ac_func (); + ; + return 0; +} +_ACEOF +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 "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_var=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + +ac_config_files="$ac_config_files Makefile" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + 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_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + +if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi +if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then + { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&5 +echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." >&2;} + { (exit 1); exit 1; }; } +fi + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be 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=: + # Zsh 3.x and 4.x performs 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 + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +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.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +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 + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +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 + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. 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" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +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 +fi +echo >conf$$.file +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 -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# 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'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by polyglot $as_me 1.4w10UCIb15, which was +generated by GNU Autoconf 2.61. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" +config_commands="$ac_config_commands" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +polyglot config.status 1.4w10UCIb15 +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2006 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +MKDIR_P='$MKDIR_P' +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS +# +AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +# +# Set up the sed scripts for CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "$CONFIG_FILES"; then + +_ACEOF + + + +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + cat >conf$$subs.sed <<_ACEOF +SHELL!$SHELL$ac_delim +PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim +PACKAGE_NAME!$PACKAGE_NAME$ac_delim +PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim +PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim +PACKAGE_STRING!$PACKAGE_STRING$ac_delim +PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim +exec_prefix!$exec_prefix$ac_delim +prefix!$prefix$ac_delim +program_transform_name!$program_transform_name$ac_delim +bindir!$bindir$ac_delim +sbindir!$sbindir$ac_delim +libexecdir!$libexecdir$ac_delim +datarootdir!$datarootdir$ac_delim +datadir!$datadir$ac_delim +sysconfdir!$sysconfdir$ac_delim +sharedstatedir!$sharedstatedir$ac_delim +localstatedir!$localstatedir$ac_delim +includedir!$includedir$ac_delim +oldincludedir!$oldincludedir$ac_delim +docdir!$docdir$ac_delim +infodir!$infodir$ac_delim +htmldir!$htmldir$ac_delim +dvidir!$dvidir$ac_delim +pdfdir!$pdfdir$ac_delim +psdir!$psdir$ac_delim +libdir!$libdir$ac_delim +localedir!$localedir$ac_delim +mandir!$mandir$ac_delim +DEFS!$DEFS$ac_delim +ECHO_C!$ECHO_C$ac_delim +ECHO_N!$ECHO_N$ac_delim +ECHO_T!$ECHO_T$ac_delim +LIBS!$LIBS$ac_delim +build_alias!$build_alias$ac_delim +host_alias!$host_alias$ac_delim +target_alias!$target_alias$ac_delim +INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim +INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim +INSTALL_DATA!$INSTALL_DATA$ac_delim +am__isrc!$am__isrc$ac_delim +CYGPATH_W!$CYGPATH_W$ac_delim +PACKAGE!$PACKAGE$ac_delim +VERSION!$VERSION$ac_delim +ACLOCAL!$ACLOCAL$ac_delim +AUTOCONF!$AUTOCONF$ac_delim +AUTOMAKE!$AUTOMAKE$ac_delim +AUTOHEADER!$AUTOHEADER$ac_delim +MAKEINFO!$MAKEINFO$ac_delim +install_sh!$install_sh$ac_delim +STRIP!$STRIP$ac_delim +INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim +mkdir_p!$mkdir_p$ac_delim +AWK!$AWK$ac_delim +SET_MAKE!$SET_MAKE$ac_delim +am__leading_dot!$am__leading_dot$ac_delim +AMTAR!$AMTAR$ac_delim +am__tar!$am__tar$ac_delim +am__untar!$am__untar$ac_delim +CXX!$CXX$ac_delim +CXXFLAGS!$CXXFLAGS$ac_delim +LDFLAGS!$LDFLAGS$ac_delim +CPPFLAGS!$CPPFLAGS$ac_delim +ac_ct_CXX!$ac_ct_CXX$ac_delim +EXEEXT!$EXEEXT$ac_delim +OBJEXT!$OBJEXT$ac_delim +DEPDIR!$DEPDIR$ac_delim +am__include!$am__include$ac_delim +am__quote!$am__quote$ac_delim +AMDEP_TRUE!$AMDEP_TRUE$ac_delim +AMDEP_FALSE!$AMDEP_FALSE$ac_delim +AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim +CXXDEPMODE!$CXXDEPMODE$ac_delim +am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim +am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim +CC!$CC$ac_delim +CFLAGS!$CFLAGS$ac_delim +ac_ct_CC!$ac_ct_CC$ac_delim +CCDEPMODE!$CCDEPMODE$ac_delim +am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim +am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim +CPP!$CPP$ac_delim +GREP!$GREP$ac_delim +EGREP!$EGREP$ac_delim +LIBOBJS!$LIBOBJS$ac_delim +LTLIBOBJS!$LTLIBOBJS$ac_delim +_ACEOF + + if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 86; then + break + elif $ac_last_try; then + { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 +echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} + { (exit 1); exit 1; }; } + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` +if test -n "$ac_eof"; then + ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` + ac_eof=`expr $ac_eof + 1` +fi + +cat >>$CONFIG_STATUS <<_ACEOF +cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end +_ACEOF +sed ' +s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g +s/^/s,@/; s/!/@,|#_!!_#|/ +:n +t n +s/'"$ac_delim"'$/,g/; t +s/$/\\/; p +N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n +' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF +:end +s/|#_!!_#|//g +CEOF$ac_eof +_ACEOF + + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/ +s/:*\${srcdir}:*/:/ +s/:*@srcdir@:*/:/ +s/^\([^=]*=[ ]*\):*/\1/ +s/:*$// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF +fi # test -n "$CONFIG_FILES" + + +for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`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 || +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" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`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 + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac + ac_MKDIR_P=$MKDIR_P + case $MKDIR_P in + [\\/$]* | ?:[\\/]* ) ;; + */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= + +case `sed -n '/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p +' $ac_file_inputs` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s&@configure_input@&$configure_input&;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +s&@MKDIR_P@&$ac_MKDIR_P&;t t +$ac_datarootdir_hack +" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&5 +echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined." >&2;} + + rm -f "$tmp/stdin" + case $ac_file in + -) cat "$tmp/out"; rm -f "$tmp/out";; + *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; + esac + ;; + :H) + # + # CONFIG_HEADER + # +_ACEOF + +# Transform confdefs.h into a sed script `conftest.defines', that +# substitutes the proper values into config.h.in to produce config.h. +rm -f conftest.defines conftest.tail +# First, append a space to every undef/define line, to ease matching. +echo 's/$/ /' >conftest.defines +# Then, protect against being on the right side of a sed subst, or in +# an unquoted here document, in config.status. If some macros were +# called several times there might be several #defines for the same +# symbol, which is useless. But do not sort them, since the last +# AC_DEFINE must be honored. +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where +# NAME is the cpp macro being defined, VALUE is the value it is being given. +# PARAMS is the parameter list in the macro definition--in most cases, it's +# just an empty string. +ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' +ac_dB='\\)[ (].*,\\1define\\2' +ac_dC=' ' +ac_dD=' ,' + +uniq confdefs.h | + sed -n ' + t rset + :rset + s/^[ ]*#[ ]*define[ ][ ]*// + t ok + d + :ok + s/[\\&,]/\\&/g + s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p + s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p + ' >>conftest.defines + +# Remove the space that was appended to ease matching. +# Then replace #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +# (The regexp can be short, since the line contains either #define or #undef.) +echo 's/ $// +s,^[ #]*u.*,/* & */,' >>conftest.defines + +# Break up conftest.defines: +ac_max_sed_lines=50 + +# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" +# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" +# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" +# et cetera. +ac_in='$ac_file_inputs' +ac_out='"$tmp/out1"' +ac_nxt='"$tmp/out2"' + +while : +do + # Write a here document: + cat >>$CONFIG_STATUS <<_ACEOF + # First, check the format of the line: + cat >"\$tmp/defines.sed" <<\\CEOF +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def +b +:def +_ACEOF + sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS + ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in + sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail + grep . conftest.tail >/dev/null || break + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines conftest.tail + +echo "ac_result=$ac_in" >>$CONFIG_STATUS +cat >>$CONFIG_STATUS <<\_ACEOF + if test x"$ac_file" != x-; then + echo "/* $configure_input */" >"$tmp/config.h" + cat "$ac_result" >>"$tmp/config.h" + if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f $ac_file + mv "$tmp/config.h" $ac_file + fi + else + echo "/* $configure_input */" + cat "$ac_result" + fi + rm -f "$tmp/out12" +# Compute $ac_file's index in $config_headers. +_am_arg=$ac_file +_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" || +$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$_am_arg" : 'X\(//\)[^/]' \| \ + X"$_am_arg" : 'X\(//\)$' \| \ + X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || +echo X"$_am_arg" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'`/stamp-h$_am_stamp_count + ;; + + :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 +echo "$as_me: executing $ac_file commands" >&6;} + ;; + esac + + + case $ac_file$ac_mode in + "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; 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" || +$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$mf" : 'X\(//\)[^/]' \| \ + X"$mf" : 'X\(//\)$' \| \ + X"$mf" : 'X\(/\)' \| . 2>/dev/null || +echo X"$mf" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + 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"` + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n 's/^U = //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' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`$as_dirname -- "$file" || +$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$file" : 'X\(//\)[^/]' \| \ + X"$file" : 'X\(//\)$' \| \ + X"$file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir=$dirpart/$fdir + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`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 || +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" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + + esac +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..a2831f6 --- /dev/null +++ b/configure.ac @@ -0,0 +1,42 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT([polyglot], [1.4w10UCIb15], [michel.vandenbergh@uhasselt.be]) +AM_INIT_AUTOMAKE +AC_CONFIG_SRCDIR([adapter.cpp]) +AC_CONFIG_HEADER([config.h]) + +# Checks for programs. +AC_PROG_CXX +AC_PROG_CC + +# Checks for libraries. +# FIXME: Replace `main' with a function in `-lm': +AC_CHECK_LIB([m], [sin]) + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([stdlib.h string.h sys/time.h unistd.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_CONST +AC_C_INLINE +AC_TYPE_PID_T +AC_TYPE_SIZE_T +AC_HEADER_TIME + +# Checks for library functions. +AC_FUNC_FORK +AC_FUNC_MALLOC +AC_FUNC_REALLOC +AC_FUNC_SELECT_ARGTYPES +AC_FUNC_SETVBUF_REVERSED +AC_TYPE_SIGNAL +AC_FUNC_VPRINTF +AC_CHECK_FUNCS([dup2 floor gettimeofday memchr memmove select strchr strdup strerror strstr]) + + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT diff --git a/debian/README b/debian/README new file mode 100644 index 0000000..74b7266 --- /dev/null +++ b/debian/README @@ -0,0 +1,6 @@ +The Debian Package polyglot +---------------------------- + +Comments regarding the Package + + -- Michel Van den Bergh Thu, 01 Jan 2009 21:32:12 +0100 diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..ed48ba3 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,75 @@ +polyglot (1.4w10UCIb15) unstable; urgency=low + + * bugfix : due to refactoring time stamps in Windows would be written twice. This has been fixed. + + * More refactoring; the number of #ifdef _WIN32's has again been drastically reduced. + + -- Michel Van den Bergh Sat, 10 Jan 2009 20:00:00 +0100 + +polyglot (1.4w10UCIb14) unstable; urgency=low + + * option to alter priority now also works on windows (Eric Mullins) + + * refactoring so that posix and win32 part share more code + + * a number of potential busy loop scenarios have been eliminated in the Windows code (Windows uses polling) + + * the return value of CreateProcess is now checked + + -- Michel Van den Bergh Fri, 09 Jan 2009 20:00:00 +0100 + +polyglot (1.4w10UCIb13) unstable; urgency=low + + * Perft mode exposed. + + -- Michel Van den Bergh Thu, 06 Jan 2009 20:00:00 +0100 + +polyglot (1.4w10UCIb12) unstable; urgency=low + + * Replaced %lld everywhere by S64_FORMAT. + + -- Michel Van den Bergh Thu, 06 Jan 2009 18:00:00 +0100 + +polyglot (1.4w10UCIb11) unstable; urgency=low + + * Crash bug fix (wrong parentheses in instruction that checked for help +option) + + -- Michel Van den Bergh Thu, 05 Jan 2009 18:00:00 +0100 + +polyglot (1.4w10UCIb10) unstable; urgency=low + + * Trivial bug fixes + + * It is now possible to do "make rpm" to make an rpm binary package. + + * Documentation added for epd-test functionality (man page). + + * Cosmetic cleanups of output of epd-test. + + * "polyglot --help" output added. + + * Added polyglot book format specification to distribution. + + + -- Michel Van den Bergh Thu, 02 Jan 2009 18:00:00 +0100 + +polyglot (1.4w10UCIb9) unstable; urgency=low + + * Trivial cosmetic fixes + + * Some engines do not support the Hash option. So we don't send memory=1 in that case. + + -- Michel Van den Bergh Thu, 02 Jan 2009 15:15:15 +0100 + +polyglot (1.4w10UCIb8) unstable; urgency=low + + * Support for egtpath command in xboard protocol + + -- Michel Van den Bergh Fri, 02 Jan 2009 11:10:23 +0100 + +polyglot (1.4w10UCIb7) unstable; urgency=low + + * Initial Release. + + -- Michel Van den Bergh Thu, 01 Jan 2009 21:32:12 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..d64fadf --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: polyglot +Section: games +Priority: extra +Maintainer: Michel Van den Bergh +Build-Depends: debhelper (>= 5), autotools-dev +Standards-Version: 3.7.2 + +Package: polyglot +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: A Winboard protocol to UCI protocol adapter + PolyGlot is a "UCI adapter". It connects a GUI interface (such as + XBoard, Winboard, Arena or Chessbase) to a UCI chess engine. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..e25c2e3 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,41 @@ +This package was debianized by Michel Van den Bergh on +Thu, 01 Jan 2009 21:32:12 +0100. + +It was downloaded from + +Upstream Authors: + + Fabien Letouzey + Huang Chen ("Morning Yellow") + Fonzy Bleumers + Michel Van den Bergh + +Copyright: + + Copyright (C) 2006 Fabien Letouzey + Copyright (C) 2006 Huang Chen + Copyright (C) 2009 Fonzy Bleumers + Copyright (C) 2009 Michel Van den Bergh + +License: + + This package 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 package 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 package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. + +The Debian packaging is (C) 2009, Michel Van den Bergh and +is licensed under the GPL, see above. + diff --git a/debian/docs b/debian/docs new file mode 100644 index 0000000..8acc481 --- /dev/null +++ b/debian/docs @@ -0,0 +1,6 @@ +NEWS +README +README1.3 +README1.4 +README1.4w +README1.4w10UCI diff --git a/debian/files b/debian/files new file mode 100644 index 0000000..6954ea7 --- /dev/null +++ b/debian/files @@ -0,0 +1 @@ +polyglot_1.4w10UCIb15_i386.deb games extra diff --git a/debian/polyglot.substvars b/debian/polyglot.substvars new file mode 100644 index 0000000..a5df8cc --- /dev/null +++ b/debian/polyglot.substvars @@ -0,0 +1 @@ +shlibs:Depends=libgcc1 , libstdc++6 (>= 4.1.1-21), libc6 (>= 2.4) diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..945f20f --- /dev/null +++ b/debian/rules @@ -0,0 +1,99 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + + +config.status: configure + dh_testdir + # Add here commands to configure the package. +ifneq "$(wildcard /usr/share/misc/config.sub)" "" + cp -f /usr/share/misc/config.sub config.sub +endif +ifneq "$(wildcard /usr/share/misc/config.guess)" "" + cp -f /usr/share/misc/config.guess config.guess +endif + ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info --bindir=\$${prefix}/games CFLAGS="$(CFLAGS)" LDFLAGS="-Wl,-z,defs" + + +build: build-stamp + +build-stamp: config.status + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + #docbook-to-man debian/polyglot.sgml > polyglot.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + # Add here commands to clean up after the build process. + [ ! -f Makefile ] || $(MAKE) distclean + rm -f config.sub config.guess + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/polyglot. + $(MAKE) DESTDIR=$(CURDIR)/debian/polyglot install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs ChangeLog + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/depcomp b/depcomp new file mode 100755 index 0000000..e5f9736 --- /dev/null +++ b/depcomp @@ -0,0 +1,589 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2007-03-29.01 + +# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software +# Foundation, Inc. + +# 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, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. + sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mechanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/engine.cpp b/engine.cpp new file mode 100644 index 0000000..b5429d9 --- /dev/null +++ b/engine.cpp @@ -0,0 +1,372 @@ +#ifndef _WIN32 + +// engine.cpp + +// includes + +#include +#include +#include +#include +#include + +#include +#include + +#include "engine.h" +#include "io.h" +#include "option.h" +#include "util.h" + + +// constants + +static const int StringSize = 4096; + +// variables + +engine_t Engine[1]; + +// prototypes + +static void my_close (int fd); +static void my_dup2 (int old_fd, int new_fd); + +// functions + +// engine_is_ok() + +bool engine_is_ok(const engine_t * engine) { + + if (engine == NULL) return false; + + if (!io_is_ok(engine->io)) return false; + + return true; +} + +// engine_open() + +void engine_open(engine_t * engine) { + + const char * dir, * command; + char string[StringSize]; + int argc; + char * ptr; + char * argv[256]; + int from_engine[2], to_engine[2]; + pid_t pid; + + ASSERT(engine!=NULL); + + // init + + dir = option_get_string("EngineDir"); + my_log("POLYGLOT Dir \"%s\"\n",dir); + + command = option_get_string("EngineCommand"); + my_log("POLYGLOT Command \"%s\"\n",command); + + // parse the command line and create the argument list + + if (strlen(command) >= StringSize) my_fatal("engine_open(): buffer overflow\n"); + strcpy(string,command); + + argc = 0; + + for (ptr = strtok(string," "); ptr != NULL; ptr = strtok(NULL," ")) { + argv[argc++] = ptr; + } + + argv[argc] = NULL; + + // create the pipes + + if (pipe(from_engine) == -1) { + my_fatal("engine_open(): pipe(): %s\n",strerror(errno)); + } + + if (pipe(to_engine) == -1) { + my_fatal("engine_open(): pipe(): %s\n",strerror(errno)); + } + + // create the child process + + pid = fork(); + + if (pid == -1) { + + my_fatal("engine_open(): fork(): %s\n",strerror(errno)); + + } else if (pid == 0) { + + // child = engine + + // close unused pipe descriptors to avoid deadlocks + + my_close(from_engine[0]); + my_close(to_engine[1]); + + // attach the pipe to standard input + + my_dup2(to_engine[0],STDIN_FILENO); + my_close(to_engine[0]); + + // attach the pipe to standard output + + my_dup2(from_engine[1],STDOUT_FILENO); + my_close(from_engine[1]); + + // attach standard error to standard output + + my_dup2(STDOUT_FILENO,STDERR_FILENO); + + // set a low priority + + if (option_get_bool("UseNice")) + { + my_log("POLYGLOT Adjust Engine Piority"); + nice(+option_get_int("NiceValue")); + } + + // change the current directory + + if (dir[0] != '\0' && chdir(dir) == -1) { + my_fatal("engine_open(): chdir(): %s\n",strerror(errno)); + } + + // launch the new executable file + + execvp(argv[0],&argv[0]); + + // execvp() only returns when an error has occured + + my_fatal("engine_open(): execvp(): %s\n",strerror(errno)); + + } else { // pid > 0 + + ASSERT(pid>0); + + // parent = PolyGlot + + // close unused pipe descriptors to avoid deadlocks + + my_close(from_engine[1]); + my_close(to_engine[0]); + + // fill in the engine struct + + engine->io->in_fd = from_engine[0]; + engine->io->out_fd = to_engine[1]; + engine->io->name = "Engine"; + + io_init(engine->io); + } +} + +// engine_close() + +void engine_close(engine_t * engine) { + + ASSERT(engine_is_ok(engine)); + + io_close(engine->io); +} + +// engine_get() + +void engine_get(engine_t * engine, char string[], int size) { + + ASSERT(engine_is_ok(engine)); + ASSERT(string!=NULL); + ASSERT(size>=256); + + while (!io_line_ready(engine->io)) { + io_get_update(engine->io); + } + + if (!io_get_line(engine->io,string,size)) { // EOF + my_log("POLYGLOT *** EOF from Engine ***\n"); + exit(EXIT_SUCCESS); + } +} + +// engine_send() + +void engine_send(engine_t * engine, const char format[], ...) { + + va_list arg_list; + char string[StringSize]; + + ASSERT(engine_is_ok(engine)); + ASSERT(format!=NULL); + + // format + + va_start(arg_list,format); + vsprintf(string,format,arg_list); + va_end(arg_list); + + // send + + io_send(engine->io,"%s",string); +} + +// engine_send_queue() + +void engine_send_queue(engine_t * engine, const char format[], ...) { + + va_list arg_list; + char string[StringSize]; + + ASSERT(engine_is_ok(engine)); + ASSERT(format!=NULL); + + // format + + va_start(arg_list,format); + vsprintf(string,format,arg_list); + va_end(arg_list); + + // send + + io_send_queue(engine->io,"%s",string); +} + +// my_close() + +static void my_close(int fd) { + + ASSERT(fd>=0); + + if (close(fd) == -1) my_fatal("my_close(): close(): %s\n",strerror(errno)); +} + +// my_dup2() + +static void my_dup2(int old_fd, int new_fd) { + + ASSERT(old_fd>=0); + ASSERT(new_fd>=0); + + if (dup2(old_fd,new_fd) == -1) my_fatal("my_dup2(): dup2(): %s\n",strerror(errno)); +} + +// end of posix part +#else + +// WIN32 part + +// includes + +#include +#include +#include +#include + + + +#include "engine.h" +#include "option.h" +#include "pipe.h" +#include "posix.h" + +// constants + +static const int StringSize = 4096; + +// variables + +static int nQueuePtr = 0; +static char szQueueString[StringSize]; +engine_t Engine[1]; + +// functions + +DWORD GetWin32Priority(int nice) +{ +/* +REALTIME_PRIORITY_CLASS 0x00000100 +HIGH_PRIORITY_CLASS 0x00000080 +ABOVE_NORMAL_PRIORITY_CLASS 0x00008000 +NORMAL_PRIORITY_CLASS 0x00000020 +BELOW_NORMAL_PRIORITY_CLASS 0x00004000 +IDLE_PRIORITY_CLASS 0x00000040 +*/ + if (nice < -15) return 0x00000080; + if (nice < 0) return 0x00008000; + if (nice == 0) return 0x00000020; + if (nice < 15) return 0x00004000; + return 0x00000040; +} + + + +void set_affinity(engine_t *engine, int affin){ + if(affin==-1) return; + SetProcessAffinityMask((engine->pipeEngine).hProcess,affin); +} + + + +void engine_send_queue(engine_t * engine,const char *szFormat, ...) { + nQueuePtr += vsprintf(szQueueString + nQueuePtr, szFormat, (va_list) (&szFormat + 1)); +} + +void engine_send(engine_t * engine, const char *szFormat, ...) { + vsprintf(szQueueString + nQueuePtr, szFormat, (va_list) (&szFormat + 1)); + (engine->pipeEngine).LineOutput(szQueueString); + my_log("Adapter->Engine: %s\n",szQueueString); + nQueuePtr = 0; +} + +void engine_close(engine_t * engine){ + (engine->pipeEngine).Close(); +} + + +void engine_open(engine_t * engine){ + int affinity; + char *my_dir; + if( (my_dir = _getcwd( NULL, 0 )) == NULL ) + my_fatal("Can't build path: %s\n",strerror(errno)); + SetCurrentDirectory(option_get_string("EngineDir")); + (engine->pipeEngine).Open(option_get_string("EngineCommand")); + //play with affinity (bad idea) + affinity=option_get_int("Affinity"); + if(affinity!=-1) set_affinity(engine,affinity); //AAA + //lets go back + SetCurrentDirectory(my_dir); + // set a low priority + if (option_get_bool("UseNice")){ + my_log("POLYGLOT Adjust Engine Piority\n"); + SetPriorityClass((engine->pipeEngine).hProcess, + GetWin32Priority(option_get_int("NiceValue"))); + } + +} + +bool engine_get_non_blocking(engine_t * engine, char *szLineStr, int size){ + if ((engine->pipeEngine).LineInput(szLineStr)) { + my_log("Engine->Adapter: %s\n",szLineStr); + return true; + } else { + szLineStr[0]='\0'; + return false; + } +} + +void engine_get(engine_t * engine, char *szLineStr, int size){ + bool data_available; + while(true){ + data_available=engine_get_non_blocking(engine,szLineStr,size); + if(!data_available){ + Idle(); + }else{ + break; + } + } +} + + +#endif diff --git a/engine.h b/engine.h new file mode 100644 index 0000000..deb9ad5 --- /dev/null +++ b/engine.h @@ -0,0 +1,39 @@ +// engine.h + +#ifndef ENGINE_H +#define ENGINE_H + +// includes + +#include "io.h" +#include "util.h" +#include "pipe.h" + +// types + +struct engine_t { +#ifndef _WIN32 + io_t io[1]; +#else + PipeStruct pipeEngine; +#endif +}; + + + +// variables + +extern engine_t Engine[1]; + +// functions + +extern bool engine_is_ok (const engine_t * engine); +extern void engine_open (engine_t * engine); +extern void engine_close (engine_t * engine); +extern void engine_send (engine_t * engine, const char format[], ...); +extern void engine_send_queue (engine_t * engine, const char format[], ...); +extern bool engine_get_non_blocking(engine_t * engine, char string[], int size); +extern void engine_get (engine_t * engine, char string[], int size); + + +#endif // !defined ENGINE_H diff --git a/epd.cpp b/epd.cpp new file mode 100644 index 0000000..18c5190 --- /dev/null +++ b/epd.cpp @@ -0,0 +1,444 @@ + +// epd.cpp + +// includes + +#include +#include +#include +#include + +#include "board.h" +#include "engine.h" +#include "epd.h" +#include "fen.h" +#include "line.h" +#include "main.h" +#include "move.h" +#include "move_legal.h" +#include "option.h" +#include "parse.h" +#include "san.h" +#include "uci.h" +#include "util.h" + +// constants + +static const bool UseDebug = false; +static const bool UseTrace = false; + +static const int StringSize = 4096; + +// variables + +static int MinDepth; +static int MaxDepth; + +static double MaxTime; +static double MinTime; + +static int DepthDelta; + +static int FirstMove; +static int FirstDepth; +static int FirstSelDepth; +static int FirstScore; +static double FirstTime; +static uint64 FirstNodeNb; +static move_t FirstPV[LineSize]; + +static int LastMove; +static int LastDepth; +static int LastSelDepth; +static int LastScore; +static double LastTime; +static uint64 LastNodeNb; +static move_t LastPV[LineSize]; + +// prototypes + +static void epd_test_file (const char file_name[]); + +static bool is_solution (int move, const board_t * board, const char bm[], const char am[]); +static bool string_contain (const char string[], const char substring[]); + +static bool engine_step (); + +// functions + +// epd_test() + +void epd_test(int argc, char * argv[]) { + + int i; + const char * epd_file; + + epd_file = NULL; + my_string_set(&epd_file,"wac.epd"); + + MinDepth = 8; + MaxDepth = 63; + + MinTime = 1.0; + MaxTime = 5.0; + + DepthDelta = 3; + + for (i = 1; i < argc; i++) { + + if (false) { + + } else if (my_string_equal(argv[i],"epd-test")) { + + // skip + + } else if (my_string_equal(argv[i],"-epd")) { + + i++; + if (argv[i] == NULL) my_fatal("epd_test(): missing argument\n"); + + my_string_set(&epd_file,argv[i]); + + } else if (my_string_equal(argv[i],"-min-depth")) { + + i++; + if (argv[i] == NULL) my_fatal("epd_test(): missing argument\n"); + + MinDepth = atoi(argv[i]); + + } else if (my_string_equal(argv[i],"-max-depth")) { + + i++; + if (argv[i] == NULL) my_fatal("epd_test(): missing argument\n"); + + MaxDepth = atoi(argv[i]); + + } else if (my_string_equal(argv[i],"-min-time")) { + + i++; + if (argv[i] == NULL) my_fatal("epd_test(): missing argument\n"); + + MinTime = atof(argv[i]); + + } else if (my_string_equal(argv[i],"-max-time")) { + + i++; + if (argv[i] == NULL) my_fatal("epd_test(): missing argument\n"); + + MaxTime = atof(argv[i]); + + } else if (my_string_equal(argv[i],"-depth-delta")) { + + i++; + if (argv[i] == NULL) my_fatal("epd_test(): missing argument\n"); + + DepthDelta = atoi(argv[i]); + + } else { + + my_fatal("epd_test(): unknown option \"%s\"\n",argv[i]); + } + } + + if(MinTime>MaxTime){ + MaxTime=MinTime; + } + + epd_test_file(epd_file); +} + +// epd_test_file() + +static void epd_test_file(const char file_name[]) { + + FILE * file; + int hit, tot; + char epd[StringSize]; + char am[StringSize], bm[StringSize], id[StringSize]; + board_t board[1]; + char string[StringSize]; + int move; + char pv_string[StringSize]; + bool correct; + double depth_tot, time_tot, node_tot; + int line=0; + + ASSERT(file_name!=NULL); + + // init + + file = fopen(file_name,"r"); + if (file == NULL) my_fatal("epd_test_file(): can't open file \"%s\": %s\n",file_name,strerror(errno)); + + hit = 0; + tot = 0; + + depth_tot = 0.0; + time_tot = 0.0; + node_tot = 0.0; + + printf("\nEngineName=%s\n",option_get_string("EngineName")); + + printf("\n[Search parameters: MaxDepth=%d MaxTime=%.1f DepthDelta=%d MinDepth=%d MinTime=%.1f]\n\n",MaxDepth,MaxTime,DepthDelta,MinDepth,MinTime); + + // loop + + while (my_file_read_line(file,epd,StringSize)) { + line++; + if(my_string_whitespace(epd)) continue; + if (UseTrace) printf("%s\n",epd); + + if (!epd_get_op(epd,"am",am,StringSize)) strcpy(am,""); + if (!epd_get_op(epd,"bm",bm,StringSize)) strcpy(bm,""); + if (!epd_get_op(epd,"id",id,StringSize)) strcpy(id,""); + + if (my_string_empty(am) && my_string_empty(bm)) { + my_fatal("epd_test(): no am or bm field at line %d\n",line); + } + + // init + + uci_send_ucinewgame(Uci); + uci_send_isready_sync(Uci); + + ASSERT(!Uci->searching); + + // position + if (!board_from_fen(board,epd)) ASSERT(false); + if (!board_to_fen(board,string,StringSize)) ASSERT(false); + + engine_send(Engine,"position fen %s",string); + + // search + + // which ones of the next two alternatives is best? + engine_send(Engine,"go movetime %.0f depth %d",MaxTime*1000.0,MaxDepth); + //engine_send(Engine,"go infinite"); + + // engine data + + board_copy(Uci->board,board); + + uci_clear(Uci); + Uci->searching = true; + Uci->pending_nb++; + + FirstMove = MoveNone; + FirstDepth = 0; + FirstSelDepth = 0; + FirstScore = 0; + FirstTime = 0.0; + FirstNodeNb = 0; + line_clear(FirstPV); + + LastMove = MoveNone; + LastDepth = 0; + LastSelDepth = 0; + LastScore = 0; + LastTime = 0.0; + LastNodeNb = 0; + line_clear(LastPV); + + // parse engine output + + while (engine_step()) { + bool stop=false; + // stop search? + + if (Uci->depth > MaxDepth){ + my_log("POLYGLOT Maximum depth %d reached\n",MaxDepth); + stop=true; + }else if(Uci->time >= MaxTime){ + my_log("POLYGLOT Maximum search time %.2fs reached\n",MaxTime); + stop=true; + }else if(Uci->depth - FirstDepth >= DepthDelta){ + my_log("POLYGLOT DepthDelta (=%d) reached\n",DepthDelta); + if(Uci->depth > MinDepth){ + my_log("POLYGLOT Minimum depth %d reached\n",MinDepth); + if(Uci->time >= MinTime){ + my_log("POLYGLOT Minimum search time %.2fs reached\n",MinTime); + if(is_solution(FirstMove,board,bm,am)){ + my_log("POLYGLOT Solution is correct\n"); + stop=true; + }else{ + my_log("POLYGLOT Solution is not correct\n"); + } + } + } + } + if(stop){ + my_log("POLYGLOT Stopping engine\n"); + engine_send(Engine,"stop"); + break; + } + } + + move = FirstMove; + correct = is_solution(move,board,bm,am); + + if (correct) hit++; + tot++; + + if (correct) { + depth_tot += double(FirstDepth); + time_tot += FirstTime; + node_tot += double(FirstNodeNb); + } + + printf("%2d: %-15s %s %4d",tot,id,correct?"OK":"--",hit); + + if (!line_to_san(LastPV,Uci->board,pv_string,StringSize)) ASSERT(false); + printf(" [at: depth=%2d time=%6.2f nodes="S64_FORMAT"] score=%+6.2f pv=%s\n",FirstDepth,FirstTime,FirstNodeNb,double(LastScore)/100.0,pv_string); + } + + printf("\nscore=%d/%d",hit,tot); + + if (hit != 0) { + + depth_tot /= double(hit); + time_tot /= double(hit); + node_tot /= double(hit); + + printf(" [averages on correct positions: depth=%.1f time=%.2f nodes=%.0f]",depth_tot,time_tot,node_tot); + } + + printf("\n"); + + fclose(file); + quit(); +} + +// is_solution() + +static bool is_solution(int move, const board_t * board, const char bm[], const char am[]) { + + char move_string[256]; + bool correct; + + ASSERT(move!=MoveNone); + ASSERT(bm!=NULL); + ASSERT(am!=NULL); + + if (!move_is_legal(move,board)) { + board_disp(board); + move_disp(move,board); + printf("\n\n"); + } + + ASSERT(move_is_legal(move,board)); + + if (!move_to_san(move,board,move_string,256)) ASSERT(false); + + correct = false; + if (!my_string_empty(bm)) { + correct = string_contain(bm,move_string); + } else if (!my_string_empty(am)) { + correct = !string_contain(am,move_string); + } else { + ASSERT(false); + } + + return correct; +} + +// epd_get_op() + +bool epd_get_op(const char record[], const char opcode[], char string[], int size) { + + char op[256]; + int len; + const char *p_start, *p_end; + + ASSERT(record!=NULL); + ASSERT(opcode!=NULL); + ASSERT(string!=NULL); + ASSERT(size>0); + + // find the opcode + + sprintf(op," %s ",opcode); + + p_start = strstr(record,op); + if (p_start == NULL){ + sprintf(op,";%s ",opcode); + p_start = strstr(record,op); + if (p_start == NULL){ + return false; + } + } + + // skip the opcode + + p_start += strlen(op); + + // find the end + p_end = strchr(p_start,';'); + if (p_end == NULL) return false; + + // calculate the length + + len = p_end - p_start; + if (size < len+1) my_fatal("epd_get_op(): size < len+1\n"); + + strncpy(string,p_start,len); + string[len] = '\0'; + + return true; +} + +// string_contain() + +static bool string_contain(const char string[], const char substring[]) { + + char new_string[StringSize], *p; + + strcpy(new_string,string); // HACK + + for (p = strtok(new_string," "); p != NULL; p = strtok(NULL," ")) { + if (my_string_equal(p,substring)) return true; + } + + return false; +} + +// engine_step() + +static bool engine_step() { + + char string[StringSize]; + int event; + + engine_get(Engine,string,StringSize); + event = uci_parse(Uci,string); + + if ((event & EVENT_MOVE) != 0) { + + return false; + } + + if ((event & EVENT_PV) != 0) { + + LastMove = Uci->best_pv[0]; + LastDepth = Uci->best_depth; + LastSelDepth = Uci->best_sel_depth; + LastScore = Uci->best_score; + LastTime = Uci->time; + LastNodeNb = Uci->node_nb; + line_copy(LastPV,Uci->best_pv); + + if (LastMove != FirstMove) { + FirstMove = LastMove; + FirstDepth = LastDepth; + FirstSelDepth = LastSelDepth; + FirstScore = LastScore; + FirstTime = LastTime; + FirstNodeNb = LastNodeNb; + line_copy(FirstPV,LastPV); + } + } + + return true; +} + +// end of epd.cpp + diff --git a/epd.h b/epd.h new file mode 100644 index 0000000..896879d --- /dev/null +++ b/epd.h @@ -0,0 +1,20 @@ + +// epd.h + +#ifndef EPD_H +#define EPD_H + +// includes + +#include "util.h" + +// functions + +extern void epd_test (int argc, char * argv[]); + +extern bool epd_get_op (const char record[], const char opcode[], char string[], int size); + +#endif // !defined EPD_H + +// end of epd.h + diff --git a/fen.cpp b/fen.cpp new file mode 100644 index 0000000..9f6f428 --- /dev/null +++ b/fen.cpp @@ -0,0 +1,392 @@ + +// fen.cpp + +// includes + +#include +#include +#include + +#include "board.h" +#include "colour.h" +#include "fen.h" +#include "option.h" +#include "piece.h" +#include "square.h" +#include "util.h" + +// "constants" + +// const char * StartFen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w HAha - 0 1"; +const char * StartFen = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1"; + +// variables + +static const bool Strict = false; + +// macros + +#define skip_white_space() \ + c=string[pos];\ + if (c != ' ' && c!='\t') my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); \ + while(c==' ' || c=='\t') c=string[++pos]; + + +// functions + +// board_from_fen() + +bool board_from_fen(board_t * board, const char string[]) { + + int pos; + int file, rank, sq; + int c; + int i, len; + int piece; + int king_pos[ColourNb]; + + ASSERT(board!=NULL); + ASSERT(string!=NULL); + + board_clear(board); + + king_pos[White] = SquareNone; + king_pos[Black] = SquareNone; + + pos = 0; + c = string[pos]; + + // piece placement + + for (rank = 7; rank >= 0; rank--) { + + for (file = 0; file < 8;) { + + sq = square_make(file,rank); + + if (c >= '1' && c <= '8') { // empty square(s) + + len = c - '0'; + if (file + len > 8) my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + + for (i = 0; i < len; i++) { + board->square[sq++] = Empty; + file++; + } + + } else { // piece + + piece = piece_from_char(c); + if (piece == PieceNone256) my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + + if (piece_is_king(piece)) king_pos[piece_colour(piece)] = sq; + + board->square[sq++] = piece; + file++; + } + + c = string[++pos]; + } + + if (rank > 0) { + if (c != '/') my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + c = string[++pos]; + } + } + + // active colour + + skip_white_space(); + + switch (c) { + case 'w': + board->turn = White; + break; + case 'b': + board->turn = Black; + break; + default: + my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + break; + } + + c = string[++pos]; + + // castling + + skip_white_space(); + + board->castle[White][SideH] = SquareNone; + board->castle[White][SideA] = SquareNone; + board->castle[Black][SideH] = SquareNone; + board->castle[Black][SideA] = SquareNone; + + if (c == '-') { // no castling rights + + c = string[++pos]; + + } else { + + // TODO: filter out illegal rights + + do { + + if (false) { + + } else if (c == 'K') { + + for (sq = H1; sq > king_pos[White]; sq--) { + if (board->square[sq] == WhiteRook256) { + board->castle[White][SideH] = sq; + break; + } + } + + } else if (c == 'Q') { + + for (sq = A1; sq < king_pos[White]; sq++) { + if (board->square[sq] == WhiteRook256) { + board->castle[White][SideA] = sq; + break; + } + } + + } else if (c == 'k') { + + for (sq = H8; sq > king_pos[Black]; sq--) { + if (board->square[sq] == BlackRook256) { + board->castle[Black][SideH] = sq; + break; + } + } + + } else if (c == 'q') { + + for (sq = A8; sq < king_pos[Black]; sq++) { + if (board->square[sq] == BlackRook256) { + board->castle[Black][SideA] = sq; + break; + } + } + + } else if (c >= 'A' && c <= 'H') { + + // white castling right + + sq = square_make(file_from_char(tolower(c)),Rank1); + + if (sq > king_pos[White]) { // h side + board->castle[White][SideH] = sq; + } else { // a side + board->castle[White][SideA] = sq; + } + + } else if (c >= 'a' && c <= 'h') { + + // black castling right + + sq = square_make(file_from_char(tolower(c)),Rank8); + + if (sq > king_pos[Black]) { // h side + board->castle[Black][SideH] = sq; + } else { // a side + board->castle[Black][SideA] = sq; + } + + } else { + + my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + } + + c = string[++pos]; + + } while (c != ' '); + } + + // en-passant + + skip_white_space(); + + if (c == '-') { // no en-passant + + sq = SquareNone; + c = string[++pos]; + + } else { + + if (c < 'a' || c > 'h') my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + file = file_from_char(c); + c = string[++pos]; + + if (c < '1' || c > '8') my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + rank = rank_from_char(c); + c = string[++pos]; + + sq = square_make(file,rank); + } + + board->ep_square = sq; + + // halfmove clock + + board->ply_nb = 0; + board->move_nb = 0; // HACK, in case of broken syntax + + if (c != ' ') { + if (!Strict) goto update; + my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + } + c = string[++pos]; + + if (!isdigit(c)) { + if (!Strict) goto update; + my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + } + + board->ply_nb = atoi(&string[pos]); + do c = string[++pos]; while (isdigit(c)); + + // fullmove number + + board->move_nb = 0; + + if (c != ' ') { + if (!Strict) goto update; + my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + } + c = string[++pos]; + + if (!isdigit(c)) { + if (!Strict) goto update; + my_fatal("board_from_fen(): bad FEN (pos=%d)\n",pos); + } + + board->move_nb = atoi(&string[pos]) - 1; + do c = string[++pos]; while (isdigit(c)); + + // board update + +update: + board_init_list(board); + + return true; +} + +// board_to_fen() + +bool board_to_fen(const board_t * board, char string[], int size) { + + int pos; + int file, rank; + int sq, piece; + int c; + int len; + int old_pos; + + ASSERT(board_is_ok(board)); + ASSERT(string!=NULL); + ASSERT(size>=92); + + // init + + if (size < 92) return false; + + pos = 0; + + // piece placement + + for (rank = 7; rank >= 0; rank--) { + + for (file = 0; file < 8;) { + + sq = square_make(file,rank); + piece = board->square[sq]; + ASSERT(piece==Empty||piece_is_ok(piece)); + + if (piece == Empty) { + + len = 0; + for (; file < 8 && board->square[square_make(file,rank)] == Empty; file++) { + len++; + } + + ASSERT(len>=1&&len<=8); + c = '0' + len; + + } else { + + c = piece_to_char(piece); + file++; + } + + string[pos++] = c; + } + + string[pos++] = '/'; + } + + string[pos-1] = ' '; // HACK: remove the last '/' + + // active colour + + string[pos++] = (colour_is_white(board->turn)) ? 'w' : 'b'; + string[pos++] = ' '; + + // castling + + old_pos = pos; + + if (option_get_bool("Chess960")) { + + // FEN-960 + + if (board->castle[White][SideH] != SquareNone) { + string[pos++] = toupper(file_to_char(square_file(board->castle[White][SideH]))); + } + + if (board->castle[White][SideA] != SquareNone) { + string[pos++] = toupper(file_to_char(square_file(board->castle[White][SideA]))); + } + + if (board->castle[Black][SideH] != SquareNone) { + string[pos++] = tolower(file_to_char(square_file(board->castle[Black][SideH]))); + } + + if (board->castle[Black][SideA] != SquareNone) { + string[pos++] = tolower(file_to_char(square_file(board->castle[Black][SideA]))); + } + + } else { + + // FEN + + if (board->castle[White][SideH] != SquareNone) string[pos++] = 'K'; + if (board->castle[White][SideA] != SquareNone) string[pos++] = 'Q'; + if (board->castle[Black][SideH] != SquareNone) string[pos++] = 'k'; + if (board->castle[Black][SideA] != SquareNone) string[pos++] = 'q'; + } + + if (pos == old_pos) string[pos++] = '-'; + + string[pos++] = ' '; + + // en-passant + + if (board->ep_square == SquareNone) { + string[pos++] = '-'; + } else { + if (!square_to_string(board->ep_square,&string[pos],3)) return false; + pos += 2; + } + + string[pos++] = ' '; + + // halfmove clock and fullmove number + + sprintf(&string[pos],"%d %d",board->ply_nb,board->move_nb+1); + + return true; +} + +// end of fen.cpp + diff --git a/fen.h b/fen.h new file mode 100644 index 0000000..fe5183e --- /dev/null +++ b/fen.h @@ -0,0 +1,24 @@ + +// fen.h + +#ifndef FEN_H +#define FEN_H + +// includes + +#include "board.h" +#include "util.h" + +// "constants" + +extern const char * StartFen; + +// functions + +extern bool board_from_fen (board_t * board, const char string[]); +extern bool board_to_fen (const board_t * board, char string[], int size); + +#endif // !defined FEN_H + +// end of fen.h + diff --git a/game.cpp b/game.cpp new file mode 100644 index 0000000..703fa2d --- /dev/null +++ b/game.cpp @@ -0,0 +1,355 @@ + +// game.cpp + +// includes + +#include "attack.h" +#include "board.h" +#include "fen.h" +#include "game.h" +#include "list.h" +#include "move.h" +#include "move_do.h" +#include "move_legal.h" +#include "piece.h" +#include "square.h" +#include "util.h" + +// constants + +static const bool UseSlowDebug = false; + +// variables + +game_t Game[1]; + +// prototypes + +static void game_update (game_t * game); +static int game_comp_status (const game_t * game); + +// functions + +// game_is_ok() + +bool game_is_ok(const game_t * game) { + + board_t board[1]; + int pos, move; + + if (game == NULL) return false; + + if (game->size < 0 || game->size > GameSize) return false; + if (game->pos < 0 || game->pos > game->size) return false; + + // optional heavy DEBUG mode + + if (!UseSlowDebug) return true; + + if (!board_is_ok(game->start_board)) return false; + + board_copy(board,game->start_board); + + for (pos = 0; pos <= game->size; pos++) { + + if (pos == game->pos) { + if (!board_equal(game->board,board)) return false; + } + + if (pos >= game->size) break; + + if (game->key[pos] != board->key) return false; + + move = game->move[pos]; + //if (!move_is_legal(move,board)); //huh?? + if (!move_is_legal(move,board)) return false; + + move_do(board,move); + } + + if (game->status != game_comp_status(game)) return false; + + return true; +} + +// game_clear() + +void game_clear(game_t * game) { + + ASSERT(game!=NULL); + + game_init(game,StartFen); +} + +// game_init() + +bool game_init(game_t * game, const char fen[]) { + + ASSERT(game!=NULL); + ASSERT(fen!=NULL); + + if (!board_from_fen(game->start_board,fen)) return false; + + game->size = 0; + + board_copy(game->board,game->start_board); + game->pos = 0; + + game_update(game); + + return true; +} + +// game_status() + +int game_status(const game_t * game) { + + ASSERT(game!=NULL); + + return game->status; +} + +// game_size() + +int game_size(const game_t * game) { + + ASSERT(game!=NULL); + + return game->size; +} + +// game_pos() + +int game_pos(const game_t * game) { + + ASSERT(game!=NULL); + + return game->pos; +} + +// game_move() + +int game_move(const game_t * game, int pos) { + + ASSERT(game!=NULL); + ASSERT(pos>=0&&pospos); + + return game->move[pos]; +} + +// game_get_board() + +void game_get_board(const game_t * game, board_t * board, int pos) { + + int start; + int i; + + ASSERT(game!=NULL); + ASSERT(board!=NULL); + ASSERT(pos==-1||(pos>=0&&pos<=game->size)); // HACK + + if (pos < 0) pos = game->pos; + + if (pos >= game->pos) { // forward from current position + start = game->pos; + board_copy(board,game->board); + } else { // backward => replay the whole game + start = 0; + board_copy(board,game->start_board); + } + + for (i = start; i < pos; i++) move_do(board,game->move[i]); +} + +// game_turn() + +int game_turn(const game_t * game) { + + ASSERT(game!=NULL); + + return game->board->turn; +} + +// game_move_nb() + +int game_move_nb(const game_t * game) { + + ASSERT(game!=NULL); + + return game->board->move_nb; +} + +// game_add_move() + +void game_add_move(game_t * game, int move) { + + ASSERT(game!=NULL); + ASSERT(move_is_ok(move)); + + ASSERT(move_is_legal(move,game->board)); + + if (game->pos >= GameSize) my_fatal("game_add_move(): game overflow\n"); + + game->move[game->pos] = move; + game->key[game->pos] = game->board->key; + + move_do(game->board,move); + game->pos++; + + game->size = game->pos; // truncate game, HACK: before calling game_is_ok() in game_update() + + game_update(game); +} + +// game_rem_move() + +void game_rem_move(game_t * game) { + + ASSERT(game!=NULL); + + game_goto(game,game->pos-1); + + game->size = game->pos; // truncate game +} + +// game_goto() + +void game_goto(game_t * game, int pos) { + + int i; + + ASSERT(game!=NULL); + ASSERT(pos>=0&&pos<=game->size); + + if (pos < game->pos) { // going backward => replay the whole game + board_copy(game->board,game->start_board); + game->pos = 0; + } + + for (i = game->pos; i < pos; i++) move_do(game->board,game->move[i]); + ASSERT(i==pos); + + game->pos = pos; + + game_update(game); +} + +// game_disp() + +void game_disp(const game_t * game) { + + board_t board[1]; + int i, move; + + ASSERT(game_is_ok(game)); + + board_copy(board,game->start_board); + + board_disp(board); + + for (i = 0; i < game->pos; i++) { + + move = game->move[i]; + move_disp(move,board); + + move_do(board,move); + } + + my_log("POLYGLOT\n"); + + board_disp(board); +} + +// game_update() + +static void game_update(game_t * game) { + + ASSERT(game!=NULL); + + game->status = game_comp_status(game); + + ASSERT(game_is_ok(game)); +} + +// game_comp_status() + +static int game_comp_status(const game_t * game) { + + int i, n; + int wb, bb; + const board_t * board; + uint64 key; + int start; + + ASSERT(game!=NULL); + + // init + + board = game->board; + + // mate and stalemate + + if (!board_can_play(board)) { + if (false) { + } else if (is_in_check(board,Black)) { // HACK + return WHITE_MATES; + } else if (is_in_check(board,White)) { // HACK + return BLACK_MATES; + } else { + return STALEMATE; + } + } + + // insufficient material + + if (board->number[WhitePawn12] == 0 + && board->number[BlackPawn12] == 0 + && board->number[WhiteQueen12] == 0 + && board->number[BlackQueen12] == 0 + && board->number[WhiteRook12] == 0 + && board->number[BlackRook12] == 0) { + + if (board->number[WhiteBishop12] + + board->number[BlackBishop12] + + board->number[WhiteKnight12] + + board->number[BlackKnight12] <= 1) { // KK, KBK and KNK + + return DRAW_MATERIAL; + + } else if (board->number[WhiteBishop12] == 1 + && board->number[BlackBishop12] == 1 + && board->number[WhiteKnight12] == 0 + && board->number[BlackKnight12] == 0) { + + wb = board->list[White][1]; // HACK + bb = board->list[Black][1]; // HACK + + if (square_colour(wb) == square_colour(bb)) { // KBKB + return DRAW_MATERIAL; + } + } + } + + // 50-move rule + + if (board->ply_nb >= 100) return DRAW_FIFTY; + + // position repetition + + key = board->key; + n = 0; + + start = game->pos - board->ply_nb; + if (start < 0) start = 0; + + for (i = game->pos-4; i >= start; i -= 2) { + if (game->key[i] == key) { + if (++n == 2) return DRAW_REPETITION; + } + } + + return PLAYING; +} + +// end of game.cpp + diff --git a/game.h b/game.h new file mode 100644 index 0000000..ec50ab2 --- /dev/null +++ b/game.h @@ -0,0 +1,70 @@ + +// game.h + +#ifndef GAME_H +#define GAME_H + +// includes + +#include "board.h" +#include "move.h" +#include "util.h" + +// constants + +const int GameSize = 4096; + +enum status_t { + PLAYING, + WHITE_MATES, + BLACK_MATES, + STALEMATE, + DRAW_MATERIAL, + DRAW_FIFTY, + DRAW_REPETITION +}; + +// types + +struct game_t { + board_t start_board[1]; + board_t board[1]; + sint16 size; + sint16 pos; + sint8 status; + move_t move[GameSize]; + uint64 key[GameSize]; +}; + +// variables + +extern game_t Game[1]; + +// functions + +extern bool game_is_ok (const game_t * game); + +extern void game_clear (game_t * game); +extern bool game_init (game_t * game, const char fen[]); + +extern int game_status (const game_t * game); + +extern int game_size (const game_t * game); +extern int game_pos (const game_t * game); +extern int game_move (const game_t * game, int pos); + +extern void game_get_board (const game_t * game, board_t * board, int pos = -1); +extern int game_turn (const game_t * game); +extern int game_move_nb (const game_t * game); + +extern void game_add_move (game_t * game, int move); +extern void game_rem_move (game_t * game); + +extern void game_goto (game_t * game, int pos); + +extern void game_disp (const game_t * game); + +#endif // !defined GAME_H + +// end of game.h + diff --git a/gui.cpp b/gui.cpp new file mode 100644 index 0000000..b80f576 --- /dev/null +++ b/gui.cpp @@ -0,0 +1,106 @@ +// gui.cpp + +// includes + +#include + +#include "gui.h" +#include "main.h" + +// constants + +static const int StringSize = 4096; + +// variables + +gui_t GUI[1]; + +// functions + + +// gui_init() + +void gui_init(gui_t *gui){ + #ifdef _WIN32 + (gui->pipeStdin).Open(); +#else + // xboard + + gui->io->in_fd = STDIN_FILENO; + gui->io->out_fd = STDOUT_FILENO; + gui->io->name = "GUI"; + + io_init(gui->io); +#endif +} + + +// gui_get_non_blocking() + +// this is only non_blocking on windows! + +bool gui_get_non_blocking(gui_t * gui, char string[], int size) { + + ASSERT(xboard!=NULL); + ASSERT(string!=NULL); + ASSERT(size>=256); +#ifndef _WIN32 + if (!io_get_line(gui->io,string,size)) { // EOF + my_log("POLYGLOT *** EOF from GUI ***\n"); + quit(); + } + return true; +#else + if ((gui->pipeStdin).LineInput(string)) { + my_log("GUI->Adapter: %s\n", string); + return true; + } else { + string[0]='\0'; + return false; + } + +#endif +} + +// gui_get() + +void gui_get(gui_t * gui, char string[], int size) { + bool data_available; + while(true){ + data_available=gui_get_non_blocking(gui, string, size); + if(!data_available){ + Idle(); + }else{ + break; + } + } +} + + +// gui_send() + +void gui_send(gui_t * gui, const char format[], ...) { + + va_list arg_list; + char string[StringSize]; + + ASSERT(xboard!=NULL); + ASSERT(format!=NULL); + + // format + + va_start(arg_list,format); + vsprintf(string,format,arg_list); + va_end(arg_list); + + // send + +#ifndef _WIN32 + io_send(gui->io,"%s",string); +#else + printf("%s\n",string); + fflush(stdout); + my_log("Adapter->GUI: %s\n",string); +#endif +} + diff --git a/gui.h b/gui.h new file mode 100644 index 0000000..b984603 --- /dev/null +++ b/gui.h @@ -0,0 +1,31 @@ +// gui.h + +#ifndef GUI_H +#define GUI_H + +// includes + +#include "pipe.h" +#include "io.h" + +struct gui_t { +#ifndef _WIN32 + io_t io[1]; +#else + PipeStruct pipeStdin; +#endif +}; + +// variables + +extern gui_t GUI[1]; + +// functions + +extern void gui_init(gui_t * gui); +extern void gui_send(gui_t * gui, const char format[], ...); +extern void gui_get (gui_t * gui, char string[], int size); +extern bool gui_get_non_blocking (gui_t * gui, char string[], int size); + + +#endif diff --git a/hash.cpp b/hash.cpp new file mode 100644 index 0000000..490a5a3 --- /dev/null +++ b/hash.cpp @@ -0,0 +1,128 @@ + +// hash.cpp + +// includes + +#include "board.h" +#include "hash.h" +#include "piece.h" +#include "random.h" +#include "square.h" +#include "util.h" + +// variables + +static uint64 Castle64[16]; + +// prototypes + +static uint64 hash_castle_key_debug (int flags); + +// functions + +// hash_init() + +void hash_init() { + + int i; + + for (i = 0; i < 16; i++) Castle64[i] = hash_castle_key_debug(i); +} + +// hash_key() + +uint64 hash_key(const board_t * board) { + + uint64 key; + int colour; + const uint8 * ptr; + int sq, piece; + + ASSERT(board_is_ok(board)); + + // init + + key = 0; + + // pieces + + for (colour = 1; colour <= 2; colour++) { // HACK + for (ptr = board->list[colour]; (sq=*ptr) != SquareNone; ptr++) { + piece = board->square[sq]; + key ^= hash_piece_key(piece,sq); + } + } + + // castle flags + + key ^= hash_castle_key(board_flags(board)); + + // en-passant square + + sq = board->ep_square; + if (sq != SquareNone) key ^= hash_ep_key(sq); + + // turn + + key ^= hash_turn_key(board->turn); + + return key; +} + +// hash_piece_key() + +uint64 hash_piece_key(int piece, int square) { + + ASSERT(piece_is_ok(piece)); + ASSERT(square_is_ok(square)); + + return random_64(RandomPiece+piece_to_12(piece)*64+square_to_64(square)); +} + +// hash_castle_key() + +uint64 hash_castle_key(int flags) { + + ASSERT((flags&~0xF)==0); + + return Castle64[flags]; +} + +// hash_castle_key_debug() + +static uint64 hash_castle_key_debug(int flags) { + + uint64 key; + int i; + + ASSERT((flags&~0xF)==0); + + key = 0; + + for (i = 0; i < 4; i++) { + if ((flags & (1<&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/io.cpp b/io.cpp new file mode 100644 index 0000000..0a9345d --- /dev/null +++ b/io.cpp @@ -0,0 +1,335 @@ +#ifndef _WIN32 + +// io.cpp + +// includes + +#include +#include +#include +#include +#include + +#include +#include + +#include "io.h" +#include "util.h" + +// constants + +static const bool UseDebug = false; +static const bool UseCR = false; + +static const int StringSize = 4096; + +static const char LF = '\n'; +static const char CR = '\r'; + +// prototypes + +static int my_read (int fd, char string[], int size); +static void my_write (int fd, const char string[], int size); + +// functions + +// io_is_ok() + +bool io_is_ok(const io_t * io) { + + if (io == NULL) return false; + + if (io->name == NULL) return false; + + if (io->in_eof != true && io->in_eof != false) return false; + + if (io->in_size < 0 || io->in_size > BufferSize) return false; + if (io->out_size < 0 || io->out_size > BufferSize) return false; + + return true; +} + +// io_init() + +void io_init(io_t * io) { + + ASSERT(io!=NULL); + + io->in_eof = false; + + io->in_size = 0; + io->out_size = 0; + + ASSERT(io_is_ok(io)); +} + +// io_close() + +void io_close(io_t * io) { + + ASSERT(io_is_ok(io)); + + ASSERT(io->out_fd>=0); + + my_log("> %s EOF\n",io->name); + + if (close(io->out_fd) == -1) { + my_fatal("io_close(): close(): %s\n",strerror(errno)); + } + + io->out_fd = -1; +} + +// io_get_update() + +void io_get_update(io_t * io) { + + int pos, size; + int n; + + ASSERT(io_is_ok(io)); + + ASSERT(io->in_fd>=0); + ASSERT(!io->in_eof); + + // init + + pos = io->in_size; + + size = BufferSize - pos; + if (size <= 0) my_fatal("io_get_update(): buffer overflow\n"); + + // read as many data as possible + + n = my_read(io->in_fd,&io->in_buffer[pos],size); + if (UseDebug) my_log("POLYGLOT read %d byte%s from %s\n",n,(n>1)?"s":"",io->name); + + if (n > 0) { // at least one character was read + + // update buffer size + + ASSERT(n>=1&&n<=size); + + io->in_size += n; + ASSERT(io->in_size>=0&&io->in_size<=BufferSize); + + } else { // EOF + + ASSERT(n==0); + + io->in_eof = true; + } +} + +// io_line_ready() + +bool io_line_ready(const io_t * io) { + + ASSERT(io_is_ok(io)); + + if (io->in_eof) return true; + + if (memchr(io->in_buffer,LF,io->in_size) != NULL) return true; // buffer contains LF + + return false; +} + +// io_get_line() + +bool io_get_line(io_t * io, char string[], int size) { + + int src, dst; + int c; + + ASSERT(io_is_ok(io)); + ASSERT(string!=NULL); + ASSERT(size>=256); + + src = 0; + dst = 0; + + while (true) { + + // test for end of buffer + + if (src >= io->in_size) { + if (io->in_eof) { + my_log("%s->Adapter: EOF\n",io->name); + return false; + } else { + my_fatal("io_get_line(): no EOL in buffer\n"); + } + } + + // test for end of string + + if (dst >= size) my_fatal("io_get_line(): buffer overflow\n"); + + // copy the next character + + c = io->in_buffer[src++]; + + if (c == LF) { // LF => line complete + string[dst] = '\0'; + break; + } else if (c != CR) { // skip CRs + string[dst++] = c; + } + } + + // shift the buffer + + ASSERT(src>0); + + io->in_size -= src; + ASSERT(io->in_size>=0); + + if (io->in_size > 0) memmove(&io->in_buffer[0],&io->in_buffer[src],io->in_size); + + // return + + my_log("%s->Adapter: %s\n",io->name,string); + + return true; +} + +// io_send() + +void io_send(io_t * io, const char format[], ...) { + + va_list arg_list; + char string[StringSize]; + int len; + + ASSERT(io_is_ok(io)); + ASSERT(format!=NULL); + + ASSERT(io->out_fd>=0); + + // format + + va_start(arg_list,format); + vsprintf(string,format,arg_list); + va_end(arg_list); + + // append string to buffer + + len = strlen(string); + if (io->out_size + len > BufferSize-2) my_fatal("io_send(): buffer overflow\n"); + + memcpy(&io->out_buffer[io->out_size],string,len); + io->out_size += len; + + ASSERT(io->out_size>=0&&io->out_size<=BufferSize-2); + + // log + + io->out_buffer[io->out_size] = '\0'; + my_log("Adapter->%s: %s\n",io->name,io->out_buffer); +// my_log("> %f %s %s\n",now_real(),io->name,io->out_buffer); + // append EOL to buffer + + if (UseCR) io->out_buffer[io->out_size++] = CR; + io->out_buffer[io->out_size++] = LF; + + ASSERT(io->out_size>=0&&io->out_size<=BufferSize); + + // flush buffer + + if (UseDebug) my_log("POLYGLOT writing %d byte%s to %s\n",io->out_size,(io->out_size>1)?"s":"",io->name); + my_write(io->out_fd,io->out_buffer,io->out_size); + + io->out_size = 0; +} + +// io_send_queue() + +void io_send_queue(io_t * io, const char format[], ...) { + + va_list arg_list; + char string[StringSize]; + int len; + + ASSERT(io_is_ok(io)); + ASSERT(format!=NULL); + + ASSERT(io->out_fd>=0); + + // format + + va_start(arg_list,format); + vsprintf(string,format,arg_list); + va_end(arg_list); + + // append string to buffer + + len = strlen(string); + if (io->out_size + len > BufferSize-2) my_fatal("io_send_queue(): buffer overflow\n"); + + memcpy(&io->out_buffer[io->out_size],string,len); + io->out_size += len; + + ASSERT(io->out_size>=0&&io->out_size<=BufferSize-2); +} + +// my_read() + +static int my_read(int fd, char string[], int size) { + + int n; + + ASSERT(fd>=0); + ASSERT(string!=NULL); + ASSERT(size>0); + + do { + n = read(fd,string,size); + } while (n == -1 && errno == EINTR); + + if (n == -1) my_fatal("my_read(): read(): %s\n",strerror(errno)); + + ASSERT(n>=0); + + return n; +} + +// my_write() + +static void my_write(int fd, const char string[], int size) { + + int n; + + ASSERT(fd>=0); + ASSERT(string!=NULL); + ASSERT(size>0); + + do { + + n = write(fd,string,size); + + // if (n == -1 && errno != EINTR && errno != EPIPE) my_fatal("my_write(): write(): %s\n",strerror(errno)); + + if (n == -1) { + if (false) { + } else if (errno == EINTR) { + n = 0; // nothing has been written + } else if (errno == EPIPE) { + n = size; // pretend everything has been written + } else { + my_fatal("my_write(): write(): %s\n",strerror(errno)); + } + } + + ASSERT(n>=0); + + string += n; + size -= n; + + } while (size > 0); + + ASSERT(size==0); +} + +// end of io.cpp + +#endif diff --git a/io.h b/io.h new file mode 100644 index 0000000..ed470d6 --- /dev/null +++ b/io.h @@ -0,0 +1,51 @@ + +// io.h + +#ifndef IO_H +#define IO_H + +// includes + +#include "util.h" + +// constants + +const int BufferSize = 16384; + +// types + +struct io_t { + + int in_fd; + int out_fd; + + const char * name; + + bool in_eof; + + sint32 in_size; + sint32 out_size; + + char in_buffer[BufferSize]; + char out_buffer[BufferSize]; +}; + +// functions + +extern bool io_is_ok (const io_t * io); + +extern void io_init (io_t * io); +extern void io_close (io_t * io); + +extern void io_get_update (io_t * io); + +extern bool io_line_ready (const io_t * io); +extern bool io_get_line (io_t * io, char string[], int size); + +extern void io_send (io_t * io, const char format[], ...); +extern void io_send_queue (io_t * io, const char format[], ...); + +#endif // !defined IO_H + +// end of io.h + diff --git a/line.cpp b/line.cpp new file mode 100644 index 0000000..db62926 --- /dev/null +++ b/line.cpp @@ -0,0 +1,205 @@ + +// line.cpp + +// includes + +#include + +#include "board.h" +#include "line.h" +#include "move.h" +#include "move_do.h" +#include "move_legal.h" +#include "san.h" +#include "util.h" + +// constants + +static const bool Strict = false; // false +static const bool UseDebug = false; // false + +static const int StringSize = 1024; + +// functions + +// line_is_ok() + +bool line_is_ok(const move_t line[]) { + + int move; + + if (line == NULL) return false; + + while ((move = *line++) != MoveNone) { + if (!move_is_ok(move)) return false; + } + + return true; +} + +// line_clear() + +void line_clear(move_t line[]) { + + ASSERT(line!=NULL); + + *line = MoveNone; +} + +// line_copy() + +void line_copy(move_t dst[], const move_t src[]) { + + ASSERT(dst!=NULL); + ASSERT(src!=NULL); + + ASSERT(dst!=src); + + while ((*dst++ = *src++) != MoveNone) + ; +} + +// line_from_can() + +bool line_from_can (move_t line[], const board_t * board, const char string[], int size) { + + int pos; + char new_string[StringSize], *p; + int move; + board_t new_board[1]; + + ASSERT(line!=NULL); + ASSERT(board_is_ok(board)); + ASSERT(string!=NULL); + ASSERT(size>=LineSize); + + // init + + pos = 0; + board_copy(new_board,board); + + // loop + + strcpy(new_string,string); // HACK + + for (p = strtok(new_string," "); p != NULL; p = strtok(NULL," ")) { + + move = move_from_can(p,new_board); + + ASSERT(move!=MoveNone); + ASSERT(move_is_legal(move,new_board)); + + if (move == MoveNone || !move_is_legal(move,new_board)) break; // HACK: ignore illegal moves + + if (pos >= size) return false; + line[pos++] = move; + + move_do(new_board,move); + } + + if (pos >= size) return false; + line[pos] = MoveNone; + + return true; +} + +// line_to_can() + +bool line_to_can(const move_t line[], const board_t * board, char string[], int size) { + + board_t new_board[1]; + int pos; + int move; + + ASSERT(line_is_ok(line)); + ASSERT(board_is_ok(board)); + ASSERT(string!=NULL); + ASSERT(size>=StringSize); + + // init + + if (size < StringSize) return false; + + board_copy(new_board,board); + pos = 0; + + // loop + + while ((move = *line++) != MoveNone) { + + if (pos != 0) { + if (pos >= size) return false; + string[pos++] = ' '; + } + + if (!move_to_can(move,new_board,&string[pos],size-pos)) return false; + pos += strlen(&string[pos]); + + move_do(new_board,move); + } + + if (pos >= size) return false; + string[pos] = '\0'; + + return true; +} + +// line_to_san() + +bool line_to_san(const move_t line[], const board_t * board, char string[], int size) { + + board_t new_board[1]; + int pos; + int move; + char move_string[256]; + + ASSERT(line_is_ok(line)); + ASSERT(board_is_ok(board)); + ASSERT(string!=NULL); + ASSERT(size>=StringSize); + + // init + + if (size < StringSize) return false; + + board_copy(new_board,board); + pos = 0; + + // loop + + while ((move = *line++) != MoveNone) { + + if (pos != 0) { + if (pos >= size) return false; + string[pos++] = ' '; + } + + if (!move_is_legal(move,new_board) + || !move_to_san(move,new_board,&string[pos],size-pos)) { + + if (Strict || UseDebug) { + + move_to_can(move,new_board,move_string,256); + my_log("POLYGLOT ILLEGAL MOVE IN LINE %s\n",move_string); + + board_disp(new_board); + } + + if (Strict) my_fatal("line_to_san(): illegal move\n"); + + break; + } + + pos += strlen(&string[pos]); + + move_do(new_board,move); + } + + if (pos >= size) return false; + string[pos] = '\0'; + + return true; +} + +// end of line.cpp + diff --git a/line.h b/line.h new file mode 100644 index 0000000..b41eed8 --- /dev/null +++ b/line.h @@ -0,0 +1,32 @@ + +// line.h + +#ifndef LINE_H +#define LINE_H + +// includes + +#include "board.h" +#include "move.h" +#include "util.h" + +// constants + +const int LineSize = 256; + +// functions + +extern bool line_is_ok (const move_t line[]); + +extern void line_clear (move_t line[]); +extern void line_copy (move_t dst[], const move_t src[]); + +extern bool line_from_can (move_t line[], const board_t * board, const char string[], int size); + +extern bool line_to_can (const move_t line[], const board_t * board, char string[], int size); +extern bool line_to_san (const move_t line[], const board_t * board, char string[], int size); + +#endif // !defined LINE_H + +// end of line.h + diff --git a/list.cpp b/list.cpp new file mode 100644 index 0000000..040d7ea --- /dev/null +++ b/list.cpp @@ -0,0 +1,269 @@ + +// list.cpp + +// includes + +#include "board.h" +#include "list.h" +#include "move.h" +#include "util.h" + +// functions + +// list_is_ok() + +bool list_is_ok(const list_t * list) { + + if (list == NULL) return false; + + if (list->size >= ListSize) return false; + + return true; +} + +// list_clear() + +void list_clear(list_t * list) { + + ASSERT(list!=NULL); + + list->size = 0; +} + +// list_add() + +void list_add(list_t * list, int move, int value) { + + ASSERT(list_is_ok(list)); + ASSERT(move_is_ok(move)); + ASSERT(value>=-32767&&value<=+32767); + + ASSERT(list->sizemove[list->size] = move; + list->value[list->size] = value; + list->size++; +} + +// list_remove() + +void list_remove(list_t * list, int index) { + + int i; + + ASSERT(list_is_ok(list)); + ASSERT(index>=0&&indexsize); + + for (i = index; i < list->size-1; i++) { + list->move[i] = list->move[i+1]; + list->value[i] = list->value[i+1]; + } + + list->size--; +} + +// list_is_empty() + +bool list_is_empty(const list_t * list) { + + ASSERT(list_is_ok(list)); + + return list->size == 0; +} + +// list_size() + +int list_size(const list_t * list) { + + ASSERT(list_is_ok(list)); + + return list->size; +} + +// list_move() + +int list_move(const list_t * list, int index) { + + ASSERT(list_is_ok(list)); + ASSERT(index>=0&&indexsize); + + return list->move[index]; +} + +// list_value() + +int list_value(const list_t * list, int index) { + + ASSERT(list_is_ok(list)); + ASSERT(index>=0&&indexsize); + + return list->value[index]; +} + +// list_copy() + +void list_copy(list_t * dst, const list_t * src) { + + int i; + + ASSERT(dst!=NULL); + ASSERT(list_is_ok(src)); + + dst->size = src->size; + + for (i = 0; i < src->size; i++) { + dst->move[i] = src->move[i]; + dst->value[i] = src->value[i]; + } +} + +// list_move_to_front() + +void list_move_to_front(list_t * list, int index) { + + int i; + int move, value; + + ASSERT(list_is_ok(list)); + ASSERT(index>=0&&indexsize); + + if (index != 0) { + + move = list->move[index]; + value = list->value[index]; + + for (i = index; i > 0; i--) { + list->move[i] = list->move[i-1]; + list->value[i] = list->value[i-1]; + } + + list->move[0] = move; + list->value[0] = value; + } +} + +// list_note() + +void list_note(list_t * list) { + + int i, move; + + ASSERT(list_is_ok(list)); + + for (i = 0; i < list->size; i++) { + move = list->move[i]; + ASSERT(move_is_ok(move)); + list->value[i] = -move_order(move); + } +} + +// list_sort() + +void list_sort(list_t * list) { + + int i, j; + int best_index, best_move, best_value; + + ASSERT(list_is_ok(list)); + + for (i = 0; i < list->size-1; i++) { + + best_index = i; + best_value = list->value[i]; + + for (j = i+1; j < list->size; j++) { + if (list->value[j] > best_value) { + best_index = j; + best_value = list->value[j]; + } + } + + if (best_index != i) { + + best_move = list->move[best_index]; + ASSERT(best_value==list->value[best_index]); + + for (j = best_index; j > i; j--) { + list->move[j] = list->move[j-1]; + list->value[j] = list->value[j-1]; + } + + list->move[i] = best_move; + list->value[i] = best_value; + } + } + + if (DEBUG) { + for (i = 0; i < list->size-1; i++) { + ASSERT(list->value[i]>=list->value[i+1]); + } + } +} + +// list_contain() + +bool list_contain(const list_t * list, int move) { + + int i; + + ASSERT(list_is_ok(list)); + ASSERT(move_is_ok(move)); + + for (i = 0; i < list->size; i++) { + if (list->move[i] == move) return true; + } + + return false; +} + +// list_equal() + +bool list_equal(list_t * list_1, list_t * list_2) { + + list_t copy_1[1], copy_2[1]; + int i; + + ASSERT(list_is_ok(list_1)); + ASSERT(list_is_ok(list_2)); + + if (list_1->size != list_2->size) return false; + + list_copy(copy_1,list_1); + list_note(copy_1); + list_sort(copy_1); + + list_copy(copy_2,list_2); + list_note(copy_2); + list_sort(copy_2); + + for (i = 0; i < copy_1->size; i++) { + if (copy_1->move[i] != copy_2->move[i]) return false; + } + + return true; +} + +// list_disp() + +void list_disp(const list_t * list, const board_t * board) { + + int i, move, value; + char string[256]; + + ASSERT(list_is_ok(list)); + ASSERT(board_is_ok(board)); + + for (i = 0; i < list->size; i++) { + + move = list->move[i]; + value = list->value[i]; + + if (!move_to_can(move,board,string,256)) ASSERT(false); + my_log("POLYGLOT %-5s %04X %+4d\n",string,move,value); + } + + my_log("POLYGLOT\n"); +} + +// end of list.cpp + diff --git a/list.h b/list.h new file mode 100644 index 0000000..9004602 --- /dev/null +++ b/list.h @@ -0,0 +1,52 @@ + +// list.h + +#ifndef LIST_H +#define LIST_H + +// includes + +#include "board.h" +#include "move.h" +#include "util.h" + +// constants + +const int ListSize = 256; + +// types + +struct list_t { + sint16 size; + move_t move[ListSize]; + sint16 value[ListSize]; +}; + +// functions + +extern bool list_is_ok (const list_t * list); + +extern void list_clear (list_t * list); +extern void list_add (list_t * list, int move, int value = 0); +extern void list_remove (list_t * list, int index); + +extern bool list_is_empty (const list_t * list); +extern int list_size (const list_t * list); + +extern int list_move (const list_t * list, int index); +extern int list_value (const list_t * list, int index); + +extern void list_copy (list_t * dst, const list_t * src); + +extern void list_note (list_t * list); +extern void list_sort (list_t * list); + +extern bool list_contain (const list_t * list, int move); +extern bool list_equal (list_t * list_1, list_t * list_2); + +extern void list_disp (const list_t * list, const board_t * board); + +#endif // !defined LIST_H + +// end of list.h + diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..88577d0 --- /dev/null +++ b/main.cpp @@ -0,0 +1,347 @@ + +// main.cpp + +// includes + +#include +#include +#include +#include +#include + +#ifdef _WIN32 + #include +#else + #include +#endif + +#include "adapter.h" +#include "attack.h" +#include "board.h" +#include "book.h" +#include "book_make.h" +#include "book_merge.h" +#include "engine.h" +#include "epd.h" +#include "fen.h" +#include "gui.h" +#include "hash.h" +#include "list.h" +#include "main.h" +#include "move.h" +#include "move_gen.h" +#include "option.h" +#include "piece.h" +#include "search.h" +#include "square.h" +#include "uci.h" +#include "util.h" +// constants + + +static const char * const Version = "1.4W10UCIb15"; +static const char * const HelpMessage = "\ +SYNTAX\n\ +polyglot [configfile]\n\ +polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply] [-min-game games] [-min-score score] [-only-white] [-only-black] [-uniform]\n\ +polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile]\n\ +polyglot [configfile] epd-test [-epd inputfile] [-min-depth depth] [-max-depth depth] [-max-time time] [-depth-delta delta]\n\ +polyglot perft [-fen fen] [-max-depth depth]\ +"; + + + +static const int SearchDepth = 63; +static const double SearchTime = 3600.0; +static const int StringSize = 4096; +// variables +static bool Init; +// prototypes + +static void parse_option (); +static void init_book (); +static bool parse_line (char line[], char * * name_ptr, char * * value_ptr); +static void stop_search (); +static void sig_quit(int); + +// functions + +// main() + +int main(int argc, char * argv[]) { + +// board_t board[1]; + + if(argc>=2 && ((my_string_case_equal(argv[1],"help")) || (my_string_case_equal(argv[1],"-help")) || (my_string_case_equal(argv[1],"--help")) || (my_string_case_equal(argv[1],"-h")) || my_string_case_equal(argv[1],"/?"))){ + printf("%s\n",HelpMessage); + return EXIT_SUCCESS; + } + // init + + Init = false; + + signal(SIGINT,sig_quit); + +#ifdef _WIN32 + signal(SIGTERM,SIG_IGN); +#ifdef SIGPIPE + signal(SIGPIPE,SIG_IGN); +#endif +#endif + + util_init(); + printf("PolyGlot %s by Fabien Letouzey\n",Version); + + option_init(); + + square_init(); + piece_init(); + attack_init(); + + hash_init(); + + my_random_init(); + + // build book + + if (argc >= 2 && my_string_equal(argv[1],"make-book")) { + book_make(argc,argv); + return EXIT_SUCCESS; + } + + if (argc >= 2 && my_string_equal(argv[1],"merge-book")) { + book_merge(argc,argv); + return EXIT_SUCCESS; + } + + if (argc >= 2 && my_string_equal(argv[1],"perft")) { + do_perft(argc,argv); + return EXIT_SUCCESS; + } + + // read options + + if (argc == 2) option_set("OptionFile",argv[1]); // HACK for compatibility + + parse_option(); // HACK: also launches the engine + + // EPD test + + if (argc >= 2 && my_string_equal(argv[1],"epd-test")){ + epd_test(argc,argv); + return EXIT_SUCCESS; + }else if(argc >= 3 && my_string_equal(argv[2],"epd-test")){ + epd_test(argc-1,argv+1); + return EXIT_SUCCESS; + } + + init_book(); + // adapter + + gui_init(GUI); + adapter_loop(); + return EXIT_SUCCESS; // we never get here.... +} + +// init_book() + +static void init_book(){ + book_clear(); + if (option_get_bool("Book")){ + my_log("POLYGLOT *** SETTING BOOK ***\n"); + my_log("POLYGLOT BOOK \"%s\"\n",option_get_string("BookFile")); + uci_set_option(Uci, + PolyglotBookFile, // name + option_get_string("BookFile"), // value + "string", // type + "", // max + "", // min + "" // var + ); + book_open(option_get_string("BookFile")); + if(!book_is_open()){ + my_log("POLYGLOT Unable to open book \"%s\"\n", + option_get_string("BookFile")); + } + } else { + uci_set_option(Uci, + PolyglotBookFile, // name + "", // value + "string", // type + "", // max + "", // min + "" // var + ); + + } +} + +// parse_option() + +static void parse_option() { + + const char * file_name; + FILE * file; + char line[256]; + char * name, * value; + file_name = option_get_string("OptionFile"); + + file = fopen(file_name,"r"); + if (file == NULL) { + my_fatal("Can't open file \"%s\": %s\n",file_name,strerror(errno)); + } + + // PolyGlot options (assumed first) + + while (true) { + + if (!my_file_read_line(file,line,256)) { + my_fatal("parse_option(): missing [Engine] section\n"); + } + + if(line[0]=='#') continue; + + if (my_string_case_equal(line,"[engine]")) break; + + if (parse_line(line,&name,&value)) option_set(name,value); + } + + if (option_get_bool("Log")) { + my_log_open(option_get_string("LogFile")); + } + + my_log("POLYGLOT *** START ***\n"); + my_log("POLYGLOT INI file \"%s\"\n",file_name); + engine_open(Engine); + if (option_get_bool("UCI")) { + my_log("POLYGLOT *** Switching to UCI mode ***\n"); + } + + + Init = true; + uci_open(Uci,Engine); + while (my_file_read_line(file,line,256)) { + + if (line[0] == '[') my_fatal("parse_option(): unknown section %s\n",line); + + if (parse_line(line,&name,&value)) { + uci_send_option(Uci,name,"%s",value); + //to get a decent display in winboard_x we need to now if an engine really is doing multipv analysis + // "multipv 1" in the pv is meaningless,f.i. toga sends that all the time + //therefore check if MultiPV is set to a decent value in the polyglot ini file + if(my_string_case_equal(name,"MultiPV") && atoi(value)>1) Uci->multipv_mode=true; + } + } + if (my_string_equal(option_get_string("EngineName"),"")) { + option_set("EngineName",Uci->name); + } + fclose(file); +} + +// parse_line() + +static bool parse_line(char line[], char * * name_ptr, char * * value_ptr) { + + char * ptr; + char * name, * value; + + ASSERT(line!=NULL); + ASSERT(name_ptr!=NULL); + ASSERT(value_ptr!=NULL); + + // remove comments + + ptr = strchr(line,';'); + if (ptr != NULL) *ptr = '\0'; + + ptr = strchr(line,'#'); + if (ptr != NULL) *ptr = '\0'; + + // split at '=' + + ptr = strchr(line,'='); + if (ptr == NULL) return false; + + name = line; + value = ptr+1; + + // cleanup name + + while (*name == ' ') name++; // remove leading spaces + + while (ptr > name && ptr[-1] == ' ') ptr--; // remove trailing spaces + *ptr = '\0'; + + if (*name == '\0') return false; + + // cleanup value + + ptr = &value[strlen(value)]; // pointer to string terminator + + while (*value == ' ') value++; // remove leading spaces + + while (ptr > value && ptr[-1] == ' ') ptr--; // remove trailing spaces + *ptr = '\0'; + + if (*value == '\0') return false; + + // end + + *name_ptr = name; + *value_ptr = value; + + return true; +} + +static void sig_quit(int dummy){ + my_log("POLYGLOT *** SIGINT Received ***\n"); + quit(); +} + + +// quit() + +void quit() { + + char string[StringSize]; + + my_log("POLYGLOT *** QUIT ***\n"); + + if (Init) { + + stop_search(); + engine_send(Engine,"quit"); + + // wait for the engine to quit + while (true) { + engine_get(Engine,string,StringSize); // HACK: calls exit() on receiving EOF + } + } +} + +// stop_search() + +static void stop_search() { + + if (Init && Uci->searching) { + + ASSERT(Uci->searching); + ASSERT(Uci->pending_nb>=1); + + my_log("POLYGLOT STOP SEARCH\n"); + +/* + engine_send(Engine,"stop"); + Uci->searching = false; +*/ + + if (option_get_bool("SyncStop")) { + uci_send_stop_sync(Uci); + } else { + uci_send_stop(Uci); + } + } +} + +// end of main.cpp + diff --git a/main.h b/main.h new file mode 100644 index 0000000..c268fb2 --- /dev/null +++ b/main.h @@ -0,0 +1,18 @@ + +// main.h + +#ifndef MAIN_H +#define MAIN_H + +// includes + +#include "util.h" + +// functions + +extern void quit (); + +#endif // !defined MAIN_H + +// end of main.h + diff --git a/makefile.gcc b/makefile.gcc new file mode 100644 index 0000000..5e18172 --- /dev/null +++ b/makefile.gcc @@ -0,0 +1,6 @@ +# what's this?? +# This is not a makefile.... + +# Anyway here is the command for compiling polyglot under Mingw/Cygwin + +g++ -O2 -mno-cygwin -D_WIN32 *.cpp -opolyglot diff --git a/missing b/missing new file mode 100755 index 0000000..1c8ff70 --- /dev/null +++ b/missing @@ -0,0 +1,367 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2006-05-10.23 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# 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, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: +sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' +sed_minuso='s/.* -o \([^ ]*\).*/\1/p' + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case $1 in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + autom4te touch the output file, or create a stub one + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). +case $1 in + lex|yacc) + # Not GNU programs, they don't have --version. + ;; + + tar) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case $1 in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case $f in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if test ! -f y.tab.h; then + echo >y.tab.h + fi + if test ! -f y.tab.c; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if test $# -ne 1; then + eval LASTARG="\${$#}" + case $LASTARG in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if test -f "$SRCFILE"; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if test ! -f lex.yy.c; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n "$sed_output"` + test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n ' + /^@setfilename/{ + s/.* \([^ ]*\) *$/\1/ + p + q + }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + tar) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case $firstarg in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case $firstarg in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/move.cpp b/move.cpp new file mode 100644 index 0000000..248ebdf --- /dev/null +++ b/move.cpp @@ -0,0 +1,380 @@ + +// move.cpp + +// includes + +#include +#include + +#include "attack.h" +#include "colour.h" +#include "list.h" +#include "move.h" +#include "move_do.h" +#include "move_gen.h" +#include "move_legal.h" +#include "option.h" +#include "piece.h" +#include "square.h" +#include "util.h" + +// "constants" + +static const uint8 PromotePiece[5] = { PieceNone64, Knight64, Bishop64, Rook64, Queen64 }; + +// functions + +// move_is_ok() + +bool move_is_ok(int move) { + + if (move < 0 || move >= 65536) return false; + + if (move == MoveNone) return false; + + return true; +} + +// move_make() + +int move_make(int from, int to) { + + ASSERT(square_is_ok(from)); + ASSERT(square_is_ok(to)); + + return (square_to_64(from) << 6) | square_to_64(to); +} + +// move_make_flags() + +int move_make_flags(int from, int to, int flags) { + + ASSERT(square_is_ok(from)); + ASSERT(square_is_ok(to)); + ASSERT((flags&~0xF000)==0); + + ASSERT(to!=from); + + return (square_to_64(from) << 6) | square_to_64(to) | flags; +} + +// move_from() + +int move_from(int move) { + + int from_64; + + ASSERT(move_is_ok(move)); + + from_64 = (move >> 6) & 077; + + return square_from_64(from_64); +} + +// move_to() + +int move_to(int move) { + + int to_64; + + ASSERT(move_is_ok(move)); + + to_64 = move & 077; + + return square_from_64(to_64); +} + +// move_promote_hack() + +int move_promote_hack(int move) { + + int code; + + ASSERT(move_is_ok(move)); + + ASSERT(move_is_promote(move)); + + code = move >> 12; + ASSERT(code>=1&&code<=4); + + return PromotePiece[code]; +} + +// move_is_capture() + +bool move_is_capture(int move, const board_t * board) { + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + if (move_is_en_passant(move,board)) return true; + if (board->square[move_to(move)] != Empty) return true; + + return false; +} + +// move_is_promote() + +bool move_is_promote(int move) { + + ASSERT(move_is_ok(move)); + + return (move & MoveFlags) != 0; +} + +// move_is_en_passant() + +bool move_is_en_passant(int move, const board_t * board) { + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + return piece_is_pawn(move_piece(move,board)) + && move_to(move) == board->ep_square; +} + +// move_is_castle() + +bool move_is_castle(int move, const board_t * board) { + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + return colour_equal(board->square[move_to(move)],board->turn); +} + +// move_piece() + +int move_piece(int move, const board_t * board) { + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + return board->square[move_from(move)]; +} + +// move_capture() + +int move_capture(int move, const board_t * board) { + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + if (move_is_en_passant(move,board)) { + return piece_pawn_opp(move_piece(move,board)); + } + + return board->square[move_to(move)]; +} + +// move_promote() + +int move_promote(int move, const board_t * board) { + + int code; + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + if (move_is_promote(move)) { + code = move >> 12; + ASSERT(code>=1&&code<=4); + return PromotePiece[code] | board->turn; + } + + return Empty; +} + +// move_is_check() + +bool move_is_check(int move, const board_t * board) { + + board_t new_board[1]; + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + board_copy(new_board,board); + move_do(new_board,move); + ASSERT(!is_in_check(new_board,colour_opp(new_board->turn))); + + return board_is_check(new_board); +} + +// move_is_mate() + +bool move_is_mate(int move, const board_t * board) { + + board_t new_board[1]; + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + board_copy(new_board,board); + move_do(new_board,move); + ASSERT(!is_in_check(new_board,colour_opp(new_board->turn))); + + return board_is_mate(new_board); +} + +// move_to_can() + +bool move_to_can(int move, const board_t * board, char string[], int size) { + + int from, to; + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + ASSERT(string!=NULL); + ASSERT(size>=6); + + ASSERT(move_is_legal(move,board)); + + if (size < 6) return false; + + // init + + from = move_from(move); + to = move_to(move); + + // king-slide castling + + if (move_is_castle(move,board) && !option_get_bool("Chess960")) { + if (false) { + } else if (from == E1 && to == H1) { + to = G1; + } else if (from == E1 && to == A1) { + to = C1; + } else if (from == E8 && to == H8) { + to = G8; + } else if (from == E8 && to == A8) { + to = C8; + } + } + + // normal moves + + if (!square_to_string(from,&string[0],3)) ASSERT(false); + if (!square_to_string(to,&string[2],3)) ASSERT(false); + ASSERT(strlen(string)==4); + + // promotes + + if (move_is_promote(move)) { + string[4] = piece_to_char(move_promote_hack(move)|Black); // HACK: black => lower-case + string[5] = '\0'; + } + + // debug + + ASSERT(move_from_can(string,board)==move); + + return true; +} + +// move_from_can() + +int move_from_can(const char string[], const board_t * board) { + + char tmp_string[256]; + int from, to; + int side; + int move; + + ASSERT(string!=NULL); + ASSERT(board_is_ok(board)); + + // from + + tmp_string[0] = string[0]; + tmp_string[1] = string[1]; + tmp_string[2] = '\0'; + + from = square_from_string(tmp_string); + if (from == SquareNone) return MoveNone; + + // to + + tmp_string[0] = string[2]; + tmp_string[1] = string[3]; + tmp_string[2] = '\0'; + + to = square_from_string(tmp_string); + if (to == SquareNone) return MoveNone; + + // convert "king slide" castling to KxR + + if (piece_is_king(board->square[from]) + && square_rank(to) == square_rank(from) + && abs(to-from) > 1) { + side = (to > from) ? SideH : SideA; + to = board->castle[board->turn][side]; + if (to == SquareNone) return MoveNone; + } + + // move + + move = move_make(from,to); + + // promote + + switch (string[4]) { + case '\0': // not a promotion + if (piece_is_pawn(board->square[from]) + && square_side_rank(to,board->turn) == Rank8 + && option_get_bool("PromoteWorkAround")) { + move |= MovePromoteQueen; + } + break; + case 'N': + case 'n': + move |= MovePromoteKnight; + break; + case 'B': + case 'b': + move |= MovePromoteBishop; + break; + case 'R': + case 'r': + move |= MovePromoteRook; + break; + case 'Q': + case 'q': + move |= MovePromoteQueen; + break; + default: + return MoveNone; + break; + } + + // debug + + ASSERT(move_is_legal(move,board)); + + return move; +} + +// move_order() + +int move_order(int move) { + + ASSERT(move_is_ok(move)); + + return ((move & 07777) << 3) | (move >> 12); // from, to, promote +} + +// move_disp() + +void move_disp(int move, const board_t * board) { + + char string[256]; + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + if (!move_to_can(move,board,string,256)) ASSERT(false); + my_log("POLYGLOT %s\n",string); +} + +// end of move.cpp + diff --git a/move.h b/move.h new file mode 100644 index 0000000..b6e7081 --- /dev/null +++ b/move.h @@ -0,0 +1,59 @@ + +// move.h + +#ifndef MOVE_H +#define MOVE_H + +// includes + +#include "board.h" +#include "util.h" + +// constants + +const int MoveNone = 0; // HACK: a1a1 cannot be a legal move + +const int MovePromoteKnight = 1 << 12; +const int MovePromoteBishop = 2 << 12; +const int MovePromoteRook = 3 << 12; +const int MovePromoteQueen = 4 << 12; +const int MoveFlags = 7 << 12; + +// types + +typedef uint16 move_t; + +// functions + +extern bool move_is_ok (int move); + +extern int move_make (int from, int to); +extern int move_make_flags (int from, int to, int flags); + +extern int move_from (int move); +extern int move_to (int move); +extern int move_promote_hack (int move); + +extern bool move_is_capture (int move, const board_t * board); +extern bool move_is_promote (int move); +extern bool move_is_en_passant (int move, const board_t * board); +extern bool move_is_castle (int move, const board_t * board); + +extern int move_piece (int move, const board_t * board); +extern int move_capture (int move, const board_t * board); +extern int move_promote (int move, const board_t * board); + +extern bool move_is_check (int move, const board_t * board); +extern bool move_is_mate (int move, const board_t * board); + +extern int move_order (int move); + +extern bool move_to_can (int move, const board_t * board, char string[], int size); +extern int move_from_can (const char string[], const board_t * board); + +extern void move_disp (int move, const board_t * board); + +#endif // !defined MOVE_H + +// end of move.h + diff --git a/move_do.cpp b/move_do.cpp new file mode 100644 index 0000000..b4b625a --- /dev/null +++ b/move_do.cpp @@ -0,0 +1,363 @@ + +// move_do.cpp + +// includes + +#include + +#include "board.h" +#include "colour.h" +#include "hash.h" +#include "move.h" +#include "move_do.h" +#include "move_legal.h" +#include "piece.h" +#include "random.h" +#include "util.h" + +// prototypes + +static void square_clear (board_t * board, int square, int piece); +static void square_set (board_t * board, int square, int piece, int pos); +static void square_move (board_t * board, int from, int to, int piece); + +// functions + +// move_do() + +void move_do(board_t * board, int move) { + + int me, opp; + int from, to; + int piece, pos, capture; + int old_flags, new_flags; + int sq, ep_square; + int pawn; + + ASSERT(board_is_ok(board)); + ASSERT(move_is_ok(move)); + + ASSERT(move_is_pseudo(move,board)); + + // init + + me = board->turn; + opp = colour_opp(me); + + from = move_from(move); + to = move_to(move); + + piece = board->square[from]; + ASSERT(colour_equal(piece,me)); + + pos = board->pos[from]; + ASSERT(pos>=0); + + // update turn + + board->turn = opp; + board->key ^= random_64(RandomTurn); + + // update castling rights + + old_flags = board_flags(board); + + if (piece_is_king(piece)) { + board->castle[me][SideH] = SquareNone; + board->castle[me][SideA] = SquareNone; + } + + if (board->castle[me][SideH] == from) board->castle[me][SideH] = SquareNone; + if (board->castle[me][SideA] == from) board->castle[me][SideA] = SquareNone; + + if (board->castle[opp][SideH] == to) board->castle[opp][SideH] = SquareNone; + if (board->castle[opp][SideA] == to) board->castle[opp][SideA] = SquareNone; + + new_flags = board_flags(board); + + board->key ^= hash_castle_key(new_flags^old_flags); // HACK + + // update en-passant square + + ep_square = sq = board->ep_square; + if (sq != SquareNone) { + board->key ^= random_64(RandomEnPassant+square_file(sq)); + board->ep_square = SquareNone; + } + + if (piece_is_pawn(piece) && abs(to-from) == 32) { + pawn = piece_make_pawn(opp); + if (board->square[to-1] == pawn || board->square[to+1] == pawn) { + board->ep_square = sq = (from + to) / 2; + board->key ^= random_64(RandomEnPassant+square_file(sq)); + } + } + + // update ply number (captures are handled later) + + board->ply_nb++; + if (piece_is_pawn(piece)) board->ply_nb = 0; // conversion + + // update move number + + if (me == Black) board->move_nb++; + + // castle + + if (colour_equal(board->square[to],me)) { + + int rank; + int king_from, king_to; + int rook_from, rook_to; + int rook; + + rank = colour_is_white(me) ? Rank1 : Rank8; + + king_from = from; + rook_from = to; + + if (to > from) { // h side + king_to = square_make(FileG,rank); + rook_to = square_make(FileF,rank); + } else { // a side + king_to = square_make(FileC,rank); + rook_to = square_make(FileD,rank); + } + + // remove the rook + + pos = board->pos[rook_from]; + ASSERT(pos>=0); + + rook = Rook64 | me; // HACK + + square_clear(board,rook_from,rook); + + // move the king + + square_move(board,king_from,king_to,piece); + + // put the rook back + + square_set(board,rook_to,rook,pos); + + ASSERT(board->key==hash_key(board)); + + return; + } + + // remove the captured piece + + if (piece_is_pawn(piece) && to == ep_square) { + + // en-passant capture + + sq = square_ep_dual(to); + capture = board->square[sq]; + ASSERT(capture==piece_make_pawn(opp)); + + square_clear(board,sq,capture); + + board->ply_nb = 0; // conversion + + } else { + + capture = board->square[to]; + + if (capture != Empty) { + + // normal capture + + ASSERT(colour_equal(capture,opp)); + ASSERT(!piece_is_king(capture)); + + square_clear(board,to,capture); + + board->ply_nb = 0; // conversion + } + } + + // move the piece + + if (move_is_promote(move)) { + + // promote + + square_clear(board,from,piece); + piece = move_promote_hack(move) | me; // HACK + square_set(board,to,piece,pos); + + } else { + + // normal move + + square_move(board,from,to,piece); + } + + ASSERT(board->key==hash_key(board)); +} + +// square_clear() + +static void square_clear(board_t * board, int square, int piece) { + + int pos, piece_12, colour; + int sq, size; + + ASSERT(board!=NULL); + ASSERT(square_is_ok(square)); + ASSERT(piece_is_ok(piece)); + + // init + + pos = board->pos[square]; + ASSERT(pos>=0); + + colour = piece_colour(piece); + piece_12 = piece_to_12(piece); + + // square + + ASSERT(board->square[square]==piece); + board->square[square] = Empty; + + ASSERT(board->pos[square]==pos); + board->pos[square] = -1; // not needed + + // piece list + + ASSERT(board->list_size[colour]>=2); + size = --board->list_size[colour]; + ASSERT(pos<=size); + + if (pos != size) { + + sq = board->list[colour][size]; + ASSERT(square_is_ok(sq)); + ASSERT(sq!=square); + + ASSERT(board->pos[sq]==size); + board->pos[sq] = pos; + + ASSERT(board->list[colour][pos]==square); + board->list[colour][pos] = sq; + } + + board->list[colour][size] = SquareNone; + + // material + + ASSERT(board->number[piece_12]>=1); + board->number[piece_12]--; + + // hash key + + board->key ^= random_64(RandomPiece+piece_12*64+square_to_64(square)); +} + +// square_set() + +static void square_set(board_t * board, int square, int piece, int pos) { + + int piece_12, colour; + int sq, size; + + ASSERT(board!=NULL); + ASSERT(square_is_ok(square)); + ASSERT(piece_is_ok(piece)); + ASSERT(pos>=0); + + // init + + colour = piece_colour(piece); + piece_12 = piece_to_12(piece); + + // square + + ASSERT(board->square[square]==Empty); + board->square[square] = piece; + + ASSERT(board->pos[square]==-1); + board->pos[square] = pos; + + // piece list + + size = board->list_size[colour]++; + ASSERT(board->list[colour][size]==SquareNone); + ASSERT(pos<=size); + + if (pos != size) { + + sq = board->list[colour][pos]; + ASSERT(square_is_ok(sq)); + ASSERT(sq!=square); + + ASSERT(board->pos[sq]==pos); + board->pos[sq] = size; + + ASSERT(board->list[colour][size]==SquareNone); + board->list[colour][size] = sq; + } + + board->list[colour][pos] = square; + + // material + + ASSERT(board->number[piece_12]<=8); + board->number[piece_12]++; + + // hash key + + board->key ^= random_64(RandomPiece+piece_12*64+square_to_64(square)); +} + +// square_move() + +static void square_move(board_t * board, int from, int to, int piece) { + + int colour, pos; + int piece_index; + + ASSERT(board!=NULL); + ASSERT(square_is_ok(from)); + ASSERT(square_is_ok(to)); + ASSERT(piece_is_ok(piece)); + + // init + + colour = piece_colour(piece); + + pos = board->pos[from]; + ASSERT(pos>=0); + + // from + + ASSERT(board->square[from]==piece); + board->square[from] = Empty; + + ASSERT(board->pos[from]==pos); + board->pos[from] = -1; // not needed + + // to + + ASSERT(board->square[to]==Empty); + board->square[to] = piece; + + ASSERT(board->pos[to]==-1); + board->pos[to] = pos; + + // piece list + + ASSERT(board->list[colour][pos]==from); + board->list[colour][pos] = to; + + // hash key + + piece_index = RandomPiece + piece_to_12(piece) * 64; + + board->key ^= random_64(piece_index+square_to_64(from)) + ^ random_64(piece_index+square_to_64(to)); +} + +// end of move_do.cpp + diff --git a/move_do.h b/move_do.h new file mode 100644 index 0000000..5954986 --- /dev/null +++ b/move_do.h @@ -0,0 +1,19 @@ + +// move_do.h + +#ifndef MOVE_DO_H +#define MOVE_DO_H + +// includes + +#include "board.h" +#include "util.h" + +// functions + +extern void move_do (board_t * board, int move); + +#endif // !defined MOVE_DO_H + +// end of move_do.h + diff --git a/move_gen.cpp b/move_gen.cpp new file mode 100644 index 0000000..5023885 --- /dev/null +++ b/move_gen.cpp @@ -0,0 +1,328 @@ + +// move_gen.cpp + +// includes + +#include "attack.h" +#include "board.h" +#include "colour.h" +#include "list.h" +#include "move.h" +#include "move_gen.h" +#include "move_legal.h" +#include "piece.h" +#include "util.h" + +// prototypes + +static void add_all_moves (list_t * list, const board_t * board); +static void add_castle_moves (list_t * list, const board_t * board); + +static void add_pawn_move (list_t * list, int from, int to); + +// functions + +// gen_legal_moves() + +void gen_legal_moves(list_t * list, const board_t * board) { + + ASSERT(list!=NULL); + ASSERT(board_is_ok(board)); + + gen_moves(list,board); + filter_legal(list,board); +} + +// gen_moves() + +void gen_moves(list_t * list, const board_t * board) { + + ASSERT(list!=NULL); + ASSERT(board_is_ok(board)); + + list_clear(list); + + add_all_moves(list,board); + if (!is_in_check(board,board->turn)) add_castle_moves(list,board); +} + +// add_all_moves() + +static void add_all_moves(list_t * list, const board_t * board) { + + int me, opp; + const uint8 * ptr; + const sint8 * ptr_inc; + int from, to; + int inc; + int piece, capture; + + ASSERT(list_is_ok(list)); + ASSERT(board_is_ok(board)); + + me = board->turn; + opp = colour_opp(me); + + for (ptr = board->list[me]; (from=*ptr) != SquareNone; ptr++) { + + piece = board->square[from]; + ASSERT(colour_equal(piece,me)); + + switch (piece_type(piece)) { + + case WhitePawn64: + + to = from + 15; + if (to == board->ep_square || colour_equal(board->square[to],opp)) { + add_pawn_move(list,from,to); + } + + to = from + 17; + if (to == board->ep_square || colour_equal(board->square[to],opp)) { + add_pawn_move(list,from,to); + } + + to = from + 16; + if (board->square[to] == Empty) { + add_pawn_move(list,from,to); + if (square_rank(from) == Rank2) { + to = from + 32; + if (board->square[to] == Empty) { + ASSERT(!square_is_promote(to)); + list_add(list,move_make(from,to)); + } + } + } + + break; + + case BlackPawn64: + + to = from - 17; + if (to == board->ep_square || colour_equal(board->square[to],opp)) { + add_pawn_move(list,from,to); + } + + to = from - 15; + if (to == board->ep_square || colour_equal(board->square[to],opp)) { + add_pawn_move(list,from,to); + } + + to = from - 16; + if (board->square[to] == Empty) { + add_pawn_move(list,from,to); + if (square_rank(from) == Rank7) { + to = from - 32; + if (board->square[to] == Empty) { + ASSERT(!square_is_promote(to)); + list_add(list,move_make(from,to)); + } + } + } + + break; + + case Knight64: + + for (ptr_inc = KnightInc; (inc=*ptr_inc) != IncNone; ptr_inc++) { + to = from + inc; + capture = board->square[to]; + if (capture == Empty || colour_equal(capture,opp)) { + list_add(list,move_make(from,to)); + } + } + + break; + + case Bishop64: + + for (ptr_inc = BishopInc; (inc=*ptr_inc) != IncNone; ptr_inc++) { + for (to = from+inc; (capture=board->square[to]) == Empty; to += inc) { + list_add(list,move_make(from,to)); + } + if (colour_equal(capture,opp)) { + list_add(list,move_make(from,to)); + } + } + + break; + + case Rook64: + + for (ptr_inc = RookInc; (inc=*ptr_inc) != IncNone; ptr_inc++) { + for (to = from+inc; (capture=board->square[to]) == Empty; to += inc) { + list_add(list,move_make(from,to)); + } + if (colour_equal(capture,opp)) { + list_add(list,move_make(from,to)); + } + } + + break; + + case Queen64: + + for (ptr_inc = QueenInc; (inc=*ptr_inc) != IncNone; ptr_inc++) { + for (to = from+inc; (capture=board->square[to]) == Empty; to += inc) { + list_add(list,move_make(from,to)); + } + if (colour_equal(capture,opp)) { + list_add(list,move_make(from,to)); + } + } + + break; + + case King64: + + for (ptr_inc = KingInc; (inc=*ptr_inc) != IncNone; ptr_inc++) { + to = from + inc; + capture = board->square[to]; + if (capture == Empty || colour_equal(capture,opp)) { + list_add(list,move_make(from,to)); + } + } + + break; + + default: + + ASSERT(false); + break; + } + } +} + +// add_castle_moves() + +static void add_castle_moves(list_t * list, const board_t * board) { + + int me, opp; + int rank; + int king_from, king_to; + int rook_from, rook_to; + bool legal; + int inc; + int sq; + + ASSERT(list_is_ok(list)); + ASSERT(board_is_ok(board)); + + ASSERT(!is_in_check(board,board->turn)); + + me = board->turn; + opp = colour_opp(me); + + rank = colour_is_white(me) ? Rank1 : Rank8; + + // h-side castling + + if (board->castle[me][SideH] != SquareNone) { + + king_from = king_pos(board,me); + king_to = square_make(FileG,rank); + rook_from = board->castle[me][SideH]; + rook_to = square_make(FileF,rank); + + ASSERT(square_rank(king_from)==rank); + ASSERT(square_rank(rook_from)==rank); + ASSERT(board->square[king_from]==(King64|me)); // HACK + ASSERT(board->square[rook_from]==(Rook64|me)); // HACK + ASSERT(rook_from>king_from); + + legal = true; + + if (king_to != king_from) { + + inc = (king_to > king_from) ? +1 : -1; + + for (sq = king_from+inc; true; sq += inc) { + + if (sq != rook_from && board->square[sq] != Empty) legal = false; + if (is_attacked(board,sq,opp)) legal = false; + + if (sq == king_to) break; + } + } + + if (rook_to != rook_from) { + + inc = (rook_to > rook_from) ? +1 : -1; + + for (sq = rook_from+inc; true; sq += inc) { + if (sq != king_from && board->square[sq] != Empty) legal = false; + if (sq == rook_to) break; + } + } + + if (legal) list_add(list,move_make(king_from,rook_from)); + } + + // a-side castling + + if (board->castle[me][SideA] != SquareNone) { + + king_from = king_pos(board,me); + king_to = square_make(FileC,rank); + rook_from = board->castle[me][SideA]; + rook_to = square_make(FileD,rank); + + ASSERT(square_rank(king_from)==rank); + ASSERT(square_rank(rook_from)==rank); + ASSERT(board->square[king_from]==(King64|me)); // HACK + ASSERT(board->square[rook_from]==(Rook64|me)); // HACK + ASSERT(rook_from king_from) ? +1 : -1; + + for (sq = king_from+inc; true; sq += inc) { + + if (sq != rook_from && board->square[sq] != Empty) legal = false; + if (is_attacked(board,sq,opp)) legal = false; + + if (sq == king_to) break; + } + } + + if (rook_to != rook_from) { + + inc = (rook_to > rook_from) ? +1 : -1; + + for (sq = rook_from+inc; true; sq += inc) { + if (sq != king_from && board->square[sq] != Empty) legal = false; + if (sq == rook_to) break; + } + } + + if (legal) list_add(list,move_make(king_from,rook_from)); + } +} + +// add_pawn_move() + +static void add_pawn_move(list_t * list, int from, int to) { + + int move; + + ASSERT(list_is_ok(list)); + ASSERT(square_is_ok(from)); + ASSERT(square_is_ok(to)); + + move = move_make(from,to); + + if (square_is_promote(to)) { + list_add(list,move|MovePromoteKnight); + list_add(list,move|MovePromoteBishop); + list_add(list,move|MovePromoteRook); + list_add(list,move|MovePromoteQueen); + } else { + list_add(list,move); + } +} + +// end of move_gen.cpp + diff --git a/move_gen.h b/move_gen.h new file mode 100644 index 0000000..b4dc1f2 --- /dev/null +++ b/move_gen.h @@ -0,0 +1,21 @@ + +// move_gen.h + +#ifndef MOVE_GEN_H +#define MOVE_GEN_H + +// includes + +#include "board.h" +#include "list.h" +#include "util.h" + +// functions + +extern void gen_legal_moves (list_t * list, const board_t * board); +extern void gen_moves (list_t * list, const board_t * board); + +#endif // !defined MOVE_GEN_H + +// end of move_gen.h + diff --git a/move_legal.cpp b/move_legal.cpp new file mode 100644 index 0000000..93e9567 --- /dev/null +++ b/move_legal.cpp @@ -0,0 +1,115 @@ + +// move_legal.cpp + +// includes + +#include "attack.h" +#include "colour.h" +#include "fen.h" +#include "list.h" +#include "move.h" +#include "move_do.h" +#include "move_gen.h" +#include "move_legal.h" +#include "piece.h" +#include "square.h" +#include "util.h" + +// prototypes + +static bool move_is_legal_debug (int move, const board_t * board); + +// functions + +// move_is_pseudo() + +bool move_is_pseudo(int move, const board_t * board) { + + list_t list[1]; + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + gen_moves(list,board); + + return list_contain(list,move); +} + +// pseudo_is_legal() + +bool pseudo_is_legal(int move, const board_t * board) { + + board_t new_board[1]; + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + ASSERT(move_is_pseudo(move,board)); + + board_copy(new_board,board); + move_do(new_board,move); + + return !is_in_check(new_board,colour_opp(new_board->turn)); +} + +// move_is_legal() + +bool move_is_legal(int move, const board_t * board) { + + bool legal; + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + legal = move_is_pseudo(move,board) && pseudo_is_legal(move,board); + ASSERT(legal==move_is_legal_debug(move,board)); + + return legal; +} + +// filter_legal() + +void filter_legal(list_t * list, const board_t * board) { + + int pos; + int i, move, value; + + ASSERT(list_is_ok(list)); + ASSERT(board_is_ok(board)); + + pos = 0; + + for (i = 0; i < list_size(list); i++) { + + ASSERT(pos>=0&&pos<=i); + + move = list_move(list,i); + value = list_value(list,i); + + if (pseudo_is_legal(move,board)) { + list->move[pos] = move; + list->value[pos] = value; + pos++; + } + } + + ASSERT(pos>=0&&pos<=list_size(list)); + list->size = pos; +} + +// move_is_legal_debug() + +static bool move_is_legal_debug(int move, const board_t * board) { + + list_t list[1]; + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + + gen_legal_moves(list,board); + + return list_contain(list,move); +} + +// end of move_legal.cpp + diff --git a/move_legal.h b/move_legal.h new file mode 100644 index 0000000..67a2af8 --- /dev/null +++ b/move_legal.h @@ -0,0 +1,24 @@ + +// move_legal.h + +#ifndef MOVE_LEGAL_H +#define MOVE_LEGAL_H + +// includes + +#include "board.h" +#include "list.h" +#include "util.h" + +// functions + +extern bool move_is_pseudo (int move, const board_t * board); +extern bool pseudo_is_legal (int move, const board_t * board); +extern bool move_is_legal (int move, const board_t * board); + +extern void filter_legal (list_t * list, const board_t * board); + +#endif // !defined MOVE_LEGAL_H + +// end of move_legal.h + diff --git a/option.cpp b/option.cpp new file mode 100644 index 0000000..716802c --- /dev/null +++ b/option.cpp @@ -0,0 +1,243 @@ + +// option.cpp + +// includes + +#include +#include + +#include "option.h" +#include "util.h" + +// constants + +static const bool UseDebug = false; + +// types + +struct option_t { + const char * var; + const char * val; +}; + +// variables + +static option_t Option[] = { + + { "OptionFile", NULL, }, // string + + // options + + { "EngineName", NULL, }, // string + { "EngineDir", NULL, }, // string + { "EngineCommand", NULL, }, // string + + { "Log", NULL, }, // true/false + { "LogFile", NULL, }, // string + + { "UCI", NULL, }, // true/false + + { "UseNice", NULL, }, // true/false + + { "NiceValue", NULL, }, // true/false + + { "Chess960", NULL, }, // true/false + + { "Resign", NULL, }, // true/false + { "ResignMoves", NULL, }, // move number + { "ResignScore", NULL, }, // centipawns + + { "MateScore", NULL, }, // centipawns + + { "Book", NULL, }, // true/false + { "BookFile", NULL, }, // string + + { "BookRandom", NULL, }, // true/false + { "BookLearn", NULL, }, // true/false + + { "KibitzMove", NULL, }, // true/false + { "KibitzPV", NULL, }, // true/false + + { "KibitzCommand", NULL, }, // string + { "KibitzDelay", NULL, }, // seconds + + { "ShowPonder", NULL, }, // true/false + + // work-arounds + + { "UCIVersion", NULL, }, // 1- + { "CanPonder", NULL, }, // true/false + { "SyncStop", NULL, }, // true/false + { "Affinity", NULL, }, // -1 else 0-32 //won't do much on *nix systems + { "RepeatPV", NULL, }, + { "PromoteWorkAround", NULL, }, // true/false + + // { "", NULL, }, + + { NULL, NULL, }, +}; + +// prototypes + +static option_t * option_find (const char var[]); + +// functions + +// option_init() + +void option_init() { + + option_set("OptionFile","polyglot.ini"); + + // options + + option_set("EngineName",""); + option_set("EngineDir","."); + option_set("EngineCommand",""); + + option_set("Log","false"); + option_set("LogFile","polyglot.log"); + + option_set("UCI","false"); + + option_set("UseNice","false"); + option_set("NiceValue","5"); + + option_set("Chess960","false"); + + option_set("Resign","false"); + option_set("ResignMoves","3"); + option_set("ResignScore","600"); + + option_set("MateScore","10000"); + + option_set("Book","false"); + option_set("BookFile","book.bin"); + + option_set("BookRandom","true"); + option_set("BookLearn","false"); + + option_set("KibitzMove","false"); + option_set("KibitzPV","false"); + + option_set("KibitzCommand","tellall"); + option_set("KibitzDelay","5"); + + option_set("ShowPonder","true"); + + // work-arounds + + option_set("UCIVersion","2"); + option_set("CanPonder","false"); + option_set("SyncStop","false"); + option_set("Affinity","-1"); + option_set("PromoteWorkAround","false"); + option_set("RepeatPV","true"); + // option_set("",""); +} + +// option_set() + +bool option_set(const char var[], const char val[]) { + + option_t * opt; + + ASSERT(var!=NULL); + ASSERT(val!=NULL); + + opt = option_find(var); + if (opt == NULL) return false; + + my_string_set(&opt->val,val); + + if (UseDebug) my_log("POLYGLOT OPTION SET \"%s\" -> \"%s\"\n",opt->var,opt->val); + + return true; +} + +// option_get() + +const char * option_get(const char var[]) { + + option_t * opt; + + ASSERT(var!=NULL); + + opt = option_find(var); + if (opt == NULL) my_fatal("option_get(): unknown option \"%s\"\n",var); + + if (UseDebug) my_log("POLYGLOT OPTION GET \"%s\" -> \"%s\"\n",opt->var,opt->val); + + return opt->val; +} + +// option_get_bool() + +bool option_get_bool(const char var[]) { + + const char * val; + + val = option_get(var); + + if (false) { + } else if (my_string_case_equal(val,"true") || my_string_case_equal(val,"yes") || my_string_equal(val,"1")) { + return true; + } else if (my_string_case_equal(val,"false") || my_string_case_equal(val,"no") || my_string_equal(val,"0")) { + return false; + } + + ASSERT(false); + + return false; +} + +// option_get_double() + +double option_get_double(const char var[]) { + + const char * val; + + val = option_get(var); + + return atof(val); +} + +// option_get_int() + +int option_get_int(const char var[]) { + + const char * val; + + val = option_get(var); + + return atoi(val); +} + +// option_get_string() + +const char * option_get_string(const char var[]) { + + const char * val; + + val = option_get(var); + + return val; +} + +// option_find() + +static option_t * option_find(const char var[]) { + + option_t * opt; + + ASSERT(var!=NULL); + + for (opt = &Option[0]; opt->var != NULL; opt++) { + if (my_string_case_equal(opt->var,var)) return opt; + } + + return NULL; +} + +// end of option.cpp + diff --git a/option.h b/option.h new file mode 100644 index 0000000..23bd84d --- /dev/null +++ b/option.h @@ -0,0 +1,26 @@ + +// option.h + +#ifndef OPTION_H +#define OPTION_H + +// includes + +#include "util.h" + +// functions + +extern void option_init (); + +extern bool option_set (const char var[], const char val[]); +extern const char * option_get (const char var[]); + +extern bool option_get_bool (const char var[]); +extern double option_get_double (const char var[]); +extern int option_get_int (const char var[]); +extern const char * option_get_string (const char var[]); + +#endif // !defined OPTION_H + +// end of option.h + diff --git a/parse.cpp b/parse.cpp new file mode 100644 index 0000000..9b12c38 --- /dev/null +++ b/parse.cpp @@ -0,0 +1,264 @@ + +// parse.cpp + +// includes + +#include + +#include "parse.h" +#include "util.h" + +// constants + +static const int StringSize = 256; + +// variables + +char * Star[STAR_NUMBER]; + +// prototypes + +static bool match_rec (char string[], const char pattern[], char * star[]); + +// functions + +// match() + +bool match(char string[], const char pattern[]) { + + ASSERT(string!=NULL); + ASSERT(pattern!=NULL); + + ASSERT(strstr(pattern,"**")==NULL); + + return match_rec(string,pattern,Star); +} + +// match_rec() + +static bool match_rec(char string[], const char pattern[], char * star[]) { + + int c; + + ASSERT(string!=NULL); + ASSERT(pattern!=NULL); + ASSERT(star!=NULL); + + // iterative matches + + while ((c=*pattern++) != '*') { + if (false) { + } else if (c == '\0') { // end of pattern + while (*string == ' ') string++; // skip trailing spaces + return *string == '\0'; + } else if (c == ' ') { // spaces + if (*string++ != ' ') return false; // mismatch + while (*string == ' ') string++; // skip trailing spaces + } else { // normal character + if (*string++ != c) return false; // mismatch + } + } + + // recursive wildcard match + + ASSERT(c=='*'); + + while (*string == ' ') string++; // skip leading spaces + *star++ = string; // remember beginning of star + + while ((c=*string++) != '\0') { // reject empty-string match + if (c != ' ' && match_rec(string,pattern,star)) { // shortest match + ASSERT(string>star[-1]); + *string = '\0'; // truncate star + return true; + } + } + + return false; +} + +// parse_is_ok() + +bool parse_is_ok(const parse_t * parse) { + + if (parse == NULL) return false; + if (parse->string == NULL) return false; + if (parse->pos < 0 || parse->pos > strlen(parse->string)) return false; + if (parse->keyword_nb < 0 || parse->keyword_nb >= KEYWORD_NUMBER) return false; + + return true; +} + +// parse_open() + +void parse_open(parse_t * parse, const char string[]) { + + ASSERT(parse!=NULL); + ASSERT(string!=NULL); + + parse->string = string; + parse->pos = 0; + parse->keyword_nb = 0; +} + +// parse_close() + +void parse_close(parse_t * parse) { + + int i; + + ASSERT(parse_is_ok(parse)); + + parse->string = NULL; + parse->pos = 0; + + for (i = 0; i < parse->keyword_nb; i++) { + my_string_clear(&parse->keyword[i]); + } + + parse->keyword_nb = 0; +} + +// parse_add_keyword() + +void parse_add_keyword(parse_t * parse, const char keyword[]) { + + const char * * string; + + ASSERT(parse_is_ok(parse)); + ASSERT(keyword!=NULL); + + if (parse->keyword_nb < KEYWORD_NUMBER) { + + string = &parse->keyword[parse->keyword_nb]; + parse->keyword_nb++; + + *string = NULL; + my_string_set(string,keyword); + } +} + +// parse_get_word() + +bool parse_get_word(parse_t * parse, char string[], int size) { + + int pos; + int c; + + ASSERT(parse!=NULL); + ASSERT(string!=NULL); + ASSERT(size>=256); + + // skip blanks + + for (; parse->string[parse->pos] == ' '; parse->pos++) + ; + + ASSERT(parse->string[parse->pos]!=' '); + + // copy word + + pos = 0; + + while (true) { + + c = parse->string[parse->pos]; + if (c == ' ' || pos >= size-1) c = '\0'; + + string[pos] = c; + if (c == '\0') break; + + parse->pos++; + pos++; + } + + ASSERT(strchr(string,' ')==NULL); + + return pos > 0; // non-empty word? +} + +// parse_get_string() + +bool parse_get_string(parse_t * parse, char string[], int size) { + + int pos; + parse_t parse_2[1]; + char word[StringSize]; + int i; + int c; + + ASSERT(parse!=NULL); + ASSERT(string!=NULL); + ASSERT(size>=256); + + // skip blanks + + for (; parse->string[parse->pos] == ' '; parse->pos++) + ; + + ASSERT(parse->string[parse->pos]!=' '); + + // copy string + + pos = 0; + + while (true) { + + parse_open(parse_2,&parse->string[parse->pos]); + + if (!parse_get_word(parse_2,word,StringSize)) { + string[pos] = '\0'; + parse_close(parse_2); + goto finished; + } + + for (i = 0; i < parse->keyword_nb; i++) { + if (my_string_equal(parse->keyword[i],word)) { + string[pos] = '\0'; + parse_close(parse_2); + goto finished; + } + } + + parse_close(parse_2); + + // copy spaces + + while (true) { + + c = parse->string[parse->pos]; + if (c != ' ') break; + + if (pos >= size-1) c = '\0'; + + string[pos] = c; + if (c == '\0') break; + + parse->pos++; + pos++; + } + + // copy non spaces + + while (true) { + + c = parse->string[parse->pos]; + if (c == ' ' || pos >= size-1) c = '\0'; + + string[pos] = c; + if (c == '\0') break; + + parse->pos++; + pos++; + } + + string[pos] = '\0'; + } + +finished: ; + + return pos > 0; // non-empty string? +} + +// end of parse.cpp + diff --git a/parse.h b/parse.h new file mode 100644 index 0000000..dbd1f4f --- /dev/null +++ b/parse.h @@ -0,0 +1,44 @@ + +// parse.h + +#ifndef PARSE_H +#define PARSE_H + +// includes + +#include "util.h" + +// constants + +const int STAR_NUMBER = 16; +const int KEYWORD_NUMBER = 256; + +// types + +struct parse_t { + const char * string; + int pos; + int keyword_nb; + const char * keyword[KEYWORD_NUMBER]; +}; + +// variables + +extern char * Star[STAR_NUMBER]; + +// functions + +extern bool match (char string[], const char pattern[]); + +extern void parse_open (parse_t * parse, const char string[]); +extern void parse_close (parse_t * parse); + +extern void parse_add_keyword (parse_t * parse, const char keyword[]); + +extern bool parse_get_word (parse_t * parse, char string[], int size); +extern bool parse_get_string (parse_t * parse, char string[], int size); + +#endif // !defined PARSE_H + +// end of parse.h + diff --git a/pgn.cpp b/pgn.cpp new file mode 100644 index 0000000..5fe07fe --- /dev/null +++ b/pgn.cpp @@ -0,0 +1,641 @@ + +// pgn.cpp + +// includes + +#include +#include +#include +#include + +#include "pgn.h" +#include "util.h" + +// constants + +static const bool DispMove = false; +static const bool DispToken = false; +static const bool DispChar = false; + +static const int TAB_SIZE = 8; + +static const int CHAR_EOF = 256; + +// types + +enum token_t { + TOKEN_ERROR = -1, + TOKEN_EOF = 256, + TOKEN_SYMBOL = 257, + TOKEN_STRING = 258, + TOKEN_INTEGER = 259, + TOKEN_NAG = 260, + TOKEN_RESULT = 261 +}; + +// prototypes + +static void pgn_token_read (pgn_t * pgn); +static void pgn_token_unread (pgn_t * pgn); + +static void pgn_read_token (pgn_t * pgn); + +static bool is_symbol_start (int c); +static bool is_symbol_next (int c); + +static void pgn_skip_blanks (pgn_t * pgn); + +static void pgn_char_read (pgn_t * pgn); +static void pgn_char_unread (pgn_t * pgn); + +// functions + +// pgn_open() + +void pgn_open(pgn_t * pgn, const char file_name[]) { + + ASSERT(pgn!=NULL); + ASSERT(file_name!=NULL); + + pgn->file = fopen(file_name,"r"); + if (pgn->file == NULL) my_fatal("pgn_open(): can't open file \"%s\": %s\n",file_name,strerror(errno)); + + pgn->char_hack = CHAR_EOF; // DEBUG + pgn->char_line = 1; + pgn->char_column = 0; + pgn->char_unread = false; + pgn->char_first = true; + + pgn->token_type = TOKEN_ERROR; // DEBUG + strcpy(pgn->token_string,"?"); // DEBUG + pgn->token_length = -1; // DEBUG + pgn->token_line = -1; // DEBUG + pgn->token_column = -1; // DEBUG + pgn->token_unread = false; + pgn->token_first = true; + + strcpy(pgn->result,"?"); // DEBUG + strcpy(pgn->fen,"?"); // DEBUG + + pgn->move_line = -1; // DEBUG + pgn->move_column = -1; // DEBUG +} + +// pgn_close() + +void pgn_close(pgn_t * pgn) { + + ASSERT(pgn!=NULL); + + fclose(pgn->file); +} + +// pgn_next_game() + +bool pgn_next_game(pgn_t * pgn) { + + char name[PGN_STRING_SIZE]; + char value[PGN_STRING_SIZE]; + + ASSERT(pgn!=NULL); + + // init + + strcpy(pgn->result,"*"); + strcpy(pgn->fen,""); + + // loop + + while (true) { + + pgn_token_read(pgn); + + if (pgn->token_type != '[') break; + + // tag + + pgn_token_read(pgn); + if (pgn->token_type != TOKEN_SYMBOL) { + my_fatal("pgn_next_game(): malformed tag at line %d, column %d, game %d\n",pgn->token_line,pgn->token_column,pgn->game_nb); + } + strcpy(name,pgn->token_string); + + pgn_token_read(pgn); + if (pgn->token_type != TOKEN_STRING) { + my_fatal("pgn_next_game(): malformed tag at line %d, column %d, game %d\n",pgn->token_line,pgn->token_column,pgn->game_nb); + } + strcpy(value,pgn->token_string); + + pgn_token_read(pgn); + if (pgn->token_type != ']') { + my_fatal("pgn_next_game(): malformed tag at line %d, column %d, game %d\n",pgn->token_line,pgn->token_column,pgn->game_nb); + } + + // special tag? + + if (false) { + } else if (my_string_equal(name,"Result")) { + strcpy(pgn->result,value); + } else if (my_string_equal(name,"FEN")) { + strcpy(pgn->fen,value); + } + } + + if (pgn->token_type == TOKEN_EOF) return false; + + pgn_token_unread(pgn); + + return true; +} + +// pgn_next_move() + +bool pgn_next_move(pgn_t * pgn, char string[], int size) { + + int depth; + + ASSERT(pgn!=NULL); + ASSERT(string!=NULL); + ASSERT(size>=PGN_STRING_SIZE); + + // init + + pgn->move_line = -1; // DEBUG + pgn->move_column = -1; // DEBUG + + // loop + + depth = 0; + + while (true) { + + pgn_token_read(pgn); + + if (false) { + + } else if (pgn->token_type == '(') { + + // open RAV + + depth++; + + } else if (pgn->token_type == ')') { + + // close RAV + + if (depth == 0) { + my_fatal("pgn_next_move(): malformed variation at line %d, column %d, game %d\n",pgn->token_line,pgn->token_column,pgn->game_nb); + } + + depth--; + ASSERT(depth>=0); + + } else if (pgn->token_type == TOKEN_RESULT) { + + // game finished + + if (depth > 0) { + my_fatal("pgn_next_move(): malformed variation at line %d, column %d, game %d\n",pgn->token_line,pgn->token_column,pgn->game_nb); + } + + return false; + + } else { + + // skip optional move number + + if (pgn->token_type == TOKEN_INTEGER) { + do pgn_token_read(pgn); while (pgn->token_type == '.'); + } + + // move must be a symbol + + if (pgn->token_type != TOKEN_SYMBOL) { + my_fatal("pgn_next_move(): malformed move at line %d, column %d, game %d\n",pgn->token_line,pgn->token_column,pgn->game_nb); + } + + // store move for later use + + if (depth == 0) { + + if (pgn->token_length >= size) { + my_fatal("pgn_next_move(): move too long at line %d, column %d, game %d\n",pgn->token_line,pgn->token_column,pgn->game_nb); + } + + strcpy(string,pgn->token_string); + pgn->move_line = pgn->token_line; + pgn->move_column = pgn->token_column; + } + + // skip optional NAGs + + do pgn_token_read(pgn); while (pgn->token_type == TOKEN_NAG); + pgn_token_unread(pgn); + + // return move + + if (depth == 0) { + if (DispMove) printf("move=\"%s\"\n",string); + return true; + } + } + } + + ASSERT(false); + + return false; +} + +// pgn_token_read() + +static void pgn_token_read(pgn_t * pgn) { + + ASSERT(pgn!=NULL); + + // token "stack" + + if (pgn->token_unread) { + pgn->token_unread = false; + return; + } + + // consume the current token + + if (pgn->token_first) { + pgn->token_first = false; + } else { + ASSERT(pgn->token_type!=TOKEN_ERROR); + ASSERT(pgn->token_type!=TOKEN_EOF); + } + + // read a new token + + pgn_read_token(pgn); + if (pgn->token_type == TOKEN_ERROR) my_fatal("pgn_token_read(): lexical error at line %d, column %d, game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + + if (DispToken) printf("< L%d C%d \"%s\" (%03X)\n",pgn->token_line,pgn->token_column,pgn->token_string,pgn->token_type); +} + +// pgn_token_unread() + +static void pgn_token_unread(pgn_t * pgn) { + + ASSERT(pgn!=NULL); + + ASSERT(!pgn->token_unread); + ASSERT(!pgn->token_first); + + pgn->token_unread = true; +} + +// pgn_read_token() + +static void pgn_read_token(pgn_t * pgn) { + + ASSERT(pgn!=NULL); + + // skip white-space characters + + pgn_skip_blanks(pgn); + + // init + + pgn->token_type = TOKEN_ERROR; + strcpy(pgn->token_string,""); + pgn->token_length = 0; + pgn->token_line = pgn->char_line; + pgn->token_column = pgn->char_column; + + // determine token type + + if (false) { + + } else if (pgn->char_hack == CHAR_EOF) { + + pgn->token_type = TOKEN_EOF; + + } else if (strchr(".[]()<>",pgn->char_hack) != NULL) { + + // single-character token + + pgn->token_type = pgn->char_hack; + sprintf(pgn->token_string,"%c",pgn->char_hack); + pgn->token_length = 1; + + } else if (pgn->char_hack == '*') { + + pgn->token_type = TOKEN_RESULT; + sprintf(pgn->token_string,"%c",pgn->char_hack); + pgn->token_length = 1; + + } else if (pgn->char_hack == '!') { + + pgn_char_read(pgn); + + if (false) { + + } else if (pgn->char_hack == '!') { // "!!" + + pgn->token_type = TOKEN_NAG; + strcpy(pgn->token_string,"3"); + pgn->token_length = 1; + + } else if (pgn->char_hack == '?') { // "!?" + + pgn->token_type = TOKEN_NAG; + strcpy(pgn->token_string,"5"); + pgn->token_length = 1; + + } else { // "!" + + pgn_char_unread(pgn); + + pgn->token_type = TOKEN_NAG; + strcpy(pgn->token_string,"1"); + pgn->token_length = 1; + } + + } else if (pgn->char_hack == '?') { + + pgn_char_read(pgn); + + if (false) { + + } else if (pgn->char_hack == '?') { // "??" + + pgn->token_type = TOKEN_NAG; + strcpy(pgn->token_string,"4"); + pgn->token_length = 1; + + } else if (pgn->char_hack == '!') { // "?!" + + pgn->token_type = TOKEN_NAG; + strcpy(pgn->token_string,"6"); + pgn->token_length = 1; + + } else { // "?" + + pgn_char_unread(pgn); + + pgn->token_type = TOKEN_NAG; + strcpy(pgn->token_string,"2"); + pgn->token_length = 1; + } + + } else if (is_symbol_start(pgn->char_hack)) { + + // symbol, integer, or result + + pgn->token_type = TOKEN_INTEGER; + pgn->token_length = 0; + + do { + + if (pgn->token_length >= PGN_STRING_SIZE-1) { + my_fatal("pgn_read_token(): symbol too long at line %d, column %d,game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } + + if (!isdigit(pgn->char_hack)) pgn->token_type = TOKEN_SYMBOL; + + pgn->token_string[pgn->token_length++] = pgn->char_hack; + + pgn_char_read(pgn); + + } while (is_symbol_next(pgn->char_hack)); + + pgn_char_unread(pgn); + + ASSERT(pgn->token_length>0&&pgn->token_lengthtoken_string[pgn->token_length] = '\0'; + + if (my_string_equal(pgn->token_string,"1-0") + || my_string_equal(pgn->token_string,"0-1") + || my_string_equal(pgn->token_string,"1/2-1/2")) { + pgn->token_type = TOKEN_RESULT; + } + + } else if (pgn->char_hack == '"') { + + // string + + pgn->token_type = TOKEN_STRING; + pgn->token_length = 0; + + while (true) { + + pgn_char_read(pgn); + + if (pgn->char_hack == CHAR_EOF) { + my_fatal("pgn_read_token(): EOF in string at line %d, column %d, game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } + + if (pgn->char_hack == '"') break; + + if (pgn->char_hack == '\\') { + + pgn_char_read(pgn); + + if (pgn->char_hack == CHAR_EOF) { + my_fatal("pgn_read_token(): EOF in string at line %d, column %d, game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } + + if (pgn->char_hack != '"' && pgn->char_hack != '\\') { + + // bad escape, ignore + + if (pgn->token_length >= PGN_STRING_SIZE-1) { + my_fatal("pgn_read_token(): string too long at line %d, column %d,game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } + + pgn->token_string[pgn->token_length++] = '\\'; + } + } + + if (pgn->token_length >= PGN_STRING_SIZE-1) { + my_fatal("pgn_read_token(): string too long at line %d, column %d,game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } + + pgn->token_string[pgn->token_length++] = pgn->char_hack; + } + + ASSERT(pgn->token_length>=0&&pgn->token_lengthtoken_string[pgn->token_length] = '\0'; + + } else if (pgn->char_hack == '$') { + + // NAG + + pgn->token_type = TOKEN_NAG; + pgn->token_length = 0; + + while (true) { + + pgn_char_read(pgn); + + if (!isdigit(pgn->char_hack)) break; + + if (pgn->token_length >= 3) { + my_fatal("pgn_read_token(): NAG too long at line %d, column %d, game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } + + pgn->token_string[pgn->token_length++] = pgn->char_hack; + } + + pgn_char_unread(pgn); + + if (pgn->token_length == 0) { + my_fatal("pgn_read_token(): malformed NAG at line %d, column %d,game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } + + ASSERT(pgn->token_length>0&&pgn->token_length<=3); + pgn->token_string[pgn->token_length] = '\0'; + + } else { + + // unknown token + + my_fatal("lexical error at line %d, column %d, game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } +} + +// pgn_skip_blanks() + +static void pgn_skip_blanks(pgn_t * pgn) { + + ASSERT(pgn!=NULL); + + while (true) { + + pgn_char_read(pgn); + + if (false) { + }else if(pgn->char_hack==CHAR_EOF){ break; + } else if (isspace(pgn->char_hack)) { + + // skip white space + + } else if (pgn->char_hack == ';') { + + // skip comment to EOL + + do { + + pgn_char_read(pgn); + + if (pgn->char_hack == CHAR_EOF) { + my_fatal("pgn_skip_blanks(): EOF in comment at line %d, column %d,game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } + + } while (pgn->char_hack != '\n'); + + } else if (pgn->char_hack == '%' && pgn->char_column == 0) { + + // skip comment to EOL + + do { + + pgn_char_read(pgn); + + if (pgn->char_hack == CHAR_EOF) { + my_fatal("pgn_skip_blanks(): EOF in comment at line %d, column %d, game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } + + } while (pgn->char_hack != '\n'); + + } else if (pgn->char_hack == '{') { + + // skip comment to next '}' + + do { + + pgn_char_read(pgn); + + if (pgn->char_hack == CHAR_EOF) { + my_fatal("pgn_skip_blanks(): EOF in comment at line %d, column %d, game %d\n",pgn->char_line,pgn->char_column,pgn->game_nb); + } + + } while (pgn->char_hack != '}'); + + } else { // not a white space + + break; + } + } +} + +// is_symbol_start() + +static bool is_symbol_start(int c) { + + return strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",c) != NULL; +} + +// is_symbol_next() + +static bool is_symbol_next(int c) { + + return strchr("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_+#=:-/",c) != NULL; +} + +// pgn_char_read() + +static void pgn_char_read(pgn_t * pgn) { + + ASSERT(pgn!=NULL); + + // char "stack" + + if (pgn->char_unread) { + pgn->char_unread = false; + return; + } + + // consume the current character + + if (pgn->char_first) { + + pgn->char_first = false; + + } else { + + // update counters + + ASSERT(pgn->char_hack!=CHAR_EOF); + + if (false) { + } else if (pgn->char_hack == '\n') { + pgn->char_line++; + pgn->char_column = 0; + } else if (pgn->char_hack == '\t') { + pgn->char_column += TAB_SIZE - (pgn->char_column % TAB_SIZE); + } else { + pgn->char_column++; + } + } + + // read a new character + + pgn->char_hack = fgetc(pgn->file); + + if (pgn->char_hack == EOF) { + if (ferror(pgn->file)) my_fatal("pgn_char_read(): fgetc(): %s\n",strerror(errno)); + pgn->char_hack = CHAR_EOF; + } + + if (DispChar) printf("< L%d C%d '%c' (%02X)\n",pgn->char_line,pgn->char_column,pgn->char_hack,pgn->char_hack); +} + +// pgn_char_unread() + +static void pgn_char_unread(pgn_t * pgn) { + + ASSERT(pgn!=NULL); + + ASSERT(!pgn->char_unread); + ASSERT(!pgn->char_first); + + pgn->char_unread = true; +} + +// end of pgn.cpp + diff --git a/pgn.h b/pgn.h new file mode 100644 index 0000000..e79fc3f --- /dev/null +++ b/pgn.h @@ -0,0 +1,56 @@ + +// pgn.h + +#ifndef PGN_H +#define PGN_H + +// includes + +#include + +#include "util.h" + +// constants + +const int PGN_STRING_SIZE = 256; + +// types + +struct pgn_t { + + FILE * file; + + int char_hack; + int char_line; + int char_column; + bool char_unread; + bool char_first; + + int token_type; + char token_string[PGN_STRING_SIZE]; + int token_length; + int token_line; + int token_column; + bool token_unread; + bool token_first; + + char result[PGN_STRING_SIZE]; + char fen[PGN_STRING_SIZE]; + + int move_line; + int move_column; + int game_nb; +}; + +// functions + +extern void pgn_open (pgn_t * pgn, const char file_name[]); +extern void pgn_close (pgn_t * pgn); + +extern bool pgn_next_game (pgn_t * pgn); +extern bool pgn_next_move (pgn_t * pgn, char string[], int size); + +#endif // !defined PGN_H + +// end of pgn.h + diff --git a/piece.cpp b/piece.cpp new file mode 100644 index 0000000..719299f --- /dev/null +++ b/piece.cpp @@ -0,0 +1,203 @@ + +// piece.cpp + +// includes + +#include + +#include "colour.h" +#include "piece.h" +#include "util.h" + +// "constants" + +static const uint8 MakePawn[ColourNb] = { PieceNone256, BlackPawn256, WhitePawn256 }; // -BW + +static const uint8 PieceFrom12[12] = { + BlackPawn256, WhitePawn256, + BlackKnight256, WhiteKnight256, + BlackBishop256, WhiteBishop256, + BlackRook256, WhiteRook256, + BlackQueen256, WhiteQueen256, + BlackKing256, WhiteKing256, +}; + +static const char PieceString[12+1] = "pPnNbBrRqQkK"; + +// variables + +static sint8 PieceTo12[256]; + +// functions + +// piece_init() + +void piece_init() { + + int piece; + + for (piece = 0; piece < 256; piece++) PieceTo12[piece] = -1; + + for (piece = 0; piece < 12; piece++) { + PieceTo12[PieceFrom12[piece]] = piece; + } +} + +// piece_is_ok() + +bool piece_is_ok(int piece) { + + if (piece < 0 || piece >= 256) return false; + + if (PieceTo12[piece] < 0) return false; + + return true; +} + +// piece_make_pawn() + +int piece_make_pawn(int colour) { + + ASSERT(colour_is_ok(colour)); + + return MakePawn[colour]; +} + +// piece_pawn_opp() + +int piece_pawn_opp(int piece) { + + ASSERT(piece==BlackPawn256||piece==WhitePawn256); + + return piece ^ 15; +} + +// piece_colour() + +int piece_colour(int piece) { + + ASSERT(piece_is_ok(piece)); + + return piece & 3; +} + +// piece_type() + +int piece_type(int piece) { + + ASSERT(piece_is_ok(piece)); + + return piece & ~3; +} + +// piece_is_pawn() + +bool piece_is_pawn(int piece) { + + ASSERT(piece_is_ok(piece)); + + return (piece & PawnFlags) != 0; +} + +// piece_is_knight() + +bool piece_is_knight(int piece) { + + ASSERT(piece_is_ok(piece)); + + return (piece & KnightFlag) != 0; +} + +// piece_is_bishop() + +bool piece_is_bishop(int piece) { + + ASSERT(piece_is_ok(piece)); + + return (piece & QueenFlags) == BishopFlag; +} + +// piece_is_rook() + +bool piece_is_rook(int piece) { + + ASSERT(piece_is_ok(piece)); + + return (piece & QueenFlags) == RookFlag; +} + +// piece_is_queen() + +bool piece_is_queen(int piece) { + + ASSERT(piece_is_ok(piece)); + + return (piece & QueenFlags) == QueenFlags; +} + +// piece_is_king() + +bool piece_is_king(int piece) { + + ASSERT(piece_is_ok(piece)); + + return (piece & KingFlag) != 0; +} + +// piece_is_slider() + +bool piece_is_slider(int piece) { + + ASSERT(piece_is_ok(piece)); + + return (piece & QueenFlags) != 0; +} + +// piece_to_12() + +int piece_to_12(int piece) { + + ASSERT(piece_is_ok(piece)); + + return PieceTo12[piece]; +} + +// piece_from_12() + +int piece_from_12(int piece) { + + ASSERT(piece>=0&&piece<12); + + return PieceFrom12[piece]; +} + +// piece_to_char() + +int piece_to_char(int piece) { + + ASSERT(piece_is_ok(piece)); + + return PieceString[piece_to_12(piece)]; +} + +// piece_from_char() + +int piece_from_char(int c) { + + const char * ptr; + + ptr = strchr(PieceString,c); + if (ptr == NULL) return PieceNone256; + + return piece_from_12(ptr-PieceString); +} + +// char_is_piece() + +bool char_is_piece(int c) { + + return strchr("PNBRQK",c) != NULL; +} + +// end of piece.cpp + diff --git a/piece.h b/piece.h new file mode 100644 index 0000000..a0bbafb --- /dev/null +++ b/piece.h @@ -0,0 +1,92 @@ + +// piece.h + +#ifndef PIECE_H +#define PIECE_H + +// includes + +#include "colour.h" +#include "util.h" + +// constants + +const int BlackPawnFlag = 1 << 2; +const int WhitePawnFlag = 1 << 3; +const int KnightFlag = 1 << 4; +const int BishopFlag = 1 << 5; +const int RookFlag = 1 << 6; +const int KingFlag = 1 << 7; + +const int PawnFlags = BlackPawnFlag | WhitePawnFlag; +const int QueenFlags = BishopFlag | RookFlag; + +const int PieceNone64 = 0; +const int BlackPawn64 = BlackPawnFlag; +const int WhitePawn64 = WhitePawnFlag; +const int Knight64 = KnightFlag; +const int Bishop64 = BishopFlag; +const int Rook64 = RookFlag; +const int Queen64 = QueenFlags; +const int King64 = KingFlag; + +const int PieceNone256 = 0; +const int BlackPawn256 = BlackPawn64 | Black; +const int WhitePawn256 = WhitePawn64 | White; +const int BlackKnight256 = Knight64 | Black; +const int WhiteKnight256 = Knight64 | White; +const int BlackBishop256 = Bishop64 | Black; +const int WhiteBishop256 = Bishop64 | White; +const int BlackRook256 = Rook64 | Black; +const int WhiteRook256 = Rook64 | White; +const int BlackQueen256 = Queen64 | Black; +const int WhiteQueen256 = Queen64 | White; +const int BlackKing256 = King64 | Black; +const int WhiteKing256 = King64 | White; + +const int BlackPawn12 = 0; +const int WhitePawn12 = 1; +const int BlackKnight12 = 2; +const int WhiteKnight12 = 3; +const int BlackBishop12 = 4; +const int WhiteBishop12 = 5; +const int BlackRook12 = 6; +const int WhiteRook12 = 7; +const int BlackQueen12 = 8; +const int WhiteQueen12 = 9; +const int BlackKing12 = 10; +const int WhiteKing12 = 11; + +// functions + +extern void piece_init (); + +extern bool piece_is_ok (int piece); + +extern int piece_make_pawn (int colour); +extern int piece_pawn_opp (int piece); + +extern int piece_colour (int piece); +extern int piece_type (int piece); + +extern bool piece_is_pawn (int piece); +extern bool piece_is_knight (int piece); +extern bool piece_is_bishop (int piece); +extern bool piece_is_rook (int piece); +extern bool piece_is_queen (int piece); +extern bool piece_is_king (int piece); + +extern bool piece_is_slider (int piece); + +extern int piece_to_12 (int piece); +extern int piece_from_12 (int piece); + +extern int piece_to_char (int piece); +extern int piece_from_char (int c); + +extern bool char_is_piece (int c); + +#endif // !defined PIECE_H + +// end of piece.h + diff --git a/pipe.cpp b/pipe.cpp new file mode 100644 index 0000000..3f8da2e --- /dev/null +++ b/pipe.cpp @@ -0,0 +1,158 @@ +#ifdef _WIN32 +#include "pipe.h" +#include "util.h" +void PipeStruct::Open(const char *szProcFile) { + DWORD dwMode; + HANDLE hStdinRead, hStdinWrite, hStdoutRead, hStdoutWrite; + SECURITY_ATTRIBUTES sa; + STARTUPINFO si; + PROCESS_INFORMATION pi; + + if (szProcFile == NULL) { + hInput = GetStdHandle(STD_INPUT_HANDLE); + hOutput = GetStdHandle(STD_OUTPUT_HANDLE); + bConsole = GetConsoleMode(hInput, &dwMode); + } else { + sa.nLength = sizeof(SECURITY_ATTRIBUTES); + sa.bInheritHandle = TRUE; + sa.lpSecurityDescriptor = NULL; + CreatePipe(&hStdinRead, &hStdinWrite, &sa, 0); + CreatePipe(&hStdoutRead, &hStdoutWrite, &sa, 0); + si.cb = sizeof(STARTUPINFO); + si.lpReserved = si.lpDesktop = si.lpTitle = NULL; + si.dwFlags = STARTF_USESTDHANDLES; + si.cbReserved2 = 0; + si.lpReserved2 = NULL; + si.hStdInput = hStdinRead; + si.hStdOutput = hStdoutWrite; + si.hStdError = hStdoutWrite; + if(!CreateProcess(NULL, (LPSTR) szProcFile, NULL, NULL, TRUE, DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP, NULL, NULL, &si, &pi)){ + my_fatal("PipeStruct::Open(): Could not start \"%s\"\n",szProcFile); + } + hProcess=pi.hProcess; + //CloseHandle(pi.hProcess);//not here,baby,but in pipe.close + CloseHandle(pi.hThread); + CloseHandle(hStdinRead); + CloseHandle(hStdoutWrite); + hInput = hStdoutRead; + hOutput = hStdinWrite; + bConsole = FALSE; + } + if (bConsole) { + SetConsoleMode(hInput, dwMode & ~(ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT)); + FlushConsoleInputBuffer(hInput); + } else { + nBytesLeft = 0; + } + nReadEnd = 0; +} + +void PipeStruct::Close(void) const { + CloseHandle(hInput); + CloseHandle(hOutput); + DWORD lpexit; + + my_log("POLYGLOT Closing child\n"); + if(GetExitCodeProcess(hProcess,&lpexit)){ + if(lpexit==STILL_ACTIVE) + my_log("POLYGLOT Process still active after \"quit\" "); + //must be java,hammer it down! + TerminateProcess(hProcess,lpexit); + } + CloseHandle(hProcess); +} + +void PipeStruct::ReadInput(void) { + DWORD dwBytes; + if(!ReadFile(hInput, szBuffer + nReadEnd, LINE_INPUT_MAX_CHAR - nReadEnd, &dwBytes, NULL)){ + // TODO move this comment to a more suitable place + my_log("POLYGLOT *** EOF from Engine or GUI ***\n"); + exit(EXIT_SUCCESS); // if we are here there should be data! + } + nReadEnd += dwBytes; + if (nBytesLeft > 0) { + nBytesLeft -= dwBytes; + } +} + +bool PipeStruct::CheckInput(void) { + DWORD dwEvents, dwBytes; + if (bConsole) { // a tty, or an un-redirected handle + GetNumberOfConsoleInputEvents(hInput, &dwEvents); + if (dwEvents > 1) { + return TRUE; + } else { + return FALSE; + } + } else { // a handle redirected to a pipe or a file + if (nBytesLeft > 0) { + return TRUE; + } else { + if (PeekNamedPipe(hInput, NULL, 0, NULL, &dwBytes, NULL)) { + nBytesLeft = dwBytes; + return nBytesLeft > 0; // a pipe + } else { + return TRUE; // a file, always TRUE + } + } + } +} + +void PipeStruct::LineOutput(const char *szLineStr) const { + DWORD dwBytes; + int nStrLen; + char szWriteBuffer[LINE_INPUT_MAX_CHAR]; + nStrLen = strlen(szLineStr); + memcpy(szWriteBuffer, szLineStr, nStrLen); + szWriteBuffer[nStrLen] = '\r'; + szWriteBuffer[nStrLen + 1] = '\n'; + WriteFile(hOutput, szWriteBuffer, nStrLen + 2, &dwBytes, NULL); +} + + + +bool PipeStruct::GetBuffer(char *szLineStr) { + char *lpFeedEnd; + int nFeedEnd; + lpFeedEnd = (char *) memchr(szBuffer, '\n', nReadEnd); + if (lpFeedEnd == NULL) { + return FALSE; + } else { + nFeedEnd = lpFeedEnd - szBuffer; + memcpy(szLineStr, szBuffer, nFeedEnd); + if (szLineStr[nFeedEnd - 1] == '\r') { + szLineStr[nFeedEnd - 1] = '\0'; + } else { + szLineStr[nFeedEnd] = '\0'; + } + nFeedEnd ++; + nReadEnd -= nFeedEnd; + memcpy(szBuffer, szBuffer + nFeedEnd, nReadEnd); + return TRUE; + } +} + +bool PipeStruct::LineInput(char *szLineStr) { + if (GetBuffer(szLineStr)) { + return TRUE; + } + if (CheckInput()) { + ReadInput(); + if (GetBuffer(szLineStr)) { + return TRUE; + } else { + if (nReadEnd == LINE_INPUT_MAX_CHAR) { + memcpy(szLineStr, szBuffer, LINE_INPUT_MAX_CHAR - 1); + szLineStr[LINE_INPUT_MAX_CHAR - 1] = '\0'; + szBuffer[0] = szBuffer[LINE_INPUT_MAX_CHAR - 1]; + nReadEnd = 1; + return TRUE; + } else { + return FALSE; + } + } + } else { + return FALSE; + } +} +#endif diff --git a/pipe.h b/pipe.h new file mode 100644 index 0000000..b13f513 --- /dev/null +++ b/pipe.h @@ -0,0 +1,33 @@ +#ifndef PIPE_H +#define PIPE_H +#ifdef _WIN32 +// includes + +#include + + +// constants + +const int LINE_INPUT_MAX_CHAR = 4096; + +// types + +struct PipeStruct { + HANDLE hInput, hOutput; + HANDLE hProcess; + BOOL bConsole; + int nBytesLeft; + int nReadEnd; + char szBuffer[LINE_INPUT_MAX_CHAR]; + + void Open(const char *szExecFile = NULL); + void Close(void) const; + void ReadInput(void); + bool CheckInput(void); + bool GetBuffer(char *szLineStr); + bool LineInput(char *szLineStr); + void LineOutput(const char *szLineStr) const; +}; // pipe + +#endif +#endif diff --git a/polyglot.man b/polyglot.man new file mode 100644 index 0000000..79a28a0 --- /dev/null +++ b/polyglot.man @@ -0,0 +1,534 @@ +.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32 +.\" +.\" Standard preamble: +.\" ======================================================================== +.de Sh \" Subsection heading +.br +.if t .Sp +.ne 5 +.PP +\fB\\$1\fR +.PP +.. +.de Sp \" Vertical space (when we can't use .PP) +.if t .sp .5v +.if n .sp +.. +.de Vb \" Begin verbatim text +.ft CW +.nf +.ne \\$1 +.. +.de Ve \" End verbatim text +.ft R +.fi +.. +.\" Set up some character translations and predefined strings. \*(-- will +.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left +.\" double quote, and \*(R" will give a right double quote. \*(C+ will +.\" give a nicer C++. Capital omega is used to do unbreakable dashes and +.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, +.\" nothing in troff, for use with C<>. +.tr \(*W- +.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' +.ie n \{\ +. ds -- \(*W- +. ds PI pi +. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch +. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch +. ds L" "" +. ds R" "" +. ds C` "" +. ds C' "" +'br\} +.el\{\ +. ds -- \|\(em\| +. ds PI \(*p +. ds L" `` +. ds R" '' +'br\} +.\" +.\" If the F register is turned on, we'll generate index entries on stderr for +.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index +.\" entries marked with X<> in POD. Of course, you'll have to process the +.\" output yourself in some meaningful fashion. +.if \nF \{\ +. de IX +. tm Index:\\$1\t\\n%\t"\\$2" +.. +. nr % 0 +. rr F +.\} +.\" +.\" For nroff, turn off justification. Always turn off hyphenation; it makes +.\" way too many mistakes in technical documents. +.hy 0 +.if n .na +.\" +.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). +.\" Fear. Run. Save yourself. No user-serviceable parts. +. \" fudge factors for nroff and troff +.if n \{\ +. ds #H 0 +. ds #V .8m +. ds #F .3m +. ds #[ \f1 +. ds #] \fP +.\} +.if t \{\ +. ds #H ((1u-(\\\\n(.fu%2u))*.13m) +. ds #V .6m +. ds #F 0 +. ds #[ \& +. ds #] \& +.\} +. \" simple accents for nroff and troff +.if n \{\ +. ds ' \& +. ds ` \& +. ds ^ \& +. ds , \& +. ds ~ ~ +. ds / +.\} +.if t \{\ +. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" +. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' +. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' +. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' +. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' +. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' +.\} +. \" troff and (daisy-wheel) nroff accents +.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' +.ds 8 \h'\*(#H'\(*b\h'-\*(#H' +.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] +.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' +.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' +.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] +.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] +.ds ae a\h'-(\w'a'u*4/10)'e +.ds Ae A\h'-(\w'A'u*4/10)'E +. \" corrections for vroff +.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' +.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' +. \" for low resolution devices (crt and lpr) +.if \n(.H>23 .if \n(.V>19 \ +\{\ +. ds : e +. ds 8 ss +. ds o a +. ds d- d\h'-1'\(ga +. ds D- D\h'-1'\(hy +. ds th \o'bp' +. ds Th \o'LP' +. ds ae ae +. ds Ae AE +.\} +.rm #[ #] #H #V #F C +.\" ======================================================================== +.\" +.IX Title "POLYGLOT 6" +.TH POLYGLOT 6 "2009-01-10" "" "" +.SH "NAME" +PolyGlot \- Winboard protocol to UCI protocol adapter + \- book engine for Polyglot books + \- a collection of utilities for creating opening books + \- a utility for analyzing epd files + \- a perft counter +.SH "SYNOPSIS" +.IX Header "SYNOPSIS" +polyglot [configfile] +.PP +polyglot make-book [\-pgn inputfile] [\-bin outputfile] [\-max\-ply ply] [\-min\-game games] [\-min\-score score] [\-only\-white] [\-only\-black] [\-uniform] +.PP +polyglot merge-book \-in1 inputfile1 \-in2 inputfile2 [\-out outputfile] +.PP +polyglot [configfile] epd-test [\-epd inputfile] [\-min\-depth depth] [\-max\-depth depth] [\-max\-time time] [\-depth\-delta delta] +.PP +polyglot perft [\-fen fen] [\-max\-depth depth] +.SH "DESCRIPTION" +.IX Header "DESCRIPTION" +.Sh "PolyGlot as adapter and book engine" +.IX Subsection "PolyGlot as adapter and book engine" +PolyGlot is a \*(L"\s-1UCI\s0 adapter\*(R". It connects a \s-1GUI\s0 interface (such as +XBoard, Winboard, Arena or Chessbase) to a \s-1UCI\s0 chess engine. +.PP +By specifying an opening book (in PolyGlot book format) chess engines can +transparently use such books. +.PP +PolyGlot understands the two main \s-1GUI\s0 protocols: \s-1UCI\s0 and +xboard. Normally the protocol will be auto detected but this can be +overridden in the configuration file. +.PP +In xboard mode PolyGlot fully translates between the xboard and \s-1UCI\s0 protocols. +In addition it tries to solve known problems with other adapters. +For instance, it detects and reports draws by fifty-move rule, +repetition, etc ... It also supports Chess960. +.PP +When in \s-1UCI\s0 mode PolyGlot mostly passes commands from the \s-1GUI\s0 +to the engine and vice versa, except that it will play book moves on +behalf of the engine when the occasion arises. +.Sh "Book making utilities" +.IX Subsection "Book making utilities" +PolyGlot supports the \*(L"PolyGlot opening book format\*(R". This is the +defacto standard non-proprietary opening book format. It is fully documented +here +.PP +http://alpha.uhasselt.be/Research/Algebra/Toga/book_format.html +.PP +Roughly speaking a PolyGlot opening book is a collection of triples +(position, move, weight). A \*(L"position\*(R" is represented by a 64\-bit +Zobrist hash key. The weight is proportional to the probability the move should +be played. +.PP +Other opening book formats such as ChessBase's .ctg format and Arena's +\&.abk format are undocumented and proprietary. They can only be used +by their own GUIs. +.PP +PolyGlot can compile a pgn file into a binary PolyGlot book and furthermore +it can merge two such binary books into a third one. +.Sh "Epd test mode" +.IX Subsection "Epd test mode" +In epd test mode, PolyGlot will search positions in an epd file and +record the number of times the right best move was found. The +arguments specify when to stop the search in any given position. +.Sh "Perft counts" +.IX Subsection "Perft counts" +A perft count is the number of legal move sequence in a given position +up to a given depth. PolyGlot can perform such perft counts. It +is however much slower than other more dedicated programs. +.SH "OPTIONS" +.IX Header "OPTIONS" +When invoked without options or with a config file as argument PolyGlot +acts as an adapter. The config file format is documented below. The +default config file is \*(L"polyglot.ini\*(R". +.PP +When invoked as +.Sh "polyglot make-book" +.IX Subsection "polyglot make-book" +PolyGlot supports the following options +.ie n .IP "\fB\-pgn\fR (default: ""book.pgn"")" 4 +.el .IP "\fB\-pgn\fR (default: ``book.pgn'')" 4 +.IX Item "-pgn (default: book.pgn)" +Input file in pgn format. +.ie n .IP "\fB\-bin\fR (default: ""book.bin"")" 4 +.el .IP "\fB\-bin\fR (default: ``book.bin'')" 4 +.IX Item "-bin (default: book.bin)" +Output file in PolyGlot format. +.IP "\fB\-max\-ply\fR (default: 1024)" 4 +.IX Item "-max-ply (default: 1024)" +Specifies the maximum ply-depth of lines included in the book. +.IP "\fB\-min\-game\fR (default: 3)" 4 +.IX Item "-min-game (default: 3)" +Specifies the minimum number of games that have to contain this move for it to be included in the book. +.IP "\fB\-min\-score\fR (default: 0.0)" 4 +.IX Item "-min-score (default: 0.0)" +Specifies the minimum score (or weight) this move should have received for +it to be included in the book. The score is 2*(wins)+(draws), globally scaled +to fit into 16 bits. +.IP "\fB\-only\-white\fR" 4 +.IX Item "-only-white" +Include only moves for white in the book. +.IP "\fB\-only\-black\fR" 4 +.IX Item "-only-black" +Include only moves for black in the book. +.IP "\fB\-uniform\fR" 4 +.IX Item "-uniform" +Set all weights to 1. In other words, all moves will be selected with +equal probability. +.PP +When invoked +as +.Sh "polyglot merge-book" +.IX Subsection "polyglot merge-book" +PolyGlot supports the following options +.IP "\fB\-in1\fR" 4 +.IX Item "-in1" +First input file (in PolyGlot book format). +.IP "\fB\-in2\fR" 4 +.IX Item "-in2" +Second input file (in PolyGlot book format). +.IP "\fB\-out\fR (default: out.bin)" 4 +.IX Item "-out (default: out.bin)" +Output file (in PolyGlot book format). +.PP +Input files are not symmetrical, \*(L"in1\*(R" has priority over \*(L"in2\*(R". In other +words when a position occurs both in \*(L"in1\*(R" and \*(L"in2\*(R" only the +moves and weights from \*(L"in1\*(R" will be retained in \*(L"out\*(R". +.PP +When invoked as +.Sh "polyglot epd-test" +.IX Subsection "polyglot epd-test" +(possibly with a config file as first argument) PolyGlot supports the following +options +.IP "\fB\-max\-depth\fR (default: 63)" 4 +.IX Item "-max-depth (default: 63)" +Unconditionally stop the search when this depth has +been reached. +.IP "\fB\-max\-time\fR (default: 5.0)" 4 +.IX Item "-max-time (default: 5.0)" +Unconditionally stop the seach after this amount of time. +.IP "\fB\-depth\-delta\fR (default: 3)" 4 +.IX Item "-depth-delta (default: 3)" +Stop the search if the best move has been constant for this many depths, +on condition that the mininal depth and minimal time have been reached. +.IP "\fB\-min\-depth\fR (default: 8)" 4 +.IX Item "-min-depth (default: 8)" +Minimal search depth when the search is stopped using \*(L"\-depth\-delta\*(R". +.IP "\fB\-min\-time\fR (default: 1.0)" 4 +.IX Item "-min-time (default: 1.0)" +Minimal search time when the search is stopped using \*(L"\-depth\-delta\*(R". +.PP +When invoked as +.Sh "polyglot perft" +.IX Subsection "polyglot perft" +PolyGlot supports the following +options +.IP "\fB\-fen\fR (default: starting position)" 4 +.IX Item "-fen (default: starting position)" +Fen at which to start searching. +.IP "\fB\-max\-depth\fR (default: 1)" 4 +.IX Item "-max-depth (default: 1)" +Maximum depth to search. +.SH "CONFIG FILE FORMAT" +.IX Header "CONFIG FILE FORMAT" +There should be a different config file for each engine. +.PP +The config file is in the traditional \s-1INI\s0 format. +.PP +.Vb 6 +\& [PolyGLot] +\& option = value +\& ... +\& [Engine] +\& option = value +\& ... +.Ve +.PP +Lines starting with \*(L"#\*(R" are ignored. +.PP +\&\s-1NOTE:\s0 There can be spaces in option names or values. Do not use +quotes. Boolean values are written as \*(L"true\*(R" or \*(L"false\*(R". +.Sh "[PolyGlot] section" +.IX Subsection "[PolyGlot] section" +This section is used by PolyGlot only. The engine is unaware of these +options. The list of available options is detailed below. +.IP "\fBEngineName\fR (default: \s-1UCI\s0 name)" 4 +.IX Item "EngineName (default: UCI name)" +This is the name that will appear in the \s-1GUI\s0. It is +cosmetic only. You can use different names for tweaked versions of +the same engine. +.ie n .IP "\fBEngineDir\fR (default: ""."")" 4 +.el .IP "\fBEngineDir\fR (default: ``.'')" 4 +.IX Item "EngineDir (default: .)" +Full path of the directory where the engine is installed. You can use +\&\*(L".\*(R" (without the quotes) if you know that PolyGlot will be launched in +the engine directory or the engine is in the \*(L"path\*(R" and does not need +any data file. +.IP "\fBEngineCommand\fR" 4 +.IX Item "EngineCommand" +Put here the name of the engine executable file. You can also add +command-line arguments. Path searching is used and the current +directory will be \*(L"EngineDir\*(R". +.IP "\fBLog\fR (default: false)" 4 +.IX Item "Log (default: false)" +Whether PolyGlot should log all transactions with the interface and +the engine. This should be necessary only to locate problems. +.IP "\fBLogFile\fR (default: polyglot.log)" 4 +.IX Item "LogFile (default: polyglot.log)" +The name of the log file. Note that it is put where PolyGlot was +launched from, not into the engine directory. +.Sp +\&\s-1WARNING:\s0 Log files are not cleared between sessions, and can become +very large. It is safe to remove them though. +.IP "\fBResign\fR (default: false)" 4 +.IX Item "Resign (default: false)" +Set this to \*(L"true\*(R" if you want PolyGlot to resign on behalf of the +engine. +.Sp +\&\s-1NOTE:\s0 Some engines display buggy scores from time to time although the +best move is correct. Use this option only if you know what you are +doing (e.g. you always check the final position of games). +.IP "\fBResignMoves\fR (default: 3)" 4 +.IX Item "ResignMoves (default: 3)" +Number of consecutive moves with \*(L"resign\*(R" score (see below) before +PolyGlot resigns for the engine. Positions with only one legal move +are ignored. +.IP "\fBResignScore\fR (default: 600)" 4 +.IX Item "ResignScore (default: 600)" +This is the score in centipawns that will trigger resign \*(L"counting\*(R". +.IP "\fBShowPonder\fR (default: true)" 4 +.IX Item "ShowPonder (default: true)" +Show search information during engine pondering. Turning this off +might be better for interactive use in some interfaces. +.IP "\fBKibitzMove\fR (default: false)" 4 +.IX Item "KibitzMove (default: false)" +Whether to kibitz when playing a move. +.IP "\fBKibitzPV\fR (default: false)" 4 +.IX Item "KibitzPV (default: false)" +Whether to kibitz when the \s-1PV\s0 is changed (new iteration or new best move). +.ie n .IP "\fBKibitzCommand\fR (default: ""tellall"")" 4 +.el .IP "\fBKibitzCommand\fR (default: ``tellall'')" 4 +.IX Item "KibitzCommand (default: tellall)" +xboard command to use for kibitzing, normally \*(L"tellall\*(R" for kibitzing +or \*(L"tellothers\*(R" for whispering. +.IP "\fBKibitzDelay\fR (default: 5)" 4 +.IX Item "KibitzDelay (default: 5)" +How many seconds to wait before starting kibitzing. This has an +effect only if \*(L"KibitzPV\*(R" is selected, move kibitzes are always sent +regardless of the delay. +.IP "\fB\s-1UCI\s0\fR (default: false)" 4 +.IX Item "UCI (default: false)" +If true PolyGlot will not understand xboard commands. +.IP "\fBBook\fR (default: false)" 4 +.IX Item "Book (default: false)" +Indicates whether a PolyGlot book should be used. This has no effect +on the engine own book (which can be controlled with the \s-1UCI\s0 option +\&\*(L"OwnBook\*(R" in the [Engine] section). In particular, it is possible to +use both a PolyGlot book and an engine book. In that case, the engine +book will be used whenever PolyGlot is out of book. Remember that +PolyGlot is unaware of whether the engine is itself using a book or +not. +.IP "\fBChess960\fR (default: false)" 4 +.IX Item "Chess960 (default: false)" +Play Chess960 (also called Fischer Random Chess or \s-1FRC\s0), +.IP "\fBMateScore\fR (default: 10000)" 4 +.IX Item "MateScore (default: 10000)" +Mate score reported to \s-1GUI\s0 when in xboard mode. +.IP "\fBBookFile\fR (default: book.bin)" 4 +.IX Item "BookFile (default: book.bin)" +The name of the (binary) book file. Note that PolyGlot will look for +it in the directory it was launched from, not in the engine directory. +Of course, full path can be used in which case the current directory +does not matter. +.Sp +\&\s-1NOTE:\s0 When using PolyGlot with a \s-1UCI\s0 \s-1GUI\s0 this parameter can be set +via the \s-1UCI\s0 option \*(L"Polyglot BookFile\*(R". +.IP "\fBBookRandom\fR (default: true)" 4 +.IX Item "BookRandom (default: true)" +Select moves according to their weights in the book. If false the move +with the highest weight is selected. +.IP "\fBBookLearn\fR (default: false)" 4 +.IX Item "BookLearn (default: false)" +Record learning information in the opening book. Naturally this requires +the opening book to be writable. +.IP "\fBUseNice\fR (default: false)" 4 +.IX Item "UseNice (default: false)" +Run the engine at nice level 5, or \*(L"NiceValue\*(R" if it set. On some +operating systems it may be necessary to run the engine at lower +priority for it to be responsive to commands from PolyGlot while +searching. +.IP "\fBNiceValue\fR (default: 5)" 4 +.IX Item "NiceValue (default: 5)" +Nice levels go from \-20 to 20 with 20 being the lowest priority. +On Unix only root can set negative nice levels. On Windows the standard +Win32 priority levels are mapped in a sensible way to Unix nice levels. +.IP "\fBAffinity\fR (default: \-1)" 4 +.IX Item "Affinity (default: -1)" +This a bit vector in which each bit represents the processors that a +process is allowed to run on. This option works only on Windows. +.Sh "Work arounds" +.IX Subsection "Work arounds" +Work arounds are identical to options except that they should be used +only when necessary. Their purpose is to try to hide problems with +various software (not just engines). The default value is always +correct for bug-free software. +.PP +\&\s-1IMPORTANT:\s0 Any of these work arounds might be removed in future +versions of PolyGlot. You are strongly recommended to contact the +author of faulty software and truly fix the problem. +.PP +PolyGlot supports the following work arounds: +.IP "\fBUCIVersion\fR (default: 2)" 4 +.IX Item "UCIVersion (default: 2)" +The default value of 2 corresponds to \s-1UCI+\s0. Use 1 to select plain +\&\s-1UCI\s0 for engines that have problems with \s-1UCI+\s0. +.IP "\fBCanPonder\fR (default: false)" 4 +.IX Item "CanPonder (default: false)" +PolyGlot now conforms to the documented \s-1UCI\s0 behaviour: the engine will +be allowed to ponder only if it (the engine) declares the \*(L"Ponder\*(R" \s-1UCI\s0 +option. However some engines which can actually ponder do not declare +the option. This work around lets PolyGlot know that they can ponder. +.IP "\fBSyncStop\fR (default: false)" 4 +.IX Item "SyncStop (default: false)" +When a ponder miss occurs, Polyglot interrupts the engine and +\&\s-1IMMEDIATELY\s0 launches a new search. While there should be no problem +with this, some engines seem confused and corrupt their search board. +\&\*(L"SyncStop\*(R" forces PolyGlot to wait for the (now useless) ponder search +to finish before launching the new search. +.IP "\fBPromoteWorkAround\fR (default: false)" 4 +.IX Item "PromoteWorkAround (default: false)" +Some engines do not specify a promotion piece, e.g. they send \*(L"e7e8\*(R" +instead of the correct \*(L"e7e8q\*(R". This work around enables the +incorrect form (and of course promotes into a queen). +.IP "\fBRepeatPV\fR (default: true)" 4 +.IX Item "RepeatPV (default: true)" +When true, PolyGlot repeats the last pv string (which also contains +score,depth and time usage) it got from the engine. Some engines +however do not send a new pv string just before sending the move and +the now old pv string might confuse debugtools that parse the winboard +debug files. +.Sh "[Engine] section" +.IX Subsection "[Engine] section" +This section contains engine \s-1UCI\s0 options. PolyGlot does not +understand them, but sends the information to the engine at startup +(converted to \s-1UCI\s0 form). You can add any \s-1UCI\s0 option that makes sense +to the engine (not just the common options about hash-table size and +tablebases). +.PP +\&\s-1NOTE:\s0 use \s-1INI\s0 syntax, not \s-1UCI\s0. For example \*(L"OwnBook = true\*(R" is +correct. It will be replaced by PolyGlot with \*(L"setoption name OwnBook +value true\*(R" at engine startup. +.PP +Standard \s-1UCI\s0 options are +.PP +.Vb 4 +\& Hash +\& NalimovPath +\& NalimovCache +\& OwnBook +.Ve +.PP +Hidden options like \*(L"Ponder\*(R" or \*(L"UCI_xxx\*(R" are automatic +and should not be put in an \s-1INI\s0 file. +.PP +The other options are engine\-specific. Check their name using a \s-1UCI\s0 +\&\s-1GUI\s0 or launch the engine in a console and type \*(L"uci\*(R". +.SH "EXAMPLES" +.IX Header "EXAMPLES" +Compile \*(L"games.pgn\*(R" into a book \*(L"book.bin\*(R" retaining all lines of at +most 30 plies. +.PP +.Vb 1 +\& polyglot make\-book \-pgn games.pgn \-bin book.bin \-max\-ply 30 +.Ve +.PP +Merge books \*(L"in1.bin\*(R" and \*(L"in2.bin\*(R" into a book \*(L"out.bin\*(R". +.PP +.Vb 1 +\& polyglot merge\-book \-in1 w1.bin \-in2 w2.bin \-out w.bin +.Ve +.PP +Here is a minimal config file +.PP +.Vb 3 +\& [PolyGlot] +\& EngineCommand = fruit +\& [Engine] +.Ve +.SH "EXIT STATUS" +.IX Header "EXIT STATUS" +PolyGlot always returns 0 on exit. +.SH "AUTHORS" +.IX Header "AUTHORS" +Main author: Fabien Letouzey +.PP +Native Windows port: Huang Chen (\*(L"Morning Yellow\*(R") +.PP +Various enhancements: Fonzy Bleumers +.PP +\&\s-1UCI\s0 port: Michel Van den Bergh +.SH "SEE ALSO" +.IX Header "SEE ALSO" +\&\fIxboard\fR\|(6) diff --git a/polyglot.pod b/polyglot.pod new file mode 100644 index 0000000..362f9f4 --- /dev/null +++ b/polyglot.pod @@ -0,0 +1,485 @@ +=head1 NAME + +PolyGlot - Winboard protocol to UCI protocol adapter + - book engine for Polyglot books + - a collection of utilities for creating opening books + - a utility for analyzing epd files + - a perft counter + +=head1 SYNOPSIS + +polyglot [configfile] + +polyglot make-book [-pgn inputfile] [-bin outputfile] [-max-ply ply] [-min-game games] [-min-score score] [-only-white] [-only-black] [-uniform] + +polyglot merge-book -in1 inputfile1 -in2 inputfile2 [-out outputfile] + +polyglot [configfile] epd-test [-epd inputfile] [-min-depth depth] [-max-depth depth] [-max-time time] [-depth-delta delta] + +polyglot perft [-fen fen] [-max-depth depth] + +=head1 DESCRIPTION + +=head2 PolyGlot as adapter and book engine + +PolyGlot is a "UCI adapter". It connects a GUI interface (such as +XBoard, Winboard, Arena or Chessbase) to a UCI chess engine. + +By specifying an opening book (in PolyGlot book format) chess engines can +transparently use such books. + +PolyGlot understands the two main GUI protocols: UCI and +xboard. Normally the protocol will be auto detected but this can be +overridden in the configuration file. + +In xboard mode PolyGlot fully translates between the xboard and UCI protocols. +In addition it tries to solve known problems with other adapters. +For instance, it detects and reports draws by fifty-move rule, +repetition, etc ... It also supports Chess960. + +When in UCI mode PolyGlot mostly passes commands from the GUI +to the engine and vice versa, except that it will play book moves on +behalf of the engine when the occasion arises. + +=head2 Book making utilities + +PolyGlot supports the "PolyGlot opening book format". This is the +defacto standard non-proprietary opening book format. It is fully documented +here + +http://alpha.uhasselt.be/Research/Algebra/Toga/book_format.html + +Roughly speaking a PolyGlot opening book is a collection of triples +(position, move, weight). A "position" is represented by a 64-bit +Zobrist hash key. The weight is proportional to the probability the move should +be played. + +Other opening book formats such as ChessBase's .ctg format and Arena's +.abk format are undocumented and proprietary. They can only be used +by their own GUIs. + +PolyGlot can compile a pgn file into a binary PolyGlot book and furthermore +it can merge two such binary books into a third one. + +=head2 Epd test mode + +In epd test mode, PolyGlot will search positions in an epd file and +record the number of times the right best move was found. The +arguments specify when to stop the search in any given position. + +=head2 Perft counts + +A perft count is the number of legal move sequence in a given position +up to a given depth. PolyGlot can perform such perft counts. It +is however much slower than other more dedicated programs. + +=head1 OPTIONS + +When invoked without options or with a config file as argument PolyGlot +acts as an adapter. The config file format is documented below. The +default config file is "polyglot.ini". + +When invoked as + +=head2 polyglot make-book + +PolyGlot supports the following options + +=over 4 + +=item B<-pgn> (default: "book.pgn") + +Input file in pgn format. + +=item B<-bin> (default: "book.bin") + +Output file in PolyGlot format. + +=item B<-max-ply> (default: 1024) + +Specifies the maximum ply-depth of lines included in the book. + +=item B<-min-game> (default: 3) + +Specifies the minimum number of games that have to contain this move for it to be included in the book. + +=item B<-min-score> (default: 0.0) + +Specifies the minimum score (or weight) this move should have received for +it to be included in the book. The score is 2*(wins)+(draws), globally scaled +to fit into 16 bits. + +=item B<-only-white> + +Include only moves for white in the book. + +=item B<-only-black> + +Include only moves for black in the book. + +=item B<-uniform> + +Set all weights to 1. In other words, all moves will be selected with +equal probability. + +=back + +When invoked +as + +=head2 polyglot merge-book + +PolyGlot supports the following options + +=over 4 + +=item B<-in1> + +First input file (in PolyGlot book format). + +=item B<-in2> + +Second input file (in PolyGlot book format). + +=item B<-out> (default: out.bin) + +Output file (in PolyGlot book format). + +=back + +Input files are not symmetrical, "in1" has priority over "in2". In other +words when a position occurs both in "in1" and "in2" only the +moves and weights from "in1" will be retained in "out". + +When invoked as + +=head2 polyglot epd-test + +(possibly with a config file as first argument) PolyGlot supports the following +options + +=over 4 + +=item B<-max-depth> (default: 63) + +Unconditionally stop the search when this depth has +been reached. + +=item B<-max-time> (default: 5.0) + +Unconditionally stop the seach after this amount of time. + +=item B<-depth-delta> (default: 3) + +Stop the search if the best move has been constant for this many depths, +on condition that the mininal depth and minimal time have been reached. + +=item B<-min-depth> (default: 8) + +Minimal search depth when the search is stopped using "-depth-delta". + +=item B<-min-time> (default: 1.0) + +Minimal search time when the search is stopped using "-depth-delta". + + +=back + +When invoked as + +=head2 polyglot perft + +PolyGlot supports the following +options + +=over 4 + +=item B<-fen> (default: starting position) + +Fen at which to start searching. + +=item B<-max-depth> (default: 1) + +Maximum depth to search. + +=back + +=head1 CONFIG FILE FORMAT + +There should be a different config file for each engine. + +The config file is in the traditional INI format. + + [PolyGLot] + option = value + ... + [Engine] + option = value + ... + +Lines starting with "#" are ignored. + +NOTE: There can be spaces in option names or values. Do not use +quotes. Boolean values are written as "true" or "false". + +=head2 [PolyGlot] section + +This section is used by PolyGlot only. The engine is unaware of these +options. The list of available options is detailed below. + +=over 4 + +=item B (default: UCI name) + +This is the name that will appear in the GUI. It is +cosmetic only. You can use different names for tweaked versions of +the same engine. + +=item B (default: ".") + +Full path of the directory where the engine is installed. You can use +"." (without the quotes) if you know that PolyGlot will be launched in +the engine directory or the engine is in the "path" and does not need +any data file. + +=item B + +Put here the name of the engine executable file. You can also add +command-line arguments. Path searching is used and the current +directory will be "EngineDir". + +=item B (default: false) + +Whether PolyGlot should log all transactions with the interface and +the engine. This should be necessary only to locate problems. + +=item B (default: polyglot.log) + +The name of the log file. Note that it is put where PolyGlot was +launched from, not into the engine directory. + +WARNING: Log files are not cleared between sessions, and can become +very large. It is safe to remove them though. + +=item B (default: false) + +Set this to "true" if you want PolyGlot to resign on behalf of the +engine. + +NOTE: Some engines display buggy scores from time to time although the +best move is correct. Use this option only if you know what you are +doing (e.g. you always check the final position of games). + +=item B (default: 3) + +Number of consecutive moves with "resign" score (see below) before +PolyGlot resigns for the engine. Positions with only one legal move +are ignored. + +=item B (default: 600) + +This is the score in centipawns that will trigger resign "counting". + +=item B (default: true) + +Show search information during engine pondering. Turning this off +might be better for interactive use in some interfaces. + +=item B (default: false) + +Whether to kibitz when playing a move. + +=item B (default: false) + +Whether to kibitz when the PV is changed (new iteration or new best move). + +=item B (default: "tellall") + +xboard command to use for kibitzing, normally "tellall" for kibitzing +or "tellothers" for whispering. + + +=item B (default: 5) + +How many seconds to wait before starting kibitzing. This has an +effect only if "KibitzPV" is selected, move kibitzes are always sent +regardless of the delay. + +=item B (default: false) + +If true PolyGlot will not understand xboard commands. + +=item B (default: false) + +Indicates whether a PolyGlot book should be used. This has no effect +on the engine own book (which can be controlled with the UCI option +"OwnBook" in the [Engine] section). In particular, it is possible to +use both a PolyGlot book and an engine book. In that case, the engine +book will be used whenever PolyGlot is out of book. Remember that +PolyGlot is unaware of whether the engine is itself using a book or +not. + +=item B (default: false) + +Play Chess960 (also called Fischer Random Chess or FRC), + +=item B (default: 10000) + +Mate score reported to GUI when in xboard mode. + +=item B (default: book.bin) + +The name of the (binary) book file. Note that PolyGlot will look for +it in the directory it was launched from, not in the engine directory. +Of course, full path can be used in which case the current directory +does not matter. + +NOTE: When using PolyGlot with a UCI GUI this parameter can be set +via the UCI option "Polyglot BookFile". + +=item B (default: true) + +Select moves according to their weights in the book. If false the move +with the highest weight is selected. + +=item B (default: false) + +Record learning information in the opening book. Naturally this requires +the opening book to be writable. + +=item B (default: false) + +Run the engine at nice level 5, or "NiceValue" if it set. On some +operating systems it may be necessary to run the engine at lower +priority for it to be responsive to commands from PolyGlot while +searching. + +=item B (default: 5) + +Nice levels go from -20 to 20 with 20 being the lowest priority. +On Unix only root can set negative nice levels. On Windows the standard +Win32 priority levels are mapped in a sensible way to Unix nice levels. + + +=item B (default: -1) + +This a bit vector in which each bit represents the processors that a +process is allowed to run on. This option works only on Windows. + + +=back + +=head2 Work arounds + +Work arounds are identical to options except that they should be used +only when necessary. Their purpose is to try to hide problems with +various software (not just engines). The default value is always +correct for bug-free software. + +IMPORTANT: Any of these work arounds might be removed in future +versions of PolyGlot. You are strongly recommended to contact the +author of faulty software and truly fix the problem. + +PolyGlot supports the following work arounds: + +=over 4 + +=item B (default: 2) + +The default value of 2 corresponds to UCI+. Use 1 to select plain +UCI for engines that have problems with UCI+. + +=item B (default: false) + +PolyGlot now conforms to the documented UCI behaviour: the engine will +be allowed to ponder only if it (the engine) declares the "Ponder" UCI +option. However some engines which can actually ponder do not declare +the option. This work around lets PolyGlot know that they can ponder. + +=item B (default: false) + +When a ponder miss occurs, Polyglot interrupts the engine and +IMMEDIATELY launches a new search. While there should be no problem +with this, some engines seem confused and corrupt their search board. +"SyncStop" forces PolyGlot to wait for the (now useless) ponder search +to finish before launching the new search. + +=item B (default: false) + +Some engines do not specify a promotion piece, e.g. they send "e7e8" +instead of the correct "e7e8q". This work around enables the +incorrect form (and of course promotes into a queen). + +=item B (default: true) + +When true, PolyGlot repeats the last pv string (which also contains +score,depth and time usage) it got from the engine. Some engines +however do not send a new pv string just before sending the move and +the now old pv string might confuse debugtools that parse the winboard +debug files. + + +=back + + +=head2 [Engine] section + +This section contains engine UCI options. PolyGlot does not +understand them, but sends the information to the engine at startup +(converted to UCI form). You can add any UCI option that makes sense +to the engine (not just the common options about hash-table size and +tablebases). + +NOTE: use INI syntax, not UCI. For example "OwnBook = true" is +correct. It will be replaced by PolyGlot with "setoption name OwnBook +value true" at engine startup. + +Standard UCI options are + + Hash + NalimovPath + NalimovCache + OwnBook + +Hidden options like "Ponder" or "UCI_xxx" are automatic +and should not be put in an INI file. + +The other options are engine-specific. Check their name using a UCI +GUI or launch the engine in a console and type "uci". + +=head1 EXAMPLES + +Compile "games.pgn" into a book "book.bin" retaining all lines of at +most 30 plies. + + polyglot make-book -pgn games.pgn -bin book.bin -max-ply 30 + +Merge books "in1.bin" and "in2.bin" into a book "out.bin". + + polyglot merge-book -in1 w1.bin -in2 w2.bin -out w.bin + + +Here is a minimal config file + + [PolyGlot] + EngineCommand = fruit + [Engine] + + +=head1 EXIT STATUS + +PolyGlot always returns 0 on exit. + +=head1 AUTHORS + +Main author: Fabien Letouzey + +Native Windows port: Huang Chen ("Morning Yellow") + +Various enhancements: Fonzy Bleumers + +UCI port: Michel Van den Bergh + +=head1 SEE ALSO + +xboard(6) diff --git a/polyglot.spec b/polyglot.spec new file mode 100644 index 0000000..ef48197 --- /dev/null +++ b/polyglot.spec @@ -0,0 +1,40 @@ +Summary: A Winboard protocol to UCI protocol adapter +Name: polyglot +Version: 1.4w10UCIb15 +Release: 1 +License: GPL +Group: Amusement/Games +URL: http://alpha.uhasselt.be/Research/Algebra/Toga + +Source: http://alpha.uhasselt.be/Research/Algebra/Toga/polyglot-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root + +%description +PolyGlot is a "UCI adapter". It connects a GUI interface (such as + XBoard, Winboard, Arena or Chessbase) to a UCI chess engine. + +%prep +%setup + +%build +%configure +%{__make} + +%install +%{__rm} -rf %{buildroot} +%makeinstall + +%clean +%{__rm} -rf %{buildroot} + +%files +%defattr(-, root, root, 0755) +%doc %{_mandir}/man6/polyglot.6* +%doc %{_docdir}/polyglot/README* +%doc %{_docdir}/polyglot/book_format.html +%{_bindir}/polyglot + +%changelog +* Sat Jan 3 2009 Michel Van den Bergh - 1.4w10UCIb10-1 +- Initial spec file + diff --git a/posix.cpp b/posix.cpp new file mode 100644 index 0000000..d5f0a9d --- /dev/null +++ b/posix.cpp @@ -0,0 +1,101 @@ + +// posix.cpp + +// includes + +#include +#include +#include +#include + +#ifdef _WIN32 + +#include + +#else + +#include // Mac OS X needs this one first +#include +#include +#include + +#endif + +#include "posix.h" +#include "util.h" + +#ifndef _WIN32 +// prototypes + +static double duration (const struct timeval *t); + +// functions + + +// input_available() + +bool input_available() { + + int val; + fd_set set[1]; + struct timeval time_val[1]; + + FD_ZERO(set); + FD_SET(STDIN_FILENO,set); + + time_val->tv_sec = 0; + time_val->tv_usec = 0; + + val = select(STDIN_FILENO+1,set,NULL,NULL,time_val); + if (val == -1) my_fatal("input_available(): select(): %s\n",strerror(errno)); + + return val != 0; +} + + +// now_real() + +double now_real() { + + struct timeval tv[1]; + struct timezone tz[1]; + + tz->tz_minuteswest = 0; + tz->tz_dsttime = 0; // DST_NONE not declared in linux + + if (gettimeofday(tv,tz) == -1) { + my_fatal("now_real(): gettimeofday(): %s\n",strerror(errno)); + } + + return duration(tv); +} + +// now_cpu() + +double now_cpu() { + + struct rusage ru[1]; + + if (getrusage(RUSAGE_SELF,ru) == -1) { + my_fatal("now_cpu(): getrusage(): %s\n",strerror(errno)); + } + + return duration(&ru->ru_utime); +} + +// duration() + +static double duration(const struct timeval *tv) { + + return tv->tv_sec + tv->tv_usec * 1E-6; +} + +#else + +double now_real(void) { + return (double) GetTickCount() / 1000.0; +} + +#endif + +// end of posix.cpp diff --git a/posix.h b/posix.h new file mode 100644 index 0000000..b667872 --- /dev/null +++ b/posix.h @@ -0,0 +1,20 @@ + +// posix.h + +#ifndef POSIX_H +#define POSIX_H + +// includes + +#include "util.h" + +// functions + +extern bool input_available (); + +extern double now_real (); + +#endif // !defined POSIX_H + +// end of posix.h + diff --git a/random.cpp b/random.cpp new file mode 100644 index 0000000..9b5d8b0 --- /dev/null +++ b/random.cpp @@ -0,0 +1,231 @@ + +// random.cpp + +// includes + +#include "random.h" +#include "util.h" + +// "constants" + +const uint64 Random64[RandomNb] = { + U64(0x9D39247E33776D41), U64(0x2AF7398005AAA5C7), U64(0x44DB015024623547), U64(0x9C15F73E62A76AE2), + U64(0x75834465489C0C89), U64(0x3290AC3A203001BF), U64(0x0FBBAD1F61042279), U64(0xE83A908FF2FB60CA), + U64(0x0D7E765D58755C10), U64(0x1A083822CEAFE02D), U64(0x9605D5F0E25EC3B0), U64(0xD021FF5CD13A2ED5), + U64(0x40BDF15D4A672E32), U64(0x011355146FD56395), U64(0x5DB4832046F3D9E5), U64(0x239F8B2D7FF719CC), + U64(0x05D1A1AE85B49AA1), U64(0x679F848F6E8FC971), U64(0x7449BBFF801FED0B), U64(0x7D11CDB1C3B7ADF0), + U64(0x82C7709E781EB7CC), U64(0xF3218F1C9510786C), U64(0x331478F3AF51BBE6), U64(0x4BB38DE5E7219443), + U64(0xAA649C6EBCFD50FC), U64(0x8DBD98A352AFD40B), U64(0x87D2074B81D79217), U64(0x19F3C751D3E92AE1), + U64(0xB4AB30F062B19ABF), U64(0x7B0500AC42047AC4), U64(0xC9452CA81A09D85D), U64(0x24AA6C514DA27500), + U64(0x4C9F34427501B447), U64(0x14A68FD73C910841), U64(0xA71B9B83461CBD93), U64(0x03488B95B0F1850F), + U64(0x637B2B34FF93C040), U64(0x09D1BC9A3DD90A94), U64(0x3575668334A1DD3B), U64(0x735E2B97A4C45A23), + U64(0x18727070F1BD400B), U64(0x1FCBACD259BF02E7), U64(0xD310A7C2CE9B6555), U64(0xBF983FE0FE5D8244), + U64(0x9F74D14F7454A824), U64(0x51EBDC4AB9BA3035), U64(0x5C82C505DB9AB0FA), U64(0xFCF7FE8A3430B241), + U64(0x3253A729B9BA3DDE), U64(0x8C74C368081B3075), U64(0xB9BC6C87167C33E7), U64(0x7EF48F2B83024E20), + U64(0x11D505D4C351BD7F), U64(0x6568FCA92C76A243), U64(0x4DE0B0F40F32A7B8), U64(0x96D693460CC37E5D), + U64(0x42E240CB63689F2F), U64(0x6D2BDCDAE2919661), U64(0x42880B0236E4D951), U64(0x5F0F4A5898171BB6), + U64(0x39F890F579F92F88), U64(0x93C5B5F47356388B), U64(0x63DC359D8D231B78), U64(0xEC16CA8AEA98AD76), + U64(0x5355F900C2A82DC7), U64(0x07FB9F855A997142), U64(0x5093417AA8A7ED5E), U64(0x7BCBC38DA25A7F3C), + U64(0x19FC8A768CF4B6D4), U64(0x637A7780DECFC0D9), U64(0x8249A47AEE0E41F7), U64(0x79AD695501E7D1E8), + U64(0x14ACBAF4777D5776), U64(0xF145B6BECCDEA195), U64(0xDABF2AC8201752FC), U64(0x24C3C94DF9C8D3F6), + U64(0xBB6E2924F03912EA), U64(0x0CE26C0B95C980D9), U64(0xA49CD132BFBF7CC4), U64(0xE99D662AF4243939), + U64(0x27E6AD7891165C3F), U64(0x8535F040B9744FF1), U64(0x54B3F4FA5F40D873), U64(0x72B12C32127FED2B), + U64(0xEE954D3C7B411F47), U64(0x9A85AC909A24EAA1), U64(0x70AC4CD9F04F21F5), U64(0xF9B89D3E99A075C2), + U64(0x87B3E2B2B5C907B1), U64(0xA366E5B8C54F48B8), U64(0xAE4A9346CC3F7CF2), U64(0x1920C04D47267BBD), + U64(0x87BF02C6B49E2AE9), U64(0x092237AC237F3859), U64(0xFF07F64EF8ED14D0), U64(0x8DE8DCA9F03CC54E), + U64(0x9C1633264DB49C89), U64(0xB3F22C3D0B0B38ED), U64(0x390E5FB44D01144B), U64(0x5BFEA5B4712768E9), + U64(0x1E1032911FA78984), U64(0x9A74ACB964E78CB3), U64(0x4F80F7A035DAFB04), U64(0x6304D09A0B3738C4), + U64(0x2171E64683023A08), U64(0x5B9B63EB9CEFF80C), U64(0x506AACF489889342), U64(0x1881AFC9A3A701D6), + U64(0x6503080440750644), U64(0xDFD395339CDBF4A7), U64(0xEF927DBCF00C20F2), U64(0x7B32F7D1E03680EC), + U64(0xB9FD7620E7316243), U64(0x05A7E8A57DB91B77), U64(0xB5889C6E15630A75), U64(0x4A750A09CE9573F7), + U64(0xCF464CEC899A2F8A), U64(0xF538639CE705B824), U64(0x3C79A0FF5580EF7F), U64(0xEDE6C87F8477609D), + U64(0x799E81F05BC93F31), U64(0x86536B8CF3428A8C), U64(0x97D7374C60087B73), U64(0xA246637CFF328532), + U64(0x043FCAE60CC0EBA0), U64(0x920E449535DD359E), U64(0x70EB093B15B290CC), U64(0x73A1921916591CBD), + U64(0x56436C9FE1A1AA8D), U64(0xEFAC4B70633B8F81), U64(0xBB215798D45DF7AF), U64(0x45F20042F24F1768), + U64(0x930F80F4E8EB7462), U64(0xFF6712FFCFD75EA1), U64(0xAE623FD67468AA70), U64(0xDD2C5BC84BC8D8FC), + U64(0x7EED120D54CF2DD9), U64(0x22FE545401165F1C), U64(0xC91800E98FB99929), U64(0x808BD68E6AC10365), + U64(0xDEC468145B7605F6), U64(0x1BEDE3A3AEF53302), U64(0x43539603D6C55602), U64(0xAA969B5C691CCB7A), + U64(0xA87832D392EFEE56), U64(0x65942C7B3C7E11AE), U64(0xDED2D633CAD004F6), U64(0x21F08570F420E565), + U64(0xB415938D7DA94E3C), U64(0x91B859E59ECB6350), U64(0x10CFF333E0ED804A), U64(0x28AED140BE0BB7DD), + U64(0xC5CC1D89724FA456), U64(0x5648F680F11A2741), U64(0x2D255069F0B7DAB3), U64(0x9BC5A38EF729ABD4), + U64(0xEF2F054308F6A2BC), U64(0xAF2042F5CC5C2858), U64(0x480412BAB7F5BE2A), U64(0xAEF3AF4A563DFE43), + U64(0x19AFE59AE451497F), U64(0x52593803DFF1E840), U64(0xF4F076E65F2CE6F0), U64(0x11379625747D5AF3), + U64(0xBCE5D2248682C115), U64(0x9DA4243DE836994F), U64(0x066F70B33FE09017), U64(0x4DC4DE189B671A1C), + U64(0x51039AB7712457C3), U64(0xC07A3F80C31FB4B4), U64(0xB46EE9C5E64A6E7C), U64(0xB3819A42ABE61C87), + U64(0x21A007933A522A20), U64(0x2DF16F761598AA4F), U64(0x763C4A1371B368FD), U64(0xF793C46702E086A0), + U64(0xD7288E012AEB8D31), U64(0xDE336A2A4BC1C44B), U64(0x0BF692B38D079F23), U64(0x2C604A7A177326B3), + U64(0x4850E73E03EB6064), U64(0xCFC447F1E53C8E1B), U64(0xB05CA3F564268D99), U64(0x9AE182C8BC9474E8), + U64(0xA4FC4BD4FC5558CA), U64(0xE755178D58FC4E76), U64(0x69B97DB1A4C03DFE), U64(0xF9B5B7C4ACC67C96), + U64(0xFC6A82D64B8655FB), U64(0x9C684CB6C4D24417), U64(0x8EC97D2917456ED0), U64(0x6703DF9D2924E97E), + U64(0xC547F57E42A7444E), U64(0x78E37644E7CAD29E), U64(0xFE9A44E9362F05FA), U64(0x08BD35CC38336615), + U64(0x9315E5EB3A129ACE), U64(0x94061B871E04DF75), U64(0xDF1D9F9D784BA010), U64(0x3BBA57B68871B59D), + U64(0xD2B7ADEEDED1F73F), U64(0xF7A255D83BC373F8), U64(0xD7F4F2448C0CEB81), U64(0xD95BE88CD210FFA7), + U64(0x336F52F8FF4728E7), U64(0xA74049DAC312AC71), U64(0xA2F61BB6E437FDB5), U64(0x4F2A5CB07F6A35B3), + U64(0x87D380BDA5BF7859), U64(0x16B9F7E06C453A21), U64(0x7BA2484C8A0FD54E), U64(0xF3A678CAD9A2E38C), + U64(0x39B0BF7DDE437BA2), U64(0xFCAF55C1BF8A4424), U64(0x18FCF680573FA594), U64(0x4C0563B89F495AC3), + U64(0x40E087931A00930D), U64(0x8CFFA9412EB642C1), U64(0x68CA39053261169F), U64(0x7A1EE967D27579E2), + U64(0x9D1D60E5076F5B6F), U64(0x3810E399B6F65BA2), U64(0x32095B6D4AB5F9B1), U64(0x35CAB62109DD038A), + U64(0xA90B24499FCFAFB1), U64(0x77A225A07CC2C6BD), U64(0x513E5E634C70E331), U64(0x4361C0CA3F692F12), + U64(0xD941ACA44B20A45B), U64(0x528F7C8602C5807B), U64(0x52AB92BEB9613989), U64(0x9D1DFA2EFC557F73), + U64(0x722FF175F572C348), U64(0x1D1260A51107FE97), U64(0x7A249A57EC0C9BA2), U64(0x04208FE9E8F7F2D6), + U64(0x5A110C6058B920A0), U64(0x0CD9A497658A5698), U64(0x56FD23C8F9715A4C), U64(0x284C847B9D887AAE), + U64(0x04FEABFBBDB619CB), U64(0x742E1E651C60BA83), U64(0x9A9632E65904AD3C), U64(0x881B82A13B51B9E2), + U64(0x506E6744CD974924), U64(0xB0183DB56FFC6A79), U64(0x0ED9B915C66ED37E), U64(0x5E11E86D5873D484), + U64(0xF678647E3519AC6E), U64(0x1B85D488D0F20CC5), U64(0xDAB9FE6525D89021), U64(0x0D151D86ADB73615), + U64(0xA865A54EDCC0F019), U64(0x93C42566AEF98FFB), U64(0x99E7AFEABE000731), U64(0x48CBFF086DDF285A), + U64(0x7F9B6AF1EBF78BAF), U64(0x58627E1A149BBA21), U64(0x2CD16E2ABD791E33), U64(0xD363EFF5F0977996), + U64(0x0CE2A38C344A6EED), U64(0x1A804AADB9CFA741), U64(0x907F30421D78C5DE), U64(0x501F65EDB3034D07), + U64(0x37624AE5A48FA6E9), U64(0x957BAF61700CFF4E), U64(0x3A6C27934E31188A), U64(0xD49503536ABCA345), + U64(0x088E049589C432E0), U64(0xF943AEE7FEBF21B8), U64(0x6C3B8E3E336139D3), U64(0x364F6FFA464EE52E), + U64(0xD60F6DCEDC314222), U64(0x56963B0DCA418FC0), U64(0x16F50EDF91E513AF), U64(0xEF1955914B609F93), + U64(0x565601C0364E3228), U64(0xECB53939887E8175), U64(0xBAC7A9A18531294B), U64(0xB344C470397BBA52), + U64(0x65D34954DAF3CEBD), U64(0xB4B81B3FA97511E2), U64(0xB422061193D6F6A7), U64(0x071582401C38434D), + U64(0x7A13F18BBEDC4FF5), U64(0xBC4097B116C524D2), U64(0x59B97885E2F2EA28), U64(0x99170A5DC3115544), + U64(0x6F423357E7C6A9F9), U64(0x325928EE6E6F8794), U64(0xD0E4366228B03343), U64(0x565C31F7DE89EA27), + U64(0x30F5611484119414), U64(0xD873DB391292ED4F), U64(0x7BD94E1D8E17DEBC), U64(0xC7D9F16864A76E94), + U64(0x947AE053EE56E63C), U64(0xC8C93882F9475F5F), U64(0x3A9BF55BA91F81CA), U64(0xD9A11FBB3D9808E4), + U64(0x0FD22063EDC29FCA), U64(0xB3F256D8ACA0B0B9), U64(0xB03031A8B4516E84), U64(0x35DD37D5871448AF), + U64(0xE9F6082B05542E4E), U64(0xEBFAFA33D7254B59), U64(0x9255ABB50D532280), U64(0xB9AB4CE57F2D34F3), + U64(0x693501D628297551), U64(0xC62C58F97DD949BF), U64(0xCD454F8F19C5126A), U64(0xBBE83F4ECC2BDECB), + U64(0xDC842B7E2819E230), U64(0xBA89142E007503B8), U64(0xA3BC941D0A5061CB), U64(0xE9F6760E32CD8021), + U64(0x09C7E552BC76492F), U64(0x852F54934DA55CC9), U64(0x8107FCCF064FCF56), U64(0x098954D51FFF6580), + U64(0x23B70EDB1955C4BF), U64(0xC330DE426430F69D), U64(0x4715ED43E8A45C0A), U64(0xA8D7E4DAB780A08D), + U64(0x0572B974F03CE0BB), U64(0xB57D2E985E1419C7), U64(0xE8D9ECBE2CF3D73F), U64(0x2FE4B17170E59750), + U64(0x11317BA87905E790), U64(0x7FBF21EC8A1F45EC), U64(0x1725CABFCB045B00), U64(0x964E915CD5E2B207), + U64(0x3E2B8BCBF016D66D), U64(0xBE7444E39328A0AC), U64(0xF85B2B4FBCDE44B7), U64(0x49353FEA39BA63B1), + U64(0x1DD01AAFCD53486A), U64(0x1FCA8A92FD719F85), U64(0xFC7C95D827357AFA), U64(0x18A6A990C8B35EBD), + U64(0xCCCB7005C6B9C28D), U64(0x3BDBB92C43B17F26), U64(0xAA70B5B4F89695A2), U64(0xE94C39A54A98307F), + U64(0xB7A0B174CFF6F36E), U64(0xD4DBA84729AF48AD), U64(0x2E18BC1AD9704A68), U64(0x2DE0966DAF2F8B1C), + U64(0xB9C11D5B1E43A07E), U64(0x64972D68DEE33360), U64(0x94628D38D0C20584), U64(0xDBC0D2B6AB90A559), + U64(0xD2733C4335C6A72F), U64(0x7E75D99D94A70F4D), U64(0x6CED1983376FA72B), U64(0x97FCAACBF030BC24), + U64(0x7B77497B32503B12), U64(0x8547EDDFB81CCB94), U64(0x79999CDFF70902CB), U64(0xCFFE1939438E9B24), + U64(0x829626E3892D95D7), U64(0x92FAE24291F2B3F1), U64(0x63E22C147B9C3403), U64(0xC678B6D860284A1C), + U64(0x5873888850659AE7), U64(0x0981DCD296A8736D), U64(0x9F65789A6509A440), U64(0x9FF38FED72E9052F), + U64(0xE479EE5B9930578C), U64(0xE7F28ECD2D49EECD), U64(0x56C074A581EA17FE), U64(0x5544F7D774B14AEF), + U64(0x7B3F0195FC6F290F), U64(0x12153635B2C0CF57), U64(0x7F5126DBBA5E0CA7), U64(0x7A76956C3EAFB413), + U64(0x3D5774A11D31AB39), U64(0x8A1B083821F40CB4), U64(0x7B4A38E32537DF62), U64(0x950113646D1D6E03), + U64(0x4DA8979A0041E8A9), U64(0x3BC36E078F7515D7), U64(0x5D0A12F27AD310D1), U64(0x7F9D1A2E1EBE1327), + U64(0xDA3A361B1C5157B1), U64(0xDCDD7D20903D0C25), U64(0x36833336D068F707), U64(0xCE68341F79893389), + U64(0xAB9090168DD05F34), U64(0x43954B3252DC25E5), U64(0xB438C2B67F98E5E9), U64(0x10DCD78E3851A492), + U64(0xDBC27AB5447822BF), U64(0x9B3CDB65F82CA382), U64(0xB67B7896167B4C84), U64(0xBFCED1B0048EAC50), + U64(0xA9119B60369FFEBD), U64(0x1FFF7AC80904BF45), U64(0xAC12FB171817EEE7), U64(0xAF08DA9177DDA93D), + U64(0x1B0CAB936E65C744), U64(0xB559EB1D04E5E932), U64(0xC37B45B3F8D6F2BA), U64(0xC3A9DC228CAAC9E9), + U64(0xF3B8B6675A6507FF), U64(0x9FC477DE4ED681DA), U64(0x67378D8ECCEF96CB), U64(0x6DD856D94D259236), + U64(0xA319CE15B0B4DB31), U64(0x073973751F12DD5E), U64(0x8A8E849EB32781A5), U64(0xE1925C71285279F5), + U64(0x74C04BF1790C0EFE), U64(0x4DDA48153C94938A), U64(0x9D266D6A1CC0542C), U64(0x7440FB816508C4FE), + U64(0x13328503DF48229F), U64(0xD6BF7BAEE43CAC40), U64(0x4838D65F6EF6748F), U64(0x1E152328F3318DEA), + U64(0x8F8419A348F296BF), U64(0x72C8834A5957B511), U64(0xD7A023A73260B45C), U64(0x94EBC8ABCFB56DAE), + U64(0x9FC10D0F989993E0), U64(0xDE68A2355B93CAE6), U64(0xA44CFE79AE538BBE), U64(0x9D1D84FCCE371425), + U64(0x51D2B1AB2DDFB636), U64(0x2FD7E4B9E72CD38C), U64(0x65CA5B96B7552210), U64(0xDD69A0D8AB3B546D), + U64(0x604D51B25FBF70E2), U64(0x73AA8A564FB7AC9E), U64(0x1A8C1E992B941148), U64(0xAAC40A2703D9BEA0), + U64(0x764DBEAE7FA4F3A6), U64(0x1E99B96E70A9BE8B), U64(0x2C5E9DEB57EF4743), U64(0x3A938FEE32D29981), + U64(0x26E6DB8FFDF5ADFE), U64(0x469356C504EC9F9D), U64(0xC8763C5B08D1908C), U64(0x3F6C6AF859D80055), + U64(0x7F7CC39420A3A545), U64(0x9BFB227EBDF4C5CE), U64(0x89039D79D6FC5C5C), U64(0x8FE88B57305E2AB6), + U64(0xA09E8C8C35AB96DE), U64(0xFA7E393983325753), U64(0xD6B6D0ECC617C699), U64(0xDFEA21EA9E7557E3), + U64(0xB67C1FA481680AF8), U64(0xCA1E3785A9E724E5), U64(0x1CFC8BED0D681639), U64(0xD18D8549D140CAEA), + U64(0x4ED0FE7E9DC91335), U64(0xE4DBF0634473F5D2), U64(0x1761F93A44D5AEFE), U64(0x53898E4C3910DA55), + U64(0x734DE8181F6EC39A), U64(0x2680B122BAA28D97), U64(0x298AF231C85BAFAB), U64(0x7983EED3740847D5), + U64(0x66C1A2A1A60CD889), U64(0x9E17E49642A3E4C1), U64(0xEDB454E7BADC0805), U64(0x50B704CAB602C329), + U64(0x4CC317FB9CDDD023), U64(0x66B4835D9EAFEA22), U64(0x219B97E26FFC81BD), U64(0x261E4E4C0A333A9D), + U64(0x1FE2CCA76517DB90), U64(0xD7504DFA8816EDBB), U64(0xB9571FA04DC089C8), U64(0x1DDC0325259B27DE), + U64(0xCF3F4688801EB9AA), U64(0xF4F5D05C10CAB243), U64(0x38B6525C21A42B0E), U64(0x36F60E2BA4FA6800), + U64(0xEB3593803173E0CE), U64(0x9C4CD6257C5A3603), U64(0xAF0C317D32ADAA8A), U64(0x258E5A80C7204C4B), + U64(0x8B889D624D44885D), U64(0xF4D14597E660F855), U64(0xD4347F66EC8941C3), U64(0xE699ED85B0DFB40D), + U64(0x2472F6207C2D0484), U64(0xC2A1E7B5B459AEB5), U64(0xAB4F6451CC1D45EC), U64(0x63767572AE3D6174), + U64(0xA59E0BD101731A28), U64(0x116D0016CB948F09), U64(0x2CF9C8CA052F6E9F), U64(0x0B090A7560A968E3), + U64(0xABEEDDB2DDE06FF1), U64(0x58EFC10B06A2068D), U64(0xC6E57A78FBD986E0), U64(0x2EAB8CA63CE802D7), + U64(0x14A195640116F336), U64(0x7C0828DD624EC390), U64(0xD74BBE77E6116AC7), U64(0x804456AF10F5FB53), + U64(0xEBE9EA2ADF4321C7), U64(0x03219A39EE587A30), U64(0x49787FEF17AF9924), U64(0xA1E9300CD8520548), + U64(0x5B45E522E4B1B4EF), U64(0xB49C3B3995091A36), U64(0xD4490AD526F14431), U64(0x12A8F216AF9418C2), + U64(0x001F837CC7350524), U64(0x1877B51E57A764D5), U64(0xA2853B80F17F58EE), U64(0x993E1DE72D36D310), + U64(0xB3598080CE64A656), U64(0x252F59CF0D9F04BB), U64(0xD23C8E176D113600), U64(0x1BDA0492E7E4586E), + U64(0x21E0BD5026C619BF), U64(0x3B097ADAF088F94E), U64(0x8D14DEDB30BE846E), U64(0xF95CFFA23AF5F6F4), + U64(0x3871700761B3F743), U64(0xCA672B91E9E4FA16), U64(0x64C8E531BFF53B55), U64(0x241260ED4AD1E87D), + U64(0x106C09B972D2E822), U64(0x7FBA195410E5CA30), U64(0x7884D9BC6CB569D8), U64(0x0647DFEDCD894A29), + U64(0x63573FF03E224774), U64(0x4FC8E9560F91B123), U64(0x1DB956E450275779), U64(0xB8D91274B9E9D4FB), + U64(0xA2EBEE47E2FBFCE1), U64(0xD9F1F30CCD97FB09), U64(0xEFED53D75FD64E6B), U64(0x2E6D02C36017F67F), + U64(0xA9AA4D20DB084E9B), U64(0xB64BE8D8B25396C1), U64(0x70CB6AF7C2D5BCF0), U64(0x98F076A4F7A2322E), + U64(0xBF84470805E69B5F), U64(0x94C3251F06F90CF3), U64(0x3E003E616A6591E9), U64(0xB925A6CD0421AFF3), + U64(0x61BDD1307C66E300), U64(0xBF8D5108E27E0D48), U64(0x240AB57A8B888B20), U64(0xFC87614BAF287E07), + U64(0xEF02CDD06FFDB432), U64(0xA1082C0466DF6C0A), U64(0x8215E577001332C8), U64(0xD39BB9C3A48DB6CF), + U64(0x2738259634305C14), U64(0x61CF4F94C97DF93D), U64(0x1B6BACA2AE4E125B), U64(0x758F450C88572E0B), + U64(0x959F587D507A8359), U64(0xB063E962E045F54D), U64(0x60E8ED72C0DFF5D1), U64(0x7B64978555326F9F), + U64(0xFD080D236DA814BA), U64(0x8C90FD9B083F4558), U64(0x106F72FE81E2C590), U64(0x7976033A39F7D952), + U64(0xA4EC0132764CA04B), U64(0x733EA705FAE4FA77), U64(0xB4D8F77BC3E56167), U64(0x9E21F4F903B33FD9), + U64(0x9D765E419FB69F6D), U64(0xD30C088BA61EA5EF), U64(0x5D94337FBFAF7F5B), U64(0x1A4E4822EB4D7A59), + U64(0x6FFE73E81B637FB3), U64(0xDDF957BC36D8B9CA), U64(0x64D0E29EEA8838B3), U64(0x08DD9BDFD96B9F63), + U64(0x087E79E5A57D1D13), U64(0xE328E230E3E2B3FB), U64(0x1C2559E30F0946BE), U64(0x720BF5F26F4D2EAA), + U64(0xB0774D261CC609DB), U64(0x443F64EC5A371195), U64(0x4112CF68649A260E), U64(0xD813F2FAB7F5C5CA), + U64(0x660D3257380841EE), U64(0x59AC2C7873F910A3), U64(0xE846963877671A17), U64(0x93B633ABFA3469F8), + U64(0xC0C0F5A60EF4CDCF), U64(0xCAF21ECD4377B28C), U64(0x57277707199B8175), U64(0x506C11B9D90E8B1D), + U64(0xD83CC2687A19255F), U64(0x4A29C6465A314CD1), U64(0xED2DF21216235097), U64(0xB5635C95FF7296E2), + U64(0x22AF003AB672E811), U64(0x52E762596BF68235), U64(0x9AEBA33AC6ECC6B0), U64(0x944F6DE09134DFB6), + U64(0x6C47BEC883A7DE39), U64(0x6AD047C430A12104), U64(0xA5B1CFDBA0AB4067), U64(0x7C45D833AFF07862), + U64(0x5092EF950A16DA0B), U64(0x9338E69C052B8E7B), U64(0x455A4B4CFE30E3F5), U64(0x6B02E63195AD0CF8), + U64(0x6B17B224BAD6BF27), U64(0xD1E0CCD25BB9C169), U64(0xDE0C89A556B9AE70), U64(0x50065E535A213CF6), + U64(0x9C1169FA2777B874), U64(0x78EDEFD694AF1EED), U64(0x6DC93D9526A50E68), U64(0xEE97F453F06791ED), + U64(0x32AB0EDB696703D3), U64(0x3A6853C7E70757A7), U64(0x31865CED6120F37D), U64(0x67FEF95D92607890), + U64(0x1F2B1D1F15F6DC9C), U64(0xB69E38A8965C6B65), U64(0xAA9119FF184CCCF4), U64(0xF43C732873F24C13), + U64(0xFB4A3D794A9A80D2), U64(0x3550C2321FD6109C), U64(0x371F77E76BB8417E), U64(0x6BFA9AAE5EC05779), + U64(0xCD04F3FF001A4778), U64(0xE3273522064480CA), U64(0x9F91508BFFCFC14A), U64(0x049A7F41061A9E60), + U64(0xFCB6BE43A9F2FE9B), U64(0x08DE8A1C7797DA9B), U64(0x8F9887E6078735A1), U64(0xB5B4071DBFC73A66), + U64(0x230E343DFBA08D33), U64(0x43ED7F5A0FAE657D), U64(0x3A88A0FBBCB05C63), U64(0x21874B8B4D2DBC4F), + U64(0x1BDEA12E35F6A8C9), U64(0x53C065C6C8E63528), U64(0xE34A1D250E7A8D6B), U64(0xD6B04D3B7651DD7E), + U64(0x5E90277E7CB39E2D), U64(0x2C046F22062DC67D), U64(0xB10BB459132D0A26), U64(0x3FA9DDFB67E2F199), + U64(0x0E09B88E1914F7AF), U64(0x10E8B35AF3EEAB37), U64(0x9EEDECA8E272B933), U64(0xD4C718BC4AE8AE5F), + U64(0x81536D601170FC20), U64(0x91B534F885818A06), U64(0xEC8177F83F900978), U64(0x190E714FADA5156E), + U64(0xB592BF39B0364963), U64(0x89C350C893AE7DC1), U64(0xAC042E70F8B383F2), U64(0xB49B52E587A1EE60), + U64(0xFB152FE3FF26DA89), U64(0x3E666E6F69AE2C15), U64(0x3B544EBE544C19F9), U64(0xE805A1E290CF2456), + U64(0x24B33C9D7ED25117), U64(0xE74733427B72F0C1), U64(0x0A804D18B7097475), U64(0x57E3306D881EDB4F), + U64(0x4AE7D6A36EB5DBCB), U64(0x2D8D5432157064C8), U64(0xD1E649DE1E7F268B), U64(0x8A328A1CEDFE552C), + U64(0x07A3AEC79624C7DA), U64(0x84547DDC3E203C94), U64(0x990A98FD5071D263), U64(0x1A4FF12616EEFC89), + U64(0xF6F7FD1431714200), U64(0x30C05B1BA332F41C), U64(0x8D2636B81555A786), U64(0x46C9FEB55D120902), + U64(0xCCEC0A73B49C9921), U64(0x4E9D2827355FC492), U64(0x19EBB029435DCB0F), U64(0x4659D2B743848A2C), + U64(0x963EF2C96B33BE31), U64(0x74F85198B05A2E7D), U64(0x5A0F544DD2B1FB18), U64(0x03727073C2E134B1), + U64(0xC7F6AA2DE59AEA61), U64(0x352787BAA0D7C22F), U64(0x9853EAB63B5E0B35), U64(0xABBDCDD7ED5C0860), + U64(0xCF05DAF5AC8D77B0), U64(0x49CAD48CEBF4A71E), U64(0x7A4C10EC2158C4A6), U64(0xD9E92AA246BF719E), + U64(0x13AE978D09FE5557), U64(0x730499AF921549FF), U64(0x4E4B705B92903BA4), U64(0xFF577222C14F0A3A), + U64(0x55B6344CF97AAFAE), U64(0xB862225B055B6960), U64(0xCAC09AFBDDD2CDB4), U64(0xDAF8E9829FE96B5F), + U64(0xB5FDFC5D3132C498), U64(0x310CB380DB6F7503), U64(0xE87FBB46217A360E), U64(0x2102AE466EBB1148), + U64(0xF8549E1A3AA5E00D), U64(0x07A69AFDCC42261A), U64(0xC4C118BFE78FEAAE), U64(0xF9F4892ED96BD438), + U64(0x1AF3DBE25D8F45DA), U64(0xF5B4B0B0D2DEEEB4), U64(0x962ACEEFA82E1C84), U64(0x046E3ECAAF453CE9), + U64(0xF05D129681949A4C), U64(0x964781CE734B3C84), U64(0x9C2ED44081CE5FBD), U64(0x522E23F3925E319E), + U64(0x177E00F9FC32F791), U64(0x2BC60A63A6F3B3F2), U64(0x222BBFAE61725606), U64(0x486289DDCC3D6780), + U64(0x7DC7785B8EFDFC80), U64(0x8AF38731C02BA980), U64(0x1FAB64EA29A2DDF7), U64(0xE4D9429322CD065A), + U64(0x9DA058C67844F20C), U64(0x24C0E332B70019B0), U64(0x233003B5A6CFE6AD), U64(0xD586BD01C5C217F6), + U64(0x5E5637885F29BC2B), U64(0x7EBA726D8C94094B), U64(0x0A56A5F0BFE39272), U64(0xD79476A84EE20D06), + U64(0x9E4C1269BAA4BF37), U64(0x17EFEE45B0DEE640), U64(0x1D95B0A5FCF90BC6), U64(0x93CBE0B699C2585D), + U64(0x65FA4F227A2B6D79), U64(0xD5F9E858292504D5), U64(0xC2B5A03F71471A6F), U64(0x59300222B4561E00), + U64(0xCE2F8642CA0712DC), U64(0x7CA9723FBB2E8988), U64(0x2785338347F2BA08), U64(0xC61BB3A141E50E8C), + U64(0x150F361DAB9DEC26), U64(0x9F6A419D382595F4), U64(0x64A53DC924FE7AC9), U64(0x142DE49FFF7A7C3D), + U64(0x0C335248857FA9E7), U64(0x0A9C32D5EAE45305), U64(0xE6C42178C4BBB92E), U64(0x71F1CE2490D20B07), + U64(0xF1BCC3D275AFE51A), U64(0xE728E8C83C334074), U64(0x96FBF83A12884624), U64(0x81A1549FD6573DA5), + U64(0x5FA7867CAF35E149), U64(0x56986E2EF3ED091B), U64(0x917F1DD5F8886C61), U64(0xD20D8C88C8FFE65F), + U64(0x31D71DCE64B2C310), U64(0xF165B587DF898190), U64(0xA57E6339DD2CF3A0), U64(0x1EF6E6DBB1961EC9), + U64(0x70CC73D90BC26E24), U64(0xE21A6B35DF0C3AD7), U64(0x003A93D8B2806962), U64(0x1C99DED33CB890A1), + U64(0xCF3145DE0ADD4289), U64(0xD0E4427A5514FB72), U64(0x77C621CC9FB3A483), U64(0x67A34DAC4356550B), + U64(0xF8D626AAAF278509), +}; + +// functions + +// random_init() + +void random_init() { + + if ((Random64[RandomNb-1] >> 32) != 0xF8D626AA) { // upper half of the last element of the array + my_fatal("random_init(): broken 64-bit types\n"); + } +} + +// random_64() + +uint64 random_64(int n) { + + ASSERT(n>=0&&n +#include +#include +#include + +#include "attack.h" +#include "board.h" +#include "list.h" +#include "move.h" +#include "move_gen.h" +#include "move_legal.h" +#include "piece.h" +#include "san.h" +#include "square.h" +#include "util.h" + +// constants + +static const bool UseSlowDebug = false; + +enum ambiguity_t { + AMBIGUITY_NONE, + AMBIGUITY_FILE, + AMBIGUITY_RANK, + AMBIGUITY_SQUARE +}; + +// functions + +static bool san_to_lan (const char san[], const board_t * board, char string[], int size); +static int move_from_lan (const char string[], const board_t * board); + +static int ambiguity (int move, const board_t * board); + +// move_to_san() + +bool move_to_san(int move, const board_t * board, char string[], int size) { + + int from, to, piece; + char tmp_string[256]; + + ASSERT(move_is_ok(move)); + ASSERT(board_is_ok(board)); + ASSERT(string!=NULL); + ASSERT(size>=8); + + ASSERT(move_is_legal(move,board)); + + if (size < 8) return false; + + // init + + from = move_from(move); + to = move_to(move); + + string[0] = '\0'; + + // castle + + if (move_is_castle(move,board)) { + + if (to > from) { + strcat(string,"O-O"); + } else { + strcat(string,"O-O-O"); + } + + goto check; + } + + // from + + piece = board->square[from]; + + if (piece_is_pawn(piece)) { + + // pawn + + if (move_is_capture(move,board)) { + sprintf(tmp_string,"%c",file_to_char(square_file(from))); + strcat(string,tmp_string); + } + + } else { + + // piece + + sprintf(tmp_string,"%c",toupper(piece_to_char(piece))); + strcat(string,tmp_string); + + // ambiguity + + switch (ambiguity(move,board)) { + case AMBIGUITY_NONE: + break; + case AMBIGUITY_FILE: + sprintf(tmp_string,"%c",file_to_char(square_file(from))); + strcat(string,tmp_string); + break; + case AMBIGUITY_RANK: + sprintf(tmp_string,"%c",rank_to_char(square_rank(from))); + strcat(string,tmp_string); + break; + case AMBIGUITY_SQUARE: + if (!square_to_string(from,tmp_string,256)) return false; + strcat(string,tmp_string); + break; + default: + ASSERT(false); + break; + } + } + + // capture + + if (move_is_capture(move,board)) strcat(string,"x"); + + // to + + if (!square_to_string(to,tmp_string,256)) return false; + strcat(string,tmp_string); + + // promote + + if (move_is_promote(move)) { + sprintf(tmp_string,"=%c",toupper(piece_to_char(move_promote(move,board)))); + strcat(string,tmp_string); + } + + // check + +check: + + if (move_is_mate(move,board)) { + strcat(string,"#"); + } else if (move_is_check(move,board)) { + strcat(string,"+"); + } + + return true; +} + +// move_from_san() + +int move_from_san(const char string[], const board_t * board) { + + char s[256]; + int move; + + ASSERT(string!=NULL); + ASSERT(board_is_ok(board)); + + san_to_lan(string,board,s,256); + move = move_from_lan(s,board); + + ASSERT(!UseSlowDebug||move==move_from_san_debug(string,board)); + + return move; +} + +// move_from_san_debug() + +int move_from_san_debug(const char string[], const board_t * board) { + + list_t list[1]; + int i, move; + char move_string[256]; + + ASSERT(string!=NULL); + ASSERT(board_is_ok(board)); + + gen_legal_moves(list,board); + + for (i = 0; i < list_size(list); i++) { + move = list_move(list,i); + if (!move_to_san(move,board,move_string,256)) ASSERT(false); + if (my_string_equal(move_string,string)) return move; + } + + return MoveNone; +} + +// san_to_lan() + +static bool san_to_lan(const char san[], const board_t * board, char string[], int size) { + + int len; + int left, right; + int c; + int king, rook; + char king_string[3], rook_string[3]; + + ASSERT(san!=NULL); + ASSERT(board_is_ok(board)); + ASSERT(string!=NULL); + ASSERT(size>=8); + + // init + + if (size < 8) return false; + strcpy(string,"???????"); + + len = strlen(san); + + left = 0; + right = len; + + // skip trailing '+' or '#' + + if (left < right) { + c = san[right-1]; + if (c == '+' || c == '#') right--; + } + + // castling + + ASSERT(left==0); + + if (false) { + + } else if (right == 3 && strncmp(san,"O-O",3) == 0) { + + if (board->castle[board->turn][SideH] == SquareNone) return false; + + king = king_pos(board,board->turn); + rook = board->castle[board->turn][SideH]; + + square_to_string(king,king_string,3); + square_to_string(rook,rook_string,3); + + sprintf(string,"K%s?%s?",king_string,rook_string); + + } else if (right == 5 && strncmp(san,"O-O-O",5) == 0) { + + if (board->castle[board->turn][SideA] == SquareNone) return false; + + king = king_pos(board,board->turn); + rook = board->castle[board->turn][SideA]; + + square_to_string(king,king_string,3); + square_to_string(rook,rook_string,3); + + sprintf(string,"K%s?%s?",king_string,rook_string); + + } else { + + // moved piece + + if (left < right) { + + c = san[left]; + + if (char_is_piece(c)) { + string[0] = c; + left++; + } + } + + // promotion + + if (left < right) { + + c = toupper(san[right-1]); + + if (char_is_piece(c)) { + + string[6] = c; + right--; + + // skip '=' + + if (left < right && san[right-1] == '=') right--; + } + } + + // to-square rank + + if (left < right) { + + c = san[right-1]; + + if (char_is_rank(c)) { + string[5] = c; + right--; + } + } + + // to-square file + + if (left < right) { + + c = san[right-1]; + + if (char_is_file(c)) { + string[4] = c; + right--; + } + } + + // captured piece + + if (left < right) { + + c = san[right-1]; + + if (char_is_piece(c)) { + string[3] = c; + right--; + } + } + + // skip middle '-' or 'x' + + if (left < right) { + c = san[right-1]; + if (c == '-' || c == 'x') right--; + } + + // from-square file + + if (left < right) { + + c = san[left]; + + if (char_is_file(c)) { + string[1] = c; + left++; + } + } + + // from-square rank + + if (left < right) { + + c = san[left]; + + if (char_is_rank(c)) { + string[2] = c; + left++; + } + } + + if (left != right) return false; + } + + // end + + return true; +} + +// move_from_lan() + +static int move_from_lan(const char string[], const board_t * board) { + + int len; + int move; + int promote; + char s[256]; + int from, to; + int colour; + int inc; + int piece_char; + int n; + const uint8 * ptr; + int piece; + int side; + + ASSERT(string!=NULL); + ASSERT(board_is_ok(board)); + + // init + + len = strlen(string); + if (len != 7) return MoveNone; + + move = MoveNone; + colour = board->turn; + + // promote + + promote = 0; + + switch (string[6]) { + case '?': // not a promotion + break; + case 'N': + promote = MovePromoteKnight; + break; + case 'B': + promote = MovePromoteBishop; + break; + case 'R': + promote = MovePromoteRook; + break; + case 'Q': + promote = MovePromoteQueen; + break; + default: + return MoveNone; + break; + } + + // to square + + s[0] = string[4]; + s[1] = string[5]; + s[2] = '\0'; + + to = square_from_string(s); + if (to == SquareNone) return MoveNone; + + // known from square? + + if (string[1] != '?' && string[2] != '?') { + + // from square + + s[0] = string[1]; + s[1] = string[2]; + s[2] = '\0'; + + from = square_from_string(s); + if (from == SquareNone) return MoveNone; + + // convert "king slide" castling to KxR + + if (piece_is_king(board->square[from]) + && square_rank(to) == square_rank(from) + && abs(to-from) > 1) { + side = (to > from) ? SideH : SideA; + to = board->castle[colour][side]; + if (to == SquareNone) return MoveNone; + } + + // move + + move = move_make(from,to) | promote; + + return move; + } + + // pawn non-capture? + + if (string[0] == '?' && string[1] == '?') { + + if (board->square[to] != Empty) return MoveNone; // useful? + + inc = (colour_is_white(colour)) ? +16 : -16; + + from = to - inc; + if (board->square[from] == Empty && square_side_rank(to,colour) == Rank4) { + from -= inc; + } + + if (board->square[from] != piece_make_pawn(colour)) { // useful? + return MoveNone; + } + + // move + + move = move_make(from,to) | promote; + + return move; + } + + // pawn capture? + + piece_char = string[0]; + + if (piece_char == '?' && string[1] != '?') { + piece_char = 'P'; + } + + // attack loop + + n = 0; + + for (ptr = board->list[colour]; (from=*ptr) != SquareNone; ptr++) { + + piece = board->square[from]; + + if (toupper(piece_to_char(piece)) == piece_char) { + if (piece_attack(board,piece,from,to)) { + if (true + && (string[1] == '?' || file_to_char(square_file(from)) == string[1]) + && (string[2] == '?' || rank_to_char(square_rank(from)) == string[2])) { + if (!is_pinned(board,from,to,colour)) { + move = move_make(from,to) | promote; + n++; + } + } + } + } + } + + if (n != 1) move = MoveNone; + + return move; +} + +// ambiguity() + +static int ambiguity(int move, const board_t * board) { + + int from, to, piece; + list_t list[1]; + int i, n, m; + + // init + + from = move_from(move); + to = move_to(move); + piece = move_piece(move,board); + + gen_legal_moves(list,board); + + // no ambiguity? + + n = 0; + + for (i = 0; i < list_size(list); i++) { + m = list_move(list,i); + if (move_piece(m,board) == piece && move_to(m) == to) { + n++; + } + } + + if (n == 1) return AMBIGUITY_NONE; + + // file ambiguity? + + n = 0; + + for (i = 0; i < list_size(list); i++) { + m = list_move(list,i); + if (move_piece(m,board) == piece && move_to(m) == to) { + if (square_file(move_from(m)) == square_file(from)) n++; + } + } + + if (n == 1) return AMBIGUITY_FILE; + + // rank ambiguity? + + n = 0; + + for (i = 0; i < list_size(list); i++) { + m = list_move(list,i); + if (move_piece(m,board) == piece && move_to(m) == to) { + if (square_rank(move_from(m)) == square_rank(from)) n++; + } + } + + if (n == 1) return AMBIGUITY_RANK; + + // square ambiguity + + return AMBIGUITY_SQUARE; +} + +// end of san.cpp + diff --git a/san.h b/san.h new file mode 100644 index 0000000..5966561 --- /dev/null +++ b/san.h @@ -0,0 +1,22 @@ + +// san.h + +#ifndef SAN_H +#define SAN_H + +// includes + +#include "board.h" +#include "util.h" + +// functions + +extern bool move_to_san (int move, const board_t * board, char string[], int size); +extern int move_from_san (const char string[], const board_t * board); + +extern int move_from_san_debug (const char string[], const board_t * board); + +#endif // !defined SAN_H + +// end of san.h + diff --git a/search.cpp b/search.cpp new file mode 100644 index 0000000..a867d24 --- /dev/null +++ b/search.cpp @@ -0,0 +1,249 @@ +// search.cpp + +// includes + +#include +#include +#include + +#include "attack.h" +#include "board.h" +#include "colour.h" +#include "engine.h" +#include "fen.h" +#include "line.h" +#include "list.h" +#include "move.h" +#include "move_do.h" +#include "move_gen.h" +#include "move_legal.h" +#include "option.h" +#include "parse.h" +#include "san.h" +#include "search.h" +#include "uci.h" +#include "util.h" + +// constants + +static const int StringSize = 4096; + +// variables + +static int Depth; + +static int BestMove; +static int BestValue; +static move_t BestPV[LineSize]; + +static sint64 NodeNb; +static sint64 LeafNb; +static double Time; + +static int Move; +static int MovePos; +static int MoveNb; + +// prototypes + +static bool depth_is_ok (int depth); +static void perft (const board_t * board, int depth); + +// functions + +// depth_is_ok() + +static bool depth_is_ok(int depth) { + + return depth >= 0 && depth < DepthMax; +} + +// search() + +void search(const board_t * board, int depth_max, double time_max) { + + char string[256]; + + ASSERT(board_is_ok(board)); + ASSERT(depth_max>=1&&depth_max=0.0); + + // engine + + Depth = 0; + + BestMove = MoveNone; + BestValue = 0; + line_clear(BestPV); + + NodeNb = 0; + LeafNb = 0; + Time = 0.0; + + Move = MoveNone; + MovePos = 0; + MoveNb = 0; + + // init + + uci_send_ucinewgame(Uci); + uci_send_isready_sync(Uci); + + // position + + if (!board_to_fen(board,string,256)) ASSERT(false); + engine_send(Engine,"position fen %s",string); + + // search + + engine_send_queue(Engine,"go"); + + engine_send_queue(Engine," movetime %.0f",time_max*1000.0); + engine_send_queue(Engine," depth %d",depth_max); + + engine_send(Engine,""); // newline + + // wait for feed-back + + while (true) { + + engine_get(Engine,string,256); + + if (false) { + + } else if (match(string,"bestmove * ponder *")) { + + BestMove = move_from_can(Star[0],board); + ASSERT(BestMove!=MoveNone&&move_is_legal(BestMove,board)); + + break; + + } else if (match(string,"bestmove *")) { + + BestMove = move_from_can(Star[0],board); + ASSERT(BestMove!=MoveNone&&move_is_legal(BestMove,board)); + + break; + } + } + + printf("\n"); +} + +// do_perft() + +void do_perft(int argc,char * argv[]){ + const char * fen=StartFen; + int depth=1; + board_t board[1]; + int i; + for (i = 1; i < argc; i++) { + if (false) { + } else if (my_string_equal(argv[i],"perft")) { + // skip + } else if (my_string_equal(argv[i],"-fen")) { + i++; + if (argv[i] == NULL) my_fatal("do_perft(): missing argument\n"); + fen=strdup(argv[i]); + } else if (my_string_equal(argv[i],"-max-depth")){ + i++; + if (argv[i] == NULL) my_fatal("do_perft(): missing argument\n"); + depth=atoi(argv[i]); + if(depth<1) my_fatal("do_perft(): illegal depth %d\n",depth); + } else { + my_fatal("do_perft(): unknown option \"%s\"\n",argv[i]); + } + } + board_from_fen(board,fen); + search_perft(board,depth); +} + +// search_perft() + +void search_perft(const board_t * board, int depth_max) { + + int depth; + my_timer_t timer[1]; + double time, speed; + char node_string[StringSize]; + char leafnode_string[StringSize]; + + ASSERT(board_is_ok(board)); + ASSERT(depth_max>=1&&depth_maxturn))); + + // init + + NodeNb++; + + // leaf + + if (depth == 0) { + LeafNb++; + return; + } + + // more init + + me = board->turn; + + // move loop + + gen_moves(list,board); + + for (i = 0; i < list_size(list); i++) { + + move = list_move(list,i); + + board_copy(new_board,board); + move_do(new_board,move); + + if (!is_in_check(new_board,me)) perft(new_board,depth-1); + } +} + +// end of search.cpp + diff --git a/search.h b/search.h new file mode 100644 index 0000000..9e55568 --- /dev/null +++ b/search.h @@ -0,0 +1,25 @@ +// search.h + +#ifndef SEARCH_H +#define SEARCH_H + +// includes + +#include "board.h" +#include "util.h" + +// constants + +const int DepthMax = 63; + +// functions + +extern void search (const board_t * board, int depth_max, double time_max); +extern void search_perft (const board_t * board, int depth_max); + +extern void do_perft (int argc, char * argv[]); + +#endif // !defined SEARCH_H + +// end of search.h + diff --git a/square.cpp b/square.cpp new file mode 100644 index 0000000..2519d38 --- /dev/null +++ b/square.cpp @@ -0,0 +1,246 @@ + +// square.cpp + +// includes + +#include "colour.h" +#include "square.h" +#include "util.h" + +// "constants" + +static const uint8 SquareFrom64[64] = { + A1, B1, C1, D1, E1, F1, G1, H1, + A2, B2, C2, D2, E2, F2, G2, H2, + A3, B3, C3, D3, E3, F3, G3, H3, + A4, B4, C4, D4, E4, F4, G4, H4, + A5, B5, C5, D5, E5, F5, G5, H5, + A6, B6, C6, D6, E6, F6, G6, H6, + A7, B7, C7, D7, E7, F7, G7, H7, + A8, B8, C8, D8, E8, F8, G8, H8, +}; + +// variables + +static sint8 SquareTo64[SquareNb]; + +// functions + +// square_init() + +void square_init() { + + int sq; + + for (sq = 0; sq < SquareNb; sq++) SquareTo64[sq] = -1; + + for (sq = 0; sq < 64; sq++) { + SquareTo64[SquareFrom64[sq]] = sq; + } +} + +// square_is_ok() + +bool square_is_ok(int square) { + + if (square < 0 || square >= SquareNb) return false; + + if (SquareTo64[square] < 0) return false; + + return true; +} + +// square_make() + +int square_make(int file, int rank) { + + int sq_64; + + ASSERT(file>=0&&file<8); + ASSERT(rank>=0&&rank<8); + + sq_64 = (rank << 3) | file; + + return square_from_64(sq_64); +} + +// square_file() + +int square_file(int square) { + + int file; + + ASSERT(square_is_ok(square)); + + file = (square - 4) & 7; + ASSERT(file==(square_to_64(square)&7)); + + return file; +} + +// square_rank() + +int square_rank(int square) { + + int rank; + + ASSERT(square_is_ok(square)); + + rank = (square >> 4) - 2; + ASSERT(rank==square_to_64(square)>>3); + + return rank; +} + +// square_side_rank() + +int square_side_rank(int square, int colour) { + + int rank; + + ASSERT(square_is_ok(square)); + ASSERT(colour_is_ok(colour)); + + rank = square_rank(square); + if (colour_is_black(colour)) rank = 7-rank; + + return rank; +} + +// square_from_64() + +int square_from_64(int square) { + + ASSERT(square>=0&&square<64); + + return SquareFrom64[square]; +} + +// square_to_64() + +int square_to_64(int square) { + + ASSERT(square_is_ok(square)); + + return SquareTo64[square]; +} + +// square_is_promote() + +bool square_is_promote(int square) { + + int rank; + + ASSERT(square_is_ok(square)); + + rank = square_rank(square); + + return rank == Rank1 || rank == Rank8; +} + +// square_ep_dual() + +int square_ep_dual(int square) { + + ASSERT(square_is_ok(square)); + ASSERT(square_rank(square)>=2&&square_rank(square)<=5); + + return square ^ 16; +} + +// square_colour() + +int square_colour(int square) { + + ASSERT(square_is_ok(square)); + + return (square ^ (square >> 4)) & 1; +} + +// file_from_char() + +int file_from_char(int c) { + + ASSERT(c>='a'&&c<='h'); + + return c - 'a'; +} + +// rank_from_char() + +int rank_from_char(int c) { + + ASSERT(c>='1'&&c<='8'); + + return c - '1'; +} + +// file_to_char() + +int file_to_char(int file) { + + ASSERT(file>=0&&file<8); + + return 'a' + file; +} + +// rank_to_char() + +int rank_to_char(int rank) { + + ASSERT(rank>=0&&rank<8); + + return '1' + rank; +} + +// char_is_file() + +bool char_is_file(int c) { + + return c >= 'a' && c <= 'h'; +} + +// char_is_rank() + +bool char_is_rank(int c) { + + return c >= '1' && c <= '8'; +} + +// square_to_string() + +bool square_to_string(int square, char string[], int size) { + + ASSERT(square_is_ok(square)); + ASSERT(string!=NULL); + ASSERT(size>=3); + + if (size < 3) return false; + + string[0] = 'a' + square_file(square); + string[1] = '1' + square_rank(square); + string[2] = '\0'; + + return true; +} + +// square_from_string() + +int square_from_string(const char string[]) { + + int file, rank; + + ASSERT(string!=NULL); + + if (string[0] < 'a' || string[0] > 'h') return SquareNone; + if (string[1] < '1' || string[1] > '8') return SquareNone; + if (string[2] != '\0') return SquareNone; + + file = file_from_char(string[0]); + rank = rank_from_char(string[1]); + + return square_make(file,rank); +} + +// end of square.cpp + diff --git a/square.h b/square.h new file mode 100644 index 0000000..60ef4f9 --- /dev/null +++ b/square.h @@ -0,0 +1,82 @@ + +// square.h + +#ifndef SQUARE_H +#define SQUARE_H + +// includes + +#include "util.h" + +// constants + +const int SquareNb = 16 * 12; + +const int FileA = 0; +const int FileB = 1; +const int FileC = 2; +const int FileD = 3; +const int FileE = 4; +const int FileF = 5; +const int FileG = 6; +const int FileH = 7; + +const int Rank1 = 0; +const int Rank2 = 1; +const int Rank3 = 2; +const int Rank4 = 3; +const int Rank5 = 4; +const int Rank6 = 5; +const int Rank7 = 6; +const int Rank8 = 7; + +const int SquareNone = 0; + +const int A1=0x24, B1=0x25, C1=0x26, D1=0x27, E1=0x28, F1=0x29, G1=0x2A, H1=0x2B; +const int A2=0x34, B2=0x35, C2=0x36, D2=0x37, E2=0x38, F2=0x39, G2=0x3A, H2=0x3B; +const int A3=0x44, B3=0x45, C3=0x46, D3=0x47, E3=0x48, F3=0x49, G3=0x4A, H3=0x4B; +const int A4=0x54, B4=0x55, C4=0x56, D4=0x57, E4=0x58, F4=0x59, G4=0x5A, H4=0x5B; +const int A5=0x64, B5=0x65, C5=0x66, D5=0x67, E5=0x68, F5=0x69, G5=0x6A, H5=0x6B; +const int A6=0x74, B6=0x75, C6=0x76, D6=0x77, E6=0x78, F6=0x79, G6=0x7A, H6=0x7B; +const int A7=0x84, B7=0x85, C7=0x86, D7=0x87, E7=0x88, F7=0x89, G7=0x8A, H7=0x8B; +const int A8=0x94, B8=0x95, C8=0x96, D8=0x97, E8=0x98, F8=0x99, G8=0x9A, H8=0x9B; + +const int Dark = 0; +const int Light = 1; + +// functions + +extern void square_init (); + +extern bool square_is_ok (int square); + +extern int square_make (int file, int rank); + +extern int square_file (int square); +extern int square_rank (int square); +extern int square_side_rank (int square, int colour); + +extern int square_from_64 (int square); +extern int square_to_64 (int square); + +extern bool square_is_promote (int square); +extern int square_ep_dual (int square); + +extern int square_colour (int square); + +extern bool char_is_file (int c); +extern bool char_is_rank (int c); + +extern int file_from_char (int c); +extern int rank_from_char (int c); + +extern int file_to_char (int file); +extern int rank_to_char (int rank); + +extern bool square_to_string (int square, char string[], int size); +extern int square_from_string (const char string[]); + +#endif // !defined SQUARE_H + +// end of square.h + diff --git a/uci.cpp b/uci.cpp new file mode 100644 index 0000000..c12c67b --- /dev/null +++ b/uci.cpp @@ -0,0 +1,955 @@ + +// uci.cpp + +// includes + +#include +#include +#include +#include + +#include "board.h" +#include "engine.h" +#include "move.h" +#include "move_do.h" +#include "move_legal.h" +#include "option.h" +#include "parse.h" +#include "line.h" +#include "uci.h" + +// constants + +static const bool UseDebug = false; + +static const int StringSize = 4096; + +// variables + +uci_t Uci[1]; + +// Hopefully the following confusion is temporary +// Normally we should check for the engine name but this is a hack anyway +// Some of there where provided by Marc Lacrosse + +const char * thread_options[]={ + "number of threads", // toga + "number threads", // Deep Learning Toga + "threads", // glaurung, zappa, cyclone, grapefruit, + // Deep Shredder, Deep Junior + "core threads", // HIARCS + "max cpus", // rybka + "cpus", // Deep Sjeng, Fruit2.3.5 + "maxthreads", // Naum + NULL +}; + +// prototypes + +static bool uci_is_ok (const uci_t * uci); + +static int parse_bestmove (uci_t * uci, const char string[]); +static void parse_id (uci_t * uci, const char string[]); +static int parse_info (uci_t * uci, const char string[]); +static void parse_option (uci_t * uci, const char string[]); +static void parse_score (uci_t * uci, const char string[]); + +static int mate_score (int dist); + +// functions + +// uci_set_threads() + +void uci_set_threads(uci_t * uci, int n) { + const char **thread_options_copy = thread_options; + const char *thread_option; + ASSERT(n>=1); + while((thread_option = *(thread_options_copy++))){ + uci_send_option(uci,thread_option,"%d",n); // checks also for existence + } +} + +// uci_thread_option_exists() + +bool uci_thread_option_exist(uci_t * uci) { + const char **thread_options_copy = thread_options; + const char *thread_option; + while((thread_option = *(thread_options_copy++))){ + if(uci_option_exist(uci,thread_option)) return true; + } + return false; +} + +// uci_is_ok() + +static bool uci_is_ok(const uci_t * uci) { + + if (uci == NULL) return false; + if (uci->engine == NULL) return false; + if (uci->option_nb < 0 || uci->option_nb >= OptionNb) return false; + + return true; +} + +// uci_open() + +void uci_open(uci_t * uci, engine_t * engine) { + + char string[StringSize]; + int event; + + ASSERT(uci!=NULL); + ASSERT(engine!=NULL); + + // init + + uci->engine = engine; + + uci->name = NULL; + my_string_set(&uci->name,""); + uci->author = NULL; + my_string_set(&uci->author,""); + uci->option_nb = 0; + + uci->ready_nb = 0; + uci->searching = 0; + uci->pending_nb = 0; + uci->multipv_mode = false; + board_start(uci->board); + uci_clear(uci); + + // send "uci" and wait for "uciok" + + engine_send(uci->engine,"uci"); + + do { + engine_get(uci->engine,string,StringSize); + event = uci_parse(uci,string); + } while ((event & EVENT_UCI) == 0); +} + +// uci_close() + +void uci_close(uci_t * uci) { + + int i; + option_t * opt; + + ASSERT(uci_is_ok(uci)); + engine_close(uci->engine); + uci->engine = NULL; + my_string_clear(&uci->name); + my_string_clear(&uci->author); + + for (i = 0; i < uci->option_nb; i++) { + opt = &uci->option[i]; + my_string_clear(&opt->name); + my_string_clear(&opt->value); + } + + uci->option_nb = 0; +} + +// uci_clear() + +void uci_clear(uci_t * uci) { + + ASSERT(uci_is_ok(uci)); + + ASSERT(!uci->searching); + + uci->best_move = MoveNone; + uci->ponder_move = MoveNone; + + uci->score = 0; + uci->depth = 0; + uci->sel_depth = 0; + line_clear(uci->pv); + + uci->best_score = 0; + uci->best_depth = 0; + uci->best_sel_depth = 0; + line_clear(uci->best_pv); + + uci->node_nb = 0; + uci->time = 0.0; + uci->speed = 0.0; + uci->cpu = 0.0; + uci->hash = 0.0; + line_clear(uci->current_line); + + uci->root_move = MoveNone; + uci->root_move_pos = 0; + uci->root_move_nb = board_mobility(uci->board); +} + +// uci_send_isready() + +void uci_send_isready(uci_t * uci) { + + ASSERT(uci!=NULL); + + engine_send(uci->engine,"isready"); + uci->ready_nb++; +} + +// uci_send_isready_sync() + +void uci_send_isready_sync(uci_t * uci) { + + char string[StringSize]; + int event; + + ASSERT(uci_is_ok(uci)); + + // send "isready" and wait for "readyok" + + uci_send_isready(uci); + + do { + engine_get(uci->engine,string,StringSize); + event = uci_parse(uci,string); + } while ((event & EVENT_READY) == 0); +} + +// uci_send_stop() + +void uci_send_stop(uci_t * uci) { + + ASSERT(uci_is_ok(uci)); + + ASSERT(uci->searching); + ASSERT(uci->pending_nb>=1); + + engine_send(Engine,"stop"); + uci->searching = false; +} + +// uci_send_stop_sync() + +void uci_send_stop_sync(uci_t * uci) { + + char string[StringSize]; + int event; + + ASSERT(uci_is_ok(uci)); + + ASSERT(uci->searching); + ASSERT(uci->pending_nb>=1); + + // send "stop" and wait for "bestmove" + + uci_send_stop(uci); + + do { + engine_get(uci->engine,string,StringSize); + event = uci_parse(uci,string); + } while ((event & EVENT_STOP) == 0); +} + +// uci_send_ucinewgame() + +void uci_send_ucinewgame(uci_t * uci) { + + ASSERT(uci!=NULL); + + if (option_get_int("UCIVersion") >= 2) { + engine_send(uci->engine,"ucinewgame"); + } +} + +// uci_option_exist() + +bool uci_option_exist(uci_t * uci, const char option[]) { + + int i; + option_t * opt; + + ASSERT(uci_is_ok(uci)); + ASSERT(option!=NULL); + + // scan options + + for (i = 0; i < uci->option_nb; i++) { + opt = &uci->option[i]; + if (my_string_case_equal(opt->name,option)) return true; + } + + return false; +} + +// uci_send_option() + +void uci_send_option(uci_t * uci, const char option[], const char format[], ...) { + + va_list arg_list; + char value[StringSize]; + int i; + option_t * opt; + + ASSERT(uci_is_ok(uci)); + ASSERT(option!=NULL); + ASSERT(format!=NULL); + + // format + + va_start(arg_list,format); + vsprintf(value,format,arg_list); + va_end(arg_list); + + if (UseDebug) my_log("POLYGLOT OPTION %s VALUE %s\n",option,value); + + // scan options + + for (i = 0; i < uci->option_nb; i++) { + + opt = &uci->option[i]; + + if (my_string_case_equal(opt->name,option) && !my_string_equal(opt->value,value)) { + engine_send(uci->engine,"setoption name %s value %s",opt->name,value); + my_string_set(&opt->value,value); + break; + } + } +} + +// uci_parse() + +int uci_parse(uci_t * uci, const char string[]) { + + int event; + parse_t parse[1]; + char command[StringSize]; + char argument[StringSize]; + + ASSERT(uci_is_ok(uci)); + ASSERT(string!=NULL); + + // init + + event = EVENT_NONE; + + // parse + + parse_open(parse,string); + + if (parse_get_word(parse,command,StringSize)) { + + parse_get_string(parse,argument,StringSize); + if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" ARGUMENT \"%s\"\n",command,argument); + + if (false) { + + } else if (my_string_equal(command,"bestmove")) { + + // search end + + ASSERT(uci->pending_nb>0); + + if (uci->searching && uci->pending_nb == 1) { + + // current search + + uci->searching = false; + uci->pending_nb--; + + event = parse_bestmove(uci,argument); // updates uci->best_move and uci->ponder_move + + } else { + + // obsolete search + + if (uci->pending_nb > 0) { + uci->pending_nb--; + if (uci->pending_nb == 0) event = EVENT_STOP; + } + } + + } else if (my_string_equal(command,"id")) { + + parse_id(uci,argument); + + } else if (my_string_equal(command,"info")) { + + // search information + + if (uci->searching && uci->pending_nb == 1) { // current search + event = parse_info(uci,argument); + } + + } else if (my_string_equal(command,"option")) { + + parse_option(uci,argument); + + } else if (my_string_equal(command,"readyok")) { + + // engine is ready + + ASSERT(uci->ready_nb>0); + + if (uci->ready_nb > 0) { + uci->ready_nb--; + if (uci->ready_nb == 0) event = EVENT_READY; + } + + } else if (my_string_equal(command,"uciok")) { + + event = EVENT_UCI; + + } else { + + if (UseDebug) my_log("POLYGLOT unknown command \"%s\"\n",command); + } + } + + parse_close(parse); + + return event; +} + +// parse_bestmove() + +static int parse_bestmove(uci_t * uci, const char string[]) { + + parse_t parse[1]; + char command[StringSize]; + char option[StringSize]; + char argument[StringSize]; + board_t board[1]; + + ASSERT(uci_is_ok(uci)); + ASSERT(string!=NULL); + + // init + + strcpy(command,"bestmove"); + + parse_open(parse,string); + parse_add_keyword(parse,"ponder"); + + // bestmove + + if (!parse_get_string(parse,argument,StringSize)) { + my_fatal("parse_bestmove(): missing argument\n"); + } + + uci->best_move = move_from_can(argument,uci->board); + if (uci->best_move == MoveNone) my_fatal("parse_bestmove(): not a move \"%s\"\n",argument); + + ASSERT(uci->best_move!=MoveNone); + ASSERT(move_is_legal(uci->best_move,uci->board)); + + // loop + + while (parse_get_word(parse,option,StringSize)) { + + parse_get_string(parse,argument,StringSize); + + if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" OPTION \"%s\" ARGUMENT \"%s\"\n",command,option,argument); + + if (false) { + + } else if (my_string_equal(option,"ponder")) { + + ASSERT(!my_string_empty(argument)); + + board_copy(board,uci->board); + move_do(board,uci->best_move); + + uci->ponder_move = move_from_can(argument,board); + // if (uci->ponder_move == MoveNone) my_fatal("parse_bestmove(): not a move \"%s\"\n",argument); + + ASSERT(uci->ponder_move!=MoveNone); + ASSERT(move_is_legal(uci->ponder_move,board)); + + } else { + + my_log("POLYGLOT unknown option \"%s\" for command \"%s\"\n",option,command); + } + } + + parse_close(parse); + + return EVENT_MOVE; +} + +// parse_id() + +static void parse_id(uci_t * uci, const char string[]) { + + parse_t parse[1]; + char command[StringSize]; + char option[StringSize]; + char argument[StringSize]; + + ASSERT(uci!=NULL); + ASSERT(string!=NULL); + + // init + + strcpy(command,"id"); + + parse_open(parse,string); + parse_add_keyword(parse,"author"); + parse_add_keyword(parse,"name"); + + // loop + + while (parse_get_word(parse,option,StringSize)) { + + parse_get_string(parse,argument,StringSize); + if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" OPTION \"%s\" ARGUMENT \"%s\"\n",command,option,argument); + + if (false) { + } else if (my_string_equal(option,"author")) { + ASSERT(!my_string_empty(argument)); + my_string_set(&uci->author,argument); + } else if (my_string_equal(option,"name")) { + ASSERT(!my_string_empty(argument)); + my_string_set(&uci->name,argument); + } else { + my_log("POLYGLOT unknown option \"%s\" for command \"%s\"\n",option,command); + } + } + + parse_close(parse); + + if (UseDebug) my_log("POLYGLOT engine name \"%s\" author \"%s\"\n",uci->name,uci->author); +} + +// parse_info() + +static int parse_info(uci_t * uci, const char string[]) { + + int event; + parse_t parse[1]; + char command[StringSize]; + char option[StringSize]; + char argument[StringSize]; + int n; + int multipvline=0; + sint64 ln; + + ASSERT(uci_is_ok(uci)); + ASSERT(string!=NULL); + + // init + + event = EVENT_NONE; + + strcpy(command,"info"); + + parse_open(parse,string); + parse_add_keyword(parse,"cpuload"); + parse_add_keyword(parse,"currline"); + parse_add_keyword(parse,"currmove"); + parse_add_keyword(parse,"currmovenumber"); + parse_add_keyword(parse,"depth"); + parse_add_keyword(parse,"hashfull"); + parse_add_keyword(parse,"multipv"); + parse_add_keyword(parse,"nodes"); + parse_add_keyword(parse,"nps"); + parse_add_keyword(parse,"pv"); + parse_add_keyword(parse,"refutation"); + parse_add_keyword(parse,"score"); + parse_add_keyword(parse,"seldepth"); + parse_add_keyword(parse,"string"); + parse_add_keyword(parse,"tbhits"); + parse_add_keyword(parse,"time"); + + // loop + + while (parse_get_word(parse,option,StringSize)) { + + parse_get_string(parse,argument,StringSize); + + if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" OPTION \"%s\" ARGUMENT \"%s\"\n",command,option,argument); + + if (false) { + + } else if (my_string_equal(option,"cpuload")) { + + ASSERT(!my_string_empty(argument)); + + n = atoi(argument); + ASSERT(n>=0); + + if (n >= 0) uci->cpu = double(n) / 1000.0; + + } else if (my_string_equal(option,"currline")) { + + ASSERT(!my_string_empty(argument)); + + line_from_can(uci->current_line,uci->board,argument,LineSize); + + } else if (my_string_equal(option,"currmove")) { + + ASSERT(!my_string_empty(argument)); + + uci->root_move = move_from_can(argument,uci->board); + ASSERT(uci->root_move!=MoveNone); + + } else if (my_string_equal(option,"currmovenumber")) { + + ASSERT(!my_string_empty(argument)); + + n = atoi(argument); + ASSERT(n>=1&&n<=uci->root_move_nb); + + if (n >= 1 && n <= uci->root_move_nb) { + uci->root_move_pos = n - 1; + ASSERT(uci->root_move_pos>=0&&uci->root_move_posroot_move_nb); + } + + } else if (my_string_equal(option,"depth")) { + + ASSERT(!my_string_empty(argument)); + + n = atoi(argument); + ASSERT(n>=1); + + if (n >= 0) { + if (n > uci->depth) event |= EVENT_DEPTH; + uci->depth = n; + } + + } else if (my_string_equal(option,"hashfull")) { + + ASSERT(!my_string_empty(argument)); + + n = atoi(argument); + ASSERT(n>=0); + + if (n >= 0) uci->hash = double(n) / 1000.0; + + } else if (my_string_equal(option,"multipv")) { + + ASSERT(!my_string_empty(argument)); + + n = atoi(argument); + if(Uci->multipv_mode) multipvline=n; + + ASSERT(n>=1); + + } else if (my_string_equal(option,"nodes")) { + + ASSERT(!my_string_empty(argument)); + + ln = my_atoll(argument); + ASSERT(ln>=0); + + if (ln >= 0) uci->node_nb = ln; + + } else if (my_string_equal(option,"nps")) { + + ASSERT(!my_string_empty(argument)); + + n = atoi(argument); + ASSERT(n>=0); + + if (n >= 0) uci->speed = double(n); + + } else if (my_string_equal(option,"pv")) { + + ASSERT(!my_string_empty(argument)); + + line_from_can(uci->pv,uci->board,argument,LineSize); + event |= EVENT_PV; + + } else if (my_string_equal(option,"refutation")) { + + ASSERT(!my_string_empty(argument)); + + line_from_can(uci->pv,uci->board,argument,LineSize); + + } else if (my_string_equal(option,"score")) { + + ASSERT(!my_string_empty(argument)); + + parse_score(uci,argument); + + } else if (my_string_equal(option,"seldepth")) { + + ASSERT(!my_string_empty(argument)); + + n = atoi(argument); + ASSERT(n>=0); + + if (n >= 0) uci->sel_depth = n; + + } else if (my_string_equal(option,"string")) { + if(!strncmp(argument,"DrawOffer",9)) + event |= EVENT_DRAW; + if(!strncmp(argument,"Resign",6)) + event |= EVENT_RESIGN; + + // TODO: argument to EOS + + ASSERT(!my_string_empty(argument)); + + } else if (my_string_equal(option,"tbhits")) { + + ASSERT(!my_string_empty(argument)); + + ln = my_atoll(argument); + ASSERT(ln>=0); + + } else if (my_string_equal(option,"time")) { + + ASSERT(!my_string_empty(argument)); + + n = atoi(argument); + ASSERT(n>=0); + + if (n >= 0) uci->time = double(n) / 1000.0; + + } else { + + my_log("POLYGLOT unknown option \"%s\" for command \"%s\"\n",option,command); + } + } + + parse_close(parse); + + // update display + //lousy uci,filter out lower depth multipv lines that have been repeated from the engine + if(multipvline>1 && uci->depthbest_depth) event &= ~EVENT_PV; + if ((event & EVENT_PV) != 0) { + uci->best_score = uci->score; + uci->best_depth = uci->depth; + if(multipvline==1)uci->depth=-1; //HACK ,clears the engine outpout window,see send_pv in adapter.cpp + uci->best_sel_depth = uci->sel_depth; + line_copy(uci->best_pv,uci->pv); + } + return event; +} + +int uci_get_option(uci_t * uci, const char * name){ + int i; + for(i=0;ioption_nb;i++){ + if(my_string_case_equal(Uci->option[i].name,name)){ + return i; + } + } + return -1; +} + + + +// uci_set_option() + +void uci_set_option(uci_t * uci, + const char * name, + const char * value, + const char * type, + const char * max, + const char * min, + const char * var){ + int i; + for(i=0;ioption_nb;i++){ + if(my_string_equal(Uci->option[i].name,name)){ + break; + } + } + if(ioption[i].name),name); + my_string_set(&(Uci->option[i].value),value); + my_string_set(&(Uci->option[i].type),type); + my_string_set(&(Uci->option[i].min),min); + my_string_set(&(Uci->option[i].max),max); + my_string_set(&(Uci->option[i].var),var); + if(i==Uci->option_nb){ + Uci->option_nb++; + } + } +} + +// parse_option() + +static void parse_option(uci_t * uci, const char string[]) { + + option_t * opt; + parse_t parse[1]; + char command[StringSize]; + char option[StringSize]; + char argument[StringSize]; + + ASSERT(uci!=NULL); + ASSERT(string!=NULL); + + // init + + strcpy(command,"option"); + + if (uci->option_nb >= OptionNb) return; + + opt = &uci->option[uci->option_nb]; + uci->option_nb++; + + opt->name = NULL; + my_string_set(&opt->name,""); + + opt->value = NULL; + my_string_set(&opt->value,""); + + opt->max = NULL; + my_string_set(&opt->max,""); + + opt->min = NULL; + my_string_set(&opt->min,""); + + opt->type = NULL; + my_string_set(&opt->type,""); + + opt->var = NULL; + my_string_set(&opt->var,""); + + parse_open(parse,string); + parse_add_keyword(parse,"default"); + parse_add_keyword(parse,"max"); + parse_add_keyword(parse,"min"); + parse_add_keyword(parse,"name"); + parse_add_keyword(parse,"type"); + parse_add_keyword(parse,"var"); + + // loop + + while (parse_get_word(parse,option,StringSize)) { + + parse_get_string(parse,argument,StringSize); + if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" OPTION \"%s\" ARGUMENT \"%s\"\n",command,option,argument); + + if (false) { + + } else if (my_string_equal(option,"default")) { + + // ASSERT(!my_string_empty(argument)); // HACK for Pepito + + if (!my_string_empty(argument)) { + my_string_set(&opt->value,argument); + } + + } else if (my_string_equal(option,"max")) { + + ASSERT(!my_string_empty(argument)); + my_string_set(&opt->max,argument); + + } else if (my_string_equal(option,"min")) { + + ASSERT(!my_string_empty(argument)); + my_string_set(&opt->min,argument); + + } else if (my_string_equal(option,"name")) { + + ASSERT(!my_string_empty(argument)); + + if (!my_string_empty(argument)) { + my_string_set(&opt->name,argument); + } + + } else if (my_string_equal(option,"type")) { + + ASSERT(!my_string_empty(argument)); + my_string_set(&opt->type,argument); + + } else if (my_string_equal(option,"var")) { + + ASSERT(!my_string_empty(argument)); + my_string_set(&opt->var,argument); + + } else { + + my_log("POLYGLOT unknown option \"%s\" for command \"%s\"\n",option,command); + } + } + + parse_close(parse); + + if (UseDebug) my_log("POLYGLOT option name \"%s\" value \"%s\"\n",opt->name,opt->value); +} + +// parse_score() + +static void parse_score(uci_t * uci, const char string[]) { + + parse_t parse[1]; + char command[StringSize]; + char option[StringSize]; + char argument[StringSize]; + int n; + + ASSERT(uci_is_ok(uci)); + ASSERT(string!=NULL); + + // init + + strcpy(command,"score"); + + parse_open(parse,string); + parse_add_keyword(parse,"cp"); + parse_add_keyword(parse,"lowerbound"); + parse_add_keyword(parse,"mate"); + parse_add_keyword(parse,"upperbound"); + + // loop + + while (parse_get_word(parse,option,StringSize)) { + + parse_get_string(parse,argument,StringSize); + + if (UseDebug) my_log("POLYGLOT COMMAND \"%s\" OPTION \"%s\" ARGUMENT \"%s\"\n",command,option,argument); + + if (false) { + + } else if (my_string_equal(option,"cp")) { + + ASSERT(!my_string_empty(argument)); + + n = atoi(argument); + + uci->score = n; + + } else if (my_string_equal(option,"lowerbound")) { + + ASSERT(my_string_empty(argument)); + + } else if (my_string_equal(option,"mate")) { + + ASSERT(!my_string_empty(argument)); + + n = atoi(argument); + ASSERT(n!=0); + + uci->score = mate_score(n); + + } else if (my_string_equal(option,"upperbound")) { + + ASSERT(my_string_empty(argument)); + + } else { + + my_log("POLYGLOT unknown option \"%s\" for command \"%s\"\n",option,command); + } + } + + parse_close(parse); +} + +// mate_score() + +static int mate_score(int dist) { + + ASSERT(dist!=0); + + if (false) { + } else if (dist > 0) { + return +option_get_int("MateScore") - (+dist) * 2 + 1; + } else if (dist < 0) { + return -option_get_int("MateScore") + (-dist) * 2; + } + + return 0; +} + +// end of uci.cpp + diff --git a/uci.h b/uci.h new file mode 100644 index 0000000..7291cdc --- /dev/null +++ b/uci.h @@ -0,0 +1,122 @@ + +// uci.h + +#ifndef UCI_H +#define UCI_H + +// includes + +#include "board.h" +#include "engine.h" +#include "line.h" +#include "move.h" +#include "util.h" + +// constants + +const int OptionNb = 256; + +// types + +struct option_t { + const char * name; + const char * value; + const char * type; + const char * max; + const char * min; + const char * var; +}; + +struct uci_t { + + engine_t * engine; + + const char * name; + const char * author; + + int option_nb; + option_t option[OptionNb]; + + bool ready; + int ready_nb; + + bool searching; + int pending_nb; + + board_t board[1]; + + int best_move; + int ponder_move; + + int score; + int depth; + int sel_depth; + move_t pv[LineSize]; + + int best_score; + int best_depth; + int best_sel_depth; + move_t best_pv[LineSize]; + + sint64 node_nb; + double time; + double speed; + double cpu; + double hash; + move_t current_line[LineSize]; + + int root_move; + int root_move_pos; + int root_move_nb; + bool multipv_mode; +}; + +enum dummy_event_t { + EVENT_NONE = 0, + EVENT_UCI = 1 << 0, + EVENT_READY = 1 << 1, + EVENT_STOP = 1 << 2, + EVENT_MOVE = 1 << 3, + EVENT_PV = 1 << 4, + EVENT_DEPTH = 1 << 5, + EVENT_DRAW = 1 << 6, + EVENT_RESIGN= 1 << 7 +}; + +// variables + +extern uci_t Uci[1]; + +// functions + +extern void uci_open (uci_t * uci, engine_t * engine); +extern void uci_send_isready (uci_t * uci); +extern void uci_send_isready_sync (uci_t * uci); +extern void uci_send_stop (uci_t * uci); +extern void uci_send_stop_sync (uci_t * uci); +extern void uci_send_ucinewgame (uci_t * uci); +extern void uci_set_threads (uci_t * uci, int n); +extern bool uci_thread_option_exist(uci_t * uci); +extern int uci_get_option (uci_t * uci, const char * name); + +extern bool uci_option_exist (uci_t * uci, const char option[]); +extern void uci_send_option (uci_t * uci, const char option[], const char format[], ...); + +extern void uci_close (uci_t * uci); + +extern void uci_clear (uci_t * uci); + +extern int uci_parse (uci_t * uci, const char string[]); + +void uci_set_option(uci_t * uci, + const char * name, + const char * value, + const char * type, + const char * max, + const char * min, + const char * var); + +#endif // !defined UCI_H + +// end of uci.h + diff --git a/uci2uci.cpp b/uci2uci.cpp new file mode 100644 index 0000000..8132224 --- /dev/null +++ b/uci2uci.cpp @@ -0,0 +1,254 @@ +// uci2uci.cpp + +// includes + +#include +#include + +#include "util.h" +#include "adapter.h" +#include "board.h" +#include "engine.h" +#include "fen.h" +#include "gui.h" +#include "move.h" +#include "move_do.h" +#include "move_legal.h" +#include "parse.h" +#include "option.h" +#include "book.h" +#include "main.h" +#include "uci.h" + +// constants + +static const int StringSize = 4096; + +// variables + +static board_t UCIboard[1]; +static bool Init=true; +static int SavedMove=MoveNone; + +// defines + +#ifdef _WIN32 +#define strcasecmp lstrcmpi +#endif + +// parse_position() + +static void parse_position(const char string[]) { + +/* This is borrowed from Toga II. This code is quite hacky and will be + rewritten using the routines in parse.cpp. +*/ + + const char * fen; + char * moves; + const char * ptr; + char move_string[256]; + int move; + char * string_copy; + + // init + + string_copy=my_strdup(string); + + fen = strstr(string_copy,"fen "); + moves = strstr(string_copy,"moves "); + + // start position + + if (fen != NULL) { // "fen" present + + if (moves != NULL) { // "moves" present + ASSERT(moves>fen); + moves[-1] = '\0'; // dirty, but so is UCI + } + + board_from_fen(UCIboard,fen+4); // CHANGE ME + + } else { + + // HACK: assumes startpos + + board_from_fen(UCIboard,StartFen); + } + + // moves + + if (moves != NULL) { // "moves" present + + ptr = moves + 6; + + while (*ptr != '\0') { + + while (*ptr == ' ') ptr++; + + move_string[0] = *ptr++; + move_string[1] = *ptr++; + move_string[2] = *ptr++; + move_string[3] = *ptr++; + + if (*ptr == '\0' || *ptr == ' ') { + move_string[4] = '\0'; + } else { // promote + move_string[4] = *ptr++; + move_string[5] = '\0'; + } + move = move_from_can(move_string,UCIboard); + + move_do(UCIboard,move); + + } + } + free(string_copy); +} + + +// send_book_move() + +static void send_book_move(int move){ + char move_string[256]; + my_log("POLYGLOT *BOOK MOVE*\n"); + move_to_can(move,UCIboard,move_string,256); + // bogus info lines + gui_send(GUI,"info depth 1 time 0 nodes 0 nps 0 cpuload 0"); + gui_send(GUI,"bestmove %s",move_string); +} + +// send_uci_options() + +void send_uci_options() { + int i; + char option_line[StringSize]=""; + char option_string[StringSize]=""; + gui_send(GUI,"id name %s", Uci->name); + gui_send(GUI,"id author %s", Uci->author); + for(i=0;ioption_nb;i++){ + strcat(option_line,"option"); + if(strcmp(Uci->option[i].name,"")){ + sprintf(option_string," name %s",Uci->option[i].name); + strcat(option_line,option_string); + } + if(strcmp(Uci->option[i].type,"")){ + sprintf(option_string," type %s",Uci->option[i].type); + strcat(option_line,option_string); + } + if(strcmp(Uci->option[i].value,"")){ + sprintf(option_string," default %s",Uci->option[i].value); + strcat(option_line,option_string); + } + if(strcmp(Uci->option[i].min,"")){ + sprintf(option_string," min %s",Uci->option[i].min); + strcat(option_line,option_string); + } + if(strcmp(Uci->option[i].max,"")){ + sprintf(option_string," max %s",Uci->option[i].max); + strcat(option_line,option_string); + } + if(strcmp(Uci->option[i].var,"")){ + sprintf(option_string," var %s",Uci->option[i].var); + strcat(option_line,option_string); + } + gui_send(GUI,"%s",option_line); + strcpy(option_line,""); + } + gui_send(GUI,"uciok"); +} + +// parse_setoption() + + + +static void parse_setoption(const char string[]) { + parse_t parse[1]; + char option[StringSize]; + char name[StringSize]; + char value[StringSize]; + char * string_copy; + string_copy=my_strdup(string); + parse_open(parse,string_copy); + parse_add_keyword(parse,"setoption"); + parse_add_keyword(parse,"name"); + parse_add_keyword(parse,"value"); + parse_get_word(parse,option,StringSize); + ASSERT(my_string_equal(option,"setoption")); + if(parse_get_word(parse,option,StringSize)){ + if(my_string_equal(option,"name")){ + parse_get_string(parse,name,StringSize); + if(parse_get_word(parse,option,StringSize)){ + if(my_string_equal(option,"value")){ + parse_get_string(parse,value,StringSize); + if(my_string_case_equal(name,PolyglotBookFile)){ + my_log("POLYGLOT *** SETTING BOOK ***\n"); + my_log("POLYGLOT BOOK \"%s\"\n",value); + book_close(); + book_clear(); + book_open(value); + if(!book_is_open()){ + my_log("POLYGLOT Unable to open book \"%s\"\n",value); + } + }else{ + engine_send(Engine,"%s",string); + } + } + } + } + } + parse_close(parse); + free(string_copy); +} + + +// uci_gui_step() + +void uci_gui_step(char string[]) { + int move; + if(false){ + }else if(match(string,"uci")){ + send_uci_options(); + return; + }else if(match(string,"setoption *")){ + parse_setoption(string); + return; + }else if(match(string,"position *")){ + parse_position(string); + Init=false; + }else if(match(string,"go *")){ + if(Init){ + board_from_fen(UCIboard,StartFen); + Init=false; + } + SavedMove=MoveNone; + if(!strstr(string,"infinite")){ + move=book_move(UCIboard,option_get_bool("BookRandom")); + if (move != MoveNone && move_is_legal(move,UCIboard)) { + if(strstr(string,"ponder")){ + SavedMove=move; + return; + }else{ + send_book_move(move); + return; + } + } + } + }else if(match(string,"ponderhit") || match(string,"stop")){ + if(SavedMove!=MoveNone){ + send_book_move(SavedMove); + SavedMove=MoveNone; + return; + } + }else if(match(string,"quit")){ + my_log("POLYGLOT *** \"quit\" from GUI ***\n"); + quit(); + } + engine_send(Engine,"%s",string); +} + +void uci_engine_step(char string[]) { + gui_send(GUI,string); +} + +// end of uci2uci.cpp diff --git a/uci2uci.h b/uci2uci.h new file mode 100644 index 0000000..2e9e0a6 --- /dev/null +++ b/uci2uci.h @@ -0,0 +1,19 @@ + +// uci2uci.h + +#ifndef UCI2UCI_H +#define UCI2UCI_H + +// constants + +const char * const PolyglotBookFile="Polyglot BookFile"; + +// functions + +extern void uci_gui_step(char string[]); +extern void uci_engine_step(char string[]); +extern void send_uci_options(); + +#endif // !defined UCI2UCI_H + +// end of uci2uci.h diff --git a/util.cpp b/util.cpp new file mode 100644 index 0000000..1bdc0a0 --- /dev/null +++ b/util.cpp @@ -0,0 +1,367 @@ + +// util.cpp + +// includes + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "main.h" +#include "posix.h" +#include "util.h" + +// variables + +static bool Error; + +FILE * LogFile=NULL; + + +// functions + +// util_init() + +void util_init() { + + Error = false; + + // init log file + + LogFile = NULL; + + // switch file buffering off + + setbuf(stdin,NULL); + setbuf(stdout,NULL); +} + +// my_random_init() + +void my_random_init() { + srand(time(NULL)); +} + +// my_random_int() + +int my_random_int(int n) { + + int r; + + ASSERT(n>0); + + r = int(floor(my_random_double()*double(n))); + ASSERT(r>=0&&r=0.0&&r<1.0); + + return r; +} + +// my_atoll() + +sint64 my_atoll(const char string[]) { + + sint64 n; + + sscanf(string,S64_FORMAT,&n); + + return n; +} + +// my_round() + +int my_round(double x) { + + return int(floor(x+0.5)); +} + +// my_malloc() + +void * my_malloc(size_t size) { + + void * address; + + ASSERT(size>0); + + address = malloc(size); + if (address == NULL) my_fatal("my_malloc(): malloc(): %s\n",strerror(errno)); + + return address; +} + +// my_realloc() + +void * my_realloc(void * address, size_t size) { + + ASSERT(address!=NULL); + ASSERT(size>0); + + address = realloc(address,size); + if (address == NULL) my_fatal("my_realloc(): realloc(): %s\n",strerror(errno)); + + return address; +} + +// my_free() + +void my_free(void * address) { + + ASSERT(address!=NULL); + + free(address); +} + +// my_log_open() + +void my_log_open(const char file_name[]) { + + ASSERT(file_name!=NULL); + + LogFile = fopen(file_name,"a"); +#ifndef _WIN32 +//line buffering doesn't work too well in MSVC and/or windows + if (LogFile != NULL) setvbuf(LogFile,NULL,_IOLBF,0); // line buffering +#endif +} + +// my_log_close() + +void my_log_close() { + + if (LogFile != NULL) fclose(LogFile); +} + +// my_log() + +void my_log(const char format[], ...) { + + va_list ap; + + ASSERT(format!=NULL); + + if (LogFile != NULL) { + fprintf(LogFile,"%.3f ",now_real()); + va_start(ap,format); + + vfprintf(LogFile,format,ap); + va_end(ap); +#ifdef _WIN32 + fflush(LogFile); +#endif + } +} + +// my_fatal() + +void my_fatal(const char format[], ...) { + + va_list ap; + + ASSERT(format!=NULL); + + va_start(ap,format); + + vfprintf(stderr,format,ap); + if (LogFile != NULL) vfprintf(LogFile,format,ap); + + va_end(ap); + if (Error) { // recursive error + my_log("POLYGLOT *** RECURSIVE ERROR ***\n"); + exit(EXIT_FAILURE); + // abort(); + } else { + Error = true; + quit(); + } +} + +// my_file_read_line() + +bool my_file_read_line(FILE * file, char string[], int size) { + + int src, dst; + int c; + + ASSERT(file!=NULL); + ASSERT(string!=NULL); + ASSERT(size>0); + + if (fgets(string,size,file) == NULL) { + if (feof(file)) { + return false; + } else { // error + my_fatal("my_file_read_line(): fgets(): %s\n",strerror(errno)); + } + } + + // remove CRs and LFs + + src = 0; + dst = 0; + + while ((c=string[src++]) != '\0') { + if (c != '\r' && c != '\n') string[dst++] = c; + } + + string[dst] = '\0'; + + return true; +} + +// my_string_empty() + +bool my_string_empty(const char string[]) { + + return string == NULL || string[0] == '\0'; +} + +// my_string_whitespace() + +bool my_string_whitespace(const char string[]){ + int pos=0; + while(string[pos]!='\0'){ + if(string[pos]!=' ' && string[pos]!='\t'){ + return false; + } + pos++; + } + return true; +} + +// my_string_equal() + +bool my_string_equal(const char string_1[], const char string_2[]) { + + ASSERT(string_1!=NULL); + ASSERT(string_2!=NULL); + + return strcmp(string_1,string_2) == 0; +} + +// my_string_case_equal() + +bool my_string_case_equal(const char string_1[], const char string_2[]) { + + int c1, c2; + + ASSERT(string_1!=NULL); + ASSERT(string_2!=NULL); + + while (true) { + + c1 = *string_1++; + c2 = *string_2++; + + if (tolower(c1) != tolower(c2)) return false; + if (c1 == '\0') return true; + } + + return false; +} + +// my_strdup() + +char * my_strdup(const char string[]) { + + char * address; + + ASSERT(string!=NULL); + + // strdup() is not ANSI C + + address = (char *) my_malloc(strlen(string)+1); + strcpy(address,string); + + return address; +} + +// my_string_clear() + +void my_string_clear(const char * * variable) { + + ASSERT(variable!=NULL); + + if (*variable != NULL) { + my_free((void*)(*variable)); + *variable = NULL; + } +} + +// my_string_set() + +void my_string_set(const char * * variable, const char string[]) { + + ASSERT(variable!=NULL); + ASSERT(string!=NULL); + + if (*variable != NULL) my_free((void*)(*variable)); + *variable = my_strdup(string); +} + +// my_timer_reset() + +void my_timer_reset(my_timer_t * timer) { + + ASSERT(timer!=NULL); + + timer->start_real = 0.0; + timer->elapsed_real = 0.0; + timer->running = false; +} + +// my_timer_start() + +void my_timer_start(my_timer_t * timer) { +// timer->start_real = 0.0; + timer->elapsed_real = 0.0; +// timer->running = false; + ASSERT(timer!=NULL); + + timer->running = true; + timer->start_real = now_real(); +} + +// my_timer_stop() + +void my_timer_stop(my_timer_t * timer) { + + ASSERT(timer!=NULL); + + ASSERT(timer->running); + + timer->elapsed_real += now_real() - timer->start_real; + timer->start_real = 0.0; + timer->running = false; +} + +// my_timer_elapsed_real() + +double my_timer_elapsed_real(const my_timer_t * timer) { + + double elapsed; + + ASSERT(timer!=NULL); + + elapsed = timer->elapsed_real; + if (timer->running) elapsed += now_real() - timer->start_real; + + if (elapsed < 0.0) elapsed = 0.0; + + return elapsed; +} diff --git a/util.h b/util.h new file mode 100644 index 0000000..9449f12 --- /dev/null +++ b/util.h @@ -0,0 +1,132 @@ + +// util.h + +#ifndef UTIL_H +#define UTIL_H + +// includes + +#include + +// constants + +#undef FALSE +#define FALSE 0 + +#undef TRUE +#define TRUE 1 + +#ifdef DEBUG +# undef DEBUG +# define DEBUG TRUE +#else +# define DEBUG FALSE +#endif + +#if defined(_MSC_VER) || defined(__MINGW32__) || defined(__MINGW64__) +# define S64_FORMAT "%I64d" +# define U64_FORMAT "%016I64X" +#else +# define S64_FORMAT "%lld" +# define U64_FORMAT "%016llX" +#endif + +// macros + +#ifdef _MSC_VER +# define S64(u) (u##i64) +# define U64(u) (u##ui64) +#else +# define S64(u) (u##LL) +# define U64(u) (u##ULL) +#endif + +#undef ASSERT +#if DEBUG +# define ASSERT(a) { if (!(a)) my_fatal("file \"%s\", line %d, assertion \"" #a "\" failed\n",__FILE__,__LINE__); } +#else +# define ASSERT(a) +#endif + +// types + +typedef signed char sint8; +typedef unsigned char uint8; + +typedef signed short sint16; +typedef unsigned short uint16; + +typedef signed int sint32; +typedef unsigned int uint32; + +#ifdef _MSC_VER + typedef signed __int64 sint64; + typedef unsigned __int64 uint64; +#else + typedef signed long long int sint64; + typedef unsigned long long int uint64; +#endif + +struct my_timer_t { + double start_real; + double elapsed_real; + bool running; +}; + +// functions + +#ifdef _WIN32 + #include + inline void Idle(void) { + Sleep(1); + } + inline void Idle500msecs(void){ + Sleep(500); + } +#else + #include + inline void Idle(void) { + usleep(1000); + } +#endif +extern void util_init (); + +extern void my_random_init (); +extern int my_random_int (int n); +extern double my_random_double (); + +extern sint64 my_atoll (const char string[]); + +extern int my_round (double x); + +extern void * my_malloc (size_t size); +extern void * my_realloc (void * address, size_t size); +extern void my_free (void * address); + +extern void my_log_open (const char file_name[]); +extern void my_log_close (); + +extern void my_log (const char format[], ...); +extern void my_fatal (const char format[], ...); + +extern bool my_file_read_line (FILE * file, char string[], int size); + +extern bool my_string_empty (const char string[]); +extern bool my_string_whitespace (const char string[]); +extern bool my_string_equal (const char string_1[], const char string_2[]); +extern bool my_string_case_equal (const char string_1[], const char string_2[]); +extern char * my_strdup (const char string[]); + +extern void my_string_clear (const char * * variable); +extern void my_string_set (const char * * variable, const char string[]); + +extern void my_timer_reset (my_timer_t * timer); +extern void my_timer_start (my_timer_t * timer); +extern void my_timer_stop (my_timer_t * timer); + +extern double my_timer_elapsed_real (const my_timer_t * timer); + + +#endif // !defined UTIL_H + +// end of util.h