towitoko-2.0.7/0002777000175000017500000000000007527763751007171 5towitoko-2.0.7/README0000644000175000017500000001001107521033735007736 Unix driver for Towitoko smartcard readers Copyright (C) 1998 1999 2000 2001 Carlos Prados This library provides a driver for using Towitoko smartcard readers under UNIX environment. Smartcard API's provided: ========================= * CT-API 1.1 and CT-BCS 0.9. See ctapi (3) and ctbcs (3) man pages provided with this package. * PCSC Lite. See http://www.linuxnet.com for download and documentation. Supported readers: ================== * Towitoko Chipdrive Micro, Extern, Extern II, Intern, and Twin. * The most recent readers labelled as "Kartenzwerg" use the same protocol as Chipdrive, and should work with this driver, although they have not been tested. Supported interfaces: ===================== * Serial readers: Configure you serial port like for a modem. See http://www.linuxdoc.org/HOWTO/Serial-HOWTO.html * USB readers: Linux kernel version 2.4.12 or greater with PL2303 USB serial driver enabled is needed. See http://www.linux-usb.org/USB-guide/book1.html Note that PL2303 support is still in experimental stage! Also note that pl2303.c drivers from kernel versions previous to 2.4.12 will surely not work with this driver and will probably hang your machine. Supported smartcards: ===================== * Processor cards: direct and inverse convention cards, T=0 and T=1 protocols. Short and extended case 1, 2, 3, 4 ISO 7816-3 APDU's. PPS and baudrate selection from 9600 bps to 115200 bps. * Memory cards: I2C, 2 wire and 3 wire bus protocol. Access to memory cards is provided via the Interindustry Commands described in the MCT v09 part 7 spec. See http://www.panstruga.de/ct-api/spec/spec_v09.html Installation: ============= See the file INSTALL. Special `configure` options: ============================ --enable-debug(=1|2|3|4) Debug level 1,2 and 3 prints debug information to stdout. Debug level 4 prints debug information to syslog. --enable-card-type(=sync|async) --enable-card-convention(=dir|inv) --enable-memory-type(=i2cs|i2cl|2w|3w) "sync" is for memory cards and "async" for processor cards. "inv" is for inverse convention cards and "dir" for direct convention. "i2cl" is for I2C cards with up to 16 kbits of memory, "i2cl" for I2C cards with up to 64 kbits of memory, 2w for 2 wire cards, and 3w for 3 wire cards. Enabling one option prevents the driver from doing auto-detection. --enable-memory-size(=size) By default memory size is set to 8192 bytes. If 0 length is specified the driver will perform probing of memory size. Otherwise the specified value will be used. --enable-ISO-t0 Transportation of APDUs by T=0. With T=0 cards this will enable the driver to automatically handle T=0 transaction control TPDUs following ISO 7816-4 Annex A normative. --with-pcsc-lite-dir PCSC Lite base directory (default=/usr/local/pcsc). USB bundle is installed under $pcsc_lite_dir/drivers if USB support is enabled. --enable-usb enable USB support (default=no). --enable-devfs enable Linux 2.4.X devfs support (default=no). --enable-devpcsc enable /dev/pcsc links support (default=no). Serial devices will be searched at /dev/pcsc/1, /dev/pcsc/2, etc. You will have to create links to the actual serial devices. --enable-win32-com enable win32 style COM port numbering (default=no). Port numbers under CT-API will start with 1 for COM1, 2 for COM2 and so on. --enable-thread-mutex enable thread mutexes (default=yes). Needed for multi-threaded applications. --enable-atr-check enable checking of valid ATR (default=yes). --enable-atr-timings enable decoding of timings from ATR (default=yes). Configuration: ============== To configure a serial reader in PCSC Lite, copy the provided file doc/reader.conf to /etc/reader.conf and modify it to match your serial port settings. No configuration is needed for USB readers. TODO: ===== * Update to CT-BCS 1.0. * Test inverse convention. Success has been reported with some inverse convetion cards, while faliures have been reported with others. * Test Chipdrive Twin and Kartenzwerg. towitoko-2.0.7/AUTHORS0000644000175000017500000000022007361642377010141 Carlos Prados : Core driver, CT-API, and IFD handler David Corcoran : CT-API and IFD handler skeleton towitoko-2.0.7/COPYING0000644000175000017500000006347407317644021010135 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 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. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, 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 and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, 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 library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete 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 distribute a copy of this License along with the Library. 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 Library or any portion of it, thus forming a work based on the Library, 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) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, 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 Library, 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 Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you 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. If distribution of 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 satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be 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. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library 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. 9. 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 Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library 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 with this License. 11. 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 Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library 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 Library. 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. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library 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. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser 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 Library 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 Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, 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 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "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 LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. 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 LIBRARY 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 LIBRARY (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 LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), 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 Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. 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 library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! towitoko-2.0.7/ChangeLog0000644000175000017500000001741507527762717010666 2002-08-18 Carlos Prados * Released 2.0.7 * Applied patch by Antti Tapaninen that contains some portability fixes, fixes compiler warnings and errors for some C/C++ compiler and also adds support for AIX and NetBSD. * Fixed support for writing to long I2C cards. Thanks Martin Preuss. * Cleaned IO_Serial_SetProperties() code. Hopefully this fixes support for inverse convention cards. * Always select first protocol proposed by the ATR and default to T=0 if no protocol is available. * The output of Get Status of CardTerminal command is now more descriptive. * Miscellaneous improvements to the tester application. * USB support is enabled by default under Linux. A new option, --enable-usb-bundle is used to install PCSC Lite USB bundle. * Compiling under CygWin 32 environment now generates a Windows DLL named cygtowitoko-2.dll. You'll need to run "reconf" before configure, having libtool 1.4e or greater installed. * Compiling under CygWin 32 environment automatically selects the option --enable-win32-com. 2002-03-17 Carlos Prados * Released 2.0.6 * Implemented 115200 bps baudrate for processor and memory cards. * Disabled transportation of APDUs by T=0 protocol following ISO 7816-4 Annex A. Implemented option --enable-ISO-t0 to enable it. * Fixed the number of null bytes (0x60) that T=0 protocol accepts from the card before aborting transmission. * Rewritten algorithm for memory smartcard type and memory size detection. * Implemented fake ATR return for I2C cards. This provides a way for applications to retrieve smartcard memory size and smartcard type. * Implemented the ability to select DIR, ATR and application data sections with memory cards according to MCT v09 part 5 spec. * Fixed Read Binary command with memory cards to return all data available of the selected data section when Le=0 is specified. * Implemented dynamic memory allocation of internal data buffers in protocol_sync and protocol_t1 for memory usage optimization. * Added support for FreeBSD and OpenBSD. By Martin Preuss 2001-12-09 Carlos Prados * Released 2.0.5 * Implemented PPS procedure and baudrate selection for processor cards. See NEWS for details. * Implemented access to memory cards at 57600 bps when supported by the drive. * Implemented optimization of write access to memory cards. * Implemented support for Chipdrive USB under Linux. See NEWS for details. * Implemented support for multiple simultaneous readers in IFD Handler. PCSC Lite 1.0.1 or greater is needed. * Implemented support for /dev/pcsc device links with the config option --enable-devpcsc. * Implemented debug of IFD Handler through syslog() with the config option --enable-debug=4. * Implemented the ability to use Windows CT-API style port numbering with the option --enable-win32-com. * Modified EJECT ICC: don't check eject handling instructions, so it will not fail if the application uses CT-BCS 1.0 semantics. Return OK if the card is not removed and 0 seconds time limit is specified. * Corrected type of parameter in ctapi (3) manpage. * Updated and summarized README file. * Updated to Autoconf 2.52. 2001-07-01 Carlos Prados * Released 2.0.4 * Fixed work waiting time calculation for T=0. * Implemented --enable-devfs option. This provides compatibility with Linux 2.4.X devfs. * Made some modifications to the build system. * Created DocBook SGML documentation. 2001-04-08 Carlos Prados * Released 2.0.3 * Fixed unassigned return value in protocol_t1.c when a 4 bytes block was read. * Removed read-only probe of I2C cards in icc_sync.c that could lead to wrong detection of long I2C cards. * Implemented configuration option --disable-atr-timings for cards whose ATR doesn't encode timings as defined by ISO 7816-3. * Fixed icc_async.c to use a second buffer for reversing bytes sent to an inverse convention card. 2001-01-14 Carlos Prados * Released 2.0.2 * Fixed problem in autoconf that caused libtowitoko.so not to be linked in Linux when dummy libposix.a was present on the system. * Implemented configuration option --enable-card-convention. * Fixed configuration option --disable-atr-check. * Driver compiles with "CFLAGS=-Wall -pedantic" without warnings. 2000-12-29 Carlos Prados * Released 2.0.1 * Implemented mutual exclusion on shared resources. The driver is now both reentrant and thread safe. * Modified tester.c to work with multiple threads. * Fixed BWT calculation in T=1. * Fixed some typos in protocol_sync.c, cardterminal.c, and protocol_t0.c. * Corrected some imprecisions in documentation files. 2000-12-11 Carlos Prados * Released 2.0.0. * Implemented T=1 protocol. See the entry in file NEWS. * Implemented PTS procedure. * Implemented Extended APDU handling. * Implemented mapping of Case 3 and Case 4 APDUs (both short and extended) onto corresponding TPDUs following ISO 7816-4 Annex A. * Implemented inversion of ATR bytes when card has inverse convention. * Implemented configuration option --disable-atr-check to allow smartcards with not standard ATR to be recognized. * Implemented control of DTR and RTS modem lines. * Micro controller parity is explicitly set to EVEN on startup. * Added configuration option --enable-card-type=[sync|async] to disable probing of card type by the driver. * Disabled writing retries while doing memory card probing for faster detection. * Changed MT unsafe function usleep for nanosleep. * Fixed extra guard time calculation in T=0 protocol. * Fixed maximum size of buffers that the driver sends to an asynchronous smartcard in each access. * Fixed character reading in tester.c. * The Master File of memory cards is selected by default. * Improved documentation. * Implemented compatibility with IFD Handler 1.0 CHANNELID numbers. * The driver compiles as a single library libtowitoko.so. The file /etc/reader.conf needs to be modified again. See the file NEWS. * The name of the whole thing have been changed to "MUSCLE driver for Towitoko smartcard readers" to better reflect what it is. 2000-07-23 Carlos Prados * Released 2.0.0-pre5 * Updated IFD Handler to version 2.0. See the file NEWS. * T=0 speed fixed to 9600. See the note in protocol_t0.c. * Fixed Verify Key command in tester.c. * Changed returned data when wrong PIN was entered to a memory card. * Fixed macros for parsing ATR of synchronous cards. * Modified detection of card change in ct_slot.c. * The file NEWS has been rewritten. * Download web page changed to http://www.geocities.com/cprados. 2000-06-18 Carlos Prados * Released 2.0.0-pre4. * Fixed 90 00 response when wrong pin was entered to a memory card. * Fixed 64 00 response when sending "Reset ICC" to a memory card. * Implemented parsing of memory cards ATR. * CT-API releases card information when card change is detected, instead of doing it only when no card is detected. * Fixed commands printed to screen with wrong length in tester.c. 2000-06-11 Carlos Prados * Released 2.0.0-pre3. * CT-API now resynchronizes its status with the reader when requesting ICC status, so it is not necessary to issue "Eject ICC" after the card is removed. * Done some orthographic and grammatical corrections to comments, debug messages and documentation. 2000-06-10 Carlos Prados * Released 2.0.0-pre2. * Fixed IFD Handler. * Fixed card insertion event in tester.c. * Implemented communication with 2nd slot of Chipdrive Twin. 2000-06-06 Carlos Prados * First 2.0 pre-release. towitoko-2.0.7/INSTALL0000644000175000017500000001722707317644021010126 Basic Installation ================== These are generic installation instructions. The `configure' shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a `Makefile' in each directory of the package. It may also create one or more `.h' files containing system-dependent definitions. Finally, it creates a shell script `config.status' that you can run in the future to recreate the current configuration, a file `config.cache' that saves the results of its tests to speed up reconfiguring, and a file `config.log' containing compiler output (useful mainly for debugging `configure'). If you need to do unusual things to compile the package, please try to figure out how `configure' could check whether to do them, and mail diffs or instructions to the address given in the `README' so they can be considered for the next release. If at some point `config.cache' contains results you don't want to keep, you may remove or edit it. The file `configure.in' is used to create `configure' by a program called `autoconf'. You only need `configure.in' if you want to change it or regenerate `configure' using a newer version of `autoconf'. The simplest way to compile this package is: 1. `cd' to the directory containing the package's source code and type `./configure' to configure the package for your system. If you're using `csh' on an old version of System V, you might need to type `sh ./configure' instead to prevent `csh' from trying to execute `configure' itself. Running `configure' takes awhile. While running, it prints some messages telling which features it is checking for. 2. Type `make' to compile the package. 3. Optionally, type `make check' to run any self-tests that come with the package. 4. Type `make install' to install the programs and any data files and documentation. 5. You can remove the program binaries and object files from the source code directory by typing `make clean'. To also remove the files that `configure' created (so you can compile the package for a different kind of computer), type `make distclean'. There is also a `make maintainer-clean' target, but that is intended mainly for the package's developers. If you use it, you may have to get all sorts of other programs in order to regenerate files that came with the distribution. Compilers and Options ===================== Some systems require unusual options for compilation or linking that the `configure' script does not know about. You can give `configure' initial values for variables by setting them in the environment. Using a Bourne-compatible shell, you can do that on the command line like this: CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure Or on systems that have the `env' program, you can do it like this: env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure Compiling For Multiple Architectures ==================================== You can compile the package for more than one kind of computer at the same time, by placing the object files for each architecture in their own directory. To do this, you must use a version of `make' that supports the `VPATH' variable, such as GNU `make'. `cd' to the directory where you want the object files and executables to go and run the `configure' script. `configure' automatically checks for the source code in the directory that `configure' is in and in `..'. If you have to use a `make' that does not supports the `VPATH' variable, you have to compile the package for one architecture at a time in the source code directory. After you have installed the package for one architecture, use `make distclean' before reconfiguring for another architecture. Installation Names ================== By default, `make install' will install the package's files in `/usr/local/bin', `/usr/local/man', etc. You can specify an installation prefix other than `/usr/local' by giving `configure' the option `--prefix=PATH'. You can specify separate installation prefixes for architecture-specific files and architecture-independent files. If you give `configure' the option `--exec-prefix=PATH', the package will use PATH as the prefix for installing programs and libraries. Documentation and other data files will still use the regular prefix. In addition, if you use an unusual directory layout you can give options like `--bindir=PATH' to specify different values for particular kinds of files. Run `configure --help' for a list of the directories you can set and what kinds of files go in them. If the package supports it, you can cause programs to be installed with an extra prefix or suffix on their names by giving `configure' the option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. Optional Features ================= Some packages pay attention to `--enable-FEATURE' options to `configure', where FEATURE indicates an optional part of the package. They may also pay attention to `--with-PACKAGE' options, where PACKAGE is something like `gnu-as' or `x' (for the X Window System). The `README' should mention any `--enable-' and `--with-' options that the package recognizes. For packages that use the X Window System, `configure' can usually find the X include and library files automatically, but if it doesn't, you can use the `configure' options `--x-includes=DIR' and `--x-libraries=DIR' to specify their locations. Specifying the System Type ========================== There may be some features `configure' can not figure out automatically, but needs to determine by the type of host the package will run on. Usually `configure' can figure that out, but if it prints a message saying it can not guess the host type, give it the `--host=TYPE' option. TYPE can either be a short name for the system type, such as `sun4', or a canonical name with three fields: CPU-COMPANY-SYSTEM See the file `config.sub' for the possible values of each field. If `config.sub' isn't included in this package, then this package doesn't need to know the host type. If you are building compiler tools for cross-compiling, you can also use the `--target=TYPE' option to select the type of system they will produce code for and the `--build=TYPE' option to select the type of system on which you are compiling the package. Sharing Defaults ================ If you want to set default values for `configure' scripts to share, you can create a site shell script called `config.site' that gives default values for variables like `CC', `cache_file', and `prefix'. `configure' looks for `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site' if it exists. Or, you can set the `CONFIG_SITE' environment variable to the location of the site script. A warning: not all `configure' scripts look for a site script. Operation Controls ================== `configure' recognizes the following options to control how it operates. `--cache-file=FILE' Use and save the results of the tests in FILE instead of `./config.cache'. Set FILE to `/dev/null' to disable caching, for debugging `configure'. `--help' Print a summary of the options to `configure', and exit. `--quiet' `--silent' `-q' Do not print messages saying which checks are being made. To suppress all normal output, redirect it to `/dev/null' (any error messages will still be shown). `--srcdir=DIR' Look for the package's source code in directory DIR. Usually `configure' can determine that directory automatically. `--version' Print the version of Autoconf used to generate the `configure' script, and exit. `configure' also accepts some other, not widely useful, options. towitoko-2.0.7/Makefile.am0000644000175000017500000000166207361641416011131 # # Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SUBDIRS = src doc EXTRA_DIST = reconf ChangeLog towitoko-2.0.7/Makefile.in0000644000175000017500000003417607527762031011151 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ # # Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AS = @AS@ AWK = @AWK@ CC = @CC@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBOOK_TO_MAN = @DOCBOOK_TO_MAN@ ECHO = @ECHO@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ PCSC_LITE_DIR = @PCSC_LITE_DIR@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ SUBDIRS = src doc EXTRA_DIST = reconf ChangeLog subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = DIST_SOURCES = RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ uninstall-info-recursive all-recursive install-data-recursive \ install-exec-recursive installdirs-recursive install-recursive \ uninstall-recursive check-recursive installcheck-recursive DIST_COMMON = README AUTHORS COPYING ChangeLog INSTALL Makefile.am \ Makefile.in NEWS THANKS aclocal.m4 config.guess config.h.in \ config.sub configure configure.ac depcomp install-sh ltmain.sh \ missing mkinstalldirs DIST_SUBDIRS = $(SUBDIRS) all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe) $(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(srcdir)/configure: $(srcdir)/configure.ac $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) cd $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): configure.ac cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) 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: $(top_srcdir)/configure.ac $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOHEADER) touch $(srcdir)/config.h.in distclean-hdr: -rm -f config.h stamp-h1 mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ETAGS = etags ETAGSFLAGS = tags: TAGS 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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ fi; \ done; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = . distdir = $(PACKAGE)-$(VERSION) am__remove_distdir = \ { test ! -d $(distdir) \ || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr $(distdir); }; } GZIP_ENV = --best distcleancheck_listfiles = find . -type f -print distdir: $(DISTFILES) $(am__remove_distdir) mkdir $(distdir) @list='$(DISTFILES)'; for file in $$list; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkinstalldirs) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ 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 list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \ || exit 1; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" \ distdir=../$(distdir)/$$subdir \ distdir) \ || 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 $(SHELL) $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r $(distdir) dist-gzip: distdir $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist dist-all: distdir $(AMTAR) chof - $(distdir) | 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 $(am__remove_distdir) GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - 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` \ && 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 \ && (test `find $$dc_install_base -type f -print | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ find $$dc_install_base -type f -print ; \ exit 1; } >&2 ) \ && $(MAKE) $(AM_MAKEFLAGS) dist-gzip \ && rm -f $(distdir).tar.gz \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck $(am__remove_distdir) @echo "$(distdir).tar.gz is ready for distribution" | \ sed 'h;s/./=/g;p;x;p;x' 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 after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile config.h installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) distclean-am: clean-am distclean-generic distclean-hdr distclean-libtool \ distclean-tags dvi: dvi-recursive dvi-am: info: info-recursive info-am: install-data-am: install-exec-am: install-info: install-info-recursive install-man: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf autom4te.cache maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool uninstall-am: uninstall-info-am uninstall-info: uninstall-info-recursive .PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ clean-generic clean-libtool clean-recursive dist dist-all \ dist-gzip distcheck distclean distclean-generic distclean-hdr \ distclean-libtool distclean-recursive distclean-tags \ distcleancheck distdir dvi dvi-am dvi-recursive info info-am \ info-recursive install install-am install-data install-data-am \ install-data-recursive install-exec install-exec-am \ install-exec-recursive install-info install-info-am \ install-info-recursive install-man install-recursive \ install-strip installcheck installcheck-am installdirs \ installdirs-am installdirs-recursive maintainer-clean \ maintainer-clean-generic maintainer-clean-recursive mostlyclean \ mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \ tags tags-recursive uninstall uninstall-am uninstall-info-am \ uninstall-info-recursive uninstall-recursive # 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: towitoko-2.0.7/NEWS0000644000175000017500000001106207404715776007600 Unix driver for Towitoko smartcard readers Copyright (C) 2000 2001 Carlos Prados SUPPORT FOR PPS AND BAUDRATE GREATER THAN 9600 BPS Starting with the release 2.0.5 it's possible to specify a PPS request to be negotiated with the card. After completion of a successful PPS handshake, the unit will be configured automatically to support the protocol, parameters and baudrate agreed. Baudrates of 9600 bps, 14400 bps, 19200 bps, 28800 bps, 38400 bps and 57600 bps are supported by the driver. To access this functionality under CT-API, the application must issue a RESET CT or REQUEST ICC and put the PPS request (at least PPSS and PPS0) in the data field of the CT-BCS command. Under PCSC Lite the PPS request can be sent within a CT-BCS command, using the function SCardControl(). Memory cards are accessed by default at 57600 bps if the unit supports this baudrate, without having to modify the programs. SUPPORT FOR CHIPDRIVE USB Chipdrive USB is supported under Linux since release 2.0.5. You need a Linux kernel version 2.4.12 or greater with USB support compiled and pl2303 USB to serial converter driver enabled. To use an USB Chipdrive with CT-API, specify port numbers starting with 0x8000: * 0x8000 for /dev/ttyUSB0, (first USB serial device) * 0x8001 for /dev/ttyUSB1, (second USB serial device) and so on. You can also create a symlink from /dev/ttyS[pn] to /dev/ttyUSB[m] and access the reader at COM[pn+1], as with the serial model. Under PCSC Lite just plug the reader and it will be automatically detected and initialized by PCSC daemon. They name assigned by SCardListReaders will be "Towitoko Chipdrive USB 0 0". SUPPORT FOR T=1 PROTOCOL Smartcards with transmission protocol T=1 are supported since release 2.0.0. When a card is reset, T=1 protocol is automatically selected if it is offered by the card in its answer to reset. PTS protocol is performed if needed. Otherwise T=0 is used. CHANGE IN THE NAME OF THE SHARED LIBRARY Since release 2.0.0 the core driver and the interfaces are linked in a single shared library, called libtowitoko. In consequence the name of the library declared in PC/SC Lite configuration file /etc/reader.conf must be changed to: /lib/libtowitoko. Where stands for the place where you installed the binary distribution of the driver (like "/usr/local"), and is the suffix of the name of shared libraries in you system (like "so"). A sample reader.conf file is included under doc/. CHANGES IN THE INTERFACE WITH PC/SC LITE (release 2.0.0-pre5) Version 2.0.0-pre5 comes with IFD handler 2.0. In contrast with previous IFD handler, this module has been designed to support any number of readers and slots per instance of the driver. Also it permits the driver to return the ATR and its length when this parameter is requested by PC/SC Lite, so it does not need to re-parse the ATR. This allows memory cards, whose ATR does not follow ISO 7816 rules to be handled. To simplify the /etc/reader.conf syntax, the channel number CHANNELID now does not use the serial port IO and IRQ number but the COM number, following MS-DOS numbering convention. That is 0x000001 for COM1 (/dev/ttyS0), 0x000002 for COM2 (/dev/ttyS1) and so on. Don't forget to change this parameter in your /etc/reader.conf file if you upgrade to 2.0.0-pre5. Note that PC/SC Lite 0.7.1 or greater is needed to use IFD Handler 2.0. CHANGES IN RELEASE 2.0.0-pre1 Since 1.X releases most of the code has been rewritten. The driver has more than 8000 lines of code. Nevertheless now it's more modular and easy to maintain. The new structure split the functionality between modules that implement objects. Each object has the methods (C functions) to handle a part of the communication, and the member variables (registers of C structures) to store status information needed for this part of the communication. As result the new driver is able to handle any number of readers, with any number of slots and smartcards at one time. Object modules has been added to implement support for memory cards and provide access through MCT v0.9 interindustry commands. Interface device module has been improved to be able to dynamically adapt its settings to support communication with inverse convention cards and with Kartenzwerg readers. The serial device code has been rewritten and improved. The new serial object does PnP COM recognition of the reader on initialization. The platform dependent code has been wrapped with #ifdef's to provide Input/Output routines for Linux, Solaris and CygWin32 environments, and make it extensible for other Operating Systems. towitoko-2.0.7/THANKS0000644000175000017500000000060307414101042007763 Unix driver for Towitoko smartcard readers Copyright (C) 1998 1999 2000 2001 Carlos Prados Here is a list of people that have contributed in different ways to this Unix driver for Towitoko smartcard readers: * David Corcoran : Creating/leading the MUSCLE project. * Axel Heider : Support with the Towitoko protocol. towitoko-2.0.7/aclocal.m40000644000175000017500000044544407527762020010746 # aclocal.m4 generated automatically by aclocal 1.6.3 -*- Autoconf -*- # Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 # Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. # Do all the work for Automake. -*- Autoconf -*- # 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. # Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # serial 8 # 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... AC_PREREQ([2.52]) # Autoconf 2.50 wants to disallow AM_ names. We explicitly allow # the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl # 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_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl # test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi # 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 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_MISSING_PROG(AMTAR, tar) AM_PROG_INSTALL_SH AM_PROG_INSTALL_STRIP # 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 _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 ]) ]) # Copyright 2002 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., 59 Temple Place - Suite 330, Boston, MA # 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. AC_DEFUN([AM_AUTOMAKE_VERSION],[am__api_version="1.6"]) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION so it can be traced. # This function is AC_REQUIREd by AC_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.6.3])]) # Helper functions for option handling. -*- Autoconf -*- # Copyright 2001, 2002 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # serial 2 # _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. # # Copyright 1996, 1997, 2000, 2001 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # serial 3 # 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)]) # -*- Autoconf -*- # Copyright 1997, 1999, 2000, 2001 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # serial 3 # 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 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 ]) # AM_AUX_DIR_EXPAND # Copyright 2001 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # 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. # Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50]) AC_DEFUN([AM_AUX_DIR_EXPAND], [ # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. # Copyright 2001 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl install_sh=${install_sh-"$am_aux_dir/install-sh"} AC_SUBST(install_sh)]) # AM_PROG_INSTALL_STRIP # Copyright 2001 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # 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="\${SHELL} \$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # serial 4 -*- Autoconf -*- # Copyright 1999, 2000, 2001 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # 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], 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 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 # 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. echo '#include "conftest.h"' > conftest.c echo 'int i;' > conftest.h echo "${am__include} ${am__quote}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=conftest.c object=conftest.o \ depfile=conftest.Po tmpdepfile=conftest.TPo \ $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && grep conftest.h conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then am_cv_$1_dependencies_compiler_type=$depmode break 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_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [rm -f .deps 2>/dev/null mkdir .deps 2>/dev/null if test -d .deps; then DEPDIR=.deps else # MS-DOS does not allow filenames that begin with a dot. DEPDIR=_deps fi rmdir .deps 2>/dev/null AC_SUBST([DEPDIR]) ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking Speeds up one-time builds --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]) ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright 1999, 2000, 2001, 2002 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. #serial 2 # _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. # So let's grep whole file. if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi grep '^DEP_FILES *= *[[^ @%:@]]' < "$mf" > /dev/null || continue # Extract the definition of DEP_FILES from the Makefile without # running `make'. DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` test -z "$DEPDIR" && continue # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n -e '/^U = / s///p' < "$mf"` test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" # 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 -e ' /^DEP_FILES = .*\\\\$/ { s/^DEP_FILES = // :loop s/\\\\$// p n /\\\\$/ b loop p } /^DEP_FILES = / s/^DEP_FILES = //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"]) ]) # Copyright 2001 Free Software Foundation, Inc. -*- Autoconf -*- # 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # serial 2 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' doit: @echo done 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 | fgrep -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 ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright 1997, 2000, 2001 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # serial 5 AC_PREREQ(2.52) # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE]) AC_SUBST([$1_FALSE]) 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])]) # Like AC_CONFIG_HEADER, but automatically create stamp file. -*- Autoconf -*- # Copyright 1996, 1997, 2000, 2001 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. AC_PREREQ([2.52]) # serial 6 # 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. We must strip everything past the first ":", # and everything past the last "/". # _AM_DIRNAME(PATH) # ----------------- # Like AS_DIRNAME, only do it during macro expansion AC_DEFUN([_AM_DIRNAME], [m4_if(regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1, m4_if(regexp([$1], [^//\([^/]\|$\)]), -1, m4_if(regexp([$1], [^/.*]), -1, [.], patsubst([$1], [^\(/\).*], [\1])), patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])), patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl ])# _AM_DIRNAME # The stamp files are numbered to have different names. # We could number them on a directory basis, but that's additional # complications, let's have a unique counter. m4_define([_AM_STAMP_Count], [0]) # _AM_STAMP(HEADER) # ----------------- # The name of the stamp file for HEADER. AC_DEFUN([_AM_STAMP], [m4_define([_AM_STAMP_Count], m4_incr(_AM_STAMP_Count))dnl AS_ESCAPE(_AM_DIRNAME(patsubst([$1], [:.*])))/stamp-h[]_AM_STAMP_Count]) # _AM_CONFIG_HEADER(HEADER[:SOURCES], COMMANDS, INIT-COMMANDS) # ------------------------------------------------------------ # We used to try to get a real timestamp in stamp-h. But the fear is that # that will cause unnecessary cvs conflicts. AC_DEFUN([_AM_CONFIG_HEADER], [# Add the stamp file to the list of files AC keeps track of, # along with our hook. AC_CONFIG_HEADERS([$1], [# update the timestamp echo 'timestamp for $1' >"_AM_STAMP([$1])" $2], [$3]) ])# _AM_CONFIG_HEADER # AM_CONFIG_HEADER(HEADER[:SOURCES]..., COMMANDS, INIT-COMMANDS) # -------------------------------------------------------------- AC_DEFUN([AM_CONFIG_HEADER], [AC_FOREACH([_AM_File], [$1], [_AM_CONFIG_HEADER(_AM_File, [$2], [$3])]) ])# AM_CONFIG_HEADER # libtool.m4 - Configure libtool for the host system. -*-Shell-script-*- # serial 46 AC_PROG_LIBTOOL AC_DEFUN([AC_PROG_LIBTOOL], [AC_REQUIRE([AC_LIBTOOL_SETUP])dnl # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl # Prevent multiple expansion define([AC_PROG_LIBTOOL], []) ]) AC_DEFUN([AC_LIBTOOL_SETUP], [AC_PREREQ(2.13)dnl AC_REQUIRE([AC_ENABLE_SHARED])dnl AC_REQUIRE([AC_ENABLE_STATIC])dnl AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_LD])dnl AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl AC_REQUIRE([AC_PROG_NM])dnl AC_REQUIRE([LT_AC_PROG_SED])dnl AC_REQUIRE([AC_PROG_LN_S])dnl AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl AC_REQUIRE([AC_OBJEXT])dnl AC_REQUIRE([AC_EXEEXT])dnl dnl _LT_AC_PROG_ECHO_BACKSLASH # Only perform the check for file, if the check method requires it case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then AC_PATH_MAGIC fi ;; esac AC_CHECK_TOOL(RANLIB, ranlib, :) AC_CHECK_TOOL(STRIP, strip, :) ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no) ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], enable_win32_dll=yes, enable_win32_dll=no) AC_ARG_ENABLE(libtool-lock, [ --disable-libtool-lock avoid locking (might break parallel builds)]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in *-*-irix6*) # Find out which ABI we are using. echo '[#]line __oline__ "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_SAVE AC_LANG_C AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_RESTORE]) if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], [*-*-cygwin* | *-*-mingw* | *-*-pw32*) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) # recent cygwin and mingw systems supply a stub DllMain which the user # can override, but on older systems we have to supply one AC_CACHE_CHECK([if libtool should supply DllMain function], lt_cv_need_dllmain, [AC_TRY_LINK([], [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*); DllMain (0, 0, 0);], [lt_cv_need_dllmain=no],[lt_cv_need_dllmain=yes])]) case $host/$CC in *-*-cygwin*/gcc*-mno-cygwin*|*-*-mingw*) # old mingw systems require "-dll" to link a DLL, while more recent ones # require "-mdll" SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -mdll" AC_CACHE_CHECK([how to link DLLs], lt_cv_cc_dll_switch, [AC_TRY_LINK([], [], [lt_cv_cc_dll_switch=-mdll],[lt_cv_cc_dll_switch=-dll])]) CFLAGS="$SAVE_CFLAGS" ;; *-*-cygwin* | *-*-pw32*) # cygwin systems need to pass --dll to the linker, and not link # crt.o which will require a WinMain@16 definition. lt_cv_cc_dll_switch="-Wl,--dll -nostartfiles" ;; esac ;; ]) esac _LT_AC_LTCONFIG_HACK ]) # AC_LIBTOOL_HEADER_ASSERT # ------------------------ AC_DEFUN([AC_LIBTOOL_HEADER_ASSERT], [AC_CACHE_CHECK([whether $CC supports assert without backlinking], [lt_cv_func_assert_works], [case $host in *-*-solaris*) if test "$GCC" = yes && test "$with_gnu_ld" != yes; then case `$CC --version 2>/dev/null` in [[12]].*) lt_cv_func_assert_works=no ;; *) lt_cv_func_assert_works=yes ;; esac fi ;; esac]) if test "x$lt_cv_func_assert_works" = xyes; then AC_CHECK_HEADERS(assert.h) fi ])# AC_LIBTOOL_HEADER_ASSERT # _LT_AC_CHECK_DLFCN # -------------------- AC_DEFUN([_LT_AC_CHECK_DLFCN], [AC_CHECK_HEADERS(dlfcn.h) ])# _LT_AC_CHECK_DLFCN # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE # --------------------------------- AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_PROG_NM]) AC_REQUIRE([AC_OBJEXT]) # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [dnl # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Transform the above into a raw symbol and a C symbol. symxfrm='\1 \2\3 \3' # Transform an extracted symbol line into a proper C declaration lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32*) symcode='[[ABCDGISTW]]' ;; hpux*) # Its linker distinguishes data from code symbols lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; solaris* | sysv5*) symcode='[[BDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # Handle CRLF in mingw tool chain opt_cr= case $host_os in mingw*) opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # If we're using GNU nm, then use its standard symbol codes. if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then symcode='[[ABCDGISTW]]' fi # Try without a prefix undercore, then with it. for ac_symprfx in "" "_"; do # Write the raw and C identifiers. lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext < $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if egrep ' nm_test_var$' "$nlist" >/dev/null; then if egrep ' nm_test_func$' "$nlist" >/dev/null; then cat < conftest.$ac_ext #ifdef __cplusplus extern "C" { #endif EOF # Now generate the symbol file. eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext' cat <> conftest.$ac_ext #if defined (__STDC__) && __STDC__ # define lt_ptr void * #else # define lt_ptr char * # define const #endif /* The mapping between symbol names and symbols. */ const struct { const char *name; lt_ptr address; } lt_preloaded_symbols[[]] = { EOF sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext cat <<\EOF >> conftest.$ac_ext {0, (lt_ptr) 0} }; #ifdef __cplusplus } #endif EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$no_builtin_flag" if AC_TRY_EVAL(ac_link) && test -s conftest; then pipe_works=yes fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&AC_FD_CC fi else echo "cannot find nm_test_var in $nlist" >&AC_FD_CC fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AC_FD_CC fi else echo "$progname: failed program was:" >&AC_FD_CC cat conftest.$ac_ext >&5 fi rm -f conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" if test -z "$lt_cv_sys_global_symbol_pipe"; then global_symbol_to_cdecl= global_symbol_to_c_name_address= else global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address" fi if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi ]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE # _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR # --------------------------------- AC_DEFUN([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR], [# Find the correct PATH separator. Usually this is `:', but # DJGPP uses `;' like DOS. if test "X${PATH_SEPARATOR+set}" != Xset; then UNAME=${UNAME-`uname 2>/dev/null`} case X$UNAME in *-DOS) lt_cv_sys_path_separator=';' ;; *) lt_cv_sys_path_separator=':' ;; esac PATH_SEPARATOR=$lt_cv_sys_path_separator fi ])# _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR # _LT_AC_PROG_ECHO_BACKSLASH # -------------------------- # Add some code to the start of the generated configure script which # will find an echo command which doesn't interpret backslashes. AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH], [ifdef([AC_DIVERSION_NOTICE], [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)], [AC_DIVERT_PUSH(NOTICE)]) _LT_AC_LIBTOOL_SYS_PATH_SEPARATOR # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','` ;; esac echo=${ECHO-echo} if test "X[$]1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X[$]1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then # Yippee, $echo works! : else # Restart under the correct shell. exec $SHELL "[$]0" --no-reexec ${1+"[$]@"} fi if test "X[$]1" = X--fallback-echo; then # used as fallback echo shift cat </dev/null && echo_test_string="`eval $cmd`" && (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null then break fi done fi if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. IFS="${IFS= }"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then echo="$dir/echo" break fi done IFS="$save_ifs" if test "X$echo" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. echo='print -r' elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"} else # Try using printf. echo='printf %s\n' if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL echo="$CONFIG_SHELL [$]0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then echo="$CONFIG_SHELL [$]0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "[$]0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"} else # Oops. We lost completely, so just stick with echo. echo=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. ECHO=$echo if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo" fi AC_SUBST(ECHO) AC_DIVERT_POP ])# _LT_AC_PROG_ECHO_BACKSLASH # _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ------------------------------------------------------------------ AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF], [if test "$cross_compiling" = yes; then : [$4] else AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif #ifdef __cplusplus extern "C" void exit (int); #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } exit (status); }] EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_unknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_AC_TRY_DLOPEN_SELF # AC_LIBTOOL_DLOPEN_SELF # ------------------- AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; cygwin* | mingw* | pw32*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_AC_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then LDFLAGS="$LDFLAGS $link_static_flag" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_AC_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi ])# AC_LIBTOOL_DLOPEN_SELF AC_DEFUN([_LT_AC_LTCONFIG_HACK], [AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])dnl # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='sed -e s/^X//' sed_quote_subst='s/\([[\\"\\`$\\\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([[\\"\\`\\\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Constants: rm="rm -f" # Global variables: default_ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except M$VC, # which needs '.lib'). libext=a ltmain="$ac_aux_dir/ltmain.sh" ofile="$default_ofile" with_gnu_ld="$lt_cv_prog_gnu_ld" need_locks="$enable_libtool_lock" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru test -z "$AS" && AS=as test -z "$CC" && CC=cc test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$LD" && LD=ld test -z "$LN_S" && LN_S="ln -s" test -z "$MAGIC_CMD" && MAGIC_CMD=file test -z "$NM" && NM=nm test -z "$OBJDUMP" && OBJDUMP=objdump test -z "$RANLIB" && RANLIB=: test -z "$STRIP" && STRIP=: test -z "$ac_objext" && ac_objext=o if test x"$host" != x"$build"; then ac_tool_prefix=${host_alias}- else ac_tool_prefix= fi # Transform linux* to *-*-linux-gnu*, to support old configure scripts. case $host_os in linux-gnu*) ;; linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` esac case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" ;; *) old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi # Allow CC to be a program name with arguments. set dummy $CC compiler="[$]2" AC_MSG_CHECKING([for objdir]) rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. objdir=_libs fi rmdir .libs 2>/dev/null AC_MSG_RESULT($objdir) AC_ARG_WITH(pic, [ --with-pic try to use only PIC/non-PIC objects [default=use both]], pic_mode="$withval", pic_mode=default) test -z "$pic_mode" && pic_mode=default # We assume here that the value for lt_cv_prog_cc_pic will not be cached # in isolation, and that seeing it set (from the cache) indicates that # the associated values are set (in the cache) correctly too. AC_MSG_CHECKING([for $compiler option to produce PIC]) AC_CACHE_VAL(lt_cv_prog_cc_pic, [ lt_cv_prog_cc_pic= lt_cv_prog_cc_shlib= lt_cv_prog_cc_wl= lt_cv_prog_cc_static= lt_cv_prog_cc_no_builtin= lt_cv_prog_cc_can_build_shared=$can_build_shared if test "$GCC" = yes; then lt_cv_prog_cc_wl='-Wl,' lt_cv_prog_cc_static='-static' case $host_os in aix*) # Below there is a dirty hack to force normal static linking with -ldl # The problem is because libdl dynamically linked with both libc and # libC (AIX C++ library), which obviously doesn't included in libraries # list by gcc. This cause undefined symbols with -static flags. # This hack allows C programs to be linked with "-static -ldl", but # not sure about C++ programs. lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" ;; amigaos*) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_cv_prog_cc_pic='-fno-common' ;; cygwin* | mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_cv_prog_cc_pic='-DDLL_EXPORT' ;; sysv4*MP*) if test -d /usr/nec; then lt_cv_prog_cc_pic=-Kconform_pic fi ;; *) lt_cv_prog_cc_pic='-fPIC' ;; esac else # PORTME Check for PIC flags for the system compiler. case $host_os in aix3* | aix4* | aix5*) lt_cv_prog_cc_wl='-Wl,' # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_cv_prog_cc_static='-Bstatic' else lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' fi ;; hpux9* | hpux10* | hpux11*) # Is there a better lt_cv_prog_cc_static that works with the bundled CC? lt_cv_prog_cc_wl='-Wl,' lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive" lt_cv_prog_cc_pic='+Z' ;; irix5* | irix6* | nonstopux*) lt_cv_prog_cc_wl='-Wl,' lt_cv_prog_cc_static='-non_shared' # PIC (with -KPIC) is the default. ;; cygwin* | mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_cv_prog_cc_pic='-DDLL_EXPORT' ;; newsos6) lt_cv_prog_cc_pic='-KPIC' lt_cv_prog_cc_static='-Bstatic' ;; osf3* | osf4* | osf5*) # All OSF/1 code is PIC. lt_cv_prog_cc_wl='-Wl,' lt_cv_prog_cc_static='-non_shared' ;; sco3.2v5*) lt_cv_prog_cc_pic='-Kpic' lt_cv_prog_cc_static='-dn' lt_cv_prog_cc_shlib='-belf' ;; solaris*) lt_cv_prog_cc_pic='-KPIC' lt_cv_prog_cc_static='-Bstatic' lt_cv_prog_cc_wl='-Wl,' ;; sunos4*) lt_cv_prog_cc_pic='-PIC' lt_cv_prog_cc_static='-Bstatic' lt_cv_prog_cc_wl='-Qoption ld ' ;; sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) lt_cv_prog_cc_pic='-KPIC' lt_cv_prog_cc_static='-Bstatic' lt_cv_prog_cc_wl='-Wl,' ;; uts4*) lt_cv_prog_cc_pic='-pic' lt_cv_prog_cc_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_cv_prog_cc_pic='-Kconform_pic' lt_cv_prog_cc_static='-Bstatic' fi ;; *) lt_cv_prog_cc_can_build_shared=no ;; esac fi ]) if test -z "$lt_cv_prog_cc_pic"; then AC_MSG_RESULT([none]) else AC_MSG_RESULT([$lt_cv_prog_cc_pic]) # Check to make sure the pic_flag actually works. AC_MSG_CHECKING([if $compiler PIC flag $lt_cv_prog_cc_pic works]) AC_CACHE_VAL(lt_cv_prog_cc_pic_works, [dnl save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" AC_TRY_COMPILE([], [], [dnl case $host_os in hpux9* | hpux10* | hpux11*) # On HP-UX, both CC and GCC only warn that PIC is supported... then # they create non-PIC objects. So, if there were any warnings, we # assume that PIC is not supported. if test -s conftest.err; then lt_cv_prog_cc_pic_works=no else lt_cv_prog_cc_pic_works=yes fi ;; *) lt_cv_prog_cc_pic_works=yes ;; esac ], [dnl lt_cv_prog_cc_pic_works=no ]) CFLAGS="$save_CFLAGS" ]) if test "X$lt_cv_prog_cc_pic_works" = Xno; then lt_cv_prog_cc_pic= lt_cv_prog_cc_can_build_shared=no else lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic" fi AC_MSG_RESULT([$lt_cv_prog_cc_pic_works]) fi # Check for any special shared library compilation flags. if test -n "$lt_cv_prog_cc_shlib"; then AC_MSG_WARN([\`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries]) if echo "$old_CC $old_CFLAGS " | egrep -e "[[ ]]$lt_cv_prog_cc_shlib[[ ]]" >/dev/null; then : else AC_MSG_WARN([add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure]) lt_cv_prog_cc_can_build_shared=no fi fi AC_MSG_CHECKING([if $compiler static flag $lt_cv_prog_cc_static works]) AC_CACHE_VAL([lt_cv_prog_cc_static_works], [dnl lt_cv_prog_cc_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" AC_TRY_LINK([], [], [lt_cv_prog_cc_static_works=yes]) LDFLAGS="$save_LDFLAGS" ]) # Belt *and* braces to stop my trousers falling down: test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static= AC_MSG_RESULT([$lt_cv_prog_cc_static_works]) pic_flag="$lt_cv_prog_cc_pic" special_shlib_compile_flags="$lt_cv_prog_cc_shlib" wl="$lt_cv_prog_cc_wl" link_static_flag="$lt_cv_prog_cc_static" no_builtin_flag="$lt_cv_prog_cc_no_builtin" can_build_shared="$lt_cv_prog_cc_can_build_shared" # Check to see if options -o and -c are simultaneously supported by compiler AC_MSG_CHECKING([if $compiler supports -c -o file.$ac_objext]) AC_CACHE_VAL([lt_cv_compiler_c_o], [ $rm -r conftest 2>/dev/null mkdir conftest cd conftest echo "int some_variable = 0;" > conftest.$ac_ext mkdir out # According to Tom Tromey, Ian Lance Taylor reported there are C compilers # that will create temporary files in the current directory regardless of # the output directory. Thus, making CWD read-only will cause this test # to fail, enabling locking or at least warning the user not to do parallel # builds. chmod -w . save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" compiler_c_o=no if { (eval echo configure:__oline__: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s out/conftest.err; then lt_cv_compiler_c_o=no else lt_cv_compiler_c_o=yes fi else # Append any errors to the config.log. cat out/conftest.err 1>&AC_FD_CC lt_cv_compiler_c_o=no fi CFLAGS="$save_CFLAGS" chmod u+w . $rm conftest* out/* rmdir out cd .. rmdir conftest $rm -r conftest 2>/dev/null ]) compiler_c_o=$lt_cv_compiler_c_o AC_MSG_RESULT([$compiler_c_o]) if test x"$compiler_c_o" = x"yes"; then # Check to see if we can write to a .lo AC_MSG_CHECKING([if $compiler supports -c -o file.lo]) AC_CACHE_VAL([lt_cv_compiler_o_lo], [ lt_cv_compiler_o_lo=no save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -c -o conftest.lo" save_objext="$ac_objext" ac_objext=lo AC_TRY_COMPILE([], [int some_variable = 0;], [dnl # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then lt_cv_compiler_o_lo=no else lt_cv_compiler_o_lo=yes fi ]) ac_objext="$save_objext" CFLAGS="$save_CFLAGS" ]) compiler_o_lo=$lt_cv_compiler_o_lo AC_MSG_RESULT([$compiler_o_lo]) else compiler_o_lo=no fi # Check to see if we can do hard links to lock some files if needed hard_links="nottested" if test "$compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $rm conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([\`$CC' does not support \`-c -o', so \`make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi if test "$GCC" = yes; then # Check to see if options -fno-rtti -fno-exceptions are supported by compiler AC_MSG_CHECKING([if $compiler supports -fno-rtti -fno-exceptions]) echo "int some_variable = 0;" > conftest.$ac_ext save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" compiler_rtti_exceptions=no AC_TRY_COMPILE([], [int some_variable = 0;], [dnl # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then compiler_rtti_exceptions=no else compiler_rtti_exceptions=yes fi ]) CFLAGS="$save_CFLAGS" AC_MSG_RESULT([$compiler_rtti_exceptions]) if test "$compiler_rtti_exceptions" = "yes"; then no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' else no_builtin_flag=' -fno-builtin' fi fi # See if the linker supports building shared libraries. AC_MSG_CHECKING([whether the linker ($LD) supports shared libraries]) allow_undefined_flag= no_undefined_flag= need_lib_prefix=unknown need_version=unknown # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments archive_cmds= archive_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= export_dynamic_flag_spec= whole_archive_flag_spec= thread_safe_flag_spec= hardcode_into_libs=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_direct=no hardcode_minus_L=no hardcode_shlibpath_var=unsupported runpath_var= link_all_deplibs=unknown always_export_symbols=no export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an egrep regular expression of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms="_GLOBAL_OFFSET_TABLE_" # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # See if GNU ld supports shared libraries. case $host_os in aix3* | aix4* | aix5*) # On AIX, the GNU linker is very broken # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available. ld_shlibs=no cat <&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. EOF ;; amigaos*) archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes # Samuel A. Falvo II reports # that the semantics of dynamic libraries on AmigaOS, at least up # to version 4, is to share data among multiple programs linked # with the same dynamic library. Since this doesn't match the # behavior of shared libraries on other platforms, we can use # them. ld_shlibs=no ;; beos*) if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32*) # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' allow_undefined_flag=unsupported always_export_symbols=yes extract_expsyms_cmds='test -f $output_objdir/impgen.c || \ sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~ test -f $output_objdir/impgen.exe || (cd $output_objdir && \ if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ else $CC -o impgen impgen.c ; fi)~ $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' # cygwin and mingw dlls have different entry points and sets of symbols # to exclude. # FIXME: what about values for MSVC? dll_entry=__cygwin_dll_entry@12 dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ case $host_os in mingw*) # mingw values dll_entry=_DllMainCRTStartup@12 dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ ;; esac # mingw and cygwin differ, and it's simplest to just exclude the union # of the two symbol sets. dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 # recent cygwin and mingw systems supply a stub DllMain which the user # can override, but on older systems we have to supply one (in ltdll.c) if test "x$lt_cv_need_dllmain" = "xyes"; then ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~ test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' else ltdll_obj= ltdll_cmds= fi # Extract the symbol export list from an `--export-all' def file, # then regenerate the def file from the symbol export list, so that # the compiled dll only exports the symbol export list. # Be careful not to strip the DATA tag left be newer dlltools. export_symbols_cmds="$ltdll_cmds"' $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ sed -e "1,/EXPORTS/d" -e "s/ @ [[0-9]]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is. # If DATA tags from a recent dlltool are present, honour them! archive_expsym_cmds='if test "x`sed 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname-def; else echo EXPORTS > $output_objdir/$soname-def; _lt_hint=1; cat $export_symbols | while read symbol; do set dummy \$symbol; case \[$]# in 2) echo " \[$]2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; 4) echo " \[$]2 \[$]3 \[$]4 ; " >> $output_objdir/$soname-def; _lt_hint=`expr \$_lt_hint - 1`;; *) echo " \[$]2 @ \$_lt_hint \[$]3 ; " >> $output_objdir/$soname-def;; esac; _lt_hint=`expr 1 + \$_lt_hint`; done; fi~ '"$ltdll_cmds"' $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~ $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~ $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags' ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris* | sysv5*) if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. EOF elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = yes; then runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' case $host_os in cygwin* | mingw* | pw32*) # dlltool doesn't understand --whole-archive et. al. whole_archive_flag_spec= ;; *) # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi ;; esac fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$link_static_flag"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. hardcode_direct=yes archive_cmds='' hardcode_libdir_separator=':' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 hardcode_direct=yes else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi esac shared_flag='-shared' else # not using gcc if test "$host_cpu" = ia64; then shared_flag='${wl}-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall can do strange things, so it is better to # generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" else hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. allow_undefined_flag='${wl}-berok' # This is a bit strange, but is similar to how AIX traditionally builds # it's shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' fi fi ;; amigaos*) archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes # see comment about different semantics on the GNU ld section ld_shlibs=no ;; cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' fix_srcfile_path='`cygpath -w "$srcfile"`' ;; darwin* | rhapsody*) case "$host_os" in rhapsody* | darwin1.[[012]]) allow_undefined_flag='-undefined suppress' ;; *) # Darwin 1.3 on allow_undefined_flag='-flat_namespace -undefined suppress' ;; esac # FIXME: Relying on posixy $() will cause problems for # cross-compilation, but unfortunately the echo tests do not # yet detect zsh echo's removal of \ escapes. Also zsh mangles # `"' quotes if we put them in here... so don't! archive_cmds='$nonopt $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags -install_name $rpath/$soname $verstring' # We need to add '_' to the symbols in $export_symbols first #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' hardcode_direct=yes hardcode_shlibpath_var=no whole_archive_flag_spec='-all_load $convenience' ;; freebsd1*) ld_shlibs=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd*) archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9* | hpux10* | hpux11*) case $host_os in hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; esac hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_minus_L=yes # Not in the search PATH, but as the default # location of the library. export_dynamic_flag_spec='${wl}-E' ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' fi hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: link_all_deplibs=yes ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; openbsd*) hardcode_direct=yes hardcode_shlibpath_var=no if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case "$host_os" in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' fi hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' #Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi hardcode_libdir_separator=: ;; sco3.2v5*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes export_dynamic_flag_spec='${wl}-Bexport' ;; solaris*) # gcc --version < 3.0 without binutils cannot create self contained # shared libraries reliably, requiring libgcc.a to resolve some of # the object symbols generated in some cases. Libraries that use # assert need libgcc.a to resolve __eprintf, for example. Linking # a copy of libgcc.a into every shared library to guarantee resolving # such symbols causes other problems: According to Tim Van Holder # , C++ libraries end up with a separate # (to the application) exception stack for one thing. no_undefined_flag=' -z defs' if test "$GCC" = yes; then case `$CC --version 2>/dev/null` in [[12]].*) cat <&2 *** Warning: Releases of GCC earlier than version 3.0 cannot reliably *** create self contained shared libraries on Solaris systems, without *** introducing a dependency on libgcc.a. Therefore, libtool is disabling *** -no-undefined support, which will at least allow you to build shared *** libraries. However, you may find that when you link such libraries *** into an application without using GCC, you have to manually add *** \`gcc --print-libgcc-file-name\` to the link command. We urge you to *** upgrade to a newer version of GCC. Another option is to rebuild your *** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer. EOF no_undefined_flag= ;; esac fi # $CC -shared without GNU ld will not create a library from C++ # object files and a static libstdc++, better avoid it by now archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv5*) no_undefined_flag=' -z text' # $CC -shared without GNU ld will not create a library from C++ # object files and a static libstdc++, better avoid it by now archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' hardcode_libdir_flag_spec= hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4.2uw2*) archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=no hardcode_shlibpath_var=no hardcode_runpath_var=yes runpath_var=LD_RUN_PATH ;; sysv5uw7* | unixware7*) no_undefined_flag='${wl}-z ${wl}text' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' fi runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac fi AC_MSG_RESULT([$ld_shlibs]) test "$ld_shlibs" = no && can_build_shared=no # Check hardcoding attributes. AC_MSG_CHECKING([how to hardcode library paths into programs]) hardcode_action= if test -n "$hardcode_libdir_flag_spec" || \ test -n "$runpath_var"; then # We can hardcode non-existant directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$hardcode_shlibpath_var" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi AC_MSG_RESULT([$hardcode_action]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi reload_cmds='$LD$reload_flag -o $output$reload_objs' test -z "$deplibs_check_method" && deplibs_check_method=unknown # PORTME Fill in your ld.so characteristics AC_MSG_CHECKING([dynamic linker characteristics]) library_names_spec= libname_spec='lib$name' soname_spec= postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}.so$versuffix $libname.a' shlibpath_var=LIBPATH # AIX has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}.so$major' ;; aix4* | aix5*) version_type=linux if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can # not hardcode correct soname into executable. Probably we can # add versioning support to collect2, so additional links can # be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}.so$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' ;; beos*) library_names_spec='${libname}.so' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi4*) version_type=linux need_version=no library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" export_dynamic_flag_spec=-rdynamic # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32*) version_type=windows need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin*) library_names_spec='$libname.dll.a' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll' postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog .libs/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $rm \$dlpath' ;; yes,mingw*) library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll' sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g" -e "s,=/,/,g"` ;; yes,pw32*) library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' ;; *) library_names_spec='${libname}`echo ${release} | sed -e 's/[[.]]/-/g'`${versuffix}.dll $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no # FIXME: Relying on posixy $() will cause problems for # cross-compilation, but unfortunately the echo tests do not # yet detect zsh echo's removal of \ escapes. library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd*) objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; *) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. dynamic_linker="$host_os dld.sl" version_type=sunos need_lib_prefix=no need_version=no shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' soname_spec='${libname}${release}.sl$major' # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) version_type=irix ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}.so$major' library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" ;; # No shared lib support for Linux oldld, aout, or coff. linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) dynamic_linker=no ;; # This must be Linux ELF. linux-gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' soname_spec='${libname}${release}.so$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; openbsd*) version_type=sunos need_lib_prefix=no need_version=no if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case "$host_os" in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH ;; os2*) libname_spec='$name' need_lib_prefix=no library_names_spec='$libname.dll $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_version=no soname_spec='${libname}${release}.so' library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; sco3.2v5*) version_type=osf soname_spec='${libname}${release}.so$major' library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' shlibpath_var=LD_LIBRARY_PATH ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) version_type=linux library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no export_dynamic_flag_spec='${wl}-Blargedynsym' runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; uts4*) version_type=linux library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' soname_spec='$libname.so.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no # Report the final consequences. AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case "$host_os" in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix4*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) if test "$hardcode_action" = relink; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi AC_LIBTOOL_DLOPEN_SELF if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_MSG_CHECKING([whether -lc should be explicitly linked in]) AC_CACHE_VAL([lt_cv_archive_cmds_need_lc], [$rm conftest* echo 'static int dummy;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_cv_prog_cc_wl compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if AC_TRY_EVAL(archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$save_allow_undefined_flag else cat conftest.err 1>&5 fi]) AC_MSG_RESULT([$lt_cv_archive_cmds_need_lc]) ;; esac fi need_lc=${lt_cv_archive_cmds_need_lc-yes} # The second clause should only fire when bootstrapping the # libtool distribution, otherwise you forgot to ship ltmain.sh # with your package, and you will get complaints that there are # no rules to generate ltmain.sh. if test -f "$ltmain"; then : else # If there is no Makefile yet, we rely on a make rule to execute # `config.status --recheck' to rerun these tests and create the # libtool script then. test -f Makefile && make "$ltmain" fi if test -f "$ltmain"; then trap "$rm \"${ofile}T\"; exit 1" 1 2 15 $rm -f "${ofile}T" echo creating $ofile # Now quote all the things that may contain metacharacters while being # careful not to overquote the AC_SUBSTed values. We take copies of the # variables and quote the copies for generation of the libtool script. for var in echo old_CC old_CFLAGS SED \ AR AR_FLAGS CC LD LN_S NM SHELL \ reload_flag reload_cmds wl \ pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ thread_safe_flag_spec whole_archive_flag_spec libname_spec \ library_names_spec soname_spec \ RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ old_striplib striplib file_magic_cmd export_symbols_cmds \ deplibs_check_method allow_undefined_flag no_undefined_flag \ finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ global_symbol_to_c_name_address \ hardcode_libdir_flag_spec hardcode_libdir_separator \ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do case $var in reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ old_postinstall_cmds | old_postuninstall_cmds | \ export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ extract_expsyms_cmds | old_archive_from_expsyms_cmds | \ postinstall_cmds | postuninstall_cmds | \ finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) # Double-quote double-evaled strings. eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ;; *) eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" ;; esac done cat <<__EOF__ > "${ofile}T" #! $SHELL # `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996-2000 Free Software Foundation, Inc. # Originally by Gordon Matzigkeit , 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 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # A sed that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="${SED} -e s/^X//" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi # ### BEGIN LIBTOOL CONFIG # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$need_lc # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host # An echo program that does not interpret backslashes. echo=$lt_echo # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # The default C compiler. CC=$lt_CC # Is the compiler the GNU C compiler? with_gcc=$GCC # The linker used to build libraries. LD=$lt_LD # Whether we need hard or soft links. LN_S=$lt_LN_S # A BSD-compatible nm program. NM=$lt_NM # A symbol stripping program STRIP=$STRIP # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=$MAGIC_CMD # Used on cygwin: DLL creation program. DLLTOOL="$DLLTOOL" # Used on cygwin: object dumper. OBJDUMP="$OBJDUMP" # Used on cygwin: assembler. AS="$AS" # The name of the directory that contains temporary libtool files. objdir=$objdir # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # How to pass a linker flag through the compiler. wl=$lt_wl # Object file suffix (normally "o"). objext="$ac_objext" # Old archive suffix (normally "a"). libext="$libext" # Executable file suffix (normally ""). exeext="$exeext" # Additional compiler flags for building library objects. pic_flag=$lt_pic_flag pic_mode=$pic_mode # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_compiler_c_o # Can we write directly to a .lo ? compiler_o_lo=$lt_compiler_o_lo # Must we lock files when doing compilation ? need_locks=$lt_need_locks # Do we need the lib prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Compiler flag to prevent dynamic linking. link_static_flag=$lt_link_static_flag # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_no_builtin_flag # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Compiler flag to generate thread-safe objects. thread_safe_flag_spec=$lt_thread_safe_flag_spec # Library versioning type. version_type=$version_type # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Commands used to build and install an old-style archive. RANLIB=$lt_RANLIB old_archive_cmds=$lt_old_archive_cmds old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build and install a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds postinstall_cmds=$lt_postinstall_cmds postuninstall_cmds=$lt_postuninstall_cmds # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == file_magic. file_magic_cmd=$lt_file_magic_cmd # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that forces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # Same as above, but a single script fragment to be evaled but not shown. finish_eval=$lt_finish_eval # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_global_symbol_pipe # Transform the output of nm in a proper C declaration global_symbol_to_cdecl=$lt_global_symbol_to_cdecl # Transform the output of nm in a C name address pair global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address # This is the shared library runtime path variable. runpath_var=$runpath_var # This is the shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist. hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the # resulting binary. hardcode_direct=$hardcode_direct # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="$variables_saved_for_relink" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Compile-time system search path for libraries sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path="$fix_srcfile_path" # Set to yes if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # ### END LIBTOOL CONFIG __EOF__ case $host_os in aix3*) cat <<\EOF >> "${ofile}T" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi EOF ;; esac case $host_os in cygwin* | mingw* | pw32* | os2*) cat <<'EOF' >> "${ofile}T" # This is a source program that is used to create dlls on Windows # Don't remove nor modify the starting and closing comments # /* ltdll.c starts here */ # #define WIN32_LEAN_AND_MEAN # #include # #undef WIN32_LEAN_AND_MEAN # #include # # #ifndef __CYGWIN__ # # ifdef __CYGWIN32__ # # define __CYGWIN__ __CYGWIN32__ # # endif # #endif # # #ifdef __cplusplus # extern "C" { # #endif # BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); # #ifdef __cplusplus # } # #endif # # #ifdef __CYGWIN__ # #include # DECLARE_CYGWIN_DLL( DllMain ); # #endif # HINSTANCE __hDllInstance_base; # # BOOL APIENTRY # DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) # { # __hDllInstance_base = hInst; # return TRUE; # } # /* ltdll.c ends here */ # This is a source program that is used to create import libraries # on Windows for dlls which lack them. Don't remove nor modify the # starting and closing comments # /* impgen.c starts here */ # /* Copyright (C) 1999-2000 Free Software Foundation, Inc. # # This file is part of GNU libtool. # # 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. # */ # # #include /* for printf() */ # #include /* for open(), lseek(), read() */ # #include /* for O_RDONLY, O_BINARY */ # #include /* for strdup() */ # # /* O_BINARY isn't required (or even defined sometimes) under Unix */ # #ifndef O_BINARY # #define O_BINARY 0 # #endif # # static unsigned int # pe_get16 (fd, offset) # int fd; # int offset; # { # unsigned char b[2]; # lseek (fd, offset, SEEK_SET); # read (fd, b, 2); # return b[0] + (b[1]<<8); # } # # static unsigned int # pe_get32 (fd, offset) # int fd; # int offset; # { # unsigned char b[4]; # lseek (fd, offset, SEEK_SET); # read (fd, b, 4); # return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); # } # # static unsigned int # pe_as32 (ptr) # void *ptr; # { # unsigned char *b = ptr; # return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); # } # # int # main (argc, argv) # int argc; # char *argv[]; # { # int dll; # unsigned long pe_header_offset, opthdr_ofs, num_entries, i; # unsigned long export_rva, export_size, nsections, secptr, expptr; # unsigned long name_rvas, nexp; # unsigned char *expdata, *erva; # char *filename, *dll_name; # # filename = argv[1]; # # dll = open(filename, O_RDONLY|O_BINARY); # if (dll < 1) # return 1; # # dll_name = filename; # # for (i=0; filename[i]; i++) # if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') # dll_name = filename + i +1; # # pe_header_offset = pe_get32 (dll, 0x3c); # opthdr_ofs = pe_header_offset + 4 + 20; # num_entries = pe_get32 (dll, opthdr_ofs + 92); # # if (num_entries < 1) /* no exports */ # return 1; # # export_rva = pe_get32 (dll, opthdr_ofs + 96); # export_size = pe_get32 (dll, opthdr_ofs + 100); # nsections = pe_get16 (dll, pe_header_offset + 4 +2); # secptr = (pe_header_offset + 4 + 20 + # pe_get16 (dll, pe_header_offset + 4 + 16)); # # expptr = 0; # for (i = 0; i < nsections; i++) # { # char sname[8]; # unsigned long secptr1 = secptr + 40 * i; # unsigned long vaddr = pe_get32 (dll, secptr1 + 12); # unsigned long vsize = pe_get32 (dll, secptr1 + 16); # unsigned long fptr = pe_get32 (dll, secptr1 + 20); # lseek(dll, secptr1, SEEK_SET); # read(dll, sname, 8); # if (vaddr <= export_rva && vaddr+vsize > export_rva) # { # expptr = fptr + (export_rva - vaddr); # if (export_rva + export_size > vaddr + vsize) # export_size = vsize - (export_rva - vaddr); # break; # } # } # # expdata = (unsigned char*)malloc(export_size); # lseek (dll, expptr, SEEK_SET); # read (dll, expdata, export_size); # erva = expdata - export_rva; # # nexp = pe_as32 (expdata+24); # name_rvas = pe_as32 (expdata+32); # # printf ("EXPORTS\n"); # for (i = 0; i> "${ofile}T" || (rm -f "${ofile}T"; exit 1) mv -f "${ofile}T" "$ofile" || \ (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T") chmod +x "$ofile" fi ])# _LT_AC_LTCONFIG_HACK # AC_LIBTOOL_DLOPEN - enable checks for dlopen support AC_DEFUN([AC_LIBTOOL_DLOPEN], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) # AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) # AC_ENABLE_SHARED - implement the --enable-shared flag # Usage: AC_ENABLE_SHARED[(DEFAULT)] # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to # `yes'. AC_DEFUN([AC_ENABLE_SHARED], [define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE(shared, changequote(<<, >>)dnl << --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," for pkg in $enableval; do if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$ac_save_ifs" ;; esac], enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl ]) # AC_DISABLE_SHARED - set the default shared flag to --disable-shared AC_DEFUN([AC_DISABLE_SHARED], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_ENABLE_SHARED(no)]) # AC_ENABLE_STATIC - implement the --enable-static flag # Usage: AC_ENABLE_STATIC[(DEFAULT)] # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to # `yes'. AC_DEFUN([AC_ENABLE_STATIC], [define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE(static, changequote(<<, >>)dnl << --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," for pkg in $enableval; do if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$ac_save_ifs" ;; esac], enable_static=AC_ENABLE_STATIC_DEFAULT)dnl ]) # AC_DISABLE_STATIC - set the default static flag to --disable-static AC_DEFUN([AC_DISABLE_STATIC], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_ENABLE_STATIC(no)]) # AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag # Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] # Where DEFAULT is either `yes' or `no'. If omitted, it defaults to # `yes'. AC_DEFUN([AC_ENABLE_FAST_INSTALL], [define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl AC_ARG_ENABLE(fast-install, changequote(<<, >>)dnl << --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], changequote([, ])dnl [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," for pkg in $enableval; do if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$ac_save_ifs" ;; esac], enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl ]) # AC_DISABLE_FAST_INSTALL - set the default to --disable-fast-install AC_DEFUN([AC_DISABLE_FAST_INSTALL], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_ENABLE_FAST_INSTALL(no)]) # AC_LIBTOOL_PICMODE - implement the --with-pic flag # Usage: AC_LIBTOOL_PICMODE[(MODE)] # Where MODE is either `yes' or `no'. If omitted, it defaults to # `both'. AC_DEFUN([AC_LIBTOOL_PICMODE], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl pic_mode=ifelse($#,1,$1,default)]) # AC_PATH_TOOL_PREFIX - find a file program which can recognise shared library AC_DEFUN([AC_PATH_TOOL_PREFIX], [AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in /*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; ?:/*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. ;; *) ac_save_MAGIC_CMD="$MAGIC_CMD" IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="ifelse([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | egrep "$file_magic_regex" > /dev/null; then : else cat <&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org EOF fi ;; esac fi break fi done IFS="$ac_save_ifs" MAGIC_CMD="$ac_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi ]) # AC_PATH_MAGIC - find a file program which can recognise a shared library AC_DEFUN([AC_PATH_MAGIC], [AC_REQUIRE([AC_CHECK_TOOL_PREFIX])dnl AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin:$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then AC_PATH_TOOL_PREFIX(file, /usr/bin:$PATH) else MAGIC_CMD=: fi fi ]) # AC_PROG_LD - find the path to the GNU or non-GNU linker AC_DEFUN([AC_PROG_LD], [AC_ARG_WITH(gnu-ld, [ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by GCC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | [[A-Za-z]]:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then test "$with_gnu_ld" != no && break else test "$with_gnu_ld" != yes && break fi fi done IFS="$ac_save_ifs" else lt_cv_path_LD="$LD" # Let the user override the test with a path. fi]) LD="$lt_cv_path_LD" if test -n "$LD"; then AC_MSG_RESULT($LD) else AC_MSG_RESULT(no) fi test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) AC_PROG_LD_GNU ]) # AC_PROG_LD_GNU - AC_DEFUN([AC_PROG_LD_GNU], [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld, [# I'd rather use --version here, but apparently some GNU ld's only accept -v. if $LD -v 2>&1 &5; then lt_cv_prog_gnu_ld=yes else lt_cv_prog_gnu_ld=no fi]) with_gnu_ld=$lt_cv_prog_gnu_ld ]) # AC_PROG_LD_RELOAD_FLAG - find reload flag for linker # -- PORTME Some linkers may need a different reload flag. AC_DEFUN([AC_PROG_LD_RELOAD_FLAG], [AC_CACHE_CHECK([for $LD option to reload object files], lt_cv_ld_reload_flag, [lt_cv_ld_reload_flag='-r']) reload_flag=$lt_cv_ld_reload_flag test -n "$reload_flag" && reload_flag=" $reload_flag" ]) # AC_DEPLIBS_CHECK_METHOD - how to check for library dependencies # -- PORTME fill in with the dynamic library characteristics AC_DEFUN([AC_DEPLIBS_CHECK_METHOD], [AC_CACHE_CHECK([how to recognise dependent libraries], lt_cv_deplibs_check_method, [lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given egrep regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix4* | aix5*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi4*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin* | mingw* | pw32*) lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' lt_cv_file_magic_cmd='/usr/bin/file -L' case "$host_os" in rhapsody* | darwin1.[[012]]) lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` ;; *) # Darwin 1.3 on lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' ;; esac ;; freebsd*) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20*|hpux11*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; irix5* | irix6* | nonstopux*) case $host_os in irix5* | nonstopux*) # this will be overridden with pass_all, but let us keep it just in case lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" ;; *) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac # this will be overridden with pass_all, but let us keep it just in case lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[[1234]] dynamic lib MIPS - version 1" ;; esac lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux-gnu*) case $host_cpu in alpha* | hppa* | i*86 | mips | mipsel | powerpc* | sparc* | ia64*) lt_cv_deplibs_check_method=pass_all ;; *) # glibc up to 2.1.1 does not perform some relocations on ARM lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; esac lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so\.[[0-9]]+\.[[0-9]]+$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/\.]]+\.so$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; openbsd*) lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB shared object' else lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' fi ;; osf3* | osf4* | osf5*) # this will be overridden with pass_all, but let us keep it just in case lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' lt_cv_file_magic_test_file=/shlib/libc.so lt_cv_deplibs_check_method=pass_all ;; sco3.2v5*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all lt_cv_file_magic_test_file=/lib/libc.so ;; sysv5uw[[78]]* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; esac ;; esac ]) file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method ]) # AC_PROG_NM - find the path to a BSD-compatible name lister AC_DEFUN([AC_PROG_NM], [AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl AC_MSG_CHECKING([for BSD-compatible nm]) AC_CACHE_VAL(lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/${ac_tool_prefix}nm if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then lt_cv_path_NM="$tmp_nm -B" break elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then lt_cv_path_NM="$tmp_nm -p" break else lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags fi fi done IFS="$ac_save_ifs" test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm fi]) NM="$lt_cv_path_NM" AC_MSG_RESULT([$NM]) ]) # AC_CHECK_LIBM - check for math library AC_DEFUN([AC_CHECK_LIBM], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cygwin* | *-*-pw32*) # These system don't have libm ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, main, LIBM="-lm") ;; esac ]) # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for # the libltdl convenience library and LTDLINCL to the include flags for # the libltdl header and adds --enable-ltdl-convenience to the # configure arguments. Note that LIBLTDL and LTDLINCL are not # AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not # provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed # with '${top_builddir}/' and LTDLINCL will be prefixed with # '${top_srcdir}/' (note the single quotes!). If your package is not # flat and you're not using automake, define top_builddir and # top_srcdir appropriately in the Makefiles. AC_DEFUN([AC_LIBLTDL_CONVENIENCE], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl case $enable_ltdl_convenience in no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; "") enable_ltdl_convenience=yes ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; esac LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) # For backwards non-gettext consistent compatibility... INCLTDL="$LTDLINCL" ]) # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for # the libltdl installable library and LTDLINCL to the include flags for # the libltdl header and adds --enable-ltdl-install to the configure # arguments. Note that LIBLTDL and LTDLINCL are not AC_SUBSTed, nor is # AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed # libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will # be prefixed with '${top_builddir}/' and LTDLINCL will be prefixed # with '${top_srcdir}/' (note the single quotes!). If your package is # not flat and you're not using automake, define top_builddir and # top_srcdir appropriately in the Makefiles. # In the future, this macro may have to be called after AC_PROG_LIBTOOL. AC_DEFUN([AC_LIBLTDL_INSTALLABLE], [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_CHECK_LIB(ltdl, main, [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], [if test x"$enable_ltdl_install" = xno; then AC_MSG_WARN([libltdl not installed, but installation disabled]) else enable_ltdl_install=yes fi ]) if test x"$enable_ltdl_install" = x"yes"; then ac_configure_args="$ac_configure_args --enable-ltdl-install" LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl']) else ac_configure_args="$ac_configure_args --enable-ltdl-install=no" LIBLTDL="-lltdl" LTDLINCL= fi # For backwards non-gettext consistent compatibility... INCLTDL="$LTDLINCL" ]) # old names AC_DEFUN([AM_PROG_LIBTOOL], [AC_PROG_LIBTOOL]) AC_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AC_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) AC_DEFUN([AM_PROG_LD], [AC_PROG_LD]) AC_DEFUN([AM_PROG_NM], [AC_PROG_NM]) # This is just to silence aclocal about the macro not being used ifelse([AC_DISABLE_FAST_INSTALL]) # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # # LT_AC_PROG_SED # -------------- # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. AC_DEFUN([LT_AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_executable_p="test -f" as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then _sed_list="$_sed_list $as_dir/$ac_prog$ac_exec_ext" fi done done done # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. : ${TMPDIR=/tmp} { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/sedXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=$TMPDIR/sed$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 { (exit 1); exit 1; } } _max=0 _count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for _sed in $_sed_list /usr/xpg4/bin/sed; do test ! -f ${_sed} && break cat /dev/null > "$tmp/sed.in" _count=0 echo ${ECHO_N-$ac_n} "0123456789${ECHO_C-$ac_c}" >"$tmp/sed.in" # Check for GNU sed and select it if it is found. if "${_sed}" --version 2>&1 < /dev/null | egrep '(GNU)' > /dev/null; then lt_cv_path_SED=${_sed} break; fi while true; do cat "$tmp/sed.in" "$tmp/sed.in" >"$tmp/sed.tmp" mv "$tmp/sed.tmp" "$tmp/sed.in" cp "$tmp/sed.in" "$tmp/sed.nl" echo >>"$tmp/sed.nl" ${_sed} -e 's/a$//' < "$tmp/sed.nl" >"$tmp/sed.out" || break cmp -s "$tmp/sed.out" "$tmp/sed.nl" || break # 40000 chars as input seems more than enough test $_count -gt 10 && break _count=`expr $_count + 1` if test $_count -gt $_max; then _max=$_count lt_cv_path_SED=$_sed fi done done rm -rf "$tmp" ]) if test "X$SED" != "X"; then lt_cv_path_SED=$SED else SED=$lt_cv_path_SED fi AC_MSG_RESULT([$SED]) ]) towitoko-2.0.7/config.guess0000755000175000017500000011330007527762020011405 #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002 Free Software Foundation, Inc. timestamp='2002-05-29' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # 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 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi dummy=dummy-$$ trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int dummy(){}" > $dummy.c ; for c in cc gcc c89 c99 ; do ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; if test $? = 0 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; rm -f $dummy.c $dummy.o $dummy.rel ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; macppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mipseb-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # 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. cat <$dummy.s .data \$Lformat: .byte 37,100,45,37,120,10,0 # "%d-%x\n" .text .globl main .align 4 .ent main main: .frame \$30,16,\$26,0 ldgp \$29,0(\$27) .prologue 1 .long 0x47e03d80 # implver \$0 lda \$2,-1 .long 0x47e20c21 # amask \$2,\$1 lda \$16,\$Lformat mov \$0,\$17 not \$1,\$18 jsr \$26,printf ldgp \$29,0(\$26) mov 0,\$16 jsr \$26,exit .end main EOF eval $set_cc_for_build $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null if test "$?" = 0 ; then case `./$dummy` in 0-0) UNAME_MACHINE="alpha" ;; 1-0) UNAME_MACHINE="alphaev5" ;; 1-1) UNAME_MACHINE="alphaev56" ;; 1-101) UNAME_MACHINE="alphapca56" ;; 2-303) UNAME_MACHINE="alphaev6" ;; 2-307) UNAME_MACHINE="alphaev67" ;; 2-1307) UNAME_MACHINE="alphaev68" ;; esac fi rm -f $dummy.s $dummy echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* 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 $dummy.c -o $dummy \ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Night_Hawk:*:*:PowerMAX_OS) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #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 $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy` if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi rm -f $dummy.c $dummy fi ;; esac echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include 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 $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3D:*:*:*) echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; x86:Interix*:3*) echo i386-pc-interix3 exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i386-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` rm -f $dummy.c test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` rm -f $dummy.c test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*: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) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) echo `uname -p`-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # 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"); 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 $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 rm -f $dummy.c $dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < 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: towitoko-2.0.7/config.h.in0000644000175000017500000000716007527762377011135 /* config.h.in. Generated from configure.ac by autoheader. */ /* Enable win32 COM numbering */ #undef CTAPI_WIN32_COM /* Debug CT-API */ #undef DEBUG_CTAPI /* Debug Integrated Circuit Card */ #undef DEBUG_ICC /* Debug Interface Device */ #undef DEBUG_IFD /* Debug IFD Handler */ #undef DEBUG_IFDH /* Debug Input/Output */ #undef DEBUG_IO /* Debug Protocol */ #undef DEBUG_PROTOCOL /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `nanosleep' function. */ #undef HAVE_NANOSLEEP /* Define to 1 if you have the `poll' function. */ #undef HAVE_POLL /* Define to 1 if you have the header file. */ #undef HAVE_PTHREAD_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 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 `syslog' function. */ #undef HAVE_SYSLOG /* 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 /* Memory size */ #undef ICC_SYNC_MEMORY_LENGTH /* Memory smartcard type (0,1,2,3) */ #undef ICC_SYNC_MEMORY_TYPE /* Smartcard of type asynchronoys */ #undef ICC_TYPE_ASYNC /* Smartcard of type synchronoys */ #undef ICC_TYPE_SYNC /* Smartcard with direct convention */ #undef IFD_TOWITOKO_CONVENTION_DIRECT /* Smartcard with inverse convention */ #undef IFD_TOWITOKO_CONVENTION_INVERSE /* ATR for asynchronous cards is cheked */ #undef IFD_TOWITOKO_STRICT_ATR_CHECK /* Enable Linux 2.4.X devfs support */ #undef IO_ENABLE_DEVFS /* Enable /dev/pcsc/ links */ #undef IO_ENABLE_DEVPCSC /* Enable USB support */ #undef IO_ENABLE_USB /* FreeBSD Operating System */ #undef OS_AIX /* Cywin32 for Windows NT environment */ #undef OS_CYGWIN32 /* FreeBSD Operating System */ #undef OS_FREEBSD /* HPUX Operating System */ #undef OS_HPUX /* IRIX Operating System */ #undef OS_IRIX /* Linux Operating System */ #undef OS_LINUX /* FreeBSD Operating System */ #undef OS_NETBSD /* OpenBSD Operating System */ #undef OS_OPENBSD /* Other Operating System */ #undef OS_OTHER /* SCO Operating System */ #undef OS_SCO /* Sun Operating System */ #undef OS_SOLARIS /* 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 /* Transportation of APDUs by T=0 */ #undef PROTOCOL_T0_ISO /* Timings in ATR are not used in T=0 cards */ #undef PROTOCOL_T0_USE_DEFAULT_TIMINGS /* Timings in ATR are not used in T=1 cards */ #undef PROTOCOL_T1_USE_DEFAULT_TIMINGS /* Timings in ATR are not used after PTS */ #undef PTS_USE_DEFAULT_TIMINGS /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Version number of package */ #undef VERSION /* This may be usefull for LinuxThreads */ #undef _REENTRANT towitoko-2.0.7/config.sub0000755000175000017500000007143307527762020011062 #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002 Free Software Foundation, Inc. timestamp='2002-06-21' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . 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 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k \ | m32r | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mipsisa32 | mipsisa32el \ | mipsisa64 | mipsisa64el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c54x-* \ | clipper-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* \ | m32r-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipstx39 | mipstx39el \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; 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 ;; 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 ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; or32 | or32-*) basic_machine=or32-unknown os=-coff ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-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-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; 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 ;; t3d) basic_machine=alpha-cray os=-unicos ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic54x | c54x*) basic_machine=tic54x-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 ;; 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 ;; windows32) basic_machine=i386-pc os=-windows32-msvcrt ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; c4x*) basic_machine=c4x-none os=-coff ;; *-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* | -netbsd* | -openbsd* | -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* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -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*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto*) os=-nto-qnx ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) 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 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -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 ;; -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 ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: towitoko-2.0.7/configure0000755000175000017500000111151707527762035011013 #! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.53. # # Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 # Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Find the correct PATH separator. Usually this is `:', but # DJGPP uses `;' like DOS. if test "X${PATH_SEPARATOR+set}" != Xset; then UNAME=${UNAME-`uname 2>/dev/null`} case X$UNAME in *-DOS) lt_cv_sys_path_separator=';' ;; *) lt_cv_sys_path_separator=':' ;; esac PATH_SEPARATOR=$lt_cv_sys_path_separator fi # Check that we are running under the correct shell. SHELL=${CONFIG_SHELL-/bin/sh} case X$ECHO in X*--fallback-echo) # Remove one level of quotation (which was required for Make). ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','` ;; esac echo=${ECHO-echo} if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then # Yippee, $echo works! : else # Restart under the correct shell. exec $SHELL "$0" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat </dev/null && echo_test_string="`eval $cmd`" && (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null then break fi done fi if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then : else # The Solaris, AIX, and Digital Unix default echo programs unquote # backslashes. This makes it impossible to quote backslashes using # echo "$something" | sed 's/\\/\\\\/g' # # So, first we look for a working echo in the user's PATH. IFS="${IFS= }"; save_ifs="$IFS"; IFS=$PATH_SEPARATOR for dir in $PATH /usr/ucb; do if (test -f $dir/echo || test -f $dir/echo$ac_exeext) && test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then echo="$dir/echo" break fi done IFS="$save_ifs" if test "X$echo" = Xecho; then # We didn't find a better echo, so look for alternatives. if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # This shell has a builtin print -r that does the trick. echo='print -r' elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) && test "X$CONFIG_SHELL" != X/bin/ksh; then # If we have ksh, try running configure again with it. ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh} export ORIGINAL_CONFIG_SHELL CONFIG_SHELL=/bin/ksh export CONFIG_SHELL exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"} else # Try using printf. echo='printf %s\n' if test "X`($echo '\t') 2>/dev/null`" = 'X\t' && echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then # Cool, printf works : elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL export CONFIG_SHELL SHELL="$CONFIG_SHELL" export SHELL echo="$CONFIG_SHELL $0 --fallback-echo" elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` && test "X$echo_testing_string" = 'X\t' && echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` && test "X$echo_testing_string" = "X$echo_test_string"; then echo="$CONFIG_SHELL $0 --fallback-echo" else # maybe with a smaller string... prev=: for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null then break fi prev="$cmd" done if test "$prev" != 'sed 50q "$0"'; then echo_test_string=`eval $prev` export echo_test_string exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"} else # Oops. We lost completely, so just stick with echo. echo=echo fi fi fi fi fi fi # Copy echo and quote the copy suitably for passing to libtool from # the Makefile, instead of quoting the original, which is used later. ECHO=$echo if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo" fi if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi # NLS nuisances. # Support unset when possible. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi (set +x; test -n "`(LANG=C; export LANG) 2>&1`") && { $as_unset LANG || test "${LANG+set}" != set; } || { LANG=C; export LANG; } (set +x; test -n "`(LC_ALL=C; export LC_ALL) 2>&1`") && { $as_unset LC_ALL || test "${LC_ALL+set}" != set; } || { LC_ALL=C; export LC_ALL; } (set +x; test -n "`(LC_TIME=C; export LC_TIME) 2>&1`") && { $as_unset LC_TIME || test "${LC_TIME+set}" != set; } || { LC_TIME=C; export LC_TIME; } (set +x; test -n "`(LC_CTYPE=C; export LC_CTYPE) 2>&1`") && { $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set; } || { LC_CTYPE=C; export LC_CTYPE; } (set +x; test -n "`(LANGUAGE=C; export LANGUAGE) 2>&1`") && { $as_unset LANGUAGE || test "${LANGUAGE+set}" != set; } || { LANGUAGE=C; export LANGUAGE; } (set +x; test -n "`(LC_COLLATE=C; export LC_COLLATE) 2>&1`") && { $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set; } || { LC_COLLATE=C; export LC_COLLATE; } (set +x; test -n "`(LC_NUMERIC=C; export LC_NUMERIC) 2>&1`") && { $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set; } || { LC_NUMERIC=C; export LC_NUMERIC; } (set +x; test -n "`(LC_MESSAGES=C; export LC_MESSAGES) 2>&1`") && { $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set; } || { LC_MESSAGES=C; export LC_MESSAGES; } # Name of the executable. as_me=`(basename "$0") 2>/dev/null || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conftest.sh echo "exit 0" >>conftest.sh chmod +x conftest.sh if (PATH=".;."; conftest.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conftest.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=$PATH_SEPARATOR; export CDPATH; } # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` exec 6>&1 # # Initializations. # ac_default_prefix=/usr/local cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. # This variable seems obsolete. It should probably be removed, and # only ac_max_sed_lines should be used. : ${ac_max_here_lines=38} # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= ac_default_prefix=/usr/local/towitoko # Factoring default headers for most tests. ac_includes_default="\ #include #if HAVE_SYS_TYPES_H # include #endif #if HAVE_SYS_STAT_H # include #endif #if STDC_HEADERS # include # include #else # if HAVE_STDLIB_H # include # endif #endif #if HAVE_STRING_H # if !STDC_HEADERS && HAVE_MEMORY_H # include # endif # include #endif #if HAVE_STRINGS_H # include #endif #if HAVE_INTTYPES_H # include #else # if HAVE_STDINT_H # include # endif #endif #if HAVE_UNISTD_H # include #endif" # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_option in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` eval "enable_$ac_feature=no" ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "enable_$ac_feature='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package| sed 's/-/_/g'` case $ac_option in *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; *) ac_optarg=yes ;; esac eval "with_$ac_package='$ac_optarg'" ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/-/_/g'` eval "with_$ac_package=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` eval "$ac_envvar='$ac_optarg'" export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute paths. for ac_var in exec_prefix prefix do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* | NONE | '' ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # Be sure to have absolute paths. for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ localstatedir libdir includedir oldincludedir infodir mandir do eval ac_val=$`echo $ac_var` case $ac_val in [\\/$]* | ?:[\\/]* ) ;; *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; };; esac done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_confdir=`(dirname "$0") 2>/dev/null || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 { (exit 1); exit 1; }; } else { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi fi srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` ac_env_build_alias_set=${build_alias+set} ac_env_build_alias_value=$build_alias ac_cv_env_build_alias_set=${build_alias+set} ac_cv_env_build_alias_value=$build_alias ac_env_host_alias_set=${host_alias+set} ac_env_host_alias_value=$host_alias ac_cv_env_host_alias_set=${host_alias+set} ac_cv_env_host_alias_value=$host_alias ac_env_target_alias_set=${target_alias+set} ac_env_target_alias_value=$target_alias ac_cv_env_target_alias_set=${target_alias+set} ac_cv_env_target_alias_value=$target_alias ac_env_CC_set=${CC+set} ac_env_CC_value=$CC ac_cv_env_CC_set=${CC+set} ac_cv_env_CC_value=$CC ac_env_CFLAGS_set=${CFLAGS+set} ac_env_CFLAGS_value=$CFLAGS ac_cv_env_CFLAGS_set=${CFLAGS+set} ac_cv_env_CFLAGS_value=$CFLAGS ac_env_LDFLAGS_set=${LDFLAGS+set} ac_env_LDFLAGS_value=$LDFLAGS ac_cv_env_LDFLAGS_set=${LDFLAGS+set} ac_cv_env_LDFLAGS_value=$LDFLAGS ac_env_CPPFLAGS_set=${CPPFLAGS+set} ac_env_CPPFLAGS_value=$CPPFLAGS ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} ac_cv_env_CPPFLAGS_value=$CPPFLAGS ac_env_CPP_set=${CPP+set} ac_env_CPP_value=$CPP ac_cv_env_CPP_set=${CPP+set} ac_cv_env_CPP_value=$CPP # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] _ACEOF cat <<_ACEOF Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data [PREFIX/share] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --infodir=DIR info documentation [PREFIX/info] --mandir=DIR man documentation [PREFIX/man] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-card-type(=sync|async) card type (default=probe) --enable-card-convention(=dir|inv) card convention (default=probe) --enable-memory-type(=i2cs|i2cl|2w|3w) memory card type (default=probe) --enable-memory-size(=size) memory card size (default=probe) --enable-ISO-t0 transportation of APDUs by T=0 (default=no) --enable-debug(=1|2|3|4) enable debug (default=no) --enable-usb-bundle enable PCSC Lite USB bundle installation (default=no) --enable-devfs enable Linux 2.4.X devfs support (default=no) --enable-devpcsc enable /dev/pcsc links support (default=no) --enable-win32-com enable win32 style COM port numbering (default=no) --enable-thread-mutex enable thread mutexes (default=yes) --enable-atr-check enable checking of valid ATR (default=yes) --enable-atr-timings enable decoding of timings from ATR (default=yes) --disable-dependency-tracking Speeds up one-time builds --enable-dependency-tracking Do not reject slow dependency extractors --enable-static=PKGS build static libraries default=no --enable-shared=PKGS build shared libraries default=yes --enable-fast-install=PKGS optimize for fast installation default=yes --disable-libtool-lock avoid locking (might break parallel builds) Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pcsc-lite-dir PCSC Lite base directory (default=/usr/local/pcsc) --with-gnu-ld assume the C compiler uses GNU ld default=no --with-pic try to use only PIC/non-PIC objects default=use both Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory 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. _ACEOF fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d $ac_dir || continue ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` cd $ac_dir # Check for guested configure; otherwise get Cygnus style configure. if test -f $ac_srcdir/configure.gnu; then echo $SHELL $ac_srcdir/configure.gnu --help=recursive elif test -f $ac_srcdir/configure; then echo $SHELL $ac_srcdir/configure --help=recursive elif test -f $ac_srcdir/configure.ac || test -f $ac_srcdir/configure.in; then echo $ac_configure --help else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi cd $ac_popdir done fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 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 0 fi exec 5>config.log cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.53. Invocation command line was $ $0 $@ _ACEOF { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` hostinfo = `(hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell meta-characters. ac_configure_args= ac_sep= for ac_arg do case $ac_arg in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n ) continue ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) continue ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" ac_sep=" " ;; esac # Get rid of the leading space. done # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Be sure not to use single quotes in there, as some shells, # such as our DU 5.0 friend, will then `close' the trap. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, { (set) 2>&1 | case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in *ac_space=\ *) sed -n \ "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" ;; *) sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } echo if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo sed "/^$/d" 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 && rm -rf conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo >confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . $cache_file;; *) . ./$cache_file;; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in `(set) 2>&1 | sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val="\$ac_cv_env_${ac_var}_value" eval ac_new_val="\$ac_env_${ac_var}_value" case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu am__api_version="1.6" ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f $ac_dir/shtool; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} { (exit 1); exit 1; }; } fi ac_config_guess="$SHELL $ac_aux_dir/config.guess" ac_config_sub="$SHELL $ac_aux_dir/config.sub" ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./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/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL=$ac_install_sh fi fi echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' 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 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 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 $as_executable_p "$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 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 dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\_ACEOF all: @echo 'ac_maketemp="${MAKE}"' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` if test -n "$ac_maketemp"; then eval ac_cv_prog_make_${ac_make}_set=yes else eval ac_cv_prog_make_${ac_make}_set=no fi rm -f conftest.make fi if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 SET_MAKE= else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 SET_MAKE="MAKE=${MAKE-make}" fi # test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && 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 # Define the identity of the package. PACKAGE=towitoko VERSION=2.0.7 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"} AMTAR=${AMTAR-"${am_missing_run}tar"} install_sh=${install_sh-"$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 $as_executable_p "$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 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 $as_executable_p "$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 test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" 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 STRIP=$ac_ct_STRIP else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Add the stamp file to the list of files AC keeps track of, # along with our hook. ac_config_headers="$ac_config_headers config.h" #---------------------------------------------------------------------------- # Options for setting fix card type / memory size #---------------------------------------------------------------------------- # Check whether --enable-card-type or --disable-card-type was given. if test "${enable_card_type+set}" = set; then enableval="$enable_card_type" fi; case "$enable_card_type" in sync) cat >>confdefs.h <<\_ACEOF #define ICC_TYPE_SYNC 1 _ACEOF ;; async) cat >>confdefs.h <<\_ACEOF #define ICC_TYPE_ASYNC 1 _ACEOF ;; esac # Check whether --enable-card-convention or --disable-card-convention was given. if test "${enable_card_convention+set}" = set; then enableval="$enable_card_convention" fi; case "$enable_card_convention" in dir) cat >>confdefs.h <<\_ACEOF #define IFD_TOWITOKO_CONVENTION_DIRECT 1 _ACEOF ;; inv) cat >>confdefs.h <<\_ACEOF #define IFD_TOWITOKO_CONVENTION_INVERSE 1 _ACEOF ;; esac # Check whether --enable-memory-type or --disable-memory-type was given. if test "${enable_memory_type+set}" = set; then enableval="$enable_memory_type" fi; case "$enable_memory_type" in i2cs) memory_type=0; ;; i2cl) memory_type=1; ;; 2w) memory_type=2; ;; 3w) memory_type=3; ;; esac if test "$memory_type" != "" ; then cat >>confdefs.h <<_ACEOF #define ICC_SYNC_MEMORY_TYPE $memory_type _ACEOF fi # Check whether --enable-memory-size or --disable-memory-size was given. if test "${enable_memory_size+set}" = set; then enableval="$enable_memory_size" fi; if test "$enable_memory_size" != ""; then cat >>confdefs.h <<_ACEOF #define ICC_SYNC_MEMORY_LENGTH $enable_memory_size _ACEOF fi # Check whether --enable-ISO-T0 or --disable-ISO-T0 was given. if test "${enable_ISO_T0+set}" = set; then enableval="$enable_ISO_T0" fi; if test "$enable_ISO_t0" = "true"; then cat >>confdefs.h <<_ACEOF #define PROTOCOL_T0_ISO 1 _ACEOF fi #---------------------------------------------------------------------------- # Debug level #---------------------------------------------------------------------------- # Check whether --enable-debug or --disable-debug was given. if test "${enable_debug+set}" = set; then enableval="$enable_debug" fi; if test "$enable_debug" = "yes"; then enable_debug=3 else if test "$enable_debug" = "no"; then enable_debug=0 fi fi if test "$enable_debug" != ""; then if test "$enable_debug" -lt "4"; then if test "$enable_debug" -gt "0"; then cat >>confdefs.h <<\_ACEOF #define DEBUG_CTAPI 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define DEBUG_PROTOCOL 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define DEBUG_ICC 1 _ACEOF fi if test "$enable_debug" -gt "1"; then cat >>confdefs.h <<\_ACEOF #define DEBUG_IFD 1 _ACEOF fi if test "$enable_debug" -gt "2"; then cat >>confdefs.h <<\_ACEOF #define DEBUG_IO 1 _ACEOF fi else cat >>confdefs.h <<\_ACEOF #define DEBUG_IFDH 1 _ACEOF fi fi #---------------------------------------------------------------------------- # Option to set PCSC Lite base directory #---------------------------------------------------------------------------- # Check whether --with-pcsc-lite-dir or --without-pcsc-lite-dir was given. if test "${with_pcsc_lite_dir+set}" = set; then withval="$with_pcsc_lite_dir" PCSC_LITE_DIR="$with_pcsc_lite_dir" else PCSC_LITE_DIR="/usr/local/pcsc" fi; #---------------------------------------------------------------------------- # Option to enable USB bundle installation #---------------------------------------------------------------------------- # Check whether --enable-usb-bundle or --disable-usb-bundle was given. if test "${enable_usb_bundle+set}" = set; then enableval="$enable_usb_bundle" fi; if test "$enable_usb_bundle" = "yes"; then INSTALL_USB_BUNDLE_TRUE= INSTALL_USB_BUNDLE_FALSE='#' else INSTALL_USB_BUNDLE_TRUE='#' INSTALL_USB_BUNDLE_FALSE= fi #---------------------------------------------------------------------------- # Option to enable devfs support #---------------------------------------------------------------------------- # Check whether --enable-devfs or --disable-devfs was given. if test "${enable_devfs+set}" = set; then enableval="$enable_devfs" fi; if test "$enable_devfs" = "yes"; then cat >>confdefs.h <<\_ACEOF #define IO_ENABLE_DEVFS 1 _ACEOF fi #---------------------------------------------------------------------------- # Option to enable /dev/pcsc/ links support #---------------------------------------------------------------------------- # Check whether --enable-devpcsc or --disable-devpcsc was given. if test "${enable_devpcsc+set}" = set; then enableval="$enable_devpcsc" fi; if test "$enable_devpcsc" = "yes"; then cat >>confdefs.h <<\_ACEOF #define IO_ENABLE_DEVPCSC 1 _ACEOF fi #---------------------------------------------------------------------------- # Option to enable win32 style COM port numbering #---------------------------------------------------------------------------- # Check whether --enable-win32-com or --disable-win32-com was given. if test "${enable_win32_com+set}" = set; then enableval="$enable_win32_com" fi; if test "$enable_win32_com" = "yes"; then cat >>confdefs.h <<\_ACEOF #define CTAPI_WIN32_COM 1 _ACEOF fi #---------------------------------------------------------------------------- # Option to disable multi-threading #---------------------------------------------------------------------------- # Check whether --enable-thread-mutex or --disable-thread-mutex was given. if test "${enable_thread_mutex+set}" = set; then enableval="$enable_thread_mutex" fi; #---------------------------------------------------------------------------- # Option for Atr cheking #---------------------------------------------------------------------------- # Check whether --enable-atr-check or --disable-atr-check was given. if test "${enable_atr_check+set}" = set; then enableval="$enable_atr_check" fi; if test "$enable_atr_check" = "" || test "$enable_atr_check" = "yes"; then cat >>confdefs.h <<\_ACEOF #define IFD_TOWITOKO_STRICT_ATR_CHECK 1 _ACEOF fi #---------------------------------------------------------------------------- # Option for Atr timings cheking #---------------------------------------------------------------------------- # Check whether --enable-atr-timings or --disable-atr-timings was given. if test "${enable_atr_timings+set}" = set; then enableval="$enable_atr_timings" fi; if test "$enable_atr_timings" = "no"; then cat >>confdefs.h <<\_ACEOF #define PROTOCOL_T0_USE_DEFAULT_TIMINGS 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define PROTOCOL_T1_USE_DEFAULT_TIMINGS 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define PTS_USE_DEFAULT_TIMINGS 1 _ACEOF fi #---------------------------------------------------------------------------- # Check environment #--------------------------------------------------------------------------- # Make sure we can run config.sub. $ac_config_sub sun4 >/dev/null 2>&1 || { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 echo "$as_me: error: cannot run $ac_config_sub" >&2;} { (exit 1); exit 1; }; } echo "$as_me:$LINENO: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6 if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_build_alias=$build_alias test -z "$ac_cv_build_alias" && ac_cv_build_alias=`$ac_config_guess` test -z "$ac_cv_build_alias" && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6 build=$ac_cv_build build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6 if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_host_alias=$host_alias test -z "$ac_cv_host_alias" && ac_cv_host_alias=$ac_cv_build_alias ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} { (exit 1); exit 1; }; } fi echo "$as_me:$LINENO: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6 host=$ac_cv_host host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` case $host in *linux*) cat >>confdefs.h <<\_ACEOF #define OS_LINUX 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define IO_ENABLE_USB 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define _REENTRANT 1 _ACEOF ;; *cygwin*) cat >>confdefs.h <<\_ACEOF #define OS_CYGWIN32 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define CTAPI_WIN32_COM 1 _ACEOF ;; *solaris*) cat >>confdefs.h <<\_ACEOF #define OS_SOLARIS 1 _ACEOF ;; *hp-hpux*) cat >>confdefs.h <<\_ACEOF #define OS_HPUX 1 _ACEOF ;; *sgi-irix*) cat >>confdefs.h <<\_ACEOF #define OS_IRIX 1 _ACEOF ;; *sco*) cat >>confdefs.h <<\_ACEOF #define OS_SCO 1 _ACEOF ;; *openbsd*) cat >>confdefs.h <<\_ACEOF #define OS_OPENBSD 1 _ACEOF ;; *freebsd*) cat >>confdefs.h <<\_ACEOF #define OS_FREEBSD 1 _ACEOF ;; *aix*) cat >>confdefs.h <<\_ACEOF #define OS_AIX 1 _ACEOF ;; *netbsd*) cat >>confdefs.h <<\_ACEOF #define OS_NETBSD 1 _ACEOF ;; *) cat >>confdefs.h <<\_ACEOF #define OS_OTHER 1 _ACEOF cat >>confdefs.h <<\_ACEOF #define IO_ENABLE_DEVPCSC 1 _ACEOF ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi CC=$ac_ct_CC else CC="$ac_cv_prog_CC" fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$as_dir/$ac_word" ${1+"$@"} shift ac_cv_prog_CC="$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -n "$ac_ct_CC" && break done CC=$ac_ct_CC fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH" >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH" >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO:" \ "checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 (eval $ac_compiler --version &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 (eval $ac_compiler -v &5) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&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 #line $LINENO "configure" #include "confdefs.h" #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe" # 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" >&5 echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 (eval $ac_link_default) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Find the output, starting from the most likely. This scheme is # not robust to junk in `.', hence go to wildcards (a.*) only as a last # resort. # Be careful to initialize this variable, since it used to be cached. # Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. ac_cv_exeext= for ac_file in `ls a_out.exe a.exe conftest.exe 2>/dev/null; ls a.out conftest 2>/dev/null; ls a.* conftest.* 2>/dev/null`; do case $ac_file in *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb | *.xSYM ) ;; a.out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` # FIXME: I believe we export ac_cv_exeext for Libtool --akim. export ac_cv_exeext break;; * ) break;; esac done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables" >&5 echo "$as_me: error: C compiler cannot create executables" >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6 # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'." >&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 ac_clean_files=$ac_clean_files_save # Check the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6 echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in `(ls conftest.exe; ls conftest; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.o | *.obj | *.xcoff | *.tds | *.d | *.pdb ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` export ac_cv_exeext break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link" >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link" >&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 #line $LINENO "configure" #include "confdefs.h" #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile" >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile" >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6 OBJEXT=$ac_cv_objext ac_objext=$OBJEXT echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS CFLAGS="-g" echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_g=no fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi # Some people use a C++ compiler to compile C. Since we use `exit', # in C++ we need to declare it. In case someone uses the same compiler # for both compiling C and C++ we need to have the C++ compiler decide # the declaration of exit, since it's the most demanding environment. cat >conftest.$ac_ext <<_ACEOF #ifndef __cplusplus choke me #endif _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then for ac_declaration in \ ''\ '#include ' \ 'extern "C" void std::exit (int) throw (); using std::exit;' \ 'extern "C" void std::exit (int); using std::exit;' \ 'extern "C" void exit (int) throw ();' \ 'extern "C" void exit (int);' \ 'void exit (int);' do cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #include $ac_declaration #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 continue fi rm -f conftest.$ac_objext conftest.$ac_ext cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" $ac_declaration #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { exit (42); ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then break else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext done rm -f conftest* if test -n "$ac_declaration"; then echo '#ifdef __cplusplus' >>confdefs.h echo $ac_declaration >>confdefs.h echo '#endif' >>confdefs.h fi else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu rm -f .deps 2>/dev/null mkdir .deps 2>/dev/null if test -d .deps; then DEPDIR=.deps else # MS-DOS does not allow filenames that begin with a dot. DEPDIR=_deps fi rmdir .deps 2>/dev/null ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' doit: @echo done 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 | fgrep -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 or --disable-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="$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 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 # 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. echo '#include "conftest.h"' > conftest.c echo 'int i;' > conftest.h echo "${am__include} ${am__quote}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=conftest.c object=conftest.o \ depfile=conftest.Po tmpdepfile=conftest.TPo \ $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && grep conftest.h conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then am_cv_CC_dependencies_compiler_type=$depmode break 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 # Check whether --enable-static or --disable-static was given. if test "${enable_static+set}" = set; then enableval="$enable_static" p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," for pkg in $enableval; do if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$ac_save_ifs" ;; esac else enable_static=no fi; # Check whether --enable-shared or --disable-shared was given. if test "${enable_shared+set}" = set; then enableval="$enable_shared" p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," for pkg in $enableval; do if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$ac_save_ifs" ;; esac else enable_shared=yes fi; # Check whether --enable-fast-install or --disable-fast-install was given. if test "${enable_fast_install+set}" = set; then enableval="$enable_fast_install" p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," for pkg in $enableval; do if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$ac_save_ifs" ;; esac else enable_fast_install=yes fi; # Find the correct PATH separator. Usually this is `:', but # DJGPP uses `;' like DOS. if test "X${PATH_SEPARATOR+set}" != Xset; then UNAME=${UNAME-`uname 2>/dev/null`} case X$UNAME in *-DOS) lt_cv_sys_path_separator=';' ;; *) lt_cv_sys_path_separator=':' ;; esac PATH_SEPARATOR=$lt_cv_sys_path_separator fi # Check whether --with-gnu-ld or --without-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then withval="$with_gnu_ld" test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi; ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo "$as_me:$LINENO: checking for ld used by GCC" >&5 echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6 case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | [A-Za-z]:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then echo "$as_me:$LINENO: checking for GNU ld" >&5 echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 else echo "$as_me:$LINENO: checking for non-GNU ld" >&5 echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 fi if test "${lt_cv_path_LD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -z "$LD"; then IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some GNU ld's only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. if "$lt_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then test "$with_gnu_ld" != no && break else test "$with_gnu_ld" != yes && break fi fi done IFS="$ac_save_ifs" else lt_cv_path_LD="$LD" # Let the user override the test with a path. fi fi LD="$lt_cv_path_LD" if test -n "$LD"; then echo "$as_me:$LINENO: result: $LD" >&5 echo "${ECHO_T}$LD" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} { (exit 1); exit 1; }; } echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 if test "${lt_cv_prog_gnu_ld+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # I'd rather use --version here, but apparently some GNU ld's only accept -v. if $LD -v 2>&1 &5; then lt_cv_prog_gnu_ld=yes else lt_cv_prog_gnu_ld=no fi fi echo "$as_me:$LINENO: result: $lt_cv_prog_gnu_ld" >&5 echo "${ECHO_T}$lt_cv_prog_gnu_ld" >&6 with_gnu_ld=$lt_cv_prog_gnu_ld echo "$as_me:$LINENO: checking for $LD option to reload object files" >&5 echo $ECHO_N "checking for $LD option to reload object files... $ECHO_C" >&6 if test "${lt_cv_ld_reload_flag+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_ld_reload_flag='-r' fi echo "$as_me:$LINENO: result: $lt_cv_ld_reload_flag" >&5 echo "${ECHO_T}$lt_cv_ld_reload_flag" >&6 reload_flag=$lt_cv_ld_reload_flag test -n "$reload_flag" && reload_flag=" $reload_flag" echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 if test "${lt_cv_path_NM+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do test -z "$ac_dir" && ac_dir=. tmp_nm=$ac_dir/${ac_tool_prefix}nm if test -f $tmp_nm || test -f $tmp_nm$ac_exeext ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file if ($tmp_nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep '(/dev/null|Invalid file or object type)' >/dev/null; then lt_cv_path_NM="$tmp_nm -B" break elif ($tmp_nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then lt_cv_path_NM="$tmp_nm -p" break else lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags fi fi done IFS="$ac_save_ifs" test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm fi fi NM="$lt_cv_path_NM" echo "$as_me:$LINENO: result: $NM" >&5 echo "${ECHO_T}$NM" >&6 echo "$as_me:$LINENO: checking for a sed that does not truncate output" >&5 echo $ECHO_N "checking for a sed that does not truncate output... $ECHO_C" >&6 if test "${lt_cv_path_SED+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_executable_p="test -f" as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then _sed_list="$_sed_list $as_dir/$ac_prog$ac_exec_ext" fi done done done # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. : ${TMPDIR=/tmp} { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/sedXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=$TMPDIR/sed$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 { (exit 1); exit 1; } } _max=0 _count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for _sed in $_sed_list /usr/xpg4/bin/sed; do test ! -f ${_sed} && break cat /dev/null > "$tmp/sed.in" _count=0 echo ${ECHO_N-$ac_n} "0123456789${ECHO_C-$ac_c}" >"$tmp/sed.in" # Check for GNU sed and select it if it is found. if "${_sed}" --version 2>&1 < /dev/null | egrep '(GNU)' > /dev/null; then lt_cv_path_SED=${_sed} break; fi while true; do cat "$tmp/sed.in" "$tmp/sed.in" >"$tmp/sed.tmp" mv "$tmp/sed.tmp" "$tmp/sed.in" cp "$tmp/sed.in" "$tmp/sed.nl" echo >>"$tmp/sed.nl" ${_sed} -e 's/a$//' < "$tmp/sed.nl" >"$tmp/sed.out" || break cmp -s "$tmp/sed.out" "$tmp/sed.nl" || break # 40000 chars as input seems more than enough test $_count -gt 10 && break _count=`expr $_count + 1` if test $_count -gt $_max; then _max=$_count lt_cv_path_SED=$_sed fi done done rm -rf "$tmp" fi if test "X$SED" != "X"; then lt_cv_path_SED=$SED else SED=$lt_cv_path_SED fi echo "$as_me:$LINENO: result: $SED" >&5 echo "${ECHO_T}$SED" >&6 echo "$as_me:$LINENO: checking whether ln -s works" >&5 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 else echo "$as_me:$LINENO: result: no, using $LN_S" >&5 echo "${ECHO_T}no, using $LN_S" >&6 fi echo "$as_me:$LINENO: checking how to recognise dependent libraries" >&5 echo $ECHO_N "checking how to recognise dependent libraries... $ECHO_C" >&6 if test "${lt_cv_deplibs_check_method+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given egrep regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix4* | aix5*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi4*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin* | mingw* | pw32*) lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method='file_magic Mach-O dynamically linked shared library' lt_cv_file_magic_cmd='/usr/bin/file -L' case "$host_os" in rhapsody* | darwin1.[012]) lt_cv_file_magic_test_file=`echo /System/Library/Frameworks/System.framework/Versions/*/System | head -1` ;; *) # Darwin 1.3 on lt_cv_file_magic_test_file='/usr/lib/libSystem.dylib' ;; esac ;; freebsd*) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20*|hpux11*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; irix5* | irix6* | nonstopux*) case $host_os in irix5* | nonstopux*) # this will be overridden with pass_all, but let us keep it just in case lt_cv_deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" ;; *) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac # this will be overridden with pass_all, but let us keep it just in case lt_cv_deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1" ;; esac lt_cv_file_magic_test_file=`echo /lib${libsuff}/libc.so*` lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux-gnu*) case $host_cpu in alpha* | hppa* | i*86 | mips | mipsel | powerpc* | sparc* | ia64*) lt_cv_deplibs_check_method=pass_all ;; *) # glibc up to 2.1.1 does not perform some relocations on ARM lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; esac lt_cv_file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so\.[0-9]+\.[0-9]+$' else lt_cv_deplibs_check_method='match_pattern /lib[^/\.]+\.so$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; openbsd*) lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB shared object' else lt_cv_deplibs_check_method='file_magic OpenBSD.* shared library' fi ;; osf3* | osf4* | osf5*) # this will be overridden with pass_all, but let us keep it just in case lt_cv_deplibs_check_method='file_magic COFF format alpha shared library' lt_cv_file_magic_test_file=/shlib/libc.so lt_cv_deplibs_check_method=pass_all ;; sco3.2v5*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all lt_cv_file_magic_test_file=/lib/libc.so ;; sysv5uw[78]* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; esac ;; esac fi echo "$as_me:$LINENO: result: $lt_cv_deplibs_check_method" >&5 echo "${ECHO_T}$lt_cv_deplibs_check_method" >&6 file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method # Check for command to grab the raw symbol name followed by C symbol from nm. echo "$as_me:$LINENO: checking command to parse $NM output" >&5 echo $ECHO_N "checking command to parse $NM output... $ECHO_C" >&6 if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Transform the above into a raw symbol and a C symbol. symxfrm='\1 \2\3 \3' # Transform an extracted symbol line into a proper C declaration lt_cv_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32*) symcode='[ABCDGISTW]' ;; hpux*) # Its linker distinguishes data from code symbols lt_cv_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" lt_cv_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (lt_ptr) \&\2},/p'" ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; solaris* | sysv5*) symcode='[BDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # Handle CRLF in mingw tool chain opt_cr= case $host_os in mingw*) opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # If we're using GNU nm, then use its standard symbol codes. if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then symcode='[ABCDGISTW]' fi # Try without a prefix undercore, then with it. for ac_symprfx in "" "_"; do # Write the raw and C identifiers. lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*\($ac_symprfx\)$sympat$opt_cr$/$symxfrm/p'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Now try to grab the symbols. nlist=conftest.nm if { (eval echo "$as_me:$LINENO: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\"") >&5 (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if egrep ' nm_test_var$' "$nlist" >/dev/null; then if egrep ' nm_test_func$' "$nlist" >/dev/null; then cat < conftest.$ac_ext #ifdef __cplusplus extern "C" { #endif EOF # Now generate the symbol file. eval "$lt_cv_global_symbol_to_cdecl"' < "$nlist" >> conftest.$ac_ext' cat <> conftest.$ac_ext #if defined (__STDC__) && __STDC__ # define lt_ptr void * #else # define lt_ptr char * # define const #endif /* The mapping between symbol names and symbols. */ const struct { const char *name; lt_ptr address; } lt_preloaded_symbols[] = { EOF sed "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (lt_ptr) \&\2},/" < "$nlist" >> conftest.$ac_ext cat <<\EOF >> conftest.$ac_ext {0, (lt_ptr) 0} }; #ifdef __cplusplus } #endif EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$no_builtin_flag" if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest; then pipe_works=yes fi LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi global_symbol_pipe="$lt_cv_sys_global_symbol_pipe" if test -z "$lt_cv_sys_global_symbol_pipe"; then global_symbol_to_cdecl= global_symbol_to_c_name_address= else global_symbol_to_cdecl="$lt_cv_global_symbol_to_cdecl" global_symbol_to_c_name_address="$lt_cv_global_symbol_to_c_name_address" fi if test -z "$global_symbol_pipe$global_symbol_to_cdec$global_symbol_to_c_name_address"; then echo "$as_me:$LINENO: result: failed" >&5 echo "${ECHO_T}failed" >&6 else echo "$as_me:$LINENO: result: ok" >&5 echo "${ECHO_T}ok" >&6 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 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. # 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 #line $LINENO "configure" #include "confdefs.h" #include Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 cat 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. # 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 #line $LINENO "configure" #include "confdefs.h" #include Syntax error _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then : else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether non-existent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 cat 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" >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check" >&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 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 #line $LINENO "configure" #include "confdefs.h" #include #include #include #include _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f conftest.err 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 #line $LINENO "configure" #include "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 #line $LINENO "configure" #include "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 #line $LINENO "configure" #include "confdefs.h" #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)) exit(2); exit (0); } _ACEOF rm -f conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core core.* *.core conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6 if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f conftest.$ac_objext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f 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 #line $LINENO "configure" #include "confdefs.h" #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 cat 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 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 preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; 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: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done # Only perform the check for file, if the check method requires it case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then echo "$as_me:$LINENO: checking for ${ac_tool_prefix}file" >&5 echo $ECHO_N "checking for ${ac_tool_prefix}file... $ECHO_C" >&6 if test "${lt_cv_path_MAGIC_CMD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $MAGIC_CMD in /*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; ?:/*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. ;; *) ac_save_MAGIC_CMD="$MAGIC_CMD" IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="/usr/bin:$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | egrep "$file_magic_regex" > /dev/null; then : else cat <&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org EOF fi ;; esac fi break fi done IFS="$ac_save_ifs" MAGIC_CMD="$ac_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 echo "${ECHO_T}$MAGIC_CMD" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then echo "$as_me:$LINENO: checking for file" >&5 echo $ECHO_N "checking for file... $ECHO_C" >&6 if test "${lt_cv_path_MAGIC_CMD+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $MAGIC_CMD in /*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; ?:/*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a dos path. ;; *) ac_save_MAGIC_CMD="$MAGIC_CMD" IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="/usr/bin:$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | egrep "$file_magic_regex" > /dev/null; then : else cat <&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org EOF fi ;; esac fi break fi done IFS="$ac_save_ifs" MAGIC_CMD="$ac_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then echo "$as_me:$LINENO: result: $MAGIC_CMD" >&5 echo "${ECHO_T}$MAGIC_CMD" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi else MAGIC_CMD=: fi fi fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 if test "${ac_cv_prog_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then echo "$as_me:$LINENO: result: $RANLIB" >&5 echo "${ECHO_T}$RANLIB" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 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_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 echo "${ECHO_T}$ac_ct_RANLIB" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi RANLIB=$ac_ct_RANLIB else RANLIB="$ac_cv_prog_RANLIB" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 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 $as_executable_p "$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 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 $as_executable_p "$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 test -z "$ac_cv_prog_ac_ct_STRIP" && ac_cv_prog_ac_ct_STRIP=":" 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 STRIP=$ac_ct_STRIP else STRIP="$ac_cv_prog_STRIP" fi enable_dlopen=no enable_win32_dll=no # Check whether --enable-libtool-lock or --disable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then enableval="$enable_libtool_lock" fi; test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in *-*-irix6*) # Find out which ABI we are using. echo '#line 4692 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 if test "${lt_cv_cc_needs_belf+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then lt_cv_cc_needs_belf=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 lt_cv_cc_needs_belf=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; esac # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed='sed -e s/^X//' sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Constants: rm="rm -f" # Global variables: default_ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except M$VC, # which needs '.lib'). libext=a ltmain="$ac_aux_dir/ltmain.sh" ofile="$default_ofile" with_gnu_ld="$lt_cv_prog_gnu_ld" need_locks="$enable_libtool_lock" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$AR" && AR=ar test -z "$AR_FLAGS" && AR_FLAGS=cru test -z "$AS" && AS=as test -z "$CC" && CC=cc test -z "$DLLTOOL" && DLLTOOL=dlltool test -z "$LD" && LD=ld test -z "$LN_S" && LN_S="ln -s" test -z "$MAGIC_CMD" && MAGIC_CMD=file test -z "$NM" && NM=nm test -z "$OBJDUMP" && OBJDUMP=objdump test -z "$RANLIB" && RANLIB=: test -z "$STRIP" && STRIP=: test -z "$ac_objext" && ac_objext=o if test x"$host" != x"$build"; then ac_tool_prefix=${host_alias}- else ac_tool_prefix= fi # Transform linux* to *-*-linux-gnu*, to support old configure scripts. case $host_os in linux-gnu*) ;; linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'` esac case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds" ;; *) old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi # Allow CC to be a program name with arguments. set dummy $CC compiler="$2" echo "$as_me:$LINENO: checking for objdir" >&5 echo $ECHO_N "checking for objdir... $ECHO_C" >&6 rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. objdir=_libs fi rmdir .libs 2>/dev/null echo "$as_me:$LINENO: result: $objdir" >&5 echo "${ECHO_T}$objdir" >&6 # Check whether --with-pic or --without-pic was given. if test "${with_pic+set}" = set; then withval="$with_pic" pic_mode="$withval" else pic_mode=default fi; test -z "$pic_mode" && pic_mode=default # We assume here that the value for lt_cv_prog_cc_pic will not be cached # in isolation, and that seeing it set (from the cache) indicates that # the associated values are set (in the cache) correctly too. echo "$as_me:$LINENO: checking for $compiler option to produce PIC" >&5 echo $ECHO_N "checking for $compiler option to produce PIC... $ECHO_C" >&6 if test "${lt_cv_prog_cc_pic+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_cc_pic= lt_cv_prog_cc_shlib= lt_cv_prog_cc_wl= lt_cv_prog_cc_static= lt_cv_prog_cc_no_builtin= lt_cv_prog_cc_can_build_shared=$can_build_shared if test "$GCC" = yes; then lt_cv_prog_cc_wl='-Wl,' lt_cv_prog_cc_static='-static' case $host_os in aix*) # Below there is a dirty hack to force normal static linking with -ldl # The problem is because libdl dynamically linked with both libc and # libC (AIX C++ library), which obviously doesn't included in libraries # list by gcc. This cause undefined symbols with -static flags. # This hack allows C programs to be linked with "-static -ldl", but # not sure about C++ programs. lt_cv_prog_cc_static="$lt_cv_prog_cc_static ${lt_cv_prog_cc_wl}-lC" ;; amigaos*) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_cv_prog_cc_pic='-fno-common' ;; cygwin* | mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_cv_prog_cc_pic='-DDLL_EXPORT' ;; sysv4*MP*) if test -d /usr/nec; then lt_cv_prog_cc_pic=-Kconform_pic fi ;; *) lt_cv_prog_cc_pic='-fPIC' ;; esac else # PORTME Check for PIC flags for the system compiler. case $host_os in aix3* | aix4* | aix5*) lt_cv_prog_cc_wl='-Wl,' # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_cv_prog_cc_static='-Bstatic' else lt_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' fi ;; hpux9* | hpux10* | hpux11*) # Is there a better lt_cv_prog_cc_static that works with the bundled CC? lt_cv_prog_cc_wl='-Wl,' lt_cv_prog_cc_static="${lt_cv_prog_cc_wl}-a ${lt_cv_prog_cc_wl}archive" lt_cv_prog_cc_pic='+Z' ;; irix5* | irix6* | nonstopux*) lt_cv_prog_cc_wl='-Wl,' lt_cv_prog_cc_static='-non_shared' # PIC (with -KPIC) is the default. ;; cygwin* | mingw* | pw32* | os2*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_cv_prog_cc_pic='-DDLL_EXPORT' ;; newsos6) lt_cv_prog_cc_pic='-KPIC' lt_cv_prog_cc_static='-Bstatic' ;; osf3* | osf4* | osf5*) # All OSF/1 code is PIC. lt_cv_prog_cc_wl='-Wl,' lt_cv_prog_cc_static='-non_shared' ;; sco3.2v5*) lt_cv_prog_cc_pic='-Kpic' lt_cv_prog_cc_static='-dn' lt_cv_prog_cc_shlib='-belf' ;; solaris*) lt_cv_prog_cc_pic='-KPIC' lt_cv_prog_cc_static='-Bstatic' lt_cv_prog_cc_wl='-Wl,' ;; sunos4*) lt_cv_prog_cc_pic='-PIC' lt_cv_prog_cc_static='-Bstatic' lt_cv_prog_cc_wl='-Qoption ld ' ;; sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) lt_cv_prog_cc_pic='-KPIC' lt_cv_prog_cc_static='-Bstatic' lt_cv_prog_cc_wl='-Wl,' ;; uts4*) lt_cv_prog_cc_pic='-pic' lt_cv_prog_cc_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_cv_prog_cc_pic='-Kconform_pic' lt_cv_prog_cc_static='-Bstatic' fi ;; *) lt_cv_prog_cc_can_build_shared=no ;; esac fi fi if test -z "$lt_cv_prog_cc_pic"; then echo "$as_me:$LINENO: result: none" >&5 echo "${ECHO_T}none" >&6 else echo "$as_me:$LINENO: result: $lt_cv_prog_cc_pic" >&5 echo "${ECHO_T}$lt_cv_prog_cc_pic" >&6 # Check to make sure the pic_flag actually works. echo "$as_me:$LINENO: checking if $compiler PIC flag $lt_cv_prog_cc_pic works" >&5 echo $ECHO_N "checking if $compiler PIC flag $lt_cv_prog_cc_pic works... $ECHO_C" >&6 if test "${lt_cv_prog_cc_pic_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $lt_cv_prog_cc_pic -DPIC" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then case $host_os in hpux9* | hpux10* | hpux11*) # On HP-UX, both CC and GCC only warn that PIC is supported... then # they create non-PIC objects. So, if there were any warnings, we # assume that PIC is not supported. if test -s conftest.err; then lt_cv_prog_cc_pic_works=no else lt_cv_prog_cc_pic_works=yes fi ;; *) lt_cv_prog_cc_pic_works=yes ;; esac else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 lt_cv_prog_cc_pic_works=no fi rm -f conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" fi if test "X$lt_cv_prog_cc_pic_works" = Xno; then lt_cv_prog_cc_pic= lt_cv_prog_cc_can_build_shared=no else lt_cv_prog_cc_pic=" $lt_cv_prog_cc_pic" fi echo "$as_me:$LINENO: result: $lt_cv_prog_cc_pic_works" >&5 echo "${ECHO_T}$lt_cv_prog_cc_pic_works" >&6 fi # Check for any special shared library compilation flags. if test -n "$lt_cv_prog_cc_shlib"; then { echo "$as_me:$LINENO: WARNING: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" >&5 echo "$as_me: WARNING: \`$CC' requires \`$lt_cv_prog_cc_shlib' to build shared libraries" >&2;} if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$lt_cv_prog_cc_shlib[ ]" >/dev/null; then : else { echo "$as_me:$LINENO: WARNING: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5 echo "$as_me: WARNING: add \`$lt_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;} lt_cv_prog_cc_can_build_shared=no fi fi echo "$as_me:$LINENO: checking if $compiler static flag $lt_cv_prog_cc_static works" >&5 echo $ECHO_N "checking if $compiler static flag $lt_cv_prog_cc_static works... $ECHO_C" >&6 if test "${lt_cv_prog_cc_static_works+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_prog_cc_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_cv_prog_cc_static" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then lt_cv_prog_cc_static_works=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi # Belt *and* braces to stop my trousers falling down: test "X$lt_cv_prog_cc_static_works" = Xno && lt_cv_prog_cc_static= echo "$as_me:$LINENO: result: $lt_cv_prog_cc_static_works" >&5 echo "${ECHO_T}$lt_cv_prog_cc_static_works" >&6 pic_flag="$lt_cv_prog_cc_pic" special_shlib_compile_flags="$lt_cv_prog_cc_shlib" wl="$lt_cv_prog_cc_wl" link_static_flag="$lt_cv_prog_cc_static" no_builtin_flag="$lt_cv_prog_cc_no_builtin" can_build_shared="$lt_cv_prog_cc_can_build_shared" # Check to see if options -o and -c are simultaneously supported by compiler echo "$as_me:$LINENO: checking if $compiler supports -c -o file.$ac_objext" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.$ac_objext... $ECHO_C" >&6 if test "${lt_cv_compiler_c_o+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else $rm -r conftest 2>/dev/null mkdir conftest cd conftest echo "int some_variable = 0;" > conftest.$ac_ext mkdir out # According to Tom Tromey, Ian Lance Taylor reported there are C compilers # that will create temporary files in the current directory regardless of # the output directory. Thus, making CWD read-only will cause this test # to fail, enabling locking or at least warning the user not to do parallel # builds. chmod -w . save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -o out/conftest2.$ac_objext" compiler_c_o=no if { (eval echo configure:5224: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.$ac_objext; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s out/conftest.err; then lt_cv_compiler_c_o=no else lt_cv_compiler_c_o=yes fi else # Append any errors to the config.log. cat out/conftest.err 1>&5 lt_cv_compiler_c_o=no fi CFLAGS="$save_CFLAGS" chmod u+w . $rm conftest* out/* rmdir out cd .. rmdir conftest $rm -r conftest 2>/dev/null fi compiler_c_o=$lt_cv_compiler_c_o echo "$as_me:$LINENO: result: $compiler_c_o" >&5 echo "${ECHO_T}$compiler_c_o" >&6 if test x"$compiler_c_o" = x"yes"; then # Check to see if we can write to a .lo echo "$as_me:$LINENO: checking if $compiler supports -c -o file.lo" >&5 echo $ECHO_N "checking if $compiler supports -c -o file.lo... $ECHO_C" >&6 if test "${lt_cv_compiler_o_lo+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else lt_cv_compiler_o_lo=no save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -c -o conftest.lo" save_objext="$ac_objext" ac_objext=lo cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { int some_variable = 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then lt_cv_compiler_o_lo=no else lt_cv_compiler_o_lo=yes fi else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext ac_objext="$save_objext" CFLAGS="$save_CFLAGS" fi compiler_o_lo=$lt_cv_compiler_o_lo echo "$as_me:$LINENO: result: $compiler_o_lo" >&5 echo "${ECHO_T}$compiler_o_lo" >&6 else compiler_o_lo=no fi # Check to see if we can do hard links to lock some files if needed hard_links="nottested" if test "$compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user echo "$as_me:$LINENO: checking if we can lock with hard links" >&5 echo $ECHO_N "checking if we can lock with hard links... $ECHO_C" >&6 hard_links=yes $rm conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no echo "$as_me:$LINENO: result: $hard_links" >&5 echo "${ECHO_T}$hard_links" >&6 if test "$hard_links" = no; then { echo "$as_me:$LINENO: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi if test "$GCC" = yes; then # Check to see if options -fno-rtti -fno-exceptions are supported by compiler echo "$as_me:$LINENO: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 echo $ECHO_N "checking if $compiler supports -fno-rtti -fno-exceptions... $ECHO_C" >&6 echo "int some_variable = 0;" > conftest.$ac_ext save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.$ac_ext" compiler_rtti_exceptions=no cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { int some_variable = 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then compiler_rtti_exceptions=no else compiler_rtti_exceptions=yes fi else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest.$ac_ext CFLAGS="$save_CFLAGS" echo "$as_me:$LINENO: result: $compiler_rtti_exceptions" >&5 echo "${ECHO_T}$compiler_rtti_exceptions" >&6 if test "$compiler_rtti_exceptions" = "yes"; then no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' else no_builtin_flag=' -fno-builtin' fi fi # See if the linker supports building shared libraries. echo "$as_me:$LINENO: checking whether the linker ($LD) supports shared libraries" >&5 echo $ECHO_N "checking whether the linker ($LD) supports shared libraries... $ECHO_C" >&6 allow_undefined_flag= no_undefined_flag= need_lib_prefix=unknown need_version=unknown # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments archive_cmds= archive_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= export_dynamic_flag_spec= whole_archive_flag_spec= thread_safe_flag_spec= hardcode_into_libs=no hardcode_libdir_flag_spec= hardcode_libdir_separator= hardcode_direct=no hardcode_minus_L=no hardcode_shlibpath_var=unsupported runpath_var= link_all_deplibs=unknown always_export_symbols=no export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols' # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list include_expsyms= # exclude_expsyms can be an egrep regular expression of symbols to exclude # it will be wrapped by ` (' and `)$', so one must not match beginning or # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc', # as well as any symbol that contains `d'. exclude_expsyms="_GLOBAL_OFFSET_TABLE_" # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out # platforms (ab)use it in PIC code, but their linkers get confused if # the symbol is explicitly referenced. Since portable code cannot # rely on this symbol name, it's probably fine to never include it in # preloaded symbol tables. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; openbsd*) with_gnu_ld=no ;; esac ld_shlibs=yes if test "$with_gnu_ld" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # See if GNU ld supports shared libraries. case $host_os in aix3* | aix4* | aix5*) # On AIX, the GNU linker is very broken # Note:Check GNU linker on AIX 5-IA64 when/if it becomes available. ld_shlibs=no cat <&2 *** Warning: the GNU linker, at least up to release 2.9.1, is reported *** to be unable to reliably create shared libraries on AIX. *** Therefore, libtool is disabling shared libraries support. If you *** really care for shared libraries, you may want to modify your PATH *** so that a non-GNU linker is found, and then restart. EOF ;; amigaos*) archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes # Samuel A. Falvo II reports # that the semantics of dynamic libraries on AmigaOS, at least up # to version 4, is to share data among multiple programs linked # with the same dynamic library. Since this doesn't match the # behavior of shared libraries on other platforms, we can use # them. ld_shlibs=no ;; beos*) if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32*) # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' allow_undefined_flag=unsupported always_export_symbols=yes extract_expsyms_cmds='test -f $output_objdir/impgen.c || \ sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //;s/^# *$//; p; }" -e d < $''0 > $output_objdir/impgen.c~ test -f $output_objdir/impgen.exe || (cd $output_objdir && \ if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ else $CC -o impgen impgen.c ; fi)~ $output_objdir/impgen $dir/$soroot > $output_objdir/$soname-def' old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $output_objdir/$soname-def --output-lib $output_objdir/$newlib' # cygwin and mingw dlls have different entry points and sets of symbols # to exclude. # FIXME: what about values for MSVC? dll_entry=__cygwin_dll_entry@12 dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12~ case $host_os in mingw*) # mingw values dll_entry=_DllMainCRTStartup@12 dll_exclude_symbols=DllMain@12,DllMainCRTStartup@12,DllEntryPoint@12~ ;; esac # mingw and cygwin differ, and it's simplest to just exclude the union # of the two symbol sets. dll_exclude_symbols=DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12,DllMainCRTStartup@12,DllEntryPoint@12 # recent cygwin and mingw systems supply a stub DllMain which the user # can override, but on older systems we have to supply one (in ltdll.c) if test "x$lt_cv_need_dllmain" = "xyes"; then ltdll_obj='$output_objdir/$soname-ltdll.'"$ac_objext " ltdll_cmds='test -f $output_objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $''0 > $output_objdir/$soname-ltdll.c~ test -f $output_objdir/$soname-ltdll.$ac_objext || (cd $output_objdir && $CC -c $soname-ltdll.c)~' else ltdll_obj= ltdll_cmds= fi # Extract the symbol export list from an `--export-all' def file, # then regenerate the def file from the symbol export list, so that # the compiled dll only exports the symbol export list. # Be careful not to strip the DATA tag left be newer dlltools. export_symbols_cmds="$ltdll_cmds"' $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $output_objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $output_objdir/$soname-def > $export_symbols' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is. # If DATA tags from a recent dlltool are present, honour them! archive_expsym_cmds='if test "x`sed 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname-def; else echo EXPORTS > $output_objdir/$soname-def; _lt_hint=1; cat $export_symbols | while read symbol; do set dummy \$symbol; case \$# in 2) echo " \$2 @ \$_lt_hint ; " >> $output_objdir/$soname-def;; 4) echo " \$2 \$3 \$4 ; " >> $output_objdir/$soname-def; _lt_hint=`expr \$_lt_hint - 1`;; *) echo " \$2 @ \$_lt_hint \$3 ; " >> $output_objdir/$soname-def;; esac; _lt_hint=`expr 1 + \$_lt_hint`; done; fi~ '"$ltdll_cmds"' $CC -Wl,--base-file,$output_objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp~ $CC -Wl,--base-file,$output_objdir/$soname-base $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags~ $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $output_objdir/$soname-def --base-file $output_objdir/$soname-base --output-exp $output_objdir/$soname-exp --output-lib $output_objdir/$libname.dll.a~ $CC $output_objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $output_objdir/$soname '$ltdll_obj'$libobjs $deplibs $compiler_flags' ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared -nodefaultlibs $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris* | sysv5*) if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <&2 *** Warning: The releases 2.8.* of the GNU linker cannot reliably *** create shared libraries on Solaris systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.9.1 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. EOF elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sunos4*) archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= hardcode_direct=yes hardcode_shlibpath_var=no ;; *) if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; esac if test "$ld_shlibs" = yes; then runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' case $host_os in cygwin* | mingw* | pw32*) # dlltool doesn't understand --whole-archive et. al. whole_archive_flag_spec= ;; *) # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi ;; esac fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$link_static_flag"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix4* | aix5*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix5*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. hardcode_direct=yes archive_cmds='' hardcode_libdir_separator=':' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && \ strings "$collect2name" | grep resolve_lib_name >/dev/null then # We have reworked collect2 hardcode_direct=yes else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi esac shared_flag='-shared' else # not using gcc if test "$host_cpu" = ia64; then shared_flag='${wl}-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi # It seems that -bexpall can do strange things, so it is better to # generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:/usr/lib:/lib' archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname ${wl}-h$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols" else hardcode_libdir_flag_spec='${wl}-bnolibpath ${wl}-blibpath:$libdir:/usr/lib:/lib' # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. allow_undefined_flag='${wl}-berok' # This is a bit strange, but is similar to how AIX traditionally builds # it's shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"' ~$AR -crlo $objdir/$libname$release.a $objdir/$soname' fi fi ;; amigaos*) archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes # see comment about different semantics on the GNU ld section ld_shlibs=no ;; cygwin* | mingw* | pw32*) # When not using gcc, we currently assume that we are using # Microsoft Visual C++. # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs' fix_srcfile_path='`cygpath -w "$srcfile"`' ;; darwin* | rhapsody*) case "$host_os" in rhapsody* | darwin1.[012]) allow_undefined_flag='-undefined suppress' ;; *) # Darwin 1.3 on allow_undefined_flag='-flat_namespace -undefined suppress' ;; esac # FIXME: Relying on posixy $() will cause problems for # cross-compilation, but unfortunately the echo tests do not # yet detect zsh echo's removal of \ escapes. Also zsh mangles # `"' quotes if we put them in here... so don't! archive_cmds='$nonopt $(test .$module = .yes && echo -bundle || echo -dynamiclib) $allow_undefined_flag -o $lib $libobjs $deplibs$linker_flags -install_name $rpath/$soname $verstring' # We need to add '_' to the symbols in $export_symbols first #archive_expsym_cmds="$archive_cmds"' && strip -s $export_symbols' hardcode_direct=yes hardcode_shlibpath_var=no whole_archive_flag_spec='-all_load $convenience' ;; freebsd1*) ld_shlibs=no ;; # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor # support. Future versions do this automatically, but an explicit c++rt0.o # does not break anything, and helps significantly (at the cost of a little # extra space). freebsd2.2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd*) archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9* | hpux10* | hpux11*) case $host_os in hpux9*) archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' ;; *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' ;; esac hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_minus_L=yes # Not in the search PATH, but as the default # location of the library. export_dynamic_flag_spec='${wl}-E' ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' fi hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: link_all_deplibs=yes ;; netbsd*) if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; openbsd*) hardcode_direct=yes hardcode_shlibpath_var=no if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case "$host_os" in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' fi hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "-exported_symbol " >> $lib.exp; echo "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~ $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib~$rm $lib.exp' #Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi hardcode_libdir_separator=: ;; sco3.2v5*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes export_dynamic_flag_spec='${wl}-Bexport' ;; solaris*) # gcc --version < 3.0 without binutils cannot create self contained # shared libraries reliably, requiring libgcc.a to resolve some of # the object symbols generated in some cases. Libraries that use # assert need libgcc.a to resolve __eprintf, for example. Linking # a copy of libgcc.a into every shared library to guarantee resolving # such symbols causes other problems: According to Tim Van Holder # , C++ libraries end up with a separate # (to the application) exception stack for one thing. no_undefined_flag=' -z defs' if test "$GCC" = yes; then case `$CC --version 2>/dev/null` in [12].*) cat <&2 *** Warning: Releases of GCC earlier than version 3.0 cannot reliably *** create self contained shared libraries on Solaris systems, without *** introducing a dependency on libgcc.a. Therefore, libtool is disabling *** -no-undefined support, which will at least allow you to build shared *** libraries. However, you may find that when you link such libraries *** into an application without using GCC, you have to manually add *** \`gcc --print-libgcc-file-name\` to the link command. We urge you to *** upgrade to a newer version of GCC. Another option is to rebuild your *** current GCC to use the GNU linker from GNU binutils 2.9.1 or newer. EOF no_undefined_flag= ;; esac fi # $CC -shared without GNU ld will not create a library from C++ # object files and a static libstdc++, better avoid it by now archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # Supported since Solaris 2.6 (maybe 2.5.1?) whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv5*) no_undefined_flag=' -z text' # $CC -shared without GNU ld will not create a library from C++ # object files and a static libstdc++, better avoid it by now archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp' hardcode_libdir_flag_spec= hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4.2uw2*) archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_minus_L=no hardcode_shlibpath_var=no hardcode_runpath_var=yes runpath_var=LD_RUN_PATH ;; sysv5uw7* | unixware7*) no_undefined_flag='${wl}-z ${wl}text' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' fi runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac fi echo "$as_me:$LINENO: result: $ld_shlibs" >&5 echo "${ECHO_T}$ld_shlibs" >&6 test "$ld_shlibs" = no && can_build_shared=no # Check hardcoding attributes. echo "$as_me:$LINENO: checking how to hardcode library paths into programs" >&5 echo $ECHO_N "checking how to hardcode library paths into programs... $ECHO_C" >&6 hardcode_action= if test -n "$hardcode_libdir_flag_spec" || \ test -n "$runpath_var"; then # We can hardcode non-existant directories. if test "$hardcode_direct" != no && # If the only mechanism to avoid hardcoding is shlibpath_var, we # have to relink, otherwise we might link with an installed library # when we should be linking with a yet-to-be-installed one ## test "$hardcode_shlibpath_var" != no && test "$hardcode_minus_L" != no; then # Linking always hardcodes the temporary library directory. hardcode_action=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. hardcode_action=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. hardcode_action=unsupported fi echo "$as_me:$LINENO: result: $hardcode_action" >&5 echo "${ECHO_T}$hardcode_action" >&6 striplib= old_striplib= echo "$as_me:$LINENO: checking whether stripping libraries is possible" >&5 echo $ECHO_N "checking whether stripping libraries is possible... $ECHO_C" >&6 if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi reload_cmds='$LD$reload_flag -o $output$reload_objs' test -z "$deplibs_check_method" && deplibs_check_method=unknown # PORTME Fill in your ld.so characteristics echo "$as_me:$LINENO: checking dynamic linker characteristics" >&5 echo $ECHO_N "checking dynamic linker characteristics... $ECHO_C" >&6 library_names_spec= libname_spec='lib$name' soname_spec= postinstall_cmds= postuninstall_cmds= finish_cmds= finish_eval= shlibpath_var= shlibpath_overrides_runpath=unknown version_type=none dynamic_linker="$host_os ld.so" sys_lib_dlsearch_path_spec="/lib /usr/lib" sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}.so$versuffix $libname.a' shlibpath_var=LIBPATH # AIX has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}.so$major' ;; aix4* | aix5*) version_type=linux if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}.so$major ${libname}${release}.so$versuffix $libname.so' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can # not hardcode correct soname into executable. Probably we can # add versioning support to collect2, so additional links can # be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}.so$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) library_names_spec='$libname.ixlibrary $libname.a' # Create ${libname}_ixlibrary.a entries in /sys/libs. finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done' ;; beos*) library_names_spec='${libname}.so' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi4*) version_type=linux need_version=no library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" export_dynamic_flag_spec=-rdynamic # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32*) version_type=windows need_version=no need_lib_prefix=no case $GCC,$host_os in yes,cygwin*) library_names_spec='$libname.dll.a' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' postinstall_cmds='dlpath=`bash 2>&1 -c '\''. $dir/${file}i;echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog .libs/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`bash 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $rm \$dlpath' ;; yes,mingw*) library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | sed -e "s/^libraries://" -e "s/;/ /g" -e "s,=/,/,g"` ;; yes,pw32*) library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | sed -e 's/./-/g'`${versuffix}.dll' ;; *) library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' ;; esac dynamic_linker='Win32 ld.exe' # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no # FIXME: Relying on posixy $() will cause problems for # cross-compilation, but unfortunately the echo tests do not # yet detect zsh echo's removal of \ escapes. library_names_spec='${libname}${release}${versuffix}.$(test .$module = .yes && echo so || echo dylib) ${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib) ${libname}.$(test .$module = .yes && echo so || echo dylib)' soname_spec='${libname}${release}${major}.$(test .$module = .yes && echo so || echo dylib)' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd*) objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix' need_version=yes ;; esac shlibpath_var=LD_LIBRARY_PATH case $host_os in freebsd2*) shlibpath_overrides_runpath=yes ;; *) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. dynamic_linker="$host_os dld.sl" version_type=sunos need_lib_prefix=no need_version=no shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl' soname_spec='${libname}${release}.sl$major' # HP-UX runs *really* slowly unless shared libraries are mode 555. postinstall_cmds='chmod 555 $lib' ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) version_type=irix ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}.so$major' library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so $libname.so' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" ;; # No shared lib support for Linux oldld, aout, or coff. linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) dynamic_linker=no ;; # This must be Linux ELF. linux-gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so' soname_spec='${libname}${release}.so$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; openbsd*) version_type=sunos need_lib_prefix=no need_version=no if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case "$host_os" in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH ;; os2*) libname_spec='$name' need_lib_prefix=no library_names_spec='$libname.dll $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_version=no soname_spec='${libname}${release}.so' library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; sco3.2v5*) version_type=osf soname_spec='${libname}${release}.so$major' library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' shlibpath_var=LD_LIBRARY_PATH ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix' finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes if test "$with_gnu_ld" = yes; then need_lib_prefix=no fi need_version=yes ;; sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) version_type=linux library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no export_dynamic_flag_spec='${wl}-Blargedynsym' runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; uts4*) version_type=linux library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' soname_spec='${libname}${release}.so$major' shlibpath_var=LD_LIBRARY_PATH ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' soname_spec='$libname.so.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; *) dynamic_linker=no ;; esac echo "$as_me:$LINENO: result: $dynamic_linker" >&5 echo "${ECHO_T}$dynamic_linker" >&6 test "$dynamic_linker" = no && can_build_shared=no # Report the final consequences. echo "$as_me:$LINENO: checking if libtool supports shared libraries" >&5 echo $ECHO_N "checking if libtool supports shared libraries... $ECHO_C" >&6 echo "$as_me:$LINENO: result: $can_build_shared" >&5 echo "${ECHO_T}$can_build_shared" >&6 echo "$as_me:$LINENO: checking whether to build shared libraries" >&5 echo $ECHO_N "checking whether to build shared libraries... $ECHO_C" >&6 test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case "$host_os" in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix4*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac echo "$as_me:$LINENO: result: $enable_shared" >&5 echo "${ECHO_T}$enable_shared" >&6 echo "$as_me:$LINENO: checking whether to build static libraries" >&5 echo $ECHO_N "checking whether to build static libraries... $ECHO_C" >&6 # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes echo "$as_me:$LINENO: result: $enable_static" >&5 echo "${ECHO_T}$enable_static" >&6 if test "$hardcode_action" = relink; then # Fast installation is not supported enable_fast_install=no elif test "$shlibpath_overrides_runpath" = yes || test "$enable_shared" = no; then # Fast installation is not necessary enable_fast_install=needless fi variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; cygwin* | mingw* | pw32*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; *) echo "$as_me:$LINENO: checking for shl_load" >&5 echo $ECHO_N "checking for shl_load... $ECHO_C" >&6 if test "${ac_cv_func_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shl_load (); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shl_load (); char (*f) (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { /* 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_shl_load) || defined (__stub___shl_load) choke me #else f = shl_load; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_shl_load=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_func_shl_load=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_shl_load" >&5 echo "${ECHO_T}$ac_cv_func_shl_load" >&6 if test $ac_cv_func_shl_load = yes; then lt_cv_dlopen="shl_load" else echo "$as_me:$LINENO: checking for shl_load in -ldld" >&5 echo $ECHO_N "checking for shl_load in -ldld... $ECHO_C" >&6 if test "${ac_cv_lib_dld_shl_load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char shl_load (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { shl_load (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dld_shl_load=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_dld_shl_load=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dld_shl_load" >&5 echo "${ECHO_T}$ac_cv_lib_dld_shl_load" >&6 if test $ac_cv_lib_dld_shl_load = yes; then lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld" else echo "$as_me:$LINENO: checking for dlopen" >&5 echo $ECHO_N "checking for dlopen... $ECHO_C" >&6 if test "${ac_cv_func_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char dlopen (); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dlopen (); char (*f) (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { /* 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_dlopen) || defined (__stub___dlopen) choke me #else f = dlopen; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_dlopen=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_func_dlopen=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: $ac_cv_func_dlopen" >&5 echo "${ECHO_T}$ac_cv_func_dlopen" >&6 if test $ac_cv_func_dlopen = yes; then lt_cv_dlopen="dlopen" else echo "$as_me:$LINENO: checking for dlopen in -ldl" >&5 echo $ECHO_N "checking for dlopen in -ldl... $ECHO_C" >&6 if test "${ac_cv_lib_dl_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dlopen (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { dlopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dl_dlopen=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_dl_dlopen=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dl_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_dl_dlopen" >&6 if test $ac_cv_lib_dl_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else echo "$as_me:$LINENO: checking for dlopen in -lsvld" >&5 echo $ECHO_N "checking for dlopen in -lsvld... $ECHO_C" >&6 if test "${ac_cv_lib_svld_dlopen+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dlopen (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { dlopen (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_svld_dlopen=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_svld_dlopen=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_svld_dlopen" >&5 echo "${ECHO_T}$ac_cv_lib_svld_dlopen" >&6 if test $ac_cv_lib_svld_dlopen = yes; then lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else echo "$as_me:$LINENO: checking for dld_link in -ldld" >&5 echo $ECHO_N "checking for dld_link in -ldld... $ECHO_C" >&6 if test "${ac_cv_lib_dld_dld_link+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char dld_link (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { dld_link (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_dld_dld_link=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_dld_dld_link=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_dld_dld_link" >&5 echo "${ECHO_T}$ac_cv_lib_dld_dld_link" >&6 if test $ac_cv_lib_dld_dld_link = yes; then lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" echo "$as_me:$LINENO: checking whether a program can dlopen itself" >&5 echo $ECHO_N "checking whether a program can dlopen itself... $ECHO_C" >&6 if test "${lt_cv_dlopen_self+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif #ifdef __cplusplus extern "C" void exit (int); #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } exit (status); } EOF if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_unknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi echo "$as_me:$LINENO: result: $lt_cv_dlopen_self" >&5 echo "${ECHO_T}$lt_cv_dlopen_self" >&6 if test "x$lt_cv_dlopen_self" = xyes; then LDFLAGS="$LDFLAGS $link_static_flag" echo "$as_me:$LINENO: checking whether a statically linked program can dlopen itself" >&5 echo $ECHO_N "checking whether a statically linked program can dlopen itself... $ECHO_C" >&6 if test "${lt_cv_dlopen_self_static+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif #ifdef __cplusplus extern "C" void exit (int); #endif void fnord() { int i=42;} int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; /* dlclose (self); */ } exit (status); } EOF if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi echo "$as_me:$LINENO: result: $lt_cv_dlopen_self_static" >&5 echo "${ECHO_T}$lt_cv_dlopen_self_static" >&6 fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. echo "$as_me:$LINENO: checking whether -lc should be explicitly linked in" >&5 echo $ECHO_N "checking whether -lc should be explicitly linked in... $ECHO_C" >&6 if test "${lt_cv_archive_cmds_need_lc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else $rm conftest* echo 'static int dummy;' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_cv_prog_cc_wl compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { (eval echo "$as_me:$LINENO: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\"") >&5 (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$save_allow_undefined_flag else cat conftest.err 1>&5 fi fi echo "$as_me:$LINENO: result: $lt_cv_archive_cmds_need_lc" >&5 echo "${ECHO_T}$lt_cv_archive_cmds_need_lc" >&6 ;; esac fi need_lc=${lt_cv_archive_cmds_need_lc-yes} # The second clause should only fire when bootstrapping the # libtool distribution, otherwise you forgot to ship ltmain.sh # with your package, and you will get complaints that there are # no rules to generate ltmain.sh. if test -f "$ltmain"; then : else # If there is no Makefile yet, we rely on a make rule to execute # `config.status --recheck' to rerun these tests and create the # libtool script then. test -f Makefile && make "$ltmain" fi if test -f "$ltmain"; then trap "$rm \"${ofile}T\"; exit 1" 1 2 15 $rm -f "${ofile}T" echo creating $ofile # Now quote all the things that may contain metacharacters while being # careful not to overquote the AC_SUBSTed values. We take copies of the # variables and quote the copies for generation of the libtool script. for var in echo old_CC old_CFLAGS SED \ AR AR_FLAGS CC LD LN_S NM SHELL \ reload_flag reload_cmds wl \ pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \ thread_safe_flag_spec whole_archive_flag_spec libname_spec \ library_names_spec soname_spec \ RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \ old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds \ postuninstall_cmds extract_expsyms_cmds old_archive_from_expsyms_cmds \ old_striplib striplib file_magic_cmd export_symbols_cmds \ deplibs_check_method allow_undefined_flag no_undefined_flag \ finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \ global_symbol_to_c_name_address \ hardcode_libdir_flag_spec hardcode_libdir_separator \ sys_lib_search_path_spec sys_lib_dlsearch_path_spec \ compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do case $var in reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \ old_postinstall_cmds | old_postuninstall_cmds | \ export_symbols_cmds | archive_cmds | archive_expsym_cmds | \ extract_expsyms_cmds | old_archive_from_expsyms_cmds | \ postinstall_cmds | postuninstall_cmds | \ finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec) # Double-quote double-evaled strings. eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" ;; *) eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" ;; esac done cat <<__EOF__ > "${ofile}T" #! $SHELL # `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996-2000 Free Software Foundation, Inc. # Originally by Gordon Matzigkeit , 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 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # A sed that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="${SED} -e s/^X//" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi # ### BEGIN LIBTOOL CONFIG # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$need_lc # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # The host system. host_alias=$host_alias host=$host # An echo program that does not interpret backslashes. echo=$lt_echo # The archiver. AR=$lt_AR AR_FLAGS=$lt_AR_FLAGS # The default C compiler. CC=$lt_CC # Is the compiler the GNU C compiler? with_gcc=$GCC # The linker used to build libraries. LD=$lt_LD # Whether we need hard or soft links. LN_S=$lt_LN_S # A BSD-compatible nm program. NM=$lt_NM # A symbol stripping program STRIP=$STRIP # Used to examine libraries when file_magic_cmd begins "file" MAGIC_CMD=$MAGIC_CMD # Used on cygwin: DLL creation program. DLLTOOL="$DLLTOOL" # Used on cygwin: object dumper. OBJDUMP="$OBJDUMP" # Used on cygwin: assembler. AS="$AS" # The name of the directory that contains temporary libtool files. objdir=$objdir # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # How to pass a linker flag through the compiler. wl=$lt_wl # Object file suffix (normally "o"). objext="$ac_objext" # Old archive suffix (normally "a"). libext="$libext" # Executable file suffix (normally ""). exeext="$exeext" # Additional compiler flags for building library objects. pic_flag=$lt_pic_flag pic_mode=$pic_mode # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_compiler_c_o # Can we write directly to a .lo ? compiler_o_lo=$lt_compiler_o_lo # Must we lock files when doing compilation ? need_locks=$lt_need_locks # Do we need the lib prefix for modules? need_lib_prefix=$need_lib_prefix # Do we need a version for libraries? need_version=$need_version # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Compiler flag to prevent dynamic linking. link_static_flag=$lt_link_static_flag # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_no_builtin_flag # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Compiler flag to generate thread-safe objects. thread_safe_flag_spec=$lt_thread_safe_flag_spec # Library versioning type. version_type=$version_type # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME. library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Commands used to build and install an old-style archive. RANLIB=$lt_RANLIB old_archive_cmds=$lt_old_archive_cmds old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build and install a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds postinstall_cmds=$lt_postinstall_cmds postuninstall_cmds=$lt_postuninstall_cmds # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method == file_magic. file_magic_cmd=$lt_file_magic_cmd # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that forces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # Same as above, but a single script fragment to be evaled but not shown. finish_eval=$lt_finish_eval # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_global_symbol_pipe # Transform the output of nm in a proper C declaration global_symbol_to_cdecl=$lt_global_symbol_to_cdecl # Transform the output of nm in a C name address pair global_symbol_to_c_name_address=$lt_global_symbol_to_c_name_address # This is the shared library runtime path variable. runpath_var=$runpath_var # This is the shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist. hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # Whether we need a single -rpath flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the # resulting binary. hardcode_direct=$hardcode_direct # Set to yes if using the -LDIR flag during linking hardcodes DIR into the # resulting binary. hardcode_minus_L=$hardcode_minus_L # Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into # the resulting binary. hardcode_shlibpath_var=$hardcode_shlibpath_var # Variables whose values should be saved in libtool wrapper scripts and # restored at relink time. variables_saved_for_relink="$variables_saved_for_relink" # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Compile-time system search path for libraries sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Fix the shell variable \$srcfile for the compiler. fix_srcfile_path="$fix_srcfile_path" # Set to yes if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # ### END LIBTOOL CONFIG __EOF__ case $host_os in aix3*) cat <<\EOF >> "${ofile}T" # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi EOF ;; esac case $host_os in cygwin* | mingw* | pw32* | os2*) cat <<'EOF' >> "${ofile}T" # This is a source program that is used to create dlls on Windows # Don't remove nor modify the starting and closing comments # /* ltdll.c starts here */ # #define WIN32_LEAN_AND_MEAN # #include # #undef WIN32_LEAN_AND_MEAN # #include # # #ifndef __CYGWIN__ # # ifdef __CYGWIN32__ # # define __CYGWIN__ __CYGWIN32__ # # endif # #endif # # #ifdef __cplusplus # extern "C" { # #endif # BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved); # #ifdef __cplusplus # } # #endif # # #ifdef __CYGWIN__ # #include # DECLARE_CYGWIN_DLL( DllMain ); # #endif # HINSTANCE __hDllInstance_base; # # BOOL APIENTRY # DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved) # { # __hDllInstance_base = hInst; # return TRUE; # } # /* ltdll.c ends here */ # This is a source program that is used to create import libraries # on Windows for dlls which lack them. Don't remove nor modify the # starting and closing comments # /* impgen.c starts here */ # /* Copyright (C) 1999-2000 Free Software Foundation, Inc. # # This file is part of GNU libtool. # # 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. # */ # # #include /* for printf() */ # #include /* for open(), lseek(), read() */ # #include /* for O_RDONLY, O_BINARY */ # #include /* for strdup() */ # # /* O_BINARY isn't required (or even defined sometimes) under Unix */ # #ifndef O_BINARY # #define O_BINARY 0 # #endif # # static unsigned int # pe_get16 (fd, offset) # int fd; # int offset; # { # unsigned char b[2]; # lseek (fd, offset, SEEK_SET); # read (fd, b, 2); # return b[0] + (b[1]<<8); # } # # static unsigned int # pe_get32 (fd, offset) # int fd; # int offset; # { # unsigned char b[4]; # lseek (fd, offset, SEEK_SET); # read (fd, b, 4); # return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); # } # # static unsigned int # pe_as32 (ptr) # void *ptr; # { # unsigned char *b = ptr; # return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); # } # # int # main (argc, argv) # int argc; # char *argv[]; # { # int dll; # unsigned long pe_header_offset, opthdr_ofs, num_entries, i; # unsigned long export_rva, export_size, nsections, secptr, expptr; # unsigned long name_rvas, nexp; # unsigned char *expdata, *erva; # char *filename, *dll_name; # # filename = argv[1]; # # dll = open(filename, O_RDONLY|O_BINARY); # if (dll < 1) # return 1; # # dll_name = filename; # # for (i=0; filename[i]; i++) # if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') # dll_name = filename + i +1; # # pe_header_offset = pe_get32 (dll, 0x3c); # opthdr_ofs = pe_header_offset + 4 + 20; # num_entries = pe_get32 (dll, opthdr_ofs + 92); # # if (num_entries < 1) /* no exports */ # return 1; # # export_rva = pe_get32 (dll, opthdr_ofs + 96); # export_size = pe_get32 (dll, opthdr_ofs + 100); # nsections = pe_get16 (dll, pe_header_offset + 4 +2); # secptr = (pe_header_offset + 4 + 20 + # pe_get16 (dll, pe_header_offset + 4 + 16)); # # expptr = 0; # for (i = 0; i < nsections; i++) # { # char sname[8]; # unsigned long secptr1 = secptr + 40 * i; # unsigned long vaddr = pe_get32 (dll, secptr1 + 12); # unsigned long vsize = pe_get32 (dll, secptr1 + 16); # unsigned long fptr = pe_get32 (dll, secptr1 + 20); # lseek(dll, secptr1, SEEK_SET); # read(dll, sname, 8); # if (vaddr <= export_rva && vaddr+vsize > export_rva) # { # expptr = fptr + (export_rva - vaddr); # if (export_rva + export_size > vaddr + vsize) # export_size = vsize - (export_rva - vaddr); # break; # } # } # # expdata = (unsigned char*)malloc(export_size); # lseek (dll, expptr, SEEK_SET); # read (dll, expdata, export_size); # erva = expdata - export_rva; # # nexp = pe_as32 (expdata+24); # name_rvas = pe_as32 (expdata+32); # # printf ("EXPORTS\n"); # for (i = 0; i> "${ofile}T" || (rm -f "${ofile}T"; exit 1) mv -f "${ofile}T" "$ofile" || \ (rm -f "$ofile" && cp "${ofile}T" "$ofile" && rm -f "${ofile}T") chmod +x "$ofile" fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' # Prevent multiple expansion # Extract the first word of "docbook-to-man", so it can be a program name with args. set dummy docbook-to-man; 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_DOCBOOK_TO_MAN+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$DOCBOOK_TO_MAN"; then ac_cv_prog_DOCBOOK_TO_MAN="$DOCBOOK_TO_MAN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DOCBOOK_TO_MAN="yes" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done test -z "$ac_cv_prog_DOCBOOK_TO_MAN" && ac_cv_prog_DOCBOOK_TO_MAN="no" fi fi DOCBOOK_TO_MAN=$ac_cv_prog_DOCBOOK_TO_MAN if test -n "$DOCBOOK_TO_MAN"; then echo "$as_me:$LINENO: result: $DOCBOOK_TO_MAN" >&5 echo "${ECHO_T}$DOCBOOK_TO_MAN" >&6 else echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6 fi if test "$ac_cv_prog_DOCBOOK_TO_MAN" = yes; then HAVE_DOCBOOK_TO_MAN_TRUE= HAVE_DOCBOOK_TO_MAN_FALSE='#' else HAVE_DOCBOOK_TO_MAN_TRUE='#' HAVE_DOCBOOK_TO_MAN_FALSE= fi echo "$as_me:$LINENO: checking whether ln -s works" >&5 echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6 else echo "$as_me:$LINENO: result: no, using $LN_S" >&5 echo "${ECHO_T}no, using $LN_S" >&6 fi if test "$enable_thread_mutex" = "yes" || test "$enable_thread_mutex" = ""; then echo "$as_me:$LINENO: checking for main in -lpthread" >&5 echo $ECHO_N "checking for main in -lpthread... $ECHO_C" >&6 if test "${ac_cv_lib_pthread_main+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lpthread $LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { main (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_lib_pthread_main=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_lib_pthread_main=no fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_lib_pthread_main" >&5 echo "${ECHO_T}$ac_cv_lib_pthread_main" >&6 if test $ac_cv_lib_pthread_main = yes; then for ac_header in pthread.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f 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 #line $LINENO "configure" #include "confdefs.h" #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 cat 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 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 preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; 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: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done LIBS="$LIBS -lpthread" fi fi for ac_header in sys/time.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if eval "test \"\${$as_ac_Header+set}\" = set"; then echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 else # Is the header compilable? echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest.$ac_objext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f 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 #line $LINENO "configure" #include "confdefs.h" #include <$ac_header> _ACEOF if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 ac_status=$? egrep -v '^ *\+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null; then if test -s conftest.err; then ac_cpp_err=$ac_c_preproc_warn_flag else ac_cpp_err= fi else ac_cpp_err=yes fi if test -z "$ac_cpp_err"; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 cat 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 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 preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; 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: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;};; esac echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 if eval "test \"\${$as_ac_Header+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=$ac_header_preproc" fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done echo "$as_me:$LINENO: checking for library containing nanosleep" >&5 echo $ECHO_N "checking for library containing nanosleep... $ECHO_C" >&6 if test "${ac_cv_search_nanosleep+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS ac_cv_search_nanosleep=no cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char nanosleep (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { nanosleep (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_nanosleep="none required" else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext if test "$ac_cv_search_nanosleep" = no; then for ac_lib in rt posix posix4; do LIBS="-l$ac_lib $ac_func_search_save_LIBS" cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char nanosleep (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { nanosleep (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_search_nanosleep="-l$ac_lib" break else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext done fi LIBS=$ac_func_search_save_LIBS fi echo "$as_me:$LINENO: result: $ac_cv_search_nanosleep" >&5 echo "${ECHO_T}$ac_cv_search_nanosleep" >&6 if test "$ac_cv_search_nanosleep" != no; then test "$ac_cv_search_nanosleep" = "none required" || LIBS="$ac_cv_search_nanosleep $LIBS" fi for ac_func in poll do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); char (*f) (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else f = $ac_func; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in nanosleep do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); char (*f) (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else f = $ac_func; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in syslog do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 if eval "test \"\${$as_ac_var+set}\" = set"; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF #line $LINENO "configure" #include "confdefs.h" /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. */ #include /* Override any gcc2 internal prototype to avoid an error. */ #ifdef __cplusplus extern "C" #endif /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func (); char (*f) (); #ifdef F77_DUMMY_MAIN # ifdef __cplusplus extern "C" # endif int F77_DUMMY_MAIN() { return 1; } #endif int main () { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else f = $ac_func; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 (eval $ac_link) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='test -s conftest$ac_exeext' { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 (eval $ac_try) 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 cat conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext fi echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done #---------------------------------------------------------------------------- # Generate Makefiles #---------------------------------------------------------------------------- ac_config_files="$ac_config_files Makefile src/Makefile src/driver/Makefile src/ct-api/Makefile src/ifd-handler/Makefile src/test/Makefile doc/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 overriden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. { (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n \ "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" ;; esac; } | sed ' t clear : clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ : end' >>confcache if cmp -s $cache_file confcache; then :; else if test -w $cache_file; then test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" cat confcache >$cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/; s/:*\${srcdir}:*/:/; s/:*@srcdir@:*/:/; s/^\([^=]*=[ ]*\):*/\1/; s/:*$//; s/^[^=]*=[ ]*$//; }' fi DEFS=-DHAVE_CONFIG_H if test -z "${INSTALL_USB_BUNDLE_TRUE}" && test -z "${INSTALL_USB_BUNDLE_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"INSTALL_USB_BUNDLE\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"INSTALL_USB_BUNDLE\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi 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 "${HAVE_DOCBOOK_TO_MAN_TRUE}" && test -z "${HAVE_DOCBOOK_TO_MAN_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"HAVE_DOCBOOK_TO_MAN\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"HAVE_DOCBOOK_TO_MAN\" 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 SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then set -o posix fi # NLS nuisances. # Support unset when possible. if (FOO=FOO; unset FOO) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi (set +x; test -n "`(LANG=C; export LANG) 2>&1`") && { $as_unset LANG || test "${LANG+set}" != set; } || { LANG=C; export LANG; } (set +x; test -n "`(LC_ALL=C; export LC_ALL) 2>&1`") && { $as_unset LC_ALL || test "${LC_ALL+set}" != set; } || { LC_ALL=C; export LC_ALL; } (set +x; test -n "`(LC_TIME=C; export LC_TIME) 2>&1`") && { $as_unset LC_TIME || test "${LC_TIME+set}" != set; } || { LC_TIME=C; export LC_TIME; } (set +x; test -n "`(LC_CTYPE=C; export LC_CTYPE) 2>&1`") && { $as_unset LC_CTYPE || test "${LC_CTYPE+set}" != set; } || { LC_CTYPE=C; export LC_CTYPE; } (set +x; test -n "`(LANGUAGE=C; export LANGUAGE) 2>&1`") && { $as_unset LANGUAGE || test "${LANGUAGE+set}" != set; } || { LANGUAGE=C; export LANGUAGE; } (set +x; test -n "`(LC_COLLATE=C; export LC_COLLATE) 2>&1`") && { $as_unset LC_COLLATE || test "${LC_COLLATE+set}" != set; } || { LC_COLLATE=C; export LC_COLLATE; } (set +x; test -n "`(LC_NUMERIC=C; export LC_NUMERIC) 2>&1`") && { $as_unset LC_NUMERIC || test "${LC_NUMERIC+set}" != set; } || { LC_NUMERIC=C; export LC_NUMERIC; } (set +x; test -n "`(LC_MESSAGES=C; export LC_MESSAGES) 2>&1`") && { $as_unset LC_MESSAGES || test "${LC_MESSAGES+set}" != set; } || { LC_MESSAGES=C; export LC_MESSAGES; } # Name of the executable. as_me=`(basename "$0") 2>/dev/null || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)$' \| \ . : '\(.\)' 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } /^X\/\(\/\/\)$/{ s//\1/; q; } /^X\/\(\/\).*/{ s//\1/; q; } s/.*/./; q'` # PATH needs CR, and LINENO needs CR and PATH. # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conftest.sh echo "exit 0" >>conftest.sh chmod +x conftest.sh if (PATH=".;."; conftest.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conftest.sh fi as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" || { # Find who we are. Look in the path if we contain no path at all # relative or not. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} { (exit 1); exit 1; }; } fi case $CONFIG_SHELL in '') as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for as_base in sh bash ksh sh5; do case $as_dir in /*) if ("$as_dir/$as_base" -c ' as_lineno_1=$LINENO as_lineno_2=$LINENO as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` test "x$as_lineno_1" != "x$as_lineno_2" && test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then CONFIG_SHELL=$as_dir/$as_base export CONFIG_SHELL exec "$CONFIG_SHELL" "$0" ${1+"$@"} fi;; esac done done ;; esac # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line before each line; the second 'sed' does the real # work. The second script uses 'N' to pair each line-number line # with the numbered line, and appends trailing '-' during # substitution so that $LINENO is not a special case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) sed '=' <$as_myself | sed ' N s,$,-, : loop s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, t loop s,-$,, s,^['$as_cr_digits']*\n,, ' >$as_me.lineno && chmod +x $as_me.lineno || { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensible to this). . ./$as_me.lineno # Exit status is that of the last command. exit } case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in *c*,-n*) ECHO_N= ECHO_C=' ' ECHO_T=' ' ;; *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; *) ECHO_N= ECHO_C='\c' ECHO_T= ;; esac if expr a : '\(a\)' >/dev/null 2>&1; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then # We could just check for DJGPP; but this test a) works b) is more generic # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). if test -f conf$$.exe; then # Don't use ln at all; we don't have any links as_ln_s='cp -p' else as_ln_s='ln -s' fi elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.file as_executable_p="test -f" # Sed expression to map a string onto a valid CPP name. as_tr_cpp="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="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" # IFS # We need space, tab and new line, in precisely that order. as_nl=' ' IFS=" $as_nl" # CDPATH. $as_unset CDPATH || test "${CDPATH+set}" != set || { CDPATH=$PATH_SEPARATOR; export CDPATH; } exec 6>&1 # Open the log real soon, to keep \$[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. Logging --version etc. is OK. exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX } >&5 cat >&5 <<_CSEOF This file was extended by $as_me, which was generated by GNU Autoconf 2.53. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ _CSEOF echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 echo >&5 _ACEOF # Files that config.status was made for. if test -n "$ac_config_files"; then echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS fi if test -n "$ac_config_headers"; then echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS fi if test -n "$ac_config_links"; then echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS fi if test -n "$ac_config_commands"; then echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS fi cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number, then exit -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="\\ config.status configured by $0, generated by GNU Autoconf 2.53, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." srcdir=$srcdir INSTALL="$INSTALL" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "x$1" : 'x\([^=]*\)='` ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` shift set dummy "$ac_option" "$ac_optarg" ${1+"$@"} shift ;; -*);; *) # This is not an option, so the user has probably given explicit # arguments. ac_need_defaults=false;; esac case $1 in # Handling of the options. _ACEOF cat >>$CONFIG_STATUS <<_ACEOF -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running $SHELL $0 " $ac_configure_args " --no-create --no-recursion" exec $SHELL $0 $ac_configure_args --no-create --no-recursion ;; _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF --version | --vers* | -V ) echo "$ac_cs_version"; exit 0 ;; --he | --h) # Conflict between --help and --header { { echo "$as_me:$LINENO: error: ambiguous option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --file | --fil | --fi | --f ) shift CONFIG_FILES="$CONFIG_FILES $1" ac_need_defaults=false;; --header | --heade | --head | --hea ) shift CONFIG_HEADERS="$CONFIG_HEADERS $1" ac_need_defaults=false;; # This is an error. -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 Try \`$0 --help' for more information." >&5 echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2;} { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ;; esac shift done _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # INIT-COMMANDS section. # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_config_target in $ac_config_targets do case "$ac_config_target" in # Handling of arguments. "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "src/driver/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/driver/Makefile" ;; "src/ct-api/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/ct-api/Makefile" ;; "src/ifd-handler/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/ifd-handler/Makefile" ;; "src/test/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/test/Makefile" ;; "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; "depfiles" ) CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; *) { { 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 # Create a temporary directory, and hook for its removal unless debugging. $debug || { trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. : ${TMPDIR=/tmp} { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/csXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=$TMPDIR/cs$$-$RANDOM (umask 077 && mkdir $tmp) } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 { (exit 1); exit 1; } } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "\$CONFIG_FILES"; then # Protect against being on the right side of a sed subst in config.status. sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF s,@SHELL@,$SHELL,;t t s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t s,@exec_prefix@,$exec_prefix,;t t s,@prefix@,$prefix,;t t s,@program_transform_name@,$program_transform_name,;t t s,@bindir@,$bindir,;t t s,@sbindir@,$sbindir,;t t s,@libexecdir@,$libexecdir,;t t s,@datadir@,$datadir,;t t s,@sysconfdir@,$sysconfdir,;t t s,@sharedstatedir@,$sharedstatedir,;t t s,@localstatedir@,$localstatedir,;t t s,@libdir@,$libdir,;t t s,@includedir@,$includedir,;t t s,@oldincludedir@,$oldincludedir,;t t s,@infodir@,$infodir,;t t s,@mandir@,$mandir,;t t s,@build_alias@,$build_alias,;t t s,@host_alias@,$host_alias,;t t s,@target_alias@,$target_alias,;t t s,@DEFS@,$DEFS,;t t s,@ECHO_C@,$ECHO_C,;t t s,@ECHO_N@,$ECHO_N,;t t s,@ECHO_T@,$ECHO_T,;t t s,@LIBS@,$LIBS,;t t s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t s,@INSTALL_DATA@,$INSTALL_DATA,;t t s,@PACKAGE@,$PACKAGE,;t t s,@VERSION@,$VERSION,;t t s,@ACLOCAL@,$ACLOCAL,;t t s,@AUTOCONF@,$AUTOCONF,;t t s,@AUTOMAKE@,$AUTOMAKE,;t t s,@AUTOHEADER@,$AUTOHEADER,;t t s,@MAKEINFO@,$MAKEINFO,;t t s,@AMTAR@,$AMTAR,;t t s,@install_sh@,$install_sh,;t t s,@STRIP@,$STRIP,;t t s,@ac_ct_STRIP@,$ac_ct_STRIP,;t t s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t s,@AWK@,$AWK,;t t s,@SET_MAKE@,$SET_MAKE,;t t s,@PCSC_LITE_DIR@,$PCSC_LITE_DIR,;t t s,@INSTALL_USB_BUNDLE_TRUE@,$INSTALL_USB_BUNDLE_TRUE,;t t s,@INSTALL_USB_BUNDLE_FALSE@,$INSTALL_USB_BUNDLE_FALSE,;t t s,@build@,$build,;t t s,@build_cpu@,$build_cpu,;t t s,@build_vendor@,$build_vendor,;t t s,@build_os@,$build_os,;t t s,@host@,$host,;t t s,@host_cpu@,$host_cpu,;t t s,@host_vendor@,$host_vendor,;t t s,@host_os@,$host_os,;t t s,@CC@,$CC,;t t s,@CFLAGS@,$CFLAGS,;t t s,@LDFLAGS@,$LDFLAGS,;t t s,@CPPFLAGS@,$CPPFLAGS,;t t s,@ac_ct_CC@,$ac_ct_CC,;t t s,@EXEEXT@,$EXEEXT,;t t s,@OBJEXT@,$OBJEXT,;t t s,@DEPDIR@,$DEPDIR,;t t s,@am__include@,$am__include,;t t s,@am__quote@,$am__quote,;t t s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t s,@CCDEPMODE@,$CCDEPMODE,;t t s,@LN_S@,$LN_S,;t t s,@ECHO@,$ECHO,;t t s,@RANLIB@,$RANLIB,;t t s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t s,@CPP@,$CPP,;t t s,@LIBTOOL@,$LIBTOOL,;t t s,@DOCBOOK_TO_MAN@,$DOCBOOK_TO_MAN,;t t s,@HAVE_DOCBOOK_TO_MAN_TRUE@,$HAVE_DOCBOOK_TO_MAN_TRUE,;t t s,@HAVE_DOCBOOK_TO_MAN_FALSE@,$HAVE_DOCBOOK_TO_MAN_FALSE,;t t CEOF _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_lines=48 ac_sed_frag=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_lines # Line after last line for current file. ac_more_lines=: ac_sed_cmds= while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag else sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag fi if test ! -s $tmp/subs.frag; then ac_more_lines=false else # The purpose of the label and of the branching condition is to # speed up the sed processing (if there are no `@' at all, there # is no need to browse any of the substitutions). # These are the two extra sed commands mentioned above. (echo ':t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" else ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" fi ac_sed_frag=`expr $ac_sed_frag + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_lines` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi fi # test -n "$CONFIG_FILES" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { case "$ac_dir" in [\\/]* | ?:[\\/]* ) as_incr_dir=;; *) as_incr_dir=.;; esac as_dummy="$ac_dir" for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do case $as_mkdir_dir in # Skip DOS drivespec ?:) as_incr_dir=$as_mkdir_dir ;; *) as_incr_dir=$as_incr_dir/$as_mkdir_dir test -d "$as_incr_dir" || mkdir "$as_incr_dir" || { { echo "$as_me:$LINENO: error: cannot create \"$ac_dir\"" >&5 echo "$as_me: error: cannot create \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; } ;; esac done; } ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_builddir$INSTALL ;; esac if test x"$ac_file" != x-; then { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} rm -f "$ac_file" fi # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then configure_input= else configure_input="$ac_file. " fi configure_input=$configure_input"Generated from `echo $ac_file_in | sed 's,.*/,,'` by configure." # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; *) # Relative if test -f "$f"; then # Build tree echo $f elif test -f "$srcdir/$f"; then # Source tree echo $srcdir/$f else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } _ACEOF cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s,@configure_input@,$configure_input,;t t s,@srcdir@,$ac_srcdir,;t t s,@abs_srcdir@,$ac_abs_srcdir,;t t s,@top_srcdir@,$ac_top_srcdir,;t t s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t s,@builddir@,$ac_builddir,;t t s,@abs_builddir@,$ac_abs_builddir,;t t s,@top_builddir@,$ac_top_builddir,;t t s,@abs_top_builddir@,$ac_abs_top_builddir,;t t s,@INSTALL@,$ac_INSTALL,;t t " $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out rm -f $tmp/stdin if test x"$ac_file" != x-; then mv $tmp/out $ac_file else cat $tmp/out rm -f $tmp/out fi done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # # CONFIG_HEADER section. # # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='[ ].*$,\1#\2' ac_dC=' ' ac_dD=',;t' # ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='$,\1#\2define\3' ac_uC=' ' ac_uD=',;t' for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case $ac_file in - | *:- | *:-:* ) # input from stdin cat >$tmp/stdin ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; * ) ac_file_in=$ac_file.in ;; esac test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} # First look for the input files in the build tree, otherwise in the # src tree. ac_file_inputs=`IFS=: for f in $ac_file_in; do case $f in -) echo $tmp/stdin ;; [\\/$]*) # Absolute (can't be DOS-style, as IFS=:) test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } echo $f;; *) # Relative if test -f "$f"; then # Build tree echo $f elif test -f "$srcdir/$f"; then # Source tree echo $srcdir/$f else # /dev/null tree { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 echo "$as_me: error: cannot find input file: $f" >&2;} { (exit 1); exit 1; }; } fi;; esac done` || { (exit 1); exit 1; } # Remove the trailing spaces. sed 's/[ ]*$//' $ac_file_inputs >$tmp/in _ACEOF # Transform confdefs.h into two sed scripts, `conftest.defines' and # `conftest.undefs', that substitutes the proper values into # config.h.in to produce config.h. The first handles `#define' # templates, and the second `#undef' templates. # And first: Protect against being on the right side of a sed subst in # config.status. Protect against being in an unquoted here document # in config.status. rm -f conftest.defines conftest.undefs # Using a here document instead of a string reduces the quoting nightmare. # Putting comments in sed scripts is not portable. # # `end' is used to avoid that the second main sed command (meant for # 0-ary CPP macros) applies to n-ary macro definitions. # See the Autoconf documentation for `clear'. cat >confdef2sed.sed <<\_ACEOF s/[\\&,]/\\&/g s,[\\$`],\\&,g t clear : clear s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp t end s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp : end _ACEOF # If some macros were called several times there might be several times # the same #defines, which is useless. Nevertheless, we may not want to # sort them, since we want the *last* AC-DEFINE to be honored. uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs rm -f confdef2sed.sed # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >>conftest.undefs <<\_ACEOF s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, _ACEOF # Break up conftest.defines because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS echo ' if egrep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS echo ' :' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.defines >/dev/null do # Write a limited-size here document to $tmp/defines.sed. echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#define' lines. echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/defines.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines echo ' fi # egrep' >>$CONFIG_STATUS echo >>$CONFIG_STATUS # Break up conftest.undefs because some shells have a limit on the size # of here documents, and old seds have small limits too (100 cmds). echo ' # Handle all the #undef templates' >>$CONFIG_STATUS rm -f conftest.tail while grep . conftest.undefs >/dev/null do # Write a limited-size here document to $tmp/undefs.sed. echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS # Speed up: don't consider the non `#undef' echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS # Work around the forget-to-reset-the-flag bug. echo 't clr' >>$CONFIG_STATUS echo ': clr' >>$CONFIG_STATUS sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS echo 'CEOF sed -f $tmp/undefs.sed $tmp/in >$tmp/out rm -f $tmp/in mv $tmp/out $tmp/in ' >>$CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail rm -f conftest.undefs mv conftest.tail conftest.undefs done rm -f conftest.undefs cat >>$CONFIG_STATUS <<\_ACEOF # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ if test x"$ac_file" = x-; then echo "/* Generated by configure. */" >$tmp/config.h else echo "/* $ac_file. Generated by configure. */" >$tmp/config.h fi cat $tmp/in >>$tmp/config.h rm -f $tmp/in if test x"$ac_file" != x-; then if cmp -s $ac_file $tmp/config.h 2>/dev/null; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else ac_dir=`(dirname "$ac_file") 2>/dev/null || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` { case "$ac_dir" in [\\/]* | ?:[\\/]* ) as_incr_dir=;; *) as_incr_dir=.;; esac as_dummy="$ac_dir" for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do case $as_mkdir_dir in # Skip DOS drivespec ?:) as_incr_dir=$as_mkdir_dir ;; *) as_incr_dir=$as_incr_dir/$as_mkdir_dir test -d "$as_incr_dir" || mkdir "$as_incr_dir" || { { echo "$as_me:$LINENO: error: cannot create \"$ac_dir\"" >&5 echo "$as_me: error: cannot create \"$ac_dir\"" >&2;} { (exit 1); exit 1; }; } ;; esac done; } rm -f $ac_file mv $tmp/config.h $ac_file fi else cat $tmp/config.h rm -f $tmp/config.h fi # Run the commands associated with the file. case $ac_file in config.h ) # update the timestamp echo 'timestamp for config.h' >"./stamp-h1" ;; esac done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # # CONFIG_COMMANDS section. # for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue ac_dest=`echo "$ac_file" | sed 's,:.*,,'` ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` ac_dir=`(dirname "$ac_dest") 2>/dev/null || $as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_dest" : 'X\(//\)[^/]' \| \ X"$ac_dest" : 'X\(//\)$' \| \ X"$ac_dest" : 'X\(/\)' \| \ . : '\(.\)' 2>/dev/null || echo X"$ac_dest" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } /^X\(\/\/\)[^/].*/{ s//\1/; q; } /^X\(\/\/\)$/{ s//\1/; q; } /^X\(\/\).*/{ s//\1/; q; } s/.*/./; q'` ac_builddir=. if test "$ac_dir" != .; then ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A "../" for each directory in $ac_dir_suffix. ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` else ac_dir_suffix= ac_top_builddir= fi case $srcdir in .) # No --srcdir option. We are building in place. ac_srcdir=. if test -z "$ac_top_builddir"; then ac_top_srcdir=. else ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` fi ;; [\\/]* | ?:[\\/]* ) # Absolute path. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ;; *) # Relative path. ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_builddir$srcdir ;; esac # Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be # absolute. ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd` ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 echo "$as_me: executing $ac_dest commands" >&6;} case $ac_dest in depfiles ) 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. # So let's grep whole file. if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then dirpart=`(dirname "$mf") 2>/dev/null || $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 grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue # Extract the definition of DEP_FILES from the Makefile without # running `make'. DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` test -z "$DEPDIR" && continue # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n -e '/^U = / s///p' < "$mf"` test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" # 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 -e ' /^DEP_FILES = .*\\\\$/ { s/^DEP_FILES = // :loop s/\\\\$// p n /\\\\$/ b loop p } /^DEP_FILES = / s/^DEP_FILES = //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=`(dirname "$file") 2>/dev/null || $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'` { case $dirpart/$fdir in [\\/]* | ?:[\\/]* ) as_incr_dir=;; *) as_incr_dir=.;; esac as_dummy=$dirpart/$fdir for as_mkdir_dir in `IFS='/\\'; set X $as_dummy; shift; echo "$@"`; do case $as_mkdir_dir in # Skip DOS drivespec ?:) as_incr_dir=$as_mkdir_dir ;; *) as_incr_dir=$as_incr_dir/$as_mkdir_dir test -d "$as_incr_dir" || mkdir "$as_incr_dir" || { { echo "$as_me:$LINENO: error: cannot create $dirpart/$fdir" >&5 echo "$as_me: error: cannot create $dirpart/$fdir" >&2;} { (exit 1); exit 1; }; } ;; esac done; } # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done ;; esac done _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: exec 5>/dev/null $SHELL $CONFIG_STATUS || 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 towitoko-2.0.7/configure.ac0000644000175000017500000002053107527760020011354 dnl configure.ac dnl Process this file with autoconf to produce a configure script. dnl dnl This file is part of the Unix driver for Towitoko smartcard readers dnl Copyright (c) 2000 Carlos Prados AC_INIT AM_INIT_AUTOMAKE(towitoko,2.0.7) AM_CONFIG_HEADER(config.h) AC_PREFIX_DEFAULT(/usr/local/towitoko) #---------------------------------------------------------------------------- # Options for setting fix card type / memory size #---------------------------------------------------------------------------- AC_ARG_ENABLE(card-type, AC_HELP_STRING([--enable-card-type(=sync|async)], [card type (default=probe)])) case "$enable_card_type" in sync) AC_DEFINE(ICC_TYPE_SYNC,1,[Smartcard of type synchronoys]) ;; async) AC_DEFINE(ICC_TYPE_ASYNC,1,[Smartcard of type asynchronoys]) ;; esac AC_ARG_ENABLE(card-convention, AC_HELP_STRING([--enable-card-convention(=dir|inv)], [card convention (default=probe)])) case "$enable_card_convention" in dir) AC_DEFINE(IFD_TOWITOKO_CONVENTION_DIRECT,1, [Smartcard with direct convention]) ;; inv) AC_DEFINE(IFD_TOWITOKO_CONVENTION_INVERSE,1, [Smartcard with inverse convention]) ;; esac AC_ARG_ENABLE(memory-type, AC_HELP_STRING([--enable-memory-type(=i2cs|i2cl|2w|3w)], [memory card type (default=probe)])) case "$enable_memory_type" in i2cs) memory_type=0; ;; i2cl) memory_type=1; ;; 2w) memory_type=2; ;; 3w) memory_type=3; ;; esac if test "$memory_type" != "" ; then AC_DEFINE_UNQUOTED(ICC_SYNC_MEMORY_TYPE,$memory_type, [Memory smartcard type (0,1,2,3)]) fi AC_ARG_ENABLE(memory-size, AC_HELP_STRING([--enable-memory-size(=size)],[memory card size (default=probe)])) if test "$enable_memory_size" != ""; then AC_DEFINE_UNQUOTED(ICC_SYNC_MEMORY_LENGTH, $enable_memory_size, [Memory size]) fi AC_ARG_ENABLE(ISO-T0, AC_HELP_STRING([--enable-ISO-t0], [transportation of APDUs by T=0 (default=no)])) if test "$enable_ISO_t0" = "true"; then AC_DEFINE_UNQUOTED(PROTOCOL_T0_ISO, 1, [Transportation of APDUs by T=0]) fi #---------------------------------------------------------------------------- # Debug level #---------------------------------------------------------------------------- AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug(=1|2|3|4)],[ enable debug (default=no)])) if test "$enable_debug" = "yes"; then enable_debug=3 else if test "$enable_debug" = "no"; then enable_debug=0 fi fi if test "$enable_debug" != ""; then if test "$enable_debug" -lt "4"; then if test "$enable_debug" -gt "0"; then AC_DEFINE(DEBUG_CTAPI,1,[Debug CT-API]) AC_DEFINE(DEBUG_PROTOCOL,1,[Debug Protocol]) AC_DEFINE(DEBUG_ICC,1,[Debug Integrated Circuit Card]) fi if test "$enable_debug" -gt "1"; then AC_DEFINE(DEBUG_IFD,1,[Debug Interface Device]) fi if test "$enable_debug" -gt "2"; then AC_DEFINE(DEBUG_IO,1,[Debug Input/Output]) fi else AC_DEFINE(DEBUG_IFDH,1,[Debug IFD Handler]) fi fi #---------------------------------------------------------------------------- # Option to set PCSC Lite base directory #---------------------------------------------------------------------------- AC_ARG_WITH(pcsc-lite-dir, AC_HELP_STRING([--with-pcsc-lite-dir], [PCSC Lite base directory (default=/usr/local/pcsc)]), PCSC_LITE_DIR="$with_pcsc_lite_dir", PCSC_LITE_DIR="/usr/local/pcsc") AC_SUBST(PCSC_LITE_DIR) #---------------------------------------------------------------------------- # Option to enable USB bundle installation #---------------------------------------------------------------------------- AC_ARG_ENABLE(usb-bundle, AC_HELP_STRING([--enable-usb-bundle],[enable PCSC Lite USB bundle installation (default=no)])) AM_CONDITIONAL(INSTALL_USB_BUNDLE, test "$enable_usb_bundle" = "yes") #---------------------------------------------------------------------------- # Option to enable devfs support #---------------------------------------------------------------------------- AC_ARG_ENABLE(devfs, AC_HELP_STRING([--enable-devfs], [enable Linux 2.4.X devfs support (default=no)])) if test "$enable_devfs" = "yes"; then AC_DEFINE(IO_ENABLE_DEVFS, 1, [Enable Linux 2.4.X devfs support]) fi #---------------------------------------------------------------------------- # Option to enable /dev/pcsc/ links support #---------------------------------------------------------------------------- AC_ARG_ENABLE(devpcsc, AC_HELP_STRING([--enable-devpcsc], [enable /dev/pcsc links support (default=no)])) if test "$enable_devpcsc" = "yes"; then AC_DEFINE(IO_ENABLE_DEVPCSC, 1, [Enable /dev/pcsc/ links]) fi #---------------------------------------------------------------------------- # Option to enable win32 style COM port numbering #---------------------------------------------------------------------------- AC_ARG_ENABLE(win32-com, AC_HELP_STRING([--enable-win32-com], [enable win32 style COM port numbering (default=no)])) if test "$enable_win32_com" = "yes"; then AC_DEFINE(CTAPI_WIN32_COM, 1, [Enable win32 COM numbering]) fi #---------------------------------------------------------------------------- # Option to disable multi-threading #---------------------------------------------------------------------------- AC_ARG_ENABLE(thread-mutex, AC_HELP_STRING([--enable-thread-mutex],[enable thread mutexes (default=yes)])) #---------------------------------------------------------------------------- # Option for Atr cheking #---------------------------------------------------------------------------- AC_ARG_ENABLE(atr-check, AC_HELP_STRING([--enable-atr-check], [enable checking of valid ATR (default=yes)])) if test "$enable_atr_check" = "" || test "$enable_atr_check" = "yes"; then AC_DEFINE(IFD_TOWITOKO_STRICT_ATR_CHECK,1, [ATR for asynchronous cards is cheked]) fi #---------------------------------------------------------------------------- # Option for Atr timings cheking #---------------------------------------------------------------------------- AC_ARG_ENABLE(atr-timings, AC_HELP_STRING([--enable-atr-timings], [enable decoding of timings from ATR (default=yes)])) if test "$enable_atr_timings" = "no"; then AC_DEFINE(PROTOCOL_T0_USE_DEFAULT_TIMINGS,1, [Timings in ATR are not used in T=0 cards]) AC_DEFINE(PROTOCOL_T1_USE_DEFAULT_TIMINGS,1, [Timings in ATR are not used in T=1 cards]) AC_DEFINE(PTS_USE_DEFAULT_TIMINGS,1, [Timings in ATR are not used after PTS]) fi #---------------------------------------------------------------------------- # Check environment #--------------------------------------------------------------------------- AC_CANONICAL_HOST case $host in *linux*) AC_DEFINE(OS_LINUX,1,[Linux Operating System]) AC_DEFINE(IO_ENABLE_USB, 1, [Enable USB support]) AC_DEFINE(_REENTRANT,1,[This may be usefull for LinuxThreads]) ;; *cygwin*) AC_DEFINE(OS_CYGWIN32,1,[Cywin32 for Windows NT environment]) AC_DEFINE(CTAPI_WIN32_COM, 1, [Enable win32 COM numbering]) ;; *solaris*) AC_DEFINE(OS_SOLARIS,1,[Sun Operating System]) ;; *hp-hpux*) AC_DEFINE(OS_HPUX,1,[HPUX Operating System]) ;; *sgi-irix*) AC_DEFINE(OS_IRIX,1,[IRIX Operating System]) ;; *sco*) AC_DEFINE(OS_SCO,1,[SCO Operating System]) ;; *openbsd*) AC_DEFINE(OS_OPENBSD,1,[OpenBSD Operating System]) ;; *freebsd*) AC_DEFINE(OS_FREEBSD,1,[FreeBSD Operating System]) ;; *aix*) AC_DEFINE(OS_AIX,1,[FreeBSD Operating System]) ;; *netbsd*) AC_DEFINE(OS_NETBSD,1,[FreeBSD Operating System]) ;; *) AC_DEFINE(OS_OTHER, 1, [Other Operating System]) AC_DEFINE(IO_ENABLE_DEVPCSC, 1, [Enable /dev/pcsc/ links]) ;; esac AC_PROG_CC AM_DISABLE_STATIC AC_LIBTOOL_WIN32_DLL AM_PROG_LIBTOOL AC_CHECK_PROG(DOCBOOK_TO_MAN, docbook-to-man, yes, no) AM_CONDITIONAL(HAVE_DOCBOOK_TO_MAN, test "$ac_cv_prog_DOCBOOK_TO_MAN" = yes) AC_PROG_LN_S if test "$enable_thread_mutex" = "yes" || test "$enable_thread_mutex" = ""; then AC_CHECK_LIB(pthread, main, [AC_CHECK_HEADERS(pthread.h) LIBS="$LIBS -lpthread"]) fi AC_CHECK_HEADERS(sys/time.h) dnl Check for libraries AC_SEARCH_LIBS(nanosleep, rt posix posix4) dnl Checks for functions. AC_CHECK_FUNCS(poll) AC_CHECK_FUNCS(nanosleep) AC_CHECK_FUNCS(syslog) #---------------------------------------------------------------------------- # Generate Makefiles #---------------------------------------------------------------------------- AC_OUTPUT(Makefile src/Makefile src/driver/Makefile src/ct-api/Makefile src/ifd-handler/Makefile src/test/Makefile doc/Makefile) towitoko-2.0.7/depcomp0000755000175000017500000002753307527463427010467 #! /bin/sh # depcomp - compile a program generating dependencies as side-effects # Copyright 1999, 2000 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . 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 # `libtool' can also be set to `yes' or `no'. if test -z "$depfile"; then base=`echo "$object" | sed -e 's,^.*/,,' -e 's,\.\([^.]*\)$,.P\1,'` dir=`echo "$object" | sed 's,/.*$,/,'` if test "$dir" = "$object"; then dir= fi # FIXME: should be _deps on DOS. depfile="$dir.deps/$base" fi 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. "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" 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. 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. stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` tmpdepfile="$stripped.u" outname="$stripped.o" if test "$libtool" = yes; then "$@" -Wc,-M else "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi 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,^$outname:,$object :," < "$tmpdepfile" > "$depfile" sed -e "s,^$outname: \(.*\)$,\1:," < "$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" ;; 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 tmpdepfile1="$dir.libs/$base.lo.d" tmpdepfile2="$dir.libs/$base.d" "$@" -Wc,-MD else tmpdepfile1="$dir$base.o.d" tmpdepfile2="$dir$base.d" "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi if test -f "$tmpdepfile1"; then tmpdepfile="$tmpdepfile1" else tmpdepfile="$tmpdepfile2" fi if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a space and a tab 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 proprocessed 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'. We will use -o /dev/null later, # however we can't do the remplacement now because # `-o $object' might simply not be used 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 "$@" -o /dev/null $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 $? # 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 ;; -*) ;; *) 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 proprocessed 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 '/^# [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 proprocessed 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 towitoko-2.0.7/install-sh0000755000175000017500000001270107527463426011104 #!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else : fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=$mkdirprog fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f "$src" ] || [ -d "$src" ] then : else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else : fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else : fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else : fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else : ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else : ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else : ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else : ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else : fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else :;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else :;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else :;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else :;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 towitoko-2.0.7/ltmain.sh0000644000175000017500000042561707527762020010726 # ltmain.sh - Provide generalized library-building support services. # NOTE: Changing this file will not affect anything until you rerun configure. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 # Free Software Foundation, Inc. # Originally by Gordon Matzigkeit , 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 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Check that we have a working $echo. if test "X$1" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test "X$1" = X--fallback-echo; then # Avoid inline document here, it may be left over : elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then # Yippee, $echo works! : else # Restart under the correct shell, and then maybe $echo will work. exec $SHELL "$0" --no-reexec ${1+"$@"} fi if test "X$1" = X--fallback-echo; then # used as fallback echo shift cat <&2 echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit 1 fi # Global variables. mode=$default_mode nonopt= prev= prevopt= run= show="$echo" show_help= execute_dlfiles= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" # Parse our command line options once, thoroughly. while test $# -gt 0 do arg="$1" shift case $arg in -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; *) optarg= ;; esac # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in execute_dlfiles) execute_dlfiles="$execute_dlfiles $arg" ;; *) eval "$prev=\$arg" ;; esac prev= prevopt= continue fi # Have we seen a non-optional argument yet? case $arg in --help) show_help=yes ;; --version) echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" exit 0 ;; --config) ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $0 exit 0 ;; --debug) echo "$progname: enabling shell trace mode" set -x ;; --dry-run | -n) run=: ;; --features) echo "host: $host" if test "$build_libtool_libs" = yes; then echo "enable shared libraries" else echo "disable shared libraries" fi if test "$build_old_libs" = yes; then echo "enable static libraries" else echo "disable static libraries" fi exit 0 ;; --finish) mode="finish" ;; --mode) prevopt="--mode" prev=mode ;; --mode=*) mode="$optarg" ;; --preserve-dup-deps) duplicate_deps="yes" ;; --quiet | --silent) show=: ;; -dlopen) prevopt="-dlopen" prev=execute_dlfiles ;; -*) $echo "$modename: unrecognized option \`$arg'" 1>&2 $echo "$help" 1>&2 exit 1 ;; *) nonopt="$arg" break ;; esac done if test -n "$prevopt"; then $echo "$modename: option \`$prevopt' requires an argument" 1>&2 $echo "$help" 1>&2 exit 1 fi # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= if test -z "$show_help"; then # Infer the operation mode. if test -z "$mode"; then case $nonopt in *cc | *++ | gcc* | *-gcc*) mode=link for arg do case $arg in -c) mode=compile break ;; esac done ;; *db | *dbx | *strace | *truss) mode=execute ;; *install*|cp|mv) mode=install ;; *rm) mode=uninstall ;; *) # If we have no mode, but dlfiles were specified, then do execute mode. test -n "$execute_dlfiles" && mode=execute # Just use the default operation mode. if test -z "$mode"; then if test -n "$nonopt"; then $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 else $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 fi fi ;; esac fi # Only execute mode is allowed to have -dlopen flags. if test -n "$execute_dlfiles" && test "$mode" != execute; then $echo "$modename: unrecognized option \`-dlopen'" 1>&2 $echo "$help" 1>&2 exit 1 fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$modename --help --mode=$mode' for more information." # These modes are in order of execution frequency so that they run quickly. case $mode in # libtool compile mode compile) modename="$modename: compile" # Get the compilation command and the source file. base_compile= prev= lastarg= srcfile="$nonopt" suppress_output= user_target=no for arg do case $prev in "") ;; xcompiler) # Aesthetically quote the previous argument. prev= lastarg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac # Add the previous argument to base_compile. if test -z "$base_compile"; then base_compile="$lastarg" else base_compile="$base_compile $lastarg" fi continue ;; esac # Accept any command-line options. case $arg in -o) if test "$user_target" != "no"; then $echo "$modename: you cannot specify \`-o' more than once" 1>&2 exit 1 fi user_target=next ;; -static) build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; -Xcompiler) prev=xcompiler continue ;; -Wc,*) args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"` lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac lastarg="$lastarg $arg" done IFS="$save_ifs" lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"` # Add the arguments to base_compile. if test -z "$base_compile"; then base_compile="$lastarg" else base_compile="$base_compile $lastarg" fi continue ;; esac case $user_target in next) # The next one is the -o target name user_target=yes continue ;; yes) # We got the output file user_target=set libobj="$arg" continue ;; esac # Accept the current argument as the source file. lastarg="$srcfile" srcfile="$arg" # Aesthetically quote the previous argument. # Backslashify any backslashes, double quotes, and dollar signs. # These are the only characters that are still specially # interpreted inside of double-quoted scrings. lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` # Double-quote args containing other shell metacharacters. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. case $lastarg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") lastarg="\"$lastarg\"" ;; esac # Add the previous argument to base_compile. if test -z "$base_compile"; then base_compile="$lastarg" else base_compile="$base_compile $lastarg" fi done case $user_target in set) ;; no) # Get the name of the library object. libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` ;; *) $echo "$modename: you must specify a target with \`-o'" 1>&2 exit 1 ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo xform='[cCFSfmso]' case $libobj in *.ada) xform=ada ;; *.adb) xform=adb ;; *.ads) xform=ads ;; *.asm) xform=asm ;; *.c++) xform=c++ ;; *.cc) xform=cc ;; *.cpp) xform=cpp ;; *.cxx) xform=cxx ;; *.f90) xform=f90 ;; *.for) xform=for ;; esac libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` case $libobj in *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; *) $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 exit 1 ;; esac if test -z "$base_compile"; then $echo "$modename: you must specify a compilation command" 1>&2 $echo "$help" 1>&2 exit 1 fi # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $libobj" else removelist="$libobj" fi $run $rm $removelist trap "$run $rm $removelist; exit 1" 1 2 15 # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" removelist="$removelist $output_obj $lockfile" trap "$run $rm $removelist; exit 1" 1 2 15 else need_locks=no lockfile= fi # Lock this critical section if it is needed # We use this script file to make the link, it avoids creating a new file if test "$need_locks" = yes; then until $run ln "$0" "$lockfile" 2>/dev/null; do $show "Waiting for $lockfile to be removed" sleep 2 done elif test "$need_locks" = warn; then if test -f "$lockfile"; then echo "\ *** ERROR, $lockfile exists and contains: `cat $lockfile 2>/dev/null` This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit 1 fi echo $srcfile > "$lockfile" fi if test -n "$fix_srcfile_path"; then eval srcfile=\"$fix_srcfile_path\" fi # Only build a PIC object if we are building libtool libraries. if test "$build_libtool_libs" = yes; then # Without this assignment, base_compile gets emptied. fbsd_hideous_sh_bug=$base_compile if test "$pic_mode" != no; then # All platforms use -DPIC, to notify preprocessed assembler code. command="$base_compile $srcfile $pic_flag -DPIC" else # Don't build PIC code command="$base_compile $srcfile" fi if test "$build_old_libs" = yes; then lo_libobj="$libobj" dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` if test "X$dir" = "X$libobj"; then dir="$objdir" else dir="$dir/$objdir" fi libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` if test -d "$dir"; then $show "$rm $libobj" $run $rm $libobj else $show "$mkdir $dir" $run $mkdir $dir status=$? if test $status -ne 0 && test ! -d $dir; then exit $status fi fi fi if test "$compiler_o_lo" = yes; then output_obj="$libobj" command="$command -o $output_obj" elif test "$compiler_c_o" = yes; then output_obj="$obj" command="$command -o $output_obj" fi $run $rm "$output_obj" $show "$command" if $run eval "$command"; then : else test -n "$output_obj" && $run $rm $removelist exit 1 fi if test "$need_locks" = warn && test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit 1 fi # Just move the object if needed, then go on to compile the next one if test x"$output_obj" != x"$libobj"; then $show "$mv $output_obj $libobj" if $run $mv $output_obj $libobj; then : else error=$? $run $rm $removelist exit $error fi fi # If we have no pic_flag, then copy the object into place and finish. if (test -z "$pic_flag" || test "$pic_mode" != default) && test "$build_old_libs" = yes; then # Rename the .lo from within objdir to obj if test -f $obj; then $show $rm $obj $run $rm $obj fi $show "$mv $libobj $obj" if $run $mv $libobj $obj; then : else error=$? $run $rm $removelist exit $error fi xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$obj"; then xdir="." else xdir="$xdir" fi baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` # Now arrange that obj and lo_libobj become the same file $show "(cd $xdir && $LN_S $baseobj $libobj)" if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then # Unlock the critical section if it was locked if test "$need_locks" != no; then $run $rm "$lockfile" fi exit 0 else error=$? $run $rm $removelist exit $error fi fi # Allow error messages only from the first compilation. suppress_output=' >/dev/null 2>&1' fi # Only build a position-dependent object if we build old libraries. if test "$build_old_libs" = yes; then if test "$pic_mode" != yes; then # Don't build PIC code command="$base_compile $srcfile" else # All platforms use -DPIC, to notify preprocessed assembler code. command="$base_compile $srcfile $pic_flag -DPIC" fi if test "$compiler_c_o" = yes; then command="$command -o $obj" output_obj="$obj" fi # Suppress compiler output if we already did a PIC compilation. command="$command$suppress_output" $run $rm "$output_obj" $show "$command" if $run eval "$command"; then : else $run $rm $removelist exit 1 fi if test "$need_locks" = warn && test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then echo "\ *** ERROR, $lockfile contains: `cat $lockfile 2>/dev/null` but it should contain: $srcfile This indicates that another process is trying to use the same temporary object file, and libtool could not work around it because your compiler does not support \`-c' and \`-o' together. If you repeat this compilation, it may succeed, by chance, but you had better avoid parallel builds (make -j) in this platform, or get a better compiler." $run $rm $removelist exit 1 fi # Just move the object if needed if test x"$output_obj" != x"$obj"; then $show "$mv $output_obj $obj" if $run $mv $output_obj $obj; then : else error=$? $run $rm $removelist exit $error fi fi # Create an invalid libtool object if no PIC, so that we do not # accidentally link it into a program. if test "$build_libtool_libs" != yes; then $show "echo timestamp > $libobj" $run eval "echo timestamp > \$libobj" || exit $? else # Move the .lo from within objdir $show "$mv $libobj $lo_libobj" if $run $mv $libobj $lo_libobj; then : else error=$? $run $rm $removelist exit $error fi fi fi # Unlock the critical section if it was locked if test "$need_locks" != no; then $run $rm "$lockfile" fi exit 0 ;; # libtool link mode link | relink) modename="$modename: link" case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) # It is impossible to link a dll without this setting, and # we shouldn't force the makefile maintainer to figure out # which system we are compiling for in order to pass an extra # flag for every libtool invokation. # allow_undefined=no # FIXME: Unfortunately, there are problems with the above when trying # to make a dll which has undefined symbols, in which case not # even a static library is built. For now, we need to specify # -no-undefined on the libtool link line when we can be certain # that all symbols are satisfied, otherwise we get a static library. allow_undefined=yes ;; *) allow_undefined=yes ;; esac libtool_args="$nonopt" compile_command="$nonopt" finalize_command="$nonopt" compile_rpath= finalize_rpath= compile_shlibpath= finalize_shlibpath= convenience= old_convenience= deplibs= old_deplibs= compiler_flags= linker_flags= dllsearchpath= lib_search_path=`pwd` avoid_version=no dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= # We need to know -static, to get the right output filenames. for arg do case $arg in -all-static | -static) if test "X$arg" = "X-all-static"; then if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi else if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi fi build_libtool_libs=no build_old_libs=yes prefer_static_libs=yes break ;; esac done # See if our shared archives depend on static archives. test -n "$old_archive_from_new_cmds" && build_old_libs=yes # Go through the arguments, transforming them on the way. while test $# -gt 0; do arg="$1" shift case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test ;; *) qarg=$arg ;; esac libtool_args="$libtool_args $qarg" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) compile_command="$compile_command @OUTPUT@" finalize_command="$finalize_command @OUTPUT@" ;; esac case $prev in dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. compile_command="$compile_command @SYMFILE@" finalize_command="$finalize_command @SYMFILE@" preload=yes fi case $arg in *.la | *.lo) ;; # We handle these cases below. force) if test "$dlself" = no; then dlself=needless export_dynamic=yes fi prev= continue ;; self) if test "$prev" = dlprefiles; then dlself=yes elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then dlself=yes else dlself=needless export_dynamic=yes fi prev= continue ;; *) if test "$prev" = dlfiles; then dlfiles="$dlfiles $arg" else dlprefiles="$dlprefiles $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" if test ! -f "$arg"; then $echo "$modename: symbol file \`$arg' does not exist" exit 1 fi prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit 1 ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) rpath="$rpath $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) xrpath="$xrpath $arg" ;; esac fi prev= continue ;; xcompiler) compiler_flags="$compiler_flags $qarg" prev= compile_command="$compile_command $qarg" finalize_command="$finalize_command $qarg" continue ;; xlinker) linker_flags="$linker_flags $qarg" compiler_flags="$compiler_flags $wl$qarg" prev= compile_command="$compile_command $wl$qarg" finalize_command="$finalize_command $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n $prev prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then compile_command="$compile_command $link_static_flag" finalize_command="$finalize_command $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 continue ;; -avoid-version) avoid_version=yes continue ;; -dlopen) prev=dlfiles continue ;; -dlpreopen) prev=dlprefiles continue ;; -export-dynamic) export_dynamic=yes continue ;; -export-symbols | -export-symbols-regex) if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: more than one -exported-symbols argument is not allowed" exit 1 fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | no/*-*-nonstopux*) compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" ;; esac continue ;; -L*) dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 exit 1 fi dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "*) ;; *) deplibs="$deplibs -L$dir" lib_search_path="$lib_search_path $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) case :$dllsearchpath: in *":$dir:"*) ;; *) dllsearchpath="$dllsearchpath:$dir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-pw32* | *-*-beos*) # These systems don't actually have a C or math library (as such) continue ;; *-*-mingw* | *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi deplibs="$deplibs $arg" continue ;; -module) module=yes continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) # The PATH hackery in wrapper scripts is required on Windows # in order for the loader to find any dlls it needs. $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2 $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2 fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -o) prev=output ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) $echo "$modename: only absolute run-paths are allowed" 1>&2 exit 1 ;; esac case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac continue ;; -static) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -Wc,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" case $flag in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") flag="\"$flag\"" ;; esac arg="$arg $wl$flag" compiler_flags="$compiler_flags $flag" done IFS="$save_ifs" arg=`$echo "X$arg" | $Xsed -e "s/^ //"` ;; -Wl,*) args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'` arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" case $flag in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") flag="\"$flag\"" ;; esac arg="$arg $wl$flag" compiler_flags="$compiler_flags $wl$flag" linker_flags="$linker_flags $flag" done IFS="$save_ifs" arg=`$echo "X$arg" | $Xsed -e "s/^ //"` ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; # Some other compiler flag. -* | +*) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac ;; *.lo | *.$objext) # A library or standard object. if test "$prev" = dlfiles; then # This file was specified with -dlopen. if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then dlfiles="$dlfiles $arg" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi if test "$prev" = dlprefiles; then # Preload the old-style object. dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` prev= else case $arg in *.lo) libobjs="$libobjs $arg" ;; *) objs="$objs $arg" ;; esac fi ;; *.$libext) # An archive. deplibs="$deplibs $arg" old_deplibs="$old_deplibs $arg" continue ;; *.la) # A libtool-controlled library. if test "$prev" = dlfiles; then # This library was specified with -dlopen. dlfiles="$dlfiles $arg" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. dlprefiles="$dlprefiles $arg" prev= else deplibs="$deplibs $arg" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") arg="\"$arg\"" ;; esac ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi done # argument parsing loop if test -n "$prev"; then $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 $echo "$help" 1>&2 exit 1 fi if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" compile_command="$compile_command $arg" finalize_command="$finalize_command $arg" fi # calculate the name of the file, without its directory outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` else shlib_search_path= fi eval sys_lib_search_path=\"$sys_lib_search_path_spec\" eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` if test "X$output_objdir" = "X$output"; then output_objdir="$objdir" else output_objdir="$output_objdir/$objdir" fi # Create the object directory. if test ! -d $output_objdir; then $show "$mkdir $output_objdir" $run $mkdir $output_objdir status=$? if test $status -ne 0 && test ! -d $output_objdir; then exit $status fi fi # Determine the type of output case $output in "") $echo "$modename: you must specify an output file" 1>&2 $echo "$help" 1>&2 exit 1 ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if test "X$duplicate_deps" = "Xyes" ; then case "$libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi libs="$libs $deplib" done deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2 exit 1 ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do if test $linkmode = prog; then # Determine which files to process case $pass in dlopen) libs="$dlfiles" save_deplibs="$deplibs" # Collect dlpreopened libraries deplibs= ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; esac fi for deplib in $libs; do lib= found=no case $deplib in -l*) if test $linkmode = oldlib && test $linkmode = obj; then $echo "$modename: warning: \`-l' is ignored for archives/objects: $deplib" 1>&2 continue fi if test $pass = conv; then deplibs="$deplib $deplibs" continue fi name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do # Search the libtool library lib="$searchdir/lib${name}.la" if test -f "$lib"; then found=yes break fi done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test $linkmode = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi ;; # -l -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test $pass = conv && continue newdependency_libs="$deplib $newdependency_libs" newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` ;; prog) if test $pass = conv; then deplibs="$deplib $deplibs" continue fi if test $pass = scan; then deplibs="$deplib $deplibs" newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi ;; *) $echo "$modename: warning: \`-L' is ignored for archives/objects: $deplib" 1>&2 ;; esac # linkmode continue ;; # -L -R*) if test $pass = link; then dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) xrpath="$xrpath $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) lib="$deplib" ;; *.$libext) if test $pass = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) if test "$deplibs_check_method" != pass_all; then echo echo "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not used here." else echo echo "*** Warning: Linking the shared library $output against the" echo "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi continue ;; prog) if test $pass != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test $pass = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. newdlprefiles="$newdlprefiles $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else newdlfiles="$newdlfiles $deplib" fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test $found = yes || test -f "$lib"; then : else $echo "$modename: cannot find the library \`$lib'" 1>&2 exit 1 fi # Check to see that this really is a libtool archive. if (${SED} -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 fi ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` test "X$ladir" = "X$lib" && ladir="." dlname= dlopen= dlpreopen= libdir= library_names= old_library= # If the library was installed with an old release of libtool, # it will not redefine variable installed. installed=yes # Read the .la file case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test $linkmode = oldlib && test $linkmode = obj; }; then # Add dl[pre]opened files of deplib test -n "$dlopen" && dlfiles="$dlfiles $dlopen" test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" fi if test $pass = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 exit 1 fi # It is a libtool convenience library, so add in its objects. convenience="$convenience $ladir/$objdir/$old_library" old_convenience="$old_convenience $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done elif test $linkmode != prog && test $linkmode != lib; then $echo "$modename: \`$lib' is not a convenience library" 1>&2 exit 1 fi continue fi # $pass = conv # Get the name of the library we link against. linklib= for l in $old_library $library_names; do linklib="$l" done if test -z "$linklib"; then $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 exit 1 fi # This library was specified with -dlopen. if test $pass = dlopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2 exit 1 fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. dlprefiles="$dlprefiles $lib" else newdlfiles="$newdlfiles $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 abs_ladir="$ladir" fi ;; esac laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then $echo "$modename: warning: library \`$lib' was moved." 1>&2 dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$libdir" absdir="$libdir" fi else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later notinst_path="$notinst_path $abs_ladir" fi # $installed = yes name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` # This library was specified with -dlpreopen. if test $pass = dlpreopen; then if test -z "$libdir"; then $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2 exit 1 fi # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then newdlprefiles="$newdlprefiles $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then newdlprefiles="$newdlprefiles $dir/$dlname" else newdlprefiles="$newdlprefiles $dir/$linklib" fi fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test $linkmode = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" fi continue fi if test $linkmode = prog && test $pass != link; then newlib_search_path="$newlib_search_path $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test esac # Need to link against all dependency_libs? if test $linkalldeplibs = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done # for deplib continue fi # $linkmode = prog... link_static=no # Whether the deplib will be linked statically if test -n "$library_names" && { test "$prefer_static_libs" = no || test -z "$old_library"; }; then # Link against this shared library if test "$linkmode,$pass" = "prog,link" || { test $linkmode = lib && test $hardcode_into_libs = yes; }; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) compile_rpath="$compile_rpath $absdir" esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" esac ;; esac if test $linkmode = prog; then # We need to hardcode the library path if test -n "$shlibpath_var"; then # Make sure the rpath contains only unique directories. case "$temp_rpath " in *" $dir "*) ;; *" $absdir "*) ;; *) temp_rpath="$temp_rpath $dir" ;; esac fi fi fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi if test "$installed" = no; then notinst_deplibs="$notinst_deplibs $lib" need_relink=yes fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names realname="$2" shift; shift libname=`eval \\$echo \"$libname_spec\"` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin*) major=`expr $current - $age` versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" soname=`echo $soroot | ${SED} -e 's/^.*\///'` newlib="libimp-`echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a" # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else $show "extracting exported symbol list from \`$soname'" save_ifs="$IFS"; IFS='~' eval cmds=\"$extract_expsyms_cmds\" for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else $show "generating import library for \`$soname'" save_ifs="$IFS"; IFS='~' eval cmds=\"$old_archive_from_expsyms_cmds\" for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n $old_archive_from_expsyms_cmds if test $linkmode = prog || test "$mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then $echo "$modename: configuration error: unsupported hardcode properties" exit 1 fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; esac fi if test $linkmode = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && \ test "$hardcode_minus_L" != yes && \ test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac fi fi fi if test $linkmode = prog || test "$mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; esac add="-l$name" else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" add="-l$name" fi if test $linkmode = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test $linkmode = prog; then if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi # Try to link the static library # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo echo "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else convenience="$convenience $dir/$old_library" old_convenience="$old_convenience $dir/$old_library" deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test $linkmode = lib; then if test -n "$dependency_libs" && { test $hardcode_into_libs != yes || test $build_old_libs = yes || test $link_static = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` case " $xrpath " in *" $temp_xrpath "*) ;; *) xrpath="$xrpath $temp_xrpath";; esac;; *) temp_deplibs="$temp_deplibs $libdir";; esac done dependency_libs="$temp_deplibs" fi newlib_search_path="$newlib_search_path $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" if test "X$duplicate_deps" = "Xyes" ; then case "$tmp_libs " in *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; esac fi tmp_libs="$tmp_libs $deplib" done if test $link_all_deplibs != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do case $deplib in -L*) path="$deplib" ;; *.la) dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$deplib" && dir="." # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 absdir="$dir" fi ;; esac if grep "^installed=no" $deplib > /dev/null; then path="-L$absdir/$objdir" else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit 1 fi if test "$absdir" != "$libdir"; then $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2 fi path="-L$absdir" fi ;; *) continue ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$deplibs $path" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test $pass = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test $pass != dlopen; then test $pass != scan && dependency_libs="$newdependency_libs" if test $pass != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) lib_search_path="$lib_search_path $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do case $deplib in -L*) new_libs="$deplib $new_libs" ;; *) case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) tmp_libs="$tmp_libs $deplib" ;; esac ;; *) tmp_libs="$tmp_libs $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi if test "$pass" = "conv" && { test "$linkmode" = "lib" || test "$linkmode" = "prog"; }; then libs="$deplibs" # reset libs deplibs= fi done # for pass if test $linkmode = prog; then dlfiles="$newdlfiles" dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 fi if test -n "$rpath"; then $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 fi if test -n "$xrpath"; then $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 fi if test -n "$export_symbols" || test -n "$export_symbols_regex"; then $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 fi # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" objs="$objs$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` eval libname=\"$libname_spec\" ;; *) if test "$module" = no; then $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 $echo "$help" 1>&2 exit 1 fi if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` eval libname=\"$libname_spec\" else libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1 exit 1 else echo echo "*** Warning: Linking the shared library $output against the non-libtool" echo "*** objects $objs is not portable!" libobjs="$libobjs $objs" fi fi if test "$dlself" != no; then $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2 fi set dummy $rpath if test $# -gt 2; then $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 fi install_libdir="$2" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. libext=al oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 fi else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 IFS="$save_ifs" if test -n "$8"; then $echo "$modename: too many parameters to \`-version-info'" 1>&2 $echo "$help" 1>&2 exit 1 fi current="$2" revision="$3" age="$4" # Check that each of the things are valid numbers. case $current in 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; *) $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit 1 ;; esac case $revision in 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; *) $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit 1 ;; esac case $age in 0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;; *) $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit 1 ;; esac if test $age -gt $current; then $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 $echo "$modename: \`$vinfo' is not valid version information" 1>&2 exit 1 fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header major=.`expr $current - $age` versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... minor_current=`expr $current + 1` verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current"; ;; irix | nonstopux) major=`expr $current - $age + 1` case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test $loop != 0; do iface=`expr $revision - $loop` loop=`expr $loop - 1` verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) major=.`expr $current - $age` versuffix="$major.$age.$revision" ;; osf) major=`expr $current - $age` versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test $loop != 0; do iface=`expr $current - $loop` loop=`expr $loop - 1` verstring="$verstring:${iface}.0" done # Make executables depend on our current version. verstring="$verstring:${current}.0" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. major=`expr $current - $age` versuffix="-$major" ;; *) $echo "$modename: unknown library version type \`$version_type'" 1>&2 echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 exit 1 ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= verstring="0.0" case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring="" ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi if test "$mode" != relink; then # Remove our outputs. $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then oldlibs="$oldlibs $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` fi # Eliminate all temporary directories. for path in $notinst_path; do lib_search_path=`echo "$lib_search_path " | ${SED} -e 's% $path % %g'` deplibs=`echo "$deplibs " | ${SED} -e 's% -L$path % %g'` dependency_libs=`echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'` done if test -n "$xrpath"; then # If the user specified any rpath flags, then add them. temp_xrpath= for libdir in $xrpath; do temp_xrpath="$temp_xrpath -R$libdir" case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done if test $hardcode_into_libs != yes || test $build_old_libs = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) dlfiles="$dlfiles $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) dlprefiles="$dlprefiles $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework deplibs="$deplibs -framework System" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd*) # Do not include libc due to us having libc/libc_r. ;; *) # Add libc to deplibs on all other systems if necessary. if test $build_libtool_need_lc = "yes"; then deplibs="$deplibs -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behaviour. newdeplibs=$deplibs ;; test_compile) # This code stresses the "libraries are programs" paradigm to its # limits. Maybe even breaks it. We compile a program, linking it # against the deplibs as a proxy for the library. Then we can check # whether they linked in statically or dynamically with ldd. $rm conftest.c cat > conftest.c </dev/null` for potent_lib in $potential_libs; do # Follow soft links. if ls -lLd "$potent_lib" 2>/dev/null \ | grep " -> " >/dev/null; then continue fi # The statement above tries to avoid entering an # endless loop below, in case of cyclic links. # We might still enter an endless loop, since a link # loop can be closed while we follow links, # but so what? potlib="$potent_lib" while test -h "$potlib" 2>/dev/null; do potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` case $potliblink in [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ | ${SED} 10q \ | egrep "$file_magic_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done if test -n "$a_deplib" ; then droppeddeps=yes echo echo "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then echo "*** with $libname but no candidates were found. (...for file magic test)" else echo "*** with $libname and none of the candidates passed a file format test" echo "*** using a file magic. Last file checked: $potlib" fi fi else # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" fi done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"` for a_deplib in $deplibs; do name="`expr $a_deplib : '-l\(.*\)'`" # If $name is empty we are operating on a -L argument. if test -n "$name" && test "$name" != "0"; then libname=`eval \\$echo \"$libname_spec\"` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check below in file_magic test if eval echo \"$potent_lib\" 2>/dev/null \ | ${SED} 10q \ | egrep "$match_pattern_regex" > /dev/null; then newdeplibs="$newdeplibs $a_deplib" a_deplib="" break 2 fi done done if test -n "$a_deplib" ; then droppeddeps=yes echo echo "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then echo "*** with $libname but no candidates were found. (...for regex pattern test)" else echo "*** with $libname and none of the candidates passed a file format test" echo "*** using a regex pattern. Last file checked: $potlib" fi fi else # Add a -L argument. newdeplibs="$newdeplibs $a_deplib" fi done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | grep . >/dev/null; then echo if test "X$deplibs_check_method" = "Xnone"; then echo "*** Warning: inter-library dependencies are not supported in this platform." else echo "*** Warning: inter-library dependencies are not known to be supported." fi echo "*** All declared inter-library dependencies are being dropped." droppeddeps=yes fi ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" echo "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test $allow_undefined = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # All the library-specific variables (install_libdir is set above). library_names= old_library= dlname= # Test again, we may have decided not to build it any more if test "$build_libtool_libs" = yes; then if test $hardcode_into_libs = yes; then # Hardcode the library paths hardcode_libdirs= dep_rpath= rpath="$finalize_rpath" test "$mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" dep_rpath="$dep_rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" fi test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" fi shlibpath="$finalize_shlibpath" test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval library_names=\"$library_names_spec\" set dummy $library_names realname="$2" shift; shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi test -z "$dlname" && dlname=$soname lib="$output_objdir/$realname" for link do linknames="$linknames $link" done # Ensure that we have .o objects for linkers which dislike .lo # (e.g. aix) in case we are running --disable-static for obj in $libobjs; do xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$obj"; then xdir="." else xdir="$xdir" fi baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` if test ! -f $xdir/$oldobj; then $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? fi done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then $show "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $run $rm $export_symbols eval cmds=\"$export_symbols_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" if test -n "$export_symbols_regex"; then $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' $show "$mv \"${export_symbols}T\" \"$export_symbols\"" $run eval '$mv "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' fi if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" else gentop="$output_objdir/${outputname}x" $show "${rm}r $gentop" $run ${rm}r "$gentop" $show "mkdir $gentop" $run mkdir "$gentop" status=$? if test $status -ne 0 && test ! -d "$gentop"; then exit $status fi generated="$generated $gentop" for xlib in $convenience; do # Extract the objects. case $xlib in [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; *) xabs=`pwd`"/$xlib" ;; esac xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` xdir="$gentop/$xlib" $show "${rm}r $xdir" $run ${rm}r "$xdir" $show "mkdir $xdir" $run mkdir "$xdir" status=$? if test $status -ne 0 && test ! -d "$xdir"; then exit $status fi $show "(cd $xdir && $AR x $xabs)" $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` done fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" linker_flags="$linker_flags $flag" fi # Make a backup of the uninstalled library when relinking if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval cmds=\"$archive_expsym_cmds\" else save_deplibs="$deplibs" for conv in $convenience; do tmp_deplibs= for test_deplib in $deplibs; do if test "$test_deplib" != "$conv"; then tmp_deplibs="$tmp_deplibs $test_deplib" fi done deplibs="$tmp_deplibs" done eval cmds=\"$archive_cmds\" deplibs="$save_deplibs" fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$mode" = relink; then $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? exit 0 fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? fi done # If -module or -export-dynamic was specified, set the dlname. if test "$module" = yes || test "$export_dynamic" = yes; then # On all known operating systems, these are identical. dlname="$soname" fi fi ;; obj) if test -n "$deplibs"; then $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 fi if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 fi if test -n "$rpath"; then $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 fi if test -n "$xrpath"; then $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 fi if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 fi case $output in *.lo) if test -n "$objs$old_deplibs"; then $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 exit 1 fi libobj="$output" obj=`$echo "X$output" | $Xsed -e "$lo2o"` ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $run $rm $obj $libobj # Objects from convenience libraries. This assumes # single-version convenience libraries. Whenever we create # different ones for PIC/non-PIC, this we'll have to duplicate # the extraction. reload_conv_objs= gentop= # reload_cmds runs $LD directly, so let us get rid of # -Wl from whole_archive_flag_spec wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" else gentop="$output_objdir/${obj}x" $show "${rm}r $gentop" $run ${rm}r "$gentop" $show "mkdir $gentop" $run mkdir "$gentop" status=$? if test $status -ne 0 && test ! -d "$gentop"; then exit $status fi generated="$generated $gentop" for xlib in $convenience; do # Extract the objects. case $xlib in [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; *) xabs=`pwd`"/$xlib" ;; esac xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` xdir="$gentop/$xlib" $show "${rm}r $xdir" $run ${rm}r "$xdir" $show "mkdir $xdir" $run mkdir "$xdir" status=$? if test $status -ne 0 && test ! -d "$xdir"; then exit $status fi $show "(cd $xdir && $AR x $xabs)" $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` done fi fi # Create the old-style object. reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" eval cmds=\"$reload_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi exit 0 fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi # Create an invalid libtool object if no PIC, so that we don't # accidentally link it into a program. $show "echo timestamp > $libobj" $run eval "echo timestamp > $libobj" || exit $? exit 0 fi if test -n "$pic_flag" || test "$pic_mode" != default; then # Only do commands if we really have different PIC objects. reload_objs="$libobjs $reload_conv_objs" output="$libobj" eval cmds=\"$reload_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" else # Just create a symlink. $show $rm $libobj $run $rm $libobj xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$libobj"; then xdir="." else xdir="$xdir" fi baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` $show "(cd $xdir && $LN_S $oldobj $baseobj)" $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? fi if test -n "$gentop"; then $show "${rm}r $gentop" $run ${rm}r $gentop fi exit 0 ;; prog) case $host in *cygwin*) output=`echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;; esac if test -n "$vinfo"; then $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 fi if test -n "$release"; then $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 fi if test "$preload" = yes; then if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown && test "$dlopen_self_static" = unknown; then $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." fi fi case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'` finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'` ;; esac compile_command="$compile_command $compile_deplibs" finalize_command="$finalize_command $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) finalize_rpath="$finalize_rpath $libdir" ;; esac done fi # Now hardcode the library paths rpath= hardcode_libdirs= for libdir in $compile_rpath $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) perm_rpath="$perm_rpath $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*) case :$dllsearchpath: in *":$libdir:"*) ;; *) dllsearchpath="$dllsearchpath:$libdir";; esac ;; esac done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi compile_rpath="$rpath" rpath= hardcode_libdirs= for libdir in $finalize_rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then if test -z "$hardcode_libdirs"; then hardcode_libdirs="$libdir" else # Just accumulate the unique libdirs. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) ;; *) hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" rpath="$rpath $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; esac fi done # Substitute the hardcoded libdirs into the rpath. if test -n "$hardcode_libdir_separator" && test -n "$hardcode_libdirs"; then libdir="$hardcode_libdirs" eval rpath=\" $hardcode_libdir_flag_spec\" fi finalize_rpath="$rpath" if test -n "$libobjs" && test "$build_old_libs" = yes; then # Transform all the library objects into standard objects. compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` fi dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then dlsyms="${outputname}S.c" else $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 fi fi if test -n "$dlsyms"; then case $dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${outputname}.nm" $show "$rm $nlist ${nlist}S ${nlist}T" $run $rm "$nlist" "${nlist}S" "${nlist}T" # Parse the name list into a source file. $show "creating $output_objdir/$dlsyms" test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ /* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ /* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ #ifdef __cplusplus extern \"C\" { #endif /* Prevent the only kind of declaration conflicts we can make. */ #define lt_preloaded_symbols some_other_symbol /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then $show "generating symbol list for \`$output'" test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` for arg in $progfiles; do $show "extracting global C symbols from \`$arg'" $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi if test -n "$export_symbols_regex"; then $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' $run eval '$mv "$nlist"T "$nlist"' fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$output.exp" $run $rm $export_symbols $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' else $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' $run eval 'mv "$nlist"T "$nlist"' fi fi for arg in $dlprefiles; do $show "extracting global C symbols from \`$arg'" name=`echo "$arg" | ${SED} -e 's%^.*/%%'` $run eval 'echo ": $name " >> "$nlist"' $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" done if test -z "$run"; then # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $mv "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if grep -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else grep -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' else echo '/* NONE */' >> "$output_objdir/$dlsyms" fi $echo >> "$output_objdir/$dlsyms" "\ #undef lt_preloaded_symbols #if defined (__STDC__) && __STDC__ # define lt_ptr void * #else # define lt_ptr char * # define const #endif /* The mapping between symbol names and symbols. */ const struct { const char *name; lt_ptr address; } lt_preloaded_symbols[] = {\ " eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms" $echo >> "$output_objdir/$dlsyms" "\ {0, (lt_ptr) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " fi pic_flag_for_symtable= case $host in # compiling the symbol table file with pic_flag works around # a FreeBSD bug that causes programs to crash when -lm is # linked before any other PIC object. But we must not use # pic_flag when linking with -static. The problem exists in # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) case "$compile_command " in *" -static "*) ;; *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; esac;; *-*-hpux*) case "$compile_command " in *" -static "*) ;; *) pic_flag_for_symtable=" $pic_flag -DPIC";; esac esac # Now compile the dynamic symbol file. $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? # Clean up the generated files. $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" # Transform the symbol file into the correct name. compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` ;; *) $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 exit 1 ;; esac else # We keep going just in case the user didn't refer to # lt_preloaded_symbols. The linker will fail if global_symbol_pipe # really was required. # Nullify the symbol file. compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` fi if test $need_relink = no || test "$build_libtool_libs" != yes; then # Replace the output file specification. compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. $show "$link_command" $run eval "$link_command" status=$? # Delete the generated files. if test -n "$dlsyms"; then $show "$rm $output_objdir/${outputname}S.${objext}" $run $rm "$output_objdir/${outputname}S.${objext}" fi exit $status fi if test -n "$shlibpath_var"; then # We should set the shlibpath_var rpath= for dir in $temp_rpath; do case $dir in [\\/]* | [A-Za-z]:[\\/]*) # Absolute path. rpath="$rpath$dir:" ;; *) # Relative path: add a thisdir entry. rpath="$rpath\$thisdir/$dir:" ;; esac done temp_rpath="$rpath" fi if test -n "$compile_shlibpath$finalize_shlibpath"; then compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" fi if test -n "$finalize_shlibpath"; then finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" fi compile_var= finalize_var= if test -n "$runpath_var"; then if test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do rpath="$rpath$dir:" done compile_var="$runpath_var=\"$rpath\$$runpath_var\" " fi if test -n "$finalize_perm_rpath"; then # We should set the runpath_var. rpath= for dir in $finalize_perm_rpath; do rpath="$rpath$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $run $rm $output # Link the executable and exit $show "$link_command" $run eval "$link_command" || exit $? exit 0 fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 $echo "$modename: \`$output' will be relinked during installation" 1>&2 else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` else # fast_install is set to needless relink_command= fi else link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" fi fi # Replace the output file specification. link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname $show "$link_command" $run eval "$link_command" || exit $? # Now create the wrapper script. $show "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` fi # Quote $echo for shipping. if test "X$echo" = "X$SHELL $0 --fallback-echo"; then case $0 in [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; *) qecho="$SHELL `pwd`/$0 --fallback-echo";; esac qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` else qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` fi # Only actually do things if our run command is non-null. if test -z "$run"; then # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) output=`echo $output|${SED} 's,.exe$,,'` ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe ;; *) exeext= ;; esac $rm $output trap "$rm $output; exit 1" 1 2 15 $echo > $output "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # The $output program cannot be directly executed until all the libtool # libraries that it depends on are installed. # # This wrapper script should never be moved out of the build directory. # If it is, it will not operate correctly. # Sed substitution that helps us do robust quoting. It backslashifies # metacharacters that are still active within double-quoted strings. Xsed="${SED}"' -e 1s/^X//' sed_quote_subst='$sed_quote_subst' # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variable: notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$echo are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then echo=\"$qecho\" file=\"\$0\" # Make sure echo works. if test \"X\$1\" = X--no-reexec; then # Discard the --no-reexec flag, and continue. shift elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then # Yippee, \$echo works! : else # Restart under the correct shell, and then maybe \$echo will work. exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} fi fi\ " $echo >> $output "\ # Find the directory that this script lives in. thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` test \"x\$thisdir\" = \"x\$file\" && thisdir=. # Follow symbolic links until we get to the real thisdir. file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` while test -n \"\$file\"; do destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` # If there was a directory component, then change thisdir. if test \"x\$destdir\" != \"x\$file\"; then case \"\$destdir\" in [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; *) thisdir=\"\$thisdir/\$destdir\" ;; esac fi file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` done # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then echo >> $output "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || \\ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $mkdir \"\$progdir\" else $rm \"\$progdir/\$file\" fi" echo >> $output "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $echo \"\$relink_command_output\" >&2 $rm \"\$progdir/\$file\" exit 1 fi fi $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $rm \"\$progdir/\$program\"; $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } $rm \"\$progdir/\$file\" fi" else echo >> $output "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi echo >> $output "\ if test -f \"\$progdir/\$program\"; then" # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $echo >> $output "\ # Add our own library path to $shlibpath_var $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" # Some systems cannot cope with colon-terminated $shlibpath_var # The second colon is a workaround for a bug in BeOS R4 ${SED} $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` export $shlibpath_var " fi # fixup the dll searchpath if we need to. if test -n "$dllsearchpath"; then $echo >> $output "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi $echo >> $output "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. " case $host in # win32 systems need to use the prog path for dll # lookup to work *-*-cygwin* | *-*-pw32*) $echo >> $output "\ exec \$progdir/\$program \${1+\"\$@\"} " ;; # Backslashes separate directories on plain windows *-*-mingw | *-*-os2*) $echo >> $output "\ exec \$progdir\\\\\$program \${1+\"\$@\"} " ;; *) $echo >> $output "\ # Export the path to the program. PATH=\"\$progdir:\$PATH\" export PATH exec \$program \${1+\"\$@\"} " ;; esac $echo >> $output "\ \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" exit 1 fi else # The program doesn't exist. \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 \$echo \"This script is just a wrapper for \$program.\" 1>&2 echo \"See the $PACKAGE documentation for more information.\" 1>&2 exit 1 fi fi\ " chmod +x $output fi exit 0 ;; esac # See if we need to build an old-fashioned archive. for oldlib in $oldlibs; do if test "$build_libtool_libs" = convenience; then oldobjs="$libobjs_save" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" $show "${rm}r $gentop" $run ${rm}r "$gentop" $show "mkdir $gentop" $run mkdir "$gentop" status=$? if test $status -ne 0 && test ! -d "$gentop"; then exit $status fi generated="$generated $gentop" # Add in members from convenience archives. for xlib in $addlibs; do # Extract the objects. case $xlib in [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; *) xabs=`pwd`"/$xlib" ;; esac xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` xdir="$gentop/$xlib" $show "${rm}r $xdir" $run ${rm}r "$xdir" $show "mkdir $xdir" $run mkdir "$xdir" status=$? if test $status -ne 0 && test ! -d "$xdir"; then exit $status fi $show "(cd $xdir && $AR x $xabs)" $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` done fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then eval cmds=\"$old_archive_from_new_cmds\" else # Ensure that we have .o objects in place in case we decided # not to build a shared library, and have fallen back to building # static libs even though --disable-static was passed! for oldobj in $oldobjs; do if test ! -f $oldobj; then xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` if test "X$xdir" = "X$oldobj"; then xdir="." else xdir="$xdir" fi baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` $show "(cd $xdir && ${LN_S} $obj $baseobj)" $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? fi done eval cmds=\"$old_archive_cmds\" fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" done if test -n "$generated"; then $show "${rm}r$generated" $run ${rm}r$generated fi # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" $show "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"` relink_command="$var=\"$var_value\"; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $0 --mode=relink $libtool_args)" relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` # Only create the output if not a dry run. if test -z "$run"; then for installed in no yes; do if test "$installed" = yes; then if test -z "$install_libdir"; then break fi output="$output_objdir/$outputname"i # Replace all uninstalled libtool libraries with the installed ones newdependency_libs= for deplib in $dependency_libs; do case $deplib in *.la) name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` if test -z "$libdir"; then $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 exit 1 fi newdependency_libs="$newdependency_libs $libdir/$name" ;; *) newdependency_libs="$newdependency_libs $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 fi newdlfiles="$newdlfiles $libdir/$name" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` if test -z "$libdir"; then $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 exit 1 fi newdlprefiles="$newdlprefiles $libdir/$name" done dlprefiles="$newdlprefiles" fi $rm $output # place dlname in correct position for cygwin tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; esac $echo > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test $need_relink = yes; then $echo >> $output "\ relink_command=\"$relink_command\"" fi done fi # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? ;; esac exit 0 ;; # libtool install mode install) modename="$modename: install" # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then # Aesthetically quote it. arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) arg="\"$arg\"" ;; esac install_prog="$arg " arg="$1" shift else install_prog= arg="$nonopt" fi # The real first argument should be the name of the installation program. # Aesthetically quote it. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) arg="\"$arg\"" ;; esac install_prog="$install_prog$arg" # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= for arg do if test -n "$dest"; then files="$files $dest" dest="$arg" continue fi case $arg in -d) isdir=yes ;; -f) prev="-f" ;; -g) prev="-g" ;; -m) prev="-m" ;; -o) prev="-o" ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then prev= else dest="$arg" continue fi ;; esac # Aesthetically quote the argument. arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` case $arg in *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) arg="\"$arg\"" ;; esac install_prog="$install_prog $arg" done if test -z "$install_prog"; then $echo "$modename: you must specify an install program" 1>&2 $echo "$help" 1>&2 exit 1 fi if test -n "$prev"; then $echo "$modename: the \`$prev' option requires an argument" 1>&2 $echo "$help" 1>&2 exit 1 fi if test -z "$files"; then if test -z "$dest"; then $echo "$modename: no file or destination specified" 1>&2 else $echo "$modename: you must specify a destination" 1>&2 fi $echo "$help" 1>&2 exit 1 fi # Strip any trailing slash from the destination. dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` test "X$destdir" = "X$dest" && destdir=. destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` # Not a directory, so check to see that there is only one file specified. set dummy $files if test $# -gt 2; then $echo "$modename: \`$dest' is not a directory" 1>&2 $echo "$help" 1>&2 exit 1 fi fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 $echo "$help" 1>&2 exit 1 ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. staticlibs="$staticlibs $file" ;; *.la) # Check to see that this really is a libtool archive. if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 exit 1 fi library_names= old_library= relink_command= # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) current_libdirs="$current_libdirs $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) future_libdirs="$future_libdirs $libdir" ;; esac fi dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/ test "X$dir" = "X$file/" && dir= dir="$dir$objdir" if test -n "$relink_command"; then $echo "$modename: warning: relinking \`$file'" 1>&2 $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 continue fi fi # See the names of the shared library. set dummy $library_names if test -n "$2"; then realname="$2" shift shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. $show "$install_prog $dir/$srcname $destdir/$realname" $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? if test -n "$stripme" && test -n "$striplib"; then $show "$striplib $destdir/$realname" $run eval "$striplib $destdir/$realname" || exit $? fi if test $# -gt 0; then # Delete the old symlinks, and create new ones. for linkname do if test "$linkname" != "$realname"; then $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" fi done fi # Do each command in the postinstall commands. lib="$destdir/$realname" eval cmds=\"$postinstall_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" fi # Install the pseudo-library for information purposes. name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` instname="$dir/$name"i $show "$install_prog $instname $destdir/$name" $run eval "$install_prog $instname $destdir/$name" || exit $? # Maybe install the static library, too. test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" ;; *.lo) # Install (i.e. copy) a libtool object. # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` ;; *.$objext) staticdest="$destfile" destfile= ;; *) $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 $echo "$help" 1>&2 exit 1 ;; esac # Install the libtool object if requested. if test -n "$destfile"; then $show "$install_prog $file $destfile" $run eval "$install_prog $file $destfile" || exit $? fi # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` $show "$install_prog $staticobj $staticdest" $run eval "$install_prog \$staticobj \$staticdest" || exit $? fi exit 0 ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` destfile="$destdir/$destfile" fi # Do a test to see if this is really a libtool program. case $host in *cygwin*|*mingw*) wrapper=`echo $file | ${SED} -e 's,.exe$,,'` ;; *) wrapper=$file ;; esac if (${SED} -e '4q' $wrapper | egrep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then notinst_deplibs= relink_command= # If there is no directory component, then add one. case $file in */* | *\\*) . $wrapper ;; *) . ./$wrapper ;; esac # Check the variables that should have been set. if test -z "$notinst_deplibs"; then $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2 exit 1 fi finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then # If there is no directory component, then add one. case $lib in */* | *\\*) . $lib ;; *) . ./$lib ;; esac fi libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 finalize=no fi done relink_command= # If there is no directory component, then add one. case $file in */* | *\\*) . $wrapper ;; *) . ./$wrapper ;; esac outputname= if test "$fast_install" = no && test -n "$relink_command"; then if test "$finalize" = yes && test -z "$run"; then tmpdir="/tmp" test -n "$TMPDIR" && tmpdir="$TMPDIR" tmpdir="$tmpdir/libtool-$$" if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : else $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 continue fi file=`$echo "X$file" | $Xsed -e 's%^.*/%%'` outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` $show "$relink_command" if $run eval "$relink_command"; then : else $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 ${rm}r "$tmpdir" continue fi file="$outputname" else $echo "$modename: warning: cannot relink \`$file'" 1>&2 fi else # Install the binary that we compiled earlier. file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyways case $install_prog,$host in /usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) destfile=`echo $destfile | ${SED} -e 's,.exe$,,'` ;; esac ;; esac $show "$install_prog$stripme $file $destfile" $run eval "$install_prog\$stripme \$file \$destfile" || exit $? test -n "$outputname" && ${rm}r "$tmpdir" ;; esac done for file in $staticlibs; do name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` # Set up the ranlib parameters. oldlib="$destdir/$name" $show "$install_prog $file $oldlib" $run eval "$install_prog \$file \$oldlib" || exit $? if test -n "$stripme" && test -n "$striplib"; then $show "$old_striplib $oldlib" $run eval "$old_striplib $oldlib" || exit $? fi # Do each command in the postinstall commands. eval cmds=\"$old_postinstall_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || exit $? done IFS="$save_ifs" done if test -n "$future_libdirs"; then $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 fi if test -n "$current_libdirs"; then # Maybe just do a dry run. test -n "$run" && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $0 --finish$current_libdirs' else exit 0 fi ;; # libtool finish mode finish) modename="$modename: finish" libdirs="$nonopt" admincmds= if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for dir do libdirs="$libdirs $dir" done for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. eval cmds=\"$finish_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" || admincmds="$admincmds $cmd" done IFS="$save_ifs" fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $run eval "$cmds" || admincmds="$admincmds $cmds" fi done fi # Exit here if they wanted silent mode. test "$show" = ":" && exit 0 echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do echo " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" echo " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then echo " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" echo "more information, such as the ld(1) and ld.so(8) manual pages." echo "----------------------------------------------------------------------" exit 0 ;; # libtool execute mode execute) modename="$modename: execute" # The first argument is the command name. cmd="$nonopt" if test -z "$cmd"; then $echo "$modename: you must specify a COMMAND" 1>&2 $echo "$help" exit 1 fi # Handle -dlopen flags immediately. for file in $execute_dlfiles; do if test ! -f "$file"; then $echo "$modename: \`$file' is not a file" 1>&2 $echo "$help" 1>&2 exit 1 fi dir= case $file in *.la) # Check to see that this really is a libtool archive. if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : else $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 $echo "$help" 1>&2 exit 1 fi # Read the libtool library. dlname= library_names= # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" continue fi dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$file" && dir=. if test -f "$dir/$objdir/$dlname"; then dir="$dir/$objdir" else $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 exit 1 fi ;; *.lo) # Just add the directory containing the .lo file. dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` test "X$dir" = "X$file" && dir=. ;; *) $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 continue ;; esac # Get the absolute pathname. absdir=`cd "$dir" && pwd` test -n "$absdir" && dir="$absdir" # Now add the directory to shlibpath_var. if eval "test -z \"\$$shlibpath_var\""; then eval "$shlibpath_var=\"\$dir\"" else eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" fi done # This variable tells wrapper scripts just to set shlibpath_var # rather than running their programs. libtool_execute_magic="$magic" # Check if any of the arguments is a wrapper script. args= for file do case $file in -*) ;; *) # Do a test to see if this is really a libtool program. if (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then # If there is no directory component, then add one. case $file in */* | *\\*) . $file ;; *) . ./$file ;; esac # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` args="$args \"$file\"" done if test -z "$run"; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved enviroment variables if test "${save_LC_ALL+set}" = set; then LC_ALL="$save_LC_ALL"; export LC_ALL fi if test "${save_LANG+set}" = set; then LANG="$save_LANG"; export LANG fi # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" $echo "export $shlibpath_var" fi $echo "$cmd$args" exit 0 fi ;; # libtool clean and uninstall mode clean | uninstall) modename="$modename: $mode" rm="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) rm="$rm $arg"; rmforce=yes ;; -*) rm="$rm $arg" ;; *) files="$files $arg" ;; esac done if test -z "$rm"; then $echo "$modename: you must specify an RM program" 1>&2 $echo "$help" 1>&2 exit 1 fi rmdirs= for file in $files; do dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` if test "X$dir" = "X$file"; then dir=. objdir="$objdir" else objdir="$dir/$objdir" fi name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` test $mode = uninstall && objdir="$dir" # Remember objdir for removal later, being careful to avoid duplicates if test $mode = clean; then case " $rmdirs " in *" $objdir "*) ;; *) rmdirs="$rmdirs $objdir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if (test -L "$file") >/dev/null 2>&1 \ || (test -h "$file") >/dev/null 2>&1 \ || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if (${SED} -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then . $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do rmfiles="$rmfiles $objdir/$n" done test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" test $mode = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" if test $mode = uninstall; then if test -n "$library_names"; then # Do each command in the postuninstall commands. eval cmds=\"$postuninstall_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" if test $? != 0 && test "$rmforce" != yes; then exit_status=1 fi done IFS="$save_ifs" fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. eval cmds=\"$old_postuninstall_cmds\" save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" $show "$cmd" $run eval "$cmd" if test $? != 0 && test "$rmforce" != yes; then exit_status=1 fi done IFS="$save_ifs" fi # FIXME: should reinstall the best remaining shared library. fi fi ;; *.lo) if test "$build_old_libs" = yes; then oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` rmfiles="$rmfiles $dir/$oldobj" fi ;; *) # Do a test to see if this is a libtool program. if test $mode = clean && (${SED} -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then relink_command= . $dir/$file rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then rmfiles="$rmfiles $objdir/lt-$name" fi fi ;; esac $show "$rm $rmfiles" $run $rm $rmfiles || exit_status=1 done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then $show "rmdir $dir" $run rmdir $dir >/dev/null 2>&1 fi done exit $exit_status ;; "") $echo "$modename: you must specify a MODE" 1>&2 $echo "$generic_help" 1>&2 exit 1 ;; esac if test -z "$exec_cmd"; then $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$generic_help" 1>&2 exit 1 fi fi # test -z "$show_help" if test -n "$exec_cmd"; then eval exec $exec_cmd exit 1 fi # We need to display help for each of the modes. case $mode in "") $echo \ "Usage: $modename [OPTION]... [MODE-ARG]... Provide generalized library-building support services. --config show all configuration variables --debug enable verbose shell tracing -n, --dry-run display commands without modifying any files --features display basic configuration information and exit --finish same as \`--mode=finish' --help display this help message and exit --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] --quiet same as \`--silent' --silent don't print informational messages --version print version information MODE must be one of the following: clean remove files from the build directory compile compile a source file into a libtool object execute automatically set library path, then run a program finish complete the installation of libtool libraries install install libraries or executables link create a library or an executable uninstall remove libraries from an installed directory MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for a more detailed description of MODE." exit 0 ;; clean) $echo \ "Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... Remove files from the build directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, object or program, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; compile) $echo \ "Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE Compile a source file into a libtool library object. This mode accepts the following additional options: -o OUTPUT-FILE set the output file name to OUTPUT-FILE -prefer-pic try to building PIC objects only -prefer-non-pic try to building non-PIC objects only -static always build a \`.o' file suitable for static linking COMPILE-COMMAND is a command to be used in creating a \`standard' object file from the given SOURCEFILE. The output file name is determined by removing the directory component from SOURCEFILE, then substituting the C source code suffix \`.c' with the library object suffix, \`.lo'." ;; execute) $echo \ "Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... Automatically set library path, then run a program. This mode accepts the following additional options: -dlopen FILE add the directory containing FILE to the library path This mode sets the library path environment variable according to \`-dlopen' flags. If any of the ARGS are libtool executable wrappers, then they are translated into their corresponding uninstalled binary, and any of their required library directories are added to the library path. Then, COMMAND is executed, with ARGS as arguments." ;; finish) $echo \ "Usage: $modename [OPTION]... --mode=finish [LIBDIR]... Complete the installation of libtool libraries. Each LIBDIR is a directory that contains libtool libraries. The commands that this mode executes may require superuser privileges. Use the \`--dry-run' option if you just want to see what would be executed." ;; install) $echo \ "Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... Install executables or libraries. INSTALL-COMMAND is the installation command. The first component should be either the \`install' or \`cp' program. The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $echo \ "Usage: $modename [OPTION]... --mode=link LINK-COMMAND... Link object files or libraries together to form another library, or to create an executable program. LINK-COMMAND is a command using the C compiler that you would use to create a program from several object files. The following components of LINK-COMMAND are treated specially: -all-static do not do any dynamic linking at all -avoid-version do not add a version suffix if possible -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -release RELEASE specify package release information -rpath LIBDIR the created library will eventually be installed in LIBDIR -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries -static do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] All other options (arguments beginning with \`-') are ignored. Every other argument is treated as a filename. Files ending in \`.la' are treated as uninstalled libtool libraries, other files are standard or library object files. If the OUTPUT-FILE ends in \`.la', then a libtool library is created, only library objects (\`.lo' files) may be specified, and \`-rpath' is required, except when creating a convenience library. If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created using \`ar' and \`ranlib', or on Windows using \`lib'. If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file is created, otherwise an executable program is created." ;; uninstall) $echo \ "Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... Remove libraries from an installation directory. RM is the name of the program to use to delete files associated with each FILE (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed to RM. If FILE is a libtool library, all the files associated with it are deleted. Otherwise, only FILE itself is deleted using RM." ;; *) $echo "$modename: invalid operation mode \`$mode'" 1>&2 $echo "$help" 1>&2 exit 1 ;; esac echo $echo "Try \`$modename --help' for more information about other modes." exit 0 # Local Variables: # mode:shell-script # sh-indentation:2 # End: towitoko-2.0.7/missing0000755000175000017500000002403607527463426010503 #! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright (C) 1996, 1997, 1999, 2000, 2002 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., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: # 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 case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case "$1" in -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' 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]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing 0.4 - GNU automake" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. 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) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. 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) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. 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*) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. 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) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. You can get \`$1Help2man' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` 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' is missing on your system. 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 [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. 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 [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. 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 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` fi if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit 1 fi ;; makeinfo) if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then # We have makeinfo, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. 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." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; tar) shift if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 fi # 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 you do not seem to have it handy on your system. 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 prerequirements 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 towitoko-2.0.7/mkinstalldirs0000755000175000017500000000341107527463426011704 #! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain errstatus=0 dirmode="" usage="\ Usage: mkinstalldirs [-h] [--help] [-m mode] dir ..." # process command line arguments while test $# -gt 0 ; do case "${1}" in -h | --help | --h* ) # -h for help echo "${usage}" 1>&2; exit 0 ;; -m ) # -m PERM arg shift test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } dirmode="${1}" shift ;; -- ) shift; break ;; # stop option processing -* ) echo "${usage}" 1>&2; exit 1 ;; # unknown option * ) break ;; # first non-opt arg esac done for file do if test -d "$file"; then shift else break fi done case $# in 0) exit 0 ;; esac case $dirmode in '') if mkdir -p -- . 2>/dev/null; then echo "mkdir -p -- $*" exec mkdir -p -- "$@" fi ;; *) if mkdir -m "$dirmode" -p -- . 2>/dev/null; then echo "mkdir -m $dirmode -p -- $*" exec mkdir -m "$dirmode" -p -- "$@" fi ;; esac for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr else if test ! -z "$dirmode"; then echo "chmod $dirmode $pathcomp" lasterr="" chmod "$dirmode" "$pathcomp" || lasterr=$? if test ! -z "$lasterr"; then errstatus=$lasterr fi fi fi fi pathcomp="$pathcomp/" done done exit $errstatus # Local Variables: # mode: shell-script # sh-indentation: 3 # End: # mkinstalldirs ends here towitoko-2.0.7/reconf0000755000175000017500000000034207527463506010277 #!/bin/sh # Run this only if you have changed a Makefile.am, configure.ac file or # if you want to use other version of autoconf / automake aclocal libtoolize --copy --force autoheader automake --copy --add-missing autoconf towitoko-2.0.7/src/0002777000175000017500000000000007527763751007760 5towitoko-2.0.7/src/Makefile.am0000644000175000017500000000165307361641263011720 # # Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SUBDIRS = ct-api ifd-handler driver test towitoko-2.0.7/src/Makefile.in0000644000175000017500000002522107527762031011727 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ # # Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AS = @AS@ AWK = @AWK@ CC = @CC@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBOOK_TO_MAN = @DOCBOOK_TO_MAN@ ECHO = @ECHO@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ PCSC_LITE_DIR = @PCSC_LITE_DIR@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ SUBDIRS = ct-api ifd-handler driver test subdir = src mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = DIST_SOURCES = RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ uninstall-info-recursive all-recursive install-data-recursive \ install-exec-recursive installdirs-recursive install-recursive \ uninstall-recursive check-recursive installcheck-recursive DIST_COMMON = Makefile.am Makefile.in DIST_SUBDIRS = $(SUBDIRS) all: all-recursive .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @set fnord $$MAKEFLAGS; amf=$$2; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ETAGS = etags ETAGSFLAGS = tags: TAGS 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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ fi; \ done; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = .. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkinstalldirs) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ 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 list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d $(distdir)/$$subdir \ || mkdir $(distdir)/$$subdir \ || exit 1; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$(top_distdir)" \ distdir=../$(distdir)/$$subdir \ distdir) \ || exit 1; \ fi; \ done check-am: all-am check: check-recursive all-am: Makefile installdirs: installdirs-recursive installdirs-am: install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive distclean-am: clean-am distclean-generic distclean-libtool \ distclean-tags dvi: dvi-recursive dvi-am: info: info-recursive info-am: install-data-am: install-exec-am: install-info: install-info-recursive install-man: installcheck-am: maintainer-clean: maintainer-clean-recursive maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool uninstall-am: uninstall-info-am uninstall-info: uninstall-info-recursive .PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ clean-generic clean-libtool clean-recursive distclean \ distclean-generic distclean-libtool distclean-recursive \ distclean-tags distdir dvi dvi-am dvi-recursive info info-am \ info-recursive install install-am install-data install-data-am \ install-data-recursive install-exec install-exec-am \ install-exec-recursive install-info install-info-am \ install-info-recursive install-man install-recursive \ install-strip installcheck installcheck-am installdirs \ installdirs-am installdirs-recursive maintainer-clean \ maintainer-clean-generic maintainer-clean-recursive mostlyclean \ mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \ tags tags-recursive uninstall uninstall-am uninstall-info-am \ uninstall-info-recursive uninstall-recursive # 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: towitoko-2.0.7/src/ct-api/0002777000175000017500000000000007527763750011134 5towitoko-2.0.7/src/ct-api/ctapi.h0000644000175000017500000000374607317644021012313 /***************************************************************** / / File : ctapi.h / Author : David Corcoran / Date : September 2, 1998 / Purpose: Defines CT-API functions and returns / License: See file LICENSE / ******************************************************************/ #ifndef _ctapi_h_ #define _ctapi_h_ #ifdef __cplusplus extern "C" { #endif #define MAX_APDULEN 1040 char CT_init ( unsigned short Ctn, /* Terminal Number */ unsigned short pn /* Port Number */ ); char CT_close( unsigned short Ctn /* Terminal Number */ ); char CT_data( unsigned short ctn, /* Terminal Number */ unsigned char *dad, /* Destination */ unsigned char *sad, /* Source */ unsigned short lc, /* Length of command */ unsigned char *cmd, /* Command/Data Buffer */ unsigned short *lr, /* Length of Response */ unsigned char *rsp /* Response */ ); #define OK 0 /* Success */ #define ERR_INVALID -1 /* Invalid Data */ #define ERR_CT -8 /* CT Error */ #define ERR_TRANS -10 /* Transmission Error */ #define ERR_MEMORY -11 /* Memory Allocate Error */ #define ERR_HTSI -128 /* HTSI Error */ #define PORT_COM1 0 /* COM 1 */ #define PORT_COM2 1 /* COM 2 */ #define PORT_COM3 2 /* COM 3 */ #define PORT_COM4 3 /* COM 4 */ #define PORT_Printer 4 /* Printer Port (MAC) */ #define PORT_Modem 5 /* Modem Port (MAC) */ #define PORT_LPT1 6 /* LPT 1 */ #define PORT_LPT2 7 /* LPT 2 */ /* #define DAD */ #define CT 1 #define HOST 2 #ifdef __cplusplus } #endif #endif towitoko-2.0.7/src/ct-api/ctbcs.h0000644000175000017500000001234307361636755012320 /* CT-BCS commands, responses and parameters for terminals without keypad and display. This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 1998 1999 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _CTBCS_ #define _CTBCS_ /* * Command and response size */ #define CTBCS_MIN_COMMAND_SIZE 2 #define CTBCS_MIN_RESPONSE_SIZE 2 /* * Class byte of all CTBCS commands */ #define CTBCS_CLA 0x20 /* * Mandatory CT-BCS commands */ #define CTBCS_INS_RESET 0x11 /* Reset CT */ #define CTBCS_INS_REQUEST 0x12 /* Request ICC */ #define CTBCS_INS_STATUS 0x13 /* Get reader status */ #define CTBCS_INS_EJECT 0x15 /* Eject ICC */ /* * P1 parameter: functional units */ #define CTBCS_P1_CT_KERNEL 0x00 #define CTBCS_P1_INTERFACE1 0x01 #define CTBCS_P1_INTERFACE2 0x02 #define CTBCS_P1_INTERFACE3 0x03 #define CTBCS_P1_INTERFACE4 0x04 #define CTBCS_P1_INTERFACE5 0x05 #define CTBCS_P1_INTERFACE6 0x06 #define CTBCS_P1_INTERFACE7 0x07 #define CTBCS_P1_INTERFACE8 0x08 #define CTBCS_P1_INTERFACE9 0x09 #define CTBCS_P1_INTERFACE10 0x0A #define CTBCS_P1_INTERFACE11 0x0B #define CTBCS_P1_INTERFACE12 0x0C #define CTBCS_P1_INTERFACE13 0x0D #define CTBCS_P1_INTERFACE14 0x0E #define CTBCS_P1_DISPLAY 0x40 #define CTBCS_P1_KEYPAD 0x50 /* * P2 parameter for Reset CT: data to be returned */ #define CTBCS_P2_RESET_NO_RESP 0x00 /* Return no data */ #define CTBCS_P2_RESET_GET_ATR 0x01 /* Return complete ATR */ #define CTBCS_P2_RESET_GET_HIST 0x02 /* Return historical bytes */ /* * P2 parameter for Request ICC: data to be returned */ #define CTBCS_P2_REQUEST_NO_RESP 0x00 /* Return no data */ #define CTBCS_P2_REQUEST_GET_ATR 0x01 /* Return complete ATR */ #define CTBCS_P2_REQUEST_GET_HIST 0x02 /* Return historical bytes */ /* * P2 parameter for Get status: TAG of data object to return */ #define CTBCS_P2_STATUS_MANUFACTURER 0x46 /* Return manufacturer DO */ #define CTBCS_P2_STATUS_ICC 0x80 /* Return ICC DO */ /* * General return codes */ #define CTBCS_SW1_OK 0x90 /* Command successful */ #define CTBCS_SW2_OK 0x00 #define CTBCS_SW1_WRONG_LENGTH 0x67 /* Wrong length */ #define CTBCS_SW2_WRONG_LENGTH 0x00 #define CTBCS_SW1_COMMAND_NOT_ALLOWED 0x69 /* Command not allowed */ #define CTBCS_SW2_COMMAND_NOT_ALLOWED 0x00 #define CTBCS_SW1_WRONG_PARAM 0x6A /* Wrong parameters P1, P2 */ #define CTBCS_SW2_WRONG_PARAM 0x00 #define CTBCS_SW1_WRONG_INS 0x6D /* Wrong Instruction */ #define CTBCS_SW2_WRONG_INS 0x00 #define CTBCS_SW1_WRONG_CLA 0x6E /* Class not supported */ #define CTBCS_SW2_WRONG_CLA 0x00 #define CTBCS_SW1_ICC_ERROR 0x6F /* ICC removed, defective or */ #define CTBCS_SW2_ICC_ERROR 0x00 /* no longer reacts */ /* * Return codes for Reset CT */ #define CTBCS_SW1_RESET_CT_OK 0x90 /* Reset CT successful */ #define CTBCS_SW2_RESET_CT_OK 0x00 #define CTBCS_SW1_RESET_SYNC_OK 0x90 /* Synchoronous ICC, */ #define CTBCS_SW2_RESET_SYNC_OK 0x00 /* reset successful */ #define CTBCS_SW1_RESET_ASYNC_OK 0x90 /* Asynchoronous ICC, */ #define CTBCS_SW2_RESET_ASYNC_OK 0x01 /* reset successful */ #define CTBCS_SW1_RESET_ERROR 0x64 /* Reset not successful */ #define CTBCS_SW2_RESET_ERROR 0x00 /* * Return codes for Request ICC */ #define CTBCS_SW1_REQUEST_SYNC_OK 0x90 /* Synchoronous ICC, */ #define CTBCS_SW2_REQUEST_SYNC_OK 0x00 /* reset successful */ #define CTBCS_SW1_REQUEST_ASYNC_OK 0x90 /* Asynchoronous ICC, */ #define CTBCS_SW2_REQUEST_ASYNC_OK 0x01 /* reset successful */ #define CTBCS_SW1_REQUEST_NO_CARD 0x62 /* No card present */ #define CTBCS_SW2_REQUEST_NO_CARD 0x00 #define CTBCS_SW1_REQUEST_CARD_PRESENT 0x62 /* Card already present */ #define CTBCS_SW2_REQUEST_CARD_PRESENT 0x01 #define CTBCS_SW1_REQUEST_ERROR 0x64 /* Reset not successful */ #define CTBCS_SW2_REQUEST_ERROR 0x00 #define CTBCS_SW1_REQUEST_TIMER_ERROR 0x69 /* Timer not supported */ #define CTBCS_SW2_REQUEST_TIMER_ERROR 0x00 /* * Return codes for Eject ICC */ #define CTBCS_SW1_EJECT_OK 0x90 /* Command succesful, */ #define CTBCS_SW2_EJECT_OK 0x00 #define CTBCS_SW1_EJECT_REMOVED 0x90 /* Command succesful, */ #define CTBCS_SW2_EJECT_REMOVED 0x01 /* Card removed */ #define CTBCS_SW1_EJECT_NOT_REMOVED 0x62 /* Card not removed */ #define CTBCS_SW2_EJECT_NOT_REMOVED 0x00 /* * Data returned on Get Status command */ #define CTBCS_DATA_STATUS_NOCARD 0x00 /* No card present */ #define CTBCS_DATA_STATUS_CARD 0x01 /* Card present */ #define CTBCS_DATA_STATUS_CARD_CONNECT 0x05 /* Card present */ #endif /* _CTBCS_ */ towitoko-2.0.7/src/ct-api/Makefile.am0000644000175000017500000000224607361641127013073 # # ct-api/Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # INC = cardterminal.h ct_slot.h ct_list.h ctapi.h ctbcs.h SRC = cardterminal.c ct_slot.c ct_list.c ctapi.c noinst_LTLIBRARIES = libtowitoko-ctapi.la INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/driver include_HEADERS = ctapi.h ctbcs.h libtowitoko_ctapi_la_SOURCES = $(SRC) $(INC) towitoko-2.0.7/src/ct-api/Makefile.in0000644000175000017500000002677707527762031013125 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ # # ct-api/Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../.. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AS = @AS@ AWK = @AWK@ CC = @CC@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBOOK_TO_MAN = @DOCBOOK_TO_MAN@ ECHO = @ECHO@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ PCSC_LITE_DIR = @PCSC_LITE_DIR@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ INC = cardterminal.h ct_slot.h ct_list.h ctapi.h ctbcs.h SRC = cardterminal.c ct_slot.c ct_list.c ctapi.c noinst_LTLIBRARIES = libtowitoko-ctapi.la INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/driver include_HEADERS = ctapi.h ctbcs.h libtowitoko_ctapi_la_SOURCES = $(SRC) $(INC) subdir = src/ct-api mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtowitoko_ctapi_la_LDFLAGS = libtowitoko_ctapi_la_LIBADD = am__objects_1 = cardterminal.lo ct_slot.lo ct_list.lo ctapi.lo am__objects_2 = am_libtowitoko_ctapi_la_OBJECTS = $(am__objects_1) $(am__objects_2) libtowitoko_ctapi_la_OBJECTS = $(am_libtowitoko_ctapi_la_OBJECTS) DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/cardterminal.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/ct_list.Plo ./$(DEPDIR)/ct_slot.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/ctapi.Plo COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ CFLAGS = @CFLAGS@ DIST_SOURCES = $(libtowitoko_ctapi_la_SOURCES) HEADERS = $(include_HEADERS) DIST_COMMON = $(include_HEADERS) Makefile.am Makefile.in SOURCES = $(libtowitoko_ctapi_la_SOURCES) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu src/ct-api/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test -z "$dir" && dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtowitoko-ctapi.la: $(libtowitoko_ctapi_la_OBJECTS) $(libtowitoko_ctapi_la_DEPENDENCIES) $(LINK) $(libtowitoko_ctapi_la_LDFLAGS) $(libtowitoko_ctapi_la_OBJECTS) $(libtowitoko_ctapi_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cardterminal.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ct_list.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ct_slot.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ctapi.Plo@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` .c.lo: @AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< CCDEPMODE = @CCDEPMODE@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: includeHEADERS_INSTALL = $(INSTALL_HEADER) install-includeHEADERS: $(include_HEADERS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(includedir) @list='$(include_HEADERS)'; for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ f="`echo $$p | sed -e 's|^.*/||'`"; \ echo " $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f"; \ $(includeHEADERS_INSTALL) $$d$$p $(DESTDIR)$(includedir)/$$f; \ done uninstall-includeHEADERS: @$(NORMAL_UNINSTALL) @list='$(include_HEADERS)'; for p in $$list; do \ f="`echo $$p | sed -e 's|^.*/||'`"; \ echo " rm -f $(DESTDIR)$(includedir)/$$f"; \ rm -f $(DESTDIR)$(includedir)/$$f; \ done ETAGS = etags ETAGSFLAGS = tags: TAGS 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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../.. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkinstalldirs) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ 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 check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) $(HEADERS) installdirs: $(mkinstalldirs) $(DESTDIR)$(includedir) 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-libtool distclean-tags dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-includeHEADERS install-exec-am: install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool uninstall-am: uninstall-includeHEADERS uninstall-info-am .PHONY: GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES distclean \ distclean-compile distclean-depend distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am info \ info-am install install-am install-data install-data-am \ install-exec install-exec-am install-includeHEADERS \ install-info install-info-am install-man install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool tags uninstall \ uninstall-am uninstall-includeHEADERS uninstall-info-am # 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: towitoko-2.0.7/src/ct-api/cardterminal.c0000644000175000017500000004520607527020312013642 /* cardterminal.c Card Terminal handling and CT-BCS functions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include "cardterminal.h" #include "atr.h" #include "atr_sync.h" #include #include /* * Not exported constants definition */ #define CARDTERMINAL_RESETCT_BUFFER_SIZE 35 #define CARDTERMINAL_REQUESTICC_BUFFER_SIZE 35 #define CARDTERMINAL_GETSTATUS_BUFFER_SIZE 19 #define CARDTERMINAL_EJECTICC_BUFFER_SIZE 2 #define CARDTERMINAL_MANUFACTURER "DETWK" /* * Not exported functions declaration */ static char CardTerminal_ResetCT (CardTerminal * ct, APDU_Cmd * cmd, APDU_Rsp ** rsp); static char CardTerminal_RequestICC (CardTerminal * ct, APDU_Cmd * cmd, APDU_Rsp ** rsp); static char CardTerminal_GetStatus (CardTerminal * ct, APDU_Cmd * cmd, APDU_Rsp ** rsp); static char CardTerminal_EjectICC (CardTerminal * ct, APDU_Cmd * cmd, APDU_Rsp ** rsp); static void CardTerminal_Clear (CardTerminal * ct); /* * Exported functions definition */ CardTerminal * CardTerminal_New (void) { CardTerminal *ct; ct = (CardTerminal *) malloc (sizeof (CardTerminal)); if (ct != NULL) CardTerminal_Clear (ct); return ct; } char CardTerminal_Init (CardTerminal * ct, unsigned short pn) { char ret; int i; bool usbserial; /* Create a new IO_Serial */ ct->io = IO_Serial_New (); /* Memory error */ if (ct->io == NULL) return ERR_MEMORY; /* * Handle USB port numbers: first USB serial port starts at 0x8000, * 0x8001 if CTAPI_WIN32_COM is set */ if ((pn & 0x8000) == 0x8000) { usbserial = TRUE; pn &= 0x7FFF; } else usbserial = FALSE; /* Initialise serial port */ #ifndef CTAPI_WIN32_COM if (!IO_Serial_Init (ct->io, pn + 1, usbserial, TRUE)) #else if (!IO_Serial_Init (ct->io, pn, usbserial, TRUE)) #endif { IO_Serial_Delete (ct->io); ct->io = NULL; return ERR_TRANS; } /* Cearte all reader slots */ ct->num_slots = 0; do { i = ct->num_slots++; /* Create one slot */ ct->slots[i] = CT_Slot_New (); if (ct->slots[i] == NULL) { ret = ERR_MEMORY; break; } /* Initialise slot */ ret = CT_Slot_Init (ct->slots[i], ct->io, i); if (ret != OK) break; } while (!CT_Slot_IsLast(ct->slots[i])); /* On error restore initial state */ if (ret != OK) { while (ct->num_slots > 0) { if (ct->slots[i] != NULL) { CT_Slot_Delete (ct->slots[i]); ct->slots[i] = NULL; } ct->num_slots --; i--; } IO_Serial_Close (ct->io); IO_Serial_Delete (ct->io); ct->io = NULL; } #ifdef HAVE_PTHREAD_H else pthread_mutex_init(&(ct->mutex), NULL); #endif return ret; } char CardTerminal_Command (CardTerminal * ct, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE buffer[CTBCS_MIN_RESPONSE_SIZE], cla, ins; long length; char ret; /* Get class of command */ cla = APDU_Cmd_Cla (cmd); if (cla != CTBCS_CLA) { length = CTBCS_MIN_RESPONSE_SIZE; buffer[0] = CTBCS_SW1_WRONG_CLA; buffer[1] = CTBCS_SW2_WRONG_CLA; (*rsp) = APDU_Rsp_New (buffer, length); ret = OK; } else { /* Get instruction */ ins = APDU_Cmd_Ins (cmd); /* Reset CT */ if (ins == CTBCS_INS_RESET) ret = CardTerminal_ResetCT (ct, cmd, rsp); /* Request ICC */ else if (ins == CTBCS_INS_REQUEST) ret = CardTerminal_RequestICC (ct, cmd, rsp); /* Get Status */ else if (ins == CTBCS_INS_STATUS) ret = CardTerminal_GetStatus (ct, cmd, rsp); /* Eject ICC */ else if (ins == CTBCS_INS_EJECT) ret = CardTerminal_EjectICC (ct, cmd, rsp); /* Wrong instruction */ else { length = CTBCS_MIN_RESPONSE_SIZE; buffer[0] = CTBCS_SW1_WRONG_INS; buffer[1] = CTBCS_SW2_WRONG_INS; (*rsp) = APDU_Rsp_New (buffer, length); ret = OK; } } return ret; } char CardTerminal_Close (CardTerminal * ct) { char ret, aux; int i; ret = OK; for (i = 0; i < ct->num_slots; i++) { if (ct->slots[i] != NULL) { aux = CT_Slot_Close (ct->slots[i]); if (aux != OK) ret = aux; CT_Slot_Delete (ct->slots[i]); } } if (ct->io != NULL) { if (!IO_Serial_Close (ct->io)) ret = ERR_TRANS; IO_Serial_Delete (ct->io); } CardTerminal_Clear (ct); #ifdef HAVE_PTHREAD_H pthread_mutex_destroy(&(ct->mutex)); #endif return ret; } void CardTerminal_Delete (CardTerminal * ct) { free (ct); } CT_Slot * CardTerminal_GetSlot (CardTerminal * ct, int number) { if (number < (ct->num_slots)) return ct->slots[number]; return NULL; } #ifdef HAVE_PTHREAD_H pthread_mutex_t * CardTerminal_GetMutex (CardTerminal * ct) { return &(ct->mutex); } #endif /* * Not exported functions definition */ static char CardTerminal_ResetCT (CardTerminal * ct, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE buffer[CARDTERMINAL_RESETCT_BUFFER_SIZE], p1, p2; bool card, change; unsigned sn, length; void *atr; char ret = OK; /* Get functional unit */ p1 = APDU_Cmd_P1 (cmd); /* Funcional unit is the card-terminal */ if (p1 == CTBCS_P1_CT_KERNEL) { /* Get command cualifier */ p2 = APDU_Cmd_P2 (cmd); /* Wrong command cualifier */ if (p2 != CTBCS_P2_RESET_NO_RESP && p2 != CTBCS_P2_RESET_GET_ATR && p2 != CTBCS_P2_RESET_GET_HIST) { buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; (*rsp) = APDU_Rsp_New (buffer, 2); return OK; } /* Close slots */ for (sn = 0; sn < ct->num_slots; sn++) { /* Close this slot */ ret = CT_Slot_Close (ct->slots[sn]); if (ret != OK) { buffer[0] = CTBCS_SW1_RESET_ERROR; buffer[1] = CTBCS_SW2_RESET_ERROR; (*rsp) = APDU_Rsp_New (buffer, 2); return ret; } /* Initialise this slot */ ret = CT_Slot_Init (ct->slots[sn],ct->io,sn); if (ret != OK) { buffer[0] = CTBCS_SW1_RESET_ERROR; buffer[1] = CTBCS_SW2_RESET_ERROR; (*rsp) = APDU_Rsp_New (buffer, 2); return ret; } } length = 2; buffer[0] = CTBCS_SW1_RESET_CT_OK; buffer[1] = CTBCS_SW2_RESET_CT_OK; } /* Funtional unit is an ICC */ else if ((p1 == CTBCS_P1_INTERFACE1) || (p1 == CTBCS_P1_INTERFACE2)) { /* Get slot number */ sn = (p1 == CTBCS_P1_INTERFACE1) ? 0 : 1; if (!(sn < ct->num_slots)) { buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; (*rsp) = APDU_Rsp_New (buffer, 2); return ERR_INVALID; } /* Release the slot */ ret = CT_Slot_Release (ct->slots[sn]); if (ret != OK) { buffer[0] = CTBCS_SW1_RESET_ERROR; buffer[1] = CTBCS_SW2_RESET_ERROR; (*rsp) = APDU_Rsp_New (buffer, 2); return ret; } /* Check for card */ ret = CT_Slot_Check (ct->slots[sn], 0, &card, &change); if (ret != OK) { buffer[0] = CTBCS_SW1_RESET_ERROR; buffer[1] = CTBCS_SW2_RESET_ERROR; (*rsp) = APDU_Rsp_New (buffer, 2); return ret; } /* No card present */ if (!card) { buffer[0] = CTBCS_SW1_RESET_ERROR; buffer[1] = CTBCS_SW2_RESET_ERROR;; (*rsp) = APDU_Rsp_New (buffer, 2); return OK; } /* Probe card type */ if (APDU_Cmd_Lc (cmd) > 1) ret = CT_Slot_Probe (ct->slots[sn], APDU_Cmd_Data(cmd), APDU_Cmd_Lc(cmd)); else ret = CT_Slot_Probe (ct->slots[sn], NULL, 0); if (ret != OK || (CT_Slot_GetICCType (ct->slots[sn]) == CT_SLOT_NULL)) { buffer[0] = CTBCS_SW1_RESET_ERROR; buffer[1] = CTBCS_SW2_RESET_ERROR; (*rsp) = APDU_Rsp_New (buffer, 2); return ret; } /* Get command cualifier */ p2 = APDU_Cmd_P2 (cmd); /* Do not return data */ if (p2 == CTBCS_P2_RESET_NO_RESP) { if (CT_Slot_GetICCType (ct->slots[sn]) == CT_SLOT_ICC_ASYNC) { buffer[0] = CTBCS_SW1_RESET_ASYNC_OK; buffer[1] = CTBCS_SW2_RESET_ASYNC_OK; length = 2; } else { buffer[0] = CTBCS_SW1_RESET_SYNC_OK; buffer[1] = CTBCS_SW2_RESET_SYNC_OK; length = 2; } } /* Return complete ATR of ICC */ else if (p2 == CTBCS_P2_RESET_GET_ATR) { atr = CT_Slot_GetAtr (ct->slots[sn]); if (CT_Slot_GetICCType (ct->slots[sn]) == CT_SLOT_ICC_ASYNC) { if (atr != NULL) ATR_GetRaw ((ATR *) atr, buffer, &length); else length = 0; buffer[length] = CTBCS_SW1_RESET_ASYNC_OK; buffer[length + 1] = CTBCS_SW2_RESET_ASYNC_OK; length += 2; } else { if (atr != NULL) ATR_Sync_GetRaw ((ATR_Sync *) atr, buffer, &length); else length = 0; buffer[length] = CTBCS_SW1_RESET_SYNC_OK; buffer[length +1] = CTBCS_SW2_RESET_SYNC_OK; length += 2; } } /* Return historical bytes of ATR */ else if (p2 == CTBCS_P2_RESET_GET_HIST) { atr = CT_Slot_GetAtr (ct->slots[sn]); if (CT_Slot_GetICCType (ct->slots[sn]) == CT_SLOT_ICC_ASYNC) { if (atr != NULL) ATR_GetHistoricalBytes ((ATR *) atr, buffer, &length); else length = 0; buffer[length] = CTBCS_SW1_RESET_ASYNC_OK; buffer[length + 1] = CTBCS_SW2_RESET_ASYNC_OK; length += 2; } else { if (atr != NULL) ATR_Sync_GetHistoricalBytes ((ATR_Sync *) atr, buffer, &length); else length = 0; buffer[length] = CTBCS_SW1_RESET_SYNC_OK; buffer[length + 1] = CTBCS_SW2_RESET_SYNC_OK; length +=2; } } /* Wrong command cualifier */ else { length = 2; buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; ret = OK; } } /* Wrong functional unit */ else { length = 2; buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; ret = OK; } (*rsp) = APDU_Rsp_New (buffer, length); return ret; } static char CardTerminal_RequestICC (CardTerminal * ct, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE buffer[CARDTERMINAL_REQUESTICC_BUFFER_SIZE], p1, p2; unsigned timeout, sn, length; bool card, change; void * atr; char ret; /* Get functional unit */ p1 = APDU_Cmd_P1 (cmd); if ((p1 == CTBCS_P1_INTERFACE1) || (p1 == CTBCS_P1_INTERFACE2)) { /* Get the slot number */ sn = (p1 == CTBCS_P1_INTERFACE1) ? 0 : 1; if (CT_Slot_GetICCType (ct->slots[sn]) != CT_SLOT_NULL) { buffer[0] = CTBCS_SW1_REQUEST_CARD_PRESENT; buffer[1] = CTBCS_SW2_REQUEST_CARD_PRESENT; (*rsp) = APDU_Rsp_New (buffer, 2); return OK; } /* Get the card insertion timeout */ if (APDU_Cmd_Lc (cmd) == 1) timeout = (APDU_Cmd_Data (cmd)[0]); else timeout = 0; /* Check for card */ ret = CT_Slot_Check (ct->slots[sn], timeout, &card, &change); if (ret != OK) { buffer[0] = CTBCS_SW1_REQUEST_ERROR; buffer[1] = CTBCS_SW2_REQUEST_ERROR; (*rsp) = APDU_Rsp_New (buffer, 2); return ret; } /* No card present */ if (!card) { buffer[0] = CTBCS_SW1_REQUEST_NO_CARD; buffer[1] = CTBCS_SW2_REQUEST_NO_CARD; (*rsp) = APDU_Rsp_New (buffer, 2); return OK; } /* Probe card type */ if (APDU_Cmd_Lc (cmd) > 1) ret = CT_Slot_Probe (ct->slots[sn], APDU_Cmd_Data(cmd), APDU_Cmd_Lc(cmd)); else ret = CT_Slot_Probe (ct->slots[sn], NULL, 0); if (ret != OK || (CT_Slot_GetICCType (ct->slots[sn]) == CT_SLOT_NULL)) { buffer[0] = CTBCS_SW1_REQUEST_ERROR; buffer[1] = CTBCS_SW2_REQUEST_ERROR; (*rsp) = APDU_Rsp_New (buffer, 2); return ret; } /* Get command cualifier */ p2 = APDU_Cmd_P2 (cmd); /* Do not return data */ if (p2 == CTBCS_P2_REQUEST_NO_RESP) { if (CT_Slot_GetICCType (ct->slots[sn]) == CT_SLOT_ICC_ASYNC) { buffer[0] = CTBCS_SW1_REQUEST_ASYNC_OK; buffer[1] = CTBCS_SW2_REQUEST_ASYNC_OK; length = 2; } else { buffer[0] = CTBCS_SW1_REQUEST_SYNC_OK; buffer[1] = CTBCS_SW2_REQUEST_SYNC_OK; length = 2; } } /* Return whole atr */ else if (p2 == CTBCS_P2_REQUEST_GET_ATR) { atr = CT_Slot_GetAtr (ct->slots[sn]); if (CT_Slot_GetICCType (ct->slots[sn]) == CT_SLOT_ICC_ASYNC) { if (atr != NULL) ATR_GetRaw ((ATR *) atr, buffer, &length); else length = 0; buffer[length] = CTBCS_SW1_REQUEST_ASYNC_OK; buffer[length + 1] = CTBCS_SW2_REQUEST_ASYNC_OK; length += 2; } else { if (atr != NULL) ATR_Sync_GetRaw ((ATR_Sync *) atr, buffer, &length); else length = 0; buffer[length] = CTBCS_SW1_REQUEST_SYNC_OK; buffer[length +1] = CTBCS_SW2_REQUEST_SYNC_OK; length += 2; } } /* Return historical bytes */ else if (p2 == CTBCS_P2_REQUEST_GET_HIST) { atr = CT_Slot_GetAtr (ct->slots[sn]); if (CT_Slot_GetICCType (ct->slots[sn]) == CT_SLOT_ICC_ASYNC) { if (atr != NULL) ATR_GetHistoricalBytes ((ATR *) atr, buffer, &length); else length = 0; buffer[length] = CTBCS_SW1_REQUEST_ASYNC_OK; buffer[length + 1] = CTBCS_SW2_REQUEST_ASYNC_OK; length += 2; } else { if (atr != NULL) ATR_Sync_GetHistoricalBytes ((ATR_Sync *) atr, buffer, &length); else length = 0; buffer[length] = CTBCS_SW1_REQUEST_SYNC_OK; buffer[length + 1] = CTBCS_SW2_REQUEST_SYNC_OK; } } /* Wrong command cualifier */ else { length = 2; buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; ret = OK; } } /* Wrong functional unit */ else { length = 2; buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; ret = OK; } (*rsp) = APDU_Rsp_New (buffer, (long)length); return ret; } static char CardTerminal_GetStatus (CardTerminal * ct, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE buffer[CARDTERMINAL_GETSTATUS_BUFFER_SIZE], p1, p2; bool card, change; int i; unsigned length; char ret = OK; /* Get functional unit */ p1 = APDU_Cmd_P1 (cmd); /* Wrong functional unit */ if (p1 != CTBCS_P1_CT_KERNEL) { length = 2; buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; ret = OK; } /* Get command cualifier */ p2 = APDU_Cmd_P2 (cmd); if (p2 == CTBCS_P2_STATUS_MANUFACTURER) { length = 17; /* CT Manufacturer */ memcpy(buffer,CARDTERMINAL_MANUFACTURER,5); /* CT type */ if (ct->slots[0] != NULL) CT_Slot_GetType(ct->slots[0], buffer + 5,5); /* CT version */ memcpy(buffer+10,VERSION,5); buffer[15] = CTBCS_SW1_OK; buffer[16] = CTBCS_SW2_OK; ret = OK; } else if (p2 == CTBCS_P2_STATUS_ICC) { for (i = 0; i < ct->num_slots; i++) { ret = CT_Slot_Check (ct->slots[i], 0, &card, &change); if (ret != OK) { /* There are no status bytes defined to be returned on error */ (*rsp) = NULL; return ret; } /* Resynchronise the driver status with the actual status of slot */ if ((CT_Slot_GetICCType (ct->slots[i]) != CT_SLOT_NULL) && (!card || change)) { ret = CT_Slot_Release (ct->slots[i]); if (ret != OK) { (*rsp) = NULL; return ret; } } buffer[i] = card? CTBCS_DATA_STATUS_CARD_CONNECT: CTBCS_DATA_STATUS_NOCARD; } length = i+2; buffer[i] = CTBCS_SW1_OK; buffer[i+1] = CTBCS_SW2_OK; } /* Wrong command cualifier */ else { length = 2; buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; ret = OK; } (*rsp) = APDU_Rsp_New (buffer, length); return ret; } static char CardTerminal_EjectICC (CardTerminal * ct, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE buffer[CARDTERMINAL_EJECTICC_BUFFER_SIZE], p1, p2; int sn, timeout; unsigned length; bool card, change; char ret; /* Get functional unit */ p1 = APDU_Cmd_P1 (cmd); /* Wrong functional unit */ if ((p1 != CTBCS_P1_INTERFACE1) && (p1 != CTBCS_P1_INTERFACE2)) { buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; (*rsp) = APDU_Rsp_New (buffer, 2); return OK; } /* Get the slot number */ sn = (p1 == CTBCS_P1_INTERFACE1) ? 0 : 1; if (!(sn < ct->num_slots)) { buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; (*rsp) = APDU_Rsp_New (buffer, 2); return ERR_INVALID; } /* Get command cualifier */ p2 = APDU_Cmd_P2 (cmd); #if 0 /* Wrong command cualifier */ if (p2 != 0) { buffer[0] = CTBCS_SW1_WRONG_PARAM; buffer[1] = CTBCS_SW2_WRONG_PARAM; (*rsp) = APDU_Rsp_New (buffer, 2); return OK; } #endif if (CT_Slot_GetICCType (ct->slots[sn]) == CT_SLOT_NULL) { buffer[0] = CTBCS_SW1_EJECT_OK; buffer[1] = CTBCS_SW2_EJECT_OK; (*rsp) = APDU_Rsp_New (buffer, 2); return OK; } /* Get the card removal timeout */ if (APDU_Cmd_Lc (cmd) == 1) timeout = (int) (*APDU_Cmd_Data (cmd)); else timeout = 0; /* Check for card removal */ ret = CT_Slot_Check (ct->slots[sn], timeout, &card, &change); if (ret != OK) { (*rsp) = NULL; return ret; } /* Release ICC (always or only when card is removed?) */ ret = CT_Slot_Release (ct->slots[sn]); if (ret != OK) { (*rsp) = NULL; return ret; } if (timeout != 0) { if (card) { buffer[0] = CTBCS_SW1_EJECT_NOT_REMOVED; buffer[1] = CTBCS_SW2_EJECT_NOT_REMOVED; length = 2; } else { buffer[0] = CTBCS_SW1_EJECT_REMOVED; buffer[1] = CTBCS_SW2_EJECT_REMOVED; length = 2; } } else { buffer[0] = CTBCS_SW1_EJECT_OK;; buffer[1] = CTBCS_SW2_EJECT_OK;; length = 2; } (*rsp) = APDU_Rsp_New (buffer, length); return ret; } static void CardTerminal_Clear (CardTerminal * ct) { int i; ct->io = NULL; ct->num_slots = 0; for (i = 0; i < CARDTERMINAL_MAX_SLOTS; i++) ct->slots[i] = NULL; } towitoko-2.0.7/src/ct-api/ct_slot.c0000644000175000017500000002541007527763655012667 /* ct_slot.c Card Terminal Slot handling functions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include "ct_slot.h" #include "ifd_towitoko.h" #include "icc_sync.h" #include "icc_async.h" #include "protocol_sync.h" #include "protocol_t0.h" #include "protocol_t1.h" #include "pps.h" #include #include #include #include #ifdef HAVE_SYS_TIME_H #include #endif /* Try first asynchronous init and if it fails try synchronous */ #undef ICC_PROBE_ASYNC_FIRST /* * Not exported functions declaration */ static void CT_Slot_Clear (CT_Slot * slot); /* * Exported functions definition */ CT_Slot * CT_Slot_New () { CT_Slot *slot; slot = (CT_Slot *) malloc (sizeof (CT_Slot)); if (slot != NULL) CT_Slot_Clear (slot); return slot; } char CT_Slot_Init (CT_Slot * slot, IO_Serial * io, int sn) { slot->ifd = IFD_Towitoko_New(); if (slot->ifd == NULL) return ERR_MEMORY; if (IFD_Towitoko_Init (slot->ifd, io, sn) != IFD_TOWITOKO_OK) { IFD_Towitoko_Delete (slot->ifd); slot->ifd = NULL; return ERR_TRANS; } return OK; } char CT_Slot_Check (CT_Slot * slot, int timeout, bool * card, bool * change) { BYTE status; #ifdef HAVE_NANOSLEEP struct timespec req_ts; req_ts.tv_sec = 1; req_ts.tv_nsec = 0; #endif /* Do first time check */ if (IFD_Towitoko_GetStatus (slot->ifd, &status) != IFD_TOWITOKO_OK) return ERR_TRANS; (*change) = IFD_TOWITOKO_CHANGE (status); while ((timeout > 0) && (!IFD_TOWITOKO_CARD (status))) { timeout --; #ifdef HAVE_NANOSLEEP /* Sleep one second */ nanosleep (&req_ts,NULL); #else usleep (1000); #endif if (IFD_Towitoko_GetStatus (slot->ifd, &status) != IFD_TOWITOKO_OK) return ERR_TRANS; (*change) |= IFD_TOWITOKO_CHANGE (status); } (*card) = IFD_TOWITOKO_CARD (status); return OK; } char CT_Slot_Probe (CT_Slot * slot, BYTE * userdata, unsigned length) { PPS * pps; BYTE buffer[PPS_MAX_LENGTH]; unsigned buffer_len = 0; #ifndef ICC_PROBE_ASYNC_FIRST /* Initiaice ICC */ slot->icc = ICC_Sync_New (); if (slot->icc == NULL) return ERR_MEMORY; if (ICC_Sync_Init ((ICC_Sync *) slot->icc, slot->ifd) != ICC_SYNC_OK) { ICC_Sync_Delete ((ICC_Sync *) slot->icc); /* Try asynchronous init */ slot->icc = ICC_Async_New (); if (slot->icc == NULL) return ERR_MEMORY; if (ICC_Async_Init ((ICC_Async *) slot->icc, slot->ifd) != ICC_ASYNC_OK) { ICC_Async_Delete ((ICC_Async *) slot->icc); /* ICC is not synchronous neither asynchronous */ slot->icc = NULL; slot->icc_type = CT_SLOT_NULL; /* return ERR_TRANS */ return OK; } /* Asynchronous card present */ slot->icc_type = CT_SLOT_ICC_ASYNC; } else /* Syncronous card present */ slot->icc_type = CT_SLOT_ICC_SYNC; #else /* Initiaice ICC */ slot->icc = ICC_Async_New (); if (slot->icc == NULL) return ERR_MEMORY; if (ICC_Async_Init (slot->icc, slot->ifd) != ICC_ASYNC_OK) { ICC_Async_Delete (slot->icc); /* Try synchronous init */ slot->icc = ICC_Sync_New (); if (slot->icc == NULL) return ERR_MEMORY; if (ICC_Sync_Init (slot->icc, slot->ifd) != ICC_SYNC_OK) { ICC_Sync_Delete (slot->icc); /* ICC is not synchronous neither asynchronous */ slot->icc = NULL; slot->icc_type = CT_SLOT_NULL; return OK; } /* Synchronous card present */ slot->icc_type = CT_SLOT_ICC_SYNC; } else /* Asyncronous card present */ slot->icc_type = CT_SLOT_ICC_ASYNC; #endif /* Initialise protocol */ if (slot->icc_type == CT_SLOT_ICC_ASYNC) { pps = PPS_New((ICC_Async *) slot->icc); if (pps == NULL) { ICC_Async_Close ((ICC_Async *) slot->icc); ICC_Async_Delete ((ICC_Async *) slot->icc); slot->icc = NULL; slot->icc_type = CT_SLOT_NULL; return ERR_MEMORY; } /* Prepare PPS request */ if ((userdata != NULL) && (length > 0)) memcpy (buffer, userdata, buffer_len = MIN(length, PPS_MAX_LENGTH)); /* Do PPS */ if (PPS_Perform (pps, buffer, &buffer_len) != PPS_OK) { PPS_Delete (pps); ICC_Async_Close ((ICC_Async *) slot->icc); ICC_Async_Delete ((ICC_Async *) slot->icc); slot->icc = NULL; slot->icc_type = CT_SLOT_NULL; slot->protocol_type = CT_SLOT_NULL; return ERR_TRANS; } slot->protocol_type = (PPS_GetProtocolParameters (pps))->t; slot->protocol = PPS_GetProtocol (pps); PPS_Delete (pps); } else if (slot->icc_type == CT_SLOT_ICC_SYNC) { slot->protocol = Protocol_Sync_New (); if (slot->protocol == NULL) { /* Delete ICC */ ICC_Sync_Close ((ICC_Sync *) slot->icc); ICC_Sync_Delete ((ICC_Sync *) slot->icc); slot->icc = NULL; slot->icc_type = CT_SLOT_NULL; return ERR_MEMORY; } if (Protocol_Sync_Init ((Protocol_Sync *) slot->protocol, (ICC_Sync *) slot->icc) != PROTOCOL_SYNC_OK) { /* Delete ICC */ ICC_Sync_Close ((ICC_Sync *) slot->icc); ICC_Sync_Delete ((ICC_Sync *) slot->icc); slot->icc = NULL; slot->icc_type = CT_SLOT_NULL; /* Delete protocol */ Protocol_Sync_Delete ((Protocol_Sync *) slot->protocol); slot->protocol = NULL; slot->protocol_type = CT_SLOT_NULL; return ERR_TRANS; } slot->protocol_type = CT_SLOT_PROTOCOL_SYNC; } return OK; } char CT_Slot_Release (CT_Slot * slot) { char ret; ret = OK; if (slot->protocol_type == CT_SLOT_PROTOCOL_SYNC) { if (Protocol_Sync_Close ((Protocol_Sync *) slot->protocol) != PROTOCOL_SYNC_OK) ret = ERR_TRANS; Protocol_Sync_Delete ((Protocol_Sync *) slot->protocol); } else if (slot->protocol_type == CT_SLOT_PROTOCOL_T0) { if (Protocol_T0_Close ((Protocol_T0 *) slot->protocol) != PROTOCOL_T0_OK) ret = ERR_TRANS; Protocol_T0_Delete ((Protocol_T0 *) slot->protocol); } else if (slot->protocol_type == CT_SLOT_PROTOCOL_T1) { if (Protocol_T1_Close ((Protocol_T1 *) slot->protocol) != PROTOCOL_T1_OK) ret = ERR_TRANS; Protocol_T1_Delete ((Protocol_T1 *) slot->protocol); } slot->protocol = NULL; slot->protocol_type = CT_SLOT_NULL; if (slot->icc_type == CT_SLOT_ICC_SYNC) { if (ICC_Sync_Close ((ICC_Sync *) slot->icc) != ICC_SYNC_OK) ret = ERR_TRANS; ICC_Sync_Delete ((ICC_Sync *) slot->icc); } else if (slot->icc_type == CT_SLOT_ICC_ASYNC) { if (ICC_Async_Close ((ICC_Async *) slot->icc) != ICC_ASYNC_OK) ret = ERR_TRANS; ICC_Async_Delete ((ICC_Async *) slot->icc); } slot->icc = NULL; slot->icc_type = CT_SLOT_NULL; return ret; } char CT_Slot_Command (CT_Slot * slot, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE buffer[2]; char ret; /* Synchronous protocol ICC */ if (slot->protocol_type == CT_SLOT_PROTOCOL_SYNC) { if (Protocol_Sync_Command ((Protocol_Sync *) slot->protocol, cmd, rsp) != PROTOCOL_SYNC_OK) ret = ERR_TRANS; else ret = OK; } /* T=0 protocol ICC */ else if (slot->protocol_type == CT_SLOT_PROTOCOL_T0) { if (Protocol_T0_Command ((Protocol_T0 *) slot->protocol, cmd, rsp) != PROTOCOL_T0_OK) ret = ERR_TRANS; else ret = OK; } /* T=1 protocol ICC */ else if (slot->protocol_type == CT_SLOT_PROTOCOL_T1) { if (Protocol_T1_Command ((Protocol_T1 *) slot->protocol, cmd, rsp) != PROTOCOL_T1_OK) ret = ERR_TRANS; else ret = OK; } /* Card removed */ else if (slot->protocol_type == CT_SLOT_NULL) { buffer[0] = CTBCS_SW1_ICC_ERROR; buffer[1] = CTBCS_SW2_ICC_ERROR; (*rsp) = APDU_Rsp_New (buffer, 2); ret = OK; } /* Other protocol */ else { (*rsp) = NULL; ret = ERR_HTSI; } return ret; } int CT_Slot_GetICCType (CT_Slot * slot) { return slot->icc_type; } void * CT_Slot_GetICC (CT_Slot * slot) { return slot->icc; } void * CT_Slot_GetAtr (CT_Slot * slot) { if (slot->icc_type == CT_SLOT_ICC_ASYNC) return ((void *) ICC_Async_GetAtr((ICC_Async *) slot->icc)); else if (slot->icc_type == CT_SLOT_ICC_SYNC) return ((void *) ICC_Sync_GetAtr((ICC_Sync *) slot->icc)); return NULL; } bool CT_Slot_IsLast (CT_Slot * slot) { return (IFD_Towitoko_GetSlot(slot->ifd) >= IFD_Towitoko_GetNumSlots(slot->ifd)-1); } void CT_Slot_GetType (CT_Slot * slot, BYTE * buffer, int len) { IFD_Towitoko_GetDescription (slot->ifd, buffer, len); } char CT_Slot_Close (CT_Slot * slot) { char ret; ret = OK; if (slot->protocol_type == CT_SLOT_PROTOCOL_SYNC) { if (Protocol_Sync_Close ((Protocol_Sync *) slot->protocol) != PROTOCOL_SYNC_OK) ret = ERR_TRANS; Protocol_Sync_Delete ((Protocol_Sync *) slot->protocol); } else if (slot->protocol_type == CT_SLOT_PROTOCOL_T0) { if (Protocol_T0_Close ((Protocol_T0 *) slot->protocol) != PROTOCOL_T0_OK) ret = ERR_TRANS; Protocol_T0_Delete ((Protocol_T0 *) slot->protocol); } else if (slot->protocol_type == CT_SLOT_PROTOCOL_T1) { if (Protocol_T1_Close ((Protocol_T1 *) slot->protocol) != PROTOCOL_T1_OK) ret = ERR_TRANS; Protocol_T1_Delete ((Protocol_T1 *) slot->protocol); } if (slot->icc_type == CT_SLOT_ICC_SYNC) { if (ICC_Sync_Close ((ICC_Sync *) slot->icc) != ICC_SYNC_OK) ret = ERR_TRANS; ICC_Sync_Delete ((ICC_Sync *) slot->icc); } else if (slot->icc_type == CT_SLOT_ICC_ASYNC) { if (ICC_Async_Close ((ICC_Async *) slot->icc) != ICC_ASYNC_OK) ret = ERR_TRANS; ICC_Async_Delete ((ICC_Async *) slot->icc); } if (slot->ifd != NULL) { if (IFD_Towitoko_Close (slot->ifd) != IFD_TOWITOKO_OK) ret = ERR_TRANS; IFD_Towitoko_Delete (slot->ifd); } CT_Slot_Clear (slot); return ret; } void CT_Slot_Delete (CT_Slot * slot) { free (slot); } /* * Not exported functions definition */ static void CT_Slot_Clear (CT_Slot * slot) { slot->ifd = NULL; slot->icc = NULL; slot->protocol = NULL; slot->icc_type = CT_SLOT_NULL; slot->protocol_type = CT_SLOT_NULL; } towitoko-2.0.7/src/ct-api/ct_list.c0000644000175000017500000000623707361636765012664 /* cl_list.c Implementation of a linked list of card-terminals This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include "ct_list.h" /* * Exported functions definition */ extern CT_List * CT_List_New (void) { CT_List *aux; aux = (CT_List *) malloc (sizeof (CT_List)); if (aux != NULL) { aux->first = NULL; aux->last = NULL; aux->elements = 0; } return (aux); } extern bool CT_List_AddCardTerminal (CT_List * list, CardTerminal * ct, unsigned short ctn) { struct CT_List_Node *node; if (list == NULL) return FALSE; node = (struct CT_List_Node *) malloc (sizeof (struct CT_List_Node)); if (node != NULL) { node->ct = ct; node->ctn = ctn; node->next = NULL; if (list->first == NULL) { list->first = node; list->last = node; } else { list->last->next = node; list->last = node; } list->elements++; } return (node != NULL); } extern CardTerminal * CT_List_GetCardTerminal (CT_List * list, unsigned short ctn) { struct CT_List_Node *node; CardTerminal *ct = NULL; if (list == NULL) return NULL; for (node = list->first; (node != NULL) && (ct == NULL); node = node->next) if (node->ctn == ctn) ct = node->ct; return ct; } extern int CT_List_GetNumberOfElements (CT_List * list) { if (list == NULL) return 0; return list->elements; } extern bool CT_List_RemoveCardTerminal (CT_List * list, unsigned short ctn) { struct CT_List_Node *current, *previous; bool found; if (list == NULL) return FALSE; previous = NULL; current = list->first; found = FALSE; while ((current != NULL) && (!found)) { if (current->ctn == ctn) found = TRUE; else { previous = current; current = current->next; } } if (found) { if (current == list->first) list->first = current->next; else previous->next = current->next; if (current == list->last) list->last = previous; CardTerminal_Delete (current->ct); free (current); list->elements--; } return found; } extern void CT_List_Delete (CT_List * list) { struct CT_List_Node *node; if (list == NULL) return; while (list->first != NULL) { node = list->first; list->first = list->first->next; CardTerminal_Delete (node->ct); free (node); } free (list); } towitoko-2.0.7/src/ct-api/ctapi.c0000644000175000017500000001547107521022540012275 /* ctapi.c CT-API interface implementation for multiple card-terminals This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 1998 1999 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include "ctapi.h" #include "ctbcs.h" #include "ct_list.h" #include "cardterminal.h" #include "ct_slot.h" #include #include #ifdef HAVE_PTHREAD_H #include #endif /* * Not exported variables definition */ /* Linked list of card-terminals */ static CT_List *ct_list = NULL; #ifdef HAVE_PTHREAD_H static pthread_mutex_t ct_list_mutex = PTHREAD_MUTEX_INITIALIZER; #endif /* * Exported functions definition */ char CT_init (unsigned short ctn, unsigned short pn) { CardTerminal *ct; char ret; bool ct_list_empty; #ifdef HAVE_PTHREAD_H pthread_mutex_lock (&ct_list_mutex); #endif /* Check that ctn is not in use */ if (CT_List_GetCardTerminal (ct_list, ctn) == NULL) { /* Create a new CardTerminal */ ct = CardTerminal_New (); if (ct != NULL) { /* Initialize CardTerminal */ ret = CardTerminal_Init (ct, pn); /* Add CardTerminal to list */ if (ret == OK) { /* See if list is initialised */ ct_list_empty = (ct_list == NULL); if (ct_list_empty) ct_list = CT_List_New (); /* Add the CardTerminal to the list */ if (!CT_List_AddCardTerminal (ct_list, ct, ctn)) { CardTerminal_Close (ct); CardTerminal_Delete (ct); if (ct_list_empty) { CT_List_Delete (ct_list); ct_list = NULL; } ret = ERR_MEMORY; } } else CardTerminal_Delete(ct); } else ret = ERR_MEMORY; } else ret = ERR_CT; #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ct_list_mutex); #endif #ifdef DEBUG_CTAPI printf ("CTAPI: CT_init(ctn=%u, pn=%u)=%d\n", ctn, pn, ret); #endif return ret; } char CT_close (unsigned short ctn) { CardTerminal *ct; char ret; #ifdef HAVE_PTHREAD_H pthread_mutex_lock (&ct_list_mutex); #endif /* Get the card-terminal */ ct = CT_List_GetCardTerminal (ct_list, ctn); if (ct != NULL) { /* Close CardTerminal */ ret = CardTerminal_Close(ct); /* Remove card-terminal from list */ CT_List_RemoveCardTerminal (ct_list, ctn); /* Delete the list if there are no more card-terminals */ if (CT_List_GetNumberOfElements (ct_list) == 0) { CT_List_Delete (ct_list); ct_list = NULL; } } else ret = ERR_CT; #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ct_list_mutex); #endif #ifdef DEBUG_CTAPI printf ("CTAPI: CT_close(ctn=%d)=%u\n", ctn, ret); #endif return ret; } char CT_data (unsigned short ctn, unsigned char *dad, unsigned char *sad, unsigned short lc, unsigned char *cmd, unsigned short *lr, unsigned char *rsp) { CardTerminal *ct; CT_Slot *slot; APDU_Cmd *apdu_cmd; APDU_Rsp *apdu_rsp = NULL; int remain; unsigned char aux; char ret; #ifdef DEBUG_CTAPI int i; printf ("CTAPI: CT_data(ctn=%u, *dad=0x%02X, *sad=0x%02X, lc=%u, *cmd={", ctn, *dad, *sad, lc); for (i=0; i 0) ret = ERR_MEMORY; (*lr) = MIN ((*lr), (short)APDU_Rsp_RawLen (apdu_rsp)); memcpy (rsp, APDU_Rsp_Raw (apdu_rsp) + remain, (*lr)); /* Delete response APDU */ APDU_Rsp_Delete (apdu_rsp); } else (*lr) = 0; /* Delete command APDU */ APDU_Cmd_Delete (apdu_cmd); } else ret = ERR_MEMORY; } else ret = ERR_CT; #ifdef DEBUG_CTAPI printf ("CTAPI: CT_data(ctn=%u, *dad=0x%02X, *sad=0x%02X, lc=%u, *cmd={}, *lr=%u, rsp={", ctn, *dad, *sad, lc, *lr); for (i=0; i<*lr; i++) printf ("%02X ", rsp[i]); printf ("})=%d\n", ret); #endif return ret; } towitoko-2.0.7/src/ct-api/cardterminal.h0000644000175000017500000000441207361636766013667 /* cardterminal.h Card Terminal handling definitions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _CARDTERMINAL_ #define _CARDTERMINAL_ #include "defines.h" #include "ct_slot.h" #include "io_serial.h" #include "apdu.h" #include "ctapi.h" #include "ctbcs.h" #ifdef HAVE_PTHREAD_H #include "pthread.h" #endif /* * Exported constats definition */ /* Maximum number of slots in a cardterminal */ #define CARDTERMINAL_MAX_SLOTS 2 /* * Exported datatypes definition */ typedef struct { IO_Serial * io; /* Serial device */ CT_Slot * slots[CARDTERMINAL_MAX_SLOTS]; /* Array of CT_Slot's */ int num_slots; /* Number of CT_Slot's */ #ifdef HAVE_PTHREAD_H pthread_mutex_t mutex; #endif } CardTerminal; /* * Exported functions declaration */ /* Cretate a new CardTerminal */ extern CardTerminal * CardTerminal_New (); /* Intialice a CardTerminal in a given port */ extern char CardTerminal_Init (CardTerminal * ct, unsigned short pn); /* Send a CT-BCS command to a CardTerminal */ extern char CardTerminal_Command (CardTerminal * ct, APDU_Cmd * cmd, APDU_Rsp ** rsp); /* Return the reference to a slot */ extern CT_Slot * CardTerminal_GetSlot (CardTerminal * ct, int number); /* Close a CardTerminal */ extern char CardTerminal_Close (CardTerminal * cn); /* Delete a CardTerminal */ extern void CardTerminal_Delete (CardTerminal * ct); #ifdef HAVE_PTHREAD_H extern pthread_mutex_t * CardTerminal_GetMutex (CardTerminal * ct); #endif #endif towitoko-2.0.7/src/ct-api/ct_slot.h0000644000175000017500000000533207400236213012644 /* ct_slot.h Card Terminal Slot handling definitions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _CT_SLOT_ #define _CT_SLOT_ #include "defines.h" #include "apdu.h" #include "ctapi.h" #include "ctbcs.h" #include "ifd_towitoko.h" /* * Exported constats definition */ /* Type of protocol and ICC */ #define CT_SLOT_PROTOCOL_T0 0 #define CT_SLOT_PROTOCOL_T1 1 #define CT_SLOT_PROTOCOL_SYNC 16 #define CT_SLOT_ICC_ASYNC 0 #define CT_SLOT_ICC_SYNC 1 #define CT_SLOT_NULL -1 /* * Exported datatypes definition */ typedef struct { IFD * ifd; /* Interface device */ void * icc; /* Integrated circuit card */ void * protocol; /* Protocol handler */ int icc_type; /* Type of ICC */ int protocol_type; /* Type of protocol */ } CT_Slot; /* * Exported functions declaration */ /* Cretate a new CT_Slot */ extern CT_Slot * CT_Slot_New (); /* Intialice a CT_Slot */ extern char CT_Slot_Init (CT_Slot * slot, IO_Serial * io, int sn); /* Check for card inserted */ extern char CT_Slot_Check (CT_Slot * slot, int timeout, bool * card, bool * change); /* Probe ICC type and protocol */ extern char CT_Slot_Probe (CT_Slot * slot, BYTE * userdata, unsigned length); /* Release status information */ extern char CT_Slot_Release (CT_Slot * slot); /* Send a command to and ICC */ extern char CT_Slot_Command (CT_Slot * slot, APDU_Cmd * cmd, APDU_Rsp ** rsp); /* Return ICC type */ extern int CT_Slot_GetICCType (CT_Slot * slot); /* Return a reference to the ICC */ extern void * CT_Slot_GetICC (CT_Slot * slot); /* Get answer to reset of the card */ extern void * CT_Slot_GetAtr (CT_Slot * slot); /* Says if this slot is last */ extern bool CT_Slot_IsLast (CT_Slot * slot); /* Return slot type */ extern void CT_Slot_GetType (CT_Slot * slot, BYTE * buffer, int len); /* Close a CT_Slot */ extern char CT_Slot_Close (CT_Slot * slot); /* Delete a CT_Slot */ extern void CT_Slot_Delete (CT_Slot * slot); #endif towitoko-2.0.7/src/ct-api/ct_list.h0000644000175000017500000000430607361636763012662 /* cl_list.c Definition of a linked list of card-terminals This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _CT_LIST_ #define _CT_LIST_ #include "defines.h" #include "cardterminal.h" /* * Exported datatypes definition */ /* Node of the list */ struct CT_List_Node { unsigned short ctn; /* Card Terminal number */ CardTerminal *ct; /* Card Terminal reference */ struct CT_List_Node *next; /* Next node of the list */ }; /* Linked list of card-terminals */ typedef struct { struct CT_List_Node *first; /* First element */ struct CT_List_Node *last; /* Last element */ int elements; /* Number of elements */ } CT_List; /* * Exported functions declaration */ /* Creates a new list of CardTerminals */ extern CT_List * CT_List_New (void); /* Adds a CardTerminal to a existing list */ extern bool CT_List_AddCardTerminal (CT_List * list, CardTerminal * ct, unsigned short ctn); /* Returns a CardTerminal by its number or NULL if not found */ extern CardTerminal * CT_List_GetCardTerminal (CT_List * list, unsigned short ctn); /* Returns the number of CardTerminals in a list */ extern int CT_List_GetNumberOfElements (CT_List * list); /* Removes a CardTerminal from a list by its number */ extern bool CT_List_RemoveCardTerminal (CT_List * list, unsigned short ctn); /* Empties and removes a list */ extern void CT_List_Delete (CT_List * list); #endif /* _CT_LIST_ */ towitoko-2.0.7/src/ifd-handler/0002777000175000017500000000000007527763750012134 5towitoko-2.0.7/src/ifd-handler/Makefile.am0000644000175000017500000000213307361641162014065 # # ifd-handler/Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SRC = ifdhandler.c INC = ifdhandler.h pcscdefines.h noinst_LTLIBRARIES = libtowitoko-ifdhandler.la INCLUDES = -I$(top_srcdir)/src/ct-api -I$(top_srcdir) libtowitoko_ifdhandler_la_SOURCES = $(SRC) $(INC) towitoko-2.0.7/src/ifd-handler/Makefile.in0000644000175000017500000002446507527762032014116 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ # # ifd-handler/Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../.. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AS = @AS@ AWK = @AWK@ CC = @CC@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBOOK_TO_MAN = @DOCBOOK_TO_MAN@ ECHO = @ECHO@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ PCSC_LITE_DIR = @PCSC_LITE_DIR@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ SRC = ifdhandler.c INC = ifdhandler.h pcscdefines.h noinst_LTLIBRARIES = libtowitoko-ifdhandler.la INCLUDES = -I$(top_srcdir)/src/ct-api -I$(top_srcdir) libtowitoko_ifdhandler_la_SOURCES = $(SRC) $(INC) subdir = src/ifd-handler mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(noinst_LTLIBRARIES) libtowitoko_ifdhandler_la_LDFLAGS = libtowitoko_ifdhandler_la_LIBADD = am__objects_1 = ifdhandler.lo am__objects_2 = am_libtowitoko_ifdhandler_la_OBJECTS = $(am__objects_1) $(am__objects_2) libtowitoko_ifdhandler_la_OBJECTS = \ $(am_libtowitoko_ifdhandler_la_OBJECTS) DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/ifdhandler.Plo COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ CFLAGS = @CFLAGS@ DIST_SOURCES = $(libtowitoko_ifdhandler_la_SOURCES) DIST_COMMON = Makefile.am Makefile.in SOURCES = $(libtowitoko_ifdhandler_la_SOURCES) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu src/ifd-handler/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) clean-noinstLTLIBRARIES: -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test -z "$dir" && dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtowitoko-ifdhandler.la: $(libtowitoko_ifdhandler_la_OBJECTS) $(libtowitoko_ifdhandler_la_DEPENDENCIES) $(LINK) $(libtowitoko_ifdhandler_la_LDFLAGS) $(libtowitoko_ifdhandler_la_OBJECTS) $(libtowitoko_ifdhandler_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifdhandler.Plo@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` .c.lo: @AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< CCDEPMODE = @CCDEPMODE@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: ETAGS = etags ETAGSFLAGS = tags: TAGS 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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../.. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkinstalldirs) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ 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 check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-libtool distclean-tags dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-exec-am: install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool uninstall-am: uninstall-info-am .PHONY: GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-noinstLTLIBRARIES distclean \ distclean-compile distclean-depend distclean-generic \ distclean-libtool distclean-tags distdir dvi dvi-am info \ info-am install install-am install-data install-data-am \ install-exec install-exec-am install-info install-info-am \ install-man install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool tags uninstall uninstall-am \ uninstall-info-am # 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: towitoko-2.0.7/src/ifd-handler/ifdhandler.c0000644000175000017500000003515107404720340014275 /* ifdhandler.c Mapping if CT-API / CT-BCS interface to the IFD Hanlder 2.0. Getting/Setting IFD/Protocol/ICC parameters other than the ATR is not supported. IFDH_MAX_READERS simultaneous readers are supported. This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 1998 1999 2000 2001 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include "pcscdefines.h" #include "ifdhandler.h" #include #include #include #include #include #ifdef HAVE_PTHREAD_H #include #endif #ifdef DEBUG_IFDH #include #endif /* * Not exported constants definition */ /* Maximum number of readers handled */ #define IFDH_MAX_READERS 4 /* Maximum number of slots per reader handled */ #define IFDH_MAX_SLOTS 1 /* * Not exported data types definition */ typedef struct { DEVICE_CAPABILITIES device_capabilities; ICC_STATE icc_state; PROTOCOL_OPTIONS protocol_options; } IFDH_Context; /* * Not exported variables definition */ /* Matrix that stores conext information of all slots and readers */ static IFDH_Context *ifdh_context[IFDH_MAX_READERS][IFDH_MAX_SLOTS] = { {NULL},{NULL},{NULL},{NULL}, }; /* Mutexes for all readers */ #ifdef HAVE_PTHREAD_H static pthread_mutex_t ifdh_context_mutex[IFDH_MAX_READERS] = { PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER, PTHREAD_MUTEX_INITIALIZER }; #endif /* * Exported functions definition */ RESPONSECODE IFDHCreateChannel (DWORD Lun, DWORD Channel) { char ret; unsigned short ctn, pn, slot; RESPONSECODE rv; ctn = ((unsigned short) (Lun >> 16)) % IFDH_MAX_READERS; slot = ((unsigned short) (Lun & 0x0000FFFF)) % IFDH_MAX_SLOTS; #ifdef HAVE_PTHREAD_H pthread_mutex_lock (&ifdh_context_mutex[ctn]); #endif if (ifdh_context[ctn][slot] == NULL) { /* Handle USB CHANNELID numbers */ if (Channel >= 0x200000) /* USB ports on this CT-API starts at 0x8000 */ #ifndef CTAPI_WIN32_COM pn = (unsigned short) (Channel & 0x1FFFFF) + 0x8000; #else pn = (unsigned short) (Channel & 0x1FFFFF) + 0x8001; #endif /* Conversion of old-style ifd-hanler 1.0 CHANNELID */ #ifndef CTAPI_WIN32_COM else if (Channel == 0x0103F8) pn = PORT_COM1; else if (Channel == 0x0102F8) pn = PORT_COM2; else if (Channel == 0x0103E8) pn = PORT_COM3; else if (Channel == 0x0102E8) pn = PORT_COM4; #else else if (Channel == 0x0103F8) pn = 1; else if (Channel == 0x0102F8) pn = 2; else if (Channel == 0x0103E8) pn = 3; else if (Channel == 0x0102E8) pn = 4; #endif /* IFD Handler 2.0 CHANNELID*/ else #ifndef CTAPI_WIN32_COM pn = (unsigned short) Channel - 1; #else pn = (unsigned short) Channel; #endif ret = CT_init (ctn, pn); if (ret == OK) { /* Initialize context of the all slots in this reader */ for (slot = 0; slot < IFDH_MAX_SLOTS; slot++) { ifdh_context[ctn][slot] = (IFDH_Context *) malloc (sizeof (IFDH_Context)); if (ifdh_context[ctn][slot] != NULL) memset (ifdh_context[ctn][slot], 0, sizeof (IFDH_Context)); } rv = IFD_SUCCESS; } else rv = IFD_COMMUNICATION_ERROR; } else { /* Assume that IFDHCreateChannel is being called for another already initialized slot in this same reader, and return Success */ rv = IFD_SUCCESS; } #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ifdh_context_mutex[ctn]); #endif #ifdef DEBUG_IFDH syslog (LOG_INFO, "IFDH: IFDHCreateChannel(Lun=0x%X, Channel=0x%X)=%d",Lun, Channel, rv); #endif return rv; } RESPONSECODE IFDHCloseChannel (DWORD Lun) { char ret; unsigned short ctn, slot; RESPONSECODE rv; ctn = ((unsigned short) (Lun >> 16)) % IFDH_MAX_READERS; slot = ((unsigned short) (Lun & 0x0000FFFF)) % IFDH_MAX_SLOTS; ret = CT_close (ctn); if (ret == OK) { #ifdef HAVE_PTHREAD_H pthread_mutex_lock (&ifdh_context_mutex[ctn]); #endif /* Free context of the all slots in this reader */ for (slot = 0; slot < IFDH_MAX_SLOTS; slot++) { if (ifdh_context[ctn][slot] != NULL) { free (ifdh_context[ctn][slot]); ifdh_context[ctn][slot] = NULL; } } #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ifdh_context_mutex[ctn]); #endif rv = IFD_SUCCESS; } else rv = IFD_COMMUNICATION_ERROR; #ifdef DEBUG_IFDH syslog (LOG_INFO, "IFDH: IFDHCloseChannel(Lun=0x%X)=%d", Lun, rv); #endif return rv; } RESPONSECODE IFDHGetCapabilities (DWORD Lun, DWORD Tag, PDWORD Length, PUCHAR Value) { unsigned short ctn, slot; RESPONSECODE rv; ctn = ((unsigned short) (Lun >> 16)) % IFDH_MAX_READERS; slot = ((unsigned short) (Lun & 0x0000FFFF)) % IFDH_MAX_SLOTS; #ifdef HAVE_PTHREAD_H pthread_mutex_lock (&ifdh_context_mutex[ctn]); #endif switch (Tag) { case TAG_IFD_ATR: (*Length) = ifdh_context[ctn][slot]->icc_state.ATR_Length; memcpy (Value, ifdh_context[ctn][slot]->icc_state.ATR, (*Length)); rv = IFD_SUCCESS; break; case TAG_IFD_SLOTS_NUMBER: (*Length) = 1; (*Value) = IFDH_MAX_SLOTS; rv = IFD_SUCCESS; break; case TAG_IFD_SIMULTANEOUS_ACCESS: (*Length) = 1; (*Value) = IFDH_MAX_READERS; rv = IFD_SUCCESS; break; default: (*Length) = 0; rv = IFD_ERROR_TAG; } #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ifdh_context_mutex[ctn]); #endif #ifdef DEBUG_IFDH syslog (LOG_INFO, "IFDH: IFDHGetCapabilities (Lun=0x%X, Tag=0x%X)=%d",Lun, Tag, rv); #endif return rv; } RESPONSECODE IFDHSetCapabilities (DWORD Lun, DWORD Tag, DWORD Length, PUCHAR Value) { #ifdef DEBUG_IFDH /* syslog (LOG_INFO, "IFDH: IFDHSetCapabilities (Lun=%X, Tag=%X)=%d",Lun, Tag, IFD_NOT_SUPPORTED ); */ #endif return IFD_NOT_SUPPORTED; } RESPONSECODE IFDHSetProtocolParameters (DWORD Lun, DWORD Protocol, UCHAR Flags, UCHAR PTS1, UCHAR PTS2, UCHAR PTS3) { char ret; unsigned short ctn, slot, lc, lr; UCHAR cmd[10], rsp[256], sad, dad; RESPONSECODE rv; ctn = ((unsigned short) (Lun >> 16)) % IFDH_MAX_READERS; slot = ((unsigned short) (Lun & 0x0000FFFF)) % IFDH_MAX_SLOTS; #ifdef HAVE_PTHREAD_H pthread_mutex_lock (&ifdh_context_mutex[ctn]); #endif if (ifdh_context[ctn][slot] != NULL) { cmd[0] = CTBCS_CLA; cmd[1] = CTBCS_INS_RESET; cmd[2] = (UCHAR) (slot + 1); cmd[3] = CTBCS_P2_RESET_GET_ATR; cmd[4] = 0x06; cmd[5] = 0xFF; cmd[6] = (Flags << 4) | (0x0F & Protocol); lc=7; if ((Flags & 0x10) == 0x10) cmd[lc++] = PTS1; if ((Flags & 0x20) == 0x20) cmd[lc++] = PTS2; if ((Flags & 0x40) == 0x40) cmd[lc++] = PTS3; dad = 0x01; sad = 0x02; lr = 256; ret = CT_data (ctn, &dad, &sad, lc, cmd, &lr, rsp); if ((ret == OK) && (lr >= 2)) { ifdh_context[ctn][slot]->icc_state.ATR_Length = (DWORD) lr - 2; memcpy (ifdh_context[ctn][slot]->icc_state.ATR, rsp, lr - 2); rv = IFD_SUCCESS; } else rv = IFD_ERROR_PTS_FAILURE; } else rv = IFD_ICC_NOT_PRESENT; #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ifdh_context_mutex[ctn]); #endif #ifdef DEBUG_IFDH syslog (LOG_INFO, "IFDH: IFDHSetProtocolParameters (Lun=0x%X, Protocol=%d, Flags=0x%02X, PTS1=0x%02X, PTS2=0x%02X, PTS3=0x%02X)=%d", Lun, Protocol, Flags, PTS1, PTS2, PTS3, rv); #endif return rv; } RESPONSECODE IFDHPowerICC (DWORD Lun, DWORD Action, PUCHAR Atr, PDWORD AtrLength) { char ret; unsigned short ctn, slot, lc, lr; UCHAR cmd[5], rsp[256], sad, dad; RESPONSECODE rv; ctn = ((unsigned short) (Lun >> 16)) % IFDH_MAX_READERS; slot = ((unsigned short) (Lun & 0x0000FFFF)) % IFDH_MAX_SLOTS; #ifdef HAVE_PTHREAD_H pthread_mutex_lock (&ifdh_context_mutex[ctn]); #endif if (ifdh_context[ctn][slot] != NULL) { if (Action == IFD_POWER_UP) { cmd[0] = CTBCS_CLA; cmd[1] = CTBCS_INS_REQUEST; cmd[2] = (UCHAR) (slot + 1); cmd[3] = CTBCS_P2_REQUEST_GET_ATR; cmd[4] = 0x00; dad = 0x01; sad = 0x02; lr = 256; lc = 5; ret = CT_data (ctn, &dad, &sad, 5, cmd, &lr, rsp); if ((ret == OK) && (lr >= 2)) { ifdh_context[ctn][slot]->icc_state.ATR_Length = (DWORD) lr - 2; memcpy (ifdh_context[ctn][slot]->icc_state.ATR, rsp, lr - 2); (*AtrLength) = (DWORD) lr - 2; memcpy (Atr, rsp, lr - 2); rv = IFD_SUCCESS; } else rv = IFD_COMMUNICATION_ERROR; } else if (Action == IFD_POWER_DOWN) { cmd[0] = CTBCS_CLA; cmd[1] = CTBCS_INS_EJECT; cmd[2] = (UCHAR) (slot + 1); cmd[3] = 0x00; cmd[4] = 0x00; dad = 0x01; sad = 0x02; lr = 256; lc = 5; ret = CT_data (ctn, &dad, &sad, 5, cmd, &lr, rsp); if (ret == OK) { ifdh_context[ctn][slot]->icc_state.ATR_Length = 0; memset (ifdh_context[ctn][slot]->icc_state.ATR, 0, MAX_ATR_SIZE); (*AtrLength) = 0; rv = IFD_SUCCESS; } else rv = IFD_COMMUNICATION_ERROR; } else if (Action == IFD_RESET) { cmd[0] = CTBCS_CLA; cmd[1] = CTBCS_INS_RESET; cmd[2] = (UCHAR) (slot + 1); cmd[3] = CTBCS_P2_RESET_GET_ATR; cmd[4] = 0x00; dad = 0x01; sad = 0x02; lr = 256; lc = 5; ret = CT_data (ctn, &dad, &sad, 5, cmd, &lr, rsp); if ((ret == OK) && (lr >= 2)) { ifdh_context[ctn][slot]->icc_state.ATR_Length = (DWORD) lr - 2; memcpy (ifdh_context[ctn][slot]->icc_state.ATR, rsp, lr - 2); (*AtrLength) = (DWORD) lr - 2; memcpy (Atr, rsp, lr - 2); rv = IFD_SUCCESS; } else rv = IFD_ERROR_POWER_ACTION; } else rv = IFD_NOT_SUPPORTED; } else rv = IFD_ICC_NOT_PRESENT; #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ifdh_context_mutex[ctn]); #endif #ifdef DEBUG_IFDH syslog (LOG_INFO, "IFDH: IFDHPowerICC (Lun=0x%X, Action=0x%X)=%d", Lun, Action, rv); #endif return rv; } RESPONSECODE IFDHTransmitToICC (DWORD Lun, SCARD_IO_HEADER SendPci, PUCHAR TxBuffer, DWORD TxLength, PUCHAR RxBuffer, PDWORD RxLength, PSCARD_IO_HEADER RecvPci) { char ret; unsigned short ctn, slot, lc, lr; UCHAR sad, dad; RESPONSECODE rv; ctn = ((unsigned short) (Lun >> 16)) % IFDH_MAX_READERS; slot = ((unsigned short) (Lun & 0x0000FFFF)) % IFDH_MAX_SLOTS; #ifdef HAVE_PTHREAD_H pthread_mutex_lock (&ifdh_context_mutex[ctn]); #endif if (ifdh_context[ctn][slot] != NULL) { #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ifdh_context_mutex[ctn]); #endif dad = (UCHAR) ((slot == 0) ? 0x00 : slot + 1); sad = 0x02; lr = (unsigned short) (*RxLength); lc = (unsigned short) TxLength; ret = CT_data (ctn, &dad, &sad, lc, TxBuffer, &lr, RxBuffer); if (ret == OK) { (*RxLength) = lr; rv = IFD_SUCCESS; } else { (*RxLength) = 0; rv = IFD_COMMUNICATION_ERROR; } } else { #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ifdh_context_mutex[ctn]); #endif rv = IFD_ICC_NOT_PRESENT; } #ifdef DEBUG_IFDH syslog (LOG_INFO, "IFDH: IFDHTransmitToICC (Lun=0x%X, Tx=%u, Rx=%u)=%d", Lun, TxLength, (*RxLength), rv); #endif return rv; } RESPONSECODE IFDHControl (DWORD Lun, PUCHAR TxBuffer, DWORD TxLength, PUCHAR RxBuffer, PDWORD RxLength) { char ret; unsigned short ctn, slot, lc, lr; UCHAR sad, dad; RESPONSECODE rv; ctn = ((unsigned short) (Lun >> 16)) % IFDH_MAX_READERS; slot = ((unsigned short) (Lun & 0x0000FFFF)) % IFDH_MAX_SLOTS; #ifdef HAVE_PTHREAD_H pthread_mutex_lock (&ifdh_context_mutex[ctn]); #endif if (ifdh_context[ctn][slot] != NULL) { #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ifdh_context_mutex[ctn]); #endif dad = 0x01; sad = 0x02; lr = (unsigned short) (*RxLength); lc = (unsigned short) TxLength; ret = CT_data (ctn, &dad, &sad, lc, TxBuffer, &lr, RxBuffer); if (ret == OK) { (*RxLength) = lr; rv = IFD_SUCCESS; } else { (*RxLength) = 0; rv = IFD_COMMUNICATION_ERROR; } } else { #ifdef HAVE_PTHREAD_H pthread_mutex_unlock (&ifdh_context_mutex[ctn]); #endif rv = IFD_ICC_NOT_PRESENT; } #ifdef DEBUG_IFDH syslog (LOG_INFO, "IFDH: IFDHControl (Lun=0x%X, Tx=%u, Rx=%u)=%d", Lun, TxLength, (*RxLength), rv); #endif return rv; } RESPONSECODE IFDHICCPresence (DWORD Lun) { char ret; unsigned short ctn, slot, lc, lr; UCHAR cmd[5], rsp[256], sad, dad; RESPONSECODE rv; ctn = ((unsigned short) (Lun >> 16)) % IFDH_MAX_READERS; slot = ((unsigned short) (Lun & 0x0000FFFF)) % IFDH_MAX_SLOTS; cmd[0] = CTBCS_CLA; cmd[1] = CTBCS_INS_STATUS; cmd[2] = CTBCS_P1_CT_KERNEL; cmd[3] = CTBCS_P2_STATUS_ICC; cmd[4] = 0x00; dad = 0x01; sad = 0x02; lc = 5; lr = 256; ret = CT_data (ctn, &dad, &sad, lc, cmd, &lr, rsp); if (ret == OK) { if (slot < lr - 2) { if (rsp[slot] == CTBCS_DATA_STATUS_NOCARD) rv = IFD_ICC_NOT_PRESENT; else rv = IFD_ICC_PRESENT; } else rv = IFD_ICC_NOT_PRESENT; } else rv = IFD_COMMUNICATION_ERROR; #ifdef DEBUG_IFDH syslog (LOG_INFO, "IFDH: IFDHICCPresence (Lun=0x%X)=%d", Lun, rv); #endif return rv; } towitoko-2.0.7/src/ifd-handler/ifdhandler.h0000644000175000017500000001053007364601464014306 /***************************************************************** / / File : ifdhandler.h / Author : David Corcoran / Date : June 15, 2000 / Purpose: This provides reader specific low-level calls. / See http://www.linuxnet.com for more information. / License: See file LICENSE / ******************************************************************/ #ifndef _ifd_handler_h_ #define _ifd_handler_h_ #ifdef __cplusplus extern "C" { #endif /* List of data structures available to ifdhandler */ typedef struct _DEVICE_CAPABILITIES { LPSTR Vendor_Name; /* Tag 0x0100 */ LPSTR IFD_Type; /* Tag 0x0101 */ DWORD IFD_Version; /* Tag 0x0102 */ LPSTR IFD_Serial; /* Tag 0x0103 */ DWORD IFD_Channel_ID; /* Tag 0x0110 */ DWORD Asynch_Supported; /* Tag 0x0120 */ DWORD Default_Clock; /* Tag 0x0121 */ DWORD Max_Clock; /* Tag 0x0122 */ DWORD Default_Data_Rate; /* Tag 0x0123 */ DWORD Max_Data_Rate; /* Tag 0x0124 */ DWORD Max_IFSD; /* Tag 0x0125 */ DWORD Synch_Supported; /* Tag 0x0126 */ DWORD Power_Mgmt; /* Tag 0x0131 */ DWORD Card_Auth_Devices; /* Tag 0x0140 */ DWORD User_Auth_Device; /* Tag 0x0142 */ DWORD Mechanics_Supported; /* Tag 0x0150 */ DWORD Vendor_Features; /* Tag 0x0180 - 0x01F0 User Defined. */ } DEVICE_CAPABILITIES, *PDEVICE_CAPABILITIES; typedef struct _ICC_STATE { UCHAR ICC_Presence; /* Tag 0x0300 */ UCHAR ICC_Interface_Status; /* Tag 0x0301 */ UCHAR ATR[MAX_ATR_SIZE]; /* Tag 0x0303 */ DWORD ATR_Length; UCHAR ICC_Type; /* Tag 0x0304 */ } ICC_STATE, *PICC_STATE; typedef struct _PROTOCOL_OPTIONS { DWORD Protocol_Type; /* Tag 0x0201 */ DWORD Current_Clock; /* Tag 0x0202 */ DWORD Current_F; /* Tag 0x0203 */ DWORD Current_D; /* Tag 0x0204 */ DWORD Current_N; /* Tag 0x0205 */ DWORD Current_W; /* Tag 0x0206 */ DWORD Current_IFSC; /* Tag 0x0207 */ DWORD Current_IFSD; /* Tag 0x0208 */ DWORD Current_BWT; /* Tag 0x0209 */ DWORD Current_CWT; /* Tag 0x020A */ DWORD Current_EBC; /* Tag 0x020B */ } PROTOCOL_OPTIONS, *PPROTOCOL_OPTIONS; typedef struct _SCARD_IO_HEADER { DWORD Protocol; DWORD Length; } SCARD_IO_HEADER, *PSCARD_IO_HEADER; /* End of structure list */ /* The list of tags should be alot more but this is all I use in the meantime */ #define TAG_IFD_ATR 0x0303 #define TAG_IFD_SLOTNUM 0x0180 #define TAG_IFD_SLOTS_NUMBER 0x0FAE #define TAG_IFD_SIMULTANEOUS_ACCESS 0x0FAF /* End of tag list */ /* List of defines available to ifdhandler */ #define IFD_POWER_UP 500 #define IFD_POWER_DOWN 501 #define IFD_RESET 502 #define IFD_NEGOTIATE_PTS1 1 #define IFD_NEGOTIATE_PTS2 2 #define IFD_NEGOTIATE_PTS3 4 #define IFD_SUCCESS 0 #define IFD_ERROR_TAG 600 #define IFD_ERROR_SET_FAILURE 601 #define IFD_ERROR_VALUE_READ_ONLY 602 #define IFD_ERROR_PTS_FAILURE 605 #define IFD_ERROR_NOT_SUPPORTED 606 #define IFD_PROTOCOL_NOT_SUPPORTED 607 #define IFD_ERROR_POWER_ACTION 608 #define IFD_ERROR_SWALLOW 609 #define IFD_ERROR_EJECT 610 #define IFD_ERROR_CONFISCATE 611 #define IFD_COMMUNICATION_ERROR 612 #define IFD_RESPONSE_TIMEOUT 613 #define IFD_NOT_SUPPORTED 614 #define IFD_ICC_PRESENT 615 #define IFD_ICC_NOT_PRESENT 616 /* List of Defined Functions Available to IFD_Handler */ RESPONSECODE IFDHCreateChannel ( DWORD, DWORD ); RESPONSECODE IFDHCloseChannel ( DWORD ); RESPONSECODE IFDHGetCapabilities ( DWORD, DWORD, PDWORD, PUCHAR ); RESPONSECODE IFDHSetCapabilities ( DWORD, DWORD, DWORD, PUCHAR ); RESPONSECODE IFDHSetProtocolParameters ( DWORD, DWORD, UCHAR, UCHAR, UCHAR, UCHAR ); RESPONSECODE IFDHPowerICC ( DWORD, DWORD, PUCHAR, PDWORD ); RESPONSECODE IFDHTransmitToICC ( DWORD, SCARD_IO_HEADER, PUCHAR, DWORD, PUCHAR, PDWORD, PSCARD_IO_HEADER ); RESPONSECODE IFDHControl ( DWORD, PUCHAR, DWORD, PUCHAR, PDWORD ); RESPONSECODE IFDHICCPresence( DWORD ); #ifdef __cplusplus } #endif #endif /* _ifd_hander_h_ */ towitoko-2.0.7/src/ifd-handler/pcscdefines.h0000644000175000017500000000160607317644021014472 /***************************************************************** / / File : pcscdefines.h / Author : David Corcoran / Date : June 15, 2000 / Purpose: This provides PC/SC shared defines. / See http://www.linuxnet.com for more information. / License: See file LICENSE / ******************************************************************/ #ifndef _pcscdefines_h_ #define _pcscdefines_h_ #ifdef __cplusplus extern "C" { #endif /* Defines a list of pseudo types. */ typedef unsigned long DWORD; typedef unsigned long* PDWORD; typedef unsigned char UCHAR; typedef unsigned char* PUCHAR; typedef char* LPSTR; typedef long RESPONSECODE; typedef void VOID; #define MAX_RESPONSE_SIZE 264 #define MAX_ATR_SIZE 33 #ifdef __cplusplus } #endif #endif /* _pcscdefines_h_ */ towitoko-2.0.7/src/driver/0002777000175000017500000000000007527763751011253 5towitoko-2.0.7/src/driver/Makefile.am0000644000175000017500000000354607521046774013222 # # driver/Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # VER = 2:0:0 INC = atr.h icc_async.h io_serial.h protocol_t0.h protocol_t1.h t1_block.h \ ifd_towitoko.h defines.h icc_sync.h apdu.h protocol_sync.h atr_sync.h \ pps.h tlv_object.h SRC = atr.c icc_async.c io_serial.c protocol_t0.c protocol_t1.c t1_block.c \ ifd_towitoko.c apdu.c icc_sync.c protocol_sync.c atr_sync.c pps.c \ tlv_object.c lib_LTLIBRARIES = libtowitoko.la INCLUDES = -I$(top_srcdir) libtowitoko_la_SOURCES = $(SRC) $(INC) libtowitoko_la_LDFLAGS = -version-info $(VER) -module libtowitoko_la_LIBADD = $(top_builddir)/src/ct-api/libtowitoko-ctapi.la \ $(top_builddir)/src/ifd-handler/libtowitoko-ifdhandler.la install-exec-hook: if INSTALL_USB_BUNDLE install -d "@PCSC_LITE_DIR@/drivers/towitoko.bundle/Contents/Linux" (cd "@PCSC_LITE_DIR@/drivers/towitoko.bundle/Contents/Linux" && \ test -f libtowitoko.so.2.0.0 || $(LN_S) @libdir@/libtowitoko.so.2.0.0 .) endif uninstall-hook: if INSTALL_USB_BUNDLE rm -rf "@PCSC_LITE_DIR@/drivers/towitoko.bundle" endif towitoko-2.0.7/src/driver/Makefile.in0000644000175000017500000003276307527762032013234 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ # # driver/Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../.. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AS = @AS@ AWK = @AWK@ CC = @CC@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBOOK_TO_MAN = @DOCBOOK_TO_MAN@ ECHO = @ECHO@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ PCSC_LITE_DIR = @PCSC_LITE_DIR@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ VER = 2:0:0 INC = atr.h icc_async.h io_serial.h protocol_t0.h protocol_t1.h t1_block.h \ ifd_towitoko.h defines.h icc_sync.h apdu.h protocol_sync.h atr_sync.h \ pps.h tlv_object.h SRC = atr.c icc_async.c io_serial.c protocol_t0.c protocol_t1.c t1_block.c \ ifd_towitoko.c apdu.c icc_sync.c protocol_sync.c atr_sync.c pps.c \ tlv_object.c lib_LTLIBRARIES = libtowitoko.la INCLUDES = -I$(top_srcdir) libtowitoko_la_SOURCES = $(SRC) $(INC) libtowitoko_la_LDFLAGS = -version-info $(VER) -module libtowitoko_la_LIBADD = $(top_builddir)/src/ct-api/libtowitoko-ctapi.la \ $(top_builddir)/src/ifd-handler/libtowitoko-ifdhandler.la subdir = src/driver mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = LTLIBRARIES = $(lib_LTLIBRARIES) libtowitoko_la_DEPENDENCIES = \ $(top_builddir)/src/ct-api/libtowitoko-ctapi.la \ $(top_builddir)/src/ifd-handler/libtowitoko-ifdhandler.la am__objects_1 = atr.lo icc_async.lo io_serial.lo protocol_t0.lo \ protocol_t1.lo t1_block.lo ifd_towitoko.lo apdu.lo icc_sync.lo \ protocol_sync.lo atr_sync.lo pps.lo tlv_object.lo am__objects_2 = am_libtowitoko_la_OBJECTS = $(am__objects_1) $(am__objects_2) libtowitoko_la_OBJECTS = $(am_libtowitoko_la_OBJECTS) DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/apdu.Plo ./$(DEPDIR)/atr.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/atr_sync.Plo ./$(DEPDIR)/icc_async.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/icc_sync.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/ifd_towitoko.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/io_serial.Plo ./$(DEPDIR)/pps.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/protocol_sync.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/protocol_t0.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/protocol_t1.Plo \ @AMDEP_TRUE@ ./$(DEPDIR)/t1_block.Plo ./$(DEPDIR)/tlv_object.Plo COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ CFLAGS = @CFLAGS@ DIST_SOURCES = $(libtowitoko_la_SOURCES) DIST_COMMON = Makefile.am Makefile.in SOURCES = $(libtowitoko_la_SOURCES) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu src/driver/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) libLTLIBRARIES_INSTALL = $(INSTALL) install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(libdir) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ if test -f $$p; then \ f="`echo $$p | sed -e 's|^.*/||'`"; \ echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \ $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \ else :; fi; \ done uninstall-libLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ p="`echo $$p | sed -e 's|^.*/||'`"; \ echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \ $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ done clean-libLTLIBRARIES: -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test -z "$dir" && dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done libtowitoko.la: $(libtowitoko_la_OBJECTS) $(libtowitoko_la_DEPENDENCIES) $(LINK) -rpath $(libdir) $(libtowitoko_la_LDFLAGS) $(libtowitoko_la_OBJECTS) $(libtowitoko_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/apdu.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atr.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/atr_sync.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icc_async.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/icc_sync.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ifd_towitoko.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/io_serial.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pps.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_sync.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_t0.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/protocol_t1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/t1_block.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tlv_object.Plo@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` .c.lo: @AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< CCDEPMODE = @CCDEPMODE@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: ETAGS = etags ETAGSFLAGS = tags: TAGS 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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../.. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkinstalldirs) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ 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 check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: $(mkinstalldirs) $(DESTDIR)$(libdir) 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-generic clean-libLTLIBRARIES clean-libtool \ mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-libtool distclean-tags dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-exec-am: install-libLTLIBRARIES @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-exec-hook install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-hook .PHONY: GTAGS all all-am check check-am clean clean-generic \ clean-libLTLIBRARIES clean-libtool distclean distclean-compile \ distclean-depend distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am info info-am install \ install-am install-data install-data-am install-exec \ install-exec-am install-info install-info-am \ install-libLTLIBRARIES install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool tags uninstall \ uninstall-am uninstall-info-am uninstall-libLTLIBRARIES install-exec-hook: @INSTALL_USB_BUNDLE_TRUE@ install -d "@PCSC_LITE_DIR@/drivers/towitoko.bundle/Contents/Linux" @INSTALL_USB_BUNDLE_TRUE@ (cd "@PCSC_LITE_DIR@/drivers/towitoko.bundle/Contents/Linux" && \ @INSTALL_USB_BUNDLE_TRUE@ test -f libtowitoko.so.2.0.0 || $(LN_S) @libdir@/libtowitoko.so.2.0.0 .) uninstall-hook: @INSTALL_USB_BUNDLE_TRUE@ rm -rf "@PCSC_LITE_DIR@/drivers/towitoko.bundle" # 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: towitoko-2.0.7/src/driver/atr.c0000644000175000017500000003207407521022540012077 /* atr.c ISO 7816 ICC's answer to reset abstract data type implementation This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include "atr.h" #include #include /* * Not exported variables definition */ static unsigned long atr_fs_table[16] = { 0, 5000000L, 6000000L, 8000000L, 12000000L, 16000000L, 20000000L, 0, 0, 5000000L, 7500000L, 10000000L, 15000000L, 20000000L, 0, 0 }; static unsigned atr_num_ib_table[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; /* * Exported variables definition */ unsigned atr_f_table[16] = { 0, 372, 558, 744, 1116, 1488, 1860, 0, 0, 512, 768, 1024, 1536, 2048, 0, 0 }; double atr_d_table[16] = { 0, 1, 2, 4, 8, 16, 0, 0, 0, 0, 0.5, 0.25, 125, 0.0625, 0.03125, 0.015625 }; unsigned atr_i_table[4] = { 25, 50, 100, 0 }; /* * Not exported functions declaration */ static bool ATR_GetNextByte (IO_Serial * io, unsigned timeout, BYTE * b, bool invert); /* * Exported funcions definition */ ATR * ATR_New (void) { ATR *atr; /* Allocate memory */ atr = (ATR *) malloc (sizeof (ATR)); return atr; } int ATR_InitFromArray (ATR * atr, BYTE atr_buffer[ATR_MAX_SIZE], unsigned length) { BYTE TDi; BYTE buffer[ATR_MAX_SIZE]; unsigned pointer = 0, pn = 0; /* Check size of buffer */ if (length < 2) return (ATR_MALFORMED); /* Check if ATR is from a inverse convention card */ if (atr_buffer[0] == 0x03) { for (pointer = 0; pointer < length; pointer++) buffer[pointer] = ~(INVERT_BYTE (atr_buffer[pointer])); } else memcpy (buffer, atr_buffer, length); /* Store T0 and TS */ atr->TS = buffer[0]; atr->T0 = TDi = buffer[1]; pointer = 1; /* Store number of historical bytes */ atr->hbn = TDi & 0x0F; /* TCK is not present by default */ (atr->TCK).present = FALSE; /* Extract interface bytes */ while (pointer < length) { /* Check buffer is long enought */ if (pointer + atr_num_ib_table[(0xF0 & TDi) >> 4] >= length) { return (ATR_MALFORMED); } /* Check TAi is present */ if ((TDi | 0xEF) == 0xFF) { pointer++; atr->ib[pn][ATR_INTERFACE_BYTE_TA].value = buffer[pointer]; atr->ib[pn][ATR_INTERFACE_BYTE_TA].present = TRUE; } else atr->ib[pn][ATR_INTERFACE_BYTE_TA].present = FALSE; /* Check TBi is present */ if ((TDi | 0xDF) == 0xFF) { pointer++; atr->ib[pn][ATR_INTERFACE_BYTE_TB].value = buffer[pointer]; atr->ib[pn][ATR_INTERFACE_BYTE_TB].present = TRUE; } else atr->ib[pn][ATR_INTERFACE_BYTE_TB].present = FALSE; /* Check TCi is present */ if ((TDi | 0xBF) == 0xFF) { pointer++; atr->ib[pn][ATR_INTERFACE_BYTE_TC].value = buffer[pointer]; atr->ib[pn][ATR_INTERFACE_BYTE_TC].present = TRUE; } else atr->ib[pn][ATR_INTERFACE_BYTE_TC].present = FALSE; /* Read TDi if present */ if ((TDi | 0x7F) == 0xFF) { pointer++; TDi = atr->ib[pn][ATR_INTERFACE_BYTE_TD].value = buffer[pointer]; atr->ib[pn][ATR_INTERFACE_BYTE_TD].present = TRUE; (atr->TCK).present = ((TDi & 0x0F) != ATR_PROTOCOL_TYPE_T0); if (pn >= ATR_MAX_PROTOCOLS) return (ATR_MALFORMED); pn++; } else { atr->ib[pn][ATR_INTERFACE_BYTE_TD].present = FALSE; break; } } /* Store number of protocols */ atr->pn = pn + 1; /* Store historical bytes */ if (pointer + atr->hbn >= length) return (ATR_MALFORMED); memcpy (atr->hb, buffer + pointer + 1, atr->hbn); pointer += (atr->hbn); /* Store TCK */ if ((atr->TCK).present) { if (pointer + 1 >= length) return (ATR_MALFORMED); pointer++; (atr->TCK).value = buffer[pointer]; } atr->length = pointer + 1; return (ATR_OK); } int ATR_InitFromStream (ATR * atr, IO_Serial * io, unsigned timeout) { BYTE TDi; unsigned pointer = 0, pn = 0, i; bool invert; invert = FALSE; /* Store T0 and TS */ if (!ATR_GetNextByte (io, timeout, &(atr->TS), invert)) return ATR_IO_ERROR; if (atr->TS == 0x03) { atr->TS = 0x3F; invert = TRUE; } if ((atr->TS != 0x3B) && (atr->TS != 0x3F)) return ATR_MALFORMED; if (!ATR_GetNextByte (io, timeout, &(atr->T0), invert)) return ATR_MALFORMED; TDi = atr->T0; pointer = 1; /* Store number of historical bytes */ atr->hbn = TDi & 0x0F; /* TCK is not present by default */ (atr->TCK).present = FALSE; /* Extract interface bytes */ while (TRUE) { /* Check TAi is present */ if ((TDi | 0xEF) == 0xFF) { pointer++; if (!ATR_GetNextByte (io, timeout, &(atr->ib[pn][ATR_INTERFACE_BYTE_TA].value), invert)) return ATR_MALFORMED; atr->ib[pn][ATR_INTERFACE_BYTE_TA].present = TRUE; } else atr->ib[pn][ATR_INTERFACE_BYTE_TA].present = FALSE; /* Check TBi is present */ if ((TDi | 0xDF) == 0xFF) { pointer++; if (!ATR_GetNextByte (io, timeout, &(atr->ib[pn][ATR_INTERFACE_BYTE_TB].value), invert)) return ATR_MALFORMED; atr->ib[pn][ATR_INTERFACE_BYTE_TB].present = TRUE; } else atr->ib[pn][ATR_INTERFACE_BYTE_TB].present = FALSE; /* Check TCi is present */ if ((TDi | 0xBF) == 0xFF) { pointer++; if (!ATR_GetNextByte (io, timeout, &(atr->ib[pn][ATR_INTERFACE_BYTE_TC].value), invert)) return ATR_MALFORMED; atr->ib[pn][ATR_INTERFACE_BYTE_TC].present = TRUE; } else atr->ib[pn][ATR_INTERFACE_BYTE_TC].present = FALSE; /* Read TDi if present */ if ((TDi | 0x7F) == 0xFF) { pointer++; if (!ATR_GetNextByte (io, timeout, &(atr->ib[pn][ATR_INTERFACE_BYTE_TD].value), invert)) return ATR_MALFORMED; TDi = atr->ib[pn][ATR_INTERFACE_BYTE_TD].value; atr->ib[pn][ATR_INTERFACE_BYTE_TD].present = TRUE; (atr->TCK).present = ((TDi & 0x0F) != ATR_PROTOCOL_TYPE_T0); if (pn >= ATR_MAX_PROTOCOLS) return (ATR_MALFORMED); pn++; } else { atr->ib[pn][ATR_INTERFACE_BYTE_TD].present = FALSE; break; } } /* Store number of protocols */ atr->pn = pn + 1; /* Store historical bytes */ for (i = 0; i < (atr->hbn); i++) if (!ATR_GetNextByte (io, timeout, &(atr->hb[i]), invert)) return ATR_MALFORMED; pointer += (atr->hbn); /* Store TCK */ if ((atr->TCK).present) { pointer++; if (!ATR_GetNextByte (io, timeout, (&((atr->TCK).value)), invert)) return ATR_MALFORMED; } atr->length = pointer + 1; return (ATR_OK); } void ATR_Delete (ATR * atr) { free (atr); } int ATR_GetConvention (ATR * atr, int *convention) { if (atr->TS == 0x3B) (*convention) = ATR_CONVENTION_DIRECT; else if (atr->TS == 0x3F) (*convention) = ATR_CONVENTION_INVERSE; else return (ATR_MALFORMED); return (ATR_OK); } int ATR_GetSize (ATR * atr, unsigned *size) { (*size) = atr->length; return (ATR_OK); } int ATR_GetNumberOfProtocols (ATR * atr, unsigned *number_protocols) { (*number_protocols) = atr->pn; return (ATR_OK); } int ATR_GetProtocolType (ATR * atr, unsigned number_protocol, BYTE *protocol_type) { if ((number_protocol > atr->pn) || number_protocol < 2) return ATR_NOT_FOUND; if (atr->ib[number_protocol - 2][ATR_INTERFACE_BYTE_TD].present) (*protocol_type) = (atr->ib[number_protocol - 2][ATR_INTERFACE_BYTE_TD].value & 0x0F); else (*protocol_type) = ATR_PROTOCOL_TYPE_T0; return (ATR_OK); } int ATR_GetInterfaceByte (ATR * atr, unsigned number, int character, BYTE * value) { if (number > atr->pn || number < 1) return (ATR_NOT_FOUND); if (atr->ib[number - 1][character].present && (character == ATR_INTERFACE_BYTE_TA || character == ATR_INTERFACE_BYTE_TB || character == ATR_INTERFACE_BYTE_TC || character == ATR_INTERFACE_BYTE_TD)) (*value) = atr->ib[number - 1][character].value; else return (ATR_NOT_FOUND); return (ATR_OK); } int ATR_GetIntegerValue (ATR * atr, int name, BYTE * value) { int ret; if (name == ATR_INTEGER_VALUE_FI) { if (atr->ib[0][ATR_INTERFACE_BYTE_TA].present) { (*value) = (atr->ib[0][ATR_INTERFACE_BYTE_TA].value & 0xF0) >> 4; ret = ATR_OK; } else ret = ATR_NOT_FOUND; } else if (name == ATR_INTEGER_VALUE_DI) { if (atr->ib[0][ATR_INTERFACE_BYTE_TA].present) { (*value) = (atr->ib[0][ATR_INTERFACE_BYTE_TA].value & 0x0F); ret = ATR_OK; } else ret = ATR_NOT_FOUND; } else if (name == ATR_INTEGER_VALUE_II) { if (atr->ib[0][ATR_INTERFACE_BYTE_TB].present) { (*value) = (atr->ib[0][ATR_INTERFACE_BYTE_TB].value & 0x60) >> 5; ret = ATR_OK; } else ret = ATR_NOT_FOUND; } else if (name == ATR_INTEGER_VALUE_PI1) { if (atr->ib[0][ATR_INTERFACE_BYTE_TB].present) { (*value) = (atr->ib[0][ATR_INTERFACE_BYTE_TB].value & 0x1F); ret = ATR_OK; } else ret = ATR_NOT_FOUND; } else if (name == ATR_INTEGER_VALUE_PI2) { if (atr->ib[1][ATR_INTERFACE_BYTE_TB].present) { (*value) = atr->ib[1][ATR_INTERFACE_BYTE_TB].value; ret = ATR_OK; } else ret = ATR_NOT_FOUND; } else if (name == ATR_INTEGER_VALUE_N) { if (atr->ib[0][ATR_INTERFACE_BYTE_TC].present) { (*value) = atr->ib[0][ATR_INTERFACE_BYTE_TC].value; ret = ATR_OK; } else ret = ATR_NOT_FOUND; } else ret = ATR_NOT_FOUND; return ret; } int ATR_GetParameter (ATR * atr, int name, double *parameter) { BYTE FI, DI, II, PI1, PI2, N; if (name == ATR_PARAMETER_F) { if (ATR_GetIntegerValue (atr, ATR_INTEGER_VALUE_FI, &FI) == ATR_OK) (*parameter) = (double) (atr_f_table[FI]); else (*parameter) = (double) ATR_DEFAULT_F; return (ATR_OK); } else if (name == ATR_PARAMETER_D) { if (ATR_GetIntegerValue (atr, ATR_INTEGER_VALUE_DI, &DI) == ATR_OK) (*parameter) = (double) (atr_d_table[DI]); else (*parameter) = (double) ATR_DEFAULT_D; return (ATR_OK); } else if (name == ATR_PARAMETER_I) { if (ATR_GetIntegerValue (atr, ATR_INTEGER_VALUE_II, &II) == ATR_OK) (*parameter) = (double) (atr_i_table[II]); else (*parameter) = ATR_DEFAULT_I; return (ATR_OK); } else if (name == ATR_PARAMETER_P) { if (ATR_GetIntegerValue (atr, ATR_INTEGER_VALUE_PI2, &PI2) == ATR_OK) (*parameter) = (double) PI2; else if (ATR_GetIntegerValue (atr, ATR_INTEGER_VALUE_PI1, &PI1) == ATR_OK) (*parameter) = (double) PI1; else (*parameter) = (double) ATR_DEFAULT_P; return (ATR_OK); } else if (name == ATR_PARAMETER_N) { if (ATR_GetIntegerValue (atr, ATR_INTEGER_VALUE_N, &N) == ATR_OK) (*parameter) = (double) N; else (*parameter) = (double) ATR_DEFAULT_N; return (ATR_OK); } return (ATR_NOT_FOUND); } int ATR_GetHistoricalBytes (ATR * atr, BYTE hist[ATR_MAX_HISTORICAL], unsigned *length) { if (atr->hbn == 0) return (ATR_NOT_FOUND); (*length) = atr->hbn; memcpy (hist, atr->hb, atr->hbn); return (ATR_OK); } int ATR_GetRaw (ATR * atr, BYTE buffer[ATR_MAX_SIZE], unsigned *length) { unsigned i, j; buffer[0] = atr->TS; buffer[1] = atr->T0; j = 2; for (i = 0; i < atr->pn; i++) { if (atr->ib[i][ATR_INTERFACE_BYTE_TA].present) buffer[j++] = atr->ib[i][ATR_INTERFACE_BYTE_TA].value; if (atr->ib[i][ATR_INTERFACE_BYTE_TB].present) buffer[j++] = atr->ib[i][ATR_INTERFACE_BYTE_TB].value; if (atr->ib[i][ATR_INTERFACE_BYTE_TC].present) buffer[j++] = atr->ib[i][ATR_INTERFACE_BYTE_TC].value; if (atr->ib[i][ATR_INTERFACE_BYTE_TD].present) buffer[j++] = atr->ib[i][ATR_INTERFACE_BYTE_TD].value; } if (atr->hbn > 0) { memcpy (&(buffer[j]), atr->hb, atr->hbn); j += atr->hbn; } if ((atr->TCK).present) buffer[j++] = (atr->TCK).value; (*length) = j; return ATR_OK; } int ATR_GetCheckByte (ATR * atr, BYTE * check_byte) { if (!((atr->TCK).present)) return (ATR_NOT_FOUND); (*check_byte) = (atr->TCK).value; return (ATR_OK); } int ATR_GetFsMax (ATR * atr, unsigned long *fsmax) { BYTE FI; if (ATR_GetIntegerValue (atr, ATR_INTEGER_VALUE_FI, &FI) == ATR_OK) (*fsmax) = atr_fs_table[FI]; else (*fsmax) = atr_fs_table[1]; return (ATR_OK); } /* * Not exported functions definition */ static bool ATR_GetNextByte (IO_Serial * io, unsigned timeout, BYTE * byte, bool invert) { bool ret; ret = IO_Serial_Read (io, timeout, 1, byte); /* Para tarjetas inversas quiza */ if (invert) (*byte) = ~(INVERT_BYTE (*byte)); return ret; } towitoko-2.0.7/src/driver/icc_async.c0000644000175000017500000001550407521022540013243 /* icc_async.c Asynchronous ICC's handling functions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 2001 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include "icc_async.h" #include #include #include /* * Not exported constants definition */ #define ICC_ASYNC_MAX_TRANSMIT 255 #define ICC_ASYNC_BAUDRATE 9600 /* * Not exported functions declaration */ static void ICC_Async_InvertBuffer (unsigned size, BYTE * buffer); static void ICC_Async_Clear (ICC_Async * icc); /* * Exported functions definition */ ICC_Async * ICC_Async_New (void) { ICC_Async *icc; /* Allocate memory */ icc = (ICC_Async *) malloc (sizeof (ICC_Async)); if (icc != NULL) ICC_Async_Clear (icc); return icc; } int ICC_Async_Init (ICC_Async * icc, IFD * ifd) { #ifndef ICC_TYPE_SYNC /* LED Red */ if (IFD_Towitoko_SetLED (ifd, IFD_TOWITOKO_LED_RED) != IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; /* Initialize Baudrate */ if (IFD_Towitoko_SetBaudrate (ifd, ICC_ASYNC_BAUDRATE)!= IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; /* Activate ICC */ if (IFD_Towitoko_ActivateICC (ifd) != IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; /* Reset ICC */ if (IFD_Towitoko_ResetAsyncICC (ifd, &(icc->atr)) != IFD_TOWITOKO_OK) { icc->atr = NULL; return ICC_ASYNC_IFD_ERROR; } /* Get ICC convention */ if (ATR_GetConvention (icc->atr, &(icc->convention)) != ATR_OK) { ATR_Delete (icc->atr); icc->atr = NULL; icc->convention = 0; return ICC_ASYNC_ATR_ERROR; } #ifdef DEBUG_ICC printf("ICC: Detected %s convention processor card\n", (icc->convention == ATR_CONVENTION_DIRECT ? "direct" : "inverse")); #endif /* LED Green */ if (IFD_Towitoko_SetLED (ifd, IFD_TOWITOKO_LED_GREEN) != IFD_TOWITOKO_OK) { ATR_Delete (icc->atr); icc->atr = NULL; icc->convention = 0; return ICC_ASYNC_IFD_ERROR; } /* Initialize member variables */ icc->baudrate = ICC_ASYNC_BAUDRATE; icc->ifd = ifd; return ICC_ASYNC_OK; #else return ICC_ASYNC_ATR_ERROR; #endif } int ICC_Async_SetTimings (ICC_Async * icc, ICC_Async_Timings * timings) { icc->timings.block_delay = timings->block_delay; icc->timings.char_delay = timings->char_delay; icc->timings.block_timeout = timings->block_timeout; icc->timings.char_timeout = timings->char_timeout; return ICC_ASYNC_OK; } int ICC_Async_GetTimings (ICC_Async * icc, ICC_Async_Timings * timings) { timings->block_delay = icc->timings.block_delay; timings->char_delay = icc->timings.char_delay; timings->block_timeout = icc->timings.block_timeout; timings->char_timeout = icc->timings.char_timeout; return ICC_ASYNC_OK; } int ICC_Async_SetBaudrate (ICC_Async * icc, unsigned long baudrate) { icc->baudrate = baudrate; return ICC_ASYNC_OK; } int ICC_Async_GetBaudrate (ICC_Async * icc, unsigned long * baudrate) { (*baudrate) = icc->baudrate; return ICC_ASYNC_OK; } int ICC_Async_BeginTransmission (ICC_Async * icc) { /* Setup parity for this ICC */ if (icc->convention == ATR_CONVENTION_INVERSE) { if (IFD_Towitoko_SetParity (icc->ifd, IFD_TOWITOKO_PARITY_ODD) != IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; } /* Setup baudrate for this ICC */ if (IFD_Towitoko_SetBaudrate (icc->ifd, icc->baudrate)!= IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; return ICC_ASYNC_OK; } int ICC_Async_Transmit (ICC_Async * icc, unsigned size, BYTE * data) { BYTE *buffer = NULL, *sent; IFD_Timings timings; if (icc->convention == ATR_CONVENTION_INVERSE) { buffer = (BYTE *) calloc(sizeof (BYTE), size); memcpy (buffer, data, size); ICC_Async_InvertBuffer (size, buffer); sent = buffer; } else sent = data; timings.block_delay = icc->timings.block_delay; timings.char_delay = icc->timings.char_delay; if (IFD_Towitoko_Transmit (icc->ifd, &timings, size, sent) != IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; if (icc->convention == ATR_CONVENTION_INVERSE) free (buffer); return ICC_ASYNC_OK; } int ICC_Async_Receive (ICC_Async * icc, unsigned size, BYTE * data) { IFD_Timings timings; timings.block_timeout = icc->timings.block_timeout; timings.char_timeout = icc->timings.char_timeout; if (IFD_Towitoko_Receive (icc->ifd, &timings, size, data) != IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; if (icc->convention == ATR_CONVENTION_INVERSE) ICC_Async_InvertBuffer (size, data); return ICC_ASYNC_OK; } int ICC_Async_Switch (ICC_Async * icc) { if (icc->baudrate > ICC_ASYNC_BAUDRATE) { if (IFD_Towitoko_Switch(icc->ifd) != IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; } return ICC_ASYNC_OK; } int ICC_Async_EndTransmission (ICC_Async * icc) { /* Restore parity */ if (icc->convention == ATR_CONVENTION_INVERSE) { if (IFD_Towitoko_SetParity (icc->ifd, IFD_TOWITOKO_PARITY_EVEN) != IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; } return ICC_ASYNC_OK; } ATR * ICC_Async_GetAtr (ICC_Async * icc) { return icc->atr; } IFD * ICC_Async_GetIFD (ICC_Async * icc) { return icc->ifd; } int ICC_Async_Close (ICC_Async * icc) { /* Dectivate ICC */ if (IFD_Towitoko_DeactivateICC (icc->ifd) != IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; /* LED Off */ if (IFD_Towitoko_SetLED (icc->ifd, IFD_TOWITOKO_LED_OFF) != IFD_TOWITOKO_OK) return ICC_ASYNC_IFD_ERROR; /* Delete atr */ ATR_Delete (icc->atr); ICC_Async_Clear (icc); return ICC_ASYNC_OK; } unsigned long ICC_Async_GetClockRate (ICC_Async * icc) { return IFD_Towitoko_GetClockRate(icc->ifd); } void ICC_Async_Delete (ICC_Async * icc) { free (icc); } /* * Not exported functions definition */ static void ICC_Async_InvertBuffer (unsigned size, BYTE * buffer) { int i; for (i = 0; i < size; i++) buffer[i] = ~(INVERT_BYTE (buffer[i])); } static void ICC_Async_Clear (ICC_Async * icc) { icc->ifd = NULL; icc->atr = NULL; icc->baudrate = 0L; icc->convention = 0; icc->timings.block_delay = 0; icc->timings.char_delay = 0; icc->timings.block_timeout = 0; icc->timings.char_timeout = 0; } towitoko-2.0.7/src/driver/io_serial.c0000644000175000017500000004574007523037267013301 /* io_serial.c Serial port input/output functions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 2001 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include #include #include #include #include #include #include #ifdef HAVE_POLL #include #else #include #include #include #endif #include #include #include "io_serial.h" #define IO_SERIAL_FILENAME_LENGTH 32 /* * Internal functions declaration */ static int IO_Serial_Bitrate(int bitrate); static bool IO_Serial_WaitToRead (int hnd, unsigned delay_ms, unsigned timeout_ms); static bool IO_Serial_WaitToWrite (int hnd, unsigned delay_ms, unsigned timeout_ms); static void IO_Serial_DeviceName (unsigned com, bool usbserial, char * filename, unsigned length); static bool IO_Serial_InitPnP (IO_Serial * io); static void IO_Serial_Clear (IO_Serial * io); static bool IO_Serial_GetPropertiesCache(IO_Serial * io, IO_Serial_Properties * props); static void IO_Serial_SetPropertiesCache(IO_Serial * io, IO_Serial_Properties * props); static void IO_Serial_ClearPropertiesCache (IO_Serial * io); /* * Public functions definition */ IO_Serial * IO_Serial_New (void) { IO_Serial *io; io = (IO_Serial *) malloc (sizeof (IO_Serial)); if (io != NULL) IO_Serial_Clear (io); return io; } bool IO_Serial_Init (IO_Serial * io, unsigned com, bool usbserial, bool pnp) { char filename[IO_SERIAL_FILENAME_LENGTH]; IO_Serial_DeviceName (com, usbserial, filename, IO_SERIAL_FILENAME_LENGTH); #ifdef DEBUG_IO printf ("IO: Opening serial port %s\n", filename); #endif if (com < 1) return FALSE; io->com = com; io->fd = open (filename, O_RDWR | O_NOCTTY); if (io->fd < 0) return FALSE; if (pnp) IO_Serial_InitPnP (io); io->usbserial=usbserial; return TRUE; } bool IO_Serial_GetProperties (IO_Serial * io, IO_Serial_Properties * props) { struct termios currtio; speed_t i_speed, o_speed; unsigned int mctl; if (IO_Serial_GetPropertiesCache(io, props)) return TRUE; if (tcgetattr (io->fd, &currtio) != 0) return FALSE; o_speed = cfgetospeed (&currtio); switch (o_speed) { #ifdef B0 case B0: props->output_bitrate = 0; break; #endif #ifdef B50 case B50: props->output_bitrate = 50; break; #endif #ifdef B75 case B75: props->output_bitrate = 75; break; #endif #ifdef B110 case B110: props->output_bitrate = 110; break; #endif #ifdef B134 case B134: props->output_bitrate = 134; break; #endif #ifdef B150 case B150: props->output_bitrate = 150; break; #endif #ifdef B200 case B200: props->output_bitrate = 200; break; #endif #ifdef B300 case B300: props->output_bitrate = 300; break; #endif #ifdef B600 case B600: props->output_bitrate = 600; break; #endif #ifdef B1200 case B1200: props->output_bitrate = 1200; break; #endif #ifdef B1800 case B1800: props->output_bitrate = 1800; break; #endif #ifdef B2400 case B2400: props->output_bitrate = 2400; break; #endif #ifdef B4800 case B4800: props->output_bitrate = 4800; break; #endif #ifdef B9600 case B9600: props->output_bitrate = 9600; break; #endif #ifdef B19200 case B19200: props->output_bitrate = 19200; break; #endif #ifdef B38400 case B38400: props->output_bitrate = 38400; break; #endif #ifdef B57600 case B57600: props->output_bitrate = 57600; break; #endif #ifdef B115200 case B115200: props->output_bitrate = 115200; break; #endif #ifdef B230400 case B230400: props->output_bitrate = 230400; break; #endif default: props->output_bitrate = 1200; break; } i_speed = cfgetispeed (&currtio); switch (i_speed) { #ifdef B0 case B0: props->input_bitrate = 0; break; #endif #ifdef B50 case B50: props->input_bitrate = 50; break; #endif #ifdef B75 case B75: props->input_bitrate = 75; break; #endif #ifdef B110 case B110: props->input_bitrate = 110; break; #endif #ifdef B134 case B134: props->input_bitrate = 134; break; #endif #ifdef B150 case B150: props->input_bitrate = 150; break; #endif #ifdef B200 case B200: props->input_bitrate = 200; break; #endif #ifdef B300 case B300: props->input_bitrate = 300; break; #endif #ifdef B600 case B600: props->input_bitrate = 600; break; #endif #ifdef B1200 case B1200: props->input_bitrate = 1200; break; #endif #ifdef B1800 case B1800: props->input_bitrate = 1800; break; #endif #ifdef B2400 case B2400: props->input_bitrate = 2400; break; #endif #ifdef B4800 case B4800: props->input_bitrate = 4800; break; #endif #ifdef B9600 case B9600: props->input_bitrate = 9600; break; #endif #ifdef B19200 case B19200: props->input_bitrate = 19200; break; #endif #ifdef B38400 case B38400: props->input_bitrate = 38400; break; #endif #ifdef B57600 case B57600: props->input_bitrate = 57600; break; #endif #ifdef B115200 case B115200: props->input_bitrate = 115200; break; #endif #ifdef B230400 case B230400: props->input_bitrate = 230400; break; #endif default: props->input_bitrate = 1200; break; } switch (currtio.c_cflag & CSIZE) { case CS5: props->bits = 5; break; case CS6: props->bits = 6; break; case CS7: props->bits = 7; break; case CS8: props->bits = 8; break; } if (((currtio.c_cflag) & PARENB) == PARENB) if (((currtio.c_cflag) & PARODD) == PARODD) props->parity = IO_SERIAL_PARITY_ODD; else props->parity = IO_SERIAL_PARITY_EVEN; else props->parity = IO_SERIAL_PARITY_NONE; if (((currtio.c_cflag) & CSTOPB) == CSTOPB) props->stopbits = 2; else props->stopbits = 1; #if !defined(OS_CYGWIN32) && !defined(OS_HPUX) if (ioctl (io->fd, TIOCMGET, &mctl) < 0) return FALSE; props->dtr = ((mctl & TIOCM_DTR) ? IO_SERIAL_HIGH : IO_SERIAL_LOW); props->rts = ((mctl & TIOCM_RTS) ? IO_SERIAL_HIGH : IO_SERIAL_LOW); #else props->dtr = IO_SERIAL_HIGH; props->rts = IO_SERIAL_HIGH; #endif IO_Serial_SetPropertiesCache (io, props); #ifdef DEBUG_IO printf ("IO: Getting properties: %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", props->input_bitrate, props->bits, props->parity == IO_SERIAL_PARITY_EVEN ? "Even" : props->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", props->stopbits, props->dtr, props->rts); #endif return TRUE; } bool IO_Serial_SetProperties (IO_Serial * io, IO_Serial_Properties * props) { struct termios newtio; unsigned int modembits; #if 1 #if !defined(OS_CYGWIN32) && !defined(OS_HPUX) modembits = TIOCM_DTR; if (props->dtr == IO_SERIAL_HIGH) { if (ioctl (io->fd, TIOCMBIS, &modembits) < 0) return FALSE; } else if (props->dtr == IO_SERIAL_LOW) { if (ioctl (io->fd, TIOCMBIC, &modembits) < 0) return FALSE; } modembits = TIOCM_RTS; if (props->rts == IO_SERIAL_HIGH) { if (ioctl (io->fd, TIOCMBIS, &modembits) < 0) return FALSE; } else if (props->rts == IO_SERIAL_LOW) { if (ioctl (io->fd, TIOCMBIC, &modembits) < 0) return FALSE; } #endif #endif memset (&newtio, 0, sizeof (newtio)); /* Set the bitrate */ cfsetispeed (&newtio, IO_Serial_Bitrate (props->input_bitrate)); cfsetospeed (&newtio, IO_Serial_Bitrate (props->output_bitrate)); /* Set the character size */ switch (props->bits) { case 5: newtio.c_cflag |= CS5; break; case 6: newtio.c_cflag |= CS6; break; case 7: newtio.c_cflag |= CS7; break; case 8: newtio.c_cflag |= CS8; break; } /* Set the parity */ switch (props->parity) { case IO_SERIAL_PARITY_ODD: newtio.c_cflag |= PARENB; newtio.c_cflag |= PARODD; break; case IO_SERIAL_PARITY_EVEN: newtio.c_cflag |= PARENB; newtio.c_cflag &= ~PARODD; break; case IO_SERIAL_PARITY_NONE: newtio.c_cflag &= ~PARENB; } /* Set the number of stop bits */ switch (props->stopbits) { case 1: newtio.c_cflag &= (~CSTOPB); break; case 2: newtio.c_cflag |= CSTOPB; break; } /* Selects raw (non-canonical) input and output */ newtio.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); newtio.c_oflag &= ~OPOST; #if 1 /* Ignore parity errors!!! Windows driver does so why shouldn't I? */ newtio.c_iflag |= IGNPAR; #endif /* Enable receiber, hang on close, ignore control line */ newtio.c_cflag |= CREAD | HUPCL | CLOCAL; /* Read 1 byte minimun, no timeout specified */ newtio.c_cc[VMIN] = 1; newtio.c_cc[VTIME] = 0; if (tcsetattr (io->fd, TCSANOW, &newtio) < 0) return FALSE; if (tcflush (io->fd, TCIFLUSH) < 0) return FALSE; IO_Serial_SetPropertiesCache (io, props); #ifdef DEBUG_IO printf ("IO: Setting properties: %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", props->input_bitrate, props->bits, props->parity == IO_SERIAL_PARITY_EVEN ? "Even" : props->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", props->stopbits, props->dtr, props->rts); #endif return TRUE; } void IO_Serial_GetPnPId (IO_Serial * io, BYTE * pnp_id, unsigned *length) { (*length) = io->PnP_id_size; memcpy (pnp_id, io->PnP_id, io->PnP_id_size); } unsigned IO_Serial_GetCom (IO_Serial * io) { return io->com; } bool IO_Serial_Read (IO_Serial * io, unsigned timeout, unsigned size, BYTE * data) { BYTE c; int count = 0; #ifdef DEBUG_IO printf ("IO: Receiving: "); fflush (stdout); #endif for (count = 0; count < size; count++) { if (IO_Serial_WaitToRead (io->fd, 0, timeout)) { if (read (io->fd, &c, 1) != 1) { #ifdef DEBUG_IO printf ("ERROR\n"); fflush (stdout); #endif return FALSE; } data[count] = c; #ifdef DEBUG_IO printf ("%X ", c); fflush (stdout); #endif } else { #ifdef DEBUG_IO printf ("TIMEOUT\n"); fflush (stdout); #endif /* tcflush (io->fd, TCIFLUSH); */ return FALSE; } } #ifdef DEBUG_IO printf ("\n"); fflush (stdout); #endif return TRUE; } bool IO_Serial_Write (IO_Serial * io, unsigned delay, unsigned size, BYTE * data) { unsigned count, to_send; #ifdef DEBUG_IO unsigned i; printf ("IO: Sending: "); fflush (stdout); #endif /* Discard input data from previous commands */ tcflush (io->fd, TCIFLUSH); for (count = 0; count < size; count += to_send) { to_send = (delay? 1: size); if (IO_Serial_WaitToWrite (io->fd, delay, 1000)) { if (write (io->fd, data + count, to_send) != to_send) { #ifdef DEBUG_IO printf ("ERROR\n"); fflush (stdout); #endif return FALSE; } #ifdef DEBUG_IO for (i=0; ifd, TCIFLUSH); */ return FALSE; } } #ifdef DEBUG_IO printf ("\n"); fflush (stdout); #endif return TRUE; } bool IO_Serial_Close (IO_Serial * io) { char filename[IO_SERIAL_FILENAME_LENGTH]; IO_Serial_DeviceName (io->com, io->usbserial, filename, IO_SERIAL_FILENAME_LENGTH); #ifdef DEBUG_IO printf ("IO: Clossing serial port %s\n", filename); #endif if (close (io->fd) != 0) return FALSE; IO_Serial_ClearPropertiesCache (io); IO_Serial_Clear (io); return TRUE; } void IO_Serial_Delete (IO_Serial * io) { if (io->props != NULL) free (io->props); free (io); } /* * Internal functions definition */ static int IO_Serial_Bitrate(int bitrate) { #ifdef B230400 if ((bitrate)>=230400) return B230400; #endif #ifdef B115200 if ((bitrate)>=115200) return B115200; #endif #ifdef B57600 if ((bitrate)>=57600) return B57600; #endif #ifdef B38400 if ((bitrate)>=38400) return B38400; #endif #ifdef B19200 if ((bitrate)>=19200) return B19200; #endif #ifdef B9600 if ((bitrate)>=9600) return B9600; #endif #ifdef B4800 if ((bitrate)>=4800) return B4800; #endif #ifdef B2400 if ((bitrate)>=2400) return B2400; #endif #ifdef B1800 if ((bitrate)>=1800) return B1800; #endif #ifdef B1200 if ((bitrate)>=1200) return B1200; #endif #ifdef B600 if ((bitrate)>=600) return B600; #endif #ifdef B300 if ((bitrate)>=300) return B300; #endif #ifdef B200 if ((bitrate)>=200) return B200; #endif #ifdef B150 if ((bitrate)>=150) return B150; #endif #ifdef B134 if ((bitrate)>=134) return B134; #endif #ifdef B110 if ((bitrate)>=110) return B110; #endif #ifdef B75 if ((bitrate)>=75) return B75; #endif #ifdef B50 if ((bitrate)>=50) return B50; #endif #ifdef B0 if ((bitrate)>=0) return B0; #endif return 0; /* Should never get here */ } static bool IO_Serial_WaitToRead (int hnd, unsigned delay_ms, unsigned timeout_ms) { int rval; #ifdef HAVE_POLL struct pollfd ufds; #else fd_set rfds; struct timeval tv; #endif if (delay_ms > 0) { #ifdef HAVE_NANOSLEEP struct timespec req_ts; req_ts.tv_sec = delay_ms / 1000; req_ts.tv_nsec = (delay_ms % 1000) * 1000000L; nanosleep (&req_ts, NULL); #else usleep ((unsigned long) (delay_ms * 1000L)); #endif } #ifdef HAVE_POLL ufds.fd = hnd; ufds.events = POLLIN; ufds.revents = 0x0000; rval = poll (&ufds, 1, timeout_ms); if (rval != 1) return (FALSE); return (((ufds.revents) & POLLIN) == POLLIN); #else tv.tv_sec = timeout_ms / 1000; tv.tv_usec = (timeout_ms % 1000) * 1000L; FD_ZERO (&rfds); FD_SET (hnd, &rfds); rval = select (hnd + 1, &rfds, NULL, NULL, &tv); return FD_ISSET (hnd, &rfds); #endif } static bool IO_Serial_WaitToWrite (int hnd, unsigned delay_ms, unsigned timeout_ms) { int rval; #ifdef HAVE_POLL struct pollfd ufds; #else fd_set rfds; struct timeval tv; #endif if (delay_ms > 0) { #ifdef HAVE_NANOSLEEP struct timespec req_ts; req_ts.tv_sec = delay_ms / 1000; req_ts.tv_nsec = (delay_ms % 1000) * 1000000L; nanosleep (&req_ts, NULL); #else usleep ((unsigned long) (delay_ms * 1000L)); #endif } #ifdef HAVE_POLL ufds.fd = hnd; ufds.events = POLLOUT; ufds.revents = 0x0000; rval = poll (&ufds, 1, timeout_ms); if (rval != 1) return (FALSE); return (((ufds.revents) & POLLOUT) == POLLOUT); #else tv.tv_sec = timeout_ms / 1000; tv.tv_usec = (timeout_ms % 1000) * 1000L; FD_ZERO (&rfds); FD_SET (hnd, &rfds); rval = select (hnd + 1, NULL, &rfds, NULL, &tv); return FD_ISSET (hnd, &rfds); #endif } static void IO_Serial_Clear (IO_Serial * io) { io->fd = -1; io->props = NULL; io->com = 0; memset (io->PnP_id, 0, IO_SERIAL_PNPID_SIZE); io->PnP_id_size = 0; io->usbserial = FALSE; } static void IO_Serial_SetPropertiesCache(IO_Serial * io, IO_Serial_Properties * props) { if (io->props == NULL) io->props = (IO_Serial_Properties *) malloc (sizeof (IO_Serial_Properties)); #ifdef DEBUG_IO printf ("IO: Catching properties\n"); #endif memcpy (io->props, props, sizeof (IO_Serial_Properties)); } static bool IO_Serial_GetPropertiesCache(IO_Serial * io, IO_Serial_Properties * props) { if (io->props != NULL) { memcpy (props, io->props, sizeof (IO_Serial_Properties)); #if 0 #ifdef DEBUG_IO printf ("IO: Getting properties (catched): %ld bps; %d bits/byte; %s parity; %d stopbits; dtr=%d; rts=%d\n", props->input_bitrate, props->bits, props->parity == IO_SERIAL_PARITY_EVEN ? "Even" : props->parity == IO_SERIAL_PARITY_ODD ? "Odd" : "None", props->stopbits, props->dtr, props->rts); #endif #endif return TRUE; } return FALSE; } static void IO_Serial_ClearPropertiesCache (IO_Serial * io) { #ifdef DEBUG_IO printf ("IO: Clearing properties cache\n"); #endif if (io->props != NULL) { free (io->props); io->props = NULL; } } static void IO_Serial_DeviceName (unsigned com, bool usbserial, char * filename, unsigned length) { #ifdef IO_ENABLE_USB if (usbserial) #ifdef OS_LINUX #ifdef IO_ENABLE_DEVFS snprintf (filename, length, "/dev/usb/tts/%d", com - 1); #else snprintf (filename, length, "/dev/ttyUSB%d", com - 1); #endif #endif /* OS_LINUX */ else #endif /* IO_ENABLE_USB */ #ifdef IO_ENABLE_DEVPCSC snprintf (filename, length, "/dev/pcsc/%d", com); #else #ifdef OS_LINUX #ifdef IO_ENABLE_DEVFS snprintf (filename, length, "/dev/tts/%d", com - 1); #else snprintf (filename, length, "/dev/ttyS%d", com - 1); #endif #endif /* OS_LINUX */ #ifdef OS_SOLARIS snprintf (filename, length, "/dev/cua/%c", 'a' + com - 1); #endif /* OS_SOLARIS */ #ifdef OS_CYGWIN32 sprintf (filename, "COM%d", com); #endif /* OS_CYGWIN32 */ #ifdef OS_HPUX snprintf (filename, length, "/dev/tty%dp0", com); #endif /* OS_HPUX */ #ifdef OS_IRIX snprintf (filename, length, "/dev/ttyf%d", com); #endif /* OS_IRIX */ #ifdef OS_DIGITAL_UNIX snprintf (filename, length, "/dev/tty%02d", com); #endif /* OS_DIGITAL_UNIX */ #ifdef OS_AIX snprintf (filename, length, "/dev/tty%d", com - 1); #endif /* OS_AIX */ #ifdef OS_SCO snprintf (filename, length, "/dev/tty%da", com); #endif /* OS_SCO */ #ifdef OS_FREEBSD /* support for for FreeBSD added by Martin Preuss */ snprintf (filename, length, "/dev/cuaa%d", com - 1); #endif /* OS_FREEBSD */ #ifdef OS_NETBSD snprintf (filename, length, "/dev/ttyC%d", com - 1); #endif /* OS_NETBSD */ #ifdef OS_OPENBSD /* support for for FreeBSD added by Martin Preuss */ snprintf (filename, length, "/dev/cua%02d", com - 1); #endif /* OS_SOLARIS */ #endif /* IO_ENABLE_DEVPCSC */ } static bool IO_Serial_InitPnP (IO_Serial * io) { IO_Serial_Properties props; int i = 0; props.input_bitrate = 1200; props.output_bitrate = 1200; props.parity = IO_SERIAL_PARITY_NONE; props.bits = 7; props.stopbits = 1; props.dtr = IO_SERIAL_HIGH; props.rts = IO_SERIAL_HIGH; if (!IO_Serial_SetProperties (io, &props)) return FALSE; while ((i < IO_SERIAL_PNPID_SIZE) && IO_Serial_Read (io, 200, 1, &(io->PnP_id[i]))) i++; io->PnP_id_size = i; return TRUE; } towitoko-2.0.7/src/driver/protocol_t0.c0000644000175000017500000006015507521022540013556 /* protocol_t0.c Handling of ISO 7816 T=0 protocol This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include #include #include #include "protocol_t0.h" #include "atr.h" /* * Not exported constants definition */ #define PROTOCOL_T0_MAX_NULLS 200 #define PROTOCOL_T0_DEFAULT_WI 10 #define PROTOCOL_T0_MAX_SHORT_COMMAND 260 #define PROTOCOL_T0_MAX_SHORT_RESPONSE 258 /* * Not exported functions declaration */ static void Protocol_T0_Clear (Protocol_T0 * t0); static int Protocol_T0_Case1 (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_T0_Case2S (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_T0_Case3S (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_T0_Case4S (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_T0_Case2E (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_T0_Case3E (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_T0_Case4E (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_T0_ExchangeTPDU (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp); /* * Exproted funtions definition */ Protocol_T0 * Protocol_T0_New (void) { Protocol_T0 *t0; t0 = (Protocol_T0 *) malloc (sizeof (Protocol_T0)); if (t0 != NULL) Protocol_T0_Clear (t0); return t0; } int Protocol_T0_Init (Protocol_T0 * t0, ICC_Async * icc, PPS_ProtocolParameters * params) { ICC_Async_Timings timings; BYTE wi; #ifndef PROTOCOL_T0_USE_DEFAULT_TIMINGS ATR *atr = ICC_Async_GetAtr (icc); #endif /* Set ICC */ t0->icc = icc; /* Integer value WI = TC2, by default 10 */ #ifndef PROTOCOL_T0_USE_DEFAULT_TIMINGS if (ATR_GetInterfaceByte (atr, 2, ATR_INTERFACE_BYTE_TC, &(wi)) != ATR_OK) #endif wi = PROTOCOL_T0_DEFAULT_WI; /* WWT = 960 * WI * (Fi / f) * 1000 milliseconds */ t0->wwt = (long unsigned int) (960 * wi * (params->f / ICC_Async_GetClockRate (t0->icc)) * 1000); /* Set timings */ ICC_Async_GetTimings (t0->icc, &timings); timings.block_timeout = t0->wwt; timings.char_timeout = t0->wwt; ICC_Async_SetTimings (t0->icc, &timings); #ifdef DEBUG_PROTOCOL printf ("Protocol: T=0: WWT=%d\n", t0->wwt); #endif return PROTOCOL_T0_OK; } int Protocol_T0_Command (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp) { int cmd_case, ret; cmd_case = APDU_Cmd_Case (cmd); #ifdef DEBUG_PROTOCOL if (cmd_case != APDU_MALFORMED) printf ("Protocol: T=0 Case %d %s\n", (cmd_case & 0x0F), APDU_CASE_IS_EXTENDED (cmd_case)? "extended": "short"); #endif if (cmd_case == APDU_CASE_1) ret = Protocol_T0_Case1 (t0, cmd, rsp); else if (cmd_case == APDU_CASE_2S) ret = Protocol_T0_Case2S (t0, cmd, rsp); else if (cmd_case == APDU_CASE_3S) ret = Protocol_T0_Case3S (t0, cmd, rsp); else if (cmd_case == APDU_CASE_4S) ret = Protocol_T0_Case4S (t0, cmd, rsp); else if (cmd_case == APDU_CASE_2E) ret = Protocol_T0_Case2E (t0, cmd, rsp); else if (cmd_case == APDU_CASE_3E) ret = Protocol_T0_Case3E (t0, cmd, rsp); else if (cmd_case == APDU_CASE_4E) ret = Protocol_T0_Case4E (t0, cmd, rsp); else { #ifdef DEBUG_PROTOCOL printf ("Protocol: T=0: Invalid APDU\n"); #endif ret = PROTOCOL_T0_ERROR; } return ret; } int Protocol_T0_Close (Protocol_T0 * t0) { Protocol_T0_Clear (t0); return PROTOCOL_T0_OK; } void Protocol_T0_Delete (Protocol_T0 * t0) { free (t0); } /* * Not exported functions definition */ static int Protocol_T0_Case1 (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp) { int ret; BYTE buffer[5]; APDU_Cmd *tpdu_cmd; /* Map command APDU onto TPDU */ memcpy (buffer, APDU_Cmd_Raw (cmd), 4); buffer[4] = 0x00; tpdu_cmd = APDU_Cmd_New (buffer, 5); /* Send command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, rsp); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); return ret; } static int Protocol_T0_Case2S (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp) { int ret; /* Send command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, cmd, rsp); return ret; } static int Protocol_T0_Case3S (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp) { int ret; APDU_Rsp *tpdu_rsp; #ifdef PROTOCOL_T0_ISO BYTE buffer[5]; APDU_Cmd *tpdu_cmd; #endif /* Send command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, cmd, (&tpdu_rsp)); if (ret == PROTOCOL_T0_OK) { #ifdef PROTOCOL_T0_ISO /* Le definitely not accepted */ if (APDU_Rsp_SW1 (tpdu_rsp) == 0x67) { /* Map response APDU onto TPDU without change */ (*rsp) = tpdu_rsp; } /* Le not accepted, La indicated */ else if (APDU_Rsp_SW1 (tpdu_rsp) == 0x6C) { /* Map command APDU onto TPDU */ memcpy (buffer, APDU_Cmd_Raw (cmd), 4); buffer[4] = APDU_Rsp_SW2 (tpdu_rsp); tpdu_cmd = APDU_Cmd_New (buffer, 5); /* Delete response TPDU */ APDU_Rsp_Delete (tpdu_rsp); /* Re-issue command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, rsp); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); if (ret == PROTOCOL_T0_OK) { if (APDU_Rsp_DataLen ((*rsp)) > APDU_Cmd_Le (cmd)) { /* Map response APDU onto TPDU */ APDU_Rsp_TruncateData ((*rsp), APDU_Cmd_Le (cmd)); } } } /* Command processed, Lx indicated */ else if (APDU_Rsp_SW1 (tpdu_rsp) == 0x61) { /* MAP response TPDU onto APDU */ (*rsp) = tpdu_rsp; /* Prepare Get Response TPDU */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = 0xC0; buffer[2] = 0x00; buffer[3] = 0x00; do { /* Issue Get Response command TPDU */ buffer[4] = APDU_Rsp_SW2 (tpdu_rsp); tpdu_cmd = APDU_Cmd_New (buffer, 5); ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, (&tpdu_rsp)); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); if (ret == PROTOCOL_T0_OK) { /* Append response TPDU to APDU */ if (APDU_Rsp_AppendData ((*rsp), tpdu_rsp) != APDU_OK) ret = PROTOCOL_T0_ERROR; /* Delete response TPDU */ APDU_Rsp_Delete (tpdu_rsp); } } while ((ret == PROTOCOL_T0_OK) && (APDU_Rsp_SW1 (*rsp) == 0x61)); if (ret == PROTOCOL_T0_OK) { if (APDU_Rsp_DataLen ((*rsp)) > APDU_Cmd_Le (cmd)) { /* Map response APDU onto TPDU */ APDU_Rsp_TruncateData ((*rsp), APDU_Cmd_Le (cmd)); } } } /* Le accepted */ else { /* Map response TPDU onto APDU without change */ (*rsp) = tpdu_rsp; } #else (*rsp) = tpdu_rsp; #endif } return ret; } static int Protocol_T0_Case4S (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp) { int ret; BYTE buffer[PROTOCOL_T0_MAX_SHORT_COMMAND]; APDU_Cmd *tpdu_cmd; APDU_Rsp *tpdu_rsp; /* Map command APDU onto TPDU */ memcpy (buffer, APDU_Cmd_Raw (cmd), APDU_Cmd_RawLen (cmd) - 1); tpdu_cmd = APDU_Cmd_New (buffer, APDU_Cmd_RawLen (cmd) - 1); /* Send command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, (&tpdu_rsp)); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); if (ret == PROTOCOL_T0_OK) { #ifdef PROTOCOL_T0_ISO /* Command accepted with information added */ if (APDU_Rsp_SW1 (tpdu_rsp) == 0x61) { /* Prepare Get Reponse command TPDU */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = 0xC0; buffer[2] = 0x00; buffer[3] = 0x00; if (APDU_Rsp_SW2 (tpdu_rsp) == 0x00) buffer[4] = (BYTE) APDU_Cmd_Le (cmd); else buffer[4] = MIN (APDU_Cmd_Le (cmd), APDU_Rsp_SW2 (tpdu_rsp)); tpdu_cmd = APDU_Cmd_New (buffer, 5); /* Delete response TPDU */ APDU_Rsp_Delete (tpdu_rsp); /* Issue Get Reponse command */ ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, rsp); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); } /* Command not accepted */ else if ((APDU_Rsp_SW1 (tpdu_rsp) & 0xF0) == 0x60) { /* Map response TPDU onto APDU without change */ (*rsp) = tpdu_rsp; } /* Command accepted */ else { /* Delete response TPDU */ APDU_Rsp_Delete (tpdu_rsp); /* Prepare Get Reponse TPDU */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = 0xC0; buffer[2] = 0x00; buffer[3] = 0x00; buffer[4] = (BYTE) APDU_Cmd_Le (cmd); tpdu_cmd = APDU_Cmd_New (buffer, 5); /* Issue Get Reponse command TPDU */ ret = Protocol_T0_Case3S (t0, tpdu_cmd, rsp); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); } #else (*rsp) = tpdu_rsp; #endif } return ret; } static int Protocol_T0_Case2E (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp) { int ret = PROTOCOL_T0_OK, i; BYTE buffer[PROTOCOL_T0_MAX_SHORT_COMMAND]; APDU_Cmd *tpdu_cmd; APDU_Rsp *tpdu_rsp; if (APDU_Cmd_Lc (cmd) < 256) { /* MAP APDU onto command TPDU */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = APDU_Cmd_Ins (cmd); buffer[2] = APDU_Cmd_P1 (cmd); buffer[3] = APDU_Cmd_P2 (cmd); buffer[4] = (BYTE) APDU_Cmd_Lc (cmd); memcpy (buffer + 5, APDU_Cmd_Data (cmd), buffer[4]); tpdu_cmd = APDU_Cmd_New (buffer, buffer[4] + 5); /* Send command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, rsp); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); } else { /* Prepare envelope TPDU */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = 0xC2; buffer[2] = 0x00; buffer[3] = 0x00; for (i = 0; i < APDU_Cmd_RawLen (cmd); i += buffer[4]) { /* Create envelope command TPDU */ buffer[4] = MIN (255, APDU_Cmd_RawLen (cmd) - i); memcpy (buffer + 5, APDU_Cmd_Raw (cmd) + i, buffer[4]); tpdu_cmd = APDU_Cmd_New (buffer, buffer[4] + 5); /* Send envelope command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, (&tpdu_rsp)); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); if (ret == PROTOCOL_T0_OK) { /* Card does support envelope command */ if (APDU_Rsp_SW1 (tpdu_rsp) == 0x90) { /* This is not the last segment */ if (buffer[4] + i < APDU_Cmd_RawLen (cmd)) { /* Delete response TPDU */ APDU_Rsp_Delete (tpdu_rsp); } else { /* Map response TPDU onto APDU */ (*rsp) = tpdu_rsp; } } /* Card does not support envelope command or error */ else { /* Map response tpdu onto APDU without change */ (*rsp) = tpdu_rsp; break; } } else break; } } return ret; } static int Protocol_T0_Case3E (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp) { int ret; BYTE buffer[5]; APDU_Cmd *tpdu_cmd; APDU_Rsp *tpdu_rsp; long Lm, Lx; if (APDU_Cmd_Le (cmd) <= 256) { /* Map APDU onto command TPDU */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = APDU_Cmd_Ins (cmd); buffer[2] = APDU_Cmd_P1 (cmd); buffer[3] = APDU_Cmd_P2 (cmd); buffer[4] = (BYTE) APDU_Cmd_Le (cmd); tpdu_cmd = APDU_Cmd_New (buffer, 5); /* Send command TPDU */ ret = Protocol_T0_Case3S (t0, tpdu_cmd, rsp); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); } else { /* Map APDU onto command TPDU */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = APDU_Cmd_Ins (cmd); buffer[2] = APDU_Cmd_P1 (cmd); buffer[3] = APDU_Cmd_P2 (cmd); buffer[4] = 0x00; tpdu_cmd = APDU_Cmd_New (buffer, 5); /* Send command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, (&tpdu_rsp)); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); if (ret == PROTOCOL_T0_OK) { /* Le definitely not accepted */ if (APDU_Rsp_SW1 (tpdu_rsp) == 0x67) { /* Map response APDU onto TPDU without change */ (*rsp) = tpdu_rsp; } /* Le not accepted, La indicated */ else if (APDU_Rsp_SW1 (tpdu_rsp) == 0x6C) { /* Map command APDU onto TPDU */ memcpy (buffer, APDU_Cmd_Raw (cmd), 4); buffer[4] = APDU_Rsp_SW2 (tpdu_rsp); tpdu_cmd = APDU_Cmd_New (buffer, 5); /* Delete response TPDU */ APDU_Rsp_Delete (tpdu_rsp); /* Re-issue command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, rsp); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); } /* Command processed, Lx indicated */ else if (APDU_Rsp_SW1 (tpdu_rsp) == 0x61) { /* Map response TPDU onto APDU */ (*rsp) = tpdu_rsp; Lx = (APDU_Rsp_SW2 (tpdu_rsp) == 0x00) ? 256 : APDU_Rsp_SW2 (tpdu_rsp); Lm = APDU_Cmd_Le (cmd) - APDU_Rsp_DataLen (*rsp); /* Prepare Get Response TPDU */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = 0xC0; buffer[2] = 0x00; buffer[3] = 0x00; while (Lm > 0) { buffer[4] = (BYTE) MIN (Lm, Lx); tpdu_cmd = APDU_Cmd_New (buffer, 5); /* Issue Get Response command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, (&tpdu_rsp)); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); if (ret == PROTOCOL_T0_OK) { /* Append response TPDU to APDU */ if (APDU_Rsp_AppendData ((*rsp), tpdu_rsp) != APDU_OK) { ret = PROTOCOL_T0_ERROR; APDU_Rsp_Delete (tpdu_rsp); break; } /* Delete response TPDU */ APDU_Rsp_Delete (tpdu_rsp); } else break; Lm = APDU_Cmd_Le (cmd) - APDU_Rsp_DataLen (*rsp); } /* Lm == 0 */ } /* Le accepted: card has no more than 265 bytes or does not support Get Response */ else { /* Map response TPDU onto APDU without change */ (*rsp) = tpdu_rsp; } } } return ret; } static int Protocol_T0_Case4E (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp) { int ret; BYTE buffer[PROTOCOL_T0_MAX_SHORT_COMMAND]; APDU_Cmd *tpdu_cmd, *gr_cmd; APDU_Rsp *tpdu_rsp; long Le; /* 4E1 */ if (APDU_Cmd_Lc (cmd) < 256) { /* Map APDU onto command TPDU */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = APDU_Cmd_Ins (cmd); buffer[2] = APDU_Cmd_P1 (cmd); buffer[3] = APDU_Cmd_P2 (cmd); buffer[4] = (BYTE) APDU_Cmd_Lc (cmd); memcpy (buffer + 5, APDU_Cmd_Data (cmd), buffer[4]); tpdu_cmd = APDU_Cmd_New (buffer, buffer[4] + 5); /* Send command TPDU */ ret = Protocol_T0_ExchangeTPDU (t0, tpdu_cmd, (&tpdu_rsp)); /* Delete command TPDU */ APDU_Cmd_Delete (tpdu_cmd); } /* 4E2 */ else { ret = Protocol_T0_Case2E (t0, cmd, (&tpdu_rsp)); } /* 4E1 a) b) and c) */ if (ret == PROTOCOL_T0_OK) { if (APDU_Rsp_SW1 (tpdu_rsp) == 0x61) { /* Lm == (Le - APDU_Rsp_RawLen (tpdu_rsp)) == 0 */ if (APDU_Rsp_SW2 (tpdu_rsp) != 0x00) Le = MIN(APDU_Rsp_SW2 (tpdu_rsp), APDU_Cmd_Le(cmd)); else Le = APDU_Cmd_Le (cmd); /* Delete response TPDU */ APDU_Rsp_Delete (tpdu_rsp); /* Prepare extended Get Response APDU command */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = 0xC0; buffer[2] = 0x00; buffer[3] = 0x00; buffer[4] = 0x00; /* B1 = 0x00 */ buffer[5] = (BYTE) (Le >> 8); /* B2 = BL-1 */ buffer[6] = (BYTE) (Le & 0x00FF); /* B3 = BL */ gr_cmd = APDU_Cmd_New (buffer, 7); /* Issue Case 3E get response command */ ret = Protocol_T0_Case3E (t0, gr_cmd, rsp); /* Delete Get Response command APDU */ APDU_Cmd_Delete (gr_cmd); } else if ((APDU_Rsp_SW1 (tpdu_rsp) & 0xF0) == 0x60) { /* Map response TPDU onto APDU without change */ (*rsp) = tpdu_rsp; } else { /* Delete response TPDU */ APDU_Rsp_Delete (tpdu_rsp); /* Prepare extended Get Response APDU command */ buffer[0] = APDU_Cmd_Cla (cmd); buffer[1] = 0xC0; buffer[2] = 0x00; buffer[3] = 0x00; buffer[4] = 0x00; /* B1 = 0x00 */ buffer[5] = (BYTE) (APDU_Cmd_Le (cmd) >> 8); /* B2 = BL-1 */ buffer[6] = (BYTE) (APDU_Cmd_Le (cmd) & 0x00FF); /* B3 = BL */ gr_cmd = APDU_Cmd_New (buffer, 7); /* Issue Case 3E get response command */ ret = Protocol_T0_Case3E (t0, gr_cmd, rsp); /* Delete Get Response command APDU */ APDU_Cmd_Delete (gr_cmd); } } return ret; } static int Protocol_T0_ExchangeTPDU (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE buffer[PROTOCOL_T0_MAX_SHORT_RESPONSE]; BYTE *data; long Lc, Le, sent, recv; int ret = PROTOCOL_T0_OK, nulls, cmd_case; /* Parse APDU */ Lc = APDU_Cmd_Lc (cmd); Le = APDU_Cmd_Le (cmd); data = APDU_Cmd_Data (cmd); cmd_case = APDU_Cmd_Case (cmd); /* Check case of command */ if ((cmd_case != APDU_CASE_2S) && (cmd_case != APDU_CASE_3S)) return PROTOCOL_T0_ERROR; /* Initialise transmission */ if (ICC_Async_BeginTransmission (t0->icc) != ICC_ASYNC_OK) { (*rsp) = NULL; return PROTOCOL_T0_ICC_ERROR; } /* Send header bytes */ if (ICC_Async_Transmit (t0->icc, 5, APDU_Cmd_Header (cmd)) != ICC_ASYNC_OK) { ICC_Async_EndTransmission (t0->icc); (*rsp) = NULL; return PROTOCOL_T0_ICC_ERROR; } /* Initialise counters */ nulls = 0; sent = 0; recv = 0; /* * Let's be a bit paranoid with buffer sizes within this loop * so it doesn't overflow reception and transmission buffers * if card does not strictly respect the protocol */ while (recv < PROTOCOL_T0_MAX_SHORT_RESPONSE) { /* Read one procedure byte */ if (ICC_Async_Receive (t0->icc, 1, buffer + recv) != ICC_ASYNC_OK) { ret = PROTOCOL_T0_ICC_ERROR; break; } /* NULL byte received */ if (buffer[recv] == 0x60) { nulls++; /* Maximum number of nulls reached */ if (nulls >= PROTOCOL_T0_MAX_NULLS) { ret = PROTOCOL_T0_NULL_ERROR; break; } continue; } /* SW1 byte received */ else if ((buffer[recv] & 0xF0) == 0x60 || (buffer[recv] & 0xF0) == 0x90) { recv++; if (recv >= PROTOCOL_T0_MAX_SHORT_RESPONSE) return PROTOCOL_T0_ERROR; /* Read SW2 byte */ if (ICC_Async_Receive (t0->icc, 1, buffer + recv) != ICC_ASYNC_OK) { ret = PROTOCOL_T0_ICC_ERROR; break; } recv++; ret = PROTOCOL_T0_OK; break; } /* ACK byte received */ else if ((buffer[recv] & 0x0E) == (APDU_Cmd_Ins (cmd) & 0x0E)) { /* Reset null's counter */ nulls = 0; /* Case 2 command: send data */ if (cmd_case == APDU_CASE_2S) { if (sent >= Lc) return PROTOCOL_T0_ERROR; if (ICC_Async_Switch (t0->icc) != ICC_ASYNC_OK) { ret = PROTOCOL_T0_ICC_ERROR; break; } /* Send remaining data bytes */ if (ICC_Async_Transmit (t0->icc, MAX (Lc - sent, 0), data + sent) != ICC_ASYNC_OK) { ret = PROTOCOL_T0_ICC_ERROR; break; } sent = Lc; continue; } /* Case 3 command: receive data */ else { if (recv >= PROTOCOL_T0_MAX_SHORT_RESPONSE) return PROTOCOL_T0_ERROR; /* * Le <= PROTOCOL_T0_MAX_SHORT_RESPONSE - 2 for short commands */ /* Read remaining data bytes */ if (ICC_Async_Receive (t0->icc, MAX (Le - recv, 0), buffer + recv) != ICC_ASYNC_OK) { ret = PROTOCOL_T0_ICC_ERROR; break; } recv = Le; continue; } } /* ~ACK byte received */ else if ((buffer[recv] & 0x0E) == ((~APDU_Cmd_Ins (cmd)) & 0x0E)) { /* Reset null's counter */ nulls = 0; /* Case 2 command: send data */ if (cmd_case == APDU_CASE_2S) { if (sent >= Lc) return PROTOCOL_T0_ERROR; if (ICC_Async_Switch (t0->icc) != ICC_ASYNC_OK) { ret = PROTOCOL_T0_ICC_ERROR; break; } /* Send next data byte */ if (ICC_Async_Transmit (t0->icc, 1, data + sent) != ICC_ASYNC_OK) { ret = PROTOCOL_T0_ICC_ERROR; break; } sent++; continue; } /* Case 3 command: receive data */ else { if (recv >= PROTOCOL_T0_MAX_SHORT_RESPONSE) return PROTOCOL_T0_ERROR; /* Read next data byte */ if (ICC_Async_Receive (t0->icc, 1, buffer + recv) != ICC_ASYNC_OK) { ret = PROTOCOL_T0_ICC_ERROR; break; } recv++; continue; } } /* Anything else received */ else { ret = PROTOCOL_T0_ERROR; break; } } if (ICC_Async_Switch (t0->icc) != ICC_ASYNC_OK) ret = PROTOCOL_T0_ICC_ERROR; if (ret == PROTOCOL_T0_OK) (*rsp) = APDU_Rsp_New (buffer, recv); else (*rsp) = NULL; /* End of transmission */ if (ICC_Async_EndTransmission (t0->icc) != ICC_ASYNC_OK) return PROTOCOL_T0_ICC_ERROR; return (ret); } static void Protocol_T0_Clear (Protocol_T0 * t0) { t0->icc = NULL; t0->wwt = 0; } towitoko-2.0.7/src/driver/protocol_t1.c0000644000175000017500000002737707521022540013570 /* protocol_t1.c Handling of ISO 7816 T=1 protocol This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include #include #include #include "protocol_t1.h" #include "t1_block.h" /* * Not exported constants definition */ #define PROTOCOL_T1_DEFAULT_IFSC 32 #define PROTOCOL_T1_DEFAULT_IFSD 32 #define PROTOCOL_T1_MAX_IFSC 251 /* Cannot send > 255 buffer */ #define PROTOCOL_T1_DEFAULT_CWI 13 #define PROTOCOL_T1_DEFAULT_BWI 4 #define PROTOCOL_T1_EDC_LRC 0 #define PROTOCOL_T1_EDC_CRC 1 /* * Not exported functions declaration */ static void Protocol_T1_Clear (Protocol_T1 * t1); static int Protocol_T1_SendBlock (Protocol_T1 * t1, T1_Block * block); static int Protocol_T1_ReceiveBlock (Protocol_T1 * t1, T1_Block ** block); static int Protocol_T1_UpdateBWT (Protocol_T1 * t1, unsigned short bwt); /* * Exproted funtions definition */ Protocol_T1 * Protocol_T1_New (void) { Protocol_T1 *t1; t1 = (Protocol_T1 *) malloc (sizeof (Protocol_T1)); if (t1 != NULL) Protocol_T1_Clear (t1); return t1; } int Protocol_T1_Init (Protocol_T1 * t1, ICC_Async * icc, PPS_ProtocolParameters * params) { ICC_Async_Timings timings; BYTE ta, tb, tc, cwi, bwi; unsigned long baudrate; double work_etu; ATR *atr; int i; /* Set ICC */ t1->icc = icc; /* Get ATR of the card */ atr = ICC_Async_GetAtr (t1->icc); /* Set IFSC */ if (ATR_GetInterfaceByte (atr, 3, ATR_INTERFACE_BYTE_TA, &ta) == ATR_NOT_FOUND) t1->ifsc = PROTOCOL_T1_DEFAULT_IFSC; else if ((ta != 0x00) && (ta != 0xFF)) t1->ifsc = ta; else t1->ifsc = PROTOCOL_T1_DEFAULT_IFSC; /* Towitoko does not allow IFSC > 251 */ t1->ifsc = MIN (t1->ifsc, PROTOCOL_T1_MAX_IFSC); /* Set IFSD */ t1->ifsd = PROTOCOL_T1_DEFAULT_IFSD; #ifndef PROTOCOL_T1_USE_DEFAULT_TIMINGS /* Calculate CWI and BWI */ if (ATR_GetInterfaceByte (atr, 3, ATR_INTERFACE_BYTE_TB, &tb) == ATR_NOT_FOUND) { #endif cwi = PROTOCOL_T1_DEFAULT_CWI; bwi = PROTOCOL_T1_DEFAULT_BWI; #ifndef PROTOCOL_T1_USE_DEFAULT_TIMINGS } else { cwi = tb & 0x0F; bwi = (tb & 0xF0) >> 4; } #endif /* Work etu = (1000 / baudrate) milliseconds */ ICC_Async_GetBaudrate (t1->icc, &baudrate); work_etu = 1000 / (double)baudrate; /* Set CWT = (2^CWI + 11) work etu */ t1->cwt = 1; for (i = 0; i < cwi ; i++) t1->cwt *= 2; t1->cwt = (unsigned short) ((t1->cwt + 11) * work_etu); /* Set BWT = (2^BWI * 960 + 11) work etu */ t1->bwt = 1; for (i = 0; i < bwi; i++) t1->bwt *= 2; t1->bwt = (unsigned short) ((t1->bwt * 960 + 11) * work_etu); /* Set BGT = 22 * work etu */ t1->bgt = (unsigned short) (22 * work_etu); /* Set the error detection code type */ if (ATR_GetInterfaceByte (atr, 3, ATR_INTERFACE_BYTE_TC, &tc) == ATR_NOT_FOUND) t1->edc = PROTOCOL_T1_EDC_LRC; else t1->edc = tc & 0x01; /* Set initial send sequence (NS) */ t1->ns = 1; /* Set timings */ ICC_Async_GetTimings (t1->icc, &timings); timings.block_timeout = t1->bwt; timings.char_timeout = t1->cwt; timings.block_delay = t1->bgt; ICC_Async_SetTimings (t1->icc, &timings); #ifdef DEBUG_PROTOCOL printf ("Protocol: T=1: IFSC=%d, IFSD=%d, CWT=%d, BWT=%d, BGT=%d, EDC=%s\n", t1->ifsc, t1->ifsd, t1->cwt, t1->bwt, t1->bgt, (t1->edc == PROTOCOL_T1_EDC_LRC) ? "LRC" : "CRC"); #endif return PROTOCOL_T1_OK; } int Protocol_T1_Command (Protocol_T1 * t1, APDU_Cmd * cmd, APDU_Rsp ** rsp) { T1_Block *block; BYTE *buffer, rsp_type, bytes, nr, wtx; unsigned short counter; int ret; bool more; /* Calculate the number of bytes to send */ counter = 0; bytes = MIN (APDU_Cmd_RawLen (cmd), t1->ifsc); /* See if chaining is needed */ more = (APDU_Cmd_RawLen (cmd) > t1->ifsc); /* Increment ns */ t1->ns = (t1->ns + 1) %2; /* Create an I-Block */ block = T1_Block_NewIBlock (bytes, APDU_Cmd_Raw (cmd), t1->ns, more); #ifdef DEBUG_PROTOCOL printf ("Sending block I(%d,%d)\n", t1->ns, more); #endif /* Send a block */ ret = Protocol_T1_SendBlock (t1, block); /* Delete I-block */ T1_Block_Delete (block); while ((ret == PROTOCOL_T1_OK) && more) { /* Receive a block */ ret = Protocol_T1_ReceiveBlock (t1, &block); if (ret == PROTOCOL_T1_OK) { rsp_type = T1_Block_GetType (block); /* Positive ACK R-Block received */ if (rsp_type == T1_BLOCK_R_OK) { #ifdef DEBUG_PROTOCOL printf ("Protocol: Received block R(%d)\n", T1_Block_GetNR (block)); #endif /* Delete block */ T1_Block_Delete (block); /* Increment ns */ t1->ns = (t1->ns + 1) % 2; /* Calculate the number of bytes to send */ counter += bytes; bytes = MIN (APDU_Cmd_RawLen (cmd) - counter, t1->ifsc); /* See if chaining is needed */ more = (APDU_Cmd_RawLen (cmd) - counter > t1->ifsc); /* Create an I-Block */ block = T1_Block_NewIBlock (bytes, APDU_Cmd_Raw (cmd) + counter, t1->ns, more); #ifdef DEBUG_PROTOCOL printf ("Protocol: Sending block I(%d,%d)\n", t1->ns, more); #endif /* Send a block */ ret = Protocol_T1_SendBlock (t1, block); /* Delete I-block */ T1_Block_Delete (block); } else { /* Delete block */ T1_Block_Delete (block); ret = PROTOCOL_T1_NOT_IMPLEMENTED; } } else { ret = PROTOCOL_T1_NOT_IMPLEMENTED; } } /* Reset counter */ buffer = NULL; counter = 0; more = TRUE; wtx = 0; while ((ret == PROTOCOL_T1_OK) && more) { if (wtx > 1) Protocol_T1_UpdateBWT (t1, wtx * (t1->bwt)); /* Receive a block */ ret = Protocol_T1_ReceiveBlock (t1, &block); if (wtx > 1) { Protocol_T1_UpdateBWT (t1, t1->bwt); wtx = 0; } if (ret == PROTOCOL_T1_OK) { rsp_type = T1_Block_GetType (block); if (rsp_type == T1_BLOCK_I) { #ifdef DEBUG_PROTOCOL printf ("Protocol: Received block I(%d,%d)\n", T1_Block_GetNS(block), T1_Block_GetMore (block)); #endif /* Calculate nr */ nr = (T1_Block_GetNS (block) + 1) % 2; /* Save inf field */ bytes = T1_Block_GetLen (block); buffer = (BYTE *) realloc(buffer, counter + bytes); memcpy (buffer + counter, T1_Block_GetInf (block), bytes); counter += bytes; /* See if chaining is requested */ more = T1_Block_GetMore (block); /* Delete block */ T1_Block_Delete (block); if (more) { /* Create an R-Block */ block = T1_Block_NewRBlock (T1_BLOCK_R_OK, nr); #ifdef DEBUG_PROTOCOL printf ("Protocol: Sending block R(%d)\n", nr); #endif /* Send R-Block */ ret = Protocol_T1_SendBlock (t1, block); /* Delete I-block */ T1_Block_Delete (block); } } /* WTX Request S-Block received */ else if (rsp_type == T1_BLOCK_S_WTX_REQ) { /* Get wtx multiplier */ wtx = (*T1_Block_GetInf (block)); #ifdef DEBUG_PROTOCOL printf ("Protocol: Received block S(WTX request, %d)\n", wtx); #endif /* Delete block */ T1_Block_Delete (block); /* Create an WTX response S-Block */ block = T1_Block_NewSBlock (T1_BLOCK_S_WTX_RES, 1, &wtx); #ifdef DEBUG_PROTOCOL printf ("Protocol: Sending block S(WTX response, %d)\n", wtx); #endif /* Send WTX response */ ret = Protocol_T1_SendBlock (t1, block); /* Delete block */ T1_Block_Delete (block); } else { ret = PROTOCOL_T1_NOT_IMPLEMENTED; } } } if (ret == PROTOCOL_T1_OK) (*rsp) = APDU_Rsp_New (buffer, counter); if (buffer != NULL) free (buffer); return ret; } int Protocol_T1_Close (Protocol_T1 * t1) { Protocol_T1_Clear (t1); return PROTOCOL_T1_OK; } void Protocol_T1_Delete (Protocol_T1 * t1) { free (t1); } /* * Not exported functions definition */ static int Protocol_T1_SendBlock (Protocol_T1 * t1, T1_Block * block) { BYTE *buffer; int length, ret; /* Setup transmission */ if (ICC_Async_BeginTransmission (t1->icc) != ICC_ASYNC_OK) ret = PROTOCOL_T1_ICC_ERROR; else { /* Send T=1 block */ buffer = T1_Block_Raw (block); length = T1_Block_RawLen (block); if (ICC_Async_Transmit (t1->icc, length, buffer) != ICC_ASYNC_OK) { ICC_Async_EndTransmission (t1->icc); ret = PROTOCOL_T1_ICC_ERROR; } else ret = PROTOCOL_T1_OK; } return ret; } static int Protocol_T1_ReceiveBlock (Protocol_T1 * t1, T1_Block ** block) { BYTE buffer[T1_BLOCK_MAX_SIZE]; int ret; /* Receive four mandatory bytes */ if (ICC_Async_Receive (t1->icc, 4, buffer) != ICC_ASYNC_OK) { ret = PROTOCOL_T1_ICC_ERROR; (*block) = NULL; } else { if (buffer[2] != 0x00) { /* Set timings to read the remaining block */ Protocol_T1_UpdateBWT (t1, t1->cwt); /* Receive remaining bytes */ if (ICC_Async_Receive (t1->icc, buffer[2], buffer + 4) != ICC_ASYNC_OK) { (*block) = NULL; ret = PROTOCOL_T1_ICC_ERROR; } else { (*block) = T1_Block_New (buffer, buffer[2] + 4); ret = PROTOCOL_T1_OK; } /* Restore timings */ Protocol_T1_UpdateBWT (t1, t1->bwt); } else { ret = PROTOCOL_T1_OK; (*block) = T1_Block_New (buffer, 4); } } if (ICC_Async_Switch (t1->icc) != ICC_ASYNC_OK) ret = PROTOCOL_T1_ICC_ERROR; /* End of transmission */ if (ICC_Async_EndTransmission (t1->icc) != ICC_ASYNC_OK) ret = PROTOCOL_T1_ICC_ERROR; return ret; } static void Protocol_T1_Clear (Protocol_T1 * t1) { t1->icc = NULL; t1->ifsc = 0; t1->ifsd = 0; t1->bgt = 0; t1->bwt = 0; t1->cwt = 0; t1->edc = 0; t1->ns = 0; } static int Protocol_T1_UpdateBWT (Protocol_T1 * t1, unsigned short bwt) { ICC_Async_Timings timings; ICC_Async_GetTimings (t1->icc, &timings); timings.block_timeout = bwt; ICC_Async_SetTimings (t1->icc, &timings); return PROTOCOL_T1_OK; } towitoko-2.0.7/src/driver/t1_block.c0000644000175000017500000001152007521022540013000 /* t1_block.h T=1 block abstract data type implementation This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "t1_block.h" #include #include /* * Not exported constants definition */ #define T1_BLOCK_NAD 0x00 /* * Not exported functions declaration */ static BYTE T1_Block_LRC (BYTE * data, unsigned length); /* * Exported functions definition */ T1_Block * T1_Block_New (BYTE * buffer, unsigned length) { T1_Block * block; if (length < 4) return NULL; block = (T1_Block *) malloc (sizeof (T1_Block)); if (block != NULL) { block->length = MIN(length, T1_BLOCK_MAX_SIZE); block->data = (BYTE *) calloc (block->length, sizeof (BYTE)); if (block->data != NULL) { memcpy (block->data, buffer, block->length); } else { free (block); block = NULL; } } return block; } T1_Block * T1_Block_NewIBlock (BYTE len, BYTE * inf, BYTE ns, bool more) { T1_Block * block; block = (T1_Block *) malloc (sizeof (T1_Block)); if (block != NULL) { block->length = len + 4; block->data = (BYTE *) calloc (block->length, sizeof (BYTE)); if (block->data != NULL) { block->data[0] = T1_BLOCK_NAD; block->data[1] = T1_BLOCK_I | ((ns << 6) & 0x40); if (more) block->data[1] |= 0x20; block->data[2] = len; if (len != 0x00) memcpy (block->data + 3, inf, len); block->data[len+3] = T1_Block_LRC (block->data, len+3); } else { free (block); block = NULL; } } return block; } T1_Block * T1_Block_NewRBlock (BYTE type, BYTE nr) { T1_Block * block; block = (T1_Block *) malloc (sizeof (T1_Block)); if (block != NULL) { block->length = 4; block->data = (BYTE *) calloc (block->length, sizeof (BYTE)); if (block->data != NULL) { block->data[0] = T1_BLOCK_NAD; block->data[1] = type | ((nr << 4) & 0x10); block->data[2] = 0x00; block->data[3] = T1_Block_LRC (block->data, 3); } else { free (block); block = NULL; } } return block; } T1_Block * T1_Block_NewSBlock (BYTE type, BYTE len, BYTE * inf) { T1_Block * block; block = (T1_Block *) malloc (sizeof (T1_Block)); if (block != NULL) { block->length = 4 + len; block->data = (BYTE *) calloc (block->length, sizeof (BYTE)); if (block->data != NULL) { block->data[0] = T1_BLOCK_NAD; block->data[1] = type; block->data[2] = len; if (len != 0x00) memcpy (block->data + 3, inf, len); block->data[len+3] = T1_Block_LRC (block->data, len+3); } else { free (block); block = NULL; } } return block; } BYTE T1_Block_GetType (T1_Block * block) { if ((block->data[1] & 0x80) == T1_BLOCK_I) return T1_BLOCK_I; return (block->data[1] & 0xEF); } BYTE T1_Block_GetNS (T1_Block * block) { return ((block->data[1] >> 6)& 0x01); } bool T1_Block_GetMore (T1_Block * block) { return ((block->data[1] >> 5) & 0x01); } BYTE T1_Block_GetNR (T1_Block * block) { return ((block->data[1] >> 4) & 0x01); } BYTE T1_Block_GetLen (T1_Block * block) { return block->data[2]; } BYTE * T1_Block_GetInf (T1_Block * block) { if (block->length < 5) return NULL; return block->data + 3; } BYTE * T1_Block_Raw (T1_Block * block) { return block->data; } unsigned T1_Block_RawLen (T1_Block * block) { return block->length; } void T1_Block_Delete (T1_Block * block) { free (block->data); free (block); } /* * Not exported functions definition */ static BYTE T1_Block_LRC (BYTE * data, unsigned length) { BYTE lrc; unsigned i; lrc = 0x00; for (i = 0; i < length; i++) { lrc ^= data[i]; } return lrc; } towitoko-2.0.7/src/driver/ifd_towitoko.c0000644000175000017500000012174407527763534014042 /* ifd_towitoko.c This module provides IFD handling functions. This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 2001 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include #include #include #include #include #include "ifd_towitoko.h" #include "io_serial.h" /* * Not exported constants */ #define IFD_TOWITOKO_TIMEOUT 1000 #define IFD_TOWITOKO_DELAY 0 #define IFD_TOWITOKO_BAUDRATE 9600 #define IFD_TOWITOKO_PS 15 #define IFD_TOWITOKO_MAX_TRANSMIT 255 #define IFD_TOWITOKO_ATR_TIMEOUT 200 #define IFD_TOWITOKO_ATR_MIN_LENGTH 1 #define IFD_TOWITOKO_CLOCK_RATE (372L * 9600L) #define HI(a) (((a) & 0xff00) >> 8) #define LO(a) ((a) & 0x00ff) /* * Not exported functions declaration */ static int IFD_Towitoko_PrepareCommand (IFD * ifd, BYTE * command, BYTE size); static BYTE IFD_Towitoko_Checksum (BYTE * cmd, unsigned size, BYTE init); static int IFD_Towitoko_GetReaderInfo (IFD * ifd); static unsigned IFD_Towitoko_NumTrials (BYTE b); static void IFD_Towitoko_Clear (IFD * ifd); /* * Exported functions definition */ IFD * IFD_Towitoko_New () { IFD *ifd; ifd = (IFD *) malloc (sizeof (IFD)); if (ifd != NULL) IFD_Towitoko_Clear (ifd); return ifd; } void IFD_Towitoko_Delete (IFD * ifd) { free (ifd); } int IFD_Towitoko_Init (IFD * ifd, IO_Serial * io, BYTE slot) { IO_Serial_Properties props; int ret; #ifdef DEBUG_IFD printf ("IFD: Initialicing slot number %d\n", slot); #endif if ((slot != IFD_TOWITOKO_SLOT_A) && (slot != IFD_TOWITOKO_SLOT_B)) return IFD_TOWITOKO_PARAM_ERROR; /* Default serial port settings */ props.input_bitrate = IFD_TOWITOKO_BAUDRATE; props.output_bitrate = IFD_TOWITOKO_BAUDRATE; props.bits = 8; props.parity = IO_SERIAL_PARITY_EVEN; props.stopbits = 2; props.dtr = IO_SERIAL_HIGH; props.rts = IO_SERIAL_HIGH; if (!IO_Serial_SetProperties (io, &props)) return IFD_TOWITOKO_IO_ERROR; /* Default ifd settings */ ifd->io = io; ifd->slot = slot; ifd->type = IFD_TOWITOKO_UNKNOWN; ret = IFD_Towitoko_SetBaudrate (ifd, IFD_TOWITOKO_BAUDRATE); if (ret != IFD_TOWITOKO_OK) { IFD_Towitoko_Clear (ifd); return ret; } ret = IFD_Towitoko_SetParity (ifd, IFD_TOWITOKO_PARITY_EVEN); if (ret != IFD_TOWITOKO_OK) { IFD_Towitoko_Clear (ifd); return ret; } ret = IFD_Towitoko_GetReaderInfo (ifd); if (ret != IFD_TOWITOKO_OK) { IFD_Towitoko_Clear (ifd); return ret; } /* Kartenzwerg settings */ if (ifd->type == IFD_TOWITOKO_KARTENZWERG) { props.input_bitrate = IFD_TOWITOKO_BAUDRATE; props.output_bitrate = IFD_TOWITOKO_BAUDRATE; props.bits = 8; props.dtr = IO_SERIAL_HIGH; props.rts = IO_SERIAL_HIGH; props.parity = IO_SERIAL_PARITY_NONE; props.stopbits = 1; if (!IO_Serial_SetProperties (ifd->io, &props)) { IFD_Towitoko_Clear (ifd); return IFD_TOWITOKO_IO_ERROR; } } return IFD_TOWITOKO_OK; } int IFD_Towitoko_Close (IFD * ifd) { int ret; #ifdef DEBUG_IFD printf ("IFD: Closing slot number %d\n", ifd->slot); #endif ret = IFD_Towitoko_SetLED (ifd, IFD_TOWITOKO_LED_OFF); if (ret != IFD_TOWITOKO_OK) return ret; IFD_Towitoko_Clear (ifd); return IFD_TOWITOKO_OK; } int IFD_Towitoko_SetBaudrate (IFD * ifd, unsigned long baudrate) { BYTE status[1]; BYTE buffer[6] = { 0x6E, 0x00, 0x00, 0x00, 0x08, 0x00}; IO_Serial_Properties props; #ifdef HAVE_NANOSLEEP struct timespec req_ts; #endif if (IFD_Towitoko_GetMaxBaudrate (ifd) < baudrate) { #ifdef DEBUG_IFD printf ("IFD: Tried to set unsupported baudrate: %lu", baudrate); #endif return IFD_TOWITOKO_PARAM_ERROR; } #ifdef DEBUG_IFD printf ("IFD: Setting baudrate to %lu\n", baudrate); #endif /* Get current settings */ if (!IO_Serial_GetProperties (ifd->io, &props)) return IFD_TOWITOKO_IO_ERROR; if (props.output_bitrate == baudrate) return IFD_TOWITOKO_OK; #if 1 /* Convert baudrate to a quantum magnitude */ if (baudrate <= 1200) { buffer[1] = 0x60; buffer[3] = 0x07; } else if (baudrate <= 2400) { buffer[1] = 0x2E; buffer[3] = 0x03; } else if (baudrate <= 4800) { buffer[1] = 0x17; buffer[3] = 0x05; } else if (baudrate <= 6975) { buffer[1] = 0x0F; buffer[3] = 0x01; } else if (baudrate <= 9600) { buffer[1] = 0x0B; buffer[3] = 0x02; } else if (baudrate <= 14400) { buffer[1] = 0x07; buffer[3] = 0x01; } else if (baudrate <= 19200) { buffer[1] = 0x05; buffer[3] = 0x02; } else if (baudrate <= 28800) { buffer[1] = 0x03; buffer[3] = 0x00; } else if (baudrate <= 38400) { buffer[1] = 0x02; buffer[3] = 0x00; } else if (baudrate <= 57600) { buffer[1] = 0x01; buffer[3] = 0x00; } else if (baudrate <= 115200L) { buffer[1] = 0x80; buffer[3] = 0x00; } else return IFD_TOWITOKO_PARAM_ERROR; buffer[2] = buffer[1] ^ 0x5D; IFD_Towitoko_PrepareCommand (ifd, buffer, 6); /* Set ifd baudrate requested */ if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 6, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; #endif /* Set serial device bitrate */ props.output_bitrate = baudrate; props.input_bitrate = baudrate; if (!IO_Serial_SetProperties (ifd->io, &props)) return IFD_TOWITOKO_IO_ERROR; /* Delay 150 ms until CHIPDRIVE is ready */ #ifdef HAVE_NANOSLEEP req_ts.tv_sec = 0; req_ts.tv_nsec = 150000000L; nanosleep (&req_ts, NULL); #else usleep (150000L); #endif return IFD_TOWITOKO_OK; } int IFD_Towitoko_GetBaudrate (IFD * ifd, unsigned long *baudrate) { IO_Serial_Properties props; /* Get current settings */ if (!IO_Serial_GetProperties (ifd->io, &props)) return IFD_TOWITOKO_IO_ERROR; (*baudrate) = props.output_bitrate; return IFD_TOWITOKO_OK; } extern int IFD_Towitoko_SetParity (IFD * ifd, BYTE parity) { BYTE buffer[5] = { 0x6F, 0x00, 0x6A, 0x0F, 0x00 }; BYTE status[1]; IO_Serial_Properties props; if (ifd->type == IFD_TOWITOKO_KARTENZWERG) return IFD_TOWITOKO_UNSUPPORTED; #ifdef DEBUG_IFD printf ("IFD: Parity = %s\n", parity == IFD_TOWITOKO_PARITY_ODD ? "Odd" : parity == IFD_TOWITOKO_PARITY_EVEN ? "Even" : "Invalid"); #endif if ((parity != IFD_TOWITOKO_PARITY_EVEN) && (parity != IFD_TOWITOKO_PARITY_ODD)) return IFD_TOWITOKO_PARAM_ERROR; /* Get current settings */ if (!IO_Serial_GetProperties (ifd->io, &props)) return IFD_TOWITOKO_IO_ERROR; /* Set serial device parity to even */ if (props.parity == IO_SERIAL_PARITY_ODD) { props.parity = IO_SERIAL_PARITY_EVEN; if (!IO_Serial_SetProperties (ifd->io, &props)) return IFD_TOWITOKO_IO_ERROR; } /* Set ifd parity as requested */ buffer[1] = parity; IFD_Towitoko_PrepareCommand (ifd, buffer, 5); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 5, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; /* if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; */ /* Set serial device parity */ if ((parity == IFD_TOWITOKO_PARITY_ODD) && (props.parity == IO_SERIAL_PARITY_EVEN)) { props.parity = IO_SERIAL_PARITY_ODD; if (!IO_Serial_SetProperties (ifd->io, &props)) return IFD_TOWITOKO_IO_ERROR; } return IFD_TOWITOKO_OK; } int IFD_Towitoko_SetLED (IFD * ifd, BYTE color) { BYTE status[1]; BYTE buffer[5] = { 0x6F, 0x00, 0x6A, 0x0F, 0x00 }; #ifdef DEBUG_IFD printf ("IFD: LED = %s\n", color == IFD_TOWITOKO_LED_RED ? "Red" : color == IFD_TOWITOKO_LED_GREEN ? "Green" : color == IFD_TOWITOKO_LED_YELLOW ? "Yellow" : color == IFD_TOWITOKO_LED_OFF ? "Off" : "Invalid Color"); #endif if ((color != IFD_TOWITOKO_LED_RED) && (color != IFD_TOWITOKO_LED_GREEN) && (color != IFD_TOWITOKO_LED_YELLOW) && (color != IFD_TOWITOKO_LED_OFF)) return IFD_TOWITOKO_PARAM_ERROR; buffer[1] = color; IFD_Towitoko_PrepareCommand (ifd, buffer, 5); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 5, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; return IFD_TOWITOKO_OK; } int IFD_Towitoko_GetStatus (IFD * ifd, BYTE * result) { BYTE buffer[2] = { 0x03, 0x07 }; BYTE status[2]; IFD_Towitoko_PrepareCommand (ifd, buffer, 2); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 2, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 2, status)) { /* * First read can exceed timeout if card has just * been inserted or removed */ IFD_Towitoko_PrepareCommand (ifd, buffer, 2); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 2, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 2, status)) return IFD_TOWITOKO_IO_ERROR; } (*result) = status[0]; #ifdef DEBUG_IFD printf ("IFD: Status = %s / %s\n", IFD_TOWITOKO_CARD(status[0])? "card": "no card", IFD_TOWITOKO_CHANGE(status[0])? "change": "no change"); #endif return IFD_TOWITOKO_OK; } int IFD_Towitoko_ActivateICC (IFD * ifd) { BYTE status[1]; BYTE buffer[3] = { 0x60, 0x0F, 0x9C }; IFD_Towitoko_PrepareCommand (ifd, buffer, 3); #ifdef DEBUG_IFD printf ("IFD: Activating card\n"); #endif if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 3, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; return IFD_TOWITOKO_OK; } int IFD_Towitoko_DeactivateICC (IFD * ifd) { BYTE status[1]; BYTE buffer[3] = { 0x61, 0x0F, 0x98 }; IFD_Towitoko_PrepareCommand (ifd, buffer, 3); #ifdef DEBUG_IFD printf ("IFD: Deactivating card\n"); #endif if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 3, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; return IFD_TOWITOKO_OK; } int IFD_Towitoko_ResetAsyncICC (IFD * ifd, ATR ** atr) { BYTE buffer1[5] = { 0x80, 0x6F, 0x00, 0x05, 0x76 }; BYTE buffer2[5] = { 0xA0, 0x6F, 0x00, 0x05, 0x74 }; #ifndef IFD_TOWITOKO_STRICT_ATR_CHECK BYTE atr_buffer[ATR_MAX_SIZE]; unsigned atr_length; #endif int i, parity, ret; if (ifd->type == IFD_TOWITOKO_KARTENZWERG) return IFD_TOWITOKO_UNSUPPORTED; buffer1[4] = IFD_Towitoko_Checksum (buffer1, 4, ifd->slot); buffer2[4] = IFD_Towitoko_Checksum (buffer2, 4, ifd->slot); #ifdef DEBUG_IFD printf ("IFD: Resetting card:\n"); #endif #ifndef IFD_TOWITOKO_CONVENTION_INVERSE parity = IFD_TOWITOKO_PARITY_EVEN; #else parity = IFD_TOWITOKO_PARITY_ODD; ret = IFD_Towitoko_SetParity (ifd, parity); if (ret != IFD_TOWITOKO_OK) return ret; #endif ret = IFD_TOWITOKO_IO_ERROR; do { for (i = 0; i < 2; i++) { /* Try active-low reset */ if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 5, buffer2)) break; (*atr) = ATR_New (); #ifndef IFD_TOWITOKO_STRICT_ATR_CHECK /* Read form input until it returns timeout */ for (atr_length = 0; atr_length < ATR_MAX_SIZE; atr_length++) { if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_ATR_TIMEOUT, 1, atr_buffer + atr_length)) break; } if (atr_length >= IFD_TOWITOKO_ATR_MIN_LENGTH) { /* Try to parse the ATR */ ATR_InitFromArray ((*atr), atr_buffer, atr_length + 1); ret = IFD_TOWITOKO_OK; break; } #else if (ATR_InitFromStream ((*atr), ifd->io, IFD_TOWITOKO_ATR_TIMEOUT) == ATR_OK) { ret = IFD_TOWITOKO_OK; break; } #endif ATR_Delete (*atr); (*atr) = NULL; /* Try active-high reset */ if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 5, buffer1)) break; (*atr) = ATR_New (); #ifndef IFD_TOWITOKO_STRICT_ATR_CHECK /* Read form input until it returns timeout */ for (atr_length = 0; atr_length < ATR_MAX_SIZE; atr_length++) { if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_ATR_TIMEOUT, 1, atr_buffer + atr_length)) break; } if (atr_length >= IFD_TOWITOKO_ATR_MIN_LENGTH) { /* Try to parse the ATR */ ATR_InitFromArray ((*atr), atr_buffer, atr_length + 1); ret = IFD_TOWITOKO_OK; break; } #else if (ATR_InitFromStream ((*atr), ifd->io, IFD_TOWITOKO_ATR_TIMEOUT) == ATR_OK) { ret = IFD_TOWITOKO_OK; break; } #endif ATR_Delete (*atr); (*atr) = NULL; } /* Succesfully retrive ATR */ if (ret == IFD_TOWITOKO_OK) { if (parity == IFD_TOWITOKO_PARITY_ODD) { parity = IFD_TOWITOKO_PARITY_EVEN; ret = IFD_Towitoko_SetParity (ifd, parity); } } /* Switch parity */ else { #ifndef IFD_TOWITOKO_CONVENTION_DIRECT parity = ((parity == IFD_TOWITOKO_PARITY_EVEN) ? IFD_TOWITOKO_PARITY_ODD : IFD_TOWITOKO_PARITY_EVEN); IFD_Towitoko_SetParity (ifd, parity); #endif } } while (parity != IFD_TOWITOKO_PARITY_EVEN); return ret; } int IFD_Towitoko_Transmit (IFD * ifd, IFD_Timings * timings, unsigned size, BYTE * buffer) { BYTE header[6] = {0x6F, 0x00, 0x05, 0x00, 0xFE, 0xF8}; unsigned block_delay, char_delay, sent=0, to_send = 0; IO_Serial_Properties props; bool s = FALSE; if (ifd->type == IFD_TOWITOKO_KARTENZWERG) return IFD_TOWITOKO_UNSUPPORTED; #ifdef DEBUG_IFD printf ("IFD: Transmit: "); for (sent = 0; sent < size; sent++) printf ("%X ", buffer[sent]); printf ("\n"); #endif /* Get current baudrate */ if (!IO_Serial_GetProperties (ifd->io, &props)) return IFD_TOWITOKO_IO_ERROR; s = (props.output_bitrate > IFD_TOWITOKO_BAUDRATE); /* Calculate delays */ char_delay = IFD_TOWITOKO_DELAY + timings->char_delay; block_delay = IFD_TOWITOKO_DELAY + timings->block_delay; for (sent = 0; sent < size; sent = sent + to_send) { /* Calculate number of bytes to send */ to_send = MIN(size, IFD_TOWITOKO_MAX_TRANSMIT); /* Send header */ header[1] = (BYTE) to_send; IFD_Towitoko_PrepareCommand (ifd, header, 4); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, (s?6:4), header)) return IFD_TOWITOKO_IO_ERROR; /* Send data */ if ((sent == 0) && (block_delay != char_delay)) { if (!IO_Serial_Write (ifd->io, block_delay, 1, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Write (ifd->io, char_delay, to_send-1, buffer+1)) return IFD_TOWITOKO_IO_ERROR; } else { if (!IO_Serial_Write (ifd->io, char_delay, to_send, buffer+sent)) return IFD_TOWITOKO_IO_ERROR; } } return IFD_TOWITOKO_OK; } int IFD_Towitoko_Receive (IFD * ifd, IFD_Timings * timings, unsigned size, BYTE * buffer) { unsigned char_timeout, block_timeout; #ifdef DEBUG_IFD int i; #endif if (ifd->type == IFD_TOWITOKO_KARTENZWERG) return IFD_TOWITOKO_UNSUPPORTED; /* Calculate timeouts */ char_timeout = IFD_TOWITOKO_TIMEOUT + timings->char_timeout; block_timeout = IFD_TOWITOKO_TIMEOUT + timings->block_timeout; if (block_timeout != char_timeout) { /* Read first byte using block timeout */ if (!IO_Serial_Read (ifd->io, block_timeout, 1, buffer)) return IFD_TOWITOKO_IO_ERROR; if (size > 1) { /* Read remaining data bytes using char timeout */ if (!IO_Serial_Read (ifd->io, char_timeout, size - 1, buffer + 1)) return IFD_TOWITOKO_IO_ERROR; } } else { /* Read all data bytes with the same timeout */ if (!IO_Serial_Read (ifd->io, char_timeout, size, buffer)) return IFD_TOWITOKO_IO_ERROR; } #ifdef DEBUG_IFD printf ("IFD: Receive: "); for (i = 0; i < size; i++) printf ("%X ", buffer[i]); printf ("\n"); #endif return IFD_TOWITOKO_OK; } int IFD_Towitoko_Switch (IFD * ifd) { IO_Serial_Properties props; BYTE buffer[1] = {0xF8}; if (!IO_Serial_GetProperties (ifd->io, &props)) return IFD_TOWITOKO_IO_ERROR; if (props.output_bitrate > IFD_TOWITOKO_BAUDRATE) { if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 1, buffer)) return IFD_TOWITOKO_IO_ERROR; #ifdef DEBUG_IFD printf ("IFD: Switching\n"); #endif } return IFD_TOWITOKO_OK; } extern int IFD_Towitoko_ResetSyncICC (IFD * ifd, ATR_Sync ** atr) { BYTE buffer[5] = {0x70, 0x80, 0x62, 0x0F, 0x00}; BYTE atr_buffer[8], status[1]; IFD_Towitoko_PrepareCommand (ifd, buffer, 5); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 5, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; if (IFD_Towitoko_ReadBuffer (ifd, 8, atr_buffer) != IFD_TOWITOKO_OK) return IFD_TOWITOKO_IO_ERROR; if (atr_buffer[0] != 0xFF) { (*atr) = ATR_Sync_New (); if ((*atr) != NULL) ATR_Sync_Init ((*atr), atr_buffer, ATR_SYNC_SIZE); } else (*atr) = NULL; return IFD_TOWITOKO_OK; } int IFD_Towitoko_SetReadAddress (IFD * ifd, int icc_type, unsigned short address) { BYTE status[1]; BYTE i2cShort[10] = { 0x7C, 0x64, 0x41, 0x00, 0x00, 0x64, 0x40, 0x00, 0x0F, 0x00 }; BYTE i2cLong[11] = { 0x7C, 0x64, 0x42, 0xA0, 0x00, 0x00, 0x64, 0x40, 0xA1, 0x0F, 0x00 }; BYTE w2[9] = { 0x70, 0x64, 0x42, 0x30, 0x00, 0x00, 0x65, 0x0F, 0x00 }; BYTE w3[10] = { 0x70, 0xA0, 0x42, 0x00, 0x00, 0x00, 0x80, 0x50, 0x0F, 0x00 }; if (icc_type == IFD_TOWITOKO_I2C_SHORT) { #ifdef DEBUG_IFD printf ("IFD: I2C short set read address: %d\n", address); #endif i2cShort[3] = (HI (address) << 1) | 0xA0; i2cShort[4] = LO (address); i2cShort[7] = (HI (address) << 1) | 0xA0 | 0x01; IFD_Towitoko_PrepareCommand (ifd, i2cShort, 10); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 10, i2cShort)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else if (icc_type == IFD_TOWITOKO_I2C_LONG) { #ifdef DEBUG_IFD printf ("IFD: I2C long set read address: %d\n", address); #endif i2cLong[4] = HI (address); i2cLong[5] = LO (address); IFD_Towitoko_PrepareCommand (ifd, i2cLong, 11); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 11, i2cLong)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else if (icc_type == IFD_TOWITOKO_2W) { #ifdef DEBUG_IFD printf ("IFD: 2W set read address: %d\n", address); #endif w2[4] = LO (address); IFD_Towitoko_PrepareCommand (ifd, w2, 9); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 9, w2)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else if (icc_type == IFD_TOWITOKO_3W) { #ifdef DEBUG_IFD printf ("IFD: 3W set read address: %d\n", address); #endif w3[3] = (HI (address) << 6) | 0x0E; w3[4] = LO (address); IFD_Towitoko_PrepareCommand (ifd, w3, 10); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 10, w3)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else return IFD_TOWITOKO_PARAM_ERROR; return IFD_TOWITOKO_OK; } int IFD_Towitoko_SetWriteAddress (IFD * ifd, int icc_type, unsigned short address, BYTE pagemode) { BYTE i2cShort1[10] = { 0x7C, 0x64, 0x41, 0xA0, 0x00, 0x64, 0x40, 0xA1, 0x0F, 0x36 }; BYTE i2cShort2[3] = { 0x7E, 0x10, 0xDA }; BYTE i2cShort3[8] = { 0x7E, 0x66, 0x6E, 0x00, 0x00, 0x10, 0x0F, 0x00 }; BYTE i2cLong1[11] = { 0x7C, 0x64, 0x42, 0xA0, 0x00, 0x00, 0x64, 0x40, 0xA1, 0x0F, 0x0B }; BYTE i2cLong2[3] = { 0x7E, 0x10, 0xDA }; BYTE i2cLong3[8] = { 0x7F, 0x66, 0x6E, 0x00, 0x00, 0xA0, 0x0F, 0x00 }; BYTE w2[7] = { 0x72, 0x6E, 0x00, 0x38, 0x03, 0x0F, 0x00 }; BYTE w3[8] = { 0x73, 0x67, 0x6E, 0x00, 0x00, 0x02, 0x0F, 0x5F }; BYTE status[2]; if (icc_type == IFD_TOWITOKO_I2C_SHORT) { #ifdef DEBUG_IFD printf ("IFD: I2C short set write address: %d\n", address); #endif IFD_Towitoko_PrepareCommand (ifd, i2cShort1, 10); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 10, i2cShort1)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; IFD_Towitoko_PrepareCommand (ifd, i2cShort2, 3); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 3, i2cShort2)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 2, status)) return IFD_TOWITOKO_IO_ERROR; i2cShort3[3] = LO (address); i2cShort3[4] = (HI (address) << 1) | 0xA0; i2cShort3[5] = pagemode; IFD_Towitoko_PrepareCommand (ifd, i2cShort3, 8); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 8, i2cShort3)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else if (icc_type == IFD_TOWITOKO_I2C_LONG) { #ifdef DEBUG_IFD printf ("IFD: I2C long set write address: %d\n", address); #endif IFD_Towitoko_PrepareCommand (ifd, i2cLong1, 11); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 11, i2cLong1)) return IFD_TOWITOKO_CHK_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; IFD_Towitoko_PrepareCommand (ifd, i2cLong2, 3); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 3, i2cLong2)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 2, status)) return IFD_TOWITOKO_IO_ERROR; i2cLong3[3] = LO (address); i2cLong3[4] = HI (address); IFD_Towitoko_PrepareCommand (ifd, i2cLong3, 8); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 8, i2cLong3)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else if (icc_type == IFD_TOWITOKO_2W) { #ifdef DEBUG_IFD printf ("IFD: 2W set write address: %d\n", address); #endif w2[2] = LO (address); IFD_Towitoko_PrepareCommand (ifd, w2, 7); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 7, w2)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else if (icc_type == IFD_TOWITOKO_3W) { #ifdef DEBUG_IFD printf ("IFD: 3W set write address: %d\n", address); #endif w3[3] = LO (address); w3[4] = (HI (address) << 6) | 0x33; IFD_Towitoko_PrepareCommand (ifd, w3, 8); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 8, w3)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else return IFD_TOWITOKO_PARAM_ERROR; return IFD_TOWITOKO_OK; } int IFD_Towitoko_ReadBuffer (IFD * ifd, unsigned length, BYTE * data) { BYTE buffer[2], status[1]; unsigned blocks_length, pointer; buffer[0] = ((BYTE) (IFD_TOWITOKO_PS - 1)) | 0x10; blocks_length = (length / IFD_TOWITOKO_PS) * IFD_TOWITOKO_PS; for (pointer = 0; pointer < blocks_length; pointer += IFD_TOWITOKO_PS) { IFD_Towitoko_PrepareCommand (ifd, buffer, 2); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 2, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, IFD_TOWITOKO_PS, data + pointer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; } if ((length % IFD_TOWITOKO_PS) != 0) { buffer[0] = ((BYTE) ((length % IFD_TOWITOKO_PS) - 1)) | 0x10; IFD_Towitoko_PrepareCommand (ifd, buffer, 2); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 2, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, length % IFD_TOWITOKO_PS, data + pointer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; } #ifdef DEBUG_IFD printf ("IFD: Read Memory: "); for (pointer = 0; pointer < length; pointer++) printf ("%X ", data[pointer]); printf ("\n"); #endif return IFD_TOWITOKO_OK; } int IFD_Towitoko_WriteBuffer (IFD * ifd, unsigned length, BYTE * data) { BYTE buffer[IFD_TOWITOKO_PS + 2], status[1]; unsigned blocks_length, remaining_length, pointer; buffer[0] = 0x4E; blocks_length = (length / IFD_TOWITOKO_PS) * IFD_TOWITOKO_PS; for (pointer = 0; pointer < blocks_length; pointer += IFD_TOWITOKO_PS) { memcpy (buffer + 1, data + pointer, IFD_TOWITOKO_PS); IFD_Towitoko_PrepareCommand (ifd, buffer, IFD_TOWITOKO_PS + 2); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, IFD_TOWITOKO_PS + 2, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } remaining_length = length % IFD_TOWITOKO_PS; if (remaining_length != 0) { buffer[0] = ((BYTE) ((remaining_length) - 1)) | 0x40; memcpy (buffer + 1, data + pointer, remaining_length); buffer[remaining_length + 1] = 0x0F; IFD_Towitoko_PrepareCommand (ifd, buffer, remaining_length + 3); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, remaining_length + 3, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } #ifdef DEBUG_IFD printf ("IFD: Write Memory: "); for (pointer = 0; pointer < length; pointer++) printf ("%X ", data[pointer]); printf ("\n"); #endif return IFD_TOWITOKO_OK; } int IFD_Towitoko_ReadErrorCounter (IFD * ifd, int icc_type, unsigned *trials) { BYTE w21[9] = { 0x70, 0x64, 0x42, 0x31, 0x00, 0x00, 0x65, 0x0F, 0x80 }; BYTE w22[2] = { 0x13, 0x27 }; BYTE w31[10] = { 0x70, 0xA0, 0x42, 0xCE, 0xFD, 0xFD, 0x80, 0x50, 0x0F, 0x17 }; BYTE w32[2] = { 0x10, 0x21 }; BYTE status[5]; if (icc_type == IFD_TOWITOKO_2W) { IFD_Towitoko_PrepareCommand (ifd, w21, 9); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 9, w21)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; IFD_Towitoko_PrepareCommand (ifd, w22, 2); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 2, w22)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 5, status)) return IFD_TOWITOKO_IO_ERROR; (*trials) = IFD_Towitoko_NumTrials (status[0]); #ifdef DEBUG_IFD printf ("IFD: Read Error Counter 2W: %d\n", *trials); #endif } else if (icc_type == IFD_TOWITOKO_3W) { IFD_Towitoko_PrepareCommand (ifd, w31, 10); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 10, w31)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; IFD_Towitoko_PrepareCommand (ifd, w32, 2); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 2, w32)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 2, status)) return IFD_TOWITOKO_IO_ERROR; (*trials) = IFD_Towitoko_NumTrials (status[0]); #ifdef DEBUG_IFD printf ("IFD: Read Error Counter 3W: %d\n", *trials); #endif } return IFD_TOWITOKO_OK; } int IFD_Towitoko_EnterPin (IFD * ifd, int icc_type, BYTE * pin, unsigned trial) { BYTE w21[7] = { 0x72, 0x6E, 0x00, 0x39, 0x03, 0x0F, 0xB5 }; BYTE w22[4] = { 0x40, 0x00, 0x0F, 0x00 }; BYTE w23[6] = { 0x42, 0x00, 0x00, 0x00, 0x0F, 0x00 }; BYTE w31[8] = { 0x73, 0x67, 0x6E, 0xFD, 0xF2, 0x02, 0x0F, 0x8C }; BYTE w32[4] = { 0x40, 0x00, 0x0F, 0x00 }; BYTE status[1]; if (icc_type == IFD_TOWITOKO_2W) { #ifdef DEBUG_IFD printf ("IFD: 2W enter pin: %X %X %X\n", pin[0], pin[1], pin[2]); #endif IFD_Towitoko_PrepareCommand (ifd, w21, 7); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 7, w21)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w22[1] = (trial == 3) ? 0x06 : (trial == 2) ? 0x04 : 0x00; IFD_Towitoko_PrepareCommand (ifd, w22, 4); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 4, w22)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w21[2] = 0x01; w21[3] = 0x33; IFD_Towitoko_PrepareCommand (ifd, w21, 7); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 7, w21)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; memcpy (w23 + 1, pin, IFD_TOWITOKO_PIN_SIZE); IFD_Towitoko_PrepareCommand (ifd, w23, 6); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 6, w23)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; w21[2] = 0x00; w21[3] = 0x39; IFD_Towitoko_PrepareCommand (ifd, w21, 7); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 7, w21)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w22[1] = 0xFF; IFD_Towitoko_PrepareCommand (ifd, w22, 4); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 4, w22)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else if (icc_type == IFD_TOWITOKO_3W) { #ifdef DEBUG_IFD printf ("IFD: 3W enter pin: %X %X\n", pin[0], pin[1]); #endif IFD_Towitoko_PrepareCommand (ifd, w31, 8); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 8, w31)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w32[1] = (trial == 8) ? 0xFE : (trial == 7) ? 0xFC : (trial == 6) ? 0xF8 : (trial == 5) ? 0xF0 : (trial == 4) ? 0xE0 : (trial == 3) ? 0xC0 : (trial == 2) ? 0x80 : 0x00; IFD_Towitoko_PrepareCommand (ifd, w32, 4); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 4, w32)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w31[3] = 0xFE; w31[4] = 0xCD; IFD_Towitoko_PrepareCommand (ifd, w31, 8); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 8, w31)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w32[1] = pin[0]; IFD_Towitoko_PrepareCommand (ifd, w32, 4); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 4, w32)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w31[3] = 0xFF; IFD_Towitoko_PrepareCommand (ifd, w31, 8); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 8, w31)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w32[1] = pin[1]; IFD_Towitoko_PrepareCommand (ifd, w32, 4); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 4, w32)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w31[3] = 0xFD; w31[4] = 0xF3; IFD_Towitoko_PrepareCommand (ifd, w31, 8); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 8, w31)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w32[1] = 0xFF; IFD_Towitoko_PrepareCommand (ifd, w32, 4); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 4, w32)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else return IFD_TOWITOKO_PARAM_ERROR; return IFD_TOWITOKO_OK; } int IFD_Towitoko_ChangePin (IFD * ifd, int icc_type, BYTE * pin) { BYTE w21[7] = { 0x72, 0x6E, 0x01, 0x39, 0x03, 0x0F, 0xA5 }; BYTE w22[6] = { 0x42, 0x00, 0x00, 0x00, 0x0F, 0x00 }; BYTE w31[8] = { 0x73, 0x67, 0x6E, 0xFE, 0xF3, 0x02, 0x0F, 0xB4 }; BYTE w32[4] = { 0x40, 0x00, 0x0F, 0x00 }; BYTE status[1]; if (icc_type == IFD_TOWITOKO_2W) { #ifdef DEBUG_IFD printf ("IFD: 2W change pin: %X %X %X\n", pin[0], pin[1], pin[2]); #endif IFD_Towitoko_PrepareCommand (ifd, w21, 7); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 7, w21)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w22[1] = pin[0]; w22[2] = pin[1]; w22[3] = pin[2]; IFD_Towitoko_PrepareCommand (ifd, w22, 6); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 6, w22)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else if (icc_type == IFD_TOWITOKO_3W) { #ifdef DEBUG_IFD printf ("IFD: 3W change pin: %X %X\n", pin[0], pin[1]); #endif IFD_Towitoko_PrepareCommand (ifd, w31, 8); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 8, w31)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w32[1] = pin[0]; IFD_Towitoko_PrepareCommand (ifd, w32, 4); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 4, w32)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w31[3] = 0xFF; IFD_Towitoko_PrepareCommand (ifd, w31, 8); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 8, w31)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; w32[1] = pin[1]; IFD_Towitoko_PrepareCommand (ifd, w32, 4); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 4, w32)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 1, status)) return IFD_TOWITOKO_IO_ERROR; if (status[0] != 0x01) return IFD_TOWITOKO_CHK_ERROR; } else return IFD_TOWITOKO_PARAM_ERROR; return IFD_TOWITOKO_OK; } BYTE IFD_Towitoko_GetType (IFD * ifd) { return ifd->type; } void IFD_Towitoko_GetDescription (IFD * ifd, BYTE * desc, unsigned length) { char buffer[3]; if (ifd->type == IFD_TOWITOKO_CHIPDRIVE_EXT_II) memcpy (desc,"CE2",MIN(length,3)); else if (ifd->type == IFD_TOWITOKO_CHIPDRIVE_EXT_I) memcpy (desc,"CE1",MIN(length,3)); else if (ifd->type == IFD_TOWITOKO_CHIPDRIVE_INT) memcpy (desc,"CDI",MIN(length,3)); else if (ifd->type == IFD_TOWITOKO_CHIPDRIVE_MICRO) memcpy (desc,"CDM",MIN(length,3)); else if (ifd->type == IFD_TOWITOKO_KARTENZWERG_II) memcpy (desc,"KZ2",MIN(length,3)); else if (ifd->type == IFD_TOWITOKO_KARTENZWERG) memcpy (desc,"KZ1",MIN(length,3)); else memcpy (desc,"UNK",MIN(length,3)); snprintf (buffer, 3, "%02X", ifd->firmware); if (length > 3) memcpy (desc+3, buffer, MIN(length-3,2)); } BYTE IFD_Towitoko_GetFirmware (IFD * ifd) { return ifd->firmware; } BYTE IFD_Towitoko_GetSlot (IFD * ifd) { return ifd->slot; } unsigned IFD_Towitoko_GetNumSlots (IFD * ifd) { if (ifd->type == IFD_TOWITOKO_CHIPDRIVE_EXT_II) return 2; return 1; } unsigned long IFD_Towitoko_GetClockRate (IFD * ifd) { return IFD_TOWITOKO_CLOCK_RATE; } unsigned long IFD_Towitoko_GetMaxBaudrate (IFD * ifd) { return 115200L; } /* * Not exported funcions definition */ static int IFD_Towitoko_PrepareCommand (IFD * ifd, BYTE * command, BYTE size) { IO_Serial_Properties props; BYTE buffer[1], initial; if (!IO_Serial_GetProperties (ifd->io, &props)) return IFD_TOWITOKO_IO_ERROR; if (props.output_bitrate >= 115200L) { buffer[0] = size - 1; if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 1, buffer)) return IFD_TOWITOKO_IO_ERROR; initial = IFD_Towitoko_Checksum(buffer, 1, ifd->slot); } else initial = ifd->slot; command[size-1] = IFD_Towitoko_Checksum(command, size-1, initial); return IFD_TOWITOKO_OK; } static BYTE IFD_Towitoko_Checksum (BYTE * command, unsigned size, BYTE initial) { BYTE checksum, x7; unsigned i; checksum = initial; for (i = 0; i < size; i++) { checksum = checksum ^ command[i]; x7 = (checksum & 0x80) >> 7; checksum = checksum << 1; checksum = !x7 == 0x01 ? checksum | 0x01 : checksum & 0xFE; } return checksum; } static int IFD_Towitoko_GetReaderInfo (IFD * ifd) { BYTE status[3]; BYTE buffer[2] = { 0x00, 0x01}; buffer[1] = IFD_Towitoko_Checksum (buffer, 1, ifd->slot); if (!IO_Serial_Write (ifd->io, IFD_TOWITOKO_DELAY, 2, buffer)) return IFD_TOWITOKO_IO_ERROR; if (!IO_Serial_Read (ifd->io, IFD_TOWITOKO_TIMEOUT, 3, status)) return IFD_TOWITOKO_IO_ERROR; ifd->type = status[0]; ifd->firmware = status[1]; #ifdef DEBUG_IFD printf ("IFD: Reader type = %s\n", status[0] == IFD_TOWITOKO_CHIPDRIVE_EXT_II ? "Chipdrive Extern II" : status[0] == IFD_TOWITOKO_CHIPDRIVE_EXT_I ? "Chipdrive Extern I" : status[0] == IFD_TOWITOKO_CHIPDRIVE_INT ? "Chipdrive Intern" : status[0] == IFD_TOWITOKO_CHIPDRIVE_MICRO ? "Chipdrive Micro" : status[0] == IFD_TOWITOKO_KARTENZWERG_II ? "Kartenzwerg II" : status[0] == IFD_TOWITOKO_KARTENZWERG ? "Kartenzwerg" : "Unknown"); #endif return IFD_TOWITOKO_OK; } static unsigned IFD_Towitoko_NumTrials (BYTE b) { unsigned i, count = 0; for (i = 0; i < 8; i++) { count += ((b & 0x01) == 0x01) ? 1 : 0; b >>= 1; } return count; } static void IFD_Towitoko_Clear (IFD * ifd) { ifd->io = NULL; ifd->slot = 0x00; ifd->type = 0x00; ifd->firmware = 0x00; } towitoko-2.0.7/src/driver/apdu.c0000644000175000017500000001664707521022540012252 /* apdu.c ISO 7816-4 Application Layer PDU's handling This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 2001 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include "apdu.h" #include #include /* * Not exported constants definiton */ #define APDU_MIN_CMD_SIZE 4 /* Min command size */ #define APDU_MIN_RSP_SIZE 2 /* Min response size */ #define APDU_CMD_HEADER_SIZE 4 /* Size of the header */ /* * Exported functions definition */ APDU_Cmd * APDU_Cmd_New (BYTE * data, unsigned long length) { APDU_Cmd *apdu; if ((length > APDU_MAX_CMD_SIZE)) return NULL; apdu = (APDU_Cmd *) malloc (sizeof (APDU_Cmd)); if (apdu != NULL) { apdu->length = MAX (APDU_MIN_CMD_SIZE, length); apdu->command = (BYTE *) calloc (apdu->length, sizeof (BYTE)); if (apdu->command != NULL) { memcpy (apdu->command, data, length); if (length < apdu->length) memset (apdu->command + length, 0, apdu->length - length); } else { free (apdu); apdu = NULL; } } return apdu; } void APDU_Cmd_Delete (APDU_Cmd * apdu) { free (apdu->command); free (apdu); } int APDU_Cmd_Case (APDU_Cmd * apdu) { BYTE B1; unsigned short B2B3; unsigned long L; int res; /* Calculate length of body */ L = MAX(apdu->length - 4, 0); /* Case 1 */ if (L == 0) res = APDU_CASE_1; else { /* Get first byte of body */ B1 = apdu->command[4]; if ((B1 != 0) && (L == B1 + 1)) res = APDU_CASE_2S; else if (L == 1) res = APDU_CASE_3S; else if ((B1 != 0) && (L == B1 + 2)) res = APDU_CASE_4S; else if ((B1 == 0) && (L>2)) { /* Get second and third byte of body */ B2B3 = (((unsigned short)(apdu->command[5]) << 8) | apdu->command[6]); if ((B2B3 != 0) && (L == B2B3 + 3)) res = APDU_CASE_2E; else if (L == 3) res = APDU_CASE_3E; else if ((B2B3 != 0) && (L == B2B3 + 5)) res = APDU_CASE_4E; else res = APDU_MALFORMED; } else res = APDU_MALFORMED; } return res; } BYTE APDU_Cmd_Cla (APDU_Cmd * apdu) { return apdu->command[0]; } BYTE APDU_Cmd_Ins (APDU_Cmd * apdu) { return apdu->command[1]; } BYTE APDU_Cmd_P1 (APDU_Cmd * apdu) { return apdu->command[2]; } BYTE APDU_Cmd_P2 (APDU_Cmd * apdu) { return apdu->command[3]; } unsigned long APDU_Cmd_Lc (APDU_Cmd * apdu) { int c; unsigned long res; c = APDU_Cmd_Case (apdu); if ((c == APDU_CASE_1) || (c == APDU_CASE_3S) || (c == APDU_CASE_3E)) res = 0; else if ((c == APDU_CASE_2S) || (c == APDU_CASE_4S)) res = apdu->command[4]; else if ((c == APDU_CASE_2E) || (c == APDU_CASE_4E)) res = (((unsigned long)(apdu->command[5]) << 8) | apdu->command[6]); else res = 0; return res; } unsigned long APDU_Cmd_Le (APDU_Cmd * apdu) { int c; unsigned long res; c = APDU_Cmd_Case (apdu); if ((c == APDU_CASE_1) || (c == APDU_CASE_2S) || (c == APDU_CASE_2E)) res = 0; else if (c == APDU_CASE_3S) res = ((apdu->command[4] == 0) ? 256: apdu->command[4]); else if (c == APDU_CASE_4S) res = ((apdu->command[apdu->length - 1] == 0) ? 256: apdu->command[apdu->length - 1]); else if (c == APDU_CASE_3E) res = ((((unsigned long)(apdu->command[5]) << 8) | apdu->command[6]) == 0 ? 65536: (((unsigned long)(apdu->command[5]) << 8) | apdu->command[6])); else if (c == APDU_CASE_4E) res = ((((unsigned long)(apdu->command[apdu->length - 2]) << 8) | apdu->command[apdu->length - 1]) == 0 ? 65536: (((unsigned long)(apdu->command[apdu->length - 2]) << 8) | apdu->command[apdu->length - 1])); else res = 0; return res; } bool APDU_Cmd_Le_Available (APDU_Cmd * apdu) { int c; bool res; c = APDU_Cmd_Case (apdu); if (c == APDU_CASE_3S) res = (apdu->command[4] == 0); else if (c == APDU_CASE_4S) res = (apdu->command[apdu->length - 1] == 0); else if (c == APDU_CASE_3E) res = ((((unsigned long)(apdu->command[5]) << 8) | apdu->command[6]) == 0); else if (c == APDU_CASE_4E) res = ((((unsigned long)(apdu->command[apdu->length - 2]) << 8) | apdu->command[apdu->length - 1]) == 0); else res = FALSE; return res; } BYTE * APDU_Cmd_Header (APDU_Cmd * apdu) { return apdu->command; } BYTE * APDU_Cmd_Data (APDU_Cmd * apdu) { int c; BYTE * res; c = APDU_Cmd_Case (apdu); if ((c == APDU_CASE_1) || (c == APDU_CASE_3S) || (c == APDU_CASE_3E)) res = NULL; else if ((c == APDU_CASE_2S) || (c == APDU_CASE_4S)) res = apdu->command + 5; else if ((c == APDU_CASE_2E) || (c == APDU_CASE_4E)) res = apdu->command + 7; else res = NULL; return res; } BYTE * APDU_Cmd_Raw (APDU_Cmd * apdu) { return apdu->command; } unsigned long APDU_Cmd_RawLen (APDU_Cmd * apdu) { return apdu->length; } APDU_Rsp * APDU_Rsp_New (BYTE * data, unsigned long length) { APDU_Rsp *apdu; if (length < APDU_MIN_RSP_SIZE) return NULL; apdu = (APDU_Rsp *) malloc (sizeof (APDU_Rsp)); if (apdu != NULL) { apdu->length = length; apdu->response = (BYTE *) calloc (length, sizeof (BYTE)); if (apdu->response != NULL) memcpy (apdu->response, data, length); else { free (apdu); apdu = NULL; } } return apdu; } void APDU_Rsp_Delete (APDU_Rsp * apdu) { free (apdu->response); free (apdu); } BYTE APDU_Rsp_SW1 (APDU_Rsp * apdu) { return (apdu->response[(apdu->length) - 2]); } BYTE APDU_Rsp_SW2 (APDU_Rsp * apdu) { return (apdu->response[(apdu->length) - 1]); } unsigned long APDU_Rsp_DataLen (APDU_Rsp * apdu) { return (apdu->length - 2); } BYTE * APDU_Rsp_Data (APDU_Rsp * apdu) { return apdu->response; } BYTE * APDU_Rsp_Raw (APDU_Rsp * apdu) { return apdu->response; } unsigned long APDU_Rsp_RawLen (APDU_Rsp * apdu) { return apdu->length; } void APDU_Rsp_TruncateData (APDU_Rsp * apdu, unsigned long length) { if ((length > 0) && ((signed long)length < (signed long)(apdu->length - 2))) { apdu->response[length] = APDU_Rsp_SW1 (apdu); apdu->response[length + 1] = APDU_Rsp_SW2 (apdu); apdu->length = length +2; } } int APDU_Rsp_AppendData (APDU_Rsp * apdu1, APDU_Rsp * apdu2) { BYTE * response; unsigned long length; int ret; length = APDU_Rsp_DataLen(apdu1) + APDU_Rsp_RawLen(apdu2); if ((length > 2) && (length <= APDU_MAX_RSP_SIZE)) { response = (BYTE *) realloc (apdu1->response, length); if (response != NULL) { memcpy (response + APDU_Rsp_DataLen (apdu1), APDU_Rsp_Raw (apdu2), APDU_Rsp_RawLen(apdu2)); apdu1->response = response; apdu1->length = length; ret = APDU_OK; } else ret = APDU_MALFORMED; } else ret = APDU_MALFORMED; return ret; } towitoko-2.0.7/src/driver/icc_sync.c0000644000175000017500000003612607523053540013113 /* icc_sync.c Synchronous ICC's handling functions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "defines.h" #include #include #include #include #include #include "icc_sync.h" /* * Not exported constants definition */ #define ICC_SYNC_MAX_MEMORY 8192 #define ICC_SYNC_MAX_TRANSMIT 256 /* This is the maximum to increase performance without bypassing address counter */ #define ICC_SYNC_I2C_MAX_RETRIES 2 #define ICC_SYNC_I2C_RETRY_TRIGGER 1 #define ICC_SYNC_BAUDRATE 115200L /* * Not exported macros definition */ #define ICC_SYNC_NEEDS_PIN(icc) (((icc)->type == ICC_SYNC_2W || \ (icc)->type == ICC_SYNC_3W) && \ (icc)->pin_needed) #define ICC_SYNC_NEEDS_ACTIVATE(icc) (!(icc)->active) #define ICC_SYNC_NEEDS_DEACTIVATE(icc) ((icc)->type != ICC_SYNC_3W && \ (icc)->active) /* * Not exported functions declaration */ static int ICC_Sync_ProbeCardType (ICC_Sync * icc); static int ICC_Sync_ProbeMemoryLength (ICC_Sync * icc); static int ICC_Sync_ProbePagemode (ICC_Sync * icc); static ATR_Sync * ICC_Sync_CreateAtr(ICC_Sync * icc); static void ICC_Sync_Clear (ICC_Sync * icc); /* * Exported functions definition */ ICC_Sync * ICC_Sync_New (void) { ICC_Sync *icc; /* Allocate memory */ icc = (ICC_Sync *) malloc (sizeof (ICC_Sync)); if (icc != NULL) ICC_Sync_Clear (icc); return icc; } void ICC_Sync_Delete (ICC_Sync * icc) { free (icc); } int ICC_Sync_Init (ICC_Sync * icc, IFD * ifd) { #ifndef ICC_TYPE_ASYNC int ret; /* LED Red */ if (IFD_Towitoko_SetLED (ifd, IFD_TOWITOKO_LED_RED) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; /* Initialize baudrate*/ if (IFD_Towitoko_SetBaudrate (ifd, ICC_SYNC_BAUDRATE) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; /* Activate ICC */ if (IFD_Towitoko_ActivateICC (ifd) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; /* Reset ICC */ if (IFD_Towitoko_ResetSyncICC (ifd, &(icc->atr)) != IFD_TOWITOKO_OK) { icc->atr = NULL; return ICC_SYNC_IFD_ERROR; } /* Intialice member variables */ icc->active = TRUE; icc->baudrate = ICC_SYNC_BAUDRATE; icc->ifd = ifd; icc->pin_ok = FALSE; icc->pin_needed = TRUE; /* Probe Card type */ ret = ICC_Sync_ProbeCardType (icc); if (ret != ICC_SYNC_OK) { ICC_Sync_Clear (icc); return ret; } /* Probe memory length */ ret = ICC_Sync_ProbeMemoryLength (icc); if (ret != ICC_SYNC_OK) { ICC_Sync_Clear (icc); return ret; } /* Probe pagemode */ ret = ICC_Sync_ProbePagemode (icc); if (ret != ICC_SYNC_OK) { ICC_Sync_Clear (icc); return ret; } /* Create fake ATR if card haven't one */ if (icc->atr == NULL) icc->atr = ICC_Sync_CreateAtr (icc); /* LED Green */ if (IFD_Towitoko_SetLED (ifd, IFD_TOWITOKO_LED_GREEN) != IFD_TOWITOKO_OK) { ICC_Sync_Clear (icc); return ICC_SYNC_IFD_ERROR; } if (ICC_SYNC_NEEDS_DEACTIVATE (icc)) { if (IFD_Towitoko_DeactivateICC (icc->ifd) != IFD_TOWITOKO_OK) { ICC_Sync_Clear (icc); return ICC_SYNC_IFD_ERROR; } icc->active = FALSE; } return ICC_SYNC_OK; #else return ICC_SYNC_DETECT_ERROR; #endif } int ICC_Sync_Close (ICC_Sync * icc) { /* Deactivate ICC */ if (IFD_Towitoko_DeactivateICC (icc->ifd) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; /* LED Off */ if (IFD_Towitoko_SetLED (icc->ifd, IFD_TOWITOKO_LED_OFF) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; if (icc->atr != NULL) ATR_Sync_Delete (icc->atr); ICC_Sync_Clear (icc); return ICC_SYNC_OK; } int ICC_Sync_Read (ICC_Sync * icc, unsigned short address, unsigned length, BYTE * data) { /* Re-activate card before reset address counter */ if (ICC_SYNC_NEEDS_ACTIVATE (icc)) { if (IFD_Towitoko_ActivateICC (icc->ifd) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; icc->active = TRUE; } /* Read access */ if (IFD_Towitoko_SetReadAddress (icc->ifd, icc->type, address) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; if (IFD_Towitoko_ReadBuffer (icc->ifd, length, data) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; if (ICC_SYNC_NEEDS_DEACTIVATE (icc)) { if (IFD_Towitoko_DeactivateICC (icc->ifd) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; icc->pin_needed = TRUE; icc->active = FALSE; } return ICC_SYNC_OK; } int ICC_Sync_Write (ICC_Sync * icc, unsigned short address, unsigned length, BYTE * data) { BYTE buffer[ICC_SYNC_MAX_TRANSMIT], mask; unsigned written, to_write, retries, max_retries, trials; int ret; if (length > ICC_SYNC_I2C_RETRY_TRIGGER) { /* At least one retry is needed for writting I2C */ if ((icc->type == ICC_SYNC_I2C_SHORT) || icc->type == (ICC_SYNC_I2C_LONG)) max_retries = ICC_SYNC_I2C_MAX_RETRIES; else max_retries = 1; } else max_retries = 1; /* * Divide data into smaller buffers to: * - Don't bypass low byte of write address counter * - Compare data written and read to see if memory is Read Only * - Retry when first writting fails with I2C cards */ for (written = 0; written < length; written += to_write) { /* See how many bytes can be written to the current page */ mask = icc->pagemode - 0x01; to_write = MIN (MIN (ICC_SYNC_MAX_TRANSMIT, length - written), (((address + written) | mask) + 1) - (address + written)); /* Repeat Until to_write bytes are written or max_retries are reached */ retries = 0; do { /* Re-activate card before reset address */ if (ICC_SYNC_NEEDS_ACTIVATE (icc)) { if (IFD_Towitoko_ActivateICC (icc->ifd) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; icc->active = TRUE; /* 2W cards needs to re-enter PIN */ if (icc->pin_ok && ICC_SYNC_NEEDS_PIN (icc)) { ret = ICC_Sync_EnterPin (icc, icc->pin, &trials); if (ret != ICC_SYNC_OK) return ret; } } /* Write access */ if (IFD_Towitoko_SetWriteAddress (icc->ifd, icc->type, address + written, icc->pagemode) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; if (IFD_Towitoko_WriteBuffer (icc->ifd, to_write, data + written) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; if (ICC_SYNC_NEEDS_DEACTIVATE (icc)) { if (IFD_Towitoko_DeactivateICC (icc->ifd) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; icc->pin_needed = TRUE; icc->active = FALSE; } /* See if the buffer has been written */ ret = ICC_Sync_Read (icc, address + written, to_write, buffer); if (ret != ICC_SYNC_OK) return ret; } while ((memcmp (data + written, buffer, to_write) != 0) && ((++retries) < max_retries)); if (retries == max_retries) return ICC_SYNC_RO_ERROR; if (IFD_Towitoko_GetType (icc->ifd) == IFD_TOWITOKO_CHIPDRIVE_INT) { #ifdef HAVE_NANOSLEEP struct timespec req_ts; req_ts.tv_sec = 0; req_ts.tv_nsec = 90000000; nanosleep (&req_ts, NULL); #else usleep (90000); #endif } } return ICC_SYNC_OK; } int ICC_Sync_EnterPin (ICC_Sync * icc, BYTE * pin, unsigned *trials) { unsigned new_trials; /* See if card needs PIN */ if (icc->type == ICC_SYNC_I2C_LONG || icc->type == ICC_SYNC_I2C_SHORT) return ICC_SYNC_OK; /* 2W ICC's needs to be re-activated before entering PIN */ if (ICC_SYNC_NEEDS_ACTIVATE (icc)) { if (IFD_Towitoko_ActivateICC (icc->ifd) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; icc->active = TRUE; } /* Get error counter and stop if it is exahusted */ if (IFD_Towitoko_ReadErrorCounter (icc->ifd, icc->type, trials) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; if ((*trials) == 0) return ICC_SYNC_BLOCKED_ERROR; /* Enter PIN */ if (IFD_Towitoko_EnterPin (icc->ifd, icc->type, pin, (*trials)) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; /* See if the error counter has maximum value */ if (IFD_Towitoko_ReadErrorCounter (icc->ifd, icc->type, &new_trials) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; if (new_trials < (*trials)) { icc->pin_ok = FALSE; (*trials) = new_trials; return ICC_SYNC_PIN_ERROR; } memcpy (icc->pin, pin, ICC_SYNC_PIN_SIZE); icc->pin_ok = TRUE; icc->pin_needed = FALSE; (*trials) = new_trials; return ICC_SYNC_OK; } int ICC_Sync_ChangePin (ICC_Sync * icc, BYTE * pin) { unsigned trials; int ret; /* See if card needs PIN */ if (icc->type == ICC_SYNC_I2C_LONG || icc->type == ICC_SYNC_I2C_SHORT) return ICC_SYNC_OK; /* Re-activate card */ if (ICC_SYNC_NEEDS_ACTIVATE (icc)) { if (IFD_Towitoko_ActivateICC (icc->ifd) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; icc->active = TRUE; /* 2W cards needs to re-enter PIN */ if (icc->pin_ok && ICC_SYNC_NEEDS_PIN (icc)) { ret = ICC_Sync_EnterPin (icc, icc->pin, &trials); if (ret != ICC_SYNC_OK) return ret; } } /* Change PIN */ if (IFD_Towitoko_ChangePin (icc->ifd, icc->type, pin) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; memcpy (icc->pin, pin, ICC_SYNC_PIN_SIZE); icc->pin_ok = TRUE; icc->pin_needed = FALSE; return ICC_SYNC_OK; } int ICC_Sync_BeginTransmission (ICC_Sync * icc) { /* Setup baudrate for this ICC */ if (IFD_Towitoko_SetBaudrate (icc->ifd, ICC_SYNC_BAUDRATE) != IFD_TOWITOKO_OK) return ICC_SYNC_IFD_ERROR; return ICC_SYNC_OK; } int ICC_Sync_SetBaudrate (ICC_Sync * icc, unsigned long baudrate) { icc->baudrate = baudrate; return ICC_SYNC_OK; } int ICC_Sync_GetBaudrate (ICC_Sync * icc, unsigned long *baudrate) { (*baudrate) = icc->baudrate; return ICC_SYNC_OK; } unsigned ICC_Sync_GetLength (ICC_Sync * icc) { return icc->length; } int ICC_Sync_GetType (ICC_Sync * icc) { return icc->type; } BYTE ICC_Sync_GetPagemode (ICC_Sync * icc) { return icc->pagemode; } IFD * ICC_Sync_GetIFD (ICC_Sync * icc) { return icc->ifd; } ATR_Sync * ICC_Sync_GetAtr (ICC_Sync * icc) { return icc->atr; } /* * Not exported functions definition */ static int ICC_Sync_ProbeCardType (ICC_Sync * icc) { #ifndef ICC_SYNC_MEMORY_TYPE BYTE protocol, status[1], orig[1], modif[1]; int ret; if (icc->atr != NULL) { ret = ICC_SYNC_OK; protocol = ATR_Sync_GetProtocolType(icc->atr); if (protocol == ATR_SYNC_PROTOCOL_TYPE_3W) icc->type = ICC_SYNC_3W; else if (protocol == ATR_SYNC_PROTOCOL_TYPE_2W) icc->type = ICC_SYNC_2W; else if (protocol == ATR_SYNC_PROTOCOL_TYPE_SDA) icc->type = ICC_SYNC_I2C_SHORT; else { ret = ICC_SYNC_DETECT_ERROR; #ifdef DEBUG_ICC printf ("ICC: Detected synchronous card with unknown ATR\n"); #endif } } else { /* Check for I2C (short or long) */ IFD_Towitoko_SetReadAddress (icc->ifd, IFD_TOWITOKO_I2C_SHORT, 0); IFD_Towitoko_GetStatus (icc->ifd, status); IFD_Towitoko_DeactivateICC (icc->ifd); if ((status[0] & 0x10) != 0x10) { /* Check for I2CX card */ icc->type = IFD_TOWITOKO_I2C_SHORT; ICC_Sync_Read (icc, 0, 1, orig); if (orig[0] == 0xFF) modif[0] = 0x01; else if (orig[0] == 0x00) modif[0] = 0xFE; else modif[0] = ~orig[0]; if (ICC_Sync_Write (icc, 0, 1, modif) == ICC_SYNC_OK) ICC_Sync_Write (icc, 0, 1, orig); else icc->type = IFD_TOWITOKO_I2C_LONG; IFD_Towitoko_ActivateICC (icc->ifd); ret = ICC_SYNC_OK; } else ret = ICC_SYNC_DETECT_ERROR; } #ifdef DEBUG_ICC if (ret == ICC_SYNC_OK) printf ("ICC: Detected %s memory card\n", icc->type == 0? "I2C short": icc->type == 1? "I2C long": icc->type == 2? "2-wire bus protocol": icc->type == 3? "3-wire bus protocol": "invalid"); #endif return ret; #else icc->type = ICC_SYNC_MEMORY_TYPE; return ICC_SYNC_OK; #endif } static int ICC_Sync_ProbeMemoryLength (ICC_Sync * icc) { int ret; #ifndef ICC_SYNC_MEMORY_LENGTH unsigned min, max; BYTE status[1]; if (icc->atr != NULL) { icc->length = ATR_Sync_GetNumberOfDataUnits(icc->atr) * ATR_Sync_GetLengthOfDataUnits(icc->atr) / 8; ret = ICC_SYNC_OK; } else { if (icc->type == ICC_SYNC_I2C_SHORT) { min = 256L; max = 2048L; } else if (icc->type == ICC_SYNC_I2C_LONG) { min = 2048L; max = 32768L; } else { min = 256L; max = 2048L; } for (icc->length = min; icc->lengthlength*=2) { IFD_Towitoko_SetReadAddress (icc->ifd, icc->type, icc->length); IFD_Towitoko_GetStatus (icc->ifd, status); IFD_Towitoko_DeactivateICC (icc->ifd); IFD_Towitoko_ActivateICC (icc->ifd); if ((status[0] & 0x10) == 0x10) break; } ret = ICC_SYNC_OK; } #else icc->length = ICC_SYNC_MEMORY_LENGTH; ret = ICC_SYNC_OK; #endif #ifdef DEBUG_ICC printf ("ICC: Memory size = %d\n", icc->length); #endif return ret; } static int ICC_Sync_ProbePagemode (ICC_Sync * icc) { if (icc->type == ICC_SYNC_I2C_LONG) icc->pagemode = 0x40; else icc->pagemode = 0x00; return ICC_SYNC_OK; } static ATR_Sync * ICC_Sync_CreateAtr(ICC_Sync * icc) { ATR_Sync * atr; BYTE atr_buffer[ATR_SYNC_SIZE], protocol; if (icc->atr !=NULL) return icc->atr; protocol = (icc->type==ICC_SYNC_I2C_SHORT)? ATR_SYNC_PROTOCOL_TYPE_SDA: (icc->type==ICC_SYNC_I2C_LONG)? ATR_SYNC_PROTOCOL_TYPE_SDA: (icc->type==ICC_SYNC_2W)? ATR_SYNC_PROTOCOL_TYPE_2W: (icc->type==ICC_SYNC_3W)? ATR_SYNC_PROTOCOL_TYPE_3W: ATR_SYNC_PROTOCOL_TYPE_SDA; atr_buffer[0] = (protocol << 4) | ATR_SYNC_STRUCTURE_ID_GENERAL; atr_buffer[1] = (icc->length == 256L)? 0x13: (icc->length == 512L)? 0x1B: (icc->length == 1024L)? 0x23: (icc->length == 2048L)? 0x2B: (icc->length == 4096L)? 0x33: (icc->length == 8192L)? 0x3B: (icc->length == 16384)? 0x43: (icc->length == 32768)? 0x4B: 0x4B; atr_buffer[2] = 0x10; atr_buffer[3] = 0x84; atr = ATR_Sync_New(); if (atr!=NULL) ATR_Sync_Init (atr, atr_buffer, ATR_SYNC_SIZE); return atr; } static void ICC_Sync_Clear (ICC_Sync * icc) { icc->ifd = NULL; icc->atr = NULL; icc->type = 0; icc->length = 0; icc->pagemode = 0x00; memset (icc->pin, 0, ICC_SYNC_PIN_SIZE); icc->pin_ok = FALSE; icc->pin_needed = FALSE; icc->active = FALSE; icc->baudrate = 0L; } towitoko-2.0.7/src/driver/protocol_sync.c0000644000175000017500000003660307431543175014224 /* protocol_sync.c MCT v0.9 part 7 interindustry command set for synchronous cards This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000, 2001, 2002 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include "defines.h" #include "protocol_sync.h" #include "tlv_object.h" #include #include /* * Not exported constants definition */ /* Selectable Data Section Files */ #define PROTOCOL_SYNC_DS_MF 0x3F00 #define PROTOCOL_SYNC_DS_DIR 0x2F00 #define PROTOCOL_SYNC_DS_ATR 0x2F01 /* Max size of application ID */ #define PROTOCOL_SYNC_AID_SIZE 16 /* * Not exported macros definition */ #define PROTOCOL_SYNC_TLV(icc, address) (TLV_Object_New ((icc), \ Protocol_Sync_GetData, \ ICC_Sync_GetLength (icc), \ (address))) /* * Not exported functions declaration */ static int Protocol_Sync_SelectFile (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_Sync_ReadBinary (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_Sync_UpdateBinary (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_Sync_Verify (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_Sync_ChangeVerifyData (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp); static int Protocol_Sync_BadCommand (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp); static bool Protocol_Sync_GetData (void * data, unsigned short address, unsigned short length, BYTE * buffer); static void Protocol_Sync_Clear (Protocol_Sync * ps); /* * Exported functions definition */ Protocol_Sync * Protocol_Sync_New (void) { Protocol_Sync *ps; ps = (Protocol_Sync *) malloc (sizeof (Protocol_Sync)); if (ps != NULL) Protocol_Sync_Clear (ps); return ps; } int Protocol_Sync_Init (Protocol_Sync * ps, ICC_Sync * icc) { ps->icc = icc; /* Select Master File by default */ ps->path = 0; ps->length = ICC_Sync_GetLength (ps->icc); return PROTOCOL_SYNC_OK; } int Protocol_Sync_Command (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp) { int ret; ICC_Sync_BeginTransmission (ps->icc); /* Interindustry Commands */ switch (APDU_Cmd_Ins (cmd)) { case 0xA4: ret = Protocol_Sync_SelectFile (ps, cmd, rsp); break; case 0xB0: ret = Protocol_Sync_ReadBinary (ps, cmd, rsp); break; case 0xD6: ret = Protocol_Sync_UpdateBinary (ps, cmd, rsp); break; case 0x20: ret = Protocol_Sync_Verify (ps, cmd, rsp); break; case 0x24: ret = Protocol_Sync_ChangeVerifyData (ps, cmd, rsp); break; default: ret = Protocol_Sync_BadCommand (ps, cmd, rsp); } return ret; } int Protocol_Sync_Close (Protocol_Sync * ps) { Protocol_Sync_Clear (ps); return PROTOCOL_SYNC_OK; } void Protocol_Sync_Delete (Protocol_Sync * ps) { free (ps); } /* * Not exported functions definition */ static int Protocol_Sync_SelectFile (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE buffer[2], aid[PROTOCOL_SYNC_AID_SIZE], path[2]; unsigned short fid, aid_length, path_length; TLV_Object *tlv_dir, *tlv_template, *tlv_aid, *tlv_path, *tlv_app; ATR_Sync *atr; /* FID selected */ if (APDU_Cmd_P1 (cmd) == 0x00) { /* Get FID */ fid = (APDU_Cmd_Data (cmd)[0] << 8) | (APDU_Cmd_Data (cmd)[1]); if (fid == PROTOCOL_SYNC_DS_MF) { ps->path = 0; ps->length = ICC_Sync_GetLength (ps->icc); buffer[0] = 0x90; buffer[1] = 0x00; } else if (fid == PROTOCOL_SYNC_DS_ATR) { atr = ICC_Sync_GetAtr (ps->icc); if ((ATR_Sync_GetCategoryIndicator (atr) == ATR_SYNC_CATEGORY_INDICATOR) && (ATR_SYNC_IS_DIR_DATA_REFERENCE (ATR_Sync_GetDirDataReference (atr))) && (ATR_SYNC_DIR_DATA_REFERENCE (ATR_Sync_GetDirDataReference (atr))) > 4 && (ICC_Sync_GetLength (ps->icc) > 4)) { ps->path = 4; ps->length = MIN (ATR_SYNC_DIR_DATA_REFERENCE (ATR_Sync_GetDirDataReference (atr)), ICC_Sync_GetLength (ps->icc)) - 4; buffer[0] = 0x90; buffer[1] = 0x00; } else { buffer[0] = 0x6A; buffer[1] = 0x82; } } else if (fid == PROTOCOL_SYNC_DS_DIR) { atr = ICC_Sync_GetAtr (ps->icc); if ((ATR_Sync_GetCategoryIndicator (atr) == ATR_SYNC_CATEGORY_INDICATOR) && (ATR_SYNC_IS_DIR_DATA_REFERENCE (ATR_Sync_GetDirDataReference (atr)))) { if ((tlv_dir = PROTOCOL_SYNC_TLV (ps->icc, ATR_SYNC_DIR_DATA_REFERENCE (ATR_Sync_GetDirDataReference (atr))))) { ps->path = TLV_Object_GetAddress (tlv_dir); ps->length = TLV_Object_GetRawLength (tlv_dir); buffer[0] = 0x90; buffer[1] = 0x00; TLV_Object_Delete (tlv_dir); } else { buffer[0] = 0x6A; buffer[1] = 0x82; } } else { buffer[0] = 0x6A; buffer[1] = 0x82; } } else { buffer[0] = 0x6A; buffer[1] = 0x82; } } /* AID selected */ else if (APDU_Cmd_P1 (cmd) == 0x04) { /* Get AID */ aid_length = MIN (APDU_Cmd_Lc (cmd), PROTOCOL_SYNC_AID_SIZE); memcpy (aid, APDU_Cmd_Data (cmd), aid_length); atr = ICC_Sync_GetAtr (ps->icc); if ((ATR_Sync_GetCategoryIndicator (atr) == ATR_SYNC_CATEGORY_INDICATOR) && (ATR_SYNC_IS_DIR_DATA_REFERENCE (ATR_Sync_GetDirDataReference (atr)))) { if ((tlv_dir = PROTOCOL_SYNC_TLV (ps->icc, ATR_SYNC_DIR_DATA_REFERENCE (ATR_Sync_GetDirDataReference (atr))))) { /* Mono-application card */ if (TLV_Object_GetTag (tlv_dir) == TLV_OBJECT_TAG_APPLICATION_ID) { if (TLV_Object_CompareValue (tlv_dir, aid, &aid_length)) { if (TLV_Object_Shift (&tlv_dir)) { ps->path = TLV_Object_GetAddress (tlv_dir); ps->length = TLV_Object_GetRawLength (tlv_dir); buffer[0] = 0x90; buffer[1] = 0x00; TLV_Object_Delete (tlv_dir); } /* Cannot initialize app data section */ else { buffer[0] = 0x6A; buffer[1] = 0x82; } } /* Cannot find application ID */ else { buffer[0] = 0x6A; buffer[1] = 0x82; TLV_Object_Delete (tlv_dir); } } /* Mono-application card with template DO */ else if (TLV_Object_GetTag (tlv_dir) == TLV_OBJECT_TAG_TEMPLATE) { if ((tlv_aid = TLV_Object_GetObjectByTag (tlv_dir, TLV_OBJECT_TAG_APPLICATION_ID))) { if (TLV_Object_CompareValue (tlv_aid, aid, &aid_length)) { if (TLV_Object_Shift (&tlv_dir)) { ps->path = TLV_Object_GetAddress (tlv_dir); ps->length = TLV_Object_GetRawLength (tlv_dir); buffer[0] = 0x90; buffer[1] = 0x00; TLV_Object_Delete (tlv_dir); } /* Cannot initialize app data section */ else { buffer[0] = 0x6A; buffer[1] = 0x82; } } /* Cannot find application ID */ else { buffer[0] = 0x6A; buffer[1] = 0x82; TLV_Object_Delete (tlv_dir); } TLV_Object_Delete (tlv_aid); } /* Cannot find application ID data object */ else { buffer[0] = 0x6A; buffer[1] = 0x82; TLV_Object_Delete (tlv_dir); } } /* Multi-application card */ else if (TLV_Object_GetTag (tlv_dir) == TLV_OBJECT_TAG_SEQUENCE) { tlv_app = NULL; tlv_template = NULL; /* Iterate over dir data section sequence */ while ((!tlv_app) && (TLV_Object_Iterate (tlv_dir, &tlv_template))) { if ((tlv_aid = TLV_Object_GetObjectByTag (tlv_template, TLV_OBJECT_TAG_APPLICATION_ID))) { if (TLV_Object_CompareValue (tlv_aid, aid, &aid_length)) { if ((tlv_path = TLV_Object_GetObjectByTag (tlv_template, TLV_OBJECT_TAG_PATH))) { if (TLV_Object_GetValue (tlv_path, path, &path_length)) { if (path_length < 2) tlv_app = PROTOCOL_SYNC_TLV (ps->icc, path[0]); else tlv_app = PROTOCOL_SYNC_TLV (ps->icc, (path[path_length-2] << 8) | path[path_length-1]); } TLV_Object_Delete (tlv_path); } } TLV_Object_Delete (tlv_aid); } } /* End of secuence was not reached */ if (tlv_template != NULL) TLV_Object_Delete (tlv_template); /* Got it! */ if (tlv_app != NULL) { ps->path = TLV_Object_GetAddress (tlv_app); ps->length = TLV_Object_GetRawLength (tlv_app); buffer[0] = 0x90; buffer[1] = 0x00; TLV_Object_Delete (tlv_app); } /* Cannot find or cannot initialize app data section */ else { buffer[0] = 0x6A; buffer[1] = 0x82; } TLV_Object_Delete (tlv_dir); } /* Invalid tag in dir data section */ else { buffer[0] = 0x6A; buffer[1] = 0x82; TLV_Object_Delete (tlv_dir); } } /* Cannot initialize dir data section */ else { buffer[0] = 0x6A; buffer[1] = 0x82; } } /* Cannot find dir data section */ else { buffer[0] = 0x6A; buffer[1] = 0x82; } } /* Bad selection control */ else { /* ID not found */ buffer[0] = 0x6A; buffer[1] = 0x82; } (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_OK; } static int Protocol_Sync_ReadBinary (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp) { unsigned offset, available; unsigned long expected; BYTE *buffer; offset = (APDU_Cmd_P1 (cmd) << 8) | APDU_Cmd_P2 (cmd); available = MAX ((signed) (ps->length) - (signed) (offset), 0); if (APDU_Cmd_Le_Available (cmd)) expected = available; else expected = APDU_Cmd_Le (cmd); /* Cannot return more than APDU_MAX_RSP_SIZE - 2 data bytes */ expected = MIN (expected, APDU_MAX_RSP_SIZE - 2); if (expected > available) { /* Get memory for response */ buffer = (BYTE *) calloc (available + 2, sizeof (BYTE)); /* Read data */ if (ICC_Sync_Read (ps->icc, ps->path + offset, available, buffer) != ICC_SYNC_OK) { buffer[0] = 0x65; buffer[1] = 0x01; (*rsp) = APDU_Rsp_New (buffer, 2); free (buffer); return PROTOCOL_SYNC_ICC_ERROR; } buffer[available] = 0x62; buffer[available + 1] = 0x82; (*rsp) = APDU_Rsp_New (buffer, available + 2); free (buffer); } else { /* Get memory for response */ buffer = (BYTE *) calloc (expected + 2, sizeof (BYTE)); /* Read data */ if (ICC_Sync_Read (ps->icc, ps->path + offset, expected, buffer) != ICC_SYNC_OK) { buffer[0] = 0x65; buffer[1] = 0x01; (*rsp) = APDU_Rsp_New (buffer, 2); free (buffer); return PROTOCOL_SYNC_ICC_ERROR; } buffer[expected] = 0x90; buffer[expected + 1] = 0x00; (*rsp) = APDU_Rsp_New (buffer, expected + 2); free (buffer); } return PROTOCOL_SYNC_OK; } static int Protocol_Sync_UpdateBinary (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp) { unsigned available, offset; unsigned long provided; BYTE buffer[2]; int ret; offset = (APDU_Cmd_P1 (cmd) << 8) | APDU_Cmd_P2 (cmd); available = MAX ((signed) (ps->length) - (signed) (offset), 0); provided = APDU_Cmd_Lc (cmd); /* Write data */ ret = ICC_Sync_Write (ps->icc, ps->path + offset, MIN (available, provided), APDU_Cmd_Data (cmd)); /* Read only error */ if (ret == ICC_SYNC_RO_ERROR) { buffer[0] = 0x62; buffer[1] = 0x00; (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_OK; } /* Communication error */ else if (ret != ICC_SYNC_OK) { buffer[0] = 0x62; buffer[1] = 0x00; (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_ICC_ERROR; } /* Wrote less bytes than given */ if (available < provided) { buffer[0] = 0x62; buffer[1] = 0x00; (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_OK; } buffer[0] = 0x90; buffer[1] = 0x00; (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_OK; } static int Protocol_Sync_Verify (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE buffer[2], pin[ICC_SYNC_PIN_SIZE]; unsigned trials; int ret; memset (pin, 0x00, ICC_SYNC_PIN_SIZE); memcpy (pin, APDU_Cmd_Data (cmd), MIN (APDU_Cmd_Lc (cmd), ICC_SYNC_PIN_SIZE)); ret = ICC_Sync_EnterPin (ps->icc, pin, &trials); /* Verificarion unsuccessfull */ if (ret == ICC_SYNC_PIN_ERROR) { buffer[0] = 0x63; buffer[1] = (0xC0 | ((BYTE) trials & 0x0F)); } /* ICC blocked */ else if (ret == ICC_SYNC_BLOCKED_ERROR) { buffer[0] = 0x69; buffer[1] = 0x83; } /* Communication error */ else if (ret != ICC_SYNC_OK) { buffer[0] = 0x63; buffer[1] = 0x00; (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_ICC_ERROR; } /* Enter PIN OK */ else { buffer[0] = 0x90; buffer[1] = 0x00; } (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_OK; } static int Protocol_Sync_ChangeVerifyData (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE pin[ICC_SYNC_PIN_SIZE], newpin[ICC_SYNC_PIN_SIZE]; BYTE buffer[2]; unsigned trials; int ret; memcpy (pin, APDU_Cmd_Data (cmd), ICC_SYNC_PIN_SIZE); memcpy (newpin, APDU_Cmd_Data (cmd) + ICC_SYNC_PIN_SIZE, ICC_SYNC_PIN_SIZE); /* Verify current pin */ ret = ICC_Sync_EnterPin (ps->icc, pin, &trials); /* Verificarion unsuccessfull */ if (ret == ICC_SYNC_PIN_ERROR) { buffer[0] = 0x63; buffer[1] = (0xC0 | ((BYTE) trials & 0x0F)); (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_OK; } /* ICC blocked */ else if (ret == ICC_SYNC_BLOCKED_ERROR) { buffer[0] = 0x69; buffer[1] = 0x83; (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_OK; } /* Communication error */ else if (ret != ICC_SYNC_OK) { buffer[0] = 0x63; buffer[1] = 0x00; (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_ICC_ERROR; } /* Change PIN */ ret = ICC_Sync_ChangePin (ps->icc, newpin); if (ret != ICC_SYNC_OK) { buffer[0] = 0x63; buffer[1] = 0x00; (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_ICC_ERROR; } buffer[0] = 0x90; buffer[1] = 0x00; (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_OK; } static int Protocol_Sync_BadCommand (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp) { BYTE buffer[2]; buffer[0] = 0x6E; buffer[1] = 0x00; (*rsp) = APDU_Rsp_New (buffer, 2); return PROTOCOL_SYNC_OK; } static bool Protocol_Sync_GetData (void * data, unsigned short address, unsigned short length, BYTE * buffer) { return (ICC_Sync_Read ((ICC_Sync *) data, address, length, buffer) == ICC_SYNC_OK); } static void Protocol_Sync_Clear (Protocol_Sync * ps) { ps->icc = NULL; ps->path = 0; ps->length = 0; } towitoko-2.0.7/src/driver/atr_sync.c0000644000175000017500000000574107414061573013146 /* atr_sync.c Memory cards answer to reset abstract data type This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "atr_sync.h" #include /* * Exported functions definition */ ATR_Sync * ATR_Sync_New (void) { ATR_Sync *atr; atr = (ATR_Sync *) malloc (sizeof (ATR_Sync)); if (atr != NULL) { atr->H1 = 0x00; atr->H2 = 0x00; atr->H3 = 0x00; atr->H4 = 0x00; } return atr; } int ATR_Sync_Init (ATR_Sync * atr, BYTE * buffer, unsigned length) { int ret; if (length < 4) return ATR_SYNC_MALFORMED; atr->H1 = buffer[0]; atr->H2 = buffer[1]; atr->H3 = buffer[2]; atr->H4 = buffer[3]; if ((buffer[0] & 0x03) == 0x02) { if (buffer[2] == 0x10) ret = ATR_SYNC_OK; else ret = ATR_SYNC_MALFORMED; } else ret = ATR_SYNC_UNKNOWN_STRUCTURE; return ret; } BYTE ATR_Sync_GetProtocolType (ATR_Sync * atr) { return (((atr->H1) >> 4) & 0x0F); } BYTE ATR_Sync_GetStructureID (ATR_Sync * atr) { return ((atr->H1) & 0x07); } BYTE ATR_Sync_GetProtocolParameter (ATR_Sync * atr) { return (atr->H2); } unsigned ATR_Sync_GetNumberOfDataUnits (ATR_Sync * atr) { unsigned exp, ret, i; exp = ((atr->H2) >> 3) & 0x0F; if (exp == 0) return 0; /* Calculate ret = 2 ^ (exp +6) */ ret = 64; for (i = 0; i < exp; i++) ret *= 2; return ret; } unsigned ATR_Sync_GetLengthOfDataUnits (ATR_Sync * atr) { unsigned exp, ret, i; exp = ((atr->H2) & 0x07); /* Calculate ret = (2 ^ exp) */ ret = 1; for (i = 0; i < exp; i++) ret *= 2; return ret; } bool ATR_Sync_GetReadToEnd (ATR_Sync * atr) { return ((atr->H2 & 0x80) == 0x00); } void ATR_Sync_GetHistoricalBytes (ATR_Sync * atr, BYTE * buffer, unsigned *length) { buffer[0] = atr->H3; buffer[1] = atr->H4; (*length) = 2; } BYTE ATR_Sync_GetCategoryIndicator (ATR_Sync * atr) { return (atr->H3); } BYTE ATR_Sync_GetDirDataReference (ATR_Sync * atr) { return (atr->H4); } void ATR_Sync_GetRaw (ATR_Sync * atr, BYTE * buffer, unsigned *length) { buffer[0] = atr->H1; buffer[1] = atr->H2; buffer[2] = atr->H3; buffer[3] = atr->H4; (*length) = 4; } void ATR_Sync_Delete (ATR_Sync * atr) { free (atr); } towitoko-2.0.7/src/driver/pps.c0000644000175000017500000001721007527763301012123 /* pps.c Protocol Parameters Selection This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 2001 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "pps.h" #include "atr.h" #include "protocol_t0.h" #include "protocol_t1.h" #include #include #include /* * Not exported constants definition */ #define PPS_DEFAULT_PROTOCOL 0x00 /* * Not exported macros definition */ #define PPS_HAS_PPS1(block) ((block[1] & 0x10) == 0x10) #define PPS_HAS_PPS2(block) ((block[1] & 0x20) == 0x20) #define PPS_HAS_PPS3(block) ((block[1] & 0x40) == 0x40) /* * Not exported funtions declaration */ static int PPS_Exchange (PPS * pps, BYTE * params, unsigned *length); static bool PPS_Match (BYTE * request, unsigned len_request, BYTE * reply, unsigned len_reply); static unsigned PPS_GetLength (BYTE * block); static int PPS_InitICC (PPS * pps); static int PPS_InitProtocol (PPS * pps); static void PPS_SelectFirstProtocol (PPS * pps); static BYTE PPS_GetPCK (BYTE * block, unsigned length); /* * Exported functions definition */ PPS * PPS_New (ICC_Async * icc) { PPS *pps; pps = (PPS *) malloc (sizeof (PPS)); if (pps != NULL) { pps->icc = icc; pps->protocol = NULL; pps->parameters.t = PPS_DEFAULT_PROTOCOL; pps->parameters.f = ATR_DEFAULT_F; pps->parameters.d = ATR_DEFAULT_D; pps->parameters.n = ATR_DEFAULT_N; } return pps; } int PPS_Perform (PPS * pps, BYTE * params, unsigned *length) { ATR *atr; int ret; /* Perform PPS Exchange if requested */ if ((*length) > 0) { ret = PPS_Exchange (pps, params, length); /* Get parameters from PPS handsake */ if (ret == PPS_OK) { pps->parameters.t = params[1] & 0x0F; if (PPS_HAS_PPS1 (params)) { pps->parameters.f = atr_f_table[(params[2] >> 4)]; pps->parameters.d = atr_d_table[(params[2] & 0x0F)]; } ret = PPS_InitICC(pps); if (ret != PPS_OK) return ret; } else return ret; } /* Get parameters from ATR */ else { PPS_SelectFirstProtocol (pps); #ifndef PPS_USE_DEFAULT_TIMINGS atr = ICC_Async_GetAtr (pps->icc); ATR_GetParameter (atr, ATR_PARAMETER_N, &(pps->parameters.n)); ATR_GetParameter (atr, ATR_PARAMETER_D, &(pps->parameters.d)); ATR_GetParameter (atr, ATR_PARAMETER_F, &(pps->parameters.f)); #endif } #ifdef DEBUG_PROTOCOL printf("PPS: T=%X, F=%.0f, D=%.6f, N=%.0f\n", pps->parameters.t, pps->parameters.f, pps->parameters.d, pps->parameters.n); #endif /* Initialize selected protocol with selected parameters */ ret = PPS_InitProtocol (pps); return ret; } void * PPS_GetProtocol (PPS * pps) { return pps->protocol; } PPS_ProtocolParameters *PPS_GetProtocolParameters (PPS * pps) { /* User must Remember not to reference this struct after removing PPS */ return &(pps->parameters); } void PPS_Delete (PPS * pps) { free (pps); } /* * Not exported funtions definition */ static int PPS_Exchange (PPS * pps, BYTE * params, unsigned *length) { BYTE confirm[PPS_MAX_LENGTH]; unsigned len_request, len_confirm; int ret; #ifdef DEBUG_PROTOCOL int i; #endif len_request = PPS_GetLength (params); params[len_request - 1] = PPS_GetPCK(params, len_request - 1); #ifdef DEBUG_PROTOCOL printf ("PPS: Sending request: "); for (i = 0; i < len_request; i++) printf ("%X ", params[i]); printf ("\n"); #endif /* Send PPS request */ if (ICC_Async_Transmit (pps->icc, len_request, params) != ICC_ASYNC_OK) return PPS_ICC_ERROR; /* Get PPS confirm */ if (ICC_Async_Receive (pps->icc, 2, confirm) != ICC_ASYNC_OK) return PPS_ICC_ERROR; len_confirm = PPS_GetLength (confirm); if (ICC_Async_Receive (pps->icc, len_confirm - 2, confirm + 2) != ICC_ASYNC_OK) return PPS_ICC_ERROR; #ifdef DEBUG_PROTOCOL printf ("PPS: Receivig confirm: "); for (i = 0; i < len_confirm; i++) printf ("%X ", confirm[i]); printf ("\n"); #endif if (!PPS_Match (params, len_request, confirm, len_confirm)) ret = PPS_HANDSAKE_ERROR; else ret = PPS_OK; /* Copy PPS handsake */ memcpy (params, confirm, len_confirm); (*length) = len_confirm; return ret; } static bool PPS_Match (BYTE * request, unsigned len_request, BYTE * confirm, unsigned len_confirm) { /* See if the reply differs from request */ if ((len_request != len_confirm) || (!memcmp (request, confirm, len_request))) { /* See if the card specifies other than default FI and D */ if ((PPS_HAS_PPS1 (confirm)) && (confirm[2] != request[2])) return FALSE; } return TRUE; } static unsigned PPS_GetLength (BYTE * block) { unsigned length = 3; if (PPS_HAS_PPS1 (block)) length++; if (PPS_HAS_PPS2 (block)) length++; if (PPS_HAS_PPS3 (block)) length++; return length; } static int PPS_InitICC (PPS * pps) { unsigned long baudrate; long double work_etu; /* Work etu = (1/D) * (F/fs) * 1000 milliseconds */ work_etu = (1000 * pps->parameters.f) / (pps->parameters.d * ICC_Async_GetClockRate (pps->icc)); /* Baudrate = 1000 / etu bps */ baudrate = (long unsigned int) (1000 / work_etu); #ifdef DEBUG_PROTOCOL printf ("PPS: Baudrate = %d\n", baudrate); #endif if (ICC_Async_SetBaudrate (pps->icc, baudrate) != ICC_ASYNC_OK) return PPS_ICC_ERROR; return PPS_OK; } static int PPS_InitProtocol (PPS * pps) { int ret; if (pps->parameters.t == ATR_PROTOCOL_TYPE_T0) { pps->protocol = Protocol_T0_New (); if ((pps->protocol) != NULL) { ret = Protocol_T0_Init ((Protocol_T0 *) pps->protocol, (ICC_Async *) pps->icc, &(pps->parameters)); if (ret != PROTOCOL_T0_OK) { Protocol_T0_Delete ((Protocol_T0 *) pps->protocol); pps->protocol = NULL; return PPS_PROTOCOL_ERROR; } return PPS_OK; } } else if (pps->parameters.t == ATR_PROTOCOL_TYPE_T1) { pps->protocol = Protocol_T1_New (); if (pps->protocol != NULL) { ret = Protocol_T1_Init ((Protocol_T1 *) pps->protocol, (ICC_Async *) pps->icc, &(pps->parameters)); if (ret != PROTOCOL_T1_OK) { Protocol_T1_Delete ((Protocol_T1 *) pps->protocol); pps->protocol = NULL; return PPS_PROTOCOL_ERROR; } return PPS_OK; } } else pps->protocol = NULL; return PPS_PROTOCOL_ERROR; } static void PPS_SelectFirstProtocol (PPS * pps) { ATR *atr = ICC_Async_GetAtr (pps->icc); unsigned np; pps->parameters.t = ATR_PROTOCOL_TYPE_T0; ATR_GetNumberOfProtocols (atr, &np); /* * Get protocol offered by interface bytes T*2 if available, * (that is, if TD1 is available), * otherwise use default T=0 */ if (np>1) ATR_GetProtocolType (atr, 2, &(pps->parameters.t)); #ifdef DEBUG_PROTOCOL printf ("PPS: Protocol T=%d selected\n", pps->parameters.t); #endif } static BYTE PPS_GetPCK (BYTE * block, unsigned length) { BYTE pck; unsigned i; pck = block[0]; for (i = 1; i < length; i++) pck ^= block[i]; return pck; } towitoko-2.0.7/src/driver/tlv_object.c0000644000175000017500000001330707433273261013454 /* tlv_object.c BER-TLV (Basic Encoding Rules - Tag Length Value) decoding This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2002 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include "defines.h" #include "tlv_object.h" /* * Exported functions definition */ TLV_Object * TLV_Object_New (void* data, TLV_Object_GetData get_data, unsigned short data_length, unsigned short address) { TLV_Object * tlv; BYTE buffer[2]; unsigned i; tlv = (TLV_Object *) malloc (sizeof(TLV_Object)); if (tlv != NULL) { tlv->data = data; tlv->get_data = get_data; tlv->data_length = data_length; tlv->address = address; /* Get Tag */ i=0; if ((address >= data_length) || !((*get_data)(data, address, 1, buffer))) { free (tlv); return NULL; } /* Two bytes tag */ if ((buffer[0] & 0x1F) == 0x1F) { i++; if ((address+i >= data_length) || !((*get_data)(data, address+i, 1, buffer+i))) { free (tlv); return NULL; } tlv->tag = (buffer[0] << 8) | buffer[1]; } /* One byte tag */ else tlv->tag = 0x00FF & buffer[0]; /* Get length */ i++; if ((address+i >= data_length) || !((*get_data)(data, address+i, 1, buffer))) { free (tlv); return NULL; } /* Length > 127 */ if ((buffer[0] & 0x80) == 0x80) { i++; /* 256 > length > 127 */ if ((buffer[0] & 0x7F) == 0x01) { if ((address+i >= data_length) || !((*get_data)(data, address+i, 1, buffer))) { free (tlv); return NULL; } tlv->length = 0x00FF & buffer[0]; i++; } /* 65536 > length > 255 */ else if ((buffer[0] & 0x7F) == 0x02) { if ((address+i+1 >= data_length) || !((*get_data)(data, address+i, 2, buffer))) { free (tlv); return NULL; } tlv->length = (buffer[0] << 8) | buffer[1]; i+=2; } else { free (tlv); return NULL; } } /* Length < 128 */ else { i++; tlv->length = 0x7F & buffer[0]; } /* Get value address */ if (address+i >= data_length) { free (tlv); return NULL; } tlv->value = address + i; /* Round tlv object length to fit within available data */ tlv->length = MIN (tlv->length, data_length - tlv->value); } return tlv; } void TLV_Object_Delete (TLV_Object * tlv) { free (tlv); } unsigned short TLV_Object_GetTag (TLV_Object * tlv) { return tlv->tag; } unsigned short TLV_Object_GetLength (TLV_Object * tlv) { return tlv->length; } bool TLV_Object_GetValue (TLV_Object * tlv, BYTE * value, unsigned short *length) { (*length) = MIN ((*length), tlv->length); if ((*length) == 0) return TRUE; return ((*(tlv->get_data)) (tlv->data, tlv->value, (*length), value)); } bool TLV_Object_CompareValue (TLV_Object * tlv, BYTE * value, unsigned short *length) { BYTE * buffer; bool ret; buffer = (BYTE *) calloc ((*length), sizeof (BYTE)); if (TLV_Object_GetValue (tlv, buffer, length)) ret = !(memcmp (value, buffer, (*length))); else ret = FALSE; return ret; } bool TLV_Object_Shift (TLV_Object ** tlv) { TLV_Object * aux; aux = TLV_Object_New ((*tlv)->data, (*tlv)->get_data, (*tlv)->data_length , (*tlv)->value + (*tlv)->length); TLV_Object_Delete (*tlv); (*tlv) = aux; return (aux != NULL); } bool TLV_Object_Iterate (TLV_Object * tlv, TLV_Object ** iterator) { TLV_Object * next; if ((*iterator) == NULL) next = TLV_Object_New (tlv->data, tlv->get_data, tlv->data_length, tlv->value); else { next = (*iterator); if (next->value + next->length < tlv->value + tlv->length) TLV_Object_Shift (&next); else { TLV_Object_Delete (next); next = NULL; } } return (((*iterator) = next) != NULL); } TLV_Object * TLV_Object_GetObjectByTag (TLV_Object * tlv, unsigned short tag) { TLV_Object * aux; aux = TLV_Object_New (tlv->data, tlv->get_data, tlv->data_length, tlv->value); while ((aux) && (TLV_Object_GetTag (aux) != tag)) { if (aux->value + aux->length < tlv->value + tlv->length) TLV_Object_Shift (&aux); else { TLV_Object_Delete (aux); aux = NULL; } } return aux; } TLV_Object * TLV_Object_GetObjectBySec (TLV_Object * tlv, unsigned short sec) { TLV_Object * aux; unsigned short i; aux = TLV_Object_New (tlv->data, tlv->get_data, tlv->data_length, tlv->value); for (i=0; ((ivalue + aux->length < tlv->value + tlv->length) TLV_Object_Shift(&aux); else { TLV_Object_Delete(aux); aux = NULL; } } return aux; } unsigned short TLV_Object_GetRawLength (TLV_Object * tlv) { return (tlv->length + (tlv->value - tlv->address)); } unsigned short TLV_Object_GetAddress (TLV_Object * tlv) { return tlv->address; } towitoko-2.0.7/src/driver/atr.h0000644000175000017500000001070407375602206012112 /* atr.h ISO 7816 ICC's answer to reset abstract data type definitions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _ATR_ #define _ATR_ #include "defines.h" #include "io_serial.h" /* * Exported constants definition */ /* Return values */ #define ATR_OK 0 /* ATR could be parsed and data returned */ #define ATR_NOT_FOUND 1 /* Data not present in ATR */ #define ATR_MALFORMED 2 /* ATR could not be parsed */ #define ATR_IO_ERROR 2 /* I/O stream error */ /* Paramenters */ #define ATR_MAX_SIZE 33 /* Maximum size of ATR byte array */ #define ATR_MAX_HISTORICAL 15 /* Maximum number of historical bytes */ #define ATR_MAX_PROTOCOLS 7 /* Maximun number of protocols */ #define ATR_MAX_IB 4 /* Maximum number of interface bytes per protocol */ #define ATR_CONVENTION_DIRECT 0 /* Direct convention */ #define ATR_CONVENTION_INVERSE 1 /* Inverse convention */ #define ATR_PROTOCOL_TYPE_T0 0 /* Protocol type T=0 */ #define ATR_PROTOCOL_TYPE_T1 1 /* Protocol type T=1 */ #define ATR_PROTOCOL_TYPE_T2 2 /* Protocol type T=2 */ #define ATR_PROTOCOL_TYPE_T3 3 /* Protocol type T=3 */ #define ATR_PROTOCOL_TYPE_T14 14 /* Protocol type T=14 */ #define ATR_INTERFACE_BYTE_TA 0 /* Interface byte TAi */ #define ATR_INTERFACE_BYTE_TB 1 /* Interface byte TBi */ #define ATR_INTERFACE_BYTE_TC 2 /* Interface byte TCi */ #define ATR_INTERFACE_BYTE_TD 3 /* Interface byte TDi */ #define ATR_PARAMETER_F 0 /* Parameter F */ #define ATR_PARAMETER_D 1 /* Parameter D */ #define ATR_PARAMETER_I 2 /* Parameter I */ #define ATR_PARAMETER_P 3 /* Parameter P */ #define ATR_PARAMETER_N 4 /* Parameter N */ #define ATR_INTEGER_VALUE_FI 0 /* Integer value FI */ #define ATR_INTEGER_VALUE_DI 1 /* Integer value DI */ #define ATR_INTEGER_VALUE_II 2 /* Integer value II */ #define ATR_INTEGER_VALUE_PI1 3 /* Integer value PI1 */ #define ATR_INTEGER_VALUE_N 4 /* Integer value N */ #define ATR_INTEGER_VALUE_PI2 5 /* Integer value PI2 */ /* Default values for paramenters */ #define ATR_DEFAULT_F 372 #define ATR_DEFAULT_D 1 #define ATR_DEFAULT_I 50 #define ATR_DEFAULT_N 0 #define ATR_DEFAULT_P 5 /* * Exported data types definition */ typedef struct { unsigned length; BYTE TS; BYTE T0; struct { BYTE value; bool present; } ib[ATR_MAX_PROTOCOLS][ATR_MAX_IB], TCK; unsigned pn; BYTE hb[ATR_MAX_HISTORICAL]; unsigned hbn; } ATR; /* * Exported variables declaration */ extern unsigned atr_f_table[16]; extern double atr_d_table[16]; extern unsigned atr_i_table[4]; /* * Exported functions declaraton */ /* Creation and deletion */ extern ATR *ATR_New (void); extern void ATR_Delete (ATR * atr); /* Initialization */ extern int ATR_InitFromArray (ATR * atr, BYTE buffer[ATR_MAX_SIZE], unsigned length); extern int ATR_InitFromStream (ATR * atr, IO_Serial * io, unsigned timeout); /* General smartcard characteristics */ extern int ATR_GetConvention (ATR * atr, int *convention); extern int ATR_GetNumberOfProtocols (ATR * atr, unsigned *number_protocols); extern int ATR_GetProtocolType (ATR * atr, unsigned number_protocol, BYTE *protocol_type); /* ATR parameters and integer values */ extern int ATR_GetInterfaceByte (ATR * atr, unsigned number, int character, BYTE * ib); extern int ATR_GetIntegerValue (ATR * atr, int name, BYTE * value); extern int ATR_GetParameter (ATR * atr, int name, double *parameter); extern int ATR_GetHistoricalBytes (ATR * atr, BYTE * hist, unsigned *length); extern int ATR_GetCheckByte (ATR * atr, BYTE * check_byte); extern int ATR_GetFsMax (ATR * atr, unsigned long *fsmax); /* Raw ATR retrieving */ extern int ATR_GetRaw (ATR * atr, BYTE * buffer, unsigned *lenght); extern int ATR_GetSize (ATR * atr, unsigned *size); #endif /* _ATR_ */ towitoko-2.0.7/src/driver/icc_async.h0000644000175000017500000000613607404146634013264 /* icc_async.h Asynchronous integrated circuit cards handling functions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 2001 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _ICC_ASYNC_ #define _ICC_ASYNC_ #include "defines.h" #include "ifd_towitoko.h" #include "atr.h" /* * Exported constants definition */ /* Return codes */ #define ICC_ASYNC_OK 0 #define ICC_ASYNC_IFD_ERROR 1 #define ICC_ASYNC_ATR_ERROR 2 /* * Exported types definition */ typedef struct { unsigned block_delay; /* Delay (ms) after starting to transmit */ unsigned char_delay; /* Delay (ms) after transmiting each sucesive char*/ unsigned block_timeout; /* Max timeout (ms) to receive first char */ unsigned char_timeout; /* Max timeout (ms) to receive sucesive characters */ } ICC_Async_Timings; typedef struct { IFD *ifd; /* Interface device */ ATR *atr; /* Answer to reset of this ICC */ int convention; /* Convention of this ICC */ unsigned long baudrate; /* Current baudrate (bps) for transmiting to this ICC */ ICC_Async_Timings timings; /* Current timings for transmiting to this ICC */ } ICC_Async; /* * Exported functions declaration */ /* Creation and Deletion */ extern ICC_Async * ICC_Async_New (void); extern void ICC_Async_Delete (ICC_Async * icc); /* Initialization and Deactivation */ extern int ICC_Async_Init (ICC_Async * icc, IFD * ifd); extern int ICC_Async_Close (ICC_Async * icc); /* Attributes */ extern int ICC_Async_SetTimings (ICC_Async * icc, ICC_Async_Timings * timings); extern int ICC_Async_GetTimings (ICC_Async * icc, ICC_Async_Timings * timings); extern int ICC_Async_SetBaudrate (ICC_Async * icc, unsigned long baudrate); extern int ICC_Async_GetBaudrate (ICC_Async * icc, unsigned long * baudrate); extern ATR *ICC_Async_GetAtr (ICC_Async * icc); extern IFD *ICC_Async_GetIFD (ICC_Async * icc); extern unsigned long ICC_Async_GetClockRate (ICC_Async * icc); /* Operations */ extern int ICC_Async_BeginTransmission (ICC_Async * icc); extern int ICC_Async_Transmit (ICC_Async * icc, unsigned size, BYTE * buffer); extern int ICC_Async_Receive (ICC_Async * icc, unsigned size, BYTE * buffer); extern int ICC_Async_Switch (ICC_Async * icc); extern int ICC_Async_EndTransmission (ICC_Async * icc); #endif /* _ICC_ASYNC_ */ towitoko-2.0.7/src/driver/io_serial.h0000644000175000017500000000552207404123777013300 /* io_serial.h Serial port input/output definitions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _IO_SERIAL_ #define _IO_SERIAL_ #include "defines.h" /* * Exported constants definition */ /* Type of parity of the serial device */ #define IO_SERIAL_PARITY_ODD 1 #define IO_SERIAL_PARITY_EVEN 2 #define IO_SERIAL_PARITY_NONE 3 /* Values for the modem lines */ #define IO_SERIAL_HIGH 1 #define IO_SERIAL_LOW 0 /* Maximum size of PnP Com ID */ #define IO_SERIAL_PNPID_SIZE 256 /* * Exported datatypes definition */ /* Settings than can be modified to the serial device */ typedef struct { unsigned long input_bitrate; unsigned long output_bitrate; unsigned bits; unsigned stopbits; int parity; int dtr; int rts; } IO_Serial_Properties; /* IO_Serial exported datatype */ typedef struct { int fd; /* Handle of the serial device */ IO_Serial_Properties * props; unsigned com; /* Com port number (1..4) */ BYTE PnP_id[IO_SERIAL_PNPID_SIZE]; /* PnP Id of the serial device */ unsigned PnP_id_size; /* Length of PnP Id */ bool usbserial; /* Is serial USB device */ } IO_Serial; /* * Exported functions declaration */ /* IO_Serial creation and deletion */ extern IO_Serial *IO_Serial_New (void); extern void IO_Serial_Delete (IO_Serial * io); /* Initialization and closing */ extern bool IO_Serial_Init (IO_Serial * io, unsigned com, bool usbserial, bool pnp); extern bool IO_Serial_Close (IO_Serial * io); /* Transmission properties */ extern bool IO_Serial_SetProperties (IO_Serial * io, IO_Serial_Properties * props); extern bool IO_Serial_GetProperties (IO_Serial * io, IO_Serial_Properties * props); /* Input and output */ extern bool IO_Serial_Read (IO_Serial * io, unsigned timeout, unsigned size, BYTE * data); extern bool IO_Serial_Write (IO_Serial * io, unsigned delay, unsigned size, BYTE * data); /* Serial port atributes */ extern unsigned IO_Serial_GetCom (IO_Serial * io); extern void IO_Serial_GetPnPId (IO_Serial * io, BYTE * pnp_id, unsigned *length); #endif /* IO_SERIAL */ towitoko-2.0.7/src/driver/protocol_t0.h0000644000175000017500000000424207375770701013576 /* protocol_t0.h ISO 7816 T=0 Transport Protocol definitions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PROTOCOL_T0_ #define _PROTOCOL_T0_ #include "defines.h" #include "icc_async.h" #include "apdu.h" #include "pps.h" /* * Exported constants definition */ /* Return codes */ #define PROTOCOL_T0_OK 0 /* Command OK */ #define PROTOCOL_T0_NULL_ERROR 1 /* Maximum NULL's reachec */ #define PROTOCOL_T0_ICC_ERROR 2 /* ICC comunication error */ #define PROTOCOL_T0_IFD_ERROR 3 /* IFD comunication error */ #define PROTOCOL_T0_ERROR 4 /* T=0 Protocol Error */ /* * Exported datatypes definition */ /* T=0 Protocol handler */ typedef struct { ICC_Async *icc; /* Asynchrosous integrated cirtuit card */ unsigned long wwt; /* Work waiting time (ms) */ } Protocol_T0; /* * Exported functions declaration */ /* Create a new protocol handler */ extern Protocol_T0 *Protocol_T0_New (void); /* Delete a protocol handler */ extern void Protocol_T0_Delete (Protocol_T0 * t0); /* Initialise a protocol handler */ extern int Protocol_T0_Init (Protocol_T0 * t0, ICC_Async * icc, PPS_ProtocolParameters * params); /* Send a command and return a response */ extern int Protocol_T0_Command (Protocol_T0 * t0, APDU_Cmd * cmd, APDU_Rsp ** rsp); /* Close a protocol handler */ extern int Protocol_T0_Close (Protocol_T0 * t0); #endif /* _PROTOCOL_T0_ */ towitoko-2.0.7/src/driver/protocol_t1.h0000644000175000017500000000500407402423052013555 /* protocol_t1.h ISO 7816 T=1 Transport Protocol definitions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PROTOCOL_T1_ #define _PROTOCOL_T1_ #include "defines.h" #include "icc_async.h" #include "apdu.h" #include "pps.h" /* * Exported constants definition */ /* Return codes */ #define PROTOCOL_T1_OK 0 /* Command OK */ #define PROTOCOL_T1_ICC_ERROR 2 /* ICC comunication error */ #define PROTOCOL_T1_ERROR 4 /* T=1 Protocol Error */ #define PROTOCOL_T1_NOT_IMPLEMENTED 7 /* Feture not implemented */ /* * Exported datatypes definition */ /* T=1 Protocol context */ typedef struct { ICC_Async *icc; /* Asynchronous integrated cirtuit card */ unsigned short ifsc; /* Information field size for the ICC */ unsigned short ifsd; /* Information field size for the IFD */ unsigned short bgt; /* Block guard time */ unsigned short bwt; /* Block waiting time */ unsigned short cwt; /* Character waiting time */ int edc; /* Type of error detection code */ BYTE ns; /* Send sequence number */ } Protocol_T1; /* * Exported functions declaration */ /* Create a new protocol handler */ extern Protocol_T1 * Protocol_T1_New (void); /* Delete a protocol handler */ extern void Protocol_T1_Delete (Protocol_T1 * t1); /* Initialise a protocol handler */ extern int Protocol_T1_Init (Protocol_T1 * t1, ICC_Async * icc, PPS_ProtocolParameters * params); /* Send a command and return a response */ extern int Protocol_T1_Command (Protocol_T1 * t1, APDU_Cmd * cmd, APDU_Rsp ** rsp); /* Close a protocol handler */ extern int Protocol_T1_Close (Protocol_T1 * t1); #endif /* _PROTOCOL_T1_ */ towitoko-2.0.7/src/driver/t1_block.h0000644000175000017500000000502507375723324013027 /* t1_block.h T=1 block abstract data type definitions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _T1_BLOCK_ #define _T1_BLOCK_ #include "defines.h" /* * Exported constants definition */ /* Buffer sizes */ #define T1_BLOCK_MAX_SIZE 259 #define T1_BLOCK_INF_MAX_SIZE 254 /* Types of block */ #define T1_BLOCK_I 0x00 #define T1_BLOCK_R_OK 0x80 #define T1_BLOCK_R_EDC_ERR 0x81 #define T1_BLOCK_R_OTHER_ERR 0x82 #define T1_BLOCK_S_RESYNCH_REQ 0xC0 #define T1_BLOCK_S_RESYNCH_RES 0xE0 #define T1_BLOCK_S_IFS_REQ 0xC1 #define T1_BLOCK_S_IFS_RES 0xE1 #define T1_BLOCK_S_ABORT_REQ 0xC2 #define T1_BLOCK_S_ABORT_RES 0xE2 #define T1_BLOCK_S_WTX_REQ 0xC3 #define T1_BLOCK_S_WTX_RES 0xE3 #define T1_BLOCK_S_VPP_ERR 0xE4 /* * Exported data types definition */ typedef struct { BYTE * data; unsigned length; } T1_Block; /* * Exported functions declaration */ extern T1_Block * T1_Block_New (BYTE * buffer, unsigned length); extern T1_Block * T1_Block_NewIBlock (BYTE len, BYTE * inf, BYTE ns, bool more); extern T1_Block * T1_Block_NewRBlock (BYTE type, BYTE nr); extern T1_Block * T1_Block_NewSBlock (BYTE type, BYTE len, BYTE * inf); extern BYTE T1_Block_GetType (T1_Block * block); extern BYTE T1_Block_GetNS (T1_Block * block); extern bool T1_Block_GetMore (T1_Block * block); extern BYTE T1_Block_GetNR (T1_Block * block); extern BYTE T1_Block_GetLen (T1_Block * block); extern BYTE * T1_Block_GetInf (T1_Block * block); extern BYTE * T1_Block_Raw (T1_Block * block); extern unsigned T1_Block_RawLen (T1_Block * block); extern void T1_Block_Delete (T1_Block * block); #endif /* _T1_BLOCK_ */ towitoko-2.0.7/src/driver/ifd_towitoko.h0000644000175000017500000001364207527763552014044 /* ifd_towitoko.h Interface device handling functions definitions. An IFD object represents on of the slots within a drive. All chipdrives but Twin have one IFD per drive and serial port. This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 2001 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _IFD_TOWITOKO_ #define _IFD_TOWITOKO_ #include "defines.h" #include "atr.h" #include "atr_sync.h" /* * Exported constants definition */ /* Return Codes */ #define IFD_TOWITOKO_OK 0 /* OK */ #define IFD_TOWITOKO_IO_ERROR 1 /* I/O Error */ #define IFD_TOWITOKO_CHK_ERROR 2 /* Checksum error */ #define IFD_TOWITOKO_PARAM_ERROR 3 /* Parameter error */ #define IFD_TOWITOKO_UNSUPPORTED 4 /* Action not supported by IFD hardware */ /* Slots: Only Chipdrive twin has slot B */ #define IFD_TOWITOKO_SLOT_A 0x00 /* Chipdrive slot A */ #define IFD_TOWITOKO_SLOT_B 0x01 /* Chipdrive twin slot B */ /* Reader types */ #define IFD_TOWITOKO_CHIPDRIVE_EXT_II 0x88 #define IFD_TOWITOKO_CHIPDRIVE_EXT_I 0x84 #define IFD_TOWITOKO_CHIPDRIVE_INT 0x90 #define IFD_TOWITOKO_KARTENZWERG 0x80 #define IFD_TOWITOKO_KARTENZWERG_II 0x64 #define IFD_TOWITOKO_CHIPDRIVE_MICRO 0x61 #define IFD_TOWITOKO_UNKNOWN 0x00 /* Card status */ #define IFD_TOWITOKO_NOCARD_NOCHANGE 0x00 #define IFD_TOWITOKO_CARD_NOCHANGE 0x40 #define IFD_TOWITOKO_NOCARD_CHANGE 0x80 #define IFD_TOWITOKO_CARD_CHANGE 0xC0 #define IFD_TOWITOKO_CARD(status) (((status) & 0x40) == 0x40) #define IFD_TOWITOKO_CHANGE(status) (((status) & 0x80) == 0x80) /* Led Color */ #define IFD_TOWITOKO_LED_OFF 0x00 #define IFD_TOWITOKO_LED_RED 0x01 #define IFD_TOWITOKO_LED_GREEN 0x02 #define IFD_TOWITOKO_LED_YELLOW 0x03 /* IFD parity */ #define IFD_TOWITOKO_PARITY_ODD 0x80 #define IFD_TOWITOKO_PARITY_EVEN 0x40 /* ICC types */ #define IFD_TOWITOKO_I2C_SHORT 0 #define IFD_TOWITOKO_I2C_LONG 1 #define IFD_TOWITOKO_2W 2 #define IFD_TOWITOKO_3W 3 #define IFD_TOWITOKO_ASYNC 4 /* Maximum size of Pin */ #define IFD_TOWITOKO_PIN_SIZE 3 /* * Exported Datatypes */ typedef struct { unsigned block_delay; /* Delay (ms) after starting to transmit */ unsigned char_delay; /* Delay (ms) after transmiting sucesive chars */ unsigned block_timeout; /* Max timeout (ms) to receive firtst char */ unsigned char_timeout; /* Max timeout (ms) to receive sucesive characters */ } IFD_Timings; /* Interface Device Handler */ typedef struct { IO_Serial *io; /* Handle of serial device */ BYTE slot; /* Chipdrive Twin Slot */ BYTE type; /* Reader type code */ BYTE firmware; /* Reader firmware version */ } IFD_Towitoko; typedef IFD_Towitoko IFD; /* * Exported functions declaration */ /* Create and Delete an IFD */ extern IFD *IFD_Towitoko_New (void); extern void IFD_Towitoko_Delete (IFD * ifd); /* Handling of the drive associated with this IFD */ extern int IFD_Towitoko_Init (IFD * ifd, IO_Serial * io, BYTE slot); extern int IFD_Towitoko_Close (IFD * ifd); /* Handling of this IFD */ extern int IFD_Towitoko_SetBaudrate (IFD * ifd, unsigned long baudrate); extern int IFD_Towitoko_GetBaudrate (IFD * ifd, unsigned long *baudrate); extern int IFD_Towitoko_SetParity (IFD * ifd, BYTE parity); extern int IFD_Towitoko_SetLED (IFD * ifd, BYTE color); extern int IFD_Towitoko_GetStatus (IFD * ifd, BYTE * status); /* General handling of ICC inserted in this IFD */ extern int IFD_Towitoko_ActivateICC (IFD * ifd); extern int IFD_Towitoko_DeactivateICC (IFD * ifd); /* Asynchronous ICC handling functions */ extern int IFD_Towitoko_ResetAsyncICC (IFD * ifd, ATR ** atr); extern int IFD_Towitoko_Transmit (IFD * ifd, IFD_Timings * timings, unsigned size, BYTE * buffer); extern int IFD_Towitoko_Receive (IFD * ifd, IFD_Timings * timings, unsigned size, BYTE * buffer); extern int IFD_Towitoko_Switch (IFD * ifd); /* Synchronous ICC handling functions */ extern int IFD_Towitoko_ResetSyncICC (IFD * ifd, ATR_Sync ** atr); extern int IFD_Towitoko_SetReadAddress (IFD * ifd, int icc_type, unsigned short addr); extern int IFD_Towitoko_SetWriteAddress (IFD * ifd, int icc_type, unsigned short addr, BYTE pm); extern int IFD_Towitoko_ReadBuffer (IFD * ifd, unsigned length, BYTE * data); extern int IFD_Towitoko_WriteBuffer (IFD * ifd, unsigned length, BYTE * data); extern int IFD_Towitoko_ReadErrorCounter (IFD * ifd, int icc_type, unsigned *trials); extern int IFD_Towitoko_EnterPin (IFD * ifd, int icc_type, BYTE * pin, unsigned trial); extern int IFD_Towitoko_ChangePin (IFD * ifd, int icc_type, BYTE * pin); /* Atributes of the drive associated with this IFD */ extern BYTE IFD_Towitoko_GetType (IFD * ifd); extern BYTE IFD_Towitoko_GetFirmware (IFD * ifd); extern unsigned IFD_Towitoko_GetNumSlots (IFD * ifd); extern unsigned long IFD_Towitoko_GetClockRate (IFD * ifd); extern unsigned long IFD_Towitoko_GetMaxBaudrate (IFD * ifd); extern void IFD_Towitoko_GetDescription (IFD * ifd, BYTE * desc, unsigned length); /* Atributes of this IFD */ extern BYTE IFD_Towitoko_GetSlot (IFD * ifd); #endif /* _IFD_TOWITOKO_ */ towitoko-2.0.7/src/driver/defines.h0000644000175000017500000000362407521022540012732 /* defines.h This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef DEFINES_H #define DEFINES_H /* * Get configuration information */ #ifdef HAVE_CONFIG_H #include "config.h" #endif /* * Boolean constants */ #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE 0 #endif /* * Type definitions */ typedef unsigned char BYTE; #ifndef __cplusplus typedef int bool; #endif typedef unsigned short USHORT; typedef unsigned char UCHAR; typedef unsigned char *PUCHAR; typedef char *STR; typedef unsigned long ULONG; typedef ULONG RESPONSECODE; typedef ULONG *PULONG; typedef ULONG DWORD; typedef void *PVOID; /* * Utility macros */ #ifndef MAX #define MAX(a,b) ((a)>(b)?(a):(b)) #endif #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) #endif /* Invert order of bits in a byte: b7->b0, b0->b7 */ #ifndef INVERT_BYTE #define INVERT_BYTE(a) ((((a) << 7) & 0x80) | \ (((a) << 5) & 0x40) | \ (((a) << 3) & 0x20) | \ (((a) << 1) & 0x10) | \ (((a) >> 1) & 0x08) | \ (((a) >> 3) & 0x04) | \ (((a) >> 5) & 0x02) | \ (((a) >> 7) & 0x01)) #endif #endif /* DEFINES_H */ towitoko-2.0.7/src/driver/icc_sync.h0000644000175000017500000000602207413332054013106 /* icc_sync.h Synchronous integrated circuit cards handling functions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _ICC_SYNC_ #define _ICC_SYNC_ #include "defines.h" #include "ifd_towitoko.h" #include "atr_sync.h" /* * Exported constants definition */ /* Return codes */ #define ICC_SYNC_OK 0 #define ICC_SYNC_DETECT_ERROR 1 #define ICC_SYNC_IFD_ERROR 2 #define ICC_SYNC_RO_ERROR 3 #define ICC_SYNC_PIN_ERROR 4 #define ICC_SYNC_BLOCKED_ERROR 5 /* ICC types */ #define ICC_SYNC_I2C_SHORT 0 #define ICC_SYNC_I2C_LONG 1 #define ICC_SYNC_2W 2 #define ICC_SYNC_3W 3 /* Maximum size of the PIN */ #define ICC_SYNC_PIN_SIZE 3 /* * Exported types definition */ /* Synchronous ICC */ typedef struct { IFD *ifd; /* Interface device */ ATR_Sync *atr; /* Answer to reset */ int type; /* Synchronous Card type */ unsigned length; /* Memory length */ BYTE pagemode; /* I2C pagemode */ BYTE pin[ICC_SYNC_PIN_SIZE]; /* 2W and 3W pin */ bool pin_ok; /* pin is correct */ bool pin_needed; /* pin has to be entered */ bool active; /* ICC is active */ unsigned long baudrate; /* Current baudrate (bps) for transmiting to this ICC */ } ICC_Sync; /* * Exported functions declaration */ /* ICC_Sync creation and deletion */ extern ICC_Sync *ICC_Sync_New (void); extern void ICC_Sync_Delete (ICC_Sync * icc); /* Card initialization and deactivation */ int ICC_Sync_Init (ICC_Sync * icc, IFD * ifd); int ICC_Sync_Close (ICC_Sync * icc); /* Get ICC atributes */ unsigned ICC_Sync_GetLength (ICC_Sync * icc); int ICC_Sync_GetType (ICC_Sync * icc); BYTE ICC_Sync_GetPagemode (ICC_Sync * icc); IFD *ICC_Sync_GetIFD (ICC_Sync * icc); ATR_Sync *ICC_Sync_GetAtr (ICC_Sync * icc); int ICC_Sync_SetBaudrate (ICC_Sync * icc, unsigned long baudrate); int ICC_Sync_GetBaudrate (ICC_Sync * icc, unsigned long * baudrate); /* ICC operations */ int ICC_Sync_BeginTransmission (ICC_Sync * icc); int ICC_Sync_Read (ICC_Sync * icc, unsigned short address, unsigned length, BYTE * data); int ICC_Sync_Write (ICC_Sync * icc, unsigned short address, unsigned length, BYTE * data); int ICC_Sync_EnterPin (ICC_Sync * icc, BYTE * pin, unsigned *trials); int ICC_Sync_ChangePin (ICC_Sync * icc, BYTE * pin); #endif /* _ICC_SYNC_ */ towitoko-2.0.7/src/driver/apdu.h0000644000175000017500000001040707422412422012245 /* apdu.h Definitions for ISO 7816-4 Application Layer PDU's handling This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 2001 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _APDU_ #define _APDU_ #include "defines.h" /* * Exported constants definiton */ /* Return codes */ #define APDU_OK 0 /* Parsing of APDU OK */ #define APDU_MALFORMED 5 /* Malformed APDU */ /* Types of APDU's */ #define APDU_CASE_1 0x0001 /* Nor send neither receive data */ #define APDU_CASE_2S 0x0002 /* Receive data (1..256) */ #define APDU_CASE_3S 0x0003 /* Send data (1..255) */ #define APDU_CASE_4S 0x0004 /* Send data (1..255) and receive data (1..256) */ #define APDU_CASE_2E 0x0102 /* Receive data (1..65536) */ #define APDU_CASE_3E 0x0103 /* Send data (1..65535) */ #define APDU_CASE_4E 0x0104 /* Send data (1..65535) and receive data (1..65536) */ /* Maximum sizes of buffers */ #define APDU_MAX_CMD_SIZE 65545 /* Max command size */ #define APDU_MAX_RSP_SIZE 65538 /* Max response size */ /* * Exported macros definition */ #define APDU_CASE_IS_EXTENDED(c) (((c) & 0x0100) == 0x0100) /* * Exported data types definition */ /* Command APDU */ typedef struct { BYTE *command; unsigned long length; } APDU_Cmd; /* Response APDU */ typedef struct { BYTE *response; unsigned long length; } APDU_Rsp; /* * Exported functions declaration */ /* Create a APDU_Cmd */ extern APDU_Cmd *APDU_Cmd_New (BYTE * data, unsigned long length); /* Delete a APDU_Cmd */ extern void APDU_Cmd_Delete (APDU_Cmd * apdu); /* Return the case of command */ extern int APDU_Cmd_Case (APDU_Cmd * apdu); /* Return class of command */ extern BYTE APDU_Cmd_Cla (APDU_Cmd * apdu); /* Return command instruction */ extern BYTE APDU_Cmd_Ins (APDU_Cmd * apdu); /* Return first paramenter of command */ extern BYTE APDU_Cmd_P1 (APDU_Cmd * apdu); /* Return second parameter of command */ extern BYTE APDU_Cmd_P2 (APDU_Cmd * apdu); /* Return length of data sent */ extern unsigned long APDU_Cmd_Lc (APDU_Cmd * apdu); /* Return length of data expected */ extern unsigned long APDU_Cmd_Le (APDU_Cmd * apdu); /* Return TRUE if the command requires all data available */ extern bool APDU_Cmd_Le_Available (APDU_Cmd * apdu); /* Return a pointer to the header of the command */ extern BYTE *APDU_Cmd_Header (APDU_Cmd * apdu); /* Return a pointer to the data of the comamnd */ extern BYTE *APDU_Cmd_Data (APDU_Cmd * apdu); /* Return a pointer to the whole command */ extern BYTE *APDU_Cmd_Raw (APDU_Cmd * apdu); /* Return the length of the whole command */ extern unsigned long APDU_Cmd_RawLen (APDU_Cmd * apdu); /* Create a APDU_Rsp */ extern APDU_Rsp *APDU_Rsp_New (BYTE * data, unsigned long length); /* Delete a APDU_Rsp */ extern void APDU_Rsp_Delete (APDU_Rsp * apdu); /* Return fitst status byte */ extern BYTE APDU_Rsp_SW1 (APDU_Rsp * apdu); /* Return second status byte */ extern BYTE APDU_Rsp_SW2 (APDU_Rsp * apdu); /* Return length of the data of the response */ extern unsigned long APDU_Rsp_DataLen (APDU_Rsp * apdu); /* Return a pointer to the data of the response */ extern BYTE *APDU_Rsp_Data (APDU_Rsp * apdu); /* Return a pointer to the whole response */ extern BYTE *APDU_Rsp_Raw (APDU_Rsp * apdu); /* Return the length of the whole response */ extern unsigned long APDU_Rsp_RawLen (APDU_Rsp * apdu); /* Truncate size of response APDU */ extern void APDU_Rsp_TruncateData (APDU_Rsp * apdu, unsigned long length); /* Adds one APDU at the end of the data bytes of an APDU */ extern int APDU_Rsp_AppendData (APDU_Rsp * apdu1, APDU_Rsp * apdu2); #endif towitoko-2.0.7/src/driver/protocol_sync.h0000644000175000017500000000415607431243235014221 /* protocol_sync.h MCT v0.9 part 7 interindustry command set for synchronous cards This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000, 2001, 2002 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PROTOCOL_SYNC_ #define _PROTOCOL_SYNC_ #include "defines.h" #include "icc_sync.h" #include "apdu.h" /* * Exported constants definition */ /* Return codes */ #define PROTOCOL_SYNC_OK 0 /* Command OK */ #define PROTOCOL_SYNC_ICC_ERROR 1 /* ICC comunication error */ #define PROTOCOL_SYNC_ERROR 2 /* Protocol Error */ /* * Exported datatypes definition */ /* Protocol handler */ typedef struct { ICC_Sync *icc; /* Synchrosous integrated cirtuit card */ unsigned path; /* start byte of selected data section */ unsigned length; /* length of selected data section */ } Protocol_Sync; /* * Exported functions declaration */ /* Create a new protocol handler */ extern Protocol_Sync *Protocol_Sync_New (void); /* Delete a protocol handler */ extern void Protocol_Sync_Delete (Protocol_Sync * ps); /* Inicialice a protocol handler */ extern int Protocol_Sync_Init (Protocol_Sync * ps, ICC_Sync * icc); /* Send a command and return a response */ extern int Protocol_Sync_Command (Protocol_Sync * ps, APDU_Cmd * cmd, APDU_Rsp ** rsp); /* Delete a protocol hanlder */ extern int Protocol_Sync_Close (Protocol_Sync * ps); #endif /* _PROTOCOL_SYNC_ */ towitoko-2.0.7/src/driver/atr_sync.h0000644000175000017500000000631407414377567013165 /* atr_sync.h Memory cards answer to reset abstract data type definitions This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _ATR_SYNC_ #define _ATR_SYNC_ #include "defines.h" /* * Exported constants definitions */ /* Length in bytes of ATR */ #define ATR_SYNC_SIZE 4 #define ATR_SYNC_HISTORICAL_SIZE 2 /* Return codes */ #define ATR_SYNC_OK 0 #define ATR_SYNC_UNKNOWN_STRUCTURE 1 #define ATR_SYNC_MALFORMED 2 /* Protocol types */ #define ATR_SYNC_IS_PROTOCOL_TYPE_ISO(type) (((type) | 0xF7) == 0xF7) #define ATR_SYNC_IS_PROTOCOL_TYPE_OTHER(type) ((((type) & 0x08) == 0x08) && \ ((type) != 0xFF)) #define ATR_SYNC_PROTOCOL_TYPE_SDA 0x08 #define ATR_SYNC_PROTOCOL_TYPE_3W 0x09 #define ATR_SYNC_PROTOCOL_TYPE_2W 0x0A #define ATR_SYNC_PROTOCOL_TYPE_RFU 0x0F /* Structure Identifiers */ #define ATR_SYNC_IS_STRUCTURE_ID_ISO(sid) (((sid) & 0x03) == 0x00) #define ATR_SYNC_STRUCTURE_ID_GENERAL 0x02 #define ATR_SYNC_STRUCTURE_ID_PROPIETARY 0x06 #define ATR_SYNC_IS_STRUCTURE_ID_SPECIAL(sid) ((((sid) & 0x03) == 0x01) || \ (((sid) & 0x03) == 0x011)) /* Category Indicators */ #define ATR_SYNC_CATEGORY_INDICATOR 0x10 /* DIR data reference */ #define ATR_SYNC_IS_DIR_DATA_REFERENCE(ddr) (((ddr) & 0x80) == 0x80) #define ATR_SYNC_DIR_DATA_REFERENCE(ddr) ((ddr) & 0x7F) /* * Exported data types definition */ /* Answer to reset for Synchronous ICC's */ typedef struct { BYTE H1; /* Protocol type */ BYTE H2; /* Protocol parameter */ BYTE H3; /* Category Indicator */ BYTE H4; /* DIR data reference */ } ATR_Sync; /* * Exported functions declaration */ extern ATR_Sync *ATR_Sync_New (void); extern int ATR_Sync_Init (ATR_Sync * atr, BYTE * buffer, unsigned length); extern BYTE ATR_Sync_GetProtocolType (ATR_Sync * atr); extern BYTE ATR_Sync_GetStructureID (ATR_Sync * atr); extern BYTE ATR_Sync_GetProtocolParameter (ATR_Sync * atr); extern unsigned ATR_Sync_GetNumberOfDataUnits (ATR_Sync * atr); extern unsigned ATR_Sync_GetLengthOfDataUnits (ATR_Sync * atr); extern bool ATR_Sync_GetReadToEnd (ATR_Sync * atr); extern void ATR_Sync_GetHistoricalBytes (ATR_Sync * atr, BYTE * buffer, unsigned *length); extern BYTE ATR_Sync_GetCategoryIndicator (ATR_Sync * atr); extern BYTE ATR_Sync_GetDirDataReference (ATR_Sync * atr); extern void ATR_Sync_GetRaw (ATR_Sync * atr, BYTE * buffer, unsigned *length); extern void ATR_Sync_Delete (ATR_Sync * atr); #endif /* _ATR_SYNC_ */ towitoko-2.0.7/src/driver/pps.h0000644000175000017500000000370707400242155012123 /* pps.h Protocol Parameters Selection This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 2001 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PPS_ #define _PPS_ #include "defines.h" #include "icc_async.h" /* * Exported constants definition */ #define PPS_OK 0 /* Negotiation OK */ #define PPS_ICC_ERROR 1 /* Comunication error */ #define PPS_HANDSAKE_ERROR 2 /* Agreement not reached */ #define PPS_PROTOCOL_ERROR 3 /* Error starting protocol */ #define PPS_MAX_LENGTH 6 /* * Exported data types definition */ typedef struct { double f; double d; double n; BYTE t; } PPS_ProtocolParameters; typedef struct { ICC_Async *icc; void *protocol; PPS_ProtocolParameters parameters; } PPS; /* * Exported functions declaration */ /* Create PPS context */ extern PPS *PPS_New (ICC_Async * icc); /* Perform protcol type selection and return confirm */ extern int PPS_Perform (PPS * pps, BYTE * params, unsigned *length); /* Get protocol handler */ extern void *PPS_GetProtocol (PPS * pps); /* Get protocol parameters */ extern PPS_ProtocolParameters *PPS_GetProtocolParameters (PPS * pps); /* Delete PPS context */ extern void PPS_Delete (PPS * pps); #endif /* _PPS_ */ towitoko-2.0.7/src/driver/tlv_object.h0000644000175000017500000000732607431542543013465 /* tlv_object.h BER-TLV (Basic Encoding Rules - Tag Length Value) decoding This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2002 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _TLV_OBJECT_ #define _TLV_OBJECT_ #include "defines.h" /* * Exported constants definition */ /*Tag class and type coding */ #define TLV_OBJECT_CLASS_UNIVERSAL 0x0000 #define TLV_OBJECT_CLASS_APPLICATION 0x0001 #define TLV_OBJECT_CLASS_CONTEXT_SPECIFIC 0x0002 #define TLV_OBJECT_CLASS_PRIVATE 0x0003 #define TLV_OBJECT_TYPE_PRIMITIVE 0x0000 #define TLV_OBJECT_TYPE_CONSTRUCTED 0x0000 /* Tag number coding */ #define TLV_OBJECT_TAG_SEQUENCE 0x30 #define TLV_OBJECT_TAG_APPLICATION_ID 0x4F #define TLV_OBJECT_TAG_APPLICATION_LABEL 0x50 #define TLV_OBJECT_TAG_PATH 0x51 #define TLV_OBJECT_TAG_DISCRETIONARY_DATA 0x53 #define TLV_OBJECT_TAG_TEMPLATE 0x61 /* * Exported macros definition */ #define TLV_OBJECT_TAG_LONG(tag) ((tag && 0xFF00) == 0x0000) #define TLV_OBJECT_TAG_CLASS(tag) (TLV_OBJECT_TAG_LONG(tag)?(tag)>>14:((tag)>>6)) #define TLV_OBJECT_TAG_TYPE(tag) (TLV_OBJECT_TAG_LONG(tag)?((tag)>>13) && 0x0001:((tag)>>5) && 0x0001) #define TLV_OBJECT_TAG_NUMBER(tag) (TLV_OBJECT_TAG_LONG(tag)?((tag) && 0x007F):((tag) && 0x001F)) /* * Exported data types definition */ typedef bool (* TLV_Object_GetData) ( void * data, unsigned short address, unsigned short length, BYTE * buffer ); typedef struct { void * data; /* Generic pointer to data source */ unsigned short data_length; /* Length of data source */ TLV_Object_GetData get_data; /* Generic function to retrive data */ unsigned short address; /* Address of this TLV in the data source */ unsigned short tag; /* Tag of this TLV */ unsigned short length; /* Length of this tlv */ unsigned short value; /* Address of the value of this TLV in the data source */ } TLV_Object; /* * Exported functions declaration */ /* Creation and deletion of a TLV Object */ extern TLV_Object * TLV_Object_New (void* data, TLV_Object_GetData get_data, unsigned short data_length, unsigned short address); extern void TLV_Object_Delete (TLV_Object * tlv); /* Get attributes of a TLV Object */ extern unsigned short TLV_Object_GetTag (TLV_Object * tlv); extern unsigned short TLV_Object_GetLength (TLV_Object * tlv); extern bool TLV_Object_GetValue (TLV_Object * tlv, BYTE * value, unsigned short * length); extern bool TLV_Object_CompareValue (TLV_Object * tlv, BYTE * value, unsigned short * length); /* To iterate TLV Object contents */ extern bool TLV_Object_Shift (TLV_Object ** tlv); extern bool TLV_Object_Iterate (TLV_Object * tlv, TLV_Object ** iterator); extern TLV_Object * TLV_Object_GetObjectByTag (TLV_Object * tlv, unsigned short tag); extern TLV_Object * TLV_Object_GetObjectBySec (TLV_Object * tlv, unsigned short sec); /* Get internals of a TLV Object */ extern unsigned short TLV_Object_GetRawLength (TLV_Object * tlv); extern unsigned short TLV_Object_GetAddress (TLV_Object * tlv); #endif /* _TLV_OBJECT */ towitoko-2.0.7/src/test/0002777000175000017500000000000007527763751010737 5towitoko-2.0.7/src/test/Makefile.am0000644000175000017500000000204707364615704012701 # # test/Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # bin_PROGRAMS = tester INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/ct-api tester_SOURCES = tester.c tester_LDADD = $(top_builddir)/src/driver/libtowitoko.la towitoko-2.0.7/src/test/Makefile.in0000644000175000017500000002551107527762033012712 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ # # test/Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = ../.. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AS = @AS@ AWK = @AWK@ CC = @CC@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBOOK_TO_MAN = @DOCBOOK_TO_MAN@ ECHO = @ECHO@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ PCSC_LITE_DIR = @PCSC_LITE_DIR@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ bin_PROGRAMS = tester INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/src/ct-api tester_SOURCES = tester.c tester_LDADD = $(top_builddir)/src/driver/libtowitoko.la subdir = src/test mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = bin_PROGRAMS = tester$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) am_tester_OBJECTS = tester.$(OBJEXT) tester_OBJECTS = $(am_tester_OBJECTS) tester_DEPENDENCIES = $(top_builddir)/src/driver/libtowitoko.la tester_LDFLAGS = DEFS = @DEFS@ DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ LIBS = @LIBS@ depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/tester.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(AM_LDFLAGS) $(LDFLAGS) -o $@ CFLAGS = @CFLAGS@ DIST_SOURCES = $(tester_SOURCES) DIST_COMMON = Makefile.am Makefile.in SOURCES = $(tester_SOURCES) all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu src/test/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(bindir) @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ || test -f $$p1 \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f; \ 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: @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ echo " rm -f $$p $$f"; \ rm -f $$p $$f ; \ done tester$(EXEEXT): $(tester_OBJECTS) $(tester_DEPENDENCIES) @rm -f tester$(EXEEXT) $(LINK) $(tester_LDFLAGS) $(tester_OBJECTS) $(tester_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) core *.core distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tester.Po@am__quote@ distclean-depend: -rm -rf ./$(DEPDIR) .c.o: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$< .c.obj: @AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(COMPILE) -c `cygpath -w $<` .c.lo: @AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ @AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$< CCDEPMODE = @CCDEPMODE@ mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: ETAGS = etags ETAGSFLAGS = tags: TAGS 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; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ 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; } \ END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$tags$$unique" \ || $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_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 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = ../.. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkinstalldirs) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ 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 check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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 clean-libtool mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-compile distclean-depend \ distclean-generic distclean-libtool distclean-tags dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-exec-am: install-binPROGRAMS install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool uninstall-am: uninstall-binPROGRAMS uninstall-info-am .PHONY: GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-libtool distclean distclean-compile \ distclean-depend distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am info info-am install \ install-am install-binPROGRAMS install-data install-data-am \ install-exec install-exec-am install-info install-info-am \ install-man install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool tags uninstall uninstall-am \ uninstall-binPROGRAMS uninstall-info-am # 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: towitoko-2.0.7/src/test/tester.c0000644000175000017500000006574007527760757012342 /* Big bad tester application that runs against CT-API library. Handles up to four card-terminal interfaces simultaneously. It issues commands for both synchronous and asynchronous cards. This file is part of the Unix driver for Towitoko smartcard readers Copyright (C) 2000 Carlos Prados This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #if !defined DEBUG_IO && !defined DEBUG_IFD && !defined DEBUG_ICC && !defined DEBUG_PROTOCOL && !defined DEBUG_CTAPI /* Define if you want multi-thread. Disabled by default if we are debugging */ #define MULTI_THREAD #endif #include #include #include #include #include #include #include "ctapi.h" #include "ctbcs.h" #if defined HAVE_PTHREAD_H && defined MULTI_THREAD #include #endif #ifdef HAVE_SYS_TIME_H #include #endif /* Default Class byte */ #define CLASS 0x00 /* Status of each card-terminal */ struct { unsigned short pn; /* Serial port (1..4), 0 if not assigned */ char port[16]; /* Descripton of port, printed in prompt */ int status; /* -1 void, 0 sync, 1 async */ unsigned char atr[33]; /* ATR bytes */ unsigned short atr_size; /* ATR size */ unsigned char cla; /* Class byte for commands */ #if defined HAVE_PTHREAD_H && defined MULTI_THREAD pthread_t thread; /* Monitoring thread for this ctn */ pthread_mutex_t mutex; /* Mutex for accessin this element */ #endif } ct_list[4]; /* Menu loop */ void menu_loop (void); /* Event handlers */ void Initialize (void); unsigned short Change (unsigned short); void Close (unsigned short); void SelectClass (unsigned short); void SelectFile (unsigned short); void GetResponse (unsigned short); void UpdateBinary (unsigned short); void ReadBinary (unsigned short); void VerifyKey (unsigned short); void SendPPS (unsigned short); void EnterPin (unsigned short); void ChangePin (unsigned short); void ReadData (unsigned short); void WriteData (unsigned short); #if defined HAVE_PTHREAD_H && defined MULTI_THREAD /* Asynchronous monitoring thread function */ void *Monitor (void *); #else /* Synchronous polling function */ unsigned short GetSmartcard (unsigned short); #endif /* Print status */ void PrintReport (void); /* Read bus and port */ unsigned short ReadPort (char port[16]); /* Calculate length of memory card */ unsigned GetMemoryLength(unsigned char * atr, unsigned length); /* Print array of bytes */ void PrintArray (unsigned char * buffer, unsigned length); int main (int argc, char *argv[]) { unsigned short ctn; /* Initialize status of ct's */ for (ctn = 0; ctn < 4; ctn++) { ct_list[ctn].pn = 0; ct_list[ctn].status = -1; ct_list[ctn].cla = CLASS; memset (ct_list[ctn].port, 0, 16); memset (ct_list[ctn].atr, 0, 33); ct_list[ctn].atr_size = 0; #if defined HAVE_PTHREAD_H && defined MULTI_THREAD pthread_mutex_init (&(ct_list[ctn].mutex), NULL); #endif } /* Start menu loop */ menu_loop (); /* Close all open ct's */ for (ctn = 0; ctn < 4; ctn++) { if (ct_list[ctn].pn != 0) { Close (ctn); #if defined HAVE_PTHREAD_H && defined MULTI_THREAD pthread_mutex_destroy (&(ct_list[ctn].mutex)); #endif } } return 0; } void menu_loop (void) { char option[32]; unsigned short ctn = 0, i; int dummy; while (1) { PrintReport (); printf ("Select option:\n"); /* Common menu */ printf ("in: Initialize new terminal\n"); printf ("ch: Change current terminal\n"); printf ("cl: Close current terminal\n"); /* Port is open */ if (ct_list[ctn].pn != 0) { /* Processor cards menu */ if (ct_list[ctn].status == 1) { printf ("sc: Select Class Byte (current: %02X)\n", ct_list[ctn].cla); printf ("sf: Select File\n"); printf ("gr: Get Response\n"); printf ("vk: Verify Key (Cryptoflex)\n"); printf ("rb: Read Binary\n"); printf ("ub: Update Binary\n"); printf ("pps: Send PPS\n"); } /* Memory card menu */ else if (ct_list[ctn].status == 0) { printf ("ep: Enter PIN\n"); printf ("cp: Change PIN\n"); printf ("rd: Read Data\n"); printf ("wd: Write Data\n"); } } printf ("*: Refresh Menu\n"); printf ("q: Quit\n"); if (ct_list[ctn].pn != 0) printf ("%s$ ", ct_list[ctn].port); else printf ("$ "); /* Get menu option */ scanf ("%s", option); dummy = getchar (); /* Convert input to lowercase */ for (i = 0; option[i]; i++) option[i] = tolower ((int) option[i]); /* Common options */ if (strcmp (option, "q") == 0) break; else if (strcmp (option, "in") == 0) Initialize (); else if (strcmp (option, "ch") == 0) ctn = Change (ctn); else if (strcmp (option, "cl") == 0) Close (ctn); /* Processor card options */ if (ct_list[ctn].status == 1) { if (strcmp (option, "sc") == 0) SelectClass (ctn); else if (strcmp (option, "sf") == 0) SelectFile (ctn); else if (strcmp (option, "gr") == 0) GetResponse (ctn); else if (strcmp (option, "vk") == 0) VerifyKey (ctn); else if (strcmp (option, "rb") == 0) ReadBinary (ctn); else if (strcmp (option, "ub") == 0) UpdateBinary (ctn); else if (strcmp (option, "pps") == 0) SendPPS (ctn); } /* Memory card options */ else if (ct_list[ctn].status == 0) { if (strcmp (option, "ep") == 0) EnterPin (ctn); else if (strcmp (option, "cp") == 0) ChangePin (ctn); else if (strcmp (option, "rd") == 0) ReadData (ctn); else if (strcmp (option, "wd") == 0) WriteData (ctn); } } } void PrintReport (void) { unsigned short ctn, num, i; num = 0; for (ctn = 0; ctn < 4; ctn++) if (ct_list[ctn].pn != 0) num++; printf ("**********************************************************************\n"); printf ("Towitoko CT-API tester utility\n"); printf ("Copyright (C) 2000 2001 Carlos Prados \n"); printf ("Initilized CardTerminals: %d\n", num); for (ctn = 0; ctn < 4; ctn++) { if (ct_list[ctn].pn != 0) { #if defined HAVE_PTHREAD_H && defined MULTI_THREAD pthread_mutex_lock (&(ct_list[ctn].mutex)); #endif printf ("**********************************************************************\n"); printf ("%s\n", ct_list[ctn].port); printf ("Status: %s", ct_list[ctn].status == 0 ? "Memory smartcard present" : ct_list[ctn].status == 1 ? "Processor smartcard present" : "No smartcard present (type * to refresh)"); if (ct_list[ctn].status == 0) printf (". Memory size: %d bytes\n", GetMemoryLength(ct_list[ctn].atr, ct_list[ctn].atr_size)); else printf("\n"); if (ct_list[ctn].status != -1) { printf ("ATR: "); for (i = 0; i < ct_list[ctn].atr_size; i++) printf ("%02X ", ct_list[ctn].atr[i]); printf ("\n"); } #if defined HAVE_PTHREAD_H && defined MULTI_THREAD pthread_mutex_unlock (&(ct_list[ctn].mutex)); #endif } } printf ("**********************************************************************\n"); } #if !defined HAVE_PTHREAD_H || !defined MULTI_THREAD unsigned short GetSmartcard (unsigned short ctn) { unsigned char cmd[11], res[256], sad, dad; unsigned short lr, count; char ret; #ifdef HAVE_NANOSLEEP struct timespec req_ts; req_ts.tv_sec = 1; req_ts.tv_nsec = 0; #endif for (count = 0; count < 60; count ++) { /* Check if card is inserted */ cmd[0] = CTBCS_CLA; cmd[1] = CTBCS_INS_STATUS; cmd[2] = CTBCS_P1_CT_KERNEL; cmd[3] = CTBCS_P2_STATUS_ICC; cmd[4] = 0x00; dad = 1; sad = 2; lr = 256; ret = CT_data (ctn, &dad, &sad, 11, cmd, &lr, res); if ((ret != OK) || (res[lr-2] != 0x90)) { fprintf (stderr, "\nError getting status of terminal: %d\n", ret); return 0; } if (res[0] == CTBCS_DATA_STATUS_CARD_CONNECT) { if (count > 1) printf("\n"); printf ("Activating card...\n"); /* Activate card */ cmd[0] = CTBCS_CLA; cmd[1] = CTBCS_INS_REQUEST; cmd[2] = CTBCS_P1_INTERFACE1; cmd[3] = CTBCS_P2_REQUEST_GET_ATR; cmd[4] = 0x00; dad = 0x01; sad = 0x02; lr = 256; ret = CT_data (ctn, &dad, &sad, 5, cmd, &lr, res); if ((ret != OK) || (res[lr - 2] != 0x90)) { fprintf (stderr, "Error activating card: %d\n", ret); return 0; } /* Store the type of card */ ct_list[ctn].status = res[lr - 1]; /* Store ATR */ memcpy (ct_list[ctn].atr, res, lr - 2); ct_list[ctn].atr_size = lr - 2; return 1; } else { if (count > 0) { printf ("."); fflush (stdout); } else printf ("Please insert a smartcard in the terminal\n"); } #ifdef HAVE_NANOSLEEP nanosleep (&req_ts, NULL); #else usleep (999999); #endif } printf ("\nTimeout waiting for smartcard insertion\n"); return 0; } #else void * Monitor (void *arg) { unsigned char cmd[5], res[256], sad, dad; unsigned short lr, ctn; char ret; #ifdef HAVE_NANOSLEEP struct timespec req_ts; req_ts.tv_sec = 1; req_ts.tv_nsec = 0; #endif ctn = *(unsigned short *) arg; free (arg); while (ct_list[ctn].pn != 0) { /* Check if card is inserted */ cmd[0] = CTBCS_CLA; cmd[1] = CTBCS_INS_STATUS; cmd[2] = CTBCS_P1_CT_KERNEL; cmd[3] = CTBCS_P2_STATUS_ICC; cmd[4] = 0x00; dad = 1; sad = 2; lr = 256; ret = CT_data (ctn, &dad, &sad, 5, cmd, &lr, res); if ((ret != OK) || (res[lr-2] != 0x90)) continue; pthread_mutex_lock (&(ct_list[ctn].mutex)); if (res[0] == CTBCS_DATA_STATUS_CARD_CONNECT) { if (ct_list[ctn].status == -1) { /* Activate card */ cmd[0] = CTBCS_CLA; cmd[1] = CTBCS_INS_REQUEST; cmd[2] = CTBCS_P1_INTERFACE1; cmd[3] = CTBCS_P2_REQUEST_GET_ATR; cmd[4] = 0x00; dad = 0x01; sad = 0x02; lr = 256; ret = CT_data (ctn, &dad, &sad, 5, cmd, &lr, res); if ((ret != OK) || (res[lr - 2] != 0x90)) { pthread_mutex_unlock (&(ct_list[ctn].mutex)); continue; } /* Store the type of card */ ct_list[ctn].status = res[lr - 1]; /* Store ATR */ memcpy (ct_list[ctn].atr, res, lr - 2); ct_list[ctn].atr_size = lr - 2; pthread_mutex_unlock (&(ct_list[ctn].mutex)); } } else { if (ct_list[ctn].status != -1) { ct_list[ctn].status = -1; memset (ct_list[ctn].atr, 0, 33); ct_list[ctn].atr_size = 0; } } pthread_mutex_unlock (&(ct_list[ctn].mutex)); #ifdef HAVE_NANOSLEEP nanosleep (&req_ts, NULL); #else usleep(999999); #endif } return NULL; } #endif unsigned short ReadPort(char port[16]) { unsigned short pn; scanf("%6s", port); if(strncasecmp(port,"COM",3) == 0) { sscanf(port+3,"%hu",&pn); snprintf(port,16,"COM%hu",pn); } else if (strncasecmp(port,"USB",3) == 0) { sscanf(port+3,"%hu",&pn); snprintf(port,16,"USB%hu",pn); pn += 32768; } else { sscanf(port,"%hu",&pn); snprintf(port,16,"COM%hu",pn); } return pn; } unsigned GetMemoryLength(unsigned char * atr, unsigned length) { if (length < 2) return 0; /* This line is dedicated to Rene Puls ;-) */ return( 1 << (((int)(atr[1] & 120) >> 3)+6) * 1 << (int)(atr[1] & 7) / 8); } void PrintArray (unsigned char * buffer, unsigned length) { unsigned i; if (length > 16) printf ("\n"); for (i=0; i 4) { printf ("Maximum number of ports open\n"); return; } printf ("Initializing terminal at %s...\n",port); #ifndef CTAPI_WIN32_COM ret = CT_init (ctn, pn - 1); #else ret = CT_init (ctn, pn); #endif if (ret != OK) { fprintf (stderr, "Error on port allocation: %d\n", ret); return; } strncpy(ct_list[ctn].port,port,16); ct_list[ctn].pn = pn; #if defined HAVE_PTHREAD_H && defined MULTI_THREAD { unsigned short *arg; arg = (unsigned short *) malloc (sizeof (unsigned short)); (*arg) = ctn; printf ("Starting terminal monitoring job...\n"); pthread_create (&(ct_list[ctn].thread), NULL, Monitor, (void *) arg); { /* Wait 0.1 seconds before returning to the menu loop to give time the monitor thread to adquire the mutex */ #ifdef HAVE_NANOSLEEP struct timespec req_ts; req_ts.tv_sec = 0; req_ts.tv_nsec = 100000000; nanosleep (&req_ts, NULL); #else usleep(100000); #endif } } #else if (!GetSmartcard (ctn)) Close (ctn); #endif } unsigned short Change (unsigned short ctn) { unsigned short pn, i; char port[16]; /* Show the list of open ports */ printf ("Port number ("); for (i = 0; i < 4; i++) { if (ct_list[i].pn != 0) printf ("%s", ct_list[i].port); if (i + 1 < 4) { if (ct_list[i + 1].pn != 0) printf (", "); } else printf ("): "); } pn = ReadPort(port); /* Search the ctn */ for (i = 0; i < 4; i++) { if (ct_list[i].pn == pn) break; } if (i >= 4) { printf ("Invalid port number\n"); return ctn; } return i; } void Close (unsigned short ctn) { char ret; if ((ct_list[ctn].pn == 0) && (ct_list[ctn].status == -1)) { printf ("Port not open\n"); return; } #if defined HAVE_PTHREAD_H && defined MULTI_THREAD pthread_mutex_lock (&(ct_list[ctn].mutex)); #endif ct_list[ctn].pn = 0; ct_list[ctn].status = -1; memset (ct_list[ctn].atr, 0, 33); ct_list[ctn].atr_size = 0; #if defined HAVE_PTHREAD_H && defined MULTI_THREAD pthread_mutex_unlock (&(ct_list[ctn].mutex)); printf ("Waiting for terminal monitoring job to stop...\n"); pthread_join(ct_list[ctn].thread ,NULL); #endif printf ("Closing terminal at %s\n", ct_list[ctn].port); ret = CT_close (ctn); if (ret != OK) printf ("Error closing terminal at %s\n", ct_list[ctn].port); } void SelectClass (unsigned short ctn) { unsigned char buffer[32]; int dummy; printf ("Class byte (current is %02X): ", ct_list[ctn].cla); scanf ("%X", (unsigned int *) buffer); dummy = getchar (); #if defined HAVE_PTHREAD_H && defined MULTI_THREAD pthread_mutex_lock (&(ct_list[ctn].mutex)); #endif ct_list[ctn].cla = buffer[0]; #if defined HAVE_PTHREAD_H && defined MULTI_THREAD pthread_mutex_unlock (&(ct_list[ctn].mutex)); #endif } void SelectFile (unsigned short ctn) { unsigned char select_file[8] = { CLASS, 0xA4, 0x00, 0x00, 0x02, 0x3f, 0x00, 0x00 }; unsigned char buffer[32]; unsigned char res[256]; unsigned char dad; unsigned char sad; unsigned short lr; int dummy; char ret; select_file[0] = ct_list[ctn].cla; printf ("File ID: "); scanf ("%X %X", (unsigned int *) buffer, (unsigned int *) buffer + 1); dummy = getchar (); select_file[5] = buffer[0]; select_file[6] = buffer[1]; dad = 0; sad = 2; lr = 256; printf ("Command: "); PrintArray (select_file, 8); ret = CT_data (ctn, &dad, &sad, 8, select_file, &lr, res); if (ret != OK) { fprintf (stderr, "Error in SELECT FILE: %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); } void GetResponse (unsigned short ctn) { unsigned char get_response[5] = { CLASS, 0xC0, 0x00, 0x00, 0x00 }; char buffer[32]; unsigned char res[256]; unsigned char dad; unsigned char sad; unsigned short lr; int dummy; char ret; get_response[0] = ct_list[ctn].cla; printf ("Response size (hexadecimal): "); scanf ("%X", (unsigned int *) buffer); dummy = getchar (); get_response[4] = buffer[0]; dad = 0; sad = 2; lr = 256; printf ("Command: "); PrintArray (get_response, 5); ret = CT_data (ctn, &dad, &sad, 5, get_response, &lr, res); if (ret != OK) { fprintf (stderr, "Error on GET RESPONSE: %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); } void UpdateBinary (unsigned short ctn) { unsigned char update_binary[260] = { CLASS, 0xD6, 0x00, 0x00, 0x00 }; char buffer[32]; unsigned char res[256]; unsigned char dad; unsigned char sad; unsigned short lr; int size, dummy; char ret; update_binary[0] = ct_list[ctn].cla; printf ("File size (0..255): "); scanf ("%d", &size); dummy = getchar (); update_binary[4] = (unsigned char) (size % 256); printf ("Data: "); scanf ("%02X", (unsigned int *) buffer); dummy = getchar (); memset(update_binary + 5, buffer[0], update_binary[4]); dad = 0; sad = 2; lr = 256; printf ("Command: "); PrintArray (update_binary, update_binary[4] + 5); ret = CT_data (ctn, &dad, &sad, (int) update_binary[4] + 5, update_binary, &lr, res); if (ret != OK) { fprintf (stderr, "Error on UPDATE BYNARY: %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); } void ReadBinary (unsigned short ctn) { unsigned char read_binary[5] = { CLASS, 0xB0, 0x00, 0x00, 0x00 }; char buffer[32]; unsigned char res[258]; unsigned char dad; unsigned char sad; unsigned short lr; int dummy; char ret; read_binary[0] = ct_list[ctn].cla; /* Read binary */ printf ("File size: "); scanf ("%X", (unsigned int *) buffer); dummy = getchar (); read_binary[4] = buffer[0]; dad = 0; sad = 2; lr = 258; printf ("Command: "); PrintArray (read_binary, 5); ret = CT_data (ctn, &dad, &sad, 5, read_binary, &lr, res); if (ret != OK) { fprintf (stderr, "Error on READ BYNARY: %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); } void VerifyKey (unsigned short ctn) { unsigned char verify_key[13] = { CLASS, 0x2A, 0x00, 0x01, 0x08, 0x47, 0x46, 0x58, 0x49, 0x32, 0x56, 0x78, 0x40 }; unsigned char res[256]; unsigned char dad; unsigned char sad; unsigned short lr; char ret; verify_key[0] = ct_list[ctn].cla; dad = 0; sad = 2; lr = 256; printf ("Command: "); PrintArray (verify_key, 13); ret = CT_data (ctn, &dad, &sad, 13, verify_key, &lr, res); if (ret != OK) { fprintf (stderr, "Error on VERIFY KEY: %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); } void SendPPS (unsigned short ctn) { unsigned char reset[9] = {0x20, 0x11, 0x01, 0x01, 0x03, 0xFF, 0x00, 0x00, 0x00}; unsigned char buffer[32], res[256]; unsigned char dad, sad; unsigned short lr; int dummy; char ret; printf ("PPS request (PPSS PPS0 PPS1): "); scanf ("%X %X %X", (unsigned int *) buffer, (unsigned int *) buffer + 1, (unsigned int *) buffer + 2); dummy = getchar (); reset[5] = buffer[0]; reset[6] = buffer[1]; reset[7] = buffer[2]; dad = 0x01; sad = 0x02; lr = 256; printf ("Command: "); PrintArray (reset, 8); ret = CT_data (ctn, &dad, &sad, 9, reset, &lr, res); if (ret != OK) { fprintf (stderr, "Error on Reset CT (Send PPS): %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); } void EnterPin (unsigned short ctn) { unsigned char verify[8] = { 0x00, 0x20, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00 }; unsigned char buffer[32]; unsigned char res[256]; unsigned char dad; unsigned char sad; unsigned short lr; int dummy; char ret; printf ("PIN (3 bytes): "); scanf ("%X %X %X", (unsigned int *) buffer, (unsigned int *) buffer + 1, (unsigned int *) buffer + 2); dummy = getchar (); verify[5] = buffer[0]; verify[6] = buffer[1]; verify[7] = buffer[2]; dad = 0; sad = 2; lr = 256; printf ("Command: "); PrintArray (verify, 8); ret = CT_data (ctn, &dad, &sad, 8, verify, &lr, res); if (ret != OK) { fprintf (stderr, "Error on VERIFY: %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); } void ChangePin (unsigned short ctn) { unsigned char change[11] = { 0x00, 0x24, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; unsigned char buffer[32]; unsigned char res[256]; unsigned char dad; unsigned char sad; unsigned short lr; int dummy; char ret; printf ("PIN (3 bytes): "); scanf ("%X %X %X", (unsigned int *) buffer, (unsigned int *) buffer + 1, (unsigned int *) buffer + 2); dummy = getchar (); change[5] = buffer[0]; change[6] = buffer[1]; change[7] = buffer[2]; printf ("New PIN (3 bytes): "); scanf ("%X %X %X", (unsigned int *) buffer, (unsigned int *) buffer + 1, (unsigned int *) buffer + 2); dummy = getchar (); change[8] = buffer[0]; change[9] = buffer[1]; change[10] = buffer[2]; dad = 0; sad = 2; lr = 256; printf ("Command: "); PrintArray (change, 11); ret = CT_data (ctn, &dad, &sad, 11, change, &lr, res); if (ret != OK) { fprintf (stderr, "Error on CHANGE VERIFICATION DATA: %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); } void ReadData (unsigned short ctn) { unsigned char select_file[7] = { 0x00, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00 }; unsigned char read_binary[6] = { 0x00, 0xB0, 0x00, 0x00, 0x00, 0x00 }; int address; int size, total_size; unsigned char * res; unsigned char dad; unsigned char sad; unsigned short lr, lc; int dummy; char ret; printf ("Address: "); scanf ("%d", &address); dummy = getchar (); read_binary[2] = (unsigned char) (address >> 8); read_binary[3] = (unsigned char) (address & 0x00FF); total_size = GetMemoryLength(ct_list[ctn].atr, ct_list[ctn].atr_size); printf ("Size (0..%d): ", total_size); scanf ("%d", &size); dummy = getchar (); if (size < 256) { read_binary[4] = (unsigned char) size; lc = 5; } else { read_binary[4] = 0; read_binary[5] = (unsigned char) (size >> 8); read_binary[6] = (unsigned char) (size & 0x00FF); lc = 7; } printf ("Command: "); PrintArray (select_file, 7); dad = 0; sad = 2; res = calloc ((lr = 2), sizeof (unsigned char)); /* Select MF */ ret = CT_data (ctn, &dad, &sad, 7, select_file, &lr, res); if (ret != OK) { fprintf (stderr, "Error on SELECT FILE: %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); free (res); printf ("Command: "); PrintArray (read_binary, lc); dad = 0; sad = 2; if (size != 0) res = calloc ((lr = size + 2), sizeof (unsigned char)); else res = calloc ((lr = total_size + 2), sizeof (unsigned char)); if (res == NULL) return; /* Read binary */ ret = CT_data (ctn, &dad, &sad, lc, read_binary, &lr, res); if (ret != OK) { fprintf (stderr, "Error on READ BINARY: %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); free (res); } void WriteData (unsigned short ctn) { unsigned char select_file[7] = { 0x00, 0xA4, 0x00, 0x00, 0x02, 0x3F, 0x00 }; unsigned char * update_binary; int address; int size, total_size; unsigned char buffer[32]; unsigned char res[256]; unsigned char dad; unsigned char sad; unsigned short lr, lc; int dummy; char ret; printf ("Address: "); scanf ("%d", &address); dummy = getchar (); total_size = GetMemoryLength(ct_list[ctn].atr, ct_list[ctn].atr_size); printf ("Size (0..%d): ", total_size); scanf ("%d", &size); dummy = getchar (); printf ("Data: "); scanf ("%X", (unsigned int *) buffer); dummy = getchar (); if (size < 256) { update_binary = calloc (size +5, sizeof (unsigned char)); if (update_binary == NULL) return; update_binary[0] = 0x00; update_binary[1] = 0xD6; update_binary[2] = (unsigned char) (address >> 8); update_binary[3] = (unsigned char) (address & 0x00FF); update_binary[4] = size; memset (update_binary+5, buffer[0], size); lc = size + 5; } else { update_binary = calloc (size +7, sizeof (unsigned char)); if (update_binary == NULL) return; update_binary[0] = 0x00; update_binary[1] = 0xD6; update_binary[2] = (unsigned char) (address >> 8); update_binary[3] = (unsigned char) (address & 0x00FF); update_binary[4] = 0; update_binary[5] = (unsigned char) (size >> 8); update_binary[6] = (unsigned char) (size & 0x00FF); memset (update_binary+7, buffer[0], size); lc = size +7; } printf ("Command: "); PrintArray (select_file, 7); dad = 0; sad = 2; lr = 256; /* Select MF */ ret = CT_data (ctn, &dad, &sad, 7, select_file, &lr, res); if (ret != OK) { fprintf (stderr, "Error on SELECT FILE: %d\n", ret); free (update_binary); return; } printf ("Response: "); PrintArray (res, lr); printf ("Command: "); PrintArray (update_binary, lc); dad = 0; sad = 2; lr = 256; /* Update binary */ ret = CT_data (ctn, &dad, &sad, lc, update_binary, &lr, res); free (update_binary); if (ret != OK) { fprintf (stderr, "Error on UPDATE BINARY: %d\n", ret); return; } printf ("Response: "); PrintArray (res, lr); } towitoko-2.0.7/doc/0002777000175000017500000000000007527763751007736 5towitoko-2.0.7/doc/Makefile.am0000644000175000017500000000342307521014347011666 # # doc/Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # EXTRA_DIST = reader.conf design.sgml design.html \ ctapi.sgml ctapi.3 ctbcs.sgml ctbcs.3 Info.plist man_MANS = ctapi.3 ctbcs.3 noinst_DATA = design.html %.3 : %.sgml if HAVE_DOCBOOK_TO_MAN docbook-to-man $< >$@ else : Warning: missing docbook-to-man, cannot make $@ echo ".TH $< 1" >$@ echo "No man page due to missing docbook-to-man" >>$@ endif %.html : %.sgml -sgmltools -b onehtml $< install-data-hook: (cd $(DESTDIR)$(man3dir) && \ test -f CT_init.3 || $(LN_S) ctapi.3 CT_init.3 && \ test -f CT_data.3 || $(LN_S) ctapi.3 CT_data.3 && \ test -f CT_close.3 || $(LN_S) ctapi.3 CT_close.3) if INSTALL_USB_BUNDLE install -D -m 644 Info.plist "@PCSC_LITE_DIR@/drivers/towitoko.bundle/Contents/Info.plist" endif uninstall-hook: (cd $(DESTDIR)$(man3dir) && rm -f CT_init.3 CT_data.3 CT_close.3) if INSTALL_USB_BUNDLE rm -f "@PCSC_LITE_DIR@/drivers/towitoko.bundle/Contents/Info.plist" endif towitoko-2.0.7/doc/Makefile.in0000644000175000017500000002176407527762031011715 # Makefile.in generated by automake 1.6.3 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 # 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@ # # doc/Makefile.am # # This file is part of the Unix driver for Towitoko smartcard readers # Copyright (C) 2000 Carlos Prados # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # SHELL = @SHELL@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ sbindir = @sbindir@ libexecdir = @libexecdir@ datadir = @datadir@ sysconfdir = @sysconfdir@ sharedstatedir = @sharedstatedir@ localstatedir = @localstatedir@ libdir = @libdir@ infodir = @infodir@ mandir = @mandir@ includedir = @includedir@ oldincludedir = /usr/include pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. ACLOCAL = @ACLOCAL@ AUTOCONF = @AUTOCONF@ AUTOMAKE = @AUTOMAKE@ AUTOHEADER = @AUTOHEADER@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_HEADER = $(INSTALL_DATA) transform = @program_transform_name@ NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : host_alias = @host_alias@ host_triplet = @host@ EXEEXT = @EXEEXT@ OBJEXT = @OBJEXT@ PATH_SEPARATOR = @PATH_SEPARATOR@ AMTAR = @AMTAR@ AS = @AS@ AWK = @AWK@ CC = @CC@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DOCBOOK_TO_MAN = @DOCBOOK_TO_MAN@ ECHO = @ECHO@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LIBTOOL = @LIBTOOL@ LN_S = @LN_S@ OBJDUMP = @OBJDUMP@ PACKAGE = @PACKAGE@ PCSC_LITE_DIR = @PCSC_LITE_DIR@ RANLIB = @RANLIB@ STRIP = @STRIP@ VERSION = @VERSION@ am__include = @am__include@ am__quote = @am__quote@ install_sh = @install_sh@ EXTRA_DIST = reader.conf design.sgml design.html \ ctapi.sgml ctapi.3 ctbcs.sgml ctbcs.3 Info.plist man_MANS = ctapi.3 ctbcs.3 noinst_DATA = design.html subdir = doc mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = DIST_SOURCES = NROFF = nroff MANS = $(man_MANS) DATA = $(noinst_DATA) DIST_COMMON = Makefile.am Makefile.in all: all-am .SUFFIXES: $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4) cd $(top_srcdir) && \ $(AUTOMAKE) --gnu doc/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe) mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool uninstall-info-am: man3dir = $(mandir)/man3 install-man3: $(man3_MANS) $(man_MANS) @$(NORMAL_INSTALL) $(mkinstalldirs) $(DESTDIR)$(man3dir) @list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ for i in $$l2; do \ case "$$i" in \ *.3*) 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 \ 3*) ;; \ *) ext='3' ;; \ 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)$(man3dir)/$$inst"; \ $(INSTALL_DATA) $$file $(DESTDIR)$(man3dir)/$$inst; \ done uninstall-man3: @$(NORMAL_UNINSTALL) @list='$(man3_MANS) $(dist_man3_MANS) $(nodist_man3_MANS)'; \ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ for i in $$l2; do \ case "$$i" in \ *.3*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ 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)$(man3dir)/$$inst"; \ rm -f $(DESTDIR)$(man3dir)/$$inst; \ done tags: TAGS TAGS: DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) top_distdir = .. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) @list='$(DISTFILES)'; for file in $$list; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkinstalldirs) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ 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 check-am: all-am check: check-am all-am: Makefile $(MANS) $(DATA) installdirs: $(mkinstalldirs) $(DESTDIR)$(man3dir) 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_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -rm -f Makefile $(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-generic clean-libtool mostlyclean-am distclean: distclean-am distclean-am: clean-am distclean-generic distclean-libtool dvi: dvi-am dvi-am: info: info-am info-am: install-data-am: install-man @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-exec-am: install-info: install-info-am install-man: install-man3 installcheck-am: maintainer-clean: maintainer-clean-am maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic mostlyclean-libtool uninstall-am: uninstall-info-am uninstall-man @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) uninstall-hook uninstall-man: uninstall-man3 .PHONY: all all-am check check-am clean clean-generic clean-libtool \ distclean distclean-generic distclean-libtool distdir dvi \ dvi-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-man3 install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic \ mostlyclean-libtool uninstall uninstall-am uninstall-info-am \ uninstall-man uninstall-man3 %.3 : %.sgml @HAVE_DOCBOOK_TO_MAN_TRUE@ docbook-to-man $< >$@ @HAVE_DOCBOOK_TO_MAN_FALSE@ : Warning: missing docbook-to-man, cannot make $@ @HAVE_DOCBOOK_TO_MAN_FALSE@ echo ".TH $< 1" >$@ @HAVE_DOCBOOK_TO_MAN_FALSE@ echo "No man page due to missing docbook-to-man" >>$@ %.html : %.sgml -sgmltools -b onehtml $< install-data-hook: (cd $(DESTDIR)$(man3dir) && \ test -f CT_init.3 || $(LN_S) ctapi.3 CT_init.3 && \ test -f CT_data.3 || $(LN_S) ctapi.3 CT_data.3 && \ test -f CT_close.3 || $(LN_S) ctapi.3 CT_close.3) @INSTALL_USB_BUNDLE_TRUE@ install -D -m 644 Info.plist "@PCSC_LITE_DIR@/drivers/towitoko.bundle/Contents/Info.plist" uninstall-hook: (cd $(DESTDIR)$(man3dir) && rm -f CT_init.3 CT_data.3 CT_close.3) @INSTALL_USB_BUNDLE_TRUE@ rm -f "@PCSC_LITE_DIR@/drivers/towitoko.bundle/Contents/Info.plist" # 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: towitoko-2.0.7/doc/reader.conf0000644000175000017500000000100107361617717011745 # Configuration file for IFD Handler 2.0 drivers # FRIENDLYNAME: Any name # DEVICENAME: Any name # LIBPATH: Location of the driver library for your reader # CHANNELID: # 0x000001 - COM1 # 0x000002 - COM2 # 0x000003 - COM3 # 0x000004 - COM4 # # Towitoko Chipdrive Micro (COM1) FRIENDLYNAME "Towitoko Chipdrive Micro" DEVICENAME TOWITOKO_CHIPDRIVE_MICRO LIBPATH /usr/local/towitoko/lib/libtowitoko.so.2.0.0 CHANNELID 0x000001 # Note: Use the full path on LIBPATH. towitoko-2.0.7/doc/design.sgml0000644000175000017500000002505007317644021011770
UNIX Towitoko Driver Design
cprados@yahoo.com
Carlos Prados 2001Carlos Prados 06-09-2001
This document explains the design guidelines followed for the implementation of this driver. You may be interested in reading this document if you intend to extend, improve, fix or some other way modify the source code of this software. Architectural Design The driver is composed of two distinct parts: the core driver and the interfaces. The core driver has the responsibility of handling the reader. It's code is tied to the reader hardware and interface, etc. The interfaces are located in separate directories, and use the API provided by the core driver to implement an interface specification, on top of the core driver. Currently there are two interfaces implemented: CT-API / CT-BCS and PCSC Lite IFD Handler, but other interfaces could be written. The driver is designed following an object oriented style. There are several classes implemented as Abstract Data Types, that interact to provide the whole functionality. Also there exists several communication layers, each containing a set of classes. The Core Driver The core driver has the following layers: IO Provides Input/Output communication with the device to which the reader is attached. An IO_Serial object provides access and configuration the serial port. IFD Provides access to the functionality of one interface device, such as transparent transmission and reception, reading and writing of memory buffers, etc. One or more IFD's can be attached to the same IO object. The IFD_Towitoko class provides this functionality for Towitoko reader. ICC This layer abstracts the upper layer from the issues related to having different types of integrated circuit cards. There are two objects within this layer: ICC_Async that encapsulates the functionality to access asynchronous (processor) cards, and ICC_Sync that does the equivalent for synchronous (memory) cards. Only one ICC object can be attached to the same IFD at a time. Protocol Implements card access via commands and responses. A different protocol implementation is needed depending on the type of ICC. Protocol_Sync class provides a command interface for synchronous cards. Protocol_T0 class provides a command interface for processor cards using T=0 protocol. Protocol_T1 class provides a command interface for processor cards using T=1 protocol. Only one Protocol object is attached to one ICC object. The following diagram illustrates the class structure of the core driver. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +---------------+ +---------------+ +---------------+ Protocol Layer | Protocol_Sync | | Protocol_T0 | | Protocol_T1 | +---------------+ +---------------+ +---------------+ - - - - - - - - - - - - | - - - - - - - - - | - - - - - - - - - | - - - - - v v v +---------------+ +-----------------------------------+ ICC Layer | ICC_Sync | | ICC_Async | +---------------+ +-----------------------------------+ - - - - - - - - - - - - | - - - - - - - - - - - - - - | - - - - - - - - - - v v +-------------------------------------------------------+ IFD Layer | IFD_Towitoko | +-------------------------------------------------------+ - - - - - - - - - - - - - - - - - - - - - - | - - - - - - - - - - - - - - - v +-------------------------------------------------------+ IO Layer | IO_Serial | +-------------------------------------------------------+ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - POSIX I/0 routines There is also a set of utility classes that represent data exchanged between layers, such as ATR and ATR_Sync that conveys the answer to reset of the smartcards, and the APDU_Cmd and APDU_Rsp classes that handle command and response messages exchanged between the application and the protocol layer. Each object contains the data and the methods for creating, accessing, and deleting it. The CT-API / CT-BCS Interface The CT-API interface interacts with the classes provided by the core driver to implement the function calls defined in the CT-API and CT-BCS specification. The CT-API has access to every class defined in the core driver, so it can create the objects and call its functionality as it is needed. CT-API / CT_BCS interface contains three classes: CardTerminal A CardTerminal object represent one reader with any number of ICC slots, that is attached to a serial port. A CardTerminal can be initialized, sent a CT-BCS control command and closed. CT_Slot A CT_Slot object represent one slot located in a CardTerminal. It contains one IFD object, which can have one ICC inserted and one Protocol object to handle the ICC. A CT_Slot object can be initialized and closed by the CardTerminal, accept commands for the ICC, and has control methods for checking the presence of card and detecting the type of card inserted. CT_List The CT-API interface defines that any number of CardTerminals can be attached to a single machine, each one accessible via a ctn number. CT_List implements a linked list that stores CardTerminal objects that are created by the user, so they can be obtained and erased giving its ctn identification. The following diagram represent the interactions between the CT-API / CT-BCS interface and the layers of the core driver. +-------------------------------+ | CT-API / CT-BCS | +-------+-----------------------+ | | CT_Slot | | | +---------------+ | | | Protocol | | | |---------------| | | | ICC | | | |---------------| | | | IFD | | +-------+---------------+ | CardTerminal | IO | +---------------+---------------+ The PCSC Lite IFD Handler Interface The PCSC IFD handler is a simple layer on top of CT-API / CT-BCS interface that implements the mapping to the functions needed to access the driver via MUSCLE PCSC Lite Resource manager. Multi-Threading Design This chapter explains guidelines followed in order to thread-enable the access to smartcard and terminal resources provided by the driver. The goal is allow a Multi-threading application to use one or more readers and smartcards from one or more threads concurrently, managing the access to shared resources as efficiently as possible. The responsibility of providing thread-safe functionality to the application is distributed between the core driver and the Interfaces: The core driver functions are reentrant, but not thread-safe: They do not use any static variable in read/write mode. They do not return a reference to static data. All data managed by functions are provided by the caller of the function. They do not call non-reentrant functions. They are not thread-safe because they share physical resources like the serial port, the smartcard and the reader, whose response depends on the order in which they receive events. It's not responsibility of the core driver to implement access in mutual exclusion to these resources. The Interfaces are thread-safe, but not necessarily reentrant: CT-API cannot be reentrant because it's design force to maintain a static list of card-terminal contexts. IFD Handler cannot be reentrant as far as it's based on CT-API interface. Both of these interfaces and future interfaces must implement mutual exclusion access to it's static variables, and serialize the access to the resources IO, IFD, ICC and Protocol, provided by the core driver.
towitoko-2.0.7/doc/design.html0000644000175000017500000002457007317644021012000 UNIX Towitoko Driver Design

UNIX Towitoko Driver Design

Carlos Prados


This document explains the design guidelines followed for the implementation of this driver. You may be interested in reading this document if you intend to extend, improve, fix or some other way modify the source code of this software.


Architectural Design

The driver is composed of two distinct parts: the core driver and the interfaces. The core driver has the responsibility of handling the reader. It's code is tied to the reader hardware and interface, etc.

The interfaces are located in separate directories, and use the API provided by the core driver to implement an interface specification, on top of the core driver. Currently there are two interfaces implemented: CT-API / CT-BCS and PCSC Lite IFD Handler, but other interfaces could be written.

The driver is designed following an object oriented style. There are several classes implemented as Abstract Data Types, that interact to provide the whole functionality.

Also there exists several communication layers, each containing a set of classes.


The Core Driver

The core driver has the following layers:

IO,

Provides Input/Output communication with the device to which the reader is attached. An IO_Serial object provides access and configuration the serial port.

IFD,

Provides access to the functionality of one interface device, such as transparent transmission and reception, reading and writing of memory buffers, etc. One or more IFD's can be attached to the same IO object. The IFD_Towitoko class provides this functionality for Towitoko reader.

ICC,

This layer abstracts the upper layer from the issues related to having different types of integrated circuit cards. There are two objects within this layer: ICC_Async that encapsulates the functionality to access asynchronous (processor) cards, and ICC_Sync that does the equivalent for synchronous (memory) cards. Only one ICC object can be attached to the same IFD at a time.

Protocol,

Implements card access via commands and responses. A different protocol implementation is needed depending on the type of ICC. Protocol_Sync class provides a command interface for synchronous cards. Protocol_T0 class provides a command interface for processor cards using T=0 protocol. Protocol_T1 class provides a command interface for processor cards using T=1 protocol. Only one Protocol object is attached to one ICC object.

The following diagram illustrates the class structure of the core driver.

  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                  +---------------+   +---------------+   +---------------+ 
  Protocol Layer  | Protocol_Sync |   |  Protocol_T0  |   |  Protocol_T1  |
                  +---------------+   +---------------+   +---------------+
  - - - - - - - - - - - - | - - - - - - - - - | - - - - - - - - - | - - - - -
                          v                   v                   v
                  +---------------+   +-----------------------------------+
  ICC Layer       |   ICC_Sync    |   |             ICC_Async             |
                  +---------------+   +-----------------------------------+
  - - - - - - - - - - - - | - - - - - - - - - - - - - - | - - - - - - - - - -
                          v                             v
                  +-------------------------------------------------------+
  IFD Layer       |                      IFD_Towitoko                     | 
                  +-------------------------------------------------------+
  - - - - - - - - - - - - - - - - - - - - - - | - - - - - - - - - - - - - - -
                                              v
                  +-------------------------------------------------------+
  IO Layer        |                       IO_Serial                       |
                  +-------------------------------------------------------+
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        
                                      POSIX I/0 routines

There is also a set of utility classes that represent data exchanged between layers, such as ATR and ATR_Sync that conveys the answer to reset of the smartcards, and the APDU_Cmd and APDU_Rsp classes that handle command and response messages exchanged between the application and the protocol layer. Each object contains the data and the methods for creating, accessing, and deleting it.


The CT-API / CT-BCS Interface

The CT-API interface interacts with the classes provided by the core driver to implement the function calls defined in the CT-API and CT-BCS specification. The CT-API has access to every class defined in the core driver, so it can create the objects and call its functionality as it is needed.

CT-API / CT_BCS interface contains three classes:

CardTerminal,

A CardTerminal object represent one reader with any number of ICC slots, that is attached to a serial port. A CardTerminal can be initialized, sent a CT-BCS control command and closed.

CT_Slot,

A CT_Slot object represent one slot located in a CardTerminal. It contains one IFD object, which can have one ICC inserted and one Protocol object to handle the ICC. A CT_Slot object can be initialized and closed by the CardTerminal, accept commands for the ICC, and has control methods for checking the presence of card and detecting the type of card inserted.

CT_List,

The CT-API interface defines that any number of CardTerminals can be attached to a single machine, each one accessible via a ctn number. CT_List implements a linked list that stores CardTerminal objects that are created by the user, so they can be obtained and erased giving its ctn identification.

The following diagram represent the interactions between the CT-API / CT-BCS interface and the layers of the core driver.

                        +-------------------------------+
                        |         CT-API / CT-BCS       |
                        +-------+-----------------------+
                        |       |        CT_Slot        |
                        |       |       +---------------+
                        |       |       |    Protocol   |
                        |       |       |---------------|
                        |       |       |      ICC      |
                        |       |       |---------------|
                        |       |       |      IFD      |
                        |       +-------+---------------+
                        | CardTerminal  |      IO       |
                        +---------------+---------------+

The PCSC Lite IFD Handler Interface

The PCSC IFD handler is a simple layer on top of CT-API / CT-BCS interface that implements the mapping to the functions needed to access the driver via MUSCLE PCSC Lite Resource manager.


Multi-Threading Design

This chapter explains guidelines followed in order to thread-enable the access to smartcard and terminal resources provided by the driver.

The goal is allow a Multi-threading application to use one or more readers and smartcards from one or more threads concurrently, managing the access to shared resources as efficiently as possible.

The responsibility of providing thread-safe functionality to the application is distributed between the core driver and the Interfaces:

The core driver functions are reentrant, but not thread-safe:

  • They do not use any static variable in read/write mode.

  • They do not return a reference to static data. All data managed by functions are provided by the caller of the function.

  • They do not call non-reentrant functions.

  • They are not thread-safe because they share physical resources like the serial port, the smartcard and the reader, whose response depends on the order in which they receive events. It's not responsibility of the core driver to implement access in mutual exclusion to these resources.

The Interfaces are thread-safe, but not necessarily reentrant:

  • CT-API cannot be reentrant because it's design force to maintain a static list of card-terminal contexts.

  • IFD Handler cannot be reentrant as far as it's based on CT-API interface.

  • Both of these interfaces and future interfaces must implement mutual exclusion access to it's static variables, and serialize the access to the resources IO, IFD, ICC and Protocol, provided by the core driver.

towitoko-2.0.7/doc/ctapi.sgml0000644000175000017500000002665607402223267011634
cprados@yahoo.com
Carlos Prados 2001Carlos Prados 06-03-2001
CT-API 3 CT_init, CT_data, CT_close CT_init CT_data CT_close Functions to handle communication with integrated circuit cards and cardterminals #include <ctapi.h> char CT_init unsigned short ctn unsigned short pn char CT_data unsigned short ctn unsigned char * dad unsigned char * sad unsigned short lenc unsigned char * command unsigned short * lenr unsigned char * response char CT_close unsigned short ctn DESCRIPTION This manual page describes the CT-API functions used to handle communication with integrated circuit cards and cardterminals. The CT-API functions are generic, and allows the use of memory cards (often referred as synchronous cards) and processor cards (often referred as asynchronous cards). The CT-API implementation is dependent on the cardterminal that is used. For each cardterminal a CT-API library implementation should be provided, either by the manufacturer or by third parties. This manpage is not a complete specification of the CT-API, but a general overview of the most common functionalities. CT_init() selects and initializes the interface with the cardterminal (f.i. serial port, USB bus, or any other type of connector). The CT_init() function must be called before communicating with the card or the cardterminal. A unique cardterminal number chosen by the caller is assigned by the CT-API library to the initialized connection. ctn Cardterminal number: identifies the connection with the cardterminal for further references. It's chosen by the caller of the function. pn Port number: selects the physical interface. The port number assignment is dependent on the CT-API implementation. However most serial cardterminal implementations use the convention of assigning the value 0 to the first serial port, 1 to the second serial port and so on. See the file /usr/include/ctapi.h of your CT-API implementation for a list of allowed values. CT_data() sends a command to the card or to the cardterminal and returns the response to the calling program. ctn Cardterminal number: the number specified in CT_init() call for this cardterminal. dad Destination address. If the command is sent to the cardterminal, it must point to a variable containing the value CT (0x01). If the command is sent to a card, the destination address variable must be set to the number identifying the slot of the cardterminal where the card is inserted, ranging from ICC1 (0x00) and ICC2 (0x02) to ICC14 (0x0E). On the return of the response, the variable pointed by dad is set to the value HOST (0x02) or REMOTE_HOST (0x05). sad Source address. When the function is called it is usually set to point to a variable with the value HOST (0x02), although the value REMOTE_HOST (0x05) may ocurr in some applications if the CT-API implementation supports remote calls. On the return of the response, the variable pointed by sad is set to any of the values from CT (0x01), ICC1 (0x00), ICC2 (0x02) to ICC14 (0x0E). lenc Command length in bytes. command Pointer to the buffer that conveys the command to be sent to the card or cardterminal. lenr Before function call, pointer to a variable containig the maximum buffer size in bytes for the response data. After successful function call it contains the size in bytes of the response data. response Pointer to the response data. Memory buffer of at least the size in bytes specified in lenr must be allocated before calling to the function. CT_close() terminates the communication with the cardterminal which has been assigned to a logical cardterminal number by the function CT_init(). The function shall be called for each initialized cardtreminal before the end of the program in order to free resources if necessary. ctn Cardterminal number: as specified in CT_init() call for this cardterminal. RETURN VALUE CT_init(), CT_data(), and CT_close() functions return a value of type char. OK Function call was successful. ERR_INVALID Invalid parameter or value. ERR_CT Cardterminal Error. The cardterminal is temporarily not accessible (busy with other or internal processes). The problem can be solved by the application. ERR_TRANS Transmission Error. Transmission errors due to mechanical, electrical or protocol failures. Reset of the cardterminal is necessary. ERR_MEMORY Memory assignment error. A memory error occurred (f.i. the allocated buffer is too small for the returned data). ERR_HTSI Host Transport Service Interface error. Commonly returned if the error is produced by the software layer and not in the communication with the hardware. SEE ALSO ctbcs (3). The MKT (Multifunktionale KartenTerminals) specifications, available for download from Teletrust website http://www.teletrust.de. In special the documents: Part 3: CT-API. Cardterminal Applications Programming Interface. Part 4: CT-BCS. Cardterminal Basic Command Set. Part 7: IC cards with synchronous transmission Part3: Usage of interindustry Commands. ISO/IEC 7816: Identification cards - Integrated circuit(s) cards with contacts: Part 4: Interindustry commands for interchange. AUTHOR This manual page was written by Carlos Prados <cprados@yahoo.com>.
towitoko-2.0.7/doc/ctapi.30000644000175000017500000001621207402223277011020 .\" This -*- nroff -*- file has been generated from .\" DocBook SGML with docbook-to-man on Debian GNU/Linux. ...\" ...\" transcript compatibility for postscript use. ...\" ...\" synopsis: .P! ...\" .de P! \\&. .fl \" force out current output buffer \\!%PB \\!/showpage{}def ...\" the following is from Ken Flowers -- it prevents dictionary overflows \\!/tempdict 200 dict def tempdict begin .fl \" prolog .sy cat \\$1\" bring in postscript file ...\" the following line matches the tempdict above \\!end % tempdict % \\!PE \\!. .sp \\$2u \" move below the image .. .de pF .ie \\*(f1 .ds f1 \\n(.f .el .ie \\*(f2 .ds f2 \\n(.f .el .ie \\*(f3 .ds f3 \\n(.f .el .ie \\*(f4 .ds f4 \\n(.f .el .tm ? font overflow .ft \\$1 .. .de fP .ie !\\*(f4 \{\ . ft \\*(f4 . ds f4\" ' br \} .el .ie !\\*(f3 \{\ . ft \\*(f3 . ds f3\" ' br \} .el .ie !\\*(f2 \{\ . ft \\*(f2 . ds f2\" ' br \} .el .ie !\\*(f1 \{\ . ft \\*(f1 . ds f1\" ' br \} .el .tm ? font underflow .. .ds f1\" .ds f2\" .ds f3\" .ds f4\" '\" t .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n .TH "CT-API" "3" .SH "NAME" \fBCT_init, CT_data, CT_close\fR \(em Functions to handle communication with integrated circuit cards and cardterminals .SH "SYNOPSIS" .PP .nf .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n #include .sp 1 \fBchar \fBCT_init\fP\fR( \fB unsigned short \fBctn\fR\fR, \fB unsigned short \fBpn\fR\fR); .sp 1 \fBchar \fBCT_data\fP\fR( \fB unsigned short \fBctn\fR\fR, \fB unsigned char * \fBdad\fR\fR, \fB unsigned char * \fBsad\fR\fR, \fB unsigned short \fBlenc\fR\fR, \fB unsigned char * \fBcommand\fR\fR, \fB unsigned short * \fBlenr\fR\fR, \fB unsigned char * \fBresponse\fR\fR); .sp 1 \fBchar \fBCT_close\fP\fR( \fB unsigned short \fBctn\fR\fR); .fi .SH "DESCRIPTION" .PP This manual page describes the CT-API functions used to handle communication with integrated circuit cards and cardterminals. The CT-API functions are generic, and allows the use of memory cards (often referred as synchronous cards) and processor cards (often referred as asynchronous cards). .PP The CT-API implementation is dependent on the cardterminal that is used. For each cardterminal a CT-API library implementation should be provided, either by the manufacturer or by third parties. This manpage is not a complete specification of the CT-API, but a general overview of the most common functionalities. .PP \fBCT_init()\fP selects and initializes the interface with the cardterminal (f.i. serial port, USB bus, or any other type of connector). The CT_init() function must be called before communicating with the card or the cardterminal. A unique cardterminal number chosen by the caller is assigned by the CT-API library to the initialized connection. .IP "\fBctn\fR" 10 Cardterminal number: identifies the connection with the cardterminal for further references. It's chosen by the caller of the function. .IP "\fBpn\fR" 10 Port number: selects the physical interface. The port number assignment is dependent on the CT-API implementation. However most serial cardterminal implementations use the convention of assigning the value 0 to the first serial port, 1 to the second serial port and so on. See the file \fB/usr/include/ctapi.h\fP of your CT-API implementation for a list of allowed values. .PP \fBCT_data()\fP sends a command to the card or to the cardterminal and returns the response to the calling program. .IP "\fBctn\fR" 10 Cardterminal number: the number specified in \fBCT_init() \fP call for this cardterminal. .IP "\fBdad\fR" 10 Destination address. If the command is sent to the cardterminal, it must point to a variable containing the value CT (0x01). If the command is sent to a card, the destination address variable must be set to the number identifying the slot of the cardterminal where the card is inserted, ranging from ICC1 (0x00) and ICC2 (0x02) to ICC14 (0x0E). .IP "" 10 On the return of the response, the variable pointed by dad is set to the value HOST (0x02) or REMOTE_HOST (0x05). .IP "\fBsad\fR" 10 Source address. When the function is called it is usually set to point to a variable with the value HOST (0x02), although the value REMOTE_HOST (0x05) may ocurr in some applications if the CT-API implementation supports remote calls. .IP "" 10 On the return of the response, the variable pointed by sad is set to any of the values from CT (0x01), ICC1 (0x00), ICC2 (0x02) to ICC14 (0x0E). .IP "\fBlenc\fR" 10 Command length in bytes. .IP "\fBcommand\fR" 10 Pointer to the buffer that conveys the command to be sent to the card or cardterminal. .IP "\fBlenr\fR" 10 Before function call, pointer to a variable containig the maximum buffer size in bytes for the response data. After successful function call it contains the size in bytes of the response data. .IP "\fBresponse\fR" 10 Pointer to the response data. Memory buffer of at least the size in bytes specified in \fBlenr\fR must be allocated before calling to the function. .PP \fBCT_close()\fP terminates the communication with the cardterminal which has been assigned to a logical cardterminal number by the function \fBCT_init()\fP. The function shall be called for each initialized cardtreminal before the end of the program in order to free resources if necessary. .IP "\fBctn\fR" 10 Cardterminal number: as specified in \fBCT_init() \fP call for this cardterminal. .SH "RETURN VALUE" .PP \fBCT_init(),\fP \fBCT_data(),\fP and \fBCT_close()\fP functions return a value of type char. .IP "\fBOK\fR" 10 Function call was successful. .IP "\fBERR_INVALID\fR" 10 Invalid parameter or value. .IP "\fBERR_CT\fR" 10 Cardterminal Error. The cardterminal is temporarily not accessible (busy with other or internal processes). The problem can be solved by the application. .IP "\fBERR_TRANS\fR" 10 Transmission Error. Transmission errors due to mechanical, electrical or protocol failures. Reset of the cardterminal is necessary. .IP "\fBERR_MEMORY\fR" 10 Memory assignment error. A memory error occurred (f.i. the allocated buffer is too small for the returned data). .IP "\fBERR_HTSI\fR" 10 Host Transport Service Interface error. Commonly returned if the error is produced by the software layer and not in the communication with the hardware. .SH "SEE ALSO" .PP ctbcs (3). .PP The \fBMKT\fP (Multifunktionale KartenTerminals) specifications, available for download from Teletrust website \fIhttp://www.teletrust.de (link to URL http://www.teletrust.de) \fR. In special the documents: .IP "Part 3:" 10 CT-API. Cardterminal Applications Programming Interface. .IP "Part 4:" 10 CT-BCS. Cardterminal Basic Command Set. .IP "Part 7:" 10 IC cards with synchronous transmission Part3: Usage of interindustry Commands. .PP ISO/IEC 7816: \fBIdentification cards - Integrated circuit(s) cards with contacts\fP: .IP "Part 4:" 10 Interindustry commands for interchange. .SH "AUTHOR" .PP This manual page was written by Carlos Prados . ...\" created by instant / docbook-to-man, Sat 01 Dec 2001, 19:51 towitoko-2.0.7/doc/ctbcs.sgml0000644000175000017500000005101207317644021011612
cprados@yahoo.com
Carlos Prados 2001Carlos Prados 06-03-2001
CT-BCS 3 CT-BCS Cardterminal basic command set for integrated circuit card applications. DESCRIPTION This manpage describes the subset of the Cardterminal Basic Command Set (CT-BCS) used to control cardterminals with one or more integrated circuit card slots, without key pad and display. This manpage is not a complete specification of the CT-BCS, but a general overview of the most common functionalities. The CT-BCS commands are constructed in compliance with ISO/IEC 7816-4 interindustry commands and are used to control cardterminal utilizing the CT-API function CT_data(). COMMAND STRUCTURE A CT-BCS command is an array of bytes that is sent to the cardterminal to perform an administrative action. The CT-BCS response is an array of bytes returned by the cardterminal that informs of the completion status of the action requested. The following diagram shows the general structure of a CT-BCS command: |<------------------------------------------>| | Header (4 Bytes) and body | | (mandatory) (optional) | |<----------------->|<---------------------->| |___________________|________________________| |CLA |INS |P1 |P2 |Lc |Data |Le | |____|____|____|____|____|______________|____| The following diagram shows the general structure of a CT-BCS response: |<------------------------------>|<--------->| | Body Trailer | | (optional) (2 Bytes) | | (mandatory)| |________________________________|___________| |Data |SW1-SW2 | |________________________________|___________| The fields within a CT-BCS command and response are equivalent to those defined by ISO/IEC 7816-4: CLA Class. The CLA value used for CT-BCS commands is 0x20. INS Instruction. Defines the action to be performed by the cardterminal. P1, P2 Command parameters 1 and 2. Lc Length of command data field. Le Length of expected data: Case 1: No command data, no response data (no Lc and no Le). Case 2: Command data, no response data (0<=Lc<=254 and no Le). Case 3: No command data, response data (no Lc and 0<=Le<=254). Case 4: Command data, response data (0<=Lc<=254 and 0<=Le<=254) SW1, SW2 Status bytes. Completion status of the command. The address value 0x01 (CT) shall be used as destination address (dad) given to CT_data() when sending CT-BCS commands (See CT_data (3)). The following commands are present in every CT-BCS implementation: Basic CT commands Cardterminal Command INS Code RESET CT 0x11 REQUEST ICC 0x12 GET STATUS 0x13 EJECT ICC 0x15
The following general return codes SW1-SW2 may occur: General return codes SW1-SW2 Description 0x6700 Wrong length 0x6900 Command not allowed 0x6A00 Wrong parameters P1, P2 0x6D00 Wrong instruction 0x6E00 Class not supported
FUNCTIONAL UNITS Functional units are entities that can be addressed as target of CT-BCS commands. In some CT-BCS commands a target functional unit needs to be specified. Functional units Functional Unit Coding CT kernel 0x00 CT/ICC slot 1 0x01 CT/ICC slot 2 0x02 \.\.\. \.\.\. CT/ICC slot 14 0x0E
Support for slots 2-14 depends on the cardterminal. Functional units for keypad and display are defined for some cardterminals but are not described here.
COMMANDS DESCRIPTION RESET CT The RESET CT command asks the cardterminal to perform a reset of the specified functional unit. If the functional unit is the CT kernel, a software reset is carried out, meaning that all status information (f.i. information of inserted cards) is cleared and gathered again. For ICC functional units, an card reset is performed. Optionally the answer to reset of the functional unit is returned in the response data. A RESET CT command can be issued after initialization of the cardterminal or after the occurrence of a communication error. The command structure is as follows: CLA 0x20 INS 0x11 (=RESET CT) P1 Functional unit: 0x00 = CT 0x01 - 0x0E = ICC Interface 1-14 P2 Command qualifier: In case P1 = 0x00: 0x00 = No response In case P1 = 0x01 - 0x0E: 0x00 = No response data 0x01 = Return complete ATR 0x02 = Return Historical Bytes Lc field Empty Le field Empty or 0x00: return full length of requested information The response structure is as follows: Data Empty, ATR or Historical Bytes SW1-SW2 Status Bytes When functional unit is CT (0x00) the following status bytes can be returned: 0x9000 Reset successful 0x6400 Reset not successful When functional unit is a ICC slot (0x01 - 0x0E) the following status bytes can be returned: 0x9000 Synchronous ICC, reset successful 0x9001 Asynchronous ICC, reset successful 0x6400 Reset not successful REQUEST ICC The REQUEST ICC command asks the cardterminal to wait for the presence of an ICC on the specified cardterminal slot during a specified time limit. The command synchronously blocks the caller application unless time limit 0 is specified. When an ICC is presented it is automatically activated and reset. The command structure is as follows: CLA 0x20 INS 0x12 (=REQUEST ICC) P1 Functional unit: 0x01 - 0x0E = ICC-Interface 1 - 14 P2 Command qualifier: Request handling instructions for the CT Lc field Empty or length of subsequent data field Data field Empty (= immediate response required) or max. waiting time in seconds (1 byte, binary coding) for presenting the ICC Le field Empty or 0x00 = Return full length of requested information The parameter P2 carries the request handling instructions for the CT. The value of P2 is constructed of two 4-bits subfields: Bits b8-b5 0x0 = No meaning Other values reserved for future use Bits b4-b1 0x0 = No response data 0x1 = Return complete ATR 0x2 = Return Historical Bytes The response structure is as follows: Data Empty, ATR or Historical Bytes SW1-SW2 Status Bytes The following status bytes can be returned: 0x9000 Synchronous ICC presented, reset successful 0x9001 Asynchronous ICC, reset successful 0x6200 No card presented within specified time 0x6201 Card already present and activated 0x6400 Reset not successful 0x6900 Command with timer not supported GET STATUS The GET STATUS command is used to gather cardterminal manufacturer information and ICC status information from the cardterminal. The information is represented by TLV (tag, length, value) encoded data objects. The tag of the data object to be retrieved is specified in the command and the value is returned in the response. The command structure is as follows: CLA 0x20 INS 0x13 (=GET STATUS) P1 Functional unit: 0x00 = CT P2 Command qualifier: Tag of data object to be returned Lc field Empty Data field Empty Le field 0x00 = Return full length of requested information The response structure is as follows: Data Status information (only value field of data object) SW1-SW2 Status Bytes The following data objects are defined. Note that only value field is returned in the response: Cardterminal manufacturer data object Tag = 0x46 Length >= 15 Value: CTM: Cardterminal manufacturer (5 bytes ASCII encoded). It consists of 2 bytes with the country code and 3 bytes with the manufacturer acronym CTT: Cardterminal type (5 bytes ASCII encoded). The value is manufacturer dependant CTSV: Cardterminal software version (5 bytes ASCII encoded). The value is manufacturer dependant DD: Discretionary data (any number of bytes including 0) ICC status data object Tag = 0x80 Length Value: One ICC status byte per ICC slot in the cardterminal. If b8-b1 = 0x00 then no ICC is present in the slot. If b1 = 1 and ICC is present in the slot and the bytes b3-b2 indicate whether the ICC is electrically connected (value 10) or electrically disconnected (value 01). The following status bytes can be returned: 0x9000 Command successful EJECT ICC The EJECT ICC command asks the cardterminal to deactivate the ICC. It must be used at the end of the communication with the card or when a irreparable communication error occur. The command structure is as follows: CLA 0x20 INS 0x15 (=EJECT ICC) P1 Functional unit: 0x01 - 0x0E = ICC-Interface 1-14 P2 Command qualifier: Eject handling instructions for the CT (0x00 for cardterminals without keypad and display) Lc field Empty or length of subsequent data field Data field Empty or time in seconds for removing the ICC Le field Empty The response structure is as follows: Data Empty SW1-SW2 Status Bytes The following status bytes can be returned 0x9000 Command successful 0x9001 Command successful, card removed 0x6200 Card not removed within specified time SEE ALSO ctapi (3). The MKT (Multifunktionale KartenTerminals) specifications, available for download from Teletrust web site http://www.teletrust.de. In special the documents: Part 3: CT-API. Cardterminal Applications Programming Interface. Part 4: CT-BCS. Cardterminal Basic Command Set. Part 7: IC cards with synchronous transmission Part3: Usage of interindustry Commands. ISO/IEC 7816: Identification cards - Integrated circuit(s) cards with contacts: Part 4: Interindustry commands for interchange. AUTHOR This manual page was written by Carlos Prados <cprados@yahoo.com>.
towitoko-2.0.7/doc/ctbcs.30000644000175000017500000003003507317644021011014 .\" This -*- nroff -*- file has been generated from .\" DocBook SGML with docbook-to-man on Debian GNU/Linux. ...\" ...\" transcript compatibility for postscript use. ...\" ...\" synopsis: .P! ...\" .de P! \\&. .fl \" force out current output buffer \\!%PB \\!/showpage{}def ...\" the following is from Ken Flowers -- it prevents dictionary overflows \\!/tempdict 200 dict def tempdict begin .fl \" prolog .sy cat \\$1\" bring in postscript file ...\" the following line matches the tempdict above \\!end % tempdict % \\!PE \\!. .sp \\$2u \" move below the image .. .de pF .ie \\*(f1 .ds f1 \\n(.f .el .ie \\*(f2 .ds f2 \\n(.f .el .ie \\*(f3 .ds f3 \\n(.f .el .ie \\*(f4 .ds f4 \\n(.f .el .tm ? font overflow .ft \\$1 .. .de fP .ie !\\*(f4 \{\ . ft \\*(f4 . ds f4\" ' br \} .el .ie !\\*(f3 \{\ . ft \\*(f3 . ds f3\" ' br \} .el .ie !\\*(f2 \{\ . ft \\*(f2 . ds f2\" ' br \} .el .ie !\\*(f1 \{\ . ft \\*(f1 . ds f1\" ' br \} .el .tm ? font underflow .. .ds f1\" .ds f2\" .ds f3\" .ds f4\" '\" t .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n .TH "CT-BCS" "3" .SH "NAME" CT-BCS \(em Cardterminal basic command set for integrated circuit card applications. .SH "DESCRIPTION" .PP This manpage describes the subset of the Cardterminal Basic Command Set (CT-BCS) used to control cardterminals with one or more integrated circuit card slots, without key pad and display. This manpage is not a complete specification of the CT-BCS, but a general overview of the most common functionalities. .PP The CT-BCS commands are constructed in compliance with \fBISO/IEC 7816-4\fP interindustry commands and are used to control cardterminal utilizing the CT-API function \fBCT_data()\fP. .SH "COMMAND STRUCTURE" .PP A CT-BCS command is an array of bytes that is sent to the cardterminal to perform an administrative action. The CT-BCS response is an array of bytes returned by the cardterminal that informs of the completion status of the action requested. .PP The following diagram shows the general structure of a CT-BCS command: .PP .nf .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n \f(CW|<------------------------------------------>| | Header (4 Bytes) and body | | (mandatory) (optional) | |<----------------->|<---------------------->| |___________________|________________________| |CLA |INS |P1 |P2 |Lc |Data |Le | |____|____|____|____|____|______________|____| \fR .fi .PP .PP The following diagram shows the general structure of a CT-BCS response: .PP .nf .ta 8n 16n 24n 32n 40n 48n 56n 64n 72n \f(CW|<------------------------------>|<--------->| | Body Trailer | | (optional) (2 Bytes) | | (mandatory)| |________________________________|___________| |Data |SW1-SW2 | |________________________________|___________| \fR .fi .PP .PP The fields within a CT-BCS command and response are equivalent to those defined by ISO/IEC 7816-4: .IP "CLA" 10 Class. The CLA value used for CT-BCS commands is 0x20. .IP "INS" 10 Instruction. Defines the action to be performed by the cardterminal. .IP "P1, P2" 10 Command parameters 1 and 2. .IP "Lc" 10 Length of command data field. .IP "Le" 10 Length of expected data: .IP "" 10 Case 1: No command data, no response data (no Lc and no Le). .IP "" 10 Case 2: Command data, no response data (0<=Lc<=254 and no Le). .IP "" 10 Case 3: No command data, response data (no Lc and 0<=Le<=254). .IP "" 10 Case 4: Command data, response data (0<=Lc<=254 and 0<=Le<=254) .IP "SW1, SW2" 10 Status bytes. Completion status of the command. .PP The address value 0x01 (CT) shall be used as destination address (dad) given to \fBCT_data()\fP when sending CT-BCS commands (See CT_data (3)). .PP The following commands are present in every CT-BCS implementation: .PP \fBBasic CT commands\fR .TS tab() box; l| r|. Cardterminal CommandINS Code RESET CT0x11 REQUEST ICC0x12 GET STATUS0x13 EJECT ICC0x15 .TE .PP The following general return codes SW1-SW2 may occur: .PP \fBGeneral return codes\fR .TS tab() box; r| l|. SW1-SW2Description 0x6700Wrong length 0x6900Command not allowed 0x6A00Wrong parameters P1, P2 0x6D00Wrong instruction 0x6E00Class not supported .TE .SH "FUNCTIONAL UNITS" .PP Functional units are entities that can be addressed as target of CT-BCS commands. In some CT-BCS commands a target functional unit needs to be specified. .PP \fBFunctional units\fR .TS tab() box; l| r|. Functional UnitCoding CT kernel0x00 CT/ICC slot 10x01 CT/ICC slot 20x02 \.\.\.\.\.\. CT/ICC slot 140x0E .TE .PP Support for slots 2-14 depends on the cardterminal. Functional units for keypad and display are defined for some cardterminals but are not described here. .SH "COMMANDS DESCRIPTION" .SS "RESET CT" .PP The RESET CT command asks the cardterminal to perform a reset of the specified functional unit. If the functional unit is the CT kernel, a software reset is carried out, meaning that all status information (f.i. information of inserted cards) is cleared and gathered again. For ICC functional units, an card reset is performed. .PP Optionally the answer to reset of the functional unit is returned in the response data. .PP A RESET CT command can be issued after initialization of the cardterminal or after the occurrence of a communication error. .PP The command structure is as follows: .IP "CLA" 10 0x20 .IP "INS" 10 0x11 (=RESET CT) .IP "P1" 10 Functional unit: .IP "" 10 0x00 = CT .IP "" 10 0x01 - 0x0E = ICC Interface 1-14 .IP "P2" 10 Command qualifier: .IP "" 10 In case P1 = 0x00: .IP "" 10 0x00 = No response .IP "" 10 In case P1 = 0x01 - 0x0E: .IP "" 10 0x00 = No response data .IP "" 10 0x01 = Return complete ATR .IP "" 10 0x02 = Return Historical Bytes .IP "Lc field" 10 Empty .IP "Le field" 10 Empty or 0x00: return full length of requested information .PP The response structure is as follows: .IP "Data" 10 Empty, ATR or Historical Bytes .IP "SW1-SW2" 10 Status Bytes .PP When functional unit is CT (0x00) the following status bytes can be returned: .IP "0x9000" 10 Reset successful .IP "0x6400" 10 Reset not successful .PP When functional unit is a ICC slot (0x01 - 0x0E) the following status bytes can be returned: .IP "0x9000" 10 Synchronous ICC, reset successful .IP "0x9001" 10 Asynchronous ICC, reset successful .IP "0x6400" 10 Reset not successful .SS "REQUEST ICC" .PP The REQUEST ICC command asks the cardterminal to wait for the presence of an ICC on the specified cardterminal slot during a specified time limit. The command synchronously blocks the caller application unless time limit 0 is specified. When an ICC is presented it is automatically activated and reset. .PP The command structure is as follows: .IP "CLA" 10 0x20 .IP "INS" 10 0x12 (=REQUEST ICC) .IP "P1" 10 Functional unit: .IP "" 10 0x01 - 0x0E = ICC-Interface 1 - 14 .IP "P2" 10 Command qualifier: Request handling instructions for the CT .IP "Lc field" 10 Empty or length of subsequent data field .IP "Data field" 10 Empty (= immediate response required) or max. waiting time in seconds (1 byte, binary coding) for presenting the ICC .IP "Le field" 10 Empty or 0x00 = Return full length of requested information .PP The parameter P2 carries the request handling instructions for the CT. The value of P2 is constructed of two 4-bits subfields: .IP "Bits b8-b5" 10 .RS .IP " \(bu" 6 0x0 = No meaning .IP " \(bu" 6 Other values reserved for future use .RE .IP "Bits b4-b1" 10 .RS .IP " \(bu" 6 0x0 = No response data .IP " \(bu" 6 0x1 = Return complete ATR .IP " \(bu" 6 0x2 = Return Historical Bytes .RE .PP The response structure is as follows: .IP "Data" 10 Empty, ATR or Historical Bytes .IP "SW1-SW2" 10 Status Bytes .PP The following status bytes can be returned: .IP "0x9000" 10 Synchronous ICC presented, reset successful .IP "0x9001" 10 Asynchronous ICC, reset successful .IP "0x6200" 10 No card presented within specified time .IP "0x6201" 10 Card already present and activated .IP "0x6400" 10 Reset not successful .IP "0x6900" 10 Command with timer not supported .SS "GET STATUS" .PP The GET STATUS command is used to gather cardterminal manufacturer information and ICC status information from the cardterminal. The information is represented by TLV (tag, length, value) encoded data objects. The tag of the data object to be retrieved is specified in the command and the value is returned in the response. .PP The command structure is as follows: .IP "CLA" 10 0x20 .IP "INS" 10 0x13 (=GET STATUS) .IP "P1" 10 Functional unit: .IP "" 10 0x00 = CT .IP "P2" 10 Command qualifier: Tag of data object to be returned .IP "Lc field" 10 Empty .IP "Data field" 10 Empty .IP "Le field" 10 Hx00 = Return full length of requested information .PP The response structure is as follows: .IP "Data" 10 Status information (only value field of data object) .IP "SW1-SW2" 10 Status Bytes .PP The following data objects are defined. Note that only value field is returned in the response: .IP "Cardterminal manufacturer data object" 10 .RS .IP " \(bu" 6 Tag = 0x46 .IP " \(bu" 6 Length >= 15 .IP " \(bu" 6 Value: .IP "" 10 CTM: Cardterminal manufacturer (5 bytes ASCII encoded). It consists of 2 bytes with the country code and 3 bytes with the manufacturer acronym .IP "" 10 CTT: Cardterminal type (5 bytes ASCII encoded). The value is manufacturer dependant .IP "" 10 CTSV: Cardterminal software version (5 bytes ASCII encoded). The value is manufacturer dependant .IP "" 10 DD: Discretionary data (any number of bytes including 0) .RE .IP "ICC status data object" 10 .RS .IP " \(bu" 6 Tag = 0x80 .IP " \(bu" 6 Length .IP " \(bu" 6 Value: One ICC status byte per ICC slot in the cardterminal. .IP "" 10 If b8-b1 = 0x00 then no ICC is present in the slot. .IP "" 10 If b1 = 1 and ICC is present in the slot and the bytes b3-b2 indicate whether the ICC is electrically connected (value 10) or electrically disconnected (value 01). .RE .PP The following status bytes can be returned: .IP "0x9000" 10 Command successful .SS "EJECT ICC" .PP The EJECT ICC command asks the cardterminal to deactivate the ICC. It must be used at the end of the communication with the card or when a irreparable communication error occur. .PP The command structure is as follows: .IP "CLA" 10 0x20 .IP "INS" 10 0x15 (=EJECT ICC) .IP "P1" 10 Functional unit: .IP "" 10 0x01 - 0x0E = ICC-Interface 1-14 .IP "P2" 10 Command qualifier: Eject handling instructions for the CT (0x00 for cardterminals without keypad and display) .IP "Lc field" 10 Empty or length of subsequent data field .IP "Data field" 10 Empty or time in seconds for removing the ICC .IP "Le field" 10 Empty .PP The response structure is as follows: .IP "Data" 10 Empty .IP "SW1-SW2" 10 Status Bytes .PP The following status bytes can be returned .IP "0x9000" 10 Command successful .IP "0x9001" 10 Command successful, card removed .IP "0x6200" 10 Card not removed within specified time .SH "SEE ALSO" .PP ctapi (3). .PP The \fBMKT\fP (Multifunktionale KartenTerminals) specifications, available for download from Teletrust web site \fIhttp://www.teletrust.de (link to URL http://www.teletrust.de) \fR. In special the documents: .IP "Part 3:" 10 CT-API. Cardterminal Applications Programming Interface. .IP "Part 4:" 10 CT-BCS. Cardterminal Basic Command Set. .IP "Part 7:" 10 IC cards with synchronous transmission Part3: Usage of interindustry Commands. .PP ISO/IEC 7816: \fBIdentification cards - Integrated circuit(s) cards with contacts\fP: .IP "Part 4:" 10 Interindustry commands for interchange. .SH "AUTHOR" .PP This manual page was written by Carlos Prados . ...\" created by instant / docbook-to-man, Wed 27 Jun 2001, 21:32 towitoko-2.0.7/doc/Info.plist0000644000175000017500000000175207527021501011601 CFBundleDevelopmentRegion English CFBundleExecutable libtowitoko.so.2.0.0 CFBundleInfoDictionaryVersion 6.0 CFBundlePackageType BNDL CFBundleSignature ???? CFBundleVersion 2.0.7 ifdCapabilities 0x00000000 ifdFriendlyName Towitoko Chipdrive USB ifdManufacturerString Towitoko GMBH ifdProductID 0x2303 ifdProductString Towitoko Chipdrive USB ifdProtocolSupport 0x00000001 ifdVendorID 0x067b ifdVersionNumber 0x00000001