From b94b27d8270ef5b1889a896c282e3bf73c769f2a Mon Sep 17 00:00:00 2001 From: handa Date: Sat, 23 Nov 2002 00:47:50 +0000 Subject: [PATCH] New --- COPYING | 340 +++++ INSTALL | 182 +++ Makefile.am | 5 + acinclude.m4 | 3968 +++++++++++++++++++++++++++++++++++++++++++++++++++ autogen.sh | 7 + configure.ac | 23 + example/Makefile.am | 15 + example/otfdraw.c | 166 +++ example/otfdump.c | 1005 +++++++++++++ otflib-config.in | 35 + src/Makefile.am | 10 + src/config.h.in | 84 ++ src/otf-open.c | 1766 +++++++++++++++++++++++ src/otf-proc.c | 564 ++++++++ src/otf-util.c | 50 + src/otf-util.h | 40 + src/otf.h | 1020 +++++++++++++ 17 files changed, 9280 insertions(+) create mode 100644 AUTHORS create mode 100644 COPYING create mode 100644 ChangeLog create mode 100644 INSTALL create mode 100644 Makefile.am create mode 100644 NEWS create mode 100644 README create mode 100644 acinclude.m4 create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 example/Makefile.am create mode 100644 example/otfdraw.c create mode 100644 example/otfdump.c create mode 100644 otflib-config.in create mode 100644 src/Makefile.am create mode 100644 src/config.h.in create mode 100644 src/otf-open.c create mode 100644 src/otf-proc.c create mode 100644 src/otf-util.c create mode 100644 src/otf-util.h create mode 100644 src/otf.h diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e69de29 diff --git a/COPYING b/COPYING new file mode 100644 index 0000000..d60c31a --- /dev/null +++ b/COPYING @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/INSTALL b/INSTALL new file mode 100644 index 0000000..b42a17a --- /dev/null +++ b/INSTALL @@ -0,0 +1,182 @@ +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source code directory by typing `make clean'. To also remove the + files that `configure' created (so you can compile the package for + a different kind of computer), type `make distclean'. There is + also a `make maintainer-clean' target, but that is intended mainly + for the package's developers. If you use it, you may have to get + all sorts of other programs in order to regenerate files that came + with the distribution. + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + +Compiling For Multiple Architectures +==================================== + + You can compile the package for more than one kind of computer at the +same time, by placing the object files for each architecture in their +own directory. To do this, you must use a version of `make' that +supports the `VPATH' variable, such as GNU `make'. `cd' to the +directory where you want the object files and executables to go and run +the `configure' script. `configure' automatically checks for the +source code in the directory that `configure' is in and in `..'. + + If you have to use a `make' that does not supports the `VPATH' +variable, you have to compile the package for one architecture at a time +in the source code directory. After you have installed the package for +one architecture, use `make distclean' before reconfiguring for another +architecture. + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + In addition, if you use an unusual directory layout you can give +options like `--bindir=PATH' to specify different values for particular +kinds of files. Run `configure --help' for a list of the directories +you can set and what kinds of files go in them. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Use and save the results of the tests in FILE instead of + `./config.cache'. Set FILE to `/dev/null' to disable caching, for + debugging `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. To + suppress all normal output, redirect it to `/dev/null' (any error + messages will still be shown). + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..90d4db1 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,5 @@ +SUBDIRS = src example + +bin_SCRIPTS = otflib-config + +EXTRA_DIST = autogen.sh \ No newline at end of file diff --git a/NEWS b/NEWS new file mode 100644 index 0000000..e69de29 diff --git a/README b/README new file mode 100644 index 0000000..e69de29 diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..330bb1e --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,3968 @@ +# libtool.m4 - Configure libtool for the host system. -*-Shell-script-*- +## Copyright 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. + +# 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([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" + +## FIXME: this should be a separate macro +## +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) +## +## END FIXME + + +## FIXME: this should be a separate macro +## +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' + if test "x$host_vendor" = xsni; then + lt_cv_prog_cc_wl='-LD' + else + lt_cv_prog_cc_wl='-Wl,' + fi + ;; + + 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 +## +## END FIXME + +# 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 + +## FIXME: this should be a separate macro +## +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" +## +## END FIXME + + +## FIXME: this should be a separate macro +## +# 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 +## +## END FIXME + +## FIXME: this should be a separate macro +## +# 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 +## +## END FIXME + +## FIXME: this should be a separate macro +## +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 +## +## END FIXME + +## FIXME: this should be a separate macro +## +# 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`head -1 $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;; + *) 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) + if test "x$host_vendor" = xsno; then + archive_cmds='$LD -G -Bsymbolic -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_direct=yes # is this really true??? + else + 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 + fi + 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 +## +## END FIXME + +## FIXME: this should be a separate macro +## +# 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]) +## +## END FIXME + +## FIXME: this should be a separate macro +## +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 +## +## END FIXME + +reload_cmds='$LD$reload_flag -o $output$reload_objs' +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +## FIXME: this should be a separate macro +## +# 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"` + ;; + 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 + need_lib_prefix=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 + ;; + 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 +## +## END FIXME + +## FIXME: this should be a separate macro +## +# Report the final consequences. +AC_MSG_CHECKING([if libtool supports shared libraries]) +AC_MSG_RESULT([$can_build_shared]) +## +## END FIXME + +## FIXME: this should be a separate macro +## +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]) +## +## END FIXME + +## FIXME: this should be a separate macro +## +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]) +## +## END FIXME + +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 + +## FIXME: this should be a separate macro +## +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} +## +## END FIXME + +## FIXME: this should be a separate macro +## +# 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 \ + 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. + +# 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 +## +## END FIXME + +])# _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 dependant 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*) + lt_cv_deplibs_check_method=pass_all + 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 + ;; + 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]) +## ltdl.m4 - Configure ltdl for the target system. -*-Shell-script-*- +## Copyright (C) 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 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. + +# serial 5 AC_LIB_LTDL + +# AC_WITH_LTDL +# ------------ +# Clients of libltdl can use this macro to allow the installer to +# choose between a shipped copy of the ltdl sources or a preinstalled +# version of the library. +AC_DEFUN([AC_WITH_LTDL], +[AC_REQUIRE([AC_LIB_LTDL]) +AC_SUBST([LIBLTDL]) +AC_SUBST([INCLTDL]) + +# Unless the user asks us to check, assume no installed ltdl exists. +use_installed_libltdl=no + +AC_ARG_WITH([included_ltdl], + [ --with-included-ltdl use the GNU ltdl sources included here]) + +if test "x$with_included_ltdl" != xyes; then + # We are not being forced to use the included libltdl sources, so + # decide whether there is a useful installed version we can use. + AC_CHECK_HEADER([ltdl.h], + [AC_CHECK_LIB([ltdl], [lt_dlcaller_register], + [with_included_ltdl=no], + [with_included_ltdl=yes]) + ]) +fi + +if test "x$enable_ltdl_install" != xyes; then + # If the user did not specify an installable libltdl, then default + # to a convenience lib. + AC_LIBLTDL_CONVENIENCE +fi + +if test "x$with_included_ltdl" = xno; then + # If the included ltdl is not to be used. then Use the + # preinstalled libltdl we found. + AC_DEFINE([HAVE_LTDL], 1, + [Define this if a modern libltdl is already installed]) + LIBLTDL=-lltdl +fi + +# Report our decision... +AC_MSG_CHECKING([whether to use included libltdl]) +AC_MSG_RESULT([$with_included_ltdl]) + +AC_CONFIG_SUBDIRS([libltdl]) +])# AC_WITH_LTDL + + +# AC_LIB_LTDL +# ----------- +# Perform all the checks necessary for compilation of the ltdl objects +# -- including compiler checks and header checks. +AC_DEFUN(AC_LIB_LTDL, +[AC_PREREQ(2.13) +AC_REQUIRE([AC_PROG_CC]) +AC_REQUIRE([AC_C_CONST]) +AC_REQUIRE([AC_HEADER_STDC]) +AC_REQUIRE([AC_HEADER_DIRENT]) +AC_REQUIRE([AC_LIBTOOL_HEADER_ASSERT]) +AC_REQUIRE([_LT_AC_CHECK_DLFCN]) +AC_REQUIRE([AC_LTDL_ENABLE_INSTALL]) +AC_REQUIRE([AC_LTDL_SHLIBEXT]) +AC_REQUIRE([AC_LTDL_SHLIBPATH]) +AC_REQUIRE([AC_LTDL_SYSSEARCHPATH]) +AC_REQUIRE([AC_LTDL_OBJDIR]) +AC_REQUIRE([AC_LTDL_DLPREOPEN]) +AC_REQUIRE([AC_LTDL_DLLIB]) +AC_REQUIRE([AC_LTDL_SYMBOL_USCORE]) +AC_REQUIRE([AC_LTDL_DLSYM_USCORE]) +AC_REQUIRE([AC_LTDL_SYS_DLOPEN_DEPLIBS]) +AC_REQUIRE([AC_LTDL_FUNC_ARGZ]) + +AC_CHECK_HEADERS([errno.h malloc.h memory.h stdlib.h stdio.h ctype.h unistd.h]) +AC_CHECK_HEADERS([dl.h sys/dl.h dld.h]) +AC_CHECK_HEADERS([string.h strings.h], break) + +AC_CHECK_FUNCS([strchr index], break) +AC_CHECK_FUNCS([strrchr rindex], break) +AC_CHECK_FUNCS([memcpy bcopy], break) +AC_CHECK_FUNCS([memmove strcmp]) + +])# AC_LIB_LTDL + +# AC_LTDL_ENABLE_INSTALL +# ---------------------- +AC_DEFUN(AC_LTDL_ENABLE_INSTALL, +[AC_ARG_ENABLE(ltdl-install, +[ --enable-ltdl-install install libltdl]) + +AM_CONDITIONAL(INSTALL_LTDL, test x"${enable_ltdl_install-no}" != xno) +AM_CONDITIONAL(CONVENIENCE_LTDL, test x"${enable_ltdl_convenience-no}" != xno) +])])# AC_LTDL_ENABLE_INSTALL + +# AC_LTDL_SYS_DLOPEN_DEPLIBS +# -------------------------- +AC_DEFUN(AC_LTDL_SYS_DLOPEN_DEPLIBS, +[AC_REQUIRE([AC_CANONICAL_HOST]) +AC_CACHE_CHECK([whether deplibs are loaded by dlopen], + libltdl_cv_sys_dlopen_deplibs, [dnl + # PORTME does your system automatically load deplibs for dlopen()? + libltdl_cv_sys_dlopen_deplibs=unknown + case "$host_os" in + linux*) + libltdl_cv_sys_dlopen_deplibs=yes + ;; + netbsd*) + libltdl_cv_sys_dlopen_deplibs=yes + ;; + openbsd*) + libltdl_cv_sys_dlopen_deplibs=yes + ;; + solaris*) + libltdl_cv_sys_dlopen_deplibs=yes + ;; + esac +]) +if test "$libltdl_cv_sys_dlopen_deplibs" != yes; then + AC_DEFINE(LTDL_DLOPEN_DEPLIBS, 1, + [Define if the OS needs help to load dependent libraries for dlopen(). ]) +fi +])# AC_LTDL_SYS_DLOPEN_DEPLIBS + +# AC_LTDL_SHLIBEXT +# ---------------- +AC_DEFUN(AC_LTDL_SHLIBEXT, +[AC_REQUIRE([_LT_AC_LTCONFIG_HACK]) +AC_CACHE_CHECK([which extension is used for shared libraries], + libltdl_cv_shlibext, +[ac_last= + for ac_spec in $library_names_spec; do + ac_last="$ac_spec" + done + echo "$ac_last" | [sed 's/\[.*\]//;s/^[^.]*//;s/\$.*$//;s/\.$//'] > conftest +libltdl_cv_shlibext=`cat conftest` +rm -f conftest +]) +if test -n "$libltdl_cv_shlibext"; then + AC_DEFINE_UNQUOTED(LTDL_SHLIB_EXT, "$libltdl_cv_shlibext", + [Define to the extension used for shared libraries, say, ".so". ]) +fi +])# AC_LTDL_SHLIBEXT + +# AC_LTDL_SHLIBPATH +# ----------------- +AC_DEFUN(AC_LTDL_SHLIBPATH, +[AC_REQUIRE([_LT_AC_LTCONFIG_HACK]) +AC_CACHE_CHECK([which variable specifies run-time library path], + libltdl_cv_shlibpath_var, [libltdl_cv_shlibpath_var="$shlibpath_var"]) +if test -n "$libltdl_cv_shlibpath_var"; then + AC_DEFINE_UNQUOTED(LTDL_SHLIBPATH_VAR, "$libltdl_cv_shlibpath_var", + [Define to the name of the environment variable that determines the dynamic library search path. ]) +fi +])# AC_LTDL_SHLIBPATH + +# AC_LTDL_SYSSEARCHPATH +# --------------------- +AC_DEFUN(AC_LTDL_SYSSEARCHPATH, +[AC_REQUIRE([_LT_AC_LTCONFIG_HACK]) +AC_CACHE_CHECK([for the default library search path], + libltdl_cv_sys_search_path, [libltdl_cv_sys_search_path="$sys_lib_dlsearch_path_spec"]) +if test -n "$libltdl_cv_sys_search_path"; then + case "$host" in + *-*-mingw*) pathsep=";" ;; + *) pathsep=":" ;; + esac + sys_search_path= + for dir in $libltdl_cv_sys_search_path; do + if test -z "$sys_search_path"; then + sys_search_path="$dir" + else + sys_search_path="$sys_search_path$pathsep$dir" + fi + done + AC_DEFINE_UNQUOTED(LTDL_SYSSEARCHPATH, "$sys_search_path", + [Define to the system default library search path. ]) +fi +])# AC_LTDL_SYSSEARCHPATH + +# AC_LTDL_OBJDIR +# -------------- +AC_DEFUN(AC_LTDL_OBJDIR, +[AC_CACHE_CHECK([for objdir], + libltdl_cv_objdir, [libltdl_cv_objdir="$objdir" +if test -n "$objdir"; then + : +else + rm -f .libs 2>/dev/null + mkdir .libs 2>/dev/null + if test -d .libs; then + libltdl_cv_objdir=.libs + else + # MS-DOS does not allow filenames that begin with a dot. + libltdl_cv_objdir=_libs + fi +rmdir .libs 2>/dev/null +fi]) +AC_DEFINE_UNQUOTED(LTDL_OBJDIR, "$libltdl_cv_objdir/", + [Define to the sub-directory in which libtool stores uninstalled libraries. ]) +])# AC_LTDL_OBJDIR + +# AC_LTDL_DLPREOPEN +# ----------------- +AC_DEFUN(AC_LTDL_DLPREOPEN, +[AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])dnl +AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen], + libltdl_cv_preloaded_symbols, [dnl + if test -n "$global_symbol_pipe"; then + libltdl_cv_preloaded_symbols=yes + else + libltdl_cv_preloaded_symbols=no + fi +]) +if test x"$libltdl_cv_preloaded_symbols" = x"yes"; then + AC_DEFINE(HAVE_PRELOADED_SYMBOLS, 1, + [Define if libtool can extract symbol lists from object files. ]) +fi +])# AC_LTDL_DLPREOPEN + +# AC_LTDL_DLLIB +# ------------- +AC_DEFUN(AC_LTDL_DLLIB, +[LIBADD_DL= +AC_SUBST(LIBADD_DL) + +AC_CHECK_FUNC([shl_load], + [AC_DEFINE([HAVE_SHL_LOAD], [1], + [Define if you have the shl_load function.])], + [AC_CHECK_LIB([dld], [shl_load], + [AC_DEFINE([HAVE_SHL_LOAD], [1], + [Define if you have the shl_load function.]) + LIBADD_DL="$LIBADD_DL -ldld"], + [AC_CHECK_LIB([dl], [dlopen], + [AC_DEFINE([HAVE_LIBDL], [1], + [Define if you have the libdl library or equivalent.]) + LIBADD_DL="-ldl"], + [AC_TRY_LINK([#if HAVE_DLFCN_H +# include +#endif + ], + [dlopen(0, 0);], + [AC_DEFINE([HAVE_LIBDL], [1], + [Define if you have the libdl library or equivalent.])], + [AC_CHECK_LIB([svld], [dlopen], + [AC_DEFINE([HAVE_LIBDL], [1], + [Define if you have the libdl library or equivalent.]) + LIBADD_DL="-lsvld"], + [AC_CHECK_LIB([dld], [dld_link], + [AC_DEFINE([HAVE_DLD], [1], + [Define if you have the GNU dld library.]) + LIBADD_DL="$LIBADD_DL -ldld" + ]) + ]) + ]) + ]) + ]) +]) + +if test "x$ac_cv_func_dlopen" = xyes || test "x$ac_cv_lib_dl_dlopen" = xyes; then + LIBS_SAVE="$LIBS" + LIBS="$LIBS $LIBADD_DL" + AC_CHECK_FUNCS(dlerror) + LIBS="$LIBS_SAVE" +fi +])# AC_LTDL_DLLIB + +# AC_LTDL_SYMBOL_USCORE +# --------------------- +AC_DEFUN(AC_LTDL_SYMBOL_USCORE, +[dnl does the compiler prefix global symbols with an underscore? +AC_REQUIRE([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])dnl +AC_MSG_CHECKING([for _ prefix in compiled symbols]) +AC_CACHE_VAL(ac_cv_sys_symbol_underscore, +[ac_cv_sys_symbol_underscore=no +cat > conftest.$ac_ext < $ac_nlist) && test -s "$ac_nlist"; then + # See whether the symbols have a leading underscore. + if egrep '^. _nm_test_func' "$ac_nlist" >/dev/null; then + ac_cv_sys_symbol_underscore=yes + else + if egrep '^. nm_test_func ' "$ac_nlist" >/dev/null; then + : + else + echo "configure: cannot find nm_test_func in $ac_nlist" >&AC_FD_CC + fi + fi + else + echo "configure: cannot run $global_symbol_pipe" >&AC_FD_CC + fi +else + echo "configure: failed program was:" >&AC_FD_CC + cat conftest.c >&AC_FD_CC +fi +rm -rf conftest* +]) +AC_MSG_RESULT($ac_cv_sys_symbol_underscore) +])# AC_LTDL_SYMBOL_USCORE + + +# AC_LTDL_DLSYM_USCORE +# -------------------- +AC_DEFUN(AC_LTDL_DLSYM_USCORE, +[AC_REQUIRE([AC_LTDL_SYMBOL_USCORE])dnl +if test x"$ac_cv_sys_symbol_underscore" = xyes; then + if test x"$ac_cv_func_dlopen" = xyes || + test x"$ac_cv_lib_dl_dlopen" = xyes ; then + AC_CACHE_CHECK([whether we have to add an underscore for dlsym], + libltdl_cv_need_uscore, [dnl + libltdl_cv_need_uscore=unknown + save_LIBS="$LIBS" + LIBS="$LIBS $LIBADD_DL" + _LT_AC_TRY_DLOPEN_SELF( + libltdl_cv_need_uscore=no, libltdl_cv_need_uscore=yes, + [], libltdl_cv_need_uscore=cross) + LIBS="$save_LIBS" + ]) + fi +fi + +if test x"$libltdl_cv_need_uscore" = xyes; then + AC_DEFINE(NEED_USCORE, 1, + [Define if dlsym() requires a leading underscore in symbol names. ]) +fi +])# AC_LTDL_DLSYM_USCORE + + +# AC_CHECK_TYPES(TYPES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND], +# [INCLUDES]) +# --------------------------------------------------------------- +# This macro did not exist in Autoconf 2.13, which we do still support +ifdef([AC_CHECK_TYPES], [], +[define([AC_CHECK_TYPES], + [AC_CACHE_CHECK([for $1], ac_Type, + [AC_TRY_LINK([$4], + [if (($1 *) 0) + return 0; + if (sizeof ($1)) + return 0;], + [ac_Type=yes], + [ac_Type=no])]) + if test "x$ac_Type" = xyes; then + ifelse([$2], [], [:], [$2]) + else + ifelse([$3], [], [:], [$3]) + fi]) +])# AC_CHECK_TYPES + + +# AC_LTDL_FUNC_ARGZ +# ----------------- +AC_DEFUN([AC_LTDL_FUNC_ARGZ], +[AC_CHECK_HEADERS([argz.h]) + +AC_CHECK_TYPES([error_t], + [], + [AC_DEFINE([error_t], [int], + [Define to a type to use for \`error_t' if it is not otherwise available.])], + [#if HAVE_ARGZ_H +# include +#endif]) + +AC_CHECK_FUNCS([argz_append argz_create_sep argz_insert argz_next argz_stringify]) +])# AC_LTDL_FUNC_ARGZ diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 0000000..de85d09 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,7 @@ +#!/bin/sh +libtoolize --automake +aclocal +autoheader +automake -a +autoconf + diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..f6e4fa3 --- /dev/null +++ b/configure.ac @@ -0,0 +1,23 @@ +# Process this file with autoconf to produce a configure script. +AC_INIT(libotf, 1.0, libotf@m17n.org) +AM_INIT_AUTOMAKE(libotf, 1.0) +AM_CONFIG_HEADER(src/config.h) + +# Checks for programs. +AC_PROG_CC +AC_PROG_LIBTOOL + +# Checks for libraries. + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([fcntl.h stdlib.h string.h unistd.h]) + +# Checks for typedefs, structures, and compiler characteristics. + +# Checks for library functions. +AC_FUNC_ALLOCA +AC_FUNC_MALLOC + +AC_CONFIG_FILES([Makefile src/Makefile example/Makefile otflib-config]) +AC_OUTPUT diff --git a/example/Makefile.am b/example/Makefile.am new file mode 100644 index 0000000..4168c53 --- /dev/null +++ b/example/Makefile.am @@ -0,0 +1,15 @@ +bin_PROGRAMS = otfdump otfdraw + +INCLUDES = `freetype-config --cflags` + +otfdump_SOURCE = otfdump.c +otfdump_LDFLAGS = -lotf + +otfdraw_SOURCE = otfdraw +otfdraw_LDFLAGS = `freetype-config --libs` -lotf -L/usr/X11R6/lib -lX11 + +# We should not install any programs in this directory. + +install-binPROGRAMS: + +uninstall-binPROGRAMS: diff --git a/example/otfdraw.c b/example/otfdraw.c new file mode 100644 index 0000000..70134e8 --- /dev/null +++ b/example/otfdraw.c @@ -0,0 +1,166 @@ +#include +#include + +#include "otf.h" + +#include +#include FT_FREETYPE_H + +#include + +Display *display; +int screen; +Window win; +GC gc; + +void +draw_bitmap (FT_Face face, int x, int y) +{ + int i, j; + FT_Bitmap *bmp = &face->glyph->bitmap; + unsigned char *buf = (unsigned char *) bmp->buffer; + + for (i = 0; i < bmp->rows; i++, buf += bmp->pitch) + for (j = 0; j < bmp->width; j++) + if (buf[j / 8] & (1 << (7 - (j % 8)))) + XDrawPoint (display, win, gc, x + j, y + i); +} + +void +quit (char *msg) +{ + fprintf (stderr, "Error by %s\n", msg); + exit (1); +} + + +static void +otf_dump_value_record (unsigned value_format, OTF_ValueRecord *value_record) +{ + if (value_format & OTF_XPlacement) + printf (" (XPlacement %d)", value_record->XPlacement); + if (value_format & OTF_YPlacement) + printf (" (YPlacement %d)", value_record->YPlacement); +} + + + +void +otf_dump_gstring (OTF_GlyphString *gstring) +{ + int i; + + for (i = 0; i < gstring->used; i++) + { + OTF_Glyph *g = gstring->glyphs + i; + + printf ("%02d: c:%04X, g:%04X class:%d\n", + i, g->c, g->glyph_id, g->GlyphClass); + // otf_dump_value_record (g->value_format1, &g->value_record1); + // otf_dump_value_record (g->value_format2, &g->value_record2); + } +} + + +int +main (int argc, char **argv) +{ + OTF *otf; + int i; + OTF_GlyphString gstring; + + if (argc != 2) + { + fprintf (stderr, "Usage, dtfdump OTF-FILE"); + exit (1); + } + + otf = otf_open (argv[1]); + + gstring.size = 10; + gstring.glyphs = (OTF_Glyph *) malloc (sizeof (OTF_Glyph) * 10); + gstring.used = 0; +#if 0 + gstring.glyphs[gstring.used++].c = 0x93F; + gstring.glyphs[gstring.used++].c = 0x939; + gstring.glyphs[gstring.used++].c = 0x928; + gstring.glyphs[gstring.used++].c = 0x94D; + gstring.glyphs[gstring.used++].c = 0x926; + gstring.glyphs[gstring.used++].c = 0x940; +#else + gstring.glyphs[gstring.used++].c = 0x92A; + gstring.glyphs[gstring.used++].c = 0x94D; + gstring.glyphs[gstring.used++].c = 0x930; + gstring.glyphs[gstring.used++].c = 0x924; + gstring.glyphs[gstring.used++].c = 0x94D; + gstring.glyphs[gstring.used++].c = 0x92F; + gstring.glyphs[gstring.used++].c = 0x947; + gstring.glyphs[gstring.used++].c = 0x915; +#endif + otf_cmap (otf, &gstring); + otf_gdef (otf, &gstring); + otf_dump_gstring (&gstring); + if (otf_gsub (otf, otf_tag ("deva"), 0, &gstring) < 0) + printf ("otf_gsub error\n"); + else + printf ("RESULT of GSUB\n"); + otf_dump_gstring (&gstring); + + if (otf_gpos (otf, otf_tag ("deva"), 0, &gstring) < 0) + printf ("otf_gsub error\n"); + else + printf ("RESULT of GPOS\n"); + otf_dump_gstring (&gstring); + + { + int x, y; + int err; + FT_Library library; + FT_Face face; + + err = FT_Init_FreeType (&library); + if (err) + quit ("FT_Init_FreeType"); + err = FT_New_Face (library, argv[1], 0, &face); + if (err == FT_Err_Unknown_File_Format) + quit ("FT_New_Face: unknown file format"); + else if (err) + quit ("FT_New_Face: another error"); + err = FT_Set_Char_Size (face, 0, 32*64, 400, 400); + if (err) + quit ("FT_Set_Char_Size"); + + display = XOpenDisplay (NULL); + screen = DefaultScreen (display); + win = XCreateSimpleWindow (display, RootWindow (display, screen), + 0, 0, 800, 600, 1, BlackPixel (display, screen), + WhitePixel (display, screen)); + gc = DefaultGC (display, screen); + XMapWindow (display, win); + XSelectInput (display, win, ExposureMask); + + while (1) + { + XEvent event; + + XNextEvent (display, &event); + + XClearWindow (display, win); + x = 20, y = 300; + for (i = 0; i < gstring.used; i++) + { + FT_Load_Glyph (face, gstring.glyphs[i].glyph_id, + FT_LOAD_RENDER | FT_LOAD_MONOCHROME); + + draw_bitmap (face, + x + face->glyph->bitmap_left, + y - face->glyph->bitmap_top); + x += face->glyph->advance.x >> 6; + } + } + } + + + otf_close (otf); + exit (0); +} diff --git a/example/otfdump.c b/example/otfdump.c new file mode 100644 index 0000000..ca0600a --- /dev/null +++ b/example/otfdump.c @@ -0,0 +1,1005 @@ +#include +#include +#include +#include +#include +#include + +#include + +char *indent_spaces[] = + { "", " ", " ", " ", " ", " ", " ", + " ", " ", " " }; + +/* Indented print. */ +#define IPRINT printf("\n%s", indent_spaces[indent]), printf + +static void +dump_tag (OTF_Tag tag) +{ + printf ("(tag \""); + putchar (tag >> 24); + putchar ((tag >> 16) & 0xFF); + putchar ((tag >> 8) & 0xFF); + putchar (tag & 0xFF); + printf ("\" #x%04X)", tag); +} + +/* HEAD */ + +static void +dump_offset_table (int indent, OTF_OffsetTable *table) +{ + IPRINT ("(OffsetTable"); + indent++; + IPRINT ("(sfnt-version %d.%d)", + table->sfnt_version.high, table->sfnt_version.low); + IPRINT ("(numTables %d)", table->numTables); + IPRINT ("(searchRange %d)", table->searchRange); + IPRINT ("(enterSelector %d)", table->enterSelector); + IPRINT ("(rangeShift %d))", table->rangeShift); +} + +static void +dump_table_directory (int indent, OTF_TableDirectory *table, int idx) +{ + IPRINT ("(Table %d ", idx); + dump_tag (table->tag); + indent++; + IPRINT ("(checkSum %08X) (offset #x%08X) (length: #x%08X))", + table->checkSum, table->offset, table->length); +} + + + +/* head */ +static void +dump_head_table (int indent, OTF_head *head) +{ + int i; + + IPRINT ("(head"); + indent++; + IPRINT ("(TableVersionNumber %d.%d)", + head->TableVersionNumber.high, head->TableVersionNumber.low); + IPRINT ("(fontRevision %d.%d)", + head->fontRevision.high, head->fontRevision.low); + IPRINT ("(checkSumAdjustment #x%04X)", head->checkSumAdjustment); + IPRINT ("(magicNumber #x%04X)", head->magicNumber); + IPRINT ("(flags #x%04X)", head->flags); + IPRINT ("(unitsPerEm %d)", head->unitsPerEm); + printf (")"); +} + + +/* COMMON */ + +static void +dump_glyph_ids (OTF_GlyphID *ids, unsigned num) +{ + while (num-- > 0) + { + printf (" #x%04X", *ids); + ids++; + } +} + +static void +dump_coverage (int indent, char *title, OTF_Coverage *coverage) +{ + int i; + + IPRINT ("(%sCoverage (CoverageFormat %d)", + (title ? title : ""), coverage->CoverageFormat); + indent++; + if (coverage->CoverageFormat == 1) + { + IPRINT ("(GlyphCount %d)", coverage->Count); + IPRINT ("(GlyphArray"); + dump_glyph_ids (coverage->table.GlyphArray, coverage->Count); + printf (")"); + } + else + { + IPRINT ("(RangeCount %d)", coverage->Count); + indent++; + for (i = 0; i < coverage->Count; i++) + { + IPRINT ("(Range (%d) (Start #x%04X) (End #x%04X)", i, + coverage->table.RangeRecord[i].Start, + coverage->table.RangeRecord[i].End); + indent++; + IPRINT ("(StartCoverageIndex %d))", + coverage->table.RangeRecord[i].StartCoverageIndex); + indent--; + } + } + printf (")"); +} + +static void +dump_coverage_list (int indent, char *title, + OTF_Coverage *coverage, unsigned num) +{ + int i; + + IPRINT ("(%s %d)", title, num); + for (i = 0; i < num; i++) + dump_coverage (indent, NULL, coverage + i); +} + + +static void +dump_language_system (int indent, int index, OTF_Tag tag, OTF_Offset offset, + OTF_LangSys *langsys) +{ + int i; + + IPRINT ("(LangSys "); + if (index >= 0) + printf ("(%d) ", index); + if (tag) + dump_tag (tag); + else + printf ("DefaultLangSys"); + printf (" (Offset #x%04X)", offset); + indent++; + IPRINT ("(LookupOrder #x%04X)", langsys->LookupOrder); + IPRINT ("(ReqFeatureIndex %d)", langsys->ReqFeatureIndex); + IPRINT ("(FeatureCount %d)", langsys->FeatureCount); + if (langsys->FeatureCount) + { + IPRINT ("(FeatureIndex"); + for (i = 0; i < langsys->FeatureCount; i++) + printf (" %d", langsys->FeatureIndex[i]); + printf (")"); + } + printf (")"); +} + +static void +dump_script_list (int indent, OTF_ScriptList *list) +{ + int i, j; + + IPRINT ("(ScriptList (count %d)", list->ScriptCount); + indent++; + for (i = 0; i < list->ScriptCount; i++) + { + OTF_Script *script = list->Script + i; + + IPRINT ("(Script (%d) ", i); + dump_tag (list->ScriptRecord[i].ScriptTag); + printf (" (Offset #x%04X)", list->ScriptRecord[i].Script); + indent++; + IPRINT ("(DefaultLangSysOffset #x%04X)", + script->DefaultLangSysOffset); + if (script->DefaultLangSysOffset) + dump_language_system (indent, -1, 0, + script->DefaultLangSysOffset, + &script->DefaultLangSys); + IPRINT ("(LangSysCount %d)", script->LangSysCount); + for (j = 0; j < script->LangSysCount; j++) + dump_language_system (indent, j, + script->LangSysRecord[j].LangSysTag, + script->LangSysRecord[j].LangSys, + script->LangSys + j); + printf (")"); + indent--; + } + printf (")"); +} + +static void +dump_feature_list (int indent, OTF_FeatureList *list) +{ + int i, j; + + IPRINT ("(FeatureList (count %d)", list->FeatureCount); + indent++; + for (i = 0; i < list->FeatureCount; i++) + { + OTF_Feature *feature = list->Feature + i; + + IPRINT ("(Feature (%d) ", i); + dump_tag (list->FeatureRecord[i].FeatureTag); + printf (" (Offset #x%04X)", list->FeatureRecord[i].Feature); + printf (" (LookupCount %d)", feature->LookupCount); + if (feature->LookupCount) + { + indent++; + IPRINT ("(LookupListIndex"); + for (j = 0; j < feature->LookupCount; j++) + printf (" %d", feature->LookupListIndex[j]); + printf (")"); + indent--; + } + printf (")"); + } + printf (")"); +} + +static void +dump_class_def (int indent, char *title, OTF_ClassDef *class) +{ + IPRINT ("(%s (offset #x%04X) (ClassFormat %d)", + (title ? title : "ClassDef"), + class->offset, class->ClassFormat); + indent++; + if (class->ClassFormat == 1) + { + IPRINT ("(StartGlyph #x%04X)", class->f.f1.StartGlyph); + IPRINT ("(GlyphCount %d)", class->f.f1.GlyphCount); + IPRINT ("(ClassValueArray"); + dump_glyph_ids ((OTF_GlyphID *) class->f.f1.ClassValueArray, + class->f.f1.GlyphCount); + printf (")"); + } + else if (class->ClassFormat == 2) + { + int i; + + IPRINT ("(ClassRangeCount %d)", class->f.f2.ClassRangeCount); + IPRINT ("(ClassRangeRecord"); + indent++; + for (i = 0; i < class->f.f2.ClassRangeCount; i++) + IPRINT ("((Start #x%04X) (End #x%04X) (class %d))", + class->f.f2.ClassRangeRecord[i].Start, + class->f.f2.ClassRangeRecord[i].End, + class->f.f2.ClassRangeRecord[i].Class); + printf (")"); + } + else + printf ("UknownClassFormat"); + printf (")"); +} + +static void +dump_device_table (int indent, char *title, OTF_DeviceTable *table) +{ + int i; + + if (! table->offset) + return; + IPRINT ("(%s (offset #x%04X)", title, table->offset); + indent++; + IPRINT ("(StartSize %d) (EndSize %d) (DeltaFormat %d)", + table->StartSize, table->EndSize, table->DeltaFormat); + IPRINT ("(DeltaValue"); + for (i = 0; i < table->EndSize - table->StartSize + 1; i++) + printf (" %d", table->DeltaValue[i]); + printf ("))"); +} + + + +static void +dump_value_record (int indent, char *title, OTF_ValueRecord *rec) +{ + IPRINT ("(%s %d %d %d %d", title, + rec->XPlacement, rec->YPlacement, rec->XAdvance, rec->YAdvance); + indent++; + if (rec->XPlaDevice.offset) + dump_device_table (indent, "XPlaDevice", &rec->XPlaDevice); + if (rec->YPlaDevice.offset) + dump_device_table (indent, "YPlaDevice", &rec->YPlaDevice); + if (rec->XAdvDevice.offset) + dump_device_table (indent, "XAdvDevice", &rec->XAdvDevice); + if (rec->YAdvDevice.offset) + dump_device_table (indent, "YAdvDevice", &rec->YAdvDevice); + printf (")"); +} + + +static void +dump_sequence_list (int indent, OTF_Sequence *sequence, unsigned num) +{ + int i; + IPRINT ("(SequenceCount %d)", num); + + for (i = 0; i < num; i++) + { + IPRINT ("(Sequence (%d) (offset #x%04X)", + i, sequence[i].offset); + indent++; + IPRINT ("(GlyphCount %d)", sequence[i].GlyphCount); + IPRINT ("(Substitute"); + dump_glyph_ids (sequence[i].Substitute, sequence[i].GlyphCount); + printf ("))"); + indent--; + } +} + +static void +dump_ligature_set_list (int indent, OTF_LigatureSet *ligset, unsigned num) +{ + int i, j; + + IPRINT ("(LigSetCount %d)", num); + for (i = 0; i < num; i++) + { + IPRINT ("(LigatureSet (%d) (offset #x%04X) (count %d)", + i, ligset[i].offset, ligset[i].LigatureCount); + indent++; + for (j = 0; j < ligset[i].LigatureCount; j++) + { + IPRINT ("(Ligature (%d) (offset #x%04X)", + j, ligset[i].Ligature[j].offset); + indent++; + IPRINT ("(LigGlyph #x%04X)", + ligset[i].Ligature[j].LigGlyph); + IPRINT ("(ComCount %d)", + ligset[i].Ligature[j].CompCount); + IPRINT ("(Component"); + dump_glyph_ids (ligset[i].Ligature[j].Component, + ligset[i].Ligature[j].CompCount - 1); + printf ("))"); + indent--; + } + indent--; + printf (")"); + } +} + +static void +dump_class1_record_list (int indent, + unsigned Class1Count, unsigned Class2Count, + OTF_Class1Record *rec) +{ + int i, j; + + for (i = 0; i < Class1Count; i++) + { + IPRINT ("(Class1Record (%d)", i); + indent++; + for (j = 0; j < Class2Count; j++) + { + IPRINT ("(Class2Record (%d)", j); + indent++; + dump_value_record (indent, "Value1", &rec[i].Class2Record[j].Value1); + dump_value_record (indent, "Value2", &rec[i].Class2Record[j].Value2); + printf (")"); + indent--; + } + printf (")"); + indent--; + } +} + +static void +dump_anchor (int indent, OTF_Anchor *anchor) +{ + IPRINT ("(Anchor (offset #x%04X) (AnchorFormat %d)", + anchor->offset, anchor->AnchorFormat); + indent++; + IPRINT ("(XCoordinate %d) (YCoordinate %d)", + anchor->XCoordinate, anchor->YCoordinate); + if (anchor->AnchorFormat == 1) + ; + else if (anchor->AnchorFormat == 2) + IPRINT ("(AnchorPoint %d)", anchor->f.f1.AnchorPoint); + else + { + dump_device_table (indent, "XDeviceTable", &anchor->f.f2.XDeviceTable); + dump_device_table (indent, "YDeviceTable", &anchor->f.f2.YDeviceTable); + } + printf (")"); +} + +static void +dump_mark_array (int indent, OTF_MarkArray *array) +{ + int i; + + IPRINT ("(MarkArray (MarkCount %d)", array->MarkCount); + indent++; + for (i = 0; i < array->MarkCount; i++) + { + IPRINT ("(MarkRecord (%d) (Class %d)", i, array->MarkRecord[i].Class); + dump_anchor (indent + 1, &array->MarkRecord[i].MarkAnchor); + printf (")"); + } + printf (")"); +} + +static void +dump_base_array (int indent, unsigned ClassCount, OTF_BaseArray *array) +{ + int i, j; + + IPRINT ("(BaseArray (BaseCount %d)", array->BaseCount); + indent++; + for (i = 0; i < array->BaseCount; i++) + { + IPRINT ("(BaseRecord (%d) ", i); + for (j = 0; j < ClassCount; j++) + dump_anchor (indent + 1, array->BaseRecord[i].BaseAnchor + j); + printf (")"); + } + printf (")"); +} + + +static void +dump_subst_lookup_record_list (int indent, + OTF_SubstLookupRecord *rec, unsigned num) +{ + int i; + + IPRINT ("(SubstCount %d)", num); + for (i = 0; i < num; i++) + { + IPRINT ("(SubstLookupRecord (%d)", i); + indent++; + IPRINT ("(SequenceIndex %d)", rec[i].SequenceIndex); + IPRINT ("(LookupListIndex %d))", rec[i].LookupListIndex); + indent--; + } +} + + +static void dump_lookup_subtable_gsub (int indent, int index, unsigned type, + OTF_LookupSubTable *subtable); +static void dump_lookup_subtable_gpos (int indent, int index, unsigned type, + OTF_LookupSubTable *subtable); + + +static void +dump_lookup_list (int indent, OTF_LookupList *list, int gsub) +{ + int i, j; + + IPRINT ("(LookupList (count %d)", list->LookupCount); + indent++; + for (i = 0; i < list->LookupCount; i++) + { + OTF_Lookup *lookup = list->Lookup + i; + + IPRINT ("(Lookup (%d) (Offset #x%04X)", + i, list->LookupOffset[i]); + printf (" (Type %d) (Flag #x%04X) (SubTableCount %d)", + lookup->LookupType, lookup->LookupFlag, lookup->SubTableCount); + if (gsub) + for (j = 0; j < lookup->SubTableCount; j++) + dump_lookup_subtable_gsub (indent + 1, j, + lookup->LookupType, lookup->SubTable + j); + else + for (j = 0; j < lookup->SubTableCount; j++) + dump_lookup_subtable_gpos (indent + 1, j, + lookup->LookupType, lookup->SubTable + j); + + printf (")"); + } + printf (")"); +} + + + +/* GSUB */ +static void +dump_gsub_header (int indent, OTF_GSUBHeader *header) +{ + IPRINT ("(Header"); + indent++; + IPRINT ("(Version %d.%d)", + header->Version.high, header->Version.low); + IPRINT ("(ScriptList #x%04X)", header->ScriptList); + IPRINT ("(FeatureList #x%04X)", header->FeatureList); + IPRINT ("(LookupList #x%04X))", header->LookupList); +} + + +static void +dump_lookup_subtable_gsub (int indent, int index, unsigned type, + OTF_LookupSubTable *subtable) +{ + IPRINT ("(SubTable (%d) (Format %d)", index, subtable->Format); + indent++; + switch (type) + { + case 1: + if (subtable->Format == 1) + { + dump_coverage (indent, NULL, &subtable->Coverage); + IPRINT ("(DeltaGlyhpID #x%04X)", + subtable->sub.gsub.single1.DeltaGlyphID); + } + else if (subtable->Format == 2) + { + dump_coverage (indent, NULL, &subtable->Coverage); + IPRINT ("(GlyphCount %d)", + subtable->sub.gsub.single2.GlyphCount); + IPRINT ("(Substitute"); + dump_glyph_ids (subtable->sub.gsub.single2.Substitute, + subtable->sub.gsub.single2.GlyphCount); + printf (")"); + } + break; + + case 2: + if (subtable->Format == 1) + { + dump_coverage (indent, NULL, &subtable->Coverage); + dump_sequence_list (indent, + subtable->sub.gsub.multiple1.Sequence, + subtable->sub.gsub.multiple1.SequenceCount); + } + break; + + case 4: + if (subtable->Format == 1) + { + dump_coverage (indent, NULL, &subtable->Coverage); + dump_ligature_set_list (indent, + subtable->sub.gsub.ligature1.LigatureSet, + subtable->sub.gsub.ligature1.LigSetCount); + } + break; + + case 6: + if (subtable->Format == 1) + { +#if 0 + read_coverage (fp, offset, + &subtable->sub.gsub.chain_context1.Coverage); + subtable->sub.gsub.chain_context1.ChainSubRuleSetCount + = (read_chain_subrule_set + (fp, offset, + &subtable->sub.gsub.chain_context1.ChainSubRuleSet)); +#endif + } + else if (subtable->Format == 2) + { +#if 0 + read_coverage (fp, offset, + &subtable->sub.gsub.chain_context2.Coverage); + read_class_def (fp, offset, + &subtable->sub.gsub.chain_context2.Backtrack); + read_class_def (fp, offset, + &subtable->sub.gsub.chain_context2.Input); + read_class_def (fp, offset, + &subtable->sub.gsub.chain_context2.LookAhead); + subtable->sub.gsub.chain_context2.ChainSubClassSetCnt + = (read_chain_subclass_set + (fp, offset, + &subtable->sub.gsub.chain_context2.ChainSubClassSet)); +#endif + } + else if (subtable->Format == 3) + { + dump_coverage_list + (indent, "BackTrackGlyphCount", + subtable->sub.gsub.chain_context3.Backtrack, + subtable->sub.gsub.chain_context3.BacktrackGlyphCount); + dump_coverage_list + (indent, "InputGlyphCount", + subtable->sub.gsub.chain_context3.Input, + subtable->sub.gsub.chain_context3.InputGlyphCount); + dump_coverage_list + (indent, "LookaheaGlyphCount", + subtable->sub.gsub.chain_context3.LookAhead, + subtable->sub.gsub.chain_context3.LookaheadGlyphCount); + dump_subst_lookup_record_list + (indent, + subtable->sub.gsub.chain_context3.SubstLookupRecord, + subtable->sub.gsub.chain_context3.SubstCount); + } + break; + } + printf (")"); +} + +static void +dump_gsub_table (int indent, OTF_GSUB *gsub) +{ + IPRINT ("(GSUB"); + indent++; + dump_gsub_header (indent, &gsub->header); + dump_script_list (indent, &gsub->script_list); + dump_feature_list (indent, &gsub->feature_list); + dump_lookup_list (indent, &gsub->lookup_list, 1); + printf (")"); +} + + +/* GPOS */ + +static void +dump_lookup_subtable_gpos (int indent, int index, unsigned type, + OTF_LookupSubTable *subtable) +{ + IPRINT ("(SubTable (%d) (Format %d)", index, subtable->Format); + indent++; + switch (type) + { + case 1: +#if 0 + if (subtable->Format == 1) + { + dump_coverage (indent, NULL, &subtable->sub.gpos.single1.Coverage); + IPRINT ("(DeltaGlyhpID #x%04X)", + subtable->sub.gsub.single1.DeltaGlyphID); + } + else if (subtable->Format == 2) + { + dump_coverage (indent, NULL, &subtable->sub.gsub.single2.Coverage); + IPRINT ("(GlyphCount %d)", + subtable->sub.gsub.single2.GlyphCount); + IPRINT ("(Substitute"); + dump_glyph_ids (subtable->sub.gsub.single2.Substitute, + subtable->sub.gsub.single2.GlyphCount); + printf (")"); + } +#endif + break; + + case 2: + if (subtable->Format == 1) + { + dump_coverage (indent, NULL, &subtable->Coverage); + } + else if (subtable->Format == 2) + { + dump_coverage (indent, NULL, &subtable->Coverage); + IPRINT ("(ValueFormat1 #x%04X)", + subtable->sub.gpos.pair2.ValueFormat1); + IPRINT ("(ValueFormat2 #x%04X)", + subtable->sub.gpos.pair2.ValueFormat2); + dump_class_def (indent, "ClassDef1", + &subtable->sub.gpos.pair2.ClassDef1); + dump_class_def (indent, "ClassDef2", + &subtable->sub.gpos.pair2.ClassDef2); + IPRINT ("(Class1Count %d)", + subtable->sub.gpos.pair2.Class1Count); + IPRINT ("(Class2Count %d)", + subtable->sub.gpos.pair2.Class2Count); + dump_class1_record_list (indent, + subtable->sub.gpos.pair2.Class1Count, + subtable->sub.gpos.pair2.Class2Count, + subtable->sub.gpos.pair2.Class1Record); + } + break; + + case 4: + if (subtable->Format == 1) + { + dump_coverage (indent, "Mark", &subtable->Coverage); + dump_coverage (indent, "Base", + &subtable->sub.gpos.mark_base1.BaseCoverage); + IPRINT ("(ClassCount %d)", + subtable->sub.gpos.mark_base1.ClassCount); + dump_mark_array (indent, &subtable->sub.gpos.mark_base1.MarkArray); + dump_base_array (indent, subtable->sub.gpos.mark_base1.ClassCount, + &subtable->sub.gpos.mark_base1.BaseArray); + } + break; + + case 6: + if (subtable->Format == 1) + { +#if 0 + read_coverage (fp, offset, + &subtable->sub.gsub.chain_context1.Coverage); + subtable->sub.gsub.chain_context1.ChainSubRuleSetCount + = (read_chain_subrule_set + (fp, offset, + &subtable->sub.gsub.chain_context1.ChainSubRuleSet)); +#endif + } + else if (subtable->Format == 2) + { +#if 0 + read_coverage (fp, offset, + &subtable->sub.gsub.chain_context2.Coverage); + read_class_def (fp, offset, + &subtable->sub.gsub.chain_context2.Backtrack); + read_class_def (fp, offset, + &subtable->sub.gsub.chain_context2.Input); + read_class_def (fp, offset, + &subtable->sub.gsub.chain_context2.LookAhead); + subtable->sub.gsub.chain_context2.ChainSubClassSetCnt + = (read_chain_subclass_set + (fp, offset, + &subtable->sub.gsub.chain_context2.ChainSubClassSet)); +#endif + } + else if (subtable->Format == 3) + { +#if 0 + dump_coverage_list + (indent, "BackTrackGlyphCount", + subtable->sub.gsub.chain_context3.Backtrack, + subtable->sub.gsub.chain_context3.BacktrackGlyphCount); + dump_coverage_list + (indent, "InputGlyphCount", + subtable->sub.gsub.chain_context3.Input, + subtable->sub.gsub.chain_context3.InputGlyphCount); + dump_coverage_list + (indent, "LookaheaGlyphCount", + subtable->sub.gsub.chain_context3.LookAhead, + subtable->sub.gsub.chain_context3.LookaheadGlyphCount); + dump_subst_lookup_record_list + (indent, + subtable->sub.gsub.chain_context3.SubstLookupRecord, + subtable->sub.gsub.chain_context3.SubstCount); +#endif + } + break; + } + printf (")"); +} + + +static void +dump_gpos_table (int indent, OTF_GPOS *gpos) +{ + IPRINT ("(GPOS"); + indent++; + dump_gsub_header (indent, (OTF_GPOSHeader *) &gpos->header); + dump_script_list (indent, &gpos->script_list); + dump_feature_list (indent, &gpos->feature_list); + dump_lookup_list (indent, &gpos->lookup_list, 0); + printf (")"); +} + +#if 0 +static void +dump_base_table (OTF_BASE *base) +{ +} + +static void +dump_jstf_table (OTF_JSTF *jstf) +{ +} +#endif + + +/* GDEF */ +static void +dump_gdef_header (int indent, OTF_GDEFHeader *header) +{ + IPRINT ("(Header\n"); + indent++; + IPRINT ("(Version %d.%d)", + header->Version.high, header->Version.low); + IPRINT ("(GlyphClassDef #x%04X)", header->GlyphClassDef); + IPRINT ("(AttachList #x%04X)", header->AttachList); + IPRINT ("(LigCaretList #x%04X)", header->LigCaretList); + IPRINT ("(MarkAttachClassDef #x%04X))", + header->MarkAttachClassDef); +} + +static void +dump_attach_list (int indent, OTF_AttachList *list) +{ +} + +static void +dump_lig_caret_list (int indent, OTF_LigCaretList *list) +{ + int i, j; + + IPRINT ("(LigCaretList"); + indent++; + dump_coverage (indent, NULL, &list->Coverage); + IPRINT ("(LigGlyphCount %d)", list->LigGlyphCount); + for (i = 0; i < list->LigGlyphCount; i++) + { + IPRINT ("(LigGlyph (%d) (offset #x%04X)", + i, list->LigGlyph[i].offset); + indent++; + IPRINT ("(CaretCount %d)", list->LigGlyph[i].CaretCount); + for (j = 0; j < list->LigGlyph[i].CaretCount; j++) + { + unsigned format = list->LigGlyph[i].CaretValue[j].CaretValueFormat; + + IPRINT ("(Caret (%d) (CaretValueFormat %d)", j, format); + if (format == 1) + { + printf ("(Coordinate %d)", + list->LigGlyph[i].CaretValue[j].f.f1.Coordinate); + } + else if (format == 2) + { + printf ("(CaretValuePoint %d)", + list->LigGlyph[i].CaretValue[j].f.f2.CaretValuePoint); + } + else if (format == 3) + { + printf ("(Coodinate %d)", + list->LigGlyph[i].CaretValue[j].f.f3.Coordinate); + indent++; + dump_device_table + (indent, "DeviceTable", + &list->LigGlyph[i].CaretValue[j].f.f3.DeviceTable); + indent--; + } + printf (")"); + } + printf (")"); + } + printf (")"); +} + + +static void +dump_gdef_table (int indent, OTF_GDEF *gdef) +{ + IPRINT ("(GDEF"); + indent++; + dump_gdef_header (indent, &gdef->header); + if (gdef->header.GlyphClassDef) + dump_class_def (indent, "GlyphClassDef", &gdef->glyph_class_def); + if (gdef->header.AttachList) + dump_attach_list (indent, &gdef->attach_list); + if (gdef->header.LigCaretList) + dump_lig_caret_list (indent, &gdef->lig_caret_list); + if (gdef->header.MarkAttachClassDef) + dump_class_def (indent, "MarkAttachClassDef", + &gdef->mark_attach_class_def); + printf (")"); +} + + +/* cmap */ +static void +dump_cmap_table (int indent, OTF_cmap *cmap) +{ + int i; + + IPRINT ("(cmap"); + indent++; + IPRINT ("(version %d)", cmap->version); + IPRINT ("(numTables %d)", cmap->numTables); + for (i = 0; i < cmap->numTables; i++) + { + IPRINT ("(EncodingRecord (%d) (platformID %d) (encodingID %d)", + i, + cmap->EncodingRecord[i].platformID, + cmap->EncodingRecord[i].encodingID); + indent++; + IPRINT ("(Subtable (offset #x%04X) (format %d) (length #x%04X) (language %d)", + cmap->EncodingRecord[i].offset, + cmap->EncodingRecord[i].subtable.format, + cmap->EncodingRecord[i].subtable.length, + cmap->EncodingRecord[i].subtable.language); + indent++; + switch (cmap->EncodingRecord[i].subtable.format) + { + case 0: + { + int j, k; + unsigned char *array + = cmap->EncodingRecord[i].subtable.f.f0->glyphIdArray; + + IPRINT ("(glyphIdArray"); + for (j = 0; j < 16; j++) + { + IPRINT (" "); + for (k = 0; k < 16; k++) + printf (" %3d", array[j * 16 + k]); + } + printf (")"); + } + break; + + case 4: + { + OTF_EncodingSubtable4 *sub4 + = cmap->EncodingRecord[i].subtable.f.f4; + int j; + + IPRINT ("(segCountX2 %d) (searchRange %d)", + sub4->segCountX2, sub4->searchRange); + IPRINT ("(entrySelector %d) (rangeShift %d)", + sub4->entrySelector, sub4->rangeShift); + for (j = 0; j < sub4->segCountX2 / 2; j++) + { + IPRINT ("(Segment (%d)", j); + indent++; + IPRINT ("(startCount #x%04X) (endCount #x%04X)", + sub4->segments[j].startCount, + sub4->segments[j].endCount); + IPRINT ("(idDelta %d) (idRangeOffset #x%04X))", + sub4->segments[j].idDelta, + sub4->segments[j].idRangeOffset); + indent--; + } + IPRINT ("(glyphIdArray"); + for (j = 0; j < sub4->GlyphCount; j++) + { + if ((j % 16) == 0) + IPRINT (" "); + printf (" %3d", sub4->glyphIdArray[j]); + } + printf (")"); + } + break; + } + + indent -= 2; + printf ("))"); + } + printf (")"); +} + + +/* name */ +static void +dump_name_table (int indent, OTF_name *name) +{ + int i; + + IPRINT ("(name"); + indent++; + IPRINT ("(format %d)", name->format); + IPRINT ("(count %d)", name->count); + IPRINT ("(stringOffset %d)", name->stringOffset); + for (i = 0; i < name->count; i++) + { + OTF_NameRecord *rec = name->nameRecord + i; + + IPRINT ("(nameRecord (%d)", i); + indent++; + IPRINT ("(platformID %d) (encodingID %d) (languageID %d) (nameID %d)", + rec->platformID, rec->encodingID, rec->languageID, rec->nameID); + IPRINT ("(length %d) (offset #x%04X))", rec->length, rec->offset); + indent--; + } + for (i = 0; i <= OTF_max_nameID; i++) + if (name->name[i]) + IPRINT ("(nameID %d \"%s\")", i, name->name[i]); + + printf (")"); +} + + + +static void +otf_dump (OTF *otf) +{ + int i; + + printf ("(OTF"); + dump_offset_table (1, &otf->offset_table); + for (i = 0; i < otf->offset_table.numTables; i++) + dump_table_directory (1, otf->table_dirs + i, i); + if (otf->head) + dump_head_table (1, otf->head); + if (otf->name) + dump_name_table (1, otf->name); + if (otf->cmap) + dump_cmap_table (1, otf->cmap); + if (otf->gdef) + dump_gdef_table (1, otf->gdef); + if (otf->gsub) + dump_gsub_table (1, otf->gsub); + if (otf->gpos) + dump_gpos_table (1, otf->gpos); +#if 0 + if (otf->base) + dump_base_table (otf->base); + if (otf->jstf) + dump_jstf_table (otf->jstf); +#endif + printf (")\n"); +} + + +int +main (int argc, char **argv) +{ + OTF *otf; + + if (argc != 2) + { + fprintf (stderr, "Usage, dtfdump OTF-FILE"); + exit (1); + } + + otf = otf_open (argv[1]); + otf_dump (otf); + otf_close (otf); + exit (0); +} diff --git a/otflib-config.in b/otflib-config.in new file mode 100644 index 0000000..1b064ae --- /dev/null +++ b/otflib-config.in @@ -0,0 +1,35 @@ +#!/bin/sh + +prefix=@prefix@ +exec_prefix=@exec_prefix@ + +help () +{ + echo "Usage: otflib-config [--version | --libs | --cflags ]" +} + +if test $# -eq 0; then + help 1>&2 + exit 0 +fi + +case $1 in +--version) + echo "@PACKAGE_VERSION@";; + +--libs) + if test "@libdir@" != "/usr/lib"; then + echo "-L@libdir@ -lotf" + else + echo "-lotf" + fi;; + +--cflags) + if test "@includedir@" != "/usr/include"; then + echo "-I@includedir@" + fi;; + +*) + help + exit 1;; +esac diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..0d5401e --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,10 @@ +lib_LTLIBRARIES = libotf.la + +libotf_la_SOURCES = \ + otf.h \ + otf-util.h otf-util.c \ + otf-open.c \ + otf-proc.c + +include_HEADERS = otf.h + diff --git a/src/config.h.in b/src/config.h.in new file mode 100644 index 0000000..46c34fe --- /dev/null +++ b/src/config.h.in @@ -0,0 +1,84 @@ +/* src/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ +#undef CRAY_STACKSEG_END + +/* Define to 1 if using `alloca.c'. */ +#undef C_ALLOCA + +/* Define to 1 if you have `alloca', as a function or macro. */ +#undef HAVE_ALLOCA + +/* Define to 1 if you have and it should be used (not on Ultrix). + */ +#undef HAVE_ALLOCA_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if your system has a working `malloc' function. */ +#undef HAVE_MALLOC + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_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 header file. */ +#undef HAVE_SYS_STAT_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 + +/* 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 + +/* If using the C implementation of alloca, define if you know the + direction of stack growth for your system; otherwise it will be + automatically deduced at run-time. + STACK_DIRECTION > 0 => grows toward higher addresses + STACK_DIRECTION < 0 => grows toward lower addresses + STACK_DIRECTION = 0 => direction of growth unknown */ +#undef STACK_DIRECTION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION diff --git a/src/otf-open.c b/src/otf-open.c new file mode 100644 index 0000000..92e1b07 --- /dev/null +++ b/src/otf-open.c @@ -0,0 +1,1766 @@ +#include +#include +#include + +#include "otf.h" +#include "otf-util.h" + +/* OTF_Stream + + Example of typical usage of OTF_Stream. + + { + OTF_Stream *stream; + OTF_StreamState state; + int offset, nbytes; + + OPEN_STREAM (_FILE_NAME_, stream); + if (! stream) + _ERROR_; + SETUP_STREAM (stream, fp, 0, 256, _NAME_); + offset = READ_OFFSET (stream); + nbytes = READ_ULONG (stream); + SETUP_STREAM (stream, fp, offset, nbytes, _NAME2_); + ...; + CLOSE_STREAM (stream); + } + +*/ + +typedef struct +{ + FILE *fp; + char *name; + long pos; + long bufsize; + long allocated; + unsigned char *buf; +} OTF_Stream; + +typedef long OTF_StreamState; + +OTF_Stream * +stream_open (char *filename) +{ + FILE *fp; + OTF_Stream *stream; + char *errfmt = "stream open for %s"; + void *errret = NULL; + + fp = fopen (filename, "r"); + if (! fp) + OTF_ERROR (OTF_ERROR_FILE, filename); + OTF_CALLOC (stream, 1, filename); + stream->fp = fp; + return stream; +} + +int +stream_setup (OTF_Stream *stream, long offset, int nbytes, char *name) +{ + char *errfmt = "stream setup for %s"; + int errret = -1; + + stream->name = name; + stream->pos = 0; + if (stream->allocated < nbytes) + { + unsigned char *buf = (unsigned char *) malloc (nbytes); + + if (! buf) + OTF_ERROR (OTF_ERROR_MEMORY, stream->name); + if (stream->buf) + free (stream->buf); + stream->buf = buf; + stream->allocated = nbytes; + } + stream->bufsize = nbytes; + if (fseek (stream->fp, offset, SEEK_SET) < 0) + OTF_ERROR (OTF_ERROR_FILE, stream->name); + if (fread (stream->buf, 1, nbytes, stream->fp) != nbytes) + OTF_ERROR (OTF_ERROR_FILE, stream->name); + return 0; +} + + +void +stream_close (OTF_Stream *stream) +{ + fclose (stream->fp); + free (stream); +} + +#define STREAM_SAVE_STATE(stream, state) ((state) = (stream)->pos) +#define STREAM_RESTORE_STATE(stream, state) ((stream)->pos = (state)) +#define STREAM_SEEK(stream, offset) ((stream)->pos = (offset)) + +int +stream_overrun (OTF_Stream *stream) +{ + char *errfmt = "buffer overrun in %s"; + int errret = -1; + + OTF_ERROR (OTF_ERROR_TABLE, (stream)->name); +} + +#define STREAM_CHECK_SIZE(stream, size) \ + if ((stream)->pos + (size) > (stream)->bufsize) \ + { \ + stream_overrun (stream); \ + return errret; \ + } \ + else + + +#define READ_USHORT(stream, var) \ + do { \ + STREAM_CHECK_SIZE ((stream), 2); \ + (var) = (((stream)->buf[(stream)->pos] << 8) \ + | (stream)->buf[(stream)->pos + 1]); \ + (stream)->pos += 2; \ + } while (0) + +#define READ_SHORT(stream, var) \ + do { \ + STREAM_CHECK_SIZE ((stream), 2); \ + (var) = (short) (((stream)->buf[(stream)->pos] << 8) \ + | (stream)->buf[(stream)->pos + 1]); \ + (stream)->pos += 2; \ + } while (0) + +#define READ_ULONG(stream, var) \ + do { \ + STREAM_CHECK_SIZE ((stream), 4); \ + (var) = (((stream)->buf[(stream)->pos] << 24) \ + | ((stream)->buf[(stream)->pos + 1] << 16) \ + | ((stream)->buf[(stream)->pos + 2] << 8) \ + | (stream)->buf[(stream)->pos + 3]); \ + (stream)->pos += 4; \ + } while (0) + +#define READ_LONG(stream, var) \ + do { \ + STREAM_CHECK_SIZE ((stream), 4); \ + (var) = (int) (((stream)->buf[(stream)->pos] << 24) \ + | ((stream)->buf[(stream)->pos + 1] << 16) \ + | ((stream)->buf[(stream)->pos + 2] << 8) \ + | (stream)->buf[(stream)->pos + 3]); \ + (stream)->pos += 4; \ + } while (0) + + +#define READ_FIXED(stream, fixed) \ + do { \ + READ_USHORT ((stream), (fixed).high); \ + READ_USHORT ((stream), (fixed).low); \ + } while (0) + + +#define READ_BYTES(stream, p, nbytes) \ + do { \ + STREAM_CHECK_SIZE ((stream), (nbytes)); \ + memcpy ((p), (stream)->buf + (stream)->pos, (nbytes)); \ + (stream)->pos += (nbytes); \ + } while (0) + + +#define READ_TAG READ_ULONG +#define READ_OFFSET READ_USHORT +#define READ_UINT16 READ_USHORT +#define READ_INT16 READ_SHORT +#define READ_GLYPHID READ_USHORT + + + +int +read_offset_table (OTF_Stream *stream, OTF_OffsetTable *table) +{ + int errret = -1; + + READ_FIXED (stream, table->sfnt_version); + READ_USHORT (stream, table->numTables); + READ_USHORT (stream, table->searchRange); + READ_USHORT (stream, table->enterSelector); + READ_USHORT (stream, table->rangeShift); + return 0; +} + +static int +read_table_directory (OTF_Stream *stream, OTF_TableDirectory *table) +{ + int errret = -1; + + READ_TAG (stream, table->tag); + READ_ULONG (stream, table->checkSum); + READ_ULONG (stream, table->offset); + READ_ULONG (stream, table->length); + return 0; +} + + + +OTF_head * +read_head_table (OTF_Stream *stream) +{ + char *errfmt = "head%s"; + void *errret = NULL; + OTF_head *head; + + OTF_CALLOC (head, 1, ""); + READ_FIXED (stream, head->TableVersionNumber); + READ_FIXED (stream, head->fontRevision); + READ_ULONG (stream, head->checkSumAdjustment); + READ_ULONG (stream, head->magicNumber); + READ_USHORT (stream, head->flags); + READ_USHORT (stream, head->unitsPerEm); + + return head; +} + + + +static int +read_script_list (OTF_Stream *stream, long offset, OTF_ScriptList *list) +{ + char *errfmt = "Script List%s"; + int errret = -1; + int i, j, k; + + STREAM_SEEK (stream, offset); + READ_USHORT (stream, list->ScriptCount); + OTF_MALLOC (list->ScriptRecord, list->ScriptCount, ""); + OTF_CALLOC (list->Script, list->ScriptCount, ""); + + for (i = 0; i < list->ScriptCount; i++) + { + READ_TAG (stream, list->ScriptRecord[i].ScriptTag); + READ_OFFSET (stream, list->ScriptRecord[i].Script); + } + for (i = 0; i < list->ScriptCount; i++) + { + OTF_Script *script = list->Script + i; + long script_offset = offset + list->ScriptRecord[i].Script; + + STREAM_SEEK (stream, script_offset); + READ_OFFSET (stream, script->DefaultLangSysOffset); + READ_USHORT (stream, script->LangSysCount); + OTF_MALLOC (script->LangSysRecord, script->LangSysCount, " (LangSys)"); + OTF_CALLOC (script->LangSys, script->LangSysCount, " (LangSys)"); + for (j = 0; j < script->LangSysCount; j++) + { + READ_TAG (stream, script->LangSysRecord[j].LangSysTag); + READ_OFFSET (stream, script->LangSysRecord[j].LangSys); + } + + if (script->DefaultLangSysOffset) + { + OTF_LangSys *langsys = &script->DefaultLangSys; + + STREAM_SEEK (stream, script_offset + script->DefaultLangSysOffset); + READ_OFFSET (stream, langsys->LookupOrder); + READ_USHORT (stream, langsys->ReqFeatureIndex); + READ_USHORT (stream, langsys->FeatureCount); + OTF_MALLOC (langsys->FeatureIndex, langsys->FeatureCount, + " (FeatureIndex)"); + for (k = 0; k < langsys->FeatureCount; k++) + READ_USHORT (stream, langsys->FeatureIndex[k]); + } + + for (j = 0; j < script->LangSysCount; j++) + { + OTF_LangSys *langsys = script->LangSys + j; + + STREAM_SEEK (stream, + script_offset + script->LangSysRecord[j].LangSys); + READ_OFFSET (stream, langsys->LookupOrder); + READ_USHORT (stream, langsys->ReqFeatureIndex); + READ_USHORT (stream, langsys->FeatureCount); + OTF_MALLOC (langsys->FeatureIndex, langsys->FeatureCount, + " (FeatureIndex)"); + for (k = 0; k < langsys->FeatureCount; k++) + READ_USHORT (stream, langsys->FeatureIndex[k]); + } + } + + return 0; +} + +static int +read_feature_list (OTF_Stream *stream, long offset, OTF_FeatureList *list) +{ + char *errfmt = "Feature List%s"; + int errret = -1; + int i, j; + + READ_UINT16 (stream, list->FeatureCount); + OTF_MALLOC (list->FeatureRecord, list->FeatureCount, ""); + OTF_CALLOC (list->Feature, list->FeatureCount, ""); + for (i = 0; i < list->FeatureCount; i++) + { + READ_TAG (stream, list->FeatureRecord[i].FeatureTag); + READ_OFFSET (stream, list->FeatureRecord[i].Feature); + } + for (i = 0; i < list->FeatureCount; i++) + { + OTF_Feature *feature = list->Feature + i; + + STREAM_SEEK (stream, offset + list->FeatureRecord[i].Feature); + READ_OFFSET (stream, feature->FeatureParams); + READ_UINT16 (stream, feature->LookupCount); + OTF_MALLOC (feature->LookupListIndex, feature->LookupCount, + " (LookupListIndex)"); + for (j = 0; j < feature->LookupCount; j++) + READ_UINT16 (stream, feature->LookupListIndex[j]); + } + + return 0; +} + +static int read_lookup_subtable_gsub (OTF_Stream *stream, long offset, + unsigned type, + OTF_LookupSubTable *subtable); +static int read_lookup_subtable_gpos (OTF_Stream *stream, long offset, + unsigned type, + OTF_LookupSubTable *subtable); + +static int +read_lookup_list (OTF_Stream *stream, long offset, + OTF_LookupList *list, int gsub) +{ + char *errfmt = "Lookup List%s"; + int errret = -1; + int i, j; + + STREAM_SEEK (stream, offset); + READ_UINT16 (stream, list->LookupCount); + OTF_MALLOC (list->LookupOffset, list->LookupCount, ""); + OTF_CALLOC (list->Lookup, list->LookupCount, ""); + + for (i = 0; i < list->LookupCount; i++) + READ_OFFSET (stream, list->LookupOffset[i]); + for (i = 0; i < list->LookupCount; i++) + { + OTF_Lookup *lookup = list->Lookup + i; + + STREAM_SEEK (stream, offset + list->LookupOffset[i]); + READ_UINT16 (stream, lookup->LookupType); + READ_UINT16 (stream, lookup->LookupFlag); + READ_UINT16 (stream, lookup->SubTableCount); + OTF_MALLOC (lookup->SubTableOffset, lookup->SubTableCount, + " (SubTableOffset)"); + OTF_CALLOC (lookup->SubTable, lookup->SubTableCount, + " (SubTable)"); + for (j = 0; j < lookup->SubTableCount; j++) + READ_OFFSET (stream, lookup->SubTableOffset[j]); + if (gsub) + for (j = 0; j < lookup->SubTableCount; j++) + { + long this_offset + = offset + list->LookupOffset[i] + lookup->SubTableOffset[j]; + + if (read_lookup_subtable_gsub (stream, this_offset, + lookup->LookupType, + lookup->SubTable + j) < 0) + return errret; + } + else + for (j = 0; j < lookup->SubTableCount; j++) + { + long this_offset + = offset + list->LookupOffset[i] + lookup->SubTableOffset[j]; + + if (read_lookup_subtable_gpos (stream, this_offset, + lookup->LookupType, + lookup->SubTable + j) < 0) + return errret; + } + } + + return 0; +} + + +static int +read_glyph_ids (OTF_Stream *stream, OTF_GlyphID **ids, int minus) +{ + char *errfmt = "GlyphID List%s"; + int errret = -1; + unsigned count; + int i; + + READ_UINT16 (stream, count); + if (! count) + return 0; + OTF_MALLOC (*ids, count, ""); + for (i = 0; i < count + minus; i++) + READ_GLYPHID (stream, (*ids)[i]); + return (int) count; +} + +static unsigned +read_range_record (OTF_Stream *stream, OTF_RangeRecord **record) +{ + char *errfmt = "RangeRecord%s"; + unsigned errret = 0; + unsigned count; + int i; + + READ_UINT16 (stream, count); + if (! count) + return 0; + OTF_MALLOC (*record, count, ""); + for (i = 0; i < count; i++) + { + READ_GLYPHID (stream, (*record)[i].Start); + READ_GLYPHID (stream, (*record)[i].End); + READ_UINT16 (stream, (*record)[i].StartCoverageIndex); + } + return count; +} + + +static int +read_coverage (OTF_Stream *stream, long offset, OTF_Coverage *coverage) +{ + char *errfmt = "Coverage%s"; + int errret = -1; + OTF_StreamState state; + int count; + + READ_OFFSET (stream, coverage->offset); + STREAM_SAVE_STATE (stream, state); + STREAM_SEEK (stream, offset + coverage->offset); + READ_UINT16 (stream, coverage->CoverageFormat); + if (coverage->CoverageFormat == 1) + count = read_glyph_ids (stream, &coverage->table.GlyphArray, 0); + else if (coverage->CoverageFormat == 2) + count = read_range_record (stream, &coverage->table.RangeRecord); + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid Format)"); + if (count < 0) + return -1; + coverage->Count = (unsigned) count; + STREAM_RESTORE_STATE (stream, state); + return 0; +} + +static int +read_coverage_list (OTF_Stream *stream, long offset, OTF_Coverage **coverage) +{ + char *errfmt = "Coverage List%s"; + int errret = -1; + int count; + int i; + + READ_UINT16 (stream, count); + if (! count) + return 0; + OTF_MALLOC (*coverage, count, ""); + for (i = 0; i < count; i++) + if (read_coverage (stream, offset, (*coverage) + i) < 0) + return -1; + return count; +} + + +static int +read_class_def_without_offset (OTF_Stream *stream, OTF_ClassDef *class) +{ + char *errfmt = "ClassDef%s"; + int errret = -1; + + STREAM_SEEK (stream, class->offset); + READ_UINT16 (stream, class->ClassFormat); + if (class->ClassFormat == 1) + { + READ_GLYPHID (stream, class->f.f1.StartGlyph); + class->f.f1.GlyphCount + = (read_glyph_ids + (stream, (OTF_GlyphID **) &class->f.f1.ClassValueArray, 0)); + if (! class->f.f1.GlyphCount) + return -1; + } + else if (class->ClassFormat == 2) + { + class->f.f2.ClassRangeCount + = (read_range_record + (stream, (OTF_RangeRecord **) &class->f.f2.ClassRangeRecord)); + if (! class->f.f2.ClassRangeCount) + return -1; + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid format)"); + return 0; +} + + +static int +read_class_def (OTF_Stream *stream, long offset, OTF_ClassDef *class) +{ + char *errfmt = "ClassDef%s"; + int errret = -1; + OTF_StreamState state; + + READ_OFFSET (stream, class->offset); + STREAM_SAVE_STATE (stream, state); + STREAM_SEEK (stream, offset + class->offset); + READ_UINT16 (stream, class->ClassFormat); + if (class->ClassFormat == 1) + { + READ_GLYPHID (stream, class->f.f1.StartGlyph); + class->f.f1.GlyphCount + = (read_glyph_ids + (stream, (OTF_GlyphID **) &class->f.f1.ClassValueArray, 0)); + if (! class->f.f1.GlyphCount) + return -1; + } + else if (class->ClassFormat == 2) + { + class->f.f2.ClassRangeCount + = (read_range_record + (stream, (OTF_RangeRecord **) &class->f.f2.ClassRangeRecord)); + if (! class->f.f2.ClassRangeCount) + return -1; + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid format)"); + + STREAM_RESTORE_STATE (stream, state); + return 0; +} + +static int +read_device_table (OTF_Stream *stream, long offset, OTF_DeviceTable *table) +{ + char *errfmt = "Device Table%s"; + int errret = -1; + + int num, i; + unsigned val; + struct { + int int2 : 2; + int int4 : 4; + int int8 : 8; + } intval; + + STREAM_SEEK (stream, offset + table->offset); + READ_UINT16 (stream, table->StartSize); + READ_UINT16 (stream, table->EndSize); + READ_UINT16 (stream, table->DeltaFormat); + num = table->EndSize - table->StartSize + 1; + OTF_MALLOC (table->DeltaValue, num, ""); + + if (table->DeltaFormat == 1) + for (i = 0; i < num; i++) + { + if ((i % 8) == 0) + READ_UINT16 (stream, val); + intval.int2 = (val >> (14 - (i % 8) * 2)) & 0x03; + table->DeltaValue[i] = intval.int2; + } + else if (table->DeltaFormat == 2) + for (i = 0; i < num; i++) + { + if ((i % 4) == 0) + READ_UINT16 (stream, val); + intval.int4 = (val >> (12 - (i % 4) * 4)) & 0x0F; + table->DeltaValue[i] = intval.int4; + } + else if (table->DeltaFormat == 3) + for (i = 0; i < num; i++) + { + if ((i % 2) == 0) + { + READ_UINT16 (stream, val); + intval.int8 = val >> 8; + table->DeltaValue[i] = intval.int8; + } + else + { + intval.int8 = val >> 8; + table->DeltaValue[i] = intval.int8; + } + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid format)"); + return 0; +} + + + +/* GSUB */ + +static int +read_gsub_header (OTF_Stream *stream, OTF_GSUBHeader *header) +{ + int errret = -1; + + READ_FIXED (stream, header->Version); + READ_OFFSET (stream, header->ScriptList); + READ_OFFSET (stream, header->FeatureList); + READ_OFFSET (stream, header->LookupList); + return 0; +} + +static OTF_GSUB * +read_gsub_table (OTF_Stream *stream) +{ + char *errfmt = "GSUB%s"; + void *errret = NULL; + OTF_GSUB *gsub; + + OTF_CALLOC (gsub, 1, ""); + if (read_gsub_header (stream, &gsub->header) < 0 + || read_script_list (stream, gsub->header.ScriptList, + &gsub->script_list) < 0 + || read_feature_list (stream, gsub->header.FeatureList, + &gsub->feature_list) < 0 + || read_lookup_list (stream, gsub->header.LookupList, + &gsub->lookup_list, 1) < 0) + return NULL; + return gsub; +} + + +static unsigned +read_sequence (OTF_Stream *stream, long offset, OTF_Sequence **seq) +{ + char *errfmt = "Sequence%s"; + unsigned errret = 0; + unsigned count; + int i; + + READ_UINT16 (stream, count); + OTF_MALLOC (*seq, count, ""); + if (! count) + OTF_ERROR (OTF_ERROR_TABLE, " (zero count)"); + for (i = 0; i < count; i++) + READ_OFFSET (stream, (*seq)[i].offset); + for (i = 0; i < count; i++) + { + STREAM_SEEK (stream, offset + (*seq)[i].offset); + (*seq)[i].GlyphCount = read_glyph_ids (stream, &(*seq)[i].Substitute, 0); + if (! (*seq)[i].GlyphCount) + return 0; + } + return count; +} + +static int +read_ligature (OTF_Stream *stream, long offset, OTF_Ligature **ligature) +{ + char *errfmt = "Ligature%s"; + int errret = -1; + int count; + int i; + + READ_UINT16 (stream, count); + if (! count) + return 0; + OTF_MALLOC (*ligature, count, ""); + for (i = 0; i < count; i++) + READ_OFFSET (stream, (*ligature)[i].offset); + for (i = 0; i < count; i++) + { + STREAM_SEEK (stream, offset + (*ligature)[i].offset); + READ_GLYPHID (stream, (*ligature)[i].LigGlyph); + (*ligature)[i].CompCount + = read_glyph_ids (stream, &(*ligature)[i].Component, -1); + if (! (*ligature)[i].CompCount) + return -1; + } + return count; +} + +static int +read_ligature_set (OTF_Stream *stream, long offset, OTF_LigatureSet **ligset) +{ + char *errfmt = "LigatureSet%s"; + int errret = -1; + int count; + int i; + + READ_UINT16 (stream, count); + if (! count) + return 0; + OTF_MALLOC (*ligset, count, ""); + for (i = 0; i < count; i++) + READ_OFFSET (stream, (*ligset)[i].offset); + for (i = 0; i < count; i++) + { + int lig_count; + + STREAM_SEEK (stream, offset + (*ligset)[i].offset); + lig_count = read_ligature (stream, offset + (*ligset)[i].offset, + &(*ligset)[i].Ligature); + if (lig_count < 0) + return -1; + (*ligset)[i].LigatureCount = (unsigned) lig_count; + } + return count; +} + +static unsigned +read_subst_lookup_record (OTF_Stream *stream, OTF_SubstLookupRecord **record) +{ + char *errfmt = "SubstLookupRecord%s"; + unsigned errret = 0; + unsigned count; + int i; + + READ_UINT16 (stream, count); + if (! count) + OTF_ERROR (OTF_ERROR_TABLE, " (zero count)"); + OTF_MALLOC (*record, count, ""); + for (i = 0; i < count; i++) + { + READ_UINT16 (stream, (*record)[i].SequenceIndex); + READ_UINT16 (stream, (*record)[i].LookupListIndex); + } + return count; +} + +static unsigned +read_chain_subrule (OTF_Stream *stream, long offset, OTF_ChainSubRule **rule) +{ + char *errfmt = "ChainSubRule%s"; + unsigned errret = 0; + unsigned count; + int i; + + READ_UINT16 (stream, count); + if (! count) + OTF_ERROR (OTF_ERROR_TABLE, " (zero count)"); + OTF_MALLOC (*rule, count, ""); + for (i = 0; i < count; i++) + READ_OFFSET (stream, (*rule)[i].offset); + for (i = 0; i < count; i++) + { + STREAM_SEEK (stream, offset + (*rule)[i].offset); + (*rule)[i].BacktrackGlyphCount + = read_glyph_ids (stream, &(*rule)[i].Backtrack, 0); + if (! (*rule)[i].BacktrackGlyphCount) + return 0; + (*rule)[i].InputGlyphCount + = read_glyph_ids (stream, &(*rule)[i].Input, -1); + if (! (*rule)[i].InputGlyphCount) + return 0; + (*rule)[i].LookaheadGlyphCount + = read_glyph_ids (stream, &(*rule)[i].LookAhead, 0); + if (! (*rule)[i].LookaheadGlyphCount) + return 0; + (*rule)[i].SubstCount + = read_subst_lookup_record (stream, &(*rule)[i].SubstLookupRecord); + if (! (*rule)[i].SubstCount) + return 0; + } + return count; +} + + +static unsigned +read_chain_subrule_set (OTF_Stream *stream, long offset, + OTF_ChainSubRuleSet **set) +{ + char *errfmt = "ChainSubRuleSet%s"; + unsigned errret = 0; + unsigned count; + int i; + + READ_UINT16 (stream, count); + if (! count) + OTF_ERROR (OTF_ERROR_TABLE, " (zero count)"); + OTF_MALLOC (*set, count, ""); + for (i = 0; i < count; i++) + READ_OFFSET (stream, (*set)[i].offset); + for (i = 0; i < count; i++) + { + STREAM_SEEK (stream, offset + (*set)[i].offset); + (*set)[i].ChainSubRuleCount + = read_chain_subrule (stream, offset + (*set)[i].offset, + &(*set)[i].ChainSubRule); + if (! (*set)[i].ChainSubRuleCount) + return 0; + } + return count; +} + +static unsigned +read_chain_subclass_rule (OTF_Stream *stream, long offset, + OTF_ChainSubClassRule **rule) +{ + char *errfmt = "ChainSubClassRule%s"; + unsigned errret = 0; + unsigned count; + int i; + + READ_UINT16 (stream, count); + if (! count) + OTF_ERROR (OTF_ERROR_TABLE, " (zero count)"); + OTF_MALLOC (*rule, count, ""); + for (i = 0; i < count; i++) + READ_OFFSET (stream, (*rule)[i].offset); + for (i = 0; i < count; i++) + { + STREAM_SEEK (stream, offset + (*rule)[i].offset); + (*rule)[i].BacktrackGlyphCount + = read_glyph_ids (stream, (OTF_GlyphID **) &(*rule)[i].Backtrack, 0); + if (! (*rule)[i].BacktrackGlyphCount) + return 0; + (*rule)[i].InputGlyphCount + = read_glyph_ids (stream, (OTF_GlyphID **) &(*rule)[i].Input, -1); + if (! (*rule)[i].InputGlyphCount) + return 0; + (*rule)[i].LookaheadGlyphCount + = read_glyph_ids (stream, (OTF_GlyphID **) &(*rule)[i].LookAhead, 0); + if (! (*rule)[i].LookaheadGlyphCount) + return 0; + (*rule)[i].SubstCount + = read_subst_lookup_record (stream, &(*rule)[i].SubstLookupRecord); + if (! (*rule)[i].SubstCount) + return 0; + } + return count; +} + +static unsigned +read_chain_subclass_set (OTF_Stream *stream, long offset, + OTF_ChainSubClassSet **set) +{ + char *errfmt = "ChainSubClassSet%s"; + unsigned errret = 0; + unsigned count; + int i; + + READ_UINT16 (stream, count); + if (! count) + OTF_ERROR (OTF_ERROR_TABLE, " (zero count)"); + OTF_MALLOC (*set, count, ""); + for (i = 0; i < count; i++) + READ_OFFSET (stream, (*set)[i].offset); + for (i = 0; i < count; i++) + { + STREAM_SEEK (stream, offset + (*set)[i].offset); + (*set)[i].ChainSubClassRuleCnt + = read_chain_subclass_rule (stream, offset + (*set)[i].offset, + &(*set)[i].ChainSubClassRule); + if (! (*set)[i].ChainSubClassRuleCnt) + return 0; + } + return count; +} + + +static int +read_lookup_subtable_gsub (OTF_Stream *stream, long offset, + unsigned type, OTF_LookupSubTable *subtable) +{ + char *errfmt = "GSUB LookupSubTable%s"; + int errret = -1; + int count; + + STREAM_SEEK (stream, offset); + READ_UINT16 (stream, subtable->Format); + switch (type) + { + case 1: + if (subtable->Format == 1) + { + if (read_coverage (stream, offset, &subtable->Coverage) < 0) + return -1; + READ_INT16 (stream, subtable->sub.gsub.single1.DeltaGlyphID); + } + else if (subtable->Format == 2) + { + if (read_coverage (stream, offset, &subtable->Coverage) < 0) + return -1; + subtable->sub.gsub.single2.GlyphCount + = read_glyph_ids (stream, &subtable->sub.gsub.single2.Substitute, + 0); + if (! subtable->sub.gsub.single2.GlyphCount) + return -1; + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)"); + break; + + case 2: + if (subtable->Format == 1) + { + read_coverage (stream, offset, &subtable->Coverage); + subtable->sub.gsub.multiple1.SequenceCount + = read_sequence (stream, offset, + &subtable->sub.gsub.multiple1.Sequence); + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)"); + break; + + case 3: + break; + + case 4: + if (subtable->Format == 1) + { + read_coverage (stream, offset, &subtable->Coverage); + count = (read_ligature_set + (stream, offset, + &subtable->sub.gsub.ligature1.LigatureSet)); + if (count < 0) + return -1; + subtable->sub.gsub.ligature1.LigSetCount = (unsigned) count; + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)"); + break; + + case 6: + if (subtable->Format == 1) + { + read_coverage (stream, offset, &subtable->Coverage); + subtable->sub.gsub.chain_context1.ChainSubRuleSetCount + = (read_chain_subrule_set + (stream, offset, + &subtable->sub.gsub.chain_context1.ChainSubRuleSet)); + } + else if (subtable->Format == 2) + { + read_coverage (stream, offset, &subtable->Coverage); + read_class_def (stream, offset, + &subtable->sub.gsub.chain_context2.Backtrack); + read_class_def (stream, offset, + &subtable->sub.gsub.chain_context2.Input); + read_class_def (stream, offset, + &subtable->sub.gsub.chain_context2.LookAhead); + subtable->sub.gsub.chain_context2.ChainSubClassSetCnt + = (read_chain_subclass_set + (stream, offset, + &subtable->sub.gsub.chain_context2.ChainSubClassSet)); + } + else if (subtable->Format == 3) + { + count = (read_coverage_list + (stream, offset, + &subtable->sub.gsub.chain_context3.Backtrack)); + if (count < 0) + return -1; + subtable->sub.gsub.chain_context3.BacktrackGlyphCount + = (unsigned) count; + count = (read_coverage_list + (stream, offset, + &subtable->sub.gsub.chain_context3.Input)); + if (count <= 0) + return -1; + subtable->sub.gsub.chain_context3.InputGlyphCount + = (unsigned) count; + subtable->Coverage = subtable->sub.gsub.chain_context3.Input[0]; + count = (read_coverage_list + (stream, offset, + &subtable->sub.gsub.chain_context3.LookAhead)); + subtable->sub.gsub.chain_context3.LookaheadGlyphCount + = (unsigned) count; + subtable->sub.gsub.chain_context3.SubstCount + = (read_subst_lookup_record + (stream, &subtable->sub.gsub.chain_context3.SubstLookupRecord)); + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)"); + break; + + + default: + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid LookupType)"); + } + return 0; +} + + +/* GPOS */ + +static int +read_value_record (OTF_Stream *stream, long offset, + enum OTF_ValueFormat bit, OTF_ValueRecord *value_record) +{ + int errret = -1; + OTF_StreamState state; + int size, i; + + if (! bit) + return 0; + for (i = 0, size = 0; i < 8; i++) + if (bit & (1 << i)) + size += 2; + + if (bit & OTF_XPlacement) + READ_INT16 (stream, value_record->XPlacement); + if (bit & OTF_XPlacement) + READ_INT16 (stream, value_record->YPlacement); + if (bit & OTF_XAdvance) + READ_INT16 (stream, value_record->XAdvance); + if (bit & OTF_YAdvance) + READ_INT16 (stream, value_record->YAdvance); + if (bit & OTF_XPlaDevice) + READ_OFFSET (stream, value_record->XPlaDevice.offset); + if (bit & OTF_YPlaDevice) + READ_OFFSET (stream, value_record->YPlaDevice.offset); + if (bit & OTF_XAdvDevice) + READ_OFFSET (stream, value_record->XAdvDevice.offset); + if (bit & OTF_YAdvDevice) + READ_OFFSET (stream, value_record->YAdvDevice.offset); + STREAM_SAVE_STATE (stream, state); + if (value_record->XPlaDevice.offset) + { + if (read_device_table (stream, offset, &value_record->XPlaDevice) < 0) + return -1; + } + if (value_record->YPlaDevice.offset) + { + if (read_device_table (stream, offset, &value_record->YPlaDevice) < 0) + return -1; + } + if (value_record->XAdvDevice.offset) + { + if (read_device_table (stream, offset, &value_record->XAdvDevice) < 0) + return -1; + } + if (value_record->YAdvDevice.offset) + { + if (read_device_table (stream, offset, &value_record->YAdvDevice) < 0) + return -1; + } + STREAM_RESTORE_STATE (stream, state); + return 0; +} + + +static int +read_anchor (OTF_Stream *stream, long offset, OTF_Anchor *anchor) +{ + char *errfmt = "Anchor%s"; + int errret = -1; + + STREAM_SEEK (stream, offset + anchor->offset); + READ_UINT16 (stream, anchor->AnchorFormat); + READ_INT16 (stream, anchor->XCoordinate); + READ_INT16 (stream, anchor->YCoordinate); + if (anchor->AnchorFormat == 1) + ; + else if (anchor->AnchorFormat == 2) + { + READ_UINT16 (stream, anchor->f.f1.AnchorPoint); + } + else if (anchor->AnchorFormat == 3) + { + READ_OFFSET (stream, anchor->f.f2.XDeviceTable.offset); + READ_OFFSET (stream, anchor->f.f2.YDeviceTable.offset); + if (anchor->f.f2.XDeviceTable.offset) + { + if (read_device_table (stream, offset + anchor->offset, + &anchor->f.f2.XDeviceTable) < 0) + return -1; + } + if (anchor->f.f2.YDeviceTable.offset) + { + if (read_device_table (stream, offset + anchor->offset, + &anchor->f.f2.YDeviceTable) < 0) + return -1; + } + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (invalid format)"); + + return 0; +} + +static int +read_mark_array (OTF_Stream *stream, long offset, OTF_MarkArray *array) +{ + char *errfmt = "MarkArray%s"; + int errret = -1; + OTF_StreamState state; + int i; + + READ_OFFSET (stream, array->offset); + STREAM_SAVE_STATE (stream, state); + STREAM_SEEK (stream, offset + array->offset); + READ_UINT16 (stream, array->MarkCount); + OTF_MALLOC (array->MarkRecord, array->MarkCount, ""); + for (i = 0; i < array->MarkCount; i++) + { + READ_UINT16 (stream, array->MarkRecord[i].Class); + READ_OFFSET (stream, array->MarkRecord[i].MarkAnchor.offset); + } + for (i = 0; i < array->MarkCount; i++) + if (read_anchor (stream, offset + array->offset, + &array->MarkRecord[i].MarkAnchor) < 0) + return -1;; + STREAM_RESTORE_STATE (stream, state); + return 0; +} + +static int +read_base_array (OTF_Stream *stream, long offset, + unsigned ClassCount, OTF_BaseArray *array) +{ + char *errfmt = "BaseArray%s"; + int errret = -1; + OTF_StreamState state; + int i, j; + + READ_OFFSET (stream, array->offset); + STREAM_SAVE_STATE (stream, state); + STREAM_SEEK (stream, offset + array->offset); + READ_UINT16 (stream, array->BaseCount); + OTF_MALLOC (array->BaseRecord, array->BaseCount, ""); + for (i = 0; i < array->BaseCount; i++) + { + OTF_MALLOC (array->BaseRecord[i].BaseAnchor, ClassCount, + " (BaseRecord)"); + for (j = 0; j < ClassCount; j++) + READ_OFFSET (stream, array->BaseRecord[i].BaseAnchor[j].offset); + } + for (i = 0; i < array->BaseCount; i++) + for (j = 0; j < ClassCount; j++) + if (read_anchor (stream, offset + array->offset, + &array->BaseRecord[i].BaseAnchor[j]) < 0) + return -1; + STREAM_RESTORE_STATE (stream, state); + return 0; +} + + +static OTF_Class1Record * +read_class1_record_list (OTF_Stream *stream, long offset, + unsigned num1, enum OTF_ValueFormat bit1, + unsigned num2, enum OTF_ValueFormat bit2) +{ + char *errfmt = "Class1Record%s"; + void *errret = NULL; + OTF_Class1Record *rec; + int i, j; + + OTF_MALLOC (rec, num1, ""); + for (i = 0; i < num1; i++) + { + OTF_CALLOC (rec[i].Class2Record, num2, " (Class2Record)"); + for (j = 0; j < num2; j++) + { + if (read_value_record (stream, offset, + bit1, &rec[i].Class2Record[j].Value1) < 0 + || read_value_record (stream, offset, + bit2, &rec[i].Class2Record[j].Value2) < 0) + return NULL; + } + } + return rec; +} + + +static int +read_lookup_subtable_gpos (OTF_Stream *stream, long offset, unsigned type, + OTF_LookupSubTable *subtable) +{ + char *errfmt = "GPOS LookupSubTable%s"; + int errret = -1; + + STREAM_SEEK (stream, offset); + READ_UINT16 (stream, subtable->Format); + switch (type) + { + case 1: +#if 0 + if (subtable->Format == 1) + { + read_coverage (stream, offset, &subtable->Coverage); + subtable->sub.gsub.single1.DeltaGlyphID = READ_INT16 (stream); + } + else if (subtable->Format == 2) + { + read_coverage (stream, offset, &subtable->Coverage); + subtable->sub.gsub.single2.GlyphCount + = read_glyph_ids (stream, + &subtable->sub.gsub.single2.Substitute, 0); + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)"); +#endif + break; + + case 2: + if (subtable->Format == 1) + { + read_coverage (stream, offset, &subtable->Coverage); + } + else if (subtable->Format == 2) + { + STREAM_SEEK (stream, offset + 2); + read_coverage (stream, offset, &subtable->Coverage); + READ_UINT16 (stream, subtable->sub.gpos.pair2.ValueFormat1); + READ_UINT16 (stream, subtable->sub.gpos.pair2.ValueFormat2); + read_class_def (stream, offset, &subtable->sub.gpos.pair2.ClassDef1); + read_class_def (stream, offset, &subtable->sub.gpos.pair2.ClassDef2); + READ_UINT16 (stream, subtable->sub.gpos.pair2.Class1Count); + READ_UINT16 (stream, subtable->sub.gpos.pair2.Class2Count); + subtable->sub.gpos.pair2.Class1Record + = read_class1_record_list (stream, offset, + subtable->sub.gpos.pair2.Class1Count, + subtable->sub.gpos.pair2.ValueFormat1, + subtable->sub.gpos.pair2.Class2Count, + subtable->sub.gpos.pair2.ValueFormat2); + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)"); + break; + + case 4: + if (subtable->Format == 1) + { + read_coverage (stream, offset, &subtable->Coverage); + read_coverage (stream, offset, + &subtable->sub.gpos.mark_base1.BaseCoverage); + READ_UINT16 (stream, subtable->sub.gpos.mark_base1.ClassCount); + read_mark_array (stream, offset, + &subtable->sub.gpos.mark_base1.MarkArray); + read_base_array (stream, offset, + subtable->sub.gpos.mark_base1.ClassCount, + &subtable->sub.gpos.mark_base1.BaseArray); + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)"); + break; + + case 6: +#if 0 + if (subtable->Format == 1) + { + read_coverage (stream, offset, + &subtable->sub.gsub.chain_context1.Coverage); + subtable->sub.gsub.chain_context1.ChainSubRuleSetCount + = (read_chain_subrule_set + (stream, offset, + &subtable->sub.gsub.chain_context1.ChainSubRuleSet)); + } + else if (subtable->Format == 2) + { + read_coverage (stream, offset, + &subtable->sub.gsub.chain_context2.Coverage); + read_class_def (stream, offset, + &subtable->sub.gsub.chain_context2.Backtrack); + read_class_def (stream, offset, + &subtable->sub.gsub.chain_context2.Input); + read_class_def (stream, offset, + &subtable->sub.gsub.chain_context2.LookAhead); + subtable->sub.gsub.chain_context2.ChainSubClassSetCnt + = (read_chain_subclass_set + (stream, offset, + &subtable->sub.gsub.chain_context2.ChainSubClassSet)); + } + else if (subtable->Format == 3) + { + subtable->sub.gsub.chain_context3.BacktrackGlyphCount + = (read_coverage_list + (stream, offset, + &subtable->sub.gsub.chain_context3.Backtrack)); + subtable->sub.gsub.chain_context3.InputGlyphCount + = (read_coverage_list + (stream, offset, + &subtable->sub.gsub.chain_context3.Input)); + subtable->sub.gsub.chain_context3.LookaheadGlyphCount + = (read_coverage_list + (stream, offset, + &subtable->sub.gsub.chain_context3.LookAhead)); + subtable->sub.gsub.chain_context3.SubstCount + = (read_subst_lookup_record + (stream, &subtable->sub.gsub.chain_context3.SubstLookupRecord)); + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid SubFormat)"); +#endif + + default: + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid LookupType)"); + } + return 0; +} + + +static OTF_GPOS * +read_gpos_table (OTF_Stream *stream) +{ + char *errfmt = "GPOS%s"; + void *errret = NULL; + OTF_GPOS *gpos; + + OTF_MALLOC (gpos, 1, ""); + if (read_gsub_header (stream, (OTF_GPOSHeader *) &gpos->header) < 0 + || read_script_list (stream, gpos->header.ScriptList, + &gpos->script_list) < 0 + || read_feature_list (stream, gpos->header.FeatureList, + &gpos->feature_list) < 0 + || read_lookup_list (stream, gpos->header.LookupList, + &gpos->lookup_list, 0) < 0) + return NULL; + return gpos; +} + + +#if 0 +/* BASE */ + +static OTF_BASE * +read_base_table (OTF_Stream *stream, long offset) +{ + OTF_BASE *base; + + OTF_MALLOC (base, 1); + + return base; +} + + +/* JSTF */ + +static OTF_JSTF * +read_jstf_table (OTF_Stream *stream, long offset) +{ + OTF_JSTF *jstf; + + OTF_MALLOC (jstf, 1); + + return jstf; +} +#endif + +/* GDEF */ +static int +read_attach_list (OTF_Stream *stream, long offset, OTF_AttachList *list) +{ + char *errfmt = "AttachList%s"; + int errret = -1; + int i, j; + + if (read_coverage (stream, offset, &list->Coverage) < 0) + return -1; + READ_UINT16 (stream, list->GlyphCount); + OTF_MALLOC (list->AttachPoint, list->GlyphCount, ""); + for (i = 0; i < list->GlyphCount; i++) + READ_OFFSET (stream, list->AttachPoint[i].offset); + for (i = 0; i < list->GlyphCount; i++) + { + int count; + + STREAM_SEEK (stream, offset + list->AttachPoint[i].offset); + READ_UINT16 (stream, count); + list->AttachPoint[i].PointCount = count; + OTF_MALLOC (list->AttachPoint[i].PointIndex, count, " (PointIndex)"); + for (j = 0; j < count; j++) + READ_UINT16 (stream, list->AttachPoint[i].PointIndex[j]); + } + return 0; +} + +static int +read_caret_value (OTF_Stream *stream, long offset, OTF_CaretValue *caret) +{ + char *errfmt = "CaretValue%s"; + int errret = -1; + + STREAM_SEEK (stream, offset + caret->offset); + READ_UINT16 (stream, caret->CaretValueFormat); + if (caret->CaretValueFormat == 1) + READ_INT16 (stream, caret->f.f1.Coordinate); + else if (caret->CaretValueFormat == 2) + READ_UINT16 (stream, caret->f.f2.CaretValuePoint); + else if (caret->CaretValueFormat == 3) + { + READ_INT16 (stream, caret->f.f3.Coordinate); + if (read_device_table (stream, offset + caret->offset, + &caret->f.f3.DeviceTable) < 0) + return -1; + } + else + OTF_ERROR (OTF_ERROR_TABLE, " (Invalid format)"); + return 0; +} + +static int +read_lig_caret_list (OTF_Stream *stream, long offset, OTF_LigCaretList *list) +{ + char *errfmt = "LigCaretList%s"; + int errret = -1; + int i, j; + + if (read_coverage (stream, offset, &list->Coverage) < 0) + return -1; + READ_UINT16 (stream, list->LigGlyphCount); + OTF_MALLOC (list->LigGlyph, list->LigGlyphCount, ""); + for (i = 0; i < list->LigGlyphCount; i++) + READ_OFFSET (stream, list->LigGlyph[i].offset); + for (i = 0; i < list->LigGlyphCount; i++) + { + int count; + + STREAM_SEEK (stream, offset + list->LigGlyph[i].offset); + READ_UINT16 (stream, count); + list->LigGlyph[i].CaretCount = count; + OTF_MALLOC (list->LigGlyph[i].CaretValue, count, " (CaretValue)"); + for (j = 0; j < count; j++) + READ_OFFSET (stream, list->LigGlyph[i].CaretValue[j].offset); + for (j = 0; j < count; j++) + if (read_caret_value (stream, offset + list->LigGlyph[i].offset, + &list->LigGlyph[i].CaretValue[j]) < 0) + return -1; + } + return 0; +} + + +static int +read_gdef_header (OTF_Stream *stream, OTF_GDEFHeader *header) +{ + int errret = -1; + + READ_FIXED (stream, header->Version); + READ_OFFSET (stream, header->GlyphClassDef); + READ_OFFSET (stream, header->AttachList); + READ_OFFSET (stream, header->LigCaretList); + READ_OFFSET (stream, header->MarkAttachClassDef); + return 0; +} + +static OTF_GDEF * +read_gdef_table (OTF_Stream *stream) +{ + char *errfmt = "GDEF%s"; + void *errret = NULL; + OTF_GDEF *gdef; + + OTF_CALLOC (gdef, 1, ""); + read_gdef_header (stream, (OTF_GDEFHeader *) &gdef->header); + if (gdef->header.GlyphClassDef) + { + gdef->glyph_class_def.offset = gdef->header.GlyphClassDef; + read_class_def_without_offset (stream, &gdef->glyph_class_def); + } + if (gdef->header.AttachList) + read_attach_list (stream, gdef->header.AttachList, + &gdef->attach_list); + if (gdef->header.LigCaretList) + read_lig_caret_list (stream, gdef->header.LigCaretList, + &gdef->lig_caret_list); + if (gdef->header.MarkAttachClassDef) + { + gdef->mark_attach_class_def.offset = gdef->header.MarkAttachClassDef; + read_class_def_without_offset (stream, &gdef->mark_attach_class_def); + } + + return gdef; +} + + + +/* cmap */ + +static OTF_cmap * +read_cmap_table (OTF_Stream *stream) +{ + char *errfmt = "cmap%s"; + void *errret = NULL; + OTF_cmap *cmap; + int i; + + OTF_CALLOC (cmap, 1, ""); + READ_USHORT (stream, cmap->version); + READ_USHORT (stream, cmap->numTables); + OTF_MALLOC (cmap->EncodingRecord, cmap->numTables, ""); + for (i = 0; i < cmap->numTables; i++) + { + READ_USHORT (stream, cmap->EncodingRecord[i].platformID); + READ_USHORT (stream, cmap->EncodingRecord[i].encodingID); + READ_ULONG (stream, cmap->EncodingRecord[i].offset); + if (cmap->EncodingRecord[i].platformID == 3 + && cmap->EncodingRecord[i].encodingID == 1) + cmap->Unicode = cmap->EncodingRecord + i; + } + for (i = 0; i < cmap->numTables; i++) + { + unsigned format; + + STREAM_SEEK (stream, cmap->EncodingRecord[i].offset); + READ_USHORT (stream, format); + cmap->EncodingRecord[i].subtable.format = format; + READ_USHORT (stream, cmap->EncodingRecord[i].subtable.length); + if (format == 8 || format == 10 || format == 12) + { + READ_ULONG (stream, cmap->EncodingRecord[i].subtable.length); + READ_ULONG (stream, cmap->EncodingRecord[i].subtable.language); + } + else + { + READ_USHORT (stream, cmap->EncodingRecord[i].subtable.language); + } + switch (format) + { + case 0: + { + OTF_MALLOC (cmap->EncodingRecord[i].subtable.f.f0, 1, + " (EncodingRecord)"); + READ_BYTES (stream, + cmap->EncodingRecord[i].subtable.f.f0->glyphIdArray, + 256); + } + break; + + case 2: + break; + + case 4: + { + OTF_EncodingSubtable4 *sub4; + int segCount; + int j; + unsigned dummy; + + OTF_MALLOC (sub4, 1, " (EncodingSubtable4)"); + cmap->EncodingRecord[i].subtable.f.f4 = sub4; + READ_USHORT (stream, sub4->segCountX2); + segCount = sub4->segCountX2 / 2; + READ_USHORT (stream, sub4->searchRange); + READ_USHORT (stream, sub4->entrySelector); + READ_USHORT (stream, sub4->rangeShift); + OTF_MALLOC (sub4->segments, segCount, " (segCount)"); + for (j = 0; j < segCount; j++) + READ_USHORT (stream, sub4->segments[j].endCount); + READ_USHORT (stream, dummy); + for (j = 0; j < segCount; j++) + READ_USHORT (stream, sub4->segments[j].startCount); + for (j = 0; j < segCount; j++) + READ_SHORT (stream, sub4->segments[j].idDelta); + for (j = 0; j < segCount; j++) + { + unsigned off; + unsigned rest = 2 * (segCount - j); + + READ_USHORT (stream, off); + if (off == 0) + sub4->segments[j].idRangeOffset = 0xFFFF; + else + sub4->segments[j].idRangeOffset = (off - rest) / 2; + } + j = (cmap->EncodingRecord[i].subtable.length + - (14 + 2 * (segCount * 4 + 1))); + sub4->GlyphCount = j / 2; + OTF_MALLOC (sub4->glyphIdArray, sub4->GlyphCount, " (GlyphCount)"); + for (j = 0; j < sub4->GlyphCount; j++) + READ_USHORT (stream, sub4->glyphIdArray[j]); + } + } + } + return cmap; +} + + + +/* name */ + +static char * +read_name (OTF_Stream *stream, OTF_NameRecord *rec, int bytes) +{ + char *errfmt = "nameID (%d)"; + void *errret = NULL; + OTF_StreamState state; + char *str; + int i; + int c; + + STREAM_SAVE_STATE (stream, state); + STREAM_SEEK (stream, stream->pos + rec->offset); + + if (bytes == 1) + { + OTF_MALLOC (str, rec->length + 1, (void *) rec->nameID); + READ_BYTES (stream, str, rec->length); + for (i = 0; i < rec->length; i++) + if (str[i] < 0) + str[i] = '?'; + } + else if (bytes == 2) + { + OTF_MALLOC (str, rec->length / 2 + 1, (void *) rec->nameID); + for (i = 0; i < rec->length / 2; i++) + { + READ_USHORT (stream, c); + if (c >= 128) + c = '?'; + str[i] = c; + } + } + else if (bytes == 4) + { + OTF_MALLOC (str, rec->length / 4 + 1, (void *) rec->nameID); + for (i = 0; i < rec->length / 4; i++) + { + READ_ULONG (stream, c); + if (c >= 128) + c = '?'; + str[i] = c; + } + } + str[i] = '\0'; + STREAM_RESTORE_STATE (stream, state); + return str; +} + +static OTF_name * +read_name_table (OTF_Stream *stream) +{ + char *errfmt = "name%s"; + void *errret = NULL; + OTF_name *name; + int i; + + OTF_CALLOC (name, 1, ""); + READ_USHORT (stream, name->format); + READ_USHORT (stream, name->count); + READ_USHORT (stream, name->stringOffset); + OTF_MALLOC (name->nameRecord, name->count, ""); + for (i = 0; i < name->count; i++) + { + OTF_NameRecord *rec = name->nameRecord + i; + + READ_USHORT (stream, rec->platformID); + READ_USHORT (stream, rec->encodingID); + READ_USHORT (stream, rec->languageID); + READ_USHORT (stream, rec->nameID); + READ_USHORT (stream, rec->length); + READ_USHORT (stream, rec->offset); + } + for (i = 0; i < name->count; i++) + { + OTF_NameRecord *rec = name->nameRecord + i; + int nameID = rec->nameID; + + if (nameID <= OTF_max_nameID + && ! name->name[nameID]) + { + if (rec->platformID == 0) + name->name[nameID] = read_name (stream, rec, + rec->encodingID <= 3 ? 2 : 4); + else if (rec->platformID == 1 + && rec->encodingID == 0) + name->name[nameID] = read_name (stream, rec, 1); + else if (rec->platformID == 3 + && (rec->encodingID == 1 || rec->encodingID == 10)) + name->name[nameID] = read_name (stream, + rec, rec->encodingID == 1 ? 2 : 4); + } + } + + return name; +} + + + + +OTF * +otf_open (char *otf_name) +{ + char *errfmt = "OTF%s"; + void *errret = NULL; + OTF_Stream *stream; + OTF *otf; + OTF_Tag head_tag, cmap_tag, name_tag, gdef_tag, gsub_tag, gpos_tag; + int i; + + stream = stream_open (otf_name); + if (! stream) + return NULL; + + head_tag = otf_tag ("head"); + cmap_tag = otf_tag ("cmap"); + name_tag = otf_tag ("name"); + gdef_tag = otf_tag ("GDEF"); + gsub_tag = otf_tag ("GSUB"); + gpos_tag = otf_tag ("GPOS"); + + /* Size of Offset Table in OTF is 12 bytes. */ + if (stream_setup (stream, 0, 12, "Offset Table") < 0) + return NULL; + + OTF_CALLOC_GOTO (otf, 1, " (body)", err); + otf->filename = strdup (otf_name); + if (! otf->filename) + { + otf_error = OTF_ERROR_MEMORY; + goto err; + } + if (read_offset_table (stream, &otf->offset_table) < 0) + goto err; + + /* Size of each Table Directory in OTF is 16 bytes. */ + if (stream_setup (stream, 12, 16 * otf->offset_table.numTables, + "Table Directory") < 0) + goto err; + OTF_CALLOC_GOTO (otf->table_dirs, otf->offset_table.numTables, + " (OffsetTable)", err); + for (i = 0; i < otf->offset_table.numTables; i++) + if (read_table_directory (stream, otf->table_dirs + i) < 0) + goto err; + + for (i = 0; i < otf->offset_table.numTables; i++) + { + if (otf->table_dirs[i].tag == head_tag) + { + stream_setup (stream, otf->table_dirs[i].offset, + otf->table_dirs[i].length, "head"); + otf->head = read_head_table (stream); + } + else if (otf->table_dirs[i].tag == cmap_tag) + { + stream_setup (stream, otf->table_dirs[i].offset, + otf->table_dirs[i].length, "cmap"); + otf->cmap = read_cmap_table (stream); + } + else if (otf->table_dirs[i].tag == name_tag) + { + stream_setup (stream, otf->table_dirs[i].offset, + otf->table_dirs[i].length, "name"); + otf->name = read_name_table (stream); + } + else if (otf->table_dirs[i].tag == gdef_tag) + { + stream_setup (stream, otf->table_dirs[i].offset, + otf->table_dirs[i].length, "GDEF"); + otf->gdef = read_gdef_table (stream); + } + else if (otf->table_dirs[i].tag == gsub_tag) + { + stream_setup (stream, otf->table_dirs[i].offset, + otf->table_dirs[i].length, "GSUB"); + otf->gsub = read_gsub_table (stream); + } + else if (otf->table_dirs[i].tag == gpos_tag) + { + stream_setup (stream, otf->table_dirs[i].offset, + otf->table_dirs[i].length, "GPOS"); + otf->gpos = read_gpos_table (stream); + } + } + + stream_close (stream); + return otf; + + err: + stream_close (stream); + otf_close (otf); + return NULL; +} + +void +otf_close (OTF *otf) +{ + if (otf->filename) + free (otf->filename); + if (otf->table_dirs) + free (otf->table_dirs); +} diff --git a/src/otf-proc.c b/src/otf-proc.c new file mode 100644 index 0000000..c9dee49 --- /dev/null +++ b/src/otf-proc.c @@ -0,0 +1,564 @@ +#include +#include +#include + +#include "otf.h" +#include "otf-util.h" + +#define GSTRING_DELETE(gstring, from, len) \ + do { \ + memmove (gstring->glyphs + from, gstring->glyphs + from + len, \ + sizeof (OTF_Glyph) * (gstring->used - from - len)); \ + gstring->used -= len; \ + } while (0) + + +#define GSTRING_INSERT(gstring, pos, len) \ + do { \ + if (gstring->used + len > gstring->size) \ + { \ + char *errfmt = "GSTRING%s"; \ + \ + gstring->size = gstring->used + len; \ + OTF_REALLOC (gstring->glyphs, gstring->size, NULL); \ + } \ + memmove (gstring->glyphs + pos + len, gstring->glyphs + pos, \ + sizeof (OTF_Glyph) * (gstring->used - pos)); \ + gstring->used += len; \ + } while (0) + + +static int +gstring_subst (OTF_GlyphString *gstring, int from, int to, + OTF_GlyphID *ids, int num) +{ + int errret = -1; + int len = to - from; + int i; + + if (len < num) + GSTRING_INSERT (gstring, from, (num - len)); + else if (len > num) + GSTRING_DELETE (gstring, from, (len - num)); + for (i = 0; i < num; i++) + gstring->glyphs[from + i].glyph_id = ids[i]; + return 0; +} + + +static int +get_coverage_index (OTF_Coverage *coverage, OTF_GlyphID id) +{ + int i; + + if (coverage->CoverageFormat == 1) + { + for (i = 0; i < coverage->Count; i++) + if (coverage->table.GlyphArray[i] == id) + return i; + } + else + { + for (i = 0; i < coverage->Count; i++) + if (coverage->table.RangeRecord[i].Start <= id + && coverage->table.RangeRecord[i].End >= id) + return (coverage->table.RangeRecord[i].StartCoverageIndex + + (id - coverage->table.RangeRecord[i].Start)); + } + return -1; +} + +static OTF_LangSys * +get_langsys (OTF_ScriptList *script_list, + OTF_Tag script_tag, OTF_Tag langsys_tag) +{ + int i, j; + + for (i = 0; i < script_list->ScriptCount; i++) + if (script_list->ScriptRecord[i].ScriptTag == script_tag) + { + OTF_Script *script = script_list->Script + i; + + if (! langsys_tag) + return &script->DefaultLangSys; + for (j = 0; j < script->LangSysCount; j++) + if (script->LangSysRecord[j].LangSysTag == langsys_tag) + return script->LangSys + j; + return &script->DefaultLangSys; + } + + return NULL; +} + +static unsigned +get_class_def (OTF_ClassDef *class_def, OTF_GlyphID glyph_id) +{ + if (class_def->ClassFormat == 1) + { + int idx = (int) glyph_id - (int) class_def->f.f1.StartGlyph; + + if (idx >= 0 && idx < class_def->f.f1.GlyphCount) + return class_def->f.f1.ClassValueArray[idx]; + } + else + { + int i; + + for (i = 0; i < class_def->f.f2.ClassRangeCount; i++) + if (glyph_id >= class_def->f.f2.ClassRangeRecord[i].Start + && glyph_id >= class_def->f.f2.ClassRangeRecord[i].End) + return class_def->f.f2.ClassRangeRecord[i].Class; + } + return 0; +} + + +static int +lookup_gsub (OTF_LookupList *lookup_list, unsigned lookup_list_index, + OTF_GlyphString *gstring, int gidx) +{ + char *errfmt = "GSUB Looking up%s"; + int errret = -1; + OTF_Lookup *lookup = lookup_list->Lookup + lookup_list_index; + unsigned int flag = lookup->LookupFlag; + int orig_gidx = gidx; + OTF_Glyph *g = gstring->glyphs + gidx; + int i; + + if (! g->glyph_id + || (g->GlyphClass + && (flag & (1 << g->GlyphClass)))) + { + // printf ("type %d at %d skiped\n", lookup->LookupType, gidx); + return (gidx + 1); + } + + //printf ("@%d idx:%d type:%d...", + //gidx, lookup_list_index, lookup->LookupType); + + /* Try all subtables until one of them handles the current glyph. */ + for (i = 0; i < lookup->SubTableCount && gidx == orig_gidx; i++) + { + OTF_LookupSubTable *subtable = lookup->SubTable + i; + int coverage_idx; + + // printf ("subtype:%d ", subtable->Format); + if (subtable->Coverage.offset) + { + coverage_idx = get_coverage_index (&subtable->Coverage, + g->glyph_id); + if (coverage_idx < 0) + { + // printf ("not covererd "); + continue; + } + } + + switch (lookup->LookupType) + { + case 1: + if (subtable->Format == 1) + g->glyph_id += subtable->sub.gsub.single1.DeltaGlyphID; + else + g->glyph_id = subtable->sub.gsub.single2.Substitute[coverage_idx]; + gidx++; + break; + + case 2: + { + OTF_GSUB_Multiple1 *multiple1 = &subtable->sub.gsub.multiple1; + OTF_Sequence *seq = multiple1->Sequence + coverage_idx; + + gstring_subst (gstring, gidx, gidx + 1, + seq->Substitute, seq->GlyphCount); + gidx += seq->GlyphCount; + } + break; + + case 3: + OTF_ERROR (OTF_ERROR_GSUB_PROC, " (LookupType not yet supported)"); + + case 4: + if (subtable->Format == 1) + { + OTF_GSUB_Ligature1 *lig1 = &subtable->sub.gsub.ligature1; + OTF_LigatureSet *ligset = lig1->LigatureSet + coverage_idx; + int j; + + for (j = 0; j < ligset->LigatureCount; j++) + { + OTF_Ligature *lig = ligset->Ligature + j; + int k; + + if (gstring->used - gidx < lig->CompCount) + continue; + for (k = 1; k < lig->CompCount; k++) + if (gstring->glyphs[gidx + k].glyph_id + != lig->Component[k - 1]) + break; + if (k < lig->CompCount) + continue; + gstring_subst (gstring, gidx, gidx + lig->CompCount, + &lig->LigGlyph, 1); + gidx++; + break; + } + } + else + OTF_ERROR (OTF_ERROR_GSUB_PROC, " (invalid SubFormat)"); + break; + + case 6: + if (subtable->Format == 1) + OTF_ERROR (OTF_ERROR_GSUB_PROC, " (not yet supported)"); + else if (subtable->Format == 2) + OTF_ERROR (OTF_ERROR_GSUB_PROC, " (not yet supported)"); + else + { + OTF_GSUB_ChainContext3 *context3 + = &subtable->sub.gsub.chain_context3; + int back_gidx = gidx - context3->BacktrackGlyphCount; + int fore_gidx = gidx + context3->InputGlyphCount; + int orig_used; + int j; + + if (back_gidx < 0 + || fore_gidx + context3->LookaheadGlyphCount > gstring->used) + break; + + for (j = 0; j < context3->BacktrackGlyphCount; j++) + if (get_coverage_index (context3->Backtrack + j, + gstring->glyphs[back_gidx + j].glyph_id) + < 0) + break; + /* Start from the secoding coverage_idx because the + first one is the same as subtable->Coverage and thus + already tested */ + for (j = 1; j < context3->InputGlyphCount; j++) + if (get_coverage_index (context3->Input + j - 1, + gstring->glyphs[gidx + j].glyph_id) + < 0) + break; + for (j = 0; j < context3->LookaheadGlyphCount; j++) + if (get_coverage_index (context3->LookAhead + j, + gstring->glyphs[fore_gidx + j].glyph_id) + < 0) + break; + + orig_used = gstring->used; + for (j = 0; j < context3->SubstCount; j++) + lookup_gsub (lookup_list, + context3->SubstLookupRecord[j].LookupListIndex, + gstring, + gidx + context3->SubstLookupRecord[j].SequenceIndex); + gidx += context3->InputGlyphCount + (gstring->used - orig_used); + } + break; + + default: + continue; + } + } + if (gidx == orig_gidx) + { + //printf ("not applied\n"); + gidx++; + } + else + { + // printf ("done\n"); + } + return gidx; +} + +int +otf_gsub (OTF *otf, OTF_Tag script_tag, OTF_Tag langsys_tag, + OTF_GlyphString *gstring) +{ + OTF_GSUB *gsub = otf->gsub; + OTF_LangSys *langsys; + int i, j; + + if (! gsub) + return -1; + langsys = get_langsys (&gsub->script_list, script_tag, langsys_tag); + if (! langsys) + return -1; + + for (i = 0; i < langsys->FeatureCount; i++) + { + OTF_Feature *feature + = gsub->feature_list.Feature + langsys->FeatureIndex[i]; + + for (j = 0; j < feature->LookupCount; j++) + { + int gidx = 0; + + while (gidx < gstring->used) + gidx = lookup_gsub (&gsub->lookup_list, feature->LookupListIndex[j], + gstring, gidx); + } + } + + return 0; +} + + + +/* GPOS */ +unsigned +get_anchor (OTF_Anchor *anchor, OTF_ValueRecord *rec) +{ + unsigned value_format = OTF_XPlacement | OTF_YPlacement; + + rec->XPlacement = anchor->XCoordinate; + rec->YPlacement = anchor->YCoordinate; + if (anchor->AnchorFormat == 1) + /* Nothing to do */ + ; + else if (anchor->AnchorFormat == 2) + /* Not yet implemented */ + ; + else if (anchor->AnchorFormat == 3) + /* Not yet implemented */ + ; + return value_format; +} + + +static int +lookup_gpos (OTF_LookupList *lookup_list, unsigned lookup_list_index, + OTF_GlyphString *gstring, int gidx) +{ + char *errfmt = "GPOS Looking up%s"; + int errret = -1; + OTF_Lookup *lookup = lookup_list->Lookup + lookup_list_index; + unsigned int flag = lookup->LookupFlag; + int orig_gidx = gidx; + OTF_Glyph *g = gstring->glyphs + gidx; + int i; + + if (! g->glyph_id + || (g->GlyphClass + && (flag & (1 << g->GlyphClass)))) + { + // printf ("type %d at %d skiped\n", lookup->LookupType, gidx); + return (gidx + 1); + } + + // printf ("0x%04X@%d idx:%d type:%d...", + // g->glyph_id, gidx, lookup_list_index, lookup->LookupType); + + /* Try all subtables until one of them handles the current glyph. */ + for (i = 0; i < lookup->SubTableCount && gidx == orig_gidx; i++) + { + OTF_LookupSubTable *subtable = lookup->SubTable + i; + int coverage_idx; + + // printf ("subtype:%d ", subtable->Format); + if (subtable->Coverage.offset) + { + coverage_idx = get_coverage_index (&subtable->Coverage, + g->glyph_id); + if (coverage_idx < 0) + { + // printf ("not covererd "); + continue; + } + } + + switch (lookup->LookupType) + { + case 1: + OTF_ERROR (OTF_ERROR_GPOS_PROC, " (not yet supported)"); + + case 2: + if (gidx + 1 >= gstring->used) + continue; + if (subtable->Format == 1) + OTF_ERROR (OTF_ERROR_GPOS_PROC, " (not yet supported)"); + else if (subtable->Format == 2) + { + OTF_GPOS_Pair2 *pair2 = &subtable->sub.gpos.pair2; + unsigned class1, class2; + + printf ("GPOS 2-2: c:0x%x g:0x%x\n", g->c, g->glyph_id); + gidx++; + class1 = get_class_def (&pair2->ClassDef1, g->glyph_id); + class2 = get_class_def (&pair2->ClassDef2, g[1].glyph_id); + g->positioning_type = lookup->LookupType; + g->f.f2.format = pair2->ValueFormat1; + g->f.f2.value + = &pair2->Class1Record[class1].Class2Record[class2].Value1; + if (pair2->ValueFormat2) + { + g++, gidx++; + g->positioning_type = lookup->LookupType; + g->f.f2.format = pair2->ValueFormat2; + g->f.f2.value + = &pair2->Class1Record[class1].Class2Record[class2].Value2; + } + } + break; + + case 3: + OTF_ERROR (OTF_ERROR_GPOS_PROC, " (not yet supported)"); + + case 4: + if (gidx < 1) + continue; + if (subtable->Format == 1) + { + OTF_GPOS_MarkBase1 *mark_base1 = &subtable->sub.gpos.mark_base1; + OTF_MarkRecord *mark_record; + OTF_BaseRecord *base_record; + OTF_Anchor *anchor1, *anchor2; + int coverage_idx_base + = get_coverage_index (&mark_base1->BaseCoverage, + g[-1].glyph_id); + + if (coverage_idx_base < 0) + continue; + printf ("GPOS 4-1: c:0x%x g:0x%x\n", g->c, g->glyph_id); + mark_record = mark_base1->MarkArray.MarkRecord + coverage_idx; + base_record + = mark_base1->BaseArray.BaseRecord + coverage_idx_base; + anchor1 = &mark_record->MarkAnchor; + anchor2 = &base_record->BaseAnchor[mark_record->Class]; + g->positioning_type = lookup->LookupType; + g->f.f4.mark_anchor = anchor1; + g->f.f4.base_anchor = anchor2; + break; + } + else + OTF_ERROR (OTF_ERROR_GPOS_PROC, " (not yet supported)"); + break; + + case 6: + OTF_ERROR (OTF_ERROR_GPOS_PROC, " (not yet supported)"); + break; + + default: + continue; + } + } + if (gidx == orig_gidx) + { + // printf ("not applied\n"); + gidx++; + } + else + { + // printf ("done\n"); + } + return gidx; +} + +int +otf_gpos (OTF *otf, OTF_Tag script_tag, OTF_Tag langsys_tag, + OTF_GlyphString *gstring) +{ + OTF_GPOS *gpos = otf->gpos; + OTF_LangSys *langsys; + int i, j; + + if (! gpos) + return -1; + langsys = get_langsys (&gpos->script_list, script_tag, langsys_tag); + if (! langsys) + return -1; + + for (i = 0; i < langsys->FeatureCount; i++) + { + OTF_Feature *feature + = gpos->feature_list.Feature + langsys->FeatureIndex[i]; + + for (j = 0; j < feature->LookupCount; j++) + { + int gidx = 0; + + while (gidx < gstring->used) + gidx = lookup_gpos (&gpos->lookup_list, feature->LookupListIndex[j], + gstring, gidx); + } + } + + return 0; +} + + + +int +otf_gdef (OTF *otf, OTF_GlyphString *gstring) +{ + int i; + OTF_GDEF *gdef = otf->gdef; + + if (! gdef) + return -1; + + if (gdef->glyph_class_def.offset) + for (i = 0; i < gstring->used; i++) + gstring->glyphs[i].GlyphClass + = get_class_def (&gdef->glyph_class_def, + gstring->glyphs[i].glyph_id); + + if (gdef->mark_attach_class_def.offset) + for (i = 0; i < gstring->used; i++) + gstring->glyphs[i].MarkAttachClass + = get_class_def (&gdef->mark_attach_class_def, + gstring->glyphs[i].glyph_id); + + return 0; +} + +int +otf_lookup_cmap (OTF *otf, int c) +{ + OTF_cmap *cmap = otf->cmap; + int i; + + if (! cmap || ! cmap->Unicode) + return 0; + + switch (cmap->Unicode->subtable.format) + { + case 0: + break; + + case 4: + { + OTF_EncodingSubtable4 *sub4 = cmap->Unicode->subtable.f.f4; + int segCount = sub4->segCountX2 / 2; + + for (i = 0; i < segCount; i++) + if (c <= sub4->segments[i].endCount) + break; + if (i == segCount || c < sub4->segments[i].startCount) + return 0; + if (sub4->segments[i].idRangeOffset == 0xFFFF) + return c + sub4->segments[i].idDelta; + return sub4->glyphIdArray[sub4->segments[i].idRangeOffset + + (c - sub4->segments[i].startCount)]; + } + break; + } + return 0; +} + +int +otf_cmap (OTF *otf, OTF_GlyphString *gstring) +{ + int unknown = 0; + int i; + + for (i = 0; i < gstring->used; i++) + { + int glyph_id = otf_lookup_cmap (otf, gstring->glyphs[i].c); + + if (! glyph_id) + unknown++; + gstring->glyphs[i].glyph_id = glyph_id; + } + return unknown; +} diff --git a/src/otf-util.c b/src/otf-util.c new file mode 100644 index 0000000..8a39323 --- /dev/null +++ b/src/otf-util.c @@ -0,0 +1,50 @@ +#include +#include +#include + +#include "otf.h" + +static char *error_message; +int otf_error; + +static char *error_string[] = + { + "Memory shortage", + "File error", + "Invalid OTF table contents" + }; + +int +otf__error (int err, char *fmt, void *arg) +{ + if (! error_message) + error_message = (char *) malloc (256); + sprintf (error_message, "OTF-Error (%s): ", error_string[-err - 1]); + sprintf (error_message + strlen (error_message), fmt, arg); + otf_error = err; + return 0; +} + +void +otf_perror (char *prefix) +{ + if (otf_error < 0) + { + if (prefix) + fprintf (stderr, "%s: %s", prefix, error_message); + else + fprintf (stderr, "%s", error_message); + } +} + + +OTF_Tag +otf_tag (char *str) +{ + unsigned char *p = (unsigned char *) str; + + if (! str) + return (OTF_Tag) 0; + return (OTF_Tag) ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); +} + diff --git a/src/otf-util.h b/src/otf-util.h new file mode 100644 index 0000000..28af06f --- /dev/null +++ b/src/otf-util.h @@ -0,0 +1,40 @@ +#define OTF_ERROR(err, arg) \ + return (otf__error ((err), errfmt, (arg)), errret) + +/* Memory allocation macros. */ + +#define OTF_MALLOC(p, size, arg) \ + do { \ + ((p) = (void *) malloc (sizeof (*(p)) * (size))); \ + if (! (p)) \ + OTF_ERROR (OTF_ERROR_MEMORY, arg); \ + } while (0) + + +#define OTF_CALLOC(p, size, arg) \ + do { \ + (p) = (void *) calloc (size, sizeof (*(p))); \ + if (! (p)) \ + OTF_ERROR (OTF_ERROR_MEMORY, arg); \ + } while (0) + + +#define OTF_REALLOC(p, size, arg) \ + do { \ + (p) = (void *) realloc ((p), sizeof (*(p)) * (size)); \ + if (! (p)) \ + OTF_ERROR (OTF_ERROR_MEMORY, arg); \ + } while (0) + +#define OTF_CALLOC_GOTO(p, size, arg, label) \ + do { \ + (p) = (void *) calloc (size, sizeof (*(p))); \ + if (! (p)) \ + { \ + otf__error (OTF_ERROR_MEMORY, errfmt, (arg)); \ + goto label; \ + } \ + } while (0) + +extern int otf__error (int err, char *fmt, void *arg); + diff --git a/src/otf.h b/src/otf.h new file mode 100644 index 0000000..4e1957d --- /dev/null +++ b/src/otf.h @@ -0,0 +1,1020 @@ +/* BASIC */ + +#define OTF_ERROR_MEMORY -1 +#define OTF_ERROR_FILE -2 +#define OTF_ERROR_TABLE -3 +#define OTF_ERROR_CMAP_PROC -4 +#define OTF_ERROR_GDEF_PROC -5 +#define OTF_ERROR_GSUB_PROC -6 +#define OTF_ERROR_GPOS_PROC -7 + +extern int otf_error; + +typedef unsigned OTF_Tag; +typedef unsigned OTF_GlyphID; +typedef unsigned OTF_Offset; + +typedef struct +{ + unsigned high; + unsigned low; +} OTF_Fixed; + + +/* COMMON */ + +/* ScriptList + ScriptRecord[] + ScriptTag + Script[] + DefaultLangSys + LangSysRecord[] + LangSysTag + LangSys[] + LookupOrder + ReqFeatureIndex + FeatureIndex[] + + FeatureList + FeatureRecored[] + FeatureTag + Feature[] + FeatureParams + LookupListIndex[] + + LookupList + LookupOffset[] + Lookup[] + LookupType + LookupFlag + SubTableOffset[] + SubTable[] +*/ + + +typedef struct OTF_ScriptRecord OTF_ScriptRecord; +typedef struct OTF_Script OTF_Script; + +typedef struct +{ + unsigned ScriptCount; + OTF_ScriptRecord *ScriptRecord; + OTF_Script *Script; +} OTF_ScriptList; + +struct OTF_ScriptRecord +{ + OTF_Tag ScriptTag; + OTF_Offset Script; +}; + +typedef struct +{ + OTF_Offset LookupOrder; + unsigned ReqFeatureIndex; + unsigned FeatureCount; + unsigned *FeatureIndex; +} OTF_LangSys; + +typedef struct +{ + OTF_Tag LangSysTag; + OTF_Offset LangSys; +} OTF_LangSysRecord; + +struct OTF_Script +{ + OTF_Offset DefaultLangSysOffset; + OTF_LangSys DefaultLangSys; + unsigned LangSysCount; + OTF_LangSysRecord *LangSysRecord; + OTF_LangSys *LangSys; +}; + +typedef struct OTF_FeatureRecord OTF_FeatureRecord; +typedef struct OTF_Feature OTF_Feature; + +typedef struct +{ + unsigned FeatureCount; + OTF_FeatureRecord *FeatureRecord; + OTF_Feature *Feature; +} OTF_FeatureList; + +struct OTF_FeatureRecord +{ + OTF_Tag FeatureTag; + OTF_Offset Feature; +}; + +struct OTF_Feature +{ + OTF_Offset FeatureParams; + unsigned LookupCount; + unsigned *LookupListIndex; +}; + +typedef struct OTF_Lookup OTF_Lookup; + +typedef struct +{ + unsigned LookupCount; + OTF_Offset *LookupOffset; + OTF_Lookup *Lookup; +} OTF_LookupList; + +typedef struct OTF_LookupSubTable OTF_LookupSubTable; + +struct OTF_Lookup +{ + unsigned LookupType; + unsigned LookupFlag; + unsigned SubTableCount; + OTF_Offset *SubTableOffset; + OTF_LookupSubTable *SubTable; +}; + +enum OTF_LookupFlagBit + { + OTF_RightToLeft = 0x0001, + OTF_IgnoreBaseGlyphs = 0x0002, + OTF_IgnoreLigatures = 0x0004, + OTF_IgnoreMarks = 0x8000, + OTF_Reserved = 0x00F0, + OTF_MarkAttachmentType = 0xFF00 + }; + +typedef struct OTF_RangeRecord OTF_RangeRecord; + +typedef struct +{ + OTF_Offset offset; + unsigned CoverageFormat; + unsigned Count; + union { + OTF_GlyphID *GlyphArray; + OTF_RangeRecord *RangeRecord; + } table; +} OTF_Coverage; + +struct OTF_RangeRecord +{ + OTF_GlyphID Start; + OTF_GlyphID End; + unsigned StartCoverageIndex; +}; + +typedef struct OTF_ClassRangeRecord OTF_ClassRangeRecord; + +typedef struct +{ + OTF_Offset offset; + unsigned ClassFormat; + union { + struct { + OTF_GlyphID StartGlyph; + unsigned GlyphCount; + unsigned *ClassValueArray; + } f1; + struct { + unsigned ClassRangeCount; + OTF_ClassRangeRecord *ClassRangeRecord; + } f2; + } f; +} OTF_ClassDef; + +struct OTF_ClassRangeRecord +{ + OTF_GlyphID Start; + OTF_GlyphID End; + unsigned Class; +}; + +typedef struct +{ + OTF_Offset offset; + unsigned StartSize; + unsigned EndSize; + unsigned DeltaFormat; + char *DeltaValue; +} OTF_DeviceTable; + + +/* head */ +typedef struct +{ + OTF_Fixed TableVersionNumber; + OTF_Fixed fontRevision; + unsigned checkSumAdjustment; + unsigned magicNumber; + unsigned flags; + int unitsPerEm; +} OTF_head; + + + +/* GSUB */ + +typedef struct +{ + int DeltaGlyphID; +} OTF_GSUB_Single1; + +typedef struct +{ + unsigned GlyphCount; + OTF_GlyphID *Substitute; +} OTF_GSUB_Single2; + +typedef struct OTF_Sequence OTF_Sequence; + +typedef struct +{ + unsigned SequenceCount; + OTF_Sequence *Sequence; +} OTF_GSUB_Multiple1; + +struct OTF_Sequence +{ + OTF_Offset offset; + unsigned GlyphCount; + OTF_GlyphID *Substitute; +}; + +typedef struct OTF_AlternateSet OTF_AlternateSet; + +typedef struct +{ + unsigned AlternateSetCount; + OTF_AlternateSet *AlternateSet; +} OTF_GSUB_Alternate1; + +struct OTF_AlternateSet +{ + OTF_Offset offset; + unsigned GlyphCount; + OTF_GlyphID *Alternate; +}; + +typedef struct OTF_LigatureSet OTF_LigatureSet; +typedef struct OTF_Ligature OTF_Ligature; + +typedef struct +{ + unsigned LigSetCount; + OTF_LigatureSet *LigatureSet; +} OTF_GSUB_Ligature1; + +struct OTF_LigatureSet +{ + OTF_Offset offset; + unsigned LigatureCount; + OTF_Ligature *Ligature; +}; + +struct OTF_Ligature +{ + OTF_Offset offset; + OTF_GlyphID LigGlyph; + unsigned CompCount; + OTF_GlyphID *Component; +}; + +typedef struct +{ + unsigned SequenceIndex; + unsigned LookupListIndex; +} OTF_SubstLookupRecord; + +typedef struct OTF_SubRuleSet OTF_SubRuleSet; + +typedef struct +{ + unsigned SubRuleSetCount; + OTF_SubRuleSet *SubRuleSet; +} OTF_GSUB_Context1; + +typedef struct OTF_SubRule OTF_SubRule; + +struct OTF_SubRuleSet +{ + OTF_Offset offset; + unsigned SubRuleCount; + OTF_SubRule *SubRule; +}; + +struct OTF_SubRule +{ + OTF_Offset offset; + unsigned GlyphCount; + unsigned SubstCount; + OTF_GlyphID *Input; + OTF_SubstLookupRecord *SubstLookupRecord; +}; + +typedef struct OTF_SubClassSet OTF_SubClassSet; + +typedef struct +{ + OTF_ClassDef ClassDef; + unsigned SubClassSetCount; + OTF_SubClassSet *SubClassSet; +} OTF_GSUB_Context2; + +typedef struct OTF_SubClassRule OTF_SubClassRule; + +struct OTF_SubClassSet +{ + unsigned SubClassRuleCnt; + OTF_SubClassRule *SubClassRule; +}; + +struct OTF_SubClassRule +{ + OTF_Offset offset; + unsigned GlyphCount; + unsigned SubstCount; + unsigned *Class; + OTF_SubstLookupRecord *SubstLookupRecord; +}; + +typedef struct +{ + unsigned GlyphCount; + unsigned SubstCount; + OTF_Coverage *Coverage; + OTF_SubstLookupRecord *SubstLookupRecord; +} OTF_GSUB_Context3; + +typedef struct OTF_ChainSubRuleSet OTF_ChainSubRuleSet; + +typedef struct +{ + unsigned ChainSubRuleSetCount; + OTF_ChainSubRuleSet *ChainSubRuleSet; +} OTF_GSUB_ChainContext1; + +typedef struct OTF_ChainSubRule OTF_ChainSubRule; + +struct OTF_ChainSubRuleSet +{ + OTF_Offset offset; + unsigned ChainSubRuleCount; + OTF_ChainSubRule *ChainSubRule; +}; + +struct OTF_ChainSubRule +{ + OTF_Offset offset; + unsigned BacktrackGlyphCount; + OTF_GlyphID *Backtrack; + unsigned InputGlyphCount; + OTF_GlyphID *Input; + unsigned LookaheadGlyphCount; + OTF_GlyphID *LookAhead; + unsigned SubstCount; + OTF_SubstLookupRecord *SubstLookupRecord; +}; + +typedef struct OTF_ChainSubClassSet OTF_ChainSubClassSet; + +typedef struct +{ + OTF_ClassDef Backtrack; + OTF_ClassDef Input; + OTF_ClassDef LookAhead; + unsigned ChainSubClassSetCnt; + OTF_ChainSubClassSet *ChainSubClassSet; +} OTF_GSUB_ChainContext2; + +typedef struct OTF_ChainSubClassRule OTF_ChainSubClassRule; + +struct OTF_ChainSubClassSet +{ + OTF_Offset offset; + unsigned ChainSubClassRuleCnt; + OTF_ChainSubClassRule *ChainSubClassRule; +}; + +struct OTF_ChainSubClassRule +{ + OTF_Offset offset; + unsigned BacktrackGlyphCount; + unsigned *Backtrack; + unsigned InputGlyphCount; + unsigned *Input; + unsigned LookaheadGlyphCount; + unsigned *LookAhead; + unsigned SubstCount; + OTF_SubstLookupRecord *SubstLookupRecord; +}; + + +typedef struct +{ + unsigned BacktrackGlyphCount; + OTF_Coverage *Backtrack; + unsigned InputGlyphCount; + OTF_Coverage *Input; + unsigned LookaheadGlyphCount; + OTF_Coverage *LookAhead; + unsigned SubstCount; + OTF_SubstLookupRecord *SubstLookupRecord; +} OTF_GSUB_ChainContext3; + +typedef struct +{ + unsigned ExtensionLookupType; + unsigned ExtentionOffset; +} OTF_GSUB_Extension1; + +typedef struct +{ + unsigned BacktrackGlyphCount; + OTF_Coverage *Backtrack; + unsigned LookaheadGlyphCount; + OTF_Coverage *LookAhead; + unsigned GlyphCount; + OTF_GlyphID *Substitute; +} OTF_GSUB_ReverseChainSingle1; + + +/* GPOS */ +enum OTF_ValueFormat + { + OTF_XPlacement = 0x0001, + OTF_YPlacement = 0x0002, + OTF_XAdvance = 0x0004, + OTF_YAdvance = 0x0008, + OTF_XPlaDevice = 0x0010, + OTF_YPlaDevice = 0x0020, + OTF_XAdvDevice = 0x0040, + OTF_YAdvDevice = 0x0080 + }; + +typedef struct +{ + int XPlacement; + int YPlacement; + int XAdvance; + int YAdvance; + OTF_DeviceTable XPlaDevice; + OTF_DeviceTable YPlaDevice; + OTF_DeviceTable XAdvDevice; + OTF_DeviceTable YAdvDevice; +} OTF_ValueRecord; + +typedef struct +{ + OTF_Offset offset; + unsigned AnchorFormat; + int XCoordinate; + int YCoordinate; + union { + union { + unsigned AnchorPoint; + } f1; + union { + OTF_DeviceTable XDeviceTable; + OTF_DeviceTable YDeviceTable; + } f2; + } f; +} OTF_Anchor; + +typedef struct +{ + unsigned Class; + OTF_Anchor MarkAnchor; +} OTF_MarkRecord; + +typedef struct +{ + OTF_Offset offset; + unsigned MarkCount; + OTF_MarkRecord *MarkRecord; +} OTF_MarkArray; + +typedef struct +{ + int dummy; +} OTF_GPOS_Single1; + +typedef struct +{ + int dummy; +} OTF_GPOS_Single2; + +typedef struct +{ + int dummy; +} OTF_GPOS_Pair1; + +typedef struct +{ + OTF_ValueRecord Value1; + OTF_ValueRecord Value2; +} OTF_Class2Record; + +typedef struct +{ + OTF_Class2Record *Class2Record; +} OTF_Class1Record; + +typedef struct +{ + unsigned ValueFormat1; + unsigned ValueFormat2; + OTF_ClassDef ClassDef1; + OTF_ClassDef ClassDef2; + unsigned Class1Count; + unsigned Class2Count; + OTF_Class1Record *Class1Record; /* size: */ +} OTF_GPOS_Pair2; + +typedef struct +{ + int dummy; +} OTF_GPOS_Cursive1; + +typedef struct +{ + OTF_Anchor *BaseAnchor; +} OTF_BaseRecord; + +typedef struct +{ + OTF_Offset offset; + unsigned BaseCount; + OTF_BaseRecord *BaseRecord; +} OTF_BaseArray; + +typedef struct +{ + OTF_Coverage BaseCoverage; + unsigned ClassCount; + OTF_MarkArray MarkArray; + OTF_BaseArray BaseArray; +} OTF_GPOS_MarkBase1; + +typedef struct +{ + int dummy; +} OTF_GPOS_MarkLig1; + +typedef struct +{ + int dummy; +} OTF_GPOS_MarkMark1; + +typedef struct +{ + int dummy; +} OTF_GPOS_Context1; + +typedef struct +{ + int dummy; +} OTF_GPOS_Context2; + +typedef struct +{ + int dummy; +} OTF_GPOS_Context3; + +typedef struct +{ + int dummy; +} OTF_GPOS_ChainContext1; + +typedef struct +{ + int dummy; +} OTF_GPOS_ChainContext2; + +typedef struct +{ + int dummy; +} OTF_GPOS_ChainContext3; + +typedef struct +{ + int dummy; +} OTF_GPOS_Extension1; + + +struct OTF_LookupSubTable +{ + unsigned Format; + OTF_Coverage Coverage; + union { + union { /* GSUB */ + /* LookupType 1 */ + OTF_GSUB_Single1 single1; + OTF_GSUB_Single2 single2; + /* LookupType 2 */ + OTF_GSUB_Multiple1 multiple1; + /* LookupType 3 */ + OTF_GSUB_Alternate1 alternate1; + /* LookupType 4 */ + OTF_GSUB_Ligature1 ligature1; + /* LookupType 5 */ + OTF_GSUB_Context1 context1; + OTF_GSUB_Context2 context2; + OTF_GSUB_Context3 context3; + /* LookupType 6 */ + OTF_GSUB_ChainContext1 chain_context1; + OTF_GSUB_ChainContext2 chain_context2; + OTF_GSUB_ChainContext3 chain_context3; + /* LookupType 7 */ + OTF_GSUB_Extension1 extension1; + /* LookupType 8 */ + OTF_GSUB_ReverseChainSingle1 reverse_chain_single1; + } gsub; + + union { /* GPOS */ + /* LookupType 1 */ + OTF_GPOS_Single1 single1; + OTF_GPOS_Single2 single2; + /* LookupType 2 */ + OTF_GPOS_Pair1 pair1; + OTF_GPOS_Pair2 pair2; + /* LookupType 3 */ + OTF_GPOS_Cursive1 cursive1; + /* LookupType 4 */ + OTF_GPOS_MarkBase1 mark_base1; + /* LookupType 5 */ + OTF_GPOS_MarkLig1 mark_lig1; + /* LookupType 6 */ + OTF_GPOS_MarkMark1 mark_mark1; + /* LookupType 7 */ + OTF_GPOS_Context1 context1; + OTF_GPOS_Context2 context2; + OTF_GPOS_Context3 context3; + /* LookupType 8 */ + OTF_GPOS_ChainContext1 chain_context1; + OTF_GPOS_ChainContext2 chain_context2; + OTF_GPOS_ChainContext3 chain_context3; + /* LookupType 9 */ + OTF_GPOS_Extension1 extension1; + } gpos; + } sub; +}; + + +/* GSUB */ + +typedef struct +{ + OTF_Fixed Version; + OTF_Offset ScriptList; + OTF_Offset FeatureList; + OTF_Offset LookupList; +} OTF_GSUBHeader; + +typedef struct +{ + OTF_GSUBHeader header; + OTF_ScriptList script_list; + OTF_FeatureList feature_list; + OTF_LookupList lookup_list; +} OTF_GSUB; + + +typedef OTF_GSUBHeader OTF_GPOSHeader; + +/* GPOS */ +typedef struct +{ + OTF_GPOSHeader header; + OTF_ScriptList script_list; + OTF_FeatureList feature_list; + OTF_LookupList lookup_list; +} OTF_GPOS; + + +/* BASE */ +typedef struct +{ + int dummy; +} OTF_BASE; + + +/* JSTF */ +typedef struct +{ + int dummy; +} OTF_JSTF; + + +/* GDEF */ +typedef struct +{ + OTF_Fixed Version; + OTF_Offset GlyphClassDef; + OTF_Offset AttachList; + OTF_Offset LigCaretList; + OTF_Offset MarkAttachClassDef; +} OTF_GDEFHeader; + +enum OTF_GlyphClassDef + { + OTF_GlyphClass0 = 0, + OTF_GlyphClassBase = 1, + OTF_GlyphClassLigature = 2, + OTF_GlyphClassMark = 3, + OTF_GlyphClassComponent = 4 + }; + +typedef struct +{ + OTF_Offset offset; + unsigned PointCount; + unsigned *PointIndex; +} OTF_AttachPoint; + +typedef struct +{ + OTF_Coverage Coverage; + unsigned GlyphCount; + OTF_AttachPoint *AttachPoint; +} OTF_AttachList; + +typedef struct +{ + OTF_Offset offset; + unsigned CaretValueFormat; /* 1, 2, 3 */ + union { + union { + int Coordinate; + } f1; + union { + unsigned CaretValuePoint; + } f2; + union { + int Coordinate; + OTF_DeviceTable DeviceTable; + } f3; + } f; +} OTF_CaretValue; + +typedef struct +{ + OTF_Offset offset; + unsigned CaretCount; + OTF_CaretValue *CaretValue; +} OTF_LigGlyph; + +typedef struct +{ + OTF_Coverage Coverage; + unsigned LigGlyphCount; + OTF_LigGlyph *LigGlyph; +} OTF_LigCaretList; + +typedef struct +{ + OTF_GDEFHeader header; + OTF_ClassDef glyph_class_def; + OTF_AttachList attach_list; + OTF_LigCaretList lig_caret_list; + OTF_ClassDef mark_attach_class_def; +} OTF_GDEF; + + + +/* cmap */ + +typedef struct +{ + unsigned char glyphIdArray[256]; +} OTF_EncodingSubtable0; + +typedef struct +{ + unsigned firstCode; + unsigned entryCount; + int idDelta; + unsigned idRangeOffset; +} OTF_cmapSubHeader; + +typedef struct +{ + unsigned subHeaderKeys[256]; + OTF_cmapSubHeader *subHeaders; + unsigned *glyphIndexArray; +} OTF_EncodingSubtable2; + +typedef struct +{ + unsigned startCount; + unsigned endCount; + int idDelta; + unsigned idRangeOffset; +} OTF_cmapSegument; + +typedef struct +{ + unsigned segCountX2; + unsigned searchRange; + unsigned entrySelector; + unsigned rangeShift; + OTF_cmapSegument *segments; + int GlyphCount; + unsigned *glyphIdArray; +} OTF_EncodingSubtable4; + +typedef struct +{ + unsigned firstCode; + unsigned entryCount; + unsigned *glyphIdArray; +} OTF_EncodingSubtable6; + +typedef struct +{ + unsigned startCharCode; + unsigned endCharCode; + unsigned startGlyphID; +} OTF_cmapGroup; + +typedef struct +{ + unsigned char is32[8192]; + unsigned nGroups; + OTF_cmapGroup *Groups; +} OTF_EncodingSubtable8; + +typedef struct +{ + unsigned startCharCode; + unsigned numChars; + unsigned *glyphs; +} OTF_EncodingSubtable10; + +typedef struct +{ + unsigned nGroups; + OTF_cmapGroup *Groups; +} OTF_EncodingSubtable12; + +typedef struct +{ + unsigned format; + unsigned length; + unsigned language; + union { + OTF_EncodingSubtable0 *f0; + OTF_EncodingSubtable2 *f2; + OTF_EncodingSubtable4 *f4; + OTF_EncodingSubtable6 *f6; + OTF_EncodingSubtable8 *f8; + OTF_EncodingSubtable10 *f10; + OTF_EncodingSubtable12 *f12; + }f; +} OTF_EncodingSubtable; + +typedef struct +{ + unsigned platformID; + unsigned encodingID; + unsigned offset; + OTF_EncodingSubtable subtable; +} OTF_EncodingRecord; + +typedef struct +{ + unsigned version; + unsigned numTables; + OTF_EncodingRecord *EncodingRecord; + OTF_EncodingRecord *Unicode; +} OTF_cmap; + + +/* name */ +typedef struct +{ + int platformID; + int encodingID; + int languageID; + int nameID; + int length; + int offset; +} OTF_NameRecord; + +#define OTF_max_nameID 20 + +typedef struct +{ + int format; + int count; + int stringOffset; + OTF_NameRecord *nameRecord; + char *name[OTF_max_nameID + 1]; +} OTF_name; + + +/* OTF */ +typedef struct +{ + OTF_Fixed sfnt_version; + unsigned numTables; + unsigned searchRange; + unsigned enterSelector; + unsigned rangeShift; +} OTF_OffsetTable; + +typedef struct +{ + OTF_Tag tag; + unsigned checkSum; + unsigned offset; + unsigned length; +} OTF_TableDirectory; + +typedef struct +{ + char *filename; + OTF_OffsetTable offset_table; + OTF_TableDirectory *table_dirs; + OTF_head *head; + OTF_name *name; + OTF_cmap *cmap; + OTF_GDEF *gdef; + OTF_GSUB *gsub; + OTF_GPOS *gpos; + /* The following tables are not yet supported. */ + // OTF_BASE *base; + // OTF_JSTF *jstf; +} OTF; + +typedef struct +{ + /* Character code of the glyph. This is the only member that a + client has to set before calling the OTF library function + otf_proc. */ + int c; + + /* Glyph ID of the glyph. */ + OTF_GlyphID glyph_id; + + /* GlyphClass of the glyph. The value is extracted from the GDEF + table of OTF. */ + enum OTF_GlyphClassDef GlyphClass; + + /* MarkAttachClassDef of the glyph. The value is extracted from the + GDEF table. */ + unsigned MarkAttachClass; + + /* Positioning format type of the glyph. The value is the same as + the LookupType of the GPOS's Lookup table that is used to decide + the positioning of the glyph. */ + int positioning_type; + union { + struct { + enum OTF_ValueFormat format; + OTF_ValueRecord *value; + } f1; + struct { + enum OTF_ValueFormat format; + OTF_ValueRecord *value; + } f2; + struct { + OTF_Anchor *entry_anchor; + OTF_Anchor *exit_anchor; + } f3; + struct { + OTF_Anchor *mark_anchor; + OTF_Anchor *base_anchor; + } f4; + struct { + OTF_Anchor *mark_anchor; + OTF_Anchor *ligature_anchor; + } f5; + struct { + OTF_Anchor *mark1_anchor; + OTF_Anchor *mark2_anchor; + } f6; + } f; +} OTF_Glyph; + +typedef struct +{ + int size; + int used; + OTF_Glyph *glyphs; +} OTF_GlyphString; + + +extern OTF_Tag otf_tag (char *str); + +extern OTF *otf_open (char *name); +extern void otf_close (OTF *otf); + +extern int otf_cmap (OTF *otf, OTF_GlyphString *gstring); +extern int otf_gdef (OTF *otf, OTF_GlyphString *gstring); +extern int otf_gsub (OTF *otf, OTF_Tag script_tag, OTF_Tag langsys_tag, + OTF_GlyphString *gstring); +extern int otf_gpos (OTF *otf, OTF_Tag script_tag, OTF_Tag langsys_tag, + OTF_GlyphString *gstring); + +extern int otf_lookup_cmap (OTF *otf, int c); -- 1.7.10.4