From 91b7bf1df3ecb9e786e1f243e2dd9f70a8d43bd4 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 21 Oct 1999 18:02:08 +0000 Subject: [PATCH] Initial revision --- CHANGES | 9 + COPYING | 437 ++++ Makefile.am | 30 + Makefile.in | 559 +++++ README | 27 + acinclude.m4 | 165 ++ aclocal.m4 | 713 +++++++ config.guess | 951 +++++++++ config.sub | 955 +++++++++ configure | 2295 ++++++++++++++++++++ configure.in | 105 + install-sh | 251 +++ ltconfig | 3461 ++++++++++++++++++++++++++++++ ltmain.sh | 4812 ++++++++++++++++++++++++++++++++++++++++++ mikmod/Makefile.am | 29 + mikmod/Makefile.in | 344 +++ mikmod/README | 14 + mikmod/drv_nos.c | 161 ++ mikmod/drv_sdl.c | 72 + mikmod/license.txt | 19 + mikmod/load_it.c | 857 ++++++++ mikmod/load_mod.c | 341 +++ mikmod/load_s3m.c | 466 ++++ mikmod/load_xm.c | 679 ++++++ mikmod/mdreg.c | 31 + mikmod/mdriver.c | 557 +++++ mikmod/mikmod.h | 394 ++++ mikmod/mloader.c | 399 ++++ mikmod/mlreg.c | 22 + mikmod/mmalloc.c | 63 + mikmod/mmerror.c | 103 + mikmod/mmio.c | 457 ++++ mikmod/mmio.h | 272 +++ mikmod/mplayer.c | 2762 ++++++++++++++++++++++++ mikmod/munitrk.c | 307 +++ mikmod/npertab.c | 14 + mikmod/ptform.h | 591 ++++++ mikmod/s3m_it.c | 187 ++ mikmod/sloader.c | 407 ++++ mikmod/tdefs.h | 105 + mikmod/virtch.c | 1362 ++++++++++++ missing | 190 ++ mixer.c | 468 ++++ mixer.h | 137 ++ mkinstalldirs | 40 + music.c | 639 ++++++ music_cmd.c | 231 ++ music_cmd.h | 63 + playmus.c | 129 ++ playwave.c | 126 ++ timidity/FAQ | 112 + timidity/Makefile.am | 31 + timidity/Makefile.in | 342 +++ timidity/README | 70 + timidity/common.c | 221 ++ timidity/common.h | 42 + timidity/config.h | 257 +++ timidity/controls.c | 41 + timidity/controls.h | 88 + timidity/filter.c | 203 ++ timidity/filter.h | 35 + timidity/instrum.c | 662 ++++++ timidity/instrum.h | 84 + timidity/mix.c | 566 +++++ timidity/mix.h | 27 + timidity/output.c | 138 ++ timidity/output.h | 75 + timidity/playmidi.c | 967 +++++++++ timidity/playmidi.h | 116 + timidity/readmidi.c | 628 ++++++ timidity/readmidi.h | 31 + timidity/resample.c | 736 +++++++ timidity/resample.h | 24 + timidity/sdl_a.c | 36 + timidity/sdl_c.c | 121 ++ timidity/tables.c | 901 ++++++++ timidity/tables.h | 45 + timidity/timidity.c | 360 ++++ timidity/timidity.h | 33 + wave.h | 51 + wavestream.c | 471 +++++ wavestream.h | 60 + 82 files changed, 35382 insertions(+) create mode 100644 CHANGES create mode 100644 COPYING create mode 100644 Makefile.am create mode 100644 Makefile.in create mode 100644 README create mode 100644 acinclude.m4 create mode 100644 aclocal.m4 create mode 100644 config.guess create mode 100644 config.sub create mode 100755 configure create mode 100644 configure.in create mode 100644 install-sh create mode 100644 ltconfig create mode 100644 ltmain.sh create mode 100644 mikmod/Makefile.am create mode 100644 mikmod/Makefile.in create mode 100644 mikmod/README create mode 100644 mikmod/drv_nos.c create mode 100644 mikmod/drv_sdl.c create mode 100644 mikmod/license.txt create mode 100644 mikmod/load_it.c create mode 100644 mikmod/load_mod.c create mode 100644 mikmod/load_s3m.c create mode 100644 mikmod/load_xm.c create mode 100644 mikmod/mdreg.c create mode 100644 mikmod/mdriver.c create mode 100644 mikmod/mikmod.h create mode 100644 mikmod/mloader.c create mode 100644 mikmod/mlreg.c create mode 100644 mikmod/mmalloc.c create mode 100644 mikmod/mmerror.c create mode 100644 mikmod/mmio.c create mode 100644 mikmod/mmio.h create mode 100644 mikmod/mplayer.c create mode 100644 mikmod/munitrk.c create mode 100644 mikmod/npertab.c create mode 100644 mikmod/ptform.h create mode 100644 mikmod/s3m_it.c create mode 100644 mikmod/sloader.c create mode 100644 mikmod/tdefs.h create mode 100644 mikmod/virtch.c create mode 100644 missing create mode 100644 mixer.c create mode 100644 mixer.h create mode 100644 mkinstalldirs create mode 100644 music.c create mode 100644 music_cmd.c create mode 100644 music_cmd.h create mode 100644 playmus.c create mode 100644 playwave.c create mode 100644 timidity/FAQ create mode 100644 timidity/Makefile.am create mode 100644 timidity/Makefile.in create mode 100644 timidity/README create mode 100644 timidity/common.c create mode 100644 timidity/common.h create mode 100644 timidity/config.h create mode 100644 timidity/controls.c create mode 100644 timidity/controls.h create mode 100644 timidity/filter.c create mode 100644 timidity/filter.h create mode 100644 timidity/instrum.c create mode 100644 timidity/instrum.h create mode 100644 timidity/mix.c create mode 100644 timidity/mix.h create mode 100644 timidity/output.c create mode 100644 timidity/output.h create mode 100644 timidity/playmidi.c create mode 100644 timidity/playmidi.h create mode 100644 timidity/readmidi.c create mode 100644 timidity/readmidi.h create mode 100644 timidity/resample.c create mode 100644 timidity/resample.h create mode 100644 timidity/sdl_a.c create mode 100644 timidity/sdl_c.c create mode 100644 timidity/tables.c create mode 100644 timidity/tables.h create mode 100644 timidity/timidity.c create mode 100644 timidity/timidity.h create mode 100644 wave.h create mode 100644 wavestream.c create mode 100644 wavestream.h diff --git a/CHANGES b/CHANGES new file mode 100644 index 00000000..06a88426 --- /dev/null +++ b/CHANGES @@ -0,0 +1,9 @@ + +1.0.0: +SOL - Added autoconf support +SP - Added MP3 support using SMPEG + +Initial Key: +SOL - Sam Lantinga (hercules@lokigames.com) +SP - Stephane Peter (megastep@lokigames.com) + diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..191a97fe --- /dev/null +++ b/COPYING @@ -0,0 +1,437 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 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. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, 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 library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, 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 companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the 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. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..34f70efb --- /dev/null +++ b/Makefile.am @@ -0,0 +1,30 @@ +# Makefile.am for the SDL sample mixer library and players + +lib_LTLIBRARIES = libmixer.la + +SUBDIRS = mikmod timidity + +libmixerincludedir = $(includedir) +libmixerinclude_HEADERS = \ + mixer.h + +libmixer_la_SOURCES = \ + mixer.c \ + music.c \ + music_cmd.c \ + music_cmd.h \ + wave.h \ + wavestream.c \ + wavestream.h + +libmixer_la_LDFLAGS = \ + -release $(LT_RELEASE) \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) +libmixer_la_LIBADD = \ + mikmod/libmikmod.la \ + timidity/libtimidity.la + +bin_PROGRAMS = playwave playmus + +playwave_LDADD = libmixer.la +playmus_LDADD = libmixer.la diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..955e6e08 --- /dev/null +++ b/Makefile.in @@ -0,0 +1,559 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Makefile.am for the SDL sample mixer library and players + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +BINARY_AGE = @BINARY_AGE@ +CC = @CC@ +DLLTOOL = @DLLTOOL@ +INTERFACE_AGE = @INTERFACE_AGE@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +MAJOR_VERSION = @MAJOR_VERSION@ +MAKEINFO = @MAKEINFO@ +MICRO_VERSION = @MICRO_VERSION@ +MINOR_VERSION = @MINOR_VERSION@ +NM = @NM@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +VERSION = @VERSION@ + +lib_LTLIBRARIES = libmixer.la + +SUBDIRS = mikmod timidity + +libmixerincludedir = $(includedir) +libmixerinclude_HEADERS = mixer.h + + +libmixer_la_SOURCES = mixer.c music.c music_cmd.c music_cmd.h wave.h wavestream.c wavestream.h + + +libmixer_la_LDFLAGS = -release $(LT_RELEASE) -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) + +libmixer_la_LIBADD = mikmod/libmikmod.la timidity/libtimidity.la + + +bin_PROGRAMS = playwave playmus + +playwave_LDADD = libmixer.la +playmus_LDADD = libmixer.la +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(lib_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +libmixer_la_DEPENDENCIES = mikmod/libmikmod.la timidity/libtimidity.la +libmixer_la_OBJECTS = mixer.lo music.lo music_cmd.lo wavestream.lo +PROGRAMS = $(bin_PROGRAMS) + +playwave_SOURCES = playwave.c +playwave_OBJECTS = playwave.o +playwave_DEPENDENCIES = libmixer.la +playwave_LDFLAGS = +playmus_SOURCES = playmus.c +playmus_OBJECTS = playmus.o +playmus_DEPENDENCIES = libmixer.la +playmus_LDFLAGS = +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +HEADERS = $(libmixerinclude_HEADERS) + +DIST_COMMON = README COPYING Makefile.am Makefile.in acinclude.m4 \ +aclocal.m4 config.guess config.sub configure configure.in install-sh \ +ltconfig ltmain.sh missing mkinstalldirs + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DEP_FILES = .deps/mixer.P .deps/music.P .deps/music_cmd.P \ +.deps/playmus.P .deps/playwave.P .deps/wavestream.P +SOURCES = $(libmixer_la_SOURCES) playwave.c playmus.c +OBJECTS = $(libmixer_la_OBJECTS) playwave.o playmus.o + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status + +$(ACLOCAL_M4): configure.in acinclude.m4 + cd $(srcdir) && $(ACLOCAL) + +config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +mostlyclean-libLTLIBRARIES: + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + +distclean-libLTLIBRARIES: + +maintainer-clean-libLTLIBRARIES: + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libdir) + @list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + if test -f $$p; then \ + echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \ + $(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \ + else :; fi; \ + done + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + list='$(lib_LTLIBRARIES)'; for p in $$list; do \ + $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \ + done + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libmixer.la: $(libmixer_la_OBJECTS) $(libmixer_la_DEPENDENCIES) + $(LINK) -rpath $(libdir) $(libmixer_la_LDFLAGS) $(libmixer_la_OBJECTS) $(libmixer_la_LIBADD) $(LIBS) + +mostlyclean-binPROGRAMS: + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) + +distclean-binPROGRAMS: + +maintainer-clean-binPROGRAMS: + +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + if test -f $$p; then \ + echo " $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`"; \ + $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + list='$(bin_PROGRAMS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(bindir)/`echo $$p|sed 's/$(EXEEXT)$$//'|sed '$(transform)'|sed 's/$$/$(EXEEXT)/'`; \ + done + +playwave: $(playwave_OBJECTS) $(playwave_DEPENDENCIES) + @rm -f playwave + $(LINK) $(playwave_LDFLAGS) $(playwave_OBJECTS) $(playwave_LDADD) $(LIBS) + +playmus: $(playmus_OBJECTS) $(playmus_DEPENDENCIES) + @rm -f playmus + $(LINK) $(playmus_LDFLAGS) $(playmus_OBJECTS) $(playmus_LDADD) $(LIBS) + +install-libmixerincludeHEADERS: $(libmixerinclude_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(libmixerincludedir) + @list='$(libmixerinclude_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libmixerincludedir)/$$p"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(libmixerincludedir)/$$p; \ + done + +uninstall-libmixerincludeHEADERS: + @$(NORMAL_UNINSTALL) + list='$(libmixerinclude_HEADERS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(libmixerincludedir)/$$p; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. + +@SET_MAKE@ + +all-recursive install-data-recursive install-exec-recursive \ +installdirs-recursive install-recursive uninstall-recursive \ +check-recursive installcheck-recursive info-recursive dvi-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + rev=''; list='$(SUBDIRS)'; for subdir in $$list; do \ + rev="$$subdir $$rev"; \ + test "$$subdir" = "." && dot_seen=yes; \ + done; \ + test "$$dot_seen" = "no" && rev=". $$rev"; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(PACKAGE)-$(VERSION) +top_distdir = $(distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + -rm -rf $(distdir) + GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + dc_install_base=`cd $(distdir)/=inst && pwd`; \ + cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) dist + -rm -rf $(distdir) + @banner="$(distdir).tar.gz is ready for distribution"; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes" +dist: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +dist-all: distdir + -chmod -R a+r $(distdir) + GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir) + -rm -rf $(distdir) +distdir: $(DISTFILES) + -rm -rf $(distdir) + mkdir $(distdir) + -chmod 777 $(distdir) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + chmod 777 $(distdir)/$$subdir; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir=../$(distdir) distdir=../$(distdir)/$$subdir distdir) \ + || exit 1; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-recursive +dvi-am: +dvi: dvi-recursive +check-am: all-am +check: check-recursive +installcheck-am: +installcheck: installcheck-recursive +install-exec-am: install-libLTLIBRARIES install-binPROGRAMS +install-exec: install-exec-recursive + +install-data-am: install-libmixerincludeHEADERS +install-data: install-data-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-recursive +uninstall-am: uninstall-libLTLIBRARIES uninstall-binPROGRAMS \ + uninstall-libmixerincludeHEADERS +uninstall: uninstall-recursive +all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS) +all-redirect: all-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(libdir) $(DESTDIR)$(bindir) \ + $(DESTDIR)$(libmixerincludedir) + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-libLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-binPROGRAMS \ + mostlyclean-tags mostlyclean-depend mostlyclean-generic + +mostlyclean: mostlyclean-recursive + +clean-am: clean-libLTLIBRARIES clean-compile clean-libtool \ + clean-binPROGRAMS clean-tags clean-depend clean-generic \ + mostlyclean-am + +clean: clean-recursive + +distclean-am: distclean-libLTLIBRARIES distclean-compile \ + distclean-libtool distclean-binPROGRAMS distclean-tags \ + distclean-depend distclean-generic clean-am + -rm -f libtool + +distclean: distclean-recursive + -rm -f config.status + +maintainer-clean-am: maintainer-clean-libLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-binPROGRAMS maintainer-clean-tags \ + maintainer-clean-depend maintainer-clean-generic \ + distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-recursive + -rm -f config.status + +.PHONY: mostlyclean-libLTLIBRARIES distclean-libLTLIBRARIES \ +clean-libLTLIBRARIES maintainer-clean-libLTLIBRARIES \ +uninstall-libLTLIBRARIES install-libLTLIBRARIES mostlyclean-compile \ +distclean-compile clean-compile maintainer-clean-compile \ +mostlyclean-libtool distclean-libtool clean-libtool \ +maintainer-clean-libtool mostlyclean-binPROGRAMS distclean-binPROGRAMS \ +clean-binPROGRAMS maintainer-clean-binPROGRAMS uninstall-binPROGRAMS \ +install-binPROGRAMS uninstall-libmixerincludeHEADERS \ +install-libmixerincludeHEADERS install-data-recursive \ +uninstall-data-recursive install-exec-recursive \ +uninstall-exec-recursive installdirs-recursive uninstalldirs-recursive \ +all-recursive check-recursive installcheck-recursive info-recursive \ +dvi-recursive mostlyclean-recursive distclean-recursive clean-recursive \ +maintainer-clean-recursive tags tags-recursive mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs-am installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/README b/README new file mode 100644 index 00000000..6f2b3338 --- /dev/null +++ b/README @@ -0,0 +1,27 @@ + +Due to popular demand, here is a simple multi-channel audio mixer. +It supports 4 channels of 16 bit stereo audio, plus a single channel +of music, mixed by the popular MikMod MOD, Timidity MIDI and SMPEG MP3 +libraries. + +See the header file mixer.h and the examples playwave.c and playmus.c +for documentation on this mixer library. + +The mixer can currently load Microsoft WAVE files as audio samples +and can load MIDI files via Timidity and the following music formats +via MikMod: .MOD .S3M .IT .XM. It can also load MP3 music using the +SMPEG library. + +The process of mixing MIDI files to wave output is very CPU intensive, +so if playing regular WAVE files sound great, but playing MIDI files +sound choppy, try using 8-bit audio, mono audio, or lower frequencies. + +To play MIDI files, you'll need to get a complete set of GUS patches +from: http://www.devolution.com/~slouken/SDL/timidity/timidity.tar.gz +and unpack them in /usr/local/lib under UNIX, and C:\ under Win32. + +You may add panning, reverb, echo, whatever, but if you do, please +mail changes back to me, Sam Lantinga at slouken@devolution.com + +This library is available under the GNU Library General Public License. + diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 00000000..332a72e1 --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,165 @@ +# Configure paths for SDL +# Sam Lantinga 9/21/99 +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS +dnl +AC_DEFUN(AM_PATH_SDL, +[dnl +dnl Get the cflags and libraries from the sdl-config script +dnl +AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], + sdl_prefix="$withval", sdl_prefix="") +AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], + sdl_exec_prefix="$withval", sdl_exec_prefix="") +AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], + , enable_sdltest=yes) + + if test x$sdl_exec_prefix != x ; then + sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_args="$sdl_args --prefix=$sdl_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_prefix/bin/sdl-config + fi + fi + + AC_PATH_PROG(SDL_CONFIG, sdl-config, no) + min_sdl_version=ifelse([$1], ,0.11.0,$1) + AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) + no_sdl="" + if test "$SDL_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` + SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + + sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SDL is sufficiently new. (Also sanity +dnl checks the results of sdl-config to some extent +dnl + rm -f conf.sdltest + AC_TRY_RUN([ +#include +#include +#include +#include + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.sdltest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); + printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$SDL_CONFIG" = "no" ; then + echo "*** The sdl-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL_CONFIG environment variable to the" + echo "*** full path to sdl-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + AC_TRY_LINK([ +#include +#include +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(SDL_CFLAGS) + AC_SUBST(SDL_LIBS) + rm -f conf.sdltest +]) diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 00000000..e3e69a5c --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,713 @@ +dnl aclocal.m4 generated automatically by aclocal 1.4a + +dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without +dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A +dnl PARTICULAR PURPOSE. + +# Configure paths for SDL +# Sam Lantinga 9/21/99 +# stolen from Manish Singh +# stolen back from Frank Belew +# stolen from Manish Singh +# Shamelessly stolen from Owen Taylor + +dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) +dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS +dnl +AC_DEFUN(AM_PATH_SDL, +[dnl +dnl Get the cflags and libraries from the sdl-config script +dnl +AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], + sdl_prefix="$withval", sdl_prefix="") +AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], + sdl_exec_prefix="$withval", sdl_exec_prefix="") +AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], + , enable_sdltest=yes) + + if test x$sdl_exec_prefix != x ; then + sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_args="$sdl_args --prefix=$sdl_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_prefix/bin/sdl-config + fi + fi + + AC_PATH_PROG(SDL_CONFIG, sdl-config, no) + min_sdl_version=ifelse([$1], ,0.11.0,$1) + AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) + no_sdl="" + if test "$SDL_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` + SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + + sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` + sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" +dnl +dnl Now check if the installed SDL is sufficiently new. (Also sanity +dnl checks the results of sdl-config to some extent +dnl + rm -f conf.sdltest + AC_TRY_RUN([ +#include +#include +#include +#include + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.sdltest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); + printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + +],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + AC_MSG_RESULT(yes) + ifelse([$2], , :, [$2]) + else + AC_MSG_RESULT(no) + if test "$SDL_CONFIG" = "no" ; then + echo "*** The sdl-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL_CONFIG environment variable to the" + echo "*** full path to sdl-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + AC_TRY_LINK([ +#include +#include +], [ return 0; ], + [ echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], + [ echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + ifelse([$3], , :, [$3]) + fi + AC_SUBST(SDL_CFLAGS) + AC_SUBST(SDL_LIBS) + rm -f conf.sdltest +]) + +# Do all the work for Automake. This macro actually does too much -- +# some checks are only needed if your package does certain things. +# But this isn't really a big deal. + +# serial 1 + +dnl Usage: +dnl AM_INIT_AUTOMAKE(package,version, [no-define]) + +AC_DEFUN(AM_INIT_AUTOMAKE, +[AC_REQUIRE([AC_PROG_INSTALL]) +dnl We require 2.13 because we rely on SHELL being computed by configure. +AC_PREREQ([2.13]) +PACKAGE=[$1] +AC_SUBST(PACKAGE) +VERSION=[$2] +AC_SUBST(VERSION) +dnl test to see if srcdir already configured +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) +fi +ifelse([$3],, +AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])) +AC_REQUIRE([AM_SANITY_CHECK]) +AC_REQUIRE([AC_ARG_PROGRAM]) +dnl FIXME This is truly gross. +missing_dir=`cd $ac_aux_dir && pwd` +AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir) +AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir) +AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir) +AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir) +AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir) +AC_REQUIRE([AC_PROG_MAKE_SET])]) + +# +# Check to make sure that the build environment is sane. +# + +AC_DEFUN(AM_SANITY_CHECK, +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftestfile +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + if test "[$]*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftestfile` + fi + if test "[$]*" != "X $srcdir/configure conftestfile" \ + && test "[$]*" != "X conftestfile $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "[$]2" = conftestfile + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +rm -f conftest* +AC_MSG_RESULT(yes)]) + +dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY) +dnl The program must properly implement --version. +AC_DEFUN(AM_MISSING_PROG, +[AC_MSG_CHECKING(for working $2) +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if ($2 --version) < /dev/null > /dev/null 2>&1; then + $1=$2 + AC_MSG_RESULT(found) +else + $1="$3/missing $2" + AC_MSG_RESULT(missing) +fi +AC_SUBST($1)]) + + +# serial 41 AC_PROG_LIBTOOL +AC_DEFUN(AC_PROG_LIBTOOL, +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl + +# Save cache, so that ltconfig can load it +AC_CACHE_SAVE + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \ +|| AC_MSG_ERROR([libtool configure failed]) + +# Reload cache, that may have been modified by ltconfig +AC_CACHE_LOAD + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log +]) + +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_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +dnl + +AC_CHECK_TOOL(RANLIB, ranlib, :) + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +AC_ARG_WITH(pic, + [ --with-pic try to use only PIC/non-PIC objects [default=use both]], + pic_mode="$withval", pic_mode=default) +test x"$pic_mode" = xyes && libtool_flags="$libtool_flags --prefer-pic" +test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic" + +# 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.o`" 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_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) + 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*) + 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([DllMain (0, 0, 0);], + [extern int __attribute__((__stdcall__)) DllMain(void*, int, void*);], + [lt_cv_need_dllmain=yes],[lt_cv_need_dllmain=no])]) + + case $host in + *-*-cygwin*) + # 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" ;; + *-*-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" ;; + esac + ;; + ]) +esac +]) + +# 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, [dnl +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, [dnl +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, [dnl +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_ENABLE_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_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_prog=ld +if test "$ac_cv_prog_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. +changequote(,)dnl + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' +changequote([,])dnl + # 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(ac_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_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 "$ac_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 + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$ac_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_SUBST(LD) +AC_PROG_LD_GNU +]) + +AC_DEFUN(AC_PROG_LD_GNU, +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_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 + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi]) +]) + +# AC_PROG_NM - find the path to a BSD-compatible name lister +AC_DEFUN(AC_PROG_NM, +[AC_MSG_CHECKING([for BSD-compatible nm]) +AC_CACHE_VAL(ac_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/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 + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/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 "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi]) +NM="$ac_cv_path_NM" +AC_MSG_RESULT([$NM]) +AC_SUBST(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*) + # 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, adds --enable-ltdl-convenience to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate 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=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) +]) + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library, and adds --enable-ltdl-install to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate 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=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + fi +]) + +dnl old names +AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl +AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl +AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl +AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl +AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl +AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl +AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl + diff --git a/config.guess b/config.guess new file mode 100644 index 00000000..1ec70cc1 --- /dev/null +++ b/config.guess @@ -0,0 +1,951 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner . +# The master version of this file is at the FSF in /home/gd/gnu/lib. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit system type (host/target name). +# +# Only a few systems have been added to this list; please add others +# (but try to keep the structure clean). +# + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <dummy.s + .globl main + .ent main +main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]` + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-cbm-sysv4 + exit 0;; + amiga:NetBSD:*:*) + echo m68k-cbm-netbsd${UNAME_RELEASE} + exit 0 ;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + arm32:NetBSD:*:*) + echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + SR2?01:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:*|MIS*:OSx*:*:*|MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + atari*:NetBSD:*:*) + echo m68k-atari-netbsd${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:NetBSD:*:*) + echo m68k-sun-netbsd${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:NetBSD:*:*) + echo m68k-apple-netbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + macppc:NetBSD:*:*) + echo powerpc-apple-netbsd${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >dummy.c + int main (argc, argv) int argc; char **argv; { + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + ${CC-cc} dummy.c -o dummy \ + && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ + -o ${TARGET_BINARY_INTERFACE}x = x ] ; then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i?86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:4) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=4.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/6?? | 9000/7?? | 9000/80[24] | 9000/8?[13679] | 9000/892 ) + sed 's/^ //' << EOF >dummy.c + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (${CC-cc} dummy.c -o dummy 2>/dev/null ) && HP_ARCH=`./dummy` + rm -f dummy.c dummy + esac + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i?86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F300:UNIX_System_V:*:*) + FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + F301:UNIX_System_V:*:*) + echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` + exit 0 ;; + hp3[0-9][05]:NetBSD:*:*) + echo m68k-hp-netbsd${UNAME_RELEASE} + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + i?86:BSD/386:*:* | *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:NetBSD:*:*) + echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin32 + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin32 + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:Linux:*:*) + # uname on the ARM produces all sorts of strangeness, and we need to + # filter it out. + case "$UNAME_MACHINE" in + arm* | sa110*) UNAME_MACHINE="arm" ;; + esac + + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. + ld_help_string=`ld --help 2>&1` + ld_supported_emulations=`echo $ld_help_string \ + | sed -ne '/supported emulations:/!d + s/[ ][ ]*/ /g + s/.*supported emulations: *// + s/ .*// + p'` + case "$ld_supported_emulations" in + i?86linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 ;; + i?86coff) echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 ;; + sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + armlinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + m68klinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;; + elf32ppc) echo "powerpc-unknown-linux-gnu" ; exit 0 ;; + esac + + if test "${UNAME_MACHINE}" = "alpha" ; then + sed 's/^ //' <dummy.s + .globl main + .ent main + main: + .frame \$30,0,\$26,0 + .prologue 0 + .long 0x47e03d80 # implver $0 + lda \$2,259 + .long 0x47e20c21 # amask $2,$1 + srl \$1,8,\$2 + sll \$2,2,\$2 + sll \$0,3,\$0 + addl \$1,\$0,\$0 + addl \$2,\$0,\$0 + ret \$31,(\$26),1 + .end main +EOF + LIBC="" + ${CC-cc} dummy.s -o dummy 2>/dev/null + if test "$?" = 0 ; then + ./dummy + case "$?" in + 7) + UNAME_MACHINE="alpha" + ;; + 15) + UNAME_MACHINE="alphaev5" + ;; + 14) + UNAME_MACHINE="alphaev56" + ;; + 10) + UNAME_MACHINE="alphapca56" + ;; + 16) + UNAME_MACHINE="alphaev6" + ;; + esac + + objdump --private-headers dummy | \ + grep ld.so.1 > /dev/null + if test "$?" = 0 ; then + LIBC="libc1" + fi + fi + rm -f dummy.s dummy + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0 + elif test "${UNAME_MACHINE}" = "mips" ; then + cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + else + # Either a pre-BFD a.out linker (linux-gnuoldld) + # or one that does not give us useful --help. + # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout. + # If ld does not provide *any* "supported emulations:" + # that means it is gnuoldld. + echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:" + test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 + + case "${UNAME_MACHINE}" in + i?86) + VENDOR=pc; + ;; + *) + VENDOR=unknown; + ;; + esac + # Determine whether the default compiler is a.out or elf + cat >dummy.c < +main(argc, argv) + int argc; + char *argv[]; +{ +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-${VENDOR}-linux-gnu\n", argv[1]); +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + fi ;; +# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions +# are messed up and put the nodename in both sysname and nodename. + i?86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i?86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i?86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + i?86:UnixWare:*:*) + if /bin/uname -X 2>/dev/null >/dev/null ; then + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + fi + echo ${UNAME_MACHINE}-unixware-${UNAME_RELEASE}-${UNAME_VERSION} + exit 0 ;; + pc:*:*:*) + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i?86:LynxOS:2.*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:*:6*) + echo mips-sony-newsos6 + exit 0 ;; + R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R4000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +#if !defined (ultrix) + printf ("vax-dec-bsd\n"); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 +rm -f dummy.c dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +#echo '(Unable to guess system type)' 1>&2 + +exit 1 diff --git a/config.sub b/config.sub new file mode 100644 index 00000000..ba26d742 --- /dev/null +++ b/config.sub @@ -0,0 +1,955 @@ +#! /bin/sh +# Configuration validation subroutine script, version 1.1. +# Copyright (C) 1991, 92-97, 1998 Free Software Foundation, Inc. +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +if [ x$1 = x ] +then + echo Configuration name missing. 1>&2 + echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 + echo "or $0 ALIAS" 1>&2 + echo where ALIAS is a recognized configuration type. 1>&2 + exit 1 +fi + +# First pass through any local machine types. +case $1 in + *local*) + echo $1 + exit 0 + ;; + *) + ;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + linux-gnu*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple) + os= + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + tahoe | i860 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \ + | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \ + | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 | hppa2.0 \ + | alpha | alphaev5 | alphaev56 | we32k | ns16k | clipper \ + | i370 | sh | powerpc | powerpcle | 1750a | dsp16xx | pdp11 \ + | mips64 | mipsel | mips64el | mips64orion | mips64orionel \ + | mipstx39 | mipstx39el | armv[34][lb] \ + | sparc | sparclet | sparclite | sparc64 | v850) + basic_machine=$basic_machine-unknown + ;; + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i[34567]86) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + vax-* | tahoe-* | i[34567]86-* | i860-* | m32r-* | m68k-* | m68000-* \ + | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \ + | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \ + | power-* | none-* | 580-* | cray2-* | h8300-* | i960-* \ + | xmp-* | ymp-* | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* \ + | alpha-* | alphaev5-* | alphaev56-* | we32k-* | cydra-* \ + | ns16k-* | pn-* | np1-* | xps100-* | clipper-* | orion-* \ + | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \ + | sparc64-* | mips64-* | mipsel-* | armv[34][lb]-*\ + | mips64el-* | mips64orion-* | mips64orionel-* \ + | mipstx39-* | mipstx39el-* \ + | f301-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-cbm + ;; + amigaos | amigados) + basic_machine=m68k-cbm + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-cbm + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [ctj]90-cray) + basic_machine=c90-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + os=-mvs + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i[34567]86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i[34567]86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i[34567]86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i[34567]86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + miniframe) + basic_machine=m68000-convergent + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + np1) + basic_machine=np1-gould + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | nexen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | k6 | 6x86) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | nexen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | k6-* | 6x86-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=rs6000-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sparc) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -xenix) + os=-xenix + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-semi) + os=-aout + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f301-fujitsu) + os=-uxpv + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -hpux*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os diff --git a/configure b/configure new file mode 100755 index 00000000..09ca1b3d --- /dev/null +++ b/configure @@ -0,0 +1,2295 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: +ac_help="$ac_help + --enable-shared[=PKGS] build shared libraries [default=yes]" +ac_help="$ac_help + --enable-static[=PKGS] build static libraries [default=yes]" +ac_help="$ac_help + --enable-fast-install[=PKGS] optimize for fast installation [default=yes]" +ac_help="$ac_help + --with-gnu-ld assume the C compiler uses GNU ld [default=no]" +ac_help="$ac_help + --disable-libtool-lock avoid locking (might break parallel builds)" +ac_help="$ac_help + --with-pic try to use only PIC/non-PIC objects [default=use both]" +ac_help="$ac_help + --with-sdl-prefix=PFX Prefix where SDL is installed (optional)" +ac_help="$ac_help + --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)" +ac_help="$ac_help + --disable-sdltest Do not try to compile and run a test SDL program" +ac_help="$ac_help + --enable-music-cmd support an external music player [default=yes]" +ac_help="$ac_help + --enable-music-wave enable streaming WAVE music [default=yes]" +ac_help="$ac_help + --enable-music-midi enable MIDI music via timidity [default=yes]" +ac_help="$ac_help + --enable-music-mod enable MOD music via mikmod [default=yes]" +ac_help="$ac_help + --enable-music-mp3 enable MP3 music via smpeg [default=yes]" + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=README + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + + +# Making releases: +# MICRO_VERSION += 1; +# INTERFACE_AGE += 1; +# BINARY_AGE += 1; +# if any functions have been added, set INTERFACE_AGE to 0. +# if backwards compatibility has been broken, +# set BINARY_AGE and INTERFACE_AGE to 0. + +MAJOR_VERSION=1 +MINOR_VERSION=0 +MICRO_VERSION=0 +INTERFACE_AGE=0 +BINARY_AGE=0 +VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION + + + + + + + + +# libtool versioning +LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION +LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE` +LT_REVISION=$INTERFACE_AGE +LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE` + + + + + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:619: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 +echo "configure:672: checking whether build environment is sane" >&5 +# Just in case +sleep 1 +echo timestamp > conftestfile +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftestfile` + fi + if test "$*" != "X $srcdir/configure conftestfile" \ + && test "$*" != "X conftestfile $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { echo "configure: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" 1>&2; exit 1; } + fi + + test "$2" = conftestfile + ) +then + # Ok. + : +else + { echo "configure: error: newly created file is older than distributed files! +Check your system clock" 1>&2; exit 1; } +fi +rm -f conftest* +echo "$ac_t""yes" 1>&6 +if test "$program_transform_name" = s,x,x,; then + program_transform_name= +else + # Double any \ or $. echo might interpret backslashes. + cat <<\EOF_SED > conftestsed +s,\\,\\\\,g; s,\$,$$,g +EOF_SED + program_transform_name="`echo $program_transform_name|sed -f conftestsed`" + rm -f conftestsed +fi +test "$program_prefix" != NONE && + program_transform_name="s,^,${program_prefix},; $program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$\$,${program_suffix},; $program_transform_name" + +# sed with no file args requires a program. +test "$program_transform_name" = "" && program_transform_name="s,x,x," + +echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 +echo "configure:729: checking whether ${MAKE-make} sets \${MAKE}" >&5 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$ac_t""yes" 1>&6 + SET_MAKE= +else + echo "$ac_t""no" 1>&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + + + +PACKAGE=mixer + +VERSION=$VERSION + +if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then + { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } +fi +cat >> confdefs.h <> confdefs.h <&6 +echo "configure:776: checking for working aclocal" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (aclocal --version) < /dev/null > /dev/null 2>&1; then + ACLOCAL=aclocal + echo "$ac_t""found" 1>&6 +else + ACLOCAL="$missing_dir/missing aclocal" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 +echo "configure:789: checking for working autoconf" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (autoconf --version) < /dev/null > /dev/null 2>&1; then + AUTOCONF=autoconf + echo "$ac_t""found" 1>&6 +else + AUTOCONF="$missing_dir/missing autoconf" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working automake""... $ac_c" 1>&6 +echo "configure:802: checking for working automake" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (automake --version) < /dev/null > /dev/null 2>&1; then + AUTOMAKE=automake + echo "$ac_t""found" 1>&6 +else + AUTOMAKE="$missing_dir/missing automake" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 +echo "configure:815: checking for working autoheader" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (autoheader --version) < /dev/null > /dev/null 2>&1; then + AUTOHEADER=autoheader + echo "$ac_t""found" 1>&6 +else + AUTOHEADER="$missing_dir/missing autoheader" + echo "$ac_t""missing" 1>&6 +fi + +echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 +echo "configure:828: checking for working makeinfo" >&5 +# Run test in a subshell; some versions of sh will print an error if +# an executable is not found, even if stderr is redirected. +# Redirect stdin to placate older versions of autoconf. Sigh. +if (makeinfo --version) < /dev/null > /dev/null 2>&1; then + MAKEINFO=makeinfo + echo "$ac_t""found" 1>&6 +else + MAKEINFO="$missing_dir/missing makeinfo" + echo "$ac_t""missing" 1>&6 +fi + + + + +echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 +echo "configure:844: checking whether ${MAKE-make} sets \${MAKE}" >&5 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` +if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$ac_t""yes" 1>&6 + SET_MAKE= +else + echo "$ac_t""no" 1>&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +# Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:873: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:903: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + if test -z "$CC"; then + case "`uname -s`" in + *win32* | *WIN32*) + # Extract the first word of "cl", so it can be a program name with args. +set dummy cl; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:954: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="cl" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + ;; + esac + fi + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 +echo "configure:986: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +cat > conftest.$ac_ext << EOF + +#line 997 "configure" +#include "confdefs.h" + +main(){return(0);} +EOF +if { (eval echo configure:1002: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + ac_cv_prog_cc_works=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>/dev/null; then + ac_cv_prog_cc_cross=no + else + ac_cv_prog_cc_cross=yes + fi +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + ac_cv_prog_cc_works=no +fi +rm -fr conftest* +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 +if test $ac_cv_prog_cc_works = no; then + { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } +fi +echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 +echo "configure:1028: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 +echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 +cross_compiling=$ac_cv_prog_cc_cross + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:1033: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +else + GCC= +fi + +ac_test_CFLAGS="${CFLAGS+set}" +ac_save_CFLAGS="$CFLAGS" +CFLAGS= +echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:1061: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi + +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_shared=yes +fi + +# Check whether --enable-static or --disable-static was given. +if test "${enable_static+set}" = set; then + enableval="$enable_static" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_static=yes +fi + +# Check whether --enable-fast-install or --disable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval="$enable_fast_install" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_fast_install=yes +fi + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:1168: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:1189: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi + +ac_prog=ld +if test "$ac_cv_prog_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 +echo "configure:1218: checking for ld used by GCC" >&5 + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case "$ac_prog" in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 +echo "configure:1248: checking for GNU ld" >&5 +else + echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 +echo "configure:1251: checking for non-GNU ld" >&5 +fi +if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_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 "$ac_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 + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$ac_cv_path_LD" +if test -n "$LD"; then + echo "$ac_t""$LD" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi +test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } + +echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 +echo "configure:1287: checking if the linker ($LD) is GNU ld" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6 + + +echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 +echo "configure:1303: checking for BSD-compatible nm" >&5 +if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/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 + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/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 "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi +fi + +NM="$ac_cv_path_NM" +echo "$ac_t""$NM" 1>&6 + + +echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 +echo "configure:1340: checking whether ln -s works" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + rm -f conftestdata +if ln -s X conftestdata 2>/dev/null +then + rm -f conftestdata + ac_cv_prog_LN_S="ln -s" +else + ac_cv_prog_LN_S=ln +fi +fi +LN_S="$ac_cv_prog_LN_S" +if test "$ac_cv_prog_LN_S" = "ln -s"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +if test $host != $build; then + ac_tool_prefix=${host_alias}- +else + ac_tool_prefix= +fi + + +# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1370: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_RANLIB"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1402: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB=":" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + RANLIB=":" +fi +fi + + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" + + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + : +fi + +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Check whether --with-pic or --without-pic was given. +if test "${with_pic+set}" = set; then + withval="$with_pic" + pic_mode="$withval" +else + pic_mode=default +fi + +test x"$pic_mode" = xyes && libtool_flags="$libtool_flags --prefer-pic" +test x"$pic_mode" = xno && libtool_flags="$libtool_flags --prefer-non-pic" + +# 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 1469 "configure"' > conftest.$ac_ext + if { (eval echo configure:1470: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 +echo "configure:1491: checking whether the C compiler needs -belf" >&5 +if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + lt_cv_cc_needs_belf=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + lt_cv_cc_needs_belf=no +fi +rm -f conftest* +fi + +echo "$ac_t""$lt_cv_cc_needs_belf" 1>&6 + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + + +esac + + +# Save cache, so that ltconfig can load it +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify --build="$build" $ac_aux_dir/ltmain.sh $host \ +|| { echo "configure: error: libtool configure failed" 1>&2; exit 1; } + +# Reload cache, that may have been modified by ltconfig +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:1616: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + + +# Check whether --with-sdl-prefix or --without-sdl-prefix was given. +if test "${with_sdl_prefix+set}" = set; then + withval="$with_sdl_prefix" + sdl_prefix="$withval" +else + sdl_prefix="" +fi + +# Check whether --with-sdl-exec-prefix or --without-sdl-exec-prefix was given. +if test "${with_sdl_exec_prefix+set}" = set; then + withval="$with_sdl_exec_prefix" + sdl_exec_prefix="$withval" +else + sdl_exec_prefix="" +fi + +# Check whether --enable-sdltest or --disable-sdltest was given. +if test "${enable_sdltest+set}" = set; then + enableval="$enable_sdltest" + : +else + enable_sdltest=yes +fi + + + if test x$sdl_exec_prefix != x ; then + sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config + fi + fi + if test x$sdl_prefix != x ; then + sdl_args="$sdl_args --prefix=$sdl_prefix" + if test x${SDL_CONFIG+set} != xset ; then + SDL_CONFIG=$sdl_prefix/bin/sdl-config + fi + fi + + # Extract the first word of "sdl-config", so it can be a program name with args. +set dummy sdl-config; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1710: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_path_SDL_CONFIG'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + case "$SDL_CONFIG" in + /*) + ac_cv_path_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test with a path. + ;; + ?:/*) + ac_cv_path_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test with a dos path. + ;; + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_path_SDL_CONFIG="$ac_dir/$ac_word" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_SDL_CONFIG" && ac_cv_path_SDL_CONFIG="no" + ;; +esac +fi +SDL_CONFIG="$ac_cv_path_SDL_CONFIG" +if test -n "$SDL_CONFIG"; then + echo "$ac_t""$SDL_CONFIG" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + min_sdl_version=0.11.2 + echo $ac_n "checking for SDL - version >= $min_sdl_version""... $ac_c" 1>&6 +echo "configure:1745: checking for SDL - version >= $min_sdl_version" >&5 + no_sdl="" + if test "$SDL_CONFIG" = "no" ; then + no_sdl=yes + else + SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` + SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` + + sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` + sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` + sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ + sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` + if test "x$enable_sdltest" = "xyes" ; then + ac_save_CFLAGS="$CFLAGS" + ac_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + rm -f conf.sdltest + if test "$cross_compiling" = yes; then + echo $ac_n "cross compiling; assumed OK... $ac_c" +else + cat > conftest.$ac_ext < +#include +#include +#include + +char* +my_strdup (char *str) +{ + char *new_str; + + if (str) + { + new_str = malloc ((strlen (str) + 1) * sizeof(char)); + strcpy (new_str, str); + } + else + new_str = NULL; + + return new_str; +} + +int main () +{ + int major, minor, micro; + char *tmp_version; + + system ("touch conf.sdltest"); + + /* HP/UX 9 (%@#!) writes to sscanf strings */ + tmp_version = my_strdup("$min_sdl_version"); + if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { + printf("%s, bad version string\n", "$min_sdl_version"); + exit(1); + } + + if (($sdl_major_version > major) || + (($sdl_major_version == major) && ($sdl_minor_version > minor)) || + (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) + { + return 0; + } + else + { + printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); + printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); + printf("*** best to upgrade to the required version.\n"); + printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); + printf("*** to point to the correct copy of sdl-config, and remove the file\n"); + printf("*** config.cache before re-running configure\n"); + return 1; + } +} + + +EOF +if { (eval echo configure:1827: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + : +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + no_sdl=yes +fi +rm -fr conftest* +fi + + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + if test "x$no_sdl" = x ; then + echo "$ac_t""yes" 1>&6 + : + else + echo "$ac_t""no" 1>&6 + if test "$SDL_CONFIG" = "no" ; then + echo "*** The sdl-config script installed by SDL could not be found" + echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" + echo "*** your path, or set the SDL_CONFIG environment variable to the" + echo "*** full path to sdl-config." + else + if test -f conf.sdltest ; then + : + else + echo "*** Could not run SDL test program, checking why..." + CFLAGS="$CFLAGS $SDL_CFLAGS" + LIBS="$LIBS $SDL_LIBS" + cat > conftest.$ac_ext < +#include + +int main() { + return 0; +; return 0; } +EOF +if { (eval echo configure:1871: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + echo "*** The test program compiled, but did not run. This usually means" + echo "*** that the run-time linker is not finding SDL or finding the wrong" + echo "*** version of SDL. If it is not finding SDL, you'll need to set your" + echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" + echo "*** to the installed location Also, make sure you have run ldconfig if that" + echo "*** is required on your system" + echo "***" + echo "*** If you have an old version installed, it is best to remove it, although" + echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + echo "*** The test program failed to compile or link. See the file config.log for the" + echo "*** exact error that occured. This usually means SDL was incorrectly installed" + echo "*** or that you have moved SDL since it was installed. In the latter case, you" + echo "*** may want to edit the sdl-config script: $SDL_CONFIG" +fi +rm -f conftest* + CFLAGS="$ac_save_CFLAGS" + LIBS="$ac_save_LIBS" + fi + fi + SDL_CFLAGS="" + SDL_LIBS="" + : + fi + + + rm -f conf.sdltest + +CFLAGS="$CFLAGS $SDL_CFLAGS" +LIBS="$LIBS $SDL_LIBS" + +# Check whether --enable-music-cmd or --disable-music-cmd was given. +if test "${enable_music_cmd+set}" = set; then + enableval="$enable_music_cmd" + : +else + enable_music_cmd=yes +fi + +if test x$enable_music_cmd = xyes; then + CFLAGS="$CFLAGS -DCMD_MUSIC" +fi +# Check whether --enable-music-wave or --disable-music-wave was given. +if test "${enable_music_wave+set}" = set; then + enableval="$enable_music_wave" + : +else + enable_music_wave=yes +fi + +if test x$enable_music_wave = xyes; then + CFLAGS="$CFLAGS -DWAV_MUSIC" +fi +# Check whether --enable-music-midi or --disable-music-midi was given. +if test "${enable_music_midi+set}" = set; then + enableval="$enable_music_midi" + : +else + enable_music_midi=yes +fi + +if test x$enable_music_midi = xyes; then + CFLAGS="$CFLAGS -DMID_MUSIC -I\$(top_srcdir)/timidity" + #MUSIC_SUBDIRS="$MUSIC_SUBDIRS timidity" +fi +# Check whether --enable-music-mod or --disable-music-mod was given. +if test "${enable_music_mod+set}" = set; then + enableval="$enable_music_mod" + : +else + enable_music_mod=yes +fi + +if test x$enable_music_mod = xyes; then + CFLAGS="$CFLAGS -DMOD_MUSIC -I\$(top_srcdir)/mikmod" + #MUSIC_SUBDIRS="$MUSIC_SUBDIRS mikmod" +fi +# Check whether --enable-music-mp3 or --disable-music-mp3 was given. +if test "${enable_music_mp3+set}" = set; then + enableval="$enable_music_mp3" + : +else + enable_music_mp3=yes +fi + +if test x$enable_music_mp3 = xyes; then + echo $ac_n "checking for SMPEG headers and libraries""... $ac_c" 1>&6 +echo "configure:1963: checking for SMPEG headers and libraries" >&5 + have_smpeg=no + cat > conftest.$ac_ext < + +int main() { + + +; return 0; } +EOF +if { (eval echo configure:1976: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + rm -rf conftest* + + have_smpeg=yes + +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 +fi +rm -f conftest* + echo "$ac_t""$have_smpeg" 1>&6 + if test x$have_smpeg = xyes; then + CFLAGS="$CFLAGS -DMP3_MUSIC" + LIBS="$LIBS -lsmpeg" + fi +fi + +# Finally create all the generated files +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo " +Makefile +mikmod/Makefile +timidity/Makefile +" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@MAJOR_VERSION@%$MAJOR_VERSION%g +s%@MINOR_VERSION@%$MINOR_VERSION%g +s%@MICRO_VERSION@%$MICRO_VERSION%g +s%@INTERFACE_AGE@%$INTERFACE_AGE%g +s%@BINARY_AGE@%$BINARY_AGE%g +s%@VERSION@%$VERSION%g +s%@LT_RELEASE@%$LT_RELEASE%g +s%@LT_CURRENT@%$LT_CURRENT%g +s%@LT_REVISION@%$LT_REVISION%g +s%@LT_AGE@%$LT_AGE%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g +s%@PACKAGE@%$PACKAGE%g +s%@ACLOCAL@%$ACLOCAL%g +s%@AUTOCONF@%$AUTOCONF%g +s%@AUTOMAKE@%$AUTOMAKE%g +s%@AUTOHEADER@%$AUTOHEADER%g +s%@MAKEINFO@%$MAKEINFO%g +s%@SET_MAKE@%$SET_MAKE%g +s%@CC@%$CC%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g +s%@LD@%$LD%g +s%@NM@%$NM%g +s%@LN_S@%$LN_S%g +s%@RANLIB@%$RANLIB%g +s%@LIBTOOL@%$LIBTOOL%g +s%@SDL_CONFIG@%$SDL_CONFIG%g +s%@SDL_CFLAGS@%$SDL_CFLAGS%g +s%@SDL_LIBS@%$SDL_LIBS%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + diff --git a/configure.in b/configure.in new file mode 100644 index 00000000..e850b2bc --- /dev/null +++ b/configure.in @@ -0,0 +1,105 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(README) + +dnl Set various version strings - taken gratefully from the GTk sources + +# Making releases: +# MICRO_VERSION += 1; +# INTERFACE_AGE += 1; +# BINARY_AGE += 1; +# if any functions have been added, set INTERFACE_AGE to 0. +# if backwards compatibility has been broken, +# set BINARY_AGE and INTERFACE_AGE to 0. + +MAJOR_VERSION=1 +MINOR_VERSION=0 +MICRO_VERSION=0 +INTERFACE_AGE=0 +BINARY_AGE=0 +VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION + +AC_SUBST(MAJOR_VERSION) +AC_SUBST(MINOR_VERSION) +AC_SUBST(MICRO_VERSION) +AC_SUBST(INTERFACE_AGE) +AC_SUBST(BINARY_AGE) +AC_SUBST(VERSION) + +# libtool versioning +LT_RELEASE=$MAJOR_VERSION.$MINOR_VERSION +LT_CURRENT=`expr $MICRO_VERSION - $INTERFACE_AGE` +LT_REVISION=$INTERFACE_AGE +LT_AGE=`expr $BINARY_AGE - $INTERFACE_AGE` + +AC_SUBST(LT_RELEASE) +AC_SUBST(LT_CURRENT) +AC_SUBST(LT_REVISION) +AC_SUBST(LT_AGE) + +dnl Setup for automake +AM_INIT_AUTOMAKE(mixer, $VERSION) + +dnl Check for tools + +AC_PROG_MAKE_SET +AC_PROG_CC +AM_PROG_LIBTOOL +AC_PROG_INSTALL + +dnl Check for SDL 0.11.2 +AM_PATH_SDL(0.11.2) +CFLAGS="$CFLAGS $SDL_CFLAGS" +LIBS="$LIBS $SDL_LIBS" + +dnl Check command-line options +AC_ARG_ENABLE(music-cmd, +[ --enable-music-cmd support an external music player [default=yes]], + , enable_music_cmd=yes) +if test x$enable_music_cmd = xyes; then + CFLAGS="$CFLAGS -DCMD_MUSIC" +fi +AC_ARG_ENABLE(music-wave, +[ --enable-music-wave enable streaming WAVE music [default=yes]], + , enable_music_wave=yes) +if test x$enable_music_wave = xyes; then + CFLAGS="$CFLAGS -DWAV_MUSIC" +fi +AC_ARG_ENABLE(music-midi, +[ --enable-music-midi enable MIDI music via timidity [default=yes]], + , enable_music_midi=yes) +if test x$enable_music_midi = xyes; then + CFLAGS="$CFLAGS -DMID_MUSIC -I\$(top_srcdir)/timidity" + #MUSIC_SUBDIRS="$MUSIC_SUBDIRS timidity" +fi +AC_ARG_ENABLE(music-mod, +[ --enable-music-mod enable MOD music via mikmod [default=yes]], + , enable_music_mod=yes) +if test x$enable_music_mod = xyes; then + CFLAGS="$CFLAGS -DMOD_MUSIC -I\$(top_srcdir)/mikmod" + #MUSIC_SUBDIRS="$MUSIC_SUBDIRS mikmod" +fi +AC_ARG_ENABLE(music-mp3, +[ --enable-music-mp3 enable MP3 music via smpeg [default=yes]], + , enable_music_mp3=yes) +if test x$enable_music_mp3 = xyes; then + AC_MSG_CHECKING(for SMPEG headers and libraries) + have_smpeg=no + AC_TRY_COMPILE([ + #include + ],[ + ],[ + have_smpeg=yes + ]) + AC_MSG_RESULT($have_smpeg) + if test x$have_smpeg = xyes; then + CFLAGS="$CFLAGS -DMP3_MUSIC" + LIBS="$LIBS -lsmpeg" + fi +fi + +# Finally create all the generated files +AC_OUTPUT([ +Makefile +mikmod/Makefile +timidity/Makefile +]) diff --git a/install-sh b/install-sh new file mode 100644 index 00000000..e9de2384 --- /dev/null +++ b/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/ltconfig b/ltconfig new file mode 100644 index 00000000..317d202c --- /dev/null +++ b/ltconfig @@ -0,0 +1,3461 @@ +#! /bin/sh + +# ltconfig - Create a system-specific libtool. +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# A lot of this script is taken from autoconf-2.10. + +# Check that we are running under the correct shell. +SHELL=${CONFIG_SHELL-/bin/sh} +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`} + case X$UNAME in + *-DOS) PATH_SEPARATOR=';' ;; + *) PATH_SEPARATOR=':' ;; + esac +fi + +# 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 + +if test "X${echo_test_string+set}" != Xset; then + # find a string as large as possible, as long as the shell can cope with it + for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do + # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ... + if (echo_test_string="`eval $cmd`") 2>/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' || + test "X`($echo "$echo_test_string") 2>/dev/null`" != X"$echo_test_string"; then + # 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="${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' && + test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = 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' && + test "X`(print -r "$echo_test_string") 2>/dev/null`" = 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 ltconfig 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' && + test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then + # Cool, printf works + : + elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && + test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = 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 test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' && + test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = 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}" "$0" ${1+"$@"} + else + # Oops. We lost completely, so just stick with echo. + echo=echo + fi + fi + fi + fi +fi + +# 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' + +# The name of this program. +progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'` + +# Constants: +PROGRAM=ltconfig +PACKAGE=libtool +VERSION=1.3c +TIMESTAMP=" (1.612 1999/09/30 00:26:50)" +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.c 1>&5' +ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.c $LIBS 1>&5' +rm="rm -f" + +help="Try \`$progname --help' for more information." + +# Global variables: +default_ofile=libtool +can_build_shared=yes +enable_shared=yes +# All known linkers require a `.a' archive for static linking (except M$VC, +# which needs '.lib'). +enable_static=yes +enable_fast_install=yes +enable_dlopen=unknown +enable_win32_dll=no +pic_mode=default +ltmain= +silent= +srcdir= +ac_config_guess= +ac_config_sub= +host= +build=NONE +nonopt=NONE +ofile="$default_ofile" +verify_host=yes +with_gcc=no +with_gnu_ld=no +need_locks=yes +ac_ext=c +objext=o +libext=a +exeext= +cache_file= + +old_AR="$AR" +old_CC="$CC" +old_CFLAGS="$CFLAGS" +old_CPPFLAGS="$CPPFLAGS" +old_LDFLAGS="$LDFLAGS" +old_LD="$LD" +old_LN_S="$LN_S" +old_LIBS="$LIBS" +old_NM="$NM" +old_RANLIB="$RANLIB" +old_DLLTOOL="$DLLTOOL" +old_OBJDUMP="$OBJDUMP" +old_AS="$AS" + +# Parse the command line options. +args= +prev= +for option +do + case "$option" in + -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + eval "$prev=\$option" + prev= + continue + fi + + case "$option" in + --help) cat <&2 + echo "$help" 1>&2 + exit 1 + ;; + + *) + if test -z "$ltmain"; then + ltmain="$option" + elif test -z "$host"; then +# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1 +# if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then +# echo "$progname: warning \`$option' is not a valid host type" 1>&2 +# fi + host="$option" + else + echo "$progname: too many arguments" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac +done + +if test -z "$ltmain"; then + echo "$progname: you must specify a LTMAIN file" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +if test ! -f "$ltmain"; then + echo "$progname: \`$ltmain' does not exist" 1>&2 + echo "$help" 1>&2 + exit 1 +fi + +# Quote any args containing shell metacharacters. +ltconfig_args= +for arg +do + case "$arg" in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ltconfig_args="$ltconfig_args '$arg'" ;; + *) ltconfig_args="$ltconfig_args $arg" ;; + esac +done + +# A relevant subset of AC_INIT. + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 5 compiler messages saved in config.log +# 6 checking for... messages and results +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>>./config.log + +# NLS nuisances. +# Only set LANG and LC_ALL to C if already set. +# These must not be set unconditionally because not all systems understand +# e.g. LANG=C (notably SCO). +if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi +if test "X${LANG+set}" = Xset; then LANG=C; export LANG; fi + +if test -n "$cache_file" && test -r "$cache_file"; then + echo "loading cache $cache_file within ltconfig" + . $cache_file +fi + +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + +if test -z "$srcdir"; then + # Assume the source directory is the same one as the path to LTMAIN. + srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'` + test "$srcdir" = "$ltmain" && srcdir=. +fi + +trap "$rm conftest*; exit 1" 1 2 15 +if test "$verify_host" = yes; then + # Check for config.guess and config.sub. + ac_aux_dir= + for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/config.guess; then + ac_aux_dir=$ac_dir + break + fi + done + if test -z "$ac_aux_dir"; then + echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2 + echo "$help" 1>&2 + exit 1 + fi + ac_config_guess=$ac_aux_dir/config.guess + ac_config_sub=$ac_aux_dir/config.sub + + # Make sure we can run config.sub. + if $SHELL $ac_config_sub sun4 >/dev/null 2>&1; then : + else + echo "$progname: cannot run $ac_config_sub" 1>&2 + echo "$help" 1>&2 + exit 1 + fi + + echo $ac_n "checking host system type""... $ac_c" 1>&6 + + host_alias=$host + case "$host_alias" in + "") + if host_alias=`$SHELL $ac_config_guess`; then : + else + echo "$progname: cannot guess host type; you must specify one" 1>&2 + echo "$help" 1>&2 + exit 1 + fi ;; + esac + host=`$SHELL $ac_config_sub $host_alias` + echo "$ac_t$host" 1>&6 + + # Make sure the host verified. + test -z "$host" && exit 1 + + # Check for the build system type + echo $ac_n "checking build system type... $ac_c" 1>&6 + + build_alias=$build + case "$build_alias" in + NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; + esac + + build=`$SHELL $ac_config_sub $build_alias` + build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` + build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` + build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + echo "$ac_t""$build" 1>&6 + +elif test -z "$host"; then + echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2 + echo "$help" 1>&2 + exit 1 +else + host_alias=$host + build_alias=$host_alias + build=$host +fi + +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 + +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + +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 cru $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +# Set a sane default for `AR'. +test -z "$AR" && AR=ar + +# Set a sane default for `OBJDUMP'. +test -z "$OBJDUMP" && OBJDUMP=objdump + +# Set sane defaults for `DLLTOOL' +test -z "$DLLTOOL" && DLLTOOL=dlltool + +# Set sane defaults for `AS' +test -z "$AS" && AS=as + +# Check to see if we can use ln -s, or we need hard links. +echo $ac_n "checking whether ln -s works... $ac_c" 1>&6 +echo "$progname:528: checking for ln -s" 1>&5 +result=yes +if test "X${ac_cv_prog_LN_S+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 + if test "X$ac_cv_prog_LN_S" != "Xln -s"; then + result=no + fi +else + if test -n "$LN_S"; then + ac_cv_prog_LN_S="$LN_S" + else + $rm conftest.dat + if ln -s X conftest.dat 2>/dev/null; then + $rm conftest.dat + ac_cv_prog_LN_S="ln -s" + else + ac_cv_prog_LN_S=ln + result=no + fi + fi +fi +LN_S="$ac_cv_prog_LN_S" +echo "$ac_t""$result" 1>&6 + +# Search for a ranlib program +for ac_prog in "${ac_host_prefix}ranlib" ranlib : +do + echo $ac_n "checking for $ac_prog... $ac_c" 1>&6 + echo "$progname:556: checking for $ac_prog" 1>&5 + if test "X${ac_cv_prog_RANLIB+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 + else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. + else + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/$ac_prog || test -f $dir/$ac_prog$ac_exeext; then + ac_cv_prog_RANLIB="$ac_prog" + break + fi + done + IFS="$save_ifs" + fi + fi + if test -n "$ac_cv_prog_RANLIB"; then + RANLIB="$ac_cv_prog_RANLIB" + old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" + old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds" + echo "$ac_t$RANLIB" 1>&6 + else + echo "$ac_t""no" 1>&6 + fi + + test -n "$RANLIB" && break +done + +if test -z "$NM"; then + echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6 + case "$NM" in + [\\/]* | [A-Za-z]:[\\/]*) ;; # Let the user override the test with a path. + *) + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/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 + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + NM="$ac_dir/nm -p" + break + else + NM=${NM="$ac_dir/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 "$NM" && NM=nm + ;; + esac + echo "$ac_t$NM" 1>&6 +fi + +# Search for a strip program +echo $ac_n "checking for strip... $ac_c" 1>&6 +echo "$progname:619: checking for strip" 1>&5 +if test "X${ac_cv_prog_STRIP+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 + result="$ac_cv_prog_STRIP" +else + if test -n "$STRIP"; then + result="$STRIP" # Let the user override the test. + ac_cv_prog_STRIP="$result" + else + result=no + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/strip || test -f $dir/strip$ac_exeext; then + result="strip" + ac_cv_prog_STRIP="$result" + break + fi + done + IFS="$save_ifs" + fi +fi +test -n "$ac_cv_prog_STRIP" && STRIP="$ac_cv_prog_STRIP" +echo "$ac_t$result" 1>&6 + +# Check to see if we are using GCC. +if test "$with_gcc" != yes || test -z "$CC"; then + # If CC is not set, then try to find GCC or a usable CC. + if test -z "$CC"; then + echo $ac_n "checking for gcc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/gcc || test -f $dir/gcc$ac_exeext; then + CC="gcc" + break + fi + done + IFS="$save_ifs" + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + fi + + # Not "gcc", so try "cc", rejecting "/usr/ucb/cc". + if test -z "$CC"; then + echo $ac_n "checking for cc... $ac_c" 1>&6 + IFS="${IFS= }"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + cc_rejected=no + for dir in $PATH; do + test -z "$dir" && dir=. + if test -f $dir/cc || test -f $dir/cc$ac_exeext; then + if test "$dir/cc" = "/usr/ucb/cc"; then + cc_rejected=yes + continue + fi + CC="cc" + break + fi + done + IFS="$save_ifs" + if test $cc_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same name, so the bogon will be chosen + # first if we set CC to just the name; use the full file name. + shift + set dummy "$dir/cc" "$@" + shift + CC="$@" + fi + fi + + if test -n "$CC"; then + echo "$ac_t$CC" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$CC"; then + echo "$progname: error: no acceptable cc found in \$PATH" 1>&2 + exit 1 + fi + fi + + # Now see if the compiler is really GCC. + with_gcc=no + echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6 + echo "$progname:713: checking whether we are using GNU C" >&5 + + $rm conftest.c + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + with_gcc=yes + fi + $rm conftest.c + echo "$ac_t$with_gcc" 1>&6 +fi + +echo $ac_n "checking for objdir... $ac_c" 1>&6 +rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + objdir=_libs +fi +rmdir .libs 2>/dev/null +echo "$ac_t$objdir" 1>&6 + +echo $ac_n "checking for object suffix... $ac_c" 1>&6 +echo "$progname:741: checking for object suffix" 1>&5 +if test "X${ac_cv_objext+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_objext="no" + $rm conftest* + echo 'int i = 1;' > conftest.c + if { (eval echo $progname:748: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + for ac_file in conftest.*; do + case $ac_file in + *.c | *.err) ;; + *) ac_cv_objext=`echo $ac_file | sed -e s/conftest.//` ;; + esac + done + else + cat conftest.err 1>&5 + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* +fi +if test "X$ac_cv_objext" = Xno; then + objext="" +else + objext="$ac_cv_objext" +fi +echo "$ac_t$ac_cv_objext" 1>&6 + +echo $ac_n "checking for executable suffix... $ac_c" 1>&6 +echo "$progname:773: checking for executable suffix" 1>&5 +if test "X${ac_cv_exeext+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_exeext="no" + $rm conftest* + echo 'main () { return 0; }' > conftest.c + if { (eval echo $progname:780: \"$ac_link\") 1>&5; (eval $ac_link) 2>conftest.err; }; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + for ac_file in conftest.*; do + case $ac_file in + *.c | *.err | *.$objext ) ;; + *) ac_cv_exeext=.`echo $ac_file | sed -e s/conftest.//` ;; + esac + done + else + cat conftest.err 1>&5 + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* +fi +if test "X$ac_cv_exeext" = Xno; then + exeext="" +else + exeext="$ac_cv_exeext" +fi +echo "$ac_t$ac_cv_exeext" 1>&6 + +# Allow CC to be a program name with arguments. +set dummy $CC +compiler="$2" + +# We assume here that the value for ac_cv_prog_cc_pic will not be cached +# in isolation, and that seeing it set (from the cache) indicates that +# the associated values are set (in the cache) correctly too. +echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6 +echo "$progname:812:checking for $compiler option to produce PIC" 1>&5 +if test "X${ac_cv_prog_cc_pic+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_cv_prog_cc_pic= + ac_cv_prog_cc_shlib= + ac_cv_prog_cc_wl= + ac_cv_prog_cc_static= + ac_cv_prog_cc_no_builtin= + ac_cv_prog_cc_can_build_shared=$can_build_shared + + if test "$with_gcc" = yes; then + ac_cv_prog_cc_wl='-Wl,' + ac_cv_prog_cc_static='-static' + + case "$host_os" in + beos* | irix5* | irix6* | osf3* | osf4*) + # PIC is the default for these OSes. + ;; + 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 + # we not sure about C++ programs. + ac_cv_prog_cc_static="$ac_cv_prog_cc_static ${ac_cv_prog_cc_wl}-lC" + ;; + cygwin* | mingw* | 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). + ac_cv_prog_cc_pic='-DDLL_EXPORT' + ;; + 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'. + ac_cv_prog_cc_pic='-m68020 -resident32 -malways-restore-a4' + ;; + sysv4*MP*) + if test -d /usr/nec; then + ac_cv_prog_cc_pic=-Kconform_pic + fi + ;; + *) + ac_cv_prog_cc_pic='-fPIC' + ;; + esac + else + # PORTME Check for PIC flags for the system compiler. + case "$host_os" in + aix3* | aix4*) + # All AIX code is PIC. + ac_cv_prog_cc_static='-bnso -bI:/lib/syscalls.exp' + ;; + + hpux9* | hpux10* | hpux11*) + # Is there a better ac_cv_prog_cc_static that works with the bundled CC? + ac_cv_prog_cc_wl='-Wl,' + ac_cv_prog_cc_static="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive" + ac_cv_prog_cc_pic='+Z' + ;; + + irix5* | irix6*) + ac_cv_prog_cc_wl='-Wl,' + ac_cv_prog_cc_static='-non_shared' + # PIC (with -KPIC) is the default. + ;; + + cygwin* | mingw* | 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). + ac_cv_prog_cc_pic='-DDLL_EXPORT' + ;; + + osf3* | osf4*) + # All OSF/1 code is PIC. + ac_cv_prog_cc_wl='-Wl,' + ac_cv_prog_cc_static='-non_shared' + ;; + + sco3.2v5*) + ac_cv_prog_cc_pic='-Kpic' + ac_cv_prog_cc_static='-dn' + ac_cv_prog_cc_shlib='-belf' + ;; + + solaris*) + ac_cv_prog_cc_pic='-KPIC' + ac_cv_prog_cc_static='-Bstatic' + ac_cv_prog_cc_wl='-Wl,' + ;; + + sunos4*) + ac_cv_prog_cc_pic='-PIC' + ac_cv_prog_cc_static='-Bstatic' + ac_cv_prog_cc_wl='-Qoption ld ' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + ac_cv_prog_cc_pic='-KPIC' + ac_cv_prog_cc_static='-Bstatic' + ac_cv_prog_cc_wl='-Wl,' + ;; + + uts4*) + ac_cv_prog_cc_pic='-pic' + ac_cv_prog_cc_static='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec ;then + ac_cv_prog_cc_pic='-Kconform_pic' + ac_cv_prog_cc_static='-Bstatic' + fi + ;; + + *) + ac_cv_prog_cc_can_build_shared=no + ;; + esac + fi +fi +if test -z "$ac_cv_prog_cc_pic"; then + echo "$ac_t"none 1>&6 +else + echo "$ac_t""$ac_cv_prog_cc_pic" 1>&6 + + # Check to make sure the pic_flag actually works. + echo $ac_n "checking if $compiler PIC flag $ac_cv_prog_cc_pic works... $ac_c" 1>&6 + echo "$progname:942:checking that $compiler PIC flag $ac_cv_prog_cc_pic works." 1>&5 + if test "X${ac_cv_prog_cc_pic_works+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 + else + ac_cv_prog_cc_pic_works=yes + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS $ac_cv_prog_cc_pic -DPIC" + if { (eval echo $progname:951: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then + # Append any warnings to the config.log. + cat conftest.err 1>&5 + + 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 + ac_cv_prog_cc_pic_works=no + ac_cv_prog_cc_can_build_shared=no + ac_cv_prog_cc_pic= + else + ac_cv_prog_cc_pic_works=yes + ac_cv_prog_cc_pic=" $ac_cv_prog_cc_pic" + fi + ;; + *) + ac_cv_prog_cc_pic_works=yes + ac_cv_prog_cc_pic=" $ac_cv_prog_cc_pic" + ;; + esac + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + ac_cv_prog_cc_pic_works=no + ac_cv_prog_cc_can_build_shared=no + ac_cv_prog_cc_pic= + fi + CFLAGS="$save_CFLAGS" + $rm conftest* + fi + # Belt *and* braces to stop my trousers falling down: + if test "X$ac_cv_prog_cc_pic_works" = Xno; then + ac_cv_prog_cc_pic= + ac_cv_prog_cc_can_build_shared=no + fi + echo "$ac_t""$ac_cv_prog_cc_pic_works" 1>&6 +fi + +# Check for any special shared library compilation flags. +if test -n "$ac_cv_prog_cc_shlib"; then + echo "$progname: warning: \`$CC' requires \`$ac_cv_prog_cc_shlib' to build shared libraries" 1>&2 + if echo "$old_CC $old_CFLAGS " | egrep -e "[ ]$ac_cv_prog_cc_shlib[ ]" >/dev/null; then : + else + echo "$progname: add \`$ac_cv_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" 1>&2 + ac_cv_prog_cc_can_build_shared=no + fi +fi + +echo $ac_n "checking if $compiler static flag $ac_cv_prog_cc_static works... $ac_c" 1>&6 +echo "$progname:1003: checking if $compiler static flag $ac_cv_prog_cc_static works" >&5 +if test "X${ac_cv_prog_cc_static_works+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + $rm conftest* + echo 'main(){return(0);}' > conftest.c + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS $ac_cv_prog_cc_static" + if { (eval echo $progname:1011: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + ac_cv_prog_cc_static_works=yes + else + ac_cv_prog_cc_static_works=no + ac_cv_prog_cc_static= + fi + LDFLAGS="$save_LDFLAGS" + $rm conftest* +fi +# Belt *and* braces to stop my trousers falling down: +if test "X$ac_cv_prog_cc_static_works" = Xno; then + ac_cv_prog_cc_static= +fi +echo "$ac_t""$ac_cv_prog_cc_static_works" 1>&6 +pic_flag="$ac_cv_prog_cc_pic" +special_shlib_compile_flags="$ac_cv_prog_cc_shlib" +wl="$ac_cv_prog_cc_wl" +link_static_flag="$ac_cv_prog_cc_static" +no_builtin_flag="$ac_cv_prog_cc_no_builtin" +can_build_shared="$ac_cv_prog_cc_can_build_shared" + +# Check to see if options -o and -c are simultaneously supported by compiler +echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6 +$rm -r conftest 2>/dev/null +mkdir conftest +cd conftest +$rm conftest* +echo "int some_variable = 0;" > conftest.c +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.o" +echo "$progname:1048: checking if $compiler supports -c -o file.o" >&5 +if { (eval echo $progname:1049: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.o; 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 + echo "$ac_t"no 1>&6 + compiler_c_o=no + else + echo "$ac_t"yes 1>&6 + compiler_c_o=yes + fi +else + # Append any errors to the config.log. + cat out/conftest.err 1>&5 + compiler_c_o=no + echo "$ac_t"no 1>&6 +fi +CFLAGS="$save_CFLAGS" +chmod u+w . +$rm conftest* out/* +rmdir out +cd .. +rmdir conftest +$rm -r conftest 2>/dev/null + +if test x"$compiler_c_o" = x"yes"; then + # Check to see if we can write to a .lo + echo $ac_n "checking if $compiler supports -c -o file.lo... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -c -o conftest.lo" + echo "$progname:1081: checking if $compiler supports -c -o file.lo" >&5 +if { (eval echo $progname:1082: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + compiler_o_lo=no + else + echo "$ac_t"yes 1>&6 + compiler_o_lo=yes + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + compiler_o_lo=no + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* +else + compiler_o_lo=no +fi + +# Check to see if we can do hard links to lock some files if needed +hard_links="nottested" +if test "$compiler_c_o" = no && test "$need_locks" != no; then + # do not overwrite the value of need_locks provided by the user + echo $ac_n "checking if we can lock with hard links... $ac_c" 1>&6 + hard_links=yes + $rm conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + echo "$ac_t$hard_links" 1>&6 + $rm conftest* + if test "$hard_links" = no; then + echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2 + need_locks=warn + fi +else + need_locks=no +fi + +if test "$with_gcc" = yes; then + # Check to see if options -fno-rtti -fno-exceptions are supported by compiler + echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions ... $ac_c" 1>&6 + $rm conftest* + echo "int some_variable = 0;" > conftest.c + save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c" + echo "$progname:1133: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 + if { (eval echo $progname:1134: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then + + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + echo "$ac_t"no 1>&6 + compiler_rtti_exceptions=no + else + echo "$ac_t"yes 1>&6 + compiler_rtti_exceptions=yes + fi + else + # Append any errors to the config.log. + cat conftest.err 1>&5 + compiler_rtti_exceptions=no + echo "$ac_t"no 1>&6 + fi + CFLAGS="$save_CFLAGS" + $rm conftest* + + if test "$compiler_rtti_exceptions" = "yes"; then + no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions' + else + no_builtin_flag=' -fno-builtin' + fi + +fi + +# Make sure LD is an absolute path. +if test -z "$LD"; then + ac_prog=ld + if test "$with_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6 + echo "$progname:1168: checking for ld used by GCC" >&5 + 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 are not using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac + elif test "$with_gnu_ld" = yes; then + echo $ac_n "checking for GNU ld... $ac_c" 1>&6 + echo "$progname:1198: checking for GNU ld" >&5 + else + echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 + echo "$progname:1201: checking for non-GNU ld" >&5 + fi + + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + 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 "$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" + fi + + if test -n "$LD"; then + echo "$ac_t$LD" 1>&6 + else + echo "$ac_t"no 1>&6 + fi + + if test -z "$LD"; then + echo "$progname: error: no acceptable ld found in \$PATH" 1>&2 + exit 1 + fi +fi + +# Check to see if it really is or is not GNU ld. +echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6 +# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + with_gnu_ld=yes +else + with_gnu_ld=no +fi +echo "$ac_t$with_gnu_ld" 1>&6 + +# See if the linker supports building shared libraries. +echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6 + +allow_undefined_flag= +no_undefined_flag= +need_lib_prefix=unknown +need_version=unknown +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +archive_cmds= +archive_expsym_cmds= +old_archive_from_new_cmds= +old_archive_from_expsyms_cmds= +striplib= +old_striplib= +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*) + # 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 "$with_gcc" != yes; then + with_gnu_ld=no + fi + ;; + +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*) + # On AIX, the GNU linker is very broken + 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 $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $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 $linker_flags ${wl}-soname $wl$soname -o $lib' + else + ld_shlibs=no + fi + ;; + + cygwin* | mingw*) + # 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 $objdir/impgen.c || \ + sed -e "/^# \/\* impgen\.c starts here \*\//,/^# \/\* impgen.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/impgen.c~ + test -f $objdir/impgen.exe || (cd $objdir && \ + if test "x$HOST_CC" != "x" ; then $HOST_CC -o impgen impgen.c ; \ + else $CC -o impgen impgen.c ; fi)~ + $objdir/impgen $dir/$soname > $objdir/$soname-def' + + old_archive_from_expsyms_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $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="objdir/$soname-ltdll.$objext " + ltdll_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~ + test -f $objdir/$soname-ltdll.$objext || (cd $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. + export_symbols_cmds="$ltdll_cmds"' + $DLLTOOL --export-all --exclude-symbols '$dll_exclude_symbols' --output-def $objdir/$soname-def '$ltdll_obj'$libobjs $convenience~ sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]* ;.*//" < $objdir/$soname-def > $export_symbols' + + archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~ + _lt_hint=1; + cat $export_symbols | while read symbol; do + echo " \$symbol @ \$_lt_hint ; " >> $objdir/$soname-def; + _lt_hint=`expr 1 + \$_lt_hint`; + done~ + '"$ltdll_cmds"' + $CC -Wl,--base-file,$objdir/$soname-base '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $lib '$ltdll_obj'$libobjs $deplibs $compiler_flags~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $lib '$ltdll_obj'$libobjs $deplibs $compiler_flags~ + $DLLTOOL --as=$AS --dllname $soname --exclude-symbols '$dll_exclude_symbols' --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~ + $CC $objdir/$soname-exp '$lt_cv_cc_dll_switch' -Wl,-e,'$dll_entry' -o $lib '$ltdll_obj'$libobjs $deplibs $compiler_flags' + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | grep __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 + archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -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 $linker_flags ${wl}-soname $wl$soname -o $lib' + archive_expsym_cmds='$CC -shared $libobjs $deplibs $linker_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*) + # 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 $objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + hardcode_minus_L=yes + if test "$with_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*) + hardcode_libdir_flag_spec='${wl}-b ${wl}nolibpath ${wl}-b ${wl}libpath:$libdir:/usr/lib:/lib' + hardcode_libdir_separator=':' + if test "$with_gcc" = yes; then + 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 + shared_flag='-shared' + else + shared_flag='${wl}-bM:SRE' + hardcode_direct=yes + fi + allow_undefined_flag=' ${wl}-berok' + archive_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bexpall ${wl}-bnoentry${allow_undefined_flag}' + archive_expsym_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}' + case "$host_os" in aix4.[01]|aix4.[01].*) + # According to Greg Wooledge, -bexpall is only supported from AIX 4.2 on + always_export_symbols=yes ;; + esac + ;; + + amigaos*) + archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $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*) + # 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' + fix_srcfile_path='`cygpath -w $srcfile`' + ;; + + 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 $objdir/$soname~$LD -b +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linker_flags~test $objdir/$soname = $lib || mv $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*) + if test "$with_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}${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 ${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='${wl}-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + openbsd*) + archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-R$libdir' + hardcode_direct=yes + hardcode_shlibpath_var=no + ;; + + os2*) + hardcode_libdir_flag_spec='-L$libdir' + hardcode_minus_L=yes + allow_undefined_flag=unsupported + archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $objdir/$libname.def' + old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def' + ;; + + osf3* | osf4*) + if test "$with_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}${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 ${objdir}/so_locations -o $lib' + fi + hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' + 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 + ;; + + solaris*) + 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='-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 + ;; + + 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 $linkopts' + 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 $linkopts~$rm $lib.exp' + hardcode_libdir_flag_spec= + hardcode_shlibpath_var=no + ;; + + sunos4*) + archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + hardcode_libdir_flag_spec='-L$libdir' + hardcode_direct=yes + hardcode_minus_L=yes + hardcode_shlibpath_var=no + ;; + + sysv4) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + hardcode_direct=no #Motorola manual says yes, but my tests say they lie + ;; + + sysv4.3*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + hardcode_shlibpath_var=no + export_dynamic_flag_spec='-Bexport' + ;; + + sysv5) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs +$linker_flags' + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + hardcode_direct=no + ;; + + 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 -z text -h $soname -o $lib$libobjs$deplibs' + archive_cmds='$LD -G -h $soname -o $lib$libobjs$deplibs' + hardcode_shlibpath_var=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + ld_shlibs=yes + fi + ;; + + unixware7* | sysv5*) + archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + runpath_var='LD_RUN_PATH' + hardcode_shlibpath_var=no + ;; + + *) + ld_shlibs=no + ;; + esac +fi +echo "$ac_t$ld_shlibs" 1>&6 +test "$ld_shlibs" = no && can_build_shared=no + +# Check hardcoding attributes. +echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6 +hardcode_action= +if test -n "$hardcode_libdir_flag_spec" || \ + test -n "$runpath_var"; then + + # We can hardcode non-existant directories. + if test "$hardcode_direct" != no && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test "$hardcode_shlibpath_var" != no && + test "$hardcode_minus_L" != no; then + # Linking always hardcodes the temporary library directory. + hardcode_action=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + hardcode_action=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + hardcode_action=unsupported +fi +echo "$ac_t$hardcode_action" 1>&6 + +echo $ac_n "checking whether stripping libraries is possible... $ac_c" 1>&6 +if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + echo "${ac_t}yes" 1>&6 +else + echo "${ac_t}no" 1>&6 +fi + +reload_flag= +reload_cmds='$LD$reload_flag -o $output$reload_objs' +echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6 +# PORTME Some linkers may need a different reload flag. +reload_flag='-r' +echo "$ac_t$reload_flag" 1>&6 +test -n "$reload_flag" && reload_flag=" $reload_flag" + +# PORTME Fill in your ld.so 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" +file_magic_cmd= +file_magic_test_file= +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. +echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6 +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*) + version_type=linux + # AIX 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. + # We preserve .a as extension for shared libraries though AIX4.2 + # and later linker supports .so + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.a' + shlibpath_var=LIBPATH + deplibs_check_method=pass_all + ;; + +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 + deplibs_check_method=pass_all + lt_cv_dlopen="load_add_on" + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + +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 + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/shlib/libc.so + 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*) + version_type=windows + need_version=no + need_lib_prefix=no + if test "$with_gcc" = yes; then + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll' + else + library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib' + fi + dynamic_linker='Win32 ld.exe' + deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?' + file_magic_cmd='${OBJDUMP} -f' + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + lt_cv_dlopen="LoadLibrary" + lt_cv_dlopen_libs= + ;; + +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*) + deplibs_check_method=pass_all + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + deplibs_check_method=unknown + 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 + ;; + freebsd3.[01]* | freebsdelf3.[01]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + *) # from 3.2 on + 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 + deplibs_check_method=pass_all + ;; + +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*) + version_type=irix + 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*) + libsuff= shlibsuff= + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1" + ;; + *) + 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 + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method="file_magic ELF ${libmagic} MSB mips-[1234] dynamic lib MIPS - version 1" + ;; + 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}" + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /lib${libsuff}/libc.so*` + deplibs_check_method='pass_all' + ;; + +# 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 + + case "$host_cpu" in + alpha* | i*86 | sparc* ) + deplibs_check_method=pass_all ;; + *) + # glibc up to 2.1.1 does not perform some relocations on ARM + deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; + esac + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /lib/libc.so* /lib/libc-*.so` + + if test -f /lib/ld.so.1; then + dynamic_linker='GNU ld.so' + else + # Only the GNU ld.so supports shared libraries on MkLinux. + case "$host_cpu" in + powerpc*) dynamic_linker=no ;; + *) dynamic_linker='Linux ld.so' ;; + esac + fi + ;; + +netbsd*) + version_type=sunos + 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 + ;; + +openbsd*) + version_type=sunos + if test "$with_gnu_ld" = yes; then + need_lib_prefix=no + need_version=no + 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*) + version_type=osf + need_version=no + soname_spec='${libname}${release}.so' + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so' + shlibpath_var=LD_LIBRARY_PATH + # this will be overridden with pass_all, but let us keep it just in case + deplibs_check_method='file_magic COFF format alpha shared library' + file_magic_cmd=/usr/bin/file + file_magic_test_file=/shlib/libc.so + deplibs_check_method='pass_all' + 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 + deplibs_check_method=pass_all + ;; + +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 + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + deplibs_check_method=pass_all + file_magic_cmd=/usr/bin/file + file_magic_test_file=/lib/libc.so + ;; + +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 + ncr) + deplibs_check_method='pass_all' + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + 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]' + file_magic_cmd=/usr/bin/file + file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + esac + ;; + +uts4*) + version_type=linux + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +dgux*) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so' + soname_spec='${libname}${release}.so$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +sysv4*MP*) + if test -d /usr/nec ;then + version_type=linux + library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so' + soname_spec='$libname.so.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +*) + dynamic_linker=no + ;; +esac +echo "$ac_t$dynamic_linker" 1>&6 +test "$dynamic_linker" = no && can_build_shared=no + +# Check for command to grab the raw symbol name followed by C symbol from nm. +echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6 + +# 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 +global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'" + +# Define system-specific variables. +case "$host_os" in +aix*) + symcode='[BCDT]' + ;; +cygwin* | mingw*) + symcode='[ABCDGISTW]' + ;; +hpux*) # Its linker distinguishes data from code symbols + global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'" + ;; +irix*) + symcode='[BCDEGRST]' + ;; +solaris* | sysv5*) + symcode='[BDT]' + ;; +sysv4) + symcode='[DFNSTU]' + ;; +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. + global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode\)[ ][ ]*\($ac_symprfx\)$sympat$/$symxfrm/p'" + + # Check to see that the pipe works correctly. + pipe_works=no + $rm conftest* + cat > conftest.c <&5 + if { (eval echo $progname:2225: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then + # Now try to grab the symbols. + nlist=conftest.nm + if { echo "$progname:2228: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && 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.c +#ifdef __cplusplus +extern "C" { +#endif + +EOF + # Now generate the symbol file. + eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c' + + cat <> conftest.c +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{ +EOF + sed 's/^. \(.*\) \(.*\)$/ {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c + cat <<\EOF >> conftest.c + {0, (lt_ptr_t) 0} +}; + +#ifdef __cplusplus +} +#endif +EOF + # Now try linking the two files. + mv conftest.$objext conftstm.$objext + save_LIBS="$LIBS" + save_CFLAGS="$CFLAGS" + LIBS="conftstm.$objext" + CFLAGS="$CFLAGS$no_builtin_flag" + if { (eval echo $progname:2280: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then + pipe_works=yes + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + LIBS="$save_LIBS" + else + echo "cannot find nm_test_func in $nlist" >&5 + fi + else + echo "cannot find nm_test_var in $nlist" >&5 + fi + else + echo "cannot run $global_symbol_pipe" >&5 + fi + else + echo "$progname: failed program was:" >&5 + cat conftest.c >&5 + fi + $rm conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test "$pipe_works" = yes; then + break + else + global_symbol_pipe= + fi +done +if test "$pipe_works" = yes; then + echo "${ac_t}ok" 1>&6 +else + echo "${ac_t}failed" 1>&6 +fi + +if test -z "$global_symbol_pipe"; then + global_symbol_to_cdecl= +fi + +# Report the final consequences. +echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6 + +# Only try to build win32 dlls if AC_LIBTOOL_WIN32_DLL was used in +# configure.in, otherwise build static only libraries. +case "$host_os" in +cygwin* | mingw* | os2*) + if test x$can_build_shared = xyes; then + test x$enable_win32_dll = xno && can_build_shared=no + echo "checking if package supports dlls... $can_build_shared" 1>&6 + fi +;; +esac + +if test -n "$file_magic_test_file" && test -n "$file_magic_cmd"; then + case "$deplibs_check_method" in + "file_magic "*) + file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`" + 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 + +echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6 +test "$can_build_shared" = "no" && enable_shared=no + +# On AIX, shared libraries and static libraries use the same namespace, and +# are all built from PIC. +case "$host_os" in +aix3*) + test "$enable_shared" = yes && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + +aix4*) + test "$enable_shared" = yes && enable_static=no + ;; +esac + +echo "$ac_t$enable_shared" 1>&6 + +# Make sure either enable_shared or enable_static is yes. +test "$enable_shared" = yes || enable_static=yes + +echo "checking whether to build static libraries... $enable_static" 1>&6 + +if test "$hardcode_action" = relink || test "$hardcode_into_libs" = yes; 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 + +# Check whether we must set pic_mode to default +test -z "$pic_flag" && pic_mode=default +# On Cygwin there's no "real" PIC flag so we must build both object types +case "$host_os" in +cygwin* | mingw* | os2*) + pic_mode=default + ;; +esac +if test $pic_mode = no && test "$deplibs_check_method" != pass_all; then + # non-PIC code in shared libraries is not supported + pic_mode=default +fi + +if test "x$enable_dlopen" != xyes; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else +if test "X${lt_cv_dlopen+set}" != Xset; then + lt_cv_dlopen=no lt_cv_dlopen_libs= +echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 +echo "$progname:2413: checking for dlopen in -ldl" >&5 +if test "X${ac_cv_lib_dl_dlopen+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldl $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_lib_dl_dlopen=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_lib_dl_dlopen=no +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if test "X$ac_cv_lib_dl_dlopen" = Xyes; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dlopen""... $ac_c" 1>&6 +echo "$progname:2449: checking for dlopen" >&5 +if test "X${ac_cv_func_dlopen+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char dlopen(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_dlopen) || defined (__stub___dlopen) +choke me +#else +dlopen(); +#endif + +; return 0; } +EOF +if { (eval echo $progname:2476: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_func_dlopen=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_func_dlopen=no +fi +rm -f conftest* +fi +if test "X$ac_cv_func_dlopen" = Xyes; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dlopen" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6 +echo "$progname:2493: checking for dld_link in -ldld" >&5 +if test "X${ac_cv_lib_dld_dld_link+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_lib_dld_dld_link=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_lib_dld_dld_link=no +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if test "X$ac_cv_lib_dld_dld_link" = Xyes; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load""... $ac_c" 1>&6 +echo "$progname:2529: checking for shl_load" >&5 +if test "X${ac_cv_func_shl_load+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char shl_load(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_shl_load) || defined (__stub___shl_load) +choke me +#else +shl_load(); +#endif + +; return 0; } +EOF +if { (eval echo $progname:2556: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_func_shl_load=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_func_shl_load=no +fi +rm -f conftest* +fi + +if test "X$ac_cv_func_shl_load" = Xyes; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" +else + echo "$ac_t""no" 1>&6 +echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6 +echo "$progname:2574: checking for shl_load in -ldld" >&5 +if test "X${ac_cv_lib_dld_shl_load+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + ac_save_LIBS="$LIBS" +LIBS="-ldld $LIBS" +cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_lib_dld_shl_load=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_lib_dld_shl_load=no +fi +rm -f conftest* +LIBS="$ac_save_LIBS" + +fi +if test "X$ac_cv_lib_dld_shl_load" = Xyes; then + echo "$ac_t""yes" 1>&6 + lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" +else + echo "$ac_t""no" 1>&6 +fi + + +fi + + +fi + + +fi + + +fi + +fi + + if test "x$lt_cv_dlopen" != xno; then + enable_dlopen=yes + fi + + case "$lt_cv_dlopen" in + dlopen) +for ac_hdr in dlfcn.h; do +ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` +echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 +echo "$progname:2635: checking for $ac_hdr" >&5 +if eval "test \"`echo 'X$''{'ac_cv_header_$ac_safe'+set}'`\" = Xset"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int fnord = 0; +EOF +ac_try="$ac_compile conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo $progname:2645: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + rm -rf conftest* + eval "ac_cv_header_$ac_safe=yes" +else + echo "$ac_err" >&5 + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_header_$ac_safe=no" +fi +rm -f conftest* +fi +if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then + echo "$ac_t""yes" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi +done + + if test "x$ac_cv_header_dlfcn_h" = xyes; then + CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + fi + eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + LIBS="$lt_cv_dlopen_libs $LIBS" + + echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6 +echo "$progname:2673: checking whether a program can dlopen itself" >&5 +if test "X${lt_cv_dlopen_self+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + lt_cv_dlopen_self=cross + else + cat > conftest.c < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LTDL_GLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LTDL_GLOBAL DL_GLOBAL +# else +# define LTDL_GLOBAL 0 +# endif +#endif + +/* We may have to define LTDL_LAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LTDL_LAZY_OR_NOW +# ifdef RTLD_LAZY +# define LTDL_LAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LTDL_LAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LTDL_LAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LTDL_LAZY_OR_NOW DL_NOW +# else +# define LTDL_LAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +fnord() { int i=42;} +main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); + if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); + if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } + +EOF +if { (eval echo $progname:2727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + lt_cv_dlopen_self=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + lt_cv_dlopen_self=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$lt_cv_dlopen_self" 1>&6 + + if test "$lt_cv_dlopen_self" = yes; then + LDFLAGS="$LDFLAGS $link_static_flag" + echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6 +echo "$progname:2746: checking whether a statically linked program can dlopen itself" >&5 +if test "X${lt_cv_dlopen_self_static+set}" = Xset; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + lt_cv_dlopen_self_static=cross + else + cat > conftest.c < +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LTDL_GLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LTDL_GLOBAL DL_GLOBAL +# else +# define LTDL_GLOBAL 0 +# endif +#endif + +/* We may have to define LTDL_LAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LTDL_LAZY_OR_NOW +# ifdef RTLD_LAZY +# define LTDL_LAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LTDL_LAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LTDL_LAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LTDL_LAZY_OR_NOW DL_NOW +# else +# define LTDL_LAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +fnord() { int i=42;} +main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW); + if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord"); + if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } + +EOF +if { (eval echo $progname:2800: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null +then + lt_cv_dlopen_self_static=yes +else + echo "$progname: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + lt_cv_dlopen_self_static=no +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6 +fi + ;; + 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 + +# Copy echo and quote the copy, instead of the original, because it is +# used later. +ltecho="$echo" +if test "X$ltecho" = "X$CONFIG_SHELL $0 --fallback-echo"; then + ltecho="$CONFIG_SHELL \$0 --fallback-echo" +fi +LTSHELL="$SHELL" + +LTCONFIG_VERSION="$VERSION" + +# Only quote variables if we're using ltmain.sh. +case "$ltmain" in +*.sh) + # Now quote all the things that may contain metacharacters. + for var in ltecho old_CC old_CFLAGS old_CPPFLAGS \ + old_LD old_LDFLAGS old_LIBS \ + old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS \ + AR CC LD LN_S NM LTSHELL LTCONFIG_VERSION \ + 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 \ + 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 "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\"" + ;; + *) + eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\"" + ;; + esac + done + + case "$ltecho" in + *'\$0 --fallback-echo"') + ltecho=`$echo "X$ltecho" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'` + ;; + esac + + trap "$rm \"$ofile\"; exit 1" 1 2 15 + echo "creating $ofile" + $rm "$ofile" + cat < "$ofile" +#! $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 ltconfig or ltmain.sh. +# +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# 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 +EOF + cfgfile="$ofile" + ;; + +*) + # Double-quote the variables that need it (for aesthetics). + for var in old_CC old_CFLAGS old_CPPFLAGS \ + old_LD old_LDFLAGS old_LIBS \ + old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS; do + eval "$var=\\\"\$var\\\"" + done + + # Just create a config file. + cfgfile="$ofile.cfg" + trap "$rm \"$cfgfile\"; exit 1" 1 2 15 + echo "creating $cfgfile" + $rm "$cfgfile" + cat < "$cfgfile" +# `$echo "$cfgfile" | sed 's%^.*/%%'` - Libtool configuration file. +# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP) +EOF + ;; +esac + +cat <> "$cfgfile" +# Libtool was configured as follows, on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# +# CC=$old_CC CFLAGS=$old_CFLAGS CPPFLAGS=$old_CPPFLAGS \\ +# LD=$old_LD LDFLAGS=$old_LDFLAGS LIBS=$old_LIBS \\ +# NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\ +# DLLTOOL=$old_DLLTOOL OBJDUMP=$old_OBJDUMP AS=$old_AS \\ +# $0$ltconfig_args +# +# Compiler and other test output produced by $progname, useful for +# debugging $progname, is in ./config.log if it exists. + +# The version of $progname that generated this script. +LTCONFIG_VERSION=$LTCONFIG_VERSION + +# Shell to use when invoking shell scripts. +SHELL=$LTSHELL + +# 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 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=$ltecho + +# The archiver. +AR=$AR + +# The default C compiler. +CC=$CC + +# The linker used to build libraries. +LD=$LD + +# Whether we need hard or soft links. +LN_S=$LN_S + +# A BSD-compatible nm program. +NM=$NM + +# 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=$reload_flag +reload_cmds=$reload_cmds + +# How to pass a linker flag through the compiler. +wl=$wl + +# Object file suffix (normally "o"). +objext="$objext" + +# Old archive suffix (normally "a"). +libext="$libext" + +# Executable file suffix (normally ""). +exeext="$exeext" + +# Additional compiler flags for building library objects. +pic_flag=$pic_flag +pic_mode=$pic_mode + +# Does compiler simultaneously support -c and -o options? +compiler_c_o=$compiler_c_o + +# Can we write directly to a .lo ? +compiler_o_lo=$compiler_o_lo + +# Must we lock files when doing compilation ? +need_locks=$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=$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=$link_static_flag + +# Compiler flag to turn off builtin functions. +no_builtin_flag=$no_builtin_flag + +# Compiler flag to allow reflexive dlopens. +export_dynamic_flag_spec=$export_dynamic_flag_spec + +# Compiler flag to generate shared objects directly from archives. +whole_archive_flag_spec=$whole_archive_flag_spec + +# Compiler flag to generate thread-safe objects. +thread_safe_flag_spec=$thread_safe_flag_spec + +# Library versioning type. +version_type=$version_type + +# Format of library name prefix. +libname_spec=$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=$library_names_spec + +# The coded name of the library, if different from the real name. +soname_spec=$soname_spec + +# Commands used to build and install an old-style archive. +RANLIB=$RANLIB +old_archive_cmds=$old_archive_cmds +old_postinstall_cmds=$old_postinstall_cmds +old_postuninstall_cmds=$old_postuninstall_cmds + +# Create an old-style archive from a shared archive. +old_archive_from_new_cmds=$old_archive_from_new_cmds + +# Create a temporary old-style archive to link instead of a shared archive. +old_archive_from_expsyms_cmds=$old_archive_from_expsyms_cmds + +# Commands used to build and install a shared archive. +archive_cmds=$archive_cmds +archive_expsym_cmds=$archive_expsym_cmds +postinstall_cmds=$postinstall_cmds +postuninstall_cmds=$postuninstall_cmds + +# Commands to strip libraries. +old_striplib=$old_striplib +striplib=$striplib + +# Method to check whether dependent libraries are shared objects. +deplibs_check_method=$deplibs_check_method + +# Command to use when deplibs_check_method == file_magic. +file_magic_cmd=$file_magic_cmd + +# Flag that allows shared libraries with undefined symbols to be built. +allow_undefined_flag=$allow_undefined_flag + +# Flag that forces no undefined symbols. +no_undefined_flag=$no_undefined_flag + +# Commands used to finish a libtool library installation in a directory. +finish_cmds=$finish_cmds + +# Same as above, but a single script fragment to be evaled but not shown. +finish_eval=$finish_eval + +# Take the output of nm and produce a listing of raw symbols and C names. +global_symbol_pipe=$global_symbol_pipe + +# Transform the output of nm in a proper C declaration +global_symbol_to_cdecl=$global_symbol_to_cdecl + +# 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=$hardcode_libdir_flag_spec + +# Whether we need a single -rpath flag with a separated argument. +hardcode_libdir_separator=$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 + +# 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=$sys_lib_search_path_spec + +# Run-time system search path for libraries +sys_lib_dlsearch_path_spec=$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=$export_symbols_cmds + +# The commands to extract the exported symbol list from a shared archive. +extract_expsyms_cmds=$extract_expsyms_cmds + +# Symbols that should not be listed in the preloaded symbols. +exclude_expsyms=$exclude_expsyms + +# Symbols that must always be exported. +include_expsyms=$include_expsyms + +EOF + +case "$ltmain" in +*.sh) + echo '### END LIBTOOL CONFIG' >> "$ofile" + echo >> "$ofile" + case "$host_os" in + aix3*) + cat <<\EOF >> "$ofile" + +# 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" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + cat <<'EOF' >> "$ofile" + # 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 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) +# 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" || (rm -f "$ofile"; exit 1) + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + + chmod +x "$ofile" + ;; + +*) + # Compile the libtool program. + echo "FIXME: would compile $ltmain" + ;; +esac + +test -n "$cache_file" || exit 0 + +# AC_CACHE_SAVE +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/ltmain.sh b/ltmain.sh new file mode 100644 index 00000000..1b97f6cb --- /dev/null +++ b/ltmain.sh @@ -0,0 +1,4812 @@ +# ltmain.sh - Provide generalized library-building support services. +# NOTE: Changing this file will not affect anything until you rerun ltconfig. +# +# Copyright (C) 1996-1999 Free Software Foundation, Inc. +# Originally by Gordon Matzigkeit , 1996 +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Check that we have a working $echo. +if test "X$1" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift +elif test "X$1" = X--fallback-echo; then + # Avoid inline document here, it may be left over + : +elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then + # Yippee, $echo works! + : +else + # Restart under the correct shell, and then maybe $echo will work. + exec $SHELL "$0" --no-reexec ${1+"$@"} +fi + +if test "X$1" = X--fallback-echo; then + # used as fallback echo + shift + cat <&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then + echo "$modename: not configured to build any kind of library" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 +fi + +# Global variables. +mode=$default_mode +nonopt= +prev= +prevopt= +run= +show="$echo" +show_help= +execute_dlfiles= +lo2o="s/\\.lo\$/.${objext}/" +o2lo="s/\\.${objext}\$/.lo/" + +# Parse our command line options once, thoroughly. +while test $# -gt 0 +do + arg="$1" + shift + + case "$arg" in + -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + execute_dlfiles) + eval "$prev=\"\$$prev \$arg\"" + ;; + *) + eval "$prev=\$arg" + ;; + esac + + prev= + prevopt= + continue + fi + + # Have we seen a non-optional argument yet? + case "$arg" in + --help) + show_help=yes + ;; + + --version) + echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP" + exit 0 + ;; + + --config) + sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0 + exit 0 + ;; + + --debug) + echo "$progname: enabling shell trace mode" + set -x + ;; + + --dry-run | -n) + run=: + ;; + + --features) + echo "host: $host" + if test "$build_libtool_libs" = yes; then + echo "enable shared libraries" + else + echo "disable shared libraries" + fi + if test "$build_old_libs" = yes; then + echo "enable static libraries" + else + echo "disable static libraries" + fi + exit 0 + ;; + + --finish) mode="finish" ;; + + --mode) prevopt="--mode" prev=mode ;; + --mode=*) mode="$optarg" ;; + + --quiet | --silent) + show=: + ;; + + -dlopen) + prevopt="-dlopen" + prev=execute_dlfiles + ;; + + -*) + $echo "$modename: unrecognized option \`$arg'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + + *) + nonopt="$arg" + break + ;; + esac +done + +if test -n "$prevopt"; then + $echo "$modename: option \`$prevopt' requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 +fi + +if test -z "$show_help"; then + + # Infer the operation mode. + if test -z "$mode"; then + case "$nonopt" in + *cc | *++ | gcc* | *-gcc*) + mode=link + for arg + do + case "$arg" in + -c) + mode=compile + break + ;; + esac + done + ;; + *db | *dbx | *strace | *truss) + mode=execute + ;; + *install*|cp|mv) + mode=install + ;; + *rm) + mode=uninstall + ;; + *) + # If we have no mode, but dlfiles were specified, then do execute mode. + test -n "$execute_dlfiles" && mode=execute + + # Just use the default operation mode. + if test -z "$mode"; then + if test -n "$nonopt"; then + $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2 + else + $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2 + fi + fi + ;; + esac + fi + + # Only execute mode is allowed to have -dlopen flags. + if test -n "$execute_dlfiles" && test "$mode" != execute; then + $echo "$modename: unrecognized option \`-dlopen'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Change the help message to a mode-specific one. + generic_help="$help" + help="Try \`$modename --help --mode=$mode' for more information." + + # These modes are in order of execution frequency so that they run quickly. + case "$mode" in + # libtool compile mode + compile) + modename="$modename: compile" + # Get the compilation command and the source file. + base_compile= + lastarg= + srcfile="$nonopt" + suppress_output= + + user_target=no + for arg + do + # Accept any command-line options. + case "$arg" in + -o) + if test "$user_target" != "no"; then + $echo "$modename: you cannot specify \`-o' more than once" 1>&2 + exit 1 + fi + user_target=next + ;; + + -static) + build_old_libs=yes + continue + ;; + esac + + case "$user_target" in + next) + # The next one is the -o target name + user_target=yes + continue + ;; + yes) + # We got the output file + user_target=set + libobj="$arg" + continue + ;; + esac + + # Accept the current argument as the source file. + lastarg="$srcfile" + srcfile="$arg" + + # Aesthetically quote the previous argument. + + # Backslashify any backslashes, double quotes, and dollar signs. + # These are the only characters that are still specially + # interpreted inside of double-quoted scrings. + lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"` + + # Double-quote args containing other shell metacharacters. + # Many Bourne shells cannot handle close brackets correctly in scan + # sets, so we specify it separately. + case "$lastarg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + lastarg="\"$lastarg\"" + ;; + esac + + # Add the previous argument to base_compile. + if test -z "$base_compile"; then + base_compile="$lastarg" + else + base_compile="$base_compile $lastarg" + fi + done + + case "$user_target" in + set) + ;; + no) + # Get the name of the library object. + libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'` + ;; + *) + $echo "$modename: you must specify a target with \`-o'" 1>&2 + exit 1 + ;; + esac + + # Recognize several different file suffixes. + # If the user specifies -o file.o, it is replaced with file.lo + xform='[cCFSfmso]' + case "$libobj" in + *.ada) xform=ada ;; + *.adb) xform=adb ;; + *.ads) xform=ads ;; + *.asm) xform=asm ;; + *.c++) xform=c++ ;; + *.cc) xform=cc ;; + *.cpp) xform=cpp ;; + *.cxx) xform=cxx ;; + *.f90) xform=f90 ;; + *.for) xform=for ;; + esac + + libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"` + + case "$libobj" in + *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;; + *) + $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2 + exit 1 + ;; + esac + + if test -z "$base_compile"; then + $echo "$modename: you must specify a compilation command" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Delete any leftover library objects. + if test "$build_old_libs" = yes; then + removelist="$obj $libobj" + else + removelist="$libobj" + fi + + $run $rm $removelist + trap "$run $rm $removelist; exit 1" 1 2 15 + + # Calculate the filename of the output object if compiler does + # not support -o with -c + if test "$compiler_c_o" = no; then + output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext} + lockfile="$output_obj.lock" + removelist="$removelist $output_obj $lockfile" + trap "$run $rm $removelist; exit 1" 1 2 15 + else + need_locks=no + lockfile= + fi + + # Lock this critical section if it is needed + # We use this script file to make the link, it avoids creating a new file + if test "$need_locks" = yes; then + until ln "$0" "$lockfile" 2>/dev/null; do + $show "Waiting for $lockfile to be removed" + sleep 2 + done + elif test "$need_locks" = warn; then + if test -f "$lockfile"; then + echo "\ +*** ERROR, $lockfile exists and contains: +`cat $lockfile 2>/dev/null` + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + echo $srcfile > "$lockfile" + fi + + if test -n "$fix_srcfile_path"; then + eval srcfile=\"$fix_srcfile_path\" + fi + + # Only build a PIC object if we are building libtool libraries. + if test "$build_libtool_libs" = yes; then + # Without this assignment, base_compile gets emptied. + fbsd_hideous_sh_bug=$base_compile + + if test "$pic_mode" != no; then + # All platforms use -DPIC, to notify preprocessed assembler code. + command="$base_compile $pic_flag -DPIC $srcfile" + else + # Don't build PIC code + command="$base_compile $srcfile" + fi + if test "$build_old_libs" = yes; then + lo_libobj="$libobj" + dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$libobj"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` + + if test -d "$dir"; then + $show "$rm $libobj" + $run $rm $libobj + else + $show "$mkdir $dir" + $run $mkdir $dir + status=$? + if test $status -ne 0 && test ! -d $dir; then + exit $status + fi + fi + fi + if test "$compiler_o_lo" = yes; then + output_obj="$libobj" + command="$command -o $output_obj" + elif test "$compiler_c_o" = yes; then + output_obj="$obj" + command="$command -o $output_obj" + fi + + $run $rm "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + test -n "$output_obj" && $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then + echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed, then go on to compile the next one + if test x"$output_obj" != x"$libobj"; then + $show "$mv $output_obj $libobj" + if $run $mv $output_obj $libobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # If we have no pic_flag, then copy the object into place and finish. + if (test -z "$pic_flag" || test "$pic_mode" != default) && + test "$build_old_libs" = yes; then + # Rename the .lo from within objdir to obj + if test -f $obj; then + $show $rm $obj + $run $rm $obj + fi + + $show "$mv $libobj $obj" + if $run $mv $libobj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"` + libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + # Now arrange that obj and lo_libobj become the same file + $show "(cd $xdir && $LN_S $baseobj $libobj)" + if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then + exit 0 + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Allow error messages only from the first compilation. + suppress_output=' >/dev/null 2>&1' + fi + + # Only build a position-dependent object if we build old libraries. + if test "$build_old_libs" = yes; then + if test "$pic_mode" != yes; then + # Don't build PIC code + command="$base_compile $srcfile" + else + # All platforms use -DPIC, to notify preprocessed assembler code. + command="$base_compile $pic_flag -DPIC $srcfile" + fi + if test "$compiler_c_o" = yes; then + command="$command -o $obj" + output_obj="$obj" + fi + + # Suppress compiler output if we already did a PIC compilation. + command="$command$suppress_output" + $run $rm "$output_obj" + $show "$command" + if $run eval "$command"; then : + else + $run $rm $removelist + exit 1 + fi + + if test "$need_locks" = warn && + test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then + echo "\ +*** ERROR, $lockfile contains: +`cat $lockfile 2>/dev/null` + +but it should contain: +$srcfile + +This indicates that another process is trying to use the same +temporary object file, and libtool could not work around it because +your compiler does not support \`-c' and \`-o' together. If you +repeat this compilation, it may succeed, by chance, but you had better +avoid parallel builds (make -j) in this platform, or get a better +compiler." + + $run $rm $removelist + exit 1 + fi + + # Just move the object if needed + if test x"$output_obj" != x"$obj"; then + $show "$mv $output_obj $obj" + if $run $mv $output_obj $obj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + + # Create an invalid libtool object if no PIC, so that we do not + # accidentally link it into a program. + if test "$build_libtool_libs" != yes; then + $show "echo timestamp > $libobj" + $run eval "echo timestamp > \$libobj" || exit $? + else + # Move the .lo from within objdir + $show "$mv $libobj $lo_libobj" + if $run $mv $libobj $lo_libobj; then : + else + error=$? + $run $rm $removelist + exit $error + fi + fi + fi + + # Unlock the critical section if it was locked + if test "$need_locks" != no; then + $rm "$lockfile" + fi + + exit 0 + ;; + + # libtool link mode + link | relink) + modename="$modename: link" + relink=no + test "$mode" = "relink" && relink=yes + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + # It is impossible to link a dll without this setting, and + # we shouldn't force the makefile maintainer to figure out + # which system we are compiling for in order to pass an extra + # flag for every libtool invokation. + # allow_undefined=no + + # FIXME: Unfortunately, there are problems with the above when trying + # to make a dll which has undefined symbols, in which case not + # even a static library is built. For now, we need to specify + # -no-undefined on the libtool link line when we can be certain + # that all symbols are satisfied, otherwise we get a static library. + allow_undefined=yes + ;; + *) + allow_undefined=yes + ;; + esac + libtool_args="$nonopt" + compile_command="$nonopt" + finalize_command="$nonopt" + + compile_rpath= + finalize_rpath= + compile_shlibpath= + finalize_shlibpath= + convenience= + old_convenience= + deplibs= + old_deplibs= + compiler_flags= + linker_flags= + dllsearchpath= + lib_search_path=`pwd` + + avoid_version=no + dlfiles= + dlprefiles= + dlself=no + export_dynamic=no + export_symbols= + export_symbols_regex= + generated= + libobjs= + ltlibs= + module=no + objs= + prefer_static_libs=no + preload=no + prev= + prevarg= + release= + rpath= + xrpath= + perm_rpath= + temp_rpath= + thread_safe=no + vinfo= + + # We need to know -static, to get the right output filenames. + for arg + do + case "$arg" in + -all-static | -static) + if test "X$arg" = "X-all-static"; then + if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then + $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2 + fi + if test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + else + if test -z "$pic_flag" && test -n "$link_static_flag"; then + dlopen_self=$dlopen_self_static + fi + fi + build_libtool_libs=no + build_old_libs=yes + prefer_static_libs=yes + break + ;; + esac + done + + # See if our shared archives depend on static archives. + test -n "$old_archive_from_new_cmds" && build_old_libs=yes + + # Go through the arguments, transforming them on the way. + while test $# -gt 0; do + arg="$1" + shift + libtool_args="$libtool_args $arg" + + # If the previous option needs an argument, assign it. + if test -n "$prev"; then + case "$prev" in + output) + compile_command="$compile_command @OUTPUT@" + finalize_command="$finalize_command @OUTPUT@" + ;; + esac + + case "$prev" in + dlfiles|dlprefiles) + if test "$preload" = no; then + # Add the symbol object into the linking commands. + compile_command="$compile_command @SYMFILE@" + finalize_command="$finalize_command @SYMFILE@" + preload=yes + fi + case "$arg" in + *.la | *.lo) ;; # We handle these cases below. + force) + if test "$dlself" = no; then + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + self) + if test "$prev" = dlprefiles; then + dlself=yes + elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then + dlself=yes + else + dlself=needless + export_dynamic=yes + fi + prev= + continue + ;; + *) + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + else + dlprefiles="$dlprefiles $arg" + fi + prev= + ;; + esac + ;; + expsyms) + export_symbols="$arg" + if test ! -f "$arg"; then + $echo "$modename: symbol file \`$arg' does not exist" + exit 1 + fi + prev= + continue + ;; + expsyms_regex) + export_symbols_regex="$arg" + prev= + continue + ;; + release) + release="-$arg" + prev= + continue + ;; + rpath | xrpath) + # We need an absolute path. + case "$arg" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + if test "$prev" = rpath; then + case "$rpath " in + *" $arg "*) ;; + *) rpath="$rpath $arg" ;; + esac + else + case "$xrpath " in + *" $arg "*) ;; + *) xrpath="$xrpath $arg" ;; + esac + fi + prev= + continue + ;; + xcompiler) + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + compiler_flags="$compiler_flags $arg" + prev= + continue + ;; + xlinker) + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + linker_flags="$linker_flags $arg" + compiler_flags="$compiler_flags $wl$arg" + prev= + continue + ;; + *) + eval "$prev=\"\$arg\"" + prev= + continue + ;; + esac + fi + + prevarg="$arg" + + case "$arg" in + -all-static) + if test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -allow-undefined) + # FIXME: remove this flag sometime in the future. + $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2 + continue + ;; + + -avoid-version) + avoid_version=yes + continue + ;; + + -dlopen) + prev=dlfiles + continue + ;; + + -dlpreopen) + prev=dlprefiles + continue + ;; + + -export-dynamic) + export_dynamic=yes + continue + ;; + + -export-symbols | -export-symbols-regex) + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: not more than one -exported-symbols argument allowed" + exit 1 + fi + if test "X$arg" = "X-export-symbols"; then + prev=expsyms + else + prev=expsyms_regex + fi + continue + ;; + + -L*) + dir=`$echo "X$arg" | $Xsed -e 's/^-L//'` + # We need an absolute path. + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2 + exit 1 + fi + dir="$absdir" + ;; + esac + case "$deplibs " in + *" -L$dir "*) ;; + *) + deplibs="$deplibs -L$dir" + lib_search_path="$lib_search_path $dir" + ;; + esac + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + case ":$dllsearchpath:" in + *":$dir:"*) ;; + *) dllsearchpath="$dllsearchpath:$dir";; + esac + ;; + esac + continue + ;; + + -l*) + if test "$arg" = "-lc"; then + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) + # These systems don't actually have c library (as such) + continue + ;; + esac + elif test "$arg" = "-lm"; then + case "$host" in + *-*-cygwin* | *-*-beos*) + # These systems don't actually have math library (as such) + continue + ;; + esac + fi + deplibs="$deplibs $arg" + continue + ;; + + -module) + module=yes + continue + ;; + + -no-fast-install) + fast_install=no + continue + ;; + + -no-undefined) + allow_undefined=no + continue + ;; + + -o) prev=output ;; + + -release) + prev=release + continue + ;; + + -rpath) + prev=rpath + continue + ;; + + -R) + prev=xrpath + continue + ;; + + -R*) + dir=`$echo "X$arg" | $Xsed -e 's/^-R//'` + # We need an absolute path. + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + $echo "$modename: only absolute run-paths are allowed" 1>&2 + exit 1 + ;; + esac + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + + -static) + # If we have no pic_flag, then this is the same as -all-static. + if test -z "$pic_flag" && test -n "$link_static_flag"; then + compile_command="$compile_command $link_static_flag" + finalize_command="$finalize_command $link_static_flag" + fi + continue + ;; + + -thread-safe) + thread_safe=yes + continue + ;; + + -version-info) + prev=vinfo + continue + ;; + + -Wc,*) + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + flag=`$echo "X$arg" | $Xsed -e 's/^-Wc,//'` + compiler_flags="$compiler_flags $flag" + ;; + + -Wl,*) + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + flag=`$echo "X$arg" | $Xsed -e 's/^-Wl,//'` + linker_flags="$linker_flags $flag" + compiler_flags="$compiler_flags $wl$flag" + ;; + + -Xcompiler) + prev=xcompiler + continue + ;; + + -Xlinker) + prev=xlinker + continue + ;; + + # Some other compiler flag. + -* | +*) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + ;; + + *.o | *.obj) + # A standard object. + objs="$objs $arg" + ;; + + *.lo) + # A library object. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then + prev= + continue + else + # If libtool objects are unsupported, then we need to preload. + prev=dlprefiles + fi + fi + + if test "$prev" = dlprefiles; then + # Preload the old-style object. + dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"` + prev= + fi + libobjs="$libobjs $arg" + ;; + + *.a | *.lib) + # An archive. + deplibs="$deplibs $arg" + old_deplibs="$old_deplibs $arg" + continue + ;; + + *.la) + # A libtool-controlled library. + + dlname= + libdir= + library_names= + old_library= + + # Check to see that this really is a libtool archive. + if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2 + exit 1 + fi + + # If the library was installed with an old release of libtool, + # it will not redefine variable installed. + installed=yes + + # Read the .la file + # If there is no directory component, then add one. + case "$arg" in + */* | *\\*) . $arg ;; + *) . ./$arg ;; + esac + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$arg'" 1>&2 + exit 1 + fi + + if test "X$installed" = Xyes; then + dir="$libdir" + else + dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$arg"; then + dir="$objdir" + else + dir="$dir/$objdir" + fi + fi + + # This library was specified with -dlopen. + if test "$prev" = dlfiles; then + dlfiles="$dlfiles $arg" + if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then + # If there is no dlname, no dlopen support or we're linking statically, + # we need to preload. + prev=dlprefiles + else + # We should not create a dependency on this library + prev= + continue + fi + fi + + # The library was specified with -dlpreopen. + if test "$prev" = dlprefiles; then + # Prefer using a static library (so that no silly _DYNAMIC symbols + # are required to link). + if test -n "$old_library"; then + dlprefiles="$dlprefiles $dir/$old_library" + else + dlprefiles="$dlprefiles $dir/$linklib" + fi + prev= + fi + + deplibs="$deplibs $arg" + continue + ;; + + # Some other compiler argument. + *) + # Unknown arguments in both finalize_command and compile_command need + # to be aesthetically quoted because they are evaled later. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + ;; + esac + + # Now actually substitute the argument into the commands. + if test -n "$arg"; then + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + done + + if test -n "$prev"; then + $echo "$modename: the \`$prevarg' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then + eval arg=\"$export_dynamic_flag_spec\" + compile_command="$compile_command $arg" + finalize_command="$finalize_command $arg" + fi + + oldlibs= + # calculate the name of the file, without its directory + outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'` + libobjs_save="$libobjs" + + if test -n "$shlibpath_var"; then + # get the directories listed in $shlibpath_var + eval shlib_search_path=\`\$echo \"X \${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` + else + shlib_search_path= + fi + eval sys_lib_search_path=\"$sys_lib_search_path_spec\" + eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" + lib_search_path="$lib_search_path $sys_lib_search_path $shlib_search_path" + + case "$output" in + "") + $echo "$modename: you must specify an output file" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + *.a | *.lib) + linkmode=oldlib ;; + *.lo | *.o | *.obj) + linkmode=obj ;; + *.la) + linkmode=lib ;; + *) # Anything else should be a program. + linkmode=prog ;; + esac + + if test $linkmode = lib || test $linkmode = prog; then + output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'` + if test "X$output_objdir" = "X$output"; then + output_objdir="$objdir" + else + output_objdir="$output_objdir/$objdir" + fi + + # Create the object directory. + if test ! -d $output_objdir; then + $show "$mkdir $output_objdir" + $run $mkdir $output_objdir + status=$? + if test $status -ne 0 && test ! -d $output_objdir; then + exit $status + fi + fi + else + # Find libtool convenience libraries + for deplib in $deplibs; do + case "$deplib" in + -l* | -L*) + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives/objects" 1>&2 + continue + ;; + esac + if test -f "$deplib"; then : + else + $echo "$modename: cannot find the library \`$deplib'" 1>&2 + exit 1 + fi + libdir= + old_library= + + # Check to see that this really is a libtool archive. + if (sed -e '2q' $deplib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit 1 + fi + + ladir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$deplib" && ladir="." + + # Read the .la file + case "$deplib" in + */* | *\\*) . $deplib ;; + *) . ./$deplib ;; + esac + + if test -z "$old_library"; then + $echo "$modename: cannot find name of link library for \`$deplib'" 1>&2 + exit 1 + fi + + if test -n "$libdir"; then + $echo "$modename: \`$deplib' is not a convenience library" 1>&2 + exit 1 + fi + + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + done + fi + + case $linkmode in + oldlib) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for archives" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for archives" 1>&2 + fi + + if test -n "$export_symbols" || test -n "$export_symbols_regex"; then + $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2 + fi + + # Now set the variables for building old libraries. + build_libtool_libs=no + oldlibs="$output" + objs="$objs$old_deplibs" + ;; + + lib) + # Make sure we only generate libraries of the form `libNAME.la'. + case "$outputname" in + lib*) + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + eval libname=\"$libname_spec\" + ;; + *) + if test "$module" = no; then + $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + if test "$need_lib_prefix" != no; then + # Add the "lib" prefix for modules if required + name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + eval libname=\"$libname_spec\" + else + libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'` + fi + ;; + esac + + if test -n "$objs$old_deplibs"; then + $echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1 + exit 1 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2 + fi + + set dummy $rpath + if test $# -gt 2; then + $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2 + fi + install_libdir="$2" + + oldlibs= + if test -z "$rpath"; then + if test "$build_libtool_libs" = yes; then + # Building a libtool convenience library. + libext=al + oldlibs="$output_objdir/$libname.$libext $oldlibs" + build_libtool_libs=convenience + build_old_libs=yes + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2 + fi + else + + # Parse the version information argument. + IFS="${IFS= }"; save_ifs="$IFS"; IFS=':' + set dummy $vinfo 0 0 0 + IFS="$save_ifs" + + if test -n "$8"; then + $echo "$modename: too many parameters to \`-version-info'" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + current="$2" + revision="$3" + age="$4" + + # Check that each of the things are valid numbers. + case "$current" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$revision" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + case "$age" in + 0 | [1-9] | [1-9][0-9]*) ;; + *) + $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + ;; + esac + + if test $age -gt $current; then + $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2 + $echo "$modename: \`$vinfo' is not valid version information" 1>&2 + exit 1 + fi + + # Calculate the version variables. + major= + versuffix= + verstring= + case "$version_type" in + none) ;; + + irix) + major=`expr $current - $age + 1` + versuffix="$major.$revision" + verstring="sgi$major.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$revision + while test $loop != 0; do + iface=`expr $revision - $loop` + loop=`expr $loop - 1` + verstring="sgi$major.$iface:$verstring" + done + ;; + + linux) + major=.`expr $current - $age` + versuffix="$major.$age.$revision" + ;; + + osf) + major=`expr $current - $age` + versuffix=".$current.$age.$revision" + verstring="$current.$age.$revision" + + # Add in all the interfaces that we are compatible with. + loop=$age + while test $loop != 0; do + iface=`expr $current - $loop` + loop=`expr $loop - 1` + verstring="$verstring:${iface}.0" + done + + # Make executables depend on our current version. + verstring="$verstring:${current}.0" + ;; + + sunos) + major=".$current" + versuffix=".$current.$revision" + ;; + + freebsd-aout) + major=".$current" + versuffix=".$current.$revision"; + ;; + + freebsd-elf) + major=".$current" + versuffix=".$current"; + ;; + + windows) + # Like Linux, but with '-' rather than '.', since we only + # want one extension on Windows 95. + major=`expr $current - $age` + versuffix="-$major-$age-$revision" + ;; + + *) + $echo "$modename: unknown library version type \`$version_type'" 1>&2 + echo "Fatal configuration error. See the $PACKAGE docs for more information." 1>&2 + exit 1 + ;; + esac + + # Clear the version info if we defaulted, and they specified a release. + if test -z "$vinfo" && test -n "$release"; then + major= + verstring="0.0" + if test "$need_version" = no; then + versuffix= + else + versuffix=".0.0" + fi + fi + + # Remove version info from name if versioning should be avoided + if test "$avoid_version" = yes && test "$need_version" = no; then + major= + versuffix= + verstring="" + fi + + # Check to see if the archive will have undefined symbols. + if test "$allow_undefined" = yes; then + if test "$allow_undefined_flag" = unsupported; then + $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2 + build_libtool_libs=no + build_old_libs=yes + fi + else + # Don't allow undefined symbols. + allow_undefined_flag="$no_undefined_flag" + fi + fi + + if test "$relink" = no; then + # Remove our outputs. + $show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*" + $run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.* + fi + + # Now set the variables for building old libraries. + if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then + oldlibs="$oldlibs $output_objdir/$libname.$libext" + + # Transform .lo files to .o files. + oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` + fi + + # Save some variables + name_save=$name + libname_save=$libname + + # Find libtool libraries and add their dependencies and directories + save_deplibs="$deplibs" + deplibs= # libraries to link (used in archive_cmds) + newdependency_libs= # all dependency libraries + uninst_path= # paths that contain uninstalled libtool libraries + new_lib_search_path= + for deplib in $save_deplibs; do + lib= + case "$deplib" in + -L*) + case "$deplibs " in + *" $deplib "*) ;; + *) + deplibs="$deplibs $deplib" + newdependency_libs="$newdependency_libs $deplib" + new_lib_search_path="$new_lib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + ;; + esac + continue + ;; + -l*) + name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` + found=no + for searchdir in $lib_search_path; do + # Search the libtool library + lib="$searchdir/lib${name}.la" + if test -f "$lib"; then + found=yes + break + fi + done + if test "$found" != yes; then + deplibs="$deplibs $deplib" + newdependency_libs="$newdependency_libs $deplib" + continue + fi + ;; + *) + lib="$deplib" + if test -f "$lib"; then : + else + $echo "$modename: cannot find the library \`$lib'" 1>&2 + exit 1 + fi + ;; + esac + libdir= + library_names= + old_library= + + # Check to see that this really is a libtool archive. + if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit 1 + fi + + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + # We need an absolute path. + case "$ladir" in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + abs_ladir="$ladir" + fi + ;; + esac + laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + + # If the library was installed with an old release of libtool, + # it will not redefine variable installed. + installed=yes + + # Read the .la file + case "$lib" in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit 1 + fi + + if test -z "$libdir"; then + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $ladir/$objdir/$old_library" + old_convenience="$old_convenience $ladir/$objdir/$old_library" + deplibs="$deplibs $ladir/$objdir/$old_library" + newdependency_libs="$newdependency_libs $dependency_libs" + continue + fi + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + $echo "$modename: warning: library \`$lib' was moved." 1>&2 + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + # Remove this search path later + uninst_path="$uninst_path $abs_ladir" + fi + name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + link_static=no # Whether this library is linked statically + + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + # This is a shared library + if test "$hardcode_into_libs" = yes; then + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + realname="$2" + shift; shift + libname=`eval \\$echo \"$libname_spec\"` + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a" + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + $show "extracting exported symbol list from \`$soname'" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + eval cmds=\"$extract_expsyms_cmds\" + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + $show "generating import library for \`$soname'" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + eval cmds=\"$old_archive_from_expsyms_cmds\" + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi + + add_dir= + add_shlibpath= + add_name=no + if test "$relink" = no; then + lib_linked=yes + case "$hardcode_action" in + immediate | unsupported) + if test "$hardcode_direct" = no; then + deplibs="$deplibs $dir/$linklib" + elif test "$hardcode_minus_L" = no; then + case "$host" in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add_name=yes + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add_name=yes + else + lib_linked=no + fi + ;; + relink) + if test "$hardcode_direct" = yes; then + deplibs="$deplibs $dir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$dir" + add_name=yes + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$dir" + add_name=yes + else + lib_linked=no + fi + ;; + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit 1 + fi + if test -n "$add_shlibpath"; then + case ":$compile_shlibpath:" in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + else + # Install command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + deplibs="$deplibs $libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add_name=yes + elif test "$hardcode_shlibpath_var" = yes; then + add_name=yes + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + add_name=yes + fi + fi + if test "$hardcode_direct" != yes && \ + test "$hardcode_minus_L" != yes && \ + test "$hardcode_shlibpath_var" = yes; then + case ":$finalize_shlibpath:" in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + fi + if test -n "$add_dir"; then + case "$deplibs " in + *" $add_dir "*) ;; + *) deplibs="$deplibs $add_dir" ;; + esac + fi + test "$add_name" = yes && deplibs="$deplibs -l$name" + elif test "$build_libtool_libs" = yes; then + # Not a shared library + if test "$deplibs_check_method" != pass_all; then + # We're trying link a shared library against a static one + # but the system doesn't support it. + # Just print a warning and add the library to dependency_libs so + # that the program can be linked against the static library. + echo + echo "*** Warning: This library needs some functionality provided by $libname." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + else + convenience="$convenience $dir/$old_library" + old_convenience="$old_convenience $dir/$old_library" + deplibs="$deplibs $dir/$old_library" + link_static=yes + fi + fi + + if test -n "$dependency_libs"; then + # Extract -R from dependency_libs + temp_deplibs= + for libdir in $dependency_libs; do + case "$libdir" in + -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'` + case " $xrpath " in + *" $temp_xrpath "*) ;; + *) xrpath="$xrpath $temp_xrpath";; + esac;; + *) temp_deplibs="$temp_deplibs $libdir";; + esac + done + dependency_libs="$temp_deplibs" + fi + + new_lib_search_path="$new_lib_search_path $absdir" + # Link against this library + test "$link_static" = no && newdependency_libs="$newdependency_libs $abs_ladir/$laname" + # ... and its dependency_libs + newdependency_libs="$newdependency_libs $dependency_libs" + + if test $link_all_deplibs != no; then + # Add the search paths of all dependency libraries + for deplib in $dependency_libs; do + case "$deplib" in + -L*) path="$deplib" ;; + *.la) + if grep "^installed=no" $deplib > /dev/null; then + dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$deplib" && dir="." + # We need an absolute path. + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; + *) + absdir=`cd "$dir" && pwd` + if test -z "$absdir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2 + absdir="$dir" + fi + ;; + esac + path="-L$absdir/$objdir" + else + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit 1 + fi + path="-L$libdir" + fi + ;; + *) + continue + ;; + esac + case "$deplibs " in + *" $path "*) ;; + *) deplibs="$path $deplibs" ;; + esac + done + fi + done + + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $new_lib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + lib_search_path="$lib_search_path $sys_lib_search_path" + + # Make sure newdependency_libs contains only unique libraries and directories. + dependency_libs= + for deplib in $newdependency_libs; do + case "$dependency_libs " in + *" $deplib "*) ;; + *) dependency_libs="$dependency_libs $deplib" ;; + esac + done + + # Eliminate all temporary directories. + for path in $uninst_path; do + lib_search_path=`echo "$lib_search_path " | sed -e 's% $path % %g'` + deplibs=`echo "$deplibs " | sed -e 's% -L$path % %g'` + dependency_libs=`echo "$dependency_libs " | sed -e 's% -L$path % %g'` + done + + if test -n "$xrpath"; then + # If the user specified any rpath flags, then add them. + temp_xrpath= + for libdir in $xrpath; do + temp_xrpath="$temp_xrpath -R$libdir" + case "$compile_rpath " in + *" $libdir "*) ;; + *) compile_rpath="$compile_rpath $libdir" ;; + esac + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + dependency_libs="$temp_xrpath $dependency_libs" + fi + + # Restore the variables + libname=$libname_save + name=$name_save + + if test "$build_libtool_libs" = yes; then + if test -n "$rpath"; then + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos*) + # these systems don't actually have a c library (as such)! + ;; + *) + # Add libc to deplibs on all other systems. + deplibs="$deplibs -lc" + ;; + esac + fi + + # Transform deplibs into only deplibs that can be linked in shared. + name_save=$name + libname_save=$libname + release_save=$release + versuffix_save=$versuffix + major_save=$major + # I'm not sure if I'm treating the release correctly. I think + # release should show up in the -l (ie -lgmp5) so we don't want to + # add it in twice. Is that correct? + release="" + versuffix="" + major="" + newdeplibs= + droppeddeps=no + case "$deplibs_check_method" in + pass_all) + # Don't check for shared/static. Everything works. + # This might be a little naive. We might want to check + # whether the library exists or not. But this is on + # osf3 & osf4 and I'm not really sure... Just + # implementing what was already the behaviour. + newdeplibs=$deplibs + ;; + test_compile) + # This code stresses the "libraries are programs" paradigm to its + # limits. Maybe even breaks it. We compile a program, linking it + # against the deplibs as a proxy for the library. Then we can check + # whether they linked in statically or dynamically with ldd. + $rm conftest.c + cat > conftest.c </dev/null` + for potent_lib in $potential_libs; do + # Follow soft links. + if ls -lLd "$potent_lib" 2>/dev/null \ + | grep " -> " >/dev/null; then + continue + fi + # The statement above tries to avoid entering an + # endless loop below, in case of cyclic links. + # We might still enter an endless loop, since a link + # loop can be closed while we follow links, + # but so what? + potlib="$potent_lib" + while test -h "$potlib" 2>/dev/null; do + potliblink=`ls -ld $potlib | sed 's/.* -> //'` + case "$potliblink" in + [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; + *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; + esac + done + if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \ + | sed 10q \ + | egrep "$file_magic_regex" > /dev/null; then + newdeplibs="$newdeplibs $a_deplib" + a_deplib="" + break 2 + fi + done + done + if test -n "$a_deplib" ; then + droppeddeps=yes + echo + echo "*** Warning: This library needs some functionality provided by $a_deplib." + echo "*** I have the capability to make that library automatically link in when" + echo "*** you link to this library. But I can only do this if you have a" + echo "*** shared version of the library, which you do not appear to have." + fi + else + # Add a -L argument. + newdeplibs="$newdeplibs $a_deplib" + fi + done # Gone through all deplibs. + ;; + none | unknown | *) + newdeplibs="" + if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \ + -e 's/ -[LR][^ ]*//g' -e 's/[ ]//g' | + grep . >/dev/null; then + echo + if test "X$deplibs_check_method" = "Xnone"; then + echo "*** Warning: inter-library dependencies are not supported in this platform." + else + echo "*** Warning: inter-library dependencies are not known to be supported." + fi + echo "*** All declared inter-library dependencies are being dropped." + droppeddeps=yes + fi + ;; + esac + versuffix=$versuffix_save + major=$major_save + release=$release_save + libname=$libname_save + name=$name_save + + if test "$droppeddeps" = yes; then + if test "$module" = yes; then + echo + echo "*** Warning: libtool could not satisfy all declared inter-library" + echo "*** dependencies of module $libname. Therefore, libtool will create" + echo "*** a static module, that should work as long as the dlopening" + echo "*** application is linked with the -dlopen flag." + if test -z "$global_symbol_pipe"; then + echo + echo "*** However, this would only work if libtool was able to extract symbol" + echo "*** lists from a program, using \`nm' or equivalent, but libtool could" + echo "*** not find such a program. So, this module is probably useless." + echo "*** \`nm' from GNU binutils and a full rebuild may help." + fi + if test "$build_old_libs" = no; then + oldlibs="$output_objdir/$libname.$libext" + build_libtool_libs=module + build_old_libs=yes + else + build_libtool_libs=no + fi + else + echo "*** The inter-library dependencies that have been dropped here will be" + echo "*** automatically added whenever a program is linked with this library" + echo "*** or is declared to -dlopen it." + fi + fi + # Done checking deplibs! + deplibs=$newdeplibs + fi + + # All the library-specific variables (install_libdir is set above). + library_names= + old_library= + dlname= + + # Test again, we may have decided not to build it any more + if test "$build_libtool_libs" = yes; then + if test "$hardcode_into_libs" = yes; then + # Hardcode the library paths + hardcode_libdirs= + dep_rpath= + rpath="$finalize_rpath" + test "$relink" = no && rpath="$compile_rpath$rpath" + for libdir in $rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + dep_rpath="$dep_rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval dep_rpath=\"$hardcode_libdir_flag_spec\" + fi + if test -n "$runpath_var" && test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" + fi + test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" + fi + + shlibpath="$finalize_shlibpath" + test "$relink" = no && shlibpath="$compile_shlibpath$shlibpath" + if test -n "$shlibpath"; then + eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" + fi + + # Get the real and link names of the library. + eval library_names=\"$library_names_spec\" + set dummy $library_names + realname="$2" + shift; shift + + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + lib="$output_objdir/$realname" + for link + do + linknames="$linknames $link" + done + + # Ensure that we have .o objects for linkers which dislike .lo + # (e.g. aix) incase we are running --disable-static + for obj in $libobjs; do + xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$obj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'` + oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` + if test ! -f $xdir/$oldobj; then + $show "(cd $xdir && ${LN_S} $baseobj $oldobj)" + $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $? + fi + done + + # Use standard objects if they are pic + test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then + $show "generating symbol list for \`$libname.la'" + export_symbols="$output_objdir/$libname.exp" + $run $rm $export_symbols + eval cmds=\"$export_symbols_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + if test -n "$export_symbols_regex"; then + $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\"" + $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' + $show "$mv \"${export_symbols}T\" \"$export_symbols\"" + $run eval '$mv "${export_symbols}T" "$export_symbols"' + fi + fi + fi + + if test -n "$export_symbols" && test -n "$include_expsyms"; then + $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"' + fi + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval libobjs=\"\$libobjs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then + eval flag=\"$thread_safe_flag_spec\" + linker_flags="$linker_flags $flag" + fi + + # Make a backup of the uninstalled library when relinking + if test "$relink" = yes && test "$hardcode_into_libs" = yes ; then + $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $? + fi + + # Do each of the archive commands. + if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then + eval cmds=\"$archive_expsym_cmds\" + else + eval cmds=\"$archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Restore the uninstalled library and exit + if test "$relink" = yes && test "$hardcode_into_libs" = yes; then + $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $? + exit 0 + fi + + # Create links to the real library. + for linkname in $linknames; do + if test "$realname" != "$linkname"; then + $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $? + fi + done + + # If -module or -export-dynamic was specified, set the dlname. + if test "$module" = yes || test "$export_dynamic" = yes; then + # On all known operating systems, these are identical. + dlname="$soname" + fi + fi + ;; + + obj) + if test -n "$deplibs"; then + $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2 + fi + + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2 + fi + + if test -n "$rpath"; then + $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2 + fi + + if test -n "$xrpath"; then + $echo "$modename: warning: \`-R' is ignored for objects" 1>&2 + fi + + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for objects" 1>&2 + fi + + case "$output" in + *.lo) + if test -n "$objs$old_deplibs"; then + $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2 + exit 1 + fi + libobj="$output" + obj=`$echo "X$output" | $Xsed -e "$lo2o"` + ;; + *) + libobj= + obj="$output" + ;; + esac + + # Delete the old objects. + $run $rm $obj $libobj + + # Objects from convenience libraries. This assumes + # single-version convenience libraries. Whenever we create + # different ones for PIC/non-PIC, this we'll have to duplicate + # the extraction. + reload_conv_objs= + gentop= + # reload_cmds runs $LD directly, so let us get rid of + # -Wl from whole_archive_flag_spec + wl= + + if test -n "$convenience"; then + if test -n "$whole_archive_flag_spec"; then + eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\" + else + gentop="$output_objdir/${obj}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + for xlib in $convenience; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP` + done + fi + fi + + # Create the old-style object. + reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" + + output="$obj" + eval cmds=\"$reload_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + + # Exit if we aren't doing a library object file. + if test -z "$libobj"; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + fi + + if test "$build_libtool_libs" != yes; then + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + # Create an invalid libtool object if no PIC, so that we don't + # accidentally link it into a program. + $show "echo timestamp > $libobj" + $run eval "echo timestamp > $libobj" || exit $? + exit 0 + fi + + if test -n "$pic_flag" || test "$pic_mode" != default; then + # Only do commands if we really have different PIC objects. + reload_objs="$libobjs $reload_conv_objs" + output="$libobj" + eval cmds=\"$reload_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + else + # Just create a symlink. + $show $rm $libobj + $run $rm $libobj + xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$libobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'` + oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"` + $show "(cd $xdir && $LN_S $oldobj $baseobj)" + $run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $? + fi + + if test -n "$gentop"; then + $show "${rm}r $gentop" + $run ${rm}r $gentop + fi + + exit 0 + ;; + + prog) + if test -n "$vinfo"; then + $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2 + fi + + if test -n "$release"; then + $echo "$modename: warning: \`-release' is ignored for programs" 1>&2 + fi + + if test "$preload" = yes; then + if test "$dlopen" = unknown && test "$dlopen_self" = unknown && + test "$dlopen_self_static" = unknown; then + $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support." + fi + fi + + # Find libtool libraries and add their dependencies + save_deplibs="$deplibs" + deplibs= + newdependency_libs= + new_lib_search_path= + for deplib in $save_deplibs; do + lib= + case "$deplib" in + *.a | *.lib) + deplibs="$deplibs $deplib" + continue + ;; + -L*) + deplibs="$deplibs $deplib" + new_lib_search_path="$new_lib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'` + continue + ;; + -l*) + name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` + found=no + for searchdir in $lib_search_path; do + # Search the libtool library + lib="$searchdir/lib${name}.la" + if test -f "$lib"; then + found=yes + break + fi + done + if test "$found" != yes; then + deplibs="$deplibs $deplib" + continue + fi + ;; + *) + lib="$deplib" + if test -f "$lib"; then : + else + $echo "$modename: cannot find the library \`$lib'" 1>&2 + exit 1 + fi + ;; + esac + libdir= + library_names= + old_library= + + # Check to see that this really is a libtool archive. + if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit 1 + fi + + # If the library was installed with an old release of libtool, + # it will not redefine variable installed. + installed=yes + + # Read the .la file + case "$lib" in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit 1 + fi + + new_lib_search_path="$new_lib_search_path `$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`" + deplibs="$deplibs $lib" + + for deplib in $dependency_libs; do + case "$deplib" in + -L*) + new_lib_search_path="$new_lib_search_path `$echo "X$deplib" | $Xsed -e 's/^-L//'`" + ;; + esac + + if test "$link_all_deplibs" != no || \ + test "$fast_install" != no || \ + test "$build_libtool_libs" = no || \ + test -z "$library_names"; then + # Need to link against all dependency_libs + deplibs="$deplibs $deplib" + else + # Need to hardcode shared library paths + # or/and link against static libraries + newdependency_libs="$newdependency_libs $deplib" + fi + done + done + + # Eliminate all dependency_libs that are already contained in deplibs + dependency_libs= + for deplib in $newdependency_libs; do + case "$deplibs " in + *" $deplib "*) ;; + *) dependency_libs="$dependency_libs $deplib" ;; + esac + done + + # Make sure lib_search_path contains only unique directories. + lib_search_path= + for dir in $new_lib_search_path; do + case "$lib_search_path " in + *" $dir "*) ;; + *) lib_search_path="$lib_search_path $dir" ;; + esac + done + lib_search_path="$lib_search_path $sys_lib_search_path" + + # Find libtool libraries and add their directories + alldeplibs=no + link_against_libtool_libs= + + for deplib in $deplibs @DEPLIBS@ $dependency_libs; do + lib= + case "$deplib" in + -L* | *.a | *.lib) + compile_command="$compile_command $deplib" + finalize_command="$finalize_command $deplib" + continue + ;; + -R*) + dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'` + # Make sure the xrpath contains only unique directories. + case "$xrpath " in + *" $dir "*) ;; + *) xrpath="$xrpath $dir" ;; + esac + continue + ;; + @DEPLIBS@) + alldeplibs=yes + continue + ;; + -l*) + name=`$echo "X$deplib" | $Xsed -e 's/^-l//'` + found=no + for searchdir in $lib_search_path; do + # Search the libtool library + lib="$searchdir/lib${name}.la" + if test -f "$lib"; then + found=yes + break + fi + done + if test "$found" != yes; then + compile_command="$compile_command $deplib" + finalize_command="$finalize_command $deplib" + continue + fi + ;; + *) + lib="$deplib" + if test -f "$lib"; then : + else + $echo "$modename: cannot find the library \`$lib'" 1>&2 + exit 1 + fi + ;; + esac + libdir= + library_names= + old_library= + + # Check to see that this really is a libtool archive. + if (sed -e '2q' $lib | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + exit 1 + fi + + ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'` + test "X$ladir" = "X$lib" && ladir="." + # We need an absolute path. + case "$ladir" in + [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; + *) + abs_ladir=`cd "$ladir" && pwd` + if test -z "$abs_ladir"; then + $echo "$modename: warning: cannot determine absolute directory name of \`$abs_ladir'" 1>&2 + $echo "$modename: passing it literally to the linker, although it might fail" 1>&2 + abs_ladir="$ladir" + fi + ;; + esac + laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'` + + # If the library was installed with an old release of libtool, + # it will not redefine variable installed. + installed=yes + + # Read the .la file + case "$lib" in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + + # Get the name of the library we link against. + linklib= + for l in $old_library $library_names; do + linklib="$l" + done + + if test -z "$linklib"; then + $echo "$modename: cannot find name of link library for \`$lib'" 1>&2 + exit 1 + fi + + # Find the relevant object directory and library name. + if test "X$installed" = Xyes; then + if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then + $echo "$modename: warning: library \`$lib' was moved." 1>&2 + dir="$ladir" + absdir="$abs_ladir" + libdir="$abs_ladir" + else + dir="$libdir" + absdir="$libdir" + fi + else + dir="$ladir/$objdir" + absdir="$abs_ladir/$objdir" + fi + name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'` + + hardcode=yes + test "$hardcode_into_libs" = yes && test "$alldeplibs" = yes && hardcode=no + if test "$hardcode" = yes && test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + # We need to hardcode the library path + if test -n "$shlibpath_var"; then + # Make sure the rpath contains only unique directories. + case "$temp_rpath " in + *" $dir "*) ;; + *" $absdir "*) ;; + *) temp_rpath="$temp_rpath $dir" ;; + esac + fi + + # Hardcode the library path. + # Skip directories that are in the system default run-time + # search path. + case " $sys_lib_dlsearch_path " in + *" $absdir "*) ;; + *) + case "$compile_rpath " in + *" $absdir "*) ;; + *) compile_rpath="$compile_rpath $absdir" + esac + ;; + esac + + case " $sys_lib_dlsearch_path " in + *" $libdir "*) ;; + *) + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" + esac + ;; + esac + fi + + if test "$alldeplibs" = yes && + { test "$deplibs_check_method" = pass_all || + { test "$build_libtool_libs" = yes && + test -n "$library_names"; }; }; then + # Do we only need to link against static libraries? + continue + fi + + if test -z "$libdir"; then + # It is a libtool convenience library, so add in its objects. + convenience="$convenience $dir/$old_library" + old_convenience="$old_convenience $dir/$old_library" + compile_command="$compile_command $dir/$old_library" + finalize_command="$finalize_command $dir/$old_library" + continue + fi + + if test -n "$library_names" && + { test "$prefer_static_libs" = no || test -z "$old_library"; }; then + link_against_libtool_libs="$link_against_libtool_libs $lib" + + if test -n "$old_archive_from_expsyms_cmds"; then + # figure out the soname + set dummy $library_names + realname="$2" + shift; shift + libname=`eval \\$echo \"$libname_spec\"` + if test -n "$soname_spec"; then + eval soname=\"$soname_spec\" + else + soname="$realname" + fi + + # Make a new name for the extract_expsyms_cmds to use + newlib="libimp-`echo $soname | sed 's/^lib//;s/\.dll$//'`.a" + + # If the library has no export list, then create one now + if test -f "$output_objdir/$soname-def"; then : + else + $show "extracting exported symbol list from \`$soname'" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + eval cmds=\"$extract_expsyms_cmds\" + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Create $newlib + if test -f "$output_objdir/$newlib"; then :; else + $show "generating import library for \`$soname'" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + eval cmds=\"$old_archive_from_expsyms_cmds\" + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + # make sure the library variables are pointing to the new library + dir=$output_objdir + linklib=$newlib + fi + + lib_linked=yes + add_dir= + add_shlibpath= + add_name=no + case "$hardcode_action" in + immediate | unsupported) + if test "$hardcode_direct" = no; then + compile_command="$compile_command $dir/$linklib" + elif test "$hardcode_minus_L" = no; then + case "$host" in + *-*-sunos*) add_shlibpath="$dir" ;; + esac + add_dir="-L$dir" + add_name=yes + elif test "$hardcode_shlibpath_var" = no; then + add_shlibpath="$dir" + add_name=yes + else + lib_linked=no + fi + ;; + + relink) + if test "$hardcode_direct" = yes; then + compile_command="$compile_command $absdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$absdir" + add_name=yes + elif test "$hardcode_shlibpath_var" = yes; then + add_shlibpath="$absdir" + add_name=yes + else + lib_linked=no + fi + ;; + + *) lib_linked=no ;; + esac + + if test "$lib_linked" != yes; then + $echo "$modename: configuration error: unsupported hardcode properties" + exit 1 + fi + if test -n "$add_dir"; then + case "$compile_command " in + *" $add_dir "*) ;; + *) compile_command="$compile_command $add_dir" ;; + esac + fi + if test -n "$add_shlibpath"; then + case ":$compile_shlibpath:" in + *":$add_shlibpath:"*) ;; + *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; + esac + fi + test "$add_name" = yes && compile_command="$compile_command -l$name" + + add_dir= + add_name=no + # Finalize command for both is simple: just hardcode it. + if test "$hardcode_direct" = yes; then + finalize_command="$finalize_command $libdir/$linklib" + elif test "$hardcode_minus_L" = yes; then + add_dir="-L$libdir" + add_name=yes + elif test "$hardcode_shlibpath_var" = yes; then + case ":$finalize_shlibpath:" in + *":$libdir:"*) ;; + *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; + esac + add_name=yes + else + # We cannot seem to hardcode it, guess we'll fake it. + add_dir="-L$libdir" + add_name=yes + fi + if test -n "$add_dir"; then + case "$finalize_command " in + *" $add_dir "*) ;; + *) finalize_command="$finalize_command $add_dir" ;; + esac + fi + test "$add_name" = yes && finalize_command="$finalize_command -l$name" + else + # Here we assume that one of hardcode_direct or hardcode_minus_L + # is not unsupported. This is valid on all known static and + # shared platforms. + if test "$hardcode_direct" != unsupported; then + test -n "$old_library" && linklib="$old_library" + compile_command="$compile_command $dir/$linklib" + finalize_command="$finalize_command $dir/$linklib" + else + case "$compile_command " in + *" -L$dir "*) ;; + *) compile_command="$compile_command -L$dir";; + esac + compile_command="$compile_command -l$name" + case "$finalize_command " in + *" -L$dir "*) ;; + *) finalize_command="$finalize_command -L$dir";; + esac + finalize_command="$finalize_command -l$name" + fi + fi + done + + if test -n "$rpath$xrpath"; then + # If the user specified any rpath flags, then add them. + for libdir in $rpath $xrpath; do + # This is the magic to use -rpath. + case "$compile_rpath " in + *" $libdir "*) ;; + *) compile_rpath="$compile_rpath $libdir" ;; + esac + case "$finalize_rpath " in + *" $libdir "*) ;; + *) finalize_rpath="$finalize_rpath $libdir" ;; + esac + done + fi + + # Now hardcode the library paths + rpath= + hardcode_libdirs= + for libdir in $compile_rpath $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$perm_rpath " in + *" $libdir "*) ;; + *) perm_rpath="$perm_rpath $libdir" ;; + esac + fi + case "$host" in + *-*-cygwin* | *-*-mingw* | *-*-os2*) + case ":$dllsearchpath:" in + *":$libdir:"*) ;; + *) dllsearchpath="$dllsearchpath:$libdir";; + esac + ;; + esac + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + compile_rpath="$rpath" + + rpath= + hardcode_libdirs= + for libdir in $finalize_rpath; do + if test -n "$hardcode_libdir_flag_spec"; then + if test -n "$hardcode_libdir_separator"; then + if test -z "$hardcode_libdirs"; then + hardcode_libdirs="$libdir" + else + # Just accumulate the unique libdirs. + case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in + *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) + ;; + *) + hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" + ;; + esac + fi + else + eval flag=\"$hardcode_libdir_flag_spec\" + rpath="$rpath $flag" + fi + elif test -n "$runpath_var"; then + case "$finalize_perm_rpath " in + *" $libdir "*) ;; + *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; + esac + fi + done + # Substitute the hardcoded libdirs into the rpath. + if test -n "$hardcode_libdir_separator" && + test -n "$hardcode_libdirs"; then + libdir="$hardcode_libdirs" + eval rpath=\" $hardcode_libdir_flag_spec\" + fi + finalize_rpath="$rpath" + + if test -n "$libobjs" && test "$build_old_libs" = yes; then + # Transform all the library objects into standard objects. + compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + fi + + dlsyms= + if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then + if test -n "$NM" && test -n "$global_symbol_pipe"; then + dlsyms="${outputname}S.c" + else + $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2 + fi + fi + + if test -n "$dlsyms"; then + case "$dlsyms" in + "") ;; + *.c) + # Discover the nlist of each of the dlfiles. + nlist="$output_objdir/${outputname}.nm" + + $show "$rm $nlist ${nlist}S ${nlist}T" + $run $rm "$nlist" "${nlist}S" "${nlist}T" + + # Parse the name list into a source file. + $show "creating $output_objdir/$dlsyms" + + test -z "$run" && $echo > "$output_objdir/$dlsyms" "\ +/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */ +/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */ + +#ifdef __cplusplus +extern \"C\" { +#endif + +/* Prevent the only kind of declaration conflicts we can make. */ +#define lt_preloaded_symbols some_other_symbol + +/* External symbol declarations for the compiler. */\ +" + + if test "$dlself" = yes; then + $show "generating symbol list for \`$output'" + + test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist" + + # Add our own program objects to the symbol list. + progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` + for arg in $progfiles; do + $show "extracting global C symbols from \`$arg'" + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -n "$exclude_expsyms"; then + $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + if test -n "$export_symbols_regex"; then + $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T' + $run eval '$mv "$nlist"T "$nlist"' + fi + + # Prepare the list of exported symbols + if test -z "$export_symbols"; then + export_symbols="$output_objdir/$output.exp" + $run $rm $export_symbols + $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' + else + $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"' + $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T' + $run eval 'mv "$nlist"T "$nlist"' + fi + fi + + for arg in $dlprefiles; do + $show "extracting global C symbols from \`$arg'" + name=`echo "$arg" | sed -e 's%^.*/%%'` + $run eval 'echo ": $name " >> "$nlist"' + $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'" + done + + if test -z "$run"; then + # Make sure we have at least an empty file. + test -f "$nlist" || : > "$nlist" + + if test -n "$exclude_expsyms"; then + egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T + $mv "$nlist"T "$nlist" + fi + + # Try sorting and uniquifying the output. + if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then + : + else + grep -v "^: " < "$nlist" > "$nlist"S + fi + + if test -f "$nlist"S; then + eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"' + else + echo '/* NONE */' >> "$output_objdir/$dlsyms" + fi + + $echo >> "$output_objdir/$dlsyms" "\ + +#undef lt_preloaded_symbols + +#if defined (__STDC__) && __STDC__ +# define lt_ptr_t void * +#else +# define lt_ptr_t char * +# define const +#endif + +/* The mapping between symbol names and symbols. */ +const struct { + const char *name; + lt_ptr_t address; +} +lt_preloaded_symbols[] = +{\ +" + + sed -n -e 's/^: \([^ ]*\) $/ {\"\1\", (lt_ptr_t) 0},/p' \ + -e 's/^. \([^ ]*\) \([^ ]*\)$/ {"\2", (lt_ptr_t) \&\2},/p' \ + < "$nlist" >> "$output_objdir/$dlsyms" + + $echo >> "$output_objdir/$dlsyms" "\ + {0, (lt_ptr_t) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif\ +" + fi + + pic_flag_for_symtable= + case "$host" in + # compiling the symbol table file with pic_flag works around + # a FreeBSD bug that causes programs to crash when -lm is + # linked before any other PIC object. But we must not use + # pic_flag when linking with -static. The problem exists in + # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. + *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";; + esac;; + *-*-hpux*) + case "$compile_command " in + *" -static "*) ;; + *) pic_flag_for_symtable=" $pic_flag -DPIC";; + esac + esac + + # Now compile the dynamic symbol file. + $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")" + $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $? + + # Clean up the generated files. + $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T" + $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T" + + # Transform the symbol file into the correct name. + compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"` + ;; + *) + $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2 + exit 1 + ;; + esac + else + # We keep going just in case the user didn't refer to + # lt_preloaded_symbols. The linker will fail if global_symbol_pipe + # really was required. + + # Nullify the symbol file. + compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` + finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` + fi + + if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then + # Replace the output file specification. + compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` + link_command="$compile_command$compile_rpath" + + # We have no uninstalled library dependencies, so finalize right now. + $show "$link_command" + $run eval "$link_command" + status=$? + + # Delete the generated files. + if test -n "$dlsyms"; then + $show "$rm $output_objdir/${outputname}S.${objext}" + $run $rm "$output_objdir/${outputname}S.${objext}" + fi + + exit $status + fi + + if test -n "$shlibpath_var"; then + # We should set the shlibpath_var + rpath= + for dir in $temp_rpath; do + case "$dir" in + [\\/]* | [A-Za-z]:[\\/]*) + # Absolute path. + rpath="$rpath$dir:" + ;; + *) + # Relative path: add a thisdir entry. + rpath="$rpath\$thisdir/$dir:" + ;; + esac + done + temp_rpath="$rpath" + fi + + if test -n "$compile_shlibpath$finalize_shlibpath"; then + compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" + fi + if test -n "$finalize_shlibpath"; then + finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" + fi + + compile_var= + finalize_var= + if test -n "$runpath_var"; then + if test -n "$perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $perm_rpath; do + rpath="$rpath$dir:" + done + compile_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + if test -n "$finalize_perm_rpath"; then + # We should set the runpath_var. + rpath= + for dir in $finalize_perm_rpath; do + rpath="$rpath$dir:" + done + finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " + fi + fi + + if test "$hardcode_action" = relink || test "$hardcode_into_libs" = yes; then + # Fast installation is not supported + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + + $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2 + $echo "$modename: \`$output' will be relinked during installation" 1>&2 + else + if test "$fast_install" != no; then + link_command="$finalize_var$compile_command$finalize_rpath" + if test "$fast_install" = yes; then + relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` + else + # fast_install is set to needless + relink_command= + fi + else + link_command="$compile_var$compile_command$compile_rpath" + relink_command="$finalize_var$finalize_command$finalize_rpath" + fi + fi + + # Replace the output file specification. + link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` + + # Delete the old output files. + $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname + + $show "$link_command" + $run eval "$link_command" || exit $? + + # Now create the wrapper script. + $show "creating $output" + + # Quote the relink command for shipping. + if test -n "$relink_command"; then + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + fi + + # Quote $echo for shipping. + if test "X$echo" = "X$SHELL $0 --fallback-echo"; then + case "$0" in + [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";; + *) qecho="$SHELL `pwd`/$0 --fallback-echo";; + esac + qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"` + else + qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"` + fi + + # Only actually do things if our run command is non-null. + if test -z "$run"; then + # win32 will think the script is a binary if it has + # a .exe suffix, so we strip it off here. + case $output in + *.exe) output=`echo $output|sed 's,.exe$,,'` ;; + esac + $rm $output + trap "$rm $output; exit 1" 1 2 15 + + $echo > $output "\ +#! $SHELL + +# $output - temporary wrapper script for $objdir/$outputname +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# The $output program cannot be directly executed until all the libtool +# libraries that it depends on are installed. +# +# This wrapper script should never be moved out of the build directory. +# If it is, it will not operate correctly. + +# Sed substitution that helps us do robust quoting. It backslashifies +# metacharacters that are still active within double-quoted strings. +Xsed='sed -e 1s/^X//' +sed_quote_subst='$sed_quote_subst' + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi + +relink_command=\"$relink_command\" + +# This environment variable determines our operation mode. +if test \"\$libtool_install_magic\" = \"$magic\"; then + # install mode needs the following variable: + link_against_libtool_libs='$link_against_libtool_libs' +else + # When we are sourced in execute mode, \$file and \$echo are already set. + if test \"\$libtool_execute_magic\" != \"$magic\"; then + echo=\"$qecho\" + file=\"\$0\" + # Make sure echo works. + if test \"X\$1\" = X--no-reexec; then + # Discard the --no-reexec flag, and continue. + shift + elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then + # Yippee, \$echo works! + : + else + # Restart under the correct shell, and then maybe \$echo will work. + exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} + fi + fi\ +" + $echo >> $output "\ + + # Find the directory that this script lives in. + thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` + test \"x\$thisdir\" = \"x\$file\" && thisdir=. + + # Follow symbolic links until we get to the real thisdir. + file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\` + while test -n \"\$file\"; do + destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` + + # If there was a directory component, then change thisdir. + if test \"x\$destdir\" != \"x\$file\"; then + case \"\$destdir\" in + [\\/]* | [A-Za-z]:[\\/]*) thisdir=\"\$destdir\" ;; + *) thisdir=\"\$thisdir/\$destdir\" ;; + esac + fi + + file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\` + file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\` + done + + # Try to get the absolute directory name. + absdir=\`cd \"\$thisdir\" && pwd\` + test -n \"\$absdir\" && thisdir=\"\$absdir\" +" + + if test "$fast_install" = yes; then + echo >> $output "\ + program=lt-'$outputname' + progdir=\"\$thisdir/$objdir\" + + if test ! -f \"\$progdir/\$program\" || \\ + { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\ + test \"X\$file\" != \"X\$progdir/\$program\"; }; then + + file=\"\$\$-\$program\" + + if test ! -d \"\$progdir\"; then + $mkdir \"\$progdir\" + else + $rm \"\$progdir/\$file\" + fi" + + echo >> $output "\ + + # relink executable if necessary + if test -n \"\$relink_command\"; then + if (cd \"\$thisdir\" && eval \$relink_command); then : + else + $rm \"\$progdir/\$file\" + exit 1 + fi + fi + + $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || + { $rm \"\$progdir/\$program\"; + $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; } + $rm \"\$progdir/\$file\" + fi" + else + echo >> $output "\ + program='$outputname$exeext' + progdir=\"\$thisdir/$objdir\" +" + fi + + echo >> $output "\ + + if test -f \"\$progdir/\$program\"; then" + + # Export our shlibpath_var if we have one. + if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then + $echo >> $output "\ + # Add our own library path to $shlibpath_var + $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" + + # Some systems cannot cope with colon-terminated $shlibpath_var + # The second colon is a workaround for a bug in BeOS R4 sed + $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` + + export $shlibpath_var +" + fi + + # fixup the dll searchpath if we need to. + if test -n "$dllsearchpath"; then + $echo >> $output "\ + # Add the dll search path components to the executable PATH + PATH=$dllsearchpath:\$PATH +" + fi + + $echo >> $output "\ + if test \"\$libtool_execute_magic\" != \"$magic\"; then + # Run the actual program with our arguments. +" + case $host in + *-*-cygwin* | *-*-mingw | *-*-os2*) + # win32 systems need to use the prog path for dll + # lookup to work + $echo >> $output "\ + exec \$progdir\\\\\$program \${1+\"\$@\"} +" + ;; + *) + $echo >> $output "\ + # Export the path to the program. + PATH=\"\$progdir:\$PATH\" + export PATH + + exec \$program \${1+\"\$@\"} +" + ;; + esac + $echo >> $output "\ + \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\" + exit 1 + fi + else + # The program doesn't exist. + \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2 + \$echo \"This script is just a wrapper for \$program.\" 1>&2 + echo \"See the $PACKAGE documentation for more information.\" 1>&2 + exit 1 + fi +fi\ +" + chmod +x $output + fi + exit 0 + ;; + esac + + # See if we need to build an old-fashioned archive. + for oldlib in $oldlibs; do + + if test "$build_libtool_libs" = convenience; then + oldobjs="$libobjs_save" + addlibs="$convenience" + build_libtool_libs=no + else + if test "$build_libtool_libs" = module; then + oldobjs="$libobjs_save" + build_libtool_libs=no + else + oldobjs="$objs$old_deplibs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP` + fi + addlibs="$old_convenience" + fi + + if test -n "$addlibs"; then + gentop="$output_objdir/${outputname}x" + $show "${rm}r $gentop" + $run ${rm}r "$gentop" + $show "mkdir $gentop" + $run mkdir "$gentop" + status=$? + if test $status -ne 0 && test ! -d "$gentop"; then + exit $status + fi + generated="$generated $gentop" + + # Add in members from convenience archives. + for xlib in $addlibs; do + # Extract the objects. + case "$xlib" in + [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;; + *) xabs=`pwd`"/$xlib" ;; + esac + xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'` + xdir="$gentop/$xlib" + + $show "${rm}r $xdir" + $run ${rm}r "$xdir" + $show "mkdir $xdir" + $run mkdir "$xdir" + status=$? + if test $status -ne 0 && test ! -d "$xdir"; then + exit $status + fi + $show "(cd $xdir && $AR x $xabs)" + $run eval "(cd \$xdir && $AR x \$xabs)" || exit $? + + oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP` + done + fi + + # Do each command in the archive commands. + if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then + eval cmds=\"$old_archive_from_new_cmds\" + else + # Ensure that we have .o objects in place in case we decided + # not to build a shared library, and have fallen back to building + # static libs even though --disable-static was passed! + for oldobj in $oldobjs; do + if test ! -f $oldobj; then + xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'` + if test "X$xdir" = "X$oldobj"; then + xdir="." + else + xdir="$xdir" + fi + baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'` + obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"` + $show "(cd $xdir && ${LN_S} $obj $baseobj)" + $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $? + fi + done + + eval cmds=\"$old_archive_cmds\" + fi + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$generated"; then + $show "${rm}r$generated" + $run ${rm}r$generated + fi + + # Now create the libtool archive. + case "$output" in + *.la) + old_library= + test "$build_old_libs" = yes && old_library="$libname.$libext" + $show "creating $output" + + # Quote the link command for shipping. + relink_command="cd `pwd`; $SHELL $0 --mode=relink $libtool_args" + relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"` + + # Only create the output if not a dry run. + if test -z "$run"; then + for installed in no yes; do + if test "$installed" = yes; then + if test -z "$install_libdir"; then + break + fi + output="$output_objdir/$outputname"i + # Replace all uninstalled libtool libraries with the installed ones + newdependency_libs= + for deplib in $dependency_libs; do + case "$deplib" in + *.la) + name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'` + eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` + if test -z "$libdir"; then + $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2 + exit 1 + fi + newdependency_libs="$newdependency_libs $libdir/$name" + ;; + *) newdependency_libs="$newdependency_libs $deplib" ;; + esac + done + dependency_libs="$newdependency_libs" + fi + $rm $output + $echo > $output "\ +# $outputname - a libtool library file +# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP +# +# Please DO NOT delete this file! +# It is necessary for linking the library. + +# The name that we can dlopen(3). +dlname='$dlname' + +# Names of this library. +library_names='$library_names' + +# The name of the static archive. +old_library='$old_library' + +# Libraries that this one depends upon. +dependency_libs='$dependency_libs' + +# Version information for $libname. +current=$current +age=$age +revision=$revision + +# Is this an already installed library? +installed=$installed + +# Directory that this library needs to be installed in: +libdir='$install_libdir'" + if test "$installed" = no; then + $echo >> $output "\ +relink_command=\"$relink_command\"" + fi + done + fi + + # Do a symbolic link so that the libtool archive can be found in + # LD_LIBRARY_PATH before the program is installed. + $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" + $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $? + ;; + esac + exit 0 + ;; + + # libtool install mode + install) + modename="$modename: install" + + # There may be an optional sh(1) argument at the beginning of + # install_prog (especially on Windows NT). + if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then + # Aesthetically quote it. + arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$arg " + arg="$1" + shift + else + install_prog= + arg="$nonopt" + fi + + # The real first argument should be the name of the installation program. + # Aesthetically quote it. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog$arg" + + # We need to accept at least all the BSD install flags. + dest= + files= + opts= + prev= + install_type= + isdir=no + stripme= + for arg + do + if test -n "$dest"; then + files="$files $dest" + dest="$arg" + continue + fi + + case "$arg" in + -d) isdir=yes ;; + -f) prev="-f" ;; + -g) prev="-g" ;; + -m) prev="-m" ;; + -o) prev="-o" ;; + -s) + stripme=" -s" + continue + ;; + -*) ;; + + *) + # If the previous option needed an argument, then skip it. + if test -n "$prev"; then + prev= + else + dest="$arg" + continue + fi + ;; + esac + + # Aesthetically quote the argument. + arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"` + case "$arg" in + *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*) + arg="\"$arg\"" + ;; + esac + install_prog="$install_prog $arg" + done + + if test -z "$install_prog"; then + $echo "$modename: you must specify an install program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -n "$prev"; then + $echo "$modename: the \`$prev' option requires an argument" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + if test -z "$files"; then + if test -z "$dest"; then + $echo "$modename: no file or destination specified" 1>&2 + else + $echo "$modename: you must specify a destination" 1>&2 + fi + $echo "$help" 1>&2 + exit 1 + fi + + # Strip any trailing slash from the destination. + dest=`$echo "X$dest" | $Xsed -e 's%/$%%'` + + # Check to see that the destination is a directory. + test -d "$dest" && isdir=yes + if test "$isdir" = yes; then + destdir="$dest" + destname= + else + destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'` + test "X$destdir" = "X$dest" && destdir=. + destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'` + + # Not a directory, so check to see that there is only one file specified. + set dummy $files + if test $# -gt 2; then + $echo "$modename: \`$dest' is not a directory" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + fi + case "$destdir" in + [\\/]* | [A-Za-z]:[\\/]*) ;; + *) + for file in $files; do + case "$file" in + *.lo) ;; + *) + $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + done + ;; + esac + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + staticlibs= + future_libdirs= + current_libdirs= + for file in $files; do + + # Do each installation. + case "$file" in + *.a | *.lib) + # Do the static libraries later. + staticlibs="$staticlibs $file" + ;; + + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$file' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + library_names= + old_library= + relink_command= + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Add the libdir to current_libdirs if it is the destination. + if test "X$destdir" = "X$libdir"; then + case "$current_libdirs " in + *" $libdir "*) ;; + *) current_libdirs="$current_libdirs $libdir" ;; + esac + else + # Note the libdir as a future libdir. + case "$future_libdirs " in + *" $libdir "*) ;; + *) future_libdirs="$future_libdirs $libdir" ;; + esac + fi + + dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/" + test "X$dir" = "X$file/" && dir= + dir="$dir$objdir" + + if test "$hardcode_into_libs" = yes; then + if test -z "$relink_command"; then + $echo "$modename: invalid libtool pseudo library \`$file'" 1>&2 + exit 1 + fi + $echo "$modename: warning: relinking \`$file'" 1>&2 + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + continue + fi + fi + + # See the names of the shared library. + set dummy $library_names + if test -n "$2"; then + realname="$2" + shift + shift + + srcname="$realname" + test "$hardcode_into_libs" = yes && srcname="$realname"T + + # Install the shared library and build the symlinks. + $show "$install_prog $dir/$srcname $destdir/$realname" + $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $? + if test -n "$stripme" && test -n "$striplib"; then + $show "$striplib $destdir/$realname" + $run eval "$striplib $destdir/$realname" || exit $? + fi + + if test $# -gt 0; then + # Delete the old symlinks, and create new ones. + for linkname + do + if test "$linkname" != "$realname"; then + $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)" + fi + done + fi + + # Do each command in the postinstall commands. + lib="$destdir/$realname" + eval cmds=\"$postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + fi + + # Install the pseudo-library for information purposes. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + instname="$dir/$name"i + $show "$install_prog $instname $destdir/$name" + $run eval "$install_prog $instname $destdir/$name" || exit $? + + # Maybe install the static library, too. + test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" + ;; + + *.lo) + # Install (i.e. copy) a libtool object. + + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Deduce the name of the destination old-style object file. + case "$destfile" in + *.lo) + staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"` + ;; + *.o | *.obj) + staticdest="$destfile" + destfile= + ;; + *) + $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; + esac + + # Install the libtool object if requested. + if test -n "$destfile"; then + $show "$install_prog $file $destfile" + $run eval "$install_prog $file $destfile" || exit $? + fi + + # Install the old object if enabled. + if test "$build_old_libs" = yes; then + # Deduce the name of the old-style object file. + staticobj=`$echo "X$file" | $Xsed -e "$lo2o"` + + $show "$install_prog $staticobj $staticdest" + $run eval "$install_prog \$staticobj \$staticdest" || exit $? + fi + exit 0 + ;; + + *) + # Figure out destination file name, if it wasn't already specified. + if test -n "$destname"; then + destfile="$destdir/$destname" + else + destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + destfile="$destdir/$destfile" + fi + + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + link_against_libtool_libs= + relink_command= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Check the variables that should have been set. + if test -z "$link_against_libtool_libs"; then + $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2 + exit 1 + fi + + finalize=yes + for lib in $link_against_libtool_libs; do + # Check to see that each library is installed. + libdir= + if test -f "$lib"; then + # If there is no directory component, then add one. + case "$lib" in + */* | *\\*) . $lib ;; + *) . ./$lib ;; + esac + fi + libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`" + if test -n "$libdir" && test ! -f "$libfile"; then + $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2 + finalize=no + fi + done + + relink_command= + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + outputname= + if test "$fast_install" = no && test -n "$relink_command"; then + if test "$finalize" = yes && test -z "$run"; then + tmpdir="/tmp" + test -n "$TMPDIR" && tmpdir="$TMPDIR" + tmpdir="$tmpdir/libtool-$$" + if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then : + else + $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2 + continue + fi + outputname="$tmpdir/$file" + # Replace the output file specification. + relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` + + $show "$relink_command" + if $run eval "$relink_command"; then : + else + $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2 + ${rm}r "$tmpdir" + continue + fi + file="$outputname" + else + $echo "$modename: warning: cannot relink \`$file'" 1>&2 + fi + else + # Install the binary that we compiled earlier. + file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` + fi + fi + + $show "$install_prog$stripme $file $destfile" + $run eval "$install_prog\$stripme \$file \$destfile" || exit $? + test -n "$outputname" && ${rm}r "$tmpdir" + ;; + esac + done + + for file in $staticlibs; do + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + # Set up the ranlib parameters. + oldlib="$destdir/$name" + + $show "$install_prog $file $oldlib" + $run eval "$install_prog \$file \$oldlib" || exit $? + + if test -n "$stripme" && test -n "$striplib"; then + $show "$old_striplib $oldlib" + $run eval "$old_striplib $oldlib" || exit $? + fi + + # Do each command in the postinstall commands. + eval cmds=\"$old_postinstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || exit $? + done + IFS="$save_ifs" + done + + if test -n "$future_libdirs"; then + $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2 + fi + + if test -n "$current_libdirs"; then + # Maybe just do a dry run. + test -n "$run" && current_libdirs=" -n$current_libdirs" + exec $SHELL $0 --finish$current_libdirs + exit 1 + fi + + exit 0 + ;; + + # libtool finish mode + finish) + modename="$modename: finish" + libdirs="$nonopt" + admincmds= + + if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then + for dir + do + libdirs="$libdirs $dir" + done + + for libdir in $libdirs; do + if test -n "$finish_cmds"; then + # Do each command in the finish commands. + eval cmds=\"$finish_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" || admincmds="$admincmds + $cmd" + done + IFS="$save_ifs" + fi + if test -n "$finish_eval"; then + # Do the single finish_eval. + eval cmds=\"$finish_eval\" + $run eval "$cmds" || admincmds="$admincmds + $cmds" + fi + done + fi + + # Exit here if they wanted silent mode. + test "$show" = : && exit 0 + + echo "----------------------------------------------------------------------" + echo "Libraries have been installed in:" + for libdir in $libdirs; do + echo " $libdir" + done + echo + echo "If you ever happen to want to link against installed libraries" + echo "in a given directory, LIBDIR, you must either use libtool, and" + echo "specify the full pathname of the library, or use \`-LLIBDIR'" + echo "flag during linking and do at least one of the following:" + if test -n "$shlibpath_var"; then + echo " - add LIBDIR to the \`$shlibpath_var' environment variable" + echo " during execution" + fi + if test -n "$runpath_var"; then + echo " - add LIBDIR to the \`$runpath_var' environment variable" + echo " during linking" + fi + if test -n "$hardcode_libdir_flag_spec"; then + libdir=LIBDIR + eval flag=\"$hardcode_libdir_flag_spec\" + + echo " - use the \`$flag' linker flag" + fi + if test -n "$admincmds"; then + echo " - have your system administrator run these commands:$admincmds" + fi + if test -f /etc/ld.so.conf; then + echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" + fi + echo + echo "See any operating system documentation about shared libraries for" + echo "more information, such as the ld(1) and ld.so(8) manual pages." + echo "----------------------------------------------------------------------" + exit 0 + ;; + + # libtool clean mode + clean) + modename="$modename: clean" + rm="$nonopt" + files= + + # This variable tells wrapper scripts just to set variables rather + # than running their programs. + libtool_install_magic="$magic" + + for arg + do + case "$arg" in + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + if test "X$dir" = "X$file"; then + dir=. + objdir="$objdir" + else + objdir="$dir/$objdir" + fi + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + rmfiles="$file" + + case "$file" in + *.la) + # Possibly a libtool archive, so verify it. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . ./$file + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $objdir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" + rmfiles="$rmfiles $objdir/$name $objdir/${name}i" + fi + ;; + + *.lo) + if test "$build_old_libs" = yes; then + oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` + rmfiles="$rmfiles $dir/$oldobj" + fi + ;; + + *) + # Do a test to see if this is a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + relink_command= + . $dir/$file + + rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" + if test "$fast_install" = yes && test -n "$relink_command"; then + rmfiles="$rmfiles $objdir/lt-$name" + fi + fi + ;; + esac + $show "$rm $rmfiles" + $run $rm $rmfiles + done + exit 0 + ;; + + # libtool execute mode + execute) + modename="$modename: execute" + + # The first argument is the command name. + cmd="$nonopt" + if test -z "$cmd"; then + $echo "$modename: you must specify a COMMAND" 1>&2 + $echo "$help" + exit 1 + fi + + # Handle -dlopen flags immediately. + for file in $execute_dlfiles; do + if test ! -f "$file"; then + $echo "$modename: \`$file' is not a file" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + dir= + case "$file" in + *.la) + # Check to see that this really is a libtool archive. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then : + else + $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + # Read the libtool library. + dlname= + library_names= + + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Skip this library if it cannot be dlopened. + if test -z "$dlname"; then + # Warn if it was a shared library. + test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'" + continue + fi + + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + + if test -f "$dir/$objdir/$dlname"; then + dir="$dir/$objdir" + else + $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2 + exit 1 + fi + ;; + + *.lo) + # Just add the directory containing the .lo file. + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + ;; + + *) + $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2 + continue + ;; + esac + + # Get the absolute pathname. + absdir=`cd "$dir" && pwd` + test -n "$absdir" && dir="$absdir" + + # Now add the directory to shlibpath_var. + if eval "test -z \"\$$shlibpath_var\""; then + eval "$shlibpath_var=\"\$dir\"" + else + eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" + fi + done + + # This variable tells wrapper scripts just to set shlibpath_var + # rather than running their programs. + libtool_execute_magic="$magic" + + # Check if any of the arguments is a wrapper script. + args= + for file + do + case "$file" in + -*) ;; + *) + # Do a test to see if this is really a libtool program. + if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + # If there is no directory component, then add one. + case "$file" in + */* | *\\*) . $file ;; + *) . ./$file ;; + esac + + # Transform arg to wrapped name. + file="$progdir/$program" + fi + ;; + esac + # Quote arguments (to preserve shell metacharacters). + file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"` + args="$args \"$file\"" + done + + if test -z "$run"; then + if test -n "$shlibpath_var"; then + # Export the shlibpath_var. + eval "export $shlibpath_var" + fi + + # Restore saved enviroment variables + if test "${save_LC_ALL+set}" = set; then + LC_ALL="$save_LC_ALL"; export LC_ALL + fi + if test "${save_LANG+set}" = set; then + LANG="$save_LANG"; export LANG + fi + + # Now actually exec the command. + eval "exec \$cmd$args" + + $echo "$modename: cannot exec \$cmd$args" + exit 1 + else + # Display what would be done. + if test -n "$shlibpath_var"; then + eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\"" + $echo "export $shlibpath_var" + fi + $echo "$cmd$args" + exit 0 + fi + ;; + + # libtool uninstall mode + uninstall) + modename="$modename: uninstall" + rm="$nonopt" + files= + + for arg + do + case "$arg" in + -*) rm="$rm $arg" ;; + *) files="$files $arg" ;; + esac + done + + if test -z "$rm"; then + $echo "$modename: you must specify an RM program" 1>&2 + $echo "$help" 1>&2 + exit 1 + fi + + for file in $files; do + dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'` + test "X$dir" = "X$file" && dir=. + name=`$echo "X$file" | $Xsed -e 's%^.*/%%'` + + rmfiles="$file" + + case "$name" in + *.la) + # Possibly a libtool archive, so verify it. + if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then + . $dir/$name + + # Delete the libtool libraries and symlinks. + for n in $library_names; do + rmfiles="$rmfiles $dir/$n" + done + test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library" + + $show "$rm $rmfiles" + $run $rm $rmfiles + + if test -n "$library_names"; then + # Do each command in the postuninstall commands. + eval cmds=\"$postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + if test -n "$old_library"; then + # Do each command in the old_postuninstall commands. + eval cmds=\"$old_postuninstall_cmds\" + IFS="${IFS= }"; save_ifs="$IFS"; IFS='~' + for cmd in $cmds; do + IFS="$save_ifs" + $show "$cmd" + $run eval "$cmd" + done + IFS="$save_ifs" + fi + + # FIXME: should reinstall the best remaining shared library. + fi + ;; + + *.lo) + if test "$build_old_libs" = yes; then + oldobj=`$echo "X$name" | $Xsed -e "$lo2o"` + rmfiles="$rmfiles $dir/$oldobj" + fi + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + + *) + $show "$rm $rmfiles" + $run $rm $rmfiles + ;; + esac + done + exit 0 + ;; + + "") + $echo "$modename: you must specify a MODE" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 + ;; + esac + + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$generic_help" 1>&2 + exit 1 +fi # test -z "$show_help" + +# We need to display help for each of the modes. +case "$mode" in +"") $echo \ +"Usage: $modename [OPTION]... [MODE-ARG]... + +Provide generalized library-building support services. + + --config show all configuration variables + --debug enable verbose shell tracing +-n, --dry-run display commands without modifying any files + --features display basic configuration information and exit + --finish same as \`--mode=finish' + --help display this help message and exit + --mode=MODE use operation mode MODE [default=inferred from MODE-ARGS] + --quiet same as \`--silent' + --silent don't print informational messages + --version print version information + +MODE must be one of the following: + + clean remove files from the build directory + compile compile a source file into a libtool object + execute automatically set library path, then run a program + finish complete the installation of libtool libraries + install install libraries or executables + link create a library or an executable + uninstall remove libraries from an installed directory + +MODE-ARGS vary depending on the MODE. Try \`$modename --help --mode=MODE' for +a more detailed description of MODE." + exit 0 + ;; + +clean) + $echo \ +"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE... + +Remove files from the build directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, object or program, all the files associated +with it are deleted. Otherwise, only FILE itself is deleted using RM." + ;; + +compile) + $echo \ +"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE + +Compile a source file into a libtool library object. + +This mode accepts the following additional options: + + -o OUTPUT-FILE set the output file name to OUTPUT-FILE + -static always build a \`.o' file suitable for static linking + +COMPILE-COMMAND is a command to be used in creating a \`standard' object file +from the given SOURCEFILE. + +The output file name is determined by removing the directory component from +SOURCEFILE, then substituting the C source code suffix \`.c' with the +library object suffix, \`.lo'." + ;; + +execute) + $echo \ +"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]... + +Automatically set library path, then run a program. + +This mode accepts the following additional options: + + -dlopen FILE add the directory containing FILE to the library path + +This mode sets the library path environment variable according to \`-dlopen' +flags. + +If any of the ARGS are libtool executable wrappers, then they are translated +into their corresponding uninstalled binary, and any of their required library +directories are added to the library path. + +Then, COMMAND is executed, with ARGS as arguments." + ;; + +finish) + $echo \ +"Usage: $modename [OPTION]... --mode=finish [LIBDIR]... + +Complete the installation of libtool libraries. + +Each LIBDIR is a directory that contains libtool libraries. + +The commands that this mode executes may require superuser privileges. Use +the \`--dry-run' option if you just want to see what would be executed." + ;; + +install) + $echo \ +"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND... + +Install executables or libraries. + +INSTALL-COMMAND is the installation command. The first component should be +either the \`install' or \`cp' program. + +The rest of the components are interpreted as arguments to that command (only +BSD-compatible install options are recognized)." + ;; + +link) + $echo \ +"Usage: $modename [OPTION]... --mode=link LINK-COMMAND... + +Link object files or libraries together to form another library, or to +create an executable program. + +LINK-COMMAND is a command using the C compiler that you would use to create +a program from several object files. + +The following components of LINK-COMMAND are treated specially: + + -all-static do not do any dynamic linking at all + -avoid-version do not add a version suffix if possible + -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime + -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols + -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) + -export-symbols SYMFILE + try to export only the symbols listed in SYMFILE + -export-symbols-regex REGEX + try to export only the symbols matching REGEX + -LLIBDIR search LIBDIR for required installed libraries + -lNAME OUTPUT-FILE requires the installed library libNAME + -module build a library that can dlopened + -no-undefined declare that a library does not refer to external symbols + -o OUTPUT-FILE create OUTPUT-FILE from the specified objects + -release RELEASE specify package release information + -rpath LIBDIR the created library will eventually be installed in LIBDIR + -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries + -static do not do any dynamic linking of libtool libraries + -version-info CURRENT[:REVISION[:AGE]] + specify library version info [each variable defaults to 0] + +All other options (arguments beginning with \`-') are ignored. + +Every other argument is treated as a filename. Files ending in \`.la' are +treated as uninstalled libtool libraries, other files are standard or library +object files. + +If the OUTPUT-FILE ends in \`.la', then a libtool library is created, +only library objects (\`.lo' files) may be specified, and \`-rpath' is +required, except when creating a convenience library. + +If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created +using \`ar' and \`ranlib', or on Windows using \`lib'. + +If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file +is created, otherwise an executable program is created." + ;; + +uninstall) + $echo \ +"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... + +Remove libraries from an installation directory. + +RM is the name of the program to use to delete files associated with each FILE +(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed +to RM. + +If FILE is a libtool library, all the files associated with it are deleted. +Otherwise, only FILE itself is deleted using RM." + ;; + +*) + $echo "$modename: invalid operation mode \`$mode'" 1>&2 + $echo "$help" 1>&2 + exit 1 + ;; +esac + +echo +$echo "Try \`$modename --help' for more information about other modes." + +exit 0 + +# Local Variables: +# mode:shell-script +# sh-indentation:2 +# End: diff --git a/mikmod/Makefile.am b/mikmod/Makefile.am new file mode 100644 index 00000000..4c26c4a9 --- /dev/null +++ b/mikmod/Makefile.am @@ -0,0 +1,29 @@ + +noinst_LTLIBRARIES = libmikmod.la + +libmikmod_la_SOURCES = \ + drv_nos.c \ + drv_sdl.c \ + load_it.c \ + load_mod.c \ + load_s3m.c \ + load_xm.c \ + mdreg.c \ + mdriver.c \ + mikmod.h \ + mloader.c \ + mlreg.c \ + mmalloc.c \ + mmerror.c \ + mmio.c \ + mmio.h \ + mplayer.c \ + munitrk.c \ + npertab.c \ + ptform.h \ + s3m_it.c \ + sloader.c \ + tdefs.h \ + virtch.c + +EXTRA_DIST = README license.txt diff --git a/mikmod/Makefile.in b/mikmod/Makefile.in new file mode 100644 index 00000000..4dbfd767 --- /dev/null +++ b/mikmod/Makefile.in @@ -0,0 +1,344 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +BINARY_AGE = @BINARY_AGE@ +CC = @CC@ +DLLTOOL = @DLLTOOL@ +INTERFACE_AGE = @INTERFACE_AGE@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +MAJOR_VERSION = @MAJOR_VERSION@ +MAKEINFO = @MAKEINFO@ +MICRO_VERSION = @MICRO_VERSION@ +MINOR_VERSION = @MINOR_VERSION@ +NM = @NM@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +VERSION = @VERSION@ + +noinst_LTLIBRARIES = libmikmod.la + +libmikmod_la_SOURCES = drv_nos.c drv_sdl.c load_it.c load_mod.c load_s3m.c load_xm.c mdreg.c mdriver.c mikmod.h mloader.c mlreg.c mmalloc.c mmerror.c mmio.c mmio.h mplayer.c munitrk.c npertab.c ptform.h s3m_it.c sloader.c tdefs.h virtch.c + + +EXTRA_DIST = README license.txt +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +libmikmod_la_LDFLAGS = +libmikmod_la_LIBADD = +libmikmod_la_OBJECTS = drv_nos.lo drv_sdl.lo load_it.lo load_mod.lo \ +load_s3m.lo load_xm.lo mdreg.lo mdriver.lo mloader.lo mlreg.lo \ +mmalloc.lo mmerror.lo mmio.lo mplayer.lo munitrk.lo npertab.lo \ +s3m_it.lo sloader.lo virtch.lo +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = README Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DEP_FILES = .deps/drv_nos.P .deps/drv_sdl.P .deps/load_it.P \ +.deps/load_mod.P .deps/load_s3m.P .deps/load_xm.P .deps/mdreg.P \ +.deps/mdriver.P .deps/mloader.P .deps/mlreg.P .deps/mmalloc.P \ +.deps/mmerror.P .deps/mmio.P .deps/mplayer.P .deps/munitrk.P \ +.deps/npertab.P .deps/s3m_it.P .deps/sloader.P .deps/virtch.P +SOURCES = $(libmikmod_la_SOURCES) +OBJECTS = $(libmikmod_la_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --foreign mikmod/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstLTLIBRARIES: + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + +distclean-noinstLTLIBRARIES: + +maintainer-clean-noinstLTLIBRARIES: + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libmikmod.la: $(libmikmod_la_OBJECTS) $(libmikmod_la_DEPENDENCIES) + $(LINK) $(libmikmod_la_LDFLAGS) $(libmikmod_la_OBJECTS) $(libmikmod_la_LIBADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = mikmod + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign mikmod/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(LTLIBRARIES) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstLTLIBRARIES clean-compile clean-libtool \ + clean-tags clean-depend clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-noinstLTLIBRARIES distclean-compile \ + distclean-libtool distclean-tags distclean-depend \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \ +clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/mikmod/README b/mikmod/README new file mode 100644 index 00000000..9510152a --- /dev/null +++ b/mikmod/README @@ -0,0 +1,14 @@ + + --> MikMod Sound Libraries Version 3.0 + -> Release Notes - August 20th, 1997 + +-- +This version of the library is based on the official UNIX MikMod version 3.0, +found at: http://freenet.tlh.fl.us/~amstpi/mikmod.html + +It has been stripped down for inclusion with Simple DirectMedia Layer, +but the missing drivers and file loaders can be plugged right in from +the MikMod 3.03 archive. + +See license.txt for copying information +-- diff --git a/mikmod/drv_nos.c b/mikmod/drv_nos.c new file mode 100644 index 00000000..6cf8f30f --- /dev/null +++ b/mikmod/drv_nos.c @@ -0,0 +1,161 @@ +/* + +Name: +DRV_NOS.C + +Description: +Mikmod driver for no output on any soundcard, monitor, keyboard, or whatever :) + +Portability: +All systems - All compilers + +*/ + +#include "mikmod.h" + + +static BOOL NS_IsThere(void) +{ + return 1; +} + + +static SWORD NS_SampleLoad(SAMPLOAD *s, int type) +{ + return 0; +} + + +static void NS_SampleUnload(SWORD h) +{ +} + + +static ULONG NS_SampleSpace(int type) +{ + return 0; +} + + +static ULONG NS_SampleLength(int type, SAMPLE *s) +{ + return s->length; +} + + +static BOOL NS_Init(void) +{ + return 0; +} + + +static void NS_Exit(void) +{ +} + + +static BOOL NS_Reset(void) +{ + return 0; +} + + +static BOOL NS_PlayStart(void) +{ + return 0; +} + + +static void NS_PlayStop(void) +{ +} + + +static void NS_Update(void) +{ +} + + +static BOOL NS_SetNumVoices(void) +{ + return 0; +} + + +static void NS_VoiceSetVolume(UBYTE voice,UWORD vol) +{ +} + + +static void NS_VoiceSetFrequency(UBYTE voice,ULONG frq) +{ +} + + +static void NS_VoiceSetPanning(UBYTE voice,ULONG pan) +{ +} + + +static void NS_VoicePlay(UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags) +{ +} + + +static void NS_VoiceStop(UBYTE voice) +{ +} + + +static BOOL NS_VoiceStopped(UBYTE voice) +{ + return 0; +} + + +static void NS_VoiceReleaseSustain(UBYTE voice) +{ +} + + +static SLONG NS_VoiceGetPosition(UBYTE voice) +{ + return 0; +} + + +static ULONG NS_VoiceRealVolume(UBYTE voice) +{ + return 0; +} + + + +MDRIVER drv_nos = +{ NULL, + "No Sound", + "Nosound Driver v2.0 - (c) Creative Silence", + 255,255, + NS_IsThere, + NS_SampleLoad, + NS_SampleUnload, + NS_SampleSpace, + NS_SampleLength, + NS_Init, + NS_Exit, + NS_Reset, + NS_SetNumVoices, + NS_PlayStart, + NS_PlayStop, + NS_Update, + NS_VoiceSetVolume, + NS_VoiceSetFrequency, + NS_VoiceSetPanning, + NS_VoicePlay, + NS_VoiceStop, + NS_VoiceStopped, + NS_VoiceReleaseSustain, + NS_VoiceGetPosition, + NS_VoiceRealVolume +}; + diff --git a/mikmod/drv_sdl.c b/mikmod/drv_sdl.c new file mode 100644 index 00000000..77851e97 --- /dev/null +++ b/mikmod/drv_sdl.c @@ -0,0 +1,72 @@ +/* + +Name: +DRV_SDL.C + +Description: +Mikmod driver for output using the Simple DirectMedia Layer + +*/ + +#include "mikmod.h" + + +static BOOL SDRV_IsThere(void) +{ + return 1; +} + + +static BOOL SDRV_Init(void) +{ + md_mode |= DMODE_SOFT_MUSIC | DMODE_SOFT_SNDFX; + return(VC_Init()); +} + + +static void SDRV_Exit(void) +{ + VC_Exit(); +} + + +static void SDRV_Update(void) +{ + /* does nothing, buffers are updated in the background */ +} + + +static BOOL SDRV_Reset(void) +{ + return 0; +} + + +MDRIVER drv_sdl = +{ NULL, + "SDL", + "MikMod Simple DirectMedia Layer driver v1.0", + 0,255, + SDRV_IsThere, + VC_SampleLoad, + VC_SampleUnload, + VC_SampleSpace, + VC_SampleLength, + SDRV_Init, + SDRV_Exit, + SDRV_Reset, + VC_SetNumVoices, + VC_PlayStart, + VC_PlayStop, + SDRV_Update, + VC_VoiceSetVolume, + VC_VoiceSetFrequency, + VC_VoiceSetPanning, + VC_VoicePlay, + VC_VoiceStop, + VC_VoiceStopped, + VC_VoiceReleaseSustain, + VC_VoiceGetPosition, + VC_VoiceRealVolume +}; + diff --git a/mikmod/license.txt b/mikmod/license.txt new file mode 100644 index 00000000..489ad35f --- /dev/null +++ b/mikmod/license.txt @@ -0,0 +1,19 @@ +MikMod is now under a "free-with-no-strings-attached-if-it-breaks-you-get-to- +keep-both-pieces" type of license. Basically this means: + +a) We're not responsible for anything you do with this program, anything +anything this program does to you, or for the little incident involving +the goat, the nun, and the jar of vasoline that occurred last summer. + +b) We're not charging you anything for this. You don't owe us anything. +On the other hand, we don't owe you anything, either. Try to keep that in +mind when writing us... We'd also prefer that, should you pass this program +on to friends, that you keep it free for them too. And keep this message +intact as well. + + +This is open-source software. That means the source code is free +for you to inspect and dissect, learn from, be disgusted by, whatever. +If you make any great additions to MikMod, we'd like to see them! + + - Peter Amstutz diff --git a/mikmod/load_it.c b/mikmod/load_it.c new file mode 100644 index 00000000..7403bb52 --- /dev/null +++ b/mikmod/load_it.c @@ -0,0 +1,857 @@ +/* + + Name: LOAD_IT.C + + Description: + ImpulseTracker (IT) module loader + + Portability: + All systems - all compilers (hopefully) + + Copyright 1997 by Jake Stine and Divine Entertainment + + If this module is found to not be portable to any particular platform, + please contact Jake Stine at dracoirs@epix.net (see MIKMOD.TXT for + more information on contacting the author). +*/ + +#include +#include "mikmod.h" + +/************************************************************************** +**************************************************************************/ + +typedef struct ITNOTE +{ UBYTE note,ins,volpan,cmd,inf; +} ITNOTE; + +UBYTE *IT_ConvertTrack(ITNOTE *tr,UWORD numrows); + + +/* Raw IT header struct: */ + +typedef struct ITHEADER +{ CHAR songname[26]; + UBYTE blank01[2]; + UWORD ordnum; + UWORD insnum; + UWORD smpnum; + UWORD patnum; + UWORD cwt; /* Created with tracker (y.xx = 0x0yxx) */ + UWORD cmwt; /* Compatable with tracker ver > than val. */ + UWORD flags; + UWORD special; /* bit 0 set = song message attached */ + UBYTE globvol; + UBYTE mixvol; /* mixing volume [ignored] */ + UBYTE initspeed; + UBYTE inittempo; + UBYTE pansep; /* panning separation between channels */ + UBYTE zerobyte; + UWORD msglength; + ULONG msgoffset; + UBYTE blank02[4]; + + UBYTE pantable[64]; + UBYTE voltable[64]; +} ITHEADER; + + +/* Raw IT sampleinfo struct: */ + +typedef struct ITSAMPLE +{ CHAR filename[12]; + UBYTE zerobyte; + UBYTE globvol; + UBYTE flag; + UBYTE volume; + UBYTE panning; + CHAR sampname[28]; + UWORD convert; /* sample conversion flag */ + ULONG length; + ULONG loopbeg; + ULONG loopend; + ULONG c5spd; + ULONG susbegin; + ULONG susend; + ULONG sampoffset; + UBYTE vibspeed; + UBYTE vibdepth; + UBYTE vibrate; + UBYTE vibwave; /* 0 = sine; 1 = rampdown; 2 = square; 3 = random (speed ignored) */ + + UBYTE noteindex; /* for converting c5spd to finetune */ +} ITSAMPLE; + + +typedef struct ITINSTHEADER +{ ULONG size; /* (dword) Instrument size */ + CHAR filename[12]; /* (char) Instrument filename */ + UBYTE zerobyte; /* (byte) Instrument type (always 0) */ + UBYTE volflg; + UBYTE volpts; + UBYTE volbeg; /* (byte) Volume loop start (node) */ + UBYTE volend; /* (byte) Volume loop end (node) */ + UBYTE volsusbeg; /* (byte) Volume sustain begin (node) */ + UBYTE volsusend; /* (byte) Volume Sustain end (node) */ + UBYTE panflg; + UBYTE panpts; + UBYTE panbeg; /* (byte) channel loop start (node) */ + UBYTE panend; /* (byte) channel loop end (node) */ + UBYTE pansusbeg; /* (byte) cahnnel sustain begin (node) */ + UBYTE pansusend; /* (byte) channel Sustain end (node) */ + UBYTE pitflg; + UBYTE pitpts; + UBYTE pitbeg; /* (byte) pitch loop start (node) */ + UBYTE pitend; /* (byte) pitch loop end (node) */ + UBYTE pitsusbeg; /* (byte) pitch sustain begin (node) */ + UBYTE pitsusend; /* (byte) pitch Sustain end (node) */ + UWORD blank; + UBYTE globvol; + UBYTE chanpan; + UWORD fadeout; /* Envelope end / NNA volume fadeout */ + UBYTE dnc; /* Duplicate note check */ + UBYTE dca; /* Duplicate check action */ + UBYTE dct; /* Duplicate check type */ + UBYTE nna; /* New Note Action [0,1,2,3] */ + UWORD trkvers; /* tracker version used to save [in files only] */ + UBYTE ppsep; /* Pitch-pan Separation */ + UBYTE ppcenter; /* Pitch-pan Center */ + UBYTE rvolvar; /* random volume varations */ + UBYTE rpanvar; /* random panning varations */ + UWORD numsmp; /* Number of samples in instrument [in files only] */ + CHAR name[26]; /* Instrument name */ + UBYTE blank01[6]; + UWORD samptable[120]; /* sample for each note [note / samp pairs] */ + + UBYTE volenv[200]; /* volume envelope (IT 1.x stuff) */ + UBYTE oldvoltick[25]; /* volume tick position (IT 1.x stuff) */ + UBYTE volnode[25]; /* aplitude of volume nodes */ + UWORD voltick[25]; /* tick value of volume nodes */ + SBYTE pannode[25]; /* panenv - node points */ + UWORD pantick[25]; /* tick value of panning nodes */ + SBYTE pitnode[25]; /* pitchenv - node points */ + UWORD pittick[25]; /* tick value of pitch nodes */ +} ITINSTHEADER; + + +/************************************************************************** +**************************************************************************/ + +extern SBYTE remap[64]; /* for removing empty channels */ +extern UBYTE *poslookup; /* S3M/IT fix - removing blank patterns needs a */ + /* lookup table to fix position-jump commands */ +static ULONG *paraptr = NULL; /* parapointer array (see IT docs) */ +static ITHEADER *mh = NULL; +static ITNOTE *itpat = NULL; /* allocate to space for one full pattern */ +static UBYTE *mask = NULL; /* arrays allocated to 64 elements and used for */ +static ITNOTE *last = NULL; /* uncompressing IT's pattern information */ +static int numtrk = 0; +static int old_effect; /* if set, use S3M old-effects stuffs */ +static int *noteindex; + +CHAR IT_Version[] = "ImpulseTracker x.xx"; + + +BOOL IT_Test(void) +{ + UBYTE id[4]; + + if(!_mm_read_UBYTES(id,4,modfp)) return 0; + if(!memcmp(id,"IMPM",4)) return 1; + return 0; +} + +BOOL IT_Init(void) +{ + if((mh=(ITHEADER *)_mm_calloc(1,sizeof(ITHEADER)))==NULL) return 0; + if((poslookup=(UBYTE *)_mm_malloc(256*sizeof(UBYTE)))==NULL) return 0; + if((itpat=(ITNOTE *)_mm_malloc(200*64*sizeof(ITNOTE)))==NULL) return 0; + if((mask=(UBYTE *)_mm_malloc(64*sizeof(UBYTE)))==NULL) return 0; + if((last=(ITNOTE *)_mm_malloc(64*sizeof(ITNOTE)))==NULL) return 0; + + return 1; +} + +void IT_Cleanup(void) +{ + if(mh!=NULL) free(mh); + if(poslookup!=NULL) free(poslookup); + if(itpat!=NULL) free(itpat); + if(mask!=NULL) free(mask); + if(last!=NULL) free(last); + if(paraptr!=NULL) free(paraptr); + if(noteindex!=NULL) free(noteindex); + + mh = NULL; + poslookup = NULL; + itpat = NULL; + mask = NULL; + last = NULL; + paraptr = NULL; + noteindex = NULL; +} + + +BOOL IT_GetNumChannels(UWORD patrows) + +/* Because so many IT files have 64 channels as the set number used, but really */ +/* only use far less (usually 8 to 12 still), I had to make this function, */ +/* which determines the number of channels that are actually USED by a pattern. */ +/* */ +/* For every channel that's used, it sets the appropriate array entry of the */ +/* global varialbe 'isused' */ +/* */ +/* NOTE: You must first seek to the file location of the pattern before calling */ +/* this procedure. */ +/* Returns 1 on error */ +{ + int row=0,flag,ch; + + do + { flag = _mm_read_UBYTE(modfp); + if(flag == EOF) + { _mm_errno = MMERR_LOADING_PATTERN; + return 1; + } + + if(flag == 0) + { row++; + } else + { ch = (flag-1) & 63; + remap[ch] = 0; + if(flag & 128) mask[ch] = _mm_read_UBYTE(modfp); + if(mask[ch] & 1) _mm_read_UBYTE(modfp); + if(mask[ch] & 2) _mm_read_UBYTE(modfp); + if(mask[ch] & 4) _mm_read_UBYTE(modfp); + if(mask[ch] & 8) { _mm_read_UBYTE(modfp); _mm_read_UBYTE(modfp); } + } + } while(row < patrows); + + return 0; +} + + +BOOL IT_ReadPattern(UWORD patrows) +{ + int blah; + int row=0,flag,ch; + ITNOTE *itt = itpat, dummy,*n,*l; + + memset(itt,255,patrows*of.numchn*sizeof(ITNOTE)); + + do + { flag = _mm_read_UBYTE(modfp); + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_PATTERN; + return 0; + } + if(flag == 0) + { itt = &itt[of.numchn]; + row++; + } else + { ch = remap[(flag-1) & 63]; + if(ch != -1) + { n = &itt[ch]; + l = &last[ch]; + } else + { n = l = &dummy; } + + if(flag & 128) mask[ch] = _mm_read_UBYTE(modfp); + if(mask[ch] & 1) if((l->note = n->note = _mm_read_UBYTE(modfp)) == 255) + { l->note = n->note = 253; } + if(mask[ch] & 2) l->ins = n->ins = _mm_read_UBYTE(modfp); + if(mask[ch] & 4) l->volpan = n->volpan = _mm_read_UBYTE(modfp); + if(mask[ch] & 8) { l->cmd = n->cmd = _mm_read_UBYTE(modfp); + l->inf = n->inf = _mm_read_UBYTE(modfp); } + if(mask[ch] & 16) n->note = l->note; + if(mask[ch] & 32) n->ins = l->ins; + if(mask[ch] & 64) n->volpan = l->volpan; + if(mask[ch] & 128) { n->cmd = l->cmd; + n->inf = l->inf; } + } + } while(row < patrows); + + for(blah=0; blah=65) && (volpan<=74)) /* fine volume slide up (65-74) */ + { UniVolEffect(VOL_VOLSLIDE,0x0f + ((volpan-65)<<4)); + } else if((volpan>=75) && (volpan<=84)) /* fine volume slide down (75-84) */ + { UniVolEffect(VOL_VOLSLIDE,0xf0 + (volpan-75)); + } else if((volpan>=85) && (volpan<=94)) /* volume slide up (85-94) */ + { UniVolEffect(VOL_VOLSLIDE,((volpan-85)<<4)); + } else if((volpan>=95) && (volpan<=104)) /* volume slide down (95-104) */ + { UniVolEffect(VOL_VOLSLIDE,(volpan-95)); + } else if((volpan>=105) && (volpan<=114)) /* pitch slide up (105-114) */ + { UniVolEffect(VOL_PITCHSLIDEDN,((volpan-105)<<4)); + } else if((volpan>=115) && (volpan<=124)) /* pitch slide down (115-124) */ + { UniVolEffect(VOL_PITCHSLIDEUP,(volpan-115)); + } else if((volpan>=128) && (volpan<=192)) + { UniVolEffect(VOL_PANNING,((volpan-128) == 64) ? 255 : ((volpan-128) << 2)); + } else if((volpan>=193) && (volpan<=202)) /* portamento to note */ + { UniVolEffect(VOL_PORTAMENTO,portatable[volpan-193]); + } else if((volpan>=203) && (volpan<=212)) /* vibrato */ + { UniVolEffect(VOL_VIBRATO,(volpan-203)); + } + + S3MIT_ProcessCmd(tr[t*of.numchn].cmd,tr[t*of.numchn].inf,old_effect); + + UniNewline(); + } + return UniDup(); +} + + +int cvt_c5spd_to_finetune(ULONG c5spd, int sampnum) +{ + int ctmp=0,tmp,note=1,finetune=0; + + c5spd/=2; + + do + { tmp = getfrequency(of.flags,getlinearperiod(note,0)); + if(tmp >= c5spd) break; + ctmp = tmp; + note++; + } while(1); + + if(tmp != c5spd) + { if((tmp-c5spd) < (c5spd-ctmp)) + while(tmp>c5spd) tmp = getfrequency(of.flags,getlinearperiod(note,--finetune)); + else + { note--; + while(ctmpsongname,26,modfp); + _mm_read_UBYTES(mh->blank01,2,modfp); + mh->ordnum =_mm_read_I_UWORD(modfp); + mh->insnum =_mm_read_I_UWORD(modfp); + mh->smpnum =_mm_read_I_UWORD(modfp); + mh->patnum =_mm_read_I_UWORD(modfp); + mh->cwt =_mm_read_I_UWORD(modfp); + mh->cmwt =_mm_read_I_UWORD(modfp); + mh->flags =_mm_read_I_UWORD(modfp); + mh->special =_mm_read_I_UWORD(modfp); + + mh->globvol =_mm_read_UBYTE(modfp); + mh->mixvol =_mm_read_UBYTE(modfp); + mh->initspeed =_mm_read_UBYTE(modfp); + mh->inittempo =_mm_read_UBYTE(modfp); + mh->pansep =_mm_read_UBYTE(modfp); + mh->zerobyte =_mm_read_UBYTE(modfp); + mh->msglength =_mm_read_I_UWORD(modfp); + mh->msgoffset =_mm_read_I_ULONG(modfp); + _mm_read_UBYTES(mh->blank02,4,modfp); + _mm_read_UBYTES(mh->pantable,64,modfp); + _mm_read_UBYTES(mh->voltable,64,modfp); + + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_HEADER; + return 0; + } + + /* set module variables */ + + of.modtype = strdup(IT_Version); + of.modtype[15] = (mh->cwt >> 8) + 0x30; + of.modtype[17] = ((mh->cwt >> 4) & 0xf) + 0x30; + of.modtype[18] = ((mh->cwt) & 0xf) + 0x30; + of.songname = DupStr(mh->songname,26); /* make a cstr of songname */ + of.reppos = 0; + of.numpat = mh->patnum; + of.numins = mh->insnum; + of.numsmp = mh->smpnum; + of.initspeed = mh->initspeed; + of.inittempo = mh->inittempo; + of.initvolume = mh->globvol; + + old_effect = 0; + if(mh->flags & 8) { of.flags |= (UF_XMPERIODS | UF_LINEAR); old_effect |= 2; } + if((mh->cwt >= 0x106) && (mh->flags & 16)) old_effect |= 1; + + /* set panning positions */ + for(t=0; t<64; t++) + { if(mh->pantable[t] < 64) of.panning[t] = mh->pantable[t] << 2; + else if(mh->pantable[t]==64) of.panning[t] = 255; + else if(mh->pantable[t]==100) of.panning[t] = PAN_SURROUND; + } + + /* set channel volumes */ + memcpy(of.chanvol,mh->voltable,64); + + /* read the order data */ + if(!AllocPositions(mh->ordnum)) return 0; + + for(t=0; tordnum; t++) + of.positions[t] = _mm_read_UBYTE(modfp); + + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_HEADER; + return 0; + } + + of.numpos = 0; + for(t=0; tordnum; t++) + { of.positions[of.numpos] = of.positions[t]; + poslookup[t] = of.numpos; /* bug fix for FREAKY S3Ms / ITs */ + if(of.positions[t]<254) of.numpos++; + } + + if((paraptr=(ULONG *)_mm_malloc((mh->insnum+mh->smpnum+of.numpat)*sizeof(ULONG))) == NULL) return 0; + + /* read the instrument, sample, and pattern parapointers */ + _mm_read_I_ULONGS(paraptr,mh->insnum+mh->smpnum+of.numpat,modfp); + + /* now is a good time to check if the header was too short :) */ + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_HEADER; + return 0; + } + + /* Check for and load song comment */ + if(mh->special & 1) + { _mm_fseek(modfp,(long)(mh->msgoffset),SEEK_SET); + if(!ReadComment(mh->msglength)) return 0; + } + + if(!(mh->flags & 4)) of.numins = of.numsmp; + if(!AllocSamples()) return 0; + + if((noteindex=(int *)_mm_malloc(mh->smpnum*sizeof(int)))==NULL) return 0; + + q = of.samples; + + /* Load all samples (they're used either way) */ + for(t=0; tsmpnum; t++) + { ITSAMPLE s; + + /* seek to sample position */ + _mm_fseek(modfp,(long)(paraptr[mh->insnum+t] + 4),SEEK_SET); + + /* and load sample info */ + _mm_read_string(s.filename,12,modfp); + s.zerobyte = _mm_read_UBYTE(modfp); + s.globvol = _mm_read_UBYTE(modfp); + s.flag = _mm_read_UBYTE(modfp); + s.volume = _mm_read_UBYTE(modfp); + _mm_read_string(s.sampname,26,modfp); + s.convert = _mm_read_UBYTE(modfp); + s.panning = _mm_read_UBYTE(modfp); + s.length = _mm_read_I_ULONG(modfp); + s.loopbeg = _mm_read_I_ULONG(modfp); + s.loopend = _mm_read_I_ULONG(modfp); + s.c5spd = _mm_read_I_ULONG(modfp); + s.susbegin = _mm_read_I_ULONG(modfp); + s.susend = _mm_read_I_ULONG(modfp); + s.sampoffset = _mm_read_I_ULONG(modfp); + s.vibspeed = _mm_read_UBYTE(modfp); + s.vibdepth = _mm_read_UBYTE(modfp); + s.vibrate = _mm_read_UBYTE(modfp); + s.vibwave = _mm_read_UBYTE(modfp); + + + /* Generate an error if c5spd is > 512k, or samplelength > 256 megs */ + /* (nothing would EVER be that high) */ + + if(feof(modfp) || (s.c5spd > 0x7ffffL) || (s.length > 0xfffffffUL) || + (s.loopbeg > 0xfffffffUL) || (s.loopend > 0xfffffffUL)) + { _mm_errno = MMERR_LOADING_SAMPLEINFO; + return 0; + } + + q->samplename = DupStr(s.sampname,26); + + q->speed = s.c5spd / 2; + q->panning = ((s.panning & 127)==64) ? 255 : (s.panning & 127) << 2; + q->length = s.length; + q->loopstart = s.loopbeg; + q->loopend = s.loopend; + q->volume = s.volume; + q->globvol = s.globvol; + q->seekpos = s.sampoffset; + + /* =================================== */ + /* Convert speed to XM linear finetune */ + + if(of.flags & UF_LINEAR) + q->speed = cvt_c5spd_to_finetune(s.c5spd, t); + + if(s.panning & 128) q->flags |= SF_OWNPAN; + + if(s.vibrate) + { q->vibflags |= AV_IT; + q->vibtype = s.vibwave; + q->vibsweep = s.vibrate * 2; + q->vibdepth = s.vibdepth; + q->vibrate = s.vibspeed; + } + + if(s.flag & 2) q->flags |= SF_16BITS; + if(s.flag & 16) q->flags |= SF_LOOP; + if(s.flag & 64) q->flags |= SF_BIDI; + + if(mh->cwt >= 0x200) + { if(s.convert & 1) q->flags |= SF_SIGNED; + if(s.convert & 4) q->flags |= SF_DELTA; + } + + q++; + } + + /* Load instruments if instrument mode flag enabled */ + + if(mh->flags & 4) + { if(!AllocInstruments()) return 0; + d = of.instruments; + of.flags |= UF_NNA | UF_INST; + + for(t=0; tinsnum; t++) + { ITINSTHEADER ih; + + /* seek to instrument position */ + _mm_fseek(modfp,paraptr[t]+4,SEEK_SET); + + /* and load instrument info */ + _mm_read_string(ih.filename,12,modfp); + ih.zerobyte = _mm_read_UBYTE(modfp); + if(mh->cwt < 0x200) /* load IT 1.xx inst header */ + { ih.volflg = _mm_read_UBYTE(modfp); + ih.volbeg = _mm_read_UBYTE(modfp); + ih.volend = _mm_read_UBYTE(modfp); + ih.volsusbeg = _mm_read_UBYTE(modfp); + ih.volsusend = _mm_read_UBYTE(modfp); + _mm_read_I_UWORD(modfp); + ih.fadeout = _mm_read_I_UWORD(modfp); + ih.nna = _mm_read_UBYTE(modfp); + ih.dnc = _mm_read_UBYTE(modfp); + } else /* Read IT200+ header */ + { ih.nna = _mm_read_UBYTE(modfp); + ih.dct = _mm_read_UBYTE(modfp); + ih.dca = _mm_read_UBYTE(modfp); + ih.fadeout = _mm_read_I_UWORD(modfp); + ih.ppsep = _mm_read_UBYTE(modfp); + ih.ppcenter = _mm_read_UBYTE(modfp); + ih.globvol = _mm_read_UBYTE(modfp); + ih.chanpan = _mm_read_UBYTE(modfp); + ih.rvolvar = _mm_read_UBYTE(modfp); + ih.rpanvar = _mm_read_UBYTE(modfp); + } + + ih.trkvers = _mm_read_I_UWORD(modfp); + ih.numsmp = _mm_read_UBYTE(modfp); + _mm_read_UBYTE(modfp); + _mm_read_string(ih.name,26,modfp); + _mm_read_UBYTES(ih.blank01,6,modfp); + _mm_read_I_UWORDS(ih.samptable,120,modfp); + if(mh->cwt < 0x200) /* load IT 1xx volume envelope */ + { _mm_read_UBYTES(ih.volenv,200,modfp); + for(lp=0; lp<25; lp++) + { ih.oldvoltick[lp] = _mm_read_UBYTE(modfp); + ih.volnode[lp] = _mm_read_UBYTE(modfp); + } + } else /* load IT 2xx vol & chanpan & pitch envs */ + { ih.volflg = _mm_read_UBYTE(modfp); + ih.volpts = _mm_read_UBYTE(modfp); + ih.volbeg = _mm_read_UBYTE(modfp); + ih.volend = _mm_read_UBYTE(modfp); + ih.volsusbeg = _mm_read_UBYTE(modfp); + ih.volsusend = _mm_read_UBYTE(modfp); + for(lp=0; lp<25; lp++) + { ih.volnode[lp] = _mm_read_UBYTE(modfp); + ih.voltick[lp] = _mm_read_I_UWORD(modfp); + } + _mm_read_UBYTE(modfp); + + ih.panflg = _mm_read_UBYTE(modfp); + ih.panpts = _mm_read_UBYTE(modfp); + ih.panbeg = _mm_read_UBYTE(modfp); + ih.panend = _mm_read_UBYTE(modfp); + ih.pansusbeg = _mm_read_UBYTE(modfp); + ih.pansusend = _mm_read_UBYTE(modfp); + for(lp=0; lp<25; lp++) + { ih.pannode[lp] = _mm_read_SBYTE(modfp); + ih.pantick[lp] = _mm_read_I_UWORD(modfp); + } + _mm_read_UBYTE(modfp); + + ih.pitflg = _mm_read_UBYTE(modfp); + ih.pitpts = _mm_read_UBYTE(modfp); + ih.pitbeg = _mm_read_UBYTE(modfp); + ih.pitend = _mm_read_UBYTE(modfp); + ih.pitsusbeg = _mm_read_UBYTE(modfp); + ih.pitsusend = _mm_read_UBYTE(modfp); + for(lp=0; lp<25; lp++) + { ih.pitnode[lp] = _mm_read_SBYTE(modfp); + ih.pittick[lp] = _mm_read_I_UWORD(modfp); + } + _mm_read_UBYTE(modfp); + } + + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_SAMPLEINFO; + return 0; + } + + d->volflg |= EF_VOLENV; + d->insname = DupStr(ih.name,26); + d->nnatype = ih.nna; + + if(mh->cwt < 0x200) + { d->volfade = ih.fadeout << 6; + if(ih.dnc) + { d->dct = DCT_NOTE; + d->dca = DCA_CUT; + } + + if(ih.volflg & 1) d->volflg |= EF_ON; + if(ih.volflg & 2) d->volflg |= EF_LOOP; + if(ih.volflg & 4) d->volflg |= EF_SUSTAIN; + + /* XM conversion of IT envelope Array */ + + d->volbeg = ih.volbeg; + d->volend = ih.volend; + d->volsusbeg = ih.volsusbeg; + d->volsusend = ih.volsusend; + + if(ih.volflg & 1) + { for(u=0; u<25; u++) + if(ih.oldvoltick[d->volpts] != 0xff) + { d->volenv[d->volpts].val = (ih.volnode[d->volpts] << 2); + d->volenv[d->volpts].pos = ih.oldvoltick[d->volpts]; + d->volpts++; + } else break; + } + } else + { d->panning = ((ih.chanpan&127) == 64) ? 255 : (ih.chanpan&127)<<2; + if(!(ih.chanpan & 128)) d->flags |= IF_OWNPAN; + + if(!(ih.ppsep & 128)) + { d->pitpansep = ih.ppsep << 2; + d->pitpancenter= ih.ppcenter; + d->flags |= IF_PITCHPAN; + } + d->globvol = ih.globvol >> 1; + d->volfade = ih.fadeout << 5; + d->dct = ih.dct; + d->dca = ih.dca; + + if(mh->cwt >= 0x204) + { d->rvolvar = ih.rvolvar; + d->rpanvar = ih.rpanvar; + } + + if(ih.volflg & 1) d->volflg |= EF_ON; + if(ih.volflg & 2) d->volflg |= EF_LOOP; + if(ih.volflg & 4) d->volflg |= EF_SUSTAIN; + + if(ih.panflg & 1) d->panflg |= EF_ON; + if(ih.panflg & 2) d->panflg |= EF_LOOP; + if(ih.panflg & 4) d->panflg |= EF_SUSTAIN; + + if(ih.pitflg & 1) d->pitflg |= EF_ON; + if(ih.pitflg & 2) d->pitflg |= EF_LOOP; + if(ih.pitflg & 4) d->pitflg |= EF_SUSTAIN; + + d->volpts = ih.volpts; + d->volbeg = ih.volbeg; + d->volend = ih.volend; + d->volsusbeg = ih.volsusbeg; + d->volsusend = ih.volsusend; + + for(u=0; uvolenv[u].val = (ih.volnode[u] << 2); + d->volenv[u].pos = ih.voltick[u]; + } + + d->panpts = ih.panpts; + d->panbeg = ih.panbeg; + d->panend = ih.panend; + d->pansusbeg = ih.pansusbeg; + d->pansusend = ih.pansusend; + + for(u=0; upanenv[u].val = (ih.pannode[u]+32) << 2; + d->panenv[u].pos = ih.pantick[u]; + } + + d->pitpts = ih.pitpts; + d->pitbeg = ih.pitbeg; + d->pitend = ih.pitend; + d->pitsusbeg = ih.pitsusbeg; + d->pitsusend = ih.pitsusend; + + for(u=0; upitenv[u].val = (ih.pitnode[u]+32); + d->pitenv[u].pos = ih.pittick[u]; + } + } + + if(of.flags & UF_LINEAR) + { for(u=0; u<120; u++) + { d->samplenote[u] = (ih.samptable[u] & 255); + d->samplenumber[u] = (ih.samptable[u] >> 8) ? ((ih.samptable[u] >> 8) - 1) : 255; + if(d->samplenumber[u]!=255) + d->samplenote[u] += noteindex[d->samplenumber[u]]; + } + } else + { for(u=0; u<120; u++) + { d->samplenote[u] = (ih.samptable[u] & 255); + d->samplenumber[u] = (ih.samptable[u] >> 8) ? ((ih.samptable[u] >> 8) - 1) : 255; + } + } + + d++; + } + } else if(of.flags & UF_LINEAR) + { if(!AllocInstruments()) return 0; + d = of.instruments; + of.flags |= UF_INST; + + for(t=0; tsmpnum; t++, d++) + { for(u=0; u<120; u++) + d->samplenote[u] += noteindex[d->samplenumber[u]]; + } + } + + + /* Figure out how many channels this blasted song actually uses (what */ + /* ever happened to common courtesy of storing this simple value */ + /* somewhere in the damn module, eh!?) */ + + of.numchn = 0; + memset(remap,-1,64*sizeof(UBYTE)); + + for(t=0; tinsnum+mh->smpnum+t] != 0) /* No parapointer = pattern of 64 rows, EMPTY */ + { _mm_fseek(modfp,(((long)paraptr[mh->insnum+mh->smpnum+t])),SEEK_SET); + packlen = _mm_read_I_UWORD(modfp); + packlen = _mm_read_I_UWORD(modfp); /* read pattern length (# of rows) */ + _mm_read_I_ULONG(modfp); + if(IT_GetNumChannels(packlen)) return 0; + } + } + + /* give each of them a different number */ + for(t=0; t<64; t++) + { if(remap[t]==0) + { remap[t] = of.numchn; + of.numchn++; + } + } + + of.numtrk = of.numpat*of.numchn; + + + if(!AllocPatterns()) return 0; + if(!AllocTracks()) return 0; + + for(t=0; tinsnum+mh->smpnum+t] == 0) /* No parapointer = pattern of 64 rows, EMPTY */ + { of.pattrows[t] = 64; + for(u=0; uinsnum+mh->smpnum+t])),SEEK_SET); + packlen = _mm_read_I_UWORD(modfp); + of.pattrows[t] = _mm_read_I_UWORD(modfp); + _mm_read_I_ULONG(modfp); + + if(!IT_ReadPattern(of.pattrows[t])) return 0; + } + } + + return 1; +} + + +CHAR *IT_LoadTitle(void) +{ + CHAR s[26]; + + _mm_fseek(modfp,4,SEEK_SET); + if(!fread(s,26,1,modfp)) return NULL; + + return(DupStr(s,26)); +} + + +MLOADER load_it = +{ NULL, + "IT", + "Portable IT loader v0.2", + IT_Init, + IT_Test, + IT_Load, + IT_Cleanup, + + IT_LoadTitle +}; + diff --git a/mikmod/load_mod.c b/mikmod/load_mod.c new file mode 100644 index 00000000..856b123a --- /dev/null +++ b/mikmod/load_mod.c @@ -0,0 +1,341 @@ +/* + + Name: LOAD_MOD.C + + Description: + Generic MOD loader (Protracker, StarTracker, FastTracker, etc) + + Portability: + All systems - all compilers (hopefully) + + If this module is found to not be portable to any particular platform, + please contact Jake Stine at dracoirs@epix.net (see MIKMOD.TXT for + more information on contacting the author). + +*/ + +#include +#include "mikmod.h" + +/************************************************************************* +*************************************************************************/ + + +typedef struct MSAMPINFO /* sample header as it appears in a module */ +{ CHAR samplename[22]; + UWORD length; + UBYTE finetune; + UBYTE volume; + UWORD reppos; + UWORD replen; +} MSAMPINFO; + + +typedef struct MODULEHEADER /* verbatim module header */ +{ CHAR songname[20]; /* the songname.. */ + MSAMPINFO samples[31]; /* all sampleinfo */ + UBYTE songlength; /* number of patterns used */ + UBYTE magic1; /* should be 127 */ + UBYTE positions[128]; /* which pattern to play at pos */ + UBYTE magic2[4]; /* string "M.K." or "FLT4" or "FLT8" */ +} MODULEHEADER; + +#define MODULEHEADERSIZE 1084 + + +typedef struct MODTYPE /* struct to identify type of module */ +{ CHAR id[5]; + UBYTE channels; + CHAR *name; +} MODTYPE; + + +typedef struct MODNOTE +{ UBYTE a,b,c,d; +} MODNOTE; + + +/************************************************************************* +*************************************************************************/ + + +CHAR protracker[] = "Protracker"; +CHAR startracker[] = "Startracker"; +CHAR fasttracker[] = "Fasttracker"; +CHAR ins15tracker[] = "15-instrument"; +CHAR oktalyzer[] = "Oktalyzer"; +CHAR taketracker[] = "TakeTracker"; + + +MODTYPE modtypes[] = +{ "M.K.",4,protracker, /* protracker 4 channel */ + "M!K!",4,protracker, /* protracker 4 channel */ + "FLT4",4,startracker, /* startracker 4 channel */ + "2CHN",2,fasttracker, /* fasttracker 2 channel */ + "4CHN",4,fasttracker, /* fasttracker 4 channel */ + "6CHN",6,fasttracker, /* fasttracker 6 channel */ + "8CHN",8,fasttracker, /* fasttracker 8 channel */ + "10CH",10,fasttracker, /* fasttracker 10 channel */ + "12CH",12,fasttracker, /* fasttracker 12 channel */ + "14CH",14,fasttracker, /* fasttracker 14 channel */ + "16CH",16,fasttracker, /* fasttracker 16 channel */ + "18CH",18,fasttracker, /* fasttracker 18 channel */ + "20CH",20,fasttracker, /* fasttracker 20 channel */ + "22CH",22,fasttracker, /* fasttracker 22 channel */ + "24CH",24,fasttracker, /* fasttracker 24 channel */ + "26CH",26,fasttracker, /* fasttracker 26 channel */ + "28CH",28,fasttracker, /* fasttracker 28 channel */ + "30CH",30,fasttracker, /* fasttracker 30 channel */ + "32CH",32,fasttracker, /* fasttracker 32 channel */ + "CD81",8,oktalyzer, /* atari oktalyzer 8 channel */ + "OKTA",8,oktalyzer, /* atari oktalyzer 8 channel */ + "16CN",16,taketracker, /* taketracker 16 channel */ + "32CN",32,taketracker, /* taketracker 32 channel */ + " ",4,ins15tracker /* 15-instrument 4 channel */ +}; + +static MODULEHEADER *mh = NULL; /* raw as-is module header */ +static MODNOTE *patbuf = NULL; +static int modtype = 0; + +BOOL MOD_Test(void) +{ + UBYTE id[4]; + + _mm_fseek(modfp,MODULEHEADERSIZE-4,SEEK_SET); + if(!fread(id,4,1,modfp)) return 0; + + /* find out which ID string */ + + for(modtype=0; modtype<23; modtype++) + if(!memcmp(id,modtypes[modtype].id,4)) return 1; + + return 0; +} + + +BOOL MOD_Init(void) +{ + if(!(mh=(MODULEHEADER *)_mm_calloc(1,sizeof(MODULEHEADER)))) return 0; + return 1; +} + + +void MOD_Cleanup(void) +{ + if(mh!=NULL) free(mh); + if(patbuf!=NULL) free(patbuf); + + mh = NULL; + patbuf = NULL; +} + + +/* +Old (amiga) noteinfo: + + _____byte 1_____ byte2_ _____byte 3_____ byte4_ +/ \ / \ / \ / \ +0000 0000-00000000 0000 0000-00000000 + +Upper four 12 bits for Lower four Effect command. +bits of sam- note period. bits of sam- +ple number. ple number. + +*/ + + +void ConvertNote(MODNOTE *n) +{ + UBYTE instrument,effect,effdat,note; + UWORD period; + + /* extract the various information from the 4 bytes that */ + /* make up a single note */ + + instrument = (n->a&0x10)|(n->c>>4); + period = (((UWORD)n->a&0xf)<<8)+n->b; + effect = n->c&0xf; + effdat = n->d; + + /* Convert the period to a note number */ + + note=0; + if(period!=0) + { for(note=0; note<60; note++) + if(period >= npertab[note]) break; + note++; + if(note==61) note = 0; + } + + if(instrument!=0) UniInstrument(instrument-1); + if(note!=0) UniNote(note+23); + + /* Convert pattern jump from Dec to Hex */ + if(effect == 0xd) + effdat = (((effdat&0xf0)>>4)*10)+(effdat&0xf); + + UniPTEffect(effect,effdat); +} + + +UBYTE *ConvertTrack(MODNOTE *n) +{ + int t; + + UniReset(); + for(t=0;t<64;t++) + { ConvertNote(n); + UniNewline(); + n+=of.numchn; + } + return UniDup(); +} + + +BOOL ML_LoadPatterns(void) +/* Loads all patterns of a modfile and converts them into the */ +/* 3 byte format. */ +{ + int t,s,tracks = 0; + + if(!AllocPatterns()) return 0; + if(!AllocTracks()) return 0; + + /* Allocate temporary buffer for loading */ + /* and converting the patterns */ + + if(!(patbuf=(MODNOTE *)_mm_calloc(64U*of.numchn,sizeof(MODNOTE)))) return 0; + + for(t=0; tsongname,20,modfp); + + for(t=0; t<31; t++) + { s = &mh->samples[t]; + _mm_read_string(s->samplename,22,modfp); + s->length =_mm_read_M_UWORD(modfp); + s->finetune =_mm_read_UBYTE(modfp); + s->volume =_mm_read_UBYTE(modfp); + s->reppos =_mm_read_M_UWORD(modfp); + s->replen =_mm_read_M_UWORD(modfp); + } + + mh->songlength =_mm_read_UBYTE(modfp); + mh->magic1 =_mm_read_UBYTE(modfp); + + _mm_read_UBYTES(mh->positions,128,modfp); + _mm_read_UBYTES(mh->magic2,4,modfp); + + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_HEADER; + return 0; + } + + /* set module variables */ + + of.initspeed = 6; + of.inittempo = 125; + of.numchn = modtypes[modtype].channels; /* get number of channels */ + of.modtype = strdup(modtypes[modtype].name); /* get ascii type of mod */ + of.songname = DupStr(mh->songname,20); /* make a cstr of songname */ + of.numpos = mh->songlength; /* copy the songlength */ + + if(!AllocPositions(of.numpos)) return 0; + for(t=0; tpositions[t]; + + /* Count the number of patterns */ + + of.numpat = 0; + + for(t=0; t of.numpat) + of.numpat = of.positions[t]; + } + of.numpat++; + of.numtrk = of.numpat*of.numchn; + + /* Finally, init the sampleinfo structures */ + of.numins = of.numsmp = 31; + + if(!AllocSamples()) return 0; + + s = mh->samples; /* init source pointer */ + q = of.samples; + + for(t=0; tsamplename = DupStr(s->samplename, 22); + + /* init the sampleinfo variables and */ + /* convert the size pointers to longword format */ + + q->speed = finetune[s->finetune & 0xf]; + q->volume = s->volume; + q->loopstart = (ULONG)s->reppos << 1; + q->loopend = q->loopstart + ((ULONG)s->replen << 1); + q->length = (ULONG)s->length << 1; + + q->flags = SF_SIGNED; + if(s->replen > 1) q->flags |= SF_LOOP; + + /* fix replen if repend > length */ + if(q->loopend > q->length) q->loopend = q->length; + + s++; /* point to next source sampleinfo */ + q++; + } + + if(!ML_LoadPatterns()) return 0; + return 1; +} + + +CHAR *MOD_LoadTitle(void) +{ + CHAR s[20]; + + _mm_fseek(modfp,0,SEEK_SET); + if(!fread(s,20,1,modfp)) return NULL; + + return(DupStr(s,20)); +} + + +MLOADER load_mod = +{ NULL, + "Standard module", + "Portable MOD loader v0.11", + MOD_Init, + MOD_Test, + MOD_Load, + MOD_Cleanup, + MOD_LoadTitle +}; + diff --git a/mikmod/load_s3m.c b/mikmod/load_s3m.c new file mode 100644 index 00000000..28b7432b --- /dev/null +++ b/mikmod/load_s3m.c @@ -0,0 +1,466 @@ +/* + + Name: LOAD_S3M.C + + Description: + Screamtracker (S3M) module loader + + Portability: + All systems - all compilers (hopefully) + + If this module is found to not be portable to any particular platform, + please contact Jake Stine at dracoirs@epix.net (see MIKMOD.TXT for + more information on contacting the author). + +*/ + +#include +#include "mikmod.h" + +/************************************************************************** +**************************************************************************/ + +typedef struct S3MNOTE +{ UBYTE note,ins,vol,cmd,inf; +} S3MNOTE; + +typedef S3MNOTE S3MTRACK[64]; + + +/* Raw S3M header struct: */ + +typedef struct S3MHEADER +{ CHAR songname[28]; + UBYTE t1a; + UBYTE type; + UBYTE unused1[2]; + UWORD ordnum; + UWORD insnum; + UWORD patnum; + UWORD flags; + UWORD tracker; + UWORD fileformat; + CHAR scrm[4]; + UBYTE mastervol; + UBYTE initspeed; + UBYTE inittempo; + UBYTE mastermult; + UBYTE ultraclick; + UBYTE pantable; + UBYTE unused2[8]; + UWORD special; + UBYTE channels[32]; +} S3MHEADER; + + +/* Raw S3M sampleinfo struct: */ + +typedef struct S3MSAMPLE +{ UBYTE type; + CHAR filename[12]; + UBYTE memsegh; + UWORD memsegl; + ULONG length; + ULONG loopbeg; + ULONG loopend; + UBYTE volume; + UBYTE dsk; + UBYTE pack; + UBYTE flags; + ULONG c2spd; + UBYTE unused[12]; + CHAR sampname[28]; + CHAR scrs[4]; +} S3MSAMPLE; + +/************************************************************************** +**************************************************************************/ + + +extern UBYTE *poslookup; /* S3M/IT fix - removing blank patterns needs a */ + /* lookup table to fix position-jump commands */ +extern SBYTE remap[64]; /* for removing empty channels */ + +static S3MNOTE *s3mbuf = NULL; /* pointer to a complete S3M pattern */ +static S3MHEADER *mh = NULL; +static UWORD *paraptr = NULL; /* parapointer array (see S3M docs) */ + +CHAR S3M_Version[] = "Screamtracker 3.xx"; + +BOOL S3M_Test(void) +{ + UBYTE id[4]; + + _mm_fseek(modfp,0x2c,SEEK_SET); + if(!_mm_read_UBYTES(id,4,modfp)) return 0; + if(!memcmp(id,"SCRM",4)) return 1; + return 0; +} + +BOOL S3M_Init(void) +{ + if(!(s3mbuf = (S3MNOTE *)_mm_malloc(16*64*sizeof(S3MNOTE)))) return 0; + if(!(mh = (S3MHEADER *)_mm_calloc(1,sizeof(S3MHEADER)))) return 0; + if(!(poslookup = (UBYTE *)_mm_malloc(sizeof(UBYTE)*128))) return 0; + + return 1; +} + +void S3M_Cleanup(void) +{ + if(s3mbuf!=NULL) free(s3mbuf); + if(paraptr!=NULL) free(paraptr); + if(poslookup!=NULL) free(poslookup); + if(mh!=NULL) free(mh); + + paraptr = NULL; + s3mbuf = NULL; + poslookup = NULL; + mh = NULL; +} + + +BOOL S3M_GetNumChannels(void) + +/* Because so many s3m files have 16 channels as the set number used, but really */ +/* only use far less (usually 8 to 12 still), I had to make this function, */ +/* which determines the number of channels that are actually USED by a pattern. */ +/* */ +/* For every channel that's used, it sets the appropriate array entry of the */ +/* global varialbe 'isused' */ +/* */ +/* NOTE: You must first seek to the file location of the pattern before calling */ +/* this procedure. */ +/* Returns 1 on fail. */ + +{ + int row=0,flag,ch; + + while(row<64) + { flag = _mm_read_UBYTE(modfp); + + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_PATTERN; + return 1; + } + + if(flag) + { ch = flag&31; + if(mh->channels[ch] < 16) remap[ch] = 0; + + if(flag&32) + { _mm_read_UBYTE(modfp); + _mm_read_UBYTE(modfp); + } + + if(flag&64) + _mm_read_UBYTE(modfp); + + if(flag&128) + { _mm_read_UBYTE(modfp); + _mm_read_UBYTE(modfp); + } + } else row++; + } + + return 0; +} + + +BOOL S3M_ReadPattern(void) +{ + int row=0,flag,ch; + S3MNOTE *n; + S3MNOTE dummy; + + /* clear pattern data */ + memset(s3mbuf,255,16*64*sizeof(S3MNOTE)); + + while(row<64) + { flag = _mm_read_UBYTE(modfp); + + if(flag==EOF) + { _mm_errno = MMERR_LOADING_PATTERN; + return 0; + } + + if(flag) + { ch = remap[flag&31]; + + if(ch != -1) + n = &s3mbuf[(64U*ch)+row]; + else + n = &dummy; + + if(flag&32) + { n->note = _mm_read_UBYTE(modfp); + n->ins = _mm_read_UBYTE(modfp); + } + + if(flag&64) + n->vol = _mm_read_UBYTE(modfp); + + if(flag&128) + { n->cmd = _mm_read_UBYTE(modfp); + n->inf = _mm_read_UBYTE(modfp); + } + } else row++; + } + return 1; +} + + +void S3MIT_ProcessCmd(UBYTE cmd, UBYTE inf, BOOL oldeffect); + +UBYTE *S3M_ConvertTrack(S3MNOTE *tr) +{ + int t; + + UBYTE note,ins,vol; + + UniReset(); + for(t=0; t<64; t++) + { + note = tr[t].note; + ins = tr[t].ins; + vol = tr[t].vol; + + + if(ins!=0 && ins!=255) UniInstrument(ins-1); + if(note!=255) + { if(note==254) UniPTEffect(0xc,0); /* <- note off command */ + else UniNote(((note>>4)*12)+(note&0xf)); /* <- normal note */ + } + + if(vol<255) + UniPTEffect(0xc,vol); + + S3MIT_ProcessCmd(tr[t].cmd,tr[t].inf,1); + UniNewline(); + } + + return UniDup(); +} + + +BOOL S3M_Load(void) +{ + int t,u,track = 0; + SAMPLE *q; + UBYTE pan[32]; + + /* try to read module header */ + + _mm_read_string(mh->songname,28,modfp); + mh->t1a =_mm_read_UBYTE(modfp); + mh->type =_mm_read_UBYTE(modfp); + _mm_read_UBYTES(mh->unused1,2,modfp); + mh->ordnum =_mm_read_I_UWORD(modfp); + mh->insnum =_mm_read_I_UWORD(modfp); + mh->patnum =_mm_read_I_UWORD(modfp); + mh->flags =_mm_read_I_UWORD(modfp); + mh->tracker =_mm_read_I_UWORD(modfp); + mh->fileformat =_mm_read_I_UWORD(modfp); + _mm_read_string(mh->scrm,4,modfp); + + mh->mastervol =_mm_read_UBYTE(modfp); + mh->initspeed =_mm_read_UBYTE(modfp); + mh->inittempo =_mm_read_UBYTE(modfp); + mh->mastermult =_mm_read_UBYTE(modfp); + mh->ultraclick =_mm_read_UBYTE(modfp); + mh->pantable =_mm_read_UBYTE(modfp); + _mm_read_UBYTES(mh->unused2,8,modfp); + mh->special =_mm_read_I_UWORD(modfp); + _mm_read_UBYTES(mh->channels,32,modfp); + + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_HEADER; + return 0; + } + + /* set module variables */ + + of.modtype = strdup(S3M_Version); + of.modtype[14] = ((mh->tracker >> 8) &0xf) + 0x30; + of.modtype[16] = ((mh->tracker >> 4)&0xf) + 0x30; + of.modtype[17] = ((mh->tracker)&0xf) + 0x30; + of.songname = DupStr(mh->songname,28); + of.numpat = mh->patnum; + of.reppos = 0; + of.numins = of.numsmp = mh->insnum; + of.initspeed = mh->initspeed; + of.inittempo = mh->inittempo; + of.initvolume = mh->mastervol<<1; + + /* read the order data */ + if(!AllocPositions(mh->ordnum)) return 0; + for(t=0; tordnum; t++) + of.positions[t] = _mm_read_UBYTE(modfp); + + of.numpos = 0; + for(t=0; tordnum; t++) + { of.positions[of.numpos] = of.positions[t]; + poslookup[t] = of.numpos; /* bug fix for FREAKY S3Ms */ + if(of.positions[t]<254) of.numpos++; + } + + if((paraptr=(UWORD *)_mm_malloc((of.numins+of.numpat)*sizeof(UWORD)))==NULL) return 0; + + /* read the instrument+pattern parapointers */ + _mm_read_I_UWORDS(paraptr,of.numins+of.numpat,modfp); + + + if(mh->pantable==252) + { /* read the panning table (ST 3.2 addition. See below for further */ + /* portions of channel panning [past reampper]). */ + _mm_read_UBYTES(pan,32,modfp); + } + + + /* now is a good time to check if the header was too short :) */ + + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_HEADER; + return 0; + } + + + /* ============================================== */ + /* Load those darned Samples! (no insts in ST3) */ + + if(!AllocSamples()) return 0; + + q = of.samples; + + for(t=0; tsamplename = DupStr(s.sampname,28); + q->speed = s.c2spd; + q->length = s.length; + q->loopstart = s.loopbeg; + q->loopend = s.loopend; + q->volume = s.volume; + q->seekpos = (((long)s.memsegh)<<16|s.memsegl)<<4; + + if(s.flags&1) q->flags |= SF_LOOP; + if(s.flags&4) q->flags |= SF_16BITS; + if(mh->fileformat==1) q->flags |= SF_SIGNED; + + /* DON'T load sample if it doesn't have the SCRS tag */ + if(memcmp(s.scrs,"SCRS",4)!=0) q->length = 0; + + q++; + } + + /* ==================================== */ + /* Determine the number of channels actually used. (what ever happened */ + /* to the concept of a single "numchn" variable, eh?! */ + + of.numchn = 0; + memset(remap,-1,32*sizeof(UBYTE)); + + for(t=0; tchannels[t]<16) && (remap[t]!=-1)) + { if(mh->channels[t]<8) + of.panning[remap[t]] = 0x20; /* 0x30 = std s3m val */ + else + of.panning[remap[t]] = 0xd0; /* 0xc0 = std s3m val */ + } + } + + if(mh->pantable==252) + { /* set panning positions according to panning table (new for st3.2) */ + for(t=0; t<32; t++) + { if((pan[t]&0x20) && (mh->channels[t]<16) && (remap[t]!=-1)) + of.panning[remap[t]] = (pan[t]&0xf)<<4; + } + } + + + /* ============================== */ + /* Load the pattern info now! */ + + of.numtrk = of.numpat*of.numchn; + if(!AllocTracks()) return 0; + if(!AllocPatterns()) return 0; + + for(t=0; t +#include "mikmod.h" + +/************************************************************************** +**************************************************************************/ + + +typedef struct XMHEADER +{ CHAR id[17]; /* ID text: 'Extended module: ' */ + CHAR songname[21]; /* Module name, padded with zeroes and 0x1a at the end */ + CHAR trackername[20]; /* Tracker name */ + UWORD version; /* (word) Version number, hi-byte major and low-byte minor */ + ULONG headersize; /* Header size */ + UWORD songlength; /* (word) Song length (in patten order table) */ + UWORD restart; /* (word) Restart position */ + UWORD numchn; /* (word) Number of channels (2,4,6,8,10,...,32) */ + UWORD numpat; /* (word) Number of patterns (max 256) */ + UWORD numins; /* (word) Number of instruments (max 128) */ + UWORD flags; /* (word) Flags: bit 0: 0 = Amiga frequency table (see below) 1 = Linear frequency table */ + UWORD tempo; /* (word) Default tempo */ + UWORD bpm; /* (word) Default BPM */ + UBYTE orders[256]; /* (byte) Pattern order table */ +} XMHEADER; + + +typedef struct XMINSTHEADER +{ ULONG size; /* (dword) Instrument size */ + CHAR name[22]; /* (char) Instrument name */ + UBYTE type; /* (byte) Instrument type (always 0) */ + UWORD numsmp; /* (word) Number of samples in instrument */ + ULONG ssize; /* */ +} XMINSTHEADER; + + +typedef struct XMPATCHHEADER +{ UBYTE what[96]; /* (byte) Sample number for all notes */ + UWORD volenv[24]; /* (byte) Points for volume envelope */ + UWORD panenv[24]; /* (byte) Points for panning envelope */ + UBYTE volpts; /* (byte) Number of volume points */ + UBYTE panpts; /* (byte) Number of panning points */ + UBYTE volsus; /* (byte) Volume sustain point */ + UBYTE volbeg; /* (byte) Volume loop start point */ + UBYTE volend; /* (byte) Volume loop end point */ + UBYTE pansus; /* (byte) Panning sustain point */ + UBYTE panbeg; /* (byte) Panning loop start point */ + UBYTE panend; /* (byte) Panning loop end point */ + UBYTE volflg; /* (byte) Volume type: bit 0: On; 1: Sustain; 2: Loop */ + UBYTE panflg; /* (byte) Panning type: bit 0: On; 1: Sustain; 2: Loop */ + UBYTE vibflg; /* (byte) Vibrato type */ + UBYTE vibsweep; /* (byte) Vibrato sweep */ + UBYTE vibdepth; /* (byte) Vibrato depth */ + UBYTE vibrate; /* (byte) Vibrato rate */ + UWORD volfade; /* (word) Volume fadeout */ + UWORD reserved[11]; /* (word) Reserved */ +} XMPATCHHEADER; + + +typedef struct XMWAVHEADER +{ ULONG length; /* (dword) Sample length */ + ULONG loopstart; /* (dword) Sample loop start */ + ULONG looplength; /* (dword) Sample loop length */ + UBYTE volume; /* (byte) Volume */ + SBYTE finetune; /* (byte) Finetune (signed byte -128..+127) */ + UBYTE type; /* (byte) Type: Bit 0-1: 0 = No loop, 1 = Forward loop, */ + /* 2 = Ping-pong loop; */ + /* 4: 16-bit sampledata */ + UBYTE panning; /* (byte) Panning (0-255) */ + SBYTE relnote; /* (byte) Relative note number (signed byte) */ + UBYTE reserved; /* (byte) Reserved */ + CHAR samplename[22]; /* (char) Sample name */ + + UBYTE vibtype; /* (byte) Vibrato type */ + UBYTE vibsweep; /* (byte) Vibrato sweep */ + UBYTE vibdepth; /* (byte) Vibrato depth */ + UBYTE vibrate; /* (byte) Vibrato rate */ +} XMWAVHEADER; + + +typedef struct XMPATHEADE +{ ULONG size; /* (dword) Pattern header length */ + UBYTE packing; /* (byte) Packing type (always 0) */ + UWORD numrows; /* (word) Number of rows in pattern (1..256) */ + UWORD packsize; /* (word) Packed patterndata size */ +} XMPATHEADER; + +typedef struct MTMNOTE +{ UBYTE a,b,c; +} MTMNOTE; + + +typedef struct XMNOTE +{ UBYTE note,ins,vol,eff,dat; +}XMNOTE; + +/************************************************************************** +**************************************************************************/ + +static XMNOTE *xmpat = NULL; +static XMHEADER *mh = NULL; + +BOOL XM_Test(void) +{ + UBYTE id[17]; + + if(!_mm_read_UBYTES(id,17,modfp)) return 0; + if(!memcmp(id,"Extended Module: ",17)) return 1; + return 0; +} + + +BOOL XM_Init(void) +{ + if(!(mh=(XMHEADER *)_mm_calloc(1,sizeof(XMHEADER)))) return 0; + return 1; +} + + +void XM_Cleanup(void) +{ + if(mh!=NULL) free(mh); + mh = NULL; +} + + +void XM_ReadNote(XMNOTE *n) +{ + UBYTE cmp; + + memset(n,0,sizeof(XMNOTE)); + + cmp = _mm_read_UBYTE(modfp); + + if(cmp&0x80) + { if(cmp&1) n->note = _mm_read_UBYTE(modfp); + if(cmp&2) n->ins = _mm_read_UBYTE(modfp); + if(cmp&4) n->vol = _mm_read_UBYTE(modfp); + if(cmp&8) n->eff = _mm_read_UBYTE(modfp); + if(cmp&16) n->dat = _mm_read_UBYTE(modfp); + } + else + { n->note = cmp; + n->ins = _mm_read_UBYTE(modfp); + n->vol = _mm_read_UBYTE(modfp); + n->eff = _mm_read_UBYTE(modfp); + n->dat = _mm_read_UBYTE(modfp); + } +} + + +UBYTE *XM_Convert(XMNOTE *xmtrack,UWORD rows) +{ + int t; + UBYTE note,ins,vol,eff,dat; + + UniReset(); + + for(t=0; tnote; + ins = xmtrack->ins; + vol = xmtrack->vol; + eff = xmtrack->eff; + dat = xmtrack->dat; + + if(note!=0) + { if(note==97) + { UniWrite(UNI_KEYFADE); + UniWrite(0); + } else + UniNote(note-1); + } + + if(ins!=0) UniInstrument(ins-1); + + switch(vol>>4) + { + case 0x6: /* volslide down */ + if(vol&0xf) + { UniWrite(UNI_XMEFFECTA); + UniWrite(vol&0xf); + } + break; + + case 0x7: /* volslide up */ + if(vol&0xf) + { UniWrite(UNI_XMEFFECTA); + UniWrite(vol<<4); + } + break; + + /* volume-row fine volume slide is compatible with protracker */ + /* EBx and EAx effects i.e. a zero nibble means DO NOT SLIDE, as */ + /* opposed to 'take the last sliding value'. */ + + case 0x8: /* finevol down */ + UniPTEffect(0xe,0xb0 | (vol&0xf)); + break; + + case 0x9: /* finevol up */ + UniPTEffect(0xe,0xa0 | (vol&0xf)); + break; + + case 0xa: /* set vibrato speed */ + UniPTEffect(0x4,vol<<4); + break; + + case 0xb: /* vibrato */ + UniPTEffect(0x4,vol&0xf); + break; + + case 0xc: /* set panning */ + UniPTEffect(0x8,vol<<4); + break; + + case 0xd: /* panning slide left */ + /* only slide when data nibble not zero: */ + + if(vol&0xf) + { UniWrite(UNI_XMEFFECTP); + UniWrite(vol&0xf); + } + break; + + case 0xe: /* panning slide right */ + /* only slide when data nibble not zero: */ + + if(vol&0xf) + { UniWrite(UNI_XMEFFECTP); + UniWrite(vol<<4); + } + break; + + case 0xf: /* tone porta */ + UniPTEffect(0x3,vol<<4); + break; + + default: + if(vol>=0x10 && vol<=0x50) + UniPTEffect(0xc,vol-0x10); + } + + switch(eff) + { + case 0x4: /* Effect 4: Vibrato */ + UniWrite(UNI_XMEFFECT4); + UniWrite(dat); + break; + + case 0xa: + UniWrite(UNI_XMEFFECTA); + UniWrite(dat); + break; + + case 0xe: + switch(dat>>4) + { case 0x1: /* XM fine porta up */ + UniWrite(UNI_XMEFFECTE1); + UniWrite(dat&0xf); + break; + + case 0x2: /* XM fine porta down */ + UniWrite(UNI_XMEFFECTE2); + UniWrite(dat&0xf); + break; + + case 0xa: /* XM fine volume up */ + UniWrite(UNI_XMEFFECTEA); + UniWrite(dat&0xf); + break; + + case 0xb: /* XM fine volume down */ + UniWrite(UNI_XMEFFECTEB); + UniWrite(dat&0xf); + break; + + default: + UniPTEffect(0x0e,dat); + } + break; + + case 'G'-55: /* G - set global volume */ + if(dat>64) dat = 64; + UniWrite(UNI_XMEFFECTG); + UniWrite(dat); + break; + + case 'H'-55: /* H - global volume slide */ + UniWrite(UNI_XMEFFECTH); + UniWrite(dat); + break; + + case 'K'-55: /* K - keyOff and KeyFade */ + UniWrite(UNI_KEYFADE); + UniWrite(dat); + break; + + case 'L'-55: /* L - set envelope position */ + UniWrite(UNI_XMEFFECTL); + UniWrite(dat); + break; + + case 'P'-55: /* P - panning slide */ + UniWrite(UNI_XMEFFECTP); + UniWrite(dat); + break; + + case 'R'-55: /* R - multi retrig note */ + UniWrite(UNI_S3MEFFECTQ); + UniWrite(dat); + break; + + case 'T'-55: /* T - Tremor !! (== S3M effect I) */ + UniWrite(UNI_S3MEFFECTI); + UniWrite(dat); + break; + + case 'X'-55: + if((dat>>4) == 1) /* X1 - Extra Fine Porta up */ + { UniWrite(UNI_XMEFFECTX1); + UniWrite(dat & 0xf); + } else if((dat>>4) == 2) /* X2 - Extra Fine Porta down */ + { UniWrite(UNI_XMEFFECTX2); + UniWrite(dat & 0xf); + } + break; + + default: + if(eff <= 0xf) + { /* Convert pattern jump from Dec to Hex */ + if(eff == 0xd) + dat = (((dat&0xf0)>>4)*10)+(dat&0xf); + UniPTEffect(eff,dat); + } + break; + } + + UniNewline(); + xmtrack++; + } + return UniDup(); +} + + + +BOOL XM_Load(void) +{ + INSTRUMENT *d; + SAMPLE *q; + XMWAVHEADER *wh,*s; + int t,u,v,p,numtrk; + long next; + ULONG nextwav[256]; + BOOL dummypat=0; + + /* try to read module header */ + + _mm_read_string(mh->id,17,modfp); + _mm_read_string(mh->songname,21,modfp); + _mm_read_string(mh->trackername,20,modfp); + mh->version =_mm_read_I_UWORD(modfp); + mh->headersize =_mm_read_I_ULONG(modfp); + mh->songlength =_mm_read_I_UWORD(modfp); + mh->restart =_mm_read_I_UWORD(modfp); + mh->numchn =_mm_read_I_UWORD(modfp); + mh->numpat =_mm_read_I_UWORD(modfp); + mh->numins =_mm_read_I_UWORD(modfp); + mh->flags =_mm_read_I_UWORD(modfp); + mh->tempo =_mm_read_I_UWORD(modfp); + mh->bpm =_mm_read_I_UWORD(modfp); + _mm_read_UBYTES(mh->orders,256,modfp); + + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_HEADER; + return 0; + } + + /* set module variables */ + of.initspeed = mh->tempo; + of.inittempo = mh->bpm; + of.modtype = DupStr(mh->trackername,20); + of.numchn = mh->numchn; + of.numpat = mh->numpat; + of.numtrk = (UWORD)of.numpat*of.numchn; /* get number of channels */ + of.songname = DupStr(mh->songname,20); /* make a cstr of songname */ + of.numpos = mh->songlength; /* copy the songlength */ + of.reppos = mh->restart; + of.numins = mh->numins; + of.flags |= UF_XMPERIODS | UF_INST; + if(mh->flags&1) of.flags |= UF_LINEAR; + + memset(of.chanvol,64,of.numchn); /* store channel volumes */ + + if(!AllocPositions(of.numpos+3)) return 0; + for(t=0; torders[t]; + +/* + WHY THIS CODE HERE?? I CAN'T REMEMBER! + + Well, I do know why, mikmak! Seems that FT2 doesn't always count blank + patterns AT ALL if they are at the END of the song. So, we have to check + for any patter numbers in the order list greater than the number of pat- + terns total. If one or more is found, we set it equal to the pattern total + and make a dummy pattern to accomidate for the discrepency! +*/ + + for(t=0; t of.numpat) + { of.positions[t] = of.numpat; + dummypat = 1; + } + } + + if(dummypat) { of.numpat++; of.numtrk+=of.numchn; } + + if(!AllocTracks()) return 0; + if(!AllocPatterns()) return 0; + + numtrk = 0; + for(t=0; tnumpat; t++) + { XMPATHEADER ph; + + ph.size =_mm_read_I_ULONG(modfp); + ph.packing =_mm_read_UBYTE(modfp); + ph.numrows =_mm_read_I_UWORD(modfp); + ph.packsize =_mm_read_I_UWORD(modfp); + + of.pattrows[t] = ph.numrows; + + /* Gr8.. when packsize is 0, don't try to load a pattern.. it's empty. */ + /* This bug was discovered thanks to Khyron's module.. */ + + if(!(xmpat=(XMNOTE *)_mm_calloc(ph.numrows*of.numchn,sizeof(XMNOTE)))) return 0; + + if(ph.packsize>0) + { for(u=0; usamplenumber,255,120); + + /* read instrument header */ + + headend = _mm_ftell(modfp); + ih.size = _mm_read_I_ULONG(modfp); + headend += ih.size; + _mm_read_string(ih.name, 22, modfp); + ih.type = _mm_read_UBYTE(modfp); + ih.numsmp = _mm_read_I_UWORD(modfp); + d->insname = DupStr(ih.name,22); + + if(ih.size > 29) + { ih.ssize = _mm_read_I_ULONG(modfp); + if(ih.numsmp > 0) + { XMPATCHHEADER pth; + + _mm_read_UBYTES (pth.what, 96, modfp); + _mm_read_I_UWORDS (pth.volenv, 24, modfp); + _mm_read_I_UWORDS (pth.panenv, 24, modfp); + pth.volpts = _mm_read_UBYTE(modfp); + pth.panpts = _mm_read_UBYTE(modfp); + pth.volsus = _mm_read_UBYTE(modfp); + pth.volbeg = _mm_read_UBYTE(modfp); + pth.volend = _mm_read_UBYTE(modfp); + pth.pansus = _mm_read_UBYTE(modfp); + pth.panbeg = _mm_read_UBYTE(modfp); + pth.panend = _mm_read_UBYTE(modfp); + pth.volflg = _mm_read_UBYTE(modfp); + pth.panflg = _mm_read_UBYTE(modfp); + pth.vibflg = _mm_read_UBYTE(modfp); + pth.vibsweep = _mm_read_UBYTE(modfp); + pth.vibdepth = _mm_read_UBYTE(modfp); + pth.vibrate = _mm_read_UBYTE(modfp); + pth.volfade = _mm_read_I_UWORD(modfp); + + /* read the remainder of the header */ + for(u=headend-_mm_ftell(modfp); u; u--) _mm_read_UBYTE(modfp); + + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_SAMPLEINFO; + return 0; + } + + for(u=0; u<96; u++) + d->samplenumber[u] = pth.what[u] + of.numsmp; + + d->volfade = pth.volfade; + + memcpy(d->volenv,pth.volenv,24); + if(pth.volflg & 1) d->volflg |= EF_ON; + if(pth.volflg & 2) d->volflg |= EF_SUSTAIN; + if(pth.volflg & 4) d->volflg |= EF_LOOP; + d->volsusbeg = d->volsusend = pth.volsus; + d->volbeg = pth.volbeg; + d->volend = pth.volend; + d->volpts = pth.volpts; + + /* scale volume envelope: */ + + for(p=0; p<12; p++) + d->volenv[p].val <<= 2; + + if((d->volflg & EF_ON) && (d->volpts < 2)) + d->volflg &= ~EF_ON; + + memcpy(d->panenv,pth.panenv,24); + d->panflg = pth.panflg; + d->pansusbeg = d->pansusend = pth.pansus; + d->panbeg = pth.panbeg; + d->panend = pth.panend; + d->panpts = pth.panpts; + + /* scale panning envelope: */ + + for(p=0; p<12; p++) + d->panenv[p].val <<= 2; + if((d->panflg & EF_ON) && (d->panpts < 2)) + d->panflg &= ~EF_ON; + + next = 0; + + /* Samples are stored outside the instrument struct now, so we have */ + /* to load them all into a temp area, count the of.numsmp along the */ + /* way and then do an AllocSamples() and move everything over */ + + for(u=0; ulength =_mm_read_I_ULONG (modfp); + s->loopstart =_mm_read_I_ULONG (modfp); + s->looplength =_mm_read_I_ULONG (modfp); + s->volume =_mm_read_UBYTE (modfp); + s->finetune =_mm_read_SBYTE (modfp); + s->type =_mm_read_UBYTE (modfp); + s->panning =_mm_read_UBYTE (modfp); + s->relnote =_mm_read_SBYTE (modfp); + s->vibtype = pth.vibflg; + s->vibsweep = pth.vibsweep; + s->vibdepth = pth.vibdepth*4; + s->vibrate = pth.vibrate; + + s->reserved =_mm_read_UBYTE (modfp); + _mm_read_string(s->samplename, 22, modfp); + + nextwav[of.numsmp+u] = next; + next += s->length; + + if(feof(modfp)) + { _mm_errno = MMERR_LOADING_SAMPLEINFO; + return 0; + } + } + + for(u=0; usamplename = DupStr(s->samplename,22); + q->length = s->length; + q->loopstart = s->loopstart; + q->loopend = s->loopstart+s->looplength; + q->volume = s->volume; + q->speed = s->finetune+128; + q->panning = s->panning; + q->seekpos = nextwav[u]; + q->vibtype = s->vibtype; + q->vibsweep = s->vibsweep; + q->vibdepth = s->vibdepth; + q->vibrate = s->vibrate; + + if(s->type & 0x10) + { q->length >>= 1; + q->loopstart >>= 1; + q->loopend >>= 1; + } + + q->flags|=SF_OWNPAN; + if(s->type&0x3) q->flags|=SF_LOOP; + if(s->type&0x2) q->flags|=SF_BIDI; + + if(s->type&0x10) q->flags|=SF_16BITS; + q->flags|=SF_DELTA; + q->flags|=SF_SIGNED; + } + + d = of.instruments; + s = wh; + for(u=0; usamplenumber[t]].relnote / 12) > ) + { s[d->samplenumber[t]].relnote -= 12; + of.samples[d->samplenumber[t]].speed <<= 1; + } + */ + for(t=0; t<96; t++) + d->samplenote[t] = (d->samplenumber[t]==of.numsmp) ? 255 : (t+s[d->samplenumber[t]].relnote); + } + + free(wh); + return 1; +} + + + +CHAR *XM_LoadTitle(void) +{ + CHAR s[21]; + + _mm_fseek(modfp,17,SEEK_SET); + if(!fread(s,21,1,modfp)) return NULL; + + return(DupStr(s,21)); +} + + + +MLOADER load_xm = +{ NULL, + "XM", + "Portable XM loader v0.5", + XM_Init, + XM_Test, + XM_Load, + XM_Cleanup, + XM_LoadTitle +}; diff --git a/mikmod/mdreg.c b/mikmod/mdreg.c new file mode 100644 index 00000000..ef01d60f --- /dev/null +++ b/mikmod/mdreg.c @@ -0,0 +1,31 @@ +/* + + Name: MDREG.C + + Description: + A single routine for registering all drivers in MikMod for the current + platform. + + Portability: + DOS, WIN95, OS2, SunOS, Solaris, + Linux, HPUX, AIX, SGI, Alpha + + Anything not listed above is assumed to not be supported by this procedure! + + All Others: n + + - all compilers! + +*/ + +#include "mikmod.h" + +void MikMod_RegisterAllDrivers(void) +{ + + MikMod_RegisterDriver(drv_sdl); + MikMod_RegisterDriver(drv_nos); + +} + + diff --git a/mikmod/mdriver.c b/mikmod/mdriver.c new file mode 100644 index 00000000..42afa329 --- /dev/null +++ b/mikmod/mdriver.c @@ -0,0 +1,557 @@ +/* + +Name: MDRIVER.C + +Description: +These routines are used to access the available soundcard drivers. + +Portability: +All systems - all compilers + +*/ + +#include "mikmod.h" + +MDRIVER *firstdriver = NULL, *md_driver = &drv_nos; +extern UNIMOD *pf; /* <- this modfile is being played */ + +UWORD md_device = 0; +UWORD md_mixfreq = 44100; +UWORD md_mode = DMODE_STEREO | DMODE_16BITS | DMODE_SURROUND; +UWORD md_dmabufsize = 50; +UBYTE md_pansep = 128; /* 128 == 100% (full left/right) */ + +UBYTE md_reverb = 6; /* Reverb */ + +UBYTE md_volume = 96; /* Global sound volume (0-128) */ +UBYTE md_musicvolume = 128; /* volume of song */ +UBYTE md_sndfxvolume = 128; /* volume of sound effects */ + +UBYTE md_bpm = 125; + + +/* Do not modify the numchn variables yourself! use MD_SetVoices() */ + +UBYTE md_numchn = 0, md_sngchn = 0, md_sfxchn = 0; +UBYTE md_hardchn = 0, md_softchn = 0; + + +void (*md_player)(void) = Player_HandleTick; +static BOOL isplaying = 0, initialized = 0; +static UBYTE *sfxinfo; +static int sfxpool; + +static SAMPLE **md_sample = NULL; + +/* Backup variables. This way, the end programmer can fiddle with the */ +/* main globals without mikmod blowing up. */ + +static UWORD idevice, imixfreq, imode, idmabufsize; + + +static void LimitHardVoices(int limit) + +/* Limits the number of hardware voices to the specified amount. */ +/* This function should only be used by the low-level drivers. */ + +{ + int t = 0; + + if(!(md_mode & DMODE_SOFT_SNDFX) && (md_sfxchn > limit)) md_sfxchn = limit; + if(!(md_mode & DMODE_SOFT_MUSIC) && (md_sngchn > limit)) md_sngchn = limit; + + if(!(md_mode & DMODE_SOFT_SNDFX)) + md_hardchn = md_sfxchn; + else + md_hardchn = 0; + + if(!(md_mode & DMODE_SOFT_MUSIC)) + md_hardchn += md_sngchn; + + while(md_hardchn > limit) + { + if(++t & 1) + if(!(md_mode & DMODE_SOFT_SNDFX) && (md_sfxchn > 4)) md_sfxchn--; + else + if(!(md_mode & DMODE_SOFT_MUSIC) && (md_sngchn > 8)) md_sngchn--; + + if(!(md_mode & DMODE_SOFT_SNDFX)) + md_hardchn = md_sfxchn; + else + md_hardchn = 0; + + if(!(md_mode & DMODE_SOFT_MUSIC)) + md_hardchn += md_sngchn; + } + + md_numchn = md_hardchn + md_softchn; +} + + +static void LimitSoftVoices(int limit) + +/* Limits the number of hardware voices to the specified amount. */ +/* This function should only be used by the low-level drivers. */ + +{ + int t = 0; + + if((md_mode & DMODE_SOFT_SNDFX) && (md_sfxchn > limit)) md_sfxchn = limit; + if((md_mode & DMODE_SOFT_MUSIC) && (md_sngchn > limit)) md_sngchn = limit; + + if(md_mode & DMODE_SOFT_SNDFX) + md_softchn = md_sfxchn; + else + md_softchn = 0; + + if(md_mode & DMODE_SOFT_MUSIC) + md_softchn += md_sngchn; + + while(md_softchn > limit) + { + if(++t & 1) + if((md_mode & DMODE_SOFT_SNDFX) && (md_sfxchn > 4)) md_sfxchn--; + else + if((md_mode & DMODE_SOFT_MUSIC) && (md_sngchn > 8)) md_sngchn--; + + if(!(md_mode & DMODE_SOFT_SNDFX)) + md_softchn = md_sfxchn; + else + md_softchn = 0; + + if(!(md_mode & DMODE_SOFT_MUSIC)) + md_softchn += md_sngchn; + } + + md_numchn = md_hardchn + md_softchn; +} + + +/* Note: 'type' indicates whether the returned value should be for music */ +/* or for sound effects. */ + +ULONG MD_SampleSpace(int type) +{ + if(type==MD_MUSIC) + type = (md_mode & DMODE_SOFT_MUSIC) ? MD_SOFTWARE : MD_HARDWARE; + else if(type==MD_SNDFX) + type = (md_mode & DMODE_SOFT_SNDFX) ? MD_SOFTWARE : MD_HARDWARE; + + return md_driver->FreeSampleSpace(type); +} + + +ULONG MD_SampleLength(int type, SAMPLE *s) +{ + if(type==MD_MUSIC) + type = (md_mode & DMODE_SOFT_MUSIC) ? MD_SOFTWARE : MD_HARDWARE; + else if(type==MD_SNDFX) + type = (md_mode & DMODE_SOFT_SNDFX) ? MD_SOFTWARE : MD_HARDWARE; + + return md_driver->RealSampleLength(type, s); +} + + +UWORD MD_SetDMA(int secs) + +/* Converts the given number of 1/10th seconds into the number of bytes of */ +/* audio that a sample # 1/10th seconds long would require at the current md_* */ +/* settings. */ + +{ + ULONG result; + + result = (md_mixfreq * ((md_mode & DMODE_STEREO) ? 2 : 1) * + ((md_mode & DMODE_16BITS) ? 2 : 1) * secs) * 10; + + if(result > 32000) result = 32000; + return(md_dmabufsize = (result & ~3)); /* round it off to an 8 byte boundry */ +} + + +void MD_InfoDriver(void) +{ + int t; + MDRIVER *l; + + /* list all registered devicedrivers: */ + for(t=1,l=firstdriver; l!=NULL; l=l->next, t++) + printf("%d. %s\n",t,l->Version); +} + + +void MD_RegisterDriver(MDRIVER *drv) +{ + MDRIVER *cruise = firstdriver; + + if(cruise!=NULL) + { while(cruise->next!=NULL) cruise = cruise->next; + cruise->next = drv; + } else + firstdriver = drv; +} + + +SWORD MD_SampleLoad(SAMPLOAD *s, int type, FILE *fp) +/* type - sample type .. MD_MUSIC or MD_SNDFX */ +{ + SWORD result; + + if(type==MD_MUSIC) + type = (md_mode & DMODE_SOFT_MUSIC) ? MD_SOFTWARE : MD_HARDWARE; + else if(type==MD_SNDFX) + type = (md_mode & DMODE_SOFT_SNDFX) ? MD_SOFTWARE : MD_HARDWARE; + + SL_Init(s); + result = md_driver->SampleLoad(s, type); + SL_Exit(s); + + return result; +} + + +void MD_SampleUnLoad(SWORD handle) +{ + md_driver->SampleUnLoad(handle); +} + + +void MD_SetBPM(UBYTE bpm) +{ + md_bpm = bpm; +} + + +void MikMod_RegisterPlayer(void (*player)(void)) +{ + md_player = player; +} + + +void MikMod_Update(void) +{ + if(isplaying && !(pf->forbid)) md_driver->Update(); +} + + +void Voice_SetVolume(int voice, UWORD vol) +{ + ULONG tmp; + + if((voice<0) || (voice>=md_numchn)) return; + tmp = (ULONG)vol * (ULONG)md_volume * ((voice < md_sngchn) ? (ULONG)md_musicvolume : (ULONG)md_sndfxvolume); + md_driver->VoiceSetVolume(voice,tmp/16384UL); +} + + +void Voice_SetFrequency(int voice, ULONG frq) +{ + if((voice < 0) || (voice >= md_numchn)) return; + if(md_sample[voice]!=NULL && md_sample[voice]->divfactor!=0) frq/=md_sample[voice]->divfactor; + md_driver->VoiceSetFrequency(voice, frq); +} + + +void Voice_SetPanning(int voice, ULONG pan) +{ + if((voice < 0) || (voice >= md_numchn)) return; + if(pan!=PAN_SURROUND) + { if(md_mode & DMODE_REVERSE) pan = 255-pan; + pan = (((SWORD)(pan-128)*md_pansep) / 128)+128; + } + md_driver->VoiceSetPanning(voice, pan); +} + + +void Voice_Play(int voice, SAMPLE *s, ULONG start) +{ + ULONG repend; + + if((voice < 0) || (voice >= md_numchn) || (start >= s->length)) return; + + md_sample[voice] = s; + repend = s->loopend; + + if(s->flags&SF_LOOP) + if(repend > s->length) repend = s->length; /* repend can't be bigger than size */ + + md_driver->VoicePlay(voice,s->handle,start,s->length,s->loopstart,repend,s->flags); +} + + +void Voice_Stop(int voice) +{ + if((voice < 0) || (voice >= md_numchn)) return; + if(voice >= md_sngchn) + { /* It is a sound effects channel, so flag the voice as non-critical! */ + sfxinfo[voice-md_sngchn] = 0; + } + + md_driver->VoiceStop(voice); +} + + +BOOL Voice_Stopped(int voice) +{ + if((voice < 0) || (voice >= md_numchn)) return 0; + return(md_driver->VoiceStopped(voice)); +} + + +SLONG Voice_GetPosition(int voice) +{ + if((voice < 0) || (voice >= md_numchn)) return 0; + return(md_driver->VoiceGetPosition(voice)); +} + + +ULONG Voice_RealVolume(int voice) +{ + if((voice < 0) || (voice >= md_numchn)) return 0; + return(md_driver->VoiceRealVolume(voice)); +} + + +/* ================================ */ +/* Functions prefixed with MikMod */ +/* ================================ */ + +BOOL MikMod_Init(void) +{ + UWORD t; + + _mm_critical = 1; + + /* if md_device==0, try to find a device number */ + + if(md_device==0) + { for(t=1,md_driver=firstdriver; md_driver!=NULL; md_driver=md_driver->next, t++) + { if(md_driver->IsPresent()) break; + } + + if(md_driver==NULL) + { _mm_errno = MMERR_DETECTING_DEVICE; + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + md_driver = &drv_nos; + return 1; + } + + md_device = t; + } else + { /* if n>0 use that driver */ + for(t=1,md_driver=firstdriver; (md_driver!=NULL) && (t!=md_device); md_driver=md_driver->next, t++); + + if(md_driver==NULL) + { _mm_errno = MMERR_INVALID_DEVICE; + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + md_driver = &drv_nos; + return 1; + } + + if(!md_driver->IsPresent()) + { _mm_errno = MMERR_DETECTING_DEVICE; + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + md_driver = &drv_nos; + return 1; + } + } + + if(md_driver->Init()) + { MikMod_Exit(); + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return 1; + } + + idevice = md_device; imode = md_mode; + imixfreq = md_mixfreq; idmabufsize = md_dmabufsize; + initialized = 1; + _mm_critical = 0; + + return 0; +} + + +void MikMod_Exit(void) +{ + MikMod_DisableOutput(); + md_driver->Exit(); + md_numchn = md_sfxchn = md_sngchn = 0; + md_driver = &drv_nos; + initialized = 0; +} + + +BOOL MikMod_Reset(void) + +/* Reset the driver using the new global variable settings. */ +/* If the driver has not been initialized, it will be now. */ + +{ + if(!initialized) return MikMod_Init(); + if((md_driver->Reset == NULL) || (md_device != idevice)) + { /* md_driver->Reset was NULL, or md_device was changed, */ + /* so do a full reset of the driver. */ + + if(isplaying) md_driver->PlayStop(); + md_driver->Exit(); + if(MikMod_Init()) + { MikMod_Exit(); + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return 1; + } + if(isplaying) md_driver->PlayStart(); + } else + { if(md_driver->Reset()) + { MikMod_Exit(); + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return 1; + } + } + + return 0; +} + + +BOOL MikMod_SetNumVoices(int music, int sfx) + +/* If either parameter is -1, the current set value will be retained. */ + +{ + BOOL resume = 0; + int t, oldchn = 0; + + if((music==0) && (sfx==0)) return 0; + + _mm_critical = 1; + + if(isplaying) + { MikMod_DisableOutput(); + oldchn = md_numchn; + resume = 1; + } + + if(sfxinfo!=NULL) free(sfxinfo); + if(md_sample!=NULL) free(md_sample); + md_sample = NULL; + sfxinfo = NULL; + + /*md_softchn = md_hardchn = 0; + + if(md_mode & DMODE_SOFT_SNDFX) + md_softchn = sfx; else md_hardchn = sfx; + + if(md_mode & DMODE_SOFT_MUSIC) + md_softchn += music; else md_hardchn += music; + */ + + if(music != -1) md_sngchn = music; + if(sfx != -1) md_sfxchn = sfx; + + md_numchn = md_sngchn + md_sfxchn; + + LimitHardVoices(md_driver->HardVoiceLimit); + LimitSoftVoices(md_driver->SoftVoiceLimit); + + if(md_driver->SetNumVoices()) + { MikMod_Exit(); + md_numchn = md_softchn = md_hardchn = md_sfxchn = md_sngchn = 0; + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return 1; + } + + if(md_sngchn || md_sfxchn) + md_sample = (SAMPLE **)_mm_calloc(md_sngchn+md_sfxchn, sizeof(SAMPLE *)); + if(md_sfxchn) + sfxinfo = (UBYTE *)_mm_calloc(md_sfxchn, sizeof(UBYTE)); + + /* make sure the player doesn't start with garbage */ + for(t=oldchn; tPlayStart()) return 1; + isplaying = 1; + } + _mm_critical = 0; + return 0; +} + + +void MikMod_DisableOutput(void) +{ + /* safety valve, prevents calling playStop when playstart */ + /* hasn't been called: */ + + if(isplaying && md_driver!=NULL) + { isplaying = 0; + md_driver->PlayStop(); + } +} + + +BOOL MikMod_Active(void) +{ + return isplaying; +} + + +int MikMod_PlaySample(SAMPLE *s, ULONG start, UBYTE flags) + +/* Plays a sound effects sample. Picks a voice from the number of voices */ +/* allocated for use as sound effects (loops through voices, skipping all */ +/* active criticals). */ +/* */ +/* Returns the voice that the sound is being played on. */ + +{ + int orig = sfxpool; /* for cases where all channels are critical */ + int c; + + if(md_sfxchn==0) return -1; + if(s->volume > 64) s->volume = 64; + + /* check the first location after sfxpool */ + do + { if(sfxinfo[sfxpool] & SFX_CRITICAL) + { if(md_driver->VoiceStopped(c=sfxpool+md_sngchn)) + { sfxinfo[sfxpool] = flags; + Voice_Play(c, s, start); + md_driver->VoiceSetVolume(c,s->volume<<2); + md_driver->VoiceSetPanning(c,s->panning); + md_driver->VoiceSetFrequency(c,s->speed); + sfxpool++; + if(sfxpool >= md_sfxchn) sfxpool = 0; + return c; + } + } else + { sfxinfo[sfxpool] = flags; + Voice_Play(c=sfxpool+md_sngchn, s, start); + md_driver->VoiceSetVolume(c,s->volume<<2); + md_driver->VoiceSetPanning(c,s->panning); + md_driver->VoiceSetFrequency(c,s->speed); + sfxpool++; + if(sfxpool >= md_sfxchn) sfxpool = 0; + return c; + } + + sfxpool++; + if(sfxpool >= md_sfxchn) sfxpool = 0; + } while(sfxpool!=orig); + + return -1; +} + diff --git a/mikmod/mikmod.h b/mikmod/mikmod.h new file mode 100644 index 00000000..26d7eab5 --- /dev/null +++ b/mikmod/mikmod.h @@ -0,0 +1,394 @@ +#ifndef _MIKMOD_H +#define _MIKMOD_H + +#include "mmio.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#define MUTE_EXCLUSIVE 32000 +#define MUTE_INCLUSIVE 32001 + +#define PAN_LEFT 0 +#define PAN_CENTER 128 +#define PAN_RIGHT 255 +#define PAN_SURROUND 512 /* panning value for Dolby Surround */ + + +#define MikMod_RegisterDriver(x) MD_RegisterDriver(&x) +#define MikMod_RegisterLoader(x) ML_RegisterLoader(&x) +#define MikMod_RegisterErrorHandler(x) _mm_RegisterErrorHandler(x) + + +/* The following #define macros are for retaining API compatiability */ +/* with the beta version of MikMod 3.0, and are TEMPORARY! They WILL */ +/* be removed in the future! */ + +#define MD_RegisterPlayer(x) MikMod_RegisterPlayer(x) +#define MD_Init MikMod_Init +#define MD_Exit MikMod_Exit +#define MD_Update MikMod_Update +#define ML_Free(x) MikMod_FreeSong(x) +#define MD_SetNumChannels(x,y) MikMod_SetNumVoices(x,y) +#define MD_SetNumVoices(x,y) MikMod_SetNumVoices(x,y) +#define MD_PlayStart MikMod_EnableOutput +#define MD_PlayStop MikMod_DisableOutput + +#define MD_VoiceSetVolume(x,y) Voice_SetVolume(x,y) +#define MD_VoiceSetFrequency(x,y) Voice_SetFrequency(x,y) +#define MD_VoiceSetPanning(x,y) Voice_SetPanning(x,y) +#define MD_VoicePlay(x,y,z) Voice_Play(x,y,z) +#define MD_VoiceStop(x) Voice_Stop(x) +#define MD_VoiceReleaseSustain(x) Voice_ReleaseSustain(x) +#define MD_VoiceStopped(x) Voice_Stopped(x) +#define MD_VoiceGetPosition(x) Voice_GetPosition(x) +#define MD_VoiceRealVolume(x) Voice_RealVolume(x) + + +#define SFX_CRITICAL 1 + + +/************************************************************************** +****** mikmod types: ****************************************************** +**************************************************************************/ + +/* Sample format [loading and in-memory] flags: */ +#define SF_16BITS 1 +#define SF_SIGNED 2 +#define SF_STEREO 4 +#define SF_DELTA 8 +#define SF_BIG_ENDIAN 16 + +/* General Playback flags */ + +#define SF_LOOP 32 +#define SF_BIDI 64 +#define SF_SUSTAIN 128 +#define SF_REVERSE 256 + +/* Module-only Playback Flags */ + +#define SF_OWNPAN 512 +#define SF_UST_LOOP 1024 + + +typedef struct SAMPLE +{ ULONG speed; /* Base playing speed/frequency of note (Middle C in player) */ + UBYTE volume; /* volume 0-64 */ + UWORD panning; /* panning (0-255 or PAN_SURROUND) */ + ULONG length; /* length of sample (in samples!) */ + ULONG loopstart; /* repeat position (relative to start, in samples) */ + ULONG loopend; /* repeat end */ + ULONG susbegin; /* sustain loop begin (in samples) \ Not Supported */ + ULONG susend; /* sustain loop end / Yet! */ + + UWORD flags; /* sample format in memory */ + +/* Variables used by the module player only! (ignored for sound effects) */ + + UBYTE globvol; /* global volume */ + UBYTE vibflags; /* autovibrato flag stuffs */ + UBYTE vibtype; /* Vibratos moved from INSTRUMENT to SAMPLE */ + UBYTE vibsweep; + UBYTE vibdepth; + UBYTE vibrate; + + CHAR *samplename; /* name of the sample */ + +/* Values used internally only (not saved in disk formats) */ + + UWORD avibpos; /* autovibrato pos [player use] */ + UBYTE divfactor; /* for sample scaling (maintains proper period slides) */ + ULONG seekpos; /* seek position in file */ + SWORD handle; /* sample handle used by individual drivers */ +} SAMPLE; + + + +/* --> Struct : SAMPLOAD */ +/* This is a handle of sorts attached to any sample registered with */ +/* SL_RegisterSample. Generally, this only need be used or changed by the */ +/* loaders and drivers of mikmod. */ + +typedef struct SAMPLOAD +{ struct SAMPLOAD *next; + + ULONG length; /* length of sample (in samples!) */ + ULONG loopstart; /* repeat position (relative to start, in samples) */ + ULONG loopend; /* repeat end */ + + UWORD infmt, outfmt; + int scalefactor; + SAMPLE *sample; + FILE *fp; +} SAMPLOAD; + +extern void SL_HalveSample(SAMPLOAD *s); +extern void SL_Sample8to16(SAMPLOAD *s); +extern void SL_Sample16to8(SAMPLOAD *s); +extern void SL_SampleSigned(SAMPLOAD *s); +extern void SL_SampleUnsigned(SAMPLOAD *s); +extern BOOL SL_LoadSamples(void); /* Returns 1 on error! */ +extern SAMPLOAD *SL_RegisterSample(SAMPLE *s, int type, FILE *fp); /* Returns 1 on error! */ +extern void SL_Load(void *buffer, SAMPLOAD *smp, int length); +extern BOOL SL_Init(SAMPLOAD *s); +extern void SL_Exit(SAMPLOAD *s); + + +/************************************************************************** +****** Wavload stuff: ***************************************************** +**************************************************************************/ + +SAMPLE *WAV_LoadFP(FILE *fp); +SAMPLE *WAV_LoadFN(CHAR *filename); +void WAV_Free(SAMPLE *si); + + +#include "ptform.h" + + +/************************************************************************** +****** Driver stuff: ****************************************************** +**************************************************************************/ + +/* max. number of handles a driver has to provide. (not strict) */ + +#define MAXSAMPLEHANDLES 384 + + +enum +{ MD_MUSIC = 0, + MD_SNDFX +}; + +enum +{ MD_HARDWARE = 0, + MD_SOFTWARE +}; + + +/* possible mixing mode bits: */ +/* -------------------------- */ +/* These take effect only after MikMod_Init or MikMod_Reset. */ + +#define DMODE_16BITS 1 /* enable 16 bit output */ +#define DMODE_SURROUND 2 /* enable Dolby surround sound (not yet supported) */ +#define DMODE_SOFT_SNDFX 4 /* Process sound effects via software mixer (not yet supported) */ +#define DMODE_SOFT_MUSIC 8 /* Process music via software mixer (not yet supported) */ + +/* These take effect immidiately. */ + +#define DMODE_STEREO 16 /* enable stereo output */ +#define DMODE_REVERSE 32 /* reverse stereo */ +#define DMODE_INTERP 64 /* enable interpolation (not yet supported) */ + + +/* driver structure: */ + +typedef struct MDRIVER +{ struct MDRIVER *next; + CHAR *Name; + CHAR *Version; + UBYTE HardVoiceLimit, /* Limit of hardware mixer voices for this driver */ + SoftVoiceLimit; /* Limit of software mixer voices for this driver */ + + BOOL (*IsPresent) (void); + SWORD (*SampleLoad) (SAMPLOAD *s, int type); + void (*SampleUnLoad) (SWORD handle); + ULONG (*FreeSampleSpace) (int type); + ULONG (*RealSampleLength) (int type, SAMPLE *s); + BOOL (*Init) (void); + void (*Exit) (void); + BOOL (*Reset) (void); + BOOL (*SetNumVoices) (void); + BOOL (*PlayStart) (void); + void (*PlayStop) (void); + void (*Update) (void); + void (*VoiceSetVolume) (UBYTE voice, UWORD vol); + void (*VoiceSetFrequency) (UBYTE voice, ULONG frq); + void (*VoiceSetPanning) (UBYTE voice, ULONG pan); + void (*VoicePlay) (UBYTE voice, SWORD handle, ULONG start, ULONG size, ULONG reppos, ULONG repend, UWORD flags); + void (*VoiceStop) (UBYTE voice); + BOOL (*VoiceStopped) (UBYTE voice); + void (*VoiceReleaseSustain)(UBYTE voice); + SLONG (*VoiceGetPosition) (UBYTE voice); + ULONG (*VoiceRealVolume) (UBYTE voice); + + BOOL (*StreamInit) (ULONG speed, UWORD flags); + void (*StreamExit) (void); + void (*StreamSetSpeed) (ULONG speed); + SLONG (*StreamGetPosition) (void); + void (*StreamLoadFP) (FILE *fp); +} MDRIVER; + + +/* These variables can be changed at ANY time and results */ +/* will be immidiate: */ + +extern UBYTE md_bpm; /* current song / hardware BPM rate */ +extern UBYTE md_volume; /* Global sound volume (0-128) */ +extern UBYTE md_musicvolume; /* volume of song */ +extern UBYTE md_sndfxvolume; /* volume of sound effects */ +extern UBYTE md_reverb; /* 0 = none; 15 = chaos */ +extern UBYTE md_pansep; /* 0 = mono; 128 == 100% (full left/right) */ + + +/* The variables below can be changed at any time, but changes will */ +/* not be implimented until MikMod_Reset is called. A call to */ +/* MikMod_Reset may result in a skip or pop in audio (depending on */ +/* the soundcard driver and the settings changed). */ + +extern UWORD md_device; /* Device. 0 = autodetect, other # depend on driver register order. */ +extern UWORD md_mixfreq; /* mixing frequency. Valid 5000 -> 44100 */ +extern UWORD md_dmabufsize; /* DMA buffer size. Valid 512 -> 32000 */ +extern UWORD md_mode; /* Mode. See DMODE_? flags above */ + + +/* Variables below can be changed via MD_SetNumVoices at any time. */ +/* However, a call to MD_SetNumVoicess while the driver */ +/* is active will cause the sound to skip slightly. */ + +extern UBYTE md_numchn, /* number of song + sound effects voices */ + md_sngchn, /* number of song voices */ + md_sfxchn, /* number of sound effects voices */ + md_hardchn, /* number of hardware mixed voices */ + md_softchn; /* number of software mixed voices */ + + +/* Following variables should not be changed! */ +extern MDRIVER *md_driver; /* Current driver in use. See MDRIVER struct */ + /* above for structure info contents. */ + +/* This is for use by the hardware drivers only. It points to the */ +/* registered tickhandler function. */ +extern void (*md_player)(void); + + +/* main driver prototypes: */ + +extern void MikMod_RegisterAllDrivers(void); +extern void MikMod_RegisterAllLoaders(void); + +extern BOOL MikMod_Init(void); +extern void MikMod_Exit(void); +extern BOOL MikMod_Reset(void); +extern int MikMod_PlaySample(SAMPLE *s, ULONG start, UBYTE flags); +extern BOOL MikMod_SetNumVoices(int music, int sndfx); +extern BOOL MikMod_Active(void); +extern BOOL MikMod_EnableOutput(void); +extern void MikMod_DisableOutput(void); +extern void MikMod_RegisterPlayer(void (*plr)(void)); +extern void MikMod_Update(void); + +extern void Voice_SetVolume(int voice, UWORD ivol); +extern void Voice_SetFrequency(int voice, ULONG frq); +extern void Voice_SetPanning(int voice, ULONG pan); +extern void Voice_Play(int voice,SAMPLE *s, ULONG start); +extern void Voice_Stop(int voice); +extern void Voice_ReleaseSustain(int voice); +extern BOOL Voice_Stopped(int voice); +extern SLONG Voice_GetPosition(int voice); +extern ULONG Voice_RealVolume(int voice); + +extern void MD_InfoDriver(void); +extern void MD_RegisterDriver(MDRIVER *drv); +extern SWORD MD_SampleLoad(SAMPLOAD *s, int type, FILE *fp); +extern void MD_SampleUnLoad(SWORD handle); +extern void MD_SetBPM(UBYTE bpm); +extern ULONG MD_SampleSpace(int type); +extern ULONG MD_SampleLength(int type, SAMPLE *s); + +/* Declare external drivers: */ + +extern MDRIVER drv_sdl; /* Simple DirectMedia Layer driver */ +extern MDRIVER drv_nos; /* nosound driver */ + + +/************************************************************************** +****** Streaming Audio stuff: ********************************************* +**************************************************************************/ + + +typedef struct MSTREAM +{ struct MSTREAM *next; + CHAR *type; + CHAR *version; + BOOL (*Init)(void); + BOOL (*Test)(void); + BOOL (*Load)(void); + void (*Cleanup)(void); +} MSTREAM; + + +extern int stream_bufsize; +extern FILE *stream_fp; +extern SLONG stream_seekpos; +extern SLONG stream_reppos; + + +/************************************************************************** +****** Virtual channel stuff: ********************************************* +**************************************************************************/ + +extern BOOL VC_Init(void); +extern void VC_Exit(void); +extern BOOL VC_SetNumVoices(void); +extern ULONG VC_SampleSpace(int type); +extern ULONG VC_SampleLength(int type, SAMPLE *s); + +extern BOOL VC_PlayStart(void); +extern void VC_PlayStop(void); + +/* extern SWORD VC_SampleLoad(SAMPLOAD *sload, int type, FILE *fp); */ +extern SWORD VC_SampleLoad(SAMPLOAD *sload, int type); +extern void VC_SampleUnload(SWORD handle); + +extern void VC_WriteSamples(SBYTE *buf,ULONG todo); +extern ULONG VC_WriteBytes(SBYTE *buf,ULONG todo); +extern void VC_SilenceBytes(SBYTE *buf,ULONG todo); + +extern void VC_VoiceSetVolume(UBYTE voice, UWORD vol); +extern void VC_VoiceSetFrequency(UBYTE voice, ULONG frq); +extern void VC_VoiceSetPanning(UBYTE voice, ULONG pan); +extern void VC_VoicePlay(UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags); + +extern void VC_VoiceStop(UBYTE voice); +extern BOOL VC_VoiceStopped(UBYTE voice); +extern void VC_VoiceReleaseSustain(UBYTE voice); +extern SLONG VC_VoiceGetPosition(UBYTE voice); +extern ULONG VC_VoiceRealVolume(UBYTE voice); + + +extern BOOL VC2_Init(void); +extern void VC2_Exit(void); +extern BOOL VC2_SetNumVoices(void); +extern ULONG VC2_SampleSpace(int type); +extern ULONG VC2_SampleLength(int type, SAMPLE *s); + +extern BOOL VC2_PlayStart(void); +extern void VC2_PlayStop(void); + +extern SWORD VC2_SampleLoad(SAMPLOAD *sload, int type, FILE *fp); +extern void VC2_SampleUnload(SWORD handle); + +extern void VC2_WriteSamples(SBYTE *buf,ULONG todo); +extern ULONG VC2_WriteBytes(SBYTE *buf,ULONG todo); +extern void VC2_SilenceBytes(SBYTE *buf,ULONG todo); + +extern void VC2_VoiceSetVolume(UBYTE voice, UWORD vol); +extern void VC2_VoiceSetFrequency(UBYTE voice, ULONG frq); +extern void VC2_VoiceSetPanning(UBYTE voice, ULONG pan); +extern void VC2_VoicePlay(UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags); + +extern void VC2_VoiceStop(UBYTE voice); +extern BOOL VC2_VoiceStopped(UBYTE voice); +extern void VC2_VoiceReleaseSustain(UBYTE voice); +extern SLONG VC2_VoiceGetPosition(UBYTE voice); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/mikmod/mloader.c b/mikmod/mloader.c new file mode 100644 index 00000000..36ebc3df --- /dev/null +++ b/mikmod/mloader.c @@ -0,0 +1,399 @@ +/* + +Name: MLOADER.C + +Description: + These routines are used to access the available module loaders + +Portability: + All systems - all compilers + +*/ + +#include +#include "mikmod.h" + + +FILE *modfp; +UNIMOD of; + +static MLOADER *firstloader = NULL; + +UWORD finetune[16] = +{ 8363, 8413, 8463, 8529, 8581, 8651, 8723, 8757, + 7895, 7941, 7985, 8046, 8107, 8169, 8232, 8280 +}; + + +void ML_InfoLoader(void) +{ + int t; + MLOADER *l; + + /* list all registered devicedrivers: */ + + for(t=1,l=firstloader; l!=NULL; l=l->next, t++) + printf("%d. %s\n",t,l->version); +} + + +void ML_RegisterLoader(MLOADER *ldr) +{ + MLOADER *cruise = firstloader; + + if(cruise!=NULL) + { while(cruise->next!=NULL) cruise = cruise->next; + cruise->next = ldr; + } else + firstloader = ldr; +} + + +BOOL ReadComment(UWORD len) +{ + /*int t; */ + + if(len) + { if(!(of.comment=(CHAR *)_mm_malloc(len+1))) return 0; + fread(of.comment,len,1,modfp); + of.comment[len] = 0; + } + return 1; +} + + +BOOL AllocPositions(int total) +{ + if((of.positions = _mm_calloc(total,sizeof(UWORD))) == NULL) return 0; + return 1; +} + + +BOOL AllocPatterns(void) +{ + int s,t,tracks = 0; + + /* Allocate track sequencing array */ + + if(!(of.patterns = (UWORD *)_mm_calloc((ULONG)(of.numpat+1)*of.numchn,sizeof(UWORD)))) return 0; + if(!(of.pattrows = (UWORD *)_mm_calloc(of.numpat+1,sizeof(UWORD)))) return 0; + + for(t=0; tlength) SL_RegisterSample(s,MD_MUSIC,modfp); + + return 1; +} + + +CHAR *DupStr(CHAR *s, UWORD len) +/* Creates a CSTR out of a character buffer of 'len' bytes, but strips */ +/* any terminating non-printing characters like 0, spaces etc. */ +{ + UWORD t; + CHAR *d = NULL; + + /* Scan for first printing char in buffer [includes high ascii up to 254] */ + while(len) + { if(s[len-1] > 0x20) break; + len--; + } + + /* When the buffer wasn't completely empty, allocate */ + /* a cstring and copy the buffer into that string, except */ + /* for any control-chars */ + +#ifdef __GNUC__ + if(len<16) len = 16; +#endif + + if((d=(CHAR *)_mm_malloc(len+1)) != NULL) + { for(t=0; thandle>=0) + MD_SampleUnLoad(s->handle); + if(s->samplename!=NULL) free(s->samplename); +} + + +static void ML_XFreeInstrument(INSTRUMENT *i) +{ + if(i->insname!=NULL) free(i->insname); +} + + +static void ML_FreeEx(UNIMOD *mf) +{ + UWORD t; + + if(mf->songname!=NULL) free(mf->songname); + if(mf->composer!=NULL) free(mf->composer); + if(mf->comment!=NULL) free(mf->comment); + + if(mf->modtype!=NULL) free(mf->modtype); + if(mf->positions!=NULL) free(mf->positions); + if(mf->patterns!=NULL) free(mf->patterns); + if(mf->pattrows!=NULL) free(mf->pattrows); + + if(mf->tracks!=NULL) + { for(t=0; tnumtrk; t++) + if(mf->tracks[t]!=NULL) free(mf->tracks[t]); + free(mf->tracks); + } + + if(mf->instruments != NULL) + { for(t=0; tnumins; t++) + ML_XFreeInstrument(&mf->instruments[t]); + free(mf->instruments); + } + + if(mf->samples != NULL) + { for(t=0; tnumsmp; t++) + if(mf->samples[t].length) ML_XFreeSample(&mf->samples[t]); + free(mf->samples); + } + + memset(mf,0,sizeof(UNIMOD)); +} + + +static UNIMOD *ML_AllocUniMod(void) +{ + UNIMOD *mf; + + if((mf=_mm_calloc(1,sizeof(UNIMOD))) == NULL) return NULL; + return mf; +} + + +/****************************************** + + Next are the user-callable functions + +******************************************/ + + +void MikMod_FreeSong(UNIMOD *mf) +{ + if(mf!=NULL) + { Player_Exit(mf); + ML_FreeEx(mf); + } +} + + +CHAR *MikMod_LoadSongTitle(CHAR *filename) +{ + MLOADER *l; + CHAR *retval; + FILE *fp; + + if((fp = _mm_fopen(filename,"rb"))==NULL) return NULL; + + _mm_errno = 0; + _mm_critical = 0; + _mm_iobase_setcur(modfp); + + /* Try to find a loader that recognizes the module */ + + for(l=firstloader; l!=NULL; l=l->next) + { _mm_rewind(modfp); + if(l->Test()) break; + } + + if(l==NULL) + { _mm_errno = MMERR_NOT_A_MODULE; + _mm_iobase_revert(); + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return NULL; + } + + retval = l->LoadTitle(); + + fclose(fp); + return(retval); +} + + +UNIMOD *MikMod_LoadSongFP(FILE *fp, int maxchan) + +/* Loads a module given a file pointer. */ +/* File is loaded from the current file seek position. */ + +{ + int t; + MLOADER *l; + BOOL ok; + UNIMOD *mf; + + modfp = fp; + _mm_errno = 0; + _mm_critical = 0; + + _mm_iobase_setcur(modfp); + + /* Try to find a loader that recognizes the module */ + + for(l=firstloader; l!=NULL; l=l->next) + { _mm_rewind(modfp); + if(l->Test()) break; + } + + if(l==NULL) + { _mm_errno = MMERR_NOT_A_MODULE; + _mm_iobase_revert(); + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return NULL; + } + + /* init unitrk routines */ + if(!UniInit()) + { if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return NULL; + } + + /* load the song using the song's loader variable */ + memset(&of,0,sizeof(UNIMOD)); + of.initvolume = 128; + + /* init panning array */ + for(t=0; t<64; t++) of.panning[t] = ((t+1)&2) ? 255 : 0; + for(t=0; t<64; t++) of.chanvol[t] = 64; + + /* init module loader and load the header / patterns */ + if(l->Init()) + { _mm_rewind(modfp); + ok = l->Load(); + } else ok = 0; + + /* free loader and unitrk allocations */ + l->Cleanup(); + UniCleanup(); + + if(!ok) + { ML_FreeEx(&of); + _mm_iobase_revert(); + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return NULL; + } + + if(!ML_LoadSamples()) + { ML_FreeEx(&of); + _mm_iobase_revert(); + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return NULL; + } + + if((mf=ML_AllocUniMod()) == NULL) + { ML_FreeEx(&of); + _mm_iobase_revert(); + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return NULL; + } + + /* Copy the static UNIMOD contents into the dynamic UNIMOD struct. */ + memcpy(mf,&of,sizeof(UNIMOD)); + + _mm_iobase_revert(); + + if(maxchan > 0) + { if(!(mf->flags & UF_NNA) && (mf->numchn < maxchan)) + maxchan = mf->numchn; + else if((mf->numvoices!=0) && mf->numvoices < maxchan) + maxchan = mf->numvoices; + + if(maxchan < mf->numchn) mf->flags |= UF_NNA; + + if(MikMod_SetNumVoices(maxchan,-1)) + { MikMod_FreeSong(mf); + return NULL; + } + } + + return mf; +} + + +UNIMOD *MikMod_LoadSong(CHAR *filename, int maxchan) + +/* Open a module via it's filename. The loader will initialize the specified */ +/* song-player 'player'. */ + +{ + FILE *fp; + UNIMOD *mf; + + if((fp = _mm_fopen(filename,"rb"))==NULL) return NULL; + if((mf = MikMod_LoadSongFP(fp, maxchan)) != NULL) + { if(SL_LoadSamples() || Player_Init(mf)) + { MikMod_FreeSong(mf); + mf = NULL; + } + } + + fclose(fp); + return mf; +} + diff --git a/mikmod/mlreg.c b/mikmod/mlreg.c new file mode 100644 index 00000000..265fe134 --- /dev/null +++ b/mikmod/mlreg.c @@ -0,0 +1,22 @@ +/* + + Name: MLREG.C + + Description: + A single routine for registering all loaders in MikMod for the current + platform. + + Portability: + All systems - all compilers + +*/ + +#include "mikmod.h" + +void MikMod_RegisterAllLoaders(void) +{ + MikMod_RegisterLoader(load_it); + MikMod_RegisterLoader(load_xm); + MikMod_RegisterLoader(load_s3m); + MikMod_RegisterLoader(load_mod); +} diff --git a/mikmod/mmalloc.c b/mikmod/mmalloc.c new file mode 100644 index 00000000..270a00b8 --- /dev/null +++ b/mikmod/mmalloc.c @@ -0,0 +1,63 @@ +/* + --> The MMIO Portable Memory Management functions + -> Divine Entertainment GameDev Libraries + + Copyright © 1997 by Jake Stine and Divine Entertainment + +*/ + +#include +#include "mmio.h" + + +/* Same as malloc, but sets error variable _mm_error when it failed */ +void *_mm_malloc(size_t size) +{ + void *d; + + if((d=malloc(size))==NULL) + { _mm_errno = MMERR_OUT_OF_MEMORY; + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + } + + return d; +} + + +/* Same as calloc, but sets error variable _mm_error when it failed */ +void *_mm_calloc(size_t nitems, size_t size) +{ + void *d; + + if((d=calloc(nitems,size))==NULL) + { _mm_errno = MMERR_OUT_OF_MEMORY; + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + } + + return d; +} + + +#ifndef __WATCOMC__ +#ifndef __GNUC__ +#ifndef __BEOS__ +#ifndef _SGI_SOURCE +/* Same as Watcom's strdup function - allocates memory for a string */ +/* and makes a copy of it. Ruturns NULL if failed. */ +CHAR *strdup(CHAR *src) +{ + CHAR *buf; + + if((buf = (CHAR *)_mm_malloc(strlen(src)+1)) == NULL) + { _mm_errno = MMERR_OUT_OF_MEMORY; + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return NULL; + } + + strcpy(buf,src); + return buf; +} +#endif +#endif +#endif +#endif diff --git a/mikmod/mmerror.c b/mikmod/mmerror.c new file mode 100644 index 00000000..6090bc2c --- /dev/null +++ b/mikmod/mmerror.c @@ -0,0 +1,103 @@ +/* + --> The MM_Error Portable Error Handling Functions + -> Divine Entertainment GameDev Libraries + + File: MMERROR.C + + Description: + Error handling functions for use with the DivEnt MMIO and MikMod + libraries. Register an error handler with _mm_RegisterErrorHandler() + and you're all set. + + NOTES: + + - the global variables _mm_error, _mm_errno, and _mm_critical are + set before the error handler in called. See below for the values + of these variables. + +-------------------------- + + +*/ + + +#include "mmio.h" + +CHAR *_mm_errmsg[] = +{ + "", + +/* Generic MikMod Errors [referenced by _mm_error] */ +/* ----------------------------------------------- */ + + "Cannot open requested file", + "Out of memory", + "Unexpected end of file", + "Cannot write to file - Disk full", + +/* Specific Misceallenous Errors: */ + + "Sample load failed - Out of memory", + "Sample load failed - Out of sample handles", + "Could not allocate page-contiguous dma-buffer", + "Unknown wave file or sample type", + "Unknown streaming audio type", + +/* Specific Module Loader [MLOADER.C] errors: */ + + "Failure loading module pattern", + "Failure loading module track", + "Failure loading module header", + "Failure loading sampleinfo", + "Unknown module format", + +/* Specific Driver [MDRIVER.C / drivers] errors: */ + + "None of the supported sound-devices were detected", + "Device number out of range", + "Software mixer failure - Out of memory", + +#ifdef SUN +#elif defined(SOLARIS) +#elif defined(__alpha) + "Cannot find suitable audio port!" +#elif defined(OSS) + #ifdef ULTRA + #endif +#elif defined(__hpux) + "Unable to open /dev/audio", + "Unable to set non-blocking mode for /dev/audio", + "Unable to select 16bit-linear sample format", + "Could not select requested sample-rate", + "Could not select requested number of channels", + "Unable to select audio output", + "Unable to get audio description", + "Unable to get gain values", + "Unable to set gain values", + "Could not set transmission buffer size" +#elif defined(AIX) + "Could not open AIX audio device", + "Configuration (init) of AIX audio device failed", + "Configuration (control) of AIX audio device failed", + "Configuration (start) of AIX audio device failed", + "Unable to set non-blocking mode for /dev/audio", +#elif defined(SGI) +#elif defined(__OS2__) +#elif defined(__WIN32__) +#else + "The requested soundcard was not found", + "Could not open a High-DMA channel" +#endif +}; + + +void (*_mm_errorhandler)(void) = NULL; +int _mm_errno = 0; +BOOL _mm_critical = 0; + + +void _mm_RegisterErrorHandler(void (*proc)(void)) +{ + _mm_errorhandler = proc; +} + diff --git a/mikmod/mmio.c b/mikmod/mmio.c new file mode 100644 index 00000000..a67309d3 --- /dev/null +++ b/mikmod/mmio.c @@ -0,0 +1,457 @@ +/* + --> The MMIO Portable Input/Output functions + -> Divine Entertainment GameDev Libraries + + File: MMIO.C + + Description: + Miscellaneous I/O routines.. used to solve some portability issues + (like big/little endian machines and word alignment in structures ) + Also includes mikmod's ingenious error handling variable. + + Portability: + All systems - all compilers + + + ----------------------------------- + The way this module works - By Jake Stine [Air Richter] + + - _mm_fopen and _mm_copyfile will call the errorhandler [see mmerror.c] in + addition to setting _mm_errno on exit. + + - _mm_iobase is for internal use. It is used by ML_LoadFP() to ensure that it + works properly with wad files. + + - _mm_read_I_UWORD and _mm_read_M_UWORD have distinct differences: + the first is for reading data written by a little endian (intel) machine, + and the second is for reading big endian (Mac, RISC, Alpha) machine data. + + - _mm_write functions work the same as the _mm_read functions. + + - _mm_read_string is for reading binary strings. It is basically the same + as an fread of bytes. +*/ + +#include +#include "mmio.h" +#include + +#define COPY_BUFSIZE 1024 + +static long _mm_iobase = 0, + temp_iobase = 0; + +UBYTE _mm_cpybuf[COPY_BUFSIZE]; + + +void StringWrite(CHAR *s, FILE *fp) +/* Specialized file output procedure. Writes a UWORD length and then a */ +/* string of the specified length (no NULL terminator) afterward. */ +{ + int slen; + + if(s==NULL) + { _mm_write_I_UWORD(0,fp); + } else + { _mm_write_I_UWORD(slen = strlen(s),fp); + _mm_write_UBYTES(s,slen,fp); + } +} + +CHAR *StringRead(FILE *fp) +/* Reads strings written out by StringWrite above: a UWORD length followed */ +/* by length characters. A NULL is added to the string after loading. */ +{ + CHAR *s; + UWORD len; + + len = _mm_read_I_UWORD(fp); + if(len==0) + { s = _mm_calloc(16, sizeof(CHAR)); + } else + { if((s = (CHAR *)_mm_malloc(len+1)) == NULL) return NULL; + _mm_read_UBYTES(s,len,fp); + s[len] = 0; + } + + return s; +} + + +FILE *_mm_fopen(CHAR *fname, CHAR *attrib) +{ + FILE *fp; + + if((fp=fopen(fname,attrib)) == NULL) + { _mm_errno = _mm_errno = MMERR_OPENING_FILE; + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + } + return fp; +} + + +int _mm_fseek(FILE *stream, long offset, int whence) +{ + return fseek(stream,(whence==SEEK_SET) ? offset+_mm_iobase : offset, whence); +} + + +long _mm_ftell(FILE *stream) +{ + return ftell(stream)-_mm_iobase; +} + + +BOOL _mm_FileExists(CHAR *fname) +{ + FILE *fp; + + if((fp=fopen(fname,"r")) == NULL) return 0; + fclose(fp); + + return 1; +} + + +long _mm_flength(FILE *stream) +{ + long tmp,tmp2; + + tmp = ftell(stream); + fseek(stream,0,SEEK_END); + tmp2 = ftell(stream); + fseek(stream,tmp,SEEK_SET); + return tmp2-tmp; +} + + +long _mm_iobase_get(void) +{ + return _mm_iobase; +} + + +void _mm_iobase_set(long iobase) +{ + temp_iobase = _mm_iobase; /* store old value in case of revert */ + _mm_iobase = iobase; +} + + +/* Sets the current file-position as the new _mm_iobase */ +void _mm_iobase_setcur(FILE *fp) +{ + temp_iobase = _mm_iobase; /* store old value in case of revert */ + _mm_iobase = ftell(fp); +} + + +/* Reverts to the last known _mm_iobase value. */ +void _mm_iobase_revert(void) +{ + _mm_iobase = temp_iobase; +} + + +/* Procedure: _mm_copyfile */ +/* Copies a given number of bytes from the source file to the destination */ +/* file. Returns 1 on error, and calls the _mm_errnohandler, if registered. */ +BOOL _mm_copyfile(FILE *fpi, FILE *fpo, ULONG len) +{ + ULONG todo; + + while(len) + { todo = (len > COPY_BUFSIZE) ? COPY_BUFSIZE : len; + if(!fread(_mm_cpybuf, todo, 1, fpi)) + { _mm_errno = _mm_errno = MMERR_END_OF_FILE; + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return 1; + } + if(!fwrite(_mm_cpybuf, todo, 1, fpo)) + { _mm_errno = _mm_errno = MMERR_DISK_FULL; + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return 1; + } + len -= todo; + } + + return 0; +} + + +void _mm_write_string(CHAR *data, FILE *fp) +{ + if(data!=NULL) + _mm_write_UBYTES(data, strlen(data), fp); +} + + +void _mm_fputs(FILE *fp, CHAR *data) +{ + if(data != NULL) + _mm_write_UBYTES(data, strlen(data), fp); + +#ifndef __UNIX__ + _mm_write_UBYTE(13,fp); +#endif + _mm_write_UBYTE(10,fp); +} + + + +#if 0 +/* These have accompanying #define's in mmio.h */ + +void _mm_write_SBYTE(SBYTE data, FILE *fp) +{ + fputc(data,fp); +} + +void _mm_write_UBYTE(UBYTE data,FILE *fp) +{ + fputc(data,fp); +} +#endif + + +#ifdef MM_BIG_ENDIAN + +/* --> Big Endian Write Functions */ + +void _mm_write_M_UWORD(UWORD data,FILE *fp) +{ + _mm_write_UBYTE(data&0xff,fp); + _mm_write_UBYTE(data>>8,fp); +} + + +void _mm_write_I_UWORD(UWORD data,FILE *fp) +{ + _mm_write_UBYTE(data>>8,fp); + _mm_write_UBYTE(data&0xff,fp); +} + + +void _mm_write_M_ULONG(ULONG data,FILE *fp) +{ + _mm_write_M_UWORD(data&0xffff,fp); + _mm_write_M_UWORD(data>>16,fp); +} + + +void _mm_write_I_ULONG(ULONG data,FILE *fp) +{ + _mm_write_I_UWORD(data>>16,fp); + _mm_write_I_UWORD(data&0xffff,fp); +} + +#else + +/* --> Little Endian Write Functions */ + +void _mm_write_M_UWORD(UWORD data,FILE *fp) +{ + _mm_write_UBYTE(data>>8,fp); + _mm_write_UBYTE(data&0xff,fp); +} + + +void _mm_write_I_UWORD(UWORD data,FILE *fp) +{ + _mm_write_UBYTE(data&0xff,fp); + _mm_write_UBYTE(data>>8,fp); +} + + +void _mm_write_M_ULONG(ULONG data,FILE *fp) +{ + _mm_write_M_UWORD(data>>16,fp); + _mm_write_M_UWORD(data&0xffff,fp); +} + + +void _mm_write_I_ULONG(ULONG data,FILE *fp) +{ + _mm_write_I_UWORD(data&0xffff,fp); + _mm_write_I_UWORD(data>>16,fp); +} + +#endif + + +void _mm_write_M_SWORD(SWORD data,FILE *fp) +{ + _mm_write_M_UWORD((UWORD)data,fp); +} + + +void _mm_write_I_SWORD(SWORD data,FILE *fp) +{ + _mm_write_I_UWORD((UWORD)data,fp); +} + + +void _mm_write_M_SLONG(SLONG data,FILE *fp) +{ + _mm_write_M_ULONG((ULONG)data,fp); +} + + +void _mm_write_I_SLONG(SLONG data,FILE *fp) +{ + _mm_write_I_ULONG((ULONG)data,fp); +} + + +#define DEFINE_MULTIPLE_WRITE_FUNCTION(type_name, type) \ +void \ +_mm_write_##type_name##S (type *buffer, int number, FILE *fp) \ +{ \ + while(number>0) \ + { _mm_write_##type_name(*(buffer++),fp); \ + number--; \ + } \ +} + +/*DEFINE_MULTIPLE_WRITE_FUNCTION (SBYTE, SBYTE) */ +/*DEFINE_MULTIPLE_WRITE_FUNCTION (UBYTE, UBYTE) */ + +DEFINE_MULTIPLE_WRITE_FUNCTION (M_SWORD, SWORD) +DEFINE_MULTIPLE_WRITE_FUNCTION (M_UWORD, UWORD) +DEFINE_MULTIPLE_WRITE_FUNCTION (I_SWORD, SWORD) +DEFINE_MULTIPLE_WRITE_FUNCTION (I_UWORD, UWORD) + +DEFINE_MULTIPLE_WRITE_FUNCTION (M_SLONG, SLONG) +DEFINE_MULTIPLE_WRITE_FUNCTION (M_ULONG, ULONG) +DEFINE_MULTIPLE_WRITE_FUNCTION (I_SLONG, SLONG) +DEFINE_MULTIPLE_WRITE_FUNCTION (I_ULONG, ULONG) + + +/********** +SBYTE _mm_read_SBYTE(FILE *fp) +{ + return(fgetc(fp)); +} + +UBYTE _mm_read_UBYTE(FILE *fp) +{ + return(fgetc(fp)); +} +**********/ + + +#ifdef MM_BIG_ENDIAN + +UWORD _mm_read_I_UWORD(FILE *fp) +{ + UWORD result=((UWORD)_mm_read_UBYTE(fp))<<8; + result|=_mm_read_UBYTE(fp); + return result; +} + +UWORD _mm_read_M_UWORD(FILE *fp) +{ + UWORD result=_mm_read_UBYTE(fp); + result|=((UWORD)_mm_read_UBYTE(fp))<<8; + return result; +} + +ULONG _mm_read_I_ULONG(FILE *fp) +{ + ULONG result=((ULONG)_mm_read_M_UWORD(fp))<<16; + result|=_mm_read_M_UWORD(fp); + return result; +} + +ULONG _mm_read_M_ULONG(FILE *fp) +{ + ULONG result=_mm_read_I_UWORD(fp); + result|=((ULONG)_mm_read_I_UWORD(fp))<<16; + return result; +} + +#else + +UWORD _mm_read_M_UWORD(FILE *fp) +{ + UWORD result=((UWORD)_mm_read_UBYTE(fp))<<8; + result|=_mm_read_UBYTE(fp); + return result; +} + +UWORD _mm_read_I_UWORD(FILE *fp) +{ + UWORD result=_mm_read_UBYTE(fp); + result|=((UWORD)_mm_read_UBYTE(fp))<<8; + return result; +} + +ULONG _mm_read_M_ULONG(FILE *fp) +{ + ULONG result=((ULONG)_mm_read_M_UWORD(fp))<<16; + result|=_mm_read_M_UWORD(fp); + return result; +} + +ULONG _mm_read_I_ULONG(FILE *fp) +{ + ULONG result=_mm_read_I_UWORD(fp); + result|=((ULONG)_mm_read_I_UWORD(fp))<<16; + return result; +} + +#endif + +SWORD _mm_read_M_SWORD(FILE *fp) +{ + return((SWORD)_mm_read_M_UWORD(fp)); +} + +SWORD _mm_read_I_SWORD(FILE *fp) +{ + return((SWORD)_mm_read_I_UWORD(fp)); +} + +SLONG _mm_read_M_SLONG(FILE *fp) +{ + return((SLONG)_mm_read_M_ULONG(fp)); +} + +SLONG _mm_read_I_SLONG(FILE *fp) +{ + return((SLONG)_mm_read_I_ULONG(fp)); +} + + +int _mm_read_string(CHAR *buffer, int number, FILE *fp) +{ + fread(buffer,1,number,fp); + return !feof(fp); +} + + + +#define DEFINE_MULTIPLE_READ_FUNCTION(type_name, type) \ +int \ +_mm_read_##type_name##S (type *buffer, int number, FILE *fp) \ +{ \ + while(number>0) \ + { *(buffer++)=_mm_read_##type_name(fp); \ + number--; \ + } \ + return !feof(fp); \ +} + +/*DEFINE_MULTIPLE_READ_FUNCTION (SBYTE, SBYTE) */ +/*DEFINE_MULTIPLE_READ_FUNCTION (UBYTE, UBYTE) */ + +DEFINE_MULTIPLE_READ_FUNCTION (M_SWORD, SWORD) +DEFINE_MULTIPLE_READ_FUNCTION (M_UWORD, UWORD) +DEFINE_MULTIPLE_READ_FUNCTION (I_SWORD, SWORD) +DEFINE_MULTIPLE_READ_FUNCTION (I_UWORD, UWORD) + +DEFINE_MULTIPLE_READ_FUNCTION (M_SLONG, SLONG) +DEFINE_MULTIPLE_READ_FUNCTION (M_ULONG, ULONG) +DEFINE_MULTIPLE_READ_FUNCTION (I_SLONG, SLONG) +DEFINE_MULTIPLE_READ_FUNCTION (I_ULONG, ULONG) + diff --git a/mikmod/mmio.h b/mikmod/mmio.h new file mode 100644 index 00000000..1f5a9f87 --- /dev/null +++ b/mikmod/mmio.h @@ -0,0 +1,272 @@ +#ifndef _MMIO_H_ +#define _MMIO_H_ + +#include +#include +#include "tdefs.h" + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* LOG.C Prototypes */ +/* ================ */ + +#define LOG_SILENT 0 +#define LOG_VERBOSE 1 + +extern int log_init(CHAR *logfile, BOOL val); +extern void log_exit(void); +extern void log_verbose(void); +extern void log_silent(void); +extern void printlog(CHAR *fmt, ... ); +extern void printlogv(CHAR *fmt, ... ); + +#ifdef __WATCOMC__ +#pragma aux log_init parm nomemory modify nomemory; +#pragma aux log_exit parm nomemory modify nomemory; +#pragma aux log_verbose parm nomemory modify nomemory; +#pragma aux log_silent parm nomemory modify nomemory; +#pragma aux printlog parm nomemory modify nomemory; +#pragma aux printlogv parm nomemory modify nomemory; +#endif + + + +/* MikMod's new error handling routines */ +/* ==================================== */ + +/* Specific Errors [referenced by _mm_errno] */ + +enum +{ MMERR_OPENING_FILE = 1, + MMERR_OUT_OF_MEMORY, + MMERR_END_OF_FILE, + MMERR_DISK_FULL, + MMERR_SAMPLE_TOO_BIG, + MMERR_OUT_OF_HANDLES, + MMERR_ALLOCATING_DMA, + MMERR_UNKNOWN_WAVE_TYPE, + MMERR_NOT_A_STREAM, + MMERR_LOADING_PATTERN, + MMERR_LOADING_TRACK, + MMERR_LOADING_HEADER, + MMERR_LOADING_SAMPLEINFO, + MMERR_NOT_A_MODULE, + MMERR_DETECTING_DEVICE, + MMERR_INVALID_DEVICE, + MMERR_INITIALIZING_MIXER +#ifdef SUN +#elif defined(SOLARIS) +#elif defined(__alpha) + ,MMERR_AF_AUDIO_PORT +#elif defined(OSS) + #ifdef ULTRA + #endif +#elif defined(__hpux) + ,MMERR_OPENING_DEVAUDIO, + MMERR_SETTING_NONBLOCKING, + MMERR_SETTING_SAMPLEFORMAT, + MMERR_SETTING_SAMPLERATE, + MMERR_SETTING_CHANNELS, + MMERR_SELECTING_AUDIO_OUTPUT, + MMERR_GETTING_AUDIO_DESC, + MMERR_GETTING_GAINS, + MMERR_SETTING_GAINS, + MMERR_SETTING_BUFFERSIZE +#elif defined(AIX) + ,MMERR_OPENING_AIX, + MMERR_AIX_CONFIG_INIT, + MMERR_AIX_CONFIG_CONTROL, + MMERR_AIX_CONFIG_START, + MMERR_AIX_NON_BLOCK +#elif defined(_SGI_SOURCE) +#elif defined(__OS2__) +#elif defined(__WIN32__) +#else + ,MMERR_DETECTING_SOUNDCARD, + MMERR_SETTING_HIDMA +#endif +}; + +/* Memory allocation with error handling - MMALLOC.C */ +/* ================================================= */ + +extern void *_mm_malloc(size_t size); +extern void *_mm_calloc(size_t nitems, size_t size); + +extern void (*_mm_errorhandler)(void); +extern int _mm_errno; +extern BOOL _mm_critical; +extern CHAR *_mm_errmsg[]; + +extern void _mm_RegisterErrorHandler(void (*proc)(void)); +extern BOOL _mm_FileExists(CHAR *fname); + +extern void StringWrite(CHAR *s, FILE *fp); +extern CHAR *StringRead(FILE *fp); + + +/* MikMod/DivEnt style file input / output - */ +/* Solves several portability issues. */ +/* Notibly little vs. big endian machine complications. */ + +#define _mm_write_SBYTE(x,y) fputc((int)x,y) +#define _mm_write_UBYTE(x,y) fputc((int)x,y) + +#define _mm_read_SBYTE(x) (SBYTE)fgetc(x) +#define _mm_read_UBYTE(x) (UBYTE)fgetc(x) + +#define _mm_write_SBYTES(x,y,z) fwrite((void *)x,1,y,z) +#define _mm_write_UBYTES(x,y,z) fwrite((void *)x,1,y,z) +#define _mm_read_SBYTES(x,y,z) fread((void *)x,1,y,z) +#define _mm_read_UBYTES(x,y,z) fread((void *)x,1,y,z) + +#define _mm_rewind(x) _mm_fseek(x,0,SEEK_SET) + + +extern int _mm_fseek(FILE *stream, long offset, int whence); +extern long _mm_iobase_get(void); +extern void _mm_iobase_set(long iobase); +extern void _mm_iobase_setcur(FILE *fp); +extern void _mm_iobase_revert(void); +extern long _mm_ftell(FILE *stream); +extern long _mm_flength(FILE *stream); +extern FILE *_mm_fopen(CHAR *fname, CHAR *attrib); +extern void _mm_fputs(FILE *fp, CHAR *data); +extern BOOL _mm_copyfile(FILE *fpi, FILE *fpo, ULONG len); +extern void _mm_write_string(CHAR *data, FILE *fp); +extern int _mm_read_string (CHAR *buffer, int number, FILE *fp); + + +/*extern SBYTE _mm_read_SBYTE (FILE *fp); */ +/*extern UBYTE _mm_read_UBYTE (FILE *fp); */ + +extern SWORD _mm_read_M_SWORD (FILE *fp); +extern SWORD _mm_read_I_SWORD (FILE *fp); + +extern UWORD _mm_read_M_UWORD (FILE *fp); +extern UWORD _mm_read_I_UWORD (FILE *fp); + +extern SLONG _mm_read_M_SLONG (FILE *fp); +extern SLONG _mm_read_I_SLONG (FILE *fp); + +extern ULONG _mm_read_M_ULONG (FILE *fp); +extern ULONG _mm_read_I_ULONG (FILE *fp); + + +/*extern int _mm_read_SBYTES (SBYTE *buffer, int number, FILE *fp); */ +/*extern int _mm_read_UBYTES (UBYTE *buffer, int number, FILE *fp); */ + +extern int _mm_read_M_SWORDS (SWORD *buffer, int number, FILE *fp); +extern int _mm_read_I_SWORDS (SWORD *buffer, int number, FILE *fp); + +extern int _mm_read_M_UWORDS (UWORD *buffer, int number, FILE *fp); +extern int _mm_read_I_UWORDS (UWORD *buffer, int number, FILE *fp); + +extern int _mm_read_M_SLONGS (SLONG *buffer, int number, FILE *fp); +extern int _mm_read_I_SLONGS (SLONG *buffer, int number, FILE *fp); + +extern int _mm_read_M_ULONGS (ULONG *buffer, int number, FILE *fp); +extern int _mm_read_I_ULONGS (ULONG *buffer, int number, FILE *fp); + + +/*extern void _mm_write_SBYTE (SBYTE data, FILE *fp); */ +/*extern void _mm_write_UBYTE (UBYTE data, FILE *fp); */ + +extern void _mm_write_M_SWORD (SWORD data, FILE *fp); +extern void _mm_write_I_SWORD (SWORD data, FILE *fp); + +extern void _mm_write_M_UWORD (UWORD data, FILE *fp); +extern void _mm_write_I_UWORD (UWORD data, FILE *fp); + +extern void _mm_write_M_SLONG (SLONG data, FILE *fp); +extern void _mm_write_I_SLONG (SLONG data, FILE *fp); + +extern void _mm_write_M_ULONG (ULONG data, FILE *fp); +extern void _mm_write_I_ULONG (ULONG data, FILE *fp); + +/*extern void _mm_write_SBYTES (SBYTE *data, int number, FILE *fp); */ +/*extern void _mm_write_UBYTES (UBYTE *data, int number, FILE *fp); */ + +extern void _mm_write_M_SWORDS (SWORD *data, int number, FILE *fp); +extern void _mm_write_I_SWORDS (SWORD *data, int number, FILE *fp); + +extern void _mm_write_M_UWORDS (UWORD *data, int number, FILE *fp); +extern void _mm_write_I_UWORDS (UWORD *data, int number, FILE *fp); + +extern void _mm_write_M_SLONGS (SLONG *data, int number, FILE *fp); +extern void _mm_write_I_SLONGS (SLONG *data, int number, FILE *fp); + +extern void _mm_write_M_ULONGS (ULONG *data, int number, FILE *fp); +extern void _mm_write_I_ULONGS (ULONG *data, int number, FILE *fp); + +#ifdef __WATCOMC__ +#pragma aux _mm_fseek parm nomemory modify nomemory +#pragma aux _mm_ftell parm nomemory modify nomemory +#pragma aux _mm_flength parm nomemory modify nomemory +#pragma aux _mm_fopen parm nomemory modify nomemory +#pragma aux _mm_fputs parm nomemory modify nomemory +#pragma aux _mm_copyfile parm nomemory modify nomemory +#pragma aux _mm_iobase_get parm nomemory modify nomemory +#pragma aux _mm_iobase_set parm nomemory modify nomemory +#pragma aux _mm_iobase_setcur parm nomemory modify nomemory +#pragma aux _mm_iobase_revert parm nomemory modify nomemory +#pragma aux _mm_write_string parm nomemory modify nomemory +#pragma aux _mm_read_string parm nomemory modify nomemory + +#pragma aux _mm_read_M_SWORD parm nomemory modify nomemory; +#pragma aux _mm_read_I_SWORD parm nomemory modify nomemory; +#pragma aux _mm_read_M_UWORD parm nomemory modify nomemory; +#pragma aux _mm_read_I_UWORD parm nomemory modify nomemory; +#pragma aux _mm_read_M_SLONG parm nomemory modify nomemory; +#pragma aux _mm_read_I_SLONG parm nomemory modify nomemory; +#pragma aux _mm_read_M_ULONG parm nomemory modify nomemory; +#pragma aux _mm_read_I_ULONG parm nomemory modify nomemory; + +#pragma aux _mm_read_M_SWORDS parm nomemory modify nomemory; +#pragma aux _mm_read_I_SWORDS parm nomemory modify nomemory; +#pragma aux _mm_read_M_UWORDS parm nomemory modify nomemory; +#pragma aux _mm_read_I_UWORDS parm nomemory modify nomemory; +#pragma aux _mm_read_M_SLONGS parm nomemory modify nomemory; +#pragma aux _mm_read_I_SLONGS parm nomemory modify nomemory; +#pragma aux _mm_read_M_ULONGS parm nomemory modify nomemory; +#pragma aux _mm_read_I_ULONGS parm nomemory modify nomemory; + +#pragma aux _mm_write_M_SWORD parm nomemory modify nomemory; +#pragma aux _mm_write_I_SWORD parm nomemory modify nomemory; +#pragma aux _mm_write_M_UWORD parm nomemory modify nomemory; +#pragma aux _mm_write_I_UWORD parm nomemory modify nomemory; +#pragma aux _mm_write_M_SLONG parm nomemory modify nomemory; +#pragma aux _mm_write_I_SLONG parm nomemory modify nomemory; +#pragma aux _mm_write_M_ULONG parm nomemory modify nomemory; +#pragma aux _mm_write_I_ULONG parm nomemory modify nomemory; + +#pragma aux _mm_write_M_SWORDS parm nomemory modify nomemory; +#pragma aux _mm_write_I_SWORDS parm nomemory modify nomemory; +#pragma aux _mm_write_M_UWORDS parm nomemory modify nomemory; +#pragma aux _mm_write_I_UWORDS parm nomemory modify nomemory; +#pragma aux _mm_write_M_SLONGS parm nomemory modify nomemory; +#pragma aux _mm_write_I_SLONGS parm nomemory modify nomemory; +#pragma aux _mm_write_M_ULONGS parm nomemory modify nomemory; +#pragma aux _mm_write_I_ULONGS parm nomemory modify nomemory; +#endif + + +#ifndef __WATCOMC__ +#ifndef __GNUC__ +#ifndef __BEOS__ +#ifndef _SGI_SOURCE +extern CHAR *strdup(CHAR *str); +#endif +#endif +#endif +#endif + +#ifdef __cplusplus +}; +#endif + +#endif diff --git a/mikmod/mplayer.c b/mikmod/mplayer.c new file mode 100644 index 00000000..053a156e --- /dev/null +++ b/mikmod/mplayer.c @@ -0,0 +1,2762 @@ +/* + --> The Protracker Player Driver + -> Part of the SPLAYER pack for MikMod 3.0 + + The protracker driver supports all base Protracker 3.x commands and fea- + tures. +*/ + +#include +#include +#include "mikmod.h" + + +static void DoNNAEffects(UBYTE dat); + +/* Set forbid to 1 when you want to modify any of the pf->sngpos, pf->patpos etc. */ +/* variables and clear it when you're done. This prevents getting strange */ +/* results due to intermediate interrupts. */ + +UNIMOD *pf; /* <- this modfile is being played */ +static SWORD mp_channel; /* channel it's working on */ +static MP_CONTROL *a; /* current AUDTMP it's working on */ +static int isfirst; + +static MP_VOICE aout_dummy; + +UWORD mytab[12] = +{ 1712*16, 1616*16, 1524*16, 1440*16, 1356*16, 1280*16, + 1208*16, 1140*16, 1076*16, 1016*16, 960*16, 907*16 +}; + + +UBYTE VibratoTable[32] = +{ 0,24,49,74,97,120,141,161, + 180,197,212,224,235,244,250,253, + 255,253,250,244,235,224,212,197, + 180,161,141,120,97,74,49,24 +}; + + +UBYTE avibtab[128] = +{ 0,1,3,4,6,7,9,10,12,14,15,17,18,20,21,23, + 24,25,27,28,30,31,32,34,35,36,38,39,40,41,42,44, + 45,46,47,48,49,50,51,52,53,54,54,55,56,57,57,58, + 59,59,60,60,61,61,62,62,62,63,63,63,63,63,63,63, + 64,63,63,63,63,63,63,63,62,62,62,61,61,60,60,59, + 59,58,57,57,56,55,54,54,53,52,51,50,49,48,47,46, + 45,44,42,41,40,39,38,36,35,34,32,31,30,28,27,25, + 24,23,21,20,18,17,15,14,12,10,9,7,6,4,3,1 +}; + + +/* ** Triton's linear periods to frequency translation table (for */ +/* ** Fast Tracker 2 [XM] modules): */ + +ULONG lintab[768] = +{ 535232,534749,534266,533784,533303,532822,532341,531861, + 531381,530902,530423,529944,529466,528988,528511,528034, + 527558,527082,526607,526131,525657,525183,524709,524236, + 523763,523290,522818,522346,521875,521404,520934,520464, + 519994,519525,519057,518588,518121,517653,517186,516720, + 516253,515788,515322,514858,514393,513929,513465,513002, + 512539,512077,511615,511154,510692,510232,509771,509312, + 508852,508393,507934,507476,507018,506561,506104,505647, + 505191,504735,504280,503825,503371,502917,502463,502010, + 501557,501104,500652,500201,499749,499298,498848,498398, + 497948,497499,497050,496602,496154,495706,495259,494812, + 494366,493920,493474,493029,492585,492140,491696,491253, + 490809,490367,489924,489482,489041,488600,488159,487718, + 487278,486839,486400,485961,485522,485084,484647,484210, + 483773,483336,482900,482465,482029,481595,481160,480726, + 480292,479859,479426,478994,478562,478130,477699,477268, + 476837,476407,475977,475548,475119,474690,474262,473834, + 473407,472979,472553,472126,471701,471275,470850,470425, + 470001,469577,469153,468730,468307,467884,467462,467041, + 466619,466198,465778,465358,464938,464518,464099,463681, + 463262,462844,462427,462010,461593,461177,460760,460345, + 459930,459515,459100,458686,458272,457859,457446,457033, + 456621,456209,455797,455386,454975,454565,454155,453745, + 453336,452927,452518,452110,451702,451294,450887,450481, + 450074,449668,449262,448857,448452,448048,447644,447240, + 446836,446433,446030,445628,445226,444824,444423,444022, + 443622,443221,442821,442422,442023,441624,441226,440828, + 440430,440033,439636,439239,438843,438447,438051,437656, + 437261,436867,436473,436079,435686,435293,434900,434508, + 434116,433724,433333,432942,432551,432161,431771,431382, + 430992,430604,430215,429827,429439,429052,428665,428278, + 427892,427506,427120,426735,426350,425965,425581,425197, + 424813,424430,424047,423665,423283,422901,422519,422138, + 421757,421377,420997,420617,420237,419858,419479,419101, + 418723,418345,417968,417591,417214,416838,416462,416086, + 415711,415336,414961,414586,414212,413839,413465,413092, + 412720,412347,411975,411604,411232,410862,410491,410121, + 409751,409381,409012,408643,408274,407906,407538,407170, + 406803,406436,406069,405703,405337,404971,404606,404241, + 403876,403512,403148,402784,402421,402058,401695,401333, + 400970,400609,400247,399886,399525,399165,398805,398445, + 398086,397727,397368,397009,396651,396293,395936,395579, + 395222,394865,394509,394153,393798,393442,393087,392733, + 392378,392024,391671,391317,390964,390612,390259,389907, + 389556,389204,388853,388502,388152,387802,387452,387102, + 386753,386404,386056,385707,385359,385012,384664,384317, + 383971,383624,383278,382932,382587,382242,381897,381552, + 381208,380864,380521,380177,379834,379492,379149,378807, + + 378466,378124,377783,377442,377102,376762,376422,376082, + 375743,375404,375065,374727,374389,374051,373714,373377, + 373040,372703,372367,372031,371695,371360,371025,370690, + 370356,370022,369688,369355,369021,368688,368356,368023, + 367691,367360,367028,366697,366366,366036,365706,365376, + 365046,364717,364388,364059,363731,363403,363075,362747, + 362420,362093,361766,361440,361114,360788,360463,360137, + 359813,359488,359164,358840,358516,358193,357869,357547, + 357224,356902,356580,356258,355937,355616,355295,354974, + 354654,354334,354014,353695,353376,353057,352739,352420, + 352103,351785,351468,351150,350834,350517,350201,349885, + 349569,349254,348939,348624,348310,347995,347682,347368, + 347055,346741,346429,346116,345804,345492,345180,344869, + 344558,344247,343936,343626,343316,343006,342697,342388, + 342079,341770,341462,341154,340846,340539,340231,339924, + 339618,339311,339005,338700,338394,338089,337784,337479, + 337175,336870,336566,336263,335959,335656,335354,335051, + 334749,334447,334145,333844,333542,333242,332941,332641, + 332341,332041,331741,331442,331143,330844,330546,330247, + 329950,329652,329355,329057,328761,328464,328168,327872, + 327576,327280,326985,326690,326395,326101,325807,325513, + 325219,324926,324633,324340,324047,323755,323463,323171, + 322879,322588,322297,322006,321716,321426,321136,320846, + 320557,320267,319978,319690,319401,319113,318825,318538, + 318250,317963,317676,317390,317103,316817,316532,316246, + 315961,315676,315391,315106,314822,314538,314254,313971, + 313688,313405,313122,312839,312557,312275,311994,311712, + 311431,311150,310869,310589,310309,310029,309749,309470, + 309190,308911,308633,308354,308076,307798,307521,307243, + 306966,306689,306412,306136,305860,305584,305308,305033, + 304758,304483,304208,303934,303659,303385,303112,302838, + 302565,302292,302019,301747,301475,301203,300931,300660, + 300388,300117,299847,299576,299306,299036,298766,298497, + 298227,297958,297689,297421,297153,296884,296617,296349, + 296082,295815,295548,295281,295015,294749,294483,294217, + 293952,293686,293421,293157,292892,292628,292364,292100, + 291837,291574,291311,291048,290785,290523,290261,289999, + 289737,289476,289215,288954,288693,288433,288173,287913, + 287653,287393,287134,286875,286616,286358,286099,285841, + 285583,285326,285068,284811,284554,284298,284041,283785, + 283529,283273,283017,282762,282507,282252,281998,281743, + 281489,281235,280981,280728,280475,280222,279969,279716, + 279464,279212,278960,278708,278457,278206,277955,277704, + 277453,277203,276953,276703,276453,276204,275955,275706, + 275457,275209,274960,274712,274465,274217,273970,273722, + 273476,273229,272982,272736,272490,272244,271999,271753, + 271508,271263,271018,270774,270530,270286,270042,269798, + 269555,269312,269069,268826,268583,268341,268099,267857 +}; + + +#define LOGFAC 2*16 + +UWORD logtab[104] = +{ LOGFAC*907,LOGFAC*900,LOGFAC*894,LOGFAC*887,LOGFAC*881,LOGFAC*875,LOGFAC*868,LOGFAC*862, + LOGFAC*856,LOGFAC*850,LOGFAC*844,LOGFAC*838,LOGFAC*832,LOGFAC*826,LOGFAC*820,LOGFAC*814, + LOGFAC*808,LOGFAC*802,LOGFAC*796,LOGFAC*791,LOGFAC*785,LOGFAC*779,LOGFAC*774,LOGFAC*768, + LOGFAC*762,LOGFAC*757,LOGFAC*752,LOGFAC*746,LOGFAC*741,LOGFAC*736,LOGFAC*730,LOGFAC*725, + LOGFAC*720,LOGFAC*715,LOGFAC*709,LOGFAC*704,LOGFAC*699,LOGFAC*694,LOGFAC*689,LOGFAC*684, + LOGFAC*678,LOGFAC*675,LOGFAC*670,LOGFAC*665,LOGFAC*660,LOGFAC*655,LOGFAC*651,LOGFAC*646, + LOGFAC*640,LOGFAC*636,LOGFAC*632,LOGFAC*628,LOGFAC*623,LOGFAC*619,LOGFAC*614,LOGFAC*610, + LOGFAC*604,LOGFAC*601,LOGFAC*597,LOGFAC*592,LOGFAC*588,LOGFAC*584,LOGFAC*580,LOGFAC*575, + LOGFAC*570,LOGFAC*567,LOGFAC*563,LOGFAC*559,LOGFAC*555,LOGFAC*551,LOGFAC*547,LOGFAC*543, + LOGFAC*538,LOGFAC*535,LOGFAC*532,LOGFAC*528,LOGFAC*524,LOGFAC*520,LOGFAC*516,LOGFAC*513, + LOGFAC*508,LOGFAC*505,LOGFAC*502,LOGFAC*498,LOGFAC*494,LOGFAC*491,LOGFAC*487,LOGFAC*484, + LOGFAC*480,LOGFAC*477,LOGFAC*474,LOGFAC*470,LOGFAC*467,LOGFAC*463,LOGFAC*460,LOGFAC*457, + LOGFAC*453,LOGFAC*450,LOGFAC*447,LOGFAC*443,LOGFAC*440,LOGFAC*437,LOGFAC*434,LOGFAC*431 +}; + +SBYTE PanbrelloTable[256] = +{ 0,2,3,5,6,8,9,11,12,14,16,17,19,20,22,23, + 24,26,27,29,30,32,33,34,36,37,38,39,41,42,43,44, + 45,46,47,48,49,50,51,52,53,54,55,56,56,57,58,59, + 59,60,60,61,61,62,62,62,63,63,63,64,64,64,64,64, + 64,64,64,64,64,64,63,63,63,62,62,62,61,61,60,60, + 59,59,58,57,56,56,55,54,53,52,51,50,49,48,47,46, + 45,44,43,42,41,39,38,37,36,34,33,32,30,29,27,26, + 24,23,22,20,19,17,16,14,12,11,9,8,6,5,3,2, + 0,-2,-3,-5,-6,-8,-9,-11,-12,-14,-16,-17,-19,-20,-22,-23, + -24,-26,-27,-29,-30,-32,-33,-34,-36,-37,-38,-39,-41,-42,-43,-44, + -45,-46,-47,-48,-49,-50,-51,-52,-53,-54,-55,-56,-56,-57,-58,-59, + -59,-60,-60,-61,-61,-62,-62,-62,-63,-63,-63,-64,-64,-64,-64,-64, + -64,-64,-64,-64,-64,-64,-63,-63,-63,-62,-62,-62,-61,-61,-60,-60, + -59,-59,-58,-57,-56,-56,-55,-54,-53,-52,-51,-50,-49,-48,-47,-46, + -45,-44,-43,-42,-41,-39,-38,-37,-36,-34,-33,-32,-30,-29,-27,-26, + -24,-23,-22,-20,-19,-17,-16,-14,-12,-11,-9,-8,-6,-5,-3,-2 +}; + + +/* New Note Action Scoring System: + --------------------------------- + 1) total-volume (fadevol, chanvol, volume) is the main scorer. + 2) a looping sample is a bonus x2 + 3) a forground channel is a bonus x4 + 4) an active envelope with keyoff is a handicap -x2 +*/ +static int MP_FindEmptyChannel(int curchan) /* returns mp_control index of free channel */ +{ + MP_VOICE *a; + ULONG t,k,tvol,p,pp; + + /*for(t=md_sngchn; t; t--, audpool++) + { if(audpool == md_sngchn) audpool = 0; + if(!(pf->voice[audpool].kick) && Voice_Stopped(audpool)) + { audpool++; + return audpool-1; + } + }*/ + + for(t=0; tvoice[t].kick) && Voice_Stopped(t)) + { return t; + } + } + + tvol = 0xffffffUL; t = 0; p = 0; a = pf->voice; + for(k=0; kkick) + { pp = a->totalvol << ((a->s->flags & SF_LOOP) ? 1 : 0); + if((a->master!=NULL) && (a==a->master->slave)) + pp <<= 2; + + /*if(a->volflg & EF_ON) + { if(a->volflg & (EF_SUSTAIN | EF_LOOP)) + { if(a->keyoff & KEY_OFF) + { pp >>= 1; + if(a->venv.env[a->venv.end].val < 32) pp>>=1; + } else + pp <<= 1; + } else pp <<= 1; + }*/ + + if(pp < tvol) + { tvol = pp; + t = k; + } + } + } + + if(tvol>8000*7) return -1; /*mp_channel; */ + + return t; +} + + +static SWORD Interpolate(SWORD p, SWORD p1, SWORD p2, SWORD v1, SWORD v2) +{ + SWORD dp,dv,di; + + if(p1==p2) return v1; + + dv = v2-v1; + dp = p2-p1; + di = p-p1; + + return v1 + ((SLONG)(di*dv) / dp); +} + + +UWORD getlinearperiod(UBYTE note, ULONG fine) +{ + return((10L*12*16*4)-((ULONG)note*16*4)-(fine/2)+64); +} + + +static UWORD getlogperiod(UBYTE note,ULONG fine) +{ + UBYTE n,o; + UWORD p1,p2; + ULONG i; + + n = note%12; + o = note/12; + i = (n<<3) + (fine>>4); /* n*8 + fine/16 */ + + p1 = logtab[i]; + p2 = logtab[i+1]; + + return(Interpolate(fine/16,0,15,p1,p2)>>o); +} + + +static UWORD getoldperiod(UBYTE note, ULONG speed) +{ + UBYTE n, o; + ULONG period; + + if(!speed) return 4242; /* <- prevent divide overflow.. (42 eheh) */ + + n = note % 12; + o = note / 12; + period = ((8363l*(ULONG)mytab[n]) >> o ) / speed; + return period; +} + + +static UWORD GetPeriod(UBYTE note, ULONG speed) +{ + if(pf->flags & UF_XMPERIODS) + return (pf->flags & UF_LINEAR) ? getlinearperiod(note,speed) : getlogperiod(note,speed); + + return getoldperiod(note,speed); +} + + +static SWORD InterpolateEnv(SWORD p, ENVPT *a, ENVPT *b) +{ + return(Interpolate(p,a->pos,b->pos,a->val,b->val)); +} + + +static SWORD DoPan(SWORD envpan, SWORD pan) +{ + return(pan + (((envpan-128)*(128-abs(pan-128)))/128)); +} + + +static void StartEnvelope(ENVPR *t, UBYTE flg, UBYTE pts, UBYTE susbeg, UBYTE susend, UBYTE beg, UBYTE end, ENVPT *p, UBYTE keyoff) +{ + t->flg = flg; + t->pts = pts; + t->susbeg = susbeg; + t->susend = susend; + t->beg = beg; + t->end = end; + t->env = p; + t->p = 0; + t->a = 0; + t->b = ((t->flg & EF_SUSTAIN) && !(keyoff & KEY_OFF)) ? 0 : 1; +} + + +static SWORD ProcessEnvelope(ENVPR *t, SWORD v, UBYTE keyoff) + +/* This procedure processes all envelope types, include volume, pitch, and */ +/* panning. Envelopes are defined by a set of points, each with a magnitude */ +/* [relating either to volume, panniong position, or pitch modifier] and a */ +/* tick position. */ +/* */ +/* Envelopes work in the following manner: */ +/* */ +/* (a) Each tick the envelope is moved a point further in its progression. */ +/* 1. For an accurate progression, magnitudes between two envelope points */ +/* are interpolated. */ +/* */ +/* (b) When progression reaches a defined point on the envelope, values */ +/* are shifted to interpolate between this point and the next, */ +/* and checks for loops or envelope end are done. */ +/* */ +/* Misc: */ +/* Sustain loops are loops that are only active as long as the keyoff */ +/* flag is clear. When a volume envelope terminates, so does the current */ +/* fadeout. */ + +{ + if(t->flg & EF_ON) + { UBYTE a, b; /* actual points in the envelope */ + UWORD p; /* the 'tick counter' - real point being played */ + + a = t->a; + b = t->b; + p = t->p; + + /* compute the current envelope value between points a and b */ + + if(a == b) + v = t->env[a].val; + else + v = InterpolateEnv(p, &t->env[a], &t->env[b]); + + p++; + + /* pointer reached point b? */ + + if(p >= t->env[b].pos) + { a = b++; /* shift points a and b */ + + /* Check for loops, sustain loops, or end of envelope. */ + + if((t->flg & EF_SUSTAIN) && !(keyoff & KEY_OFF) && (b > t->susend)) + { a = t->susbeg; + if(t->susbeg == t->susend) b = a; else b = a + 1; + p = t->env[a].pos; + } else if((t->flg & EF_LOOP) && (b > t->end)) + { a = t->beg; + if(t->beg == t->end) b = a; else b = a + 1; + p = t->env[a].pos; + } else + { if(b >= t->pts) + { if((t->flg & EF_VOLENV) && (mp_channel != -1)) + { pf->voice[mp_channel].keyoff |= KEY_FADE; + if(v==0) + pf->voice[mp_channel].fadevol = 0; + } + b--; p--; + } + } + } + t->a = a; + t->b = b; + t->p = p; + } + return v; +} + + +ULONG getfrequency(UBYTE flags, ULONG period) + +/* XM linear period to frequency conversion */ + +{ + ULONG result; + + if(flags & UF_LINEAR) + result = lintab[period % 768] >> (period / 768); + else + result = (8363L*1712L) / period; + + return result; +} + + +static void DoEEffects(UBYTE dat) +{ + UBYTE nib; + + nib = dat & 0xf; + + switch(dat>>4) + { case 0x0: /* filter toggle, not supported */ + break; + + case 0x1: /* fineslide up */ + if(!pf->vbtick) a->tmpperiod-=(nib<<2); + break; + + case 0x2: /* fineslide dn */ + if(!pf->vbtick) a->tmpperiod+=(nib<<2); + break; + + case 0x3: /* glissando ctrl */ + a->glissando = nib; + break; + + case 0x4: /* set vibrato waveform */ + a->wavecontrol &= 0xf0; + a->wavecontrol |= nib; + break; + + case 0x5: /* set finetune */ +/* a->speed=finetune[nib]; */ +/* a->tmpperiod=GetPeriod(a->note,pf->samples[a->sample].transpose,a->speed); */ + break; + + case 0x6: /* set patternloop */ + if(pf->vbtick) break; + /* hmm.. this one is a real kludge. But now it */ + /* works */ + if(nib) /* set reppos or repcnt ? */ + { /* set repcnt, so check if repcnt already is set, */ + /* which means we are already looping */ + + if(pf->pat_repcnt > 0) + pf->pat_repcnt--; /* already looping, decrease counter */ + else + pf->pat_repcnt = nib; /* not yet looping, so set repcnt */ + + if(pf->pat_repcnt) /* jump to reppos if repcnt>0 */ + pf->patpos = pf->pat_reppos; + } else + { pf->pat_reppos = pf->patpos-1; /* set reppos */ + } + break; + + + case 0x7: /* set tremolo waveform */ + a->wavecontrol &= 0x0f; + a->wavecontrol |= nib << 4; + break; + + case 0x8: /* set panning */ + if(pf->panflag) + { if(nib<=8) nib*=16; else nib*=17; + a->panning = nib; + pf->panning[mp_channel] = nib; + } + break; + + case 0x9: /* retrig note */ + /* only retrigger if */ + /* data nibble > 0 */ + + if(nib > 0) + { if(a->retrig==0) + { /* when retrig counter reaches 0, */ + /* reset counter and restart the sample */ + a->kick = 1; + a->retrig = nib; + } + a->retrig--; /* countdown */ + } + break; + + case 0xa: /* fine volume slide up */ + if(pf->vbtick) break; + + a->tmpvolume += nib; + if(a->tmpvolume > 64) a->tmpvolume = 64; + break; + + case 0xb: /* fine volume slide dn */ + if(pf->vbtick) break; + + a->tmpvolume -= nib; + if(a->tmpvolume < 0) a->tmpvolume = 0; + break; + + case 0xc: /* cut note */ + /* When pf->vbtick reaches the cut-note value, */ + /* turn the volume to zero ( Just like */ + /* on the amiga) */ + if(pf->vbtick>=nib) + a->tmpvolume = 0; /* just turn the volume down */ + break; + + case 0xd: /* note delay */ + /* delay the start of the */ + /* sample until pf->vbtick==nib */ + if(pf->vbtick==nib) + { /*a->kick = 1; */ + a->notedelay = 0; + } else if(pf->vbtick==0) + { /*a->kick = 0; */ + a->notedelay = 1; + } + break; + + case 0xe: /* pattern delay */ + if(pf->vbtick) break; + if(!pf->patdly2) pf->patdly = nib+1; /* only once (when pf->vbtick=0) */ + break; + + case 0xf: /* invert loop, not supported */ + break; + } +} + + +static void DoVibrato(void) +{ + UBYTE q; + UWORD temp; + + q = (a->vibpos>>2)&0x1f; + + switch(a->wavecontrol&3) + { case 0: /* sine */ + temp = VibratoTable[q]; + break; + + case 1: /* ramp down */ + q<<=3; + if(a->vibpos<0) q = 255-q; + temp = q; + break; + + case 2: /* square wave */ + temp = 255; + break; + + case 3: /* Evil random wave */ + temp = rand() & 255; + break; + } + + temp*=a->vibdepth; + temp>>=7; + temp<<=2; + + if(a->vibpos>=0) + a->period = a->tmpperiod+temp; + else + a->period = a->tmpperiod-temp; + + if(pf->vbtick) a->vibpos+=a->vibspd; /* do not update when pf->vbtick==0 */ +} + + +static void DoTremolo(void) +{ + UBYTE q; + UWORD temp; + + q = (a->trmpos>>2) & 0x1f; + + switch((a->wavecontrol>>4) & 3) + { case 0: /* sine */ + temp = VibratoTable[q]; + break; + + case 1: /* ramp down */ + q<<=3; + if(a->trmpos<0) q = 255-q; + temp = q; + break; + + case 2: /* square wave */ + temp = 255; + break; + + case 3: /* Evil random wave */ + temp = rand() & 255; + break; + } + + temp *= a->trmdepth; + temp >>= 6; + + if(a->trmpos >= 0) + { a->volume = a->tmpvolume + temp; + if(a->volume > 64) a->volume = 64; + } else + { a->volume = a->tmpvolume - temp; + if(a->volume < 0) a->volume = 0; + } + + if(pf->vbtick) a->trmpos+=a->trmspd; /* do not update when pf->vbtick==0 */ +} + + +static void DoVolSlide(UBYTE dat) +{ + if(!pf->vbtick) return; /* do not update when pf->vbtick==0 */ + + a->tmpvolume += dat >> 4; /* volume slide */ + a->tmpvolume -= dat & 0xf; + if(a->tmpvolume < 0) a->tmpvolume = 0; + if(a->tmpvolume > 64) a->tmpvolume = 64; +} + + +static void DoToneSlide(void) +{ + int dist; + + if(a->period==0) return; + + if(!pf->vbtick) + { a->tmpperiod = a->period; + return; + } + + /* We have to slide a->period towards a->wantedperiod, so */ + /* compute the difference between those two values */ + + dist = a->period-a->wantedperiod; + + if( dist==0 || a->portspeed>abs(dist) ) /* if they are equal or if portamentospeed is too big */ + a->period = a->wantedperiod; /* make tmpperiod equal tperiod */ + else if(dist>0) /* dist>0 ? */ + a->period-=a->portspeed; /* then slide up */ + else + a->period+=a->portspeed; /* dist<0 -> slide down */ + + a->tmpperiod = a->period; +} + + +static void DoPTEffect0(UBYTE dat) +{ + UBYTE note; + + note = a->note; + + if(dat!=0) + { switch(pf->vbtick%3) + { case 1: + note+=(dat>>4); break; + case 2: + note+=(dat&0xf); break; + } + a->period = GetPeriod(note,a->speed); + a->ownper = 1; + } +} + + +/* ----------------------------------------- */ +/* --> ScreamTreacker 3 Specific Effects <-- */ +/* ----------------------------------------- */ + +static void DoS3MVolSlide(UBYTE inf) +{ + UBYTE lo, hi; + + if(inf) a->s3mvolslide = inf; + + inf = a->s3mvolslide; + lo = inf & 0xf; + hi = inf >> 4; + + if(hi==0) a->tmpvolume -= lo; + else if(lo==0) a->tmpvolume += hi; + else if(hi==0xf) + { if(!pf->vbtick) a->tmpvolume -= lo; + } else if(lo==0xf) + { if(!pf->vbtick) a->tmpvolume += hi; + } + if(a->tmpvolume < 0) a->tmpvolume = 0; + if(a->tmpvolume > 64) a->tmpvolume = 64; +} + + +static void DoS3MSlideDn(UBYTE inf) +{ + UBYTE hi,lo; + + if(inf!=0) a->slidespeed = inf; + else inf = a->slidespeed; + + hi = inf>>4; + lo = inf&0xf; + + if(hi==0xf) + { if(!pf->vbtick) a->tmpperiod+=(UWORD)lo<<2; + } else if(hi==0xe) + { if(!pf->vbtick) a->tmpperiod+=lo; + } else + { if(pf->vbtick) a->tmpperiod+=(UWORD)inf<<2; + } +} + + +static void DoS3MSlideUp(UBYTE inf) +{ + UBYTE hi,lo; + + if(inf!=0) a->slidespeed = inf; + else inf = a->slidespeed; + + hi = inf>>4; + lo = inf&0xf; + + if(hi==0xf) + { if(!pf->vbtick) a->tmpperiod-=(UWORD)lo<<2; + } else if(hi==0xe) + { if(!pf->vbtick) a->tmpperiod-=lo; + } else + { if(pf->vbtick) a->tmpperiod-=(UWORD)inf<<2; + } +} + + +static void DoS3MTremor(UBYTE inf) +{ + UBYTE on,off; + + if(inf!=0) a->s3mtronof = inf; + else inf = a->s3mtronof; + + if(!pf->vbtick) return; + + on = (inf>>4)+1; + off = (inf&0xf)+1; + + a->s3mtremor %= (on+off); + a->volume = (a->s3mtremor < on ) ? a->tmpvolume : 0; + a->s3mtremor++; +} + + +static void DoS3MRetrig(UBYTE inf) +{ + UBYTE hi,lo; + + hi = inf >> 4; + lo = inf & 0xf; + + if(inf) + { a->s3mrtgslide = hi; + a->s3mrtgspeed = lo; + } + + /* only retrigger if */ + /* lo nibble > 0 */ + + if(a->s3mrtgspeed > 0) + { if(a->retrig == 0) + { /* when retrig counter reaches 0, */ + /* reset counter and restart the sample */ + + if(!a->kick) a->kick = 2; + a->retrig = a->s3mrtgspeed; + + if(pf->vbtick) /* don't slide on first retrig */ + { switch(a->s3mrtgslide) + { case 1: + case 2: + case 3: + case 4: + case 5: + a->tmpvolume-=(1<<(a->s3mrtgslide-1)); + break; + + case 6: + a->tmpvolume = (2*a->tmpvolume)/3; + break; + + case 7: + a->tmpvolume = a->tmpvolume>>1; + break; + + case 9: + case 0xa: + case 0xb: + case 0xc: + case 0xd: + a->tmpvolume+=(1<<(a->s3mrtgslide-9)); + break; + + case 0xe: + a->tmpvolume=(3*a->tmpvolume)/2; + break; + + case 0xf: + a->tmpvolume=a->tmpvolume<<1; + break; + } + if(a->tmpvolume<0) a->tmpvolume = 0; + if(a->tmpvolume>64) a->tmpvolume = 64; + } + } + a->retrig--; /* countdown */ + } +} + + +static void DoS3MSpeed(UBYTE speed) +{ + if(pf->vbtick || pf->patdly2) return; + + if(speed) + { pf->sngspd = speed; + pf->vbtick = 0; + } +} + + +static void DoS3MTempo(UBYTE tempo) +{ + if(pf->vbtick || pf->patdly2) return; + pf->bpm = tempo; +} + + +static void DoS3MFineVibrato(void) +{ + UBYTE q; + UWORD temp; + + q = (a->vibpos>>2)&0x1f; + + switch(a->wavecontrol&3) + { case 0: /* sine */ + temp=VibratoTable[q]; + break; + + case 1: /* ramp down */ + q<<=3; + if(a->vibpos<0) q=255-q; + temp=q; + break; + + case 2: /* square wave */ + temp=255; + break; + + case 3: /* evil random */ + temp = rand() & 255; /* (range 0 to 255) */ + } + + temp*=a->vibdepth; + temp>>=8; + + if(a->vibpos>=0) + a->period = a->tmpperiod+temp; + else + a->period = a->tmpperiod-temp; + + a->vibpos += a->vibspd; +} + + +static void DoS3MTremolo(void) +{ + UBYTE q; + UWORD temp; + + q = (a->trmpos>>2)&0x1f; + + switch((a->wavecontrol>>4)&3) + { case 0: /* sine */ + temp = VibratoTable[q]; + break; + + case 1: /* ramp down */ + q<<=3; + if(a->trmpos<0) q = 255-q; + temp = q; + break; + + case 2: /* square wave */ + temp=255; + break; + + case 3: /* evil random */ + temp = rand() & 255; /* (range 0 to 255) */ + } + + temp*=a->trmdepth; + temp>>=7; + + if(a->trmpos>=0) + { a->volume = a->tmpvolume + temp; + if(a->volume>64) a->volume = 64; + } else + { a->volume = a->tmpvolume - temp; + if(a->volume<0) a->volume = 0; + } + + if(pf->vbtick) a->trmpos += a->trmspd; /* do not update when pf->vbtick==0 */ +} + + +/* -------------------------------------- */ +/* --> FastTracker 2 Specific Effects <-- */ +/* -------------------------------------- */ + +static void DoXMVolSlide(UBYTE inf) +{ + UBYTE lo,hi; + + if(inf) + a->s3mvolslide = inf; + + inf = a->s3mvolslide; + if(!pf->vbtick) return; + + lo = inf&0xf; + hi = inf>>4; + + if(hi==0) + a->tmpvolume-=lo; + else + a->tmpvolume+=hi; + + if(a->tmpvolume<0) a->tmpvolume=0; + else if(a->tmpvolume>64) a->tmpvolume=64; +} + + +static void DoXMGlobalSlide(UBYTE inf) +{ + if(pf->vbtick) + { if(inf) pf->globalslide=inf; else inf=pf->globalslide; + if(inf & 0xf0) inf &= 0xf0; + pf->volume = pf->volume + ((inf >> 4) - (inf & 0xf))*2; + + if(pf->volume<0) pf->volume = 0; + else if(pf->volume>128) pf->volume = 128; + } +} + + +static void DoXMPanSlide(UBYTE inf) +{ + UBYTE lo,hi; + SWORD pan; + + + if(inf!=0) a->pansspd = inf; + else inf = a->pansspd; + + if(!pf->vbtick) return; + + lo = inf & 0xf; + hi = inf >> 4; + + /* slide right has absolute priority: */ + + if(hi) lo = 0; + + pan = (a->panning == PAN_SURROUND) ? 128 : a->panning; + + pan -= lo; + pan += hi; + + if(pan < 0) pan = 0; + if(pan > 255) pan = 255; + + a->panning = pan; +} + + +static void DoXMExtraFineSlideUp(UBYTE inf) +{ + if(!pf->vbtick) + { if(inf) a->ffportupspd = inf; else inf = a->ffportupspd; + a->period -= inf; + } + a->tmpperiod = a->period; +} + + +static void DoXMExtraFineSlideDown(UBYTE inf) +{ + if(!pf->vbtick) + { if(inf) a->ffportdnspd = inf; else inf = a->ffportdnspd; + a->period += inf; + } + a->tmpperiod = a->period; +} + + +/* --------------------------------------- */ +/* --> ImpulseTracker Player Functions <-- */ +/* --------------------------------------- */ + +static void DoITChanVolSlide(UBYTE inf) +{ + UBYTE lo, hi; + + if(inf) a->chanvolslide = inf; + inf = a->chanvolslide; + + lo = inf&0xf; + hi = inf>>4; + + if(hi==0) + { a->chanvol-=lo; + } else if(lo==0) + { a->chanvol+=hi; + } else if(hi==0xf) + { if(!pf->vbtick) a->chanvol-=lo; + } else if(lo==0xf) + { if(!pf->vbtick) a->chanvol+=hi; + } + + if(a->chanvol<0) a->chanvol = 0; + if(a->chanvol>64) a->chanvol = 64; +} + + +static void DoITGlobalSlide(UBYTE inf) +{ + UBYTE lo,hi; + + if(inf) pf->globalslide = inf; + inf = pf->globalslide; + + lo = inf&0xf; + hi = inf>>4; + + if(lo==0) + { pf->volume += hi; + } else if(hi==0) + { pf->volume -= lo; + } else if(lo==0xf) + { if(!pf->vbtick) pf->volume += hi; + } else if(hi==0xf) + { if(!pf->vbtick) pf->volume -= lo; + } + + if(pf->volume < 0) pf->volume = 0; + if(pf->volume > 128) pf->volume = 128; +} + + +static void DoITPanSlide(UBYTE inf) +{ + UBYTE lo,hi; + SWORD pan; + + if(inf) a->pansspd = inf; + inf = a->pansspd; + + lo = inf & 0xf; + hi = inf >> 4; + + pan = (a->panning == PAN_SURROUND) ? 128 : a->panning; + + if(hi==0) + { pan += lo << 2; + } else if(lo==0) + { pan -= hi << 2; + } else if(hi==0xf) + { if(!pf->vbtick) pan += lo << 2; + } else if(lo==0xf) + { if(!pf->vbtick) pan -= hi << 2; + } + if(pan > 255) pan = 255; + if(pan < 0) pan = 0; + a->panning = /*pf->panning[mp_channel] =*/ pan; +} + + +static void DoITVibrato(void) +{ + UBYTE q; + UWORD temp; + + q = (a->vibpos>>2)&0x1f; + + switch(a->wavecontrol&3) + { case 0: /* sine */ + temp=VibratoTable[q]; + break; + + case 1: /* ramp down */ + q<<=3; + if(a->vibpos<0) q=255-q; + temp=q; + break; + + case 2: /* square wave */ + temp=255; + break; + + case 3: /* evil random */ + temp = rand() & 255; /* (range 0 to 255) */ + break; + } + + temp*=a->vibdepth; + temp>>=8; + temp<<=2; + + if(a->vibpos>=0) + a->period = a->tmpperiod+temp; + else + a->period = a->tmpperiod-temp; + + a->vibpos+=a->vibspd; +} + + +static void DoITFineVibrato(void) +{ + UBYTE q; + UWORD temp; + + q = (a->vibpos>>2)&0x1f; + + switch(a->wavecontrol&3) + { case 0: /* sine */ + temp=VibratoTable[q]; + break; + + case 1: /* ramp down */ + q<<=3; + if(a->vibpos<0) q = 255-q; + temp = q; + break; + + case 2: /* square wave */ + temp = 255; + break; + + case 3: /* evil random */ + temp = rand() & 255; /* (range 0 to 255) */ + break; + } + + temp*=a->vibdepth; + temp>>=8; + + if(a->vibpos>=0) + a->period = a->tmpperiod+temp; + else + a->period = a->tmpperiod-temp; + + a->vibpos+=a->vibspd; +} + + +static void DoITTremor(UBYTE inf) +{ + UBYTE on,off; + + if(inf!=0) a->s3mtronof = inf; + else inf = a->s3mtronof; + + if(!pf->vbtick) return; + + on=(inf>>4); + off=(inf&0xf); + + a->s3mtremor%=(on+off); + a->volume = (a->s3mtremor < on ) ? a->tmpvolume : 0; + a->s3mtremor++; +} + + +static void DoITPanbrello(void) +{ + UBYTE q; + static SLONG temp; + + q = a->panbpos; + + switch(a->panbwave) + { case 0: /* sine */ + temp = PanbrelloTable[q]; + break; + + /* only sinewave is correctly supported right now */ + + case 1: /* ramp down */ + q<<=3; + temp = q; + break; + + case 2: /* square wave */ + temp = 64; + break; + + case 3: /* evil random */ + if(a->panbpos >= a->panbspd) + { a->panbpos = 0; + temp = rand() & 255; + } + } + + temp*=a->panbdepth; + temp/=8; + + a->panning = pf->panning[mp_channel] + temp; + a->panbpos += a->panbspd; +} + + +static void DoITToneSlide(void) +{ + int dist; + + if(a->period == 0) return; + + if(!pf->vbtick) + { a->tmpperiod = a->period; + return; + } + + /* We have to slide a->period towards a->wantedperiod, */ + /* compute the difference between those two values */ + + dist = a->period - a->wantedperiod; + + if( (dist == 0) || /* if they are equal */ + ((a->slidespeed<<2) > abs(dist)) ) /* or if portamentospeed is too big */ + { a->period = a->wantedperiod; /* make tmpperiod equal tperiod */ + } else if(dist > 0) /* dist>0 ? */ + { a->period -= a->slidespeed << 2; /* then slide up */ + } else + { a->period += a->slidespeed << 2; /* dist<0 -> slide down */ + } + a->tmpperiod = a->period; +} + + +static void DoSSEffects(UBYTE dat) + +/* Impulse/Scream Tracker Sxx effects. */ +/* All Sxx effects share the same memory space. */ + +{ + UBYTE inf,c; + + inf = dat&0xf; + c = dat>>4; + + if(dat==0) + { c = a->sseffect; + inf = a->ssdata; + } else + { a->sseffect = c; + a->ssdata = inf; + } + + switch(c) + { case SS_GLISSANDO: /* S1x set glissando voice */ + DoEEffects(0x30|inf); + break; + + case SS_FINETUNE: /* S2x set finetune */ + DoEEffects(0x50|inf); + break; + + case SS_VIBWAVE: /* S3x set vibrato waveform */ + DoEEffects(0x40|inf); + break; + + case SS_TREMWAVE: /* S4x set tremolo waveform */ + DoEEffects(0x70|inf); + break; + + case SS_PANWAVE: /* The Satanic Panbrello waveform */ + a->panbwave = (UniGetByte()); + break; + + case SS_FRAMEDELAY: /* S6x Delay x number of frames (patdly) */ + DoEEffects(0xe0|inf); + break; + + case SS_S7EFFECTS: /* S7x Instrument / NNA commands */ + DoNNAEffects(UniGetByte()); + break; + + case SS_PANNING: /* S8x set panning position */ + DoEEffects(0x80 | inf); + break; + + case SS_SURROUND: /* S9x Set Surround Sound */ + a->panning = pf->panning[mp_channel] = PAN_SURROUND; + break; + + case SS_HIOFFSET: /* SAy Set high order sample offset yxx00h */ + a->hioffset |= UniGetByte() << 16; + break; + + case SS_PATLOOP: /* SBx pattern loop */ + DoEEffects(0x60|inf); + break; + + case SS_NOTECUT: /* SCx notecut */ + DoEEffects(0xC0|inf); + break; + + case SS_NOTEDELAY: /* SDx notedelay */ + DoEEffects(0xD0|inf); + break; + + case SS_PATDELAY: /* SEx patterndelay */ + DoEEffects(0xE0|inf); + break; + } +} + + +static void DoVolEffects(UBYTE c) + +/* Impulse Tracker Volume/Pan Column effects. */ +/* All volume/pan column effects share the same memory space. */ + +{ + UBYTE inf; + + inf = UniGetByte(); + + if(c==0 && inf==0) + { c = a->voleffect; + inf = a->voldata; + } else + { a->voleffect = c; + a->voldata = inf; + } + + switch(c) + { case 0: break; /* do nothing */ + case VOL_VOLUME: + if(pf->vbtick) break; + if(inf>64) inf = 64; + a->tmpvolume = inf; + break; + + case VOL_PANNING: + if(pf->panflag) + { a->panning = inf; + pf->panning[mp_channel] = inf; + } + break; + + case VOL_VOLSLIDE: + DoS3MVolSlide(inf); + break; + + case VOL_PITCHSLIDEDN: + DoS3MSlideDn(UniGetByte()); + break; + + case VOL_PITCHSLIDEUP: + DoS3MSlideUp(UniGetByte()); + break; + + case VOL_PORTAMENTO: + if(inf != 0) a->slidespeed = inf; + + if(a->period != 0) + { if(!(pf->vbtick==pf->sngspd-1) && (a->newsamp)) + { a->kick = 1; + a->start = -1; + /*a->period *= a->speed * a->newsamp; */ + } else + a->kick = 0; + + DoITToneSlide(); + a->ownper = 1; + } + break; + + case VOL_VIBRATO: + if(inf & 0x0f) a->vibdepth = inf & 0xf; + if(inf & 0xf0) a->vibspd = (inf & 0xf0) >> 2; + DoITVibrato(); + a->ownper = 1; + break; + } +} + + + +/* -------------------------------- */ +/* --> General Player Functions <-- */ +/* -------------------------------- */ + +static void pt_playeffects(void) +{ + UBYTE dat,c; + + while(c = UniGetByte()) + switch(c) + { case UNI_NOTE: + case UNI_INSTRUMENT: + UniSkipOpcode(c); + break; + + case UNI_PTEFFECT0: + DoPTEffect0(UniGetByte()); + break; + + case UNI_PTEFFECT1: + dat = UniGetByte(); + if(dat != 0) a->slidespeed = (UWORD)dat << 2; + if(pf->vbtick) a->tmpperiod -= a->slidespeed; + break; + + case UNI_PTEFFECT2: + dat = UniGetByte(); + if(dat != 0) a->slidespeed = (UWORD)dat << 2; + if(pf->vbtick) a->tmpperiod += a->slidespeed; + break; + + case UNI_PTEFFECT3: + dat = UniGetByte(); + + if(dat!=0) + { a->portspeed = dat; + a->portspeed <<= 2; + } + + if(a->period != 0) + { a->kick = 0; /* temp XM fix */ + DoToneSlide(); + a->ownper = 1; + } + break; + + case UNI_PTEFFECT4: + dat = UniGetByte(); + if(dat & 0x0f) a->vibdepth = dat & 0xf; + if(dat & 0xf0) a->vibspd = (dat & 0xf0) >> 2; + DoVibrato(); + a->ownper = 1; + break; + + case UNI_PTEFFECT5: + dat = UniGetByte(); + a->kick = 0; + DoToneSlide(); + DoVolSlide(dat); + a->ownper = 1; + break; + + case UNI_PTEFFECT6: + dat = UniGetByte(); + DoVibrato(); + DoVolSlide(dat); + a->ownper = 1; + break; + + case UNI_PTEFFECT7: + dat = UniGetByte(); + if(dat & 0x0f) a->trmdepth = dat & 0xf; + if(dat & 0xf0) a->trmspd = (dat & 0xf0) >> 2; + DoTremolo(); + a->ownvol = 1; + break; + + case UNI_PTEFFECT8: + dat = UniGetByte(); + if(pf->panflag) + { a->panning = dat; + pf->panning[mp_channel] = dat; + } + break; + + case UNI_PTEFFECT9: + dat = UniGetByte(); + if(dat) a->soffset = (UWORD)dat << 8; + a->start = a->hioffset | a->soffset; + if((a->s != NULL) && (a->start > a->s->length)) a->start = a->s->loopstart; + break; + + case UNI_PTEFFECTA: + DoVolSlide(UniGetByte()); + break; + + case UNI_PTEFFECTB: + dat = UniGetByte(); + if(pf->patdly2) break; + pf->patbrk = 0; + pf->sngpos = dat-1; + pf->posjmp = 3; + break; + + case UNI_PTEFFECTC: + dat = UniGetByte(); + if(pf->vbtick) break; + if(dat>64) dat = 64; + a->tmpvolume = dat; + break; + + case UNI_PTEFFECTD: + dat = UniGetByte(); + if(pf->patdly2) break; + pf->patbrk = dat; + if(pf->patbrk>pf->pattrows[mp_channel]) + pf->patbrk = pf->pattrows[mp_channel]; + pf->posjmp = 3; + break; + + case UNI_PTEFFECTE: + DoEEffects(UniGetByte()); + break; + + case UNI_PTEFFECTF: + dat = UniGetByte(); + + if(pf->vbtick || pf->patdly2) break; + + if(pf->extspd && (dat >= 0x20)) + pf->bpm = dat; + else + { if(dat) + { pf->sngspd = dat; + pf->vbtick = 0; + } + } + break; + + case UNI_S3MEFFECTA: + DoS3MSpeed(UniGetByte()); + break; + + case UNI_S3MEFFECTD: + DoS3MVolSlide(UniGetByte()); + break; + + case UNI_S3MEFFECTE: + DoS3MSlideDn(UniGetByte()); + break; + + case UNI_S3MEFFECTF: + DoS3MSlideUp(UniGetByte()); + break; + + case UNI_S3MEFFECTI: + DoS3MTremor(UniGetByte()); + a->ownvol = 1; + break; + + case UNI_S3MEFFECTQ: + DoS3MRetrig(UniGetByte()); + break; + + case UNI_S3MEFFECTR: + dat = UniGetByte(); + if(dat & 0x0f) a->trmdepth = dat & 0xf; + if(dat & 0xf0) a->trmspd = (dat & 0xf0) >> 2; + DoS3MTremolo(); + a->ownvol = 1; + break; + + case UNI_S3MEFFECTT: + DoS3MTempo(UniGetByte()); + break; + + case UNI_S3MEFFECTU: + dat = UniGetByte(); + if(dat & 0x0f) a->vibdepth = dat & 0xf; + if(dat & 0xf0) a->vibspd = (dat & 0xf0) >> 2; + DoS3MFineVibrato(); + a->ownper = 1; + break; + + case UNI_KEYOFF: + a->keyoff |= KEY_OFF; + if(a->i != NULL) + { if(!(a->i->volflg & EF_ON) || (a->i->volflg & EF_LOOP)) + a->keyoff = KEY_KILL; + } + break; + + case UNI_KEYFADE: + if(pf->vbtick >= UniGetByte()) + { a->keyoff = KEY_KILL; + if((a->i != NULL) && !(a->i->volflg & EF_ON)) + a->fadevol = 0; + } + break; + + case UNI_VOLEFFECTS: + DoVolEffects(UniGetByte()); + break; + + case UNI_XMEFFECT4: + dat = UniGetByte(); + if(pf->vbtick) + { if(dat & 0x0f) a->vibdepth = dat & 0xf; + if(dat & 0xf0) a->vibspd = (dat & 0xf0) >> 2; + } + DoVibrato(); + a->ownper = 1; + break; + + case UNI_XMEFFECTA: + DoXMVolSlide(UniGetByte()); + break; + + case UNI_XMEFFECTE1: /* xm fineslide up */ + dat = UniGetByte(); + if(!pf->vbtick) + { if(dat) a->fportupspd = dat; else dat = a->fportupspd; + a->tmpperiod -= (dat << 2); + } + break; + + case UNI_XMEFFECTE2: /* xm fineslide dn */ + dat = UniGetByte(); + if(!pf->vbtick) + { if(dat) a->fportdnspd = dat; else dat = a->fportdnspd; + a->tmpperiod += (dat<<2); + } + break; + + case UNI_XMEFFECTEA: /* fine volume slide up */ + dat = UniGetByte(); + if(pf->vbtick) break; + if(dat) a->fslideupspd = dat; else dat = a->fslideupspd; + a->tmpvolume+=dat; + if(a->tmpvolume>64) a->tmpvolume = 64; + break; + + case UNI_XMEFFECTEB: /* fine volume slide dn */ + dat = UniGetByte(); + if(pf->vbtick) break; + if(dat) a->fslidednspd = dat; else dat = a->fslidednspd; + a->tmpvolume-=dat; + if(a->tmpvolume<0) a->tmpvolume = 0; + break; + + case UNI_XMEFFECTG: + pf->volume = UniGetByte(); + break; + + case UNI_XMEFFECTH: + DoXMGlobalSlide(UniGetByte()); + break; + + case UNI_XMEFFECTL: + dat = UniGetByte(); + if(!pf->vbtick && a->i!=NULL) + { UWORD points; + INSTRUMENT *i = a->i; + MP_VOICE *aout; + + if((aout = a->slave) != NULL) + { points = i->volenv[i->volpts-1].pos; + aout->venv.p = aout->venv.env[(dat>points) ? points : dat].pos; + + points = i->panenv[i->panpts-1].pos; + aout->penv.p = aout->penv.env[(dat>points) ? points : dat].pos; + } + } + break; + + case UNI_XMEFFECTP: + DoXMPanSlide(UniGetByte()); + break; + + case UNI_XMEFFECTX1: + DoXMExtraFineSlideUp(UniGetByte()); + a->ownper = 1; + break; + + case UNI_XMEFFECTX2: + DoXMExtraFineSlideDown(UniGetByte()); + a->ownper = 1; + break; + + case UNI_ITEFFECTG: + dat = UniGetByte(); + if(dat != 0) a->slidespeed = dat; + + if(a->period != 0) + { if((pf->vbtick < 1) && (a->newsamp)) + { a->kick = 1; + a->start = -1; + /*a->period *= a->speed * a->newsamp; */ + } else + a->kick = 0; + + DoITToneSlide(); + a->ownper = 1; + } + break; + + case UNI_ITEFFECTH: /* it vibrato */ + dat = UniGetByte(); + if(dat & 0x0f) a->vibdepth = dat & 0xf; + if(dat & 0xf0) a->vibspd = (dat & 0xf0) >> 2; + DoITVibrato(); + a->ownper = 1; + break; + + case UNI_ITEFFECTI: /* it tremor */ + DoITTremor(UniGetByte()); + a->ownvol = 1; + break; + + case UNI_ITEFFECTM: + a->chanvol = UniGetByte(); + if(a->chanvol > 64) a->chanvol = 64; + else if(a->chanvol < 0) a->chanvol = 0; + break; + + case UNI_ITEFFECTN: /* Slide / Fineslide Channel Volume */ + DoITChanVolSlide(UniGetByte()); + break; + + case UNI_ITEFFECTP: /* slide / fineslide channel panning */ + DoITPanSlide(UniGetByte()); + break; + + case UNI_ITEFFECTU: /* fine vibrato */ + dat = UniGetByte(); + if(dat & 0x0f) a->vibdepth = dat & 0xf; + if(dat & 0xf0) a->vibspd = (dat & 0xf0) >> 2; + DoITFineVibrato(); + a->ownper = 1; + break; + + case UNI_ITEFFECTW: /* Slide / Fineslide Global volume */ + DoITGlobalSlide(UniGetByte()); + break; + + case UNI_ITEFFECTY: /* The Satanic Panbrello */ + dat = UniGetByte(); + if(dat & 0x0f) a->panbdepth = (dat & 0xf); + if(dat & 0xf0) a->panbspd = (dat & 0xf0) >> 4; + DoITPanbrello(); + break; + + case UNI_ITEFFECTS0: + DoSSEffects(UniGetByte()); + break; + + default: + UniSkipOpcode(c); + break; + } +} + + +static void DoNNAEffects(UBYTE dat) +{ + int t; + MP_VOICE *aout; + + dat &= 0xf; + aout = (a->slave==NULL) ? &aout_dummy : a->slave; + + switch(dat) + { case 0x0: /* Past note cut */ + for(t=0; tvoice[t].master == a) + pf->voice[t].fadevol = 0; + break; + + case 0x1: /* Past note off */ + for(t=0; tvoice[t].master == a) + { pf->voice[t].keyoff |= KEY_OFF; + if(!(pf->voice[t].venv.flg & EF_ON)) + pf->voice[t].keyoff = KEY_KILL; + } + break; + + case 0x2: /* Past note fade */ + for(t=0; tvoice[t].master == a) + pf->voice[t].keyoff |= KEY_FADE; + break; + + case 0x3: /* set NNA note cut */ + a->nna = (a->nna & ~0x3f) | NNA_CUT; + break; + + case 0x4: /* set NNA note continue */ + a->nna = (a->nna & ~0x3f) | NNA_CONTINUE; + break; + + case 0x5: /* set NNA note off */ + a->nna = (a->nna & ~0x3f) | NNA_OFF; + break; + + case 0x6: /* set NNA note fade */ + a->nna = (a->nna & ~0x3f) | NNA_FADE; + break; + + case 0x7: /* disable volume envelope */ + aout->volflg &= ~EF_ON; + break; + + case 0x8: /* enable volume envelope */ + aout->volflg |= EF_ON; + break; + + case 0x9: /* disable panning envelope */ + aout->panflg &= ~EF_ON; + break; + + case 0xa: /* enable panning envelope */ + aout->panflg |= EF_ON; + break; + + case 0xb: /* disable pitch envelope */ + aout->pitflg &= ~EF_ON; + break; + + case 0xc: /* enable pitch envelope */ + aout->pitflg |= EF_ON; + break; + } +} + + +void Player_HandleTick(void) +{ + MP_VOICE *aout; /* current audout (slave of audtmp) it's working on */ + int t, tr, t2, k; + ULONG tmpvol, period; + UBYTE c; + BOOL funky; + SAMPLE *s; + INSTRUMENT *i; + + if(isfirst) + { /* don't handle the very first ticks, this allows the */ + /* other hardware to settle down so we don't loose any */ + /* starting notes */ + isfirst--; + return; + } + + if(pf==NULL || pf->forbid) return; + + if(++pf->vbtick >= pf->sngspd) + { pf->patpos++; + pf->vbtick = 0; + + /* process pattern-delay. pf->patdly2 is the counter and pf->patdly */ + /* is the command memory. */ + + if(pf->patdly) + { pf->patdly2 = pf->patdly; + pf->patdly = 0; + } + + if(pf->patdly2) + { /* patterndelay active */ + if(--pf->patdly2) pf->patpos--; /* so turn back pf->patpos by 1 */ + } + + /* Do we have to get a new patternpointer ? */ + /* (when pf->patpos reaches 64 or when */ + /* a patternbreak is active) */ + + if(pf->patpos == pf->numrow) pf->posjmp = 3; + + if(pf->posjmp) + { pf->patpos = pf->patbrk; + pf->sngpos+=(pf->posjmp-2); + pf->patbrk = pf->posjmp = 0; + if(pf->sngpos>=pf->numpos) + { if(!pf->loop) return; + if((pf->sngpos = pf->reppos) == 0) + { pf->volume = pf->initvolume; + pf->sngspd = pf->initspeed; + pf->bpm = pf->inittempo; + } + } + if(pf->sngpos<0) pf->sngpos = pf->numpos-1; + } + + if(!pf->patdly2) + { for(t=0; tnumchn; t++) + { UBYTE inst; + + tr = pf->patterns[(pf->positions[pf->sngpos]*pf->numchn)+t]; + pf->numrow = pf->pattrows[pf->positions[pf->sngpos]]; + + mp_channel = t; + a = &pf->control[t]; + a->row = (tr < pf->numtrk) ? UniFindRow(pf->tracks[tr],pf->patpos) : NULL; + a->newsamp = 0; + + if(a->row==NULL) continue; + UniSetRow(a->row); + funky = 0; /* Funky is set to indicate note or inst change */ + + while(c = UniGetByte()) + { switch(c) + { case UNI_NOTE: + funky |= 1; + a->anote = UniGetByte(); + a->kick = 1; + a->start = -1; + + /* retrig tremolo and vibrato waves ? */ + + if(!(a->wavecontrol & 0x80)) a->trmpos = 0; + if(!(a->wavecontrol & 0x08)) a->vibpos = 0; + if(!a->panbwave) a->panbpos = 0; + break; + + case UNI_INSTRUMENT: + funky |= 2; + inst = UniGetByte(); + if(inst >= pf->numins) break; /* <- safety valve */ + + a->i = (pf->flags & UF_INST) ? &pf->instruments[inst] : NULL; + a->retrig = 0; + a->s3mtremor = 0; + a->sample = inst; + break; + + default: + UniSkipOpcode(c); + break; + } + } + + if(funky) + { i = a->i; + if(i != NULL) + { if(i->samplenumber[a->anote] >= pf->numsmp) continue; + s = &pf->samples[i->samplenumber[a->anote]]; + a->note = i->samplenote[a->anote]; + } else + { a->note = a->anote; + s = &pf->samples[a->sample]; + } + + if(a->s != s) + { a->s = s; + a->newsamp = a->period; + } + + /* channel or instrument determined panning ? */ + + a->panning = pf->panning[t]; + if(s->flags & SF_OWNPAN) + a->panning = s->panning; + else if((i != NULL) && (i->flags & IF_OWNPAN)) + a->panning = i->panning; + + a->handle = s->handle; + a->speed = s->speed; + + if(i != NULL) + { if(i->flags & IF_PITCHPAN) + a->panning += ((a->anote-i->pitpancenter) * i->pitpansep) / 8; + a->pitflg = i->pitflg; + a->volflg = i->volflg; + a->panflg = i->panflg; + a->nna = i->nnatype; + a->dca = i->dca; + a->dct = i->dct; + } else + { a->pitflg = 0; + a->volflg = 0; + a->panflg = 0; + a->nna = 0; + a->dca = 0; + a->dct = 0; + } + + if(funky & 2) + { /* IT's random volume variations: 0:8 bit fixed, and one bit for sign. */ + a->volume = s->volume; + a->tmpvolume = s->volume; + if((s != NULL) && (i != NULL)) + { a->volume = a->tmpvolume = s->volume + ((s->volume * ((SLONG)i->rvolvar * (SLONG)((rand() & 511)-255))) / 25600); + if(a->panning != PAN_SURROUND) a->panning += ((a->panning * ((SLONG)i->rpanvar * (SLONG)((rand() & 511)-255))) / 25600); + } + } + + period = GetPeriod(a->note, a->speed); + a->wantedperiod = period; + a->tmpperiod = period; + a->keyoff = KEY_KICK; + } + } + } + } + + /* Update effects */ + + for(t=0; tnumchn; t++) + { mp_channel = t; + a = &pf->control[t]; + + if((aout = a->slave) != NULL) + { a->fadevol = aout->fadevol; + a->period = aout->period; + if(a->kick != 1) a->keyoff = aout->keyoff; + } + + if(a->row == NULL) continue; + UniSetRow(a->row); + + a->ownper = a->ownvol = 0; + pt_playeffects(); + if(!a->ownper) a->period = a->tmpperiod; + if(!a->ownvol) a->volume = a->tmpvolume; + + if(a->s != NULL) + { if(a->i != NULL) + a->outvolume = (a->volume * a->s->globvol * a->i->globvol) / 1024; /* max val: 256 */ + else + a->outvolume = (a->volume * a->s->globvol) / 16; /* max val: 256 */ + if(a->outvolume > 256) a->volume = 256; + } + } + + + a = pf->control; + if(pf->flags & UF_NNA) + { for(t=0; tnumchn; t++, a++) + { if(a->kick == 1) + { if(a->slave != NULL) + { aout = a->slave; + if(aout->nna & 0x3f) + { /* oh boy, we have to do an NNA */ + /* Make sure the old MP_VOICE channel knows it has no master now! */ + + a->slave = NULL; /* assume the channel is taken by NNA */ + aout->mflag = 0; + + switch(aout->nna) + { case NNA_CONTINUE: + break; /* continue note, do nothing */ + + case NNA_OFF: /* note off */ + aout->keyoff |= KEY_OFF; + if(!(aout->volflg & EF_ON) || (aout->volflg & EF_LOOP)) + aout->keyoff = KEY_KILL; + break; + + case NNA_FADE: + aout->keyoff |= KEY_FADE; + break; + } + } + } + + k = 0; + if(a->dct != DCT_OFF) + { for(t2=0; t2voice[t2].masterchn == t) && (a->sample == pf->voice[t2].sample)) + { switch(a->dct) + { case DCT_NOTE: + if(a->note == pf->voice[t2].note) + k = 1; + break; + + case DCT_SAMPLE: + if(a->handle == pf->voice[t2].handle) + k = 1; + break; + + case DCT_INST: + k = 1; + break; + } + + if(k==1) + { k = 0; + switch(a->dca) + { case DCA_CUT : + pf->voice[t2].fadevol = 0; + a->slave = &pf->voice[a->slavechn=t2]; + break; + + case DCA_OFF : + /*a->slave = &pf->voice[newchn]; */ + pf->voice[t2].keyoff |= KEY_OFF; + if(!(pf->voice[t2].volflg & EF_ON) || (pf->voice[t2].volflg & EF_LOOP)) + pf->voice[t2].keyoff = KEY_KILL; + break; + + case DCA_FADE: + /*a->slave = &pf->voice[newchn]; */ + pf->voice[t2].keyoff |= KEY_FADE; + break; + } + } + } + } + } /* DCT checking */ + } /* if a->kick */ + } /* for loop */ + } + + a = pf->control; + for(t=0; tnumchn; t++, a++) + { int newchn; + + if(a->notedelay) continue; + + if(a->kick == 1) + { /* If no channel was cut above, find an empty or quiet channel here */ + if(pf->flags & UF_NNA) + { if(a->slave==NULL) + { if((newchn = MP_FindEmptyChannel(t)) != -1) + a->slave = &pf->voice[a->slavechn=newchn]; + } + } else + a->slave = &pf->voice[a->slavechn=t]; + + /* Assign parts of MP_VOICE only done for a KICK! */ + + if((aout = a->slave) != NULL) + { if(aout->mflag && (aout->master!=NULL)) aout->master->slave = NULL; + a->slave = aout; + aout->master = a; + aout->masterchn = t; + aout->mflag = 1; + } + } else + { aout = a->slave; + } + + if(aout != NULL) + { aout->kick = a->kick; + aout->i = a->i; + aout->s = a->s; + aout->sample = a->sample; + aout->handle = a->handle; + aout->period = a->period; + aout->panning = a->panning; + aout->chanvol = a->chanvol; + aout->fadevol = a->fadevol; + aout->start = a->start; + aout->volflg = a->volflg; + aout->panflg = a->panflg; + aout->pitflg = a->pitflg; + aout->volume = a->outvolume; + aout->keyoff = a->keyoff; + aout->note = a->note; + aout->nna = a->nna; + } + a->kick = 0; + + } + + /* Now set up the actual hardware channel playback information */ + + for(t=0; tvoice[mp_channel = t]; + i = aout->i; + s = aout->s; + + if(s==NULL) continue; + + if(aout->period < 40) aout->period = 40; + if(aout->period > 50000) aout->period = 50000; + + if(aout->kick) + { Voice_Play(t,s,(aout->start == -1) ? ((s->flags & SF_UST_LOOP) ? s->loopstart : 0) : aout->start); + /*aout->keyoff = KEY_KICK; */ + aout->fadevol = 32768; + aout->aswppos = 0; + + if((i != NULL) && (aout->kick != 2)) + { StartEnvelope(&aout->venv, aout->volflg, i->volpts, i->volsusbeg, i->volsusend, i->volbeg, i->volend, i->volenv, aout->keyoff); + StartEnvelope(&aout->penv, aout->panflg, i->panpts, i->pansusbeg, i->pansusend, i->panbeg, i->panend, i->panenv, aout->keyoff); + StartEnvelope(&aout->cenv, aout->pitflg, i->pitpts, i->pitsusbeg, i->pitsusend, i->pitbeg, i->pitend, i->pitenv, aout->keyoff); + } + aout->kick = 0; + } + + if(i != NULL) + { envvol = ProcessEnvelope(&aout->venv,256,aout->keyoff); + envpan = ProcessEnvelope(&aout->penv,128,aout->keyoff); + envpit = ProcessEnvelope(&aout->cenv,32,aout->keyoff); + } + + tmpvol = aout->fadevol; /* max 32768 */ + tmpvol *= aout->chanvol; /* * max 64 */ + tmpvol *= aout->volume; /* * max 256 */ + tmpvol /= 16384L; /* tmpvol is max 32768 */ + aout->totalvol = tmpvol>>2; /* totalvolume used to determine samplevolume */ + tmpvol *= envvol; /* * max 256 */ + tmpvol *= pf->volume; /* * max 128 */ + tmpvol /= 4194304UL; + + if((aout->masterchn != -1) && pf->control[aout->masterchn].muted) /* Channel Muting Line */ + Voice_SetVolume(t,0); + else + Voice_SetVolume(t,tmpvol); + + + if(aout->panning == PAN_SURROUND) + Voice_SetPanning(t, PAN_SURROUND); + else + { if(aout->penv.flg & EF_ON) + Voice_SetPanning(t,DoPan(envpan,aout->panning)); + else + Voice_SetPanning(t,aout->panning); + } + + if(aout->period && s->vibdepth) + { switch(s->vibtype) + { case 0: + vibval = avibtab[s->avibpos & 127]; + if(s->avibpos & 0x80) vibval=-vibval; + break; + + case 1: + vibval = 64; + if(s->avibpos & 0x80) vibval=-vibval; + break; + + case 2: + vibval = 63-(((s->avibpos + 128) & 255) >> 1); + break; + + case 3: + vibval = (((s->avibpos + 128) & 255) >> 1) - 64; + break; + } + } + + if(s->vibflags & AV_IT) + { if((aout->aswppos >> 8) < s->vibdepth) + { aout->aswppos += s->vibsweep; + vibdpt = aout->aswppos; + } else + vibdpt = s->vibdepth << 8; + vibval = (vibval*vibdpt) >> 16; + if(aout->mflag) + { if(!(pf->flags & UF_LINEAR)) vibval>>=1; + aout->period -= vibval; + } + } else /* do XM style auto-vibrato */ + { if(!(aout->keyoff & KEY_OFF)) + { if(aout->aswppos < s->vibsweep) + { vibdpt = (aout->aswppos*s->vibdepth) / s->vibsweep; + aout->aswppos++; + } else + vibdpt = s->vibdepth; + } else + { /* key-off -> depth becomes 0 if final depth wasn't reached */ + /* or stays at final level if depth WAS reached */ + if(aout->aswppos>=s->vibsweep) + vibdpt = s->vibdepth; + else + vibdpt = 0; + } + vibval = (vibval*vibdpt)>>8; + aout->period -= vibval; + } + + /* update vibrato position */ + s->avibpos = (s->avibpos+s->vibrate) & 0xff; + + if(aout->cenv.flg & EF_ON) + { envpit = envpit-32; + aout->period -= envpit; + } + + Voice_SetFrequency(t,getfrequency(pf->flags,aout->period)); + + if(aout->fadevol == 0) /* check for a dead note (fadevol = 0) */ + Voice_Stop(t); + else + { /* if keyfade, start substracting */ + /* fadeoutspeed from fadevol: */ + + if((i != NULL) && (aout->keyoff & KEY_FADE)) + { if(aout->fadevol >= i->volfade) + aout->fadevol -= i->volfade; + else + aout->fadevol = 0; + } + } + + MD_SetBPM(pf->bpm); + } +} + + +BOOL Player_Init(UNIMOD *mf) +{ + int t; + + mf->extspd = 1; + mf->panflag = 1; + mf->loop = 0; + + mf->pat_reppos = 0; + mf->pat_repcnt = 0; + mf->sngpos = 0; + mf->sngspd = mf->initspeed; + mf->volume = mf->initvolume; + + mf->vbtick = mf->sngspd; + mf->patdly = 0; + mf->patdly2 = 0; + mf->bpm = mf->inittempo; + + mf->patpos = 0; + mf->posjmp = 2; /* <- make sure the player fetches the first note */ + mf->patbrk = 0; + + /* Make sure the player doesn't start with garbage: */ + + if((mf->control=(MP_CONTROL *)_mm_calloc(mf->numchn,sizeof(MP_CONTROL)))==NULL) return 1; + if((mf->voice=(MP_VOICE *)_mm_calloc(md_sngchn,sizeof(MP_VOICE)))==NULL) return 1; + + for(t=0; tnumchn; t++) + { mf->control[t].chanvol = mf->chanvol[t]; + mf->control[t].panning = mf->panning[t]; + } + + return 0; +} + + +void Player_Exit(UNIMOD *mf) +{ + if(mf==NULL) return; + if(mf==pf) + { Player_Stop(); + pf = NULL; + } + if(mf->control!=NULL) free(mf->control); + if(mf->voice!=NULL) free(mf->voice); + mf->control = NULL; + mf->voice = NULL; + +} + + +void Player_SetVolume(int volume) +{ + if(pf==NULL) return; + + if(volume > 128) volume = 128; + if(volume < 0) volume = 0; + + pf->volume = volume; +} + + +UNIMOD *Player_GetUnimod(void) +{ + return pf; +} + + +void Player_Start(UNIMOD *mf) +{ + int t; + + if(!MikMod_Active()) + { isfirst = 2; + MikMod_EnableOutput(); + } + + if(mf==NULL) return; + + mf->forbid = 0; + if(pf != mf) + { /* new song is being started, so completely stop out the old one. */ + if(pf!=NULL) pf->forbid = 1; + for(t=0; tforbid = 1; + pf = NULL; +} + + +BOOL MP_Playing(UNIMOD *mf) +{ + if((mf==NULL) || (mf!=pf)) return 0; + return(!(mf->sngpos>=mf->numpos)); +} + + +BOOL Player_Active(void) +{ + if(pf==NULL) return 0; + return(!(pf->sngpos>=pf->numpos)); +} + + +void MP_NextPosition(UNIMOD *mf) +{ + int t; + + if(mf==NULL) return; + mf->forbid = 1; + mf->posjmp = 3; + mf->patbrk = 0; + mf->vbtick = mf->sngspd; + + for(t=0; tvoice[t].i = NULL; + mf->voice[t].s = NULL; + } + + for(t=0; tnumchn; t++) + { mf->control[t].i = NULL; + mf->control[t].s = NULL; + } + mf->forbid = 0; +} + + +void Player_NextPosition(void) +{ + MP_NextPosition(pf); +} + + +void MP_PrevPosition(UNIMOD *mf) +{ + int t; + + if(mf==NULL) return; + mf->forbid = 1; + mf->posjmp = 1; + mf->patbrk = 0; + mf->vbtick = mf->sngspd; + + for(t=0; tvoice[t].i = NULL; + mf->voice[t].s = NULL; + } + + for(t=0; tnumchn; t++) + { mf->control[t].i = NULL; + mf->control[t].s = NULL; + } + + mf->forbid = 0; +} + + +void Player_PrevPosition(void) +{ + MP_PrevPosition(pf); +} + + +void MP_SetPosition(UNIMOD *mf, UWORD pos) +{ + int t; + + if(mf==NULL) return; + mf->forbid = 1; + if(pos>=mf->numpos) pos = mf->numpos; + mf->posjmp = 2; + mf->patbrk = 0; + mf->sngpos = pos; + mf->vbtick = mf->sngspd; + + for(t=0; tvoice[t].i = NULL; + mf->voice[t].s = NULL; + } + + for(t=0; tnumchn; t++) + { mf->control[t].i = NULL; + mf->control[t].s = NULL; + } + + mf->forbid = 0; +} + + +void Player_SetPosition(UWORD pos) +{ + MP_SetPosition(pf,pos); +} + + +void MP_Unmute(UNIMOD *mf, SLONG arg1, ...) +{ + va_list ap; + SLONG t, arg2, arg3; + + va_start(ap,arg1); + + if(mf != NULL) + { switch(arg1) + { case MUTE_INCLUSIVE: + if((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn)) + { va_end(ap); + return; + } + for(;arg2numchn && arg2<=arg3;arg2++) + mf->control[arg2].muted = 0; + break; + + case MUTE_EXCLUSIVE: + if((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn)) + { va_end(ap); + return; + } + for(t=0;tnumchn;t++) + { if ((t>=arg2) && (t<=arg3)) continue; + mf->control[t].muted = 0; + } + break; + + default: + if(arg1numchn) mf->control[arg1].muted = 0; + break; + } + } + va_end(ap); + + return; +} + + +void Player_Unmute(SLONG arg1, ...) +{ + va_list argptr; + va_start(argptr,arg1); + MP_Unmute(pf,arg1, argptr); + va_end(argptr); +} + + +void MP_Mute(UNIMOD *mf, SLONG arg1, ...) +{ + va_list ap; + SLONG t, arg2, arg3; + + va_start(ap,arg1); + + if(mf != NULL) + { switch (arg1) + { case MUTE_INCLUSIVE: + if ((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn)) + { va_end(ap); + return; + } + for(;arg2numchn && arg2<=arg3;arg2++) + mf->control[arg2].muted = 1; + break; + + case MUTE_EXCLUSIVE: + if ((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn)) + { va_end(ap); + return; + } + for (t=0; tnumchn; t++) + { if ((t>=arg2) && (t<=arg3)) continue; + mf->control[t].muted = 1; + } + break; + + default: + if(arg1numchn) + mf->control[arg1].muted = 1; + break; + } + } + va_end(ap); + + return; +} + + +void Player_Mute(SLONG arg1, ...) +{ + va_list argptr; + va_start(argptr,arg1); + MP_Mute(pf,arg1, argptr); + va_end(argptr); +} + + +void MP_ToggleMute(UNIMOD *mf, SLONG arg1, ...) +{ + va_list ap; + SLONG arg2, arg3; + ULONG t; + + va_start(ap,arg1); + + if(mf != NULL) + { switch (arg1) + { case MUTE_INCLUSIVE: + if ((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn)) + { va_end(ap); + return; + } + for(; arg2numchn && arg2<=arg3; arg2++) + mf->control[arg2].muted = (mf->control[arg2].muted) ? 0 : 1; + + break; + + case MUTE_EXCLUSIVE: + if ((!(arg2=va_arg(ap,SLONG))) && (!(arg3=va_arg(ap,SLONG))) || (arg2 > arg3) || (arg3 >= mf->numchn)) + { va_end(ap); + return; + } + for (t=0;tnumchn;t++) + { if((t>=arg2) && (t<=arg3)) continue; + mf->control[t].muted = (mf->control[t].muted) ? 0 : 1; + } + break; + + default: + if(arg1numchn) + mf->control[arg1].muted = (mf->control[arg1].muted) ? 0 : 1; + break; + } + } + va_end(ap); + + return; +} + + +void Player_ToggleMute(SLONG arg1, ...) +{ + va_list argptr; + va_start(argptr,arg1); + MP_ToggleMute(pf,arg1, argptr); + va_end(argptr); +} + + +BOOL MP_Muted(UNIMOD *mf, int chan) +{ + if(mf==NULL) return 1; + return (channumchn) ? mf->control[chan].muted : 1; +} + + +BOOL Player_Muted(int chan) +{ + if(pf==NULL) return 1; + return (channumchn) ? pf->control[chan].muted : 1; +} + + +int MP_GetChannelVoice(UNIMOD *mf, int chan) +{ + if(mf==NULL) return 0; + return mf->control[chan].slavechn; +} + + +int Player_GetChannelVoice(int chan) +{ + if(pf==NULL) return 0; + return pf->control[chan].slavechn; +} + + +void Player_TogglePause(void) +{ + if(pf==NULL) return; + if(pf->forbid == 1) + pf->forbid = 0; + else + pf->forbid = 1; +} + + +/* --> The following procedures were taken from UNITRK because they */ +/* -> are ProTracker format specific. */ + +void UniInstrument(UBYTE ins) +/* Appends UNI_INSTRUMENT opcode to the unitrk stream. */ +{ + UniWrite(UNI_INSTRUMENT); + UniWrite(ins); +} + +void UniNote(UBYTE note) +/* Appends UNI_NOTE opcode to the unitrk stream. */ +{ + UniWrite(UNI_NOTE); + UniWrite(note); +} + +void UniPTEffect(UBYTE eff, UBYTE dat) +/* Appends UNI_PTEFFECTX opcode to the unitrk stream. */ +{ + if(eff!=0 || dat!=0) /* don't write empty effect */ + { UniWrite(UNI_PTEFFECT0+eff); + UniWrite(dat); + } +} + +void UniVolEffect(UWORD eff, UBYTE dat) +/* Appends UNI_VOLEFFECT + effect/dat to unistream. */ +{ + if(eff!=0 || dat!=0) /* don't write empty effect */ + { UniWrite(UNI_VOLEFFECTS); + UniWrite(eff); UniWrite(dat); + } +} + diff --git a/mikmod/munitrk.c b/mikmod/munitrk.c new file mode 100644 index 00000000..a2fba726 --- /dev/null +++ b/mikmod/munitrk.c @@ -0,0 +1,307 @@ +/* + +Name: +MUNITRK.C + +Description: +All routines dealing with the manipulation of UNITRK(tm) streams + +Portability: +All systems - all compilers + +*/ + +#include +#include "mikmod.h" + +#define BUFPAGE 128 /* smallest unibuffer size */ +#define TRESHOLD 16 + +UWORD unioperands[256] = +{ 0, /* not used */ + 1, /* UNI_NOTE */ + 1, /* UNI_INSTRUMENT */ + 1, /* UNI_PTEFFECT0 */ + 1, /* UNI_PTEFFECT1 */ + 1, /* UNI_PTEFFECT2 */ + 1, /* UNI_PTEFFECT3 */ + 1, /* UNI_PTEFFECT4 */ + 1, /* UNI_PTEFFECT5 */ + 1, /* UNI_PTEFFECT6 */ + 1, /* UNI_PTEFFECT7 */ + 1, /* UNI_PTEFFECT8 */ + 1, /* UNI_PTEFFECT9 */ + 1, /* UNI_PTEFFECTA */ + 1, /* UNI_PTEFFECTB */ + 1, /* UNI_PTEFFECTC */ + 1, /* UNI_PTEFFECTD */ + 1, /* UNI_PTEFFECTE */ + 1, /* UNI_PTEFFECTF */ + 1, /* UNI_S3MEFFECTA */ + 1, /* UNI_S3MEFFECTD */ + 1, /* UNI_S3MEFFECTE */ + 1, /* UNI_S3MEFFECTF */ + 1, /* UNI_S3MEFFECTI */ + 1, /* UNI_S3MEFFECTQ */ + 1, /* UNI_S3MEFFECTR */ + 1, /* UNI_S3MEFFECTT */ + 1, /* UNI_S3MEFFECTU */ + 0, /* UNI_KEYOFF */ + 1, /* UNI_KEYFADE */ + 2, /* UNI_VOLEFFECTS */ + 1, /* UNI_XMEFFECT4 */ + 1, /* UNI_XMEFFECTA */ + 1, /* UNI_XMEFFECTE1 */ + 1, /* UNI_XMEFFECTE2 */ + 1, /* UNI_XMEFFECTEA */ + 1, /* UNI_XMEFFECTEB */ + 1, /* UNI_XMEFFECTG */ + 1, /* UNI_XMEFFECTH */ + 1, /* UNI_XMEFFECTL */ + 1, /* UNI_XMEFFECTP */ + 1, /* UNI_XMEFFECTX1 */ + 1, /* UNI_XMEFFECTX2 */ + 1, /* UNI_ITEFFECTG */ + 1, /* UNI_ITEFFECTH */ + 1, /* UNI_ITEFFECTI */ + 1, /* UNI_ITEFFECTM */ + 1, /* UNI_ITEFFECTN */ + 1, /* UNI_ITEFFECTP */ + 1, /* UNI_ITEFFECTU */ + 1, /* UNI_ITEFFECTW */ + 1, /* UNI_ITEFFECTY */ + 1 /* UNI_ITEFFECTS0 */ +}; + + +/* unibuffer is increased by BUFPAGE */ +/* bytes when unipc reaches unimax-TRESHOLD */ + + +/* + Ok.. I'll try to explain the new internal module format.. so here it goes: + + + The UNITRK(tm) Format: + ====================== + + A UNITRK stream is an array of bytes representing a single track + of a pattern. It's made up of 'repeat/length' bytes, opcodes and + operands (sort of a assembly language): + + rrrlllll + [REP/LEN][OPCODE][OPERAND][OPCODE][OPERAND] [REP/LEN][OPCODE][OPERAND].. + ^ ^ ^ + |-------ROWS 0 - 0+REP of a track---------| |-------ROWS xx - xx+REP of a track... + + + The rep/len byte contains the number of bytes in the current row, + _including_ the length byte itself (So the LENGTH byte of row 0 in the + previous example would have a value of 5). This makes it easy to search + through a stream for a particular row. A track is concluded by a 0-value + length byte. + + The upper 3 bits of the rep/len byte contain the number of times -1 this + row is repeated for this track. (so a value of 7 means this row is repeated + 8 times) + + Opcodes can range from 1 to 255 but currently only opcodes 1 to 45 are + being used. Each opcode can have a different number of operands. You can + find the number of operands to a particular opcode by using the opcode + as an index into the 'unioperands' table. + +*/ + + +/*************************************************************************** +>>>>>>>>>>> Next are the routines for reading a UNITRK stream: <<<<<<<<<<<<< +***************************************************************************/ + + +static UBYTE *rowstart; /* startadress of a row */ +static UBYTE *rowend; /* endaddress of a row (exclusive) */ +static UBYTE *rowpc; /* current unimod(tm) programcounter */ + + +void UniSetRow(UBYTE *t) +{ + rowstart = t; + rowpc = rowstart; + rowend = rowstart+(*(rowpc++)&0x1f); +} + + +UBYTE UniGetByte(void) +{ + return (rowpc end of track.. */ + l = (c>>5)+1; /* extract repeat value */ + if(l>row) break; /* reached wanted row? -> return pointer */ + row -= l; /* haven't reached row yet.. update row */ + t += c&0x1f; /* point t to the next row */ + } + + return t; +} + + + +/*************************************************************************** +>>>>>>>>>>> Next are the routines for CREATING UNITRK streams: <<<<<<<<<<<<< +***************************************************************************/ + + +static UBYTE *unibuf; /* pointer to the temporary unitrk buffer */ +static UWORD unimax; /* maximum number of bytes to be written to this buffer */ + +static UWORD unipc; /* index in the buffer where next opcode will be written */ +static UWORD unitt; /* holds index of the rep/len byte of a row */ +static UWORD lastp; /* holds index to the previous row (needed for compressing) */ + + +void UniReset(void) +/* Resets index-pointers to create a new track. */ +{ + unitt = 0; /* reset index to rep/len byte */ + unipc = 1; /* first opcode will be written to index 1 */ + lastp = 0; /* no previous row yet */ + unibuf[0] = 0; /* clear rep/len byte */ +} + + +void UniWrite(UBYTE data) +/* Appends one byte of data to the current row of a track. */ +{ + /* write byte to current position and update */ + + unibuf[unipc++] = data; + + /* Check if we've reached the end of the buffer */ + + if(unipc > (unimax-TRESHOLD)) + { UBYTE *newbuf; + + /* We've reached the end of the buffer, so expand */ + /* the buffer by BUFPAGE bytes */ + + newbuf = (UBYTE *)realloc(unibuf, unimax+BUFPAGE); + + /* Check if realloc succeeded */ + + if(newbuf!=NULL) + { unibuf = newbuf; + unimax+=BUFPAGE; + } else + { /* realloc failed, so decrease unipc so we won't write beyond */ + /* the end of the buffer.. I don't report the out-of-memory */ + /* here; the UniDup() will fail anyway so that's where the */ + /* loader sees that something went wrong */ + + unipc--; + } + } +} + + +BOOL MyCmp(UBYTE *a, UBYTE *b, UWORD l) +{ + UWORD t; + + for(t=0; t>5)+1; /* repeat of previous row */ + l = (unibuf[lastp]&0x1f); /* length of previous row */ + + len = unipc-unitt; /* length of current row */ + + /* Now, check if the previous and the current row are identical.. */ + /* when they are, just increase the repeat field of the previous row */ + + if(n<8 && len==l && MyCmp(&unibuf[lastp+1],&unibuf[unitt+1],len-1)) + { unibuf[lastp]+=0x20; + unipc = unitt+1; + } else + { /* current and previous row aren't equal.. so just update the pointers */ + + unibuf[unitt] = len; + lastp = unitt; + unitt = unipc; + unipc++; + } +} + + +UBYTE *UniDup(void) +/* Terminates the current unitrk stream and returns a pointer */ +/* to a copy of the stream. */ +{ + UBYTE *d; + + unibuf[unitt] = 0; + + if((d=(UBYTE *)_mm_malloc(unipc))==NULL) return NULL; + memcpy(d,unibuf,unipc); + + return d; +} + + +UWORD TrkLen(UBYTE *t) +/* Determines the length (in rows) of a unitrk stream 't' */ +{ + UWORD len = 0; + UBYTE c; + + while(c = *t & 0x1f) + { len += c; + t += c; + } + len++; + + return len; +} + + +BOOL UniInit(void) +{ + unimax = BUFPAGE; + + if(!(unibuf=(UBYTE *)_mm_malloc(unimax))) return 0; + return 1; +} + + +void UniCleanup(void) +{ + if(unibuf!=NULL) free(unibuf); + unibuf = NULL; +} + diff --git a/mikmod/npertab.c b/mikmod/npertab.c new file mode 100644 index 00000000..d888ffa5 --- /dev/null +++ b/mikmod/npertab.c @@ -0,0 +1,14 @@ +/* MOD format period table. Used by both the MOD and */ +/* M15 (15-inst mod) Loaders. */ + +#include "tdefs.h" + +UWORD npertab[60] = +{ /* -> Tuning 0 */ + 1712,1616,1524,1440,1356,1280,1208,1140,1076,1016,960,906, + 856,808,762,720,678,640,604,570,538,508,480,453, + 428,404,381,360,339,320,302,285,269,254,240,226, + 214,202,190,180,170,160,151,143,135,127,120,113, + 107,101,95,90,85,80,75,71,67,63,60,56 +}; + diff --git a/mikmod/ptform.h b/mikmod/ptform.h new file mode 100644 index 00000000..5495a1f7 --- /dev/null +++ b/mikmod/ptform.h @@ -0,0 +1,591 @@ +/* + --> The Protracker Enums + -> For MikMod 3.0 +*/ + +#ifndef _PTFORM_H_ +#define _PTFORM_H_ + +#ifdef __cplusplus +extern "C" { +#endif + + +extern UWORD mytab[12],logtab[104]; +extern UBYTE VibratoTable[32],avibtab[128]; +extern SBYTE PanbrelloTable[256]; +extern ULONG lintab[768]; + + +/************************************************************************** +****** Unitrack stuff: **************************************************** +**************************************************************************/ + +/* The UniTrack stuff is generally for internal use only, but would be */ +/* required in making a tracker or a module player tha scrolls pattern */ +/* data. */ + +/* prototypes: */ + +extern void UniSetRow(UBYTE *t); +extern UBYTE UniGetByte(void); +extern UBYTE *UniFindRow(UBYTE *t,UWORD row); +extern void UniReset(void); +extern void UniWrite(UBYTE data); +extern void UniNewline(void); +extern UBYTE *UniDup(void); +extern void UniSkipOpcode(UBYTE op); +extern BOOL UniInit(void); +extern void UniCleanup(void); +extern UWORD TrkLen(UBYTE *t); +extern BOOL MyCmp(UBYTE *a, UBYTE *b, UWORD l); +extern void UniInstrument(UBYTE ins); +extern void UniNote(UBYTE note); +extern void UniPTEffect(UBYTE eff, UBYTE dat); +extern void UniVolEffect(UWORD eff, UBYTE dat); + + +/* Enumaerated UniMod Commands */ + +enum +{ UNI_NOTE = 1, + UNI_INSTRUMENT, + UNI_PTEFFECT0, + UNI_PTEFFECT1, + UNI_PTEFFECT2, + UNI_PTEFFECT3, + UNI_PTEFFECT4, + UNI_PTEFFECT5, + UNI_PTEFFECT6, + UNI_PTEFFECT7, + UNI_PTEFFECT8, + UNI_PTEFFECT9, + UNI_PTEFFECTA, + UNI_PTEFFECTB, + UNI_PTEFFECTC, + UNI_PTEFFECTD, + UNI_PTEFFECTE, + UNI_PTEFFECTF, + UNI_S3MEFFECTA, + UNI_S3MEFFECTD, + UNI_S3MEFFECTE, + UNI_S3MEFFECTF, + UNI_S3MEFFECTI, + UNI_S3MEFFECTQ, + UNI_S3MEFFECTR, + UNI_S3MEFFECTT, + UNI_S3MEFFECTU, + UNI_KEYOFF, + UNI_KEYFADE, + UNI_VOLEFFECTS, + UNI_XMEFFECT4, + UNI_XMEFFECTA, + UNI_XMEFFECTE1, + UNI_XMEFFECTE2, + UNI_XMEFFECTEA, + UNI_XMEFFECTEB, + UNI_XMEFFECTG, + UNI_XMEFFECTH, + UNI_XMEFFECTL, + UNI_XMEFFECTP, + UNI_XMEFFECTX1, + UNI_XMEFFECTX2, + UNI_ITEFFECTG, /* Porta to Note .. no kick=0; */ + UNI_ITEFFECTH, /* IT specific Vibrato */ + UNI_ITEFFECTI, /* IT tremor (xy not incremeneted) */ + UNI_ITEFFECTM, /* Set Channel Volume */ + UNI_ITEFFECTN, /* Slide / Fineslide Channel Volume */ + UNI_ITEFFECTP, /* Slide / Fineslide Channel Panning */ + UNI_ITEFFECTU, /* IT fine vibrato */ + UNI_ITEFFECTW, /* Slide / Fineslide Global volume */ + UNI_ITEFFECTY, /* The Satanic Panbrello */ + UNI_ITEFFECTS0, + UNI_LAST +}; + + +/* IT / S3M Extended SS effects: */ + +enum +{ SS_GLISSANDO = 1, + SS_FINETUNE, + SS_VIBWAVE, + SS_TREMWAVE, + SS_PANWAVE, + SS_FRAMEDELAY, + SS_S7EFFECTS, + SS_PANNING, + SS_SURROUND, + SS_HIOFFSET, + SS_PATLOOP, + SS_NOTECUT, + SS_NOTEDELAY, + SS_PATDELAY +}; + + +/* IT Volume column effects */ + +enum +{ VOL_VOLUME = 1, + VOL_PANNING, + VOL_VOLSLIDE, + VOL_PITCHSLIDEDN, + VOL_PITCHSLIDEUP, + VOL_PORTAMENTO, + VOL_VIBRATO +}; + + +/************************************************************************** +****** Instrument stuff: ************************************************** +**************************************************************************/ + + +/* Instrument format flags */ +#define IF_OWNPAN 1 +#define IF_PITCHPAN 2 + +/* Envelope flags: */ + +#define EF_ON 1 +#define EF_SUSTAIN 2 +#define EF_LOOP 4 +#define EF_VOLENV 8 + +/* New Note Action Flags */ + +#define NNA_CUT 0 +#define NNA_CONTINUE 1 +#define NNA_OFF 2 +#define NNA_FADE 3 + +#define DCT_OFF 0 +#define DCT_NOTE 1 +#define DCT_SAMPLE 2 +#define DCT_INST 3 + +#define DCA_CUT 0 +#define DCA_OFF 1 +#define DCA_FADE 2 + +#define KEY_KICK 0 +#define KEY_OFF 1 +#define KEY_FADE 2 +#define KEY_KILL 3 + +#define AV_IT 1 /* IT vs. XM vibrato info */ + + +typedef struct ENVPT +{ SWORD pos; + SWORD val; +} ENVPT; + + +typedef struct INSTRUMENT +{ + UBYTE flags; + + UBYTE samplenumber[120]; + UBYTE samplenote[120]; + + UBYTE nnatype; + UBYTE dca; /* duplicate check action */ + UBYTE dct; /* duplicate check type */ + UBYTE globvol; + UWORD panning; /* instrument-based panning var */ + + UBYTE pitpansep; /* pitch pan separation (0 to 255) */ + UBYTE pitpancenter; /* pitch pan center (0 to 119) */ + UBYTE rvolvar; /* random volume varations (0 - 100%) */ + UBYTE rpanvar; /* random panning varations (0 - 100%) */ + + UWORD volfade; + + UBYTE volflg; /* bit 0: on 1: sustain 2: loop */ + UBYTE volpts; + UBYTE volsusbeg; + UBYTE volsusend; + UBYTE volbeg; + UBYTE volend; + ENVPT volenv[32]; + + UBYTE panflg; /* bit 0: on 1: sustain 2: loop */ + UBYTE panpts; + UBYTE pansusbeg; + UBYTE pansusend; + UBYTE panbeg; + UBYTE panend; + ENVPT panenv[32]; + + UBYTE pitflg; /* bit 0: on 1: sustain 2: loop */ + UBYTE pitpts; + UBYTE pitsusbeg; + UBYTE pitsusend; + UBYTE pitbeg; + UBYTE pitend; + ENVPT pitenv[32]; + +/* UBYTE vibtype; */ +/* UBYTE vibsweep; */ +/* UBYTE vibdepth; */ +/* UBYTE vibrate; */ + + CHAR *insname; + +} INSTRUMENT; + + + +/************************************************************************** +****** Player stuff: ****************************************************** +**************************************************************************/ + +typedef struct ENVPR +{ UBYTE flg; /* envelope flag */ + UBYTE pts; /* number of envelope points */ + UBYTE susbeg; /* envelope sustain index begin */ + UBYTE susend; /* envelope sustain index end */ + UBYTE beg; /* envelope loop begin */ + UBYTE end; /* envelope loop end */ + SWORD p; /* current envelope counter */ + UWORD a; /* envelope index a */ + UWORD b; /* envelope index b */ + ENVPT *env; /* envelope points */ +} ENVPR; + + + +/* Struct MP_VOICE - Used by NNA only player (audio control. AUDTMP is */ +/* used for full effects control). */ +typedef struct MP_VOICE +{ INSTRUMENT *i; + SAMPLE *s; + UBYTE sample; /* which instrument number */ + + SWORD volume; /* output volume (vol + sampcol + instvol) */ + UWORD panning; /* panning position */ + SBYTE chanvol; /* channel's "global" volume */ + UWORD fadevol; /* fading volume rate */ + UWORD period; /* period to play the sample at */ + + UBYTE volflg; /* volume envelope settings */ + UBYTE panflg; /* panning envelope settings */ + UBYTE pitflg; /* pitch envelope settings */ + + UBYTE keyoff; /* if true = fade out and stuff */ + UBYTE kick; /* if true = sample has to be restarted */ + UBYTE note; /* the audible note (as heard, direct rep of period) */ + UBYTE nna; /* New note action type + master/slave flags */ + SWORD handle; /* which sample-handle */ + SLONG start; /* The start byte index in the sample */ + + + /* ---------------------------------- */ + /* Below here is info NOT in MP_CONTROL!! */ + /* ---------------------------------- */ + + ENVPR venv; + ENVPR penv; + ENVPR cenv; + + UWORD avibpos; /* autovibrato pos */ + UWORD aswppos; /* autovibrato sweep pos */ + + ULONG totalvol; /* total volume of channel (before global mixings) */ + + BOOL mflag; + SWORD masterchn; + struct MP_CONTROL *master;/* index of "master" effects channel */ +} MP_VOICE; + + +typedef struct MP_CONTROL +{ INSTRUMENT *i; + SAMPLE *s; + UBYTE sample; /* which sample number */ + UBYTE note; /* the audible note (as heard, direct rep of period) */ + SWORD outvolume; /* output volume (vol + sampcol + instvol) */ + SBYTE chanvol; /* channel's "global" volume */ + UWORD fadevol; /* fading volume rate */ + UWORD panning; /* panning position */ + UBYTE kick; /* if true = sample has to be restarted */ + UBYTE muted; /* if set, channel not played */ + UWORD period; /* period to play the sample at */ + UBYTE nna; /* New note action type + master/slave flags */ + + UBYTE volflg; /* volume envelope settings */ + UBYTE panflg; /* panning envelope settings */ + UBYTE pitflg; /* pitch envelope settings */ + + UBYTE keyoff; /* if true = fade out and stuff */ + SWORD handle; /* which sample-handle */ + UBYTE notedelay; /* (used for note delay) */ + SLONG start; /* The starting byte index in the sample */ + + struct MP_VOICE *slave;/* Audio Slave of current effects control channel */ + UBYTE slavechn; /* Audio Slave of current effects control channel */ + UBYTE anote; /* the note that indexes the audible (note seen in tracker) */ + SWORD ownper; + SWORD ownvol; + UBYTE dca; /* duplicate check action */ + UBYTE dct; /* duplicate check type */ + UBYTE *row; /* row currently playing on this channel */ + SBYTE retrig; /* retrig value (0 means don't retrig) */ + ULONG speed; /* what finetune to use */ + SWORD volume; /* amiga volume (0 t/m 64) to play the sample at */ + + SBYTE tmpvolume; /* tmp volume */ + UWORD tmpperiod; /* tmp period */ + UWORD wantedperiod; /* period to slide to (with effect 3 or 5) */ + UBYTE pansspd; /* panslide speed */ + UWORD slidespeed; /* */ + UWORD portspeed; /* noteslide speed (toneportamento) */ + + UBYTE s3mtremor; /* s3m tremor (effect I) counter */ + UBYTE s3mtronof; /* s3m tremor ontime/offtime */ + UBYTE s3mvolslide; /* last used volslide */ + UBYTE s3mrtgspeed; /* last used retrig speed */ + UBYTE s3mrtgslide; /* last used retrig slide */ + + UBYTE glissando; /* glissando (0 means off) */ + UBYTE wavecontrol; /* */ + + SBYTE vibpos; /* current vibrato position */ + UBYTE vibspd; /* "" speed */ + UBYTE vibdepth; /* "" depth */ + + SBYTE trmpos; /* current tremolo position */ + UBYTE trmspd; /* "" speed */ + UBYTE trmdepth; /* "" depth */ + + UBYTE fslideupspd; + UBYTE fslidednspd; + UBYTE fportupspd; /* fx E1 (extra fine portamento up) data */ + UBYTE fportdnspd; /* fx E2 (extra fine portamento dn) data */ + UBYTE ffportupspd; /* fx X1 (extra fine portamento up) data */ + UBYTE ffportdnspd; /* fx X2 (extra fine portamento dn) data */ + + ULONG hioffset; /* last used high order of sample offset */ + UWORD soffset; /* last used low order of sample-offset (effect 9) */ + + UBYTE sseffect; /* last used Sxx effect */ + UBYTE ssdata; /* last used Sxx data info */ + UBYTE chanvolslide; /* last used channel volume slide */ + + UBYTE panbwave; /* current panbrello waveform */ + UBYTE panbpos; /* current panbrello position */ + SBYTE panbspd; /* "" speed */ + UBYTE panbdepth; /* "" depth */ + + UWORD newsamp; /* set to 1 upon a sample / inst change */ + UBYTE voleffect; /* Volume Column Effect Memory as used by Impulse Tracker */ + UBYTE voldata; /* Volume Column Data Memory */ +} MP_CONTROL; + + +/****************************************************** +******** MikMod UniMod type: ************************** +*******************************************************/ + +/* UniMod flags */ +#define UF_XMPERIODS 1 /* XM periods / finetuning */ +#define UF_LINEAR 2 /* LINEAR periods (UF_XMPERIODS must be set as well) */ +#define UF_INST 4 /* Instruments are used */ +#define UF_NNA 8 /* New Note Actions used (set numvoices rather than numchn) */ + + +typedef struct UNIMOD +{ + /* This section of elements are all file-storage related. */ + /* all of this information can be found in the UNIMOD disk format. */ + /* For further details about there variables, see the MikMod Docs. */ + + UWORD flags; /* See UniMod Flags above */ + UBYTE numchn; /* number of module channels */ + UBYTE numvoices; /* max # voices used for full NNA playback */ + UWORD numpos; /* number of positions in this song */ + UWORD numpat; /* number of patterns in this song */ + UWORD numtrk; /* number of tracks */ + UWORD numins; /* number of instruments */ + UWORD numsmp; /* number of samples */ + UWORD reppos; /* restart position */ + UBYTE initspeed; /* initial song speed */ + UBYTE inittempo; /* initial song tempo */ + UBYTE initvolume; /* initial global volume (0 - 128) */ + UWORD panning[64]; /* 64 panning positions */ + UBYTE chanvol[64]; /* 64 channel positions */ + CHAR *songname; /* name of the song */ + CHAR *composer; /* name of the composer */ + CHAR *comment; /* module comments */ + UBYTE **tracks; /* array of numtrk pointers to tracks */ + UWORD *patterns; /* array of Patterns [pointers to tracks for each channel]. */ + UWORD *pattrows; /* array of number of rows for each pattern */ + UWORD *positions; /* all positions */ + INSTRUMENT *instruments; /* all instruments */ + SAMPLE *samples; /* all samples */ + + /* following are the player-instance variables. They are in no way file */ + /* storage related - they are for internal replay use only. */ + + /* All following variables can be modified at any time. */ + + CHAR *modtype; /* string type of module loaded */ + UBYTE bpm; /* current beats-per-minute speed */ + UWORD sngspd; /* current song speed */ + SWORD volume; /* song volume (0-128) (or user volume) */ + BOOL extspd; /* extended speed flag (default enabled) */ + BOOL panflag; /* panning flag (default enabled) */ + BOOL loop; /* loop module ? (default disabled) */ + BOOL forbid; /* if true, no player update! */ + + /* The following variables are considered useful for reading, and should */ + /* should not be directly modified by the end user. */ + + MP_CONTROL *control; /* Effects Channel information (pf->numchn alloc'ed) */ + MP_VOICE *voice; /* Audio Voice information (md_numchn alloc'ed) */ + UWORD numrow; /* number of rows on current pattern */ + UWORD vbtick; /* tick counter (counts from 0 to sngspd) */ + UWORD patpos; /* current row number */ + SWORD sngpos; /* current song position. This should not */ + /* be modified directly. Use MikMod_NextPosition, */ + /* MikMod_PrevPosition, and MikMod_SetPosition. */ + + /* The following variables should not be modified, and have information */ + /* that is pretty useless outside the internal player, so just ignore :) */ + + UBYTE globalslide; /* global volume slide rate */ + UWORD pat_reppos; /* patternloop position */ + UWORD pat_repcnt; /* times to loop */ + UWORD patbrk; /* position where to start a new pattern */ + UBYTE patdly; /* patterndelay counter (command memory) */ + UBYTE patdly2; /* patterndelay counter (real one) */ + SWORD posjmp; /* flag to indicate a position jump is needed... */ + /* changed since 1.00: now also indicates the */ + /* direction the position has to jump to: */ + /* 0: Don't do anything */ + /* 1: Jump back 1 position */ + /* 2: Restart on current position */ + /* 3: Jump forward 1 position */ + +} UNIMOD; + + +/*************************************************** +****** Loader stuff: ******************************* +****************************************************/ + +/* loader structure: */ + +typedef struct MLOADER +{ struct MLOADER *next; + CHAR *type; + CHAR *version; + BOOL (*Init)(void); + BOOL (*Test)(void); + BOOL (*Load)(void); + void (*Cleanup)(void); + CHAR *(*LoadTitle)(void); +} MLOADER; + +/* public loader variables: */ + +extern FILE *modfp; +extern UWORD finetune[16]; +extern UNIMOD of; /* static unimod loading space */ +extern UWORD npertab[60]; /* used by the original MOD loaders */ + +/* main loader prototypes: */ + +void ML_InfoLoader(void); +void ML_RegisterLoader(MLOADER *ldr); +UNIMOD *MikMod_LoadSongFP(FILE *fp, int maxchan); +UNIMOD *MikMod_LoadSong(CHAR *filename, int maxchan); +void MikMod_FreeSong(UNIMOD *mf); + + +/* other loader prototypes: (used by the loader modules) */ + +BOOL InitTracks(void); +void AddTrack(UBYTE *tr); +BOOL ReadComment(UWORD len); +BOOL AllocPositions(int total); +BOOL AllocPatterns(void); +BOOL AllocTracks(void); +BOOL AllocInstruments(void); +BOOL AllocSamples(void); +CHAR *DupStr(CHAR *s, UWORD len); + + +/* Declare external loaders: */ + +extern MLOADER load_uni; /* Internal UniMod Loader (Current version of UniMod only) */ +extern MLOADER load_mod; /* Standard 31-instrument Module loader (Protracker, StarTracker, FastTracker, etc) */ +extern MLOADER load_m15; /* 15-instrument (SoundTracker and Ultimate SoundTracker) */ +extern MLOADER load_mtm; /* Multi-Tracker Module (by Renaissance) */ +extern MLOADER load_s3m; /* ScreamTracker 3 (by Future Crew) */ +extern MLOADER load_stm; /* ScreamTracker 2 (by Future Crew) */ +extern MLOADER load_ult; /* UltraTracker */ +extern MLOADER load_xm; /* FastTracker 2 (by Trition) */ +extern MLOADER load_it; /* Impulse Tracker (by Jeffrey Lim) */ +extern MLOADER load_669; /* 669 and Extended-669 (by Tran / Renaissance) */ +extern MLOADER load_dsm; /* DSIK internal module format */ +extern MLOADER load_med; /* MMD0 and MMD1 Amiga MED modules (by OctaMED) */ +extern MLOADER load_far; /* Farandole Composer Module */ + +/* used to convert c4spd to linear XM periods (IT loader). */ +extern UWORD getlinearperiod(UBYTE note, ULONG fine); +extern ULONG getfrequency(UBYTE flags, ULONG period); + + +#define MP_HandleTick Player_HandleTick +#define ML_LoadFN(x,y) MikMod_LoadSong(x,y) +#define ML_LoadFP(x,y) MikMod_LoadSongFP(x,y) +#define MP_PlayStart(x) Player_Start(x) +#define MP_PlayStop Player_Stop + + +/* MikMod Player Prototypes: */ +/* =========================================================== */ +/* This batch of prototypes affects the currently ACTIVE module */ +/* set with MikMod_PlayStart) */ + +extern void Player_Start(UNIMOD *mf); +extern BOOL Player_Active(void); +extern void Player_Stop(void); +extern void Player_TogglePause(void); +extern void Player_NextPosition(void); +extern void Player_PrevPosition(void); +extern void Player_SetPosition(UWORD pos); +extern void Player_Mute(SLONG arg1, ...); +extern void Player_UnMute(SLONG arg1, ...); +extern void Player_ToggleMute(SLONG arg1, ...); +extern BOOL Player_Muted(int chan); +extern void Player_HandleTick(void); +extern void Player_SetVolume(int volume); +extern UNIMOD *Player_GetUnimod(void); + +extern BOOL Player_Init(UNIMOD *mf); /* internal use only [by loader] */ +extern void Player_Exit(UNIMOD *mf); /* internal use only [by loader] */ + +/* This batch of prototypes adheres closely to the old MikMod 2.10 */ +/* naming, and affects ANY specified module (need not be active, */ +/* only loaded and initialized) */ + +extern BOOL MP_Playing(UNIMOD *mf); +extern void MP_TogglePause(UNIMOD *mf); +extern void MP_NextPosition(UNIMOD *mf); +extern void MP_PrevPosition(UNIMOD *mf); +extern void MP_SetPosition(UNIMOD *mf, UWORD pos); +extern void MP_Mute(UNIMOD *mf, SLONG arg1, ...); +extern void MP_UnMute(UNIMOD *mf, SLONG arg1, ...); +extern void MP_ToggleMute(UNIMOD *mf, SLONG arg1, ...); +extern BOOL MP_Muted(UNIMOD *mf, int chan); + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/mikmod/s3m_it.c b/mikmod/s3m_it.c new file mode 100644 index 00000000..f77fcfba --- /dev/null +++ b/mikmod/s3m_it.c @@ -0,0 +1,187 @@ +/* + +Name: +S3M_IT.C + +Description: +Commonfunctions between S3Ms and ITs (smaller .EXE! :) + +Portability: +All systems - all compilers (hopefully) + +*/ + +#include "mikmod.h" + +UBYTE *poslookup=NULL;/* S3M/IT fix - removing blank patterns needs a */ + /* lookup table to fix position-jump commands */ +SBYTE remap[64]; /* for removing empty channels */ +SBYTE isused[64]; /* for removing empty channels */ + + +void S3MIT_ProcessCmd(UBYTE cmd,UBYTE inf,BOOL oldeffect) +{ + UBYTE hi,lo; + + lo=inf&0xf; + hi=inf>>4; + + /* process S3M / IT specific command structure */ + + if(cmd!=255) + { switch(cmd) + { case 1: /* Axx set speed to xx */ + UniWrite(UNI_S3MEFFECTA); + UniWrite(inf); + break; + + case 2: /* Bxx position jump */ + UniPTEffect(0xb,poslookup[inf]); + break; + + case 3: /* Cxx patternbreak to row xx */ + if(oldeffect & 1) + UniPTEffect(0xd,(((inf&0xf0)>>4)*10)+(inf&0xf)); + else + UniPTEffect(0xd,inf); + break; + + case 4: /* Dxy volumeslide */ + UniWrite(UNI_S3MEFFECTD); + UniWrite(inf); + break; + + case 5: /* Exy toneslide down */ + UniWrite(UNI_S3MEFFECTE); + UniWrite(inf); + break; + + case 6: /* Fxy toneslide up */ + UniWrite(UNI_S3MEFFECTF); + UniWrite(inf); + break; + + case 7: /* Gxx Tone portamento, speed xx */ + UniWrite(UNI_ITEFFECTG); + UniWrite(inf); + break; + + case 8: /* Hxy vibrato */ + if(oldeffect & 1) + UniPTEffect(0x4,inf); + else + { UniWrite(UNI_ITEFFECTH); + UniWrite(inf); + } + break; + + case 9: /* Ixy tremor, ontime x, offtime y */ + if(oldeffect & 1) + UniWrite(UNI_S3MEFFECTI); + else + UniWrite(UNI_ITEFFECTI); + UniWrite(inf); + break; + + case 0xa: /* Jxy arpeggio */ + UniPTEffect(0x0,inf); + break; + + case 0xb: /* Kxy Dual command H00 & Dxy */ + if(oldeffect & 1) + UniPTEffect(0x4,0); + else + { UniWrite(UNI_ITEFFECTH); + UniWrite(0); + } + UniWrite(UNI_S3MEFFECTD); + UniWrite(inf); + break; + + case 0xc: /* Lxy Dual command G00 & Dxy */ + if(oldeffect & 1) + UniPTEffect(0x3,0); + else + { UniWrite(UNI_ITEFFECTG); + UniWrite(0); + } + UniWrite(UNI_S3MEFFECTD); + UniWrite(inf); + break; + + case 0xd: /* Mxx Set Channel Volume */ + UniWrite(UNI_ITEFFECTM); + UniWrite(inf); + break; + + case 0xe: /* Nxy Slide Channel Volume */ + UniWrite(UNI_ITEFFECTN); + UniWrite(inf); + break; + + case 0xf: /* Oxx set sampleoffset xx00h */ + UniPTEffect(0x9,inf); + break; + + case 0x10: /* Pxy Slide Panning Commands */ + UniWrite(UNI_ITEFFECTP); + UniWrite(inf); + break; + + case 0x11: /* Qxy Retrig (+volumeslide) */ + UniWrite(UNI_S3MEFFECTQ); + if((inf!=0) && (lo==0) && !(oldeffect & 1)) + UniWrite(1); + else + UniWrite(inf); + break; + + case 0x12: /* Rxy tremolo speed x, depth y */ + UniWrite(UNI_S3MEFFECTR); + UniWrite(inf); + break; + + case 0x13: /* Sxx special commands */ + UniWrite(UNI_ITEFFECTS0); + UniWrite(inf); + break; + + case 0x14: /* Txx tempo */ + if(inf>0x20) + { UniWrite(UNI_S3MEFFECTT); + UniWrite(inf); + } + break; + + case 0x15: /* Uxy Fine Vibrato speed x, depth y */ + if(oldeffect & 1) + UniWrite(UNI_S3MEFFECTU); + else + UniWrite(UNI_ITEFFECTU); + UniWrite(inf); + break; + + case 0x16: /* Vxx Set Global Volume */ + UniWrite(UNI_XMEFFECTG); + UniWrite(inf); + break; + + case 0x17: /* Wxy Global Volume Slide */ + UniWrite(UNI_ITEFFECTW); + UniWrite(inf); + break; + + case 0x18: /* Xxx amiga command 8xx */ + if(oldeffect & 1) + UniPTEffect(0x8,((inf<<1) == 256) ? 255 : (inf<<1)); + else + UniPTEffect(0x8,inf); + break; + + case 0x19: /* Yxy Panbrello speed x, depth y */ + UniWrite(UNI_ITEFFECTY); + UniWrite(inf); + break; + } + } +} diff --git a/mikmod/sloader.c b/mikmod/sloader.c new file mode 100644 index 00000000..7c791593 --- /dev/null +++ b/mikmod/sloader.c @@ -0,0 +1,407 @@ +/* + --> Sample Loaders and Sample Processing + +Name: sloader.c + +Description: +Routines for loading samples. The sample loader utilizes the routines +provided by the "registered" sample loader. See SAMPLELOADER in +MIKMOD.H for the sample loader structure. + +Portability: +All systems - all compilers + +*/ + +#include "mikmod.h" + + +static int sl_rlength; +static SWORD sl_old; +static SWORD *sl_buffer = NULL; +static SAMPLOAD *musiclist = NULL, + *sndfxlist = NULL; + + + +BOOL SL_Init(SAMPLOAD *s) /* returns 0 on error! */ +{ + if(sl_buffer==NULL) + if((sl_buffer=_mm_malloc(4100)) == NULL) return 0; + + sl_rlength = s->length; + if(s->infmt & SF_16BITS) sl_rlength>>=1; + sl_old = 0; + + return 1; +} + + +void SL_Exit(SAMPLOAD *s) +{ + if(sl_rlength > 0) _mm_fseek(s->fp,sl_rlength,SEEK_CUR); +} + + +void SL_Reset(void) +{ + sl_old = 0; +} + + +void SL_Load(void *buffer, SAMPLOAD *smp, int length) +{ + UWORD infmt = smp->infmt, outfmt = smp->outfmt; + SBYTE *bptr = (SBYTE *)buffer; + SWORD *wptr = (SWORD *)buffer; + int stodo; + int t, u; + + while(length) + { stodo = (length<2048) ? length : 2048; + + if(infmt & SF_16BITS) + { if(infmt & SF_BIG_ENDIAN) + _mm_read_M_SWORDS(sl_buffer,stodo,smp->fp); + else + _mm_read_I_SWORDS(sl_buffer,stodo,smp->fp); + } else + { SBYTE *s; + SWORD *d; + + fread(sl_buffer,sizeof(SBYTE),stodo,smp->fp); + + s = (SBYTE *)sl_buffer; + d = sl_buffer; + s += stodo; + d += stodo; + + for(t=0; tscalefactor) + { int idx = 0; + SLONG scaleval; + + /* Sample Scaling... average values for better results. */ + t = 0; + while(tscalefactor; u && tscalefactor-u); + length--; + } + sl_rlength -= stodo; + stodo = idx; + } else + { length -= stodo; + sl_rlength -= stodo; + } + + if(outfmt & SF_16BITS) + { for(t=0; t>8; + } + } +} + + +void SL_LoadStream(void *buffer, UWORD infmt, UWORD outfmt, int length, FILE *fp) + +/* This is like SL_Load, but does not perform sample scaling, and does not */ +/* require calls to SL_Init / SL_Exit. */ + +{ + SBYTE *bptr = (SBYTE *)buffer; + SWORD *wptr = (SWORD *)buffer; + int stodo; + int t; + + /* compute number of samples to load */ + + if(sl_buffer==NULL) + if((sl_buffer=_mm_malloc(4100)) == NULL) return; + + while(length) + { stodo = (length<2048) ? length : 2048; + + if(infmt & SF_16BITS) + { if(infmt & SF_BIG_ENDIAN) + _mm_read_M_SWORDS(sl_buffer,stodo,fp); + else + _mm_read_I_SWORDS(sl_buffer,stodo,fp); + } else + { SBYTE *s; + SWORD *d; + + fread(sl_buffer,sizeof(SBYTE),stodo,fp); + + s = (SBYTE *)sl_buffer; + d = sl_buffer; + s += stodo; + d += stodo; + + for(t=0; t> 1; + length-=2; + } + stodo = idx; + } + + if(outfmt & SF_16BITS) + { for(t=0; t>8; + } + } +} + + +SAMPLOAD *SL_RegisterSample(SAMPLE *s, int type, FILE *fp) /* Returns 1 on error! */ + +/* Registers a sample for loading when SL_LoadSamples() is called. */ +/* type - type of sample to be loaded .. */ +/* MD_MUSIC, MD_SNDFX */ + +{ + SAMPLOAD *news, **samplist, *cruise; + + if(type==MD_MUSIC) + { samplist = & musiclist; + cruise = musiclist; + } else + { samplist = &sndfxlist; + cruise = sndfxlist; + } + + /* Allocate and add structure to the END of the list */ + + if((news=(SAMPLOAD *)_mm_calloc(1,sizeof(SAMPLOAD))) == NULL) return NULL; + + if(cruise!=NULL) + { while(cruise->next!=NULL) cruise = cruise->next; + cruise->next = news; + } else + *samplist = news; + + news->infmt = s->flags & 31; + news->outfmt = news->infmt; + news->fp = fp; + news->sample = s; + news->length = s->length; + news->loopstart = s->loopstart; + news->loopend = s->loopend; + + return news; +} + + +static void FreeSampleList(SAMPLOAD *s) +{ + SAMPLOAD *old; + + while(s!=NULL) + { old = s; + s = s->next; + free(old); + } +} + + +static ULONG SampleTotal(SAMPLOAD *samplist, int type) +/* Returns the total amount of memory required by the samplelist queue. */ +{ + int total = 0; + + while(samplist!=NULL) + { samplist->sample->flags = (samplist->sample->flags&~31) | samplist->outfmt; + total += MD_SampleLength(type,samplist->sample); + samplist = samplist->next; + } + + return total; +} + + +static ULONG RealSpeed(SAMPLOAD *s) +{ + return(s->sample->speed / ((s->scalefactor==0) ? 1 : s->scalefactor)); +} + + +static BOOL DitherSamples(SAMPLOAD *samplist, int type) +{ + SAMPLOAD *c2smp; + ULONG maxsize, speed; + SAMPLOAD *s; + + if(samplist==NULL) return 0; + + /* make sure the samples will fit inside available RAM */ + if((maxsize = MD_SampleSpace(type)*1024) != 0) + { while(SampleTotal(samplist, type) > maxsize) + { /* First Pass - check for any 16 bit samples */ + s = samplist; + while(s!=NULL) + { if(s->outfmt & SF_16BITS) + { SL_Sample16to8(s); + break; + } + s = s->next; + } + + /* Second pass (if no 16bits found above) is to take the sample */ + /* with the highest speed and dither it by half. */ + if(s==NULL) + { s = samplist; + speed = 0; + while(s!=NULL) + { if((s->sample->length) && (RealSpeed(s) > speed)) + { speed = RealSpeed(s); + c2smp = s; + } + s = s->next; + } + SL_HalveSample(c2smp); + } + } + } + + + /* Samples dithered, now load them! */ + /* ================================ */ + + s = samplist; + while(s != NULL) + { /* sample has to be loaded ? -> increase number of */ + /* samples, allocate memory and load sample. */ + + if(s->sample->length) + { if(s->sample->seekpos) + _mm_fseek(s->fp, s->sample->seekpos, SEEK_SET); + + /* Call the sample load routine of the driver module. */ + /* It has to return a 'handle' (>=0) that identifies */ + /* the sample. */ + + s->sample->handle = MD_SampleLoad(s, type, s->fp); + s->sample->flags = (s->sample->flags & ~31) | s->outfmt; + if(s->sample->handle < 0) + { FreeSampleList(samplist); + if(_mm_errorhandler!=NULL) _mm_errorhandler(); + return 1; + } + } + s = s->next; + } + + FreeSampleList(samplist); + return 0; +} + + +BOOL SL_LoadSamples(void) /* Returns 1 on error! */ +{ + BOOL ok; + + _mm_critical = 0; + + if((musiclist==NULL) && (sndfxlist==NULL)) return 0; +/* MikMod_Exit(); */ +/* exit(1); */ + ok = DitherSamples(musiclist,MD_MUSIC) || DitherSamples(sndfxlist,MD_SNDFX); + + musiclist = sndfxlist = NULL; + + return ok; +} + + +void SL_Sample16to8(SAMPLOAD *s) +{ + s->outfmt &= ~SF_16BITS; + s->sample->flags = (s->sample->flags&~31) | s->outfmt; +} + + +void SL_Sample8to16(SAMPLOAD *s) +{ + s->outfmt |= SF_16BITS; + s->sample->flags = (s->sample->flags&~31) | s->outfmt; +} + + +void SL_SampleSigned(SAMPLOAD *s) +{ + s->outfmt |= SF_SIGNED; + s->sample->flags = (s->sample->flags&~31) | s->outfmt; +} + + +void SL_SampleUnsigned(SAMPLOAD *s) +{ + s->outfmt &= ~SF_SIGNED; + s->sample->flags = (s->sample->flags&~31) | s->outfmt; +} + + +void SL_HalveSample(SAMPLOAD *s) +{ + if(s->scalefactor) + s->scalefactor++; + else + s->scalefactor = 2; + + s->sample->divfactor = s->scalefactor; + s->sample->length = s->length / s->scalefactor; + s->sample->loopstart = s->loopstart / s->scalefactor; + s->sample->loopend = s->loopend / s->scalefactor; +} + diff --git a/mikmod/tdefs.h b/mikmod/tdefs.h new file mode 100644 index 00000000..6614873e --- /dev/null +++ b/mikmod/tdefs.h @@ -0,0 +1,105 @@ +/* + TDEFS.H : Type definitions for the more commonly used type statements. + A 'shortened' version of MTYPES.H that has only what I use most. + + This module is my hidden secret of "portability" to many compilers + and platforms. I really love C sometimes.. ;) +*/ + + +#ifndef TDEFS_H +#define TDEFS_H + + +/* + MikMod atomic types: + ==================== +*/ + +typedef char CHAR; + +#ifdef __OS2__ + +typedef signed char SBYTE; /* has to be 1 byte signed */ +typedef unsigned char UBYTE; /* has to be 1 byte unsigned */ +typedef signed short SWORD; /* has to be 2 bytes signed */ +typedef unsigned short UWORD; /* has to be 2 bytes unsigned */ +typedef signed long SLONG; /* has to be 4 bytes signed */ +/* ULONG and BOOL are already defined in OS2.H */ + +#elif defined(__alpha) + +typedef signed char SBYTE; /* has to be 1 byte signed */ +typedef unsigned char UBYTE; /* has to be 1 byte unsigned */ +typedef signed short SWORD; /* has to be 2 bytes signed */ +typedef unsigned short UWORD; /* has to be 2 bytes unsigned */ +/* long is 8 bytes on dec alpha - RCA */ +typedef signed int SLONG; /* has to be 4 bytes signed */ +typedef unsigned int ULONG; /* has to be 4 bytes unsigned */ +typedef int BOOL; /* doesn't matter.. 0=FALSE, <>0 true */ + +#else + +typedef signed char SBYTE; /* has to be 1 byte signed */ +typedef unsigned char UBYTE; /* has to be 1 byte unsigned */ +typedef signed short SWORD; /* has to be 2 bytes signed */ +typedef unsigned short UWORD; /* has to be 2 bytes unsigned */ +typedef signed long SLONG; /* has to be 4 bytes signed */ +typedef unsigned long ULONG; /* has to be 4 bytes unsigned */ +typedef int BOOL; /* doesn't matter.. 0=FALSE, <>0 true */ + +#endif + + +#ifdef __OS2__ +#define INCL_DOS +#define INCL_MCIOS2 +#define INCL_MMIOOS2 +#include +#include +#include +#endif + + +#ifdef __WATCOMC__ + +typedef __int64 SDOUBLE; +typedef unsigned __int64 UDOUBLE; + +#define inportb(x) inp(x) +#define outportb(x,y) outp(x,y) +#define inport(x) inpw(x) +#define outport(x,y) outpw(x,y) +#define disable() _disable() +#define enable() _enable() +#endif + +#ifdef __BORLANDC__ +#define inp(x) inportb(x) +#define outp(x,y) outportb(x,y) +#define inpw(x) inport(x) +#define outpw(x,y) outport(x,y) +#define _disable() disable() +#define _enable() enable() +#endif + +#ifdef __DJGPP__ +#include +#include +#include +#define inp inportw +#define outport outportw +#define inport inportw +#define interrupt +#endif + +#if defined(__OS2__) + #define delay(x) DosSleep(x); +#elif defined(__WIN32__) + #define delay(x) Sleep(x); +#elif defined(__GNUC__) + #define delay(x) ; +#endif + +#endif + diff --git a/mikmod/virtch.c b/mikmod/virtch.c new file mode 100644 index 00000000..85781fe8 --- /dev/null +++ b/mikmod/virtch.c @@ -0,0 +1,1362 @@ +/* + +Name: VIRTCH.C + +Description: + Sample mixing routines, using a 32 bits mixing buffer. + + Optional features include: + (a) 4-step reverb (for 16 bit output only) + (b) Interpolation of sample data during mixing + (c) Dolby Surround Sound + (d) Optimized assembly mixers for the Intel platform + (e) Optional high-speed or high-quality modes + +C Mixer Portability: + All Systems -- All compilers. + +Assembly Mixer Portability: + + MSDOS: BC(?) Watcom(y) DJGPP(y) + Win95: ? + Os2: ? + Linux: y + + (y) - yes + (n) - no (not possible or not useful) + (?) - may be possible, but not tested + +*/ + +#include +#include +#include "mikmod.h" + + +/* +// ** For PC-assembly mixing +// ========================= +// Uncomment both lines below for assembly mixing under WATCOM or GCC for +// Linux. Note that there is no 16 bit mixers for assembly yet (C only), so +// defining __ASSEMBLY__ when not defining __FASTMIXER__ will lead to compiler +// errors. +*/ + +#define __FASTMIXER__ +/* #define __ASSEMBLY__ */ +#define __FAST_REVERB__ + +/* +// Various other VIRTCH.C Compiler Options +// ======================================= + +// BITSHIFT : Controls the maximum volume of the sound output. All data +// is shifted right by BITSHIFT after being mixed. Higher values +// result in quieter sound and less chance of distortion. If you +// are using the assembly mixer, you must change the bitshift const- +// ant in RESAMPLE.ASM or RESAMPLE.S as well! +*/ + +#define BITSHIFT 9 + +/* +// REVERBERATION : Controls the duration of the reverb. Larger values +// represent a shorter reverb loop. Smaller values extend the reverb +// but can result in more of an echo-ish sound. +*/ + +#define REVERBERATION 110000l + +/* +// BOUNDS_CHECKING : Forces VIRTCH to perform bounds checking. Commenting +// the line below will result in a slightly faster mixing process but +// could cause nasty clicks and pops on some modules. Disable this +// option on games or demos only, where speed is very important all +// songs / sndfx played can be specifically tested for pops. +*/ + +#define BOUNDS_CHECKING + + +#ifndef __cdecl +#ifdef __GNUC__ +#define __cdecl +#endif +#endif + +#ifdef __WATCOMC__ +#define inline +#endif + +#define FRACBITS 11 +#define FRACMASK ((1l<(b))?(a):(b)) +#endif + + +typedef struct +{ UBYTE kick; /* =1 -> sample has to be restarted */ + UBYTE active; /* =1 -> sample is playing */ + UWORD flags; /* 16/8 bits looping/one-shot */ + SWORD handle; /* identifies the sample */ + ULONG start; /* start index */ + ULONG size; /* samplesize */ + ULONG reppos; /* loop start */ + ULONG repend; /* loop end */ + ULONG frq; /* current frequency */ + int vol; /* current volume */ + int pan; /* current panning position */ + SLONG current; /* current index in the sample */ + SLONG increment; /* fixed-point increment value */ +} VINFO; + +#ifdef __FASTMIXER__ +static SBYTE **Samples; +SLONG *lvoltab, *rvoltab; /* Volume Table values for use by 8 bit mixers */ +#else +static SWORD **Samples; +static SLONG lvolsel, rvolsel; /* Volume Selectors for 16 bit mixers. */ +#endif + +/* Volume table for 8 bit sample mixing */ +#ifdef __FASTMIXER__ +static SLONG **voltab; +#endif + +static VINFO *vinf = NULL, *vnf; +static long TICKLEFT, samplesthatfit, vc_memory = 0; +static int vc_softchn; +static SLONG idxsize, idxlpos, idxlend; +static SLONG *VC_TICKBUF = NULL; +static UWORD vc_mode; + + +/* +// Reverb control variables +// ======================== +*/ + +static int RVc1, RVc2, RVc3, RVc4; +#ifndef __FAST_REVERB__ +static int RVc5, RVc6, RVc7, RVc8; +#endif +static ULONG RVRindex; + + +/* For Mono or Left Channel */ + +static SLONG *RVbuf1 = NULL, *RVbuf2 = NULL, *RVbuf3 = NULL, *RVbuf4 = NULL; +#ifndef __FAST_REVERB__ +static SLONG *RVbuf5 = NULL, *RVbuf6 = NULL, *RVbuf7 = NULL, *RVbuf8 = NULL; +#endif + +/* +// For Stereo only (Right Channel) +// Values start at 9 to leave room for expanding this to 8-step +// reverb in the future. +*/ + +static SLONG *RVbuf9 = NULL, *RVbuf10 = NULL, *RVbuf11 = NULL, *RVbuf12 = NULL; +#ifndef __FAST_REVERB__ +static SLONG *RVbuf13 = NULL, *RVbuf14 = NULL, *RVbuf15 = NULL, *RVbuf16 = NULL; +#endif + + +/* +// Define external Assembly Language Prototypes +// ============================================ +*/ + +#ifdef __ASSEMBLY__ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __cdecl +#ifdef __GNUC__ +#define __cdecl +#endif +#endif + +void __cdecl AsmStereoNormal(SBYTE *srce,SLONG *dest,SLONG index,SLONG increment,SLONG todo); +void __cdecl AsmStereoInterp(SBYTE *srce,SLONG *dest,SLONG index,SLONG increment,SLONG todo); +void __cdecl AsmSurroundNormal(SBYTE *srce,SLONG *dest,SLONG index,SLONG increment,SLONG todo); +void __cdecl AsmSurroundInterp(SBYTE *srce,SLONG *dest,SLONG index,SLONG increment,SLONG todo); +void __cdecl AsmMonoNormal(SBYTE *srce,SLONG *dest,SLONG index,SLONG increment,SLONG todo); +void __cdecl AsmMonoInterp(SBYTE *srce,SLONG *dest,SLONG index,SLONG increment,SLONG todo); + +#ifdef __cplusplus +}; +#endif + +#else + +#ifdef __FASTMIXER__ + +/* +// ============================================================== +// 8 bit sample mixers! +*/ + +static SLONG MixStereoNormal(SBYTE *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo) +{ + UBYTE sample1, sample2, sample3, sample4; + int remain; + + remain = todo & 3; + + for(todo>>=2; todo; todo--) + { + sample1 = srce[index >> FRACBITS]; + index += increment; + sample2 = srce[index >> FRACBITS]; + index += increment; + sample3 = srce[index >> FRACBITS]; + index += increment; + sample4 = srce[index >> FRACBITS]; + index += increment; + + *dest++ += lvoltab[sample1]; + *dest++ += rvoltab[sample1]; + *dest++ += lvoltab[sample2]; + *dest++ += rvoltab[sample2]; + *dest++ += lvoltab[sample3]; + *dest++ += rvoltab[sample3]; + *dest++ += lvoltab[sample4]; + *dest++ += rvoltab[sample4]; + } + + for(; remain--; ) + { + sample1 = srce[index >> FRACBITS]; + index += increment; + *dest++ += lvoltab[sample1]; + *dest++ += rvoltab[sample1]; + } + + return index; +} + + +static SLONG MixStereoInterp(SBYTE *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo) +{ + UBYTE sample; + + for(; todo; todo--) + { sample = (UBYTE)((srce[index >> FRACBITS] * ((FRACMASK+1l) - (index & FRACMASK))) + + (srce[(index >> FRACBITS) + 1] * (index & FRACMASK)) >> FRACBITS); + index += increment; + + *dest++ += lvoltab[sample]; + *dest++ += rvoltab[sample]; + } + + return index; +} + + +static SLONG MixSurroundNormal(SBYTE *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo) +{ + SLONG sample1, sample2, sample3, sample4; + int remain; + + remain = todo & 3; + + for(todo>>=2; todo; todo--) + { + sample1 = lvoltab[(UBYTE)srce[index >> FRACBITS]]; + index += increment; + sample2 = lvoltab[(UBYTE)srce[index >> FRACBITS]]; + index += increment; + sample3 = lvoltab[(UBYTE)srce[index >> FRACBITS]]; + index += increment; + sample4 = lvoltab[(UBYTE)srce[index >> FRACBITS]]; + index += increment; + + *dest++ += sample1; + *dest++ -= sample1; + *dest++ += sample2; + *dest++ -= sample2; + *dest++ += sample3; + *dest++ -= sample3; + *dest++ += sample4; + *dest++ -= sample4; + } + + for(; remain--; ) + { sample1 = lvoltab[(UBYTE)srce[index >> FRACBITS]]; + index += increment; + *dest++ += sample1; + *dest++ -= sample1; + } + + return index; +} + + +static SLONG MixSurroundInterp(SBYTE *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo) +{ + SLONG sample; + + for(; todo; todo--) + { sample = lvoltab[(UBYTE)((srce[index >> FRACBITS] * ((FRACMASK+1l) - (index & FRACMASK))) + + (srce[(index >> FRACBITS) + 1] * (index & FRACMASK)) >> FRACBITS)]; + index += increment; + + *dest++ += sample; + *dest++ -= sample; + } + + return index; +} + + +static SLONG MixMonoNormal(SBYTE *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo) +{ + SLONG sample1, sample2, sample3, sample4; + int remain; + + remain = todo & 3; + + for(todo>>=2; todo; todo--) + { + sample1 = lvoltab[(UBYTE)srce[index >> FRACBITS]]; + index += increment; + sample2 = lvoltab[(UBYTE)srce[index >> FRACBITS]]; + index += increment; + sample3 = lvoltab[(UBYTE)srce[index >> FRACBITS]]; + index += increment; + sample4 = lvoltab[(UBYTE)srce[index >> FRACBITS]]; + index += increment; + + *dest++ += sample1; + *dest++ += sample2; + *dest++ += sample3; + *dest++ += sample4; + } + + for(; remain--;) + { sample1 = lvoltab[(UBYTE)srce[index >> FRACBITS]]; + index += increment; + *dest++ += sample1; + } + + return index; +} + + +static SLONG MixMonoInterp(SBYTE *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo) +{ + SLONG sample; + + for(; todo; todo--) + { sample = lvoltab[(UBYTE)(((srce[index >> FRACBITS] * ((FRACMASK+1l) - (index & FRACMASK))) + + (srce[(index >> FRACBITS) + 1] * (index & FRACMASK))) >> FRACBITS)]; + index += increment; + + *dest++ += sample; + } + + return index; +} + + +#else + +/* +// ============================================================== +// 16 bit sample mixers! +*/ + +static SLONG MixStereoNormal(SWORD *srce, SLONG *dest, SLONG index, SLONG increment, ULONG todo) +{ + SWORD sample; + + for(; todo; todo--) + { + sample = srce[index >> FRACBITS]; + index += increment; + + *dest++ += lvolsel * sample; + *dest++ += rvolsel * sample; + } + + return index; +} + + +static SLONG MixStereoInterp(SWORD *srce, SLONG *dest, SLONG index, SLONG increment, ULONG todo) +{ + SWORD sample; + + for(; todo; todo--) + { + sample = (srce[index >> FRACBITS] * ((FRACMASK+1l) - (index & FRACMASK))) + + (srce[(index >> FRACBITS)+1] * (index & FRACMASK)) >> FRACBITS; + index += increment; + + *dest++ += lvolsel * sample; + *dest++ += rvolsel * sample; + } + + return index; +} + + +static SLONG MixSurroundNormal(SWORD *srce, SLONG *dest, SLONG index, SLONG increment, ULONG todo) +{ + SWORD sample; + + for (; todo; todo--) + { + sample = srce[index >> FRACBITS]; + index += increment; + + *dest++ += lvolsel * sample; + *dest++ -= lvolsel * sample; + } + + return index; +} + + +static SLONG MixSurroundInterp(SWORD *srce, SLONG *dest, SLONG index, SLONG increment, ULONG todo) +{ + SWORD sample; + + for (; todo; todo--) + { + sample = (srce[index >> FRACBITS] * ((FRACMASK+1l) - (index & FRACMASK))) + + (srce[(index >> FRACBITS)+1] * (index & FRACMASK)) >> FRACBITS; + index += increment; + + *dest++ += lvolsel * sample; + *dest++ -= lvolsel * sample; + } + + return index; +} + + +static SLONG MixMonoNormal(SWORD *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo) +{ + SWORD sample; + + for(; todo; todo--) + { + sample = srce[index >> FRACBITS]; + index += increment; + + *dest++ += lvolsel * sample; + } + + return index; +} + + +static SLONG MixMonoInterp(SWORD *srce, SLONG *dest, SLONG index, SLONG increment, SLONG todo) +{ + SWORD sample; + + for(; todo; todo--) + { + sample = (srce[index >> FRACBITS] * ((FRACMASK+1l) - (index & FRACMASK))) + + (srce[(index >> FRACBITS)+1] * (index & FRACMASK)) >> FRACBITS; + index += increment; + + *dest++ += lvolsel * sample; + } + + return index; +} + + +#endif +#endif + +static void (*MixReverb)(SLONG *srce, SLONG count); + +static void MixReverb_Normal(SLONG *srce, SLONG count) +{ + unsigned int speedup; + int ReverbPct; + unsigned int loc1, loc2, loc3, loc4; +#ifndef __FAST_REVERB__ + unsigned int loc5, loc6, loc7, loc8; + + ReverbPct = 58 + (md_reverb*4); +#else + ReverbPct = 89 + (md_reverb*2); +#endif + + loc1 = RVRindex % RVc1; + loc2 = RVRindex % RVc2; + loc3 = RVRindex % RVc3; + loc4 = RVRindex % RVc4; +#ifndef __FAST_REVERB__ + loc5 = RVRindex % RVc5; + loc6 = RVRindex % RVc6; + loc7 = RVRindex % RVc7; + loc8 = RVRindex % RVc8; +#endif + + for(; count; count--) + { + /* Compute the LEFT CHANNEL echo buffers! */ + + speedup = *srce >> 3; + + RVbuf1[loc1] = speedup + ((ReverbPct * RVbuf1[loc1]) / 128); + RVbuf2[loc2] = speedup + ((ReverbPct * RVbuf2[loc2]) / 128); + RVbuf3[loc3] = speedup + ((ReverbPct * RVbuf3[loc3]) / 128); + RVbuf4[loc4] = speedup + ((ReverbPct * RVbuf4[loc4]) / 128); +#ifndef __FAST_REVERB__ + RVbuf5[loc5] = speedup + ((ReverbPct * RVbuf5[loc5]) / 128); + RVbuf6[loc6] = speedup + ((ReverbPct * RVbuf6[loc6]) / 128); + RVbuf7[loc7] = speedup + ((ReverbPct * RVbuf7[loc7]) / 128); + RVbuf8[loc8] = speedup + ((ReverbPct * RVbuf8[loc8]) / 128); +#endif + + /* Prepare to compute actual finalized data! */ + + RVRindex++; + loc1 = RVRindex % RVc1; + loc2 = RVRindex % RVc2; + loc3 = RVRindex % RVc3; + loc4 = RVRindex % RVc4; +#ifndef __FAST_REVERB__ + loc5 = RVRindex % RVc5; + loc6 = RVRindex % RVc6; + loc7 = RVRindex % RVc7; + loc8 = RVRindex % RVc8; +#endif + /* Left Channel! */ + +#ifdef __FAST_REVERB__ + *srce++ += RVbuf1[loc1] - RVbuf2[loc2] + RVbuf3[loc3] - RVbuf4[loc4]; +#else + *srce++ += RVbuf1[loc1] - RVbuf2[loc2] + RVbuf3[loc3] - RVbuf4[loc4] + + RVbuf5[loc5] - RVbuf6[loc6] + RVbuf7[loc7] - RVbuf8[loc8]; +#endif + } +} + + +static void MixReverb_Stereo(SLONG *srce, SLONG count) +{ + unsigned int speedup; + int ReverbPct; + unsigned int loc1, loc2, loc3, loc4; +#ifndef __FAST_REVERB__ + unsigned int loc5, loc6, loc7, loc8; + + ReverbPct = 63 + (md_reverb*4); +#else + ReverbPct = 92 + (md_reverb*2); +#endif + + loc1 = RVRindex % RVc1; + loc2 = RVRindex % RVc2; + loc3 = RVRindex % RVc3; + loc4 = RVRindex % RVc4; +#ifndef __FAST_REVERB__ + loc5 = RVRindex % RVc5; + loc6 = RVRindex % RVc6; + loc7 = RVRindex % RVc7; + loc8 = RVRindex % RVc8; +#endif + + for(; count; count--) + { + /* Compute the LEFT CHANNEL echo buffers! */ + + speedup = *srce >> 3; + + RVbuf1[loc1] = speedup + ((ReverbPct * RVbuf1[loc1]) / 128); + RVbuf2[loc2] = speedup + ((ReverbPct * RVbuf2[loc2]) / 128); + RVbuf3[loc3] = speedup + ((ReverbPct * RVbuf3[loc3]) / 128); + RVbuf4[loc4] = speedup + ((ReverbPct * RVbuf4[loc4]) / 128); +#ifndef __FAST_REVERB__ + RVbuf5[loc5] = speedup + ((ReverbPct * RVbuf5[loc5]) / 128); + RVbuf6[loc6] = speedup + ((ReverbPct * RVbuf6[loc6]) / 128); + RVbuf7[loc7] = speedup + ((ReverbPct * RVbuf7[loc7]) / 128); + RVbuf8[loc8] = speedup + ((ReverbPct * RVbuf8[loc8]) / 128); +#endif + + /* Compute the RIGHT CHANNEL echo buffers! */ + + speedup = srce[1] >> 3; + + RVbuf9[loc1] = speedup + ((ReverbPct * RVbuf9[loc1]) / 128); + RVbuf10[loc2] = speedup + ((ReverbPct * RVbuf11[loc2]) / 128); + RVbuf11[loc3] = speedup + ((ReverbPct * RVbuf12[loc3]) / 128); + RVbuf12[loc4] = speedup + ((ReverbPct * RVbuf12[loc4]) / 128); +#ifndef __FAST_REVERB__ + RVbuf13[loc5] = speedup + ((ReverbPct * RVbuf13[loc5]) / 128); + RVbuf14[loc6] = speedup + ((ReverbPct * RVbuf14[loc6]) / 128); + RVbuf15[loc7] = speedup + ((ReverbPct * RVbuf15[loc7]) / 128); + RVbuf16[loc8] = speedup + ((ReverbPct * RVbuf16[loc8]) / 128); +#endif + + /* Prepare to compute actual finalized data! */ + + RVRindex++; + loc1 = RVRindex % RVc1; + loc2 = RVRindex % RVc2; + loc3 = RVRindex % RVc3; + loc4 = RVRindex % RVc4; +#ifndef __FAST_REVERB__ + loc5 = RVRindex % RVc5; + loc6 = RVRindex % RVc6; + loc7 = RVRindex % RVc7; + loc8 = RVRindex % RVc8; +#endif + +#ifdef __FAST_REVERB__ + /* Left Channel then right channel! */ + *srce++ += RVbuf1[loc1] - RVbuf2[loc2] + RVbuf3[loc3] - RVbuf4[loc4]; + *srce++ += RVbuf9[loc1] - RVbuf10[loc2] + RVbuf11[loc3] - RVbuf12[loc4]; +#else + /* Left Channel then right channel! */ + *srce++ += RVbuf1[loc1] - RVbuf2[loc2] + RVbuf3[loc3] - RVbuf4[loc4] + + RVbuf5[loc5] - RVbuf6[loc6] + RVbuf7[loc7] - RVbuf8[loc8]; + + *srce++ += RVbuf9[loc1] - RVbuf10[loc2] + RVbuf11[loc3] - RVbuf12[loc4] + + RVbuf13[loc5] - RVbuf14[loc6] + RVbuf15[loc7] - RVbuf16[loc8]; +#endif + } +} + + +static void Mix32To16(SWORD *dste, SLONG *srce, SLONG count) +{ + SLONG x1, x2, x3, x4; + int remain; + + remain = count & 3; + + for(count>>=2; count; count--) + { x1 = *srce++ >> BITSHIFT; + x2 = *srce++ >> BITSHIFT; + x3 = *srce++ >> BITSHIFT; + x4 = *srce++ >> BITSHIFT; + +#ifdef BOUNDS_CHECKING + x1 = (x1 > 32767) ? 32767 : (x1 < -32768) ? -32768 : x1; + x2 = (x2 > 32767) ? 32767 : (x2 < -32768) ? -32768 : x2; + x3 = (x3 > 32767) ? 32767 : (x3 < -32768) ? -32768 : x3; + x4 = (x4 > 32767) ? 32767 : (x4 < -32768) ? -32768 : x4; +#endif + + *dste++ = x1; + *dste++ = x2; + *dste++ = x3; + *dste++ = x4; + } + + for(; remain; remain--) + { x1 = *srce++ >> BITSHIFT; +#ifdef BOUNDS_CHECKING + x1 = (x1 > 32767) ? 32767 : (x1 < -32768) ? -32768 : x1; +#endif + *dste++ = x1; + } +} + + +static void Mix32To8(SBYTE *dste, SLONG *srce, SLONG count) +{ + int x1, x2, x3, x4; + int remain; + + remain = count & 3; + + for(count>>=2; count; count--) + { x1 = *srce++ >> (BITSHIFT + 8); + x2 = *srce++ >> (BITSHIFT + 8); + x3 = *srce++ >> (BITSHIFT + 8); + x4 = *srce++ >> (BITSHIFT + 8); + +#ifdef BOUNDS_CHECKING + x1 = (x1 > 127) ? 127 : (x1 < -128) ? -128 : x1; + x2 = (x2 > 127) ? 127 : (x2 < -128) ? -128 : x2; + x3 = (x3 > 127) ? 127 : (x3 < -128) ? -128 : x3; + x4 = (x4 > 127) ? 127 : (x4 < -128) ? -128 : x4; +#endif + + *dste++ = x1 + 128; + *dste++ = x2 + 128; + *dste++ = x3 + 128; + *dste++ = x4 + 128; + } + + for(; remain; remain--) + { x1 = *srce++ >> (BITSHIFT + 8); +#ifdef BOUNDS_CHECKING + x1 = (x1 > 127) ? 127 : (x1 < -128) ? -128 : x1; +#endif + *dste++ = x1 + 128; + } +} + + +static ULONG samples2bytes(ULONG samples) +{ + if(vc_mode & DMODE_16BITS) samples <<= 1; + if(vc_mode & DMODE_STEREO) samples <<= 1; + return samples; +} + + +static ULONG bytes2samples(ULONG bytes) +{ + if(vc_mode & DMODE_16BITS) bytes >>= 1; + if(vc_mode & DMODE_STEREO) bytes >>= 1; + return bytes; +} + + +static void AddChannel(SLONG *ptr, SLONG todo) +{ + SLONG end, done; +#ifdef __FASTMIXER__ + SBYTE *s; +#else + SWORD *s; +#endif + + if((s=Samples[vnf->handle]) == NULL) + { vnf->current = 0; + vnf->active = 0; + return; + } + + while(todo > 0) + { /* update the 'current' index so the sample loops, or + // stops playing if it reached the end of the sample + */ + + if(vnf->flags & SF_REVERSE) + { + /* The sample is playing in reverse */ + + if((vnf->flags & SF_LOOP) && (vnf->current < idxlpos)) + { + /* the sample is looping, and it has + // reached the loopstart index + */ + + if(vnf->flags & SF_BIDI) + { + /* sample is doing bidirectional loops, so 'bounce' + // the current index against the idxlpos + */ + + vnf->current = idxlpos + (idxlpos - vnf->current); + vnf->flags &= ~SF_REVERSE; + vnf->increment = -vnf->increment; + } else + /* normal backwards looping, so set the + // current position to loopend index + */ + + vnf->current = idxlend - (idxlpos-vnf->current); + } else + { + /* the sample is not looping, so check if it reached index 0 */ + + if(vnf->current < 0) + { + /* playing index reached 0, so stop playing this sample */ + + vnf->current = 0; + vnf->active = 0; + break; + } + } + } else + { + /* The sample is playing forward */ + + if((vnf->flags & SF_LOOP) && (vnf->current > idxlend)) + { + /* the sample is looping, so check if + // it reached the loopend index + */ + + if(vnf->flags & SF_BIDI) + { + /* sample is doing bidirectional loops, so 'bounce' + // the current index against the idxlend + */ + + vnf->flags |= SF_REVERSE; + vnf->increment = -vnf->increment; + vnf->current = idxlend - (vnf->current-idxlend); + } else + /* normal backwards looping, so set the + // current position to loopend index + */ + + vnf->current = idxlpos + (vnf->current-idxlend); + } else + { + /* sample is not looping, so check + // if it reached the last position + */ + + if(vnf->current > idxsize) + { + /* yes, so stop playing this sample */ + + vnf->current = 0; + vnf->active = 0; + break; + } + } + } + + end = (vnf->flags & SF_REVERSE) ? + (vnf->flags & SF_LOOP) ? idxlpos : 0 : + (vnf->flags & SF_LOOP) ? idxlend : idxsize; + + done = MIN((end - vnf->current) / vnf->increment + 1, todo); + + if(!done) + { vnf->active = 0; + break; + } + + if(vnf->vol) + { +#ifdef __ASSEMBLY__ + if(md_mode & DMODE_INTERP) + { if(vc_mode & DMODE_STEREO) + if((vnf->pan == PAN_SURROUND) && (vc_mode & DMODE_SURROUND)) + AsmSurroundInterp(s,ptr,vnf->current,vnf->increment,done); + else + AsmStereoInterp(s,ptr,vnf->current,vnf->increment,done); + else + AsmMonoInterp(s,ptr,vnf->current,vnf->increment,done); + } else if(vc_mode & DMODE_STEREO) + if((vnf->pan == PAN_SURROUND) && (vc_mode & DMODE_SURROUND)) + AsmSurroundNormal(s,ptr,vnf->current,vnf->increment,done); + else + AsmStereoNormal(s,ptr,vnf->current,vnf->increment,done); + else + AsmMonoNormal(s,ptr,vnf->current,vnf->increment,done); + + vnf->current += (vnf->increment*done); +#else + if((md_mode & DMODE_INTERP)) + { if(vc_mode & DMODE_STEREO) + if((vnf->pan == PAN_SURROUND) && (vc_mode & DMODE_SURROUND)) + vnf->current = MixSurroundInterp(s,ptr,vnf->current,vnf->increment,done); + else + vnf->current = MixStereoInterp(s,ptr,vnf->current,vnf->increment,done); + else + vnf->current = MixMonoInterp(s,ptr,vnf->current,vnf->increment,done); + } else if(vc_mode & DMODE_STEREO) + if((vnf->pan == PAN_SURROUND) && (vc_mode & DMODE_SURROUND)) + vnf->current = MixSurroundNormal(s,ptr,vnf->current,vnf->increment,done); + else + vnf->current = MixStereoNormal(s,ptr,vnf->current,vnf->increment,done); + else + vnf->current = MixMonoNormal(s,ptr,vnf->current,vnf->increment,done); +#endif + } + + todo -= done; + ptr += (vc_mode & DMODE_STEREO) ? (done<<1) : done; + } + +} + + +void VC_WriteSamples(SBYTE *buf, ULONG todo) +{ + int left, portion = 0, count; + SBYTE *buffer; + int t; + int pan, vol; + + while(todo) + { if(TICKLEFT==0) + { if(vc_mode & DMODE_SOFT_MUSIC) md_player(); + TICKLEFT = (md_mixfreq * 125l) / (md_bpm * 50L); + } + + left = MIN(TICKLEFT, todo); + + buffer = buf; + TICKLEFT -= left; + todo -= left; + + buf += samples2bytes(left); + + while(left) + { portion = MIN(left, samplesthatfit); + count = (vc_mode & DMODE_STEREO) ? (portion<<1) : portion; + + memset(VC_TICKBUF, 0, count<<2); + + for(t=0; tkick) + { vnf->current = vnf->start << FRACBITS; + vnf->kick = 0; + vnf->active = 1; + } + + if((vnf->frq == 0) || (vnf->size == 0)) vnf->active = 0; + + if(vnf->active) + { vnf->increment = (vnf->frq << FRACBITS) / md_mixfreq; + if(vnf->flags & SF_REVERSE) vnf->increment =- vnf->increment; + vol = vnf->vol; pan = vnf->pan; + + if(vc_mode & DMODE_STEREO) + { if(pan != PAN_SURROUND) + { +#ifdef __FASTMIXER__ + lvoltab = voltab[(vol * (255-pan)) / 1024]; + rvoltab = voltab[(vol * pan) / 1024]; +#else + lvolsel = (vol * (255-pan)) >> 8; + rvolsel = (vol * pan) >> 8; +#endif + } else + { +#ifdef __FASTMIXER__ + lvoltab = voltab[(vol+1)>>3]; +#else + lvolsel = vol/2; +#endif + } + } else + { +#ifdef __FASTMIXER__ + lvoltab = voltab[vol>>2]; +#else + lvolsel = vol; +#endif + } + + idxsize = (vnf->size) ? (vnf->size << FRACBITS)-1 : 0; + idxlend = (vnf->repend) ? (vnf->repend << FRACBITS)-1 : 0; + idxlpos = vnf->reppos << FRACBITS; + AddChannel(VC_TICKBUF, portion); + } + } + + if(md_reverb) MixReverb(VC_TICKBUF, portion); + + if(vc_mode & DMODE_16BITS) + Mix32To16((SWORD *) buffer, VC_TICKBUF, count); + else + Mix32To8((SBYTE *) buffer, VC_TICKBUF, count); + + buffer += samples2bytes(portion); + left -= portion; + } + } +} + + +void VC_SilenceBytes(SBYTE *buf, ULONG todo) + +/* Fill the buffer with 'todo' bytes of silence (it depends on the mixing +// mode how the buffer is filled) +*/ + +{ + /* clear the buffer to zero (16 bits signed) or 0x80 (8 bits unsigned) */ + + if(vc_mode & DMODE_16BITS) + memset(buf,0,todo); + else + memset(buf,0x80,todo); +} + + +ULONG VC_WriteBytes(SBYTE *buf, ULONG todo) + +/* Writes 'todo' mixed SBYTES (!!) to 'buf'. It returns the number of +// SBYTES actually written to 'buf' (which is rounded to number of samples +// that fit into 'todo' bytes). +*/ + +{ + if(vc_softchn == 0) + { VC_SilenceBytes(buf,todo); + return todo; + } + + todo = bytes2samples(todo); + VC_WriteSamples(buf,todo); + + return samples2bytes(todo); +} + + +BOOL VC_Init(void) +{ + +#ifdef __FASTMIXER__ + int t; + + _mm_errno = MMERR_INITIALIZING_MIXER; + if((voltab = (SLONG **)calloc(65,sizeof(SLONG *))) == NULL) return 1; + for(t=0; t<65; t++) + if((voltab[t] = (SLONG *)calloc(256,sizeof(SLONG))) == NULL) return 1; + + if((Samples = (SBYTE **)calloc(MAXSAMPLEHANDLES, sizeof(SBYTE *))) == NULL) return 1; +#else + _mm_errno = MMERR_INITIALIZING_MIXER; + if((Samples = (SWORD **)calloc(MAXSAMPLEHANDLES, sizeof(SWORD *))) == NULL) return 1; +#endif + + if(VC_TICKBUF==NULL) if((VC_TICKBUF=(SLONG *)malloc((TICKLSIZE+32) * sizeof(SLONG))) == NULL) return 1; + + MixReverb = (md_mode & DMODE_STEREO) ? MixReverb_Stereo : MixReverb_Normal; + + vc_mode = md_mode; + + _mm_errno = 0; + return 0; +} + + +void VC_Exit(void) +{ +#ifdef __FASTMIXER__ + int t; + if(voltab!=NULL) + { for(t=0; t<65; t++) if(voltab[t]!=NULL) free(voltab[t]); + free(voltab); voltab = NULL; + } +#endif + + if(vinf!=NULL) free(vinf); + if(Samples!=NULL) free(Samples); + + vinf = NULL; + Samples = NULL; +} + + +BOOL VC_PlayStart(void) +{ + int numchn; + + numchn = md_softchn; +#ifdef __FASTMIXER__ + if(numchn > 0) + { + int c, t; + SLONG volmul; + + for(t=0; t<65; t++) + { volmul = (65536l*t) / 64; + for(c=-128; c<128; c++) + voltab[t][(UBYTE)c] = (SLONG)c*volmul; + } + } +#endif + + samplesthatfit = TICKLSIZE; + if(vc_mode & DMODE_STEREO) samplesthatfit >>= 1; + TICKLEFT = 0; + +#ifdef __FAST_REVERB__ + RVc1 = (5000L * md_mixfreq) / (REVERBERATION * 2); + RVc2 = (5946L * md_mixfreq) / (REVERBERATION * 2); + RVc3 = (7071L * md_mixfreq) / (REVERBERATION * 2); + RVc4 = (8409L * md_mixfreq) / (REVERBERATION * 2); +#else + RVc1 = (5000L * md_mixfreq) / REVERBERATION; + RVc2 = (5078L * md_mixfreq) / REVERBERATION; + RVc3 = (5313L * md_mixfreq) / REVERBERATION; + RVc4 = (5703L * md_mixfreq) / REVERBERATION; + RVc5 = (6250L * md_mixfreq) / REVERBERATION; + RVc6 = (6953L * md_mixfreq) / REVERBERATION; + RVc7 = (7813L * md_mixfreq) / REVERBERATION; + RVc8 = (8828L * md_mixfreq) / REVERBERATION; +#endif + + if((RVbuf1 = (SLONG *)_mm_calloc((RVc1+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf2 = (SLONG *)_mm_calloc((RVc2+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf3 = (SLONG *)_mm_calloc((RVc3+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf4 = (SLONG *)_mm_calloc((RVc4+1),sizeof(SLONG))) == NULL) return 1; +#ifndef __FAST_REVERB__ + if((RVbuf5 = (SLONG *)_mm_calloc((RVc5+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf6 = (SLONG *)_mm_calloc((RVc6+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf7 = (SLONG *)_mm_calloc((RVc7+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf8 = (SLONG *)_mm_calloc((RVc8+1),sizeof(SLONG))) == NULL) return 1; +#endif + + if((RVbuf9 = (SLONG *)_mm_calloc((RVc1+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf10 = (SLONG *)_mm_calloc((RVc2+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf11 = (SLONG *)_mm_calloc((RVc3+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf12 = (SLONG *)_mm_calloc((RVc4+1),sizeof(SLONG))) == NULL) return 1; +#ifndef __FAST_REVERB__ + if((RVbuf13 = (SLONG *)_mm_calloc((RVc5+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf14 = (SLONG *)_mm_calloc((RVc6+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf15 = (SLONG *)_mm_calloc((RVc7+1),sizeof(SLONG))) == NULL) return 1; + if((RVbuf16 = (SLONG *)_mm_calloc((RVc8+1),sizeof(SLONG))) == NULL) return 1; +#endif + + RVRindex = 0; + + return 0; +} + + +void VC_PlayStop(void) +{ + if(RVbuf1 != NULL) free(RVbuf1); + if(RVbuf2 != NULL) free(RVbuf2); + if(RVbuf3 != NULL) free(RVbuf3); + if(RVbuf4 != NULL) free(RVbuf4); + if(RVbuf9 != NULL) free(RVbuf9); + if(RVbuf10 != NULL) free(RVbuf10); + if(RVbuf11 != NULL) free(RVbuf11); + if(RVbuf12 != NULL) free(RVbuf12); + + RVbuf1 = RVbuf2 = RVbuf3 = RVbuf4 = NULL; + RVbuf9 = RVbuf10 = RVbuf11 = RVbuf12 = NULL; + +#ifndef __FAST_REVERB__ + if(RVbuf5 != NULL) free(RVbuf5); + if(RVbuf6 != NULL) free(RVbuf6); + if(RVbuf7 != NULL) free(RVbuf7); + if(RVbuf8 != NULL) free(RVbuf8); + if(RVbuf13 != NULL) free(RVbuf13); + if(RVbuf14 != NULL) free(RVbuf14); + if(RVbuf15 != NULL) free(RVbuf15); + if(RVbuf16 != NULL) free(RVbuf16); + + RVbuf13 = RVbuf14 = RVbuf15 = RVbuf16 = NULL; + RVbuf5 = RVbuf6 = RVbuf7 = RVbuf8 = NULL; +#endif + +} + + +BOOL VC_SetNumVoices(void) +{ + int t; + + if((vc_softchn = md_softchn) == 0) return 0; + + if(vinf!=NULL) free(vinf); + if((vinf = _mm_calloc(sizeof(VINFO),vc_softchn)) == NULL) return 1; + + for(t=0; t> FRACBITS); +} + + +/************************************************** +*************************************************** +*************************************************** +**************************************************/ + + +void VC_SampleUnload(SWORD handle) +{ + free(Samples[handle]); + Samples[handle] = NULL; +} + + +SWORD VC_SampleLoad(SAMPLOAD *sload, int type) +{ + SAMPLE *s = sload->sample; + int handle; + ULONG t, length,loopstart,loopend; + + if(type==MD_HARDWARE) return -1; + + /* Find empty slot to put sample address in */ + + for(handle=0; handlelength; + loopstart = s->loopstart; + loopend = s->loopend; + + SL_SampleSigned(sload); + +#ifdef __FASTMIXER__ + SL_Sample16to8(sload); + if((Samples[handle]=(SBYTE *)malloc(length+20))==NULL) + { _mm_errno = MMERR_SAMPLE_TOO_BIG; + return -1; + } + + /* read sample into buffer. */ + SL_Load(Samples[handle],sload,length); +#else + SL_Sample8to16(sload); + if((Samples[handle]=(SWORD *)malloc((length+20)<<1))==NULL) + { _mm_errno = MMERR_SAMPLE_TOO_BIG; + return -1; + } + + /* read sample into buffer. */ + SL_Load(Samples[handle],sload,length); +#endif + + + /* Unclick samples: */ + + if(s->flags & SF_LOOP) + { if(s->flags & SF_BIDI) + for(t=0; t<16; t++) Samples[handle][loopend+t] = Samples[handle][(loopend-t)-1]; + else + for(t=0; t<16; t++) Samples[handle][loopend+t] = Samples[handle][t+loopstart]; + } else + for(t=0; t<16; t++) Samples[handle][t+length] = 0; + + return handle; +} + + +ULONG VC_SampleSpace(int type) +{ + return vc_memory; +} + + +ULONG VC_SampleLength(int type, SAMPLE *s) +{ +#ifdef __FASTMIXER__ + return s->length + 16; +#else + return (s->length * ((s->flags&SF_16BITS) ? 2 : 1)) + 16; +#endif +} + + +/************************************************** +*************************************************** +*************************************************** +**************************************************/ + + +ULONG VC_VoiceRealVolume(UBYTE voice) +{ + ULONG i,s,size; + int k,j; +#ifdef __FASTMIXER__ + SBYTE *smp; +#else + SWORD *smp; +#endif + SLONG t; + + t = vinf[voice].current>>FRACBITS; + if(vinf[voice].active==0) return 0; + + s = vinf[voice].handle; + size = vinf[voice].size; + + i=64; t-=64; k=0; j=0; + if(i>size) i = size; + if(t<0) t = 0; + if(t+i > size) t = size-i; + + i &= ~1; /* make sure it's EVEN. */ + + smp = &Samples[s][t]; + for(; i; i--, smp++) + { if(k<*smp) k = *smp; + if(j>*smp) j = *smp; + } + +#ifdef __FASTMIXER__ + k = abs(k-j)<<8; +#else + k = abs(k-j); +#endif + + return k; +} + diff --git a/missing b/missing new file mode 100644 index 00000000..7789652e --- /dev/null +++ b/missing @@ -0,0 +1,190 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. +# Copyright (C) 1996, 1997 Free Software Foundation, Inc. +# Franc,ois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +case "$1" in + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + yacc create \`y.tab.[ch]', if possible, from existing .[ch]" + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing - GNU libit 0.0" + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + + aclocal) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acinclude.m4' or \`configure.in'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`configure.in'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`acconfig.h' or \`configure.in'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is missing on your system. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` + fi + touch $file + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and you do not seem to have it handy on your + system. You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequirements for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 diff --git a/mixer.c b/mixer.c new file mode 100644 index 00000000..05064b5d --- /dev/null +++ b/mixer.c @@ -0,0 +1,468 @@ +/* + MIXERLIB: An audio mixer library based on the SDL library + Copyright (C) 1997-1999 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +#include +#include +#include + +#include +#include + +#include "mixer.h" + +static int audio_opened = 0; + +static SDL_AudioSpec mixer; +static SDL_mutex *mixer_lock; +static struct _Mix_Channel { + Mix_Chunk *chunk; + int playing; + int paused; + Uint8 *samples; + int volume; + int looping; +} channel[MIX_CHANNELS]; + +#define MUSIC_VOL 64 /* Music volume 0-64 */ + +/* Support for user defined music functions, plus the default one */ +extern int music_active; +extern void music_mixer(void *udata, Uint8 *stream, int len); +static void (*mix_music)(void *udata, Uint8 *stream, int len) = music_mixer; +static int num_channels; /* Holds the number of channels actually mixed, for debugging */ +static int reserved_channels = 0; +void *music_data = NULL; + +/* Mixing function */ +static void mix_channels(void *udata, Uint8 *stream, int len) +{ + int i, mixable, volume; + + /* Grab the channels we need to mix */ + SDL_mutexP(mixer_lock); + num_channels = 0; + for ( i=0; i len ) { + mixable = len; + } + volume = (channel[i].volume*channel[i].chunk->volume) / + MIX_MAX_VOLUME; + SDL_MixAudio(stream,channel[i].samples,mixable,volume); + channel[i].samples += mixable; + channel[i].playing -= mixable; + if ( ! channel[i].playing && channel[i].looping ) { + if ( --channel[i].looping ) { + channel[i].samples = channel[i].chunk->abuf; + channel[i].playing = channel[i].chunk->alen; + } + } + } + } + SDL_mutexV(mixer_lock); + + /* Mix the music */ + if ( music_active ) { + mix_music(music_data, stream, len); + } +} + +static void PrintFormat(char *title, SDL_AudioSpec *fmt) +{ + printf("%s: %d bit %s audio (%s) at %u Hz\n", title, (fmt->format&0xFF), + (fmt->format&0x8000) ? "signed" : "unsigned", + (fmt->channels > 1) ? "stereo" : "mono", fmt->freq); +} + +/* Open the mixer with a certain desired audio format */ +int Mix_OpenAudio(int frequency, Uint16 format, int channels, int chunksize) +{ + int i; + SDL_AudioSpec desired; + + /* If the mixer is already opened, increment open count */ + if ( audio_opened ) { + ++audio_opened; + return(0); + } + + /* Set the desired format and frequency */ + desired.freq = frequency; + desired.format = format; + desired.channels = channels; + desired.samples = chunksize; + desired.callback = mix_channels; + desired.userdata = NULL; + + /* Accept nearly any audio format */ + if ( SDL_OpenAudio(&desired, &mixer) < 0 ) { + return(-1); + } +#if 0 + PrintFormat("Audio device", &mixer); +#endif + + /* Create the channel lock mutex */ + mixer_lock = SDL_CreateMutex(); + if ( mixer_lock == NULL ) { + SDL_CloseAudio(); + SDL_SetError("Unable to create mixer lock"); + return(-1); + } + + /* Initialize the music players */ + if ( open_music(&mixer) < 0 ) { + SDL_CloseAudio(); + SDL_DestroyMutex(mixer_lock); + return(-1); + } + + /* Clear out the audio channels */ + for ( i=0; iabuf, &chunk->alen) == NULL ) { + free(chunk); + return(NULL); + } +#if 0 + PrintFormat("Audio device", &mixer); + PrintFormat("-- Wave file", &wavespec); +#endif + + /* Build the audio converter and create conversion buffers */ + if ( SDL_BuildAudioCVT(&wavecvt, + wavespec.format, wavespec.channels, wavespec.freq, + mixer.format, mixer.channels, mixer.freq) < 0 ) { + SDL_FreeWAV(chunk->abuf); + free(chunk); + return(NULL); + } + wavecvt.len = chunk->alen; + wavecvt.buf = (Uint8 *)malloc(wavecvt.len*wavecvt.len_mult); + if ( wavecvt.buf == NULL ) { + SDL_SetError("Out of memory"); + SDL_FreeWAV(chunk->abuf); + free(chunk); + return(NULL); + } + memcpy(wavecvt.buf, chunk->abuf, chunk->alen); + SDL_FreeWAV(chunk->abuf); + + /* Run the audio converter */ + if ( SDL_ConvertAudio(&wavecvt) < 0 ) { + free(wavecvt.buf); + free(chunk); + return(NULL); + } + chunk->abuf = wavecvt.buf; + chunk->alen = wavecvt.len_cvt; + chunk->volume = MIX_MAX_VOLUME; + return(chunk); +} + +/* Free an audio chunk previously loaded */ +void Mix_FreeChunk(Mix_Chunk *chunk) +{ + int i; + + /* Caution -- if the chunk is playing, the mixer will crash */ + if ( chunk ) { + /* Guarantee that this chunk isn't playing */ + SDL_mutexP(mixer_lock); + for ( i=0; iabuf); + free(chunk); + } +} + +/* Add your own music player or mixer function. + If 'mix_func' is NULL, the default music player is re-enabled. + */ +void Mix_HookMusic(void (*mix_func)(void *udata, Uint8 *stream, int len), + void *arg) +{ + SDL_LockAudio(); + if ( mix_func != NULL ) { + music_data = arg; + mix_music = mix_func; + } else { + music_data = NULL; + mix_music = music_mixer; + } + SDL_UnlockAudio(); +} + +void *Mix_GetMusicHookData(void) +{ + return(music_data); +} + +/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + them dynamically to the next sample if requested with a -1 value below. + Returns the number of reserved channels. + */ +int Mix_ReserveChannels(int num) +{ + if (num > MIX_CHANNELS) + num = MIX_CHANNELS; + reserved_channels = num; + return num; +} + +/* Play an audio chunk on a specific channel. + If the specified channel is -1, play on the first free channel. + Returns which channel was used to play the sound. +*/ +int Mix_PlayChannel(int which, Mix_Chunk *chunk, int loops) +{ + int i; + + /* Don't play null pointers :-) */ + if ( chunk == NULL ) { + return(-1); + } + + /* Lock the mixer while modifying the playing channels */ + SDL_mutexP(mixer_lock); + { + /* If which is -1, play on the first free channel */ + if ( which == -1 ) { + for ( i=reserved_channels; i= 0 ) { + channel[which].samples = chunk->abuf; + channel[which].playing = chunk->alen; + channel[which].looping = loops; + channel[which].chunk = chunk; + channel[which].paused = 0; + } + } + SDL_mutexV(mixer_lock); + + /* Return the channel on which the sound is being played */ + return(which); +} + +/* Set volume of a particular channel */ +int Mix_Volume(int which, int volume) +{ + int i; + int prev_volume; + + if ( which == -1 ) { + prev_volume = 0; + for ( i=0; i= 0 ) { + if ( volume > SDL_MIX_MAXVOLUME ) { + volume = SDL_MIX_MAXVOLUME; + } + channel[which].volume = volume; + } + } + return(prev_volume); +} +/* Set volume of a particular chunk */ +int Mix_VolumeChunk(Mix_Chunk *chunk, int volume) +{ + int prev_volume; + + prev_volume = chunk->volume; + if ( volume >= 0 ) { + if ( volume > MIX_MAX_VOLUME ) { + volume = MIX_MAX_VOLUME; + } + chunk->volume = volume; + } + return(prev_volume); +} + +/* Halt playing of a particular channel */ +int Mix_HaltChannel(int which) +{ + int i; + + if ( which == -1 ) { + for ( i=0; i 0 ) { + ++status; + } + } + } else { + if ( channel[which].playing > 0 ) { + ++status; + } + } + return(status); +} + +/* Close the mixer, halting all playing audio */ +void Mix_CloseAudio(void) +{ + if ( audio_opened ) { + if ( audio_opened == 1 ) { + close_music(); + Mix_HaltChannel(-1); + SDL_CloseAudio(); + SDL_DestroyMutex(mixer_lock); + } + --audio_opened; + } +} + +/* Pause a particular channel (or all) */ +void Mix_Pause(int which) +{ + if ( which == -1 ) { + int i; + + for ( i=0; i 0 ) { + channel[i].paused = 1; + } + } + } else { + if ( channel[which].playing > 0 ) { + channel[which].paused = 1; + } + } +} + +/* Resume a paused channel */ +void Mix_Resume(int which) +{ + if ( which == -1 ) { + int i; + + for ( i=0; i 0 ) { + channel[i].paused = 0; + } + } + } else { + if ( channel[which].playing > 0 ) { + channel[which].paused = 0; + } + } +} diff --git a/mixer.h b/mixer.h new file mode 100644 index 00000000..afca557c --- /dev/null +++ b/mixer.h @@ -0,0 +1,137 @@ +/* + MIXERLIB: An audio mixer library based on the SDL library + Copyright (C) 1997-1999 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +#ifndef _MIXER_H_ +#define _MIXER_H_ + +#include +#include +#include + +#include + +/* The default mixer has 8 simultaneous mixing channels */ +#ifndef MIX_CHANNELS +#define MIX_CHANNELS 8 +#endif + +/* Good default values for a PC soundcard */ +#define MIX_DEFAULT_FREQUENCY 22050 +#define MIX_DEFAULT_FORMAT AUDIO_S16 +#define MIX_DEFAULT_CHANNELS 2 +#define MIX_MAX_VOLUME 128 /* Volume of a chunk */ + +/* The internal format for an audio chunk */ +typedef struct { + Uint8 *abuf; + Uint32 alen; + Uint8 volume; /* Per-sample volume, 0-128 */ +} Mix_Chunk; + +/* The internal format for a music chunk interpreted via mikmod */ +typedef struct _Mix_Music Mix_Music; + +/* Open the mixer with a certain audio format */ +extern int Mix_OpenAudio(int frequency, Uint16 format, int channels, + int chunksize); + +/* Find out what the actual audio device parameters are. + This function returns 1 if the audio has been opened, 0 otherwise. + */ +extern int Mix_QuerySpec(int *frequency, Uint16 *format, int *channels); + +/* Load a wave file or a MOD (.mod .s3m .it .xm) file */ +extern Mix_Chunk *Mix_LoadWAV_RW(SDL_RWops *src, int freesrc); +#define Mix_LoadWAV(file) Mix_LoadWAV_RW(SDL_RWFromFile(file, "rb"), 1) +extern Mix_Music *Mix_LoadMUS(const char *file); + +/* Free an audio chunk previously loaded */ +extern void Mix_FreeChunk(Mix_Chunk *chunk); +extern void Mix_FreeMusic(Mix_Music *music); + +/* Add your own music player or additional mixer function. + If 'mix_func' is NULL, the default music player is re-enabled. + */ +extern void Mix_HookMusic(void (*mix_func)(void *udata, Uint8 *stream, int len), + void *arg); + +/* Get a pointer to the user data for the current music hook */ +extern void *Mix_GetMusicHookData(void); + +/* Reserve the first channels (0 -> n-1) for the application, i.e. don't allocate + them dynamically to the next sample if requested with a -1 value below. + Returns the number of reserved channels. + */ +extern int Mix_ReserveChannels(int num); + +/* Play an audio chunk on a specific channel. + If the specified channel is -1, play on the first free channel. + If 'loops' is greater than zero, loop the sound that many times. + If 'loops' is -1, loop inifinitely (~65000 times). + Returns which channel was used to play the sound. +*/ +extern int Mix_PlayChannel(int channel, Mix_Chunk *chunk, int loops); +extern int Mix_PlayMusic(Mix_Music *music, int loops); + +/* Set the volume in the range of 0-128 of a specific channel or chunk. + If the specified channel is -1, set volume for all channels. + Returns the original volume. + If the specified volume is -1, just return the current volume. +*/ +extern int Mix_Volume(int channel, int volume); +extern int Mix_VolumeChunk(Mix_Chunk *chunk, int volume); +extern int Mix_VolumeMusic(int volume); + +/* Halt playing of a particular channel */ +extern int Mix_HaltChannel(int channel); +extern int Mix_HaltMusic(void); + +/* Pause/Resume a particular channel */ +extern void Mix_Pause(int channel); +extern void Mix_Resume(int channel); + +/* Pause/Resume the music stream */ +extern void Mix_PauseMusic(void); +extern void Mix_ResumeMusic(void); +extern void Mix_RewindMusic(void); + +/* Check the status of a specific channel. + If the specified channel is -1, check all channels. +*/ +extern int Mix_Playing(int channel); +extern int Mix_PlayingMusic(void); + +/* Stop music and set external music playback command */ +extern int Mix_SetMusicCMD(const char *command); + +/* Close the mixer, halting all playing audio */ +extern void Mix_CloseAudio(void); + +/* We'll use SDL for reporting errors */ +#define Mix_SetError SDL_SetError +#define Mix_GetError SDL_GetError + +#include + +#endif /* _MIXER_H_ */ diff --git a/mkinstalldirs b/mkinstalldirs new file mode 100644 index 00000000..6b3b5fc5 --- /dev/null +++ b/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id$ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/music.c b/music.c new file mode 100644 index 00000000..ed0fd28e --- /dev/null +++ b/music.c @@ -0,0 +1,639 @@ +/* + MIXERLIB: An audio mixer library based on the SDL library + Copyright (C) 1997-1999 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +#include +#include + +#include "mixer.h" + +/* The music command hack is UNIX specific */ +#ifndef unix +#undef CMD_MUSIC +#endif + +#ifdef CMD_MUSIC +#include "music_cmd.h" +#endif +#ifdef WAV_MUSIC +#include "wavestream.h" +#endif +#ifdef MOD_MUSIC +#include "mikmod.h" +#endif +#ifdef MID_MUSIC +#include "timidity.h" +#endif +#ifdef MP3_MUSIC +#include + +static SDL_AudioSpec used_mixer; +#endif + +int music_active = 1; +static int music_loops = 0; +static char *music_cmd = NULL; +static int samplesize; +static Mix_Music *music_playing = 0; +static int music_volume; +static int music_swap8; +static int music_swap16; +struct _Mix_Music { + enum { + MUS_CMD, + MUS_WAV, + MUS_MOD, + MUS_MID, + MUS_MP3 + } type; + union { +#ifdef CMD_MUSIC + MusicCMD *cmd; +#endif +#ifdef WAV_MUSIC + WAVStream *wave; +#endif +#ifdef MOD_MUSIC + UNIMOD *module; +#endif +#ifdef MID_MUSIC + MidiSong *midi; +#endif +#ifdef MP3_MUSIC + SMPEG *mp3; +#endif + } data; + int error; +}; +static int timidity_ok; + +/* Mixing function */ +void music_mixer(void *udata, Uint8 *stream, int len) +{ + int i; + + if ( music_playing ) { + switch (music_playing->type) { +#ifdef CMD_MUSIC + case MUS_CMD: + /* The playing is done externally */ + break; +#endif +#ifdef WAV_MUSIC + case MUS_WAV: + WAVStream_PlaySome(stream, len); + break; +#endif +#ifdef MOD_MUSIC + case MUS_MOD: + VC_WriteBytes((SBYTE *)stream, len); + if ( music_swap8 ) { + Uint8 *dst; + + dst = stream; + for ( i=len; i; --i ) { + *dst++ ^= 0x80; + } + } else + if ( music_swap16 ) { + Uint8 *dst, tmp; + + dst = stream; + for ( i=(len/2); i; --i ) { + tmp = dst[0]; + dst[0] = dst[1]; + dst[1] = tmp; + dst += 2; + } + } + break; +#endif +#ifdef MID_MUSIC + case MUS_MID: + Timidity_PlaySome(stream, len/samplesize); + break; +#endif +#ifdef MP3_MUSIC + case MUS_MP3: + SMPEG_playAudio(music_playing->data.mp3, stream, len); + break; +#endif + default: + /* Unknown music type?? */ + break; + } + } +} + +/* Initialize the music players with a certain desired audio format */ +int open_music(SDL_AudioSpec *mixer) +{ + int music_error; + + music_error = 0; +#ifdef WAV_MUSIC + if ( WAVStream_Init(mixer) < 0 ) { + ++music_error; + } +#endif +#ifdef MOD_MUSIC + /* Set the MikMod music format */ + music_swap8 = 0; + music_swap16 = 0; + switch (mixer->format) { + + case AUDIO_U8: + case AUDIO_S8: { + if ( mixer->format == AUDIO_S8 ) { + music_swap8 = 1; + } + md_mode = 0; + } + break; + + case AUDIO_S16LSB: + case AUDIO_S16MSB: { + /* See if we need to correct MikMod mixing */ +#if SDL_BYTEORDER == SDL_LIL_ENDIAN + if ( mixer->format == AUDIO_S16MSB ) { +#else + if ( mixer->format == AUDIO_S16LSB ) { +#endif + music_swap16 = 1; + } + md_mode = DMODE_16BITS; + } + break; + + default: { + SDL_SetError("Unknown hardware audio format"); + ++music_error; + } + } + if ( mixer->channels > 1 ) { + if ( mixer->channels > 2 ) { + SDL_SetError("Hardware uses more channels than mixer"); + ++music_error; + } + md_mode |= DMODE_STEREO; + } + samplesize = mixer->size/mixer->samples; + md_mixfreq = mixer->freq; + md_device = 0; + md_volume = 96; + md_musicvolume = 128; + md_sndfxvolume = 128; + md_pansep = 128; + md_reverb = 0; + MikMod_RegisterAllLoaders(); + MikMod_RegisterAllDrivers(); + if ( MikMod_Init() ) { + SDL_SetError("%s", _mm_errmsg[_mm_errno]); + ++music_error; + } +#endif +#ifdef MID_MUSIC + if ( Timidity_Init(mixer->freq, + mixer->format, mixer->channels, mixer->samples) == 0 ) { + timidity_ok = 1; + } else { + timidity_ok = 0; + } +#endif +#ifdef MP3_MUSIC + /* Keep a copy of the mixer */ + used_mixer = *mixer; +#endif + music_playing = 0; + if ( music_error ) { + return(-1); + } + Mix_VolumeMusic(SDL_MIX_MAXVOLUME); + + return(0); +} + +/* Load a music file */ +Mix_Music *Mix_LoadMUS(const char *file) +{ + FILE *fp; + unsigned char magic[5]; + Mix_Music *music; + + /* Figure out what kind of file this is */ + fp = fopen(file, "rb"); + if ( (fp == NULL) || !fread(magic, 4, 1, fp) ) { + if ( fp != NULL ) { + fclose(fp); + } + SDL_SetError("Couldn't read from '%s'", file); + return(NULL); + } + magic[4] = '\0'; + fclose(fp); + + /* Allocate memory for the music structure */ + music = (Mix_Music *)malloc(sizeof(Mix_Music)); + if ( music == NULL ) { + SDL_SetError("Out of memory"); + return(NULL); + } + music->error = 0; + +#ifdef CMD_MUSIC + if ( music_cmd ) { + music->type = MUS_CMD; + music->data.cmd = MusicCMD_LoadSong(music_cmd, file); + if ( music->data.cmd == NULL ) { + music->error = 1; + } + } else +#endif +#ifdef WAV_MUSIC + /* WAVE files have the magic four bytes "RIFF" + AIFF files have the magic 12 bytes "FORM" XXXX "AIFF" + */ + if ( (strcmp(magic, "RIFF") == 0) || (strcmp(magic, "FORM") == 0) ) { + music->type = MUS_WAV; + music->data.wave = WAVStream_LoadSong(file, magic); + if ( music->data.wave == NULL ) { + music->error = 1; + } + } else +#endif +#ifdef MID_MUSIC + /* MIDI files have the magic four bytes "MThd" */ + if ( strcmp(magic, "MThd") == 0 ) { + music->type = MUS_MID; + if ( timidity_ok ) { + music->data.midi = Timidity_LoadSong((char *)file); + if ( music->data.midi == NULL ) { + SDL_SetError("%s", Timidity_Error()); + music->error = 1; + } + } + else { + SDL_SetError("%s", Timidity_Error()); + music->error = 1; + } + } else +#endif +#ifdef MP3_MUSIC + if ( magic[0]==0xFF && (magic[1]&0xF0)==0xF0) { + SMPEG_Info info; + music->type = MUS_MP3; + music->data.mp3 = SMPEG_new(file, &info, 0); + if(!info.has_audio){ + SDL_SetError("MPEG file does not have any audio stream."); + music->error = 1; + }else{ + SMPEG_actualSpec(music->data.mp3, &used_mixer); + } + } else +#endif +#ifdef MOD_MUSIC + if ( 1 ) { + music->type = MUS_MOD; + music->data.module = MikMod_LoadSong((char *)file, 64); + if ( music->data.module == NULL ) { + SDL_SetError("%s", _mm_errmsg[_mm_errno]); + music->error = 1; + } + } else +#endif + { + SDL_SetError("Unrecognized music format"); + music->error = 1; + } + if ( music->error ) { + free(music); + music = NULL; + } + return(music); +} + +/* Free a music chunk previously loaded */ +void Mix_FreeMusic(Mix_Music *music) +{ + if ( music ) { + /* Caution: If music is playing, mixer will crash */ + if ( music == music_playing ) { + Mix_HaltMusic(); + } + switch (music->type) { +#ifdef CMD_MUSIC + case MUS_CMD: + MusicCMD_FreeSong(music->data.cmd); + break; +#endif +#ifdef WAV_MUSIC + case MUS_WAV: + WAVStream_FreeSong(music->data.wave); + break; +#endif +#ifdef MOD_MUSIC + case MUS_MOD: + MikMod_FreeSong(music->data.module); + break; +#endif +#ifdef MID_MUSIC + case MUS_MID: + Timidity_FreeSong(music->data.midi); + break; +#endif +#ifdef MP3_MUSIC + case MUS_MP3: + SMPEG_delete(music->data.mp3); + break; +#endif + default: + /* Unknown music type?? */ + break; + } + free(music); + } +} + +/* Play a music chunk. Returns 0, or -1 if there was an error. +*/ +int Mix_PlayMusic(Mix_Music *music, int loops) +{ + /* Don't play null pointers :-) */ + if ( music == NULL ) { + return(-1); + } + switch (music->type) { +#ifdef CMD_MUSIC + case MUS_CMD: + MusicCMD_SetVolume(music_volume); + MusicCMD_Start(music->data.cmd); + break; +#endif +#ifdef WAV_MUSIC + case MUS_WAV: + WAVStream_SetVolume(music_volume); + WAVStream_Start(music->data.wave); + break; +#endif +#ifdef MOD_MUSIC + case MUS_MOD: + Player_SetVolume(music_volume); + Player_Start(music->data.module); + Player_SetPosition(0); + break; +#endif +#ifdef MID_MUSIC + case MUS_MID: + Timidity_SetVolume(music_volume); + Timidity_Start(music->data.midi); + break; +#endif +#ifdef MP3_MUSIC + case MUS_MP3: + SMPEG_enableaudio(music->data.mp3,1); + SMPEG_enablevideo(music->data.mp3,0); + SMPEG_setvolume(music->data.mp3,((float)music_volume/(float)MIX_MAX_VOLUME)*100.0); + SMPEG_loop(music->data.mp3, loops); + SMPEG_play(music->data.mp3); + break; +#endif + default: + /* Unknown music type?? */ + return(-1); + } + music_active = 1; + music_playing = music; + return(0); +} + +/* Set the music volume */ +int Mix_VolumeMusic(int volume) +{ + int prev_volume; + + prev_volume = music_volume; + if ( volume >= 0 ) { + if ( volume > SDL_MIX_MAXVOLUME ) { + volume = SDL_MIX_MAXVOLUME; + } + music_volume = volume; + if ( music_playing ) { + switch (music_playing->type) { +#ifdef CMD_MUSIC + case MUS_CMD: + MusicCMD_SetVolume(music_volume); + break; +#endif +#ifdef WAV_MUSIC + case MUS_WAV: + WAVStream_SetVolume(music_volume); + break; +#endif +#ifdef MOD_MUSIC + case MUS_MOD: + Player_SetVolume(music_volume); + break; +#endif +#ifdef MID_MUSIC + case MUS_MID: + Timidity_SetVolume(music_volume); + break; +#endif +#ifdef MP3_MUSIC + case MUS_MP3: + SMPEG_setvolume(music_playing->data.mp3,((float)music_volume/(float)MIX_MAX_VOLUME)*100.0); + break; +#endif + default: + /* Unknown music type?? */ + break; + } + } + } + return(prev_volume); +} + +/* Halt playing of music */ +int Mix_HaltMusic(void) +{ + if ( music_playing ) { + switch (music_playing->type) { +#ifdef CMD_MUSIC + case MUS_CMD: + MusicCMD_Stop(music_playing->data.cmd); + break; +#endif +#ifdef WAV_MUSIC + case MUS_WAV: + WAVStream_Stop(); + break; +#endif +#ifdef MOD_MUSIC + case MUS_MOD: + Player_Stop(); + break; +#endif +#ifdef MID_MUSIC + case MUS_MID: + Timidity_Stop(); + break; +#endif +#ifdef MP3_MUSIC + case MUS_MP3: + SMPEG_stop(music_playing->data.mp3); + break; +#endif + default: + /* Unknown music type?? */ + return(-1); + } + music_playing = 0; + } + return(0); +} + +/* Pause/Resume the music stream */ +void Mix_PauseMusic(void) +{ + if ( music_playing ) { + switch ( music_playing->type ) { +#ifdef CMD_MUSIC + case MUS_CMD: + MusicCMD_Pause(music_playing->data.cmd); + break; +#endif +#ifdef MP3_MUSIC + case MUS_MP3: + SMPEG_pause(music_playing->data.mp3); + break; +#endif + } + } + music_active = 0; +} +void Mix_ResumeMusic(void) +{ + if ( music_playing ) { + switch ( music_playing->type ) { +#ifdef CMD_MUSIC + case MUS_CMD: + MusicCMD_Resume(music_playing->data.cmd); + break; +#endif +#ifdef MP3_MUSIC + case MUS_MP3: + SMPEG_pause(music_playing->data.mp3); + break; +#endif + } + } + music_active = 1; +} + +void Mix_RewindMusic(void) +{ + if ( music_playing ) { + switch ( music_playing->type ) { +#ifdef MP3_MUSIC + case MUS_MP3: + SMPEG_rewind(music_playing->data.mp3); + break; +#endif + } + } +} + +/* Check the status of the music */ +int Mix_PlayingMusic(void) +{ + if ( music_playing ) { + switch (music_playing->type) { +#ifdef CMD_MUSIC + case MUS_CMD: + if (!MusicCMD_Active(music_playing->data.cmd)) { + music_playing = 0; + } + break; +#endif +#ifdef WAV_MUSIC + case MUS_WAV: + if ( ! WAVStream_Active() ) { + music_playing = 0; + } + break; +#endif +#ifdef MOD_MUSIC + case MUS_MOD: + if ( ! Player_Active() ) { + music_playing = 0; + } + break; +#endif +#ifdef MID_MUSIC + case MUS_MID: + if ( ! Timidity_Active() ) { + music_playing = 0; + } + break; +#endif +#ifdef MP3_MUSIC + case MUS_MP3: + if(SMPEG_status(music_playing->data.mp3)!=SMPEG_PLAYING) + music_playing = 0; + break; +#endif + } + } + return(music_playing ? 1 : 0); +} + +/* Set the external music playback command */ +int Mix_SetMusicCMD(const char *command) +{ + Mix_HaltMusic(); + if ( music_cmd ) { + free(music_cmd); + music_cmd = NULL; + } + if ( command ) { + music_cmd = (char *)malloc(strlen(command)+1); + if ( music_cmd == NULL ) { + return(-1); + } + strcpy(music_cmd, command); + } + return(0); +} + +/* Uninitialize the music players */ +void close_music(void) +{ + Mix_HaltMusic(); +#ifdef CMD_MUSIC + Mix_SetMusicCMD(NULL); +#endif +#ifdef MOD_MUSIC + MikMod_Exit(); +#endif +} + diff --git a/music_cmd.c b/music_cmd.c new file mode 100644 index 00000000..1b038fb3 --- /dev/null +++ b/music_cmd.c @@ -0,0 +1,231 @@ +/* + MIXERLIB: An audio mixer library based on the SDL library + Copyright (C) 1997-1999 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +/* This file supports an external command for playing music */ + +#ifdef unix /* This is a UNIX-specific hack */ + +#include +#include +#include +#include +#include +#include +#include + +#include "mixer.h" +#include "music_cmd.h" + +/* Unimplemented */ +void MusicCMD_SetVolume(int volume) +{ + Mix_SetError("No way to modify external player volume"); +} + +/* Load a music stream from the given file */ +MusicCMD *MusicCMD_LoadSong(const char *cmd, const char *file) +{ + MusicCMD *music; + + /* Allocate and fill the music structure */ + music = (MusicCMD *)malloc(sizeof *music); + if ( music == NULL ) { + Mix_SetError("Out of memory"); + return(NULL); + } + strncpy(music->file, file, (sizeof music->file)-1); + music->file[(sizeof music->file)-1] = '\0'; + strncpy(music->cmd, cmd, (sizeof music->cmd)-1); + music->cmd[(sizeof music->cmd)-1] = '\0'; + music->pid = 0; + + /* We're done */ + return(music); +} + +/* Parse a command line buffer into arguments */ +static int ParseCommandLine(char *cmdline, char **argv) +{ + char *bufp; + int argc; + + argc = 0; + for ( bufp = cmdline; *bufp; ) { + /* Skip leading whitespace */ + while ( isspace(*bufp) ) { + ++bufp; + } + /* Skip over argument */ + if ( *bufp == '"' ) { + ++bufp; + if ( *bufp ) { + if ( argv ) { + argv[argc] = bufp; + } + ++argc; + } + /* Skip over word */ + while ( *bufp && (*bufp != '"') ) { + ++bufp; + } + } else { + if ( *bufp ) { + if ( argv ) { + argv[argc] = bufp; + } + ++argc; + } + /* Skip over word */ + while ( *bufp && ! isspace(*bufp) ) { + ++bufp; + } + } + if ( *bufp ) { + if ( argv ) { + *bufp = '\0'; + } + ++bufp; + } + } + if ( argv ) { + argv[argc] = NULL; + } + return(argc); +} + +static char **parse_args(char *command, char *last_arg) +{ + int argc; + char **argv; + + /* Parse the command line */ + argc = ParseCommandLine(command, NULL); + if ( last_arg ) { + ++argc; + } + argv = (char **)malloc((argc+1)*(sizeof *argv)); + if ( argv == NULL ) { + return(NULL); + } + argc = ParseCommandLine(command, argv); + + /* Add last command line argument */ + if ( last_arg ) { + argv[argc++] = last_arg; + } + argv[argc] = NULL; + + /* We're ready! */ + return(argv); +} + +/* Start playback of a given music stream */ +void MusicCMD_Start(MusicCMD *music) +{ + music->pid = fork(); + switch(music->pid) { + /* Failed fork() system call */ + case -1: + Mix_SetError("fork() failed"); + return; + + /* Child process - executes here */ + case 0: { + char command[PATH_MAX]; + char **argv; + + /* Execute the command */ + strcpy(command, music->cmd); + argv = parse_args(command, music->file); + if ( argv != NULL ) { + execvp(argv[0], argv); + } + + /* exec() failed */ + perror(argv[0]); + _exit(-1); + } + break; + + /* Parent process - executes here */ + default: + break; + } + return; +} + +/* Stop playback of a stream previously started with MusicCMD_Start() */ +void MusicCMD_Stop(MusicCMD *music) +{ + int status; + + if ( music->pid > 0 ) { + while ( kill(music->pid, 0) == 0 ) { + kill(music->pid, SIGTERM); + sleep(1); + waitpid(music->pid, &status, WNOHANG); + } + music->pid = 0; + } +} + +/* Pause playback of a given music stream */ +void MusicCMD_Pause(MusicCMD *music) +{ + if ( music->pid > 0 ) { + kill(music->pid, SIGSTOP); + } +} + +/* Resume playback of a given music stream */ +void MusicCMD_Resume(MusicCMD *music) +{ + if ( music->pid > 0 ) { + kill(music->pid, SIGCONT); + } +} + +/* Close the given music stream */ +void MusicCMD_FreeSong(MusicCMD *music) +{ + free(music); +} + +/* Return non-zero if a stream is currently playing */ +int MusicCMD_Active(MusicCMD *music) +{ + int status; + int active; + + active = 0; + if ( music->pid > 0 ) { + waitpid(music->pid, &status, WNOHANG); + if ( kill(music->pid, 0) == 0 ) { + active = 1; + } + } + return(active); +} + +#endif /* unix */ diff --git a/music_cmd.h b/music_cmd.h new file mode 100644 index 00000000..4b1ea9dd --- /dev/null +++ b/music_cmd.h @@ -0,0 +1,63 @@ +/* + MIXERLIB: An audio mixer library based on the SDL library + Copyright (C) 1997-1999 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +/* This file supports an external command for playing music */ + +#ifdef unix /* This is a UNIX-specific hack */ + +#include +#include +#include + +typedef struct { + char file[PATH_MAX]; + char cmd[PATH_MAX]; + pid_t pid; +} MusicCMD; + +/* Unimplemented */ +extern void MusicCMD_SetVolume(int volume); + +/* Load a music stream from the given file */ +extern MusicCMD *MusicCMD_LoadSong(const char *cmd, const char *file); + +/* Start playback of a given music stream */ +extern void MusicCMD_Start(MusicCMD *music); + +/* Stop playback of a stream previously started with MusicCMD_Start() */ +extern void MusicCMD_Stop(MusicCMD *music); + +/* Pause playback of a given music stream */ +extern void MusicCMD_Pause(MusicCMD *music); + +/* Resume playback of a given music stream */ +extern void MusicCMD_Resume(MusicCMD *music); + +/* Close the given music stream */ +extern void MusicCMD_FreeSong(MusicCMD *music); + +/* Return non-zero if a stream is currently playing */ +extern int MusicCMD_Active(MusicCMD *music); + +#endif /* unix */ diff --git a/playmus.c b/playmus.c new file mode 100644 index 00000000..059fb4cb --- /dev/null +++ b/playmus.c @@ -0,0 +1,129 @@ +/* + PLAYMUS: A test application for the SDL mixer library. + Copyright (C) 1997-1999 Sam Lantinga + + 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 + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +#include +#include +#include +#include +#ifndef WIN32 +#include +#endif + +#include +#include "mixer.h" + + +static int audio_open = 0; +static Mix_Music *music = NULL; + +void CleanUp(void) +{ + if ( audio_open ) { + Mix_CloseAudio(); + audio_open = 0; + } + if ( music ) { + Mix_FreeMusic(music); + music = NULL; + } + SDL_Quit(); +} + +void Usage(char *argv0) +{ + fprintf(stderr, "Usage: %s [-8] [-r rate] [-s] \n", argv0); +} + +main(int argc, char *argv[]) +{ + Uint32 audio_rate; + Uint16 audio_format; + int audio_channels; + int i; + + /* Initialize variables */ + audio_rate = 22050; + audio_format = AUDIO_S16; + audio_channels = 2; + + /* Check command line usage */ + for ( i=1; argv[i] && (*argv[i] == '-'); ++i ) { + if ( (strcmp(argv[i], "-r") == 0) && argv[i+1] ) { + ++i; + audio_rate = atoi(argv[i]); + } else + if ( strcmp(argv[i], "-m") == 0 ) { + audio_channels = 1; + } else + if ( strcmp(argv[i], "-8") == 0 ) { + audio_format = AUDIO_U8; + } else { + Usage(argv[0]); + exit(1); + } + } + if ( ! argv[i] ) { + Usage(argv[0]); + exit(1); + } + + /* Initialize the SDL library */ + if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) { + fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); + exit(255); + } + atexit(CleanUp); + signal(SIGINT, exit); + signal(SIGTERM, exit); + + /* Open the audio device */ + if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) { + fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); + exit(2); + } else { + Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); + printf("Opened audio at %d Hz %d bit %s\n", audio_rate, + (audio_format&0xFF), + (audio_channels > 1) ? "stereo" : "mono"); + } + audio_open = 1; + + /* Set the external music player, if any */ + Mix_SetMusicCMD(getenv("MUSIC_CMD")); + + /* Load the requested music file */ + music = Mix_LoadMUS(argv[i]); + if ( music == NULL ) { + fprintf(stderr, "Couldn't load %s: %s\n", + argv[i], SDL_GetError()); + exit(2); + } + + /* Play and then exit */ + Mix_PlayMusic(music,0); + while ( Mix_PlayingMusic() ) { + SDL_Delay(100); + } + exit(0); +} diff --git a/playwave.c b/playwave.c new file mode 100644 index 00000000..4c5c0828 --- /dev/null +++ b/playwave.c @@ -0,0 +1,126 @@ +/* + PLAYWAVE: A test application for the SDL mixer library. + Copyright (C) 1997-1999 Sam Lantinga + + 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 + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +#include +#include +#include +#include +#ifndef WIN32 +#include +#endif + +#include +#include "mixer.h" + + +static int audio_open = 0; +static Mix_Chunk *wave = NULL; + +void CleanUp(void) +{ + if ( audio_open ) { + Mix_CloseAudio(); + audio_open = 0; + } + if ( wave ) { + Mix_FreeChunk(wave); + wave = NULL; + } + SDL_Quit(); +} + +void Usage(char *argv0) +{ + fprintf(stderr, "Usage: %s [-8] [-r rate] [-m] \n", argv0); +} + +main(int argc, char *argv[]) +{ + Uint32 audio_rate; + Uint16 audio_format; + int audio_channels; + int i; + + /* Initialize variables */ + audio_rate = 22050; + audio_format = AUDIO_S16; + audio_channels = 2; + + /* Check command line usage */ + for ( i=1; argv[i] && (*argv[i] == '-'); ++i ) { + if ( (strcmp(argv[i], "-r") == 0) && argv[i+1] ) { + ++i; + audio_rate = atoi(argv[i]); + } else + if ( strcmp(argv[i], "-m") == 0 ) { + audio_channels = 1; + } else + if ( strcmp(argv[i], "-8") == 0 ) { + audio_format = AUDIO_U8; + } else { + Usage(argv[0]); + exit(1); + } + } + if ( ! argv[i] ) { + Usage(argv[0]); + exit(1); + } + + /* Initialize the SDL library */ + if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) { + fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError()); + exit(255); + } + atexit(CleanUp); + signal(SIGINT, exit); + signal(SIGTERM, exit); + + /* Open the audio device */ + if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) { + fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError()); + exit(2); + } else { + Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels); + printf("Opened audio at %d Hz %d bit %s\n", audio_rate, + (audio_format&0xFF), + (audio_channels > 1) ? "stereo" : "mono"); + } + audio_open = 1; + + /* Load the requested wave file */ + wave = Mix_LoadWAV(argv[i]); + if ( wave == NULL ) { + fprintf(stderr, "Couldn't load %s: %s\n", + argv[i], SDL_GetError()); + exit(2); + } + + /* Play and then exit */ + Mix_PlayChannel(0, wave, 0); + while ( Mix_Playing(0) ) { + SDL_Delay(100); + } + exit(0); +} diff --git a/timidity/FAQ b/timidity/FAQ new file mode 100644 index 00000000..f1f8e237 --- /dev/null +++ b/timidity/FAQ @@ -0,0 +1,112 @@ +---------------------------*-indented-text-*------------------------------ + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + +-------------------------------------------------------------------------- + + Frequently Asked Questions with answers: + +-------------------------------------------------------------------------- +Q: What is it? + +A: Where? Well Chris, TiMidity is a software-only synthesizer, MIDI + renderer, MIDI to WAVE converter, realtime MIDI player for UNIX machines, + even (I've heard) a Netscape helper application. It takes a MIDI file + and writes a WAVE or raw PCM data or plays it on your digital audio + device. It sounds much more realistic than FM synthesis, but you need a + ~100Mhz processor to listen to 32kHz stereo music in the background while + you work. 11kHz mono can be played on a low-end 486, and, to some, it + still sounds better than FM. + +-------------------------------------------------------------------------- +Q: I don't have a GUS, can I use TiMidity? + +A: Yes. That's the point. You don't need a Gravis Ultrasound to use + TiMidity, you just need GUS-compatible patches, which are freely + available on the Internet. See below for pointers. + +-------------------------------------------------------------------------- +Q: I have a GUS, can I use TiMidity? + +A: The DOS port doesn't have GUS support, and TiMidity won't be taking + advantage of the board's internal synthesizer under other operating + systems either. So it kind of defeats the purpose. But you can use it. + +-------------------------------------------------------------------------- +Q: I tried playing a MIDI file I got off the Net but all I got was a + dozen warnings saying "No instrument mapped to tone bank 0, program + xx - this instrument will not be heard". What's wrong? + +A: The General MIDI standard specifies 128 melodic instruments and + some sixty percussion sounds. If you wish to play arbitrary General + MIDI files, you'll need to get more patch files. + + There's a program called Midia for SGI's, which also plays MIDI + files and has a lot more bells and whistles than TiMidity. It uses + GUS-compatible patches, too -- so you can get the 8 MB set at + ftp://archive.cs.umbc.edu/pub/midia for pretty good GM compatibility. + + There are also many excellent patches on the Ultrasound FTP sites. + I can recommend Dustin McCartney's collections gsdrum*.zip and + wow*.zip in the "[.../]sound/patches/files" directory. The huge + ProPats series (pp3-*.zip) contains good patches as well. General + MIDI files can also be found on these sites. + + This site list is from the GUS FAQ: + +> FTP Sites Archive Directories +> --------- ------------------- +> Main N.American Site: archive.orst.edu pub/packages/gravis +> wuarchive.wustl.edu systems/ibmpc/ultrasound +> Main Asian Site: nctuccca.edu.tw PC/ultrasound +> Main European Site: src.doc.ic.ac.uk packages/ultrasound +> Main Australian Site: ftp.mpx.com.au /ultrasound/general +> /ultrasound/submit +> South African Site: ftp.sun.ac.za /pub/packages/ultrasound +> Submissions: archive.epas.utoronto.ca pub/pc/ultrasound/submit +> Newly Validated Files: archive.epas.utoronto.ca pub/pc/ultrasound +> +> Mirrors: garbo.uwasa.fi mirror/ultrasound +> ftp.st.nepean.uws.edu.au pc/ultrasound +> ftp.luth.se pub/msdos/ultrasound + +-------------------------------------------------------------------------- +Q: Some files have awful clicks and pops. + +A: Find out which patch is responsible for the clicking (try "timidity + -P ". Add "strip=tail" in + the config file after its name. If this doesn't fix it, mail me the + patch. + +-------------------------------------------------------------------------- +Q: I'm playing Fantasie Impromptu in the background. When I run Netscape, + the sound gets choppy and it takes ten minutes to load. What can I do? + +A: Here are some things to try: + + - Use a lower sampling rate. + + - Use mono output. This can improve performance by 10-30%. + (Using 8-bit instead of 16-bit output makes no difference.) + + - Use a smaller number of simultaneous voices. + + - Make sure you compiled with FAST_DECAY and PRECALC_LOOPS enabled + in config.h + + - If you don't have hardware to compute sines, recompile with + LOOKUP_SINE enabled in config.h + + - Recompile with LOOKUP_HACK enabled in config.h. + + - Recompile with LINEAR_INTERPOLATION disabled in config.h. + + - Recompile with DANGEROUS_RENICE enabled in config.h, and make + TiMidity setuid root. This will help only if you frequently play + music while other processes are running. + + - Recompile with an Intel-optimized gcc for a 5-15% + performance increase. + +-------------------------------------------------------------------------- diff --git a/timidity/Makefile.am b/timidity/Makefile.am new file mode 100644 index 00000000..65bad63d --- /dev/null +++ b/timidity/Makefile.am @@ -0,0 +1,31 @@ + +noinst_LTLIBRARIES = libtimidity.la + +libtimidity_la_SOURCES = \ + common.c \ + common.h \ + config.h \ + controls.c \ + controls.h \ + filter.c \ + filter.h \ + instrum.c \ + instrum.h \ + mix.c \ + mix.h \ + output.c \ + output.h \ + playmidi.c \ + playmidi.h \ + readmidi.c \ + readmidi.h \ + resample.c \ + resample.h \ + sdl_a.c \ + sdl_c.c \ + tables.c \ + tables.h \ + timidity.c \ + timidity.h + +EXTRA_DIST = FAQ README diff --git a/timidity/Makefile.in b/timidity/Makefile.in new file mode 100644 index 00000000..6fef7ba3 --- /dev/null +++ b/timidity/Makefile.in @@ -0,0 +1,342 @@ +# Makefile.in generated automatically by automake 1.4a from Makefile.am + +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include + +DESTDIR = + +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ + +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_FLAG = +transform = @program_transform_name@ + +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +host_alias = @host_alias@ +host_triplet = @host@ +AS = @AS@ +BINARY_AGE = @BINARY_AGE@ +CC = @CC@ +DLLTOOL = @DLLTOOL@ +INTERFACE_AGE = @INTERFACE_AGE@ +LD = @LD@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +LT_AGE = @LT_AGE@ +LT_CURRENT = @LT_CURRENT@ +LT_RELEASE = @LT_RELEASE@ +LT_REVISION = @LT_REVISION@ +MAJOR_VERSION = @MAJOR_VERSION@ +MAKEINFO = @MAKEINFO@ +MICRO_VERSION = @MICRO_VERSION@ +MINOR_VERSION = @MINOR_VERSION@ +NM = @NM@ +OBJDUMP = @OBJDUMP@ +PACKAGE = @PACKAGE@ +RANLIB = @RANLIB@ +SDL_CFLAGS = @SDL_CFLAGS@ +SDL_CONFIG = @SDL_CONFIG@ +SDL_LIBS = @SDL_LIBS@ +VERSION = @VERSION@ + +noinst_LTLIBRARIES = libtimidity.la + +libtimidity_la_SOURCES = common.c common.h config.h controls.c controls.h filter.c filter.h instrum.c instrum.h mix.c mix.h output.c output.h playmidi.c playmidi.h readmidi.c readmidi.h resample.c resample.h sdl_a.c sdl_c.c tables.c tables.h timidity.c timidity.h + + +EXTRA_DIST = FAQ README +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +libtimidity_la_LDFLAGS = +libtimidity_la_LIBADD = +libtimidity_la_OBJECTS = common.lo controls.lo filter.lo instrum.lo \ +mix.lo output.lo playmidi.lo readmidi.lo resample.lo sdl_a.lo sdl_c.lo \ +tables.lo timidity.lo +CFLAGS = @CFLAGS@ +COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@ +DIST_COMMON = README Makefile.am Makefile.in + + +DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) + +TAR = gtar +GZIP_ENV = --best +DEP_FILES = .deps/common.P .deps/controls.P .deps/filter.P \ +.deps/instrum.P .deps/mix.P .deps/output.P .deps/playmidi.P \ +.deps/readmidi.P .deps/resample.P .deps/sdl_a.P .deps/sdl_c.P \ +.deps/tables.P .deps/timidity.P +SOURCES = $(libtimidity_la_SOURCES) +OBJECTS = $(libtimidity_la_OBJECTS) + +all: all-redirect +.SUFFIXES: +.SUFFIXES: .S .c .lo .o .s +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && $(AUTOMAKE) --foreign timidity/Makefile + +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + + +mostlyclean-noinstLTLIBRARIES: + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + +distclean-noinstLTLIBRARIES: + +maintainer-clean-noinstLTLIBRARIES: + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libtimidity.la: $(libtimidity_la_OBJECTS) $(libtimidity_la_DEPENDENCIES) + $(LINK) $(libtimidity_la_LDFLAGS) $(libtimidity_la_OBJECTS) $(libtimidity_la_LIBADD) $(LIBS) + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) + +subdir = timidity + +distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign timidity/Makefile + @for file in $(DISTFILES); do \ + d=$(srcdir); \ + if test -d $$d/$$file; then \ + cp -pr $$d/$$file $(distdir)/$$file; \ + else \ + test -f $(distdir)/$$file \ + || ln $$d/$$file $(distdir)/$$file 2> /dev/null \ + || cp -p $$d/$$file $(distdir)/$$file || :; \ + fi; \ + done + +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp +info-am: +info: info-am +dvi-am: +dvi: dvi-am +check-am: all-am +check: check-am +installcheck-am: +installcheck: installcheck-am +install-exec-am: +install-exec: install-exec-am + +install-data-am: +install-data: install-data-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am +install: install-am +uninstall-am: +uninstall: uninstall-am +all-am: Makefile $(LTLIBRARIES) +all-redirect: all-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_STRIP_FLAG=-s install +installdirs: + + +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f config.cache config.log stamp-h stamp-h[0-9]* + +maintainer-clean-generic: +mostlyclean-am: mostlyclean-noinstLTLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic + +mostlyclean: mostlyclean-am + +clean-am: clean-noinstLTLIBRARIES clean-compile clean-libtool \ + clean-tags clean-depend clean-generic mostlyclean-am + +clean: clean-am + +distclean-am: distclean-noinstLTLIBRARIES distclean-compile \ + distclean-libtool distclean-tags distclean-depend \ + distclean-generic clean-am + -rm -f libtool + +distclean: distclean-am + +maintainer-clean-am: maintainer-clean-noinstLTLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + +maintainer-clean: maintainer-clean-am + +.PHONY: mostlyclean-noinstLTLIBRARIES distclean-noinstLTLIBRARIES \ +clean-noinstLTLIBRARIES maintainer-clean-noinstLTLIBRARIES \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend info-am info dvi-am dvi check check-am \ +installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/timidity/README b/timidity/README new file mode 100644 index 00000000..64f45e1e --- /dev/null +++ b/timidity/README @@ -0,0 +1,70 @@ +[This version of timidity has been stripped for simplicity in porting to SDL] +---------------------------------*-text-*--------------------------------- + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +-------------------------------------------------------------------------- + + This is the README file for TiMidity v0.2i + + TiMidity is a MIDI to WAVE converter that uses Gravis +Ultrasound(*)-compatible patch files to generate digital audio data +from General MIDI files. The audio data can be played through any +sound device or stored on disk. On a fast machine, music can be +played in real time. TiMidity runs under Linux, FreeBSD, HP-UX, SunOS, and +Win32, and porting to other systems with gcc should be easy. + + TiMidity Features: + + * 32 or more dynamically allocated fully independent voices + * Compatibility with GUS patch files + * Output to 16- or 8-bit PCM or uLaw audio device, file, or + stdout at any sampling rate + * Optional interactive mode with real-time status display + under ncurses and SLang terminal control libraries. Also + a user friendly motif interface since version 0.2h + * Support for transparent loading of compressed MIDI files and + patch files + + * Support for the following MIDI events: + - Program change + - Key pressure + - Channel main volume + - Tempo + - Panning + - Damper pedal (Sustain) + - Pitch wheel + - Pitch wheel sensitivity + - Change drum set + +* The GNU General Public License can, as always, be found in the file + "../COPYING". + +* TiMidity requires sampled instruments (patches) to play MIDI files. You + should get the file "timidity-lib-0.1.tar.gz" and unpack it in the same + directory where you unpacked the source code archive. You'll want more + patches later -- read the file "FAQ" for pointers. + +* Timidity is no longer supported, but can be found by searching the web. + + + Tuukka Toivonen + +[(*) Any Registered Trademarks used anywhere in the documentation or +source code for TiMidity are acknowledged as belonging to their +respective owners.] diff --git a/timidity/common.c b/timidity/common.c new file mode 100644 index 00000000..0a1c29dc --- /dev/null +++ b/timidity/common.c @@ -0,0 +1,221 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + common.c + + */ + +#include +#include +#include + +#include +#include "config.h" +#include "common.h" +#include "output.h" +#include "controls.h" + +/* I guess "rb" should be right for any libc */ +#define OPEN_MODE "rb" + +char current_filename[1024]; + +#ifdef DEFAULT_PATH + /* The paths in this list will be tried whenever we're reading a file */ + static PathList defaultpathlist={DEFAULT_PATH,0}; + static PathList *pathlist=&defaultpathlist; /* This is a linked list */ +#else + static PathList *pathlist=0; +#endif + +/* Try to open a file for reading. If the filename ends in one of the + defined compressor extensions, pipe the file through the decompressor */ +static FILE *try_to_open(char *name, int decompress, int noise_mode) +{ + FILE *fp; + + fp=fopen(name, OPEN_MODE); /* First just check that the file exists */ + + if (!fp) + return 0; + +#ifdef DECOMPRESSOR_LIST + if (decompress) + { + int l,el; + static char *decompressor_list[] = DECOMPRESSOR_LIST, **dec; + char tmp[1024], tmp2[1024], *cp, *cp2; + /* Check if it's a compressed file */ + l=strlen(name); + for (dec=decompressor_list; *dec; dec+=2) + { + el=strlen(*dec); + if ((el>=l) || (strcmp(name+l-el, *dec))) + continue; + + /* Yes. Close the file, open a pipe instead. */ + fclose(fp); + + /* Quote some special characters in the file name */ + cp=name; + cp2=tmp2; + while (*cp) + { + switch(*cp) + { + case '\'': + case '\\': + case ' ': + case '`': + case '!': + case '"': + case '&': + case ';': + *cp2++='\\'; + } + *cp2++=*cp++; + } + *cp2=0; + + sprintf(tmp, *(dec+1), tmp2); + fp=popen(tmp, "r"); + break; + } + } +#endif + + return fp; +} + +/* This is meant to find and open files for reading, possibly piping + them through a decompressor. */ +FILE *open_file(char *name, int decompress, int noise_mode) +{ + FILE *fp; + PathList *plp=pathlist; + int l; + + if (!name || !(*name)) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Attempted to open nameless file."); + return 0; + } + + /* First try the given name */ + + strncpy(current_filename, name, 1023); + current_filename[1023]='\0'; + + ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Trying to open %s", current_filename); + if ((fp=try_to_open(current_filename, decompress, noise_mode))) + return fp; + + if (noise_mode && (errno != ENOENT)) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", + current_filename, strerror(errno)); + return 0; + } + + if (name[0] != PATH_SEP) + while (plp) /* Try along the path then */ + { + *current_filename=0; + l=strlen(plp->path); + if(l) + { + strcpy(current_filename, plp->path); + if(current_filename[l-1]!=PATH_SEP) + strcat(current_filename, PATH_STRING); + } + strcat(current_filename, name); + ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Trying to open %s", current_filename); + if ((fp=try_to_open(current_filename, decompress, noise_mode))) + return fp; + if (noise_mode && (errno != ENOENT)) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", + current_filename, strerror(errno)); + return 0; + } + plp=plp->next; + } + + /* Nothing could be opened. */ + + *current_filename=0; + + if (noise_mode>=2) + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", name, strerror(errno)); + + return 0; +} + +/* This closes files opened with open_file */ +void close_file(FILE *fp) +{ +#ifdef DECOMPRESSOR_LIST + if (pclose(fp)) /* Any better ideas? */ +#endif + fclose(fp); +} + +/* This is meant for skipping a few bytes in a file or fifo. */ +void skip(FILE *fp, size_t len) +{ + size_t c; + char tmp[1024]; + while (len>0) + { + c=len; + if (c>1024) c=1024; + len-=c; + if (c!=fread(tmp, 1, c, fp)) + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: skip: %s", + current_filename, strerror(errno)); + } +} + +/* This'll allocate memory or die. */ +void *safe_malloc(size_t count) +{ + void *p; + if (count > (1<<21)) + { + ctl->cmsg(CMSG_FATAL, VERB_NORMAL, + "Strange, I feel like allocating %d bytes. This must be a bug.", + count); + } + else if ((p=malloc(count))) + return p; + else + ctl->cmsg(CMSG_FATAL, VERB_NORMAL, "Sorry. Couldn't malloc %d bytes.", count); + + ctl->close(); + exit(10); +} + +/* This adds a directory to the path list */ +void add_to_pathlist(char *s) +{ + PathList *plp=safe_malloc(sizeof(PathList)); + strcpy((plp->path=safe_malloc(strlen(s)+1)),s); + plp->next=pathlist; + pathlist=plp; +} diff --git a/timidity/common.h b/timidity/common.h new file mode 100644 index 00000000..1bb06d3d --- /dev/null +++ b/timidity/common.h @@ -0,0 +1,42 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + + common.h +*/ + +extern char *program_name, current_filename[]; + +extern FILE *msgfp; + +typedef struct { + char *path; + void *next; +} PathList; + +/* Noise modes for open_file */ +#define OF_SILENT 0 +#define OF_NORMAL 1 +#define OF_VERBOSE 2 + +extern FILE *open_file(char *name, int decompress, int noise_mode); +extern void add_to_pathlist(char *s); +extern void close_file(FILE *fp); +extern void skip(FILE *fp, size_t len); +extern void *safe_malloc(size_t count); diff --git a/timidity/config.h b/timidity/config.h new file mode 100644 index 00000000..3870ca83 --- /dev/null +++ b/timidity/config.h @@ -0,0 +1,257 @@ +/* + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +/* This is for use with the SDL library */ +#define SDL + +/* When a patch file can't be opened, one of these extensions is + appended to the filename and the open is tried again. + */ +#define PATCH_EXT_LIST { ".pat", 0 } + +/* Acoustic Grand Piano seems to be the usual default instrument. */ +#define DEFAULT_PROGRAM 0 + +/* 9 here is MIDI channel 10, which is the standard percussion channel. + Some files (notably C:\WINDOWS\CANYON.MID) think that 16 is one too. + On the other hand, some files know that 16 is not a drum channel and + try to play music on it. This is now a runtime option, so this isn't + a critical choice anymore. */ +#define DEFAULT_DRUMCHANNELS ((1<<9) | (1<<15)) + +/* A somewhat arbitrary frequency range. The low end of this will + sound terrible as no lowpass filtering is performed on most + instruments before resampling. */ +#define MIN_OUTPUT_RATE 4000 +#define MAX_OUTPUT_RATE 65000 + +/* In percent. */ +#define DEFAULT_AMPLIFICATION 70 + +/* Default sampling rate, default polyphony, and maximum polyphony. + All but the last can be overridden from the command line. */ +#define DEFAULT_RATE 32000 +#define DEFAULT_VOICES 32 +#define MAX_VOICES 48 + +/* 1000 here will give a control ratio of 22:1 with 22 kHz output. + Higher CONTROLS_PER_SECOND values allow more accurate rendering + of envelopes and tremolo. The cost is CPU time. */ +#define CONTROLS_PER_SECOND 1000 + +/* Strongly recommended. This option increases CPU usage by half, but + without it sound quality is very poor. */ +#define LINEAR_INTERPOLATION + +/* This is an experimental kludge that needs to be done right, but if + you've got an 8-bit sound card, or cheap multimedia speakers hooked + to your 16-bit output device, you should definitely give it a try. + + Defining LOOKUP_HACK causes table lookups to be used in mixing + instead of multiplication. We convert the sample data to 8 bits at + load time and volumes to logarithmic 7-bit values before looking up + the product, which degrades sound quality noticeably. + + Defining LOOKUP_HACK should save ~20% of CPU on an Intel machine. + LOOKUP_INTERPOLATION might give another ~5% */ +/* #define LOOKUP_HACK + #define LOOKUP_INTERPOLATION */ + +/* Make envelopes twice as fast. Saves ~20% CPU time (notes decay + faster) and sounds more like a GUS. There is now a command line + option to toggle this as well. */ +#define FAST_DECAY + +/* How many bits to use for the fractional part of sample positions. + This affects tonal accuracy. The entire position counter must fit + in 32 bits, so with FRACTION_BITS equal to 12, the maximum size of + a sample is 1048576 samples (2 megabytes in memory). The GUS gets + by with just 9 bits and a little help from its friends... + "The GUS does not SUCK!!!" -- a happy user :) */ +#define FRACTION_BITS 12 + +/* For some reason the sample volume is always set to maximum in all + patch files. Define this for a crude adjustment that may help + equalize instrument volumes. */ +#define ADJUST_SAMPLE_VOLUMES + +/* The number of samples to use for ramping out a dying note. Affects + click removal. */ +#define MAX_DIE_TIME 20 + +/* On some machines (especially PCs without math coprocessors), + looking up sine values in a table will be significantly faster than + computing them on the fly. Uncomment this to use lookups. */ +/* #define LOOKUP_SINE */ + +/* Shawn McHorse's resampling optimizations. These may not in fact be + faster on your particular machine and compiler. You'll have to run + a benchmark to find out. */ +#define PRECALC_LOOPS + +/* If calling ldexp() is faster than a floating point multiplication + on your machine/compiler/libm, uncomment this. It doesn't make much + difference either way, but hey -- it was on the TODO list, so it + got done. */ +/* #define USE_LDEXP */ + +/**************************************************************************/ +/* Anything below this shouldn't need to be changed unless you're porting + to a new machine with other than 32-bit, big-endian words. */ +/**************************************************************************/ + +/* change FRACTION_BITS above, not these */ +#define INTEGER_BITS (32 - FRACTION_BITS) +#define INTEGER_MASK (0xFFFFFFFF << FRACTION_BITS) +#define FRACTION_MASK (~ INTEGER_MASK) + +/* This is enforced by some computations that must fit in an int */ +#define MAX_CONTROL_RATIO 255 + +/* Byte order, defined in for FreeBSD and DEC OSF/1 */ +#ifdef DEC +#include +#endif + +#ifdef linux +/* + * Byte order is defined in as __BYTE_ORDER, that need to + * be checked against __LITTLE_ENDIAN and __BIG_ENDIAN defined in + * includes automagically + * for Linux. + */ +#include + +/* + * We undef the two things to start with a clean situation + * (oddly enough, defines under certain conditions + * the two things below, as __LITTLE_ENDIAN and __BIG_ENDIAN, that + * are useless for our plans) + */ +#undef LITTLE_ENDIAN +#undef BIG_ENDIAN + +# if __BYTE_ORDER == __LITTLE_ENDIAN +# define LITTLE_ENDIAN +# elif __BYTE_ORDER == __BIG_ENDIAN +# define BIG_ENDIAN +# else +# error No byte sex defined +# endif +#endif /* linux */ + +/* Win32 on Intel machines */ +#ifdef __WIN32__ +# define LITTLE_ENDIAN +#endif + +/* DEC MMS has 64 bit long words */ +#ifdef DEC +typedef unsigned int uint32; +typedef int int32; +#else +typedef unsigned long uint32; +typedef long int32; +#endif +typedef unsigned short uint16; +typedef short int16; +typedef unsigned char uint8; +typedef char int8; + +/* Instrument files are little-endian, MIDI files big-endian, so we + need to do some conversions. */ + +#define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF)) +# define XCHG_LONG(x) ((((x)&0xFF)<<24) | \ + (((x)&0xFF00)<<8) | \ + (((x)&0xFF0000)>>8) | \ + (((x)>>24)&0xFF)) + +#ifdef LITTLE_ENDIAN +#define LE_SHORT(x) x +#define LE_LONG(x) x +#define BE_SHORT(x) XCHG_SHORT(x) +#define BE_LONG(x) XCHG_LONG(x) +#else +#define BE_SHORT(x) x +#define BE_LONG(x) x +#define LE_SHORT(x) XCHG_SHORT(x) +#define LE_LONG(x) XCHG_LONG(x) +#endif + +#define MAX_AMPLIFICATION 800 + +/* You could specify a complete path, e.g. "/etc/timidity.cfg", and + then specify the library directory in the configuration file. */ +#define CONFIG_FILE "timidity.cfg" +#ifdef __WIN32__ +#define DEFAULT_PATH "\\TIMIDITY" +#else +#define DEFAULT_PATH "/usr/local/lib/timidity" +#endif + +/* These affect general volume */ +#define GUARD_BITS 3 +#define AMP_BITS (15-GUARD_BITS) + +#ifdef LOOKUP_HACK + typedef int8 sample_t; + typedef uint8 final_volume_t; +# define FINAL_VOLUME(v) (~_l2u[v]) +# define MIXUP_SHIFT 5 +# define MAX_AMP_VALUE 4095 +#else + typedef int16 sample_t; + typedef int32 final_volume_t; +# define FINAL_VOLUME(v) (v) +# define MAX_AMP_VALUE ((1<<(AMP_BITS+1))-1) +#endif + +#ifdef USE_LDEXP +# define FSCALE(a,b) ldexp((a),(b)) +# define FSCALENEG(a,b) ldexp((a),-(b)) +#else +# define FSCALE(a,b) ((a) * (double)(1<<(b))) +# define FSCALENEG(a,b) ((a) * (1.0L / (double)(1<<(b)))) +#endif + +/* Vibrato and tremolo Choices of the Day */ +#define SWEEP_TUNING 38 +#define VIBRATO_AMPLITUDE_TUNING 1.0L +#define VIBRATO_RATE_TUNING 38 +#define TREMOLO_AMPLITUDE_TUNING 1.0L +#define TREMOLO_RATE_TUNING 38 + +#define SWEEP_SHIFT 16 +#define RATE_SHIFT 5 + +#define VIBRATO_SAMPLE_INCREMENTS 32 + +#ifndef PI + #define PI 3.14159265358979323846 +#endif + +/* The path separator (D.M.) */ +#ifdef __WIN32__ +# define PATH_SEP '\\' +# define PATH_STRING "\\" +#else +# define PATH_SEP '/' +# define PATH_STRING "/" +#endif diff --git a/timidity/controls.c b/timidity/controls.c new file mode 100644 index 00000000..49a92cb2 --- /dev/null +++ b/timidity/controls.c @@ -0,0 +1,41 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + controls.c + + */ + +#include "config.h" +#include "controls.h" + +#ifdef SDL + extern ControlMode sdl_control_mode; +# ifndef DEFAULT_CONTROL_MODE +# define DEFAULT_CONTROL_MODE &sdl_control_mode +# endif +#endif + +ControlMode *ctl_list[]={ +#ifdef SDL + &sdl_control_mode, +#endif + 0 +}; + +ControlMode *ctl=DEFAULT_CONTROL_MODE; diff --git a/timidity/controls.h b/timidity/controls.h new file mode 100644 index 00000000..c0f4fb58 --- /dev/null +++ b/timidity/controls.h @@ -0,0 +1,88 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + controls.h +*/ + +/* Return values for ControlMode.read */ + +#define RC_ERROR -1 +#define RC_NONE 0 +#define RC_QUIT 1 +#define RC_NEXT 2 +#define RC_PREVIOUS 3 /* Restart this song at beginning, or the previous + song if we're less than a second into this one. */ +#define RC_FORWARD 4 +#define RC_BACK 5 +#define RC_JUMP 6 +#define RC_TOGGLE_PAUSE 7 /* Pause/continue */ +#define RC_RESTART 8 /* Restart song at beginning */ + +#define RC_PAUSE 9 /* Really pause playing */ +#define RC_CONTINUE 10 /* Continue if paused */ +#define RC_REALLY_PREVIOUS 11 /* Really go to the previous song */ +#define RC_CHANGE_VOLUME 12 +#define RC_LOAD_FILE 13 /* Load a new midifile */ +#define RC_TUNE_END 14 /* The tune is over, play it again sam? */ + +#define CMSG_INFO 0 +#define CMSG_WARNING 1 +#define CMSG_ERROR 2 +#define CMSG_FATAL 3 +#define CMSG_TRACE 4 +#define CMSG_TIME 5 +#define CMSG_TOTAL 6 +#define CMSG_FILE 7 +#define CMSG_TEXT 8 + +#define VERB_NORMAL 0 +#define VERB_VERBOSE 1 +#define VERB_NOISY 2 +#define VERB_DEBUG 3 +#define VERB_DEBUG_SILLY 4 + +typedef struct { + char *id_name, id_character; + int verbosity, trace_playing, opened; + + int (*open)(int using_stdin, int using_stdout); + void (*pass_playing_list)(int number_of_files, char *list_of_files[]); + void (*close)(void); + int (*read)(int32 *valp); + int (*cmsg)(int type, int verbosity_level, char *fmt, ...); + + void (*refresh)(void); + void (*reset)(void); + void (*file_name)(char *name); + void (*total_time)(int tt); + void (*current_time)(int ct); + + void (*note)(int v); + void (*master_volume)(int mv); + void (*program)(int channel, int val); /* val<0 means drum set -val */ + void (*volume)(int channel, int val); + void (*expression)(int channel, int val); + void (*panning)(int channel, int val); + void (*sustain)(int channel, int val); + void (*pitch_bend)(int channel, int val); + +} ControlMode; + +extern ControlMode *ctl_list[], *ctl; +extern char timidity_error[]; diff --git a/timidity/filter.c b/timidity/filter.c new file mode 100644 index 00000000..458a3d93 --- /dev/null +++ b/timidity/filter.c @@ -0,0 +1,203 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + filter.c: written by Vincent Pagel ( pagel@loria.fr ) + + implements fir antialiasing filter : should help when setting sample + rates as low as 8Khz. + + April 95 + - first draft + + 22/5/95 + - modify "filter" so that it simulate leading and trailing 0 in the buffer + */ + +#include +#include +#include +#include +#include "config.h" +#include "common.h" +#include "controls.h" +#include "instrum.h" +#include "filter.h" + +/* bessel function */ +static float ino(float x) +{ + float y, de, e, sde; + int i; + + y = x / 2; + e = 1.0; + de = 1.0; + i = 1; + do { + de = de * y / (float) i; + sde = de * de; + e += sde; + } while (!( (e * 1.0e-08 - sde > 0) || (i++ > 25) )); + return(e); +} + +/* Kaiser Window (symetric) */ +static void kaiser(float *w,int n,float beta) +{ + float xind, xi; + int i; + + xind = (2*n - 1) * (2*n - 1); + for (i =0; i apply the filter given by coef[] to the data buffer + * Note that we simulate leading and trailing 0 at the border of the + * data buffer + */ +static void filter(sample_t *result,sample_t *data, int32 length,float coef[]) +{ + int32 sample,i,sample_window; + int16 peak = 0; + float sum; + + /* Simulate leading 0 at the begining of the buffer */ + for (sample = 0; sample < ORDER2 ; sample++ ) + { + sum = 0.0; + sample_window= sample - ORDER2; + + for (i = 0; i < ORDER ;i++) + sum += coef[i] * + ((sample_window<0)? 0.0 : data[sample_window++]) ; + + /* Saturation ??? */ + if (sum> 32767.) { sum=32767.; peak++; } + if (sum< -32768.) { sum=-32768; peak++; } + result[sample] = (sample_t) sum; + } + + /* The core of the buffer */ + for (sample = ORDER2; sample < length - ORDER + ORDER2 ; sample++ ) + { + sum = 0.0; + sample_window= sample - ORDER2; + + for (i = 0; i < ORDER ;i++) + sum += data[sample_window++] * coef[i]; + + /* Saturation ??? */ + if (sum> 32767.) { sum=32767.; peak++; } + if (sum< -32768.) { sum=-32768; peak++; } + result[sample] = (sample_t) sum; + } + + /* Simulate 0 at the end of the buffer */ + for (sample = length - ORDER + ORDER2; sample < length ; sample++ ) + { + sum = 0.0; + sample_window= sample - ORDER2; + + for (i = 0; i < ORDER ;i++) + sum += coef[i] * + ((sample_window>=length)? 0.0 : data[sample_window++]) ; + + /* Saturation ??? */ + if (sum> 32767.) { sum=32767.; peak++; } + if (sum< -32768.) { sum=-32768; peak++; } + result[sample] = (sample_t) sum; + } + + if (peak) + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "Saturation %2.3f %%.", 100.0*peak/ (float) length); +} + +/***********************************************************************/ +/* Prevent aliasing by filtering any freq above the output_rate */ +/* */ +/* I don't worry about looping point -> they will remain soft if they */ +/* were already */ +/***********************************************************************/ +void antialiasing(Sample *sp, int32 output_rate ) +{ + sample_t *temp; + int i; + float fir_symetric[ORDER]; + float fir_coef[ORDER2]; + float freq_cut; /* cutoff frequency [0..1.0] FREQ_CUT/SAMP_FREQ*/ + + + ctl->cmsg(CMSG_INFO, VERB_NOISY, "Antialiasing: Fsample=%iKHz", + sp->sample_rate); + + /* No oversampling */ + if (output_rate>=sp->sample_rate) + return; + + freq_cut= (float) output_rate / (float) sp->sample_rate; + ctl->cmsg(CMSG_INFO, VERB_NOISY, "Antialiasing: cutoff=%f%%", + freq_cut*100.); + + designfir(fir_coef,freq_cut); + + /* Make the filter symetric */ + for (i = 0 ; idata_length); + memcpy(temp,sp->data,sp->data_length); + + filter(sp->data,temp,sp->data_length/sizeof(sample_t),fir_symetric); + + free(temp); +} diff --git a/timidity/filter.h b/timidity/filter.h new file mode 100644 index 00000000..7c929143 --- /dev/null +++ b/timidity/filter.h @@ -0,0 +1,35 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + filter.h : written by Vincent Pagel ( pagel@loria.fr ) + + implements fir antialiasing filter : should help when setting sample + rates as low as 8Khz. + + */ + +/* Order of the FIR filter = 20 should be enough ! */ +#define ORDER 20 +#define ORDER2 ORDER/2 + +#ifndef PI +#define PI 3.14159265 +#endif + +extern void antialiasing(Sample *sp, int32 output_rate); diff --git a/timidity/instrum.c b/timidity/instrum.c new file mode 100644 index 00000000..9df6ed45 --- /dev/null +++ b/timidity/instrum.c @@ -0,0 +1,662 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + instrum.c + + Code to load and unload GUS-compatible instrument patches. + +*/ + +#include +#include + +#if defined(__FreeBSD__) || defined (__WIN32__) +#include +#else +#include +#endif + +#include "config.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "output.h" +#include "controls.h" +#include "resample.h" +#include "tables.h" +#include "filter.h" + +/* Some functions get aggravated if not even the standard banks are + available. */ +static ToneBank standard_tonebank, standard_drumset; +ToneBank + *tonebank[128]={&standard_tonebank}, + *drumset[128]={&standard_drumset}; + +/* This is a special instrument, used for all melodic programs */ +Instrument *default_instrument=0; + +/* This is only used for tracks that don't specify a program */ +int default_program=DEFAULT_PROGRAM; + +int antialiasing_allowed=0; +#ifdef FAST_DECAY +int fast_decay=1; +#else +int fast_decay=0; +#endif + +static void free_instrument(Instrument *ip) +{ + Sample *sp; + int i; + if (!ip) return; + for (i=0; isamples; i++) + { + sp=&(ip->sample[i]); + free(sp->data); + } + free(ip->sample); + free(ip); +} + +static void free_bank(int dr, int b) +{ + int i; + ToneBank *bank=((dr) ? drumset[b] : tonebank[b]); + for (i=0; i<128; i++) + if (bank->tone[i].instrument) + { + /* Not that this could ever happen, of course */ + if (bank->tone[i].instrument != MAGIC_LOAD_INSTRUMENT) + free_instrument(bank->tone[i].instrument); + bank->tone[i].instrument=0; + } +} + +static int32 convert_envelope_rate(uint8 rate) +{ + int32 r; + + r=3-((rate>>6) & 0x3); + r*=3; + r = (int32)(rate & 0x3f) << r; /* 6.9 fixed point */ + + /* 15.15 fixed point. */ + return (((r * 44100) / play_mode->rate) * control_ratio) + << ((fast_decay) ? 10 : 9); +} + +static int32 convert_envelope_offset(uint8 offset) +{ + /* This is not too good... Can anyone tell me what these values mean? + Are they GUS-style "exponential" volumes? And what does that mean? */ + + /* 15.15 fixed point */ + return offset << (7+15); +} + +static int32 convert_tremolo_sweep(uint8 sweep) +{ + if (!sweep) + return 0; + + return + ((control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) / + (play_mode->rate * sweep); +} + +static int32 convert_vibrato_sweep(uint8 sweep, int32 vib_control_ratio) +{ + if (!sweep) + return 0; + + return + (int32) (FSCALE((double) (vib_control_ratio) * SWEEP_TUNING, SWEEP_SHIFT) + / (double)(play_mode->rate * sweep)); + + /* this was overflowing with seashore.pat + + ((vib_control_ratio * SWEEP_TUNING) << SWEEP_SHIFT) / + (play_mode->rate * sweep); */ +} + +static int32 convert_tremolo_rate(uint8 rate) +{ + return + ((SINE_CYCLE_LENGTH * control_ratio * rate) << RATE_SHIFT) / + (TREMOLO_RATE_TUNING * play_mode->rate); +} + +static int32 convert_vibrato_rate(uint8 rate) +{ + /* Return a suitable vibrato_control_ratio value */ + return + (VIBRATO_RATE_TUNING * play_mode->rate) / + (rate * 2 * VIBRATO_SAMPLE_INCREMENTS); +} + +static void reverse_data(int16 *sp, int32 ls, int32 le) +{ + int16 s, *ep=sp+le; + sp+=ls; + le-=ls; + le/=2; + while (le--) + { + s=*sp; + *sp++=*ep; + *ep--=s; + } +} + +/* + If panning or note_to_use != -1, it will be used for all samples, + instead of the sample-specific values in the instrument file. + + For note_to_use, any value <0 or >127 will be forced to 0. + + For other parameters, 1 means yes, 0 means no, other values are + undefined. + + TODO: do reverse loops right */ +static Instrument *load_instrument(char *name, int percussion, + int panning, int amp, int note_to_use, + int strip_loop, int strip_envelope, + int strip_tail) +{ + Instrument *ip; + Sample *sp; + FILE *fp; + uint8 tmp[1024]; + int i,j,noluck=0; +#ifdef PATCH_EXT_LIST + static char *patch_ext[] = PATCH_EXT_LIST; +#endif + + if (!name) return 0; + + /* Open patch file */ + if (!(fp=open_file(name, 1, OF_NORMAL))) + { + noluck=1; +#ifdef PATCH_EXT_LIST + /* Try with various extensions */ + for (i=0; patch_ext[i]; i++) + { + if (strlen(name)+strlen(patch_ext[i])<1024) + { + strcpy(tmp, name); + strcat(tmp, patch_ext[i]); + if ((fp=open_file(tmp, 1, OF_NORMAL))) + { + noluck=0; + break; + } + } + } +#endif + } + + if (noluck) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "Instrument `%s' can't be found.", name); + return 0; + } + + ctl->cmsg(CMSG_INFO, VERB_NOISY, "Loading instrument %s", current_filename); + + /* Read some headers and do cursory sanity checks. There are loads + of magic offsets. This could be rewritten... */ + + if ((239 != fread(tmp, 1, 239, fp)) || + (memcmp(tmp, "GF1PATCH110\0ID#000002", 22) && + memcmp(tmp, "GF1PATCH100\0ID#000002", 22))) /* don't know what the + differences are */ + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: not an instrument", name); + return 0; + } + + if (tmp[82] != 1 && tmp[82] != 0) /* instruments. To some patch makers, + 0 means 1 */ + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "Can't handle patches with %d instruments", tmp[82]); + return 0; + } + + if (tmp[151] != 1 && tmp[151] != 0) /* layers. What's a layer? */ + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "Can't handle instruments with %d layers", tmp[151]); + return 0; + } + + ip=safe_malloc(sizeof(Instrument)); + ip->samples = tmp[198]; + ip->sample = safe_malloc(sizeof(Sample) * ip->samples); + for (i=0; isamples; i++) + { + + uint8 fractions; + int32 tmplong; + uint16 tmpshort; + uint8 tmpchar; + +#define READ_CHAR(thing) \ + if (1 != fread(&tmpchar, 1, 1, fp)) goto fail; \ + thing = tmpchar; +#define READ_SHORT(thing) \ + if (1 != fread(&tmpshort, 2, 1, fp)) goto fail; \ + thing = LE_SHORT(tmpshort); +#define READ_LONG(thing) \ + if (1 != fread(&tmplong, 4, 1, fp)) goto fail; \ + thing = LE_LONG(tmplong); + + skip(fp, 7); /* Skip the wave name */ + + if (1 != fread(&fractions, 1, 1, fp)) + { + fail: + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Error reading sample %d", i); + for (j=0; jsample[j].data); + free(ip->sample); + free(ip); + return 0; + } + + sp=&(ip->sample[i]); + + READ_LONG(sp->data_length); + READ_LONG(sp->loop_start); + READ_LONG(sp->loop_end); + READ_SHORT(sp->sample_rate); + READ_LONG(sp->low_freq); + READ_LONG(sp->high_freq); + READ_LONG(sp->root_freq); + skip(fp, 2); /* Why have a "root frequency" and then "tuning"?? */ + + READ_CHAR(tmp[0]); + + if (panning==-1) + sp->panning = (tmp[0] * 8 + 4) & 0x7f; + else + sp->panning=(uint8)(panning & 0x7F); + + /* envelope, tremolo, and vibrato */ + if (18 != fread(tmp, 1, 18, fp)) goto fail; + + if (!tmp[13] || !tmp[14]) + { + sp->tremolo_sweep_increment= + sp->tremolo_phase_increment=sp->tremolo_depth=0; + ctl->cmsg(CMSG_INFO, VERB_DEBUG, " * no tremolo"); + } + else + { + sp->tremolo_sweep_increment=convert_tremolo_sweep(tmp[12]); + sp->tremolo_phase_increment=convert_tremolo_rate(tmp[13]); + sp->tremolo_depth=tmp[14]; + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + " * tremolo: sweep %d, phase %d, depth %d", + sp->tremolo_sweep_increment, sp->tremolo_phase_increment, + sp->tremolo_depth); + } + + if (!tmp[16] || !tmp[17]) + { + sp->vibrato_sweep_increment= + sp->vibrato_control_ratio=sp->vibrato_depth=0; + ctl->cmsg(CMSG_INFO, VERB_DEBUG, " * no vibrato"); + } + else + { + sp->vibrato_control_ratio=convert_vibrato_rate(tmp[16]); + sp->vibrato_sweep_increment= + convert_vibrato_sweep(tmp[15], sp->vibrato_control_ratio); + sp->vibrato_depth=tmp[17]; + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + " * vibrato: sweep %d, ctl %d, depth %d", + sp->vibrato_sweep_increment, sp->vibrato_control_ratio, + sp->vibrato_depth); + + } + + READ_CHAR(sp->modes); + + skip(fp, 40); /* skip the useless scale frequency, scale factor + (what's it mean?), and reserved space */ + + /* Mark this as a fixed-pitch instrument if such a deed is desired. */ + if (note_to_use!=-1) + sp->note_to_use=(uint8)(note_to_use); + else + sp->note_to_use=0; + + /* seashore.pat in the Midia patch set has no Sustain. I don't + understand why, and fixing it by adding the Sustain flag to + all looped patches probably breaks something else. We do it + anyway. */ + + if (sp->modes & MODES_LOOPING) + sp->modes |= MODES_SUSTAIN; + + /* Strip any loops and envelopes we're permitted to */ + if ((strip_loop==1) && + (sp->modes & (MODES_SUSTAIN | MODES_LOOPING | + MODES_PINGPONG | MODES_REVERSE))) + { + ctl->cmsg(CMSG_INFO, VERB_DEBUG, " - Removing loop and/or sustain"); + sp->modes &=~(MODES_SUSTAIN | MODES_LOOPING | + MODES_PINGPONG | MODES_REVERSE); + } + + if (strip_envelope==1) + { + if (sp->modes & MODES_ENVELOPE) + ctl->cmsg(CMSG_INFO, VERB_DEBUG, " - Removing envelope"); + sp->modes &= ~MODES_ENVELOPE; + } + else if (strip_envelope != 0) + { + /* Have to make a guess. */ + if (!(sp->modes & (MODES_LOOPING | MODES_PINGPONG | MODES_REVERSE))) + { + /* No loop? Then what's there to sustain? No envelope needed + either... */ + sp->modes &= ~(MODES_SUSTAIN|MODES_ENVELOPE); + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + " - No loop, removing sustain and envelope"); + } + else if (!memcmp(tmp, "??????", 6) || tmp[11] >= 100) + { + /* Envelope rates all maxed out? Envelope end at a high "offset"? + That's a weird envelope. Take it out. */ + sp->modes &= ~MODES_ENVELOPE; + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + " - Weirdness, removing envelope"); + } + else if (!(sp->modes & MODES_SUSTAIN)) + { + /* No sustain? Then no envelope. I don't know if this is + justified, but patches without sustain usually don't need the + envelope either... at least the Gravis ones. They're mostly + drums. I think. */ + sp->modes &= ~MODES_ENVELOPE; + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + " - No sustain, removing envelope"); + } + } + + for (j=0; j<6; j++) + { + sp->envelope_rate[j]= + convert_envelope_rate(tmp[j]); + sp->envelope_offset[j]= + convert_envelope_offset(tmp[6+j]); + } + + /* Then read the sample data */ + sp->data = safe_malloc(sp->data_length); + if (1 != fread(sp->data, sp->data_length, 1, fp)) + goto fail; + + if (!(sp->modes & MODES_16BIT)) /* convert to 16-bit data */ + { + int32 i=sp->data_length; + uint8 *cp=(uint8 *)(sp->data); + uint16 *tmp,*new; + tmp=new=safe_malloc(sp->data_length*2); + while (i--) + *tmp++ = (uint16)(*cp++) << 8; + cp=(uint8 *)(sp->data); + sp->data = (sample_t *)new; + free(cp); + sp->data_length *= 2; + sp->loop_start *= 2; + sp->loop_end *= 2; + } +#ifndef LITTLE_ENDIAN + else + /* convert to machine byte order */ + { + int32 i=sp->data_length/2; + int16 *tmp=(int16 *)sp->data,s; + while (i--) + { + s=LE_SHORT(*tmp); + *tmp++=s; + } + } +#endif + + if (sp->modes & MODES_UNSIGNED) /* convert to signed data */ + { + int32 i=sp->data_length/2; + int16 *tmp=(int16 *)sp->data; + while (i--) + *tmp++ ^= 0x8000; + } + + /* Reverse reverse loops and pass them off as normal loops */ + if (sp->modes & MODES_REVERSE) + { + int32 t; + /* The GUS apparently plays reverse loops by reversing the + whole sample. We do the same because the GUS does not SUCK. */ + + ctl->cmsg(CMSG_WARNING, VERB_NORMAL, "Reverse loop in %s", name); + reverse_data((int16 *)sp->data, 0, sp->data_length/2); + + t=sp->loop_start; + sp->loop_start=sp->data_length - sp->loop_end; + sp->loop_end=sp->data_length - t; + + sp->modes &= ~MODES_REVERSE; + sp->modes |= MODES_LOOPING; /* just in case */ + } + + /* If necessary do some anti-aliasing filtering */ + + if (antialiasing_allowed) + antialiasing(sp,play_mode->rate); + +#ifdef ADJUST_SAMPLE_VOLUMES + if (amp!=-1) + sp->volume=(double)(amp) / 100.0; + else + { + /* Try to determine a volume scaling factor for the sample. + This is a very crude adjustment, but things sound more + balanced with it. Still, this should be a runtime option. */ + int32 i=sp->data_length/2; + int16 maxamp=0,a; + int16 *tmp=(int16 *)sp->data; + while (i--) + { + a=*tmp++; + if (a<0) a=-a; + if (a>maxamp) + maxamp=a; + } + sp->volume=32768.0 / (double)(maxamp); + ctl->cmsg(CMSG_INFO, VERB_DEBUG, " * volume comp: %f", sp->volume); + } +#else + if (amp!=-1) + sp->volume=(double)(amp) / 100.0; + else + sp->volume=1.0; +#endif + + sp->data_length /= 2; /* These are in bytes. Convert into samples. */ + sp->loop_start /= 2; + sp->loop_end /= 2; + + /* Then fractional samples */ + sp->data_length <<= FRACTION_BITS; + sp->loop_start <<= FRACTION_BITS; + sp->loop_end <<= FRACTION_BITS; + + /* Adjust for fractional loop points. This is a guess. Does anyone + know what "fractions" really stands for? */ + sp->loop_start |= + (fractions & 0x0F) << (FRACTION_BITS-4); + sp->loop_end |= + ((fractions>>4) & 0x0F) << (FRACTION_BITS-4); + + /* If this instrument will always be played on the same note, + and it's not looped, we can resample it now. */ + if (sp->note_to_use && !(sp->modes & MODES_LOOPING)) + pre_resample(sp); + +#ifdef LOOKUP_HACK + /* Squash the 16-bit data into 8 bits. */ + { + uint8 *gulp,*ulp; + int16 *swp; + int l=sp->data_length >> FRACTION_BITS; + gulp=ulp=safe_malloc(l+1); + swp=(int16 *)sp->data; + while(l--) + *ulp++ = (*swp++ >> 8) & 0xFF; + free(sp->data); + sp->data=(sample_t *)gulp; + } +#endif + + if (strip_tail==1) + { + /* Let's not really, just say we did. */ + ctl->cmsg(CMSG_INFO, VERB_DEBUG, " - Stripping tail"); + sp->data_length = sp->loop_end; + } + } + + close_file(fp); + return ip; +} + +static int fill_bank(int dr, int b) +{ + int i, errors=0; + ToneBank *bank=((dr) ? drumset[b] : tonebank[b]); + if (!bank) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "Huh. Tried to load instruments in non-existent %s %d", + (dr) ? "drumset" : "tone bank", b); + return 0; + } + for (i=0; i<128; i++) + { + if (bank->tone[i].instrument==MAGIC_LOAD_INSTRUMENT) + { + if (!(bank->tone[i].name)) + { + ctl->cmsg(CMSG_WARNING, (b!=0) ? VERB_VERBOSE : VERB_NORMAL, + "No instrument mapped to %s %d, program %d%s", + (dr)? "drum set" : "tone bank", b, i, + (b!=0) ? "" : " - this instrument will not be heard"); + if (b!=0) + { + /* Mark the corresponding instrument in the default + bank / drumset for loading (if it isn't already) */ + if (!dr) + { + if (!(standard_tonebank.tone[i].instrument)) + standard_tonebank.tone[i].instrument= + MAGIC_LOAD_INSTRUMENT; + } + else + { + if (!(standard_drumset.tone[i].instrument)) + standard_drumset.tone[i].instrument= + MAGIC_LOAD_INSTRUMENT; + } + } + bank->tone[i].instrument=0; + errors++; + } + else if (!(bank->tone[i].instrument= + load_instrument(bank->tone[i].name, + (dr) ? 1 : 0, + bank->tone[i].pan, + bank->tone[i].amp, + (bank->tone[i].note!=-1) ? + bank->tone[i].note : + ((dr) ? i : -1), + (bank->tone[i].strip_loop!=-1) ? + bank->tone[i].strip_loop : + ((dr) ? 1 : -1), + (bank->tone[i].strip_envelope != -1) ? + bank->tone[i].strip_envelope : + ((dr) ? 1 : -1), + bank->tone[i].strip_tail ))) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "Couldn't load instrument %s (%s %d, program %d)", + bank->tone[i].name, + (dr)? "drum set" : "tone bank", b, i); + errors++; + } + } + } + return errors; +} + +int load_missing_instruments(void) +{ + int i=128,errors=0; + while (i--) + { + if (tonebank[i]) + errors+=fill_bank(0,i); + if (drumset[i]) + errors+=fill_bank(1,i); + } + return errors; +} + +void free_instruments(void) +{ + int i=128; + while(i--) + { + if (tonebank[i]) + free_bank(0,i); + if (drumset[i]) + free_bank(1,i); + } +} + +int set_default_instrument(char *name) +{ + Instrument *ip; + if (!(ip=load_instrument(name, 0, -1, -1, -1, 0, 0, 0))) + return -1; + if (default_instrument) + free_instrument(default_instrument); + default_instrument=ip; + default_program=SPECIAL_PROGRAM; + return 0; +} diff --git a/timidity/instrum.h b/timidity/instrum.h new file mode 100644 index 00000000..775512b9 --- /dev/null +++ b/timidity/instrum.h @@ -0,0 +1,84 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + instrum.h + + */ + +typedef struct { + int32 + loop_start, loop_end, data_length, + sample_rate, low_freq, high_freq, root_freq; + int32 + envelope_rate[6], envelope_offset[6]; + float + volume; + sample_t *data; + int32 + tremolo_sweep_increment, tremolo_phase_increment, + vibrato_sweep_increment, vibrato_control_ratio; + uint8 + tremolo_depth, vibrato_depth, + modes; + int8 + panning, note_to_use; +} Sample; + +/* Bits in modes: */ +#define MODES_16BIT (1<<0) +#define MODES_UNSIGNED (1<<1) +#define MODES_LOOPING (1<<2) +#define MODES_PINGPONG (1<<3) +#define MODES_REVERSE (1<<4) +#define MODES_SUSTAIN (1<<5) +#define MODES_ENVELOPE (1<<6) + +typedef struct { + int samples; + Sample *sample; +} Instrument; + +typedef struct { + char *name; + Instrument *instrument; + int note, amp, pan, strip_loop, strip_envelope, strip_tail; +} ToneBankElement; + +/* A hack to delay instrument loading until after reading the + entire MIDI file. */ +#define MAGIC_LOAD_INSTRUMENT ((Instrument *)(-1)) + +typedef struct { + ToneBankElement tone[128]; +} ToneBank; + +extern ToneBank *tonebank[], *drumset[]; + +extern Instrument *default_instrument; +extern int default_program; +extern int antialiasing_allowed; +extern int fast_decay; +extern int free_instruments_afterwards; + +#define SPECIAL_PROGRAM -1 + +extern int load_missing_instruments(void); +extern void free_instruments(void); +extern int set_default_instrument(char *name); + diff --git a/timidity/mix.c b/timidity/mix.c new file mode 100644 index 00000000..f8c3d3be --- /dev/null +++ b/timidity/mix.c @@ -0,0 +1,566 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + Suddenly, you realize that this program is free software; you get + an overwhelming urge to 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 another copy of the GNU General Public + License along with this program; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + I bet they'll be amazed. + + mix.c */ + +#include +#include +#include + +#include "config.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "output.h" +#include "controls.h" +#include "tables.h" +#include "resample.h" +#include "mix.h" + +/* Returns 1 if envelope runs out */ +int recompute_envelope(int v) +{ + int stage; + + stage = voice[v].envelope_stage; + + if (stage>5) + { + /* Envelope ran out. */ + int tmp=(voice[v].status == VOICE_DIE); /* Already displayed as dead */ + voice[v].status = VOICE_FREE; + if(!tmp) + ctl->note(v); + return 1; + } + + if (voice[v].sample->modes & MODES_ENVELOPE) + { + if (voice[v].status==VOICE_ON || voice[v].status==VOICE_SUSTAINED) + { + if (stage>2) + { + /* Freeze envelope until note turns off. Trumpets want this. */ + voice[v].envelope_increment=0; + return 0; + } + } + } + voice[v].envelope_stage=stage+1; + + if (voice[v].envelope_volume==voice[v].sample->envelope_offset[stage]) + return recompute_envelope(v); + voice[v].envelope_target=voice[v].sample->envelope_offset[stage]; + voice[v].envelope_increment = voice[v].sample->envelope_rate[stage]; + if (voice[v].envelope_targetmodes & MODES_ENVELOPE) + { + lamp *= vol_table[voice[v].envelope_volume>>23]; + ramp *= vol_table[voice[v].envelope_volume>>23]; + } + + la = FSCALE(lamp,AMP_BITS); + + if (la>MAX_AMP_VALUE) + la=MAX_AMP_VALUE; + + ra = FSCALE(ramp,AMP_BITS); + if (ra>MAX_AMP_VALUE) + ra=MAX_AMP_VALUE; + + + voice[v].left_mix=FINAL_VOLUME(la); + voice[v].right_mix=FINAL_VOLUME(ra); + } + else + { + if (voice[v].tremolo_phase_increment) + lamp *= voice[v].tremolo_volume; + if (voice[v].sample->modes & MODES_ENVELOPE) + lamp *= vol_table[voice[v].envelope_volume>>23]; + + la = FSCALE(lamp,AMP_BITS); + + if (la>MAX_AMP_VALUE) + la=MAX_AMP_VALUE; + + voice[v].left_mix=FINAL_VOLUME(la); + } +} + +static int update_envelope(int v) +{ + voice[v].envelope_volume += voice[v].envelope_increment; + /* Why is there no ^^ operator?? */ + if (((voice[v].envelope_increment < 0) && + (voice[v].envelope_volume <= voice[v].envelope_target)) || + ((voice[v].envelope_increment > 0) && + (voice[v].envelope_volume >= voice[v].envelope_target))) + { + voice[v].envelope_volume = voice[v].envelope_target; + if (recompute_envelope(v)) + return 1; + } + return 0; +} + +static void update_tremolo(int v) +{ + int32 depth=voice[v].sample->tremolo_depth<<7; + + if (voice[v].tremolo_sweep) + { + /* Update sweep position */ + + voice[v].tremolo_sweep_position += voice[v].tremolo_sweep; + if (voice[v].tremolo_sweep_position>=(1<>= SWEEP_SHIFT; + } + } + + voice[v].tremolo_phase += voice[v].tremolo_phase_increment; + + /* if (voice[v].tremolo_phase >= (SINE_CYCLE_LENGTH<> RATE_SHIFT) + 1.0) + * depth * TREMOLO_AMPLITUDE_TUNING, + 17); + + /* I'm not sure about the +1.0 there -- it makes tremoloed voices' + volumes on average the lower the higher the tremolo amplitude. */ +} + +/* Returns 1 if the note died */ +static int update_signal(int v) +{ + if (voice[v].envelope_increment && update_envelope(v)) + return 1; + + if (voice[v].tremolo_phase_increment) + update_tremolo(v); + + apply_envelope_to_amp(v); + return 0; +} + +#ifdef LOOKUP_HACK +# define MIXATION(a) *lp++ += mixup[(a<<8) | (uint8)s]; +#else +# define MIXATION(a) *lp++ += (a)*s; +#endif + +static void mix_mystery_signal(sample_t *sp, int32 *lp, int v, int count) +{ + Voice *vp = voice + v; + final_volume_t + left=vp->left_mix, + right=vp->right_mix; + int cc; + sample_t s; + + if (!(cc = vp->control_counter)) + { + cc = control_ratio; + if (update_signal(v)) + return; /* Envelope ran out */ + left = vp->left_mix; + right = vp->right_mix; + } + + while (count) + if (cc < count) + { + count -= cc; + while (cc--) + { + s = *sp++; + MIXATION(left); + MIXATION(right); + } + cc = control_ratio; + if (update_signal(v)) + return; /* Envelope ran out */ + left = vp->left_mix; + right = vp->right_mix; + } + else + { + vp->control_counter = cc - count; + while (count--) + { + s = *sp++; + MIXATION(left); + MIXATION(right); + } + return; + } +} + +static void mix_center_signal(sample_t *sp, int32 *lp, int v, int count) +{ + Voice *vp = voice + v; + final_volume_t + left=vp->left_mix; + int cc; + sample_t s; + + if (!(cc = vp->control_counter)) + { + cc = control_ratio; + if (update_signal(v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + + while (count) + if (cc < count) + { + count -= cc; + while (cc--) + { + s = *sp++; + MIXATION(left); + MIXATION(left); + } + cc = control_ratio; + if (update_signal(v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + else + { + vp->control_counter = cc - count; + while (count--) + { + s = *sp++; + MIXATION(left); + MIXATION(left); + } + return; + } +} + +static void mix_single_signal(sample_t *sp, int32 *lp, int v, int count) +{ + Voice *vp = voice + v; + final_volume_t + left=vp->left_mix; + int cc; + sample_t s; + + if (!(cc = vp->control_counter)) + { + cc = control_ratio; + if (update_signal(v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + + while (count) + if (cc < count) + { + count -= cc; + while (cc--) + { + s = *sp++; + MIXATION(left); + lp++; + } + cc = control_ratio; + if (update_signal(v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + else + { + vp->control_counter = cc - count; + while (count--) + { + s = *sp++; + MIXATION(left); + lp++; + } + return; + } +} + +static void mix_mono_signal(sample_t *sp, int32 *lp, int v, int count) +{ + Voice *vp = voice + v; + final_volume_t + left=vp->left_mix; + int cc; + sample_t s; + + if (!(cc = vp->control_counter)) + { + cc = control_ratio; + if (update_signal(v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + + while (count) + if (cc < count) + { + count -= cc; + while (cc--) + { + s = *sp++; + MIXATION(left); + } + cc = control_ratio; + if (update_signal(v)) + return; /* Envelope ran out */ + left = vp->left_mix; + } + else + { + vp->control_counter = cc - count; + while (count--) + { + s = *sp++; + MIXATION(left); + } + return; + } +} + +static void mix_mystery(sample_t *sp, int32 *lp, int v, int count) +{ + final_volume_t + left=voice[v].left_mix, + right=voice[v].right_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); + MIXATION(right); + } +} + +static void mix_center(sample_t *sp, int32 *lp, int v, int count) +{ + final_volume_t + left=voice[v].left_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); + MIXATION(left); + } +} + +static void mix_single(sample_t *sp, int32 *lp, int v, int count) +{ + final_volume_t + left=voice[v].left_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); + lp++; + } +} + +static void mix_mono(sample_t *sp, int32 *lp, int v, int count) +{ + final_volume_t + left=voice[v].left_mix; + sample_t s; + + while (count--) + { + s = *sp++; + MIXATION(left); + } +} + +/* Ramp a note out in c samples */ +static void ramp_out(sample_t *sp, int32 *lp, int v, int32 c) +{ + + /* should be final_volume_t, but uint8 gives trouble. */ + int32 left, right, li, ri; + + sample_t s=0; /* silly warning about uninitialized s */ + + left=voice[v].left_mix; + li=-(left/c); + if (!li) li=-1; + + /* printf("Ramping out: left=%d, c=%d, li=%d\n", left, c, li); */ + + if (!(play_mode->encoding & PE_MONO)) + { + if (voice[v].panned==PANNED_MYSTERY) + { + right=voice[v].right_mix; + ri=-(right/c); + while (c--) + { + left += li; + if (left<0) + left=0; + right += ri; + if (right<0) + right=0; + s=*sp++; + MIXATION(left); + MIXATION(right); + } + } + else if (voice[v].panned==PANNED_CENTER) + { + while (c--) + { + left += li; + if (left<0) + return; + s=*sp++; + MIXATION(left); + MIXATION(left); + } + } + else if (voice[v].panned==PANNED_LEFT) + { + while (c--) + { + left += li; + if (left<0) + return; + s=*sp++; + MIXATION(left); + lp++; + } + } + else if (voice[v].panned==PANNED_RIGHT) + { + while (c--) + { + left += li; + if (left<0) + return; + s=*sp++; + lp++; + MIXATION(left); + } + } + } + else + { + /* Mono output. */ + while (c--) + { + left += li; + if (left<0) + return; + s=*sp++; + MIXATION(left); + } + } +} + + +/**************** interface function ******************/ + +void mix_voice(int32 *buf, int v, int32 c) +{ + Voice *vp=voice+v; + sample_t *sp; + if (vp->status==VOICE_DIE) + { + if (c>=MAX_DIE_TIME) + c=MAX_DIE_TIME; + sp=resample_voice(v, &c); + ramp_out(sp, buf, v, c); + vp->status=VOICE_FREE; + } + else + { + sp=resample_voice(v, &c); + if (play_mode->encoding & PE_MONO) + { + /* Mono output. */ + if (vp->envelope_increment || vp->tremolo_phase_increment) + mix_mono_signal(sp, buf, v, c); + else + mix_mono(sp, buf, v, c); + } + else + { + if (vp->panned == PANNED_MYSTERY) + { + if (vp->envelope_increment || vp->tremolo_phase_increment) + mix_mystery_signal(sp, buf, v, c); + else + mix_mystery(sp, buf, v, c); + } + else if (vp->panned == PANNED_CENTER) + { + if (vp->envelope_increment || vp->tremolo_phase_increment) + mix_center_signal(sp, buf, v, c); + else + mix_center(sp, buf, v, c); + } + else + { + /* It's either full left or full right. In either case, + every other sample is 0. Just get the offset right: */ + if (vp->panned == PANNED_RIGHT) buf++; + + if (vp->envelope_increment || vp->tremolo_phase_increment) + mix_single_signal(sp, buf, v, c); + else + mix_single(sp, buf, v, c); + } + } + } +} diff --git a/timidity/mix.h b/timidity/mix.h new file mode 100644 index 00000000..f52cbe93 --- /dev/null +++ b/timidity/mix.h @@ -0,0 +1,27 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + In case you haven't heard, 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + mix.h + +*/ + +extern void mix_voice(int32 *buf, int v, int32 c); +extern int recompute_envelope(int v); +extern void apply_envelope_to_amp(int v); diff --git a/timidity/output.c b/timidity/output.c new file mode 100644 index 00000000..7fa4cd61 --- /dev/null +++ b/timidity/output.c @@ -0,0 +1,138 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + output.c + + Audio output (to file / device) functions. +*/ + +#include "config.h" +#include "output.h" +#include "tables.h" + + +#ifdef SDL +extern PlayMode sdl_play_mode; +#define DEFAULT_PLAY_MODE &sdl_play_mode +#endif + +PlayMode *play_mode_list[] = { +#ifdef DEFAULT_PLAY_MODE + DEFAULT_PLAY_MODE, +#endif + 0 +}; + +#ifdef DEFAULT_PLAY_MODE + PlayMode *play_mode=DEFAULT_PLAY_MODE; +#endif + +/*****************************************************************/ +/* Some functions to convert signed 32-bit data to other formats */ + +void s32tos8(void *dp, int32 *lp, int32 c) +{ + int8 *cp=(int8 *)(dp); + int32 l; + while (c--) + { + l=(*lp++)>>(32-8-GUARD_BITS); + if (l>127) l=127; + else if (l<-128) l=-128; + *cp++ = (int8) (l); + } +} + +void s32tou8(void *dp, int32 *lp, int32 c) +{ + uint8 *cp=(uint8 *)(dp); + int32 l; + while (c--) + { + l=(*lp++)>>(32-8-GUARD_BITS); + if (l>127) l=127; + else if (l<-128) l=-128; + *cp++ = 0x80 ^ ((uint8) l); + } +} + +void s32tos16(void *dp, int32 *lp, int32 c) +{ + int16 *sp=(int16 *)(dp); + int32 l; + while (c--) + { + l=(*lp++)>>(32-16-GUARD_BITS); + if (l > 32767) l=32767; + else if (l<-32768) l=-32768; + *sp++ = (int16)(l); + } +} + +void s32tou16(void *dp, int32 *lp, int32 c) +{ + uint16 *sp=(uint16 *)(dp); + int32 l; + while (c--) + { + l=(*lp++)>>(32-16-GUARD_BITS); + if (l > 32767) l=32767; + else if (l<-32768) l=-32768; + *sp++ = 0x8000 ^ (uint16)(l); + } +} + +void s32tos16x(void *dp, int32 *lp, int32 c) +{ + int16 *sp=(int16 *)(dp); + int32 l; + while (c--) + { + l=(*lp++)>>(32-16-GUARD_BITS); + if (l > 32767) l=32767; + else if (l<-32768) l=-32768; + *sp++ = XCHG_SHORT((int16)(l)); + } +} + +void s32tou16x(void *dp, int32 *lp, int32 c) +{ + uint16 *sp=(uint16 *)(dp); + int32 l; + while (c--) + { + l=(*lp++)>>(32-16-GUARD_BITS); + if (l > 32767) l=32767; + else if (l<-32768) l=-32768; + *sp++ = XCHG_SHORT(0x8000 ^ (uint16)(l)); + } +} + +void s32toulaw(void *dp, int32 *lp, int32 c) +{ + uint8 *up=(uint8 *)(dp); + int32 l; + while (c--) + { + l=(*lp++)>>(32-13-GUARD_BITS); + if (l > 4095) l=4095; + else if (l<-4096) l=-4096; + *up++ = _l2u[l]; + } +} diff --git a/timidity/output.h b/timidity/output.h new file mode 100644 index 00000000..865339ab --- /dev/null +++ b/timidity/output.h @@ -0,0 +1,75 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + output.h + +*/ + +/* Data format encoding bits */ + +#define PE_MONO 0x01 /* versus stereo */ +#define PE_SIGNED 0x02 /* versus unsigned */ +#define PE_16BIT 0x04 /* versus 8-bit */ +#define PE_ULAW 0x08 /* versus linear */ +#define PE_BYTESWAP 0x10 /* versus the other way */ + +typedef struct { + int32 rate, encoding; + char *id_name; +} PlayMode; + +extern PlayMode *play_mode_list[], *play_mode; +extern int init_buffers(int kbytes); + +/* Conversion functions -- These overwrite the int32 data in *lp with + data in another format */ + +/* The size of the output buffers */ +extern int AUDIO_BUFFER_SIZE; + +/* Actual copy function */ +extern void (*s32tobuf)(void *dp, int32 *lp, int32 c); + +/* 8-bit signed and unsigned*/ +extern void s32tos8(void *dp, int32 *lp, int32 c); +extern void s32tou8(void *dp, int32 *lp, int32 c); + +/* 16-bit */ +extern void s32tos16(void *dp, int32 *lp, int32 c); +extern void s32tou16(void *dp, int32 *lp, int32 c); + +/* byte-exchanged 16-bit */ +extern void s32tos16x(void *dp, int32 *lp, int32 c); +extern void s32tou16x(void *dp, int32 *lp, int32 c); + +/* uLaw (8 bits) */ +extern void s32toulaw(void *dp, int32 *lp, int32 c); + +/* little-endian and big-endian specific */ +#ifdef LITTLE_ENDIAN +#define s32tou16l s32tou16 +#define s32tou16b s32tou16x +#define s32tos16l s32tos16 +#define s32tos16b s32tos16x +#else +#define s32tou16l s32tou16x +#define s32tou16b s32tou16 +#define s32tos16l s32tos16x +#define s32tos16b s32tos16 +#endif diff --git a/timidity/playmidi.c b/timidity/playmidi.c new file mode 100644 index 00000000..09e8e54f --- /dev/null +++ b/timidity/playmidi.c @@ -0,0 +1,967 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + playmidi.c -- random stuff in need of rearrangement + +*/ + +#include +#ifndef WIN32 +#include +#endif +#include +#include + +#include "config.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "readmidi.h" +#include "output.h" +#include "mix.h" +#include "controls.h" +#include "timidity.h" + +#include "tables.h" + +Channel channel[16]; +Voice voice[MAX_VOICES]; + +int + voices=DEFAULT_VOICES; + +int32 + control_ratio=0, + amplification=DEFAULT_AMPLIFICATION; + +float + master_volume; + +int32 drumchannels=DEFAULT_DRUMCHANNELS; +int adjust_panning_immediately=0; + +struct _MidiSong { + int32 samples; + MidiEvent *events; +}; +static int midi_playing = 0; +static int32 lost_notes, cut_notes; +static int32 *buffer_pointer; +static int32 buffered_count; +extern int32 *common_buffer; + +static MidiEvent *event_list, *current_event; +static int32 sample_count, current_sample; + +static void adjust_amplification(void) +{ + master_volume = (double)(amplification) / 100.0L; +} + +static void reset_voices(void) +{ + int i; + for (i=0; ivolume(c, channel[c].volume); + ctl->expression(c, channel[c].expression); + ctl->sustain(c, channel[c].sustain); + ctl->pitch_bend(c, channel[c].pitchbend); +} + +static void reset_midi(void) +{ + int i; + for (i=0; i<16; i++) + { + reset_controllers(i); + /* The rest of these are unaffected by the Reset All Controllers event */ + channel[i].program=default_program; + channel[i].panning=NO_PANNING; + channel[i].pitchsens=2; + channel[i].bank=0; /* tone bank or drum set */ + } + reset_voices(); +} + +static void select_sample(int v, Instrument *ip) +{ + int32 f, cdiff, diff; + int s,i; + Sample *sp, *closest; + + s=ip->samples; + sp=ip->sample; + + if (s==1) + { + voice[v].sample=sp; + return; + } + + f=voice[v].orig_frequency; + for (i=0; ilow_freq <= f && sp->high_freq >= f) + { + voice[v].sample=sp; + return; + } + sp++; + } + + /* + No suitable sample found! We'll select the sample whose root + frequency is closest to the one we want. (Actually we should + probably convert the low, high, and root frequencies to MIDI note + values and compare those.) */ + + cdiff=0x7FFFFFFF; + closest=sp=ip->sample; + for(i=0; iroot_freq - f; + if (diff<0) diff=-diff; + if (diffsample_rate) + return; + + if (voice[v].vibrato_control_ratio) + { + /* This instrument has vibrato. Invalidate any precomputed + sample_increments. */ + + int i=VIBRATO_SAMPLE_INCREMENTS; + while (i--) + voice[v].vibrato_sample_increment[i]=0; + } + + if (pb==0x2000 || pb<0 || pb>0x3FFF) + voice[v].frequency=voice[v].orig_frequency; + else + { + pb-=0x2000; + if (!(channel[voice[v].channel].pitchfactor)) + { + /* Damn. Somebody bent the pitch. */ + int32 i=pb*channel[voice[v].channel].pitchsens; + if (pb<0) + i=-i; + channel[voice[v].channel].pitchfactor= + bend_fine[(i>>5) & 0xFF] * bend_coarse[i>>13]; + } + if (pb>0) + voice[v].frequency= + (int32)(channel[voice[v].channel].pitchfactor * + (double)(voice[v].orig_frequency)); + else + voice[v].frequency= + (int32)((double)(voice[v].orig_frequency) / + channel[voice[v].channel].pitchfactor); + } + + a = FSCALE(((double)(voice[v].sample->sample_rate) * + (double)(voice[v].frequency)) / + ((double)(voice[v].sample->root_freq) * + (double)(play_mode->rate)), + FRACTION_BITS); + + if (sign) + a = -a; /* need to preserve the loop direction */ + + voice[v].sample_increment = (int32)(a); +} + +static void recompute_amp(int v) +{ + int32 tempamp; + + /* TODO: use fscale */ + + tempamp= (voice[v].velocity * + channel[voice[v].channel].volume * + channel[voice[v].channel].expression); /* 21 bits */ + + if (!(play_mode->encoding & PE_MONO)) + { + if (voice[v].panning > 60 && voice[v].panning < 68) + { + voice[v].panned=PANNED_CENTER; + + voice[v].left_amp= + FSCALENEG((double)(tempamp) * voice[v].sample->volume * master_volume, + 21); + } + else if (voice[v].panning<5) + { + voice[v].panned = PANNED_LEFT; + + voice[v].left_amp= + FSCALENEG((double)(tempamp) * voice[v].sample->volume * master_volume, + 20); + } + else if (voice[v].panning>123) + { + voice[v].panned = PANNED_RIGHT; + + voice[v].left_amp= /* left_amp will be used */ + FSCALENEG((double)(tempamp) * voice[v].sample->volume * master_volume, + 20); + } + else + { + voice[v].panned = PANNED_MYSTERY; + + voice[v].left_amp= + FSCALENEG((double)(tempamp) * voice[v].sample->volume * master_volume, + 27); + voice[v].right_amp=voice[v].left_amp * (voice[v].panning); + voice[v].left_amp *= (double)(127-voice[v].panning); + } + } + else + { + voice[v].panned=PANNED_CENTER; + + voice[v].left_amp= + FSCALENEG((double)(tempamp) * voice[v].sample->volume * master_volume, + 21); + } +} + +static void start_note(MidiEvent *e, int i) +{ + Instrument *ip; + int j; + + if (ISDRUMCHANNEL(e->channel)) + { + if (!(ip=drumset[channel[e->channel].bank]->tone[e->a].instrument)) + { + if (!(ip=drumset[0]->tone[e->a].instrument)) + return; /* No instrument? Then we can't play. */ + } + if (ip->samples != 1) + { + ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, + "Strange: percussion instrument with %d samples!", ip->samples); + } + + if (ip->sample->note_to_use) /* Do we have a fixed pitch? */ + voice[i].orig_frequency=freq_table[(int)(ip->sample->note_to_use)]; + else + voice[i].orig_frequency=freq_table[e->a & 0x7F]; + + /* drums are supposed to have only one sample */ + voice[i].sample=ip->sample; + } + else + { + if (channel[e->channel].program==SPECIAL_PROGRAM) + ip=default_instrument; + else if (!(ip=tonebank[channel[e->channel].bank]-> + tone[channel[e->channel].program].instrument)) + { + if (!(ip=tonebank[0]->tone[channel[e->channel].program].instrument)) + return; /* No instrument? Then we can't play. */ + } + + if (ip->sample->note_to_use) /* Fixed-pitch instrument? */ + voice[i].orig_frequency=freq_table[(int)(ip->sample->note_to_use)]; + else + voice[i].orig_frequency=freq_table[e->a & 0x7F]; + select_sample(i, ip); + } + + voice[i].status=VOICE_ON; + voice[i].channel=e->channel; + voice[i].note=e->a; + voice[i].velocity=e->b; + voice[i].sample_offset=0; + voice[i].sample_increment=0; /* make sure it isn't negative */ + + voice[i].tremolo_phase=0; + voice[i].tremolo_phase_increment=voice[i].sample->tremolo_phase_increment; + voice[i].tremolo_sweep=voice[i].sample->tremolo_sweep_increment; + voice[i].tremolo_sweep_position=0; + + voice[i].vibrato_sweep=voice[i].sample->vibrato_sweep_increment; + voice[i].vibrato_sweep_position=0; + voice[i].vibrato_control_ratio=voice[i].sample->vibrato_control_ratio; + voice[i].vibrato_control_counter=voice[i].vibrato_phase=0; + for (j=0; jchannel].panning != NO_PANNING) + voice[i].panning=channel[e->channel].panning; + else + voice[i].panning=voice[i].sample->panning; + + recompute_freq(i); + recompute_amp(i); + if (voice[i].sample->modes & MODES_ENVELOPE) + { + /* Ramp up from 0 */ + voice[i].envelope_stage=0; + voice[i].envelope_volume=0; + voice[i].control_counter=0; + recompute_envelope(i); + apply_envelope_to_amp(i); + } + else + { + voice[i].envelope_increment=0; + apply_envelope_to_amp(i); + } + ctl->note(i); +} + +static void kill_note(int i) +{ + voice[i].status=VOICE_DIE; + ctl->note(i); +} + +/* Only one instance of a note can be playing on a single channel. */ +static void note_on(MidiEvent *e) +{ + int i=voices, lowest=-1; + int32 lv=0x7FFFFFFF, v; + + while (i--) + { + if (voice[i].status == VOICE_FREE) + lowest=i; /* Can't get a lower volume than silence */ + else if (voice[i].channel==e->channel && + (voice[i].note==e->a || channel[voice[i].channel].mono)) + kill_note(i); + } + + if (lowest != -1) + { + /* Found a free voice. */ + start_note(e,lowest); + return; + } + + /* Look for the decaying note with the lowest volume */ + i=voices; + while (i--) + { + if ((voice[i].status!=VOICE_ON) && + (voice[i].status!=VOICE_DIE)) + { + v=voice[i].left_mix; + if ((voice[i].panned==PANNED_MYSTERY) && (voice[i].right_mix>v)) + v=voice[i].right_mix; + if (vnote(lowest); + start_note(e,lowest); + } + else + lost_notes++; +} + +static void finish_note(int i) +{ + if (voice[i].sample->modes & MODES_ENVELOPE) + { + /* We need to get the envelope out of Sustain stage */ + voice[i].envelope_stage=3; + voice[i].status=VOICE_OFF; + recompute_envelope(i); + apply_envelope_to_amp(i); + ctl->note(i); + } + else + { + /* Set status to OFF so resample_voice() will let this voice out + of its loop, if any. In any case, this voice dies when it + hits the end of its data (ofs>=data_length). */ + voice[i].status=VOICE_OFF; + } +} + +static void note_off(MidiEvent *e) +{ + int i=voices; + while (i--) + if (voice[i].status==VOICE_ON && + voice[i].channel==e->channel && + voice[i].note==e->a) + { + if (channel[e->channel].sustain) + { + voice[i].status=VOICE_SUSTAINED; + ctl->note(i); + } + else + finish_note(i); + return; + } +} + +/* Process the All Notes Off event */ +static void all_notes_off(int c) +{ + int i=voices; + ctl->cmsg(CMSG_INFO, VERB_DEBUG, "All notes off on channel %d", c); + while (i--) + if (voice[i].status==VOICE_ON && + voice[i].channel==c) + { + if (channel[c].sustain) + { + voice[i].status=VOICE_SUSTAINED; + ctl->note(i); + } + else + finish_note(i); + } +} + +/* Process the All Sounds Off event */ +static void all_sounds_off(int c) +{ + int i=voices; + while (i--) + if (voice[i].channel==c && + voice[i].status != VOICE_FREE && + voice[i].status != VOICE_DIE) + { + kill_note(i); + } +} + +static void adjust_pressure(MidiEvent *e) +{ + int i=voices; + while (i--) + if (voice[i].status==VOICE_ON && + voice[i].channel==e->channel && + voice[i].note==e->a) + { + voice[i].velocity=e->b; + recompute_amp(i); + apply_envelope_to_amp(i); + return; + } +} + +static void adjust_panning(int c) +{ + int i=voices; + while (i--) + if ((voice[i].channel==c) && + (voice[i].status==VOICE_ON || voice[i].status==VOICE_SUSTAINED)) + { + voice[i].panning=channel[c].panning; + recompute_amp(i); + apply_envelope_to_amp(i); + } +} + +static void drop_sustain(int c) +{ + int i=voices; + while (i--) + if (voice[i].status==VOICE_SUSTAINED && voice[i].channel==c) + finish_note(i); +} + +static void adjust_pitchbend(int c) +{ + int i=voices; + while (i--) + if (voice[i].status!=VOICE_FREE && voice[i].channel==c) + { + recompute_freq(i); + } +} + +static void adjust_volume(int c) +{ + int i=voices; + while (i--) + if (voice[i].channel==c && + (voice[i].status==VOICE_ON || voice[i].status==VOICE_SUSTAINED)) + { + recompute_amp(i); + apply_envelope_to_amp(i); + } +} + +static void seek_forward(int32 until_time) +{ + reset_voices(); + while (current_event->time < until_time) + { + switch(current_event->type) + { + /* All notes stay off. Just handle the parameter changes. */ + + case ME_PITCH_SENS: + channel[current_event->channel].pitchsens= + current_event->a; + channel[current_event->channel].pitchfactor=0; + break; + + case ME_PITCHWHEEL: + channel[current_event->channel].pitchbend= + current_event->a + current_event->b * 128; + channel[current_event->channel].pitchfactor=0; + break; + + case ME_MAINVOLUME: + channel[current_event->channel].volume=current_event->a; + break; + + case ME_PAN: + channel[current_event->channel].panning=current_event->a; + break; + + case ME_EXPRESSION: + channel[current_event->channel].expression=current_event->a; + break; + + case ME_PROGRAM: + if (ISDRUMCHANNEL(current_event->channel)) + /* Change drum set */ + channel[current_event->channel].bank=current_event->a; + else + channel[current_event->channel].program=current_event->a; + break; + + case ME_SUSTAIN: + channel[current_event->channel].sustain=current_event->a; + break; + + case ME_RESET_CONTROLLERS: + reset_controllers(current_event->channel); + break; + + case ME_TONE_BANK: + channel[current_event->channel].bank=current_event->a; + break; + + case ME_EOT: + current_sample=current_event->time; + return; + } + current_event++; + } + /*current_sample=current_event->time;*/ + if (current_event != event_list) + current_event--; + current_sample=until_time; +} + +static void skip_to(int32 until_time) +{ + if (current_sample > until_time) + current_sample=0; + + reset_midi(); + buffered_count=0; + buffer_pointer=common_buffer; + current_event=event_list; + + if (until_time) + seek_forward(until_time); + ctl->reset(); +} + +static int apply_controls(void) +{ + int rc, i, did_skip=0; + int32 val; + /* ASCII renditions of CD player pictograms indicate approximate effect */ + do + switch(rc=ctl->read(&val)) + { + case RC_QUIT: /* [] */ + case RC_LOAD_FILE: + case RC_NEXT: /* >>| */ + case RC_REALLY_PREVIOUS: /* |<< */ + return rc; + + case RC_CHANGE_VOLUME: + if (val>0 || amplification > -val) + amplification += val; + else + amplification=0; + if (amplification > MAX_AMPLIFICATION) + amplification=MAX_AMPLIFICATION; + adjust_amplification(); + for (i=0; imaster_volume(amplification); + break; + + case RC_PREVIOUS: /* |<< */ + if (current_sample < 2*play_mode->rate) + return RC_REALLY_PREVIOUS; + return RC_RESTART; + + case RC_RESTART: /* |<< */ + skip_to(0); + did_skip=1; + break; + + case RC_JUMP: + if (val >= sample_count) + return RC_NEXT; + skip_to(val); + return rc; + + case RC_FORWARD: /* >> */ + if (val+current_sample >= sample_count) + return RC_NEXT; + skip_to(val+current_sample); + did_skip=1; + break; + + case RC_BACK: /* << */ + if (current_sample > val) + skip_to(current_sample-val); + else + skip_to(0); /* We can't seek to end of previous song. */ + did_skip=1; + break; + } + while (rc!= RC_NONE); + + /* Advertise the skip so that we stop computing the audio buffer */ + if (did_skip) + return RC_JUMP; + else + return rc; +} + +static void do_compute_data(int32 count) +{ + int i; + memset(buffer_pointer, 0, + (play_mode->encoding & PE_MONO) ? (count * 4) : (count * 8)); + for (i=0; iencoding & PE_MONO ) + channels = 1; + else + channels = 2; + + if (!count) + { + if (buffered_count) + s32tobuf(stream, common_buffer, channels*buffered_count); + buffer_pointer=common_buffer; + buffered_count=0; + return RC_NONE; + } + + while ((count+buffered_count) >= AUDIO_BUFFER_SIZE) + { + do_compute_data(AUDIO_BUFFER_SIZE-buffered_count); + count -= AUDIO_BUFFER_SIZE-buffered_count; + s32tobuf(stream, common_buffer, channels*AUDIO_BUFFER_SIZE); + buffer_pointer=common_buffer; + buffered_count=0; + + ctl->current_time(current_sample); + if ((rc=apply_controls())!=RC_NONE) + return rc; + } + if (count>0) + { + do_compute_data(count); + buffered_count += count; + buffer_pointer += (play_mode->encoding & PE_MONO) ? count : count*2; + } + return RC_NONE; +} + +int Timidity_PlaySome(void *stream, int samples) +{ + int rc; + int32 end_sample; + + if ( ! midi_playing ) { + return RC_NONE; + } + end_sample = current_sample+samples; + while ( current_sample < end_sample ) { + /* Handle all events that should happen at this time */ + while (current_event->time <= current_sample) { + switch(current_event->type) { + + /* Effects affecting a single note */ + + case ME_NOTEON: + if (!(current_event->b)) /* Velocity 0? */ + note_off(current_event); + else + note_on(current_event); + break; + + case ME_NOTEOFF: + note_off(current_event); + break; + + case ME_KEYPRESSURE: + adjust_pressure(current_event); + break; + + /* Effects affecting a single channel */ + + case ME_PITCH_SENS: + channel[current_event->channel].pitchsens=current_event->a; + channel[current_event->channel].pitchfactor=0; + break; + + case ME_PITCHWHEEL: + channel[current_event->channel].pitchbend= + current_event->a + current_event->b * 128; + channel[current_event->channel].pitchfactor=0; + /* Adjust pitch for notes already playing */ + adjust_pitchbend(current_event->channel); + ctl->pitch_bend(current_event->channel, + channel[current_event->channel].pitchbend); + break; + + case ME_MAINVOLUME: + channel[current_event->channel].volume=current_event->a; + adjust_volume(current_event->channel); + ctl->volume(current_event->channel, current_event->a); + break; + + case ME_PAN: + channel[current_event->channel].panning=current_event->a; + if (adjust_panning_immediately) + adjust_panning(current_event->channel); + ctl->panning(current_event->channel, current_event->a); + break; + + case ME_EXPRESSION: + channel[current_event->channel].expression=current_event->a; + adjust_volume(current_event->channel); + ctl->expression(current_event->channel, current_event->a); + break; + + case ME_PROGRAM: + if (ISDRUMCHANNEL(current_event->channel)) { + /* Change drum set */ + channel[current_event->channel].bank=current_event->a; + } + else + { + channel[current_event->channel].program=current_event->a; + } + ctl->program(current_event->channel, current_event->a); + break; + + case ME_SUSTAIN: + channel[current_event->channel].sustain=current_event->a; + if (!current_event->a) + drop_sustain(current_event->channel); + ctl->sustain(current_event->channel, current_event->a); + break; + + case ME_RESET_CONTROLLERS: + reset_controllers(current_event->channel); + redraw_controllers(current_event->channel); + break; + + case ME_ALL_NOTES_OFF: + all_notes_off(current_event->channel); + break; + + case ME_ALL_SOUNDS_OFF: + all_sounds_off(current_event->channel); + break; + + case ME_TONE_BANK: + channel[current_event->channel].bank=current_event->a; + break; + + case ME_EOT: + /* Give the last notes a couple of seconds to decay */ + ctl->cmsg(CMSG_INFO, VERB_VERBOSE, + "Playing time: ~%d seconds", current_sample/play_mode->rate+2); + ctl->cmsg(CMSG_INFO, VERB_VERBOSE, + "Notes cut: %d", cut_notes); + ctl->cmsg(CMSG_INFO, VERB_VERBOSE, + "Notes lost totally: %d", lost_notes); + midi_playing = 0; + return RC_TUNE_END; + } + current_event++; + } + if (current_event->time > end_sample) + rc=compute_data(stream, end_sample-current_sample); + else + rc=compute_data(stream, current_event->time-current_sample); + ctl->refresh(); + if ( (rc!=RC_NONE) && (rc!=RC_JUMP)) + break; + } + return rc; +} + + +void Timidity_SetVolume(int volume) +{ + int i; + if (volume > MAX_AMPLIFICATION) + amplification=MAX_AMPLIFICATION; + else + if (volume < 0) + amplification=0; + else + amplification=volume; + adjust_amplification(); + for (i=0; imaster_volume(amplification); +} + +MidiSong *Timidity_LoadSong(char *midifile) +{ + MidiSong *song; + MidiEvent *event; + int32 events, samples; + int rc; + FILE *fp; + + /* Allocate memory for the song */ + song = (MidiSong *)safe_malloc(sizeof(*song)); + memset(song, 0, sizeof(*song)); + + /* Open the file */ + fp = open_file(midifile, 1, OF_VERBOSE); + if ( fp != NULL ) { + song->events=read_midi_file(fp, &events, &song->samples); + close_file(fp); + } + + /* Make sure everything is okay */ + if (!song->events) { + free(song); + song = NULL; + } + return(song); +} + +void Timidity_Start(MidiSong *song) +{ + load_missing_instruments(); + adjust_amplification(); + sample_count = song->samples; + event_list = song->events; + lost_notes=cut_notes=0; + + skip_to(0); + midi_playing = 1; +} + +int Timidity_Active(void) +{ + return(midi_playing); +} + +void Timidity_Stop(void) +{ + midi_playing = 0; +} + +void Timidity_FreeSong(MidiSong *song) +{ + if (free_instruments_afterwards) + free_instruments(); + + free(song->events); + free(song); +} + diff --git a/timidity/playmidi.h b/timidity/playmidi.h new file mode 100644 index 00000000..db7bbba4 --- /dev/null +++ b/timidity/playmidi.h @@ -0,0 +1,116 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + playmidi.h + + */ + +typedef struct { + int32 time; + uint8 channel, type, a, b; +} MidiEvent; + +/* Midi events */ +#define ME_NONE 0 +#define ME_NOTEON 1 +#define ME_NOTEOFF 2 +#define ME_KEYPRESSURE 3 +#define ME_MAINVOLUME 4 +#define ME_PAN 5 +#define ME_SUSTAIN 6 +#define ME_EXPRESSION 7 +#define ME_PITCHWHEEL 8 +#define ME_PROGRAM 9 +#define ME_TEMPO 10 +#define ME_PITCH_SENS 11 + +#define ME_ALL_SOUNDS_OFF 12 +#define ME_RESET_CONTROLLERS 13 +#define ME_ALL_NOTES_OFF 14 +#define ME_TONE_BANK 15 + +#define ME_LYRIC 16 + +#define ME_EOT 99 + +typedef struct { + int + bank, program, volume, sustain, panning, pitchbend, expression, + mono, /* one note only on this channel -- not implemented yet */ + pitchsens; + /* chorus, reverb... Coming soon to a 300-MHz, eight-way superscalar + processor near you */ + float + pitchfactor; /* precomputed pitch bend factor to save some fdiv's */ +} Channel; + +/* Causes the instrument's default panning to be used. */ +#define NO_PANNING -1 + +typedef struct { + uint8 + status, channel, note, velocity; + Sample *sample; + int32 + orig_frequency, frequency, + sample_offset, sample_increment, + envelope_volume, envelope_target, envelope_increment, + tremolo_sweep, tremolo_sweep_position, + tremolo_phase, tremolo_phase_increment, + vibrato_sweep, vibrato_sweep_position; + + final_volume_t left_mix, right_mix; + + float + left_amp, right_amp, tremolo_volume; + int32 + vibrato_sample_increment[VIBRATO_SAMPLE_INCREMENTS]; + int + vibrato_phase, vibrato_control_ratio, vibrato_control_counter, + envelope_stage, control_counter, panning, panned; + +} Voice; + +/* Voice status options: */ +#define VOICE_FREE 0 +#define VOICE_ON 1 +#define VOICE_SUSTAINED 2 +#define VOICE_OFF 3 +#define VOICE_DIE 4 + +/* Voice panned options: */ +#define PANNED_MYSTERY 0 +#define PANNED_LEFT 1 +#define PANNED_RIGHT 2 +#define PANNED_CENTER 3 +/* Anything but PANNED_MYSTERY only uses the left volume */ + +extern Channel channel[16]; +extern Voice voice[MAX_VOICES]; + +extern int32 control_ratio, amp_with_poly, amplification; +extern int32 drumchannels; +extern int adjust_panning_immediately; +extern int voices; + +#define ISDRUMCHANNEL(c) ((drumchannels & (1<<(c)))) + +extern int play_midi(MidiEvent *el, int32 events, int32 samples); +extern int play_midi_file(char *fn); +extern void dumb_pass_playing_list(int number_of_files, char *list_of_files[]); diff --git a/timidity/readmidi.c b/timidity/readmidi.c new file mode 100644 index 00000000..17e16d37 --- /dev/null +++ b/timidity/readmidi.c @@ -0,0 +1,628 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include +#include +#include + +#if defined(SOLARIS) | defined(WIN32) +# include +#else +#include +#endif + +#ifndef WIN32 +#include +#endif + +#include "config.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "readmidi.h" +#include "output.h" +#include "controls.h" + +int32 quietchannels=0; + +/* to avoid some unnecessary parameter passing */ +static MidiEventList *evlist; +static int32 event_count; +static FILE *fp; +static int32 at; + +/* These would both fit into 32 bits, but they are often added in + large multiples, so it's simpler to have two roomy ints */ +static int32 sample_increment, sample_correction; /*samples per MIDI delta-t*/ + +/* Computes how many (fractional) samples one MIDI delta-time unit contains */ +static void compute_sample_increment(int32 tempo, int32 divisions) +{ + double a; + a = (double) (tempo) * (double) (play_mode->rate) * (65536.0/1000000.0) / + (double)(divisions); + + sample_correction = (int32)(a) & 0xFFFF; + sample_increment = (int32)(a) >> 16; + + ctl->cmsg(CMSG_INFO, VERB_DEBUG, "Samples per delta-t: %d (correction %d)", + sample_increment, sample_correction); +} + +/* Read variable-length number (7 bits per byte, MSB first) */ +static int32 getvl(void) +{ + int32 l=0; + uint8 c; + for (;;) + { + fread(&c,1,1,fp); + l += (c & 0x7f); + if (!(c & 0x80)) return l; + l<<=7; + } +} + +/* Print a string from the file, followed by a newline. Any non-ASCII + or unprintable characters will be converted to periods. */ +static int dumpstring(int32 len, char *label) +{ + signed char *s=safe_malloc(len+1); + if (len != fread(s, 1, len, fp)) + { + free(s); + return -1; + } + s[len]='\0'; + while (len--) + { + if (s[len]<32) + s[len]='.'; + } + ctl->cmsg(CMSG_TEXT, VERB_VERBOSE, "%s%s", label, s); + free(s); + return 0; +} + +#define MIDIEVENT(at,t,ch,pa,pb) \ + new=safe_malloc(sizeof(MidiEventList)); \ + new->event.time=at; new->event.type=t; new->event.channel=ch; \ + new->event.a=pa; new->event.b=pb; new->next=0;\ + return new; + +#define MAGIC_EOT ((MidiEventList *)(-1)) + +/* Read a MIDI event, returning a freshly allocated element that can + be linked to the event list */ +static MidiEventList *read_midi_event(void) +{ + static uint8 laststatus, lastchan; + static uint8 nrpn=0, rpn_msb[16], rpn_lsb[16]; /* one per channel */ + uint8 me, type, a,b,c; + int32 len; + MidiEventList *new; + + for (;;) + { + at+=getvl(); + if (fread(&me,1,1,fp)!=1) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: read_midi_event: %s", + current_filename, strerror(errno)); + return 0; + } + + if(me==0xF0 || me == 0xF7) /* SysEx event */ + { + len=getvl(); + skip(fp, len); + } + else if(me==0xFF) /* Meta event */ + { + fread(&type,1,1,fp); + len=getvl(); + if (type>0 && type<16) + { + static char *label[]={ + "Text event: ", "Text: ", "Copyright: ", "Track name: ", + "Instrument: ", "Lyric: ", "Marker: ", "Cue point: "}; + dumpstring(len, label[(type>7) ? 0 : type]); + } + else + switch(type) + { + case 0x2F: /* End of Track */ + return MAGIC_EOT; + + case 0x51: /* Tempo */ + fread(&a,1,1,fp); fread(&b,1,1,fp); fread(&c,1,1,fp); + MIDIEVENT(at, ME_TEMPO, c, a, b); + + default: + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + "(Meta event type 0x%02x, length %ld)", type, len); + skip(fp, len); + break; + } + } + else + { + a=me; + if (a & 0x80) /* status byte */ + { + lastchan=a & 0x0F; + laststatus=(a>>4) & 0x07; + fread(&a, 1,1, fp); + a &= 0x7F; + } + switch(laststatus) + { + case 0: /* Note off */ + fread(&b, 1,1, fp); + b &= 0x7F; + MIDIEVENT(at, ME_NOTEOFF, lastchan, a,b); + + case 1: /* Note on */ + fread(&b, 1,1, fp); + b &= 0x7F; + MIDIEVENT(at, ME_NOTEON, lastchan, a,b); + + case 2: /* Key Pressure */ + fread(&b, 1,1, fp); + b &= 0x7F; + MIDIEVENT(at, ME_KEYPRESSURE, lastchan, a, b); + + case 3: /* Control change */ + fread(&b, 1,1, fp); + b &= 0x7F; + { + int control=255; + switch(a) + { + case 7: control=ME_MAINVOLUME; break; + case 10: control=ME_PAN; break; + case 11: control=ME_EXPRESSION; break; + case 64: control=ME_SUSTAIN; break; + case 120: control=ME_ALL_SOUNDS_OFF; break; + case 121: control=ME_RESET_CONTROLLERS; break; + case 123: control=ME_ALL_NOTES_OFF; break; + + /* These should be the SCC-1 tone bank switch + commands. I don't know why there are two, or + why the latter only allows switching to bank 0. + Also, some MIDI files use 0 as some sort of + continuous controller. This will cause lots of + warnings about undefined tone banks. */ + case 0: control=ME_TONE_BANK; break; + case 32: + if (b!=0) + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + "(Strange: tone bank change 0x20%02x)", b); + else + control=ME_TONE_BANK; + break; + + case 100: nrpn=0; rpn_msb[lastchan]=b; break; + case 101: nrpn=0; rpn_lsb[lastchan]=b; break; + case 99: nrpn=1; rpn_msb[lastchan]=b; break; + case 98: nrpn=1; rpn_lsb[lastchan]=b; break; + + case 6: + if (nrpn) + { + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + "(Data entry (MSB) for NRPN %02x,%02x: %ld)", + rpn_msb[lastchan], rpn_lsb[lastchan], + b); + break; + } + + switch((rpn_msb[lastchan]<<8) | rpn_lsb[lastchan]) + { + case 0x0000: /* Pitch bend sensitivity */ + control=ME_PITCH_SENS; + break; + + case 0x7F7F: /* RPN reset */ + /* reset pitch bend sensitivity to 2 */ + MIDIEVENT(at, ME_PITCH_SENS, lastchan, 2, 0); + + default: + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + "(Data entry (MSB) for RPN %02x,%02x: %ld)", + rpn_msb[lastchan], rpn_lsb[lastchan], + b); + break; + } + break; + + default: + ctl->cmsg(CMSG_INFO, VERB_DEBUG, + "(Control %d: %d)", a, b); + break; + } + if (control != 255) + { + MIDIEVENT(at, control, lastchan, b, 0); + } + } + break; + + case 4: /* Program change */ + a &= 0x7f; + MIDIEVENT(at, ME_PROGRAM, lastchan, a, 0); + + case 5: /* Channel pressure - NOT IMPLEMENTED */ + break; + + case 6: /* Pitch wheel */ + fread(&b, 1,1, fp); + b &= 0x7F; + MIDIEVENT(at, ME_PITCHWHEEL, lastchan, a, b); + + default: + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "*** Can't happen: status 0x%02X, channel 0x%02X", + laststatus, lastchan); + break; + } + } + } + + return new; +} + +#undef MIDIEVENT + +/* Read a midi track into the linked list, either merging with any previous + tracks or appending to them. */ +static int read_track(int append) +{ + MidiEventList *meep; + MidiEventList *next, *new; + int32 len; + char tmp[4]; + + meep=evlist; + if (append && meep) + { + /* find the last event in the list */ + for (; meep->next; meep=meep->next) + ; + at=meep->event.time; + } + else + at=0; + + /* Check the formalities */ + + if ((fread(tmp,1,4,fp) != 4) || (fread(&len,4,1,fp) != 1)) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: Can't read track header.", current_filename); + return -1; + } + len=BE_LONG(len); + if (memcmp(tmp, "MTrk", 4)) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: Corrupt MIDI file.", current_filename); + return -2; + } + + for (;;) + { + if (!(new=read_midi_event())) /* Some kind of error */ + return -2; + + if (new==MAGIC_EOT) /* End-of-track Hack. */ + { + return 0; + } + + next=meep->next; + while (next && (next->event.time < new->event.time)) + { + meep=next; + next=meep->next; + } + + new->next=next; + meep->next=new; + + event_count++; /* Count the event. (About one?) */ + meep=new; + } +} + +/* Free the linked event list from memory. */ +static void free_midi_list(void) +{ + MidiEventList *meep, *next; + if (!(meep=evlist)) return; + while (meep) + { + next=meep->next; + free(meep); + meep=next; + } + evlist=0; +} + +/* Allocate an array of MidiEvents and fill it from the linked list of + events, marking used instruments for loading. Convert event times to + samples: handle tempo changes. Strip unnecessary events from the list. + Free the linked list. */ +static MidiEvent *groom_list(int32 divisions,int32 *eventsp,int32 *samplesp) +{ + MidiEvent *groomed_list, *lp; + MidiEventList *meep; + int32 i, our_event_count, tempo, skip_this_event, new_value; + int32 sample_cum, samples_to_do, at, st, dt, counting_time; + + int current_bank[16], current_set[16], current_program[16]; + /* Or should each bank have its own current program? */ + + for (i=0; i<16; i++) + { + current_bank[i]=0; + current_set[i]=0; + current_program[i]=default_program; + } + + tempo=500000; + compute_sample_increment(tempo, divisions); + + /* This may allocate a bit more than we need */ + groomed_list=lp=safe_malloc(sizeof(MidiEvent) * (event_count+1)); + meep=evlist; + + our_event_count=0; + st=at=sample_cum=0; + counting_time=2; /* We strip any silence before the first NOTE ON. */ + + for (i=0; icmsg(CMSG_INFO, VERB_DEBUG_SILLY, + "%6d: ch %2d: event %d (%d,%d)", + meep->event.time, meep->event.channel + 1, + meep->event.type, meep->event.a, meep->event.b); + + if (meep->event.type==ME_TEMPO) + { + tempo= + meep->event.channel + meep->event.b * 256 + meep->event.a * 65536; + compute_sample_increment(tempo, divisions); + skip_this_event=1; + } + else if ((quietchannels & (1<event.channel))) + skip_this_event=1; + else switch (meep->event.type) + { + case ME_PROGRAM: + if (ISDRUMCHANNEL(meep->event.channel)) + { + if (drumset[meep->event.a]) /* Is this a defined drumset? */ + new_value=meep->event.a; + else + { + ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, + "Drum set %d is undefined", meep->event.a); + new_value=meep->event.a=0; + } + if (current_set[meep->event.channel] != new_value) + current_set[meep->event.channel]=new_value; + else + skip_this_event=1; + } + else + { + new_value=meep->event.a; + if ((current_program[meep->event.channel] != SPECIAL_PROGRAM) + && (current_program[meep->event.channel] != new_value)) + current_program[meep->event.channel] = new_value; + else + skip_this_event=1; + } + break; + + case ME_NOTEON: + if (counting_time) + counting_time=1; + if (ISDRUMCHANNEL(meep->event.channel)) + { + /* Mark this instrument to be loaded */ + if (!(drumset[current_set[meep->event.channel]] + ->tone[meep->event.a].instrument)) + drumset[current_set[meep->event.channel]] + ->tone[meep->event.a].instrument= + MAGIC_LOAD_INSTRUMENT; + } + else + { + if (current_program[meep->event.channel]==SPECIAL_PROGRAM) + break; + /* Mark this instrument to be loaded */ + if (!(tonebank[current_bank[meep->event.channel]] + ->tone[current_program[meep->event.channel]].instrument)) + tonebank[current_bank[meep->event.channel]] + ->tone[current_program[meep->event.channel]].instrument= + MAGIC_LOAD_INSTRUMENT; + } + break; + + case ME_TONE_BANK: + if (ISDRUMCHANNEL(meep->event.channel)) + { + skip_this_event=1; + break; + } + if (tonebank[meep->event.a]) /* Is this a defined tone bank? */ + new_value=meep->event.a; + else + { + ctl->cmsg(CMSG_WARNING, VERB_VERBOSE, + "Tone bank %d is undefined", meep->event.a); + new_value=meep->event.a=0; + } + if (current_bank[meep->event.channel]!=new_value) + current_bank[meep->event.channel]=new_value; + else + skip_this_event=1; + break; + } + + /* Recompute time in samples*/ + if ((dt=meep->event.time - at) && !counting_time) + { + samples_to_do=sample_increment * dt; + sample_cum += sample_correction * dt; + if (sample_cum & 0xFFFF0000) + { + samples_to_do += ((sample_cum >> 16) & 0xFFFF); + sample_cum &= 0x0000FFFF; + } + st += samples_to_do; + } + else if (counting_time==1) counting_time=0; + if (!skip_this_event) + { + /* Add the event to the list */ + *lp=meep->event; + lp->time=st; + lp++; + our_event_count++; + } + at=meep->event.time; + meep=meep->next; + } + /* Add an End-of-Track event */ + lp->time=st; + lp->type=ME_EOT; + our_event_count++; + free_midi_list(); + + *eventsp=our_event_count; + *samplesp=st; + return groomed_list; +} + +MidiEvent *read_midi_file(FILE *mfp, int32 *count, int32 *sp) +{ + int32 len, divisions; + int16 format, tracks, divisions_tmp; + int i; + char tmp[4]; + + fp=mfp; + event_count=0; + at=0; + evlist=0; + + if ((fread(tmp,1,4,fp) != 4) || (fread(&len,4,1,fp) != 1)) + { + if (ferror(fp)) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: %s", current_filename, + strerror(errno)); + } + else + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: Not a MIDI file!", current_filename); + return 0; + } + len=BE_LONG(len); + if (memcmp(tmp, "MThd", 4) || len < 6) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: Not a MIDI file!", current_filename); + return 0; + } + + fread(&format, 2, 1, fp); + fread(&tracks, 2, 1, fp); + fread(&divisions_tmp, 2, 1, fp); + format=BE_SHORT(format); + tracks=BE_SHORT(tracks); + divisions_tmp=BE_SHORT(divisions_tmp); + + if (divisions_tmp<0) + { + /* SMPTE time -- totally untested. Got a MIDI file that uses this? */ + divisions= + (int32)(-(divisions_tmp/256)) * (int32)(divisions_tmp & 0xFF); + } + else divisions=(int32)(divisions_tmp); + + if (len > 6) + { + ctl->cmsg(CMSG_WARNING, VERB_NORMAL, + "%s: MIDI file header size %ld bytes", + current_filename, len); + skip(fp, len-6); /* skip the excess */ + } + if (format<0 || format >2) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: Unknown MIDI file format %d", current_filename, format); + return 0; + } + ctl->cmsg(CMSG_INFO, VERB_VERBOSE, + "Format: %d Tracks: %d Divisions: %d", format, tracks, divisions); + + /* Put a do-nothing event first in the list for easier processing */ + evlist=safe_malloc(sizeof(MidiEventList)); + evlist->event.time=0; + evlist->event.type=ME_NONE; + evlist->next=0; + event_count++; + + switch(format) + { + case 0: + if (read_track(0)) + { + free_midi_list(); + return 0; + } + break; + + case 1: + for (i=0; i + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + readmidi.h + + */ + +typedef struct { + MidiEvent event; + void *next; +} MidiEventList; + +extern int32 quietchannels; + +extern MidiEvent *read_midi_file(FILE *mfp, int32 *count, int32 *sp); diff --git a/timidity/resample.c b/timidity/resample.c new file mode 100644 index 00000000..584e56ea --- /dev/null +++ b/timidity/resample.c @@ -0,0 +1,736 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + resample.c +*/ + +#include +#include +#include + +#include "config.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "output.h" +#include "controls.h" +#include "tables.h" +#include "resample.h" + +#ifdef LINEAR_INTERPOLATION +# if defined(LOOKUP_HACK) && defined(LOOKUP_INTERPOLATION) +# define RESAMPLATION \ + v1=src[ofs>>FRACTION_BITS];\ + v2=src[(ofs>>FRACTION_BITS)+1];\ + *dest++ = v1 + (iplookup[(((v2-v1)<<5) & 0x03FE0) | \ + ((ofs & FRACTION_MASK) >> (FRACTION_BITS-5))]); +# else +# define RESAMPLATION \ + v1=src[ofs>>FRACTION_BITS];\ + v2=src[(ofs>>FRACTION_BITS)+1];\ + *dest++ = v1 + (((v2-v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); +# endif +# define INTERPVARS sample_t v1, v2 +#else +/* Earplugs recommended for maximum listening enjoyment */ +# define RESAMPLATION *dest++=src[ofs>>FRACTION_BITS]; +# define INTERPVARS +#endif + +#define FINALINTERP if (ofs == le) *dest++=src[ofs>>FRACTION_BITS]; +/* So it isn't interpolation. At least it's final. */ + +extern sample_t *resample_buffer; + +/*************** resampling with fixed increment *****************/ + +static sample_t *rs_plain(int v, int32 *countptr) +{ + + /* Play sample until end, then free the voice. */ + + INTERPVARS; + Voice + *vp=&voice[v]; + sample_t + *dest=resample_buffer, + *src=vp->sample->data; + int32 + ofs=vp->sample_offset, + incr=vp->sample_increment, + le=vp->sample->data_length, + count=*countptr; + +#ifdef PRECALC_LOOPS + int32 i; + + if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */ + + /* Precalc how many times we should go through the loop. + NOTE: Assumes that incr > 0 and that ofs <= le */ + i = (le - ofs) / incr + 1; + + if (i > count) + { + i = count; + count = 0; + } + else count -= i; + + while (i--) + { + RESAMPLATION; + ofs += incr; + } + + if (ofs >= le) + { + FINALINTERP; + vp->status=VOICE_FREE; + ctl->note(v); + *countptr-=count+1; + } + +#else /* PRECALC_LOOPS */ + while (count--) + { + RESAMPLATION; + ofs += incr; + if (ofs >= le) + { + FINALINTERP; + vp->status=VOICE_FREE; + ctl->note(v); + *countptr-=count+1; + break; + } + } +#endif /* PRECALC_LOOPS */ + + vp->sample_offset=ofs; /* Update offset */ + return resample_buffer; +} + +static sample_t *rs_loop(Voice *vp, int32 count) +{ + + /* Play sample until end-of-loop, skip back and continue. */ + + INTERPVARS; + int32 + ofs=vp->sample_offset, + incr=vp->sample_increment, + le=vp->sample->loop_end, + ll=le - vp->sample->loop_start; + sample_t + *dest=resample_buffer, + *src=vp->sample->data; + +#ifdef PRECALC_LOOPS + int32 i; + + while (count) + { + if (ofs >= le) + /* NOTE: Assumes that ll > incr and that incr > 0. */ + ofs -= ll; + /* Precalc how many times we should go through the loop */ + i = (le - ofs) / incr + 1; + if (i > count) + { + i = count; + count = 0; + } + else count -= i; + while (i--) + { + RESAMPLATION; + ofs += incr; + } + } +#else + while (count--) + { + RESAMPLATION; + ofs += incr; + if (ofs>=le) + ofs -= ll; /* Hopefully the loop is longer than an increment. */ + } +#endif + + vp->sample_offset=ofs; /* Update offset */ + return resample_buffer; +} + +static sample_t *rs_bidir(Voice *vp, int32 count) +{ + INTERPVARS; + int32 + ofs=vp->sample_offset, + incr=vp->sample_increment, + le=vp->sample->loop_end, + ls=vp->sample->loop_start; + sample_t + *dest=resample_buffer, + *src=vp->sample->data; + +#ifdef PRECALC_LOOPS + int32 + le2 = le<<1, + ls2 = ls<<1, + i; + /* Play normally until inside the loop region */ + + if (ofs <= ls) + { + /* NOTE: Assumes that incr > 0, which is NOT always the case + when doing bidirectional looping. I have yet to see a case + where both ofs <= ls AND incr < 0, however. */ + i = (ls - ofs) / incr + 1; + if (i > count) + { + i = count; + count = 0; + } + else count -= i; + while (i--) + { + RESAMPLATION; + ofs += incr; + } + } + + /* Then do the bidirectional looping */ + + while(count) + { + /* Precalc how many times we should go through the loop */ + i = ((incr > 0 ? le : ls) - ofs) / incr + 1; + if (i > count) + { + i = count; + count = 0; + } + else count -= i; + while (i--) + { + RESAMPLATION; + ofs += incr; + } + if (ofs>=le) + { + /* fold the overshoot back in */ + ofs = le2 - ofs; + incr *= -1; + } + else if (ofs <= ls) + { + ofs = ls2 - ofs; + incr *= -1; + } + } + +#else /* PRECALC_LOOPS */ + /* Play normally until inside the loop region */ + + if (ofs < ls) + { + while (count--) + { + RESAMPLATION; + ofs += incr; + if (ofs>=ls) + break; + } + } + + /* Then do the bidirectional looping */ + + if (count>0) + while (count--) + { + RESAMPLATION; + ofs += incr; + if (ofs>=le) + { + /* fold the overshoot back in */ + ofs = le - (ofs - le); + incr = -incr; + } + else if (ofs <= ls) + { + ofs = ls + (ls - ofs); + incr = -incr; + } + } +#endif /* PRECALC_LOOPS */ + vp->sample_increment=incr; + vp->sample_offset=ofs; /* Update offset */ + return resample_buffer; +} + +/*********************** vibrato versions ***************************/ + +/* We only need to compute one half of the vibrato sine cycle */ +static int vib_phase_to_inc_ptr(int phase) +{ + if (phase < VIBRATO_SAMPLE_INCREMENTS/2) + return VIBRATO_SAMPLE_INCREMENTS/2-1-phase; + else if (phase >= 3*VIBRATO_SAMPLE_INCREMENTS/2) + return 5*VIBRATO_SAMPLE_INCREMENTS/2-1-phase; + else + return phase-VIBRATO_SAMPLE_INCREMENTS/2; +} + +static int32 update_vibrato(Voice *vp, int sign) +{ + int32 depth; + int phase, pb; + double a; + + if (vp->vibrato_phase++ >= 2*VIBRATO_SAMPLE_INCREMENTS-1) + vp->vibrato_phase=0; + phase=vib_phase_to_inc_ptr(vp->vibrato_phase); + + if (vp->vibrato_sample_increment[phase]) + { + if (sign) + return -vp->vibrato_sample_increment[phase]; + else + return vp->vibrato_sample_increment[phase]; + } + + /* Need to compute this sample increment. */ + + depth=vp->sample->vibrato_depth<<7; + + if (vp->vibrato_sweep) + { + /* Need to update sweep */ + vp->vibrato_sweep_position += vp->vibrato_sweep; + if (vp->vibrato_sweep_position >= (1<vibrato_sweep=0; + else + { + /* Adjust depth */ + depth *= vp->vibrato_sweep_position; + depth >>= SWEEP_SHIFT; + } + } + + a = FSCALE(((double)(vp->sample->sample_rate) * + (double)(vp->frequency)) / + ((double)(vp->sample->root_freq) * + (double)(play_mode->rate)), + FRACTION_BITS); + + pb=(int)((sine(vp->vibrato_phase * + (SINE_CYCLE_LENGTH/(2*VIBRATO_SAMPLE_INCREMENTS))) + * (double)(depth) * VIBRATO_AMPLITUDE_TUNING)); + + if (pb<0) + { + pb=-pb; + a /= bend_fine[(pb>>5) & 0xFF] * bend_coarse[pb>>13]; + } + else + a *= bend_fine[(pb>>5) & 0xFF] * bend_coarse[pb>>13]; + + /* If the sweep's over, we can store the newly computed sample_increment */ + if (!vp->vibrato_sweep) + vp->vibrato_sample_increment[phase]=(int32) a; + + if (sign) + a = -a; /* need to preserve the loop direction */ + + return (int32) a; +} + +static sample_t *rs_vib_plain(int v, int32 *countptr) +{ + + /* Play sample until end, then free the voice. */ + + INTERPVARS; + Voice *vp=&voice[v]; + sample_t + *dest=resample_buffer, + *src=vp->sample->data; + int32 + le=vp->sample->data_length, + ofs=vp->sample_offset, + incr=vp->sample_increment, + count=*countptr; + int + cc=vp->vibrato_control_counter; + + /* This has never been tested */ + + if (incr<0) incr = -incr; /* In case we're coming out of a bidir loop */ + + while (count--) + { + if (!cc--) + { + cc=vp->vibrato_control_ratio; + incr=update_vibrato(vp, 0); + } + RESAMPLATION; + ofs += incr; + if (ofs >= le) + { + FINALINTERP; + vp->status=VOICE_FREE; + ctl->note(v); + *countptr-=count+1; + break; + } + } + + vp->vibrato_control_counter=cc; + vp->sample_increment=incr; + vp->sample_offset=ofs; /* Update offset */ + return resample_buffer; +} + +static sample_t *rs_vib_loop(Voice *vp, int32 count) +{ + + /* Play sample until end-of-loop, skip back and continue. */ + + INTERPVARS; + int32 + ofs=vp->sample_offset, + incr=vp->sample_increment, + le=vp->sample->loop_end, + ll=le - vp->sample->loop_start; + sample_t + *dest=resample_buffer, + *src=vp->sample->data; + int + cc=vp->vibrato_control_counter; + +#ifdef PRECALC_LOOPS + int32 i; + int + vibflag=0; + + while (count) + { + /* Hopefully the loop is longer than an increment */ + if(ofs >= le) + ofs -= ll; + /* Precalc how many times to go through the loop, taking + the vibrato control ratio into account this time. */ + i = (le - ofs) / incr + 1; + if(i > count) i = count; + if(i > cc) + { + i = cc; + vibflag = 1; + } + else cc -= i; + count -= i; + while(i--) + { + RESAMPLATION; + ofs += incr; + } + if(vibflag) + { + cc = vp->vibrato_control_ratio; + incr = update_vibrato(vp, 0); + vibflag = 0; + } + } + +#else /* PRECALC_LOOPS */ + while (count--) + { + if (!cc--) + { + cc=vp->vibrato_control_ratio; + incr=update_vibrato(vp, 0); + } + RESAMPLATION; + ofs += incr; + if (ofs>=le) + ofs -= ll; /* Hopefully the loop is longer than an increment. */ + } +#endif /* PRECALC_LOOPS */ + + vp->vibrato_control_counter=cc; + vp->sample_increment=incr; + vp->sample_offset=ofs; /* Update offset */ + return resample_buffer; +} + +static sample_t *rs_vib_bidir(Voice *vp, int32 count) +{ + INTERPVARS; + int32 + ofs=vp->sample_offset, + incr=vp->sample_increment, + le=vp->sample->loop_end, + ls=vp->sample->loop_start; + sample_t + *dest=resample_buffer, + *src=vp->sample->data; + int + cc=vp->vibrato_control_counter; + +#ifdef PRECALC_LOOPS + int32 + le2=le<<1, + ls2=ls<<1, + i; + int + vibflag = 0; + + /* Play normally until inside the loop region */ + while (count && (ofs <= ls)) + { + i = (ls - ofs) / incr + 1; + if (i > count) i = count; + if (i > cc) + { + i = cc; + vibflag = 1; + } + else cc -= i; + count -= i; + while (i--) + { + RESAMPLATION; + ofs += incr; + } + if (vibflag) + { + cc = vp->vibrato_control_ratio; + incr = update_vibrato(vp, 0); + vibflag = 0; + } + } + + /* Then do the bidirectional looping */ + + while (count) + { + /* Precalc how many times we should go through the loop */ + i = ((incr > 0 ? le : ls) - ofs) / incr + 1; + if(i > count) i = count; + if(i > cc) + { + i = cc; + vibflag = 1; + } + else cc -= i; + count -= i; + while (i--) + { + RESAMPLATION; + ofs += incr; + } + if (vibflag) + { + cc = vp->vibrato_control_ratio; + incr = update_vibrato(vp, (incr < 0)); + vibflag = 0; + } + if (ofs >= le) + { + /* fold the overshoot back in */ + ofs = le2 - ofs; + incr *= -1; + } + else if (ofs <= ls) + { + ofs = ls2 - ofs; + incr *= -1; + } + } + +#else /* PRECALC_LOOPS */ + /* Play normally until inside the loop region */ + + if (ofs < ls) + { + while (count--) + { + if (!cc--) + { + cc=vp->vibrato_control_ratio; + incr=update_vibrato(vp, 0); + } + RESAMPLATION; + ofs += incr; + if (ofs>=ls) + break; + } + } + + /* Then do the bidirectional looping */ + + if (count>0) + while (count--) + { + if (!cc--) + { + cc=vp->vibrato_control_ratio; + incr=update_vibrato(vp, (incr < 0)); + } + RESAMPLATION; + ofs += incr; + if (ofs>=le) + { + /* fold the overshoot back in */ + ofs = le - (ofs - le); + incr = -incr; + } + else if (ofs <= ls) + { + ofs = ls + (ls - ofs); + incr = -incr; + } + } +#endif /* PRECALC_LOOPS */ + + vp->vibrato_control_counter=cc; + vp->sample_increment=incr; + vp->sample_offset=ofs; /* Update offset */ + return resample_buffer; +} + +sample_t *resample_voice(int v, int32 *countptr) +{ + int32 ofs; + uint8 modes; + Voice *vp=&voice[v]; + + if (!(vp->sample->sample_rate)) + { + /* Pre-resampled data -- just update the offset and check if + we're out of data. */ + ofs=vp->sample_offset >> FRACTION_BITS; /* Kind of silly to use + FRACTION_BITS here... */ + if (*countptr >= (vp->sample->data_length>>FRACTION_BITS) - ofs) + { + /* Note finished. Free the voice. */ + vp->status = VOICE_FREE; + ctl->note(v); + + /* Let the caller know how much data we had left */ + *countptr = (vp->sample->data_length>>FRACTION_BITS) - ofs; + } + else + vp->sample_offset += *countptr << FRACTION_BITS; + + return vp->sample->data+ofs; + } + + /* Need to resample. Use the proper function. */ + modes=vp->sample->modes; + + if (vp->vibrato_control_ratio) + { + if ((modes & MODES_LOOPING) && + ((modes & MODES_ENVELOPE) || + (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED))) + { + if (modes & MODES_PINGPONG) + return rs_vib_bidir(vp, *countptr); + else + return rs_vib_loop(vp, *countptr); + } + else + return rs_vib_plain(v, countptr); + } + else + { + if ((modes & MODES_LOOPING) && + ((modes & MODES_ENVELOPE) || + (vp->status==VOICE_ON || vp->status==VOICE_SUSTAINED))) + { + if (modes & MODES_PINGPONG) + return rs_bidir(vp, *countptr); + else + return rs_loop(vp, *countptr); + } + else + return rs_plain(v, countptr); + } +} + +void pre_resample(Sample * sp) +{ + double a, xdiff; + int32 incr, ofs, newlen, count; + int16 *newdata, *dest, *src = (int16 *) sp->data; + int16 v1, v2, v3, v4, *vptr; + static const char note_name[12][3] = + { + "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" + }; + + ctl->cmsg(CMSG_INFO, VERB_NOISY, " * pre-resampling for note %d (%s%d)", + sp->note_to_use, + note_name[sp->note_to_use % 12], (sp->note_to_use & 0x7F) / 12); + + a = ((double) (sp->sample_rate) * freq_table[(int) (sp->note_to_use)]) / + ((double) (sp->root_freq) * play_mode->rate); + newlen = sp->data_length / a; + dest = newdata = safe_malloc(newlen >> (FRACTION_BITS - 1)); + + count = (newlen >> FRACTION_BITS) - 1; + ofs = incr = (sp->data_length - (1 << FRACTION_BITS)) / count; + + if (--count) + *dest++ = src[0]; + + /* Since we're pre-processing and this doesn't have to be done in + real-time, we go ahead and do the full sliding cubic interpolation. */ + while (--count) + { + vptr = src + (ofs >> FRACTION_BITS); + v1 = *(vptr - 1); + v2 = *vptr; + v3 = *(vptr + 1); + v4 = *(vptr + 2); + xdiff = FSCALENEG(ofs & FRACTION_MASK, FRACTION_BITS); + *dest++ = v2 + (xdiff / 6.0) * (-2 * v1 - 3 * v2 + 6 * v3 - v4 + + xdiff * (3 * (v1 - 2 * v2 + v3) + xdiff * (-v1 + 3 * (v2 - v3) + v4))); + ofs += incr; + } + + if (ofs & FRACTION_MASK) + { + v1 = src[ofs >> FRACTION_BITS]; + v2 = src[(ofs >> FRACTION_BITS) + 1]; + *dest++ = v1 + (((v2 - v1) * (ofs & FRACTION_MASK)) >> FRACTION_BITS); + } + else + *dest++ = src[ofs >> FRACTION_BITS]; + + sp->data_length = newlen; + sp->loop_start = sp->loop_start / a; + sp->loop_end = sp->loop_end / a; + free(sp->data); + sp->data = (sample_t *) newdata; + sp->sample_rate = 0; +} diff --git a/timidity/resample.h b/timidity/resample.h new file mode 100644 index 00000000..3bb59dec --- /dev/null +++ b/timidity/resample.h @@ -0,0 +1,24 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + resample.h +*/ + +extern sample_t *resample_voice(int v, int32 *countptr); +extern void pre_resample(Sample *sp); diff --git a/timidity/sdl_a.c b/timidity/sdl_a.c new file mode 100644 index 00000000..83dabba9 --- /dev/null +++ b/timidity/sdl_a.c @@ -0,0 +1,36 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + sdl_a.c + + Functions to output RIFF WAVE format data to a file or stdout. + +*/ + +#include "config.h" +#include "output.h" + +/* export the playback mode */ + +#define dpm sdl_play_mode + +PlayMode dpm = { + DEFAULT_RATE, PE_16BIT|PE_SIGNED, + "SDL audio" +}; diff --git a/timidity/sdl_c.c b/timidity/sdl_c.c new file mode 100644 index 00000000..da35b489 --- /dev/null +++ b/timidity/sdl_c.c @@ -0,0 +1,121 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + sdl_c.c + Minimal control mode -- no interaction, just stores messages. + */ + +#include +#include +#include + +#include "config.h" +#include "common.h" +#include "output.h" +#include "controls.h" +#include "instrum.h" +#include "playmidi.h" + +static void ctl_refresh(void); +static void ctl_total_time(int tt); +static void ctl_master_volume(int mv); +static void ctl_file_name(char *name); +static void ctl_current_time(int ct); +static void ctl_note(int v); +static void ctl_program(int ch, int val); +static void ctl_volume(int channel, int val); +static void ctl_expression(int channel, int val); +static void ctl_panning(int channel, int val); +static void ctl_sustain(int channel, int val); +static void ctl_pitch_bend(int channel, int val); +static void ctl_reset(void); +static int ctl_open(int using_stdin, int using_stdout); +static void ctl_close(void); +static int ctl_read(int32 *valp); +static int cmsg(int type, int verbosity_level, char *fmt, ...); + +/**********************************/ +/* export the interface functions */ + +#define ctl sdl_control_mode + +ControlMode ctl= +{ + "SDL interface", 's', + 1,0,0, + ctl_open,NULL, ctl_close, ctl_read, cmsg, + ctl_refresh, ctl_reset, ctl_file_name, ctl_total_time, ctl_current_time, + ctl_note, + ctl_master_volume, ctl_program, ctl_volume, + ctl_expression, ctl_panning, ctl_sustain, ctl_pitch_bend +}; + +static int ctl_open(int using_stdin, int using_stdout) +{ + ctl.opened=1; + return 0; +} + +static void ctl_close(void) +{ + ctl.opened=0; +} + +static int ctl_read(int32 *valp) +{ + return RC_NONE; +} + +static int cmsg(int type, int verbosity_level, char *fmt, ...) +{ + va_list ap; + if ((type==CMSG_TEXT || type==CMSG_INFO || type==CMSG_WARNING) && + ctl.verbosity + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + The 8-bit uLaw to 16-bit PCM and the 13-bit-PCM to 8-bit uLaw + tables were lifted from the rsynth-2.0 sources. The README says: + + > + > This is a text to speech system produced by integrating various pieces + > of code and tables of data, which are all (I believe) in the public domain. + > + > The bulk of the intergration was done by myself, that is Nick Ing-Simmons. + > I can be reached via my employer at nik@tiuk.ti.com. + > + +*/ + +#include +#include "config.h" +#include "common.h" +#include "tables.h" + +int32 freq_table[128]= +{ + 8176, 8662, 9177, 9723, + 10301, 10913, 11562, 12250, + 12978, 13750, 14568, 15434, + + 16352, 17324, 18354, 19445, + 20602, 21827, 23125, 24500, + 25957, 27500, 29135, 30868, + + 32703, 34648, 36708, 38891, + 41203, 43654, 46249, 48999, + 51913, 55000, 58270, 61735, + + 65406, 69296, 73416, 77782, + 82407, 87307, 92499, 97999, + 103826, 110000, 116541, 123471, + + 130813, 138591, 146832, 155563, + 164814, 174614, 184997, 195998, + 207652, 220000, 233082, 246942, + + 261626, 277183, 293665, 311127, + 329628, 349228, 369994, 391995, + 415305, 440000, 466164, 493883, + + 523251, 554365, 587330, 622254, + 659255, 698456, 739989, 783991, + 830609, 880000, 932328, 987767, + + 1046502, 1108731, 1174659, 1244508, + 1318510, 1396913, 1479978, 1567982, + 1661219, 1760000, 1864655, 1975533, + + 2093005, 2217461, 2349318, 2489016, + 2637020, 2793826, 2959955, 3135963, + 3322438, 3520000, 3729310, 3951066, + + 4186009, 4434922, 4698636, 4978032, + 5274041, 5587652, 5919911, 6271927, + 6644875, 7040000, 7458620, 7902133, + + 8372018, 8869844, 9397273, 9956063, + 10548082, 11175303, 11839822, 12543854 +}; + +/* v=2.^((x/127-1) * 6) */ +float vol_table[128] = +{ + 0.015625, 0.016145143728351113, 0.016682602624583379, 0.017237953096759438, + 0.017811790741104401, 0.01840473098076444, 0.019017409725829021, 0.019650484055324921, + 0.020304632921913132, 0.020980557880044631, 0.021678983838355849, 0.02240065983711079, + 0.023146359851523596, 0.023916883621822989, 0.024713057510949051, 0.025535735390801884, + 0.026385799557992876, 0.027264161680080529, 0.028171763773305786, 0.029109579212875332, + 0.030078613776876421, 0.031079906724942836, 0.032114531912828696, 0.033183598944085631, + 0.034288254360078256, 0.035429682869614412, 0.036609108619508737, 0.037827796507442342, + 0.039087053538526394, 0.040388230227024875, 0.041732722044739302, 0.043121970917609151, + 0.044557466772132896, 0.046040749133268132, 0.047573408775524545, 0.049157089429020417, + 0.050793489542332405, 0.05248436410402918, 0.054231526524842463, 0.056036850582493913, + 0.057902272431264008, 0.059829792678457581, 0.061821478529993396, 0.063879466007418645, + 0.066005962238725971, 0.068203247825430205, 0.070473679288442961, 0.072819691595368496, + 0.075243800771931268, 0.077748606600335793, 0.080336795407452768, 0.083011142945821612, + 0.085774517370559328, 0.088629882315368294, 0.091580300070941839, 0.094628934869176312, + 0.097779056276712184, 0.10103404270144323, 0.1043973850157546, 0.1078726903003755, + 0.11146368571286204, 0.11517422248485852, 0.11900828005242428, 0.12296997032385605, + 0.12706354208958254, 0.13129338557886089, 0.13566403716816194, 0.14018018424629392, + 0.14484667024148207, 0.14966849981579558, 0.15465084423249356, 0.15979904690204472, + 0.16511862911277009, 0.17061529595225433, 0.17629494242587571, 0.18216365977901747, + 0.18822774202974024, 0.19449369271892172, 0.20096823188510385, 0.20765830327152621, + 0.21457108177307616, 0.22171398113114205, 0.2290946618846218, 0.23672103958561411, + 0.2446012932886038, 0.25274387432224471, 0.26115751535314891, 0.26985123975140174, + 0.27883437126784744, 0.28811654403352405, 0.29770771289197112, 0.30761816407549192, + 0.31785852623682015, 0.32843978184802081, 0.33937327897885317, 0.3506707434672246, + 0.36234429149478936, 0.37440644258117928, 0.38687013301080181, 0.39974872970660535, + 0.41305604456569134, 0.42680634927214656, 0.44101439060298442, 0.45569540624360722, + 0.47086514112975281, 0.48653986433345225, 0.50273638651110641, 0.51947207793239625, + 0.53676488710936021, 0.55463336004561792, 0.57309666012638816, 0.59217458867062556, + 0.61188760616732485, 0.63225685421876243, 0.65330417821421161, 0.67505215075844849, + 0.69752409588017272, 0.72074411404630734, 0.74473710800900605, 0.76952880951308478, + 0.79514580689252357, 0.82161557358563286, 0.84896649759946774, 0.87722791195508854, + 0.90643012614631979, 0.93660445864574493, 0.96778327049280244, 1 +}; + +float bend_fine[256] = { + 1, 1.0002256593050698, 1.0004513695322617, 1.0006771306930664, + 1.0009029427989777, 1.0011288058614922, 1.0013547198921082, 1.0015806849023274, + 1.0018067009036538, 1.002032767907594, 1.0022588859256572, 1.0024850549693551, + 1.0027112750502025, 1.0029375461797159, 1.0031638683694153, 1.0033902416308227, + 1.0036166659754628, 1.0038431414148634, 1.0040696679605541, 1.0042962456240678, + 1.0045228744169397, 1.0047495543507072, 1.0049762854369111, 1.0052030676870944, + 1.0054299011128027, 1.0056567857255843, 1.00588372153699, 1.006110708558573, + 1.0063377468018897, 1.0065648362784985, 1.0067919769999607, 1.0070191689778405, + 1.0072464122237039, 1.0074737067491204, 1.0077010525656616, 1.0079284496849015, + 1.0081558981184175, 1.008383397877789, 1.008610948974598, 1.0088385514204294, + 1.0090662052268706, 1.0092939104055114, 1.0095216669679448, 1.0097494749257656, + 1.009977334290572, 1.0102052450739643, 1.0104332072875455, 1.0106612209429215, + 1.0108892860517005, 1.0111174026254934, 1.0113455706759138, 1.0115737902145781, + 1.0118020612531047, 1.0120303838031153, 1.0122587578762337, 1.012487183484087, + 1.0127156606383041, 1.0129441893505169, 1.0131727696323602, 1.0134014014954713, + 1.0136300849514894, 1.0138588200120575, 1.0140876066888203, 1.0143164449934257, + 1.0145453349375237, 1.0147742765327674, 1.0150032697908125, 1.0152323147233171, + 1.015461411341942, 1.0156905596583505, 1.0159197596842091, 1.0161490114311862, + 1.0163783149109531, 1.0166076701351838, 1.0168370771155553, 1.0170665358637463, + 1.0172960463914391, 1.0175256087103179, 1.0177552228320703, 1.0179848887683858, + 1.0182146065309567, 1.0184443761314785, 1.0186741975816487, 1.0189040708931674, + 1.0191339960777379, 1.0193639731470658, 1.0195940021128593, 1.0198240829868295, + 1.0200542157806898, 1.0202844005061564, 1.0205146371749483, 1.0207449257987866, + 1.0209752663893958, 1.0212056589585028, 1.0214361035178368, 1.0216666000791297, + 1.0218971486541166, 1.0221277492545349, 1.0223584018921241, 1.0225891065786274, + 1.0228198633257899, 1.0230506721453596, 1.023281533049087, 1.0235124460487257, + 1.0237434111560313, 1.0239744283827625, 1.0242054977406807, 1.0244366192415495, + 1.0246677928971357, 1.0248990187192082, 1.025130296719539, 1.0253616269099028, + 1.0255930093020766, 1.0258244439078401, 1.0260559307389761, 1.0262874698072693, + 1.0265190611245079, 1.0267507047024822, 1.0269824005529853, 1.027214148687813, + 1.0274459491187637, 1.0276778018576387, 1.0279097069162415, 1.0281416643063788, + 1.0283736740398595, 1.0286057361284953, 1.0288378505841009, 1.0290700174184932, + 1.0293022366434921, 1.0295345082709197, 1.0297668323126017, 1.0299992087803651, + 1.030231637686041, 1.0304641190414621, 1.0306966528584645, 1.0309292391488862, + 1.0311618779245688, 1.0313945691973556, 1.0316273129790936, 1.0318601092816313, + 1.0320929581168212, 1.0323258594965172, 1.0325588134325767, 1.0327918199368598, + 1.0330248790212284, 1.0332579906975481, 1.0334911549776868, 1.033724371873515, + 1.0339576413969056, 1.0341909635597348, 1.0344243383738811, 1.0346577658512259, + 1.034891246003653, 1.0351247788430489, 1.0353583643813031, 1.0355920026303078, + 1.0358256936019572, 1.0360594373081489, 1.0362932337607829, 1.0365270829717617, + 1.0367609849529913, 1.0369949397163791, 1.0372289472738365, 1.0374630076372766, + 1.0376971208186156, 1.0379312868297725, 1.0381655056826686, 1.0383997773892284, + 1.0386341019613787, 1.0388684794110492, 1.0391029097501721, 1.0393373929906822, + 1.0395719291445176, 1.0398065182236185, 1.0400411602399278, 1.0402758552053915, + 1.0405106031319582, 1.0407454040315787, 1.0409802579162071, 1.0412151647977996, + 1.0414501246883161, 1.0416851375997183, 1.0419202035439705, 1.0421553225330404, + 1.042390494578898, 1.042625719693516, 1.0428609978888699, 1.043096329176938, + 1.0433317135697009, 1.0435671510791424, 1.0438026417172486, 1.0440381854960086, + 1.0442737824274138, 1.044509432523459, 1.044745135796141, 1.0449808922574599, + 1.0452167019194181, 1.0454525647940205, 1.0456884808932754, 1.0459244502291931, + 1.0461604728137874, 1.0463965486590741, 1.046632677777072, 1.0468688601798024, + 1.0471050958792898, 1.047341384887561, 1.0475777272166455, 1.047814122878576, + 1.048050571885387, 1.0482870742491166, 1.0485236299818055, 1.0487602390954964, + 1.0489969016022356, 1.0492336175140715, 1.0494703868430555, 1.0497072096012419, + 1.0499440858006872, 1.0501810154534512, 1.050417998571596, 1.0506550351671864, + 1.0508921252522903, 1.0511292688389782, 1.0513664659393229, 1.0516037165654004, + 1.0518410207292894, 1.0520783784430709, 1.0523157897188296, 1.0525532545686513, + 1.0527907730046264, 1.0530283450388465, 1.0532659706834067, 1.0535036499504049, + 1.0537413828519411, 1.0539791694001188, 1.0542170096070436, 1.0544549034848243, + 1.0546928510455722, 1.0549308523014012, 1.0551689072644284, 1.0554070159467728, + 1.0556451783605572, 1.0558833945179062, 1.0561216644309479, 1.0563599881118126, + 1.0565983655726334, 1.0568367968255465, 1.0570752818826903, 1.0573138207562065, + 1.057552413458239, 1.0577910600009348, 1.0580297603964437, 1.058268514656918, + 1.0585073227945128, 1.0587461848213857, 1.058985100749698, 1.0592240705916123 +}; + +float bend_coarse[128] = { + 1, 1.0594630943592953, 1.122462048309373, 1.189207115002721, + 1.2599210498948732, 1.3348398541700344, 1.4142135623730951, 1.4983070768766815, + 1.5874010519681994, 1.681792830507429, 1.7817974362806785, 1.8877486253633868, + 2, 2.1189261887185906, 2.244924096618746, 2.3784142300054421, + 2.5198420997897464, 2.6696797083400687, 2.8284271247461903, 2.996614153753363, + 3.1748021039363992, 3.363585661014858, 3.5635948725613571, 3.7754972507267741, + 4, 4.2378523774371812, 4.4898481932374912, 4.7568284600108841, + 5.0396841995794928, 5.3393594166801366, 5.6568542494923806, 5.993228307506727, + 6.3496042078727974, 6.727171322029716, 7.1271897451227151, 7.5509945014535473, + 8, 8.4757047548743625, 8.9796963864749824, 9.5136569200217682, + 10.079368399158986, 10.678718833360273, 11.313708498984761, 11.986456615013454, + 12.699208415745595, 13.454342644059432, 14.25437949024543, 15.101989002907095, + 16, 16.951409509748721, 17.959392772949972, 19.027313840043536, + 20.158736798317967, 21.357437666720553, 22.627416997969522, 23.972913230026901, + 25.398416831491197, 26.908685288118864, 28.508758980490853, 30.203978005814196, + 32, 33.902819019497443, 35.918785545899944, 38.054627680087073, + 40.317473596635935, 42.714875333441107, 45.254833995939045, 47.945826460053802, + 50.796833662982394, 53.817370576237728, 57.017517960981706, 60.407956011628393, + 64, 67.805638038994886, 71.837571091799887, 76.109255360174146, + 80.63494719327187, 85.429750666882214, 90.509667991878089, 95.891652920107603, + 101.59366732596479, 107.63474115247546, 114.03503592196341, 120.81591202325679, + 128, 135.61127607798977, 143.67514218359977, 152.21851072034829, + 161.26989438654374, 170.85950133376443, 181.01933598375618, 191.78330584021521, + 203.18733465192958, 215.26948230495091, 228.07007184392683, 241.63182404651357, + 256, 271.22255215597971, 287.35028436719938, 304.43702144069658, + 322.53978877308765, 341.71900266752868, 362.03867196751236, 383.56661168043064, + 406.37466930385892, 430.53896460990183, 456.14014368785394, 483.26364809302686, + 512, 542.44510431195943, 574.70056873439876, 608.87404288139317, + 645.0795775461753, 683.43800533505737, 724.07734393502471, 767.13322336086128, + 812.74933860771785, 861.07792921980365, 912.28028737570787, 966.52729618605372, + 1024, 1084.8902086239189, 1149.4011374687975, 1217.7480857627863, + 1290.1591550923506, 1366.8760106701147, 1448.1546878700494, 1534.2664467217226 +}; + +#ifdef LOOKUP_SINE +static float sine_table[257]= +{ + 0, 0.0061358846491544753, 0.012271538285719925, 0.01840672990580482, + 0.024541228522912288, 0.030674803176636626, 0.036807222941358832, 0.04293825693494082, + 0.049067674327418015, 0.055195244349689934, 0.061320736302208578, 0.067443919563664051, + 0.073564563599667426, 0.079682437971430126, 0.085797312344439894, 0.091908956497132724, + 0.098017140329560604, 0.10412163387205459, 0.11022220729388306, 0.11631863091190475, + 0.1224106751992162, 0.12849811079379317, 0.13458070850712617, 0.14065823933284921, + 0.14673047445536175, 0.15279718525844344, 0.15885814333386145, 0.16491312048996989, + 0.17096188876030122, 0.17700422041214875, 0.18303988795514095, 0.18906866414980619, + 0.19509032201612825, 0.2011046348420919, 0.20711137619221856, 0.21311031991609136, + 0.2191012401568698, 0.22508391135979283, 0.23105810828067111, 0.2370236059943672, + 0.24298017990326387, 0.24892760574572015, 0.25486565960451457, 0.26079411791527551, + 0.26671275747489837, 0.27262135544994898, 0.27851968938505306, 0.28440753721127188, + 0.29028467725446233, 0.29615088824362379, 0.30200594931922808, 0.30784964004153487, + 0.31368174039889152, 0.31950203081601569, 0.32531029216226293, 0.33110630575987643, + 0.33688985339222005, 0.34266071731199438, 0.34841868024943456, 0.35416352542049034, + 0.35989503653498811, 0.36561299780477385, 0.37131719395183754, 0.37700741021641826, + 0.38268343236508978, 0.38834504669882625, 0.3939920400610481, 0.39962419984564679, + 0.40524131400498986, 0.41084317105790391, 0.41642956009763715, 0.42200027079979968, + 0.42755509343028208, 0.43309381885315196, 0.43861623853852766, 0.4441221445704292, + 0.44961132965460654, 0.45508358712634384, 0.46053871095824001, 0.46597649576796618, + 0.47139673682599764, 0.47679923006332209, 0.48218377207912272, 0.487550160148436, + 0.49289819222978404, 0.49822766697278187, 0.50353838372571758, 0.50883014254310699, + 0.51410274419322166, 0.51935599016558964, 0.52458968267846895, 0.52980362468629461, + 0.53499761988709715, 0.54017147272989285, 0.54532498842204646, 0.55045797293660481, + 0.55557023301960218, 0.56066157619733603, 0.56573181078361312, 0.57078074588696726, + 0.57580819141784534, 0.58081395809576453, 0.58579785745643886, 0.59075970185887416, + 0.59569930449243336, 0.60061647938386897, 0.60551104140432555, 0.61038280627630948, + 0.61523159058062682, 0.6200572117632891, 0.62485948814238634, 0.62963823891492698, + 0.63439328416364549, 0.63912444486377573, 0.64383154288979139, 0.64851440102211244, + 0.65317284295377676, 0.65780669329707864, 0.66241577759017178, 0.66699992230363747, + 0.67155895484701833, 0.67609270357531592, 0.68060099779545302, 0.68508366777270036, + 0.68954054473706683, 0.693971460889654, 0.69837624940897292, 0.7027547444572253, + 0.70710678118654746, 0.71143219574521643, 0.71573082528381859, 0.72000250796138165, + 0.72424708295146689, 0.7284643904482252, 0.73265427167241282, 0.73681656887736979, + 0.74095112535495911, 0.74505778544146595, 0.74913639452345926, 0.75318679904361241, + 0.75720884650648446, 0.76120238548426178, 0.76516726562245896, 0.76910333764557959, + 0.77301045336273699, 0.77688846567323244, 0.78073722857209438, 0.78455659715557524, + 0.78834642762660623, 0.79210657730021239, 0.79583690460888346, 0.79953726910790501, + 0.80320753148064483, 0.80684755354379922, 0.81045719825259477, 0.8140363297059483, + 0.81758481315158371, 0.82110251499110465, 0.82458930278502529, 0.8280450452577558, + 0.83146961230254524, 0.83486287498638001, 0.83822470555483797, 0.84155497743689833, + 0.84485356524970701, 0.84812034480329712, 0.8513551931052652, 0.85455798836540053, + 0.85772861000027212, 0.86086693863776731, 0.8639728561215867, 0.86704624551569265, + 0.87008699110871135, 0.87309497841829009, 0.8760700941954066, 0.87901222642863341, + 0.88192126434835494, 0.88479709843093779, 0.88763962040285393, 0.89044872324475788, + 0.89322430119551532, 0.89596624975618511, 0.89867446569395382, 0.90134884704602203, + 0.90398929312344334, 0.90659570451491533, 0.90916798309052227, 0.91170603200542988, + 0.91420975570353069, 0.9166790599210427, 0.91911385169005777, 0.9215140393420419, + 0.92387953251128674, 0.92621024213831127, 0.92850608047321548, 0.93076696107898371, + 0.93299279883473885, 0.9351835099389475, 0.93733901191257496, 0.93945922360218992, + 0.94154406518302081, 0.94359345816196039, 0.94560732538052128, 0.94758559101774109, + 0.94952818059303667, 0.95143502096900834, 0.95330604035419375, 0.95514116830577067, + 0.95694033573220894, 0.9587034748958716, 0.96043051941556579, 0.96212140426904158, + 0.96377606579543984, 0.9653944416976894, 0.96697647104485207, 0.96852209427441727, + 0.97003125319454397, 0.97150389098625178, 0.97293995220556007, 0.97433938278557586, + 0.97570213003852857, 0.97702814265775439, 0.97831737071962765, 0.97956976568544052, + 0.98078528040323043, 0.98196386910955524, 0.98310548743121629, 0.98421009238692903, + 0.98527764238894122, 0.98630809724459867, 0.98730141815785843, 0.98825756773074946, + 0.98917650996478101, 0.99005821026229712, 0.99090263542778001, 0.99170975366909953, + 0.99247953459870997, 0.9932119492347945, 0.99390697000235606, 0.99456457073425542, + 0.99518472667219682, 0.99576741446765982, 0.996312612182778, 0.99682029929116567, + 0.99729045667869021, 0.99772306664419164, 0.99811811290014918, 0.99847558057329477, + 0.99879545620517241, 0.99907772775264536, 0.99932238458834954, 0.99952941750109314, + 0.99969881869620425, 0.9998305817958234, 0.9999247018391445, 0.99998117528260111, + 1 +}; + +/* + looks up sin(2 * Pi * x / 1024) +*/ +float sine(int x) +{ + int xx = x & 0xFF; + switch ((x>>8) & 0x03) + { + default: /* just to shut gcc up. */ + case 0: + return sine_table[xx]; + case 1: + return sine_table[0x100 - xx]; + case 2: + return -sine_table[xx]; + case 3: + return -sine_table[0x100 - xx]; + } +} +#endif /* LOOKUP_SINE */ + +#ifdef LOOKUP_HACK +int16 _u2l[] = +{ + -32256, -31228, -30200, -29172, -28143, -27115, -26087, -25059, + -24031, -23002, -21974, -20946, -19918, -18889, -17861, -16833, + -16062, -15548, -15033, -14519, -14005, -13491, -12977, -12463, + -11949, -11435, -10920, -10406, -9892, -9378, -8864, -8350, + -7964, -7707, -7450, -7193, -6936, -6679, -6422, -6165, + -5908, -5651, -5394, -5137, -4880, -4623, -4365, -4108, + -3916, -3787, -3659, -3530, -3402, -3273, -3144, -3016, + -2887, -2759, -2630, -2502, -2373, -2245, -2116, -1988, + -1891, -1827, -1763, -1698, -1634, -1570, -1506, -1441, + -1377, -1313, -1249, -1184, -1120, -1056, -992, -927, + -879, -847, -815, -783, -751, -718, -686, -654, + -622, -590, -558, -526, -494, -461, -429, -397, + -373, -357, -341, -325, -309, -293, -277, -261, + -245, -228, -212, -196, -180, -164, -148, -132, + -120, -112, -104, -96, -88, -80, -72, -64, + -56, -48, -40, -32, -24, -16, -8, 0, + 32256, 31228, 30200, 29172, 28143, 27115, 26087, 25059, + 24031, 23002, 21974, 20946, 19918, 18889, 17861, 16833, + 16062, 15548, 15033, 14519, 14005, 13491, 12977, 12463, + 11949, 11435, 10920, 10406, 9892, 9378, 8864, 8350, + 7964, 7707, 7450, 7193, 6936, 6679, 6422, 6165, + 5908, 5651, 5394, 5137, 4880, 4623, 4365, 4108, + 3916, 3787, 3659, 3530, 3402, 3273, 3144, 3016, + 2887, 2759, 2630, 2502, 2373, 2245, 2116, 1988, + 1891, 1827, 1763, 1698, 1634, 1570, 1506, 1441, + 1377, 1313, 1249, 1184, 1120, 1056, 992, 927, + 879, 847, 815, 783, 751, 718, 686, 654, + 622, 590, 558, 526, 494, 461, 429, 397, + 373, 357, 341, 325, 309, 293, 277, 261, + 245, 228, 212, 196, 180, 164, 148, 132, + 120, 112, 104, 96, 88, 80, 72, 64, + 56, 48, 40, 32, 24, 16, 8, 0 +}; + +int32 *mixup; +#ifdef LOOKUP_INTERPOLATION +int8 *iplookup; +#endif + +#endif + +void init_tables(void) +{ +#ifdef LOOKUP_HACK + int i,j,v; + mixup=safe_malloc(1<<(7+8+2)); /* Give your cache a workout! */ + + for (i=0; i<128; i++) + { + v=_u2l[255-i]; + for (j=-128; j<128; j++) + { + mixup[ ((i & 0x7F)<<8) | (j & 0xFF)] = + (v * j) << MIXUP_SHIFT; + } + } + +#ifdef LOOKUP_INTERPOLATION + iplookup=safe_malloc(1<<(9+5)); + for (i=-256; i<256; i++) + for(j=0; j<32; j++) + iplookup[((i<<5) & 0x3FE0) | j] = (i * j)>>5; + /* I don't know. Quantum bits? Magick? */ +#endif + +#endif +} + +uint8 _l2u_[] = +{ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, + 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, + 0x03, 0x03, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, + 0x04, 0x04, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, + 0x05, 0x05, 0x05, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, + 0x06, 0x06, 0x06, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, 0x07, + 0x07, 0x07, 0x07, 0x07, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, + 0x09, 0x09, 0x09, 0x09, 0x09, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, + 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0A, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, + 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0B, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, + 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, + 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0D, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, + 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0E, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, + 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, + 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, + 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, + 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, + 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, + 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, + 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, + 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, + 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, + 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, + 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, + 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, + 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, + 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, + 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, + 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1D, 0x1D, + 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, + 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, + 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, + 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1E, + 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, + 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, + 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, + 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, + 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, + 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, + 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, + 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23, 0x23, 0x23, + 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, + 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x23, 0x24, 0x24, 0x24, + 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, + 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x24, 0x25, 0x25, 0x25, + 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, + 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x25, 0x26, 0x26, 0x26, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, + 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, + 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x27, 0x28, 0x28, + 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, + 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x28, 0x29, 0x29, + 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, + 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x2A, 0x2A, + 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, + 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, 0x2B, 0x2B, + 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, + 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2B, 0x2C, 0x2C, + 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, + 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2C, 0x2D, 0x2D, + 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, + 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, + 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2E, 0x2F, 0x2F, + 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, + 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x2F, 0x30, + 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, + 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x32, + 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x32, 0x33, + 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x34, + 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x34, 0x35, + 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x36, + 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, + 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x37, 0x38, + 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x38, 0x39, + 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x3A, + 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3A, 0x3B, + 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3B, 0x3C, + 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3D, + 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, 0x3D, + 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, 0x3E, + 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, 0x3F, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, 0x41, + 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, 0x43, + 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, 0x45, + 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x46, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, 0x47, + 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x48, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, 0x49, + 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4A, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, 0x4B, + 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4C, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, 0x4D, + 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4E, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, 0x4F, + 0x50, 0x50, 0x50, 0x50, 0x51, 0x51, 0x51, 0x51, 0x52, 0x52, 0x52, 0x52, 0x53, 0x53, 0x53, 0x53, + 0x54, 0x54, 0x54, 0x54, 0x55, 0x55, 0x55, 0x55, 0x56, 0x56, 0x56, 0x56, 0x57, 0x57, 0x57, 0x57, + 0x58, 0x58, 0x58, 0x58, 0x59, 0x59, 0x59, 0x59, 0x5A, 0x5A, 0x5A, 0x5A, 0x5B, 0x5B, 0x5B, 0x5B, + 0x5C, 0x5C, 0x5C, 0x5C, 0x5D, 0x5D, 0x5D, 0x5D, 0x5E, 0x5E, 0x5E, 0x5E, 0x5F, 0x5F, 0x5F, 0x5F, + 0x60, 0x60, 0x61, 0x61, 0x62, 0x62, 0x63, 0x63, 0x64, 0x64, 0x65, 0x65, 0x66, 0x66, 0x67, 0x67, + 0x68, 0x68, 0x68, 0x69, 0x69, 0x6A, 0x6A, 0x6B, 0x6B, 0x6C, 0x6C, 0x6D, 0x6D, 0x6E, 0x6E, 0x6F, + 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7E, + 0xFF, 0xFE, 0xFD, 0xFC, 0xFB, 0xFA, 0xF9, 0xF8, 0xF7, 0xF6, 0xF5, 0xF4, 0xF3, 0xF2, 0xF1, 0xF0, + 0xEF, 0xEF, 0xEE, 0xEE, 0xED, 0xED, 0xEC, 0xEC, 0xEB, 0xEB, 0xEA, 0xEA, 0xE9, 0xE9, 0xE8, 0xE8, + 0xE7, 0xE7, 0xE6, 0xE6, 0xE5, 0xE5, 0xE4, 0xE4, 0xE3, 0xE3, 0xE2, 0xE2, 0xE1, 0xE1, 0xE0, 0xE0, + 0xDF, 0xDF, 0xDF, 0xDF, 0xDE, 0xDE, 0xDE, 0xDE, 0xDD, 0xDD, 0xDD, 0xDD, 0xDC, 0xDC, 0xDC, 0xDC, + 0xDB, 0xDB, 0xDB, 0xDB, 0xDA, 0xDA, 0xDA, 0xDA, 0xD9, 0xD9, 0xD9, 0xD9, 0xD8, 0xD8, 0xD8, 0xD8, + 0xD7, 0xD7, 0xD7, 0xD7, 0xD6, 0xD6, 0xD6, 0xD6, 0xD5, 0xD5, 0xD5, 0xD5, 0xD4, 0xD4, 0xD4, 0xD4, + 0xD3, 0xD3, 0xD3, 0xD3, 0xD2, 0xD2, 0xD2, 0xD2, 0xD1, 0xD1, 0xD1, 0xD1, 0xD0, 0xD0, 0xD0, 0xD0, + 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE, + 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCD, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, + 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCB, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, 0xCA, + 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC9, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, + 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC7, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, + 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC5, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, 0xC4, + 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC3, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, 0xC2, + 0xC2, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC1, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, + 0xC0, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, 0xBF, + 0xBF, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, 0xBE, + 0xBE, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, 0xBD, + 0xBD, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, 0xBC, + 0xBC, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, + 0xBB, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, 0xBA, + 0xBA, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, 0xB9, + 0xB9, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, 0xB8, + 0xB8, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, 0xB7, + 0xB7, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, 0xB6, + 0xB6, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, 0xB5, + 0xB5, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, 0xB4, + 0xB4, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, 0xB3, + 0xB3, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, 0xB2, + 0xB2, 0xB2, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, 0xB1, + 0xB1, 0xB1, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, 0xB0, + 0xB0, 0xB0, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, + 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, 0xAF, + 0xAF, 0xAF, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, + 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, 0xAE, + 0xAE, 0xAE, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, + 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, 0xAD, + 0xAD, 0xAD, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, + 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, 0xAC, + 0xAC, 0xAC, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, + 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, 0xAB, + 0xAB, 0xAB, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, + 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, + 0xAA, 0xAA, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, + 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, 0xA9, + 0xA9, 0xA9, 0xA9, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, + 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, 0xA8, + 0xA8, 0xA8, 0xA8, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, + 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, 0xA7, + 0xA7, 0xA7, 0xA7, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, + 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, 0xA6, + 0xA6, 0xA6, 0xA6, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, + 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, 0xA5, + 0xA5, 0xA5, 0xA5, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, + 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, 0xA4, + 0xA4, 0xA4, 0xA4, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, + 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, 0xA3, + 0xA3, 0xA3, 0xA3, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, + 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, 0xA2, + 0xA2, 0xA2, 0xA2, 0xA2, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, + 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, 0xA1, + 0xA1, 0xA1, 0xA1, 0xA1, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, + 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, + 0xA0, 0xA0, 0xA0, 0xA0, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, + 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, + 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, + 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, 0x9F, + 0x9F, 0x9F, 0x9F, 0x9F, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, + 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, + 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, + 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, 0x9E, + 0x9E, 0x9E, 0x9E, 0x9E, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, + 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, + 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, + 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, + 0x9D, 0x9D, 0x9D, 0x9D, 0x9D, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, + 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, + 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, + 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, + 0x9C, 0x9C, 0x9C, 0x9C, 0x9C, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, + 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, + 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, + 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, + 0x9B, 0x9B, 0x9B, 0x9B, 0x9B, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, + 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, + 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, + 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, + 0x9A, 0x9A, 0x9A, 0x9A, 0x9A, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, + 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, + 0x98, 0x98, 0x98, 0x98, 0x98, 0x98, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, + 0x97, 0x97, 0x97, 0x97, 0x97, 0x97, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, + 0x96, 0x96, 0x96, 0x96, 0x96, 0x96, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, + 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x95, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, + 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x94, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, + 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x93, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, + 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, + 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x91, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, + 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, + 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, + 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, + 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, + 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, + 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, + 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, + 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, + 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, + 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, + 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, + 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, + 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, + 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, + 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, + 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, + 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8E, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, + 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, + 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, + 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, + 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, + 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, + 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, + 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, + 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8D, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, + 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, + 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, + 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, + 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, + 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, + 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, + 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, + 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8C, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, + 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, + 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, + 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, + 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, + 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, + 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, + 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, + 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8B, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, + 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, + 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, + 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, + 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, + 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, + 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, + 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, + 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x8A, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, + 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x89, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, + 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x88, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, + 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x87, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, + 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x86, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, + 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x85, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, + 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, + 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x83, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 +}; + +uint8 *_l2u = _l2u_ + 4096; diff --git a/timidity/tables.h b/timidity/tables.h new file mode 100644 index 00000000..cb490090 --- /dev/null +++ b/timidity/tables.h @@ -0,0 +1,45 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + + tables.h +*/ + +#ifdef LOOKUP_SINE +extern float sine(int x); +#else +#include +#define sine(x) (sin((2*PI/1024.0) * (x))) +#endif + +#define SINE_CYCLE_LENGTH 1024 +extern int32 freq_table[]; +extern float vol_table[]; +extern float bend_fine[]; +extern float bend_coarse[]; +extern uint8 *_l2u; /* 13-bit PCM to 8-bit u-law */ +extern uint8 _l2u_[]; /* used in LOOKUP_HACK */ +#ifdef LOOKUP_HACK +extern int16 _u2l[]; +extern int32 *mixup; +#ifdef LOOKUP_INTERPOLATION +extern int8 *iplookup; +#endif +#endif + +extern void init_tables(void); diff --git a/timidity/timidity.c b/timidity/timidity.c new file mode 100644 index 00000000..ea90f516 --- /dev/null +++ b/timidity/timidity.c @@ -0,0 +1,360 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ +#include +#include +#include + +#include +#include "config.h" +#include "common.h" +#include "instrum.h" +#include "playmidi.h" +#include "readmidi.h" +#include "output.h" +#include "controls.h" +#include "timidity.h" + +#include "tables.h" + +void (*s32tobuf)(void *dp, int32 *lp, int32 c); +int free_instruments_afterwards=0; +static char def_instr_name[256]=""; + +int AUDIO_BUFFER_SIZE; +sample_t *resample_buffer; +int32 *common_buffer; + +#define MAXWORDS 10 + +static int read_config_file(char *name) +{ + FILE *fp; + char tmp[1024], *w[MAXWORDS], *cp; + ToneBank *bank=0; + int i, j, k, line=0, words; + static int rcf_count=0; + + if (rcf_count>50) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "Probable source loop in configuration files"); + return (-1); + } + + if (!(fp=open_file(name, 1, OF_VERBOSE))) + return -1; + + while (fgets(tmp, sizeof(tmp), fp)) + { + line++; + w[words=0]=strtok(tmp, " \t\r\n\240"); + if (!w[0] || (*w[0]=='#')) continue; + while (w[words] && (words < MAXWORDS)) + w[++words]=strtok(0," \t\r\n\240"); + if (!strcmp(w[0], "dir")) + { + if (words < 2) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: No directory given\n", name, line); + return -2; + } + for (i=1; icmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: No file name given\n", name, line); + return -2; + } + for (i=1; icmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: Must specify exactly one patch name\n", + name, line); + return -2; + } + strncpy(def_instr_name, w[1], 255); + def_instr_name[255]='\0'; + } + else if (!strcmp(w[0], "drumset")) + { + if (words < 2) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: No drum set number given\n", + name, line); + return -2; + } + i=atoi(w[1]); + if (i<0 || i>127) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: Drum set must be between 0 and 127\n", + name, line); + return -2; + } + if (!drumset[i]) + { + drumset[i]=safe_malloc(sizeof(ToneBank)); + memset(drumset[i], 0, sizeof(ToneBank)); + } + bank=drumset[i]; + } + else if (!strcmp(w[0], "bank")) + { + if (words < 2) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: No bank number given\n", + name, line); + return -2; + } + i=atoi(w[1]); + if (i<0 || i>127) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: Tone bank must be between 0 and 127\n", + name, line); + return -2; + } + if (!tonebank[i]) + { + tonebank[i]=safe_malloc(sizeof(ToneBank)); + memset(tonebank[i], 0, sizeof(ToneBank)); + } + bank=tonebank[i]; + } + else { + if ((words < 2) || (*w[0] < '0' || *w[0] > '9')) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: syntax error\n", name, line); + return -2; + } + i=atoi(w[0]); + if (i<0 || i>127) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: Program must be between 0 and 127\n", + name, line); + return -2; + } + if (!bank) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: Must specify tone bank or drum set " + "before assignment\n", + name, line); + return -2; + } + if (bank->tone[i].name) + free(bank->tone[i].name); + strcpy((bank->tone[i].name=safe_malloc(strlen(w[1])+1)),w[1]); + bank->tone[i].note=bank->tone[i].amp=bank->tone[i].pan= + bank->tone[i].strip_loop=bank->tone[i].strip_envelope= + bank->tone[i].strip_tail=-1; + + for (j=2; j '9')) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: amplification must be between " + "0 and %d\n", name, line, MAX_AMPLIFICATION); + return -2; + } + bank->tone[i].amp=k; + } + else if (!strcmp(w[j], "note")) + { + k=atoi(cp); + if ((k<0 || k>127) || (*cp < '0' || *cp > '9')) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: note must be between 0 and 127\n", + name, line); + return -2; + } + bank->tone[i].note=k; + } + else if (!strcmp(w[j], "pan")) + { + if (!strcmp(cp, "center")) + k=64; + else if (!strcmp(cp, "left")) + k=0; + else if (!strcmp(cp, "right")) + k=127; + else + k=((atoi(cp)+100) * 100) / 157; + if ((k<0 || k>127) || + (k==0 && *cp!='-' && (*cp < '0' || *cp > '9'))) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: panning must be left, right, " + "center, or between -100 and 100\n", + name, line); + return -2; + } + bank->tone[i].pan=k; + } + else if (!strcmp(w[j], "keep")) + { + if (!strcmp(cp, "env")) + bank->tone[i].strip_envelope=0; + else if (!strcmp(cp, "loop")) + bank->tone[i].strip_loop=0; + else + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: keep must be env or loop\n", name, line); + return -2; + } + } + else if (!strcmp(w[j], "strip")) + { + if (!strcmp(cp, "env")) + bank->tone[i].strip_envelope=1; + else if (!strcmp(cp, "loop")) + bank->tone[i].strip_loop=1; + else if (!strcmp(cp, "tail")) + bank->tone[i].strip_tail=1; + else + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, + "%s: line %d: strip must be env, loop, or tail\n", + name, line); + return -2; + } + } + else + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "%s: line %d: bad patch option %s\n", + name, line, w[j]); + return -2; + } + } + } + } + if (ferror(fp)) + { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Can't read from %s\n", name); + close_file(fp); + return -2; + } + close_file(fp); + return 0; +} + +int Timidity_Init(int rate, int format, int channels, int samples) +{ + if (read_config_file(CONFIG_FILE)<0) { + return(-1); + } + + /* Set play mode parameters */ + play_mode->rate = rate; + play_mode->encoding = 0; + if ( (format&0xFF) == 16 ) { + play_mode->encoding |= PE_16BIT; + } + if ( (format&0x8000) ) { + play_mode->encoding |= PE_SIGNED; + } + if ( channels == 1 ) { + play_mode->encoding |= PE_MONO; + } + switch (format) { + case AUDIO_S8: + s32tobuf = s32tos8; + break; + case AUDIO_U8: + s32tobuf = s32tou8; + break; + case AUDIO_S16LSB: + s32tobuf = s32tos16l; + break; + case AUDIO_S16MSB: + s32tobuf = s32tos16b; + break; + case AUDIO_U16LSB: + s32tobuf = s32tou16l; + break; + case AUDIO_U16MSB: + s32tobuf = s32tou16b; + break; + default: + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Unsupported audio format"); + return(-1); + } + AUDIO_BUFFER_SIZE = samples; + + /* Allocate memory for mixing (WARNING: Memory leak!) */ + resample_buffer = safe_malloc(AUDIO_BUFFER_SIZE*sizeof(sample_t)); + common_buffer = safe_malloc(AUDIO_BUFFER_SIZE*2*sizeof(int32)); + + init_tables(); + + if (ctl->open(0, 0)) { + ctl->cmsg(CMSG_ERROR, VERB_NORMAL, "Couldn't open %s\n", ctl->id_name); + return(-1); + } + + if (!control_ratio) { + control_ratio = play_mode->rate / CONTROLS_PER_SECOND; + if(control_ratio<1) + control_ratio=1; + else if (control_ratio > MAX_CONTROL_RATIO) + control_ratio=MAX_CONTROL_RATIO; + } + if (*def_instr_name) + set_default_instrument(def_instr_name); + return(0); +} + +char timidity_error[1024] = ""; +char *Timidity_Error(void) +{ + return(timidity_error); +} diff --git a/timidity/timidity.h b/timidity/timidity.h new file mode 100644 index 00000000..2cffcc99 --- /dev/null +++ b/timidity/timidity.h @@ -0,0 +1,33 @@ +/* + + TiMidity -- Experimental MIDI to WAVE converter + Copyright (C) 1995 Tuukka Toivonen + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +typedef struct _MidiSong MidiSong; + +extern int Timidity_Init(int rate, int format, int channels, int samples); +extern char *Timidity_Error(void); +extern void Timidity_SetVolume(int volume); +extern int Timidity_PlaySome(void *stream, int samples); +extern MidiSong *Timidity_LoadSong(char *midifile); +extern void Timidity_Start(MidiSong *song); +extern int Timidity_Active(void); +extern void Timidity_Stop(void); +extern void Timidity_FreeSong(MidiSong *song); + diff --git a/wave.h b/wave.h new file mode 100644 index 00000000..4b9be2ad --- /dev/null +++ b/wave.h @@ -0,0 +1,51 @@ +/* + Taken with permission from SDL_wave.h, part of the SDL library, + available at: http://www.devolution.com/~slouken/SDL + and placed under the same license as this mixer library. +*/ + +/* WAVE files are little-endian */ + +/*******************************************/ +/* Define values for Microsoft WAVE format */ +/*******************************************/ +#define RIFF 0x46464952 /* "RIFF" */ +#define WAVE 0x45564157 /* "WAVE" */ +#define FACT 0x74636166 /* "fact" */ +#define LIST 0x5453494c /* "LIST" */ +#define FMT 0x20746D66 /* "fmt " */ +#define DATA 0x61746164 /* "data" */ +#define PCM_CODE 1 +#define ADPCM_CODE 2 +#define WAVE_MONO 1 +#define WAVE_STEREO 2 + +/* Normally, these three chunks come consecutively in a WAVE file */ +typedef struct WaveFMT { +/* Not saved in the chunk we read: + Uint32 FMTchunk; + Uint32 fmtlen; +*/ + Uint16 encoding; + Uint16 channels; /* 1 = mono, 2 = stereo */ + Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */ + Uint32 byterate; /* Average bytes per second */ + Uint16 blockalign; /* Bytes per sample block */ + Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */ +} WaveFMT; + +/* The general chunk found in the WAVE file */ +typedef struct Chunk { + Uint32 magic; + Uint32 length; + Uint8 *data; /* Data includes magic and length */ +} Chunk; + +/*********************************************/ +/* Define values for AIFF (IFF audio) format */ +/*********************************************/ +#define FORM 0x4d524f46 /* "FORM" */ +#define AIFF 0x46464941 /* "AIFF" */ +#define SSND 0x444e5353 /* "SSND" */ +#define COMM 0x4d4d4f43 /* "COMM" */ + diff --git a/wavestream.c b/wavestream.c new file mode 100644 index 00000000..e7920834 --- /dev/null +++ b/wavestream.c @@ -0,0 +1,471 @@ +/* + MIXERLIB: An audio mixer library based on the SDL library + Copyright (C) 1997-1999 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +/* This file supports streaming WAV files, without volume adjustment */ + +#include +#include + +#include +#include +#include +#include + +#include "wave.h" +#include "wavestream.h" + +/* Currently we only support a single stream at a time */ +static WAVStream *theWave = NULL; + +/* This is initialized by the music mixer */ +SDL_mutex *music_lock = NULL; + +/* This is the format of the audio mixer data */ +static SDL_AudioSpec mixer; + +/* Function to load the WAV/AIFF stream */ +static FILE *LoadWAVStream (const char *file, SDL_AudioSpec *spec, + long *start, long *stop); +static FILE *LoadAIFFStream (const char *file, SDL_AudioSpec *spec, + long *start, long *stop); + +/* Initialize the WAVStream player, with the given mixer settings + This function returns 0, or -1 if there was an error. + */ +int WAVStream_Init(SDL_AudioSpec *mixerfmt) +{ + /* FIXME: clean up the mutex, or move it into music.c */ + music_lock = SDL_CreateMutex(); + if ( music_lock == NULL ) { + return(-1); + } + mixer = *mixerfmt; + return(0); +} + +/* Unimplemented */ +extern void WAVStream_SetVolume(int volume) +{ +} + +/* Load a WAV stream from the given file */ +extern WAVStream *WAVStream_LoadSong(const char *file, const char *magic) +{ + WAVStream *wave; + SDL_AudioSpec wavespec; + + if ( ! mixer.format ) { + SDL_SetError("WAV music output not started"); + return(NULL); + } + wave = (WAVStream *)malloc(sizeof *wave); + if ( wave ) { + memset(wave, 0, (sizeof *wave)); + if ( strcmp(magic, "RIFF") == 0 ) { + wave->wavefp = LoadWAVStream(file, &wavespec, + &wave->start, &wave->stop); + } else + if ( strcmp(magic, "FORM") == 0 ) { + wave->wavefp = LoadAIFFStream(file, &wavespec, + &wave->start, &wave->stop); + } + if ( wave->wavefp == NULL ) { + free(wave); + return(NULL); + } + SDL_BuildAudioCVT(&wave->cvt, + wavespec.format, wavespec.channels, wavespec.freq, + mixer.format, mixer.channels, mixer.freq); + } + return(wave); +} + +/* Start playback of a given WAV stream */ +extern void WAVStream_Start(WAVStream *wave) +{ + SDL_mutexP(music_lock); + clearerr(wave->wavefp); + fseek(wave->wavefp, wave->start, SEEK_SET); + theWave = wave; + SDL_mutexV(music_lock); +} + +/* Play some of a stream previously started with WAVStream_Start() + The music_lock is held while this function is called. + */ +extern void WAVStream_PlaySome(Uint8 *stream, int len) +{ + long pos; + + SDL_mutexP(music_lock); + if ( theWave && ((pos=ftell(theWave->wavefp)) < theWave->stop) ) { + if ( theWave->cvt.needed ) { + int original_len; + + original_len=(int)((double)len/theWave->cvt.len_ratio); + if ( theWave->cvt.len != original_len ) { + int worksize; + if ( theWave->cvt.buf != NULL ) { + free(theWave->cvt.buf); + } + worksize = original_len*theWave->cvt.len_mult; + theWave->cvt.buf=(Uint8 *)malloc(worksize); + if ( theWave->cvt.buf == NULL ) { + SDL_mutexV(music_lock); + return; + } + theWave->cvt.len = original_len; + } + if ( (theWave->stop - pos) < original_len ) { + original_len = (theWave->stop - pos); + } + theWave->cvt.len = original_len; + fread(theWave->cvt.buf,original_len,1,theWave->wavefp); + SDL_ConvertAudio(&theWave->cvt); + memcpy(stream, theWave->cvt.buf, theWave->cvt.len_cvt); + } else { + if ( (theWave->stop - pos) < len ) { + len = (theWave->stop - pos); + } + fread(stream, len, 1, theWave->wavefp); + } + } + SDL_mutexV(music_lock); +} + +/* Stop playback of a stream previously started with WAVStream_Start() */ +extern void WAVStream_Stop(void) +{ + SDL_mutexP(music_lock); + theWave = NULL; + SDL_mutexV(music_lock); +} + +/* Close the given WAV stream */ +extern void WAVStream_FreeSong(WAVStream *wave) +{ + if ( wave ) { + /* Remove song from the currently playing list */ + SDL_mutexP(music_lock); + if ( wave == theWave ) { + theWave = NULL; + } + SDL_mutexV(music_lock); + + /* Clean up associated data */ + if ( wave->wavefp ) { + fclose(wave->wavefp); + } + if ( wave->cvt.buf ) { + free(wave->cvt.buf); + } + free(wave); + } +} + +/* Return non-zero if a stream is currently playing */ +extern int WAVStream_Active(void) +{ + int active; + + SDL_mutexP(music_lock); + active = 0; + if ( theWave && (ftell(theWave->wavefp) < theWave->stop) ) { + active = 1; + } + SDL_mutexV(music_lock); + + return(active); +} + +static int ReadChunk(SDL_RWops *src, Chunk *chunk, int read_data) +{ + chunk->magic = SDL_ReadLE32(src); + chunk->length = SDL_ReadLE32(src); + if ( read_data ) { + chunk->data = (Uint8 *)malloc(chunk->length); + if ( chunk->data == NULL ) { + SDL_SetError("Out of memory"); + return(-1); + } + if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) { + SDL_SetError("Couldn't read chunk"); + free(chunk->data); + return(-1); + } + } else { + SDL_RWseek(src, chunk->length, SEEK_CUR); + } + return(chunk->length); +} + +static FILE *LoadWAVStream (const char *file, SDL_AudioSpec *spec, + long *start, long *stop) +{ + int was_error; + FILE *wavefp; + SDL_RWops *src; + Chunk chunk; + int lenread; + + /* WAV magic header */ + Uint32 RIFFchunk; + Uint32 wavelen; + Uint32 WAVEmagic; + + /* FMT chunk */ + WaveFMT *format = NULL; + + /* Make sure we are passed a valid data source */ + was_error = 0; + wavefp = fopen(file, "rb"); + src = NULL; + if ( wavefp ) { + src = SDL_RWFromFP(wavefp, 0); + } + if ( src == NULL ) { + was_error = 1; + goto done; + } + + /* Check the magic header */ + RIFFchunk = SDL_ReadLE32(src); + wavelen = SDL_ReadLE32(src); + WAVEmagic = SDL_ReadLE32(src); + if ( (RIFFchunk != RIFF) || (WAVEmagic != WAVE) ) { + SDL_SetError("Unrecognized file type (not WAVE)"); + was_error = 1; + goto done; + } + + /* Read the audio data format chunk */ + chunk.data = NULL; + do { + /* FIXME! Add this logic to SDL_LoadWAV_RW() */ + if ( chunk.data ) { + free(chunk.data); + } + lenread = ReadChunk(src, &chunk, 1); + if ( lenread < 0 ) { + was_error = 1; + goto done; + } + } while ( (chunk.magic == FACT) || (chunk.magic == LIST) ); + + /* Decode the audio data format */ + format = (WaveFMT *)chunk.data; + if ( chunk.magic != FMT ) { + free(chunk.data); + SDL_SetError("Complex WAVE files not supported"); + was_error = 1; + goto done; + } + switch (SDL_SwapLE16(format->encoding)) { + case PCM_CODE: + /* We can understand this */ + break; + default: + SDL_SetError("Unknown WAVE data format"); + was_error = 1; + goto done; + } + memset(spec, 0, (sizeof *spec)); + spec->freq = SDL_SwapLE32(format->frequency); + switch (SDL_SwapLE16(format->bitspersample)) { + case 8: + spec->format = AUDIO_U8; + break; + case 16: + spec->format = AUDIO_S16; + break; + default: + SDL_SetError("Unknown PCM data format"); + was_error = 1; + goto done; + } + spec->channels = SDL_SwapLE16(format->channels); + spec->samples = 4096; /* Good default buffer size */ + + /* Set the file offset to the DATA chunk data */ + chunk.data = NULL; + do { + *start = SDL_RWtell(src) + 2*sizeof(Uint32); + lenread = ReadChunk(src, &chunk, 0); + if ( lenread < 0 ) { + was_error = 1; + goto done; + } + } while ( chunk.magic != DATA ); + *stop = SDL_RWtell(src); + +done: + if ( format != NULL ) { + free(format); + } + if ( src ) { + SDL_RWclose(src); + } + if ( was_error ) { + if ( wavefp ) { + fclose(wavefp); + wavefp = NULL; + } + } + return(wavefp); +} + +static double SANE_to_double(Uint32 l1, Uint32 l2, Uint16 s1) +{ + double d; + struct almost_double { + Uint32 hi, lo; + } *dp = (struct almost_double *)&d; + + dp->hi = ((l1 << 4) & 0x3ff00000) | (l1 & 0xc0000000); + dp->hi |= (l1 << 5) & 0xffff0; + dp->hi |= (l2 >> 27) & 0x1f; + dp->lo = (l2 << 5) & 0xffffffe0; + dp->lo |= ((s1 >> 11) & 0x1f); + return(d); +} + +static FILE *LoadAIFFStream (const char *file, SDL_AudioSpec *spec, + long *start, long *stop) +{ + int was_error; + FILE *wavefp; + SDL_RWops *src; + Chunk chunk; + int lenread; + + /* AIFF magic header */ + Uint32 FORMchunk; + Uint32 chunklen; + Uint32 AIFFmagic; + /* SSND chunk */ + Uint32 SSNDchunk; + Uint32 ssndlen; + Uint32 offset; + Uint32 blocksize; + /* COMM format chunk */ + Uint32 COMMchunk; + Uint32 commlen; + Uint16 channels; + Uint32 numsamples; + Uint16 samplesize; + struct { /* plus a SANE format double precision number */ + Uint32 l1; + Uint32 l2; + Uint16 s1; + } sane_freq; + + Uint32 frequency; + + + /* Make sure we are passed a valid data source */ + was_error = 0; + wavefp = fopen(file, "rb"); + src = NULL; + if ( wavefp ) { + src = SDL_RWFromFP(wavefp, 0); + } + if ( src == NULL ) { + was_error = 1; + goto done; + } + + /* Check the magic header */ + FORMchunk = SDL_ReadLE32(src); + chunklen = SDL_ReadLE32(src); + AIFFmagic = SDL_ReadLE32(src); + if ( (FORMchunk != FORM) || (AIFFmagic != AIFF) ) { + SDL_SetError("Unrecognized file type (not AIFF)"); + was_error = 1; + goto done; + } + + /* Read the SSND data chunk */ + SSNDchunk = SDL_ReadLE32(src); + if ( SSNDchunk != SSND ) { + SDL_SetError("Unrecognized AIFF chunk (not SSND)"); + was_error = 1; + goto done; + } + ssndlen = SDL_ReadLE32(src); + offset = SDL_ReadLE32(src); + blocksize = SDL_ReadLE32(src); + + /* Fill in start and stop pointers, then seek to format chunk */ + ssndlen -= (2*sizeof(Uint32)); + *start = SDL_RWtell(src) + offset; + *stop = SDL_RWtell(src) + ssndlen; + SDL_RWseek(src, *stop, SEEK_SET); + + /* Read the audio data format chunk */ + COMMchunk = SDL_ReadLE32(src); + if ( COMMchunk != COMM ) { + SDL_SetError("Unrecognized AIFF chunk (not COMM)"); + was_error = 1; + goto done; + } + commlen = SDL_ReadLE32(src); + channels = SDL_ReadLE16(src); + numsamples = SDL_ReadLE32(src); + samplesize = SDL_ReadLE16(src); + sane_freq.l1 = SDL_ReadLE32(src); + sane_freq.l2 = SDL_ReadLE32(src); + sane_freq.s1 = SDL_ReadLE16(src); + frequency = (Uint32)SANE_to_double(sane_freq.l1, sane_freq.l2, + sane_freq.s1); + + /* Decode the audio data format */ + memset(spec, 0, (sizeof *spec)); + spec->freq = frequency; + switch (samplesize) { + case 8: + spec->format = AUDIO_U8; + break; + case 16: + spec->format = AUDIO_S16; + break; + default: + SDL_SetError("Unknown samplesize in data format"); + was_error = 1; + goto done; + } + spec->channels = channels; + spec->samples = 4096; /* Good default buffer size */ + +done: + if ( src ) { + SDL_RWclose(src); + } + if ( was_error ) { + if ( wavefp ) { + fclose(wavefp); + wavefp = NULL; + } + } + return(wavefp); +} diff --git a/wavestream.h b/wavestream.h new file mode 100644 index 00000000..a827feb1 --- /dev/null +++ b/wavestream.h @@ -0,0 +1,60 @@ +/* + MIXERLIB: An audio mixer library based on the SDL library + Copyright (C) 1997-1999 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + 5635-34 Springhouse Dr. + Pleasanton, CA 94588 (USA) + slouken@devolution.com +*/ + +/* This file supports streaming WAV files, without volume adjustment */ + +#include + +typedef struct { + FILE *wavefp; + long start; + long stop; + SDL_AudioCVT cvt; +} WAVStream; + +/* Initialize the WAVStream player, with the given mixer settings + This function returns 0, or -1 if there was an error. + */ +extern int WAVStream_Init(SDL_AudioSpec *mixer); + +/* Unimplemented */ +extern void WAVStream_SetVolume(int volume); + +/* Load a WAV stream from the given file */ +extern WAVStream *WAVStream_LoadSong(const char *file, const char *magic); + +/* Start playback of a given WAV stream */ +extern void WAVStream_Start(WAVStream *wave); + +/* Play some of a stream previously started with WAVStream_Start() */ +extern void WAVStream_PlaySome(Uint8 *stream, int len); + +/* Stop playback of a stream previously started with WAVStream_Start() */ +extern void WAVStream_Stop(void); + +/* Close the given WAV stream */ +extern void WAVStream_FreeSong(WAVStream *wave); + +/* Return non-zero if a stream is currently playing */ +extern int WAVStream_Active(void);