forked-daapd-0.19gcd/0000775000175000017500000000000011633141307014001 5ustar julienjulienforked-daapd-0.19gcd/.gitignore0000664000175000017500000000045311633141135015772 0ustar julienjulien*~ *.swp Makefile.in Makefile *.o *.lo *.a *.la .deps/ .libs/ # autofoo stuff autom4te.cache aclocal.m4 compile config.guess config.h config.h.in config.log config.status config.sub configure depcomp install-sh libtool ltmain.sh missing stamp-h1 # ignore debian packaging for convenience debian/ forked-daapd-0.19gcd/AUTHORS0000664000175000017500000000060111633141135015045 0ustar julienjulienforked-daapd is a fork/rewrite of mt-daapd (Firefly Media Server) written by Julien BLACHE . mt-daapd (Firefly Media Server) was originally written by Ron Pedde and a handful of contributors. Contributors to forked-daapd include: - Ace Jones - Dustin King - Kai Elwert forked-daapd-0.19gcd/COPYING0000664000175000017500000004310311633141135015034 0ustar julienjulien GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. forked-daapd-0.19gcd/ChangeLog0000664000175000017500000000466511633141135015565 0ustar julienjulienChangeLog for forked-daapd -------------------------- version 0.19gcd: - no GCD-specific changes. version 0.19: - more libav 0.7 updates. - database speedups. - fix for iTunes 30-minute timeout. - fixes, big and small. version 0.18gcd: - build fix for FreeBSD, from Raivo Hool. version 0.18: - add config knob for ALSA mixer channel name. - do not elevate privileges for reopening the log file; log file will now be owned by the user forked-daapd runs as. - fixes, big and small. version 0.17gcd: - initial release of the GCD codebase. version 0.17: - support for libav 0.7 - fixes, big and small. version 0.16: - fix issue with non-UTF-8 metadata while scanning. - use proper file size in HTTP streaming code. - fix DAAP songlist bug with sort tags. - small code fixes. version 0.15: - add support for sending metadata to AppleTV during AirTunes streaming. - support DOS-encoded Remote pairing files. - rework album_artist_sort handling. - enable RAOP to queue RTSP requests. - speedup DAAP & RSP filters processing. - speedup DAAP songlist generation. - artwork can handle and send out both PNG and JPEG. - fixes, big and small. version 0.14: - sort headers/tags handling improvements. - better handling of tags for TV shows. - better handling of DRM-afflicted files. - configurable IPv6 support. - fix scanning of URL files. - fixes, big and small. version 0.13: - add Remote v2 support; Remote v1 is not supported anymore. - add per-speaker volume support. - implement RAOP retransmission. - implement per-device quirks in RAOP. - improve compatibility with 802.11g AirPort Express. - improve mDNS address resolution, making IPv4 usable again. - fix Murmur Hash bug on 32bit platforms. - add support for JPEG artwork and alternative filenames. - disable session expiration that was causing issues. - FFmpeg 0.6 support. - fixes, big and small. version 0.12: - add AirTunes v2 streaming. - add Remote support. - add gzipped replies. - add IPv6 support. - check for UTF-8 correctness of metadata. - fixes, big and small. version 0.11: - support iTunes 9. - add iTunes XML playlist scanner. - add support for TV shows. - add FreeBSD and GNU/kFreeBSD support. - add support for DAAP groups. - add support for artwork. - rework metdata extraction, better support for ID3 tags. - database code rework. - preliminary support for Remote (pairing, browsing). - fixes, big and small. version 0.10: - initial release. forked-daapd-0.19gcd/INSTALL0000664000175000017500000001656011633141135015041 0ustar julienjulienInstallation instructions for forked-daapd ------------------------------------------ There are two ways to install forked-daapd: from a tarball or from the git tree. The tarball contains a working build system and pre-generated ANTLR3 parsers; the git tree doesn't and requires more tools to generate the build system and the ANTLR3 parsers. In both cases the installation procedure is the traditional ./configure; make; make install. Please read this file carefully before proceeding. System-specific requirements: - Linux: + glibc 2.13+ (bugfix: process-wide setgroups(), glibc BZ#10563) + libasound (ALSA sound support - or you can use OSS4) - FreeBSD: + OSS4 sound support + libiconv Tools: - The clang C compiler from the LLVM project. forked-daapd uses Blocks, an extension to the C language that is not supported by gcc. Along with clang, you'll also need the Blocks runtime, libblocksruntime. - pkg-config - gperf 3.x from Libraries: - libantlr3c (ANTLR3 C runtime, version 3.2 for tarball builds) from - Avahi client libraries (avahi-client), 0.6.24 minimum from - sqlite3 3.5.0+ with unlock notify API enabled (read below) from - libav 0.6+/0.7+ (or ffmpeg 0.5.1+) from - libconfuse from - libdispatch /!\ Read below - libtre from - libavl /!\ Read below - MiniXML (aka mxml or libmxml) from - gcrypt 1.2.0+ from - zlib from - libunistring 0.9.3+ from - libflac (optional - FLAC support) from - taglib (optional - Musepack support) from - libplist 0.16+ (optional - iTunes XML support) from If using binary packages, remember that you need the development packages to build forked-daapd (usually named -dev or -devel). libdispatch for Linux and its dependencies can be found in the Debian archive; you need at least libdispatch from SVN rev 197 + Debian patches (Linux support), libkqueue 0.9.2 and libpthread_workqueue 0.7. At this time, it's probably easiest to use whatever versions happen to be in Debian unstable. libavl is not the GNU libavl. There doesn't seem to be an upstream website anymore, but you'll find the source tarball alongside the forked-daapd release tarballs (see below for the URL). Alternatively, you can fetch it from any Debian mirror, too (it'll be in /debian/pool/main/liba/libavl). sqlite3 needs to be built with support for the unlock notify API; this isn't always the case in binary packages, so you may need to rebuild sqlite3 to enable the unlock notify API (you can check for the presence of the sqlite3_unlock_notify symbol in the sqlite3 library). Refer to the sqlite3 documentation, look for SQLITE_ENABLE_UNLOCK_NOTIFY. Note about libav (ffmpeg) ------------------------- libav (ffmpeg) is a central piece of forked-daapd and most other FLOSS multimedia applications. The version of libav you use will potentially have a great influence on your experience with forked-daapd. The following versions of libav (ffmpeg) are supported and known to work: - ffmpeg 0.5.x: has issues with metadata (tags) extraction, notably with MP3 files and ID3 tags in general; - libav 0.6.x: known to work better with regard to metadata extraction; - libav 0.7.x: better yet Note that forked-daapd uses libav since the ffmpeg/libav fork during the 0.6.x series. Building from the git tree -------------------------- Gitweb: Git tree: Required tools: - ANTLR v3 is required to build forked-daapd, along with its C runtime (libantlr3c). Use at least version 3.1.3 of ANTLR v3 and the matching C runtime version. - Java runtime: ANTLR is written in Java and as such a JRE is required to run the tool. The JRE is enough, you don't need a full JDK. - autotools: autoconf 2.63+, automake 1.10+, libtool 2.2. Run autoreconf -i at the top of the source tree to generate the build system. - gettext: libunistring requires iconv and gettext provides the autotools macro definitions for iconv. Start by generating the build system by running autoreconf -i. This will generate the configure script and Makefile.in. The configure script will look for a wrapper called antlr3 in the PATH to invoke ANTLR3. If your installation of ANTLR3 does not come with such a wrapper, create one as follows: #!/bin/sh CLASSPATH=... exec /path/to/java -cp $CLASSPATH org.antlr.Tool "@" Adjust the CLASSPATH as needed so that Java will find all the jars needed by ANTLR3. The parsers will be generated during the build, no manual intervention is needed. Building from the tarball ------------------------- Download URL: When building forked-daapd from a release tarball, the usual ./configure; make; make install procedure applies. FLAC and Musepack support are optional. If not enabled, metadata extraction will fail on these files. Support for iTunes Music Library XML format is optional. Use --enable-itunes to enable this feature. Recommended build settings: ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --enable-flac --enable-musepack After installation, edit the configuration file, /etc/forked-daapd.conf and adjust the values at your convenience. forked-daapd will drop privileges to any user you'll specify in the configuration file if it's started as root. It's recommended to create a dedicated user without login privileges. This user must have read permission on your library (you can create a group for this and make the user a member of the group, for instance) and read/write permissions on the database location ($localstatedir/cache/forked-daapd by default). You'll need an init script if you want to start forked-daapd at boot. A simple init script will do, forked-daapd daemonizes all by itself and creates a pidfile under /var/run. Different distributions have different standards for init scripts and some do not use init scripts anymore; check the documentation for your distribution. For dependency-based boot systems, here are the forked-daapd dependencies: - local filesystems - network filesystems, if needed in your setup (library on NFS, ...) - networking - NTP - Avahi daemon The LSB header below sums it up: ### BEGIN INIT INFO # Provides: forked-daapd # Required-Start: $local_fs $remote_fs $network $time avahi # Required-Stop: $local_fs $remote_fs $network $time # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: media server with support for RSP, DAAP, DACP and AirTunes # Description: forked-daapd is an iTunes-compatible media server for # sharing your music library over the local network with RSP # clients like the SoundBridge from Roku and DAAP clients like # iTunes. It can also stream music to AirTunes devices. ### END INIT INFO forked-daapd-0.19gcd/Makefile.am0000664000175000017500000000032111633141135016030 0ustar julienjulienACLOCAL_AMFLAGS = -I m4 sysconf_DATA = forked-daapd.conf EXTRA_DIST = configure SUBDIRS = sqlext src man_MANS = forked-daapd.8 install-data-hook: $(MKDIR_P) $(DESTDIR)$(localstatedir)/cache/forked-daapd forked-daapd-0.19gcd/NEWS0000664000175000017500000000013111633141135014472 0ustar julienjulienforked-daapd NEWS ----------------- version 0.10: It's released, and that's news. Yup. forked-daapd-0.19gcd/README0000664000175000017500000002406711633141135014671 0ustar julienjulienforked-daapd ------------ forked-daapd is a DAAP and RSP media server, with support for Linux and FreeBSD. It is a complete rewrite of mt-daapd (Firefly Media Server). DAAP stands for Digital Audio Access Protocol, and is the protocol used by iTunes and friends to share/stream media libraries over the network. RSP is Roku's own media sharing protocol. Roku are the makers of the SoundBridge devices. See . forked-daapd is a working title that will eventually change in the future. The forked-daapd git tree can be found at: Release tarballs can be downloaded at: Supported clients ----------------- forked-daapd supports iTunes clients as well as a number of devices similar to the SoundBridge. It should be able to serve your media library to any client supporting DAAP or RSP. A single forked-daapd instance can handle several clients concurrently, regardless of the protocol. Using Remote ------------ If you plan to use Remote with forked-daapd, read the following sections carefully. Pairing with Remote on iPod/iPhone ---------------------------------- forked-daapd can be paired with Apple's Remote application for iPod/iPhone; this is how the pairing process works: - start forked-daapd - start Remote, go to Choose Library, Add Library - prepare a text file with a filename ending with .remote; the filename doesn't matter, only the .remote ending does. This file must contain two lines: the first line is the name of your iPod/iPhone, the second is the 4-digit pairing code displayed by Remote. If your iPod/iPhone is named "Foobar" and Remote gives you the pairing code 5387, the file content will be: Foobar 5387 - move this file somewhere in your library At this point, you should be done with the pairing process and Remote should display the name of your forked-daapd library. You can delete the .remote file once the pairing process is done. If Remote doesn't display the name of your forked-daapd library at this point, the pairing process failed. This will usually be because the .remote file did not contain the correct name or pairing code. Start over the pairing process and try again. If in doubt, enable a more verbose level of logging and check that forked-daapd receives the mDNS announcement from your iPod/iPhone when the pairing code is displayed by Remote (you can also use avahi-browse for this purpose, see below). If not, you have a network issue and mDNS doesn't work properly on your network. If you are unsure about your iPod/iPhone's name, here's how you can check for the correct value: - in a terminal, run avahi-browse -r -k _touch-remote._tcp - start Remote, goto Choose Library, Add Library - after a couple seconds at most, you should get something similar to this: + ath0 IPv4 59eff13ea2f98dbbef6c162f9df71b784a3ef9a3 _touch-remote._tcp local = ath0 IPv4 59eff13ea2f98dbbef6c162f9df71b784a3ef9a3 _touch-remote._tcp local hostname = [Foobar.local] address = [192.168.1.1] port = [49160] txt = ["DvTy=iPod touch" "RemN=Remote" "txtvers=1" "RemV=10000" "Pair=FAEA410630AEC05E" "DvNm=Foobar"] The name of your iPod/iPhone is the value of the DvNm field above. In this example, the correct value is Foobar. Watch out for fancy characters; for instance, the name of your device may include Unicode characters that aren't visually different from plain ASCII characters (like the single quote if your device name follows the default scheme of "Foo's iPhone"). If unsure, change the name of your device or capture the output in a file to extract the real, correct name. Hit Ctrl-C to terminate avahi-browse. Selecting output devices ------------------------ Remote gets a list of output devices from the server; this list includes any and all devices on the network we know of that advertise AirTunes: AirPort Express, Apple TV, ... It also includes the local audio output, that is, the sound card on the server (even if there is no soundcard). By default, if no output is selected when playback starts, the local output device will be used, following the principle of least surprise (ie not selecting an output device at random that can be anywhere in the house or elsewhere). forked-daapd will error out if the local output is not usable (no soundcard, bad permissions, ...). There are two ways to select the output devices in Remote: - in the settings panel; - in the AirPlay panel during playback. Be aware that the settings panel doesn't show any output device when there is only one; the one output device that is available is automatically used. forked-daapd remembers your selection and the individual volume for each output device; selected devices will be automatically re-selected at the next server startup, provided they appear in the 5 minutes following the startup and no playback has occured yet. Again, principle of least surprise. AirTunes devices ---------------- forked-daapd will discover the AirTunes devices available on your network. For devices that are password-protected, the device's AirTunes name and password must be given in the configuration file. See the sample configuration file for the syntax. Local audio output ------------------ The audio section of the configuration file supports 2 parameters for the local audio device: - nickname: this is the name that will be used in the speakers list in Remote - card: this is the name/device string (ALSA) or device node (OSS4) to be used as the local audio device. Defaults to "default" for ALSA and "/dev/dsp" for OSS4. Supported formats ----------------- forked-daapd should support pretty much all media formats. It relies on libav (ffmpeg) to extract metadata and decode the files on the fly when the client doesn't support the format. However, libav is not necessarily very good at extracting metadata, so some formats may cause problems. FLAC, Musepack and WMA use custom metadata extractors to work around that. Formats are attributed a code, so any new format will need to be explicitely added. Currently supported: - MPEG4: mp4a, mp4v - AAC: alac - MP3 (and friends): mpeg - FLAC: flac - OGG VORBIS: ogg - Musepack: mpc - WMA: wma (WMA Pro), wmal (WMA Lossless), wmav (WMA video) - AIFF: aif - WAV: wav Streaming MPEG4 --------------- Depending on the client application, you may need to optimize your MPEG4 files for streaming. Stream-optimized MPEG4 files have their metadata at the beginning of the file, whereas non-optimized files have them at the end. Not all clients need this; if you're having trouble playing your MPEG4 files, this is the most probable cause. iTunes, in particular, doesn't handle files that aren't optimized, though FrontRow does. Files produced by iTunes are always optimized by default. Files produced by FAAC and a lot of other encoders are not, though some encoders have an option for that. The mp4creator tool from the mpeg4ip suite can be used to optimize MPEG4 files, with the -optimize option: $ mp4creator -optimize foo.m4a Don't forget to make a backup copy of your file, just in case. Note that not all tag/metadata editors know about stream optimization and will happily write the metadata back at the end of the file after you've modified them. Watch out for that. Playlists --------- forked-daapd supports M3U playlists. Just drop your playlist somewhere in your library with an .m3u extension and it will pick it up. Support for iTunes Music Library XML format is available as a compile-time option. By default, metadata from our parsers is preferred over what's in the iTunes DB; use itunes_overrides = true if you prefer iTunes' metadata. Smart playlists are not supported at the moment. Artwork ------- forked-daapd has /some/ support for artwork, with a number of limitations. Embedded artwork is not supported; libav (ffmpeg) doesn't support this yet, if and when this is added to libav, forked-daapd will support it. Your artwork must be in PNG or JPEG format, dimensions do not matter; forked-daapd scales down (never up) the artwork on-the-fly to match the constraints given by the client. Note, however, that the bigger the picture, the more time and resources it takes to perform the scaling operation. As for the naming convention, it is quite simple; consider your foo.mp3 song, residing at /bar/foo.mp3: - if /bar/foo.{png,jpg} exists, this will be used as the artwork for this file; - failing that, if /bar/{artwork,cover}.{png,jpg} exists, it will be used. For "groups" (same album name and album artist), the situation is a bit different: - if a file {artwork,cover}.{png,jpg} is found in one of the directories containing files that are part of the group, it is used as the artwork. The first file found is used, ordering is not guaranteed; - failing that, individual files are examined and the first artwork found is used. Here again, ordering is not guaranteed. You can use symlinks for the artwork files; the artwork is not scanned/indexed in any way in the database and there is no caching on forked-daapd's side. Library ------- The library is scanned in bulk mode at startup, but the server will be available even while this scan is in progress. Of course, if files have gone missing while the server was not running a request for these files will produce an error until the scan has completed and the file is no longer offered. Similarly, new files added while the server was not running won't be offered until they've been scanned. Changes to the library are reflected in real time after the initial scan. The directories are monitored for changes and rescanned on the fly. Symlinks are supported and dereferenced. This does interact in tricky ways with the above monitoring and rescanning, so you've been warned. Changes to symlinks themselves won't be taken into account, or not the way you'd expect. If you use symlinks, do not move around the target of the symlink. Avoid linking files, as files themselves aren't monitored for changes individually, so changes won't be noticed unless the file happens to be in a directory that is monitored. Bottom line: symlinks are for directories only. forked-daapd-0.19gcd/UPGRADING0000664000175000017500000000162411633141135015246 0ustar julienjulienUpgrading forked-daapd ---------------------- From time to time, newer versions of forked-daapd may need to perform a database upgrade. This upgrade is handled by forked-daapd upon startup if required. Before upgrading forked-daapd, it is always a good idea to backup your database, just in case. The database upgrade procedure is built into forked-daapd; there is no external upgrade script to run. Depending on the changes done to the database structure, the upgrade process will take more or less time and may need some space in /tmp for temporary data. The upgrade can also require some more space in the directory containing the database file. Before running the new forked-daapd version, make sure you have done your backups and checked your disk space. Some upgrades can also trigger a full rescan to rebuild parts of the database, so startup will be a bit slower and more resource-intensive than usual. forked-daapd-0.19gcd/config.rpath0000664000175000017500000000000011633141135016273 0ustar julienjulienforked-daapd-0.19gcd/configure.in0000664000175000017500000001563411633141135016322 0ustar julienjuliendnl Process this file with autoconf to produce a configure script. AC_INIT(config.h.in) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE(forked-daapd, 0.19gcd) dnl Checks for programs. AC_PROG_CC([clang llvm-gcc]) AM_PROG_CC_C_O LT_INIT([disable-static]) AC_CHECK_PROG(GPERF, [gperf], [gperf]) if test "x$GPERF" = x; then AC_MSG_ERROR([GNU gperf not found, please install it]) fi AC_SUBST(GPERF) AC_CHECK_PROG(ANTLR, [antlr3], [antlr3]) if test "x$ANTLR" = x; then if test -d $srcdir/src/pregen; then for f in $srcdir/src/pregen/*; do bf=`basename $f` ln -sf pregen/$bf $srcdir/src/$bf done AC_MSG_NOTICE([antlr3 wrapper not found, using pre-generated files]) else AC_MSG_ERROR([antlr3 wrapper not found and pre-generated files not available]) fi fi AC_SUBST(ANTLR) AM_CONDITIONAL(COND_ANTLR, test "x$ANTLR" != x) CFLAGS="$CFLAGS -Wall -D_LARGEFILE_SOURCE" AC_CHECK_HEADERS([sys/wait.h]) AC_CHECK_HEADERS([sys/param.h]) AC_CHECK_HEADERS([sys/select.h]) AC_CHECK_HEADERS([dirent.h]) AC_CHECK_FUNCS(posix_fadvise) AC_CHECK_FUNCS(strptime) AC_CHECK_FUNCS(strtok_r) AC_CHECK_FUNCS(timegm) dnl Large File Support (LFS) AC_SYS_LARGEFILE AC_TYPE_OFF_T AC_ARG_ENABLE(flac, AC_HELP_STRING([--enable-flac], [Enable FLAC support]), use_flac=true; CPPFLAGS="${CPPFLAGS} -DFLAC") AC_ARG_ENABLE(musepack, AC_HELP_STRING([--enable-musepack], [Enable Musepack support]), use_musepack=true; CPPFLAGS="${CPPFLAGS} -DMUSEPACK") AC_ARG_ENABLE(itunes, AC_HELP_STRING([--enable-itunes], [Enable iTunes library support]), use_itunes=true; CPPFLAGS="${CPPFLAGS} -DITUNES") AM_CONDITIONAL(COND_FLAC, test x$use_flac = xtrue) AM_CONDITIONAL(COND_MUSEPACK, test x$use_musepack = xtrue) AM_CONDITIONAL(COND_ITUNES, test x$use_itunes = xtrue) AC_ARG_WITH(oss4, AC_HELP_STRING([--with-oss4=includedir], [Use OSS4 with soundcard.h in includedir (default /usr/lib/oss/include/sys)]), [ case "$withval" in no) case "$host" in *-*-linux-*) use_oss4=false ;; *-*-kfreebsd*-*|*-*-freebsd-*) AC_MSG_ERROR([OSS4 must be enabled on FreeBSD systems]) ;; esac ;; yes) use_oss4=true oss4_includedir=/usr/lib/oss/include/sys ;; [[\\/$]]* | ?:[[\\/]]* ) use_oss4=true oss4_includedir="$withval" ;; *) AC_MSG_ERROR([expected an absolute directory name for --with-oss4: $withval]) ;; esac ], [ case "$host" in *-*-linux-*) use_oss4=false ;; *-*-kfreebsd*-*|*-*-freebsd-*) use_oss4=true oss4_includedir=/usr/lib/oss/include/sys ;; esac ]) dnl Checks for libraries. gl_LIBUNISTRING if test x$HAVE_LIBUNISTRING != xyes; then AC_MSG_ERROR([GNU libunistring is required]) fi PKG_CHECK_MODULES(ZLIB, [ zlib ]) PKG_CHECK_MODULES(TRE, [ tre ]) PKG_CHECK_MODULES(CONFUSE, [ libconfuse ]) PKG_CHECK_MODULES(AVAHI, [ avahi-client >= 0.6.24 ]) PKG_CHECK_MODULES(SQLITE3, [ sqlite3 >= 3.5.0 ]) save_LIBS="$LIBS" LIBS="$SQLITE3_LIBS" dnl Check that SQLite3 has the unlock notify API built-in AC_CHECK_LIB([sqlite3], [sqlite3_unlock_notify], [], AC_MSG_ERROR([SQLite3 was built without unlock notify support])) dnl Check that SQLite3 has been built with threadsafe operations AC_MSG_CHECKING([if SQLite3 was built with threadsafe operations support]) AC_LANG_PUSH([C]) AC_RUN_IFELSE( [AC_LANG_PROGRAM([dnl #include ], [dnl int ret = sqlite3_config(SQLITE_CONFIG_MULTITHREAD); if (ret != SQLITE_OK) return 1; return 0;])], [AC_MSG_RESULT([yes])], [AC_MSG_ERROR([SQLite3 was not built with threadsafe operations support])], [AC_MSG_RESULT([runtime will tell])]) AC_LANG_POP([C]) LIBS="$save_LIBS" PKG_CHECK_MODULES(LIBAV, [ libavcodec libavformat libswscale libavutil ]) dnl Check for av_lock_manager (ffmpeg >= 0.5.1) save_LIBS="$LIBS" AC_CHECK_LIB([avcodec], [av_lockmgr_register], , AC_MSG_ERROR([libav (ffmpeg) >= 0.5.1 required])) LIBS="$save_LIBS" # Check for libavformat >= 53; url -> avio switch _PKG_CONFIG([libavformat_VERSION], [atleast-version=53], [libavformat]) if test $pkg_failed = yes; then AM_CONDITIONAL(COND_AVIO, false) else AM_CONDITIONAL(COND_AVIO, true) fi PKG_CHECK_MODULES(MINIXML, [ mxml ]) AC_CHECK_HEADER(avl.h, , AC_MSG_ERROR([avl.h not found])) AC_CHECK_LIB([avl], [avl_alloc_tree], [LIBAVL_LIBS="-lavl"], AC_MSG_ERROR([libavl not found])) AC_SUBST(LIBAVL_LIBS) AC_CHECK_HEADER(antlr3.h, , AC_MSG_ERROR([antlr3.h not found])) AC_CHECK_LIB([antlr3c], [antlr3BaseRecognizerNew], [ANTLR3C_LIBS="-lantlr3c"], AC_MSG_ERROR([ANTLR3 C runtime (libantlr3c) not found])) AC_CHECK_LIB([antlr3c], [antlr3NewAsciiStringInPlaceStream], AC_DEFINE(ANTLR3C_NEW_INPUT, 0, [define if antlr3 C runtime uses new input routines]), AC_DEFINE(ANTLR3C_NEW_INPUT, 1, [define if antlr3 C runtime uses new input routines])) AC_SUBST(ANTLR3C_LIBS) AM_PATH_LIBGCRYPT([1:1.2.0], , AC_MSG_ERROR([libgcrypt not found])) AM_PATH_GPG_ERROR([1.6], , AC_MSG_ERROR([libgpg-error not found])) if test x$use_flac = xtrue; then PKG_CHECK_MODULES(FLAC, [ flac ]) fi if test x$use_musepack = xtrue; then PKG_CHECK_MODULES(TAGLIB, [ taglib_c ]) fi if test x$use_itunes = xtrue; then PKG_CHECK_MODULES(LIBPLIST, [ libplist >= 0.16 ]) fi case "$host" in *-*-linux-*) if test x$use_oss4 != xtrue; then use_alsa=true PKG_CHECK_MODULES(ALSA, [ alsa ]) AC_DEFINE(LAUDIO_USE_ALSA, 1, [define if local audio output uses ALSA]) fi AC_CHECK_HEADERS([sys/eventfd.h]) AC_CHECK_FUNCS(eventfd) AC_CHECK_HEADER(sys/timerfd.h, , AC_MSG_ERROR([timerfd required; glibc 2.8+ recommended])) AC_CHECK_FUNC(timerfd_create, , AC_MSG_ERROR([timerfd required; glibc 2.8+ recommended])) ;; esac if test x$use_oss4 = xtrue; then OSS4CPPFLAGS="-I$oss4_includedir" save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$OSS4CPPFLAGS" AC_CHECK_HEADER(soundcard.h, , AC_MSG_ERROR([soundcard.h not found in $oss4_includedir])) CPPFLAGS="$save_CPPFLAGS" fi AM_CONDITIONAL(COND_ALSA, test x$use_alsa = xtrue) AM_CONDITIONAL(COND_OSS4, test x$use_oss4 = xtrue) AC_SUBST(OSS4CPPFLAGS) AC_CHECK_SIZEOF(void *) AC_CHECK_HEADERS(getopt.h,,) AC_CHECK_HEADERS(stdint.h,,) dnl Checks for header files. AC_HEADER_STDC AC_HEADER_SYS_WAIT dnl Check for libdispatch, C Blocks support in libdispatch and C Blocks support in the compiler AC_CHECK_HEADER(dispatch/dispatch.h, , AC_MSG_ERROR([dispatch/dispatch.h not found])) AC_CHECK_LIB([dispatch], [dispatch_main], [LIBDISPATCH_LIBS="-ldispatch"], AC_MSG_ERROR([libdispatch not found])) AC_CHECK_LIB([dispatch], [dispatch_after], [LIBDISPATCH_LIBS="-ldispatch"], AC_MSG_ERROR([libdispatch built without Blocks support])) AC_SUBST(LIBDISPATCH_LIBS) save_LIBS="$LIBS" DISPATCH_C_BLOCKS if test "x$have_cblocks" != xtrue; then AC_MSG_ERROR([C compiler doesn't support C Blocks extension]) fi CBLOCKS_LIBS="$LIBS" AC_SUBST(CBLOCKS_LIBS) LIBS="$save_LIBS" AC_OUTPUT(src/Makefile sqlext/Makefile Makefile) forked-daapd-0.19gcd/ffmpeg/0000775000175000017500000000000011633141135015244 5ustar julienjulienforked-daapd-0.19gcd/ffmpeg/ffmpeg-0.5.tv.patch.sh0000775000175000017500000000607311633141135021103 0ustar julienjulien#!/bin/sh # # Patch for ffmpeg so forked-daapd can extract iTunes TV metadata from mp4 video files # Ace Jones # # Usage: chmod +x this file, and run it from the directory above where you want ffmpeg # svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg patch -p0 < $0 exit Index: ffmpeg/libavformat/mov.c =================================================================== --- ffmpeg/libavformat/mov.c (revision 20790) +++ ffmpeg/libavformat/mov.c (working copy) @@ -80,19 +80,45 @@ static const MOVParseTableEntry mov_default_parse_table[]; -static int mov_metadata_trkn(MOVContext *c, ByteIOContext *pb, unsigned len) +static int mov_metadata_trkn(MOVContext *c, ByteIOContext *pb, unsigned len, const char *key) { char buf[16]; get_be16(pb); // unknown snprintf(buf, sizeof(buf), "%d", get_be16(pb)); - av_metadata_set(&c->fc->metadata, "track", buf); + av_metadata_set(&c->fc->metadata, key, buf); get_be16(pb); // total tracks return 0; } +static int mov_metadata_int8(MOVContext *c, ByteIOContext *pb, unsigned len, const char *key) +{ + char buf[16]; + + /* bypass padding bytes */ + get_byte(pb); + get_byte(pb); + get_byte(pb); + + snprintf(buf, sizeof(buf-1), "%hu", get_byte(pb)); + buf[sizeof(buf)-1] = 0; + av_metadata_set(&c->fc->metadata, key, buf); + + return 0; +} + +static int mov_metadata_stik(MOVContext *c, ByteIOContext *pb, unsigned len, const char *key) +{ + char buf[16]; + + snprintf(buf, sizeof(buf-1), "%hu", get_byte(pb)); + buf[sizeof(buf)-1] = 0; + av_metadata_set(&c->fc->metadata, key, buf); + + return 0; +} static int mov_read_udta_string(MOVContext *c, ByteIOContext *pb, MOVAtom atom) { #ifdef MOV_EXPORT_ALL_METADATA @@ -101,7 +127,7 @@ char str[1024], key2[16], language[4] = {0}; const char *key = NULL; uint16_t str_size; - int (*parse)(MOVContext*, ByteIOContext*, unsigned) = NULL; + int (*parse)(MOVContext*, ByteIOContext*, unsigned, const char*) = NULL; switch (atom.type) { case MKTAG(0xa9,'n','a','m'): key = "title"; break; @@ -122,6 +148,12 @@ case MKTAG( 't','v','s','h'): key = "show"; break; case MKTAG( 't','v','e','n'): key = "episode_id";break; case MKTAG( 't','v','n','n'): key = "network"; break; + case MKTAG( 't','v','e','s'): key = "episode_sort"; + parse = mov_metadata_int8; break; + case MKTAG( 't','v','s','n'): key = "season_number"; + parse = mov_metadata_int8; break; + case MKTAG( 's','t','i','k'): key = "stik"; + parse = mov_metadata_stik; break; case MKTAG( 't','r','k','n'): key = "track"; parse = mov_metadata_trkn; break; } @@ -157,10 +189,11 @@ str_size = FFMIN3(sizeof(str)-1, str_size, atom.size); if (parse) - parse(c, pb, str_size); + parse(c, pb, str_size, key); else { get_buffer(pb, str, str_size); str[str_size] = 0; + av_metadata_set(&c->fc->metadata, key, str); if (*language && strcmp(language, "und")) { snprintf(key2, sizeof(key2), "%s-%s", key, language); forked-daapd-0.19gcd/ffmpeg/ffmpeg-0.6.patch0000664000175000017500000000520411633141135020033 0ustar julienjulien--- ffmpeg/libavformat/mov.c 2010-12-13 17:10:32.347224001 -0800 +++ ffmpeg/libavformat/mov.c 2010-12-13 17:03:05.078969987 -0800 @@ -78,19 +78,46 @@ static const MOVParseTableEntry mov_default_parse_table[]; -static int mov_metadata_trkn(MOVContext *c, ByteIOContext *pb, unsigned len) +static int mov_metadata_trkn(MOVContext *c, ByteIOContext *pb, unsigned len, const char *key) { char buf[16]; get_be16(pb); // unknown snprintf(buf, sizeof(buf), "%d", get_be16(pb)); - av_metadata_set2(&c->fc->metadata, "track", buf, 0); + av_metadata_set(&c->fc->metadata, key, buf); get_be16(pb); // total tracks return 0; } +static int mov_metadata_int8(MOVContext *c, ByteIOContext *pb, unsigned len, const char *key) +{ + char buf[16]; + + /* bypass padding bytes */ + get_byte(pb); + get_byte(pb); + get_byte(pb); + + snprintf(buf, sizeof(buf-1), "%hu", get_byte(pb)); + buf[sizeof(buf)-1] = 0; + av_metadata_set(&c->fc->metadata, key, buf); + + return 0; +} + +static int mov_metadata_stik(MOVContext *c, ByteIOContext *pb, unsigned len, const char *key) +{ + char buf[16]; + + snprintf(buf, sizeof(buf-1), "%hu", get_byte(pb)); + buf[sizeof(buf)-1] = 0; + av_metadata_set(&c->fc->metadata, key, buf); + + return 0; +} + static const uint32_t mac_to_unicode[128] = { 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1, 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8, @@ -137,7 +164,7 @@ const char *key = NULL; uint16_t str_size, langcode = 0; uint32_t data_type = 0; - int (*parse)(MOVContext*, ByteIOContext*, unsigned) = NULL; + int (*parse)(MOVContext*, ByteIOContext*, unsigned, const char *) = NULL; switch (atom.type) { case MKTAG(0xa9,'n','a','m'): key = "title"; break; @@ -159,6 +186,11 @@ case MKTAG( 't','v','s','h'): key = "show"; break; case MKTAG( 't','v','e','n'): key = "episode_id";break; case MKTAG( 't','v','n','n'): key = "network"; break; + case MKTAG( 't','v','e','s'): key = "episode_sort"; + case MKTAG( 't','v','s','n'): key = "season_number"; + parse = mov_metadata_int8; break; + case MKTAG( 's','t','i','k'): key = "stik"; + parse = mov_metadata_stik; break; case MKTAG( 't','r','k','n'): key = "track"; parse = mov_metadata_trkn; break; } @@ -195,7 +227,7 @@ str_size = FFMIN3(sizeof(str)-1, str_size, atom.size); if (parse) - parse(c, pb, str_size); + parse(c, pb, str_size, key); else { if (data_type == 3 || (data_type == 0 && langcode < 0x800)) { // MAC Encoded mov_read_mac_string(c, pb, str_size, str, sizeof(str)); forked-daapd-0.19gcd/ffmpeg/libav-0.7.patch0000664000175000017500000000522511633141135017670 0ustar julienjulien--- libav/libavformat/mov.c 2011-08-09 14:03:47.622688230 -0700 +++ libav/libavformat/mov.c 2011-08-09 14:09:33.181475099 -0700 @@ -81,19 +81,46 @@ static const MOVParseTableEntry mov_default_parse_table[]; -static int mov_metadata_trkn(MOVContext *c, AVIOContext *pb, unsigned len) +static int mov_metadata_trkn(MOVContext *c, AVIOContext *pb, unsigned len, const char *key) { char buf[16]; avio_rb16(pb); // unknown snprintf(buf, sizeof(buf), "%d", avio_rb16(pb)); - av_dict_set(&c->fc->metadata, "track", buf, 0); + av_dict_set(&c->fc->metadata, key, buf, 0); avio_rb16(pb); // total tracks return 0; } +static int mov_metadata_int8(MOVContext *c, AVIOContext *pb, unsigned len, const char *key) +{ + char buf[16]; + + /* bypass padding bytes */ + get_byte(pb); + get_byte(pb); + get_byte(pb); + + snprintf(buf, sizeof(buf-1), "%hu", get_byte(pb)); + buf[sizeof(buf)-1] = 0; + av_metadata_set2(&c->fc->metadata, key, buf, 0); + + return 0; +} + +static int mov_metadata_stik(MOVContext *c, AVIOContext *pb, unsigned len, const char *key) +{ + char buf[16]; + + snprintf(buf, sizeof(buf-1), "%hu", get_byte(pb)); + buf[sizeof(buf)-1] = 0; + av_metadata_set2(&c->fc->metadata, key, buf, 0); + + return 0; +} + static const uint32_t mac_to_unicode[128] = { 0x00C4,0x00C5,0x00C7,0x00C9,0x00D1,0x00D6,0x00DC,0x00E1, 0x00E0,0x00E2,0x00E4,0x00E3,0x00E5,0x00E7,0x00E9,0x00E8, @@ -140,7 +167,7 @@ const char *key = NULL; uint16_t str_size, langcode = 0; uint32_t data_type = 0; - int (*parse)(MOVContext*, AVIOContext*, unsigned) = NULL; + int (*parse)(MOVContext*, AVIOContext*, unsigned, const char *) = NULL; switch (atom.type) { case MKTAG(0xa9,'n','a','m'): key = "title"; break; @@ -162,6 +189,11 @@ case MKTAG( 't','v','s','h'): key = "show"; break; case MKTAG( 't','v','e','n'): key = "episode_id";break; case MKTAG( 't','v','n','n'): key = "network"; break; + case MKTAG( 't','v','e','s'): key = "episode_sort"; + case MKTAG( 't','v','s','n'): key = "season_number"; + parse = mov_metadata_int8; break; + case MKTAG( 's','t','i','k'): key = "stik"; + parse = mov_metadata_stik; break; case MKTAG( 't','r','k','n'): key = "track"; parse = mov_metadata_trkn; break; } @@ -198,7 +230,7 @@ str_size = FFMIN3(sizeof(str)-1, str_size, atom.size); if (parse) - parse(c, pb, str_size); + parse(c, pb, str_size, key); else { if (data_type == 3 || (data_type == 0 && langcode < 0x800)) { // MAC Encoded mov_read_mac_string(c, pb, str_size, str, sizeof(str)); forked-daapd-0.19gcd/forked-daapd.80000664000175000017500000000301511633141135016411 0ustar julienjulien.\" -*- nroff -*- .TH FORKED-DAAPD "8" "2010-07-18" "forked-daapd" "RSP & DAAP media server" .SH NAME mt\-daapd \- RSP & iTunes\-compatible DAAP server .SH SYNOPSIS .B forked-daapd [\fIoptions\fR] .SH DESCRIPTION \fBforked\-daapd\fP is an RSP (Roku Streaming Protocol) and DAAP (Digital Audio Access Protocol) server. It allows you to share your music collection over the local network using the RSP protocol used by devices from Roku and/or the DAAP protocol also used by Apple's iTunes. .SH OPTIONS .TP \fB\-d\fR \fIlevel\fP Log level (0\-5). .TP \fB\-D\fR \fIdom,..,dom\fP Debug domains; available domains are: \fIconfig\fP, \fIdaap\fP, \fIdb\fP, \fIhttpd\fP, \fImain\fP, \fImdns\fP, \fImisc\fP, \fIrsp\fP, \fIscan\fP, \fIxcode\fP, \fIevent\fP. .TP \fB\-s\fR Synchronous logging; logging is asynchronous by default. Use when debugging, especially if debugging a crash. .TP \fB\-c\fR \fIfile\fP Use \fIfile\fP as the configuration file. .TP \fB\-P\fR \fIfile\fP Write PID to \fIfile\fP. .TP \fB\-f\fR Run in the foreground. .TP \fB\-b\fR \fIffid\fP \fIffid\fP to be broadcast in mDNS records. .TP \fB\-v\fR Display version information. .SH FILES .nf \fI/etc/forked\-daapd.conf\fR \fI/var/cache/forked\-daapd\fR .fi .SH AUTHORS \fBforked\-daapd\fP was written by Julien BLACHE as a fork/rewrite of mt\-daapd. mt\-daapd was written by Ron Pedde . .PP This manual page was written by Rog\['e]rio Brito and Julien BLACHE for the Debian project (but may be used by others). forked-daapd-0.19gcd/forked-daapd.conf0000664000175000017500000000273011633141135017172 0ustar julienjulien general { # Username uid = "daapd" logfile = "/var/log/forked-daapd.log" # Database location # db_path = "/var/cache/forked-daapd/songs3.db" # Available levels: fatal, log, warning, info, debug, spam loglevel = log # Admin password for the non-existent web interface admin_password = "unused" # Enable/disable IPv6 ipv6 = no } # Library configuration library { # Name of the library as displayed by the clients # %h: hostname, %v: version name = "My Music on %h" # TCP port to listen on. Default port is 3689 (daap) port = 3689 # Password for the library. Optional. # password = "" # Directories to index directories = { "/srv/music" } # Directories containing compilations # Matches anywhere in the path (not a regexp, though) # compilations = { "/compilations/" } # Should iTunes metadata override ours? # itunes_overrides = true # Formats: mp4a, mp4v, mpeg, alac, flac, mpc, ogg, wma, wmal, wmav, aif, wav # Formats that should never be transcoded # no_transcode = { "alac", "mp4a" } # Formats that should always be transcoded # force_transcode = { "ogg", "flac" } } # Local audio output audio { # AirTunes name - used in the speaker list in Remote nickname = "Computer" # Audio device name for local audio output # card = "default" # Mixer channel to use for volume control - ALSA/Linux only # If not set, PCM will be used if available, otherwise Master. # mixer = "" } # Airport Express device #apex "ApEx" { # AirTunes password # password = "s1kr3t" #} forked-daapd-0.19gcd/m4/0000775000175000017500000000000011633141300014312 5ustar julienjulienforked-daapd-0.19gcd/m4/.gitignore0000664000175000017500000000002311633141135016303 0ustar julienjulienlibtool.m4 lt*.m4 forked-daapd-0.19gcd/m4/blocks.m40000664000175000017500000000335011633141135016040 0ustar julienjulienAC_DEFUN([DISPATCH_C_BLOCKS], [ # # Allow configure to be passed a path to the directory where it should look # for the Blocks runtime library, if any. # AC_ARG_WITH([blocks-runtime], [AS_HELP_STRING([--with-blocks-runtime], [Specify path to the blocks runtime])], [blocks_runtime=${withval} LIBS="$LIBS -L$blocks_runtime"] ) # # Detect compiler support for Blocks; perhaps someday -fblocks won't be # required, in which case we'll need to change this. # AC_CACHE_CHECK([for C Blocks support], [dispatch_cv_cblocks], [ saveCFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fblocks" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],[(void)^{int i; i = 0; }();])], [ CFLAGS="$saveCFLAGS" dispatch_cv_cblocks="-fblocks" ], [ CFLAGS="$saveCFLAGS" dispatch_cv_cblocks="no" ]) ]) AS_IF([test "x$dispatch_cv_cblocks" != "xno"], [ CBLOCKS_FLAGS="$dispatch_cv_cblocks" # # It may be necessary to directly link the Blocks runtime on some # systems, so give it a try if we can't link a C program that uses # Blocks. We will want to remove this at somepoint, as really -fblocks # should force that linkage already. # saveCFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fblocks -O0" AC_MSG_CHECKING([whether additional libraries are required for the Blocks runtime]) AC_TRY_LINK([], [ ^{ int j; j=0; }(); ], [ AC_MSG_RESULT([no]); ], [ saveLIBS="$LIBS" LIBS="$LIBS -lBlocksRuntime" AC_TRY_LINK([], [ ^{ int k; k=0; }(); ], [ AC_MSG_RESULT([-lBlocksRuntime]) ], [ AC_MSG_ERROR([can't find Blocks runtime]) ]) ]) CFLAGS="$saveCFLAGS" have_cblocks=true ], [ CBLOCKS_FLAGS="" have_cblocks=false ]) AM_CONDITIONAL(HAVE_CBLOCKS, $have_cblocks) AC_SUBST([CBLOCKS_FLAGS]) ]) forked-daapd-0.19gcd/m4/libunistring.m40000664000175000017500000000327511633141135017302 0ustar julienjulien# libunistring.m4 serial 4 dnl Copyright (C) 2009-2010 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 gl_LIBUNISTRING dnl Searches for an installed libunistring. dnl If found, it sets and AC_SUBSTs HAVE_LIBUNISTRING=yes and the LIBUNISTRING dnl and LTLIBUNISTRING variables and augments the CPPFLAGS variable, and dnl #defines HAVE_LIBUNISTRING to 1. Otherwise, it sets and AC_SUBSTs dnl HAVE_LIBUNISTRING=no and LIBUNISTRING and LTLIBUNISTRING to empty. AC_DEFUN([gl_LIBUNISTRING], [ dnl First, try to link without -liconv. libunistring often depends on dnl libiconv, but we don't know (and often don't need to know) where dnl libiconv is installed. AC_LIB_HAVE_LINKFLAGS([unistring], [], [#include ], [u8_strconv_from_locale((char*)0);], [no, consider installing GNU libunistring]) if test "$ac_cv_libunistring" != yes; then dnl Second try, with -liconv. AC_REQUIRE([AM_ICONV]) if test -n "$LIBICONV"; then dnl We have to erase the cached result of the first AC_LIB_HAVE_LINKFLAGS dnl invocation, otherwise the second one will not be run. unset ac_cv_libunistring glus_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" AC_LIB_HAVE_LINKFLAGS([unistring], [], [#include ], [u8_strconv_from_locale((char*)0);], [no, consider installing GNU libunistring]) if test -n "$LIBUNISTRING"; then LIBUNISTRING="$LIBUNISTRING $LIBICONV" LTLIBUNISTRING="$LTLIBUNISTRING $LTLIBICONV" fi LIBS="$glus_save_LIBS" fi fi ]) forked-daapd-0.19gcd/m4/libtool.m40000644000175000017500000104622011633141277016240 0ustar julienjulien# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, # Inc. # Written by Gordon Matzigkeit, 1996 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. m4_define([_LT_COPYING], [dnl # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, # Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ]) # serial 57 LT_INIT # LT_PREREQ(VERSION) # ------------------ # Complain and exit if this libtool version is less that VERSION. m4_defun([LT_PREREQ], [m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, [m4_default([$3], [m4_fatal([Libtool version $1 or higher is required], 63)])], [$2])]) # _LT_CHECK_BUILDDIR # ------------------ # Complain if the absolute build directory name contains unusual characters m4_defun([_LT_CHECK_BUILDDIR], [case `pwd` in *\ * | *\ *) AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; esac ]) # LT_INIT([OPTIONS]) # ------------------ AC_DEFUN([LT_INIT], [AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl AC_BEFORE([$0], [LT_LANG])dnl AC_BEFORE([$0], [LT_OUTPUT])dnl AC_BEFORE([$0], [LTDL_INIT])dnl m4_require([_LT_CHECK_BUILDDIR])dnl dnl Autoconf doesn't catch unexpanded LT_ macros by default: m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 dnl unless we require an AC_DEFUNed macro: AC_REQUIRE([LTOPTIONS_VERSION])dnl AC_REQUIRE([LTSUGAR_VERSION])dnl AC_REQUIRE([LTVERSION_VERSION])dnl AC_REQUIRE([LTOBSOLETE_VERSION])dnl m4_require([_LT_PROG_LTMAIN])dnl _LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) dnl Parse OPTIONS _LT_SET_OPTIONS([$0], [$1]) # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' AC_SUBST(LIBTOOL)dnl _LT_SETUP # Only expand once: m4_define([LT_INIT]) ])# LT_INIT # Old names: AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PROG_LIBTOOL], []) dnl AC_DEFUN([AM_PROG_LIBTOOL], []) # _LT_CC_BASENAME(CC) # ------------------- # Calculate cc_basename. Skip known compiler wrappers and cross-prefix. m4_defun([_LT_CC_BASENAME], [for cc_temp in $1""; do case $cc_temp in compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ]) # _LT_FILEUTILS_DEFAULTS # ---------------------- # It is okay to use these file commands and assume they have been set # sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'. m4_defun([_LT_FILEUTILS_DEFAULTS], [: ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} ])# _LT_FILEUTILS_DEFAULTS # _LT_SETUP # --------- m4_defun([_LT_SETUP], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl _LT_DECL([], [host_alias], [0], [The host system])dnl _LT_DECL([], [host], [0])dnl _LT_DECL([], [host_os], [0])dnl dnl _LT_DECL([], [build_alias], [0], [The build system])dnl _LT_DECL([], [build], [0])dnl _LT_DECL([], [build_os], [0])dnl dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl dnl AC_REQUIRE([AC_PROG_LN_S])dnl test -z "$LN_S" && LN_S="ln -s" _LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl dnl AC_REQUIRE([LT_CMD_MAX_LEN])dnl _LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl _LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl m4_require([_LT_CMD_RELOAD])dnl m4_require([_LT_CHECK_MAGIC_METHOD])dnl m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl m4_require([_LT_CMD_OLD_ARCHIVE])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_WITH_SYSROOT])dnl _LT_CONFIG_LIBTOOL_INIT([ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi ]) if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi _LT_CHECK_OBJDIR m4_require([_LT_TAG_COMPILER])dnl case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o _LT_CC_BASENAME([$compiler]) # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then _LT_PATH_MAGIC fi ;; esac # Use C for the default configuration in the libtool script LT_SUPPORTED_TAG([CC]) _LT_LANG_C_CONFIG _LT_LANG_DEFAULT_CONFIG _LT_CONFIG_COMMANDS ])# _LT_SETUP # _LT_PREPARE_SED_QUOTE_VARS # -------------------------- # Define a few sed substitution that help us do robust quoting. m4_defun([_LT_PREPARE_SED_QUOTE_VARS], [# Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\([["`\\]]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ]) # _LT_PROG_LTMAIN # --------------- # Note that this code is called both from `configure', and `config.status' # now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, # `config.status' has no value for ac_aux_dir unless we are using Automake, # so we pass a copy along to make sure it has a sensible value anyway. m4_defun([_LT_PROG_LTMAIN], [m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl _LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) ltmain="$ac_aux_dir/ltmain.sh" ])# _LT_PROG_LTMAIN ## ------------------------------------- ## ## Accumulate code for creating libtool. ## ## ------------------------------------- ## # So that we can recreate a full libtool script including additional # tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS # in macros and then make a single call at the end using the `libtool' # label. # _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) # ---------------------------------------- # Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL_INIT], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_INIT], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_INIT]) # _LT_CONFIG_LIBTOOL([COMMANDS]) # ------------------------------ # Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. m4_define([_LT_CONFIG_LIBTOOL], [m4_ifval([$1], [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], [$1 ])])]) # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) # _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) # ----------------------------------------------------- m4_defun([_LT_CONFIG_SAVE_COMMANDS], [_LT_CONFIG_LIBTOOL([$1]) _LT_CONFIG_LIBTOOL_INIT([$2]) ]) # _LT_FORMAT_COMMENT([COMMENT]) # ----------------------------- # Add leading comment marks to the start of each line, and a trailing # full-stop to the whole comment if one is not present already. m4_define([_LT_FORMAT_COMMENT], [m4_ifval([$1], [ m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) )]) ## ------------------------ ## ## FIXME: Eliminate VARNAME ## ## ------------------------ ## # _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) # ------------------------------------------------------------------- # CONFIGNAME is the name given to the value in the libtool script. # VARNAME is the (base) name used in the configure script. # VALUE may be 0, 1 or 2 for a computed quote escaped value based on # VARNAME. Any other value will be used directly. m4_define([_LT_DECL], [lt_if_append_uniq([lt_decl_varnames], [$2], [, ], [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], [m4_ifval([$1], [$1], [$2])]) lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) m4_ifval([$4], [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) lt_dict_add_subkey([lt_decl_dict], [$2], [tagged?], [m4_ifval([$5], [yes], [no])])]) ]) # _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) # -------------------------------------------------------- m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) # lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_tag_varnames], [_lt_decl_filter([tagged?], [yes], $@)]) # _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) # --------------------------------------------------------- m4_define([_lt_decl_filter], [m4_case([$#], [0], [m4_fatal([$0: too few arguments: $#])], [1], [m4_fatal([$0: too few arguments: $#: $1])], [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], [lt_dict_filter([lt_decl_dict], $@)])[]dnl ]) # lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) # -------------------------------------------------- m4_define([lt_decl_quote_varnames], [_lt_decl_filter([value], [1], $@)]) # lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_dquote_varnames], [_lt_decl_filter([value], [2], $@)]) # lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) # --------------------------------------------------- m4_define([lt_decl_varnames_tagged], [m4_assert([$# <= 2])dnl _$0(m4_quote(m4_default([$1], [[, ]])), m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) m4_define([_lt_decl_varnames_tagged], [m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) # lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) # ------------------------------------------------ m4_define([lt_decl_all_varnames], [_$0(m4_quote(m4_default([$1], [[, ]])), m4_if([$2], [], m4_quote(lt_decl_varnames), m4_quote(m4_shift($@))))[]dnl ]) m4_define([_lt_decl_all_varnames], [lt_join($@, lt_decl_varnames_tagged([$1], lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl ]) # _LT_CONFIG_STATUS_DECLARE([VARNAME]) # ------------------------------------ # Quote a variable value, and forward it to `config.status' so that its # declaration there will have the same value as in `configure'. VARNAME # must have a single quote delimited value for this to work. m4_define([_LT_CONFIG_STATUS_DECLARE], [$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) # _LT_CONFIG_STATUS_DECLARATIONS # ------------------------------ # We delimit libtool config variables with single quotes, so when # we write them to config.status, we have to be sure to quote all # embedded single quotes properly. In configure, this macro expands # each variable declared with _LT_DECL (and _LT_TAGDECL) into: # # ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], [m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAGS # ---------------- # Output comment and list of tags supported by the script m4_defun([_LT_LIBTOOL_TAGS], [_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl available_tags="_LT_TAGS"dnl ]) # _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) # ----------------------------------- # Extract the dictionary values for VARNAME (optionally with TAG) and # expand to a commented shell variable setting: # # # Some comment about what VAR is for. # visible_name=$lt_internal_name m4_define([_LT_LIBTOOL_DECLARE], [_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [description])))[]dnl m4_pushdef([_libtool_name], m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), [0], [_libtool_name=[$]$1], [1], [_libtool_name=$lt_[]$1], [2], [_libtool_name=$lt_[]$1], [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl ]) # _LT_LIBTOOL_CONFIG_VARS # ----------------------- # Produce commented declarations of non-tagged libtool config variables # suitable for insertion in the LIBTOOL CONFIG section of the `libtool' # script. Tagged libtool config variables (even for the LIBTOOL CONFIG # section) are produced by _LT_LIBTOOL_TAG_VARS. m4_defun([_LT_LIBTOOL_CONFIG_VARS], [m4_foreach([_lt_var], m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) # _LT_LIBTOOL_TAG_VARS(TAG) # ------------------------- m4_define([_LT_LIBTOOL_TAG_VARS], [m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) # _LT_TAGVAR(VARNAME, [TAGNAME]) # ------------------------------ m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) # _LT_CONFIG_COMMANDS # ------------------- # Send accumulated output to $CONFIG_STATUS. Thanks to the lists of # variables for single and double quote escaping we saved from calls # to _LT_DECL, we can put quote escaped variables declarations # into `config.status', and then the shell code to quote escape them in # for loops in `config.status'. Finally, any additional code accumulated # from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. m4_defun([_LT_CONFIG_COMMANDS], [AC_PROVIDE_IFELSE([LT_OUTPUT], dnl If the libtool generation code has been placed in $CONFIG_LT, dnl instead of duplicating it all over again into config.status, dnl then we will have config.status run $CONFIG_LT later, so it dnl needs to know what name is stored there: [AC_CONFIG_COMMANDS([libtool], [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], dnl If the libtool generation code is destined for config.status, dnl expand the accumulated commands and init code now: [AC_CONFIG_COMMANDS([libtool], [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) ])#_LT_CONFIG_COMMANDS # Initialize. m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], [ # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' _LT_CONFIG_STATUS_DECLARATIONS LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$[]1 _LTECHO_EOF' } # Quote evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_quote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in lt_decl_all_varnames([[ \ ]], lt_decl_dquote_varnames); do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[[\\\\\\\`\\"\\\$]]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done _LT_OUTPUT_LIBTOOL_INIT ]) # _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) # ------------------------------------ # Generate a child script FILE with all initialization necessary to # reuse the environment learned by the parent script, and make the # file executable. If COMMENT is supplied, it is inserted after the # `#!' sequence but before initialization text begins. After this # macro, additional text can be appended to FILE to form the body of # the child script. The macro ends with non-zero status if the # file could not be fully written (such as if the disk is full). m4_ifdef([AS_INIT_GENERATED], [m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], [m4_defun([_LT_GENERATED_FILE_INIT], [m4_require([AS_PREPARE])]dnl [m4_pushdef([AS_MESSAGE_LOG_FD])]dnl [lt_write_fail=0 cat >$1 <<_ASEOF || lt_write_fail=1 #! $SHELL # Generated by $as_me. $2 SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$1 <<\_ASEOF || lt_write_fail=1 AS_SHELL_SANITIZE _AS_PREPARE exec AS_MESSAGE_FD>&1 _ASEOF test $lt_write_fail = 0 && chmod +x $1[]dnl m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT # LT_OUTPUT # --------- # This macro allows early generation of the libtool script (before # AC_OUTPUT is called), incase it is used in configure for compilation # tests. AC_DEFUN([LT_OUTPUT], [: ${CONFIG_LT=./config.lt} AC_MSG_NOTICE([creating $CONFIG_LT]) _LT_GENERATED_FILE_INIT(["$CONFIG_LT"], [# Run this file to recreate a libtool stub with the current configuration.]) cat >>"$CONFIG_LT" <<\_LTEOF lt_cl_silent=false exec AS_MESSAGE_LOG_FD>>config.log { echo AS_BOX([Running $as_me.]) } >&AS_MESSAGE_LOG_FD lt_cl_help="\ \`$as_me' creates a local libtool stub from the current configuration, for use in further configure time tests before the real libtool is generated. Usage: $[0] [[OPTIONS]] -h, --help print this help, then exit -V, --version print version number, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files Report bugs to ." lt_cl_version="\ m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) configured by $[0], generated by m4_PACKAGE_STRING. Copyright (C) 2010 Free Software Foundation, Inc. This config.lt script is free software; the Free Software Foundation gives unlimited permision to copy, distribute and modify it." while test $[#] != 0 do case $[1] in --version | --v* | -V ) echo "$lt_cl_version"; exit 0 ;; --help | --h* | -h ) echo "$lt_cl_help"; exit 0 ;; --debug | --d* | -d ) debug=: ;; --quiet | --q* | --silent | --s* | -q ) lt_cl_silent=: ;; -*) AC_MSG_ERROR([unrecognized option: $[1] Try \`$[0] --help' for more information.]) ;; *) AC_MSG_ERROR([unrecognized argument: $[1] Try \`$[0] --help' for more information.]) ;; esac shift done if $lt_cl_silent; then exec AS_MESSAGE_FD>/dev/null fi _LTEOF cat >>"$CONFIG_LT" <<_LTEOF _LT_OUTPUT_LIBTOOL_COMMANDS_INIT _LTEOF cat >>"$CONFIG_LT" <<\_LTEOF AC_MSG_NOTICE([creating $ofile]) _LT_OUTPUT_LIBTOOL_COMMANDS AS_EXIT(0) _LTEOF chmod +x "$CONFIG_LT" # configure is writing to config.log, but config.lt does its own redirection, # appending to config.log, which fails on DOS, as config.log is still kept # open by configure. Here we exec the FD to /dev/null, effectively closing # config.log, so it can be properly (re)opened and appended to by config.lt. lt_cl_success=: test "$silent" = yes && lt_config_lt_args="$lt_config_lt_args --quiet" exec AS_MESSAGE_LOG_FD>/dev/null $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false exec AS_MESSAGE_LOG_FD>>config.log $lt_cl_success || AS_EXIT(1) ])# LT_OUTPUT # _LT_CONFIG(TAG) # --------------- # If TAG is the built-in tag, create an initial libtool script with a # default configuration from the untagged config vars. Otherwise add code # to config.status for appending the configuration named by TAG from the # matching tagged config vars. m4_defun([_LT_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_CONFIG_SAVE_COMMANDS([ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl m4_if(_LT_TAG, [C], [ # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # _LT_COPYING _LT_LIBTOOL_TAGS # ### BEGIN LIBTOOL CONFIG _LT_LIBTOOL_CONFIG_VARS _LT_LIBTOOL_TAG_VARS # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # 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 _LT_EOF ;; esac _LT_PROG_LTMAIN # 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? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) _LT_PROG_REPLACE_SHELLFNS mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ], [cat <<_LT_EOF >> "$ofile" dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded dnl in a comment (ie after a #). # ### BEGIN LIBTOOL TAG CONFIG: $1 _LT_LIBTOOL_TAG_VARS(_LT_TAG) # ### END LIBTOOL TAG CONFIG: $1 _LT_EOF ])dnl /m4_if ], [m4_if([$1], [], [ PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile'], []) ])dnl /_LT_CONFIG_SAVE_COMMANDS ])# _LT_CONFIG # LT_SUPPORTED_TAG(TAG) # --------------------- # Trace this macro to discover what tags are supported by the libtool # --tag option, using: # autoconf --trace 'LT_SUPPORTED_TAG:$1' AC_DEFUN([LT_SUPPORTED_TAG], []) # C support is built-in for now m4_define([_LT_LANG_C_enabled], []) m4_define([_LT_TAGS], []) # LT_LANG(LANG) # ------------- # Enable libtool support for the given language if not already enabled. AC_DEFUN([LT_LANG], [AC_BEFORE([$0], [LT_OUTPUT])dnl m4_case([$1], [C], [_LT_LANG(C)], [C++], [_LT_LANG(CXX)], [Java], [_LT_LANG(GCJ)], [Fortran 77], [_LT_LANG(F77)], [Fortran], [_LT_LANG(FC)], [Windows Resource], [_LT_LANG(RC)], [m4_ifdef([_LT_LANG_]$1[_CONFIG], [_LT_LANG($1)], [m4_fatal([$0: unsupported language: "$1"])])])dnl ])# LT_LANG # _LT_LANG(LANGNAME) # ------------------ m4_defun([_LT_LANG], [m4_ifdef([_LT_LANG_]$1[_enabled], [], [LT_SUPPORTED_TAG([$1])dnl m4_append([_LT_TAGS], [$1 ])dnl m4_define([_LT_LANG_]$1[_enabled], [])dnl _LT_LANG_$1_CONFIG($1)])dnl ])# _LT_LANG # _LT_LANG_DEFAULT_CONFIG # ----------------------- m4_defun([_LT_LANG_DEFAULT_CONFIG], [AC_PROVIDE_IFELSE([AC_PROG_CXX], [LT_LANG(CXX)], [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [LT_LANG(F77)], [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) AC_PROVIDE_IFELSE([AC_PROG_FC], [LT_LANG(FC)], [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal dnl pulling things in needlessly. AC_PROVIDE_IFELSE([AC_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], [LT_LANG(GCJ)], [AC_PROVIDE_IFELSE([LT_PROG_GCJ], [LT_LANG(GCJ)], [m4_ifdef([AC_PROG_GCJ], [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([A][M_PROG_GCJ], [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) m4_ifdef([LT_PROG_GCJ], [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) AC_PROVIDE_IFELSE([LT_PROG_RC], [LT_LANG(RC)], [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) ])# _LT_LANG_DEFAULT_CONFIG # Obsolete macros: AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_CXX], []) dnl AC_DEFUN([AC_LIBTOOL_F77], []) dnl AC_DEFUN([AC_LIBTOOL_FC], []) dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) dnl AC_DEFUN([AC_LIBTOOL_RC], []) # _LT_TAG_COMPILER # ---------------- m4_defun([_LT_TAG_COMPILER], [AC_REQUIRE([AC_PROG_CC])dnl _LT_DECL([LTCC], [CC], [1], [A C compiler])dnl _LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl _LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl _LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC ])# _LT_TAG_COMPILER # _LT_COMPILER_BOILERPLATE # ------------------------ # Check for compiler boilerplate output or warnings with # the simple compiler test code. m4_defun([_LT_COMPILER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ])# _LT_COMPILER_BOILERPLATE # _LT_LINKER_BOILERPLATE # ---------------------- # Check for linker boilerplate output or warnings with # the simple link test code. m4_defun([_LT_LINKER_BOILERPLATE], [m4_require([_LT_DECL_SED])dnl ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ])# _LT_LINKER_BOILERPLATE # _LT_REQUIRED_DARWIN_CHECKS # ------------------------- m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ case $host_os in rhapsody* | darwin*) AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) AC_CHECK_TOOL([LIPO], [lipo], [:]) AC_CHECK_TOOL([OTOOL], [otool], [:]) AC_CHECK_TOOL([OTOOL64], [otool64], [:]) _LT_DECL([], [DSYMUTIL], [1], [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) _LT_DECL([], [NMEDIT], [1], [Tool to change global to local symbols on Mac OS X]) _LT_DECL([], [LIPO], [1], [Tool to manipulate fat objects and archives on Mac OS X]) _LT_DECL([], [OTOOL], [1], [ldd/readelf like tool for Mach-O binaries on Mac OS X]) _LT_DECL([], [OTOOL64], [1], [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], [lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -rf libconftest.dylib* rm -f conftest.* fi]) AC_CACHE_CHECK([for -exported_symbols_list linker flag], [lt_cv_ld_exported_symbols_list], [lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [lt_cv_ld_exported_symbols_list=yes], [lt_cv_ld_exported_symbols_list=no]) LDFLAGS="$save_LDFLAGS" ]) AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], [lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then lt_cv_ld_force_load=yes else cat conftest.err >&AS_MESSAGE_LOG_FD fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM ]) case $host_os in rhapsody* | darwin1.[[012]]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[[012]]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ]) # _LT_DARWIN_LINKER_FEATURES # -------------------------- # Checks for linker and compiler features on darwin m4_defun([_LT_DARWIN_LINKER_FEATURES], [ m4_require([_LT_REQUIRED_DARWIN_CHECKS]) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported if test "$lt_cv_ld_force_load" = "yes"; then _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else _LT_TAGVAR(whole_archive_flag_spec, $1)='' fi _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" m4_if([$1], [CXX], [ if test "$lt_cv_apple_cc_single_mod" != "yes"; then _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}" _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}" fi ],[]) else _LT_TAGVAR(ld_shlibs, $1)=no fi ]) # _LT_SYS_MODULE_PATH_AIX([TAGNAME]) # ---------------------------------- # Links a minimal program and checks the executable # for the system default hardcoded library path. In most cases, # this is /usr/lib:/lib, but when the MPI compilers are used # the location of the communication and MPI libs are included too. # If we don't find anything, use the default library path according # to the aix ld manual. # Store the results from the different compilers for each TAGNAME. # Allow to override them for all tags through lt_cv_aix_libpath. m4_defun([_LT_SYS_MODULE_PATH_AIX], [m4_require([_LT_DECL_SED])dnl if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ lt_aix_libpath_sed='[ /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }]' _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi],[]) if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib" fi ]) aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) fi ])# _LT_SYS_MODULE_PATH_AIX # _LT_SHELL_INIT(ARG) # ------------------- m4_define([_LT_SHELL_INIT], [m4_divert_text([M4SH-INIT], [$1 ])])# _LT_SHELL_INIT # _LT_PROG_ECHO_BACKSLASH # ----------------------- # Find how we can fake an echo command that does not interpret backslash. # In particular, with Autoconf 2.60 or later we add some code to the start # of the generated configure script which will find a shell with a builtin # printf (which we can use as an echo command). m4_defun([_LT_PROG_ECHO_BACKSLASH], [ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO AC_MSG_CHECKING([how to print strings]) # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $[]1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } case "$ECHO" in printf*) AC_MSG_RESULT([printf]) ;; print*) AC_MSG_RESULT([print -r]) ;; *) AC_MSG_RESULT([cat]) ;; esac m4_ifdef([_AS_DETECT_SUGGESTED], [_AS_DETECT_SUGGESTED([ test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test "X`printf %s $ECHO`" = "X$ECHO" \ || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) _LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) _LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) ])# _LT_PROG_ECHO_BACKSLASH # _LT_WITH_SYSROOT # ---------------- AC_DEFUN([_LT_WITH_SYSROOT], [AC_MSG_CHECKING([for sysroot]) AC_ARG_WITH([sysroot], [ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the compiler's sysroot if not specified).], [], [with_sysroot=no]) dnl lt_sysroot will always be passed unquoted. We quote it here dnl in case the user passed a directory name. lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) AC_MSG_RESULT([${with_sysroot}]) AC_MSG_ERROR([The sysroot must be an absolute path.]) ;; esac AC_MSG_RESULT([${lt_sysroot:-no}]) _LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl [dependent libraries, and in which our libraries should be installed.])]) # _LT_ENABLE_LOCK # --------------- m4_defun([_LT_ENABLE_LOCK], [AC_ARG_ENABLE([libtool-lock], [AS_HELP_STRING([--disable-libtool-lock], [avoid locking (might break parallel builds)])]) test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, [AC_LANG_PUSH(C) AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) AC_LANG_POP]) 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 ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if AC_TRY_EVAL(ac_compile); then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" ])# _LT_ENABLE_LOCK # _LT_PROG_AR # ----------- m4_defun([_LT_PROG_AR], [AC_CHECK_TOOLS(AR, [ar], false) : ${AR=ar} : ${AR_FLAGS=cru} _LT_DECL([], [AR], [1], [The archiver]) _LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], [lt_cv_ar_at_file=no AC_COMPILE_IFELSE([AC_LANG_PROGRAM], [echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a AC_TRY_EVAL([lt_ar_try]) if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a ]) ]) if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi _LT_DECL([], [archiver_list_spec], [1], [How to feed a file listing to the archiver]) ])# _LT_PROG_AR # _LT_CMD_OLD_ARCHIVE # ------------------- m4_defun([_LT_CMD_OLD_ARCHIVE], [_LT_PROG_AR AC_CHECK_TOOL(STRIP, strip, :) test -z "$STRIP" && STRIP=: _LT_DECL([], [STRIP], [1], [A symbol stripping program]) AC_CHECK_TOOL(RANLIB, ranlib, :) test -z "$RANLIB" && RANLIB=: _LT_DECL([], [RANLIB], [1], [Commands used to install an old-style archive]) # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac _LT_DECL([], [old_postinstall_cmds], [2]) _LT_DECL([], [old_postuninstall_cmds], [2]) _LT_TAGDECL([], [old_archive_cmds], [2], [Commands used to build an old-style archive]) _LT_DECL([], [lock_old_archive_extraction], [0], [Whether to use a lock for old archive extraction]) ])# _LT_CMD_OLD_ARCHIVE # _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------------------- # Check whether the given compiler option works AC_DEFUN([_LT_COMPILER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$3" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi fi $RM conftest* ]) if test x"[$]$2" = xyes; then m4_if([$5], , :, [$5]) else m4_if([$6], , :, [$6]) fi ])# _LT_COMPILER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) # _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, # [ACTION-SUCCESS], [ACTION-FAILURE]) # ---------------------------------------------------- # Check whether the given linker option works AC_DEFUN([_LT_LINKER_OPTION], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_SED])dnl AC_CACHE_CHECK([$1], [$2], [$2=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $3" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&AS_MESSAGE_LOG_FD $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then $2=yes fi else $2=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" ]) if test x"[$]$2" = xyes; then m4_if([$4], , :, [$4]) else m4_if([$5], , :, [$5]) fi ])# _LT_LINKER_OPTION # Old name: AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) # LT_CMD_MAX_LEN #--------------- AC_DEFUN([LT_CMD_MAX_LEN], [AC_REQUIRE([AC_CANONICAL_HOST])dnl # find the maximum length of command line arguments AC_MSG_CHECKING([the maximum length of command line arguments]) AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac ]) if test -n $lt_cv_sys_max_cmd_len ; then AC_MSG_RESULT($lt_cv_sys_max_cmd_len) else AC_MSG_RESULT(none) fi max_cmd_len=$lt_cv_sys_max_cmd_len _LT_DECL([], [max_cmd_len], [0], [What is the maximum length of a command?]) ])# LT_CMD_MAX_LEN # Old name: AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) # _LT_HEADER_DLFCN # ---------------- m4_defun([_LT_HEADER_DLFCN], [AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl ])# _LT_HEADER_DLFCN # _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, # ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) # ---------------------------------------------------------------- m4_defun([_LT_TRY_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "$cross_compiling" = yes; then : [$4] else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF [#line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; }] _LT_EOF if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) $1 ;; x$lt_dlneed_uscore) $2 ;; x$lt_dlunknown|x*) $3 ;; esac else : # compilation failed $3 fi fi rm -fr conftest* ])# _LT_TRY_DLOPEN_SELF # LT_SYS_DLOPEN_SELF # ------------------ AC_DEFUN([LT_SYS_DLOPEN_SELF], [m4_require([_LT_HEADER_DLFCN])dnl if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[ lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ]) ;; *) AC_CHECK_FUNC([shl_load], [lt_cv_dlopen="shl_load"], [AC_CHECK_LIB([dld], [shl_load], [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"], [AC_CHECK_FUNC([dlopen], [lt_cv_dlopen="dlopen"], [AC_CHECK_LIB([dl], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"], [AC_CHECK_LIB([svld], [dlopen], [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"], [AC_CHECK_LIB([dld], [dld_link], [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"]) ]) ]) ]) ]) ]) ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" AC_CACHE_CHECK([whether a program can dlopen itself], lt_cv_dlopen_self, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) ]) if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" AC_CACHE_CHECK([whether a statically linked program can dlopen itself], lt_cv_dlopen_self_static, [dnl _LT_TRY_DLOPEN_SELF( lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) ]) fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi _LT_DECL([dlopen_support], [enable_dlopen], [0], [Whether dlopen is supported]) _LT_DECL([dlopen_self], [enable_dlopen_self], [0], [Whether dlopen of programs is supported]) _LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], [Whether dlopen of statically linked programs is supported]) ])# LT_SYS_DLOPEN_SELF # Old name: AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) # _LT_COMPILER_C_O([TAGNAME]) # --------------------------- # Check to see if options -c and -o are simultaneously supported by compiler. # This macro does not hard code the compiler like AC_PROG_CC_C_O. m4_defun([_LT_COMPILER_C_O], [m4_require([_LT_DECL_SED])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&AS_MESSAGE_LOG_FD echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes fi fi chmod u+w . 2>&AS_MESSAGE_LOG_FD $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* ]) _LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], [Does compiler simultaneously support -c and -o options?]) ])# _LT_COMPILER_C_O # _LT_COMPILER_FILE_LOCKS([TAGNAME]) # ---------------------------------- # Check to see if we can do hard links to lock some files if needed m4_defun([_LT_COMPILER_FILE_LOCKS], [m4_require([_LT_ENABLE_LOCK])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl _LT_COMPILER_C_O([$1]) hard_links="nottested" if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user AC_MSG_CHECKING([if we can lock with hard links]) hard_links=yes $RM conftest* ln conftest.a conftest.b 2>/dev/null && hard_links=no touch conftest.a ln conftest.a conftest.b 2>&5 || hard_links=no ln conftest.a conftest.b 2>/dev/null && hard_links=no AC_MSG_RESULT([$hard_links]) if test "$hard_links" = no; then AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe]) need_locks=warn fi else need_locks=no fi _LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) ])# _LT_COMPILER_FILE_LOCKS # _LT_CHECK_OBJDIR # ---------------- m4_defun([_LT_CHECK_OBJDIR], [AC_CACHE_CHECK([for objdir], [lt_cv_objdir], [rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null]) objdir=$lt_cv_objdir _LT_DECL([], [objdir], [0], [The name of the directory that contains temporary libtool files])dnl m4_pattern_allow([LT_OBJDIR])dnl AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/", [Define to the sub-directory in which libtool stores uninstalled libraries.]) ])# _LT_CHECK_OBJDIR # _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) # -------------------------------------- # Check hardcoding attributes. m4_defun([_LT_LINKER_HARDCODE_LIBPATH], [AC_MSG_CHECKING([how to hardcode library paths into programs]) _LT_TAGVAR(hardcode_action, $1)= if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || test -n "$_LT_TAGVAR(runpath_var, $1)" || test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then # We can hardcode non-existent directories. if test "$_LT_TAGVAR(hardcode_direct, $1)" != 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 "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no && test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then # Linking always hardcodes the temporary library directory. _LT_TAGVAR(hardcode_action, $1)=relink else # We can link without hardcoding, and we can hardcode nonexisting dirs. _LT_TAGVAR(hardcode_action, $1)=immediate fi else # We cannot hardcode anything, or else we can only hardcode existing # directories. _LT_TAGVAR(hardcode_action, $1)=unsupported fi AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) if test "$_LT_TAGVAR(hardcode_action, $1)" = relink || test "$_LT_TAGVAR(inherit_rpath, $1)" = 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 _LT_TAGDECL([], [hardcode_action], [0], [How to hardcode a shared library path into an executable]) ])# _LT_LINKER_HARDCODE_LIBPATH # _LT_CMD_STRIPLIB # ---------------- m4_defun([_LT_CMD_STRIPLIB], [m4_require([_LT_DECL_EGREP]) striplib= old_striplib= AC_MSG_CHECKING([whether stripping libraries is possible]) if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" test -z "$striplib" && striplib="$STRIP --strip-unneeded" AC_MSG_RESULT([yes]) else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ;; *) AC_MSG_RESULT([no]) ;; esac fi _LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) _LT_DECL([], [striplib], [1]) ])# _LT_CMD_STRIPLIB # _LT_SYS_DYNAMIC_LINKER([TAG]) # ----------------------------- # PORTME Fill in your ld.so characteristics m4_defun([_LT_SYS_DYNAMIC_LINKER], [AC_REQUIRE([AC_CANONICAL_HOST])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_OBJDUMP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CHECK_SHELL_FEATURES])dnl AC_MSG_CHECKING([dynamic linker characteristics]) m4_if([$1], [], [ if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[[lt_foo]]++; } if (lt_freq[[lt_foo]] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([[A-Za-z]]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi]) library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" 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" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[[4-9]]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[[01]] | aix4.[[01]].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) 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=`func_echo_all "$lib" | $SED '\''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' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[[45]]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' m4_if([$1], [],[ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[[123]]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$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 ;; freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[[3-9]]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], [lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], [lt_cv_shlibpath_overrides_runpath=yes])]) LDFLAGS=$save_LDFLAGS libdir=$save_libdir ]) shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[[89]] | openbsd2.[[89]].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$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.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac AC_MSG_RESULT([$dynamic_linker]) test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi _LT_DECL([], [variables_saved_for_relink], [1], [Variables whose values should be saved in libtool wrapper scripts and restored at link time]) _LT_DECL([], [need_lib_prefix], [0], [Do we need the "lib" prefix for modules?]) _LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) _LT_DECL([], [version_type], [0], [Library versioning type]) _LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) _LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) _LT_DECL([], [shlibpath_overrides_runpath], [0], [Is shlibpath searched before the hard-coded library search path?]) _LT_DECL([], [libname_spec], [1], [Format of library name prefix]) _LT_DECL([], [library_names_spec], [1], [[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]]) _LT_DECL([], [soname_spec], [1], [[The coded name of the library, if different from the real name]]) _LT_DECL([], [install_override_mode], [1], [Permission mode override for installation of shared libraries]) _LT_DECL([], [postinstall_cmds], [2], [Command to use after installation of a shared archive]) _LT_DECL([], [postuninstall_cmds], [2], [Command to use after uninstallation of a shared archive]) _LT_DECL([], [finish_cmds], [2], [Commands used to finish a libtool library installation in a directory]) _LT_DECL([], [finish_eval], [1], [[As "finish_cmds", except a single script fragment to be evaled but not shown]]) _LT_DECL([], [hardcode_into_libs], [0], [Whether we should hardcode library paths into libraries]) _LT_DECL([], [sys_lib_search_path_spec], [2], [Compile-time system search path for libraries]) _LT_DECL([], [sys_lib_dlsearch_path_spec], [2], [Run-time system search path for libraries]) ])# _LT_SYS_DYNAMIC_LINKER # _LT_PATH_TOOL_PREFIX(TOOL) # -------------------------- # find a file program which can recognize shared library AC_DEFUN([_LT_PATH_TOOL_PREFIX], [m4_require([_LT_DECL_EGREP])dnl AC_MSG_CHECKING([for $1]) AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, [case $MAGIC_CMD in [[\\/*] | ?:[\\/]*]) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR dnl $ac_dummy forces splitting on constant user-supplied paths. dnl POSIX.2 word splitting is done only on the output of word expansions, dnl not every word. This closes a longstanding sh security hole. ac_dummy="m4_if([$2], , $PATH, [$2])" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$1; then lt_cv_path_MAGIC_CMD="$ac_dir/$1" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac]) MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then AC_MSG_RESULT($MAGIC_CMD) else AC_MSG_RESULT(no) fi _LT_DECL([], [MAGIC_CMD], [0], [Used to examine libraries when file_magic_cmd begins with "file"])dnl ])# _LT_PATH_TOOL_PREFIX # Old name: AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) # _LT_PATH_MAGIC # -------------- # find a file program which can recognize a shared library m4_defun([_LT_PATH_MAGIC], [_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) else MAGIC_CMD=: fi fi ])# _LT_PATH_MAGIC # LT_PATH_LD # ---------- # find the pathname to the GNU or non-GNU linker AC_DEFUN([LT_PATH_LD], [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PROG_ECHO_BACKSLASH])dnl AC_ARG_WITH([gnu-ld], [AS_HELP_STRING([--with-gnu-ld], [assume the C compiler uses GNU ld @<:@default=no@:>@])], [test "$withval" = no || with_gnu_ld=yes], [with_gnu_ld=no])dnl ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by $CC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]]* | ?:[[\\/]]*) re_direlt='/[[^/]][[^/]]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL(lt_cv_path_LD, [if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &1 /dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[[3-9]]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac ]) file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown _LT_DECL([], [deplibs_check_method], [1], [Method to check whether dependent libraries are shared objects]) _LT_DECL([], [file_magic_cmd], [1], [Command to use when deplibs_check_method = "file_magic"]) _LT_DECL([], [file_magic_glob], [1], [How to find potential files when deplibs_check_method = "file_magic"]) _LT_DECL([], [want_nocaseglob], [1], [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) ])# _LT_CHECK_MAGIC_METHOD # LT_PATH_NM # ---------- # find the pathname to a BSD- or MS-compatible name lister AC_DEFUN([LT_PATH_NM], [AC_REQUIRE([AC_PROG_CC])dnl AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, [if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi]) if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi AC_SUBST([DUMPBIN]) if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm AC_SUBST([NM]) _LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], [lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&AS_MESSAGE_LOG_FD (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) cat conftest.out >&AS_MESSAGE_LOG_FD if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest*]) ])# LT_PATH_NM # Old names: AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_PROG_NM], []) dnl AC_DEFUN([AC_PROG_NM], []) # _LT_CHECK_SHAREDLIB_FROM_LINKLIB # -------------------------------- # how to determine the name of the shared library # associated with a specific link library. # -- PORTME fill in with the dynamic library characteristics m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], [m4_require([_LT_DECL_EGREP]) m4_require([_LT_DECL_OBJDUMP]) m4_require([_LT_DECL_DLLTOOL]) AC_CACHE_CHECK([how to associate runtime and link libraries], lt_cv_sharedlib_from_linklib_cmd, [lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac ]) sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO _LT_DECL([], [sharedlib_from_linklib_cmd], [1], [Command to associate shared and link libraries]) ])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB # _LT_PATH_MANIFEST_TOOL # ---------------------- # locate the manifest tool m4_defun([_LT_PATH_MANIFEST_TOOL], [AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], [lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&AS_MESSAGE_LOG_FD if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest*]) if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi _LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl ])# _LT_PATH_MANIFEST_TOOL # LT_LIB_M # -------- # check for math library AC_DEFUN([LT_LIB_M], [AC_REQUIRE([AC_CANONICAL_HOST])dnl LIBM= case $host in *-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) # These system don't have libm, or don't need it ;; *-ncr-sysv4.3*) AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") ;; *) AC_CHECK_LIB(m, cos, LIBM="-lm") ;; esac AC_SUBST([LIBM]) ])# LT_LIB_M # Old name: AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_CHECK_LIBM], []) # _LT_COMPILER_NO_RTTI([TAGNAME]) # ------------------------------- m4_defun([_LT_COMPILER_NO_RTTI], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= if test "$GCC" = yes; then case $cc_basename in nvcc*) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; *) _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; esac _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], lt_cv_prog_compiler_rtti_exceptions, [-fno-rtti -fno-exceptions], [], [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) fi _LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], [Compiler flag to turn off builtin functions]) ])# _LT_COMPILER_NO_RTTI # _LT_CMD_GLOBAL_SYMBOLS # ---------------------- m4_defun([_LT_CMD_GLOBAL_SYMBOLS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([LT_PATH_NM])dnl AC_REQUIRE([LT_PATH_LD])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_TAG_COMPILER])dnl # Check for command to grab the raw symbol name followed by C symbol from nm. AC_MSG_CHECKING([command to parse $NM output from $compiler object]) AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], [ # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[[BCDEGRST]]' # Regexp to match symbols that can be accessed directly from C. sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[[BCDT]]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[[ABCDGISTW]]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[[ABCDEGRST]]' fi ;; irix* | nonstopux*) symcode='[[BCDEGRST]]' ;; osf*) symcode='[[BCDEGQRST]]' ;; solaris*) symcode='[[BDRT]]' ;; sco3.2v5*) symcode='[[DT]]' ;; sysv4.2uw2*) symcode='[[DT]]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[[ABDT]]' ;; sysv4) symcode='[[DFNSTU]]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[[ABCDGIRSTW]]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK ['"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx]" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if AC_TRY_EVAL(ac_compile); then # Now try to grab the symbols. nlist=conftest.nm if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT@&t@_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT@&t@_DLSYM_CONST #else # define LT@&t@_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT@&t@_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[[]] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD fi else echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done ]) if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then AC_MSG_RESULT(failed) else AC_MSG_RESULT(ok) fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then nm_file_list_spec='@' fi _LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], [Take the output of nm and produce a listing of raw symbols and C names]) _LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], [Transform the output of nm in a proper C declaration]) _LT_DECL([global_symbol_to_c_name_address], [lt_cv_sys_global_symbol_to_c_name_address], [1], [Transform the output of nm in a C name address pair]) _LT_DECL([global_symbol_to_c_name_address_lib_prefix], [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], [Transform the output of nm in a C name address pair when lib prefix is needed]) _LT_DECL([], [nm_file_list_spec], [1], [Specify filename containing input files for $NM]) ]) # _LT_CMD_GLOBAL_SYMBOLS # _LT_COMPILER_PIC([TAGNAME]) # --------------------------- m4_defun([_LT_COMPILER_PIC], [m4_require([_LT_TAG_COMPILER])dnl _LT_TAGVAR(lt_prog_compiler_wl, $1)= _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)= m4_if([$1], [CXX], [ # C++ specific cases for pic, static, wl, etc. if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # 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). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; *djgpp*) # DJGPP does not support shared libraries at all _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac else case $host_os in aix[[4-9]]*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; chorus*) case $cc_basename in cxch68*) # Green Hills C++ Compiler # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" ;; esac ;; mingw* | cygwin* | os2* | pw32* | cegcc*) # 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). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; dgux*) case $cc_basename in ec++*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; ghcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; freebsd* | dragonfly*) # FreeBSD uses GNU C++ ;; hpux9* | hpux10* | hpux11*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' if test "$host_cpu" != ia64; then _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' fi ;; aCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac ;; *) ;; esac ;; interix*) # This is c89, which is MS Visual C++ (no shared libs) # Anyone wants to do a port? ;; irix5* | irix6* | nonstopux*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' # CC pic flag -KPIC is the default. ;; *) ;; esac ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # KAI C++ Compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; ecpc* ) # old Intel C++ for x86_64 which still supported -KPIC. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; icpc* ) # Intel C++, used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; pgCC* | pgcpp*) # Portland Group C++ compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; cxx*) # Compaq C++ # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL 8.0, 9.0 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; esac ;; esac ;; lynxos*) ;; m88k*) ;; mvs*) case $cc_basename in cxx*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' ;; *) ;; esac ;; netbsd* | netbsdelf*-gnu) ;; *qnx* | *nto*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' ;; RCC*) # Rational C++ 2.4.1 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; cxx*) # Digital/Compaq C++ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # Make sure the PIC flag is empty. It appears that all Alpha # Linux and Compaq Tru64 Unix objects are PIC. _LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; *) ;; esac ;; psos*) ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' ;; *) ;; esac ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; lcc*) # Lucid _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' ;; *) ;; esac ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) case $cc_basename in CC*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' ;; *) ;; esac ;; vxworks*) ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ], [ if test "$GCC" = yes; then _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # 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). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. _LT_TAGVAR(lt_prog_compiler_static, $1)= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac ;; interix[[3-9]]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic fi ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' else _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # 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). m4_if([$1], [GCJ], [], [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) ;; hpux9* | hpux10* | hpux11*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # PIC (with -KPIC) is the default. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' ;; # Lahey Fortran 8.1. lf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' ;; nagfor*) # NAG Fortran compiler _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; ccc*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All Alpha code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ F* | *Sun*Fortran*) # Sun Fortran 8.3 passes all unrecognized flags to the linker _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='' ;; *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' ;; esac ;; esac ;; newsos6) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' ;; osf3* | osf4* | osf5*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' # All OSF/1 code is PIC. _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; rdos*) _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' ;; solaris*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; *) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; esac ;; sunos4*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; unicos*) _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; uts4*) _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' ;; *) _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no ;; esac fi ]) case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) _LT_TAGVAR(lt_prog_compiler_pic, $1)= ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" ;; esac AC_CACHE_CHECK([for $compiler option to produce PIC], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) _LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) # # Check to make sure the PIC flag actually works. # if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in "" | " "*) ;; *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; esac], [_LT_TAGVAR(lt_prog_compiler_pic, $1)= _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) fi _LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], [Additional compiler flags for building library objects]) _LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], [How to pass a linker flag through the compiler]) # # Check to make sure the static flag actually works. # wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" _LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), $lt_tmp_static_flag, [], [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) _LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], [Compiler flag to prevent dynamic linking]) ])# _LT_COMPILER_PIC # _LT_LINKER_SHLIBS([TAGNAME]) # ---------------------------- # See if the linker supports building shared libraries. m4_defun([_LT_LINKER_SHLIBS], [AC_REQUIRE([LT_PATH_LD])dnl AC_REQUIRE([LT_PATH_NM])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_DECL_SED])dnl m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl m4_require([_LT_TAG_COMPILER])dnl AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) m4_if([$1], [CXX], [ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] case $host_os in aix[[4-9]]*) # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global defined # symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi ;; pw32*) _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds" ;; cygwin* | mingw* | cegcc*) case $cc_basename in cl*) ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] ;; esac ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; *) _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' ;; esac ], [ runpath_var= _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_cmds, $1)= _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(old_archive_from_new_cmds, $1)= _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= _LT_TAGVAR(thread_safe_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= # include_expsyms should be a list of space-separated symbols to be *always* # included in the symbol list _LT_TAGVAR(include_expsyms, $1)= # exclude_expsyms can be an extended regexp 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'. _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] # 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. # Exclude shared library initialization/finalization symbols. dnl Note also adjust exclude_expsyms for C++ above. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) _LT_TAGVAR(link_all_deplibs, $1)=no ;; esac _LT_TAGVAR(ld_shlibs, $1)=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[[3-9]]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, 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 install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 _LT_TAGVAR(whole_archive_flag_spec, $1)= tmp_sharedflag='--shared' ;; xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir' _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&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. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) _LT_TAGVAR(ld_shlibs, $1)=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; sunos4*) _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' wlarc= _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then runpath_var= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. _LT_TAGVAR(hardcode_minus_L, $1)=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. _LT_TAGVAR(hardcode_direct, $1)=unsupported fi ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=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 _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi _LT_TAGVAR(link_all_deplibs, $1)=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='' ;; m68k) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac ;; bsdi[[45]]*) _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # 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. case $cc_basename in cl*) # Native MSVC _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' # FIXME: Should let the user specify the lib program. _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; freebsd1*) _LT_TAGVAR(ld_shlibs, $1)=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*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # Unfortunately, older versions of FreeBSD 2 do not have this feature. freebsd2*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; # FreeBSD 3 and greater uses gcc -shared to do shared libraries. freebsd* | dragonfly*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; hpux9*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) m4_if($1, [], [ # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) _LT_LINKER_OPTION([if $CC understands -b], _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) ;; esac fi if test "$with_gnu_ld" = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. _LT_TAGVAR(hardcode_minus_L, $1)=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], [lt_cv_irix_exported_symbol], [save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" AC_LINK_IFELSE( [AC_LANG_SOURCE( [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], [C++], [[int foo (void) { return 0; }]], [Fortran 77], [[ subroutine foo end]], [Fortran], [[ subroutine foo end]])])], [lt_cv_irix_exported_symbol=yes], [lt_cv_irix_exported_symbol=no]) LDFLAGS="$save_LDFLAGS"]) if test "$lt_cv_irix_exported_symbol" = yes; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes _LT_TAGVAR(link_all_deplibs, $1)=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; newsos6) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' else case $host_os in openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*) _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' ;; esac fi else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; os2*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' else _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' fi _LT_TAGVAR(archive_cmds_need_lc, $1)='no' _LT_TAGVAR(hardcode_libdir_separator, $1)=: ;; solaris*) _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='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' ;; *) wlarc='${wl}' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' fi ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4) case $host_vendor in sni) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' _LT_TAGVAR(hardcode_direct, $1)=no ;; motorola) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; sysv4.3*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes _LT_TAGVAR(ld_shlibs, $1)=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(ld_shlibs, $1)=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym' ;; esac fi fi ]) AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld _LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl _LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl _LT_DECL([], [extract_expsyms_cmds], [2], [The commands to extract the exported symbol list from a shared archive]) # # Do we need to explicitly link libc? # case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in x|xyes) # Assume -lc should be added _LT_TAGVAR(archive_cmds_need_lc, $1)=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $_LT_TAGVAR(archive_cmds, $1) in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. AC_CACHE_CHECK([whether -lc should be explicitly linked in], [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), [$RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if AC_TRY_EVAL(ac_compile) 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) _LT_TAGVAR(allow_undefined_flag, $1)= if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) then lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no else lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes fi _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* ]) _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) ;; esac fi ;; esac _LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], [Whether or not to add -lc for building shared libraries]) _LT_TAGDECL([allow_libtool_libs_with_static_runtimes], [enable_shared_with_static_runtimes], [0], [Whether or not to disallow shared libs when runtime libs are static]) _LT_TAGDECL([], [export_dynamic_flag_spec], [1], [Compiler flag to allow reflexive dlopens]) _LT_TAGDECL([], [whole_archive_flag_spec], [1], [Compiler flag to generate shared objects directly from archives]) _LT_TAGDECL([], [compiler_needs_object], [1], [Whether the compiler copes with passing no objects directly]) _LT_TAGDECL([], [old_archive_from_new_cmds], [2], [Create an old-style archive from a shared archive]) _LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], [Create a temporary old-style archive to link instead of a shared archive]) _LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) _LT_TAGDECL([], [archive_expsym_cmds], [2]) _LT_TAGDECL([], [module_cmds], [2], [Commands used to build a loadable module if different from building a shared archive.]) _LT_TAGDECL([], [module_expsym_cmds], [2]) _LT_TAGDECL([], [with_gnu_ld], [1], [Whether we are building with GNU ld or not]) _LT_TAGDECL([], [allow_undefined_flag], [1], [Flag that allows shared libraries with undefined symbols to be built]) _LT_TAGDECL([], [no_undefined_flag], [1], [Flag that enforces no undefined symbols]) _LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], [Flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]) _LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1], [[If ld is used when linking, flag to hardcode $libdir into a binary during linking. This must work even if $libdir does not exist]]) _LT_TAGDECL([], [hardcode_libdir_separator], [1], [Whether we need a single "-rpath" flag with a separated argument]) _LT_TAGDECL([], [hardcode_direct], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_direct_absolute], [0], [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the resulting binary and the resulting library dependency is "absolute", i.e impossible to change by setting ${shlibpath_var} if the library is relocated]) _LT_TAGDECL([], [hardcode_minus_L], [0], [Set to "yes" if using the -LDIR flag during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_shlibpath_var], [0], [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into the resulting binary]) _LT_TAGDECL([], [hardcode_automatic], [0], [Set to "yes" if building a shared library automatically hardcodes DIR into the library and all subsequent libraries and executables linked against it]) _LT_TAGDECL([], [inherit_rpath], [0], [Set to yes if linker adds runtime paths of dependent libraries to runtime path list]) _LT_TAGDECL([], [link_all_deplibs], [0], [Whether libtool must link a program against all its dependency libraries]) _LT_TAGDECL([], [always_export_symbols], [0], [Set to "yes" if exported symbols are required]) _LT_TAGDECL([], [export_symbols_cmds], [2], [The commands to list exported symbols]) _LT_TAGDECL([], [exclude_expsyms], [1], [Symbols that should not be listed in the preloaded symbols]) _LT_TAGDECL([], [include_expsyms], [1], [Symbols that must always be exported]) _LT_TAGDECL([], [prelink_cmds], [2], [Commands necessary for linking programs (against libraries) with templates]) _LT_TAGDECL([], [postlink_cmds], [2], [Commands necessary for finishing linking programs]) _LT_TAGDECL([], [file_list_spec], [1], [Specify filename containing input files]) dnl FIXME: Not yet implemented dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], dnl [Compiler flag to generate thread safe objects]) ])# _LT_LINKER_SHLIBS # _LT_LANG_C_CONFIG([TAG]) # ------------------------ # Ensure that the configuration variables for a C compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_C_CONFIG], [m4_require([_LT_DECL_EGREP])dnl lt_save_CC="$CC" AC_LANG_PUSH(C) # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' _LT_TAG_COMPILER # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) LT_SYS_DLOPEN_SELF _LT_CMD_STRIPLIB # Report which library types will actually be built AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_CONFIG($1) fi AC_LANG_POP CC="$lt_save_CC" ])# _LT_LANG_C_CONFIG # _LT_LANG_CXX_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a C++ compiler are suitably # defined. These variables are subsequently used by _LT_CONFIG to write # the compiler configuration to `libtool'. m4_defun([_LT_LANG_CXX_CONFIG], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl m4_require([_LT_DECL_EGREP])dnl m4_require([_LT_PATH_MANIFEST_TOOL])dnl if test -n "$CXX" && ( test "X$CXX" != "Xno" && ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) || (test "X$CXX" != "Xg++"))) ; then AC_PROG_CXXCPP else _lt_caught_CXX_error=yes fi AC_LANG_PUSH(C++) _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(compiler_needs_object, $1)=no _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for C++ test sources. ac_ext=cpp # Object file extension for compiled C++ test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the CXX compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_caught_CXX_error" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_LD=$LD lt_save_GCC=$GCC GCC=$GXX lt_save_with_gnu_ld=$with_gnu_ld lt_save_path_LD=$lt_cv_path_LD if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx else $as_unset lt_cv_prog_gnu_ld fi if test -n "${lt_cv_path_LDCXX+set}"; then lt_cv_path_LD=$lt_cv_path_LDCXX else $as_unset lt_cv_path_LD fi test -z "${LDCXX+set}" || LD=$LDCXX CC=${CXX-"c++"} CFLAGS=$CXXFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then # We don't want -fno-exception when compiling C++ code, so set the # no_builtin_flag separately if test "$GXX" = yes; then _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' else _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= fi if test "$GXX" = yes; then # Set up default GNU C++ configuration LT_PATH_LD # Check if GNU C++ uses GNU ld as the underlying linker, since the # archiving commands below assume that GNU ld is being used. if test "$with_gnu_ld" = yes; then _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # If archive_cmds runs LD, not CC, wlarc should be empty # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to # investigate it a little bit more. (MM) wlarc='${wl}' # ancient GNU ld didn't support --whole-archive et. al. if eval "`$CC -print-prog-name=ld` --help 2>&1" | $GREP 'no-whole-archive' > /dev/null; then _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else _LT_TAGVAR(whole_archive_flag_spec, $1)= fi else with_gnu_ld=no wlarc= # A generic and very simple default shared library creation # command for GNU C++ for the case where it uses the native # linker, instead of GNU ld. If possible, this setting should # overridden to take advantage of the native linker features on # the platform it is being used on. _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' fi # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else GXX=no with_gnu_ld=no wlarc= fi # PORTME: fill in a description of your system's C++ link characteristics AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) _LT_TAGVAR(ld_shlibs, $1)=yes case $host_os in aix3*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aix[[4-9]]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) for ld_flag in $LDFLAGS; do case $ld_flag in *-brtl*) aix_use_runtimelinking=yes break ;; esac done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. _LT_TAGVAR(archive_cmds, $1)='' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(file_list_spec, $1)='${wl}-f,' if test "$GXX" = yes; then case $host_os in aix4.[[012]]|aix4.[[012]].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 _LT_TAGVAR(hardcode_direct, $1)=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 _LT_TAGVAR(hardcode_minus_L, $1)=yes _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)= fi esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to # export. _LT_TAGVAR(always_export_symbols, $1)=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. _LT_TAGVAR(allow_undefined_flag, $1)='-berok' # Determine the default libpath from the value encoded in an empty # executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib' _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. _LT_SYS_MODULE_PATH_AIX([$1]) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok' _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' fi _LT_TAGVAR(archive_cmds_need_lc, $1)=yes # This is similar to how AIX traditionally builds its shared # libraries. _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then _LT_TAGVAR(allow_undefined_flag, $1)=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; chorus*) case $cc_basename in *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; cygwin* | mingw* | pw32* | cegcc*) case $GXX,$cc_basename in ,cl* | no,cl*) # Native MSVC # hardcode_libdir_flag_spec is actually meaningless, as there is # no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=yes _LT_TAGVAR(file_list_spec, $1)='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes # Don't use ranlib _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ func_to_tool_file "$lt_outputfile"~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # g++ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, # as there is no search path for DLLs. _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols' _LT_TAGVAR(allow_undefined_flag, $1)=unsupported _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; darwin* | rhapsody*) _LT_DARWIN_LINKER_FEATURES($1) ;; dgux*) case $cc_basename in ec++*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; ghcx*) # Green Hills C++ Compiler # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; freebsd[[12]]*) # C++ shared libraries reported to be fairly broken before # switch to ELF _LT_TAGVAR(ld_shlibs, $1)=no ;; freebsd-elf*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; freebsd* | dragonfly*) # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF # conventions _LT_TAGVAR(ld_shlibs, $1)=yes ;; gnu*) ;; haiku*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(link_all_deplibs, $1)=yes ;; hpux9*) _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; hpux10*|hpux11*) if test $with_gnu_ld = no; then _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: case $host_cpu in hppa*64*|ia64*) ;; *) _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' ;; esac fi case $host_cpu in hppa*64*|ia64*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no ;; *) _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, # but as the default # location of the library. ;; esac case $cc_basename in CC*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; aCC*) case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes; then if test $with_gnu_ld = no; then case $host_cpu in hppa*64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; ia64*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' ;; esac fi else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; interix[[3-9]]*) _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; irix5* | irix6*) case $cc_basename in CC*) # SGI C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' # Archives containing C++ object files must be created using # "CC -ar", where "CC" is the IRIX C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' ;; *) if test "$GXX" = yes; then if test "$with_gnu_ld" = no; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib' fi fi _LT_TAGVAR(link_all_deplibs, $1)=yes ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: _LT_TAGVAR(inherit_rpath, $1)=yes ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' # Archives containing C++ object files must be created using # "CC -Bstatic", where "CC" is the KAI C++ compiler. _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; icpc* | ecpc* ) # Intel C++ with_gnu_ld=yes # version 8.0 and above of icpc choke on multiply defined symbols # if we add $predep_objects and $postdep_objects, however 7.1 and # earlier do not add the objects themselves. case `$CC -V 2>&1` in *"Version 7."*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; *) # Version 8.0 or newer tmp_idyn= case $host_cpu in ia64*) tmp_idyn=' -i_dynamic';; esac _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' ;; esac _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive' ;; pgCC* | pgcpp*) # Portland Group C++ compiler case `$CC -V` in *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ $RANLIB $oldlib' _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ rm -rf $tpldir~ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; *) # Version 6 and above use weak symbols _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' ;; cxx*) # Compaq C++ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols' runpath_var=LD_RUN_PATH _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' ;; xl* | mpixl* | bgxl*) # IBM XL 8.0 on PPC, with GNU ld _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic' _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' _LT_TAGVAR(compiler_needs_object, $1)=yes # Not sure whether something based on # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 # would be better. output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; esac ;; esac ;; lynxos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; m88k*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; mvs*) case $cc_basename in cxx*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; netbsd*) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' wlarc= _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no fi # Workaround some broken pre-1.5 toolchains output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' ;; *nto* | *qnx*) _LT_TAGVAR(ld_shlibs, $1)=yes ;; openbsd2*) # C++ shared libraries are fairly broken _LT_TAGVAR(ld_shlibs, $1)=no ;; openbsd*) if test -f /usr/libexec/ld.so; then _LT_TAGVAR(hardcode_direct, $1)=yes _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=yes _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib' _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E' _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' fi output_verbose_link_cmd=func_echo_all else _LT_TAGVAR(ld_shlibs, $1)=no fi ;; osf3* | osf4* | osf5*) case $cc_basename in KCC*) # Kuck and Associates, Inc. (KAI) C++ Compiler # KCC will only create a shared library if the output file # ends with ".so" (or ".sl" for HP-UX), so rename the library # to its proper name (with version) after linking. _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Archives containing C++ object files must be created using # the KAI C++ compiler. case $host in osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; esac ;; RCC*) # Rational C++ 2.4.1 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; cxx*) case $host in osf3*) _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' ;; *) _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ echo "-hidden">> $lib.exp~ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~ $RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' ;; esac _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. # # There doesn't appear to be a way to prevent this compiler from # explicitly linking system object files so we need to strip them # from the output so that they don't get included in the library # dependencies. output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' ;; *) if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*' case $host in osf3*) _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' ;; esac _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=: # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no fi ;; esac ;; psos*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; sunos4*) case $cc_basename in CC*) # Sun C++ 4.x # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; lcc*) # Lucid # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # Sun C++ 4.2, 5.x and Centerline C++ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' _LT_TAGVAR(hardcode_shlibpath_var, $1)=no case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. # Supported since Solaris 2.6 (maybe 2.5.1?) _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;; esac _LT_TAGVAR(link_all_deplibs, $1)=yes output_verbose_link_cmd='func_echo_all' # Archives containing C++ object files must be created using # "CC -xar", where "CC" is the Sun C++ compiler. This is # necessary to make sure instantiated templates are included # in the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' ;; gcx*) # Green Hills C++ Compiler _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' # The C++ compiler must be used to create the archive. _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' ;; *) # GNU C++ compiler with Solaris linker if test "$GXX" = yes && test "$with_gnu_ld" = no; then _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs' if $CC --version | $GREP -v '^2\.7' > /dev/null; then _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' else # g++ 2.7 appears to require `-G' NOT `-shared' on this # platform. _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' # Commands to make compiler produce verbose output that lists # what "hidden" libraries, object files and flags are used when # linking a shared library. output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' fi _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir' case $host_os in solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; *) _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' ;; esac fi ;; esac ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text' _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs' _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(hardcode_shlibpath_var, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir' _LT_TAGVAR(hardcode_libdir_separator, $1)=':' _LT_TAGVAR(link_all_deplibs, $1)=yes _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport' runpath_var='LD_RUN_PATH' case $cc_basename in CC*) _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ '"$_LT_TAGVAR(old_archive_cmds, $1)" _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ '"$_LT_TAGVAR(reload_cmds, $1)" ;; *) _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' ;; esac ;; tandem*) case $cc_basename in NCC*) # NonStop-UX NCC 3.20 # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac ;; vxworks*) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; *) # FIXME: insert proper C++ library support _LT_TAGVAR(ld_shlibs, $1)=no ;; esac AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no _LT_TAGVAR(GCC, $1)="$GXX" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS LDCXX=$LD LD=$lt_save_LD GCC=$lt_save_GCC with_gnu_ld=$lt_save_with_gnu_ld lt_cv_path_LDCXX=$lt_cv_path_LD lt_cv_path_LD=$lt_save_path_LD lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld fi # test "$_lt_caught_CXX_error" != yes AC_LANG_POP ])# _LT_LANG_CXX_CONFIG # _LT_FUNC_STRIPNAME_CNF # ---------------------- # func_stripname_cnf prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # # This function is identical to the (non-XSI) version of func_stripname, # except this one can be used by m4 code that may be executed by configure, # rather than the libtool script. m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl AC_REQUIRE([_LT_DECL_SED]) AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) func_stripname_cnf () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname_cnf ])# _LT_FUNC_STRIPNAME_CNF # _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) # --------------------------------- # Figure out "hidden" library dependencies from verbose # compiler output when linking a shared library. # Parse the compiler output and extract the necessary # objects, libraries and library flags. m4_defun([_LT_SYS_HIDDEN_LIBDEPS], [m4_require([_LT_FILEUTILS_DEFAULTS])dnl AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl # Dependencies to place before and after the object being linked: _LT_TAGVAR(predep_objects, $1)= _LT_TAGVAR(postdep_objects, $1)= _LT_TAGVAR(predeps, $1)= _LT_TAGVAR(postdeps, $1)= _LT_TAGVAR(compiler_lib_search_path, $1)= dnl we can't use the lt_simple_compile_test_code here, dnl because it contains code intended for an executable, dnl not a library. It's possible we should let each dnl tag define a new lt_????_link_test_code variable, dnl but it's only used here... m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF int a; void foo (void) { a = 0; } _LT_EOF ], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF class Foo { public: Foo (void) { a = 0; } private: int a; }; _LT_EOF ], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer*4 a a=0 return end _LT_EOF ], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF subroutine foo implicit none integer a a=0 return end _LT_EOF ], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF public class foo { private int a; public void bar (void) { a = 0; } }; _LT_EOF ]) _lt_libdeps_save_CFLAGS=$CFLAGS case "$CC $CFLAGS " in #( *\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; *\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; esac dnl Parse the compiler output and extract the necessary dnl objects, libraries and library flags. if AC_TRY_EVAL(ac_compile); then # Parse the compiler output and extract the necessary # objects, libraries and library flags. # Sentinel used to keep track of whether or not we are before # the conftest object file. pre_test_object_deps_done=no for p in `eval "$output_verbose_link_cmd"`; do case ${prev}${p} in -L* | -R* | -l*) # Some compilers place space between "-{L,R}" and the path. # Remove the space. if test $p = "-L" || test $p = "-R"; then prev=$p continue fi # Expand the sysroot to ease extracting the directories later. if test -z "$prev"; then case $p in -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; esac fi case $p in =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; esac if test "$pre_test_object_deps_done" = no; then case ${prev} in -L | -R) # Internal compiler library paths should come after those # provided the user. The postdeps already come after the # user supplied libs so there is no need to process them. if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}" else _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}" fi ;; # The "-l" case would never come before the object being # linked, so don't bother handling this case. esac else if test -z "$_LT_TAGVAR(postdeps, $1)"; then _LT_TAGVAR(postdeps, $1)="${prev}${p}" else _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}" fi fi prev= ;; *.lto.$objext) ;; # Ignore GCC LTO objects *.$objext) # This assumes that the test object file only shows up # once in the compiler output. if test "$p" = "conftest.$objext"; then pre_test_object_deps_done=yes continue fi if test "$pre_test_object_deps_done" = no; then if test -z "$_LT_TAGVAR(predep_objects, $1)"; then _LT_TAGVAR(predep_objects, $1)="$p" else _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" fi else if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then _LT_TAGVAR(postdep_objects, $1)="$p" else _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" fi fi ;; *) ;; # Ignore the rest. esac done # Clean up. rm -f a.out a.exe else echo "libtool.m4: error: problem compiling $1 test program" fi $RM -f confest.$objext CFLAGS=$_lt_libdeps_save_CFLAGS # PORTME: override above test on systems where it is broken m4_if([$1], [CXX], [case $host_os in interix[[3-9]]*) # Interix 3.5 installs completely hosed .la files for C++, so rather than # hack all around it, let's just trust "g++" to DTRT. _LT_TAGVAR(predep_objects,$1)= _LT_TAGVAR(postdep_objects,$1)= _LT_TAGVAR(postdeps,$1)= ;; linux*) case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C++ 5.9 # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; solaris*) case $cc_basename in CC* | sunCC*) # The more standards-conforming stlport4 library is # incompatible with the Cstd library. Avoid specifying # it if it's in CXXFLAGS. Ignore libCrun as # -library=stlport4 depends on it. case " $CXX $CXXFLAGS " in *" -library=stlport4 "*) solaris_use_stlport4=yes ;; esac # Adding this requires a known-good setup of shared libraries for # Sun compiler versions before 5.6, else PIC objects from an old # archive will be linked into the output, leading to subtle bugs. if test "$solaris_use_stlport4" != yes; then _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun' fi ;; esac ;; esac ]) case " $_LT_TAGVAR(postdeps, $1) " in *" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; esac _LT_TAGVAR(compiler_lib_search_dirs, $1)= if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'` fi _LT_TAGDECL([], [compiler_lib_search_dirs], [1], [The directories searched by this compiler when creating a shared library]) _LT_TAGDECL([], [predep_objects], [1], [Dependencies to place before and after the objects being linked to create a shared library]) _LT_TAGDECL([], [postdep_objects], [1]) _LT_TAGDECL([], [predeps], [1]) _LT_TAGDECL([], [postdeps], [1]) _LT_TAGDECL([], [compiler_lib_search_path], [1], [The library search path used internally by the compiler when linking a shared library]) ])# _LT_SYS_HIDDEN_LIBDEPS # _LT_LANG_F77_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for a Fortran 77 compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_F77_CONFIG], [AC_LANG_PUSH(Fortran 77) if test -z "$F77" || test "X$F77" = "Xno"; then _lt_disable_F77=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for f77 test sources. ac_ext=f # Object file extension for compiled f77 test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the F77 compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_F77" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${F77-"f77"} CFLAGS=$FFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) GCC=$G77 if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$G77" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC="$lt_save_CC" CFLAGS="$lt_save_CFLAGS" fi # test "$_lt_disable_F77" != yes AC_LANG_POP ])# _LT_LANG_F77_CONFIG # _LT_LANG_FC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for a Fortran compiler are # suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_FC_CONFIG], [AC_LANG_PUSH(Fortran) if test -z "$FC" || test "X$FC" = "Xno"; then _lt_disable_FC=yes fi _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(allow_undefined_flag, $1)= _LT_TAGVAR(always_export_symbols, $1)=no _LT_TAGVAR(archive_expsym_cmds, $1)= _LT_TAGVAR(export_dynamic_flag_spec, $1)= _LT_TAGVAR(hardcode_direct, $1)=no _LT_TAGVAR(hardcode_direct_absolute, $1)=no _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)= _LT_TAGVAR(hardcode_libdir_separator, $1)= _LT_TAGVAR(hardcode_minus_L, $1)=no _LT_TAGVAR(hardcode_automatic, $1)=no _LT_TAGVAR(inherit_rpath, $1)=no _LT_TAGVAR(module_cmds, $1)= _LT_TAGVAR(module_expsym_cmds, $1)= _LT_TAGVAR(link_all_deplibs, $1)=unknown _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds _LT_TAGVAR(no_undefined_flag, $1)= _LT_TAGVAR(whole_archive_flag_spec, $1)= _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no # Source file extension for fc test sources. ac_ext=${ac_fc_srcext-f} # Object file extension for compiled fc test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # No sense in running all these tests if we already determined that # the FC compiler isn't working. Some variables (like enable_shared) # are currently assumed to apply to all compilers on this platform, # and will be corrupted by setting them based on a non-working compiler. if test "$_lt_disable_FC" != yes; then # Code to be used in simple compile tests lt_simple_compile_test_code="\ subroutine t return end " # Code to be used in simple link tests lt_simple_link_test_code="\ program t end " # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_GCC=$GCC lt_save_CFLAGS=$CFLAGS CC=${FC-"f95"} CFLAGS=$FCFLAGS compiler=$CC GCC=$ac_cv_fc_compiler_gnu _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) if test -n "$compiler"; then AC_MSG_CHECKING([if libtool supports shared libraries]) AC_MSG_RESULT([$can_build_shared]) AC_MSG_CHECKING([whether to build shared libraries]) test "$can_build_shared" = "no" && enable_shared=no # On AIX, shared libraries and static libraries use the same namespace, and # are all built from PIC. case $host_os in aix3*) test "$enable_shared" = yes && enable_static=no if test -n "$RANLIB"; then archive_cmds="$archive_cmds~\$RANLIB \$lib" postinstall_cmds='$RANLIB $lib' fi ;; aix[[4-9]]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac AC_MSG_RESULT([$enable_shared]) AC_MSG_CHECKING([whether to build static libraries]) # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes AC_MSG_RESULT([$enable_static]) _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu" _LT_TAGVAR(LD, $1)="$LD" ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... _LT_SYS_HIDDEN_LIBDEPS($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_SYS_DYNAMIC_LINKER($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi # test -n "$compiler" GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS fi # test "$_lt_disable_FC" != yes AC_LANG_POP ])# _LT_LANG_FC_CONFIG # _LT_LANG_GCJ_CONFIG([TAG]) # -------------------------- # Ensure that the configuration variables for the GNU Java Compiler compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_GCJ_CONFIG], [AC_REQUIRE([LT_PROG_GCJ])dnl AC_LANG_SAVE # Source file extension for Java test sources. ac_ext=java # Object file extension for compiled Java test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="class foo {}" # Code to be used in simple link tests lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC=$CC lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC=yes CC=${GCJ-"gcj"} CFLAGS=$GCJFLAGS compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_TAGVAR(LD, $1)="$LD" _LT_CC_BASENAME([$compiler]) # GCJ did not exist at the time GCC didn't implicitly link libc in. _LT_TAGVAR(archive_cmds_need_lc, $1)=no _LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds _LT_TAGVAR(reload_flag, $1)=$reload_flag _LT_TAGVAR(reload_cmds, $1)=$reload_cmds ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then _LT_COMPILER_NO_RTTI($1) _LT_COMPILER_PIC($1) _LT_COMPILER_C_O($1) _LT_COMPILER_FILE_LOCKS($1) _LT_LINKER_SHLIBS($1) _LT_LINKER_HARDCODE_LIBPATH($1) _LT_CONFIG($1) fi AC_LANG_RESTORE GCC=$lt_save_GCC CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_GCJ_CONFIG # _LT_LANG_RC_CONFIG([TAG]) # ------------------------- # Ensure that the configuration variables for the Windows resource compiler # are suitably defined. These variables are subsequently used by _LT_CONFIG # to write the compiler configuration to `libtool'. m4_defun([_LT_LANG_RC_CONFIG], [AC_REQUIRE([LT_PROG_RC])dnl AC_LANG_SAVE # Source file extension for RC test sources. ac_ext=rc # Object file extension for compiled RC test sources. objext=o _LT_TAGVAR(objext, $1)=$objext # Code to be used in simple compile tests lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' # Code to be used in simple link tests lt_simple_link_test_code="$lt_simple_compile_test_code" # ltmain only uses $CC for tagged configurations so make sure $CC is set. _LT_TAG_COMPILER # save warnings/boilerplate of simple test code _LT_COMPILER_BOILERPLATE _LT_LINKER_BOILERPLATE # Allow CC to be a program name with arguments. lt_save_CC="$CC" lt_save_CFLAGS=$CFLAGS lt_save_GCC=$GCC GCC= CC=${RC-"windres"} CFLAGS= compiler=$CC _LT_TAGVAR(compiler, $1)=$CC _LT_CC_BASENAME([$compiler]) _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes if test -n "$compiler"; then : _LT_CONFIG($1) fi GCC=$lt_save_GCC AC_LANG_RESTORE CC=$lt_save_CC CFLAGS=$lt_save_CFLAGS ])# _LT_LANG_RC_CONFIG # LT_PROG_GCJ # ----------- AC_DEFUN([LT_PROG_GCJ], [m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], [AC_CHECK_TOOL(GCJ, gcj,) test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2" AC_SUBST(GCJFLAGS)])])[]dnl ]) # Old name: AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_GCJ], []) # LT_PROG_RC # ---------- AC_DEFUN([LT_PROG_RC], [AC_CHECK_TOOL(RC, windres,) ]) # Old name: AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_RC], []) # _LT_DECL_EGREP # -------------- # If we don't have a new enough Autoconf to choose the best grep # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_EGREP], [AC_REQUIRE([AC_PROG_EGREP])dnl AC_REQUIRE([AC_PROG_FGREP])dnl test -z "$GREP" && GREP=grep _LT_DECL([], [GREP], [1], [A grep program that handles long lines]) _LT_DECL([], [EGREP], [1], [An ERE matcher]) _LT_DECL([], [FGREP], [1], [A literal string matcher]) dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too AC_SUBST([GREP]) ]) # _LT_DECL_OBJDUMP # -------------- # If we don't have a new enough Autoconf to choose the best objdump # available, choose the one first in the user's PATH. m4_defun([_LT_DECL_OBJDUMP], [AC_CHECK_TOOL(OBJDUMP, objdump, false) test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) AC_SUBST([OBJDUMP]) ]) # _LT_DECL_DLLTOOL # ---------------- # Ensure DLLTOOL variable is set. m4_defun([_LT_DECL_DLLTOOL], [AC_CHECK_TOOL(DLLTOOL, dlltool, false) test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program]) AC_SUBST([DLLTOOL]) ]) # _LT_DECL_SED # ------------ # Check for a fully-functional sed program, that truncates # as few characters as possible. Prefer GNU sed if found. m4_defun([_LT_DECL_SED], [AC_PROG_SED test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" _LT_DECL([], [SED], [1], [A sed program that does not truncate output]) _LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], [Sed that helps us avoid accidentally triggering echo(1) options like -n]) ])# _LT_DECL_SED m4_ifndef([AC_PROG_SED], [ ############################################################ # NOTE: This macro has been submitted for inclusion into # # GNU Autoconf as AC_PROG_SED. When it is available in # # a released version of Autoconf we should remove this # # macro and use it instead. # ############################################################ m4_defun([AC_PROG_SED], [AC_MSG_CHECKING([for a sed that does not truncate output]) AC_CACHE_VAL(lt_cv_path_SED, [# Loop through the user's path and test for sed and gsed. # Then use that list of sed's as ones to test for truncation. as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for lt_ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" fi done done done IFS=$as_save_IFS lt_ac_max=0 lt_ac_count=0 # Add /usr/xpg4/bin/sed as it is typically found on Solaris # along with /bin/sed that truncates output. for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do test ! -f $lt_ac_sed && continue cat /dev/null > conftest.in lt_ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >conftest.in # Check for GNU sed and select it if it is found. if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then lt_cv_path_SED=$lt_ac_sed break fi while true; do cat conftest.in conftest.in >conftest.tmp mv conftest.tmp conftest.in cp conftest.in conftest.nl echo >>conftest.nl $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break cmp -s conftest.out conftest.nl || break # 10000 chars as input seems more than enough test $lt_ac_count -gt 10 && break lt_ac_count=`expr $lt_ac_count + 1` if test $lt_ac_count -gt $lt_ac_max; then lt_ac_max=$lt_ac_count lt_cv_path_SED=$lt_ac_sed fi done done ]) SED=$lt_cv_path_SED AC_SUBST([SED]) AC_MSG_RESULT([$SED]) ])#AC_PROG_SED ])#m4_ifndef # Old name: AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([LT_AC_PROG_SED], []) # _LT_CHECK_SHELL_FEATURES # ------------------------ # Find out whether the shell is Bourne or XSI compatible, # or has some other useful features. m4_defun([_LT_CHECK_SHELL_FEATURES], [AC_MSG_CHECKING([whether the shell understands some XSI constructs]) # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes AC_MSG_RESULT([$xsi_shell]) _LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell']) AC_MSG_CHECKING([whether the shell understands "+="]) lt_shell_append=no ( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes AC_MSG_RESULT([$lt_shell_append]) _LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append']) if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi _LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac _LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl _LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl ])# _LT_CHECK_SHELL_FEATURES # _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY) # ------------------------------------------------------ # In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and # '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY. m4_defun([_LT_PROG_FUNCTION_REPLACE], [dnl { sed -e '/^$1 ()$/,/^} # $1 /c\ $1 ()\ {\ m4_bpatsubsts([$2], [$], [\\], [^\([ ]\)], [\\\1]) } # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: ]) # _LT_PROG_REPLACE_SHELLFNS # ------------------------- # Replace existing portable implementations of several shell functions with # equivalent extended shell implementations where those features are available.. m4_defun([_LT_PROG_REPLACE_SHELLFNS], [if test x"$xsi_shell" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl case ${1} in */*) func_dirname_result="${1%/*}${2}" ;; * ) func_dirname_result="${3}" ;; esac func_basename_result="${1##*/}"]) _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are # positional parameters, so assign one to ordinary parameter first. func_stripname_result=${3} func_stripname_result=${func_stripname_result#"${1}"} func_stripname_result=${func_stripname_result%"${2}"}]) _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl func_split_long_opt_name=${1%%=*} func_split_long_opt_arg=${1#*=}]) _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl func_split_short_opt_arg=${1#??} func_split_short_opt_name=${1%"$func_split_short_opt_arg"}]) _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl case ${1} in *.lo) func_lo2o_result=${1%.lo}.${objext} ;; *) func_lo2o_result=${1} ;; esac]) _LT_PROG_FUNCTION_REPLACE([func_xform], [ func_xform_result=${1%.*}.lo]) _LT_PROG_FUNCTION_REPLACE([func_arith], [ func_arith_result=$(( $[*] ))]) _LT_PROG_FUNCTION_REPLACE([func_len], [ func_len_result=${#1}]) fi if test x"$lt_shell_append" = xyes; then _LT_PROG_FUNCTION_REPLACE([func_append], [ eval "${1}+=\\${2}"]) _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl func_quote_for_eval "${2}" dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"]) # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then AC_MSG_WARN([Unable to substitute extended shell functions in $ofile]) fi ]) # _LT_PATH_CONVERSION_FUNCTIONS # ----------------------------- # Determine which file name conversion functions should be used by # func_to_host_file (and, implicitly, by func_to_host_path). These are needed # for certain cross-compile configurations and native mingw. m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], [AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_REQUIRE([AC_CANONICAL_BUILD])dnl AC_MSG_CHECKING([how to convert $build file names to $host format]) AC_CACHE_VAL(lt_cv_to_host_file_cmd, [case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac ]) to_host_file_cmd=$lt_cv_to_host_file_cmd AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) _LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], [0], [convert $build file names to $host format])dnl AC_MSG_CHECKING([how to convert $build file names to toolchain format]) AC_CACHE_VAL(lt_cv_to_tool_file_cmd, [#assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac ]) to_tool_file_cmd=$lt_cv_to_tool_file_cmd AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], [0], [convert $build files to toolchain format])dnl ])# _LT_PATH_CONVERSION_FUNCTIONS forked-daapd-0.19gcd/m4/ltoptions.m40000644000175000017500000002725611633141300016621 0ustar julienjulien# Helper functions for option handling. -*- Autoconf -*- # # Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, # Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 7 ltoptions.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) # _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) # ------------------------------------------ m4_define([_LT_MANGLE_OPTION], [[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) # _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) # --------------------------------------- # Set option OPTION-NAME for macro MACRO-NAME, and if there is a # matching handler defined, dispatch to it. Other OPTION-NAMEs are # saved as a flag. m4_define([_LT_SET_OPTION], [m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), _LT_MANGLE_DEFUN([$1], [$2]), [m4_warning([Unknown $1 option `$2'])])[]dnl ]) # _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) # ------------------------------------------------------------ # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. m4_define([_LT_IF_OPTION], [m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) # _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) # ------------------------------------------------------- # Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME # are set. m4_define([_LT_UNLESS_OPTIONS], [m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), [m4_define([$0_found])])])[]dnl m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 ])[]dnl ]) # _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) # ---------------------------------------- # OPTION-LIST is a space-separated list of Libtool options associated # with MACRO-NAME. If any OPTION has a matching handler declared with # LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about # the unknown option and exit. m4_defun([_LT_SET_OPTIONS], [# Set options m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), [_LT_SET_OPTION([$1], _LT_Option)]) m4_if([$1],[LT_INIT],[ dnl dnl Simply set some default values (i.e off) if boolean options were not dnl specified: _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no ]) _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no ]) dnl dnl If no reference was made to various pairs of opposing options, then dnl we run the default mode handler for the pair. For example, if neither dnl `shared' nor `disable-shared' was passed, we enable building of shared dnl archives by default: _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], [_LT_ENABLE_FAST_INSTALL]) ]) ])# _LT_SET_OPTIONS ## --------------------------------- ## ## Macros to handle LT_INIT options. ## ## --------------------------------- ## # _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) # ----------------------------------------- m4_define([_LT_MANGLE_DEFUN], [[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) # LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) # ----------------------------------------------- m4_define([LT_OPTION_DEFINE], [m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl ])# LT_OPTION_DEFINE # dlopen # ------ LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes ]) AU_DEFUN([AC_LIBTOOL_DLOPEN], [_LT_SET_OPTION([LT_INIT], [dlopen]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `dlopen' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) # win32-dll # --------- # Declare package support for building win32 dll's. LT_OPTION_DEFINE([LT_INIT], [win32-dll], [enable_win32_dll=yes case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) AC_CHECK_TOOL(AS, as, false) AC_CHECK_TOOL(DLLTOOL, dlltool, false) AC_CHECK_TOOL(OBJDUMP, objdump, false) ;; esac test -z "$AS" && AS=as _LT_DECL([], [AS], [1], [Assembler program])dnl test -z "$DLLTOOL" && DLLTOOL=dlltool _LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl test -z "$OBJDUMP" && OBJDUMP=objdump _LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl ])# win32-dll AU_DEFUN([AC_LIBTOOL_WIN32_DLL], [AC_REQUIRE([AC_CANONICAL_HOST])dnl _LT_SET_OPTION([LT_INIT], [win32-dll]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `win32-dll' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) # _LT_ENABLE_SHARED([DEFAULT]) # ---------------------------- # implement the --enable-shared flag, and supports the `shared' and # `disable-shared' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_SHARED], [m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([shared], [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) _LT_DECL([build_libtool_libs], [enable_shared], [0], [Whether or not to build shared libraries]) ])# _LT_ENABLE_SHARED LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) # Old names: AC_DEFUN([AC_ENABLE_SHARED], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) ]) AC_DEFUN([AC_DISABLE_SHARED], [_LT_SET_OPTION([LT_INIT], [disable-shared]) ]) AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_SHARED], []) dnl AC_DEFUN([AM_DISABLE_SHARED], []) # _LT_ENABLE_STATIC([DEFAULT]) # ---------------------------- # implement the --enable-static flag, and support the `static' and # `disable-static' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_STATIC], [m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([static], [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_static=]_LT_ENABLE_STATIC_DEFAULT) _LT_DECL([build_old_libs], [enable_static], [0], [Whether or not to build static libraries]) ])# _LT_ENABLE_STATIC LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) # Old names: AC_DEFUN([AC_ENABLE_STATIC], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) ]) AC_DEFUN([AC_DISABLE_STATIC], [_LT_SET_OPTION([LT_INIT], [disable-static]) ]) AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AM_ENABLE_STATIC], []) dnl AC_DEFUN([AM_DISABLE_STATIC], []) # _LT_ENABLE_FAST_INSTALL([DEFAULT]) # ---------------------------------- # implement the --enable-fast-install flag, and support the `fast-install' # and `disable-fast-install' LT_INIT options. # DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'. m4_define([_LT_ENABLE_FAST_INSTALL], [m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl AC_ARG_ENABLE([fast-install], [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], [p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac], [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) _LT_DECL([fast_install], [enable_fast_install], [0], [Whether or not to optimize for fast installation])dnl ])# _LT_ENABLE_FAST_INSTALL LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) # Old names: AU_DEFUN([AC_ENABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `fast-install' option into LT_INIT's first parameter.]) ]) AU_DEFUN([AC_DISABLE_FAST_INSTALL], [_LT_SET_OPTION([LT_INIT], [disable-fast-install]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `disable-fast-install' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) # _LT_WITH_PIC([MODE]) # -------------------- # implement the --with-pic flag, and support the `pic-only' and `no-pic' # LT_INIT options. # MODE is either `yes' or `no'. If omitted, it defaults to `both'. m4_define([_LT_WITH_PIC], [AC_ARG_WITH([pic], [AS_HELP_STRING([--with-pic], [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], [pic_mode="$withval"], [pic_mode=default]) test -z "$pic_mode" && pic_mode=m4_default([$1], [default]) _LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl ])# _LT_WITH_PIC LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) # Old name: AU_DEFUN([AC_LIBTOOL_PICMODE], [_LT_SET_OPTION([LT_INIT], [pic-only]) AC_DIAGNOSE([obsolete], [$0: Remove this warning and the call to _LT_SET_OPTION when you put the `pic-only' option into LT_INIT's first parameter.]) ]) dnl aclocal-1.4 backwards compatibility: dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) ## ----------------- ## ## LTDL_INIT Options ## ## ----------------- ## m4_define([_LTDL_MODE], []) LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], [m4_define([_LTDL_MODE], [nonrecursive])]) LT_OPTION_DEFINE([LTDL_INIT], [recursive], [m4_define([_LTDL_MODE], [recursive])]) LT_OPTION_DEFINE([LTDL_INIT], [subproject], [m4_define([_LTDL_MODE], [subproject])]) m4_define([_LTDL_TYPE], []) LT_OPTION_DEFINE([LTDL_INIT], [installable], [m4_define([_LTDL_TYPE], [installable])]) LT_OPTION_DEFINE([LTDL_INIT], [convenience], [m4_define([_LTDL_TYPE], [convenience])]) forked-daapd-0.19gcd/m4/ltsugar.m40000644000175000017500000001042411633141300016234 0ustar julienjulien# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. # Written by Gary V. Vaughan, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 6 ltsugar.m4 # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) # lt_join(SEP, ARG1, [ARG2...]) # ----------------------------- # Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their # associated separator. # Needed until we can rely on m4_join from Autoconf 2.62, since all earlier # versions in m4sugar had bugs. m4_define([lt_join], [m4_if([$#], [1], [], [$#], [2], [[$2]], [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) m4_define([_lt_join], [m4_if([$#$2], [2], [], [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) # lt_car(LIST) # lt_cdr(LIST) # ------------ # Manipulate m4 lists. # These macros are necessary as long as will still need to support # Autoconf-2.59 which quotes differently. m4_define([lt_car], [[$1]]) m4_define([lt_cdr], [m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], [$#], 1, [], [m4_dquote(m4_shift($@))])]) m4_define([lt_unquote], $1) # lt_append(MACRO-NAME, STRING, [SEPARATOR]) # ------------------------------------------ # Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'. # Note that neither SEPARATOR nor STRING are expanded; they are appended # to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). # No SEPARATOR is output if MACRO-NAME was previously undefined (different # than defined and empty). # # This macro is needed until we can rely on Autoconf 2.62, since earlier # versions of m4sugar mistakenly expanded SEPARATOR but not STRING. m4_define([lt_append], [m4_define([$1], m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) # lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) # ---------------------------------------------------------- # Produce a SEP delimited list of all paired combinations of elements of # PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list # has the form PREFIXmINFIXSUFFIXn. # Needed until we can rely on m4_combine added in Autoconf 2.62. m4_define([lt_combine], [m4_if(m4_eval([$# > 3]), [1], [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl [[m4_foreach([_Lt_prefix], [$2], [m4_foreach([_Lt_suffix], ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) # lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) # ----------------------------------------------------------------------- # Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited # by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. m4_define([lt_if_append_uniq], [m4_ifdef([$1], [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], [lt_append([$1], [$2], [$3])$4], [$5])], [lt_append([$1], [$2], [$3])$4])]) # lt_dict_add(DICT, KEY, VALUE) # ----------------------------- m4_define([lt_dict_add], [m4_define([$1($2)], [$3])]) # lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) # -------------------------------------------- m4_define([lt_dict_add_subkey], [m4_define([$1($2:$3)], [$4])]) # lt_dict_fetch(DICT, KEY, [SUBKEY]) # ---------------------------------- m4_define([lt_dict_fetch], [m4_ifval([$3], m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) # lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) # ----------------------------------------------------------------- m4_define([lt_if_dict_fetch], [m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], [$5], [$6])]) # lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) # -------------------------------------------------------------- m4_define([lt_dict_filter], [m4_if([$5], [], [], [lt_join(m4_quote(m4_default([$4], [[, ]])), lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl ]) forked-daapd-0.19gcd/m4/ltversion.m40000644000175000017500000000125611633141300016603 0ustar julienjulien# ltversion.m4 -- version numbers -*- Autoconf -*- # # Copyright (C) 2004 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004 # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # @configure_input@ # serial 3293 ltversion.m4 # This file is part of GNU Libtool m4_define([LT_PACKAGE_VERSION], [2.4]) m4_define([LT_PACKAGE_REVISION], [1.3293]) AC_DEFUN([LTVERSION_VERSION], [macro_version='2.4' macro_revision='1.3293' _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) _LT_DECL(, macro_revision, 0) ]) forked-daapd-0.19gcd/m4/lt~obsolete.m40000644000175000017500000001375611633141300017140 0ustar julienjulien# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- # # Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc. # Written by Scott James Remnant, 2004. # # This file is free software; the Free Software Foundation gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # serial 5 lt~obsolete.m4 # These exist entirely to fool aclocal when bootstrapping libtool. # # In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN) # which have later been changed to m4_define as they aren't part of the # exported API, or moved to Autoconf or Automake where they belong. # # The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN # in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us # using a macro with the same name in our local m4/libtool.m4 it'll # pull the old libtool.m4 in (it doesn't see our shiny new m4_define # and doesn't know about Autoconf macros at all.) # # So we provide this file, which has a silly filename so it's always # included after everything else. This provides aclocal with the # AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything # because those macros already exist, or will be overwritten later. # We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. # # Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. # Yes, that means every name once taken will need to remain here until # we give up compatibility with versions before 1.7, at which point # we need to keep only those names which we still refer to. # This is to help aclocal find these macros, as it can't see m4_define. AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) forked-daapd-0.19gcd/sqlext/0000775000175000017500000000000011633141304015316 5ustar julienjulienforked-daapd-0.19gcd/sqlext/Makefile.am0000664000175000017500000000030611633141135017353 0ustar julienjulienpkglib_LTLIBRARIES = forked-daapd-sqlext.la forked_daapd_sqlext_la_SOURCES = sqlext.c forked_daapd_sqlext_la_LDFLAGS = -avoid-version -module -shared forked_daapd_sqlext_la_LIBADD = @LIBUNISTRING@ forked-daapd-0.19gcd/sqlext/sqlext.c0000664000175000017500000001354311633141135017012 0ustar julienjulien/* * Copyright (C) 2009-2010 Julien BLACHE * Copyright (C) 2010 Kai Elwert * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include SQLITE_EXTENSION_INIT1 /* * MurmurHash2, 64-bit versions, by Austin Appleby * * Code released under the public domain, as per * * as of 2010-01-03. */ #if SIZEOF_VOID_P == 8 /* 64bit platforms */ static uint64_t murmur_hash64(const void *key, int len, uint32_t seed) { const int r = 47; const uint64_t m = 0xc6a4a7935bd1e995; const uint64_t *data; const uint64_t *end; const unsigned char *data_tail; uint64_t h; uint64_t k; h = seed ^ (len * m); data = (const uint64_t *)key; end = data + (len / 8); while (data != end) { k = *data++; k *= m; k ^= k >> r; k *= m; h ^= k; h *= m; } data_tail = (const unsigned char *)data; switch (len & 7) { case 7: h ^= (uint64_t)(data_tail[6]) << 48; case 6: h ^= (uint64_t)(data_tail[5]) << 40; case 5: h ^= (uint64_t)(data_tail[4]) << 32; case 4: h ^= (uint64_t)(data_tail[3]) << 24; case 3: h ^= (uint64_t)(data_tail[2]) << 16; case 2: h ^= (uint64_t)(data_tail[1]) << 8; case 1: h ^= (uint64_t)(data_tail[0]); h *= m; } h ^= h >> r; h *= m; h ^= h >> r; return h; } #elif SIZEOF_VOID_P == 4 /* 32bit platforms */ static uint64_t murmur_hash64(const void *key, int len, uint32_t seed) { const int r = 24; const uint32_t m = 0x5bd1e995; const uint32_t *data; const unsigned char *data_tail; uint32_t k1; uint32_t h1; uint32_t k2; uint32_t h2; uint64_t h; h1 = seed ^ len; h2 = 0; data = (const uint32_t *)key; while (len >= 8) { k1 = *data++; k1 *= m; k1 ^= k1 >> r; k1 *= m; h1 *= m; h1 ^= k1; k2 = *data++; k2 *= m; k2 ^= k2 >> r; k2 *= m; h2 *= m; h2 ^= k2; len -= 8; } if (len >= 4) { k1 = *data++; k1 *= m; k1 ^= k1 >> r; k1 *= m; h1 *= m; h1 ^= k1; len -= 4; } data_tail = (const unsigned char *)data; switch(len) { case 3: h2 ^= (uint32_t)(data_tail[2]) << 16; case 2: h2 ^= (uint32_t)(data_tail[1]) << 8; case 1: h2 ^= (uint32_t)(data_tail[0]); h2 *= m; }; h1 ^= h2 >> 18; h1 *= m; h2 ^= h1 >> 22; h2 *= m; h1 ^= h2 >> 17; h1 *= m; h2 ^= h1 >> 19; h2 *= m; h = h1; h = (h << 32) | h2; return h; } #else # error Platform not supported #endif static void sqlext_daap_songalbumid_xfunc(sqlite3_context *pv, int n, sqlite3_value **ppv) { const char *album_artist; const char *album; char *hashbuf; sqlite3_int64 result; if (n != 2) { sqlite3_result_error(pv, "daap_songalbumid() requires 2 parameters, album_artist and album", -1); return; } if ((sqlite3_value_type(ppv[0]) != SQLITE_TEXT) || (sqlite3_value_type(ppv[1]) != SQLITE_TEXT)) { sqlite3_result_error(pv, "daap_songalbumid() requires 2 text parameters", -1); return; } album_artist = (const char *)sqlite3_value_text(ppv[0]); album = (const char *)sqlite3_value_text(ppv[1]); hashbuf = sqlite3_mprintf("%s==%s", (album_artist) ? album_artist : "", (album) ? album : ""); if (!hashbuf) { sqlite3_result_error(pv, "daap_songalbumid() out of memory for hashbuf", -1); return; } /* Limit hash length to 63 bits, due to signed type in sqlite */ result = murmur_hash64(hashbuf, strlen(hashbuf), 0) >> 1; sqlite3_free(hashbuf); sqlite3_result_int64(pv, result); } static int sqlext_daap_unicode_xcollation(void *notused, int llen, const void *left, int rlen, const void *right) { ucs4_t lch; ucs4_t rch; int lalpha; int ralpha; int rpp; int ret; /* Extract first utf-8 character */ ret = u8_mbtoucr(&lch, (const uint8_t *)left, llen); if (ret < 0) return 0; ret = u8_mbtoucr(&rch, (const uint8_t *)right, rlen); if (ret < 0) return 0; /* Ensure digits and other non-alphanum sort to tail */ lalpha = uc_is_alpha(lch); ralpha = uc_is_alpha(rch); if (!lalpha && ralpha) return 1; else if (lalpha && !ralpha) return -1; /* Compare case and normalization insensitive */ ret = u8_casecmp((const uint8_t *)left, llen, (const uint8_t*)right, rlen, NULL, UNINORM_NFD, &rpp); if (ret < 0) return 0; return rpp; } int sqlite3_extension_init(sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi) { SQLITE_EXTENSION_INIT2(pApi); int ret; ret = sqlite3_create_function(db, "daap_songalbumid", 2, SQLITE_UTF8, NULL, sqlext_daap_songalbumid_xfunc, NULL, NULL); if (ret != SQLITE_OK) { if (pzErrMsg) *pzErrMsg = sqlite3_mprintf("Could not create daap_songalbumid function: %s\n", sqlite3_errmsg(db)); return -1; } ret = sqlite3_create_collation(db, "DAAP", SQLITE_UTF8, NULL, sqlext_daap_unicode_xcollation); if (ret != SQLITE_OK) { if (pzErrMsg) *pzErrMsg = sqlite3_mprintf("Could not create sqlite3 custom collation DAAP: %s\n", sqlite3_errmsg(db)); return -1; } return 0; } forked-daapd-0.19gcd/sqlext/Makefile.in0000664000175000017500000004341011633141304017365 0ustar julienjulien# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = sqlext DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/blocks.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/libunistring.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__installdirs = "$(DESTDIR)$(pkglibdir)" LTLIBRARIES = $(pkglib_LTLIBRARIES) forked_daapd_sqlext_la_DEPENDENCIES = am_forked_daapd_sqlext_la_OBJECTS = sqlext.lo forked_daapd_sqlext_la_OBJECTS = $(am_forked_daapd_sqlext_la_OBJECTS) forked_daapd_sqlext_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ $(forked_daapd_sqlext_la_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(forked_daapd_sqlext_la_SOURCES) DIST_SOURCES = $(forked_daapd_sqlext_la_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALSA_CFLAGS = @ALSA_CFLAGS@ ALSA_LIBS = @ALSA_LIBS@ AMTAR = @AMTAR@ ANTLR = @ANTLR@ ANTLR3C_LIBS = @ANTLR3C_LIBS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ CBLOCKS_FLAGS = @CBLOCKS_FLAGS@ CBLOCKS_LIBS = @CBLOCKS_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFUSE_CFLAGS = @CONFUSE_CFLAGS@ CONFUSE_LIBS = @CONFUSE_LIBS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FLAC_CFLAGS = @FLAC_CFLAGS@ FLAC_LIBS = @FLAC_LIBS@ GPERF = @GPERF@ GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@ GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@ GPG_ERROR_LIBS = @GPG_ERROR_LIBS@ GREP = @GREP@ HAVE_LIBUNISTRING = @HAVE_LIBUNISTRING@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBAVL_LIBS = @LIBAVL_LIBS@ LIBAV_CFLAGS = @LIBAV_CFLAGS@ LIBAV_LIBS = @LIBAV_LIBS@ LIBDISPATCH_LIBS = @LIBDISPATCH_LIBS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBPLIST_CFLAGS = @LIBPLIST_CFLAGS@ LIBPLIST_LIBS = @LIBPLIST_LIBS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBUNISTRING = @LIBUNISTRING@ LIBUNISTRING_PREFIX = @LIBUNISTRING_PREFIX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LTLIBUNISTRING = @LTLIBUNISTRING@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINIXML_CFLAGS = @MINIXML_CFLAGS@ MINIXML_LIBS = @MINIXML_LIBS@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OSS4CPPFLAGS = @OSS4CPPFLAGS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ TAGLIB_CFLAGS = @TAGLIB_CFLAGS@ TAGLIB_LIBS = @TAGLIB_LIBS@ TRE_CFLAGS = @TRE_CFLAGS@ TRE_LIBS = @TRE_LIBS@ VERSION = @VERSION@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ pkglib_LTLIBRARIES = forked-daapd-sqlext.la forked_daapd_sqlext_la_SOURCES = sqlext.c forked_daapd_sqlext_la_LDFLAGS = -avoid-version -module -shared forked_daapd_sqlext_la_LIBADD = @LIBUNISTRING@ all: all-am .SUFFIXES: .SUFFIXES: .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu sqlext/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu sqlext/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-pkglibLTLIBRARIES: $(pkglib_LTLIBRARIES) @$(NORMAL_INSTALL) test -z "$(pkglibdir)" || $(MKDIR_P) "$(DESTDIR)$(pkglibdir)" @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ list2=; for p in $$list; do \ if test -f $$p; then \ list2="$$list2 $$p"; \ else :; fi; \ done; \ test -z "$$list2" || { \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkglibdir)'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkglibdir)"; \ } uninstall-pkglibLTLIBRARIES: @$(NORMAL_UNINSTALL) @list='$(pkglib_LTLIBRARIES)'; test -n "$(pkglibdir)" || list=; \ for p in $$list; do \ $(am__strip_dir) \ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkglibdir)/$$f'"; \ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkglibdir)/$$f"; \ done clean-pkglibLTLIBRARIES: -test -z "$(pkglib_LTLIBRARIES)" || rm -f $(pkglib_LTLIBRARIES) @list='$(pkglib_LTLIBRARIES)'; for p in $$list; do \ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ test "$$dir" != "$$p" || dir=.; \ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done forked-daapd-sqlext.la: $(forked_daapd_sqlext_la_OBJECTS) $(forked_daapd_sqlext_la_DEPENDENCIES) $(forked_daapd_sqlext_la_LINK) -rpath $(pkglibdir) $(forked_daapd_sqlext_la_OBJECTS) $(forked_daapd_sqlext_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sqlext.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LTLIBRARIES) installdirs: for dir in "$(DESTDIR)$(pkglibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-libtool clean-pkglibLTLIBRARIES \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-pkglibLTLIBRARIES install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-pkglibLTLIBRARIES .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-pkglibLTLIBRARIES ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-pkglibLTLIBRARIES \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-pkglibLTLIBRARIES # 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: forked-daapd-0.19gcd/src/0000775000175000017500000000000011633141323014566 5ustar julienjulienforked-daapd-0.19gcd/src/.gitignore0000664000175000017500000000023011633141135016552 0ustar julienjulienforked-daapd *.tokens *Lexer.[ch] *Parser.[ch] DAAP2SQL.[ch] RSP2SQL.[ch] *.u daap_query_hash.c rsp_query_hash.c dacp_prop_hash.c dmap_fields_hash.c forked-daapd-0.19gcd/src/DAAP.g0000664000175000017500000000326511633141135015452 0ustar julienjulien/* * Copyright (C) 2009-2010 Julien BLACHE * * 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 */ grammar DAAP; options { output = AST; ASTLabelType = pANTLR3_BASE_TREE; language = C; } query : expr NEWLINE? EOF -> expr ; expr : aexpr (OPOR^ aexpr)* ; aexpr : crit (OPAND^ crit)* ; crit : LPAR expr RPAR -> expr | STR ; QUOTE : '\''; LPAR : '('; RPAR : ')'; OPAND : '+'; OPOR : ','; NEWLINE : '\r'? '\n'; /* Unescaping adapted from (ported to the C runtime) */ STR @init{ pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory); } : QUOTE ( reg = ~('\\' | '\'') { unesc->addc(unesc, reg); } | esc = ESCAPED { unesc->appendS(unesc, GETTEXT()); } )+ QUOTE { SETTEXT(unesc); }; fragment ESCAPED : '\\' ( '\\' { SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\")); } | '\'' { SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\'")); } ) ; forked-daapd-0.19gcd/src/DAAP2SQL.g0000664000175000017500000001677611633141135016127 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * * 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 */ tree grammar DAAP2SQL; options { tokenVocab = DAAP; ASTLabelType = pANTLR3_BASE_TREE; language = C; } @header { #include #include #include #include #include #include "logger.h" #include "db.h" #include "daap_query.h" } @members { struct dmap_query_field_map { char *dmap_field; char *db_col; int as_int; }; /* gperf static hash, daap_query.gperf */ #include "daap_query_hash.c" } query returns [ pANTLR3_STRING result ] @init { $result = NULL; } : e = expr { if (!$e.valid) { $result = NULL; } else { $result = $e.result->factory->newRaw($e.result->factory); $result->append8($result, "("); $result->appendS($result, $e.result); $result->append8($result, ")"); } } ; expr returns [ pANTLR3_STRING result, int valid ] @init { $result = NULL; $valid = 1; } : ^(OPAND a = expr b = expr) { if (!$a.valid || !$b.valid) { $valid = 0; } else { $result = $a.result->factory->newRaw($a.result->factory); $result->append8($result, "("); $result->appendS($result, $a.result); $result->append8($result, " AND "); $result->appendS($result, $b.result); $result->append8($result, ")"); } } | ^(OPOR a = expr b = expr) { if (!$a.valid || !$b.valid) { $valid = 0; } else { $result = $a.result->factory->newRaw($a.result->factory); $result->append8($result, "("); $result->appendS($result, $a.result); $result->append8($result, " OR "); $result->appendS($result, $b.result); $result->append8($result, ")"); } } | STR { pANTLR3_STRING str; pANTLR3_UINT8 field; pANTLR3_UINT8 val; pANTLR3_UINT8 escaped; ANTLR3_UINT8 op; int neg_op; const struct dmap_query_field_map *dqfm; char *end; long long llval; escaped = NULL; $result = $STR.text->factory->newRaw($STR.text->factory); str = $STR.text->toUTF8($STR.text); /* NOTE: the lexer delivers the string without quotes which may not be obvious from the grammar due to embedded code */ /* Make daap.songalbumid:0 a no-op */ if (strcmp((char *)str->chars, "daap.songalbumid:0") == 0) { $result->append8($result, "1 = 1"); goto STR_out; } field = str->chars; val = field; while ((*val != '\0') && ((*val == '.') || ((*val >= 'a') && (*val <= 'z')) || ((*val >= 'A') && (*val <= 'Z')) || ((*val >= '0') && (*val <= '9')))) { val++; } if (*field == '\0') { DPRINTF(E_LOG, L_DAAP, "No field name found in clause '\%s'\n", field); $valid = 0; goto STR_result_valid_0; /* ABORT */ } if (*val == '\0') { DPRINTF(E_LOG, L_DAAP, "No operator found in clause '\%s'\n", field); $valid = 0; goto STR_result_valid_0; /* ABORT */ } op = *val; *val = '\0'; val++; if (op == '!') { if (*val == '\0') { DPRINTF(E_LOG, L_DAAP, "Negation found but operator missing in clause '\%s\%c'\n", field, op); $valid = 0; goto STR_result_valid_0; /* ABORT */ } neg_op = 1; op = *val; val++; } else neg_op = 0; /* Lookup DMAP field in the query field map */ dqfm = daap_query_field_lookup((char *)field, strlen((char *)field)); if (!dqfm) { DPRINTF(E_LOG, L_DAAP, "DMAP field '\%s' is not a valid field in queries\n", field); $valid = 0; goto STR_result_valid_0; /* ABORT */ } /* Empty values OK for string fields, NOK for integer */ if (*val == '\0') { if (dqfm->as_int) { DPRINTF(E_LOG, L_DAAP, "No value given in clause '\%s\%s\%c'\n", field, (neg_op) ? "!" : "", op); $valid = 0; goto STR_result_valid_0; /* ABORT */ } /* Need to check against NULL too */ if (op == ':') $result->append8($result, "("); } $result->append8($result, dqfm->db_col); /* Int field: check integer conversion */ if (dqfm->as_int) { errno = 0; llval = strtoll((const char *)val, &end, 10); if (((errno == ERANGE) && ((llval == LLONG_MAX) || (llval == LLONG_MIN))) || ((errno != 0) && (llval == 0))) { DPRINTF(E_LOG, L_DAAP, "Value '\%s' in clause '\%s\%s\%c\%s' does not convert to an integer type\n", val, field, (neg_op) ? "!" : "", op, val); $valid = 0; goto STR_result_valid_0; /* ABORT */ } if (end == (char *)val) { DPRINTF(E_LOG, L_DAAP, "Value '\%s' in clause '\%s\%s\%c\%s' does not represent an integer value\n", val, field, (neg_op) ? "!" : "", op, val); $valid = 0; goto STR_result_valid_0; /* ABORT */ } *end = '\0'; /* Cut out potential garbage - we're being kind */ } /* String field: escape string, check for '*' */ else { if (op != ':') { DPRINTF(E_LOG, L_DAAP, "Operation '\%c' not valid for string values\n", op); $valid = 0; goto STR_result_valid_0; /* ABORT */ } escaped = (pANTLR3_UINT8)db_escape_string((char *)val); if (!escaped) { DPRINTF(E_LOG, L_DAAP, "Could not escape value\n"); $valid = 0; goto STR_result_valid_0; /* ABORT */ } val = escaped; if (val[0] == '*') { op = '\%'; val[0] = '\%'; } if (val[strlen((char *)val) - 1] == '*') { op = '\%'; val[strlen((char *)val) - 1] = '\%'; } } switch(op) { case ':': if (neg_op) $result->append8($result, " <> "); else $result->append8($result, " = "); break; case '+': if (neg_op) $result->append8($result, " <= "); else $result->append8($result, " > "); break; case '-': if (neg_op) $result->append8($result, " >= "); else $result->append8($result, " < "); break; case '\%': $result->append8($result, " LIKE "); break; default: if (neg_op) DPRINTF(E_LOG, L_DAAP, "Missing or unknown operator '\%c' in clause '\%s!\%c\%s'\n", op, field, op, val); else DPRINTF(E_LOG, L_DAAP, "Unknown operator '\%c' in clause '\%s\%c\%s'\n", op, field, op, val); $valid = 0; goto STR_result_valid_0; /* ABORT */ break; } if (!dqfm->as_int) $result->append8($result, "'"); $result->append8($result, (const char *)val); if (!dqfm->as_int) $result->append8($result, "'"); /* For empty string value, we need to check against NULL too */ if ((*val == '\0') && (op == ':')) { if (neg_op) $result->append8($result, " AND "); else $result->append8($result, " OR "); $result->append8($result, dqfm->db_col); if (neg_op) $result->append8($result, " IS NOT NULL"); else $result->append8($result, " IS NULL"); $result->append8($result, ")"); } STR_result_valid_0: /* bail out label */ ; if (escaped) free(escaped); STR_out: /* get out of here */ ; } ; forked-daapd-0.19gcd/src/Makefile.am0000664000175000017500000000640411633141135016627 0ustar julienjulien sbin_PROGRAMS = forked-daapd if COND_FLAC FLACSRC=scan-flac.c endif if COND_MUSEPACK MUSEPACKSRC=scan-mpc.c endif if COND_ITUNES ITUNESSRC=filescanner_itunes.c endif if COND_ALSA ALSASRC=laudio_alsa.c endif if COND_OSS4 OSS4SRC=laudio_oss4.c endif if COND_AVIO AVIO_SRC=avio_evbuffer.c avio_evbuffer.h else FFURL_SRC=ffmpeg_url_evbuffer.c ffmpeg_url_evbuffer.h endif GPERF_FILES = \ daap_query.gperf \ rsp_query.gperf \ dacp_prop.gperf \ dmap_fields.gperf GPERF_PRODUCTS = \ daap_query_hash.c \ rsp_query_hash.c \ dacp_prop_hash.c \ dmap_fields_hash.c ANTLR_GRAMMARS = \ RSP.g RSP2SQL.g \ DAAP.g DAAP2SQL.g ANTLR_SOURCES = \ RSPLexer.c RSPLexer.h RSPParser.c RSPParser.h \ RSP2SQL.c RSP2SQL.h \ DAAPLexer.c DAAPLexer.h DAAPParser.c DAAPParser.h \ DAAP2SQL.c DAAP2SQL.h ANTLR_PRODUCTS = forked_daapd_CPPFLAGS = -D_GNU_SOURCE \ -DDATADIR="\"$(pkgdatadir)\"" -DCONFDIR="\"$(sysconfdir)\"" \ -DSTATEDIR="\"$(localstatedir)\"" -DPKGLIBDIR="\"$(pkglibdir)\"" \ @OSS4CPPFLAGS@ forked_daapd_CFLAGS = @CBLOCKS_FLAGS@ \ @ZLIB_CFLAGS@ @AVAHI_CFLAGS@ @SQLITE3_CFLAGS@ @LIBAV_CFLAGS@ \ @CONFUSE_CFLAGS@ @TAGLIB_CFLAGS@ @MINIXML_CFLAGS@ @LIBPLIST_CFLAGS@ \ @LIBGCRYPT_CFLAGS@ @GPG_ERROR_CFLAGS@ @ALSA_CFLAGS@ @TRE_CFLAGS@ forked_daapd_LDADD = -lrt \ @ZLIB_LIBS@ @AVAHI_LIBS@ @SQLITE3_LIBS@ @LIBAV_LIBS@ \ @CONFUSE_LIBS@ @FLAC_LIBS@ @TAGLIB_LIBS@ \ @LIBAVL_LIBS@ @MINIXML_LIBS@ @ANTLR3C_LIBS@ @LIBPLIST_LIBS@ \ @LIBGCRYPT_LIBS@ @GPG_ERROR_LIBS@ @ALSA_LIBS@ @LIBUNISTRING@ \ @LIBDISPATCH_LIBS@ @CBLOCKS_LIBS@ @TRE_LIBS@ forked_daapd_SOURCES = main.c \ db.c db.h \ logger.c logger.h \ conffile.c conffile.h \ filescanner.c filescanner.h \ filescanner_ffmpeg.c filescanner_urlfile.c filescanner_m3u.c $(ITUNESSRC) \ mdns_avahi.c mdns.h \ network.c network.h \ remote_pairing.c remote_pairing.h \ $(FFURL_SRC) $(AVIO_SRC) \ http.c http.h \ httpd.c httpd.h \ httpd_rsp.c httpd_rsp.h \ httpd_daap.c httpd_daap.h \ httpd_dacp.c httpd_dacp.h \ dmap_common.c dmap_common.h \ transcode.c transcode.h \ artwork.c artwork.h \ misc.c misc.h \ rng.c rng.h \ rsp_query.c rsp_query.h \ daap_query.c daap_query.h \ player.c player.h \ $(ALSASRC) $(OSS4SRC) laudio.h \ raop.c raop.h \ evbuffer/evbuffer.c evbuffer/evbuffer.h \ scan-wma.c \ $(FLACSRC) $(MUSEPACKSRC) nodist_forked_daapd_SOURCES = \ $(ANTLR_SOURCES) BUILT_SOURCES = \ $(GPERF_PRODUCTS) EXTRA_DIST = \ $(ANTLR_GRAMMARS) \ scan-mpc.c \ scan-flac.c CLEANFILES = \ $(GPERF_PRODUCTS) # gperf construction rules %_hash.c: %.gperf if $(GPERF) $< > $@.tmp; then \ mv $@.tmp $@; \ elif $(GPERF) --version >/dev/null 2>&1; then \ rm $@.tmp; \ exit 1; \ else \ rm $@.tmp; \ touch $@; \ fi # Support for building the parsers when ANTLR3 is available if COND_ANTLR SUFFIXES = .g .u %.tokens %.c %Lexer.c %Parser.c %Lexer.h %Parser.h %.h: %.g $(ANTLR) $(ANTLR_OPTIONS) $< %.u: %.g $(ANTLR) -depend $< > $@ @echo -n "ANTLR_PRODUCTS += " > $@.tmp @grep : $@ | cut -d : -f 1 | tr -d ' ' | { while read f; do test "$$f" != "$<" && echo -n "$$f "; done } >> $@.tmp @cat $@.tmp >> $@ @rm $@.tmp BUILT_SOURCES += $(ANTLR_SOURCES) CLEANFILES += \ $(ANTLR_PRODUCTS) \ $(ANTLR_GRAMMARS:.g=.u) else !COND_ANTLR DISTCLEANFILES = \ $(ANTLR_PRODUCTS) \ $(ANTLR_GRAMMARS:.g=.u) endif -include $(ANTLR_GRAMMARS:.g=.u) forked-daapd-0.19gcd/src/RSP.g0000664000175000017500000000565311633141135015414 0ustar julienjulien/* * Copyright (C) 2009-2010 Julien BLACHE * * 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 */ grammar RSP; options { output = AST; ASTLabelType = pANTLR3_BASE_TREE; language = C; } query : expr NEWLINE? EOF -> expr ; expr : aexpr (OR^ aexpr)* ; aexpr : crit (AND^ crit)* ; crit : LPAR expr RPAR -> expr | strcrit | intcrit | datecrit ; strcrit : FIELD strop STR -> ^(strop FIELD STR) | FIELD NOT strop STR -> ^(NOT ^(strop FIELD STR)) ; strop : EQUAL | INCLUDES | STARTSW | ENDSW ; intcrit : FIELD intop INT -> ^(intop FIELD INT) | FIELD NOT intop INT -> ^(NOT ^(intop FIELD INT)) ; intop : EQUAL | LESS | GREATER | LTE | GTE ; datecrit: FIELD dateop datespec -> ^(dateop FIELD datespec) ; dateop : BEFORE | AFTER ; datespec: dateref | INT dateintval dateop dateref -> ^(dateop dateref INT dateintval) ; dateref : DATE | TODAY ; dateintval : DAY | WEEK | MONTH | YEAR ; QUOTE : '"'; LPAR : '('; RPAR : ')'; AND : 'and'; OR : 'or'; NOT : '!'; /* Both string & int */ EQUAL : '='; /* String */ INCLUDES: 'includes'; STARTSW : 'startswith'; ENDSW : 'endswith'; /* Int */ GREATER : '>'; LESS : '<'; GTE : '>='; LTE : '<='; /* Date */ BEFORE : 'before'; AFTER : 'after'; DAY : 'day' | 'days'; WEEK : 'week' | 'weeks'; MONTH : 'month' | 'months'; YEAR : 'year' | 'years'; TODAY : 'today'; NEWLINE : '\r'? '\n'; WS : (' ' | '\t') { $channel = HIDDEN; }; FIELD : 'a'..'z' ('a'..'z' | '_')* 'a'..'z'; INT : DIGIT19 DIGIT09*; /* YYYY-MM-DD */ DATE : DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ('0' DIGIT19 | '1' '0'..'2') '-' ('0' DIGIT19 | '1'..'2' DIGIT09 | '3' '0'..'1'); /* Unescaping adapted from (ported to the C runtime) */ STR @init{ pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory); } : QUOTE ( reg = ~('\\' | '"') { unesc->addc(unesc, reg); } | esc = ESCAPED { unesc->appendS(unesc, GETTEXT()); } )+ QUOTE { SETTEXT(unesc); } ; fragment ESCAPED : '\\' ( '\\' { SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\")); } | '"' { SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\"")); } ) ; fragment DIGIT09 : '0'..'9'; fragment DIGIT19 : '1'..'9'; forked-daapd-0.19gcd/src/RSP2SQL.g0000664000175000017500000002375211633141135016056 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * * 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 */ tree grammar RSP2SQL; options { tokenVocab = RSP; ASTLabelType = pANTLR3_BASE_TREE; language = C; } @header { /* Needs #define _GNU_SOURCE for strptime() */ #include #include #include #include #include "logger.h" #include "db.h" #include "misc.h" #include "rsp_query.h" } @members { #define RSP_TYPE_STRING 0 #define RSP_TYPE_INT 1 #define RSP_TYPE_DATE 2 struct rsp_query_field_map { char *rsp_field; int field_type; /* RSP fields are named after the DB columns - or vice versa */ }; /* gperf static hash, rsp_query.gperf */ #include "rsp_query_hash.c" } query returns [ pANTLR3_STRING result ] @init { $result = NULL; } : e = expr { if (!$e.valid) { $result = NULL; } else { $result = $e.result->factory->newRaw($e.result->factory); $result->append8($result, "("); $result->appendS($result, $e.result); $result->append8($result, ")"); } } ; expr returns [ pANTLR3_STRING result, int valid ] @init { $result = NULL; $valid = 1; } : ^(AND a = expr b = expr) { if (!$a.valid || !$b.valid) { $valid = 0; } else { $result = $a.result->factory->newRaw($a.result->factory); $result->append8($result, "("); $result->appendS($result, $a.result); $result->append8($result, " AND "); $result->appendS($result, $b.result); $result->append8($result, ")"); } } | ^(OR a = expr b = expr) { if (!$a.valid || !$b.valid) { $valid = 0; } else { $result = $a.result->factory->newRaw($a.result->factory); $result->append8($result, "("); $result->appendS($result, $a.result); $result->append8($result, " OR "); $result->appendS($result, $b.result); $result->append8($result, ")"); } } | c = strcrit { $valid = $c.valid; $result = $c.result; } | ^(NOT c = strcrit) { if (!$c.valid) { $valid = 0; } else { $result = $c.result->factory->newRaw($c.result->factory); $result->append8($result, "(NOT "); $result->appendS($result, $c.result); $result->append8($result, ")"); } } | i = intcrit { $valid = $i.valid; $result = $i.result; } | ^(NOT i = intcrit) { if (!$i.valid) { $valid = 0; } else { $result = $i.result->factory->newRaw($i.result->factory); $result->append8($result, "(NOT "); $result->appendS($result, $i.result); $result->append8($result, ")"); } } | d = datecrit { $valid = $d.valid; $result = $d.result; } ; strcrit returns [ pANTLR3_STRING result, int valid ] @init { $result = NULL; $valid = 1; } : ^(o = strop f = FIELD s = STR) { char *op; const struct rsp_query_field_map *rqfp; pANTLR3_STRING field; char *escaped; ANTLR3_UINT32 optok; escaped = NULL; op = NULL; optok = $o.op->getType($o.op); switch (optok) { case EQUAL: op = " = "; break; case INCLUDES: case STARTSW: case ENDSW: op = " LIKE "; break; } field = $f->getText($f); /* Field lookup */ rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars)); if (!rqfp) { DPRINTF(E_LOG, L_RSP, "Field '\%s' is not a valid field in queries\n", field->chars); $valid = 0; goto strcrit_valid_0; /* ABORT */ } /* Check field type */ if (rqfp->field_type != RSP_TYPE_STRING) { DPRINTF(E_LOG, L_RSP, "Field '\%s' is not a string field\n", field->chars); $valid = 0; goto strcrit_valid_0; /* ABORT */ } escaped = db_escape_string((char *)$s->getText($s)->chars); if (!escaped) { DPRINTF(E_LOG, L_RSP, "Could not escape value\n"); $valid = 0; goto strcrit_valid_0; /* ABORT */ } $result = field->factory->newRaw(field->factory); $result->append8($result, "f."); $result->appendS($result, field); $result->append8($result, op); $result->append8($result, "'"); if ((optok == INCLUDES) || (optok == STARTSW)) $result->append8($result, "\%"); $result->append8($result, escaped); if ((optok == INCLUDES) || (optok == ENDSW)) $result->append8($result, "\%"); $result->append8($result, "'"); strcrit_valid_0: ; if (escaped) free(escaped); } ; strop returns [ pANTLR3_COMMON_TOKEN op ] @init { $op = NULL; } : n = EQUAL { $op = $n->getToken($n); } | n = INCLUDES { $op = $n->getToken($n); } | n = STARTSW { $op = $n->getToken($n); } | n = ENDSW { $op = $n->getToken($n); } ; intcrit returns [ pANTLR3_STRING result, int valid ] @init { $result = NULL; $valid = 1; } : ^(o = intop f = FIELD i = INT) { char *op; const struct rsp_query_field_map *rqfp; pANTLR3_STRING field; op = NULL; switch ($o.op->getType($o.op)) { case EQUAL: op = " = "; break; case LESS: op = " < "; break; case GREATER: op = " > "; break; case LTE: op = " <= "; break; case GTE: op = " >= "; break; } field = $f->getText($f); /* Field lookup */ rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars)); if (!rqfp) { DPRINTF(E_LOG, L_RSP, "Field '\%s' is not a valid field in queries\n", field->chars); $valid = 0; goto intcrit_valid_0; /* ABORT */ } /* Check field type */ if (rqfp->field_type != RSP_TYPE_INT) { DPRINTF(E_LOG, L_RSP, "Field '\%s' is not an integer field\n", field->chars); $valid = 0; goto intcrit_valid_0; /* ABORT */ } $result = field->factory->newRaw(field->factory); $result->append8($result, "f."); $result->appendS($result, field); $result->append8($result, op); $result->appendS($result, $i->getText($i)); intcrit_valid_0: ; } ; intop returns [ pANTLR3_COMMON_TOKEN op ] @init { $op = NULL; } : n = EQUAL { $op = $n->getToken($n); } | n = LESS { $op = $n->getToken($n); } | n = GREATER { $op = $n->getToken($n); } | n = LTE { $op = $n->getToken($n); } | n = GTE { $op = $n->getToken($n); } ; datecrit returns [ pANTLR3_STRING result, int valid ] @init { $result = NULL; $valid = 1; } : ^(o = dateop f = FIELD d = datespec) { char *op; const struct rsp_query_field_map *rqfp; pANTLR3_STRING field; char buf[32]; int ret; op = NULL; switch ($o.op->getType($o.op)) { case BEFORE: op = " < "; break; case AFTER: op = " > "; break; } field = $f->getText($f); /* Field lookup */ rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars)); if (!rqfp) { DPRINTF(E_LOG, L_RSP, "Field '\%s' is not a valid field in queries\n", field->chars); $valid = 0; goto datecrit_valid_0; /* ABORT */ } /* Check field type */ if (rqfp->field_type != RSP_TYPE_DATE) { DPRINTF(E_LOG, L_RSP, "Field '\%s' is not a date field\n", field->chars); $valid = 0; goto datecrit_valid_0; /* ABORT */ } ret = snprintf(buf, sizeof(buf), "\%ld", $d.date); if ((ret < 0) || (ret >= sizeof(buf))) { DPRINTF(E_LOG, L_RSP, "Date \%ld too large for buffer, oops!\n", $d.date); $valid = 0; goto datecrit_valid_0; /* ABORT */ } $result = field->factory->newRaw(field->factory); $result->append8($result, "f."); $result->appendS($result, field); $result->append8($result, op); $result->append8($result, buf); datecrit_valid_0: ; } ; dateop returns [ pANTLR3_COMMON_TOKEN op ] @init { $op = NULL; } : n = BEFORE { $op = $n->getToken($n); } | n = AFTER { $op = $n->getToken($n); } ; datespec returns [ time_t date, int valid ] @init { $date = 0; $valid = 1; } : r = dateref { if (!$r.valid) $valid = 0; else $date = $r.date; } | ^(o = dateop r = dateref m = INT i = dateintval) { int32_t val; int ret; if (!$r.valid || !$i.valid) { $valid = 0; goto datespec_valid_0; /* ABORT */ } ret = safe_atoi32((char *)$m->getText($m)->chars, &val); if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Could not convert '\%s' to integer\n", (char *)$m->getText($m)); $valid = 0; goto datespec_valid_0; /* ABORT */ } switch ($o.op->getType($o.op)) { case BEFORE: $date = $r.date - (val * $i.period); break; case AFTER: $date = $r.date + (val * $i.period); break; } datespec_valid_0: ; } ; dateref returns [ time_t date, int valid ] @init { $date = 0; $valid = 1; } : n = DATE { struct tm tm; char *ret; ret = strptime((char *)$n->getText($n), "\%Y-\%m-\%d", &tm); if (!ret) { DPRINTF(E_LOG, L_RSP, "Date '\%s' could not be interpreted\n", (char *)$n->getText($n)); $valid = 0; goto dateref_valid_0; /* ABORT */ } else { if (*ret != '\0') DPRINTF(E_LOG, L_RSP, "Garbage at end of date '\%s' ?!\n", (char *)$n->getText($n)); $date = mktime(&tm); if ($date == (time_t) -1) { DPRINTF(E_LOG, L_RSP, "Date '\%s' could not be converted to an epoch\n", (char *)$n->getText($n)); $valid = 0; goto dateref_valid_0; /* ABORT */ } } dateref_valid_0: ; } | TODAY { $date = time(NULL); } ; dateintval returns [ time_t period, int valid ] @init { $period = 0; $valid = 1; } : DAY { $period = 24 * 60 * 60; } | WEEK { $period = 7 * 24 * 60 * 60; } | MONTH { $period = 30 * 24 * 60 * 60; } | YEAR { $period = 365 * 24 * 60 * 60; } ; forked-daapd-0.19gcd/src/artwork.c0000664000175000017500000004535611633141135016441 0ustar julienjulien/* * Copyright (C) 2010-2011 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include "evbuffer/evbuffer.h" #include "db.h" #include "logger.h" #if LIBAVFORMAT_VERSION_MAJOR >= 53 # include "avio_evbuffer.h" #endif #include "artwork.h" static const char *cover_basename[] = { "artwork", "cover", }; static const char *cover_extension[] = { "png", "jpg", }; static int artwork_read(char *filename, struct evbuffer *evbuf) { uint8_t buf[4096]; struct stat sb; int fd; int ret; fd = open(filename, O_RDONLY); if (fd < 0) { DPRINTF(E_WARN, L_ART, "Could not open artwork file '%s': %s\n", filename, strerror(errno)); return -1; } ret = fstat(fd, &sb); if (ret < 0) { DPRINTF(E_WARN, L_ART, "Could not stat() artwork file '%s': %s\n", filename, strerror(errno)); goto out_fail; } ret = evbuffer_expand(evbuf, sb.st_size); if (ret < 0) { DPRINTF(E_LOG, L_ART, "Out of memory for artwork\n"); goto out_fail; } while ((ret = read(fd, buf, sizeof(buf))) > 0) evbuffer_add(evbuf, buf, ret); close(fd); return 0; out_fail: close(fd); return -1; } static int artwork_rescale(AVFormatContext *src_ctx, int s, int out_w, int out_h, int format, struct evbuffer *evbuf) { uint8_t *buf; uint8_t *outbuf; AVCodecContext *src; AVFormatContext *dst_ctx; AVCodecContext *dst; AVOutputFormat *dst_fmt; AVStream *dst_st; AVCodec *img_decoder; AVCodec *img_encoder; int64_t pix_fmt_mask; const enum PixelFormat *pix_fmts; AVFrame *i_frame; AVFrame *o_frame; struct SwsContext *swsctx; AVPacket pkt; int have_frame; int outbuf_len; int ret; src = src_ctx->streams[s]->codec; img_decoder = avcodec_find_decoder(src->codec_id); if (!img_decoder) { DPRINTF(E_LOG, L_ART, "No suitable decoder found for artwork %s\n", src_ctx->filename); return -1; } ret = avcodec_open(src, img_decoder); if (ret < 0) { DPRINTF(E_LOG, L_ART, "Could not open codec for decoding: %s\n", strerror(AVUNERROR(ret))); return -1; } /* Set up output */ #if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 52 && LIBAVFORMAT_VERSION_MINOR >= 45) /* FFmpeg 0.6 */ dst_fmt = av_guess_format("image2", NULL, NULL); #else dst_fmt = guess_format("image2", NULL, NULL); #endif if (!dst_fmt) { DPRINTF(E_LOG, L_ART, "ffmpeg image2 muxer not available\n"); ret = -1; goto out_close_src; } dst_fmt->video_codec = CODEC_ID_NONE; /* Try to keep same codec if possible */ if ((src->codec_id == CODEC_ID_PNG) && (format & ART_CAN_PNG)) dst_fmt->video_codec = CODEC_ID_PNG; else if ((src->codec_id == CODEC_ID_MJPEG) && (format & ART_CAN_JPEG)) dst_fmt->video_codec = CODEC_ID_MJPEG; /* If not possible, select new codec */ if (dst_fmt->video_codec == CODEC_ID_NONE) { if (format & ART_CAN_PNG) dst_fmt->video_codec = CODEC_ID_PNG; else if (format & ART_CAN_JPEG) dst_fmt->video_codec = CODEC_ID_MJPEG; } img_encoder = avcodec_find_encoder(dst_fmt->video_codec); if (!img_encoder) { DPRINTF(E_LOG, L_ART, "No suitable encoder found for codec ID %d\n", dst_fmt->video_codec); ret = -1; goto out_close_src; } dst_ctx = avformat_alloc_context(); if (!dst_ctx) { DPRINTF(E_LOG, L_ART, "Out of memory for format context\n"); ret = -1; goto out_close_src; } dst_ctx->oformat = dst_fmt; #if LIBAVFORMAT_VERSION_MAJOR >= 53 dst_fmt->flags &= ~AVFMT_NOFILE; #else ret = snprintf(dst_ctx->filename, sizeof(dst_ctx->filename), "evbuffer:%p", evbuf); if ((ret < 0) || (ret >= sizeof(dst_ctx->filename))) { DPRINTF(E_LOG, L_ART, "Output artwork URL too long\n"); ret = -1; goto out_free_dst_ctx; } #endif dst_st = av_new_stream(dst_ctx, 0); if (!dst_st) { DPRINTF(E_LOG, L_ART, "Out of memory for new output stream\n"); ret = -1; goto out_free_dst_ctx; } dst = dst_st->codec; #if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 64) avcodec_get_context_defaults2(dst, AVMEDIA_TYPE_VIDEO); #else avcodec_get_context_defaults2(dst, CODEC_TYPE_VIDEO); #endif if (dst_fmt->flags & AVFMT_GLOBALHEADER) dst->flags |= CODEC_FLAG_GLOBAL_HEADER; dst->codec_id = dst_fmt->video_codec; #if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 64) dst->codec_type = AVMEDIA_TYPE_VIDEO; #else dst->codec_type = CODEC_TYPE_VIDEO; #endif pix_fmt_mask = 0; pix_fmts = img_encoder->pix_fmts; while (pix_fmts && (*pix_fmts != -1)) { pix_fmt_mask |= (1 << *pix_fmts); pix_fmts++; } dst->pix_fmt = avcodec_find_best_pix_fmt(pix_fmt_mask, src->pix_fmt, 1, NULL); if (dst->pix_fmt < 0) { DPRINTF(E_LOG, L_ART, "Could not determine best pixel format\n"); ret = -1; goto out_free_dst; } DPRINTF(E_DBG, L_ART, "Selected pixel format: %d\n", dst->pix_fmt); dst->time_base.num = 1; dst->time_base.den = 25; dst->width = out_w; dst->height = out_h; #if LIBAVFORMAT_VERSION_MAJOR <= 52 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR <= 1) ret = av_set_parameters(dst_ctx, NULL); if (ret < 0) { DPRINTF(E_LOG, L_ART, "Invalid parameters for artwork output: %s\n", strerror(AVUNERROR(ret))); ret = -1; goto out_free_dst; } #endif /* Open encoder */ ret = avcodec_open(dst, img_encoder); if (ret < 0) { DPRINTF(E_LOG, L_ART, "Could not open codec for encoding: %s\n", strerror(AVUNERROR(ret))); ret = -1; goto out_free_dst; } i_frame = avcodec_alloc_frame(); o_frame = avcodec_alloc_frame(); if (!i_frame || !o_frame) { DPRINTF(E_LOG, L_ART, "Could not allocate input/output frame\n"); ret = -1; goto out_free_frames; } ret = avpicture_get_size(dst->pix_fmt, src->width, src->height); DPRINTF(E_DBG, L_ART, "Artwork buffer size: %d\n", ret); buf = (uint8_t *)av_malloc(ret); if (!buf) { DPRINTF(E_LOG, L_ART, "Out of memory for artwork buffer\n"); ret = -1; goto out_free_frames; } avpicture_fill((AVPicture *)o_frame, buf, dst->pix_fmt, src->width, src->height); swsctx = sws_getContext(src->width, src->height, src->pix_fmt, dst->width, dst->height, dst->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL); if (!swsctx) { DPRINTF(E_LOG, L_ART, "Could not get SWS context\n"); ret = -1; goto out_free_buf; } /* Get frame */ have_frame = 0; while (av_read_frame(src_ctx, &pkt) == 0) { if (pkt.stream_index != s) { av_free_packet(&pkt); continue; } #if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32) /* FFmpeg 0.6 */ avcodec_decode_video2(src, i_frame, &have_frame, &pkt); #else avcodec_decode_video(src, i_frame, &have_frame, pkt.data, pkt.size); #endif break; } if (!have_frame) { DPRINTF(E_LOG, L_ART, "Could not decode artwork\n"); av_free_packet(&pkt); sws_freeContext(swsctx); ret = -1; goto out_free_buf; } /* Scale */ #if LIBSWSCALE_VERSION_MAJOR >= 1 || (LIBSWSCALE_VERSION_MAJOR == 0 && LIBSWSCALE_VERSION_MINOR >= 9) /* FFmpeg 0.6, libav 0.6+ */ sws_scale(swsctx, (const uint8_t * const *)i_frame->data, i_frame->linesize, 0, src->height, o_frame->data, o_frame->linesize); #else sws_scale(swsctx, i_frame->data, i_frame->linesize, 0, src->height, o_frame->data, o_frame->linesize); #endif sws_freeContext(swsctx); av_free_packet(&pkt); /* Open output file */ #if LIBAVFORMAT_VERSION_MAJOR >= 53 dst_ctx->pb = avio_evbuffer_open(evbuf); #else ret = url_fopen(&dst_ctx->pb, dst_ctx->filename, URL_WRONLY); #endif if (ret < 0) { DPRINTF(E_LOG, L_ART, "Could not open artwork destination buffer\n"); ret = -1; goto out_free_buf; } /* Encode frame */ outbuf_len = dst->width * dst->height * 3; if (outbuf_len < FF_MIN_BUFFER_SIZE) outbuf_len = FF_MIN_BUFFER_SIZE; outbuf = (uint8_t *)av_malloc(outbuf_len); if (!outbuf) { DPRINTF(E_LOG, L_ART, "Out of memory for encoded artwork buffer\n"); #if LIBAVFORMAT_VERSION_MAJOR >= 53 avio_evbuffer_close(dst_ctx->pb); #else url_fclose(dst_ctx->pb); #endif ret = -1; goto out_free_buf; } ret = avcodec_encode_video(dst, outbuf, outbuf_len, o_frame); if (ret <= 0) { DPRINTF(E_LOG, L_ART, "Could not encode artwork\n"); ret = -1; goto out_fclose_dst; } av_init_packet(&pkt); pkt.stream_index = 0; pkt.data = outbuf; pkt.size = ret; #if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 3) ret = avformat_write_header(dst_ctx, NULL); #else ret = av_write_header(dst_ctx); #endif if (ret != 0) { DPRINTF(E_LOG, L_ART, "Could not write artwork header: %s\n", strerror(AVUNERROR(ret))); ret = -1; goto out_fclose_dst; } ret = av_interleaved_write_frame(dst_ctx, &pkt); if (ret != 0) { DPRINTF(E_LOG, L_ART, "Error writing artwork\n"); ret = -1; goto out_fclose_dst; } ret = av_write_trailer(dst_ctx); if (ret != 0) { DPRINTF(E_LOG, L_ART, "Could not write artwork trailer: %s\n", strerror(AVUNERROR(ret))); ret = -1; goto out_fclose_dst; } switch (dst_fmt->video_codec) { case CODEC_ID_PNG: ret = ART_FMT_PNG; break; case CODEC_ID_MJPEG: ret = ART_FMT_JPEG; break; default: DPRINTF(E_LOG, L_ART, "Unhandled rescale output format\n"); ret = -1; break; } out_fclose_dst: #if LIBAVFORMAT_VERSION_MAJOR >= 53 avio_evbuffer_close(dst_ctx->pb); #else url_fclose(dst_ctx->pb); #endif av_free(outbuf); out_free_buf: av_free(buf); out_free_frames: if (i_frame) av_free(i_frame); if (o_frame) av_free(o_frame); avcodec_close(dst); out_free_dst: av_free(dst_st); av_free(dst); out_free_dst_ctx: av_free(dst_ctx); out_close_src: avcodec_close(src); return ret; } static int artwork_get(char *filename, int max_w, int max_h, int format, struct evbuffer *evbuf) { AVFormatContext *src_ctx; AVCodecContext *src; int s; int target_w; int target_h; int need_rescale; int format_ok; int ret; DPRINTF(E_DBG, L_ART, "Artwork request parameters: max w = %d, max h = %d\n", max_w, max_h); src_ctx = NULL; #if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 3) ret = avformat_open_input(&src_ctx, filename, NULL, NULL); #else ret = av_open_input_file(&src_ctx, filename, NULL, 0, NULL); #endif if (ret < 0) { DPRINTF(E_WARN, L_ART, "Cannot open artwork file '%s': %s\n", filename, strerror(AVUNERROR(ret))); return -1; } ret = av_find_stream_info(src_ctx); if (ret < 0) { DPRINTF(E_WARN, L_ART, "Cannot get stream info: %s\n", strerror(AVUNERROR(ret))); av_close_input_file(src_ctx); return -1; } format_ok = 0; for (s = 0; s < src_ctx->nb_streams; s++) { if (src_ctx->streams[s]->codec->codec_id == CODEC_ID_PNG) { format_ok = (format & ART_CAN_PNG) ? ART_FMT_PNG : 0; break; } else if (src_ctx->streams[s]->codec->codec_id == CODEC_ID_MJPEG) { format_ok = (format & ART_CAN_JPEG) ? ART_FMT_JPEG : 0; break; } } if (s == src_ctx->nb_streams) { DPRINTF(E_LOG, L_ART, "Artwork file '%s' not a PNG or JPEG file\n", filename); av_close_input_file(src_ctx); return -1; } src = src_ctx->streams[s]->codec; DPRINTF(E_DBG, L_ART, "Original image '%s': w %d h %d\n", filename, src->width, src->height); need_rescale = 1; /* Determine width/height -- assuming max_w == max_h */ if ((src->width <= max_w) && (src->height <= max_h)) { need_rescale = 0; target_w = src->width; target_h = src->height; } else if (src->width > src->height) { target_w = max_w; target_h = (double)max_h * ((double)src->height / (double)src->width); } else if (src->height > src->width) { target_h = max_h; target_w = (double)max_w * ((double)src->width / (double)src->height); } else { target_w = max_w; target_h = max_h; } DPRINTF(E_DBG, L_ART, "Raw destination width %d height %d\n", target_w, target_h); if (target_h > max_h) target_h = max_h; /* PNG prefers even row count */ target_w += target_w % 2; if (target_w > max_w) target_w = max_w - (max_w % 2); DPRINTF(E_DBG, L_ART, "Destination width %d height %d\n", target_w, target_h); /* Fastpath */ if (!need_rescale && format_ok) { ret = artwork_read(filename, evbuf); if (ret == 0) ret = format_ok; } else ret = artwork_rescale(src_ctx, s, target_w, target_h, format, evbuf); av_close_input_file(src_ctx); if (ret < 0) { if (EVBUFFER_LENGTH(evbuf) > 0) evbuffer_drain(evbuf, EVBUFFER_LENGTH(evbuf)); } return ret; } static int artwork_get_own_image(char *path, int max_w, int max_h, int format, struct evbuffer *evbuf) { char artwork[PATH_MAX]; char *ptr; int len; int i; int ret; ret = snprintf(artwork, sizeof(artwork), "%s", path); if ((ret < 0) || (ret >= sizeof(artwork))) { DPRINTF(E_INFO, L_ART, "Artwork path exceeds PATH_MAX\n"); return -1; } ptr = strrchr(artwork, '.'); if (ptr) *ptr = '\0'; len = strlen(artwork); for (i = 0; i < (sizeof(cover_extension) / sizeof(cover_extension[0])); i++) { ret = snprintf(artwork + len, sizeof(artwork) - len, ".%s", cover_extension[i]); if ((ret < 0) || (ret >= sizeof(artwork) - len)) { DPRINTF(E_INFO, L_ART, "Artwork path exceeds PATH_MAX (ext %s)\n", cover_extension[i]); continue; } DPRINTF(E_DBG, L_ART, "Trying own artwork file %s\n", artwork); ret = access(artwork, F_OK); if (ret < 0) continue; break; } if (i == (sizeof(cover_extension) / sizeof(cover_extension[0]))) return -1; return artwork_get(artwork, max_w, max_h, format, evbuf); } static int artwork_get_dir_image(char *path, int isdir, int max_w, int max_h, int format, struct evbuffer *evbuf) { char artwork[PATH_MAX]; char *ptr; int i; int j; int len; int ret; ret = snprintf(artwork, sizeof(artwork), "%s", path); if ((ret < 0) || (ret >= sizeof(artwork))) { DPRINTF(E_INFO, L_ART, "Artwork path exceeds PATH_MAX\n"); return -1; } if (!isdir) { ptr = strrchr(artwork, '/'); if (ptr) *ptr = '\0'; } len = strlen(artwork); for (i = 0; i < (sizeof(cover_basename) / sizeof(cover_basename[0])); i++) { for (j = 0; j < (sizeof(cover_extension) / sizeof(cover_extension[0])); j++) { ret = snprintf(artwork + len, sizeof(artwork) - len, "/%s.%s", cover_basename[i], cover_extension[j]); if ((ret < 0) || (ret >= sizeof(artwork) - len)) { DPRINTF(E_INFO, L_ART, "Artwork path exceeds PATH_MAX (%s.%s)\n", cover_basename[i], cover_extension[j]); continue; } DPRINTF(E_DBG, L_ART, "Trying directory artwork file %s\n", artwork); ret = access(artwork, F_OK); if (ret < 0) continue; break; } if (j < (sizeof(cover_extension) / sizeof(cover_extension[0]))) break; } if (i == (sizeof(cover_basename) / sizeof(cover_basename[0]))) return -1; return artwork_get(artwork, max_w, max_h, format, evbuf); } int artwork_get_item_filename(char *filename, int max_w, int max_h, int format, struct evbuffer *evbuf) { int ret; /* FUTURE: look at embedded artwork */ /* Look for basename(filename).{png,jpg} */ ret = artwork_get_own_image(filename, max_w, max_h, format, evbuf); if (ret > 0) return ret; /* Look for basedir(filename)/{artwork,cover}.{png,jpg} */ ret = artwork_get_dir_image(filename, 0, max_w, max_h, format, evbuf); if (ret > 0) return ret; return -1; } int artwork_get_item(int id, int max_w, int max_h, int format, struct evbuffer *evbuf) { char *filename; int ret; DPRINTF(E_DBG, L_ART, "Artwork request for item %d\n", id); filename = db_file_path_byid(id); if (!filename) return -1; ret = artwork_get_item_filename(filename, max_w, max_h, format, evbuf); if (ret < 0) DPRINTF(E_DBG, L_ART, "No artwork found for item id %d\n", id); free(filename); return ret; } int artwork_get_group(int id, int max_w, int max_h, int format, struct evbuffer *evbuf) { struct query_params qp; struct db_media_file_info dbmfi; char *dir; int got_art; int ret; DPRINTF(E_DBG, L_ART, "Artwork request for group %d\n", id); /* Try directory artwork first */ memset(&qp, 0, sizeof(struct query_params)); qp.type = Q_GROUP_DIRS; qp.id = id; ret = db_query_start(&qp); if (ret < 0) { DPRINTF(E_LOG, L_ART, "Could not start Q_GROUP_DIRS query\n"); /* Skip to invidual files artwork */ goto files_art; } got_art = -1; while ((got_art < 0) && ((ret = db_query_fetch_string(&qp, &dir)) == 0) && (dir)) { got_art = artwork_get_dir_image(dir, 1, max_w, max_h, format, evbuf); } db_query_end(&qp); if (ret < 0) DPRINTF(E_LOG, L_ART, "Error fetching Q_GROUP_DIRS results\n"); else if (got_art > 0) return got_art; /* Then try individual files */ files_art: memset(&qp, 0, sizeof(struct query_params)); qp.type = Q_GROUPITEMS; qp.id = id; ret = db_query_start(&qp); if (ret < 0) { DPRINTF(E_LOG, L_ART, "Could not start Q_GROUPITEMS query\n"); return -1; } got_art = -1; while ((got_art < 0) && ((ret = db_query_fetch_file(&qp, &dbmfi)) == 0) && (dbmfi.id)) { got_art = artwork_get_own_image(dbmfi.path, max_w, max_h, format, evbuf); } db_query_end(&qp); if (ret < 0) DPRINTF(E_LOG, L_ART, "Error fetching Q_GROUPITEMS results\n"); else if (got_art > 0) return got_art; return -1; } forked-daapd-0.19gcd/src/artwork.h0000664000175000017500000000074011633141135016432 0ustar julienjulien #ifndef __ARTWORK_H__ #define __ARTWORK_H__ #define ART_CAN_PNG (1 << 0) #define ART_CAN_JPEG (1 << 1) #define ART_FMT_PNG 1 #define ART_FMT_JPEG 2 int artwork_get_item_filename(char *filename, int max_w, int max_h, int format, struct evbuffer *evbuf); int artwork_get_item(int id, int max_w, int max_h, int format, struct evbuffer *evbuf); int artwork_get_group(int id, int max_w, int max_h, int format, struct evbuffer *evbuf); #endif /* !__ARTWORK_H__ */ forked-daapd-0.19gcd/src/avio_evbuffer.c0000664000175000017500000000436111633141135017561 0ustar julienjulien/* * Copyright (C) 2011 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include "evbuffer/evbuffer.h" #include "logger.h" #include "avio_evbuffer.h" /* * libav AVIO interface for evbuffers */ #define BUFFER_SIZE 4096 struct avio_evbuffer { struct evbuffer *evbuf; uint8_t *buffer; }; static int avio_evbuffer_write(void *opaque, uint8_t *buf, int size) { struct avio_evbuffer *ae; int ret; ae = (struct avio_evbuffer *)opaque; ret = evbuffer_add(ae->evbuf, buf, size); return (ret == 0) ? size : -1; } AVIOContext * avio_evbuffer_open(struct evbuffer *evbuf) { struct avio_evbuffer *ae; AVIOContext *s; ae = (struct avio_evbuffer *)malloc(sizeof(struct avio_evbuffer)); if (!ae) { DPRINTF(E_LOG, L_FFMPEG, "Out of memory for avio_evbuffer\n"); return NULL; } ae->buffer = av_mallocz(BUFFER_SIZE); if (!ae->buffer) { DPRINTF(E_LOG, L_FFMPEG, "Out of memory for avio buffer\n"); free(ae); return NULL; } ae->evbuf = evbuf; s = avio_alloc_context(ae->buffer, BUFFER_SIZE, 1, ae, NULL, avio_evbuffer_write, NULL); if (!s) { DPRINTF(E_LOG, L_FFMPEG, "Could not allocate AVIOContext\n"); av_free(ae->buffer); free(ae); return NULL; } s->seekable = 0; return s; } void avio_evbuffer_close(AVIOContext *s) { struct avio_evbuffer *ae; ae = (struct avio_evbuffer *)s->opaque; avio_flush(s); av_free(ae->buffer); free(ae); av_free(s); } forked-daapd-0.19gcd/src/avio_evbuffer.h0000664000175000017500000000030211633141135017555 0ustar julienjulien #ifndef __AVIO_EVBUFFER_H__ #define __AVIO_EVBUFFER_H__ AVIOContext * avio_evbuffer_open(struct evbuffer *evbuf); void avio_evbuffer_close(AVIOContext *s); #endif /* !__AVIO_EVBUFFER_H__ */ forked-daapd-0.19gcd/src/conffile.c0000664000175000017500000001451311633141135016524 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include "logger.h" #include "misc.h" #include "conffile.h" /* Forward */ static int cb_loglevel(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result); /* general section structure */ static cfg_opt_t sec_general[] = { CFG_STR("uid", "nobody", CFGF_NONE), CFG_STR("admin_password", NULL, CFGF_NONE), CFG_STR("logfile", STATEDIR "/log/" PACKAGE ".log", CFGF_NONE), CFG_STR("db_path", STATEDIR "/cache/" PACKAGE "/songs3.db", CFGF_NONE), CFG_INT_CB("loglevel", E_LOG, CFGF_NONE, &cb_loglevel), CFG_BOOL("ipv6", cfg_true, CFGF_NONE), CFG_END() }; /* library section structure */ static cfg_opt_t sec_library[] = { CFG_STR("name", "My Music on %h", CFGF_NONE), CFG_INT("port", 3689, CFGF_NONE), CFG_STR("password", NULL, CFGF_NONE), CFG_STR_LIST("directories", NULL, CFGF_NONE), CFG_STR_LIST("compilations", NULL, CFGF_NONE), CFG_BOOL("itunes_overrides", cfg_false, CFGF_NONE), CFG_STR_LIST("no_transcode", NULL, CFGF_NONE), CFG_STR_LIST("force_transcode", NULL, CFGF_NONE), CFG_END() }; /* local audio section structure */ static cfg_opt_t sec_audio[] = { CFG_STR("nickname", "Computer", CFGF_NONE), #ifdef __linux__ CFG_STR("card", "default", CFGF_NONE), #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) CFG_STR("card", "/dev/dsp", CFGF_NONE), #endif CFG_STR("mixer", NULL, CFGF_NONE), CFG_END() }; /* ApEx device section structure */ static cfg_opt_t sec_apex[] = { CFG_STR("password", NULL, CFGF_NONE), CFG_END() }; /* Config file structure */ static cfg_opt_t toplvl_cfg[] = { CFG_SEC("general", sec_general, CFGF_NONE), CFG_SEC("library", sec_library, CFGF_NONE), CFG_SEC("audio", sec_audio, CFGF_NONE), CFG_SEC("apex", sec_apex, CFGF_MULTI | CFGF_TITLE), CFG_END() }; cfg_t *cfg; uint64_t libhash; uid_t runas_uid; gid_t runas_gid; static int cb_loglevel(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result) { if (strcasecmp(value, "fatal") == 0) *(long int *)result = E_FATAL; else if (strcasecmp(value, "log") == 0) *(long int *)result = E_LOG; else if (strcasecmp(value, "warning") == 0) *(long int *)result = E_WARN; else if (strcasecmp(value, "info") == 0) *(long int *)result = E_INFO; else if (strcasecmp(value, "debug") == 0) *(long int *)result = E_DBG; else if (strcasecmp(value, "spam") == 0) *(long int *)result = E_SPAM; else { DPRINTF(E_WARN, L_CONF, "Unrecognised loglevel '%s'\n", value); /* Default to warning */ *(long int *)result = 1; } return 0; } static int conffile_expand_libname(cfg_t *lib) { char *libname; char *hostname; char *s; char *d; char *expanded; struct utsname sysinfo; size_t len; size_t olen; size_t hostlen; size_t verlen; int ret; libname = cfg_getstr(lib, "name"); olen = strlen(libname); /* Fast path */ s = strchr(libname, '%'); if (!s) { libhash = murmur_hash64(libname, olen, 0); return 0; } /* Grab what we need */ ret = uname(&sysinfo); if (ret != 0) { DPRINTF(E_WARN, L_CONF, "Could not get system name: %s\n", strerror(errno)); hostname = "Unknown host"; } else hostname = sysinfo.nodename; hostlen = strlen(hostname); verlen = strlen(VERSION); /* Compute expanded size */ len = olen; s = libname; while (*s) { if (*s == '%') { s++; switch (*s) { case 'h': len += hostlen; break; case 'v': len += verlen; break; } } s++; } expanded = (char *)malloc(len + 1); if (!expanded) { DPRINTF(E_FATAL, L_CONF, "Out of memory\n"); return -1; } memset(expanded, 0, len + 1); /* Do the actual expansion */ s = libname; d = expanded; while (*s) { if (*s == '%') { s++; switch (*s) { case 'h': strcat(d, hostname); d += hostlen; break; case 'v': strcat(d, VERSION); d += verlen; break; } s++; } else { *d = *s; s++; d++; } } cfg_setstr(lib, "name", expanded); libhash = murmur_hash64(expanded, strlen(expanded), 0); free(expanded); return 0; } int conffile_load(char *file) { cfg_t *lib; struct passwd *pw; char *runas; int ret; cfg = cfg_init(toplvl_cfg, CFGF_NONE); ret = cfg_parse(cfg, file); if (ret == CFG_FILE_ERROR) { DPRINTF(E_FATAL, L_CONF, "Could not open config file %s\n", file); goto out_fail; } else if (ret == CFG_PARSE_ERROR) { DPRINTF(E_FATAL, L_CONF, "Parse error in config file %s\n", file); goto out_fail; } /* Resolve runas username */ runas = cfg_getstr(cfg_getsec(cfg, "general"), "uid"); pw = getpwnam(runas); if (!pw) { DPRINTF(E_FATAL, L_CONF, "Could not lookup user %s: %s\n", runas, strerror(errno)); goto out_fail; } runas_uid = pw->pw_uid; runas_gid = pw->pw_gid; lib = cfg_getsec(cfg, "library"); if (cfg_size(lib, "directories") == 0) { DPRINTF(E_FATAL, L_CONF, "No directories specified for library\n"); goto out_fail; } /* Do keyword expansion on library names */ ret = conffile_expand_libname(lib); if (ret != 0) { DPRINTF(E_FATAL, L_CONF, "Could not expand library name\n"); goto out_fail; } return 0; out_fail: cfg_free(cfg); return -1; } void conffile_unload(void) { cfg_free(cfg); } forked-daapd-0.19gcd/src/conffile.h0000664000175000017500000000050611633141135016526 0ustar julienjulien #ifndef __CONFFILE_H__ #define __CONFFILE_H__ #include #include #define CONFFILE CONFDIR "/forked-daapd.conf" extern cfg_t *cfg; extern uint64_t libhash; extern uid_t runas_uid; extern gid_t runas_gid; int conffile_load(char *file); void conffile_unload(void); #endif /* !__CONFFILE_H__ */ forked-daapd-0.19gcd/src/daap_query.c0000664000175000017500000000762511633141135017077 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include "logger.h" #include "misc.h" #include "daap_query.h" #include "DAAPLexer.h" #include "DAAPParser.h" #include "DAAP2SQL.h" char * daap_query_parse_sql(const char *daap_query) { /* Input DAAP query, fed to the lexer */ pANTLR3_INPUT_STREAM query; /* Lexer and the resulting token stream, fed to the parser */ pDAAPLexer lxr; pANTLR3_COMMON_TOKEN_STREAM tkstream; /* Parser and the resulting AST, fed to the tree parser */ pDAAPParser psr; DAAPParser_query_return qtree; pANTLR3_COMMON_TREE_NODE_STREAM nodes; /* Tree parser and the resulting SQL query string */ pDAAP2SQL sqlconv; pANTLR3_STRING sql; char *ret = NULL; DPRINTF(E_DBG, L_DAAP, "Trying DAAP query -%s-\n", daap_query); #if ANTLR3C_NEW_INPUT query = antlr3StringStreamNew ((pANTLR3_UINT8)daap_query, ANTLR3_ENC_8BIT, (ANTLR3_UINT64)strlen(daap_query), (pANTLR3_UINT8)"DAAP query"); #else query = antlr3NewAsciiStringInPlaceStream ((pANTLR3_UINT8)daap_query, (ANTLR3_UINT64)strlen(daap_query), (pANTLR3_UINT8)"DAAP query"); #endif if (!query) { DPRINTF(E_DBG, L_DAAP, "Could not create input stream\n"); return NULL; } lxr = DAAPLexerNew(query); if (!lxr) { DPRINTF(E_DBG, L_DAAP, "Could not create DAAP lexer\n"); goto lxr_fail; } tkstream = antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, TOKENSOURCE(lxr)); if (!tkstream) { DPRINTF(E_DBG, L_DAAP, "Could not create DAAP token stream\n"); goto tkstream_fail; } psr = DAAPParserNew(tkstream); if (!psr) { DPRINTF(E_DBG, L_DAAP, "Could not create DAAP parser\n"); goto psr_fail; } qtree = psr->query(psr); /* Check for parser errors */ if (psr->pParser->rec->state->errorCount > 0) { DPRINTF(E_LOG, L_DAAP, "DAAP query parser terminated with %d errors\n", psr->pParser->rec->state->errorCount); goto psr_error; } DPRINTF(E_SPAM, L_DAAP, "DAAP query AST:\n\t%s\n", qtree.tree->toStringTree(qtree.tree)->chars); nodes = antlr3CommonTreeNodeStreamNewTree(qtree.tree, ANTLR3_SIZE_HINT); if (!nodes) { DPRINTF(E_DBG, L_DAAP, "Could not create node stream\n"); goto psr_error; } sqlconv = DAAP2SQLNew(nodes); if (!sqlconv) { DPRINTF(E_DBG, L_DAAP, "Could not create SQL converter\n"); goto sql_fail; } sql = sqlconv->query(sqlconv); /* Check for tree parser errors */ if (sqlconv->pTreeParser->rec->state->errorCount > 0) { DPRINTF(E_LOG, L_DAAP, "DAAP query tree parser terminated with %d errors\n", sqlconv->pTreeParser->rec->state->errorCount); goto sql_error; } if (sql) { DPRINTF(E_DBG, L_DAAP, "DAAP SQL query: -%s-\n", sql->chars); ret = strdup((char *)sql->chars); } else { DPRINTF(E_LOG, L_DAAP, "Invalid DAAP query\n"); ret = NULL; } sql_error: sqlconv->free(sqlconv); sql_fail: nodes->free(nodes); psr_error: psr->free(psr); psr_fail: tkstream->free(tkstream); tkstream_fail: lxr->free(lxr); lxr_fail: query->close(query); return ret; } forked-daapd-0.19gcd/src/daap_query.gperf0000664000175000017500000000326711633141135017756 0ustar julienjulien%language=ANSI-C %readonly-tables %enum %switch=1 %compare-lengths %define hash-function-name daap_query_field_hash %define lookup-function-name daap_query_field_lookup %define slot-name dmap_field %struct-type %omit-struct-type struct dmap_query_field_map; %% "dmap.itemname", "f.title", 0 "dmap.itemid", "f.id", 1 "daap.songalbum", "f.album", 0 "daap.songalbumid", "f.songalbumid", 1 "daap.songartist", "f.artist", 0 "daap.songalbumartist", "f.album_artist", 0 "daap.songbitrate", "f.bitrate", 1 "daap.songcomment", "f.comment", 0 "daap.songcompilation", "f.compilation", 1 "daap.songcomposer", "f.composer", 0 "daap.songdatakind", "f.data_kind", 1 "daap.songdataurl", "f.url", 0 "daap.songdateadded", "f.time_added", 1 "daap.songdatemodified", "f.time_modified", 1 "daap.songdescription", "f.description", 0 "daap.songdisccount", "f.total_discs", 1 "daap.songdiscnumber", "f.disc", 1 "daap.songformat", "f.type", 0 "daap.songgenre", "f.genre", 0 "daap.songsamplerate", "f.samplerate", 1 "daap.songsize", "f.file_size", 1 "daap.songstoptime", "f.song_length", 1 "daap.songtime", "f.song_length", 1 "daap.songtrackcount", "f.total_tracks", 1 "daap.songtracknumber", "f.track", 1 "daap.songyear", "f.year", 1 "com.apple.itunes.mediakind", "f.media_kind", 1 forked-daapd-0.19gcd/src/daap_query.h0000664000175000017500000000026111633141135017071 0ustar julienjulien #ifndef __DAAP_QUERY_H__ #define __DAAP_QUERY_H__ #include "logger.h" #include "misc.h" char * daap_query_parse_sql(const char *daap_query); #endif /* !__DAAP_QUERY_H__ */ forked-daapd-0.19gcd/src/dacp_prop.gperf0000664000175000017500000000204111633141135017560 0ustar julienjulien%language=ANSI-C %readonly-tables %enum %switch=1 %compare-lengths %define hash-function-name dacp_hash_prop %define lookup-function-name dacp_find_prop %define slot-name desc %struct-type %omit-struct-type struct dacp_prop_map; %% "dmcp.volume", dacp_propget_volume, dacp_propset_volume "dacp.playerstate", dacp_propget_playerstate, NULL "dacp.nowplaying", dacp_propget_nowplaying, NULL "dacp.playingtime", dacp_propget_playingtime, dacp_propset_playingtime "dacp.volumecontrollable", dacp_propget_volumecontrollable, NULL "dacp.availableshufflestates", dacp_propget_availableshufflestates, NULL "dacp.availablerepeatstates", dacp_propget_availablerepeatstates, NULL "dacp.shufflestate", dacp_propget_shufflestate, dacp_propset_shufflestate "dacp.repeatstate", dacp_propget_repeatstate, dacp_propset_repeatstate "dacp.userrating", NULL, dacp_propset_userrating forked-daapd-0.19gcd/src/db.c0000664000175000017500000036105611633141135015333 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * Copyright (C) 2010 Kai Elwert * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "conffile.h" #include "logger.h" #include "misc.h" #include "db.h" #define STR(x) ((x) ? (x) : "") /* Inotify cookies are uint32_t */ #define INOTIFY_FAKE_COOKIE ((int64_t)1 << 32) enum group_type { G_ALBUMS = 1, }; #define DB_POOL_MIN_SIZE 4 #define DB_POOL_MIN_FREE 2 #define DB_POOL_MAX_AGE (5 * 60) #define DB_POOL_MAX_AGE_NSEC (DB_POOL_MAX_AGE * NSEC_PER_SEC) struct db_pool_hdl { sqlite3 *hdl; time_t last; struct db_pool_hdl *next; struct db_pool_hdl *saved; }; struct db_unlock { int proceed; pthread_cond_t cond; pthread_mutex_t lck; }; #define DB_TYPE_CHAR 1 #define DB_TYPE_INT 2 #define DB_TYPE_INT64 3 #define DB_TYPE_STRING 4 struct col_type_map { ssize_t offset; short type; }; /* This list must be kept in sync with * - the order of the columns in the files table * - the type and name of the fields in struct media_file_info */ static const struct col_type_map mfi_cols_map[] = { { mfi_offsetof(id), DB_TYPE_INT }, { mfi_offsetof(path), DB_TYPE_STRING }, { mfi_offsetof(fname), DB_TYPE_STRING }, { mfi_offsetof(title), DB_TYPE_STRING }, { mfi_offsetof(artist), DB_TYPE_STRING }, { mfi_offsetof(album), DB_TYPE_STRING }, { mfi_offsetof(genre), DB_TYPE_STRING }, { mfi_offsetof(comment), DB_TYPE_STRING }, { mfi_offsetof(type), DB_TYPE_STRING }, { mfi_offsetof(composer), DB_TYPE_STRING }, { mfi_offsetof(orchestra), DB_TYPE_STRING }, { mfi_offsetof(conductor), DB_TYPE_STRING }, { mfi_offsetof(grouping), DB_TYPE_STRING }, { mfi_offsetof(url), DB_TYPE_STRING }, { mfi_offsetof(bitrate), DB_TYPE_INT }, { mfi_offsetof(samplerate), DB_TYPE_INT }, { mfi_offsetof(song_length), DB_TYPE_INT }, { mfi_offsetof(file_size), DB_TYPE_INT64 }, { mfi_offsetof(year), DB_TYPE_INT }, { mfi_offsetof(track), DB_TYPE_INT }, { mfi_offsetof(total_tracks), DB_TYPE_INT }, { mfi_offsetof(disc), DB_TYPE_INT }, { mfi_offsetof(total_discs), DB_TYPE_INT }, { mfi_offsetof(bpm), DB_TYPE_INT }, { mfi_offsetof(compilation), DB_TYPE_CHAR }, { mfi_offsetof(rating), DB_TYPE_INT }, { mfi_offsetof(play_count), DB_TYPE_INT }, { mfi_offsetof(data_kind), DB_TYPE_INT }, { mfi_offsetof(item_kind), DB_TYPE_INT }, { mfi_offsetof(description), DB_TYPE_STRING }, { mfi_offsetof(time_added), DB_TYPE_INT }, { mfi_offsetof(time_modified), DB_TYPE_INT }, { mfi_offsetof(time_played), DB_TYPE_INT }, { mfi_offsetof(db_timestamp), DB_TYPE_INT }, { mfi_offsetof(disabled), DB_TYPE_INT }, { mfi_offsetof(sample_count), DB_TYPE_INT64 }, { mfi_offsetof(codectype), DB_TYPE_STRING }, { mfi_offsetof(index), DB_TYPE_INT }, { mfi_offsetof(has_video), DB_TYPE_INT }, { mfi_offsetof(contentrating), DB_TYPE_INT }, { mfi_offsetof(bits_per_sample), DB_TYPE_INT }, { mfi_offsetof(album_artist), DB_TYPE_STRING }, { mfi_offsetof(media_kind), DB_TYPE_INT }, { mfi_offsetof(tv_series_name), DB_TYPE_STRING }, { mfi_offsetof(tv_episode_num_str), DB_TYPE_STRING }, { mfi_offsetof(tv_network_name), DB_TYPE_STRING }, { mfi_offsetof(tv_episode_sort), DB_TYPE_INT }, { mfi_offsetof(tv_season_num), DB_TYPE_INT }, { mfi_offsetof(songalbumid), DB_TYPE_INT64 }, { mfi_offsetof(title_sort), DB_TYPE_STRING }, { mfi_offsetof(artist_sort), DB_TYPE_STRING }, { mfi_offsetof(album_sort), DB_TYPE_STRING }, { mfi_offsetof(composer_sort), DB_TYPE_STRING }, { mfi_offsetof(album_artist_sort), DB_TYPE_STRING }, }; /* This list must be kept in sync with * - the order of the columns in the playlists table * - the type and name of the fields in struct playlist_info */ static const struct col_type_map pli_cols_map[] = { { pli_offsetof(id), DB_TYPE_INT }, { pli_offsetof(title), DB_TYPE_STRING }, { pli_offsetof(type), DB_TYPE_INT }, { pli_offsetof(query), DB_TYPE_STRING }, { pli_offsetof(db_timestamp), DB_TYPE_INT }, { pli_offsetof(disabled), DB_TYPE_INT }, { pli_offsetof(path), DB_TYPE_STRING }, { pli_offsetof(index), DB_TYPE_INT }, { pli_offsetof(special_id), DB_TYPE_INT }, /* items is computed on the fly */ }; /* This list must be kept in sync with * - the order of the columns in the files table * - the name of the fields in struct db_media_file_info */ static const ssize_t dbmfi_cols_map[] = { dbmfi_offsetof(id), dbmfi_offsetof(path), dbmfi_offsetof(fname), dbmfi_offsetof(title), dbmfi_offsetof(artist), dbmfi_offsetof(album), dbmfi_offsetof(genre), dbmfi_offsetof(comment), dbmfi_offsetof(type), dbmfi_offsetof(composer), dbmfi_offsetof(orchestra), dbmfi_offsetof(conductor), dbmfi_offsetof(grouping), dbmfi_offsetof(url), dbmfi_offsetof(bitrate), dbmfi_offsetof(samplerate), dbmfi_offsetof(song_length), dbmfi_offsetof(file_size), dbmfi_offsetof(year), dbmfi_offsetof(track), dbmfi_offsetof(total_tracks), dbmfi_offsetof(disc), dbmfi_offsetof(total_discs), dbmfi_offsetof(bpm), dbmfi_offsetof(compilation), dbmfi_offsetof(rating), dbmfi_offsetof(play_count), dbmfi_offsetof(data_kind), dbmfi_offsetof(item_kind), dbmfi_offsetof(description), dbmfi_offsetof(time_added), dbmfi_offsetof(time_modified), dbmfi_offsetof(time_played), dbmfi_offsetof(db_timestamp), dbmfi_offsetof(disabled), dbmfi_offsetof(sample_count), dbmfi_offsetof(codectype), dbmfi_offsetof(idx), dbmfi_offsetof(has_video), dbmfi_offsetof(contentrating), dbmfi_offsetof(bits_per_sample), dbmfi_offsetof(album_artist), dbmfi_offsetof(media_kind), dbmfi_offsetof(tv_series_name), dbmfi_offsetof(tv_episode_num_str), dbmfi_offsetof(tv_network_name), dbmfi_offsetof(tv_episode_sort), dbmfi_offsetof(tv_season_num), dbmfi_offsetof(songalbumid), dbmfi_offsetof(title_sort), dbmfi_offsetof(artist_sort), dbmfi_offsetof(album_sort), dbmfi_offsetof(composer_sort), dbmfi_offsetof(album_artist_sort), }; /* This list must be kept in sync with * - the order of the columns in the playlists table * - the name of the fields in struct playlist_info */ static const ssize_t dbpli_cols_map[] = { dbpli_offsetof(id), dbpli_offsetof(title), dbpli_offsetof(type), dbpli_offsetof(query), dbpli_offsetof(db_timestamp), dbpli_offsetof(disabled), dbpli_offsetof(path), dbpli_offsetof(index), dbpli_offsetof(special_id), /* items is computed on the fly */ }; /* This list must be kept in sync with * - the order of fields in the Q_GROUPS query * - the name of the fields in struct group_info */ static const ssize_t dbgri_cols_map[] = { dbgri_offsetof(itemcount), dbgri_offsetof(id), dbgri_offsetof(persistentid), dbgri_offsetof(songalbumartist), dbgri_offsetof(itemname), }; /* This list must be kept in sync with * - the order of the columns in the inotify table * - the name and type of the fields in struct watch_info */ static const struct col_type_map wi_cols_map[] = { { wi_offsetof(wd), DB_TYPE_INT }, { wi_offsetof(cookie), DB_TYPE_INT }, { wi_offsetof(path), DB_TYPE_STRING }, }; /* Sort clauses */ /* Keep in sync with enum sort_type */ static const char *sort_clause[] = { "", "ORDER BY f.title_sort ASC", "ORDER BY f.album_sort ASC, f.disc ASC, f.track ASC", "ORDER BY f.artist_sort ASC", }; static char *db_path; static __thread struct db_pool_hdl *pool_hdl; static dispatch_queue_t dbpool_sq; static dispatch_source_t pool_reclaim_timer; static int pool_size; static int pool_free_size; static struct db_pool_hdl *pool_free; static struct db_pool_hdl *pool_used; /* Forward */ static int db_pl_count_items(int id); static int db_smartpl_count_items(const char *smartpl_query); struct playlist_info * db_pl_fetch_byid(int id); char * db_escape_string(const char *str) { char *escaped; char *ret; escaped = sqlite3_mprintf("%q", str); if (!escaped) { DPRINTF(E_LOG, L_DB, "Out of memory for escaped string\n"); return NULL; } ret = strdup(escaped); sqlite3_free(escaped); return ret; } void free_pi(struct pairing_info *pi, int content_only) { if (pi->remote_id) free(pi->remote_id); if (pi->name) free(pi->name); if (pi->guid) free(pi->guid); if (!content_only) free(pi); } void free_mfi(struct media_file_info *mfi, int content_only) { if (mfi->path) free(mfi->path); if (mfi->fname) free(mfi->fname); if (mfi->title) free(mfi->title); if (mfi->artist) free(mfi->artist); if (mfi->album) free(mfi->album); if (mfi->genre) free(mfi->genre); if (mfi->comment) free(mfi->comment); if (mfi->type) free(mfi->type); if (mfi->composer) free(mfi->composer); if (mfi->orchestra) free(mfi->orchestra); if (mfi->conductor) free(mfi->conductor); if (mfi->grouping) free(mfi->grouping); if (mfi->description) free(mfi->description); if (mfi->codectype) free(mfi->codectype); if (mfi->album_artist) free(mfi->album_artist); if (mfi->tv_series_name) free(mfi->tv_series_name); if (mfi->tv_episode_num_str) free(mfi->tv_episode_num_str); if (mfi->tv_network_name) free(mfi->tv_network_name); if (mfi->title_sort) free(mfi->title_sort); if (mfi->artist_sort) free(mfi->artist_sort); if (mfi->album_sort) free(mfi->album_sort); if (mfi->composer_sort) free(mfi->composer_sort); if (mfi->album_artist_sort) free(mfi->album_artist_sort); if (!content_only) free(mfi); } void unicode_fixup_mfi(struct media_file_info *mfi) { char *ret; char **field; int i; for (i = 0; i < (sizeof(mfi_cols_map) / sizeof(mfi_cols_map[0])); i++) { if (mfi_cols_map[i].type != DB_TYPE_STRING) continue; switch (mfi_cols_map[i].offset) { case mfi_offsetof(path): case mfi_offsetof(fname): case mfi_offsetof(codectype): continue; } field = (char **) ((char *)mfi + mfi_cols_map[i].offset); if (!*field) continue; ret = unicode_fixup_string(*field); if (ret != *field) { free(*field); *field = ret; } } } void free_pli(struct playlist_info *pli, int content_only) { if (pli->title) free(pli->title); if (pli->query) free(pli->query); if (pli->path) free(pli->path); if (!content_only) free(pli); } /* Unlock notification support */ static void unlock_notify_cb(void **args, int nargs) { struct db_unlock *u; int i; for (i = 0; i < nargs; i++) { u = (struct db_unlock *)args[i]; pthread_mutex_lock(&u->lck); u->proceed = 1; pthread_cond_signal(&u->cond); pthread_mutex_unlock(&u->lck); } } static int db_wait_unlock(void) { struct db_unlock u; int ret; u.proceed = 0; pthread_mutex_init(&u.lck, NULL); pthread_cond_init(&u.cond, NULL); ret = sqlite3_unlock_notify(pool_hdl->hdl, unlock_notify_cb, &u); if (ret == SQLITE_OK) { pthread_mutex_lock(&u.lck); if (!u.proceed) pthread_cond_wait(&u.cond, &u.lck); pthread_mutex_unlock(&u.lck); } pthread_cond_destroy(&u.cond); pthread_mutex_destroy(&u.lck); return ret; } static int db_blocking_step(sqlite3_stmt *stmt) { int ret; while ((ret = sqlite3_step(stmt)) == SQLITE_LOCKED) { ret = db_wait_unlock(); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Database deadlocked!\n"); break; } sqlite3_reset(stmt); } return ret; } static int db_blocking_prepare_v2(const char *query, int len, sqlite3_stmt **stmt, const char **end) { int ret; while ((ret = sqlite3_prepare_v2(pool_hdl->hdl, query, len, stmt, end)) == SQLITE_LOCKED) { ret = db_wait_unlock(); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Database deadlocked!\n"); break; } } return ret; } /* Modelled after sqlite3_exec() */ static int db_exec(const char *query, char **errmsg) { sqlite3_stmt *stmt; int try; int ret; *errmsg = NULL; for (try = 0; try < 5; try++) { ret = db_blocking_prepare_v2(query, -1, &stmt, NULL); if (ret != SQLITE_OK) { *errmsg = sqlite3_mprintf("prepare failed: %s", sqlite3_errmsg(pool_hdl->hdl)); return ret; } while ((ret = db_blocking_step(stmt)) == SQLITE_ROW) ; /* EMPTY */ sqlite3_finalize(stmt); if (ret != SQLITE_SCHEMA) break; } if (ret != SQLITE_DONE) { *errmsg = sqlite3_mprintf("step failed: %s", sqlite3_errmsg(pool_hdl->hdl)); return ret; } return SQLITE_OK; } /* Maintenance and DB hygiene */ static void db_analyze(void) { char *query = "ANALYZE;"; char *errmsg; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "ANALYZE failed: %s\n", errmsg); sqlite3_free(errmsg); } } void db_hook_post_scan(void) { DPRINTF(E_DBG, L_DB, "Running post-scan DB maintenance tasks...\n"); db_analyze(); DPRINTF(E_DBG, L_DB, "Done with post-scan DB maintenance\n"); } void db_purge_cruft(time_t ref) { char *errmsg; int i; int ret; char *queries[3] = { NULL, NULL, NULL }; char *queries_tmpl[3] = { "DELETE FROM playlistitems WHERE playlistid IN (SELECT id FROM playlists p WHERE p.type <> 1 AND p.db_timestamp < %" PRIi64 ");", "DELETE FROM playlists WHERE type <> 1 AND db_timestamp < %" PRIi64 ";", "DELETE FROM files WHERE db_timestamp < %" PRIi64 ";" }; if (sizeof(queries) != sizeof(queries_tmpl)) { DPRINTF(E_LOG, L_DB, "db_purge_cruft(): queries out of sync with queries_tmpl\n"); return; } for (i = 0; i < (sizeof(queries_tmpl) / sizeof(queries_tmpl[0])); i++) { queries[i] = sqlite3_mprintf(queries_tmpl[i], (int64_t)ref); if (!queries[i]) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); goto purge_fail; } } for (i = 0; i < (sizeof(queries) / sizeof(queries[0])); i++) { DPRINTF(E_DBG, L_DB, "Running purge query '%s'\n", queries[i]); ret = db_exec(queries[i], &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Purge query %d error: %s\n", i, errmsg); sqlite3_free(errmsg); } else DPRINTF(E_DBG, L_DB, "Purged %d rows\n", sqlite3_changes(pool_hdl->hdl)); } purge_fail: for (i = 0; i < (sizeof(queries) / sizeof(queries[0])); i++) { sqlite3_free(queries[i]); } } static int db_get_count(char *query) { sqlite3_stmt *stmt; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_blocking_prepare_v2(query, -1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return -1; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); return -1; } ret = sqlite3_column_int(stmt, 0); #ifdef DB_PROFILE while (db_blocking_step(stmt) == SQLITE_ROW) ; /* EMPTY */ #endif sqlite3_finalize(stmt); return ret; } /* Queries */ static int db_build_query_index_clause(struct query_params *qp, char **i) { char *idx; switch (qp->idx_type) { case I_FIRST: idx = sqlite3_mprintf("LIMIT %d", qp->limit); break; case I_LAST: idx = sqlite3_mprintf("LIMIT -1 OFFSET %d", qp->results - qp->limit); break; case I_SUB: idx = sqlite3_mprintf("LIMIT %d OFFSET %d", qp->limit, qp->offset); break; case I_NONE: *i = NULL; return 0; default: DPRINTF(E_LOG, L_DB, "Unknown index type\n"); return -1; } if (!idx) { DPRINTF(E_LOG, L_DB, "Could not build index string; out of memory"); return -1; } *i = idx; return 0; } static int db_build_query_items(struct query_params *qp, char **q) { char *query; char *count; char *idx; const char *sort; int ret; if (qp->filter) count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0 AND %s;", qp->filter); else count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0;"); if (!count) { DPRINTF(E_LOG, L_DB, "Out of memory for count query string\n"); return -1; } qp->results = db_get_count(count); sqlite3_free(count); if (qp->results < 0) return -1; /* Get index clause */ ret = db_build_query_index_clause(qp, &idx); if (ret < 0) return -1; sort = sort_clause[qp->sort]; if (idx && qp->filter) query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND %s %s %s;", qp->filter, sort, idx); else if (idx) query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 %s %s;", sort, idx); else if (qp->filter) query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND %s %s;", qp->filter, sort); else query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 %s;", sort); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } *q = query; return 0; } static int db_build_query_pls(struct query_params *qp, char **q) { char *query; char *idx; int ret; qp->results = db_get_count("SELECT COUNT(*) FROM playlists p WHERE p.disabled = 0;"); if (qp->results < 0) return -1; /* Get index clause */ ret = db_build_query_index_clause(qp, &idx); if (ret < 0) return -1; if (idx && qp->filter) query = sqlite3_mprintf("SELECT f.* FROM playlists f WHERE f.disabled = 0 AND %s %s;", qp->filter, idx); else if (idx) query = sqlite3_mprintf("SELECT f.* FROM playlists f WHERE f.disabled = 0 %s;", idx); else if (qp->filter) query = sqlite3_mprintf("SELECT f.* FROM playlists f WHERE f.disabled = 0 AND %s;", qp->filter); else query = sqlite3_mprintf("SELECT f.* FROM playlists f WHERE f.disabled = 0;"); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } *q = query; return 0; } static int db_build_query_plitems_plain(struct query_params *qp, char **q) { char *query; char *count; char *idx; int ret; if (qp->filter) count = sqlite3_mprintf("SELECT COUNT(*) FROM files f JOIN playlistitems pi ON f.path = pi.filepath" " WHERE pi.playlistid = %d AND f.disabled = 0 AND %s;", qp->id, qp->filter); else count = sqlite3_mprintf("SELECT COUNT(*) FROM files f JOIN playlistitems pi ON f.path = pi.filepath" " WHERE pi.playlistid = %d AND f.disabled = 0;", qp->id); if (!count) { DPRINTF(E_LOG, L_DB, "Out of memory for count query string\n"); return -1; } qp->results = db_get_count(count); sqlite3_free(count); if (qp->results < 0) return -1; /* Get index clause */ ret = db_build_query_index_clause(qp, &idx); if (ret < 0) return -1; if (idx && qp->filter) query = sqlite3_mprintf("SELECT f.* FROM files f JOIN playlistitems pi ON f.path = pi.filepath" " WHERE pi.playlistid = %d AND f.disabled = 0 AND %s ORDER BY pi.id ASC %s;", qp->id, qp->filter, idx); else if (idx) query = sqlite3_mprintf("SELECT f.* FROM files f JOIN playlistitems pi ON f.path = pi.filepath" " WHERE pi.playlistid = %d AND f.disabled = 0 ORDER BY pi.id ASC %s;", qp->id, idx); else if (qp->filter) query = sqlite3_mprintf("SELECT f.* FROM files f JOIN playlistitems pi ON f.path = pi.filepath" " WHERE pi.playlistid = %d AND f.disabled = 0 AND %s ORDER BY pi.id ASC;", qp->id, qp->filter); else query = sqlite3_mprintf("SELECT f.* FROM files f JOIN playlistitems pi ON f.path = pi.filepath" " WHERE pi.playlistid = %d AND f.disabled = 0 ORDER BY pi.id ASC;", qp->id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } *q = query; return 0; } static int db_build_query_plitems_smart(struct query_params *qp, char *smartpl_query, char **q) { char *query; char *count; char *filter; char *idx; const char *sort; int ret; if (qp->filter) filter = qp->filter; else filter = "1 = 1"; count = sqlite3_mprintf("SELECT COUNT(*) FROM files f WHERE f.disabled = 0 AND %s AND %s;", filter, smartpl_query); if (!count) { DPRINTF(E_LOG, L_DB, "Out of memory for count query string\n"); return -1; } qp->results = db_get_count(count); sqlite3_free(count); if (qp->results < 0) return -1; /* Get index clause */ ret = db_build_query_index_clause(qp, &idx); if (ret < 0) return -1; if (!idx) idx = ""; sort = sort_clause[qp->sort]; query = sqlite3_mprintf("SELECT f.* FROM files f WHERE f.disabled = 0 AND %s AND %s %s %s;", smartpl_query, filter, sort, idx); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } *q = query; return 0; } static int db_build_query_plitems(struct query_params *qp, char **q) { struct playlist_info *pli; int ret; if (qp->id <= 0) { DPRINTF(E_LOG, L_DB, "No playlist id specified in playlist items query\n"); return -1; } pli = db_pl_fetch_byid(qp->id); if (!pli) return -1; switch (pli->type) { case PL_SMART: ret = db_build_query_plitems_smart(qp, pli->query, q); break; case PL_PLAIN: ret = db_build_query_plitems_plain(qp, q); break; default: DPRINTF(E_LOG, L_DB, "Unknown playlist type %d in playlist items query\n", pli->type); ret = -1; break; } free_pli(pli, 0); return ret; } static int db_build_query_groups(struct query_params *qp, char **q) { char *query; char *idx; int ret; qp->results = db_get_count("SELECT COUNT(DISTINCT f.songalbumid) FROM files f WHERE f.disabled = 0;"); if (qp->results < 0) return -1; /* Get index clause */ ret = db_build_query_index_clause(qp, &idx); if (ret < 0) return -1; if (idx && qp->filter) query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album, g.name %s;", G_ALBUMS, qp->filter, idx); else if (idx) query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album, g.name %s;", G_ALBUMS, idx); else if (qp->filter) query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 AND %s GROUP BY f.album, g.name;", G_ALBUMS, qp->filter); else query = sqlite3_mprintf("SELECT COUNT(*), g.id, g.persistentid, f.album_artist, g.name FROM files f, groups g WHERE f.songalbumid = g.persistentid AND g.type = %d AND f.disabled = 0 GROUP BY f.album, g.name;", G_ALBUMS); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } *q = query; return 0; } static int db_build_query_groupitems(struct query_params *qp, char **q) { char *query; char *count; enum group_type gt; gt = db_group_type_byid(qp->id); switch (gt) { case G_ALBUMS: count = sqlite3_mprintf("SELECT COUNT(*) FROM files f JOIN groups g ON f.songalbumid = g.persistentid" " WHERE g.id = %d AND f.disabled = 0;", qp->id); break; default: DPRINTF(E_LOG, L_DB, "Unsupported group type %d for group id %d\n", gt, qp->id); return -1; } if (!count) { DPRINTF(E_LOG, L_DB, "Out of memory for count query string\n"); return -1; } qp->results = db_get_count(count); sqlite3_free(count); if (qp->results < 0) return -1; switch (gt) { case G_ALBUMS: query = sqlite3_mprintf("SELECT f.* FROM files f JOIN groups g ON f.songalbumid = g.persistentid" " WHERE g.id = %d AND f.disabled = 0;", qp->id); break; } if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } *q = query; return 0; } static int db_build_query_group_dirs(struct query_params *qp, char **q) { char *query; char *count; enum group_type gt; gt = db_group_type_byid(qp->id); switch (gt) { case G_ALBUMS: count = sqlite3_mprintf("SELECT COUNT(DISTINCT(SUBSTR(f.path, 1, LENGTH(f.path) - LENGTH(f.fname) - 1)))" " FROM files f JOIN groups g ON f.songalbumid = g.persistentid" " WHERE g.id = %d AND f.disabled = 0;", qp->id); break; default: DPRINTF(E_LOG, L_DB, "Unsupported group type %d for group id %d\n", gt, qp->id); return -1; } if (!count) { DPRINTF(E_LOG, L_DB, "Out of memory for count query string\n"); return -1; } qp->results = db_get_count(count); sqlite3_free(count); if (qp->results < 0) return -1; switch (gt) { case G_ALBUMS: query = sqlite3_mprintf("SELECT DISTINCT(SUBSTR(f.path, 1, LENGTH(f.path) - LENGTH(f.fname) - 1))" " FROM files f JOIN groups g ON f.songalbumid = g.persistentid" " WHERE g.id = %d AND f.disabled = 0;", qp->id); break; } if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } *q = query; return 0; } static int db_build_query_browse(struct query_params *qp, char *field, char **q) { char *query; char *count; char *idx; int ret; if (qp->filter) count = sqlite3_mprintf("SELECT COUNT(DISTINCT f.%s) FROM files f WHERE f.data_kind = 0 AND f.disabled = 0 AND f.%s != '' AND %s;", field, field, qp->filter); else count = sqlite3_mprintf("SELECT COUNT(DISTINCT f.%s) FROM files f WHERE f.data_kind = 0 AND f.disabled = 0 AND f.%s != '';", field, field); if (!count) { DPRINTF(E_LOG, L_DB, "Out of memory for count query string\n"); return -1; } qp->results = db_get_count(count); sqlite3_free(count); if (qp->results < 0) return -1; /* Get index clause */ ret = db_build_query_index_clause(qp, &idx); if (ret < 0) return -1; if (idx && qp->filter) query = sqlite3_mprintf("SELECT DISTINCT f.%s, f.%s FROM files f WHERE f.data_kind = 0 AND f.disabled = 0 AND f.%s != ''" " AND %s %s;", field, field, field, qp->filter, idx); else if (idx) query = sqlite3_mprintf("SELECT DISTINCT f.%s, f.%s FROM files f WHERE f.data_kind = 0 AND f.disabled = 0 AND f.%s != ''" " %s;", field, field, field, idx); else if (qp->filter) query = sqlite3_mprintf("SELECT DISTINCT f.%s, f.%s FROM files f WHERE f.data_kind = 0 AND f.disabled = 0 AND f.%s != ''" " AND %s;", field, field, field, qp->filter); else query = sqlite3_mprintf("SELECT DISTINCT f.%s, f.%s FROM files f WHERE f.data_kind = 0 AND f.disabled = 0 AND f.%s != ''", field, field, field); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } *q = query; return 0; } int db_query_start(struct query_params *qp) { char *query; int ret; qp->stmt = NULL; switch (qp->type) { case Q_ITEMS: ret = db_build_query_items(qp, &query); break; case Q_PL: ret = db_build_query_pls(qp, &query); break; case Q_PLITEMS: ret = db_build_query_plitems(qp, &query); break; case Q_GROUPS: ret = db_build_query_groups(qp, &query); break; case Q_GROUPITEMS: ret = db_build_query_groupitems(qp, &query); break; case Q_GROUP_DIRS: ret = db_build_query_group_dirs(qp, &query); break; case Q_BROWSE_ALBUMS: ret = db_build_query_browse(qp, "album", &query); break; case Q_BROWSE_ARTISTS: ret = db_build_query_browse(qp, "artist", &query); break; case Q_BROWSE_GENRES: ret = db_build_query_browse(qp, "genre", &query); break; case Q_BROWSE_COMPOSERS: ret = db_build_query_browse(qp, "composer", &query); break; default: DPRINTF(E_LOG, L_DB, "Unknown query type\n"); return -1; } if (ret < 0) return -1; DPRINTF(E_DBG, L_DB, "Starting query '%s'\n", query); ret = db_blocking_prepare_v2(query, -1, &qp->stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_free(query); return -1; } sqlite3_free(query); return 0; } void db_query_end(struct query_params *qp) { if (!qp->stmt) return; qp->results = -1; sqlite3_finalize(qp->stmt); qp->stmt = NULL; } int db_query_fetch_file(struct query_params *qp, struct db_media_file_info *dbmfi) { int ncols; char **strcol; int i; int ret; memset(dbmfi, 0, sizeof(struct db_media_file_info)); if (!qp->stmt) { DPRINTF(E_LOG, L_DB, "Query not started!\n"); return -1; } if ((qp->type != Q_ITEMS) && (qp->type != Q_PLITEMS) && (qp->type != Q_GROUPITEMS)) { DPRINTF(E_LOG, L_DB, "Not an items, playlist or group items query!\n"); return -1; } ret = db_blocking_step(qp->stmt); if (ret == SQLITE_DONE) { DPRINTF(E_INFO, L_DB, "End of query results\n"); dbmfi->id = NULL; return 0; } else if (ret != SQLITE_ROW) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return -1; } ncols = sqlite3_column_count(qp->stmt); if (sizeof(dbmfi_cols_map) / sizeof(dbmfi_cols_map[0]) != ncols) { DPRINTF(E_LOG, L_DB, "BUG: dbmfi column map out of sync with schema\n"); return -1; } for (i = 0; i < ncols; i++) { strcol = (char **) ((char *)dbmfi + dbmfi_cols_map[i]); *strcol = (char *)sqlite3_column_text(qp->stmt, i); } return 0; } int db_query_fetch_pl(struct query_params *qp, struct db_playlist_info *dbpli) { int ncols; char **strcol; int id; int type; int nitems; int i; int ret; memset(dbpli, 0, sizeof(struct db_playlist_info)); if (!qp->stmt) { DPRINTF(E_LOG, L_DB, "Query not started!\n"); return -1; } if (qp->type != Q_PL) { DPRINTF(E_LOG, L_DB, "Not a playlist query!\n"); return -1; } ret = db_blocking_step(qp->stmt); if (ret == SQLITE_DONE) { DPRINTF(E_INFO, L_DB, "End of query results\n"); dbpli->id = NULL; return 0; } else if (ret != SQLITE_ROW) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return -1; } ncols = sqlite3_column_count(qp->stmt); if (sizeof(dbpli_cols_map) / sizeof(dbpli_cols_map[0]) != ncols) { DPRINTF(E_LOG, L_DB, "BUG: dbpli column map out of sync with schema\n"); return -1; } for (i = 0; i < ncols; i++) { strcol = (char **) ((char *)dbpli + dbpli_cols_map[i]); *strcol = (char *)sqlite3_column_text(qp->stmt, i); } type = sqlite3_column_int(qp->stmt, 2); switch (type) { case PL_PLAIN: id = sqlite3_column_int(qp->stmt, 0); nitems = db_pl_count_items(id); break; case PL_SMART: nitems = db_smartpl_count_items(dbpli->query); break; default: DPRINTF(E_LOG, L_DB, "Unknown playlist type %d while fetching playlist\n", type); return -1; } dbpli->items = qp->buf; ret = snprintf(qp->buf, sizeof(qp->buf), "%d", nitems); if ((ret < 0) || (ret >= sizeof(qp->buf))) { DPRINTF(E_LOG, L_DB, "Could not convert items, buffer too small\n"); strcpy(qp->buf, "0"); } return 0; } int db_query_fetch_group(struct query_params *qp, struct db_group_info *dbgri) { int ncols; char **strcol; int i; int ret; memset(dbgri, 0, sizeof(struct db_group_info)); if (!qp->stmt) { DPRINTF(E_LOG, L_DB, "Query not started!\n"); return -1; } if (qp->type != Q_GROUPS) { DPRINTF(E_LOG, L_DB, "Not a groups query!\n"); return -1; } ret = db_blocking_step(qp->stmt); if (ret == SQLITE_DONE) { DPRINTF(E_INFO, L_DB, "End of query results\n"); return 1; } else if (ret != SQLITE_ROW) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return -1; } ncols = sqlite3_column_count(qp->stmt); if (sizeof(dbgri_cols_map) / sizeof(dbgri_cols_map[0]) != ncols) { DPRINTF(E_LOG, L_DB, "BUG: dbgri column map out of sync with schema\n"); return -1; } for (i = 0; i < ncols; i++) { strcol = (char **) ((char *)dbgri + dbgri_cols_map[i]); *strcol = (char *)sqlite3_column_text(qp->stmt, i); } return 0; } int db_query_fetch_string(struct query_params *qp, char **string) { int ret; *string = NULL; if (!qp->stmt) { DPRINTF(E_LOG, L_DB, "Query not started!\n"); return -1; } if (!(qp->type & Q_F_BROWSE)) { DPRINTF(E_LOG, L_DB, "Not a browse query!\n"); return -1; } ret = db_blocking_step(qp->stmt); if (ret == SQLITE_DONE) { DPRINTF(E_INFO, L_DB, "End of query results\n"); *string = NULL; return 0; } else if (ret != SQLITE_ROW) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return -1; } *string = (char *)sqlite3_column_text(qp->stmt, 0); return 0; } int db_query_fetch_string_sort(struct query_params *qp, char **string, char **sortstring) { int ret; *string = NULL; if (!qp->stmt) { DPRINTF(E_LOG, L_DB, "Query not started!\n"); return -1; } if (!(qp->type & Q_F_BROWSE)) { DPRINTF(E_LOG, L_DB, "Not a browse query!\n"); return -1; } ret = db_blocking_step(qp->stmt); if (ret == SQLITE_DONE) { DPRINTF(E_INFO, L_DB, "End of query results\n"); *string = NULL; return 0; } else if (ret != SQLITE_ROW) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return -1; } *string = (char *)sqlite3_column_text(qp->stmt, 0); *sortstring = (char *)sqlite3_column_text(qp->stmt, 1); return 0; } /* Files */ int db_files_get_count(void) { return db_get_count("SELECT COUNT(*) FROM files f WHERE f.disabled = 0;"); } void db_files_update_songalbumid(void) { #define Q_SONGALBUMID "UPDATE files SET songalbumid = daap_songalbumid(album_artist, album);" char *errmsg; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", Q_SONGALBUMID); ret = db_exec(Q_SONGALBUMID, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error updating songalbumid: %s\n", errmsg); sqlite3_free(errmsg); #undef Q_SONGALBUMID } void db_file_inc_playcount(int id) { #define Q_TMPL "UPDATE files SET play_count = play_count + 1, time_played = %" PRIi64 " WHERE id = %d;" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, (int64_t)time(NULL), id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error incrementing play count on %d: %s\n", id, errmsg); sqlite3_free(errmsg); sqlite3_free(query); #undef Q_TMPL } void db_file_ping(int id) { #define Q_TMPL "UPDATE files SET db_timestamp = %" PRIi64 ", disabled = 0 WHERE id = %d;" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, (int64_t)time(NULL), id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error pinging file ID %d: %s\n", id, errmsg); sqlite3_free(errmsg); sqlite3_free(query); #undef Q_TMPL } char * db_file_path_byid(int id) { #define Q_TMPL "SELECT f.path FROM files f WHERE f.id = %d;" char *query; sqlite3_stmt *stmt; char *res; int ret; query = sqlite3_mprintf(Q_TMPL, id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return NULL; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_blocking_prepare_v2(query, strlen(query) + 1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_free(query); return NULL; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { if (ret == SQLITE_DONE) DPRINTF(E_INFO, L_DB, "No results\n"); else DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); sqlite3_free(query); return NULL; } res = (char *)sqlite3_column_text(stmt, 0); if (res) res = strdup(res); #ifdef DB_PROFILE while (db_blocking_step(stmt) == SQLITE_ROW) ; /* EMPTY */ #endif sqlite3_finalize(stmt); sqlite3_free(query); return res; #undef Q_TMPL } static int db_file_id_byquery(char *query) { sqlite3_stmt *stmt; int ret; if (!query) return 0; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_blocking_prepare_v2(query, strlen(query) + 1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return 0; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { if (ret == SQLITE_DONE) DPRINTF(E_INFO, L_DB, "No results\n"); else DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); return 0; } ret = sqlite3_column_int(stmt, 0); #ifdef DB_PROFILE while (db_blocking_step(stmt) == SQLITE_ROW) ; /* EMPTY */ #endif sqlite3_finalize(stmt); return ret; } int db_file_id_bypath(char *path) { #define Q_TMPL "SELECT f.id FROM files f WHERE f.path = '%q';" char *query; int ret; query = sqlite3_mprintf(Q_TMPL, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return 0; } ret = db_file_id_byquery(query); sqlite3_free(query); return ret; #undef Q_TMPL } int db_file_id_byfilebase(char *filename, char *base) { #define Q_TMPL "SELECT f.id FROM files f WHERE f.path LIKE '%q/%%/%q';" char *query; int ret; query = sqlite3_mprintf(Q_TMPL, base, filename); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return 0; } ret = db_file_id_byquery(query); sqlite3_free(query); return ret; #undef Q_TMPL } int db_file_id_byfile(char *filename) { #define Q_TMPL "SELECT f.id FROM files f WHERE f.fname = '%q';" char *query; int ret; query = sqlite3_mprintf(Q_TMPL, filename); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return 0; } ret = db_file_id_byquery(query); sqlite3_free(query); return ret; #undef Q_TMPL } int db_file_id_byurl(char *url) { #define Q_TMPL "SELECT f.id FROM files f WHERE f.url = '%q';" char *query; int ret; query = sqlite3_mprintf(Q_TMPL, url); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return 0; } ret = db_file_id_byquery(query); sqlite3_free(query); return ret; #undef Q_TMPL } void db_file_stamp_bypath(char *path, time_t *stamp, int *id) { #define Q_TMPL "SELECT f.id, f.db_timestamp FROM files f WHERE f.path = '%q';" char *query; sqlite3_stmt *stmt; int ret; *stamp = 0; query = sqlite3_mprintf(Q_TMPL, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_blocking_prepare_v2(query, strlen(query) + 1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_free(query); return; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { if (ret == SQLITE_DONE) DPRINTF(E_INFO, L_DB, "No results\n"); else DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); sqlite3_free(query); return; } *id = sqlite3_column_int(stmt, 0); *stamp = (time_t)sqlite3_column_int64(stmt, 1); #ifdef DB_PROFILE while (db_blocking_step(stmt) == SQLITE_ROW) ; /* EMPTY */ #endif sqlite3_finalize(stmt); sqlite3_free(query); #undef Q_TMPL } static struct media_file_info * db_file_fetch_byquery(char *query) { struct media_file_info *mfi; sqlite3_stmt *stmt; int ncols; char *cval; uint32_t *ival; uint64_t *i64val; char **strval; uint64_t disabled; int i; int ret; if (!query) return NULL; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); mfi = (struct media_file_info *)malloc(sizeof(struct media_file_info)); if (!mfi) { DPRINTF(E_LOG, L_DB, "Could not allocate struct media_file_info, out of memory\n"); return NULL; } memset(mfi, 0, sizeof(struct media_file_info)); ret = db_blocking_prepare_v2(query, -1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); free(mfi); return NULL; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { if (ret == SQLITE_DONE) DPRINTF(E_INFO, L_DB, "No results\n"); else DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); free(mfi); return NULL; } ncols = sqlite3_column_count(stmt); if (sizeof(mfi_cols_map) / sizeof(mfi_cols_map[0]) != ncols) { DPRINTF(E_LOG, L_DB, "BUG: mfi column map out of sync with schema\n"); sqlite3_finalize(stmt); free(mfi); return NULL; } for (i = 0; i < ncols; i++) { switch (mfi_cols_map[i].type) { case DB_TYPE_CHAR: cval = (char *)mfi + mfi_cols_map[i].offset; *cval = sqlite3_column_int(stmt, i); break; case DB_TYPE_INT: ival = (uint32_t *) ((char *)mfi + mfi_cols_map[i].offset); if (mfi_cols_map[i].offset == mfi_offsetof(disabled)) { disabled = sqlite3_column_int64(stmt, i); *ival = (disabled != 0); } else *ival = sqlite3_column_int(stmt, i); break; case DB_TYPE_INT64: i64val = (uint64_t *) ((char *)mfi + mfi_cols_map[i].offset); *i64val = sqlite3_column_int64(stmt, i); break; case DB_TYPE_STRING: strval = (char **) ((char *)mfi + mfi_cols_map[i].offset); cval = (char *)sqlite3_column_text(stmt, i); if (cval) *strval = strdup(cval); break; default: DPRINTF(E_LOG, L_DB, "BUG: Unknown type %d in mfi column map\n", mfi_cols_map[i].type); free_mfi(mfi, 0); sqlite3_finalize(stmt); return NULL; } } #ifdef DB_PROFILE while (db_blocking_step(stmt) == SQLITE_ROW) ; /* EMPTY */ #endif sqlite3_finalize(stmt); return mfi; } struct media_file_info * db_file_fetch_byid(int id) { #define Q_TMPL "SELECT f.* FROM files f WHERE f.id = %d;" struct media_file_info *mfi; char *query; query = sqlite3_mprintf(Q_TMPL, id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return NULL; } mfi = db_file_fetch_byquery(query); sqlite3_free(query); return mfi; #undef Q_TMPL } int db_file_add(struct media_file_info *mfi) { #define Q_TMPL "INSERT INTO files (id, path, fname, title, artist, album, genre, comment, type, composer," \ " orchestra, conductor, grouping, url, bitrate, samplerate, song_length, file_size, year, track," \ " total_tracks, disc, total_discs, bpm, compilation, rating, play_count, data_kind, item_kind," \ " description, time_added, time_modified, time_played, db_timestamp, disabled, sample_count," \ " codectype, idx, has_video, contentrating, bits_per_sample, album_artist," \ " media_kind, tv_series_name, tv_episode_num_str, tv_network_name, tv_episode_sort, tv_season_num, " \ " songalbumid, title_sort, artist_sort, album_sort, composer_sort, album_artist_sort" \ " ) " \ " VALUES (NULL, '%q', '%q', TRIM(%Q), TRIM(%Q), TRIM(%Q), TRIM(%Q), TRIM(%Q), %Q, TRIM(%Q)," \ " TRIM(%Q), TRIM(%Q), TRIM(%Q), %Q, %d, %d, %d, %" PRIi64 ", %d, %d," \ " %d, %d, %d, %d, %d, %d, %d, %d, %d," \ " %Q, %" PRIi64 ", %" PRIi64 ", %" PRIi64 ", %" PRIi64 ", %d, %" PRIi64 "," \ " %Q, %d, %d, %d, %d, TRIM(%Q), %d, TRIM(%Q), TRIM(%Q), TRIM(%Q), %d, %d, daap_songalbumid(TRIM(%Q), TRIM(%Q))," \ " TRIM(%Q), TRIM(%Q), TRIM(%Q), TRIM(%Q), TRIM(%Q));" char *query; char *errmsg; int ret; if (mfi->id != 0) { DPRINTF(E_WARN, L_DB, "Trying to add file with non-zero id; use db_file_update()?\n"); return -1; } mfi->db_timestamp = (uint64_t)time(NULL); mfi->time_added = mfi->db_timestamp; if (mfi->time_modified == 0) mfi->time_modified = mfi->db_timestamp; query = sqlite3_mprintf(Q_TMPL, STR(mfi->path), STR(mfi->fname), mfi->title, mfi->artist, mfi->album, mfi->genre, mfi->comment, mfi->type, mfi->composer, mfi->orchestra, mfi->conductor, mfi->grouping, mfi->url, mfi->bitrate, mfi->samplerate, mfi->song_length, mfi->file_size, mfi->year, mfi->track, mfi->total_tracks, mfi->disc, mfi->total_discs, mfi->bpm, mfi->compilation, mfi->rating, mfi->play_count, mfi->data_kind, mfi->item_kind, mfi->description, (int64_t)mfi->time_added, (int64_t)mfi->time_modified, (int64_t)mfi->time_played, (int64_t)mfi->db_timestamp, mfi->disabled, mfi->sample_count, mfi->codectype, mfi->index, mfi->has_video, mfi->contentrating, mfi->bits_per_sample, mfi->album_artist, mfi->media_kind, mfi->tv_series_name, mfi->tv_episode_num_str, mfi->tv_network_name, mfi->tv_episode_sort, mfi->tv_season_num, mfi->album_artist, mfi->album, mfi->title_sort, mfi->artist_sort, mfi->album_sort, mfi->composer_sort, mfi->album_artist_sort); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Query error: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); return 0; #undef Q_TMPL } int db_file_update(struct media_file_info *mfi) { #define Q_TMPL "UPDATE files SET path = '%q', fname = '%q', title = TRIM(%Q), artist = TRIM(%Q), album = TRIM(%Q), genre = TRIM(%Q)," \ " comment = TRIM(%Q), type = %Q, composer = TRIM(%Q), orchestra = TRIM(%Q), conductor = TRIM(%Q), grouping = TRIM(%Q)," \ " url = %Q, bitrate = %d, samplerate = %d, song_length = %d, file_size = %" PRIi64 "," \ " year = %d, track = %d, total_tracks = %d, disc = %d, total_discs = %d, bpm = %d," \ " compilation = %d, rating = %d, data_kind = %d, item_kind = %d," \ " description = %Q, time_modified = %" PRIi64 "," \ " db_timestamp = %" PRIi64 ", sample_count = %" PRIi64 "," \ " codectype = %Q, idx = %d, has_video = %d," \ " bits_per_sample = %d, album_artist = TRIM(%Q)," \ " media_kind = %d, tv_series_name = TRIM(%Q), tv_episode_num_str = TRIM(%Q)," \ " tv_network_name = TRIM(%Q), tv_episode_sort = %d, tv_season_num = %d," \ " songalbumid = daap_songalbumid(TRIM(%Q), TRIM(%Q))," \ " title_sort = TRIM(%Q), artist_sort = TRIM(%Q), album_sort = TRIM(%Q), composer_sort = TRIM(%Q), album_artist_sort = TRIM(%Q)" \ " WHERE id = %d;" char *query; char *errmsg; int ret; if (mfi->id == 0) { DPRINTF(E_WARN, L_DB, "Trying to update file with id 0; use db_file_add()?\n"); return -1; } mfi->db_timestamp = (uint64_t)time(NULL); if (mfi->time_modified == 0) mfi->time_modified = mfi->db_timestamp; query = sqlite3_mprintf(Q_TMPL, STR(mfi->path), STR(mfi->fname), mfi->title, mfi->artist, mfi->album, mfi->genre, mfi->comment, mfi->type, mfi->composer, mfi->orchestra, mfi->conductor, mfi->grouping, mfi->url, mfi->bitrate, mfi->samplerate, mfi->song_length, mfi->file_size, mfi->year, mfi->track, mfi->total_tracks, mfi->disc, mfi->total_discs, mfi->bpm, mfi->compilation, mfi->rating, mfi->data_kind, mfi->item_kind, mfi->description, (int64_t)mfi->time_modified, (int64_t)mfi->db_timestamp, mfi->sample_count, mfi->codectype, mfi->index, mfi->has_video, mfi->bits_per_sample, mfi->album_artist, mfi->media_kind, mfi->tv_series_name, mfi->tv_episode_num_str, mfi->tv_network_name, mfi->tv_episode_sort, mfi->tv_season_num, mfi->album_artist, mfi->album, mfi->title_sort, mfi->artist_sort, mfi->album_sort, mfi->composer_sort, mfi->album_artist_sort, mfi->id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Query error: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); return 0; #undef Q_TMPL } void db_file_delete_bypath(char *path) { #define Q_TMPL "DELETE FROM files WHERE path = '%q';" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error deleting file: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); #undef Q_TMPL } static void db_file_disable_byquery(char *query) { char *errmsg; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error disabling file: %s\n", errmsg); sqlite3_free(errmsg); } void db_file_disable_bypath(char *path, char *strip, uint32_t cookie) { #define Q_TMPL "UPDATE files SET path = substr(path, %d), disabled = %" PRIi64 " WHERE path = '%q';" char *query; int64_t disabled; int striplen; disabled = (cookie != 0) ? cookie : INOTIFY_FAKE_COOKIE; striplen = strlen(strip) + 1; query = sqlite3_mprintf(Q_TMPL, striplen, disabled, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } db_file_disable_byquery(query); sqlite3_free(query); #undef Q_TMPL } void db_file_disable_bymatch(char *path, char *strip, uint32_t cookie) { #define Q_TMPL "UPDATE files SET path = substr(path, %d), disabled = %" PRIi64 " WHERE path LIKE '%q/%%';" char *query; int64_t disabled; int striplen; disabled = (cookie != 0) ? cookie : INOTIFY_FAKE_COOKIE; striplen = strlen(strip) + 1; query = sqlite3_mprintf(Q_TMPL, striplen, disabled, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } db_file_disable_byquery(query); sqlite3_free(query); #undef Q_TMPL } int db_file_enable_bycookie(uint32_t cookie, char *path) { #define Q_TMPL "UPDATE files SET path = '%q' || path, disabled = 0 WHERE disabled = %" PRIi64 ";" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, path, (int64_t)cookie); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error enabling files: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); return sqlite3_changes(pool_hdl->hdl); #undef Q_TMPL } /* Playlists */ int db_pl_get_count(void) { return db_get_count("SELECT COUNT(*) FROM playlists p WHERE p.disabled = 0;"); } static int db_pl_count_items(int id) { #define Q_TMPL "SELECT COUNT(*) FROM playlistitems pi JOIN files f" \ " ON pi.filepath = f.path WHERE f.disabled = 0 AND pi.playlistid = %d;" char *query; int ret; query = sqlite3_mprintf(Q_TMPL, id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return 0; } ret = db_get_count(query); sqlite3_free(query); return ret; #undef Q_TMPL } static int db_smartpl_count_items(const char *smartpl_query) { #define Q_TMPL "SELECT COUNT(*) FROM files f WHERE f.disabled = 0 AND %s;" char *query; int ret; query = sqlite3_mprintf(Q_TMPL, smartpl_query); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return 0; } ret = db_get_count(query); sqlite3_free(query); return ret; #undef Q_TMPL } void db_pl_ping(int id) { #define Q_TMPL "UPDATE playlists SET db_timestamp = %" PRIi64 ", disabled = 0 WHERE id = %d;" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, (int64_t)time(NULL), id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error pinging playlist %d: %s\n", id, errmsg); sqlite3_free(errmsg); sqlite3_free(query); #undef Q_TMPL } static int db_pl_id_bypath(char *path, int *id) { #define Q_TMPL "SELECT p.id FROM playlists p WHERE p.path = '%q';" char *query; sqlite3_stmt *stmt; int ret; query = sqlite3_mprintf(Q_TMPL, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_blocking_prepare_v2(query, -1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_free(query); return -1; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { if (ret == SQLITE_DONE) DPRINTF(E_INFO, L_DB, "No results\n"); else DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); sqlite3_free(query); return -1; } *id = sqlite3_column_int(stmt, 0); #ifdef DB_PROFILE while (db_blocking_step(stmt) == SQLITE_ROW) ; /* EMPTY */ #endif sqlite3_finalize(stmt); sqlite3_free(query); return 0; #undef Q_TMPL } static struct playlist_info * db_pl_fetch_byquery(char *query) { struct playlist_info *pli; sqlite3_stmt *stmt; int ncols; char *cval; uint32_t *ival; char **strval; uint64_t disabled; int i; int ret; if (!query) return NULL; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); pli = (struct playlist_info *)malloc(sizeof(struct playlist_info)); if (!pli) { DPRINTF(E_LOG, L_DB, "Could not allocate struct playlist_info, out of memory\n"); return NULL; } memset(pli, 0, sizeof(struct playlist_info)); ret = db_blocking_prepare_v2(query, -1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); free(pli); return NULL; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { if (ret == SQLITE_DONE) DPRINTF(E_INFO, L_DB, "No results\n"); else DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); free(pli); return NULL; } ncols = sqlite3_column_count(stmt); if (sizeof(pli_cols_map) / sizeof(pli_cols_map[0]) != ncols) { DPRINTF(E_LOG, L_DB, "BUG: pli column map out of sync with schema\n"); sqlite3_finalize(stmt); free(pli); return NULL; } for (i = 0; i < ncols; i++) { switch (pli_cols_map[i].type) { case DB_TYPE_INT: ival = (uint32_t *) ((char *)pli + pli_cols_map[i].offset); if (pli_cols_map[i].offset == pli_offsetof(disabled)) { disabled = sqlite3_column_int64(stmt, i); *ival = (disabled != 0); } else *ival = sqlite3_column_int(stmt, i); break; case DB_TYPE_STRING: strval = (char **) ((char *)pli + pli_cols_map[i].offset); cval = (char *)sqlite3_column_text(stmt, i); if (cval) *strval = strdup(cval); break; default: DPRINTF(E_LOG, L_DB, "BUG: Unknown type %d in pli column map\n", pli_cols_map[i].type); sqlite3_finalize(stmt); free_pli(pli, 0); return NULL; } } ret = db_blocking_step(stmt); sqlite3_finalize(stmt); if (ret != SQLITE_DONE) { DPRINTF(E_WARN, L_DB, "Query had more than a single result!\n"); free_pli(pli, 0); return NULL; } switch (pli->type) { case PL_PLAIN: pli->items = db_pl_count_items(pli->id); break; case PL_SMART: pli->items = db_smartpl_count_items(pli->query); break; default: DPRINTF(E_LOG, L_DB, "Unknown playlist type %d while fetching playlist\n", pli->type); free_pli(pli, 0); return NULL; } return pli; } struct playlist_info * db_pl_fetch_bypath(char *path) { #define Q_TMPL "SELECT p.* FROM playlists p WHERE p.path = '%q';" struct playlist_info *pli; char *query; query = sqlite3_mprintf(Q_TMPL, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return NULL; } pli = db_pl_fetch_byquery(query); sqlite3_free(query); return pli; #undef Q_TMPL } struct playlist_info * db_pl_fetch_byid(int id) { #define Q_TMPL "SELECT p.* FROM playlists p WHERE p.id = %d;" struct playlist_info *pli; char *query; query = sqlite3_mprintf(Q_TMPL, id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return NULL; } pli = db_pl_fetch_byquery(query); sqlite3_free(query); return pli; #undef Q_TMPL } struct playlist_info * db_pl_fetch_bytitlepath(char *title, char *path) { #define Q_TMPL "SELECT p.* FROM playlists p WHERE p.title = '%q' AND p.path = '%q';" struct playlist_info *pli; char *query; query = sqlite3_mprintf(Q_TMPL, title, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return NULL; } pli = db_pl_fetch_byquery(query); sqlite3_free(query); return pli; #undef Q_TMPL } int db_pl_add(char *title, char *path, int *id) { #define QDUP_TMPL "SELECT COUNT(*) FROM playlists p WHERE p.title = '%q' AND p.path = '%q';" #define QADD_TMPL "INSERT INTO playlists (title, type, query, db_timestamp, disabled, path, idx, special_id)" \ " VALUES ('%q', 0, NULL, %" PRIi64 ", 0, '%q', 0, 0);" char *query; char *errmsg; int ret; /* Check duplicates */ query = sqlite3_mprintf(QDUP_TMPL, title, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } ret = db_get_count(query); sqlite3_free(query); if (ret > 0) { DPRINTF(E_WARN, L_DB, "Duplicate playlist with title '%s' path '%s'\n", title, path); return -1; } /* Add */ query = sqlite3_mprintf(QADD_TMPL, title, (int64_t)time(NULL), path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Query error: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); *id = (int)sqlite3_last_insert_rowid(pool_hdl->hdl); if (*id == 0) { DPRINTF(E_LOG, L_DB, "Successful insert but no last_insert_rowid!\n"); return -1; } DPRINTF(E_DBG, L_DB, "Added playlist %s (path %s) with id %d\n", title, path, *id); return 0; #undef QDUP_TMPL #undef QADD_TMPL } int db_pl_add_item_bypath(int plid, char *path) { #define Q_TMPL "INSERT INTO playlistitems (playlistid, filepath) VALUES (%d, '%q');" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, plid, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Query error: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); return 0; #undef Q_TMPL } int db_pl_add_item_byid(int plid, int fileid) { #define Q_TMPL "INSERT INTO playlistitems (playlistid, filepath) VALUES (%d, (SELECT f.path FROM files f WHERE f.id = %d));" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, plid, fileid); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Query error: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); return 0; #undef Q_TMPL } void db_pl_clear_items(int id) { #define Q_TMPL "DELETE FROM playlistitems WHERE playlistid = %d;" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error clearing playlist %d items: %s\n", id, errmsg); sqlite3_free(errmsg); sqlite3_free(query); #undef Q_TMPL } void db_pl_delete(int id) { #define Q_TMPL "DELETE FROM playlists WHERE id = %d;" char *query; char *errmsg; int ret; if (id == 1) return; query = sqlite3_mprintf(Q_TMPL, id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error deleting playlist %d: %s\n", id, errmsg); sqlite3_free(errmsg); sqlite3_free(query); db_pl_clear_items(id); #undef Q_TMPL } void db_pl_delete_bypath(char *path) { int id; int ret; ret = db_pl_id_bypath(path, &id); if (ret < 0) return; db_pl_delete(id); } static void db_pl_disable_byquery(char *query) { char *errmsg; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error disabling playlist: %s\n", errmsg); sqlite3_free(errmsg); } void db_pl_disable_bypath(char *path, char *strip, uint32_t cookie) { #define Q_TMPL "UPDATE playlists SET path = substr(path, %d), disabled = %" PRIi64 " WHERE path = '%q';" char *query; int64_t disabled; int striplen; disabled = (cookie != 0) ? cookie : INOTIFY_FAKE_COOKIE; striplen = strlen(strip) + 1; query = sqlite3_mprintf(Q_TMPL, striplen, disabled, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } db_pl_disable_byquery(query); sqlite3_free(query); #undef Q_TMPL } void db_pl_disable_bymatch(char *path, char *strip, uint32_t cookie) { #define Q_TMPL "UPDATE playlists SET path = substr(path, %d), disabled = %" PRIi64 " WHERE path LIKE '%q/%%';" char *query; int64_t disabled; int striplen; disabled = (cookie != 0) ? cookie : INOTIFY_FAKE_COOKIE; striplen = strlen(strip) + 1; query = sqlite3_mprintf(Q_TMPL, striplen, disabled, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } db_pl_disable_byquery(query); sqlite3_free(query); #undef Q_TMPL } int db_pl_enable_bycookie(uint32_t cookie, char *path) { #define Q_TMPL "UPDATE playlists SET path = '%q' || path, disabled = 0 WHERE disabled = %" PRIi64 ";" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, path, (int64_t)cookie); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error enabling playlists: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); return sqlite3_changes(pool_hdl->hdl); #undef Q_TMPL } /* Groups */ int db_groups_clear(void) { char *query = "DELETE FROM groups;"; char *errmsg; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Query error: %s\n", errmsg); sqlite3_free(errmsg); return -1; } return 0; } enum group_type db_group_type_byid(int id) { #define Q_TMPL "SELECT g.type FROM groups g WHERE g.id = '%d';" char *query; sqlite3_stmt *stmt; int ret; query = sqlite3_mprintf(Q_TMPL, id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return 0; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_blocking_prepare_v2(query, strlen(query) + 1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_free(query); return 0; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { if (ret == SQLITE_DONE) DPRINTF(E_INFO, L_DB, "No results\n"); else DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); sqlite3_free(query); return 0; } ret = sqlite3_column_int(stmt, 0); #ifdef DB_PROFILE while (db_blocking_step(stmt) == SQLITE_ROW) ; /* EMPTY */ #endif sqlite3_finalize(stmt); sqlite3_free(query); return ret; #undef Q_TMPL } /* Remotes */ static int db_pairing_delete_byremote(char *remote_id) { #define Q_TMPL "DELETE FROM pairings WHERE remote = '%q';" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, remote_id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error deleting pairing: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); return 0; #undef Q_TMPL } int db_pairing_add(struct pairing_info *pi) { #define Q_TMPL "INSERT INTO pairings (remote, name, guid) VALUES ('%q', '%q', '%q');" char *query; char *errmsg; int ret; ret = db_pairing_delete_byremote(pi->remote_id); if (ret < 0) return ret; query = sqlite3_mprintf(Q_TMPL, pi->remote_id, pi->name, pi->guid); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error adding pairing: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); return 0; #undef Q_TMPL } int db_pairing_fetch_byguid(struct pairing_info *pi) { #define Q_TMPL "SELECT p.* FROM pairings p WHERE p.guid = '%q';" char *query; sqlite3_stmt *stmt; int ret; query = sqlite3_mprintf(Q_TMPL, pi->guid); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_blocking_prepare_v2(query, -1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return -1; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { if (ret == SQLITE_DONE) DPRINTF(E_INFO, L_DB, "Pairing GUID %s not found\n", pi->guid); else DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); sqlite3_free(query); return -1; } pi->remote_id = strdup((char *)sqlite3_column_text(stmt, 0)); pi->name = strdup((char *)sqlite3_column_text(stmt, 1)); #ifdef DB_PROFILE while (db_blocking_step(stmt) == SQLITE_ROW) ; /* EMPTY */ #endif sqlite3_finalize(stmt); sqlite3_free(query); return 0; #undef Q_TMPL } /* Speakers */ int db_speaker_save(uint64_t id, int selected, int volume) { #define Q_TMPL "INSERT OR REPLACE INTO speakers (id, selected, volume) VALUES (%" PRIi64 ", %d, %d);" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, id, selected, volume); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); errmsg = NULL; ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error saving speaker state: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); return 0; #undef Q_TMPL } int db_speaker_get(uint64_t id, int *selected, int *volume) { #define Q_TMPL "SELECT s.selected, s.volume FROM speakers s WHERE s.id = %" PRIi64 ";" sqlite3_stmt *stmt; char *query; int ret; query = sqlite3_mprintf(Q_TMPL, id); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_blocking_prepare_v2(query, -1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); ret = -1; goto out; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { if (ret != SQLITE_DONE) DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); ret = -1; goto out; } *selected = sqlite3_column_int(stmt, 0); *volume = sqlite3_column_int(stmt, 1); #ifdef DB_PROFILE while (db_blocking_step(stmt) == SQLITE_ROW) ; /* EMPTY */ #endif sqlite3_finalize(stmt); ret = 0; out: sqlite3_free(query); return ret; #undef Q_TMPL } void db_speaker_clear_all(void) { char *query = "UPDATE speakers SET selected = 0;"; char *errmsg; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Query error: %s\n", errmsg); sqlite3_free(errmsg); } } /* Inotify */ int db_watch_clear(void) { char *query = "DELETE FROM inotify;"; char *errmsg; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Query error: %s\n", errmsg); sqlite3_free(errmsg); return -1; } return 0; } int db_watch_add(struct watch_info *wi) { #define Q_TMPL "INSERT INTO inotify (wd, cookie, path) VALUES (%d, 0, '%q');" char *query; char *errmsg; int ret; query = sqlite3_mprintf(Q_TMPL, wi->wd, wi->path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error adding watch: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } sqlite3_free(query); return 0; #undef Q_TMPL } static int db_watch_delete_byquery(char *query) { char *errmsg; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error deleting watch: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); return -1; } return 0; } int db_watch_delete_bywd(uint32_t wd) { #define Q_TMPL "DELETE FROM inotify WHERE wd = %d;" char *query; int ret; query = sqlite3_mprintf(Q_TMPL, wd); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } ret = db_watch_delete_byquery(query); sqlite3_free(query); return ret; #undef Q_TMPL } int db_watch_delete_bypath(char *path) { #define Q_TMPL "DELETE FROM inotify WHERE path = '%q';" char *query; int ret; query = sqlite3_mprintf(Q_TMPL, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } ret = db_watch_delete_byquery(query); sqlite3_free(query); return ret; #undef Q_TMPL } int db_watch_delete_bymatch(char *path) { #define Q_TMPL "DELETE FROM inotify WHERE path LIKE '%q/%%';" char *query; int ret; query = sqlite3_mprintf(Q_TMPL, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } ret = db_watch_delete_byquery(query); sqlite3_free(query); return ret; #undef Q_TMPL } int db_watch_delete_bycookie(uint32_t cookie) { #define Q_TMPL "DELETE FROM inotify WHERE cookie = %" PRIi64 ";" char *query; int ret; if (cookie == 0) return -1; query = sqlite3_mprintf(Q_TMPL, (int64_t)cookie); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } ret = db_watch_delete_byquery(query); sqlite3_free(query); return ret; #undef Q_TMPL } int db_watch_get_bywd(struct watch_info *wi) { #define Q_TMPL "SELECT * FROM inotify WHERE wd = %d;" char *query; sqlite3_stmt *stmt; char **strval; char *cval; uint32_t *ival; int64_t cookie; int ncols; int i; int ret; query = sqlite3_mprintf(Q_TMPL, wi->wd); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_blocking_prepare_v2(query, -1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return -1; } ret = db_blocking_step(stmt); if (ret != SQLITE_ROW) { DPRINTF(E_LOG, L_DB, "Watch wd %d not found\n", wi->wd); sqlite3_finalize(stmt); sqlite3_free(query); return -1; } ncols = sqlite3_column_count(stmt); if (sizeof(wi_cols_map) / sizeof(wi_cols_map[0]) != ncols) { DPRINTF(E_LOG, L_DB, "BUG: wi column map out of sync with schema\n"); sqlite3_finalize(stmt); sqlite3_free(query); return -1; } for (i = 0; i < ncols; i++) { switch (wi_cols_map[i].type) { case DB_TYPE_INT: ival = (uint32_t *) ((char *)wi + wi_cols_map[i].offset); if (wi_cols_map[i].offset == wi_offsetof(cookie)) { cookie = sqlite3_column_int64(stmt, i); *ival = (cookie == INOTIFY_FAKE_COOKIE) ? 0 : cookie; } else *ival = sqlite3_column_int(stmt, i); break; case DB_TYPE_STRING: strval = (char **) ((char *)wi + wi_cols_map[i].offset); cval = (char *)sqlite3_column_text(stmt, i); if (cval) *strval = strdup(cval); break; default: DPRINTF(E_LOG, L_DB, "BUG: Unknown type %d in wi column map\n", wi_cols_map[i].type); sqlite3_finalize(stmt); sqlite3_free(query); return -1; } } #ifdef DB_PROFILE while (db_blocking_step(stmt) == SQLITE_ROW) ; /* EMPTY */ #endif sqlite3_finalize(stmt); sqlite3_free(query); return 0; #undef Q_TMPL } static void db_watch_mark_byquery(char *query) { char *errmsg; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error marking watch: %s\n", errmsg); sqlite3_free(errmsg); } void db_watch_mark_bypath(char *path, char *strip, uint32_t cookie) { #define Q_TMPL "UPDATE inotify SET path = substr(path, %d), cookie = %" PRIi64 " WHERE path = '%q';" char *query; int64_t disabled; int striplen; disabled = (cookie != 0) ? cookie : INOTIFY_FAKE_COOKIE; striplen = strlen(strip) + 1; query = sqlite3_mprintf(Q_TMPL, striplen, disabled, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } db_watch_mark_byquery(query); sqlite3_free(query); #undef Q_TMPL } void db_watch_mark_bymatch(char *path, char *strip, uint32_t cookie) { #define Q_TMPL "UPDATE inotify SET path = substr(path, %d), cookie = %" PRIi64 " WHERE path LIKE '%q/%%';" char *query; int64_t disabled; int striplen; disabled = (cookie != 0) ? cookie : INOTIFY_FAKE_COOKIE; striplen = strlen(strip) + 1; query = sqlite3_mprintf(Q_TMPL, striplen, disabled, path); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } db_watch_mark_byquery(query); sqlite3_free(query); #undef Q_TMPL } void db_watch_move_bycookie(uint32_t cookie, char *path) { #define Q_TMPL "UPDATE inotify SET path = '%q' || path, cookie = 0 WHERE cookie = %" PRIi64 ";" char *query; char *errmsg; int ret; if (cookie == 0) return; query = sqlite3_mprintf(Q_TMPL, path, (int64_t)cookie); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = db_exec(query, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error moving watch: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); #undef Q_TMPL } int db_watch_cookie_known(uint32_t cookie) { #define Q_TMPL "SELECT COUNT(*) FROM inotify WHERE cookie = %" PRIi64 ";" char *query; int ret; if (cookie == 0) return 0; query = sqlite3_mprintf(Q_TMPL, (int64_t)cookie); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return 0; } ret = db_get_count(query); sqlite3_free(query); return (ret > 0); #undef Q_TMPL } int db_watch_enum_start(struct watch_enum *we) { #define Q_MATCH_TMPL "SELECT wd FROM inotify WHERE path LIKE '%q/%%';" #define Q_COOKIE_TMPL "SELECT wd FROM inotify WHERE cookie = %" PRIi64 ";" char *query; int ret; we->stmt = NULL; if (we->match) query = sqlite3_mprintf(Q_MATCH_TMPL, we->match); else if (we->cookie != 0) query = sqlite3_mprintf(Q_COOKIE_TMPL, we->cookie); else { DPRINTF(E_LOG, L_DB, "Could not start enum, no parameter given\n"); return -1; } if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Starting enum '%s'\n", query); ret = db_blocking_prepare_v2(query, -1, &we->stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_free(query); return -1; } sqlite3_free(query); return 0; #undef Q_MATCH_TMPL #undef Q_COOKIE_TMPL } void db_watch_enum_end(struct watch_enum *we) { if (!we->stmt) return; sqlite3_finalize(we->stmt); we->stmt = NULL; } int db_watch_enum_fetchwd(struct watch_enum *we, uint32_t *wd) { int ret; *wd = 0; if (!we->stmt) { DPRINTF(E_LOG, L_DB, "Watch enum not started!\n"); return -1; } ret = db_blocking_step(we->stmt); if (ret == SQLITE_DONE) { DPRINTF(E_INFO, L_DB, "End of watch enum results\n"); return 0; } else if (ret != SQLITE_ROW) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return -1; } *wd = (uint32_t)sqlite3_column_int(we->stmt, 0); return 0; } #ifdef DB_PROFILE static void db_xprofile(void *notused, const char *pquery, sqlite3_uint64 ptime) { sqlite3_stmt *stmt; char *query; int ret; DPRINTF(E_DBG, L_DBPERF, "SQL PROFILE query: %s\n", pquery); DPRINTF(E_DBG, L_DBPERF, "SQL PROFILE time: %" PRIu64 " ms\n", ((uint64_t)ptime / 1000000)); if ((strncmp(pquery, "SELECT", 6) != 0) && (strncmp(pquery, "UPDATE", 6) != 0) && (strncmp(pquery, "DELETE", 6) != 0)) return; /* Disable profiling callback */ sqlite3_profile(pool_hdl->hdl, NULL, NULL); query = sqlite3_mprintf("EXPLAIN QUERY PLAN %s", pquery); if (!query) { DPRINTF(E_DBG, L_DBPERF, "Query plan: Out of memory\n"); goto out; } ret = db_blocking_prepare_v2(query, -1, &stmt, NULL); sqlite3_free(query); if (ret != SQLITE_OK) { DPRINTF(E_DBG, L_DBPERF, "Query plan: Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); goto out; } DPRINTF(E_DBG, L_DBPERF, "Query plan:\n"); while ((ret = db_blocking_step(stmt)) == SQLITE_ROW) { DPRINTF(E_DBG, L_DBPERF, "(%d,%d,%d) %s\n", sqlite3_column_int(stmt, 0), sqlite3_column_int(stmt, 1), sqlite3_column_int(stmt, 2), sqlite3_column_text(stmt, 3)); } if (ret != SQLITE_DONE) DPRINTF(E_DBG, L_DBPERF, "Query plan: Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); DPRINTF(E_DBG, L_DBPERF, "---\n"); sqlite3_finalize(stmt); out: /* Reenable profiling callback */ sqlite3_profile(pool_hdl->hdl, db_xprofile, NULL); } #endif /* Database connections */ static sqlite3 * db_conn_open(void) { sqlite3 *conn; char *errmsg; int ret; ret = sqlite3_open(db_path, &conn); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not open database: %s\n", sqlite3_errmsg(conn)); goto fail; } ret = sqlite3_enable_load_extension(conn, 1); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not enable extension loading\n"); goto fail; } errmsg = NULL; ret = sqlite3_load_extension(conn, PKGLIBDIR "/forked-daapd-sqlext.so", NULL, &errmsg); if (ret != SQLITE_OK) { if (errmsg) { DPRINTF(E_LOG, L_DB, "Could not load SQLite extension: %s\n", errmsg); sqlite3_free(errmsg); } else DPRINTF(E_LOG, L_DB, "Could not load SQLite extension: %s\n", sqlite3_errmsg(conn)); goto fail; } ret = sqlite3_enable_load_extension(conn, 0); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not disable extension loading\n"); goto fail; } #ifdef DB_PROFILE sqlite3_profile(conn, db_xprofile, NULL); #endif return conn; fail: sqlite3_close(conn); return NULL; } static void db_conn_close(sqlite3 *conn) { sqlite3_stmt *stmt; /* Tear down anything that's in flight */ while ((stmt = sqlite3_next_stmt(conn, 0))) sqlite3_finalize(stmt); sqlite3_close(conn); } /* Database connection pool */ static int db_pool_open(void) { struct db_pool_hdl *ph; ph = (struct db_pool_hdl *)malloc(sizeof(struct db_pool_hdl)); if (!ph) { DPRINTF(E_LOG, L_DB, "Out of memory for database connection pool\n"); return -1; } memset(ph, 0, sizeof(struct db_pool_hdl)); ph->hdl = db_conn_open(); if (!ph->hdl) { free(ph); return -1; } pool_size++; ph->next = pool_free; pool_free = ph; return 0; } static void db_pool_close(struct db_pool_hdl *ph) { pool_size--; db_conn_close(ph->hdl); free(ph); } static void db_pool_reclaim(void *arg) { struct db_pool_hdl *ph; struct db_pool_hdl *ph_prev; time_t threshold; int reclaimed; DPRINTF(E_DBG, L_DB, "DB pool status: size %d free %d\n", pool_size, pool_free_size); if (pool_free_size <= DB_POOL_MIN_FREE) return; threshold = time(NULL) - DB_POOL_MAX_AGE; reclaimed = 0; ph_prev = NULL; for (ph = pool_free; ph && (pool_free_size > DB_POOL_MIN_FREE); /* EMPTY */) { if (ph->last <= threshold) { if (ph_prev) ph_prev->next = ph->next; else pool_free = ph->next; db_pool_close(ph); reclaimed++; pool_free_size--; if (ph_prev) ph = ph_prev->next; else ph = pool_free; } else { ph_prev = ph; ph = ph->next; } } DPRINTF(E_DBG, L_DB, "DB pool status: reclaimed %d size %d free %d\n", reclaimed, pool_size, pool_free_size); } static void db_pool_get_task(void *arg) { struct db_pool_hdl *ph; struct db_pool_hdl **my_pool_hdl; int ret; my_pool_hdl = (struct db_pool_hdl **)arg; if (!pool_free) { ret = db_pool_open(); if (ret < 0) { DPRINTF(E_LOG, L_DB, "Could not open a new database connection; no free connections available\n"); return; } } else pool_free_size--; /* Remove from free list */ ph = pool_free; pool_free = ph->next; /* Add to used list */ ph->next = pool_used; pool_used = ph; ph->saved = *my_pool_hdl; *my_pool_hdl = ph; } int db_pool_get(void) { struct db_pool_hdl *my_pool_hdl; my_pool_hdl = pool_hdl; dispatch_sync_f(dbpool_sq, &my_pool_hdl, db_pool_get_task); /* Failed to get a new pool_hdl */ if (my_pool_hdl == pool_hdl) return -1; /* Set thread-local database handle */ pool_hdl = my_pool_hdl; return 0; } static void db_pool_release_task(void *arg) { struct db_pool_hdl *ph; struct db_pool_hdl *ph_prev; struct db_pool_hdl *my_pool_hdl; my_pool_hdl = (struct db_pool_hdl *)arg; ph_prev = NULL; for (ph = pool_used; ph; ph = ph->next) { if (ph == my_pool_hdl) break; ph_prev = ph; } if (!ph) return; /* Remove from used list */ if (!ph_prev) pool_used = ph->next; else ph_prev->next = ph->next; /* Add to free list */ ph->next = pool_free; pool_free = ph; ph->last = time(NULL); pool_free_size++; } void db_pool_release(void) { struct db_pool_hdl *my_pool_hdl; /* Copy thread-local database handle */ my_pool_hdl = pool_hdl; /* Restore thread-local database handle to previous value */ pool_hdl = my_pool_hdl->saved; dispatch_async_f(dbpool_sq, my_pool_hdl, db_pool_release_task); } static int db_pool_init(void) { time_t now; int ret; pool_size = 0; pool_free_size = 0; pool_free = 0; pool_used = 0; dbpool_sq = dispatch_queue_create("org.forked-daapd.db-pool", NULL); if (!dbpool_sq) { DPRINTF(E_LOG, L_DB, "Could not create dispatch queue for database pool\n"); return -1; } now = time(NULL); for (pool_size = 0; pool_size < DB_POOL_MIN_SIZE; pool_free_size++) { ret = db_pool_open(); if (ret < 0) return -1; pool_free->last = now; } pool_reclaim_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, dbpool_sq); if (!pool_reclaim_timer) { DPRINTF(E_LOG, L_DB, "Could not create timer for database pool reclaim\n"); return -1; } dispatch_source_set_timer(pool_reclaim_timer, dispatch_time(DISPATCH_TIME_NOW, DB_POOL_MAX_AGE_NSEC), DB_POOL_MAX_AGE_NSEC, 30 * NSEC_PER_SEC); dispatch_source_set_event_handler_f(pool_reclaim_timer, db_pool_reclaim); dispatch_resume(pool_reclaim_timer); return 0; } static void db_pool_deinit(void) { struct db_pool_hdl *ph; dispatch_source_cancel(pool_reclaim_timer); dispatch_release(pool_reclaim_timer); dispatch_sync(dbpool_sq, ^{ /* Nothing to do, just resynching with the queue */ }); dispatch_release(dbpool_sq); if (pool_used) DPRINTF(E_LOG, L_DB, "db_pool_deinit: some connections are still in use!\n"); for (ph = pool_free; pool_free; ph = pool_free) { pool_free = ph->next; db_conn_close(ph->hdl); free(ph); } } /* Per-thread database handles */ static int db_perthread_init(void) { pool_hdl = (struct db_pool_hdl *)malloc(sizeof(struct db_pool_hdl)); if (!pool_hdl) return -1; memset(pool_hdl, 0, sizeof(struct db_pool_hdl)); pool_hdl->hdl = db_conn_open(); if (!pool_hdl->hdl) { free(pool_hdl); pool_hdl = NULL; return -1; } return 0; } static void db_perthread_deinit(void) { if (!pool_hdl) return; db_conn_close(pool_hdl->hdl); free(pool_hdl); pool_hdl = NULL; } #define T_ADMIN \ "CREATE TABLE IF NOT EXISTS admin(" \ " key VARCHAR(32) NOT NULL," \ " value VARCHAR(32) NOT NULL" \ ");" #define T_FILES \ "CREATE TABLE IF NOT EXISTS files (" \ " id INTEGER PRIMARY KEY NOT NULL," \ " path VARCHAR(4096) NOT NULL," \ " fname VARCHAR(255) NOT NULL," \ " title VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " artist VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " album VARCHAR(1024) NOT NULL COLLATE DAAP," \ " genre VARCHAR(255) DEFAULT NULL COLLATE DAAP," \ " comment VARCHAR(4096) DEFAULT NULL COLLATE DAAP," \ " type VARCHAR(255) DEFAULT NULL COLLATE DAAP," \ " composer VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " orchestra VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " conductor VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " grouping VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " url VARCHAR(1024) DEFAULT NULL," \ " bitrate INTEGER DEFAULT 0," \ " samplerate INTEGER DEFAULT 0," \ " song_length INTEGER DEFAULT 0," \ " file_size INTEGER DEFAULT 0," \ " year INTEGER DEFAULT 0," \ " track INTEGER DEFAULT 0," \ " total_tracks INTEGER DEFAULT 0," \ " disc INTEGER DEFAULT 0," \ " total_discs INTEGER DEFAULT 0," \ " bpm INTEGER DEFAULT 0," \ " compilation INTEGER DEFAULT 0," \ " rating INTEGER DEFAULT 0," \ " play_count INTEGER DEFAULT 0," \ " data_kind INTEGER DEFAULT 0," \ " item_kind INTEGER DEFAULT 0," \ " description INTEGER DEFAULT 0," \ " time_added INTEGER DEFAULT 0," \ " time_modified INTEGER DEFAULT 0," \ " time_played INTEGER DEFAULT 0," \ " db_timestamp INTEGER DEFAULT 0," \ " disabled INTEGER DEFAULT 0," \ " sample_count INTEGER DEFAULT 0," \ " codectype VARCHAR(5) DEFAULT NULL," \ " idx INTEGER NOT NULL," \ " has_video INTEGER DEFAULT 0," \ " contentrating INTEGER DEFAULT 0," \ " bits_per_sample INTEGER DEFAULT 0," \ " album_artist VARCHAR(1024) NOT NULL COLLATE DAAP," \ " media_kind INTEGER NOT NULL," \ " tv_series_name VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " tv_episode_num_str VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " tv_network_name VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " tv_episode_sort INTEGER NOT NULL," \ " tv_season_num INTEGER NOT NULL," \ " songalbumid INTEGER NOT NULL," \ " title_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " artist_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " album_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " composer_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " album_artist_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP" \ ");" #define T_PL \ "CREATE TABLE IF NOT EXISTS playlists (" \ " id INTEGER PRIMARY KEY NOT NULL," \ " title VARCHAR(255) NOT NULL COLLATE DAAP," \ " type INTEGER NOT NULL," \ " query VARCHAR(1024)," \ " db_timestamp INTEGER NOT NULL," \ " disabled INTEGER DEFAULT 0," \ " path VARCHAR(4096)," \ " idx INTEGER NOT NULL," \ " special_id INTEGER DEFAULT 0" \ ");" #define T_PLITEMS \ "CREATE TABLE IF NOT EXISTS playlistitems (" \ " id INTEGER PRIMARY KEY NOT NULL," \ " playlistid INTEGER NOT NULL," \ " filepath VARCHAR(4096) NOT NULL" \ ");" #define T_GROUPS \ "CREATE TABLE IF NOT EXISTS groups (" \ " id INTEGER PRIMARY KEY NOT NULL," \ " type INTEGER NOT NULL," \ " name VARCHAR(1024) NOT NULL COLLATE DAAP," \ " persistentid INTEGER NOT NULL," \ "CONSTRAINT groups_type_unique_persistentid UNIQUE (type, persistentid)" \ ");" #define T_PAIRINGS \ "CREATE TABLE IF NOT EXISTS pairings(" \ " remote VARCHAR(64) PRIMARY KEY NOT NULL," \ " name VARCHAR(255) NOT NULL," \ " guid VARCHAR(16) NOT NULL" \ ");" #define T_SPEAKERS \ "CREATE TABLE IF NOT EXISTS speakers(" \ " id INTEGER PRIMARY KEY NOT NULL," \ " selected INTEGER NOT NULL," \ " volume INTEGER NOT NULL" \ ");" #define T_INOTIFY \ "CREATE TABLE IF NOT EXISTS inotify (" \ " wd INTEGER PRIMARY KEY NOT NULL," \ " cookie INTEGER NOT NULL," \ " path VARCHAR(4096) NOT NULL" \ ");" #define I_RESCAN \ "CREATE INDEX IF NOT EXISTS idx_rescan ON files(path, db_timestamp);" #define I_SONGALBUMID \ "CREATE INDEX IF NOT EXISTS idx_sai ON files(songalbumid);" #define I_STATEMKINDSAI \ "CREATE INDEX IF NOT EXISTS idx_state_mkind_sai ON files(disabled, media_kind, songalbumid);" #define I_ARTIST \ "CREATE INDEX IF NOT EXISTS idx_artist ON files(artist, artist_sort);" #define I_ALBUMARTIST \ "CREATE INDEX IF NOT EXISTS idx_albumartist ON files(album_artist, album_artist_sort);" #define I_COMPOSER \ "CREATE INDEX IF NOT EXISTS idx_composer ON files(composer, composer_sort);" #define I_TITLE \ "CREATE INDEX IF NOT EXISTS idx_title ON files(title, title_sort);" #define I_ALBUM \ "CREATE INDEX IF NOT EXISTS idx_album ON files(album, album_sort);" #define I_PL_PATH \ "CREATE INDEX IF NOT EXISTS idx_pl_path ON playlists(path);" #define I_PL_DISABLED \ "CREATE INDEX IF NOT EXISTS idx_pl_disabled ON playlists(disabled);" #define I_FILEPATH \ "CREATE INDEX IF NOT EXISTS idx_filepath ON playlistitems(filepath ASC);" #define I_PLITEMID \ "CREATE INDEX IF NOT EXISTS idx_playlistid ON playlistitems(playlistid, filepath);" #define I_GRP_TYPE_PERSIST \ "CREATE INDEX IF NOT EXISTS idx_grp_type_persist ON groups(type, persistentid);" #define I_PAIRING \ "CREATE INDEX IF NOT EXISTS idx_pairingguid ON pairings(guid);" #define TRG_GROUPS_INSERT_FILES \ "CREATE TRIGGER update_groups_new_file AFTER INSERT ON files FOR EACH ROW" \ " BEGIN" \ " INSERT OR IGNORE INTO groups (type, name, persistentid) VALUES (1, NEW.album, NEW.songalbumid);" \ " END;" #define TRG_GROUPS_UPDATE_FILES \ "CREATE TRIGGER update_groups_update_file AFTER UPDATE OF songalbumid ON files FOR EACH ROW" \ " BEGIN" \ " INSERT OR IGNORE INTO groups (type, name, persistentid) VALUES (1, NEW.album, NEW.songalbumid);" \ " END;" #define Q_PL1 \ "INSERT INTO playlists (id, title, type, query, db_timestamp, path, idx, special_id)" \ " VALUES(1, 'Library', 1, '1 = 1', 0, '', 0, 0);" #define Q_PL2 \ "INSERT INTO playlists (id, title, type, query, db_timestamp, path, idx, special_id)" \ " VALUES(2, 'Music', 1, 'f.media_kind = 1', 0, '', 0, 6);" #define Q_PL3 \ "INSERT INTO playlists (id, title, type, query, db_timestamp, path, idx, special_id)" \ " VALUES(3, 'Movies', 1, 'f.media_kind = 2', 0, '', 0, 4);" #define Q_PL4 \ "INSERT INTO playlists (id, title, type, query, db_timestamp, path, idx, special_id)" \ " VALUES(4, 'TV Shows', 1, 'f.media_kind = 64', 0, '', 0, 5);" /* These are the remaining automatically-created iTunes playlists, but * their query is unknown " VALUES(5, 'Podcasts', 0, 'media_kind = 128 ', 0, '', 0, 1);" " VALUES(6, 'iTunes U', 0, 'media_kind = 256', 0, '', 0, 13);" " VALUES(7, 'Audiobooks', 0, 'media_kind = 512', 0, '', 0, 7);" " VALUES(8, 'Purchased', 0, 'media_kind = 1024', 0, '', 0, 8);" */ #define SCHEMA_VERSION 13 #define Q_SCVER \ "INSERT INTO admin (key, value) VALUES ('schema_version', '13');" struct db_init_query { char *query; char *desc; }; static const struct db_init_query db_init_queries[] = { { T_ADMIN, "create table admin" }, { T_FILES, "create table files" }, { T_PL, "create table playlists" }, { T_PLITEMS, "create table playlistitems" }, { T_GROUPS, "create table groups" }, { T_PAIRINGS, "create table pairings" }, { T_SPEAKERS, "create table speakers" }, { T_INOTIFY, "create table inotify" }, { I_RESCAN, "create rescan index" }, { I_SONGALBUMID, "create songalbumid index" }, { I_STATEMKINDSAI, "create state/mkind/sai index" }, { I_ARTIST, "create artist index" }, { I_ALBUMARTIST, "create album_artist index" }, { I_COMPOSER, "create composer index" }, { I_TITLE, "create title index" }, { I_ALBUM, "create album index" }, { I_PL_PATH, "create playlist path index" }, { I_PL_DISABLED, "create playlist state index" }, { I_FILEPATH, "create file path index" }, { I_PLITEMID, "create playlist id index" }, { I_GRP_TYPE_PERSIST, "create groups type/persistentid index" }, { I_PAIRING, "create pairing guid index" }, { TRG_GROUPS_INSERT_FILES, "create trigger update_groups_new_file" }, { TRG_GROUPS_UPDATE_FILES, "create trigger update_groups_update_file" }, { Q_PL1, "create default playlist" }, { Q_PL2, "create default smart playlist 'Music'" }, { Q_PL3, "create default smart playlist 'Movies'" }, { Q_PL4, "create default smart playlist 'TV Shows'" }, { Q_SCVER, "set schema version" }, }; static int db_create_tables(void) { char *errmsg; int i; int ret; for (i = 0; i < (sizeof(db_init_queries) / sizeof(db_init_queries[0])); i++) { DPRINTF(E_DBG, L_DB, "DB init query: %s\n", db_init_queries[i].desc); ret = sqlite3_exec(pool_hdl->hdl, db_init_queries[i].query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_FATAL, L_DB, "DB init error: %s\n", errmsg); sqlite3_free(errmsg); return -1; } } return 0; } static int db_generic_upgrade(const struct db_init_query *queries, int nqueries) { char *errmsg; int i; int ret; for (i = 0; i < nqueries; i++, queries++) { DPRINTF(E_DBG, L_DB, "DB upgrade query: %s\n", queries->desc); ret = sqlite3_exec(pool_hdl->hdl, queries->query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_FATAL, L_DB, "DB upgrade error: %s\n", errmsg); sqlite3_free(errmsg); return -1; } } return 0; } /* Upgrade from schema v10 to v11 */ #define U_V11_SPEAKERS \ "CREATE TABLE speakers(" \ " id INTEGER PRIMARY KEY NOT NULL," \ " selected INTEGER NOT NULL," \ " volume INTEGER NOT NULL" \ ");" #define U_V11_SCVER \ "UPDATE admin SET value = '11' WHERE key = 'schema_version';" static const struct db_init_query db_upgrade_v11_queries[] = { { U_V11_SPEAKERS, "create new table speakers" }, { U_V11_SCVER, "set schema_version to 11" }, }; static int db_upgrade_v11(void) { #define Q_NEWSPK "INSERT INTO speakers (id, selected, volume) VALUES (%" PRIi64 ", 1, 75);" #define Q_SPKVOL "UPDATE speakers SET volume = %d;" sqlite3_stmt *stmt; char *query; char *errmsg; const char *strid; uint64_t *spkids; int volume; int count; int i; int qret; int ret; /* Get saved speakers */ count = db_get_count("SELECT COUNT(*) FROM admin WHERE key = 'player:active-spk';"); if (count == 0) goto clear_vars; else if (count < 0) return -1; spkids = (uint64_t *)malloc(count * sizeof(uint64_t)); if (!spkids) { DPRINTF(E_LOG, L_DB, "Out of memory for speaker IDs\n"); return -1; } query = "SELECT value FROM admin WHERE key = 'player:active-spk';"; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = sqlite3_prepare_v2(pool_hdl->hdl, query, -1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); goto out_free_ids; } i = 0; ret = 0; while ((qret = sqlite3_step(stmt)) == SQLITE_ROW) { strid = (const char *)sqlite3_column_text(stmt, 0); ret = safe_hextou64(strid, spkids + i); if (ret < 0) { DPRINTF(E_LOG, L_DB, "Could not convert speaker ID: %s\n", strid); break; } i++; } sqlite3_finalize(stmt); if ((ret == 0) && (qret != SQLITE_DONE)) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); goto out_free_ids; } else if (ret < 0) goto out_free_ids; /* Get saved volume */ query = "SELECT value FROM admin WHERE key = 'player:volume';"; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = sqlite3_prepare_v2(pool_hdl->hdl, query, -1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); goto out_free_ids; } ret = sqlite3_step(stmt); if (ret != SQLITE_ROW) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); goto out_free_ids; } volume = sqlite3_column_int(stmt, 0); sqlite3_finalize(stmt); /* Add speakers to the table */ for (i = 0; i < count; i++) { query = sqlite3_mprintf(Q_NEWSPK, spkids[i]); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); goto out_free_ids; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = sqlite3_exec(pool_hdl->hdl, query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error adding speaker: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); } free(spkids); /* Update with volume */ query = sqlite3_mprintf(Q_SPKVOL, volume); if (!query) { DPRINTF(E_LOG, L_DB, "Out of memory for query string\n"); return -1; } DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = sqlite3_exec(pool_hdl->hdl, query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error adding speaker: %s\n", errmsg); sqlite3_free(errmsg); sqlite3_free(query); /* Clear old config keys */ clear_vars: query = "DELETE FROM admin WHERE key = 'player:volume' OR key = 'player:active-spk';"; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", query); ret = sqlite3_exec(pool_hdl->hdl, query, NULL, NULL, &errmsg); if (ret != SQLITE_OK) DPRINTF(E_LOG, L_DB, "Error adding speaker: %s\n", errmsg); sqlite3_free(errmsg); return 0; out_free_ids: free(spkids); return -1; #undef Q_NEWSPK #undef Q_SPKVOL } /* Upgrade from schema v11 to v12 */ #define U_V12_NEW_FILES_TABLE \ "CREATE TABLE IF NOT EXISTS files (" \ " id INTEGER PRIMARY KEY NOT NULL," \ " path VARCHAR(4096) NOT NULL," \ " fname VARCHAR(255) NOT NULL," \ " title VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " artist VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " album VARCHAR(1024) NOT NULL COLLATE DAAP," \ " genre VARCHAR(255) DEFAULT NULL COLLATE DAAP," \ " comment VARCHAR(4096) DEFAULT NULL COLLATE DAAP," \ " type VARCHAR(255) DEFAULT NULL COLLATE DAAP," \ " composer VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " orchestra VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " conductor VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " grouping VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " url VARCHAR(1024) DEFAULT NULL," \ " bitrate INTEGER DEFAULT 0," \ " samplerate INTEGER DEFAULT 0," \ " song_length INTEGER DEFAULT 0," \ " file_size INTEGER DEFAULT 0," \ " year INTEGER DEFAULT 0," \ " track INTEGER DEFAULT 0," \ " total_tracks INTEGER DEFAULT 0," \ " disc INTEGER DEFAULT 0," \ " total_discs INTEGER DEFAULT 0," \ " bpm INTEGER DEFAULT 0," \ " compilation INTEGER DEFAULT 0," \ " rating INTEGER DEFAULT 0," \ " play_count INTEGER DEFAULT 0," \ " data_kind INTEGER DEFAULT 0," \ " item_kind INTEGER DEFAULT 0," \ " description INTEGER DEFAULT 0," \ " time_added INTEGER DEFAULT 0," \ " time_modified INTEGER DEFAULT 0," \ " time_played INTEGER DEFAULT 0," \ " db_timestamp INTEGER DEFAULT 0," \ " disabled INTEGER DEFAULT 0," \ " sample_count INTEGER DEFAULT 0," \ " codectype VARCHAR(5) DEFAULT NULL," \ " idx INTEGER NOT NULL," \ " has_video INTEGER DEFAULT 0," \ " contentrating INTEGER DEFAULT 0," \ " bits_per_sample INTEGER DEFAULT 0," \ " album_artist VARCHAR(1024) NOT NULL COLLATE DAAP," \ " media_kind INTEGER NOT NULL," \ " tv_series_name VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " tv_episode_num_str VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " tv_network_name VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " tv_episode_sort INTEGER NOT NULL," \ " tv_season_num INTEGER NOT NULL," \ " songalbumid INTEGER NOT NULL," \ " title_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " artist_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " album_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " composer_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " album_artist_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP" \ ");" #define U_V12_IDX_PATH \ "CREATE INDEX IF NOT EXISTS idx_path ON files(path, idx);" #define U_V12_IDX_TS \ "CREATE INDEX IF NOT EXISTS idx_titlesort ON files(title_sort);" #define U_V12_IDX_AS \ "CREATE INDEX IF NOT EXISTS idx_artistsort ON files(artist_sort);" #define U_V12_IDX_BS \ "CREATE INDEX IF NOT EXISTS idx_albumsort ON files(album_sort);" #define U_V12_TRG1 \ "CREATE TRIGGER update_groups_new_file AFTER INSERT ON files FOR EACH ROW" \ " BEGIN" \ " INSERT OR IGNORE INTO groups (type, name, persistentid) VALUES (1, NEW.album, NEW.songalbumid);" \ " END;" #define U_V12_TRG2 \ "CREATE TRIGGER update_groups_update_file AFTER UPDATE OF songalbumid ON files FOR EACH ROW" \ " BEGIN" \ " INSERT OR IGNORE INTO groups (type, name, persistentid) VALUES (1, NEW.album, NEW.songalbumid);" \ " END;" #define U_V12_SCVER \ "UPDATE admin SET value = '12' WHERE key = 'schema_version';" static const struct db_init_query db_upgrade_v12_queries[] = { { U_V12_IDX_PATH, "create index path table files" }, { U_V12_IDX_TS, "create index titlesort table files" }, { U_V12_IDX_AS, "create index artistsort table files" }, { U_V12_IDX_BS, "create index albumsort table files" }, { U_V12_TRG1, "create trigger update_groups_new_file" }, { U_V12_TRG2, "create trigger update_groups_update_file" }, { U_V12_SCVER, "set schema_version to 12" }, }; /* Upgrade the files table to the new schema by dumping and reloading the * table. A bit tedious. */ static int db_upgrade_v12(void) { #define Q_DUMP "SELECT 'INSERT INTO files " \ "(id, path, fname, title, artist, album, genre, comment, type, composer," \ " orchestra, conductor, grouping, url, bitrate, samplerate, song_length, file_size, year, track," \ " total_tracks, disc, total_discs, bpm, compilation, rating, play_count, data_kind, item_kind," \ " description, time_added, time_modified, time_played, db_timestamp, disabled, sample_count," \ " codectype, idx, has_video, contentrating, bits_per_sample, album_artist," \ " media_kind, tv_series_name, tv_episode_num_str, tv_network_name, tv_episode_sort, tv_season_num, " \ " songalbumid, title_sort, artist_sort, album_sort, composer_sort, album_artist_sort)" \ " VALUES (' || id || ', ' || QUOTE(path) || ', ' || QUOTE(fname) || ', ' || QUOTE(title) || ', '" \ " || QUOTE(artist) || ', ' || QUOTE(album) || ', ' || QUOTE(genre) || ', ' || QUOTE(comment) || ', '" \ " || QUOTE(type) || ', ' || QUOTE(composer) || ', ' || QUOTE(orchestra) || ', ' || QUOTE(conductor) || ', '" \ " || QUOTE(grouping) || ', ' || QUOTE(url) || ', ' || bitrate || ', ' || samplerate || ', '" \ " || song_length || ', ' || file_size || ', ' || year || ', ' || track || ', ' || total_tracks || ', '" \ " || disc || ', ' || total_discs || ', ' || bpm || ', ' || compilation || ', ' || rating || ', '" \ " || play_count || ', ' || data_kind || ', ' || item_kind || ', ' || QUOTE(description) || ', '" \ " || time_added || ', ' || time_modified || ', ' || time_played || ', 1, '" \ " || disabled || ', ' || sample_count || ', ' || QUOTE(codectype) || ', ' || idx || ', '" \ " || has_video || ', ' || contentrating || ', ' || bits_per_sample || ', ' || QUOTE(album_artist) || ', '" \ " || media_kind || ', ' || QUOTE(tv_series_name) || ', ' || QUOTE(tv_episode_num_str) || ', '" \ " || QUOTE(tv_network_name) || ', ' || tv_episode_sort || ', ' || tv_season_num || ', '" \ " || songalbumid || ', ' || QUOTE(title) || ', ' || QUOTE(artist) || ', ' || QUOTE(album) || ', '" \ " || QUOTE(composer) || ', ' || QUOTE(album_artist) || ');' FROM files;" struct stat sb; FILE *fp; sqlite3_stmt *stmt; const unsigned char *dumprow; char *dump; char *errmsg; int fd; int ret; fp = tmpfile(); if (!fp) { DPRINTF(E_LOG, L_DB, "Could not create temporary file for files table dump: %s\n", strerror(errno)); return -1; } DPRINTF(E_LOG, L_DB, "Dumping old files table...\n"); /* dump */ ret = sqlite3_prepare_v2(pool_hdl->hdl, Q_DUMP, strlen(Q_DUMP) + 1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); ret = -1; goto out_fclose; } while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) { dumprow = sqlite3_column_text(stmt, 0); ret = fprintf(fp, "%s\n", dumprow); if (ret < 0) { DPRINTF(E_LOG, L_DB, "Could not write dump: %s\n", strerror(errno)); sqlite3_finalize(stmt); ret = -1; goto out_fclose; } } if (ret != SQLITE_DONE) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); ret = -1; goto out_fclose; } sqlite3_finalize(stmt); /* Seek back to start of dump file */ ret = fseek(fp, 0, SEEK_SET); if (ret < 0) { DPRINTF(E_LOG, L_DB, "Could not seek back to start of dump: %s\n", strerror(errno)); ret = -1; goto out_fclose; } /* Map dump file */ fd = fileno(fp); if (fd < 0) { DPRINTF(E_LOG, L_DB, "Could not obtain file descriptor: %s\n", strerror(errno)); ret = -1; goto out_fclose; } ret = fstat(fd, &sb); if (ret < 0) { DPRINTF(E_LOG, L_DB, "Could not stat dump file: %s\n", strerror(errno)); ret = -1; goto out_fclose; } if (sb.st_size == 0) dump = NULL; else { dump = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); if (dump == MAP_FAILED) { DPRINTF(E_LOG, L_DB, "Could not map dump file: %s\n", strerror(errno)); ret = -1; goto out_fclose; } } /* Move old table out of the way */ DPRINTF(E_LOG, L_DB, "Moving old files table out of the way...\n"); ret = sqlite3_exec(pool_hdl->hdl, "ALTER TABLE files RENAME TO oldfilesv11;", NULL, NULL, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error renaming old files table: %s\n", errmsg); sqlite3_free(errmsg); ret = -1; goto out_munmap; } /* Create new table */ DPRINTF(E_LOG, L_DB, "Creating new files table...\n"); ret = sqlite3_exec(pool_hdl->hdl, U_V12_NEW_FILES_TABLE, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error creating new files table: %s\n", errmsg); sqlite3_free(errmsg); ret = -1; goto out_munmap; } /* Reload dump */ DPRINTF(E_LOG, L_DB, "Reloading new files table...\n"); if (dump) { ret = sqlite3_exec(pool_hdl->hdl, dump, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error reloading files table data: %s\n", errmsg); sqlite3_free(errmsg); ret = -1; goto out_munmap; } } /* Delete old files table */ DPRINTF(E_LOG, L_DB, "Deleting old files table...\n"); ret = sqlite3_exec(pool_hdl->hdl, "DROP TABLE oldfilesv11;", NULL, NULL, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Error dropping old files table: %s\n", errmsg); sqlite3_free(errmsg); /* Not an issue, but takes up space in the database */ } out_munmap: if (dump) { if (munmap(dump, sb.st_size) < 0) DPRINTF(E_LOG, L_DB, "Could not unmap dump file: %s\n", strerror(errno)); } out_fclose: fclose(fp); return ret; #undef Q_DUMP } /* Upgrade from schema v12 to v13 */ #define U_V13_DROP_IDX_PATH \ "DROP INDEX idx_path;" #define U_V13_DROP_IDX_TS \ "DROP INDEX idx_titlesort;" #define U_V13_DROP_IDX_AS \ "DROP INDEX idx_artistsort;" #define U_V13_DROP_IDX_BS \ "DROP INDEX idx_albumsort;" #define U_V13_IDX_RESCAN \ "CREATE INDEX IF NOT EXISTS idx_rescan ON files(path, db_timestamp);" #define U_V13_IDX_SONGALBUMID \ "CREATE INDEX IF NOT EXISTS idx_sai ON files(songalbumid);" #define U_V13_IDX_STATEMKINDSAI \ "CREATE INDEX IF NOT EXISTS idx_state_mkind_sai ON files(disabled, media_kind, songalbumid);" #define U_V13_IDX_ARTIST \ "CREATE INDEX IF NOT EXISTS idx_artist ON files(artist, artist_sort);" #define U_V13_IDX_ALBUMARTIST \ "CREATE INDEX IF NOT EXISTS idx_albumartist ON files(album_artist, album_artist_sort);" #define U_V13_IDX_COMPOSER \ "CREATE INDEX IF NOT EXISTS idx_composer ON files(composer, composer_sort);" #define U_V13_IDX_TITLE \ "CREATE INDEX IF NOT EXISTS idx_title ON files(title, title_sort);" #define U_V13_IDX_ALBUM \ "CREATE INDEX IF NOT EXISTS idx_album ON files(album, album_sort);" #define U_V13_IDX_GRP_TYPE_PERSIST \ "CREATE INDEX IF NOT EXISTS idx_grp_type_persist ON groups(type, persistentid);" #define U_V13_IDX_PL_PATH \ "CREATE INDEX IF NOT EXISTS idx_pl_path ON playlists(path);" #define U_V13_IDX_PL_DISABLED \ "CREATE INDEX IF NOT EXISTS idx_pl_disabled ON playlists(disabled);" #define U_V13_PL2 \ "UPDATE playlists SET query = 'f.media_kind = 1' where id = 2;" #define U_V13_PL3 \ "UPDATE playlists SET query = 'f.media_kind = 2' where id = 3;" #define U_V13_PL4 \ "UPDATE playlists SET query = 'f.media_kind = 64' where id = 4;" #define U_V13_SCVER \ "UPDATE admin SET value = '13' WHERE key = 'schema_version';" static const struct db_init_query db_upgrade_v13_queries[] = { { U_V13_DROP_IDX_PATH, "drop index path table files" }, { U_V13_DROP_IDX_TS, "drop index titlesort table files" }, { U_V13_DROP_IDX_AS, "drop index artistsort table files" }, { U_V13_DROP_IDX_BS, "drop index albumsort table files" }, { U_V13_IDX_RESCAN, "create rescan index" }, { U_V13_IDX_SONGALBUMID, "create songalbumid index" }, { U_V13_IDX_STATEMKINDSAI, "create state/mkind/sai index" }, { U_V13_IDX_ARTIST, "create artist index" }, { U_V13_IDX_ALBUMARTIST, "create album_artist index" }, { U_V13_IDX_COMPOSER, "create composer index" }, { U_V13_IDX_TITLE, "create title index" }, { U_V13_IDX_ALBUM, "create album index" }, { U_V13_IDX_GRP_TYPE_PERSIST, "create groups type/persistentid index" }, { U_V13_IDX_PL_PATH, "create playlist path index" }, { U_V13_IDX_PL_DISABLED, "create playlist state index" }, { U_V13_PL2, "update default smart playlist 'Music'" }, { U_V13_PL3, "update default smart playlist 'Movies'" }, { U_V13_PL4, "update default smart playlist 'TV Shows'" }, { U_V13_SCVER, "set schema_version to 13" }, }; static int db_check_version(void) { #define Q_VER "SELECT value FROM admin WHERE key = 'schema_version';" #define Q_VACUUM "VACUUM;" sqlite3_stmt *stmt; char *errmsg; int cur_ver; int ret; DPRINTF(E_DBG, L_DB, "Running query '%s'\n", Q_VER); ret = sqlite3_prepare_v2(pool_hdl->hdl, Q_VER, strlen(Q_VER) + 1, &stmt, NULL); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not prepare statement: %s\n", sqlite3_errmsg(pool_hdl->hdl)); return 1; } ret = sqlite3_step(stmt); if (ret != SQLITE_ROW) { DPRINTF(E_LOG, L_DB, "Could not step: %s\n", sqlite3_errmsg(pool_hdl->hdl)); sqlite3_finalize(stmt); return -1; } cur_ver = sqlite3_column_int(stmt, 0); sqlite3_finalize(stmt); if (cur_ver < 10) { DPRINTF(E_FATAL, L_DB, "Database schema v%d too old, cannot upgrade\n", cur_ver); return -1; } else if (cur_ver < SCHEMA_VERSION) { DPRINTF(E_LOG, L_DB, "Database schema outdated, schema upgrade needed v%d -> v%d\n", cur_ver, SCHEMA_VERSION); switch (cur_ver) { case 10: ret = db_generic_upgrade(db_upgrade_v11_queries, sizeof(db_upgrade_v11_queries) / sizeof(db_upgrade_v11_queries[0])); if (ret < 0) return -1; ret = db_upgrade_v11(); if (ret < 0) return -1; /* FALLTHROUGH */ case 11: ret = db_upgrade_v12(); if (ret < 0) return -1; ret = db_generic_upgrade(db_upgrade_v12_queries, sizeof(db_upgrade_v12_queries) / sizeof(db_upgrade_v12_queries[0])); if (ret < 0) return -1; /* FALLTHROUGH */ case 12: ret = db_generic_upgrade(db_upgrade_v13_queries, sizeof(db_upgrade_v13_queries) / sizeof(db_upgrade_v13_queries[0])); if (ret < 0) return -1; break; default: DPRINTF(E_LOG, L_DB, "No upgrade path from DB schema v%d to v%d\n", cur_ver, SCHEMA_VERSION); return -1; } /* What about some housekeeping work, eh? */ DPRINTF(E_INFO, L_DB, "Now vacuuming database, this may take some time...\n"); ret = sqlite3_exec(pool_hdl->hdl, Q_VACUUM, NULL, NULL, &errmsg); if (ret != SQLITE_OK) { DPRINTF(E_LOG, L_DB, "Could not VACUUM database: %s\n", errmsg); sqlite3_free(errmsg); return -1; } } else if (cur_ver > SCHEMA_VERSION) { DPRINTF(E_LOG, L_DB, "Database schema is newer than the supported version\n"); return -1; } return 0; #undef Q_VER #undef Q_VACUUM } int db_init(void) { int files; int pls; int ret; db_path = cfg_getstr(cfg_getsec(cfg, "general"), "db_path"); ret = sqlite3_config(SQLITE_CONFIG_MULTITHREAD); if (ret != SQLITE_OK) { DPRINTF(E_FATAL, L_DB, "Could not switch SQLite3 to multithread mode\n"); DPRINTF(E_FATAL, L_DB, "Check that SQLite3 has been configured for thread-safe operations\n"); return -1; } ret = sqlite3_enable_shared_cache(1); if (ret != SQLITE_OK) { DPRINTF(E_FATAL, L_DB, "Could not enable SQLite3 shared-cache mode\n"); return -1; } ret = sqlite3_initialize(); if (ret != SQLITE_OK) { DPRINTF(E_FATAL, L_DB, "SQLite3 failed to initialize\n"); return -1; } ret = db_perthread_init(); if (ret < 0) return ret; ret = db_check_version(); if (ret < 0) { DPRINTF(E_FATAL, L_DB, "Database version check errored out, incompatible database\n"); db_perthread_deinit(); return -1; } else if (ret > 0) { DPRINTF(E_FATAL, L_DB, "Could not check database version, trying DB init\n"); ret = db_create_tables(); if (ret < 0) { DPRINTF(E_FATAL, L_DB, "Could not create tables\n"); db_perthread_deinit(); return -1; } } db_analyze(); files = db_files_get_count(); pls = db_pl_get_count(); db_perthread_deinit(); DPRINTF(E_INFO, L_DB, "Database OK with %d active files and %d active playlists\n", files, pls); ret = db_pool_init(); if (ret < 0) { DPRINTF(E_FATAL, L_DB, "Could not initialize database connection pool\n"); db_pool_deinit(); return -1; } return 0; } void db_deinit(void) { db_pool_deinit(); sqlite3_shutdown(); } forked-daapd-0.19gcd/src/db.h0000664000175000017500000002207311633141135015331 0ustar julienjulien #ifndef __DB_H__ #define __DB_H__ #include #include #include #include enum index_type { I_NONE, I_FIRST, I_LAST, I_SUB }; enum sort_type { S_NONE = 0, S_NAME, S_ALBUM, S_ARTIST, }; #define Q_F_BROWSE (1 << 15) enum query_type { Q_ITEMS = (1 << 0), Q_PL = (1 << 1), Q_PLITEMS = (1 << 2), Q_BROWSE_ARTISTS = Q_F_BROWSE | (1 << 3), Q_BROWSE_ALBUMS = Q_F_BROWSE | (1 << 4), Q_BROWSE_GENRES = Q_F_BROWSE | (1 << 5), Q_BROWSE_COMPOSERS = Q_F_BROWSE | (1 << 6), Q_GROUPS = (1 << 7), Q_GROUPITEMS = (1 << 8), Q_GROUP_DIRS = Q_F_BROWSE | (1 << 9), }; struct query_params { /* Query parameters, filled in by caller */ enum query_type type; enum index_type idx_type; enum sort_type sort; int id; int offset; int limit; char *filter; /* Query results, filled in by query_start */ int results; /* Private query context, keep out */ sqlite3_stmt *stmt; char buf[32]; }; struct pairing_info { char *remote_id; char *name; char *guid; }; struct media_file_info { char *path; uint32_t index; char *fname; char *title; char *artist; char *album; char *genre; char *comment; char *type; /* daap.songformat */ char *composer; char *orchestra; char *conductor; char *grouping; char *url; /* daap.songdataurl (asul) */ uint32_t bitrate; uint32_t samplerate; uint32_t song_length; int64_t file_size; uint32_t year; /* TDRC */ uint32_t track; /* TRCK */ uint32_t total_tracks; uint32_t disc; /* TPOS */ uint32_t total_discs; uint32_t time_added; /* FIXME: time_t */ uint32_t time_modified; uint32_t time_played; uint32_t play_count; uint32_t rating; uint32_t db_timestamp; uint32_t disabled; uint32_t bpm; /* TBPM */ uint32_t id; char *description; /* daap.songdescription */ char *codectype; /* song.codectype, 4 chars max (32 bits) */ uint32_t item_kind; /* song or movie */ uint32_t data_kind; /* dmap.datakind (asdk) */ uint64_t sample_count; char compilation; /* iTunes 5+ */ uint32_t contentrating; /* iTunes 6.0.2 */ uint32_t has_video; uint32_t bits_per_sample; uint32_t media_kind; uint32_t tv_episode_sort; uint32_t tv_season_num; char *tv_series_name; char *tv_episode_num_str; /* com.apple.itunes.episode-num-str, used as a unique episode identifier */ char *tv_network_name; char *album_artist; int64_t songalbumid; char *title_sort; char *artist_sort; char *album_sort; char *composer_sort; char *album_artist_sort; }; #define mfi_offsetof(field) offsetof(struct media_file_info, field) enum pl_type { PL_PLAIN, PL_SMART, PL_MAX }; struct playlist_info { uint32_t id; /* integer id (miid) */ char *title; /* playlist name as displayed in iTunes (minm) */ enum pl_type type; /* see PL_ types */ uint32_t items; /* number of items (mimc) */ char *query; /* where clause if type 1 (MSPS) */ uint32_t db_timestamp; /* time last updated */ uint32_t disabled; char *path; /* path of underlying playlist */ uint32_t index; /* index of playlist for paths with multiple playlists */ uint32_t special_id; /* iTunes identifies certain 'special' playlists with special meaning */ }; #define pli_offsetof(field) offsetof(struct playlist_info, field) struct db_playlist_info { char *id; char *title; char *type; char *items; char *query; char *db_timestamp; char *disabled; char *path; char *index; char *special_id; }; #define dbpli_offsetof(field) offsetof(struct db_playlist_info, field) struct group_info { uint32_t id; /* integer id (miid) */ uint64_t persistentid; /* ulonglong id (mper) */ char *itemname; /* playlist name as displayed in iTunes (minm) */ uint32_t itemcount; /* number of items (mimc) */ char *songalbumartist; /* song album artist (asaa) */ }; #define gri_offsetof(field) offsetof(struct group_info, field) struct db_group_info { char *id; char *persistentid; char *itemname; char *itemcount; char *songalbumartist; }; #define dbgri_offsetof(field) offsetof(struct db_group_info, field) struct db_media_file_info { char *id; char *path; char *fname; char *title; char *artist; char *album; char *genre; char *comment; char *type; char *composer; char *orchestra; char *conductor; char *grouping; char *url; char *bitrate; char *samplerate; char *song_length; char *file_size; char *year; char *track; char *total_tracks; char *disc; char *total_discs; char *bpm; char *compilation; char *rating; char *play_count; char *data_kind; char *item_kind; char *description; char *time_added; char *time_modified; char *time_played; char *db_timestamp; char *disabled; char *sample_count; char *codectype; char *idx; char *has_video; char *contentrating; char *bits_per_sample; char *album_artist; char *media_kind; char *tv_episode_sort; char *tv_season_num; char *tv_series_name; char *tv_episode_num_str; char *tv_network_name; char *songalbumid; char *title_sort; char *artist_sort; char *album_sort; char *composer_sort; char *album_artist_sort; }; #define dbmfi_offsetof(field) offsetof(struct db_media_file_info, field) struct watch_info { int wd; char *path; uint32_t cookie; }; #define wi_offsetof(field) offsetof(struct watch_info, field) struct watch_enum { uint32_t cookie; char *match; /* Private enum context, keep out */ sqlite3_stmt *stmt; }; char * db_escape_string(const char *str); void free_pi(struct pairing_info *pi, int content_only); void free_mfi(struct media_file_info *mfi, int content_only); void unicode_fixup_mfi(struct media_file_info *mfi); void free_pli(struct playlist_info *pli, int content_only); /* Maintenance and DB hygiene */ void db_hook_post_scan(void); void db_purge_cruft(time_t ref); /* Queries */ int db_query_start(struct query_params *qp); void db_query_end(struct query_params *qp); int db_query_fetch_file(struct query_params *qp, struct db_media_file_info *dbmfi); int db_query_fetch_pl(struct query_params *qp, struct db_playlist_info *dbpli); int db_query_fetch_group(struct query_params *qp, struct db_group_info *dbgri); int db_query_fetch_string(struct query_params *qp, char **string); int db_query_fetch_string_sort(struct query_params *qp, char **string, char **sortstring); /* Files */ int db_files_get_count(void); void db_files_update_songalbumid(void); void db_file_inc_playcount(int id); void db_file_ping(int id); char * db_file_path_byid(int id); int db_file_id_bypath(char *path); int db_file_id_byfilebase(char *filename, char *base); int db_file_id_byfile(char *filename); int db_file_id_byurl(char *url); void db_file_stamp_bypath(char *path, time_t *stamp, int *id); struct media_file_info * db_file_fetch_byid(int id); int db_file_add(struct media_file_info *mfi); int db_file_update(struct media_file_info *mfi); void db_file_delete_bypath(char *path); void db_file_disable_bypath(char *path, char *strip, uint32_t cookie); void db_file_disable_bymatch(char *path, char *strip, uint32_t cookie); int db_file_enable_bycookie(uint32_t cookie, char *path); /* Playlists */ int db_pl_get_count(void); void db_pl_ping(int id); struct playlist_info * db_pl_fetch_bypath(char *path); struct playlist_info * db_pl_fetch_bytitlepath(char *title, char *path); int db_pl_add(char *title, char *path, int *id); int db_pl_add_item_bypath(int plid, char *path); int db_pl_add_item_byid(int plid, int fileid); void db_pl_clear_items(int id); void db_pl_delete(int id); void db_pl_delete_bypath(char *path); void db_pl_disable_bypath(char *path, char *strip, uint32_t cookie); void db_pl_disable_bymatch(char *path, char *strip, uint32_t cookie); int db_pl_enable_bycookie(uint32_t cookie, char *path); /* Groups */ int db_groups_clear(void); enum group_type db_group_type_byid(int id); /* Remotes */ int db_pairing_add(struct pairing_info *pi); int db_pairing_fetch_byguid(struct pairing_info *pi); /* Speakers */ int db_speaker_save(uint64_t id, int selected, int volume); int db_speaker_get(uint64_t id, int *selected, int *volume); void db_speaker_clear_all(void); /* Inotify */ int db_watch_clear(void); int db_watch_add(struct watch_info *wi); int db_watch_delete_bywd(uint32_t wd); int db_watch_delete_bypath(char *path); int db_watch_delete_bymatch(char *path); int db_watch_delete_bycookie(uint32_t cookie); int db_watch_get_bywd(struct watch_info *wi); void db_watch_mark_bypath(char *path, char *strip, uint32_t cookie); void db_watch_mark_bymatch(char *path, char *strip, uint32_t cookie); void db_watch_move_bycookie(uint32_t cookie, char *path); int db_watch_cookie_known(uint32_t cookie); int db_watch_enum_start(struct watch_enum *we); void db_watch_enum_end(struct watch_enum *we); int db_watch_enum_fetchwd(struct watch_enum *we, uint32_t *wd); int db_pool_get(void); void db_pool_release(void); int db_init(void); void db_deinit(void); #endif /* !__DB_H__ */ forked-daapd-0.19gcd/src/dmap_common.c0000664000175000017500000002467111633141135017236 0ustar julienjulien/* * Copyright (C) 2009-2010 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include "evbuffer/evbuffer.h" #include "db.h" #include "misc.h" #include "logger.h" #include "http.h" #include "dmap_common.h" /* gperf static hash, dmap_fields.gperf */ #include "dmap_fields_hash.c" const struct dmap_field * dmap_get_fields_table(int *nfields) { *nfields = sizeof(dmap_fields) / sizeof(dmap_fields[0]); return dmap_fields; } void dmap_add_container(struct evbuffer *evbuf, char *tag, int len) { unsigned char buf[4]; evbuffer_add(evbuf, tag, 4); /* Container length */ buf[0] = (len >> 24) & 0xff; buf[1] = (len >> 16) & 0xff; buf[2] = (len >> 8) & 0xff; buf[3] = len & 0xff; evbuffer_add(evbuf, buf, sizeof(buf)); } void dmap_add_long(struct evbuffer *evbuf, char *tag, int64_t val) { unsigned char buf[12]; evbuffer_add(evbuf, tag, 4); /* Length */ buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 8; /* Value */ buf[4] = (val >> 56) & 0xff; buf[5] = (val >> 48) & 0xff; buf[6] = (val >> 40) & 0xff; buf[7] = (val >> 32) & 0xff; buf[8] = (val >> 24) & 0xff; buf[9] = (val >> 16) & 0xff; buf[10] = (val >> 8) & 0xff; buf[11] = val & 0xff; evbuffer_add(evbuf, buf, sizeof(buf)); } void dmap_add_int(struct evbuffer *evbuf, char *tag, int val) { unsigned char buf[8]; evbuffer_add(evbuf, tag, 4); /* Length */ buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 4; /* Value */ buf[4] = (val >> 24) & 0xff; buf[5] = (val >> 16) & 0xff; buf[6] = (val >> 8) & 0xff; buf[7] = val & 0xff; evbuffer_add(evbuf, buf, sizeof(buf)); } void dmap_add_short(struct evbuffer *evbuf, char *tag, short val) { unsigned char buf[6]; evbuffer_add(evbuf, tag, 4); /* Length */ buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 2; /* Value */ buf[4] = (val >> 8) & 0xff; buf[5] = val & 0xff; evbuffer_add(evbuf, buf, sizeof(buf)); } void dmap_add_char(struct evbuffer *evbuf, char *tag, char val) { unsigned char buf[5]; evbuffer_add(evbuf, tag, 4); /* Length */ buf[0] = 0; buf[1] = 0; buf[2] = 0; buf[3] = 1; /* Value */ buf[4] = val; evbuffer_add(evbuf, buf, sizeof(buf)); } void dmap_add_literal(struct evbuffer *evbuf, char *tag, char *str, int len) { char buf[4]; evbuffer_add(evbuf, tag, 4); /* Length */ buf[0] = (len >> 24) & 0xff; buf[1] = (len >> 16) & 0xff; buf[2] = (len >> 8) & 0xff; buf[3] = len & 0xff; evbuffer_add(evbuf, buf, sizeof(buf)); if (str && (len > 0)) evbuffer_add(evbuf, str, len); } void dmap_add_string(struct evbuffer *evbuf, char *tag, const char *str) { unsigned char buf[4]; int len; if (str) len = strlen(str); else len = 0; evbuffer_add(evbuf, tag, 4); /* String length */ buf[0] = (len >> 24) & 0xff; buf[1] = (len >> 16) & 0xff; buf[2] = (len >> 8) & 0xff; buf[3] = len & 0xff; evbuffer_add(evbuf, buf, sizeof(buf)); if (len) evbuffer_add(evbuf, str, len); } void dmap_add_field(struct evbuffer *evbuf, const struct dmap_field *df, char *strval, int32_t intval) { union { int32_t v_i32; uint32_t v_u32; int64_t v_i64; uint64_t v_u64; } val; int ret; if (strval && (df->type != DMAP_TYPE_STRING)) { switch (df->type) { case DMAP_TYPE_DATE: case DMAP_TYPE_UBYTE: case DMAP_TYPE_USHORT: case DMAP_TYPE_UINT: ret = safe_atou32(strval, &val.v_u32); if (ret < 0) val.v_u32 = 0; break; case DMAP_TYPE_BYTE: case DMAP_TYPE_SHORT: case DMAP_TYPE_INT: ret = safe_atoi32(strval, &val.v_i32); if (ret < 0) val.v_i32 = 0; break; case DMAP_TYPE_ULONG: ret = safe_atou64(strval, &val.v_u64); if (ret < 0) val.v_u64 = 0; break; case DMAP_TYPE_LONG: ret = safe_atoi64(strval, &val.v_i64); if (ret < 0) val.v_i64 = 0; break; /* DMAP_TYPE_VERSION & DMAP_TYPE_LIST not handled here */ default: DPRINTF(E_LOG, L_DAAP, "Unsupported DMAP type %d for DMAP field %s\n", df->type, df->desc); return; } } else if (!strval && (df->type != DMAP_TYPE_STRING)) { switch (df->type) { case DMAP_TYPE_DATE: case DMAP_TYPE_UBYTE: case DMAP_TYPE_USHORT: case DMAP_TYPE_UINT: val.v_u32 = intval; break; case DMAP_TYPE_BYTE: case DMAP_TYPE_SHORT: case DMAP_TYPE_INT: val.v_i32 = intval; break; case DMAP_TYPE_ULONG: val.v_u64 = intval; break; case DMAP_TYPE_LONG: val.v_i64 = intval; break; /* DMAP_TYPE_VERSION & DMAP_TYPE_LIST not handled here */ default: DPRINTF(E_LOG, L_DAAP, "Unsupported DMAP type %d for DMAP field %s\n", df->type, df->desc); return; } } switch (df->type) { case DMAP_TYPE_UBYTE: if (val.v_u32) dmap_add_char(evbuf, df->tag, val.v_u32); break; case DMAP_TYPE_BYTE: if (val.v_i32) dmap_add_char(evbuf, df->tag, val.v_i32); break; case DMAP_TYPE_USHORT: if (val.v_u32) dmap_add_short(evbuf, df->tag, val.v_u32); break; case DMAP_TYPE_SHORT: if (val.v_i32) dmap_add_short(evbuf, df->tag, val.v_i32); break; case DMAP_TYPE_DATE: case DMAP_TYPE_UINT: if (val.v_u32) dmap_add_int(evbuf, df->tag, val.v_u32); break; case DMAP_TYPE_INT: if (val.v_i32) dmap_add_int(evbuf, df->tag, val.v_i32); break; case DMAP_TYPE_ULONG: if (val.v_u64) dmap_add_long(evbuf, df->tag, val.v_u64); break; case DMAP_TYPE_LONG: if (val.v_i64) dmap_add_long(evbuf, df->tag, val.v_i64); break; case DMAP_TYPE_STRING: if (strval) dmap_add_string(evbuf, df->tag, strval); break; case DMAP_TYPE_VERSION: case DMAP_TYPE_LIST: return; } } int dmap_send_error(struct httpd_hdl *h, char *container, char *errmsg) { struct evbuffer *evbuf; int len; int ret; evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_DAAP, "Could not allocate evbuffer for DAAP error\n"); goto out_error; } len = 12 + 8 + 8 + strlen(errmsg); ret = evbuffer_expand(evbuf, len); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP error\n"); evbuffer_free(evbuf); goto out_error; } dmap_add_container(evbuf, container, len - 8); dmap_add_int(evbuf, "mstt", 500); dmap_add_string(evbuf, "msts", errmsg); http_response_set_body(h->r, evbuf); ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } int dmap_encode_file_metadata(struct evbuffer *songlist, struct evbuffer *song, struct db_media_file_info *dbmfi, const struct dmap_field **meta, int nmeta, int sort_tags, int force_wav) { const struct dmap_field_map *dfm; const struct dmap_field *df; char **strval; char *ptr; int32_t val; int want_mikd; int want_asdk; int i; int ret; want_mikd = 0; want_asdk = 0; i = -1; while (1) { i++; /* Specific meta tags requested (or default list) */ if (nmeta > 0) { if (i == nmeta) break; df = meta[i]; dfm = df->dfm; } /* No specific meta tags requested, send out everything */ else { /* End of list */ if (i == (sizeof(dmap_fields) / sizeof(dmap_fields[0]))) break; df = &dmap_fields[i]; dfm = dmap_fields[i].dfm; } /* Not in struct media_file_info */ if (dfm->mfi_offset < 0) continue; /* Will be prepended to the list */ if (dfm == &dfm_dmap_mikd) { /* item kind */ want_mikd = 1; continue; } else if (dfm == &dfm_dmap_asdk) { /* data kind */ want_asdk = 1; continue; } DPRINTF(E_DBG, L_DAAP, "Investigating %s\n", df->desc); strval = (char **) ((char *)dbmfi + dfm->mfi_offset); if (!(*strval) || (**strval == '\0')) continue; /* Here's one exception ... codectype (ascd) is actually an integer */ if (dfm == &dfm_dmap_ascd) { dmap_add_literal(song, df->tag, *strval, 4); continue; } val = 0; if (force_wav) { switch (dfm->mfi_offset) { case dbmfi_offsetof(type): ptr = "wav"; strval = &ptr; break; case dbmfi_offsetof(bitrate): val = 0; ret = safe_atoi32(dbmfi->samplerate, &val); if ((ret < 0) || (val == 0)) val = 1411; else val = (val * 8) / 250; ptr = NULL; strval = &ptr; break; case dbmfi_offsetof(description): ptr = "wav audio file"; strval = &ptr; break; default: break; } } dmap_add_field(song, df, *strval, val); DPRINTF(E_DBG, L_DAAP, "Done with meta tag %s (%s)\n", df->desc, *strval); } if (sort_tags) { dmap_add_string(song, "assn", dbmfi->title_sort); dmap_add_string(song, "assa", dbmfi->artist_sort); dmap_add_string(song, "assu", dbmfi->album_sort); dmap_add_string(song, "assl", dbmfi->album_artist_sort); if (dbmfi->composer_sort) dmap_add_string(song, "assc", dbmfi->composer_sort); } val = 0; if (want_mikd) val += 9; if (want_asdk) val += 9; dmap_add_container(songlist, "mlit", EVBUFFER_LENGTH(song) + val); /* Prepend mikd & asdk if needed */ if (want_mikd) { /* dmap.itemkind must come first */ ret = safe_atoi32(dbmfi->item_kind, &val); if (ret < 0) val = 2; /* music by default */ dmap_add_char(songlist, "mikd", val); } if (want_asdk) { ret = safe_atoi32(dbmfi->data_kind, &val); if (ret < 0) val = 0; dmap_add_char(songlist, "asdk", val); } ret = evbuffer_add_buffer(songlist, song); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add song to song list\n"); return -1; } return 0; } forked-daapd-0.19gcd/src/dmap_common.h0000664000175000017500000000361211633141135017233 0ustar julienjulien #ifndef __DMAP_HELPERS_H__ #define __DMAP_HELPERS_H__ #include "evbuffer/evbuffer.h" #include "db.h" #include "httpd.h" enum dmap_type { DMAP_TYPE_UBYTE = 0x01, DMAP_TYPE_BYTE = 0x02, DMAP_TYPE_USHORT = 0x03, DMAP_TYPE_SHORT = 0x04, DMAP_TYPE_UINT = 0x05, DMAP_TYPE_INT = 0x06, DMAP_TYPE_ULONG = 0x07, DMAP_TYPE_LONG = 0x08, DMAP_TYPE_STRING = 0x09, DMAP_TYPE_DATE = 0x0a, DMAP_TYPE_VERSION = 0x0b, DMAP_TYPE_LIST = 0x0c, }; struct dmap_field_map { ssize_t mfi_offset; ssize_t pli_offset; ssize_t gri_offset; }; struct dmap_field { char *desc; char *tag; const struct dmap_field_map *dfm; enum dmap_type type; }; extern const struct dmap_field_map dfm_dmap_mimc; extern const struct dmap_field_map dfm_dmap_aeSP; const struct dmap_field * dmap_get_fields_table(int *nfields); /* From dmap_fields.gperf - keep in sync, don't alter */ const struct dmap_field * dmap_find_field (register const char *str, register unsigned int len); void dmap_add_container(struct evbuffer *evbuf, char *tag, int len); void dmap_add_long(struct evbuffer *evbuf, char *tag, int64_t val); void dmap_add_int(struct evbuffer *evbuf, char *tag, int val); void dmap_add_short(struct evbuffer *evbuf, char *tag, short val); void dmap_add_char(struct evbuffer *evbuf, char *tag, char val); void dmap_add_literal(struct evbuffer *evbuf, char *tag, char *str, int len); void dmap_add_string(struct evbuffer *evbuf, char *tag, const char *str); void dmap_add_field(struct evbuffer *evbuf, const struct dmap_field *df, char *strval, int32_t intval); int dmap_send_error(struct httpd_hdl *h, char *container, char *errmsg); int dmap_encode_file_metadata(struct evbuffer *songlist, struct evbuffer *song, struct db_media_file_info *dbmfi, const struct dmap_field **meta, int nmeta, int sort_tags, int force_wav); #endif /* !__DMAP_HELPERS_H__ */ forked-daapd-0.19gcd/src/dmap_fields.gperf0000664000175000017500000007355311633141135020100 0ustar julienjulien%language=ANSI-C %readonly-tables %enum %switch=1 %compare-lengths %define hash-function-name dmap_hash_field %define lookup-function-name dmap_find_field %define slot-name desc %global-table %define word-array-name dmap_fields %struct-type %omit-struct-type %{ /* Non-static fields are exported by dmap_common.h */ static const struct dmap_field_map dfm_dmap_miid = { dbmfi_offsetof(id), dbpli_offsetof(id), -1 }; static const struct dmap_field_map dfm_dmap_minm = { dbmfi_offsetof(title), dbpli_offsetof(title), dbgri_offsetof(itemname) }; static const struct dmap_field_map dfm_dmap_mikd = { dbmfi_offsetof(item_kind), -1, -1 }; static const struct dmap_field_map dfm_dmap_mper = { dbmfi_offsetof(id), dbpli_offsetof(id), dbgri_offsetof(persistentid) }; static const struct dmap_field_map dfm_dmap_mcon = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mcti = { dbmfi_offsetof(id), -1, -1 }; static const struct dmap_field_map dfm_dmap_mpco = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mstt = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msts = { -1, -1, -1 }; const struct dmap_field_map dfm_dmap_mimc = { dbmfi_offsetof(total_tracks), dbpli_offsetof(items), dbgri_offsetof(itemcount) }; static const struct dmap_field_map dfm_dmap_mctc = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mrco = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mtco = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mlcl = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mlit = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mbcl = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mdcl = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msrv = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msau = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mslr = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mpro = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msal = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msup = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mspi = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msex = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msbr = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msqy = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msix = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msrs = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mstm = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_msdc = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mlog = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mlid = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mupd = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_musr = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_muty = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mudl = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mccr = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mcnm = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mcna = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_mcty = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_apro = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_avdb = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_abro = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_abal = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_abar = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_abcp = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_abgn = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_adbs = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_asal = { dbmfi_offsetof(album), -1, -1 }; static const struct dmap_field_map dfm_dmap_asai = { dbmfi_offsetof(songalbumid), -1, -1 }; static const struct dmap_field_map dfm_dmap_asaa = { dbmfi_offsetof(album_artist), -1, dbgri_offsetof(songalbumartist) }; static const struct dmap_field_map dfm_dmap_asar = { dbmfi_offsetof(artist), -1, -1 }; static const struct dmap_field_map dfm_dmap_asbt = { dbmfi_offsetof(bpm), -1, -1 }; static const struct dmap_field_map dfm_dmap_asbr = { dbmfi_offsetof(bitrate), -1, -1 }; static const struct dmap_field_map dfm_dmap_ascm = { dbmfi_offsetof(comment), -1, -1 }; static const struct dmap_field_map dfm_dmap_asco = { dbmfi_offsetof(compilation), -1, -1 }; static const struct dmap_field_map dfm_dmap_ascp = { dbmfi_offsetof(composer), -1, -1 }; static const struct dmap_field_map dfm_dmap_asda = { dbmfi_offsetof(time_added), -1, -1 }; static const struct dmap_field_map dfm_dmap_asdm = { dbmfi_offsetof(time_modified), -1, -1 }; static const struct dmap_field_map dfm_dmap_asdc = { dbmfi_offsetof(total_discs), -1, -1 }; static const struct dmap_field_map dfm_dmap_asdn = { dbmfi_offsetof(disc), -1, -1 }; static const struct dmap_field_map dfm_dmap_asdb = { dbmfi_offsetof(disabled), -1, -1 }; static const struct dmap_field_map dfm_dmap_aseq = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_asfm = { dbmfi_offsetof(type), -1, -1 }; static const struct dmap_field_map dfm_dmap_asgn = { dbmfi_offsetof(genre), -1, -1 }; static const struct dmap_field_map dfm_dmap_asdt = { dbmfi_offsetof(description), -1, -1 }; static const struct dmap_field_map dfm_dmap_asrv = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_assr = { dbmfi_offsetof(samplerate), -1, -1 }; static const struct dmap_field_map dfm_dmap_assz = { dbmfi_offsetof(file_size), -1, -1 }; static const struct dmap_field_map dfm_dmap_asst = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_assp = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_astm = { dbmfi_offsetof(song_length), -1, -1 }; static const struct dmap_field_map dfm_dmap_astc = { dbmfi_offsetof(total_tracks), -1, -1 }; static const struct dmap_field_map dfm_dmap_astn = { dbmfi_offsetof(track), -1, -1 }; static const struct dmap_field_map dfm_dmap_asur = { dbmfi_offsetof(rating), -1, -1 }; static const struct dmap_field_map dfm_dmap_asyr = { dbmfi_offsetof(year), -1, -1 }; static const struct dmap_field_map dfm_dmap_asdk = { dbmfi_offsetof(data_kind), -1, -1 }; static const struct dmap_field_map dfm_dmap_asul = { dbmfi_offsetof(url), -1, -1 }; static const struct dmap_field_map dfm_dmap_aply = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_abpl = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_apso = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_arsv = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_arif = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aeNV = { -1, -1, -1 }; const struct dmap_field_map dfm_dmap_aeSP = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aePS = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_ascd = { dbmfi_offsetof(codectype), -1, -1 }; static const struct dmap_field_map dfm_dmap_ascs = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_agrp = { dbmfi_offsetof(grouping), -1, -1 }; static const struct dmap_field_map dfm_dmap_aeSV = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aePI = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aeCI = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aeGI = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aeAI = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aeSI = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aeSF = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_ascr = { dbmfi_offsetof(contentrating), -1, -1 }; static const struct dmap_field_map dfm_dmap_aeHV = { dbmfi_offsetof(has_video), -1, -1 }; static const struct dmap_field_map dfm_dmap_msas = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_asct = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_ascn = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aslc = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_asky = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_apsm = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aprm = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aePC = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aePP = { -1, -1, -1 }; static const struct dmap_field_map dfm_dmap_aeMK = { dbmfi_offsetof(media_kind), -1, -1 }; static const struct dmap_field_map dfm_dmap_aeMk = { dbmfi_offsetof(media_kind), -1, -1 }; static const struct dmap_field_map dfm_dmap_aeSN = { dbmfi_offsetof(tv_series_name), -1, -1 }; static const struct dmap_field_map dfm_dmap_aeNN = { dbmfi_offsetof(tv_network_name), -1, -1 }; static const struct dmap_field_map dfm_dmap_aeEN = { dbmfi_offsetof(tv_episode_num_str), -1, -1 }; static const struct dmap_field_map dfm_dmap_aeES = { dbmfi_offsetof(tv_episode_sort), -1, -1 }; static const struct dmap_field_map dfm_dmap_aeSU = { dbmfi_offsetof(tv_season_num), -1, -1 }; static const struct dmap_field_map dfm_dmap_assn = { dbmfi_offsetof(title_sort), -1, -1 }; static const struct dmap_field_map dfm_dmap_assa = { dbmfi_offsetof(artist_sort), -1, -1 }; static const struct dmap_field_map dfm_dmap_assu = { dbmfi_offsetof(album_sort), -1, -1 }; static const struct dmap_field_map dfm_dmap_assc = { dbmfi_offsetof(composer_sort), -1, -1 }; static const struct dmap_field_map dfm_dmap_assl = { dbmfi_offsetof(album_artist_sort), -1, -1 }; %} struct dmap_field; %% "daap.browsealbumlisting", "abal", &dfm_dmap_abal, DMAP_TYPE_LIST "daap.browseartistlisting", "abar", &dfm_dmap_abar, DMAP_TYPE_LIST "daap.browsecomposerlisting", "abcp", &dfm_dmap_abcp, DMAP_TYPE_LIST "daap.browsegenrelisting", "abgn", &dfm_dmap_abgn, DMAP_TYPE_LIST "daap.baseplaylist", "abpl", &dfm_dmap_abpl, DMAP_TYPE_UBYTE "daap.databasebrowse", "abro", &dfm_dmap_abro, DMAP_TYPE_LIST "daap.databasesongs", "adbs", &dfm_dmap_adbs, DMAP_TYPE_LIST "com.apple.itunes.itms-artistid", "aeAI", &dfm_dmap_aeAI, DMAP_TYPE_UINT "com.apple.itunes.itms-composerid", "aeCI", &dfm_dmap_aeCI, DMAP_TYPE_UINT "com.apple.itunes.episode-num-str", "aeEN", &dfm_dmap_aeEN, DMAP_TYPE_STRING "com.apple.itunes.episode-sort", "aeES", &dfm_dmap_aeES, DMAP_TYPE_UINT "com.apple.itunes.itms-genreid", "aeGI", &dfm_dmap_aeGI, DMAP_TYPE_UINT "com.apple.itunes.has-video", "aeHV", &dfm_dmap_aeHV, DMAP_TYPE_UBYTE "com.apple.itunes.extended-media-kind", "aeMk", &dfm_dmap_aeMk, DMAP_TYPE_UINT "com.apple.itunes.mediakind", "aeMK", &dfm_dmap_aeMK, DMAP_TYPE_UBYTE "com.apple.itunes.network-name", "aeNN", &dfm_dmap_aeNN, DMAP_TYPE_STRING "com.apple.itunes.norm-volume", "aeNV", &dfm_dmap_aeNV, DMAP_TYPE_UINT "com.apple.itunes.is-podcast", "aePC", &dfm_dmap_aePC, DMAP_TYPE_UBYTE "com.apple.itunes.itms-playlistid", "aePI", &dfm_dmap_aePI, DMAP_TYPE_UINT "com.apple.itunes.is-podcast-playlist", "aePP", &dfm_dmap_aePP, DMAP_TYPE_UBYTE "com.apple.itunes.special-playlist", "aePS", &dfm_dmap_aePS, DMAP_TYPE_UBYTE "com.apple.itunes.itms-storefrontid", "aeSF", &dfm_dmap_aeSF, DMAP_TYPE_UINT "com.apple.itunes.itms-songid", "aeSI", &dfm_dmap_aeSI, DMAP_TYPE_UINT "com.apple.itunes.series-name", "aeSN", &dfm_dmap_aeSN, DMAP_TYPE_STRING "com.apple.itunes.smart-playlist", "aeSP", &dfm_dmap_aeSP, DMAP_TYPE_UBYTE "com.apple.itunes.season-num", "aeSU", &dfm_dmap_aeSU, DMAP_TYPE_UINT "com.apple.itunes.music-sharing-version", "aeSV", &dfm_dmap_aeSV, DMAP_TYPE_UINT "daap.songgrouping", "agrp", &dfm_dmap_agrp, DMAP_TYPE_STRING "daap.databaseplaylists", "aply", &dfm_dmap_aply, DMAP_TYPE_LIST "daap.playlistrepeatmode", "aprm", &dfm_dmap_aprm, DMAP_TYPE_UBYTE "daap.protocolversion", "apro", &dfm_dmap_apro, DMAP_TYPE_VERSION "daap.playlistshufflemode", "apsm", &dfm_dmap_apsm, DMAP_TYPE_UBYTE "daap.playlistsongs", "apso", &dfm_dmap_apso, DMAP_TYPE_LIST "daap.resolveinfo", "arif", &dfm_dmap_arif, DMAP_TYPE_LIST "daap.resolve", "arsv", &dfm_dmap_arsv, DMAP_TYPE_LIST "daap.songalbumartist", "asaa", &dfm_dmap_asaa, DMAP_TYPE_STRING "daap.songalbumid", "asai", &dfm_dmap_asai, DMAP_TYPE_ULONG "daap.songalbum", "asal", &dfm_dmap_asal, DMAP_TYPE_STRING "daap.songartist", "asar", &dfm_dmap_asar, DMAP_TYPE_STRING "daap.songbitrate", "asbr", &dfm_dmap_asbr, DMAP_TYPE_USHORT "daap.songbeatsperminute", "asbt", &dfm_dmap_asbt, DMAP_TYPE_USHORT "daap.songcodectype", "ascd", &dfm_dmap_ascd, DMAP_TYPE_UINT "daap.songcomment", "ascm", &dfm_dmap_ascm, DMAP_TYPE_STRING "daap.songcontentdescription", "ascn", &dfm_dmap_ascn, DMAP_TYPE_STRING "daap.songcompilation", "asco", &dfm_dmap_asco, DMAP_TYPE_UBYTE "daap.songcomposer", "ascp", &dfm_dmap_ascp, DMAP_TYPE_STRING "daap.songcontentrating", "ascr", &dfm_dmap_ascr, DMAP_TYPE_UBYTE "daap.songcodecsubtype", "ascs", &dfm_dmap_ascs, DMAP_TYPE_UINT "daap.songcategory", "asct", &dfm_dmap_asct, DMAP_TYPE_STRING "daap.songdateadded", "asda", &dfm_dmap_asda, DMAP_TYPE_DATE "daap.songdisabled", "asdb", &dfm_dmap_asdb, DMAP_TYPE_UBYTE "daap.songdisccount", "asdc", &dfm_dmap_asdc, DMAP_TYPE_USHORT "daap.songdatakind", "asdk", &dfm_dmap_asdk, DMAP_TYPE_UBYTE "daap.songdatemodified", "asdm", &dfm_dmap_asdm, DMAP_TYPE_DATE "daap.songdiscnumber", "asdn", &dfm_dmap_asdn, DMAP_TYPE_USHORT "daap.songdescription", "asdt", &dfm_dmap_asdt, DMAP_TYPE_STRING "daap.songeqpreset", "aseq", &dfm_dmap_aseq, DMAP_TYPE_STRING "daap.songformat", "asfm", &dfm_dmap_asfm, DMAP_TYPE_STRING "daap.songgenre", "asgn", &dfm_dmap_asgn, DMAP_TYPE_STRING "daap.songkeywords", "asky", &dfm_dmap_asky, DMAP_TYPE_STRING "daap.songlongcontentdescription", "aslc", &dfm_dmap_aslc, DMAP_TYPE_STRING "daap.songrelativevolume", "asrv", &dfm_dmap_asrv, DMAP_TYPE_BYTE "daap.sortartist", "assa", &dfm_dmap_assa, DMAP_TYPE_STRING "daap.sortcomposer", "assc", &dfm_dmap_assc, DMAP_TYPE_STRING "daap.sortalbumartist", "assl", &dfm_dmap_assl, DMAP_TYPE_STRING "daap.sortname", "assn", &dfm_dmap_assn, DMAP_TYPE_STRING "daap.songstoptime", "assp", &dfm_dmap_assp, DMAP_TYPE_UINT "daap.songsamplerate", "assr", &dfm_dmap_assr, DMAP_TYPE_UINT "daap.songstarttime", "asst", &dfm_dmap_asst, DMAP_TYPE_UINT "daap.sortalbum", "assu", &dfm_dmap_assu, DMAP_TYPE_STRING "daap.songsize", "assz", &dfm_dmap_assz, DMAP_TYPE_UINT "daap.songtrackcount", "astc", &dfm_dmap_astc, DMAP_TYPE_USHORT "daap.songtime", "astm", &dfm_dmap_astm, DMAP_TYPE_UINT "daap.songtracknumber", "astn", &dfm_dmap_astn, DMAP_TYPE_USHORT "daap.songdataurl", "asul", &dfm_dmap_asul, DMAP_TYPE_STRING "daap.songuserrating", "asur", &dfm_dmap_asur, DMAP_TYPE_UBYTE "daap.songyear", "asyr", &dfm_dmap_asyr, DMAP_TYPE_USHORT "daap.serverdatabases", "avdb", &dfm_dmap_avdb, DMAP_TYPE_LIST "dmap.bag", "mbcl", &dfm_dmap_mbcl, DMAP_TYPE_LIST "dmap.contentcodesresponse", "mccr", &dfm_dmap_mccr, DMAP_TYPE_LIST "dmap.contentcodesname", "mcna", &dfm_dmap_mcna, DMAP_TYPE_STRING "dmap.contentcodesnumber", "mcnm", &dfm_dmap_mcnm, DMAP_TYPE_UINT "dmap.container", "mcon", &dfm_dmap_mcon, DMAP_TYPE_LIST "dmap.containercount", "mctc", &dfm_dmap_mctc, DMAP_TYPE_UINT "dmap.containeritemid", "mcti", &dfm_dmap_mcti, DMAP_TYPE_UINT "dmap.contentcodestype", "mcty", &dfm_dmap_mcty, DMAP_TYPE_USHORT "dmap.dictionary", "mdcl", &dfm_dmap_mdcl, DMAP_TYPE_LIST "dmap.itemid", "miid", &dfm_dmap_miid, DMAP_TYPE_UINT "dmap.itemkind", "mikd", &dfm_dmap_mikd, DMAP_TYPE_UBYTE "dmap.itemcount", "mimc", &dfm_dmap_mimc, DMAP_TYPE_UINT "dmap.itemname", "minm", &dfm_dmap_minm, DMAP_TYPE_STRING "dmap.listing", "mlcl", &dfm_dmap_mlcl, DMAP_TYPE_LIST "dmap.sessionid", "mlid", &dfm_dmap_mlid, DMAP_TYPE_UINT "dmap.listingitem", "mlit", &dfm_dmap_mlit, DMAP_TYPE_LIST "dmap.loginresponse", "mlog", &dfm_dmap_mlog, DMAP_TYPE_LIST "dmap.parentcontainerid", "mpco", &dfm_dmap_mpco, DMAP_TYPE_UINT "dmap.persistentid", "mper", &dfm_dmap_mper, DMAP_TYPE_ULONG "dmap.protocolversion", "mpro", &dfm_dmap_mpro, DMAP_TYPE_VERSION "dmap.returnedcount", "mrco", &dfm_dmap_mrco, DMAP_TYPE_UINT "dmap.supportsautologout", "msal", &dfm_dmap_msal, DMAP_TYPE_UBYTE "dmap.authenticationschemes", "msas", &dfm_dmap_msas, DMAP_TYPE_UINT "dmap.authenticationmethod", "msau", &dfm_dmap_msau, DMAP_TYPE_UBYTE "dmap.supportsbrowse", "msbr", &dfm_dmap_msbr, DMAP_TYPE_UBYTE "dmap.databasescount", "msdc", &dfm_dmap_msdc, DMAP_TYPE_UINT "dmap.supportsextensions", "msex", &dfm_dmap_msex, DMAP_TYPE_UBYTE "dmap.supportsindex", "msix", &dfm_dmap_msix, DMAP_TYPE_UBYTE "dmap.loginrequired", "mslr", &dfm_dmap_mslr, DMAP_TYPE_UBYTE "dmap.supportspersistentids", "mspi", &dfm_dmap_mspi, DMAP_TYPE_UBYTE "dmap.supportsquery", "msqy", &dfm_dmap_msqy, DMAP_TYPE_UBYTE "dmap.supportsresolve", "msrs", &dfm_dmap_msrs, DMAP_TYPE_UBYTE "dmap.serverinforesponse", "msrv", &dfm_dmap_msrv, DMAP_TYPE_LIST "dmap.timeoutinterval", "mstm", &dfm_dmap_mstm, DMAP_TYPE_UINT "dmap.statusstring", "msts", &dfm_dmap_msts, DMAP_TYPE_STRING "dmap.status", "mstt", &dfm_dmap_mstt, DMAP_TYPE_UINT "dmap.supportsupdate", "msup", &dfm_dmap_msup, DMAP_TYPE_UBYTE "dmap.specifiedtotalcount", "mtco", &dfm_dmap_mtco, DMAP_TYPE_UINT "dmap.deletedidlisting", "mudl", &dfm_dmap_mudl, DMAP_TYPE_LIST "dmap.updateresponse", "mupd", &dfm_dmap_mupd, DMAP_TYPE_LIST "dmap.serverrevision", "musr", &dfm_dmap_musr, DMAP_TYPE_UINT "dmap.updatetype", "muty", &dfm_dmap_muty, DMAP_TYPE_UBYTE %% /* Sort fields */ /* "dmap.sortingheaderlisting", "mshl", &dfm_dmap_mshl, DMAP_TYPE_UINT "dmap.sortingheaderchar", "mshc", &dfm_dmap_mshc, DMAP_TYPE_SHORT "dmap.sortingheaderindex", "mshi", &dfm_dmap_mshi, DMAP_TYPE_UINT "dmap.sortingheadernumber", "mshn", &dfm_dmap_mshn, DMAP_TYPE_UINT */ /* Unsupported DMAP fields */ /* "com.apple.itunes.adam-ids-array", "aeAD", &dfm_dmap_aeAD, DMAP_TYPE_LIST "com.apple.itunes.content-rating", "aeCR", &dfm_dmap_aeCR, DMAP_TYPE_STRING "com.apple.itunes.drm-platform-id", "aeDP", &dfm_dmap_aeDP, DMAP_TYPE_UINT "com.apple.itunes.drm-user-id", "aeDR", &dfm_dmap_aeDR, DMAP_TYPE_ULONG "com.apple.itunes.drm-versions", "aeDV", &dfm_dmap_aeDV, DMAP_TYPE_UINT "com.apple.itunes.gapless-enc-dr", "aeGD", &dfm_dmap_aeGD, DMAP_TYPE_UINT "com.apple.itunes.gapless-enc-del", "aeGE", &dfm_dmap_aeGE, DMAP_TYPE_UINT "com.apple.itunes.gapless-heur", "aeGH", &dfm_dmap_aeGH, DMAP_TYPE_UINT "com.apple.itunes.gapless-resy", "aeGR", &dfm_dmap_aeGR, DMAP_TYPE_ULONG "com.apple.itunes.gapless-dur", "aeGU", &dfm_dmap_aeGU, DMAP_TYPE_ULONG "com.apple.itunes.is-hd-video", "aeHD", &dfm_dmap_aeHD, DMAP_TYPE_UBYTE "com.apple.itunes.drm-key1-id", "aeK1", &dfm_dmap_aeK1, DMAP_TYPE_ULONG "com.apple.itunes.drm-key2-id", "aeK2", &dfm_dmap_aeK2, DMAP_TYPE_ULONG "com.apple.itunes.non-drm-user-id", "aeND", &dfm_dmap_aeND, DMAP_TYPE_ULONG "com.apple.itunes.store-pers-id", "aeSE", &dfm_dmap_aeSE, DMAP_TYPE_ULONG "com.apple.itunes.saved-genius", "aeSG", &dfm_dmap_aeSG, DMAP_TYPE_UBYTE "com.apple.itunes.xid", "aeXD", &dfm_dmap_aeXD, DMAP_TYPE_STRING "daap.bookmarkable", "asbk", &dfm_dmap_asbk, DMAP_TYPE_UBYTE "daap.songbookmark", "asbo", &dfm_dmap_asbo, DMAP_TYPE_UINT "daap.songdatepurchased", "asdp", &dfm_dmap_asdp, DMAP_TYPE_DATE "daap.songdatereleased", "asdr", &dfm_dmap_asdr, DMAP_TYPE_DATE "daap.songextradata", "ased", &dfm_dmap_ased, DMAP_TYPE_USHORT "daap.songgapless", "asgp", &dfm_dmap_asgp, DMAP_TYPE_UBYTE "daap.songhasbeenplayed", "ashp", &dfm_dmap_ashp, DMAP_TYPE_UBYTE "daap.songlongsize", "asls", &dfm_dmap_asls, DMAP_TYPE_ULONG "daap.songpodcasturl", "aspu", &dfm_dmap_aspu, DMAP_TYPE_STRING "daap.sortseriesname", "asss", &dfm_dmap_asss, DMAP_TYPE_STRING "daap.supportsextradata", "ated", &dfm_dmap_ated, DMAP_TYPE_USHORT "com.apple.itunes.jukebox-client-vote", "ceJC", &dfm_dmap_ceJC, DMAP_TYPE_BYTE "com.apple.itunes.jukebox-current", "ceJI", &dfm_dmap_ceJI, DMAP_TYPE_UINT "com.apple.itunes.jukebox-score", "ceJS", &dfm_dmap_ceJS, DMAP_TYPE_SHORT "com.apple.itunes.jukebox-vote", "ceJV", &dfm_dmap_ceJV, DMAP_TYPE_UINT "dmap.editcommandssupported", "meds", &dfm_dmap_meds, DMAP_TYPE_UINT "dmap.utctime", "mstc", &dfm_dmap_mstc, DMAP_TYPE_DATE "dmap.utcoffset", "msto", &dfm_dmap_msto, DMAP_TYPE_INT */ /* DMAP test fields */ /* "test.container", "TEST", &dfm_dmap_TEST, DMAP_TYPE_LIST "test.ubyte", "TST1", &dfm_dmap_TST1, DMAP_TYPE_UBYTE "test.byte", "TST2", &dfm_dmap_TST2, DMAP_TYPE_BYTE "test.ushort", "TST3", &dfm_dmap_TST3, DMAP_TYPE_USHORT "test.short", "TST4", &dfm_dmap_TST4, DMAP_TYPE_SHORT "test.uint", "TST5", &dfm_dmap_TST5, DMAP_TYPE_UINT "test.int", "TST6", &dfm_dmap_TST6, DMAP_TYPE_INT "test.ulong", "TST7", &dfm_dmap_TST7, DMAP_TYPE_ULONG "test.long", "TST8", &dfm_dmap_TST8, DMAP_TYPE_LONG "test.string", "TST9", &dfm_dmap_TST9, DMAP_TYPE_STRING */ forked-daapd-0.19gcd/src/evbuffer/0000775000175000017500000000000011633141135016373 5ustar julienjulienforked-daapd-0.19gcd/src/evbuffer/evbuffer.c0000664000175000017500000002257211633141135020353 0ustar julienjulien/* * evbuffer imported from libevent 1.4.13 (buffer.c) * Adapted for forked-daapd * * Copyright (c) 2002, 2003 Niels Provos * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include #include #include #include #include #include #include #include #include #include #include "evbuffer/evbuffer.h" struct evbuffer * evbuffer_new(void) { struct evbuffer *buffer; buffer = calloc(1, sizeof(struct evbuffer)); return (buffer); } void evbuffer_free(struct evbuffer *buffer) { if (buffer->orig_buffer != NULL) free(buffer->orig_buffer); free(buffer); } /* * This is a destructive add. The data from one buffer moves into * the other buffer. */ #define SWAP(x,y) do { \ (x)->buffer = (y)->buffer; \ (x)->orig_buffer = (y)->orig_buffer; \ (x)->misalign = (y)->misalign; \ (x)->totallen = (y)->totallen; \ (x)->off = (y)->off; \ } while (0) int evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf) { int res; /* Short cut for better performance */ if (outbuf->off == 0) { struct evbuffer tmp; size_t oldoff = inbuf->off; /* Swap them directly */ SWAP(&tmp, outbuf); SWAP(outbuf, inbuf); SWAP(inbuf, &tmp); /* * Optimization comes with a price; we need to notify the * buffer if necessary of the changes. oldoff is the amount * of data that we transfered from inbuf to outbuf */ if (inbuf->off != oldoff && inbuf->cb != NULL) (*inbuf->cb)(inbuf, oldoff, inbuf->off, inbuf->cbarg); if (oldoff && outbuf->cb != NULL) (*outbuf->cb)(outbuf, 0, oldoff, outbuf->cbarg); return (0); } res = evbuffer_add(outbuf, inbuf->buffer, inbuf->off); if (res == 0) { /* We drain the input buffer on success */ evbuffer_drain(inbuf, inbuf->off); } return (res); } int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap) { char *buffer; size_t space; size_t oldoff = buf->off; int sz; va_list aq; /* make sure that at least some space is available */ evbuffer_expand(buf, 64); for (;;) { size_t used = buf->misalign + buf->off; buffer = (char *)buf->buffer + buf->off; assert(buf->totallen >= used); space = buf->totallen - used; #ifndef va_copy #define va_copy(dst, src) memcpy(&(dst), &(src), sizeof(va_list)) #endif va_copy(aq, ap); sz = vsnprintf(buffer, space, fmt, aq); buffer[space - 1] = '\0'; va_end(aq); if (sz < 0) return (-1); if ((size_t)sz < space) { buf->off += sz; if (buf->cb != NULL) (*buf->cb)(buf, oldoff, buf->off, buf->cbarg); return (sz); } if (evbuffer_expand(buf, sz + 1) == -1) return (-1); } /* NOTREACHED */ } int evbuffer_add_printf(struct evbuffer *buf, const char *fmt, ...) { int res = -1; va_list ap; va_start(ap, fmt); res = evbuffer_add_vprintf(buf, fmt, ap); va_end(ap); return (res); } /* Reads data from an event buffer and drains the bytes read */ int evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen) { size_t nread = datlen; if (nread >= buf->off) nread = buf->off; memcpy(data, buf->buffer, nread); evbuffer_drain(buf, nread); return (nread); } /* * Reads a line terminated by either '\r\n', '\n\r' or '\r' or '\n'. * The returned buffer needs to be freed by the called. */ char * evbuffer_readline(struct evbuffer *buffer) { u_char *data = EVBUFFER_DATA(buffer); size_t len = EVBUFFER_LENGTH(buffer); char *line; unsigned int i; for (i = 0; i < len; i++) { if (data[i] == '\r' || data[i] == '\n') break; } if (i == len) return (NULL); if ((line = malloc(i + 1)) == NULL) { fprintf(stderr, "%s: out of memory\n", __func__); return (NULL); } memcpy(line, data, i); line[i] = '\0'; /* * Some protocols terminate a line with '\r\n', so check for * that, too. */ if ( i < len - 1 ) { char fch = data[i], sch = data[i+1]; /* Drain one more character if needed */ if ( (sch == '\r' || sch == '\n') && sch != fch ) i += 1; } evbuffer_drain(buffer, i + 1); return (line); } /* Adds data to an event buffer */ static void evbuffer_align(struct evbuffer *buf) { memmove(buf->orig_buffer, buf->buffer, buf->off); buf->buffer = buf->orig_buffer; buf->misalign = 0; } /* Expands the available space in the event buffer to at least datlen */ int evbuffer_expand(struct evbuffer *buf, size_t datlen) { size_t need = buf->misalign + buf->off + datlen; /* If we can fit all the data, then we don't have to do anything */ if (buf->totallen >= need) return (0); /* * If the misalignment fulfills our data needs, we just force an * alignment to happen. Afterwards, we have enough space. */ if (buf->misalign >= datlen) { evbuffer_align(buf); } else { void *newbuf; size_t length = buf->totallen; if (length < 256) length = 256; while (length < need) length <<= 1; if (buf->orig_buffer != buf->buffer) evbuffer_align(buf); if ((newbuf = realloc(buf->buffer, length)) == NULL) return (-1); buf->orig_buffer = buf->buffer = newbuf; buf->totallen = length; } return (0); } int evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen) { size_t need = buf->misalign + buf->off + datlen; size_t oldoff = buf->off; if (buf->totallen < need) { if (evbuffer_expand(buf, datlen) == -1) return (-1); } memcpy(buf->buffer + buf->off, data, datlen); buf->off += datlen; if (datlen && buf->cb != NULL) (*buf->cb)(buf, oldoff, buf->off, buf->cbarg); return (0); } void evbuffer_drain(struct evbuffer *buf, size_t len) { size_t oldoff = buf->off; if (len >= buf->off) { buf->off = 0; buf->buffer = buf->orig_buffer; buf->misalign = 0; goto done; } buf->buffer += len; buf->misalign += len; buf->off -= len; done: /* Tell someone about changes in this buffer */ if (buf->off != oldoff && buf->cb != NULL) (*buf->cb)(buf, oldoff, buf->off, buf->cbarg); } /* * Reads data from a file descriptor into a buffer. */ #define EVBUFFER_MAX_READ 4096 int evbuffer_read(struct evbuffer *buf, int fd, int howmuch) { u_char *p; size_t oldoff = buf->off; int n = EVBUFFER_MAX_READ; #if defined(FIONREAD) #ifdef WIN32 long lng = n; if (ioctlsocket(fd, FIONREAD, &lng) == -1 || (n=lng) <= 0) { #else if (ioctl(fd, FIONREAD, &n) == -1 || n <= 0) { #endif n = EVBUFFER_MAX_READ; } else if (n > EVBUFFER_MAX_READ && n > howmuch) { /* * It's possible that a lot of data is available for * reading. We do not want to exhaust resources * before the reader has a chance to do something * about it. If the reader does not tell us how much * data we should read, we artifically limit it. */ if ((size_t)n > buf->totallen << 2) n = buf->totallen << 2; if (n < EVBUFFER_MAX_READ) n = EVBUFFER_MAX_READ; } #endif if (howmuch < 0 || howmuch > n) howmuch = n; /* If we don't have FIONREAD, we might waste some space here */ if (evbuffer_expand(buf, howmuch) == -1) return (-1); /* We can append new data at this point */ p = buf->buffer + buf->off; #ifndef WIN32 n = read(fd, p, howmuch); #else n = recv(fd, p, howmuch, 0); #endif if (n == -1) return (-1); if (n == 0) return (0); buf->off += n; /* Tell someone about changes in this buffer */ if (buf->off != oldoff && buf->cb != NULL) (*buf->cb)(buf, oldoff, buf->off, buf->cbarg); return (n); } int evbuffer_write(struct evbuffer *buffer, int fd) { int n; #ifndef WIN32 n = write(fd, buffer->buffer, buffer->off); #else n = send(fd, buffer->buffer, buffer->off, 0); #endif if (n == -1) return (-1); if (n == 0) return (0); evbuffer_drain(buffer, n); return (n); } u_char * evbuffer_find(struct evbuffer *buffer, const u_char *what, size_t len) { u_char *search = buffer->buffer, *end = search + buffer->off; u_char *p; while (search < end && (p = memchr(search, *what, end - search)) != NULL) { if (p + len > end) break; if (memcmp(p, what, len) == 0) return (p); search = p + 1; } return (NULL); } void evbuffer_setcb(struct evbuffer *buffer, void (*cb)(struct evbuffer *, size_t, size_t, void *), void *cbarg) { buffer->cb = cb; buffer->cbarg = cbarg; } forked-daapd-0.19gcd/src/evbuffer/evbuffer.h0000664000175000017500000001454611633141135020362 0ustar julienjulien/* * evbuffer imported from libevent 1.4.13 (event.h) * Adapted for forked-daapd * * Copyright (c) 2000-2007 Niels Provos * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef __EVBUFFER_H__ #define __EVBUFFER_H__ #include #include #include struct evbuffer { u_char *buffer; u_char *orig_buffer; size_t misalign; size_t totallen; size_t off; void (*cb)(struct evbuffer *, size_t, size_t, void *); void *cbarg; }; #define EVBUFFER_LENGTH(x) (x)->off #define EVBUFFER_DATA(x) (x)->buffer #define EVBUFFER_INPUT(x) (x)->input #define EVBUFFER_OUTPUT(x) (x)->output /** Allocate storage for a new evbuffer. @return a pointer to a newly allocated evbuffer struct, or NULL if an error occurred */ struct evbuffer *evbuffer_new(void); /** Deallocate storage for an evbuffer. @param pointer to the evbuffer to be freed */ void evbuffer_free(struct evbuffer *); /** Expands the available space in an event buffer. Expands the available space in the event buffer to at least datlen @param buf the event buffer to be expanded @param datlen the new minimum length requirement @return 0 if successful, or -1 if an error occurred */ int evbuffer_expand(struct evbuffer *, size_t); /** Append data to the end of an evbuffer. @param buf the event buffer to be appended to @param data pointer to the beginning of the data buffer @param datlen the number of bytes to be copied from the data buffer */ int evbuffer_add(struct evbuffer *, const void *, size_t); /** Read data from an event buffer and drain the bytes read. @param buf the event buffer to be read from @param data the destination buffer to store the result @param datlen the maximum size of the destination buffer @return the number of bytes read */ int evbuffer_remove(struct evbuffer *, void *, size_t); /** * Read a single line from an event buffer. * * Reads a line terminated by either '\r\n', '\n\r' or '\r' or '\n'. * The returned buffer needs to be freed by the caller. * * @param buffer the evbuffer to read from * @return pointer to a single line, or NULL if an error occurred */ char *evbuffer_readline(struct evbuffer *); /** Move data from one evbuffer into another evbuffer. This is a destructive add. The data from one buffer moves into the other buffer. The destination buffer is expanded as needed. @param outbuf the output buffer @param inbuf the input buffer @return 0 if successful, or -1 if an error occurred */ int evbuffer_add_buffer(struct evbuffer *, struct evbuffer *); /** Append a formatted string to the end of an evbuffer. @param buf the evbuffer that will be appended to @param fmt a format string @param ... arguments that will be passed to printf(3) @return The number of bytes added if successful, or -1 if an error occurred. */ int evbuffer_add_printf(struct evbuffer *, const char *fmt, ...) #ifdef __GNUC__ __attribute__((format(printf, 2, 3))) #endif ; /** Append a va_list formatted string to the end of an evbuffer. @param buf the evbuffer that will be appended to @param fmt a format string @param ap a varargs va_list argument array that will be passed to vprintf(3) @return The number of bytes added if successful, or -1 if an error occurred. */ int evbuffer_add_vprintf(struct evbuffer *, const char *fmt, va_list ap); /** Remove a specified number of bytes data from the beginning of an evbuffer. @param buf the evbuffer to be drained @param len the number of bytes to drain from the beginning of the buffer */ void evbuffer_drain(struct evbuffer *, size_t); /** Write the contents of an evbuffer to a file descriptor. The evbuffer will be drained after the bytes have been successfully written. @param buffer the evbuffer to be written and drained @param fd the file descriptor to be written to @return the number of bytes written, or -1 if an error occurred @see evbuffer_read() */ int evbuffer_write(struct evbuffer *, int); /** Read from a file descriptor and store the result in an evbuffer. @param buf the evbuffer to store the result @param fd the file descriptor to read from @param howmuch the number of bytes to be read @return the number of bytes read, or -1 if an error occurred @see evbuffer_write() */ int evbuffer_read(struct evbuffer *, int, int); /** Find a string within an evbuffer. @param buffer the evbuffer to be searched @param what the string to be searched for @param len the length of the search string @return a pointer to the beginning of the search string, or NULL if the search failed. */ u_char *evbuffer_find(struct evbuffer *, const u_char *, size_t); /** Set a callback to invoke when the evbuffer is modified. @param buffer the evbuffer to be monitored @param cb the callback function to invoke when the evbuffer is modified @param cbarg an argument to be provided to the callback function */ void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, size_t, void *), void *); #endif /* __EVBUFFER_H__ */ forked-daapd-0.19gcd/src/ffmpeg_url_evbuffer.c0000664000175000017500000000564711633141135020761 0ustar julienjulien/* * Copyright (C) 2010 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include "evbuffer/evbuffer.h" #include "logger.h" #include "ffmpeg_url_evbuffer.h" /* * FFmpeg URL Protocol handler for evbuffers * * URL: evbuffer:0x03FB33DA ("evbuffer:%p") */ static int url_evbuffer_open(URLContext *h, const char *filename, int flags) { const char *p; char *end; unsigned long evbuffer_addr; if (flags != URL_WRONLY) { DPRINTF(E_LOG, L_FFMPEG, "Flags other than URL_WRONLY not supported while opening '%s'\n", filename); return AVERROR(EIO); } p = strchr(filename, ':'); if (!p) { DPRINTF(E_LOG, L_FFMPEG, "Malformed evbuffer URL: '%s'\n", filename); return AVERROR(EIO); } p++; errno = 0; evbuffer_addr = strtoul(p, &end, 16); if (((errno == ERANGE) && (evbuffer_addr == ULONG_MAX)) || ((errno != 0) && (evbuffer_addr == 0))) { DPRINTF(E_LOG, L_FFMPEG, "Invalid buffer address in URL: '%s'\n", filename); return AVERROR(EIO); } if (end == p) { DPRINTF(E_LOG, L_FFMPEG, "No buffer address found in URL: '%s'\n", filename); return AVERROR(EIO); } h->priv_data = (void *)evbuffer_addr; if (!h->priv_data) { DPRINTF(E_LOG, L_FFMPEG, "Got a NULL buffer address from URL '%s'\n", filename); return AVERROR(EIO); } /* Seek not supported */ h->is_streamed = 1; return 0; } static int url_evbuffer_close(URLContext *h) { h->priv_data = NULL; return 0; } static int url_evbuffer_write(URLContext *h, unsigned char *buf, int size) { struct evbuffer *evbuf; int ret; evbuf = (struct evbuffer *)h->priv_data; if (!evbuf) { DPRINTF(E_LOG, L_FFMPEG, "Write called on evbuffer URL with priv_data = NULL!\n"); return -1; } ret = evbuffer_add(evbuf, buf, size); return (ret == 0) ? size : -1; } URLProtocol evbuffer_protocol = { .name = "evbuffer", .url_open = url_evbuffer_open, .url_close = url_evbuffer_close, .url_write = url_evbuffer_write, }; int register_ffmpeg_evbuffer_url_protocol(void) { int ret; ret = av_register_protocol(&evbuffer_protocol); return ret; } forked-daapd-0.19gcd/src/ffmpeg_url_evbuffer.h0000664000175000017500000000024011633141135020746 0ustar julienjulien #ifndef __FFMPEG_URL_EVBUFFER_H__ #define __FFMPEG_URL_EVBUFFER_H__ int register_ffmpeg_evbuffer_url_protocol(void); #endif /* !__FFMPEG_URL_EVBUFFER_H__ */ forked-daapd-0.19gcd/src/filescanner.c0000664000175000017500000007540611633141135017240 0ustar julienjulien/* * Copyright (C) 2009-2010 Julien BLACHE * * Bits and pieces from mt-daapd: * Copyright (C) 2003 Ron Pedde (ron@pedde.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #if defined(__linux__) # include #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include # include #endif #include #include "logger.h" #include "db.h" #include "filescanner.h" #include "conffile.h" #include "misc.h" #include "remote_pairing.h" #define F_SCAN_BULK (1 << 0) #define F_SCAN_RESCAN (1 << 1) #define F_SCAN_NODUP (1 << 2) static int stop_scan; static dispatch_group_t scanner_grp; static dispatch_queue_t deferred_pl_sq; static int ino_fd; static dispatch_source_t ino_src; #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) struct stacked_dir { char *path; struct stacked_dir *next; }; static int push_dir(struct stacked_dir **s, char *path) { struct stacked_dir *d; d = (struct stacked_dir *)malloc(sizeof(struct stacked_dir)); if (!d) { DPRINTF(E_LOG, L_SCAN, "Could not stack directory %s; out of memory\n", path); return -1; } d->path = strdup(path); if (!d->path) { DPRINTF(E_LOG, L_SCAN, "Could not stack directory %s; out of memory for path\n", path); return -1; } d->next = *s; *s = d; return 0; } static char * pop_dir(struct stacked_dir **s) { struct stacked_dir *d; char *ret; if (!*s) return NULL; d = *s; *s = d->next; ret = d->path; free(d); return ret; } #endif /* defined(__FreeBSD__) || defined(__FreeBSD_kernel__) */ static void normalize_fixup_tag(char **tag, char *src_tag) { char *norm; size_t len; /* Note: include terminating NUL in string length for u8_normalize */ if (!*tag) *tag = (char *)u8_normalize(UNINORM_NFD, (uint8_t *)src_tag, strlen(src_tag) + 1, NULL, &len); else { norm = (char *)u8_normalize(UNINORM_NFD, (uint8_t *)*tag, strlen(*tag) + 1, NULL, &len); free(*tag); *tag = norm; } } static void fixup_tags(struct media_file_info *mfi) { size_t len; char *tag; char *sep = " - "; if (mfi->genre && (strlen(mfi->genre) == 0)) { free(mfi->genre); mfi->genre = NULL; } if (mfi->artist && (strlen(mfi->artist) == 0)) { free(mfi->artist); mfi->artist = NULL; } if (mfi->title && (strlen(mfi->title) == 0)) { free(mfi->title); mfi->title = NULL; } /* * Default to mpeg4 video/audio for unknown file types * in an attempt to allow streaming of DRM-afflicted files */ if (strcmp(mfi->codectype, "unkn") == 0) { if (mfi->has_video) { strcpy(mfi->codectype, "mp4v"); strcpy(mfi->type, "m4v"); } else { strcpy(mfi->codectype, "mp4a"); strcpy(mfi->type, "m4a"); } } if (!mfi->artist) { if (mfi->orchestra && mfi->conductor) { len = strlen(mfi->orchestra) + strlen(sep) + strlen(mfi->conductor); tag = (char *)malloc(len + 1); if (tag) { sprintf(tag,"%s%s%s", mfi->orchestra, sep, mfi->conductor); mfi->artist = tag; } } else if (mfi->orchestra) { mfi->artist = strdup(mfi->orchestra); } else if (mfi->conductor) { mfi->artist = strdup(mfi->conductor); } } /* Handle TV shows, try to present prettier metadata */ if (mfi->tv_series_name && strlen(mfi->tv_series_name) != 0) { mfi->media_kind = 64; /* tv show */ /* Default to artist = series_name */ if (mfi->artist && strlen(mfi->artist) == 0) { free(mfi->artist); mfi->artist = NULL; } if (!mfi->artist) mfi->artist = strdup(mfi->tv_series_name); /* Default to album = ", Season " */ if (mfi->album && strlen(mfi->album) == 0) { free(mfi->album); mfi->album = NULL; } if (!mfi->album) { len = snprintf(NULL, 0, "%s, Season %d", mfi->tv_series_name, mfi->tv_season_num); mfi->album = (char *)malloc(len + 1); if (mfi->album) sprintf(mfi->album, "%s, Season %d", mfi->tv_series_name, mfi->tv_season_num); } } /* Check the 4 top-tags are filled */ if (!mfi->artist) mfi->artist = strdup("Unknown artist"); if (!mfi->album) mfi->album = strdup("Unknown album"); if (!mfi->genre) mfi->genre = strdup("Unknown genre"); if (!mfi->title) { /* fname is left untouched by unicode_fixup_mfi() for * obvious reasons, so ensure it is proper UTF-8 */ mfi->title = unicode_fixup_string(mfi->fname); if (mfi->title == mfi->fname) mfi->title = strdup(mfi->fname); } /* Ensure sort tags are filled and normalized */ normalize_fixup_tag(&mfi->artist_sort, mfi->artist); normalize_fixup_tag(&mfi->album_sort, mfi->album); normalize_fixup_tag(&mfi->title_sort, mfi->title); /* If we don't have an album_artist, set it to artist */ if (!mfi->album_artist) { if (mfi->compilation) { mfi->album_artist = strdup(""); mfi->album_artist_sort = strdup(""); } else mfi->album_artist = strdup(mfi->artist); } if (!mfi->album_artist_sort && (strcmp(mfi->album_artist, mfi->artist) == 0)) mfi->album_artist_sort = strdup(mfi->artist_sort); else normalize_fixup_tag(&mfi->album_artist_sort, mfi->album_artist); /* Composer is not one of our mandatory tags, so take extra care */ if (mfi->composer_sort || mfi->composer) normalize_fixup_tag(&mfi->composer_sort, mfi->composer); } /* Queue: global */ static void process_media_file(char *file, time_t mtime, off_t size, int compilation) { struct media_file_info mfi; char *filename; char *ext; time_t stamp; int id; int ret; db_file_stamp_bypath(file, &stamp, &id); if (stamp >= mtime) { db_file_ping(id); return; } memset(&mfi, 0, sizeof(struct media_file_info)); if (stamp) mfi.id = db_file_id_bypath(file); filename = strrchr(file, '/'); if (!filename) { DPRINTF(E_LOG, L_SCAN, "Could not determine filename for %s\n", file); return; } mfi.fname = strdup(filename + 1); if (!mfi.fname) { DPRINTF(E_WARN, L_SCAN, "Out of memory for fname\n"); return; } mfi.path = strdup(file); if (!mfi.path) { DPRINTF(E_WARN, L_SCAN, "Out of memory for path\n"); free(mfi.fname); return; } mfi.time_modified = mtime; mfi.file_size = size; ret = -1; /* Special cases */ ext = strrchr(file, '.'); if (ext) { if ((strcmp(ext, ".pls") == 0) || (strcmp(ext, ".url") == 0)) { mfi.data_kind = 1; /* url/stream */ ret = scan_url_file(file, &mfi); if (ret < 0) goto out; } else if ((strcmp(ext, ".png") == 0) || (strcmp(ext, ".jpg") == 0)) { /* Artwork - don't scan */ goto out; } } /* General case */ if (ret < 0) { ret = scan_metadata_ffmpeg(file, &mfi); mfi.data_kind = 0; /* real file */ } if (ret < 0) { DPRINTF(E_INFO, L_SCAN, "Could not extract metadata for %s\n", file); goto out; } mfi.compilation = compilation; if (!mfi.item_kind) mfi.item_kind = 2; /* music */ if (!mfi.media_kind) mfi.media_kind = 1; /* music */ unicode_fixup_mfi(&mfi); fixup_tags(&mfi); if (mfi.id == 0) db_file_add(&mfi); else db_file_update(&mfi); out: free_mfi(&mfi, 1); } /* Queue: global & deferred_pl_sq */ static void process_playlist(char *file) { char *ext; ext = strrchr(file, '.'); if (ext) { if (strcmp(ext, ".m3u") == 0) scan_m3u_playlist(file); #ifdef ITUNES else if (strcmp(ext, ".xml") == 0) scan_itunes_itml(file); #endif } } /* Queue: global */ static void defer_playlist(char *path) { char *pl_path; pl_path = strdup(path); if (!pl_path) { DPRINTF(E_WARN, L_SCAN, "Out of memory for deferred playlist\n"); return; } /* Not using dispatch_group_async() on the scanner_grp as deferred playlists * processing is triggered by scanner_grp being empty at the end of the bulk * scan. */ dispatch_retain(scanner_grp); dispatch_async(deferred_pl_sq, ^{ int ret; if (stop_scan) { free(pl_path); return; } /* In case deinit() happens after the bulk scan */ dispatch_group_enter(scanner_grp); ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Could not acquire database connection; skipping playlist %s\n", pl_path); free(pl_path); return; } process_playlist(pl_path); free(pl_path); db_pool_release(); dispatch_group_leave(scanner_grp); dispatch_release(scanner_grp); }); DPRINTF(E_INFO, L_SCAN, "Deferred playlist %s\n", path); } /* Queue: global */ static void process_file(char *file, time_t mtime, off_t size, int compilation, int flags) { char *ext; ext = strrchr(file, '.'); if (ext) { if ((strcmp(ext, ".m3u") == 0) #ifdef ITUNES || (strcmp(ext, ".xml") == 0) #endif ) { if (flags & F_SCAN_BULK) defer_playlist(file); else process_playlist(file); return; } else if (strcmp(ext, ".remote") == 0) { remote_pairing_read_pin(file); return; } } /* Not any kind of special file, so let's see if it's a media file */ process_media_file(file, mtime, size, compilation); } /* Queue: global */ static int check_compilation(char *path) { cfg_t *lib; int ndirs; int i; lib = cfg_getsec(cfg, "library"); ndirs = cfg_size(lib, "compilations"); for (i = 0; i < ndirs; i++) { if (strstr(path, cfg_getnstr(lib, "compilations", i))) return 1; } return 0; } static void process_directory_async(char *path, int flags); /* Queue: global */ static void process_directory(char *path, int flags) { DIR *dirp; struct dirent buf; struct dirent *de; char entry[PATH_MAX]; char *deref; struct stat sb; struct watch_info wi; #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) struct kevent kev; #endif int compilation; int ret; DPRINTF(E_DBG, L_SCAN, "Processing directory %s (flags = 0x%x)\n", path, flags); dirp = opendir(path); if (!dirp) { DPRINTF(E_LOG, L_SCAN, "Could not open directory %s: %s\n", path, strerror(errno)); return; } /* Check for a compilation directory */ compilation = check_compilation(path); for (;;) { if (stop_scan) break; ret = readdir_r(dirp, &buf, &de); if (ret != 0) { DPRINTF(E_LOG, L_SCAN, "readdir_r error in %s: %s\n", path, strerror(errno)); break; } if (de == NULL) break; if (buf.d_name[0] == '.') continue; ret = snprintf(entry, sizeof(entry), "%s/%s", path, buf.d_name); if ((ret < 0) || (ret >= sizeof(entry))) { DPRINTF(E_LOG, L_SCAN, "Skipping %s/%s, PATH_MAX exceeded\n", path, buf.d_name); continue; } ret = lstat(entry, &sb); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Skipping %s, lstat() failed: %s\n", entry, strerror(errno)); continue; } if (S_ISLNK(sb.st_mode)) { deref = m_realpath(entry); if (!deref) { DPRINTF(E_LOG, L_SCAN, "Skipping %s, could not dereference symlink: %s\n", entry, strerror(errno)); continue; } ret = stat(deref, &sb); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Skipping %s, stat() failed: %s\n", deref, strerror(errno)); free(deref); continue; } ret = snprintf(entry, sizeof(entry), "%s", deref); free(deref); if ((ret < 0) || (ret >= sizeof(entry))) { DPRINTF(E_LOG, L_SCAN, "Skipping %s, PATH_MAX exceeded\n", deref); continue; } } if (S_ISREG(sb.st_mode)) process_file(entry, sb.st_mtime, sb.st_size, compilation, flags); else if (S_ISDIR(sb.st_mode)) process_directory_async(entry, flags); else DPRINTF(E_LOG, L_SCAN, "Skipping %s, not a directory, symlink nor regular file\n", entry); } closedir(dirp); if (stop_scan) return; memset(&wi, 0, sizeof(struct watch_info)); #if defined(__linux__) /* Add inotify watch */ wi.wd = inotify_add_watch(ino_fd, path, IN_CREATE | IN_DELETE | IN_MODIFY | IN_CLOSE_WRITE | IN_MOVE | IN_DELETE | IN_MOVE_SELF); if (wi.wd < 0) { DPRINTF(E_WARN, L_SCAN, "Could not create inotify watch for %s: %s\n", path, strerror(errno)); return; } if (!(flags & F_SCAN_RESCAN)) { wi.cookie = 0; wi.path = path; db_watch_add(&wi); } #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) memset(&kev, 0, sizeof(struct kevent)); wi.wd = open(path, O_RDONLY | O_NONBLOCK); if (wi.wd < 0) { DPRINTF(E_WARN, L_SCAN, "Could not open directory %s for watching: %s\n", path, strerror(errno)); return; } /* Add kevent */ EV_SET(&kev, wi.wd, EVFILT_VNODE, EV_ADD | EV_CLEAR, NOTE_DELETE | NOTE_WRITE | NOTE_RENAME, 0, NULL); ret = kevent(ino_fd, &kev, 1, NULL, 0, NULL); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Could not add kevent for %s: %s\n", path, strerror(errno)); close(wi.wd); return; } wi.cookie = 0; wi.path = path; db_watch_add(&wi); #endif } /* Queue: global */ static void process_directory_async(char *path, int flags) { char *my_path; if (stop_scan) { if (flags & F_SCAN_NODUP) free(path); return; } if (flags & F_SCAN_NODUP) { my_path = path; flags &= ~F_SCAN_NODUP; } else { my_path = strdup(path); if (!my_path) { DPRINTF(E_LOG, L_SCAN, "Skipping %s, out of memory\n", path); return; } } dispatch_group_async(scanner_grp, dispatch_get_current_queue(), ^{ int ret; if (stop_scan) { free(my_path); return; } ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Could not acquire database connection; skipping %s\n", my_path); free(my_path); return; } process_directory(my_path, flags); free(my_path); db_pool_release(); }); } /* Queue: global */ static void bulk_scan(void) { cfg_t *lib; int ndirs; char *path; char *deref; time_t start; int i; start = time(NULL); lib = cfg_getsec(cfg, "library"); ndirs = cfg_size(lib, "directories"); for (i = 0; i < ndirs; i++) { path = cfg_getnstr(lib, "directories", i); deref = m_realpath(path); if (!deref) { DPRINTF(E_LOG, L_SCAN, "Skipping library directory %s, could not dereference: %s\n", path, strerror(errno)); continue; } process_directory_async(deref, F_SCAN_BULK | F_SCAN_NODUP); } /* Wait for the scanner group to be empty, then queue db_purge_cruft() * on the deferred playlists queue and resume that queue. * In a nutshell: wait until initial bulk scan is done, then * process deferred playlists, then purge the database. */ dispatch_retain(scanner_grp); dispatch_group_notify(scanner_grp, dispatch_get_current_queue(), ^{ dispatch_async(deferred_pl_sq, ^{ int ret; if (stop_scan) return; /* In case deinit() happens after the bulk scan */ dispatch_group_enter(scanner_grp); ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Could not acquire database connection; DB purge aborted\n"); return; } DPRINTF(E_DBG, L_SCAN, "Purging old database content\n"); db_purge_cruft(start); db_hook_post_scan(); db_pool_release(); dispatch_group_leave(scanner_grp); dispatch_release(scanner_grp); }); DPRINTF(E_DBG, L_SCAN, "Now processing deferred playlists from bulk scan\n"); dispatch_resume(deferred_pl_sq); dispatch_release(deferred_pl_sq); deferred_pl_sq = NULL; }); } /* Queue: global */ static void startup_task(void *arg) { int ret; ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Startup failed: could not acquire database connection\n"); return; } ret = db_watch_clear(); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Error: could not clear old watches from DB\n"); goto startup_fail; } ret = db_groups_clear(); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Error: could not clear old groups from DB\n"); goto startup_fail; } /* Recompute all songalbumids, in case the SQLite DB got transferred * to a different host; the hash is not portable. * It will also rebuild the groups we just cleared. */ db_files_update_songalbumid(); bulk_scan(); startup_fail: db_pool_release(); } #if defined(__linux__) #define process_fs_events() inotify_fs_events() /* Queue: global */ static void process_inotify_dir(struct watch_info *wi, char *path, struct inotify_event *ie) { struct watch_enum we; uint32_t rm_wd; int flags = 0; int ret; DPRINTF(E_DBG, L_SCAN, "Directory event: 0x%x, cookie 0x%x, wd %d\n", ie->mask, ie->cookie, wi->wd); if (ie->mask & IN_UNMOUNT) { db_file_disable_bymatch(path, "", 0); db_pl_disable_bymatch(path, "", 0); } if (ie->mask & IN_MOVE_SELF) { /* A directory we know about, that got moved from a place * we know about to a place we know nothing about */ if (wi->cookie) { memset(&we, 0, sizeof(struct watch_enum)); we.cookie = wi->cookie; ret = db_watch_enum_start(&we); if (ret < 0) return; while ((db_watch_enum_fetchwd(&we, &rm_wd) == 0) && (rm_wd)) { inotify_rm_watch(ino_fd, rm_wd); } db_watch_enum_end(&we); db_watch_delete_bycookie(wi->cookie); } else { /* If the directory exists, it has been moved and we've * kept track of it successfully, so we're done */ ret = access(path, F_OK); if (ret == 0) return; /* Most probably a top-level dir is getting moved, * and we can't tell where it's going */ inotify_rm_watch(ino_fd, ie->wd); db_watch_delete_bywd(ie->wd); memset(&we, 0, sizeof(struct watch_enum)); we.match = path; ret = db_watch_enum_start(&we); if (ret < 0) return; while ((db_watch_enum_fetchwd(&we, &rm_wd) == 0) && (rm_wd)) { inotify_rm_watch(ino_fd, rm_wd); } db_watch_enum_end(&we); db_watch_delete_bymatch(path); db_file_disable_bymatch(path, "", 0); db_pl_disable_bymatch(path, "", 0); } } if (ie->mask & IN_MOVED_FROM) { db_watch_mark_bypath(path, path, ie->cookie); db_watch_mark_bymatch(path, path, ie->cookie); db_file_disable_bymatch(path, path, ie->cookie); db_pl_disable_bymatch(path, path, ie->cookie); } if (ie->mask & IN_MOVED_TO) { if (db_watch_cookie_known(ie->cookie)) { db_watch_move_bycookie(ie->cookie, path); db_file_enable_bycookie(ie->cookie, path); db_pl_enable_bycookie(ie->cookie, path); /* We'll rescan the directory tree to update playlists */ flags |= F_SCAN_RESCAN; } ie->mask |= IN_CREATE; } if (ie->mask & IN_CREATE) process_directory_async(path, flags); } /* Queue: global */ static void process_inotify_file(struct watch_info *wi, char *path, struct inotify_event *ie) { struct stat sb; char *deref = NULL; char *file = path; int compilation; int ret; DPRINTF(E_DBG, L_SCAN, "File event: 0x%x, cookie 0x%x, wd %d\n", ie->mask, ie->cookie, wi->wd); if (ie->mask & IN_DELETE) { db_file_delete_bypath(path); db_pl_delete_bypath(path); } if (ie->mask & IN_MOVED_FROM) { db_file_disable_bypath(path, wi->path, ie->cookie); db_pl_disable_bypath(path, wi->path, ie->cookie); } if (ie->mask & IN_MOVED_TO) { ret = db_file_enable_bycookie(ie->cookie, wi->path); if (ret <= 0) { /* It's not a known media file, so it's either a new file * or a playlist, known or not. * We want to scan the new file and we want to rescan the * playlist to update playlist items (relative items). */ ie->mask |= IN_CREATE; db_pl_enable_bycookie(ie->cookie, wi->path); } } if (ie->mask & (IN_MODIFY | IN_CREATE | IN_CLOSE_WRITE)) { ret = lstat(path, &sb); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Could not lstat() '%s': %s\n", path, strerror(errno)); return; } if (S_ISLNK(sb.st_mode)) { deref = m_realpath(path); if (!deref) { DPRINTF(E_LOG, L_SCAN, "Could not dereference symlink '%s': %s\n", path, strerror(errno)); return; } file = deref; ret = stat(deref, &sb); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Could not stat() '%s': %s\n", file, strerror(errno)); free(deref); return; } if (S_ISDIR(sb.st_mode)) { process_inotify_dir(wi, deref, ie); free(deref); return; } } compilation = check_compilation(path); process_file(file, sb.st_mtime, sb.st_size, compilation, 0); if (deref) free(deref); } } /* Queue: global */ static void inotify_fs_events(void) { struct inotify_event *buf; struct inotify_event *ie; struct watch_info wi; char path[PATH_MAX]; int qsize; int namelen; int ret; /* Determine the size of the inotify queue */ ret = ioctl(ino_fd, FIONREAD, &qsize); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Could not determine inotify queue size: %s\n", strerror(errno)); return; } buf = (struct inotify_event *)malloc(qsize); if (!buf) { DPRINTF(E_LOG, L_SCAN, "Could not allocate %d bytes for inotify events\n", qsize); return; } ret = read(ino_fd, buf, qsize); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "inotify read failed: %s\n", strerror(errno)); free(buf); return; } /* ioctl(FIONREAD) returns the number of bytes, now we need the number of elements */ qsize /= sizeof(struct inotify_event); /* Loop through all the events we got */ for (ie = buf; (ie - buf) < qsize; ie += (1 + (ie->len / sizeof(struct inotify_event)))) { memset(&wi, 0, sizeof(struct watch_info)); /* ie[0] contains the inotify event information * the memory space for ie[1+] contains the name of the file * see the inotify documentation */ wi.wd = ie->wd; ret = db_watch_get_bywd(&wi); if (ret < 0) { if (!(ie->mask & IN_IGNORED)) DPRINTF(E_LOG, L_SCAN, "No matching watch found, ignoring event (0x%x)\n", ie->mask); continue; } if (ie->mask & IN_IGNORED) { DPRINTF(E_DBG, L_SCAN, "%s deleted or backing filesystem unmounted!\n", wi.path); db_watch_delete_bywd(ie->wd); free(wi.path); continue; } path[0] = '\0'; ret = snprintf(path, PATH_MAX, "%s", wi.path); if ((ret < 0) || (ret >= PATH_MAX)) { DPRINTF(E_LOG, L_SCAN, "Skipping event under %s, PATH_MAX exceeded\n", wi.path); free(wi.path); continue; } if (ie->len > 0) { namelen = PATH_MAX - ret; ret = snprintf(path + ret, namelen, "/%s", ie->name); if ((ret < 0) || (ret >= namelen)) { DPRINTF(E_LOG, L_SCAN, "Skipping %s/%s, PATH_MAX exceeded\n", wi.path, ie->name); free(wi.path); continue; } } /* ie->len == 0 catches events on the subject of the watch itself. * As we only watch directories, this catches directories. * General watch events like IN_UNMOUNT and IN_IGNORED do not come * with the IN_ISDIR flag set. */ if ((ie->mask & IN_ISDIR) || (ie->len == 0)) process_inotify_dir(&wi, path, ie); else process_inotify_file(&wi, path, ie); free(wi.path); } free(buf); } #endif /* __linux__ */ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #define process_fs_events() kqueue_fs_events() /* Queue: global */ static void kqueue_fs_events(void) { struct kevent kev; struct timespec ts; struct watch_info wi; struct watch_enum we; struct stacked_dir *rescan; struct stacked_dir *d; struct stacked_dir *dprev; char *path; uint32_t wd; int d_len; int w_len; int need_rescan; int ret; ts.tv_sec = 0; ts.tv_nsec = 0; we.cookie = 0; rescan = NULL; DPRINTF(E_DBG, L_SCAN, "Library changed!\n"); /* We can only monitor directories with kqueue; to monitor files, we'd need * to have an open fd on every file in the library, which is totally insane. * Unfortunately, that means we only know when directories get renamed, * deleted or changed. We don't get directory/file names when directories/files * are created/deleted/renamed in the directory, so we have to rescan. */ while (kevent(ino_fd, NULL, 0, &kev, 1, &ts) > 0) { /* This should not happen, and if it does, we'll end up in * an infinite loop. */ if (kev.filter != EVFILT_VNODE) continue; wi.wd = kev.ident; ret = db_watch_get_bywd(&wi); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Found no matching watch for kevent, killing this event\n"); close(kev.ident); continue; } /* Whatever the type of event that happened, disable matching watches and * files before we trigger an eventual rescan. */ we.match = wi.path; ret = db_watch_enum_start(&we); if (ret < 0) { free(wi.path); continue; } while ((db_watch_enum_fetchwd(&we, &wd) == 0) && (wd)) { close(wd); } db_watch_enum_end(&we); db_watch_delete_bymatch(wi.path); close(wi.wd); db_watch_delete_bywd(wi.wd); /* Disable files */ db_file_disable_bymatch(wi.path, "", 0); db_pl_disable_bymatch(wi.path, "", 0); if (kev.flags & EV_ERROR) { DPRINTF(E_LOG, L_SCAN, "kevent reports EV_ERROR (%s): %s\n", wi.path, strerror(kev.data)); ret = access(wi.path, F_OK); if (ret != 0) { free(wi.path); continue; } /* The directory still exists, so try to add it back to the library */ kev.fflags |= NOTE_WRITE; } /* No further action on NOTE_DELETE & NOTE_RENAME; NOTE_WRITE on the * parent directory will trigger a rescan in both cases and the * renamed directory will be picked up then. */ if (kev.fflags & NOTE_WRITE) { DPRINTF(E_DBG, L_SCAN, "Got NOTE_WRITE (%s)\n", wi.path); need_rescan = 1; w_len = strlen(wi.path); /* Abusing stacked_dir a little bit here */ dprev = NULL; d = rescan; while (d) { d_len = strlen(d->path); if (d_len > w_len) { /* Stacked dir child of watch dir? */ if ((d->path[w_len] == '/') && (strncmp(d->path, wi.path, w_len) == 0)) { DPRINTF(E_DBG, L_SCAN, "Watched directory is a parent\n"); if (dprev) dprev->next = d->next; else rescan = d->next; free(d->path); free(d); if (dprev) d = dprev->next; else d = rescan; continue; } } else if (w_len > d_len) { /* Watch dir child of stacked dir? */ if ((wi.path[d_len] == '/') && (strncmp(wi.path, d->path, d_len) == 0)) { DPRINTF(E_DBG, L_SCAN, "Watched directory is a child\n"); need_rescan = 0; break; } } else if (strcmp(wi.path, d->path) == 0) { DPRINTF(E_DBG, L_SCAN, "Watched directory already listed\n"); need_rescan = 0; break; } dprev = d; d = d->next; } if (need_rescan) push_dir(&rescan, wi.path); } free(wi.path); } while ((path = pop_dir(&rescan))) process_directory_async(path, F_SCAN_NODUP); } #endif /* __FreeBSD__ || __FreeBSD_kernel__ */ /* Thread: main */ int filescanner_init(void) { dispatch_queue_t global_q; stop_scan = 0; scanner_grp = dispatch_group_create(); if (!scanner_grp) { DPRINTF(E_FATAL, L_SCAN, "Could not create dispatch group\n"); return -1; } deferred_pl_sq = dispatch_queue_create("org.forked-daapd.deferred-pl", NULL); if (!deferred_pl_sq) { DPRINTF(E_FATAL, L_SCAN, "Could not create dispatch queue for deferred playlists\n"); goto queue_fail; } dispatch_suspend(deferred_pl_sq); #if defined(__linux__) ino_fd = inotify_init1(IN_CLOEXEC | IN_NONBLOCK); if (ino_fd < 0) { DPRINTF(E_FATAL, L_SCAN, "Could not create inotify fd: %s\n", strerror(errno)); goto ino_fail; } #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) ino_fd = kqueue(); if (ino_fd < 0) { DPRINTF(E_FATAL, L_SCAN, "Could not create kqueue: %s\n", strerror(errno)); goto ino_fail; } #endif global_q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); if (!global_q) { DPRINTF(E_FATAL, L_SCAN, "Could not get global dispatch queue\n"); goto source_fail; } ino_src = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, ino_fd, 0, global_q); if (!ino_src) { DPRINTF(E_FATAL, L_SCAN, "Could not create dispatch source for inotify\n"); goto source_fail; } dispatch_source_set_event_handler(ino_src, ^{ int ret; dispatch_group_enter(scanner_grp); if (stop_scan) { dispatch_group_leave(scanner_grp); return; } ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Could not acquire database connection; inotify event aborted\n"); dispatch_group_leave(scanner_grp); return; } process_fs_events(); db_pool_release(); dispatch_group_leave(scanner_grp); }); dispatch_source_set_cancel_handler(ino_src, ^{ close(ino_fd); }); dispatch_resume(ino_src); dispatch_group_async_f(scanner_grp, global_q, NULL, startup_task); return 0; source_fail: close(ino_fd); ino_fail: dispatch_release(deferred_pl_sq); queue_fail: dispatch_release(scanner_grp); return -1; } /* Thread: main */ void filescanner_deinit(void) { long ret; dispatch_source_cancel(ino_src); dispatch_release(ino_src); stop_scan = 1; DPRINTF(E_INFO, L_SCAN, "Waiting for filescanner jobs to finish...\n"); ret = dispatch_group_wait(scanner_grp, DISPATCH_TIME_FOREVER); dispatch_release(scanner_grp); if (ret != 0) DPRINTF(E_LOG, L_SCAN, "Error waiting for dispatch group\n"); /* deferred_pl_sq resumed & released after completion of the bulk scan */ } forked-daapd-0.19gcd/src/filescanner.h0000664000175000017500000000063111633141135017231 0ustar julienjulien #ifndef __FILESCANNER_H__ #define __FILESCANNER_H__ #include "db.h" int filescanner_init(void); void filescanner_deinit(void); /* Actual scanners */ int scan_metadata_ffmpeg(char *file, struct media_file_info *mfi); int scan_url_file(char *file, struct media_file_info *mfi); void scan_m3u_playlist(char *file); #ifdef ITUNES void scan_itunes_itml(char *file); #endif #endif /* !__FILESCANNER_H__ */ forked-daapd-0.19gcd/src/filescanner_ffmpeg.c0000664000175000017500000005205511633141135020557 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #ifdef HAVE_STDINT_H #include #endif #include #include #include "logger.h" #include "filescanner.h" #include "misc.h" /* Legacy format-specific scanners */ extern int scan_get_wmainfo(char *filename, struct media_file_info *pmp3); #ifdef FLAC extern int scan_get_flacinfo(char *filename, struct media_file_info *pmp3); #endif #ifdef MUSEPACK extern int scan_get_mpcinfo(char *filename, struct media_file_info *pmp3); #endif /* Mapping between the metadata name(s) and the offset * of the equivalent metadata field in struct media_file_info */ struct metadata_map { char *key; int as_int; size_t offset; int (*handler_function)(struct media_file_info *, char *); }; static int parse_slash_separated_ints(char *string, uint32_t *firstval, uint32_t *secondval) { int numvals = 0; char *ptr; ptr = strchr(string, '/'); if (ptr) { *ptr = '\0'; if (safe_atou32(ptr + 1, secondval) == 0) numvals++; } if (safe_atou32(string, firstval) == 0) numvals++; return numvals; } static int parse_track(struct media_file_info *mfi, char *track_string) { uint32_t *track = (uint32_t *) ((char *) mfi + mfi_offsetof(track)); uint32_t *total_tracks = (uint32_t *) ((char *) mfi + mfi_offsetof(total_tracks)); return parse_slash_separated_ints(track_string, track, total_tracks); } static int parse_disc(struct media_file_info *mfi, char *disc_string) { uint32_t *disc = (uint32_t *) ((char *) mfi + mfi_offsetof(disc)); uint32_t *total_discs = (uint32_t *) ((char *) mfi + mfi_offsetof(total_discs)); return parse_slash_separated_ints(disc_string, disc, total_discs); } /* Lookup is case-insensitive, first occurrence takes precedence */ static const struct metadata_map md_map_generic[] = { { "title", 0, mfi_offsetof(title), NULL }, { "artist", 0, mfi_offsetof(artist), NULL }, { "author", 0, mfi_offsetof(artist), NULL }, { "album_artist", 0, mfi_offsetof(album_artist), NULL }, { "album", 0, mfi_offsetof(album), NULL }, { "genre", 0, mfi_offsetof(genre), NULL }, { "composer", 0, mfi_offsetof(composer), NULL }, { "grouping", 0, mfi_offsetof(grouping), NULL }, { "orchestra", 0, mfi_offsetof(orchestra), NULL }, { "conductor", 0, mfi_offsetof(conductor), NULL }, { "comment", 0, mfi_offsetof(comment), NULL }, { "description", 0, mfi_offsetof(comment), NULL }, { "track", 1, mfi_offsetof(track), parse_track }, { "disc", 1, mfi_offsetof(disc), parse_disc }, { "year", 1, mfi_offsetof(year), NULL }, { "date", 1, mfi_offsetof(year), NULL }, { "title-sort", 0, mfi_offsetof(title_sort), NULL }, { "artist-sort", 0, mfi_offsetof(artist_sort), NULL }, { "album-sort", 0, mfi_offsetof(album_sort), NULL }, { NULL, 0, 0, NULL } }; static const struct metadata_map md_map_tv[] = { { "stik", 1, mfi_offsetof(media_kind), NULL }, { "show", 0, mfi_offsetof(tv_series_name), NULL }, { "episode_id", 0, mfi_offsetof(tv_episode_num_str), NULL }, { "network", 0, mfi_offsetof(tv_network_name), NULL }, { "episode_sort", 1, mfi_offsetof(tv_episode_sort), NULL }, { "season_number",1, mfi_offsetof(tv_season_num), NULL }, { NULL, 0, 0, NULL } }; /* NOTE about VORBIS comments: * Only a small set of VORBIS comment fields are officially designated. Most * common tags are at best de facto standards. Currently, metadata conversion * functionality in ffmpeg only adds support for a couple of tags. Specifically, * ALBUMARTIST and TRACKNUMBER are handled as of Feb 1, 2010 (rev 21587). Tags * with names that already match the generic ffmpeg scheme--TITLE and ARTIST, * for example--are of course handled. The rest of these tags are reported to * have been used by various programs in the wild. */ static const struct metadata_map md_map_vorbis[] = { { "albumartist", 0, mfi_offsetof(album_artist), NULL }, { "album artist", 0, mfi_offsetof(album_artist), NULL }, { "tracknumber", 1, mfi_offsetof(track), NULL }, { "tracktotal", 1, mfi_offsetof(total_tracks), NULL }, { "totaltracks", 1, mfi_offsetof(total_tracks), NULL }, { "discnumber", 1, mfi_offsetof(disc), NULL }, { "disctotal", 1, mfi_offsetof(total_discs), NULL }, { "totaldiscs", 1, mfi_offsetof(total_discs), NULL }, { NULL, 0, 0, NULL } }; /* NOTE about ID3 tag names: * metadata conversion for ID3v2 tags was added in ffmpeg in september 2009 * (rev 20073) for ID3v2.3; support for ID3v2.2 tag names was added in december * 2009 (rev 20839). * * ID3v2.x tags will be removed from the map once a version of ffmpeg containing * the changes listed above will be generally available. The more entries in the * map, the slower the filescanner gets. */ static const struct metadata_map md_map_id3[] = { { "TT2", 0, mfi_offsetof(title), NULL }, /* ID3v2.2 */ { "TIT2", 0, mfi_offsetof(title), NULL }, /* ID3v2.3 */ { "TP1", 0, mfi_offsetof(artist), NULL }, /* ID3v2.2 */ { "TPE1", 0, mfi_offsetof(artist), NULL }, /* ID3v2.3 */ { "TP2", 0, mfi_offsetof(album_artist), NULL }, /* ID3v2.2 */ { "TPE2", 0, mfi_offsetof(album_artist), NULL }, /* ID3v2.3 */ { "TAL", 0, mfi_offsetof(album), NULL }, /* ID3v2.2 */ { "TALB", 0, mfi_offsetof(album), NULL }, /* ID3v2.3 */ { "TCO", 0, mfi_offsetof(genre), NULL }, /* ID3v2.2 */ { "TCON", 0, mfi_offsetof(genre), NULL }, /* ID3v2.3 */ { "TCM", 0, mfi_offsetof(composer), NULL }, /* ID3v2.2 */ { "TCOM", 0, mfi_offsetof(composer), NULL }, /* ID3v2.3 */ { "TRK", 1, mfi_offsetof(track), parse_track }, /* ID3v2.2 */ { "TRCK", 1, mfi_offsetof(track), parse_track }, /* ID3v2.3 */ { "TPA", 1, mfi_offsetof(disc), parse_disc }, /* ID3v2.2 */ { "TPOS", 1, mfi_offsetof(disc), parse_disc }, /* ID3v2.3 */ { "TYE", 1, mfi_offsetof(year), NULL }, /* ID3v2.2 */ { "TYER", 1, mfi_offsetof(year), NULL }, /* ID3v2.3 */ { "TDRC", 1, mfi_offsetof(year), NULL }, /* ID3v2.4 */ { "TSOA", 0, mfi_offsetof(album_sort), NULL }, /* ID3v2.4 */ { "XSOA", 0, mfi_offsetof(album_sort), NULL }, /* ID3v2.3 */ { "TSOP", 0, mfi_offsetof(artist_sort), NULL }, /* ID3v2.4 */ { "XSOP", 0, mfi_offsetof(artist_sort), NULL }, /* ID3v2.3 */ { "TSOT", 0, mfi_offsetof(title_sort), NULL }, /* ID3v2.4 */ { "XSOT", 0, mfi_offsetof(title_sort), NULL }, /* ID3v2.3 */ { "TS2", 0, mfi_offsetof(album_artist_sort), NULL }, /* ID3v2.2 */ { "TSO2", 0, mfi_offsetof(album_artist_sort), NULL }, /* ID3v2.3 */ { "ALBUMARTISTSORT", 0, mfi_offsetof(album_artist_sort), NULL }, /* ID3v2.x */ { "TSC", 0, mfi_offsetof(composer_sort), NULL }, /* ID3v2.2 */ { "TSOC", 0, mfi_offsetof(composer_sort), NULL }, /* ID3v2.3 */ { NULL, 0, 0, NULL } }; static int #if LIBAVUTIL_VERSION_MAJOR >= 51 || (LIBAVUTIL_VERSION_MAJOR == 51 && LIBAVUTIL_VERSION_MINOR >= 5) extract_metadata_core(struct media_file_info *mfi, AVDictionary *md, const struct metadata_map *md_map) #else extract_metadata_core(struct media_file_info *mfi, AVMetadata *md, const struct metadata_map *md_map) #endif { #if LIBAVUTIL_VERSION_MAJOR >= 51 || (LIBAVUTIL_VERSION_MAJOR == 51 && LIBAVUTIL_VERSION_MINOR >= 5) AVDictionaryEntry *mdt; #else AVMetadataTag *mdt; #endif char **strval; uint32_t *intval; int mdcount; int i; int ret; #if 0 /* Dump all the metadata reported by ffmpeg */ mdt = NULL; #if LIBAVUTIL_VERSION_MAJOR >= 51 || (LIBAVUTIL_VERSION_MAJOR == 51 && LIBAVUTIL_VERSION_MINOR >= 5) while ((mdt = av_dict_get(md, "", mdt, AV_DICT_IGNORE_SUFFIX)) != NULL) #else while ((mdt = av_metadata_get(md, "", mdt, AV_METADATA_IGNORE_SUFFIX)) != NULL) #endif fprintf(stderr, " -> %s = %s\n", mdt->key, mdt->value); #endif mdcount = 0; /* Extract actual metadata */ for (i = 0; md_map[i].key != NULL; i++) { #if LIBAVUTIL_VERSION_MAJOR >= 51 || (LIBAVUTIL_VERSION_MAJOR == 51 && LIBAVUTIL_VERSION_MINOR >= 5) mdt = av_dict_get(md, md_map[i].key, NULL, 0); #else mdt = av_metadata_get(md, md_map[i].key, NULL, 0); #endif if (mdt == NULL) continue; if ((mdt->value == NULL) || (strlen(mdt->value) == 0)) continue; if (md_map[i].handler_function) { mdcount += md_map[i].handler_function(mfi, mdt->value); continue; } mdcount++; if (!md_map[i].as_int) { strval = (char **) ((char *) mfi + md_map[i].offset); if (*strval == NULL) *strval = strdup(mdt->value); } else { intval = (uint32_t *) ((char *) mfi + md_map[i].offset); if (*intval == 0) { ret = safe_atou32(mdt->value, intval); if (ret < 0) continue; } } } return mdcount; } static int extract_metadata(struct media_file_info *mfi, AVFormatContext *ctx, AVStream *audio_stream, AVStream *video_stream, const struct metadata_map *md_map) { int mdcount; int ret; mdcount = 0; if (ctx->metadata) { ret = extract_metadata_core(mfi, ctx->metadata, md_map); mdcount += ret; DPRINTF(E_DBG, L_SCAN, "Picked up %d tags from file metadata\n", ret); } if (audio_stream->metadata) { ret = extract_metadata_core(mfi, audio_stream->metadata, md_map); mdcount += ret; DPRINTF(E_DBG, L_SCAN, "Picked up %d tags from audio stream metadata\n", ret); } if (video_stream && video_stream->metadata) { ret = extract_metadata_core(mfi, video_stream->metadata, md_map); mdcount += ret; DPRINTF(E_DBG, L_SCAN, "Picked up %d tags from video stream metadata\n", ret); } return mdcount; } int scan_metadata_ffmpeg(char *file, struct media_file_info *mfi) { AVFormatContext *ctx; const struct metadata_map *extra_md_map; enum CodecID codec_id; enum CodecID video_codec_id; enum CodecID audio_codec_id; AVStream *video_stream; AVStream *audio_stream; int mdcount; int i; int ret; ctx = NULL; #if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 3) ret = avformat_open_input(&ctx, file, NULL, NULL); #else ret = av_open_input_file(&ctx, file, NULL, 0, NULL); #endif if (ret != 0) { DPRINTF(E_WARN, L_SCAN, "Cannot open media file '%s': %s\n", file, strerror(AVUNERROR(ret))); return -1; } ret = av_find_stream_info(ctx); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Cannot get stream info: %s\n", strerror(AVUNERROR(ret))); av_close_input_file(ctx); return -1; } #if 0 /* Dump input format as determined by ffmpeg */ # if LIBAVFORMAT_VERSION_MAJOR >= 52 || (LIBAVFORMAT_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 101) av_dump_format(ctx, 0, file, 0); # else dump_format(ctx, 0, file, FALSE); # endif #endif DPRINTF(E_DBG, L_SCAN, "File has %d streams\n", ctx->nb_streams); /* Extract codec IDs, check for video */ video_codec_id = CODEC_ID_NONE; video_stream = NULL; audio_codec_id = CODEC_ID_NONE; audio_stream = NULL; for (i = 0; i < ctx->nb_streams; i++) { switch (ctx->streams[i]->codec->codec_type) { #if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 64) case AVMEDIA_TYPE_VIDEO: #else case CODEC_TYPE_VIDEO: #endif if (!video_stream) { DPRINTF(E_DBG, L_SCAN, "File has video (stream %d)\n", i); mfi->has_video = 1; video_stream = ctx->streams[i]; video_codec_id = video_stream->codec->codec_id; } break; #if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 64) case AVMEDIA_TYPE_AUDIO: #else case CODEC_TYPE_AUDIO: #endif if (!audio_stream) { audio_stream = ctx->streams[i]; audio_codec_id = audio_stream->codec->codec_id; } break; default: break; } } if (audio_codec_id == CODEC_ID_NONE) { DPRINTF(E_DBG, L_SCAN, "File has no audio streams, discarding\n"); av_close_input_file(ctx); return -1; } /* Common media information */ if (ctx->duration > 0) mfi->song_length = ctx->duration / (AV_TIME_BASE / 1000); /* ms */ if (ctx->bit_rate > 0) mfi->bitrate = ctx->bit_rate / 1000; else if (ctx->duration > AV_TIME_BASE) /* guesstimate */ mfi->bitrate = ((mfi->file_size * 8) / (ctx->duration / AV_TIME_BASE)) / 1000; DPRINTF(E_DBG, L_SCAN, "Duration %d ms, bitrate %d kbps\n", mfi->song_length, mfi->bitrate); /* Get some more information on the audio stream */ if (audio_stream) { if (audio_stream->codec->sample_rate != 0) mfi->samplerate = audio_stream->codec->sample_rate; /* Try sample format first */ #if LIBAVUTIL_VERSION_MAJOR >= 51 || (LIBAVUTIL_VERSION_MAJOR == 51 && LIBAVUTIL_VERSION_MINOR >= 4) mfi->bits_per_sample = 8 * av_get_bytes_per_sample(audio_stream->codec->sample_fmt); #elif LIBAVCODEC_VERSION_MAJOR >= 53 mfi->bits_per_sample = av_get_bits_per_sample_fmt(audio_stream->codec->sample_fmt); #else mfi->bits_per_sample = av_get_bits_per_sample_format(audio_stream->codec->sample_fmt); #endif if (mfi->bits_per_sample == 0) { /* Try codec */ mfi->bits_per_sample = av_get_bits_per_sample(audio_codec_id); } DPRINTF(E_DBG, L_SCAN, "samplerate %d, bps %d\n", mfi->samplerate, mfi->bits_per_sample); } /* Check codec */ extra_md_map = NULL; codec_id = (mfi->has_video) ? video_codec_id : audio_codec_id; switch (codec_id) { case CODEC_ID_AAC: DPRINTF(E_DBG, L_SCAN, "AAC\n"); mfi->type = strdup("m4a"); mfi->codectype = strdup("mp4a"); mfi->description = strdup("AAC audio file"); break; case CODEC_ID_ALAC: DPRINTF(E_DBG, L_SCAN, "ALAC\n"); mfi->type = strdup("m4a"); mfi->codectype = strdup("alac"); mfi->description = strdup("AAC audio file"); break; case CODEC_ID_FLAC: DPRINTF(E_DBG, L_SCAN, "FLAC\n"); mfi->type = strdup("flac"); mfi->codectype = strdup("flac"); mfi->description = strdup("FLAC audio file"); extra_md_map = md_map_vorbis; break; case CODEC_ID_MUSEPACK7: case CODEC_ID_MUSEPACK8: DPRINTF(E_DBG, L_SCAN, "Musepack\n"); mfi->type = strdup("mpc"); mfi->codectype = strdup("mpc"); mfi->description = strdup("Musepack audio file"); break; case CODEC_ID_MPEG4: /* Video */ case CODEC_ID_H264: DPRINTF(E_DBG, L_SCAN, "MPEG4 video\n"); mfi->type = strdup("m4v"); mfi->codectype = strdup("mp4v"); mfi->description = strdup("MPEG-4 video file"); extra_md_map = md_map_tv; break; case CODEC_ID_MP3: DPRINTF(E_DBG, L_SCAN, "MP3\n"); mfi->type = strdup("mp3"); mfi->codectype = strdup("mpeg"); mfi->description = strdup("MPEG audio file"); extra_md_map = md_map_id3; break; case CODEC_ID_VORBIS: DPRINTF(E_DBG, L_SCAN, "VORBIS\n"); mfi->type = strdup("ogg"); mfi->codectype = strdup("ogg"); mfi->description = strdup("Ogg Vorbis audio file"); extra_md_map = md_map_vorbis; break; case CODEC_ID_WMAVOICE: DPRINTF(E_DBG, L_SCAN, "WMA Voice\n"); mfi->type = strdup("wma"); mfi->codectype = strdup("wmav"); mfi->description = strdup("WMA audio file"); break; case CODEC_ID_WMAPRO: DPRINTF(E_DBG, L_SCAN, "WMA Pro\n"); mfi->type = strdup("wmap"); mfi->codectype = strdup("wma"); mfi->description = strdup("WMA audio file"); break; case CODEC_ID_WMALOSSLESS: DPRINTF(E_DBG, L_SCAN, "WMA Lossless\n"); mfi->type = strdup("wma"); mfi->codectype = strdup("wmal"); mfi->description = strdup("WMA audio file"); break; case CODEC_ID_PCM_S16LE ... CODEC_ID_PCM_F64LE: if (strcmp(ctx->iformat->name, "aiff") == 0) { DPRINTF(E_DBG, L_SCAN, "AIFF\n"); mfi->type = strdup("aif"); mfi->codectype = strdup("aif"); mfi->description = strdup("AIFF audio file"); break; } else if (strcmp(ctx->iformat->name, "wav") == 0) { DPRINTF(E_DBG, L_SCAN, "WAV\n"); mfi->type = strdup("wav"); mfi->codectype = strdup("wav"); mfi->description = strdup("WAV audio file"); break; } /* WARNING: will fallthrough to default case, don't move */ /* FALLTHROUGH */ default: DPRINTF(E_DBG, L_SCAN, "Unknown codec 0x%x (video: %s), format %s (%s)\n", codec_id, (mfi->has_video) ? "yes" : "no", ctx->iformat->name, ctx->iformat->long_name); mfi->type = strdup("unkn"); mfi->codectype = strdup("unkn"); if (mfi->has_video) { mfi->description = strdup("Unknown video file format"); extra_md_map = md_map_tv; } else mfi->description = strdup("Unknown audio file format"); break; } mdcount = 0; if ((!ctx->metadata) && (!audio_stream->metadata) && (video_stream && !video_stream->metadata)) { DPRINTF(E_WARN, L_SCAN, "ffmpeg reports no metadata\n"); goto skip_extract; } if (extra_md_map) { ret = extract_metadata(mfi, ctx, audio_stream, video_stream, extra_md_map); mdcount += ret; DPRINTF(E_DBG, L_SCAN, "Picked up %d tags with extra md_map\n", ret); } #if LIBAVFORMAT_VERSION_MAJOR < 53 av_metadata_conv(ctx, NULL, ctx->iformat->metadata_conv); #endif ret = extract_metadata(mfi, ctx, audio_stream, video_stream, md_map_generic); mdcount += ret; DPRINTF(E_DBG, L_SCAN, "Picked up %d tags with generic md_map, %d tags total\n", ret, mdcount); /* fix up TV metadata */ if (mfi->media_kind == 10) { /* I have no idea why this is, but iTunes reports a media kind of 64 for stik==10 (?!) */ mfi->media_kind = 64; } /* Unspecified video files are "Movies", media_kind 2 */ else if (mfi->has_video == 1) { mfi->media_kind = 2; } skip_extract: if (mdcount == 0) { /* ffmpeg doesn't support FLAC nor Musepack metadata, * and is buggy for some WMA variants, so fall back to the * legacy format-specific parsers until it gets fixed */ if ((codec_id == CODEC_ID_WMAPRO) || (codec_id == CODEC_ID_WMAVOICE) || (codec_id == CODEC_ID_WMALOSSLESS)) { DPRINTF(E_WARN, L_SCAN, "Falling back to legacy WMA scanner\n"); av_close_input_file(ctx); return (scan_get_wmainfo(file, mfi) ? 0 : -1); } #ifdef FLAC else if (codec_id == CODEC_ID_FLAC) { DPRINTF(E_WARN, L_SCAN, "Falling back to legacy FLAC scanner\n"); av_close_input_file(ctx); return (scan_get_flacinfo(file, mfi) ? 0 : -1); } #endif /* FLAC */ #ifdef MUSEPACK else if ((codec_id == CODEC_ID_MUSEPACK7) || (codec_id == CODEC_ID_MUSEPACK8)) { DPRINTF(E_WARN, L_SCAN, "Falling back to legacy Musepack scanner\n"); av_close_input_file(ctx); return (scan_get_mpcinfo(file, mfi) ? 0 : -1); } #endif /* MUSEPACK */ else DPRINTF(E_WARN, L_SCAN, "Could not extract any metadata\n"); } /* Just in case there's no title set ... */ if (mfi->title == NULL) mfi->title = strdup(mfi->fname); /* All done */ av_close_input_file(ctx); return 0; } forked-daapd-0.19gcd/src/filescanner_itunes.c0000664000175000017500000004344411633141135020624 0ustar julienjulien/* * Copyright (C) 2009-2010 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include "logger.h" #include "db.h" #include "http.h" #include "filescanner.h" #include "conffile.h" #include "misc.h" /* Mapping between iTunes library IDs and our DB IDs */ struct itml_to_db_map { uint64_t itml_id; uint32_t db_id; }; /* Mapping between iTunes library metadata keys and the offset * of the equivalent metadata field in struct media_file_info */ struct metadata_map { char *key; plist_type type; size_t offset; }; static struct metadata_map md_map[] = { { "Name", PLIST_STRING, mfi_offsetof(title) }, { "Artist", PLIST_STRING, mfi_offsetof(artist) }, { "Album Artist", PLIST_STRING, mfi_offsetof(album_artist) }, { "Composer", PLIST_STRING, mfi_offsetof(composer) }, { "Album", PLIST_STRING, mfi_offsetof(album) }, { "Genre", PLIST_STRING, mfi_offsetof(genre) }, { "Comments", PLIST_STRING, mfi_offsetof(comment) }, { "Track Count", PLIST_UINT, mfi_offsetof(total_tracks) }, { "Track Number", PLIST_UINT, mfi_offsetof(track) }, { "Disc Count", PLIST_UINT, mfi_offsetof(total_discs) }, { "Disc Number", PLIST_UINT, mfi_offsetof(disc) }, { "Year", PLIST_UINT, mfi_offsetof(year) }, { "Total Time", PLIST_UINT, mfi_offsetof(song_length) }, { "Bit Rate", PLIST_UINT, mfi_offsetof(bitrate) }, { "Sample Rate", PLIST_UINT, mfi_offsetof(samplerate) }, { "BPM", PLIST_UINT, mfi_offsetof(bpm) }, { "Rating", PLIST_UINT, mfi_offsetof(rating) }, { "Compilation", PLIST_BOOLEAN, mfi_offsetof(compilation) }, { "Date Added", PLIST_DATE, mfi_offsetof(time_added) }, { NULL, 0, 0 } }; static avl_tree_t *itml_to_db; static int itml_to_db_compare(const void *aa, const void *bb) { struct itml_to_db_map *a = (struct itml_to_db_map *)aa; struct itml_to_db_map *b = (struct itml_to_db_map *)bb; if (a->itml_id < b->itml_id) return -1; if (a->itml_id > b->itml_id) return 1; return 0; } /* plist helpers */ static int get_dictval_int_from_key(plist_t dict, const char *key, uint64_t *val) { plist_t node; node = plist_dict_get_item(dict, key); if (!node) return -1; if (plist_get_node_type(node) != PLIST_UINT) return -1; plist_get_uint_val(node, val); return 0; } static int get_dictval_date_from_key(plist_t dict, const char *key, uint32_t *val) { plist_t node; int32_t secs; int32_t dummy; node = plist_dict_get_item(dict, key); if (!node) return -1; if (plist_get_node_type(node) != PLIST_DATE) return -1; plist_get_date_val(node, &secs, &dummy); *val = (uint32_t) secs; return 0; } static int get_dictval_bool_from_key(plist_t dict, const char *key, uint8_t *val) { plist_t node; node = plist_dict_get_item(dict, key); /* Not present means false */ if (!node) { *val = 0; return 0; } if (plist_get_node_type(node) != PLIST_BOOLEAN) return -1; plist_get_bool_val(node, val); return 0; } static int get_dictval_string_from_key(plist_t dict, const char *key, char **val) { plist_t node; node = plist_dict_get_item(dict, key); if (!node) return -1; if (plist_get_node_type(node) != PLIST_STRING) return -1; plist_get_string_val(node, val); return 0; } static int get_dictval_dict_from_key(plist_t dict, const char *key, plist_t *val) { plist_t node; node = plist_dict_get_item(dict, key); if (!node) return -1; if (plist_get_node_type(node) != PLIST_DICT) return -1; *val = node; return 0; } static int get_dictval_array_from_key(plist_t dict, const char *key, plist_t *val) { plist_t node; node = plist_dict_get_item(dict, key); if (!node) return -1; if (plist_get_node_type(node) != PLIST_ARRAY) return -1; *val = node; return 0; } /* We don't actually check anything (yet) despite the name */ static int check_meta(plist_t dict) { char *appver; char *folder; uint64_t major; uint64_t minor; int ret; ret = get_dictval_int_from_key(dict, "Major Version", &major); if (ret < 0) return -1; ret = get_dictval_int_from_key(dict, "Minor Version", &minor); if (ret < 0) return -1; ret = get_dictval_string_from_key(dict, "Application Version", &appver); if (ret < 0) return -1; ret = get_dictval_string_from_key(dict, "Music Folder", &folder); if (ret < 0) { free(appver); return -1; } DPRINTF(E_INFO, L_SCAN, "iTunes XML playlist Major:%" PRIu64 " Minor:%" PRIu64 " Application:%s Folder:%s\n", major, minor, appver, folder); free(appver); free(folder); return 0; } /* Best-effort attempt at locating the file: * - first exact location given in itml * - somewhere under the location of itml * - anywhere (filename only) */ static int find_track_file(char *location, char *base) { char *filename; int plen; int mfi_id; http_decode_uri(location, URI_DECODE_NORMAL); plen = strlen("file://localhost/"); /* Not a local file ... */ if (strncmp(location, "file://localhost/", plen) != 0) return 0; /* Windows pathspec, from iTunes Win32 */ if (location[plen + 1] == ':') plen += 2; else plen -= 1; /* Try exact path first */ filename = m_realpath(location + plen); if (filename) { mfi_id = db_file_id_bypath(filename); free(filename); if (mfi_id > 0) return mfi_id; } filename = strrchr(location, '/'); if (!filename) { DPRINTF(E_WARN, L_SCAN, "Could not extract filename from location\n"); return 0; } filename++; /* Try to locate the file under the playlist location */ mfi_id = db_file_id_byfilebase(filename, base); if (mfi_id > 0) return mfi_id; /* Last resort, filename only */ mfi_id = db_file_id_byfile(filename); return mfi_id; } static int process_track_file(plist_t trk, char *base) { char *location; struct media_file_info *mfi; char *string; uint64_t integer; char **strval; uint32_t *intval; char *chrval; uint8_t boolean; int mfi_id; int i; int ret; ret = get_dictval_string_from_key(trk, "Location", &location); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Track type File with no Location\n"); return 0; } mfi_id = find_track_file(location, base); if (mfi_id <= 0) { DPRINTF(E_INFO, L_SCAN, "Could not match location '%s' to any known file\n", location); free(location); return 0; } free(location); if (!cfg_getbool(cfg_getsec(cfg, "library"), "itunes_overrides")) return mfi_id; /* Override our metadata with what's provided by iTunes */ mfi = db_file_fetch_byid(mfi_id); if (!mfi) { DPRINTF(E_LOG, L_SCAN, "Could not retrieve file info for file id %d\n", mfi_id); return mfi_id; } for (i = 0; md_map[i].key != NULL; i++) { switch (md_map[i].type) { case PLIST_UINT: ret = get_dictval_int_from_key(trk, md_map[i].key, &integer); if (ret < 0) break; intval = (uint32_t *) ((char *) mfi + md_map[i].offset); *intval = (uint32_t)integer; break; case PLIST_STRING: ret = get_dictval_string_from_key(trk, md_map[i].key, &string); if (ret < 0) break; strval = (char **) ((char *) mfi + md_map[i].offset); if (*strval) free(*strval); *strval = string; break; case PLIST_BOOLEAN: ret = get_dictval_bool_from_key(trk, md_map[i].key, &boolean); if (ret < 0) break; chrval = (char *) mfi + md_map[i].offset; *chrval = boolean; break; case PLIST_DATE: intval = (uint32_t *) ((char *) mfi + md_map[i].offset); get_dictval_date_from_key(trk, md_map[i].key, intval); break; default: DPRINTF(E_WARN, L_SCAN, "Unhandled metadata type %d\n", md_map[i].type); break; } } /* Don't let album_artist set to "Unknown artist" if we've * filled artist from the iTunes data in the meantime */ if (strcmp(mfi->album_artist, "Unknown artist") == 0) { free(mfi->album_artist); mfi->album_artist = strdup(mfi->artist); } unicode_fixup_mfi(mfi); db_file_update(mfi); free_mfi(mfi, 0); return mfi_id; } static int process_track_stream(plist_t trk) { char *url; int ret; ret = get_dictval_string_from_key(trk, "Location", &url); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Track type URL with no Location entry!\n"); return 0; } ret = db_file_id_byurl(url); free(url); return ret; } static int process_tracks(plist_t tracks, char *base) { plist_t trk; plist_dict_iter iter; struct itml_to_db_map *map; avl_node_t *mapnode; char *str; uint64_t trk_id; uint8_t disabled; int ntracks; int mfi_id; int ret; if (plist_dict_get_size(tracks) == 0) { DPRINTF(E_WARN, L_SCAN, "No tracks in iTunes library\n"); return 0; } ntracks = 0; iter = NULL; plist_dict_new_iter(tracks, &iter); plist_dict_next_item(tracks, iter, NULL, &trk); while (trk) { if (plist_get_node_type(trk) != PLIST_DICT) { plist_dict_next_item(tracks, iter, NULL, &trk); continue; } ret = get_dictval_int_from_key(trk, "Track ID", &trk_id); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Track ID not found!\n"); plist_dict_next_item(tracks, iter, NULL, &trk); continue; } ret = get_dictval_bool_from_key(trk, "Disabled", &disabled); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Malformed track record (id %" PRIu64 ")\n", trk_id); plist_dict_next_item(tracks, iter, NULL, &trk); continue; } if (disabled) { DPRINTF(E_INFO, L_SCAN, "Track %" PRIu64 " disabled; skipping\n", trk_id); plist_dict_next_item(tracks, iter, NULL, &trk); continue; } ret = get_dictval_string_from_key(trk, "Track Type", &str); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Track %" PRIu64 " has no track type\n", trk_id); plist_dict_next_item(tracks, iter, NULL, &trk); continue; } if (strcmp(str, "URL") == 0) mfi_id = process_track_stream(trk); else if (strcmp(str, "File") == 0) mfi_id = process_track_file(trk, base); else { DPRINTF(E_LOG, L_SCAN, "Unknown track type: %s\n", str); free(str); plist_dict_next_item(tracks, iter, NULL, &trk); continue; } free(str); if (mfi_id <= 0) { plist_dict_next_item(tracks, iter, NULL, &trk); continue; } ntracks++; map = (struct itml_to_db_map *)malloc(sizeof(struct itml_to_db_map)); if (!map) { DPRINTF(E_WARN, L_SCAN, "Out of memory for itml -> db mapping\n"); plist_dict_next_item(tracks, iter, NULL, &trk); continue; } map->itml_id = trk_id; map->db_id = mfi_id; mapnode = avl_insert(itml_to_db, map); if (!mapnode) { if (errno == EEXIST) DPRINTF(E_WARN, L_SCAN, "Track %" PRIu64 " already in itml -> db map?!\n", trk_id); else DPRINTF(E_WARN, L_SCAN, "Track %" PRIu64 ": AVL insert error: %s\n", trk_id, strerror(errno)); free(map); } plist_dict_next_item(tracks, iter, NULL, &trk); } free(iter); return ntracks; } static void process_pl_items(plist_t items, int pl_id) { struct itml_to_db_map needle; struct itml_to_db_map *map; plist_t trk; avl_node_t *mapnode; uint32_t alen; uint32_t i; int ret; alen = plist_array_get_size(items); for (i = 0; i < alen; i++) { trk = plist_array_get_item(items, i); if (plist_get_node_type(trk) != PLIST_DICT) continue; ret = get_dictval_int_from_key(trk, "Track ID", &needle.itml_id); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "No Track ID found for playlist item %u\n", i); continue; } mapnode = avl_search(itml_to_db, &needle); if (!mapnode) { DPRINTF(E_INFO, L_SCAN, "Track ID %" PRIu64 " dropped\n", needle.itml_id); continue; } map = (struct itml_to_db_map *)mapnode->item; ret = db_pl_add_item_byid(pl_id, map->db_id); if (ret < 0) DPRINTF(E_WARN, L_SCAN, "Could not add ID %d to playlist\n", map->db_id); } } static int ignore_pl(plist_t pl, char *name) { uint64_t kind; int smart; uint8_t master; uint8_t party; kind = 0; smart = 0; master = 0; party = 0; /* Special (builtin) playlists */ get_dictval_int_from_key(pl, "Distinguished Kind", &kind); /* If only we could recover the smart playlists ... */ if (plist_dict_get_item(pl, "Smart Info") || plist_dict_get_item(pl, "Smart Criteria")) smart = 1; /* Not interested in the Master playlist */ get_dictval_bool_from_key(pl, "Master", &master); /* Not interested in Party Shuffle playlists */ get_dictval_bool_from_key(pl, "Party Shuffle", &party); if ((kind > 0) || smart || party || master) { DPRINTF(E_INFO, L_SCAN, "Ignoring playlist '%s' (k %" PRIu64 " s%d p%d m%d)\n", name, kind, smart, party, master); return 1; } return 0; } static void process_pls(plist_t playlists, char *file) { plist_t pl; plist_t items; struct playlist_info *pli; char *name; uint64_t id; int pl_id; uint32_t alen; uint32_t i; int ret; alen = plist_array_get_size(playlists); for (i = 0; i < alen; i++) { pl = plist_array_get_item(playlists, i); if (plist_get_node_type(pl) != PLIST_DICT) continue; ret = get_dictval_int_from_key(pl, "Playlist ID", &id); if (ret < 0) { DPRINTF(E_DBG, L_SCAN, "Playlist ID not found!\n"); continue; } ret = get_dictval_string_from_key(pl, "Name", &name); if (ret < 0) { DPRINTF(E_DBG, L_SCAN, "Name not found!\n"); continue; } if (ignore_pl(pl, name)) { free(name); continue; } pli = db_pl_fetch_bytitlepath(name, file); if (pli) { pl_id = pli->id; free_pli(pli, 0); db_pl_ping(pl_id); db_pl_clear_items(pl_id); } else pl_id = 0; ret = get_dictval_array_from_key(pl, "Playlist Items", &items); if (ret < 0) { DPRINTF(E_INFO, L_SCAN, "Playlist '%s' has no items\n", name); free(name); continue; } if (pl_id == 0) { ret = db_pl_add(name, file, &pl_id); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Error adding iTunes playlist '%s' (%s)\n", name, file); free(name); continue; } DPRINTF(E_INFO, L_SCAN, "Added playlist as id %d\n", pl_id); } free(name); process_pl_items(items, pl_id); } } void scan_itunes_itml(char *file) { struct stat sb; char *itml_xml; char *ptr; plist_t itml; plist_t node; int fd; int ret; DPRINTF(E_INFO, L_SCAN, "Processing iTunes library: %s\n", file); fd = open(file, O_RDONLY); if (fd < 0) { DPRINTF(E_WARN, L_SCAN, "Could not open iTunes library '%s': %s\n", file, strerror(errno)); return; } ret = fstat(fd, &sb); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Could not stat iTunes library '%s': %s\n", file, strerror(errno)); close(fd); return; } itml_xml = mmap(NULL, sb.st_size, PROT_READ, MAP_SHARED, fd, 0); if (itml_xml == MAP_FAILED) { DPRINTF(E_WARN, L_SCAN, "Could not map iTunes library: %s\n", strerror(errno)); close(fd); return; } itml = NULL; plist_from_xml(itml_xml, sb.st_size, &itml); ret = munmap(itml_xml, sb.st_size); if (ret < 0) DPRINTF(E_LOG, L_SCAN, "Could not unmap iTunes library: %s\n", strerror(errno)); close(fd); if (!itml) { DPRINTF(E_WARN, L_SCAN, "iTunes XML playlist '%s' failed to parse\n", file); return; } if (plist_get_node_type(itml) != PLIST_DICT) { DPRINTF(E_WARN, L_SCAN, "Malformed iTunes XML playlist '%s'\n", file); plist_free(itml); return; } /* Meta data */ ret = check_meta(itml); if (ret < 0) { plist_free(itml); return; } /* Tracks */ ret = get_dictval_dict_from_key(itml, "Tracks", &node); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Could not find Tracks dict\n"); plist_free(itml); return; } itml_to_db = avl_alloc_tree(itml_to_db_compare, free); if (!itml_to_db) { DPRINTF(E_FATAL, L_SCAN, "iTunes library parser could not allocate AVL tree\n"); plist_free(itml); return; } ptr = strrchr(file, '/'); if (!ptr) { DPRINTF(E_FATAL, L_SCAN, "Invalid filename\n"); avl_free_tree(itml_to_db); plist_free(itml); return; } *ptr = '\0'; ret = process_tracks(node, file); if (ret <= 0) { DPRINTF(E_WARN, L_SCAN, "No tracks loaded\n"); avl_free_tree(itml_to_db); plist_free(itml); return; } *ptr = '/'; DPRINTF(E_INFO, L_SCAN, "Loaded %d tracks from iTunes library\n", ret); /* Playlists */ ret = get_dictval_array_from_key(itml, "Playlists", &node); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Could not find Playlists dict\n"); avl_free_tree(itml_to_db); plist_free(itml); return; } process_pls(node, file); avl_free_tree(itml_to_db); plist_free(itml); } forked-daapd-0.19gcd/src/filescanner_m3u.c0000664000175000017500000001050511633141135020011 0ustar julienjulien/* * Copyright (C) 2009-2010 Julien BLACHE * * Rewritten from mt-daapd code: * Copyright (C) 2003 Ron Pedde (ron@pedde.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include "logger.h" #include "db.h" #include "filescanner.h" #include "misc.h" void scan_m3u_playlist(char *file) { FILE *fp; struct playlist_info *pli; struct stat sb; char buf[PATH_MAX]; char rel_entry[PATH_MAX]; char *pl_base; char *entry; char *filename; char *ptr; size_t len; int pl_id; int ret; DPRINTF(E_INFO, L_SCAN, "Processing static playlist: %s\n", file); ret = stat(file, &sb); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Could not stat() '%s': %s\n", file, strerror(errno)); return; } filename = strrchr(file, '/'); if (!filename) filename = file; else filename++; pli = db_pl_fetch_bypath(file); if (pli) { DPRINTF(E_DBG, L_SCAN, "Playlist found, updating\n"); pl_id = pli->id; free_pli(pli, 0); db_pl_ping(pl_id); db_pl_clear_items(pl_id); } else pl_id = 0; fp = fopen(file, "r"); if (!fp) { DPRINTF(E_WARN, L_SCAN, "Could not open playlist '%s': %s\n", file, strerror(errno)); return; } if (pl_id == 0) { /* Get only the basename, to be used as the playlist name */ ptr = strrchr(filename, '.'); if (ptr) *ptr = '\0'; /* Safe: filename is a subset of file which is <= PATH_MAX already */ strncpy(buf, filename, sizeof(buf)); /* Restore the full filename */ if (ptr) *ptr = '.'; ret = db_pl_add(buf, file, &pl_id); if (ret < 0) { DPRINTF(E_LOG, L_SCAN, "Error adding m3u playlist '%s'\n", file); return; } DPRINTF(E_INFO, L_SCAN, "Added playlist as id %d\n", pl_id); } ptr = strrchr(file, '/'); if (!ptr) { DPRINTF(E_WARN, L_SCAN, "Could not determine playlist base path\n"); return; } *ptr = '\0'; pl_base = strdup(file); *ptr = '/'; if (!pl_base) { DPRINTF(E_WARN, L_SCAN, "Out of memory\n"); return; } while (fgets(buf, sizeof(buf), fp) != NULL) { len = strlen(buf); if (buf[len - 1] != '\n') { DPRINTF(E_WARN, L_SCAN, "Entry exceeds PATH_MAX, discarding\n"); while (fgets(buf, sizeof(buf), fp) != NULL) { if (buf[strlen(buf) - 1] == '\n') break; } continue; } if ((buf[0] == ';') || (buf[0] == '#') || (buf[0] == '\n')) continue; while (isspace(buf[len - 1])) { len--; buf[len] = '\0'; } /* Absolute vs. relative path */ if (buf[0] == '/') { entry = buf; } else { ret = snprintf(rel_entry, sizeof(rel_entry),"%s/%s", pl_base, buf); if ((ret < 0) || (ret >= sizeof(rel_entry))) { DPRINTF(E_WARN, L_SCAN, "Skipping entry, PATH_MAX exceeded\n"); continue; } entry = rel_entry; } filename = m_realpath(entry); if (!filename) { DPRINTF(E_WARN, L_SCAN, "Could not determine real path for '%s': %s\n", entry, strerror(errno)); continue; } ret = db_pl_add_item_bypath(pl_id, filename); if (ret < 0) DPRINTF(E_WARN, L_SCAN, "Could not add %s to playlist\n", filename); free(filename); } free(pl_base); if (!feof(fp)) { DPRINTF(E_LOG, L_SCAN, "Error reading playlist '%s': %s\n", file, strerror(errno)); fclose(fp); return; } fclose(fp); DPRINTF(E_INFO, L_SCAN, "Done processing playlist\n"); } forked-daapd-0.19gcd/src/filescanner_urlfile.c0000664000175000017500000000530711633141135020753 0ustar julienjulien/* * Copyright (C) 2009-2010 Julien BLACHE * * Rewritten from mt-daapd code: * Copyright (C) 2003 Ron Pedde (ron@pedde.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include "logger.h" #include "db.h" #include "misc.h" #include "filescanner.h" int scan_url_file(char *file, struct media_file_info *mfi) { FILE *fp; char *head; char *tail; char buf[256]; size_t len; int ret; DPRINTF(E_DBG, L_SCAN, "Getting URL file info\n"); fp = fopen(file, "r"); if (!fp) { DPRINTF(E_WARN, L_SCAN, "Could not open '%s' for reading: %s\n", file, strerror(errno)); return -1; } head = fgets(buf, sizeof(buf), fp); fclose(fp); if (!head) { DPRINTF(E_WARN, L_SCAN, "Error reading from file '%s': %s", file, strerror(errno)); return -1; } len = strlen(buf); if (buf[len - 1] != '\n') { DPRINTF(E_WARN, L_SCAN, "URL info in file '%s' too large for buffer\n", file); return -1; } while (isspace(buf[len - 1])) { len--; buf[len] = '\0'; } tail = strchr(head, ','); if (!tail) { DPRINTF(E_LOG, L_SCAN, "Badly formatted .url file; expected format is bitrate,descr,url\n"); return -1; } head = tail + 1; tail = strchr(head, ','); if (!tail) { DPRINTF(E_LOG, L_SCAN, "Badly formatted .url file; expected format is bitrate,descr,url\n"); return -1; } *tail = '\0'; mfi->title = strdup(head); mfi->url = strdup(tail + 1); ret = safe_atou32(buf, &mfi->bitrate); if (ret < 0) { DPRINTF(E_WARN, L_SCAN, "Could not read bitrate\n"); return -1; } DPRINTF(E_DBG, L_SCAN," Title: %s\n", mfi->title); DPRINTF(E_DBG, L_SCAN," Bitrate: %d\n", mfi->bitrate); DPRINTF(E_DBG, L_SCAN," URL: %s\n", mfi->url); mfi->type = strdup("pls"); /* codectype = NULL */ mfi->description = strdup("Playlist URL"); return 0; } forked-daapd-0.19gcd/src/http.c0000664000175000017500000015610611633141135015723 0ustar julienjulien/* * Copyright (C) 2010 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include "evbuffer/evbuffer.h" #include "logger.h" #include "misc.h" #include "network.h" #include "http.h" #if 0 # define HTTP_TRACE(args...) fprintf(stderr, ##args) #else # define HTTP_TRACE(args...) #endif #define USER_AGENT PACKAGE "/" VERSION enum xfer_status { R_NEW, R_FROZEN, R_RUNNABLE, R_FIRSTLINE, R_HEADERS, R_BODY, R_DONE, }; #define REQ_F_CLOSE (1 << 0) struct http_request { enum xfer_status status; enum p_version proto_ver; enum request_method method; int flags; char *uri; struct keyval headers; struct evbuffer *body; struct http_response *response; /* Server-specific */ int64_t content_length; struct http_request *next; /* --- */ /* Client-specific */ http_cb cb; /* --- */ }; struct http_response { enum xfer_status status; enum p_version proto_ver; int status_code; char *reason; struct keyval headers; int64_t content_length; struct evbuffer *body; struct http_request *request; /* Server-specific */ void *data; http_chunk_cb chunk_cb; http_free_cb free_cb; /* --- */ }; #define CONN_F_CLOSE (1 << 0) #define CONN_F_LAST_CHUNK (1 << 1) struct http_connection { struct nconn *conn; struct evbuffer *readbuf; int flags; dispatch_queue_t queue; dispatch_group_t group; /* Request queue */ struct http_request *req_head; struct http_request *req_tail; void *data; http_close_cb close_cb; http_free_cb free_cb; /* Server-specific */ http_cb cb; /* Chunked response in progress or frozen request */ struct http_response *response; struct http_connection *next; /* --- */ }; struct http_server { struct nconn *lconn; dispatch_queue_t queue; dispatch_group_t group; dispatch_group_t user_group; struct http_connection *hconn_head; struct http_connection *hconn_tail; http_cb cb; http_server_close_cb close_cb; }; /* Keep in sync with enum p_version */ static const char *p_versions[] = { "1.0", "1.1", }; #define METHOD_STR(x) (methods[(x & ~METHOD_MASK)]) /* Keep in sync with enum request_method */ static const char *methods[] = { /* HTTP */ "GET", "POST", /* RTSP */ "ANNOUNCE", "OPTIONS", "SETUP", "RECORD", "PAUSE", "GET_PARAMETER", "SET_PARAMETER", "FLUSH", "TEARDOWN", }; /* Utilities */ void http_decode_uri(char *uri, enum uri_decode_mode mode) { char *e; char *d; int decode_plus; switch (mode) { case URI_DECODE_NORMAL: case URI_DECODE_PLUS_NEVER: decode_plus = 0; break; case URI_DECODE_PLUS_ALWAYS: decode_plus = 1; break; } e = uri; d = e; while (*e != '\0') { if ((*e == '?') && (mode == URI_DECODE_NORMAL)) decode_plus = 1; else if ((*e == '+') && decode_plus) *d = ' '; else if ((e[0] == '%') && isxdigit(e[1]) && isxdigit(e[2])) { e[1] = tolower(e[1]); e[2] = tolower(e[2]); e[1] -= (e[1] > '9') ? ('a' - 10) : '0'; e[2] -= (e[2] > '9') ? ('a' - 10) : '0'; *d = (e[1] << 4) | (e[2] & 0x0f); e += 2; } else if (d != e) *d = *e; d++; e++; } *d = '\0'; } int http_parse_query_string(const char *uri, struct keyval *kv) { char *query; char *p; char *name; char *value; int count; int ret; kv->head = NULL; kv->tail = NULL; /* No query in URI */ uri = strchr(uri, '?'); if (!uri) return 0; query = strdup(uri + 1); if (!query) { DPRINTF(E_LOG, L_HTTP, "Out of memory for query string copy\n"); return -1; } count = 0; p = query; ret = 0; while (p && (*p != '\0')) { value = strsep(&p, "&"); name = strsep(&value, "="); if (!value) break; http_decode_uri(value, URI_DECODE_PLUS_ALWAYS); ret = keyval_add(kv, name, value); if (ret < 0) break; count++; } free(query); return (ret < 0) ? ret : count; } const char * http_method(enum request_method method) { return METHOD_STR(method); } /* Helpers */ static int header_parse_line(char *line, struct onekeyval *okv, char **name, char **value) { char *p; /* Reached end of headers */ if (*line == '\0') return 1; /* Multiline header continuation */ if ((*line == ' ') || (*line == '\t')) { if (!okv) { DPRINTF(E_LOG, L_HTTP, "Malformed request, continuation header line with no previous header\n"); return -1; } p = realloc(okv->value, strlen(okv->value) + strlen(line) + 1); if (!p) { DPRINTF(E_LOG, L_HTTP, "Out of memory for multiline header\n"); return -1; } strcat(p, line); okv->value = p; return 2; } p = strchr(line, ':'); if (!p) { DPRINTF(E_LOG, L_HTTP, "Malformed header: %s\n", line); return -1; } *p = '\0'; p++; p += strspn(p, " \t"); *name = line; *value = p; return 0; } static int headers_read(struct keyval *hdr, struct evbuffer *buf) { char *line; char *name; char *value; int ret; while ((line = evbuffer_readline(buf))) { ret = header_parse_line(line, hdr->tail, &name, &value); if (ret == 2) continue; /* Multi-line header */ else if (ret != 0) break; ret = keyval_add(hdr, name, value); if (ret < 0) { ret = -2; break; } } /* More to come */ if (!line) return 1; /* End of headers or error */ return (ret == 1) ? 0 : -1; } static int headers_write(struct onekeyval *hh, struct evbuffer *buf) { struct onekeyval *h; int ret; for (h = hh; h; h = h->next) { ret = evbuffer_add_printf(buf, "%s: %s\r\n", h->name, h->value); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Out of memory while writing HTTP headers\n"); return -1; } } ret = evbuffer_add(buf, "\r\n", 2); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Out of memory for HTTP headers separator\n"); return -1; } return 0; } /* HTTP connection */ int http_connection_get_local_addr(struct http_connection *c, char *buf) { if (!c->conn) return -1; return nconn_get_local_addrstr(c->conn, buf); } int http_connection_get_remote_addr(struct http_connection *c, char *buf) { if (!c->conn) return -1; return nconn_get_remote_addrstr(c->conn, buf); } static void connection_free_task(void *arg) { struct nconn *n; struct http_connection *c; c = (struct http_connection *)arg; dispatch_group_enter(c->group); dispatch_group_notify(c->group, c->queue, ^{ struct http_request *req; struct http_request *reqs; dispatch_release(c->group); dispatch_release(c->queue); evbuffer_free(c->readbuf); /* Chunked response or frozen request */ if (c->response) { c->response->free_cb(c->response->data); http_response_free(c->response); c->response = NULL; } reqs = c->req_head; for (req = reqs; reqs; req = reqs) { reqs = req->next; http_request_free(req); } c->free_cb(c->data); free(c); }); if (c->conn) { n = c->conn; c->conn = NULL; nconn_close_and_free(n); } dispatch_group_leave(c->group); } static void connection_free(struct http_connection *c) { if (dispatch_get_current_queue() != c->queue) dispatch_sync_f(c->queue, c, connection_free_task); else connection_free_task(c); } /* HTTP request */ void http_request_free(struct http_request *req) { if (req->uri) free(req->uri); keyval_clear(&req->headers); if (req->body) evbuffer_free(req->body); if (req->response) { req->response->request = NULL; http_response_free(req->response); } free(req); } const char * http_request_get_uri(struct http_request *req) { return req->uri; } int http_request_set_body(struct http_request *req, struct evbuffer *evbuf) { if (!(req->method & METHOD_HAS_BODY)) return -1; if (req->body) evbuffer_free(req->body); req->body = evbuf; return 0; } void http_request_remove_header(struct http_request *req, const char *name) { keyval_remove(&req->headers, name); } int http_request_add_header(struct http_request *req, const char *name, const char *value) { return keyval_add(&req->headers, name, value); } const char * http_request_get_header(struct http_request *req, const char *name) { return keyval_get(&req->headers, name); } /* HTTP response */ void http_response_free(struct http_response *r) { keyval_clear(&r->headers); if (r->reason) free(r->reason); if (r->body) evbuffer_free(r->body); if (r->request) { r->request->response = NULL; http_request_free(r->request); } free(r); } struct evbuffer * http_response_get_body(struct http_response *r) { return r->body; } void http_response_set_body(struct http_response *r, struct evbuffer *evbuf) { if (r->body) evbuffer_free(r->body); r->body = evbuf; } void http_response_remove_header(struct http_response *r, const char *name) { keyval_remove(&r->headers, name); } int http_response_add_header(struct http_response *r, const char *name, const char *value) { return keyval_add(&r->headers, name, value); } const char * http_response_get_header(struct http_response *r, const char *name) { return keyval_get(&r->headers, name); } int http_response_get_status(struct http_response *r, const char **reason) { if (*reason) *reason = r->reason; return r->status_code; } int http_response_set_status(struct http_response *r, int status_code, const char *reason) { if (!reason) return -1; if (r->reason) free(r->reason); r->reason = strdup(reason); if (!r->reason) { DPRINTF(E_LOG, L_HTTP, "Out of memory for HTTP response reason\n"); return -1; } r->status_code = status_code; return 0; } /* * GCD-based HTTP client - Theory of operation * * The HTTP client is actually a struct http_connection object and a set of * methods to manipulate struct http_request and struct http_response, * including submitting (running) a struct http_request to the struct * http_connection. * * The HTTP connection uses a struct nconn for all network operations. * * As such, write operations happen on the struct nconn write queue. Read * operations happen on the struct http_connection queue; this includes the * user processing of the response via the user-supplied http_cb. All * http_client_*() operations must happen on the struct http_connection queue. * * The HTTP client uses the current queue at the time it is created as the * struct http_connection queue. * * The "write queue" references the struct nconn write queue. * The "read queue" references the struct http_connection queue. * * A private dispatch_group is used by the struct http_connection to * synchronize with the struct nconn at shutdown. * * The HTTP client also handles RTSP methods. */ /* HTTP/RTSP client */ static int response_parse_status_line(struct http_response *r, char *line) { char *version; char *code; char *reason; int i; int ret; version = strchr(line, '/'); if (!version) goto malformed; version++; code = strchr(version, ' '); if (!code) goto malformed; *code = '\0'; code++; reason = strchr(code, ' '); if (!reason) { *(code - 1) = ' '; goto malformed; } *reason = '\0'; reason++; for (i = 0; i < (sizeof(p_versions) / sizeof(p_versions[0])); i++) { if (strcmp(version, p_versions[i]) == 0) { r->proto_ver = i; break; } } if (i == (sizeof(p_versions) / sizeof(p_versions[0]))) { DPRINTF(E_LOG, L_HTTP, "Unknown HTTP version %s\n", version); return -1; } /* RTSP: check version is 1.0 */ if ((r->request->method & RTSP_METHOD) && (r->proto_ver != P_VER_1_0)) { DPRINTF(E_LOG, L_HTTP, "Bad version %s for RTSP response\n", version); return -1; } ret = safe_atoi32(code, &r->status_code); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not convert status code to integer: %s\n", code); return -1; } r->reason = strdup(reason); if (!r->reason) { DPRINTF(E_LOG, L_HTTP, "Out of memory for HTTP reason\n"); return -1; } return 0; malformed: DPRINTF(E_LOG, L_HTTP, "Malformed status line in response: %s\n", line); return -1; } static void client_read_cb(struct nconn *n, int fd, size_t estimated, void *data) { struct http_connection *c; struct http_request *req; struct http_response *r; const char *hdr; char *line; size_t len; int ret; c = (struct http_connection *)data; req = c->req_head; if (!req) { DPRINTF(E_LOG, L_HTTP, "HTTP client error: data received with no pending requests\n"); goto fail; } if (req->response) r = req->response; else { r = (struct http_response *)malloc(sizeof(struct http_response)); if (!r) { DPRINTF(E_LOG, L_HTTP, "Out of memory for HTTP reponse\n"); goto fail; } memset(r, 0, sizeof(struct http_response)); r->body = evbuffer_new(); if (!r->body) { DPRINTF(E_LOG, L_HTTP, "Out of memory for HTTP response body\n"); free(r); goto fail; } r->status = R_FIRSTLINE; r->request = req; req->response = r; } ret = evbuffer_read(c->readbuf, fd, -1); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "HTTP client failure while reading response\n"); goto fail; } do { if (r->status == R_FIRSTLINE) { line = evbuffer_readline(c->readbuf); if (!line) { ret = 1; /* Not enough data */ break; } ret = response_parse_status_line(r, line); if (ret == 0) { DPRINTF(E_DBG, L_HTTP, "Response status: %d %s (ver %s)\n", r->status_code, r->reason, p_versions[r->proto_ver]); r->status = R_HEADERS; } } else if (r->status == R_HEADERS) { ret = headers_read(&r->headers, c->readbuf); if (ret == 1) DPRINTF(E_DBG, L_HTTP, "More headers expected in response\n"); else if (ret == 0) { DPRINTF(E_DBG, L_HTTP, "End of headers in response\n"); r->status = R_BODY; hdr = keyval_get(&r->headers, "Content-Length"); if (hdr) { ret = safe_atoi64(hdr, &r->content_length); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Invalid Content-Length: %s\n", hdr); break; } } else { if (req->flags & REQ_F_CLOSE) r->content_length = -1; else if (req->method & RTSP_METHOD) r->content_length = 0; else { DPRINTF(E_LOG, L_HTTP, "Cannot determine response length!\n"); ret = -1; break; } } if (r->content_length == 0) { r->status = R_DONE; ret = 1; break; } if (EVBUFFER_LENGTH(c->readbuf) == 0) { ret = 1; break; } } } else { DPRINTF(E_DBG, L_HTTP, "Reading body, content-length %" PRId64 "\n", r->content_length); if (r->content_length == -1) { ret = evbuffer_add_buffer(r->body, c->readbuf); if (ret < 0) DPRINTF(E_LOG, L_HTTP, "Out of memory for response body\n"); /* Nothing more to do here */ break; } else { len = r->content_length - EVBUFFER_LENGTH(r->body); DPRINTF(E_DBG, L_HTTP, "Reading body, %lu bytes to go\n", (unsigned long)len); if (len >= EVBUFFER_LENGTH(c->readbuf)) ret = evbuffer_add_buffer(r->body, c->readbuf); else { ret = evbuffer_add(r->body, EVBUFFER_DATA(c->readbuf), len); evbuffer_drain(c->readbuf, len); } if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Out of memory for response body\n"); break; } if ((r->content_length - EVBUFFER_LENGTH(r->body)) == 0) { r->status = R_DONE; ret = 1; } /* Nothing more to do here */ break; } /* For chunked replies, would need to try to read trailer * after body is complete */ } } while (ret == 0); if (ret < 0) goto fail; if (r->status == R_DONE) { c->req_head = req->next; req->next = NULL; if (c->req_tail == req) c->req_tail = NULL; req->cb(c, req, r, c->data); } return; fail: c->conn = NULL; nconn_close_and_free(n); c->close_cb(c, c->data); } static void client_fail_cb(void *data) { struct nconn *n; struct http_connection *c; struct http_request *req; struct http_response *r; c = (struct http_connection *)data; n = c->conn; c->conn = NULL; nconn_close_and_free(n); req = c->req_head; if (!req) goto fail; if (!req->response) goto fail; r = req->response; if ((r->status != R_BODY) || (r->content_length != -1)) goto fail; /* Reply to a Connection: close request without Content-Length */ r->status = R_DONE; c->req_head = req->next; req->next = NULL; if (c->req_tail == req) c->req_tail = NULL; req->cb(c, req, r, c->data); return; fail: c->close_cb(c, c->data); } struct http_connection * http_client_new(int ldomain, const char *address, short port, http_close_cb close_cb, http_free_cb free_cb, void *data) { struct http_connection *c; int ret; c = (struct http_connection *)malloc(sizeof(struct http_connection)); if (!c) { DPRINTF(E_LOG, L_HTTP, "Out of memory for HTTP client\n"); return NULL; } memset(c, 0, sizeof(struct http_connection)); c->readbuf = evbuffer_new(); if (!c->readbuf) { DPRINTF(E_LOG, L_HTTP, "Could not create HTTP client buffer\n"); goto buffer_fail; } c->group = dispatch_group_create(); if (!c->group) { DPRINTF(E_LOG, L_HTTP, "Could not create HTTP client group\n"); goto group_fail; } /* Client executes on the same queue; don't use a global concurrent queue! */ c->queue = dispatch_get_current_queue(); dispatch_retain(c->queue); c->conn = nconn_outgoing_new(ldomain, c->group, c->queue, address, port); if (!c->conn) { DPRINTF(E_LOG, L_HTTP, "Could not create HTTP client network connection\n"); goto nconn_fail; } c->close_cb = close_cb; c->free_cb = free_cb; c->data = data; ret = nconn_start(c->conn, c, client_read_cb, NULL, client_fail_cb); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not start HTTP client network connection\n"); goto start_fail; } return c; start_fail: nconn_free(c->conn); nconn_fail: dispatch_release(c->group); dispatch_release(c->queue); group_fail: evbuffer_free(c->readbuf); buffer_fail: free(c); return NULL; } void http_client_free(struct http_connection *c) { connection_free(c); } struct http_request * http_client_request_new(enum request_method method, enum p_version version, const char *uri, http_cb cb) { struct http_request *req; req = (struct http_request *)malloc(sizeof(struct http_request)); if (!req) { DPRINTF(E_LOG, L_HTTP, "Out of memory for new HTTP request\n"); return NULL; } memset(req, 0, sizeof(struct http_request)); req->method = method; req->proto_ver = version; req->uri = strdup(uri); if (!req->uri) { DPRINTF(E_LOG, L_HTTP, "Couldn't make new request: out of memory for URI\n"); free(req); return NULL; } req->cb = cb; return req; } int http_client_request_run(struct http_connection *c, struct http_request *req) { char buf[16]; struct nconn *n; struct http_request *old_tail; struct evbuffer *evbuf; const char *hdr; const char *method; const char *protocol; size_t bodylen; int ret; if (!c->conn) { DPRINTF(E_LOG, L_HTTP, "Could not run request: HTTP client failed\n"); return -1; } if (c->req_tail && (c->req_tail->flags & REQ_F_CLOSE)) { DPRINTF(E_LOG, L_HTTP, "Not running request: previous request closes connection\n"); return -1; } evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_HTTP, "Could not run request: out of memory for buffer\n"); return -1; } /* Handle connection depending on protocol version & options */ if (req->method & HTTP_METHOD) { if (req->proto_ver == P_VER_1_0) req->flags |= REQ_F_CLOSE; else { hdr = keyval_get(&req->headers, "Connection"); if (hdr && (strcmp(hdr, "close") == 0)) { DPRINTF(E_DBG, L_HTTP, "Request is HTTP/1.1 with Connection: close\n"); req->flags |= REQ_F_CLOSE; } } } /* Content-Length */ keyval_remove(&req->headers, "Content-Length"); bodylen = (req->body) ? EVBUFFER_LENGTH(req->body) : 0; if (bodylen > 0) { buf[0] = '\0'; snprintf(buf, sizeof(buf), "%ld", (long)bodylen); keyval_add(&req->headers, "Content-Length", buf); } /* User-Agent */ keyval_add(&req->headers, "User-Agent", USER_AGENT); /* Assemble request */ if (req->method & RTSP_METHOD) protocol = "RTSP"; else protocol = "HTTP"; method = METHOD_STR(req->method); ret = evbuffer_add_printf(evbuf, "%s %s %s/%s\r\n", method, req->uri, protocol, p_versions[req->proto_ver]); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run request: out of memory for request line\n"); goto buffer_fail; } ret = headers_write(req->headers.head, evbuf); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run request: out of memory for headers\n"); goto buffer_fail; } if (req->body) { ret = evbuffer_add_buffer(evbuf, req->body); evbuffer_free(req->body); req->body = NULL; if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run request: out of memory for body\n"); goto buffer_fail; } } /* Store request */ req->next = NULL; old_tail = c->req_tail; if (c->req_tail) c->req_tail->next = req; c->req_tail = req; if (!c->req_head) c->req_head = c->req_tail; ret = nconn_write(c->conn, evbuf); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run request: connection write error\n"); n = c->conn; c->conn = NULL; nconn_close_and_free(n); if (c->req_head == c->req_tail) c->req_head = NULL; if (old_tail) old_tail->next = NULL; c->req_tail = old_tail; goto buffer_fail; } evbuffer_free(evbuf); return 0; buffer_fail: evbuffer_free(evbuf); return -1; } /* * GCD-based HTTP server - Theory of operation * * The HTTP server is a struct http_server object maintaining a pasive socket * for incoming connections and a list of active struct http_connection. The * struct http_server uses its own private queue to manage the list of active * connections. * * The server uses two dispatch_groups: * - a private dispatch_group to synchronize with the active struct * http_connections at shutdown; * - a user-provided dispatch_group that the user can use to synchronize with * her active struct http_servers when shutting down. * * The HTTP server uses struct nconn for all network operations. * * As such, write operations happen on the struct nconn write queue; this * includes the user-supplied chunk_cb when running a chunked response. Read * operations happen on the struct http_connection queue; this includes the * user processing of the requests via the user-supplied http_cb. With a few * specific exceptions, all http_server_*() operations must happen on the * struct http_connection queue. * * The exceptions are: * - http_server_response_end_chunked(), called by the user-supplied chunk_cb * from the write queue; * - http_server_response_thaw_and_run(), called by the user from any queue; * - http_server_kill_connection(), called by the user from any queue. * * Contrary to the HTTP client, struct http_connections used by the HTTP server * run in their own private queue. * * The "write queue" references the struct nconn write queue. * The "read queue" references the struct http_connection queue. * * The HTTP server supports Transfer-Encoding: chunked responses to HTTP/1.1 * requests; the user must supply: * - a chunk_cb to be called from the write queue to get the next chunk or * end the reply when EOD is reached; * - a free_cb that will be called whenever the associated struct * http_response is freed (error or EOD); * - a data pointer, passed to the chunk_cb and the free_cb. * * The chunk_cb must return: * - an evbuffer filled with chunk data if data is available; * - an empty evbuffer if EOD is reached (after ending the response). Ownership * of the evbuffer is transferred to the server which will free it; * - NULL if an error occurs, instructing the server to kill the connection. * The chunk_cb must free the data pointer before killing the connection. * * The HTTP server supports freezing a response, for the cases where the * response cannot be emitted immediately. Freezing a response is done with a * call to http_server_response_freeze() in the http_cb; the user must supply: * - a free_cb to be called if the response gets freed while frozen (error); * - a data pointer, passed to the free_cb. * * Once ready, the response can be thawed and run with a call to * http_server_response_thaw_and_run(); if an error occurs, the connection must * be killed with a call to http_server_kill_connection(). * * If an error occurs while initiating a response, be it a standard response * or a chunked response, the response must be freed and an attempt at sending * back an error code must be made using http_server_error_run(). Should that * fail, the http_cb must return -1 to instruct the server to kill the * connection. */ /* HTTP server */ static int request_parse_request_line(struct http_request *req, char *line) { char *method; char *uri; char *protocol; char *version; int i; HTTP_TRACE("*** request_parse_request_line\n"); method = line; uri = strchr(method, ' '); if (!uri) goto malformed; *uri = '\0'; uri++; protocol = strrchr(uri, ' '); if (!protocol) { *(uri - 1) = ' '; goto malformed; } *protocol = '\0'; protocol++; version = strchr(protocol, '/'); if (!version) { *(uri - 1) = ' '; *(protocol - 1) = ' '; goto malformed; } *version = '\0'; version++; /* Protocol check */ if (strcmp(protocol, "HTTP") != 0) goto bad_request; /* Version check */ for (i = 0; i < (sizeof(p_versions) / sizeof(p_versions[0])); i++) { if (strcmp(version, p_versions[i]) == 0) { req->proto_ver = i; break; } } if (i == (sizeof(p_versions) / sizeof(p_versions[0]))) { DPRINTF(E_LOG, L_HTTP, "Unknown HTTP version %s\n", version); goto bad_request; } /* Method check */ for (i = 0; i < (sizeof(methods) / sizeof(methods[0])); i++) { if (strcmp(method, methods[i]) == 0) { req->method = i; break; } } if (i == (sizeof(methods) / sizeof(methods[0]))) { DPRINTF(E_LOG, L_HTTP, "Unknown HTTP method %s\n", method); goto bad_request; } /* HTTP methods only - RTSP not supported */ switch (req->method) { case (HTTP_GET & ~METHOD_MASK): req->method = HTTP_GET; break; case (HTTP_POST & ~METHOD_MASK): req->method = HTTP_POST; break; default: DPRINTF(E_LOG, L_HTTP, "Method %s not supported for HTTP\n", method); goto bad_request; } req->uri = strdup(uri); if (!req->uri) { DPRINTF(E_LOG, L_HTTP, "Out of memory for request URI!\n"); return -1; } return 0; malformed: DPRINTF(E_LOG, L_HTTP, "Malformed request: %s\n", line); return -1; bad_request: *(uri - 1) = ' '; *(protocol - 1) = ' '; *(version - 1) = '/'; DPRINTF(E_LOG, L_HTTP, "Bad request: %s\n", line); /* Caller closes connection */ return -1; } static int server_make_chunk(struct evbuffer *evbuf, struct evbuffer *chunk) { int ret; HTTP_TRACE("*** server_make_chunk\n"); ret = evbuffer_add_printf(evbuf, "%lx\r\n", (unsigned long)EVBUFFER_LENGTH(chunk)); if (ret < 0) goto out_err; ret = evbuffer_add_buffer(evbuf, chunk); if (ret < 0) goto out_err; ret = evbuffer_add(evbuf, "\r\n", 2); if (ret < 0) goto out_err; return 0; out_err: DPRINTF(E_LOG, L_HTTP, "Out of memory for response chunk\n"); return -1; } static int server_make_end_chunk(struct evbuffer *evbuf) { int ret; HTTP_TRACE("*** server_make_end_chunk\n"); ret = evbuffer_add(evbuf, "0\r\n\r\n", 5); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Out of memory for response end chunk\n"); return -1; } return 0; } static int server_response_chunk_write(struct http_connection *c, struct evbuffer *chunk) { struct evbuffer *evbuf; int ret; HTTP_TRACE("*** server_response_chunk_write\n"); if (c->response->proto_ver != P_VER_1_0) { evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_HTTP, "Out of memory for chunk buffer\n"); return -1; } ret = server_make_chunk(evbuf, chunk); if (ret < 0) goto fail; } else evbuf = chunk; if (c->conn) { ret = nconn_write(c->conn, evbuf); if (ret < 0) goto fail; } if (c->response->proto_ver != P_VER_1_0) evbuffer_free(evbuf); return 0; fail: evbuffer_free(evbuf); return -1; } /* Helpers */ /* Queue: server queue */ static void server_fail(struct http_server *srv) { struct nconn *n; HTTP_TRACE("*** server_fail\n"); n = srv->lconn; srv->lconn = NULL; nconn_close_and_free(n); /* User must free server */ srv->close_cb(srv, NULL); } /* Queue: server queue */ static void server_remove_connection(struct http_server *srv, struct http_connection *c) { struct http_connection *hc; struct http_connection *pc; HTTP_TRACE("*** server_remove_connection\n"); for (pc = NULL, hc = srv->hconn_head; hc; pc = hc, hc = hc->next) { if (hc == c) break; } if (!hc) { DPRINTF(E_DBG, L_HTTP, "Cannot remove connection: not found in list!\n"); return; } if (hc == srv->hconn_head) srv->hconn_head = c->next; if (hc == srv->hconn_tail) srv->hconn_tail = pc; if (pc) pc->next = c->next; } /* Queue: connection queue (aka read queue) */ static void server_exec_request(struct http_connection *c) { struct nconn *n; struct http_request *req; struct http_response *r; int ret; HTTP_TRACE("*** server_exec_request\n"); if (!c->conn) return; /* No pending requests */ if (!c->req_head) return; /* Chunked response in progress, or frozen request */ if (c->response) return; /* Request is not ready */ if (c->req_head->status != R_DONE) return; req = c->req_head; r = (struct http_response *)malloc(sizeof(struct http_response)); if (!r) { DPRINTF(E_LOG, L_HTTP, "Out of memory for HTTP reponse\n"); goto fail; } memset(r, 0, sizeof(struct http_response)); r->proto_ver = req->proto_ver; r->request = req; req->response = r; c->req_head = req->next; if (c->req_tail == req) c->req_tail = NULL; req->next = NULL; ret = c->cb(c, req, r, c->data); if (ret < 0) { DPRINTF(E_INFO, L_HTTP, "User callback retval < 0, killing connection\n"); goto fail; } return; fail: if (c->conn) { n = c->conn; c->conn = NULL; nconn_close_and_free(n); c->close_cb(c, c->data); } } /* HTTP connections callbacks - network connection */ /* Queue: connection queue (aka read queue) */ static void server_connection_read_cb(struct nconn *n, int fd, size_t estimated, void *data) { struct http_connection *c; struct http_request *req; const char *hdr; char *line; size_t len; int ret; HTTP_TRACE("*** server_connection_read_cb\n"); c = (struct http_connection *)data; /* The connection has been closed by a job scheduled on the connection * queue that ran just before us. The next job on the queue will be the * read source cancel handler. The nconn is still valid for us at that * point, however, but there's no point anymore as this connection is * shutting down. */ if (!c->conn) return; for (req = c->req_head; req; req = req->next) { if (req->status != R_DONE) break; } if (!req) { req = (struct http_request *)malloc(sizeof(struct http_request)); if (!req) { DPRINTF(E_LOG, L_HTTP, "Out of memory for incoming HTTP request\n"); goto fail; } memset(req, 0, sizeof(struct http_request)); req->body = evbuffer_new(); if (!req->body) { DPRINTF(E_LOG, L_HTTP, "Out of memory for incoming HTTP request body\n"); free(req); goto fail; } req->status = R_FIRSTLINE; /* Add to list */ if (c->req_tail) c->req_tail->next = req; c->req_tail = req; if (!c->req_head) c->req_head = c->req_tail; } ret = evbuffer_read(c->readbuf, fd, -1); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "HTTP server failure while reading request\n"); goto fail; } do { if (req->status == R_FIRSTLINE) { line = evbuffer_readline(c->readbuf); if (!line) { ret = 1; /* Not enough data */ break; } ret = request_parse_request_line(req, line); if (ret == 0) { DPRINTF(E_DBG, L_HTTP, "Request: %s %s (ver %s)\n", METHOD_STR(req->method), req->uri, p_versions[req->proto_ver]); req->status = R_HEADERS; } } else if (req->status == R_HEADERS) { ret = headers_read(&req->headers, c->readbuf); if (ret == 1) DPRINTF(E_DBG, L_HTTP, "More headers expected in request\n"); else if (ret == 0) { DPRINTF(E_DBG, L_HTTP, "End of headers in request\n"); req->status = R_BODY; /* Check if connection must be closed after this request */ if (req->proto_ver == P_VER_1_0) req->flags |= REQ_F_CLOSE; else { hdr = keyval_get(&req->headers, "Connection"); if (hdr) { if (strcasecmp(hdr, "close") == 0) req->flags |= REQ_F_CLOSE; } } /* Grab request body length */ req->content_length = -1; hdr = keyval_get(&req->headers, "Content-Length"); if (hdr) { ret = safe_atoi64(hdr, &req->content_length); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Invalid Content-Length in request: %s\n", hdr); break; } } /* Check that body length is correctly supplied */ if ((req->method & METHOD_HAS_BODY) && (req->content_length < 0)) { DPRINTF(E_LOG, L_HTTP, "Received HTTP request with no Content-Length for method with body\n"); ret = -1; break; } else if (req->content_length > 0) { DPRINTF(E_LOG, L_HTTP, "Received HTTP request with Content-Length > 0 for method with no body\n"); ret = -1; break; } else req->content_length = 0; if (req->content_length == 0) { req->status = R_DONE; ret = 1; break; } if (EVBUFFER_LENGTH(c->readbuf) == 0) { ret = 1; break; } } } else { len = req->content_length - EVBUFFER_LENGTH(req->body); DPRINTF(E_DBG, L_HTTP, "Reading request body, content-length %" PRId64 ", %lu bytes to go\n", req->content_length, (unsigned long)len); if (len >= EVBUFFER_LENGTH(c->readbuf)) ret = evbuffer_add_buffer(req->body, c->readbuf); else { ret = evbuffer_add(req->body, EVBUFFER_DATA(c->readbuf), len); evbuffer_drain(c->readbuf, len); } if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Out of memory for request body\n"); break; } if ((req->content_length - EVBUFFER_LENGTH(req->body)) == 0) { req->status = R_DONE; ret = 1; } /* Nothing more we can do here */ break; } } while (ret == 0); if (ret < 0) goto fail; /* For the cases where Bad Request could be sent out, accept the request * and use a new R_BAD status; exec_request() can then send out the * Bad Request response when appropriate */ /* See if the head request can be executed */ server_exec_request(c); return; fail: c->conn = NULL; nconn_close_and_free(n); c->close_cb(c, c->data); } /* Queue: nconn queue (aka write queue) */ static void server_connection_write_cb(struct nconn *n, void *data) { struct http_connection *c; struct evbuffer *chunk; int ret; HTTP_TRACE("*** server_connection_write_cb\n"); c = (struct http_connection *)data; /* The connection has been closed and the write source has been cancelled * already, however we were already scheduled to run when that happened. * The nconn is still valid for us at that point, however, but there's no * point anymore as this connection is shutting down. */ if (!c->conn) return; HTTP_TRACE("***** checking frozen/chunked response\n"); /* Frozen request or chunked response in progress */ if (c->response) { HTTP_TRACE("***** frozen or chunked response!\n"); /* Frozen request, do nothing */ if (!c->response->chunk_cb) return; /* Chunked response in progress */ HTTP_TRACE("***** chunked response!\n"); if (c->flags & CONN_F_LAST_CHUNK) { c->flags &= ~CONN_F_LAST_CHUNK; c->response->chunk_cb = NULL; goto write_done; } chunk = c->response->chunk_cb(c, c->response, c->response->data); /* An error occured in the user callback */ if (!chunk) goto fail; if (EVBUFFER_LENGTH(chunk) > 0) { ret = server_response_chunk_write(c, chunk); if (ret < 0) goto fail; return; } /* EOD handling */ /* Ownership of the buffer transferred by the client */ evbuffer_free(chunk); switch (c->response->proto_ver) { case P_VER_1_0: /* EOD - Connection can be closed */ break; case P_VER_1_1: /* Last chunk is being sent, close after */ c->flags |= CONN_F_LAST_CHUNK; return; } } write_done: /* All data has been written */ /* The connection is shutting down, we cannot schedule jobs on the connection * queue anymore at that point as the read source cancel handler is waiting * for the write source (us) to terminate. The nconn would not exist anymore * (not an issue) and the connection_free task would be scheduled next. */ if (!nconn_running(n)) return; dispatch_async(c->queue, ^{ struct nconn *conn; struct http_response *r; HTTP_TRACE("*** server_connection_write_cb BLOCK (close/handle next)\n"); /* Ending a chunked response */ if (c->response) { HTTP_TRACE("***** cleaning up chunked response\n"); r = c->response; c->response = NULL; r->free_cb(r->data); http_response_free(r); } if (c->flags & CONN_F_CLOSE) { if (c->conn) { conn = c->conn; c->conn = NULL; nconn_close_and_free(conn); c->close_cb(c, c->data); } } else server_exec_request(c); }); HTTP_TRACE("***** write_cb is done!\n"); return; fail: /* Connection is already shutting down - don't do it twice */ if (!nconn_running(n)) return; dispatch_async(c->queue, ^{ HTTP_TRACE("*** server_connection_write_cb BLOCK (close on failure)\n"); if (c->conn) { c->conn = NULL; nconn_close_and_free(n); c->close_cb(c, c->data); } }); } /* Queue: connection queue (aka read queue) */ static void server_connection_fail_cb(void *data) { struct nconn *n; struct http_connection *c; HTTP_TRACE("*** server_connection_fail_cb\n"); c = (struct http_connection *)data; n = c->conn; c->conn = NULL; nconn_close_and_free(n); /* This actually calls server_connection_close_cb() */ c->close_cb(c, c->data); } /* HTTP connections callbacks */ /* Queue: connection queue (aka read queue) */ static void server_connection_close_cb(struct http_connection *c, void *data) { struct http_server *srv; HTTP_TRACE("*** server_connection_close_cb\n"); srv = (struct http_server *)data; dispatch_sync(srv->queue, ^{ HTTP_TRACE("*** server_connection_close_cb BLOCK (remove connection)\n"); server_remove_connection(srv, c); }); connection_free(c); } /* Queue: connection queue (aka read queue) */ static void server_connection_free_cb(void *data) { struct http_server *srv; HTTP_TRACE("*** server_connection_free_cb\n"); srv = (struct http_server *)data; dispatch_group_leave(srv->group); } /* Listening socket callbacks */ /* Queue: server queue */ static void server_read_cb(struct nconn *passive, int fd, size_t estimated, void *data) { char qid[80]; struct http_server *srv; struct http_connection *old_tail; struct http_connection *c; int ret; HTTP_TRACE("*** server_read_cb\n"); srv = (struct http_server *)data; /* Server is shutting down, listen socket has been/is being closed */ if (!srv->lconn) return; c = (struct http_connection *)malloc(sizeof(struct http_connection)); if (!c) { DPRINTF(E_LOG, L_HTTP, "Out of memory for incoming HTTP connection\n"); goto out_fail; } memset(c, 0, sizeof(struct http_connection)); c->readbuf = evbuffer_new(); if (!c->readbuf) { DPRINTF(E_LOG, L_HTTP, "Out of memory for incoming HTTP connection buffer\n"); goto free_conn; } c->group = dispatch_group_create(); if (!c->group) { DPRINTF(E_LOG, L_HTTP, "Could not create incoming HTTP connection group\n"); goto free_buf; } snprintf(qid, sizeof(qid), "org.forked-daapd.http_connection.read.%p", c); c->queue = dispatch_queue_create(qid, NULL); if (!c->queue) { DPRINTF(E_LOG, L_HTTP, "Could not create incoming HTTP connection queue\n"); goto rel_group; } c->conn = nconn_incoming_new(passive, c->group, c->queue); if (!c->conn) { DPRINTF(E_LOG, L_HTTP, "Could not create incoming HTTP connection\n"); goto rel_queue; } DPRINTF(E_DBG, L_HTTP, "Server %p: incoming http_connection %p with nconn %p\n", srv, c, c->conn); c->data = srv; c->close_cb = server_connection_close_cb; c->free_cb = server_connection_free_cb; c->cb = srv->cb; /* Enter server group, connection will exit when freed, via free_cb */ dispatch_group_enter(srv->group); old_tail = srv->hconn_tail; if (srv->hconn_tail) srv->hconn_tail->next = c; srv->hconn_tail = c; if (!srv->hconn_head) srv->hconn_head = c; ret = nconn_start(c->conn, c, server_connection_read_cb, server_connection_write_cb, server_connection_fail_cb); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not start new incoming HTTP connection\n"); if (srv->hconn_head == srv->hconn_tail) srv->hconn_head = NULL; if (old_tail) old_tail->next = NULL; srv->hconn_tail = old_tail; nconn_free(c->conn); evbuffer_free(c->readbuf); dispatch_release(c->group); dispatch_release(c->queue); free(c); dispatch_group_leave(srv->group); /* Do not fail the whole server because one connection failed to start */ } return; rel_queue: dispatch_release(c->queue); rel_group: dispatch_release(c->group); free_buf: evbuffer_free(c->readbuf); free_conn: free(c); out_fail: server_fail(srv); } /* Queue: server queue */ static void server_fail_cb(void *data) { struct http_server *srv; HTTP_TRACE("*** server_fail_cb\n"); srv = (struct http_server *)data; server_fail(srv); } struct http_server * http_server_new(int ldomain, dispatch_group_t user_group, const char *address, short port, http_cb cb, http_server_close_cb close_cb) { char qid[80]; struct http_server *srv; HTTP_TRACE("*** http_server_new\n"); srv = (struct http_server *)malloc(sizeof(struct http_server)); if (!srv) { DPRINTF(E_LOG, L_HTTP, "Out of memory for HTTP server\n"); return NULL; } memset(srv, 0, sizeof(struct http_server)); srv->group = dispatch_group_create(); if (!srv->group) { DPRINTF(E_LOG, L_HTTP, "Could not create HTTP server group\n"); goto group_fail; } snprintf(qid, sizeof(qid), "org.forked-daapd.http_server.%p", srv); srv->queue = dispatch_queue_create(qid, NULL); if (!srv->queue) { DPRINTF(E_LOG, L_HTTP, "Could not create HTTP server queue\n"); goto queue_fail; } srv->lconn = nconn_listen_new(ldomain, srv->group, srv->queue, address, port); if (!srv->lconn) { DPRINTF(E_LOG, L_HTTP, "Could not create HTTP server socket\n"); goto lconn_fail; } DPRINTF(E_DBG, L_HTTP, "Server %p: listen nconn %p\n", srv, srv->lconn); srv->cb = cb; srv->close_cb = close_cb; srv->user_group = user_group; dispatch_retain(srv->user_group); /* http_server_free() will leave the group once the server is terminated */ dispatch_group_enter(srv->user_group); return srv; lconn_fail: dispatch_release(srv->queue); queue_fail: dispatch_release(srv->group); group_fail: free(srv); return NULL; } /* Queue: server queue */ static void http_server_free_task(void *arg) { struct nconn *n; struct http_server *srv; struct http_connection *hc; struct http_connection *c; HTTP_TRACE("*** http_server_free_task\n"); srv = (struct http_server *)arg; dispatch_group_enter(srv->group); dispatch_group_notify(srv->group, srv->queue, ^{ dispatch_release(srv->group); dispatch_release(srv->queue); dispatch_group_leave(srv->user_group); dispatch_release(srv->user_group); free(srv); }); if (srv->lconn) { n = srv->lconn; srv->lconn = NULL; nconn_close_and_free(n); } hc = srv->hconn_head; srv->hconn_head = NULL; srv->hconn_tail = NULL; for (c = hc; hc; c = hc) { hc = c->next; connection_free(c); } dispatch_group_leave(srv->group); } void http_server_free(struct http_server *srv) { HTTP_TRACE("*** http_server_free\n"); if (dispatch_get_current_queue() != srv->queue) dispatch_sync_f(srv->queue, srv, http_server_free_task); else http_server_free_task(srv); } int http_server_start(struct http_server *srv) { int ret; HTTP_TRACE("*** http_server_start\n"); ret = nconn_start(srv->lconn, srv, server_read_cb, NULL, server_fail_cb); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not start HTTP server socket\n"); nconn_free(srv->lconn); srv->lconn = NULL; /* User must free server */ return -1; } return 0; } /* Upon error on initiating a response, the user must free the response. * If the error was from run() or run_chunked(), the user can attempt to send * an HTTP error; if the error was from thaw_and_run(), the user must kill the * connection. */ /* Queue: connection queue (aka read queue) */ int http_server_response_run(struct http_connection *c, struct http_response *r) { char buf[16]; struct evbuffer *evbuf; size_t bodylen; int ret; HTTP_TRACE("*** http_server_response_run\n"); if (!c->conn) { DPRINTF(E_LOG, L_HTTP, "Could not run response: HTTP connection failed\n"); return -1; } evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_HTTP, "Could not run response: out of memory for buffer\n"); return -1; } /* Manage connection closing */ if ((r->proto_ver == P_VER_1_0) || (r->request->flags & REQ_F_CLOSE)) { c->flags |= CONN_F_CLOSE; if (r->proto_ver == P_VER_1_1) keyval_add(&r->headers, "Connection", "close"); } /* Content-Length */ keyval_remove(&r->headers, "Content-Length"); bodylen = (r->body) ? EVBUFFER_LENGTH(r->body) : 0; buf[0] = '\0'; snprintf(buf, sizeof(buf), "%ld", (long)bodylen); keyval_add(&r->headers, "Content-Length", buf); /* Server */ keyval_add(&r->headers, "Server", USER_AGENT); /* Assemble response */ ret = evbuffer_add_printf(evbuf, "HTTP/%s %d %s\r\n", p_versions[r->proto_ver], r->status_code, r->reason); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run response: out of memory for status line\n"); goto buffer_fail; } ret = headers_write(r->headers.head, evbuf); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run response: out of memory for headers\n"); goto buffer_fail; } if (r->body) { ret = evbuffer_add_buffer(evbuf, r->body); evbuffer_free(r->body); r->body = NULL; if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run response: out of memory for body\n"); goto buffer_fail; } evbuffer_add(evbuf, "\r\n", 2); } ret = nconn_write(c->conn, evbuf); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run response: connection write error\n"); goto buffer_fail; } evbuffer_free(evbuf); http_response_free(r); return 0; buffer_fail: evbuffer_free(evbuf); return -1; } /* Response freezing */ /* Queue: connection queue (aka read queue) */ void http_server_response_freeze(struct http_connection *c, struct http_response *r, http_free_cb free_cb, void *data) { HTTP_TRACE("*** http_server_response_freeze\n"); r->status = R_FROZEN; r->data = data; r->free_cb = free_cb; c->response = r; } /* Queue: unknown - external user queue */ /* Synchronized with r->free_cb via the external user queue managing frozen connections */ int http_server_response_thaw_and_run(struct http_connection *c, struct http_response *r) { __block int b_ret; dispatch_block_t thaw_and_run = ^{ HTTP_TRACE("*** http_server_response_thaw_and_run BLOCK\n"); if (c->response != r) { b_ret = -1; return; } r->status = R_RUNNABLE; r->data = NULL; r->free_cb = NULL; c->response = NULL; b_ret = http_server_response_run(c, r); }; HTTP_TRACE("*** http_server_response_thaw_and_run\n"); if (dispatch_get_current_queue() == c->queue) thaw_and_run(); else dispatch_sync(c->queue, thaw_and_run); return b_ret; } /* Chunked responses */ /* Queue: connection queue (aka read queue) */ int http_server_response_run_chunked(struct http_connection *c, struct http_response *r, struct evbuffer *chunk, http_chunk_cb chunk_cb, http_free_cb free_cb, void *data) { struct evbuffer *evbuf; int ret; HTTP_TRACE("*** http_server_response_run_chunked\n"); if (!c->conn) { DPRINTF(E_LOG, L_HTTP, "Could not run response: HTTP connection failed\n"); return -1; } evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_HTTP, "Could not run response: out of memory for buffer\n"); return -1; } /* Manage connection closing */ if ((r->proto_ver == P_VER_1_0) || (r->request->flags & REQ_F_CLOSE)) { c->flags |= CONN_F_CLOSE; if (r->proto_ver == P_VER_1_1) keyval_add(&r->headers, "Connection", "close"); } /* Server */ keyval_add(&r->headers, "Server", USER_AGENT); if (r->proto_ver != P_VER_1_0) { /* Remove Content-Length header, add Transfer-Encoding: chunked */ keyval_remove(&r->headers, "Content-Length"); keyval_add(&r->headers, "Transfer-Encoding", "chunked"); } /* Assemble response & first chunk */ ret = evbuffer_add_printf(evbuf, "HTTP/%s %d %s\r\n", p_versions[r->proto_ver], r->status_code, r->reason); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run response: out of memory for status line\n"); goto buffer_fail; } ret = headers_write(r->headers.head, evbuf); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run response: out of memory for headers\n"); goto buffer_fail; } if (r->proto_ver != P_VER_1_0) ret = server_make_chunk(evbuf, chunk); else ret = evbuffer_add_buffer(evbuf, chunk); if (ret < 0) goto buffer_fail; r->data = data; r->chunk_cb = chunk_cb; r->free_cb = free_cb; c->response = r; ret = nconn_write(c->conn, evbuf); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run response: connection write error\n"); c->response = NULL; goto buffer_fail; } evbuffer_free(evbuf); return 0; buffer_fail: evbuffer_free(evbuf); return -1; } /* Queue: nconn queue (aka write queue) */ /* Upon an error here, the user chunk callback is expected to return NULL */ int http_server_response_end_chunked(struct http_connection *c, struct http_response *r) { struct evbuffer *evbuf; int ret; HTTP_TRACE("*** http_server_response_end_chunked\n"); if (!c->conn) { DPRINTF(E_LOG, L_HTTP, "Could not run response: HTTP connection failed\n"); return -1; } /* Nothing to do for HTTP/1.0 */ if (r->proto_ver == P_VER_1_0) return 0; evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_HTTP, "Could not run response: out of memory for buffer\n"); return -1; } ret = server_make_end_chunk(evbuf); if (ret < 0) goto buffer_fail; ret = nconn_write(c->conn, evbuf); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run response: connection write error\n"); goto buffer_fail; } return 0; buffer_fail: evbuffer_free(evbuf); return -1; } /* Queue: connection queue (aka read queue) */ /* On error, the user http_cb must return -1 to tell the server to kill * the connection. */ int http_server_error_run(struct http_connection *c, struct http_response *r, int status_code, char *reason) { #define ERR_TMPL "%d - %s

%d - %s

" \ "

An error was encountered while processing the request.

" \ "

" USER_AGENT "

" const char *hdr; int do_close; int ret; __block int b_ret; dispatch_block_t error_run = ^{ HTTP_TRACE("*** http_server_error_run BLOCK\n"); b_ret = http_server_response_run(c, r); }; HTTP_TRACE("*** http_server_error_run\n"); /* If the response had a Connection: close header, keep it for the error */ hdr = http_response_get_header(r, "Connection"); if (hdr && (strcmp(hdr, "close") == 0)) do_close = 1; else do_close = 0; /* The response might be reused from a failed response_run attempt */ keyval_clear(&r->headers); if (do_close) http_response_add_header(r, "Connection", "close"); ret = http_response_set_status(r, status_code, reason); if (ret < 0) return -1; if (r->body) evbuffer_drain(r->body, EVBUFFER_LENGTH(r->body)); else { r->body = evbuffer_new(); if (!r->body) { DPRINTF(E_LOG, L_HTTP, "Could not run error: out of memory for body buffer\n"); return -1; } } ret = evbuffer_add_printf(r->body, ERR_TMPL, status_code, reason, status_code, reason); if (ret < 0) { DPRINTF(E_LOG, L_HTTP, "Could not run error: out of memory for error body\n"); return -1; } if (dispatch_get_current_queue() == c->queue) error_run(); else dispatch_sync(c->queue, error_run); if (b_ret < 0) http_response_free(r); return b_ret; #undef ERR_TMPL } /* Queue: any */ /* Use only after error from thaw_and_run() */ void http_server_kill_connection(struct http_connection *c) { HTTP_TRACE("*** http_server_kill_connection\n"); dispatch_async(c->queue, ^{ struct nconn *n; HTTP_TRACE("*** http_server_kill_connection BLOCK\n"); if (c->conn) { n = c->conn; c->conn = NULL; nconn_close_and_free(n); c->close_cb(c, c->data); } }); } forked-daapd-0.19gcd/src/http.h0000664000175000017500000001131011633141135015713 0ustar julienjulien #ifndef __HTTP_H__ #define __HTTP_H__ #include #include "evbuffer/evbuffer.h" #include "misc.h" /* Some HTTP codes */ #define HTTP_CONTINUE 100 #define HTTP_OK 200 #define HTTP_NO_CONTENT 204 #define HTTP_PARTIAL_CONTENT 206 #define HTTP_MOVE_TEMP 302 #define HTTP_BAD_REQUEST 400 #define HTTP_UNAUTHORIZED 401 #define HTTP_FORBIDDEN 403 #define HTTP_NOT_FOUND 404 #define HTTP_INTERNAL_ERROR 500 #define HTTP_UNAVAILABLE 503 enum p_version { P_VER_1_0, P_VER_1_1, }; #define METHOD_HAS_BODY (1 << 5) #define HTTP_METHOD (1 << 6) #define RTSP_METHOD (1 << 7) #define METHOD_MASK 0xe0 enum request_method { HTTP_GET = 0 | HTTP_METHOD, HTTP_POST = 1 | HTTP_METHOD | METHOD_HAS_BODY, RTSP_ANNOUNCE = 2 | RTSP_METHOD | METHOD_HAS_BODY, RTSP_OPTIONS = 3 | RTSP_METHOD, RTSP_SETUP = 4 | RTSP_METHOD, RTSP_RECORD = 5 | RTSP_METHOD, RTSP_PAUSE = 6 | RTSP_METHOD, RTSP_GET_PARAMETER = 7 | RTSP_METHOD | METHOD_HAS_BODY, RTSP_SET_PARAMETER = 8 | RTSP_METHOD | METHOD_HAS_BODY, RTSP_FLUSH = 9 | RTSP_METHOD, RTSP_TEARDOWN = 10 | RTSP_METHOD, }; enum uri_decode_mode { URI_DECODE_NORMAL, URI_DECODE_PLUS_ALWAYS, URI_DECODE_PLUS_NEVER, }; struct http_request; struct http_response; struct http_connection; struct http_server; typedef int (*http_cb)(struct http_connection *c, struct http_request *req, struct http_response *resp, void *data); typedef struct evbuffer *(*http_chunk_cb)(struct http_connection *c, struct http_response *resp, void *data); typedef void (*http_server_close_cb)(struct http_server *srv, void *data); typedef void (*http_close_cb)(struct http_connection *c, void *data); typedef void (*http_free_cb)(void *data); /* Utilities */ void http_decode_uri(char *uri, enum uri_decode_mode mode); int http_parse_query_string(const char *uri, struct keyval *kv); const char * http_method(enum request_method method); /* HTTP connection */ int http_connection_get_local_addr(struct http_connection *c, char *buf); int http_connection_get_remote_addr(struct http_connection *c, char *buf); /* HTTP request */ void http_request_free(struct http_request *req); const char * http_request_get_uri(struct http_request *req); int http_request_set_body(struct http_request *req, struct evbuffer *evbuf); void http_request_remove_header(struct http_request *req, const char *name); int http_request_add_header(struct http_request *req, const char *name, const char *value); const char * http_request_get_header(struct http_request *req, const char *name); /* HTTP response */ void http_response_free(struct http_response *r); struct evbuffer * http_response_get_body(struct http_response *r); void http_response_set_body(struct http_response *r, struct evbuffer *evbuf); void http_response_remove_header(struct http_response *r, const char *name); int http_response_add_header(struct http_response *r, const char *name, const char *value); const char * http_response_get_header(struct http_response *r, const char *name); int http_response_get_status(struct http_response *r, const char **reason); int http_response_set_status(struct http_response *r, int status_code, const char *reason); /* HTTP client */ struct http_connection * http_client_new(int ldomain, const char *address, short port, http_close_cb close_cb, http_free_cb free_cb, void *data); void http_client_free(struct http_connection *c); struct http_request * http_client_request_new(enum request_method method, enum p_version version, const char *uri, http_cb cb); int http_client_request_run(struct http_connection *c, struct http_request *req); /* HTTP server */ struct http_server * http_server_new(int ldomain, dispatch_group_t user_group, const char *address, short port, http_cb cb, http_server_close_cb close_cb); void http_server_free(struct http_server *srv); int http_server_start(struct http_server *srv); int http_server_response_run(struct http_connection *c, struct http_response *r); void http_server_response_freeze(struct http_connection *c, struct http_response *r, http_free_cb free_cb, void *data); int http_server_response_thaw_and_run(struct http_connection *c, struct http_response *r); int http_server_response_run_chunked(struct http_connection *c, struct http_response *r, struct evbuffer *chunk, http_chunk_cb chunk_cb, http_free_cb free_cb, void *data); int http_server_response_end_chunked(struct http_connection *c, struct http_response *r); int http_server_error_run(struct http_connection *c, struct http_response *r, int status_code, char *reason); void http_server_kill_connection(struct http_connection *c); #endif /* !__HTTP_H__ */ forked-daapd-0.19gcd/src/httpd.c0000664000175000017500000007313111633141135016063 0ustar julienjulien/* * Copyright (C) 2009-2010 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "evbuffer/evbuffer.h" #include "logger.h" #include "db.h" #include "conffile.h" #include "misc.h" #include "network.h" #include "http.h" #include "httpd.h" #include "httpd_rsp.h" #include "httpd_daap.h" #include "httpd_dacp.h" #include "transcode.h" /* * HTTP client quirks by User-Agent, from mt-daapd * * - iTunes: * + Connection: Keep-Alive on HTTP error 401 * - Hifidelio: * + Connection: Keep-Alive for streaming (Connection: close not honoured) * * These quirks are not implemented. Implement as needed. * * Implemented quirks: * * - Roku: * + Does not encode space as + in query string * - iTunes: * + Does not encode space as + in query string */ #define STREAM_CHUNK_SIZE (64 * 1024) #define WEBFACE_ROOT DATADIR "/webface/" struct content_type_map { char *ext; char *ctype; }; struct stream_ctx { uint8_t *buf; struct evbuffer *evbuf; int id; int fd; off_t size; off_t stream_size; off_t offset; off_t start_offset; off_t end_offset; int marked; struct transcode_ctx *xcode; }; static const struct content_type_map ext2ctype[] = { { ".html", "text/html; charset=utf-8" }, { ".xml", "text/xml; charset=utf-8" }, { ".css", "text/css; charset=utf-8" }, { ".txt", "text/plain; charset=utf-8" }, { ".js", "application/javascript; charset=utf-8" }, { ".gif", "image/gif" }, { ".ico", "image/x-ico" }, { ".png", "image/png" }, { NULL, NULL } }; static dispatch_group_t http_group; static struct http_server *http6; static struct http_server *http4; static void stream_chunk_free_cb(void *data) { struct stream_ctx *st; st = (struct stream_ctx *)data; DPRINTF(E_LOG, L_HTTPD, "Connection closed; stopping streaming of file ID %d\n", st->id); if (st->evbuf) evbuffer_free(st->evbuf); if (st->xcode) transcode_cleanup(st->xcode); else { free(st->buf); close(st->fd); } free(st); } static void stream_up_playcount(struct stream_ctx *st) { int ret; if (!st->marked && (st->stream_size > ((st->size * 50) / 100)) && (st->offset > ((st->size * 80) / 100))) { ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Could not acquire database connection; cannot increase playcount\n"); return; } st->marked = 1; db_file_inc_playcount(st->id); db_pool_release(); } } static int stream_get_chunk_xcode(struct stream_ctx *st) { int xcoded; int ret; consume: xcoded = transcode(st->xcode, st->evbuf, STREAM_CHUNK_SIZE); if (xcoded == 0) { DPRINTF(E_LOG, L_HTTPD, "Done streaming transcoded file id %d\n", st->id); return 0; } else if (xcoded < 0) { DPRINTF(E_LOG, L_HTTPD, "Transcoding error, file id %d\n", st->id); return -1; } DPRINTF(E_DBG, L_HTTPD, "Got %d bytes from transcode; streaming file id %d\n", xcoded, st->id); /* Consume transcoded data until we meet start_offset */ if (st->start_offset > st->offset) { ret = st->start_offset - st->offset; if (ret < xcoded) { evbuffer_drain(st->evbuf, ret); st->offset += ret; ret = xcoded - ret; } else { evbuffer_drain(st->evbuf, xcoded); st->offset += xcoded; goto consume; } } else ret = xcoded; st->offset += ret; return 0; } static int stream_get_chunk_raw(struct stream_ctx *st) { size_t chunk_size; int ret; if (st->end_offset && (st->offset > st->end_offset)) return 0; if (st->end_offset && ((st->offset + STREAM_CHUNK_SIZE) > (st->end_offset + 1))) chunk_size = st->end_offset + 1 - st->offset; else chunk_size = STREAM_CHUNK_SIZE; ret = read(st->fd, st->buf, chunk_size); if (ret == 0) { DPRINTF(E_LOG, L_HTTPD, "Done streaming file id %d\n", st->id); return 0; } else if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Streaming error, file id %d\n", st->id); return -1; } DPRINTF(E_DBG, L_HTTPD, "Read %d bytes; streaming file id %d\n", ret, st->id); st->offset += ret; ret = evbuffer_add(st->evbuf, st->buf, ret); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Out of memory for raw streaming evbuffer\n"); return -1; } return 0; } static struct evbuffer * stream_chunk_cb(struct http_connection *c, struct http_response *r, void *data) { struct stream_ctx *st; struct evbuffer *evbuf; int ret; st = (struct stream_ctx *)data; if (st->xcode) ret = stream_get_chunk_xcode(st); else ret = stream_get_chunk_raw(st); if (ret < 0) return NULL; if (EVBUFFER_LENGTH(st->evbuf) == 0) { ret = http_server_response_end_chunked(c, r); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Failed to terminate chunked response properly!\n"); stream_chunk_free_cb(st); return NULL; } /* Buffer will be freed by the server */ evbuf = st->evbuf; st->evbuf = NULL; return evbuf; } stream_up_playcount(st); return st->evbuf; } int httpd_stream_file(struct http_connection *c, struct http_request *req, struct http_response *r, int id) { struct stat sb; struct media_file_info *mfi; struct stream_ctx *st; const char *param; const char *param_end; char buf[64]; int64_t offset; int64_t end_offset; off_t pos; int transcode; int ret; offset = 0; end_offset = 0; param = http_request_get_header(req, "Range"); if (param) { DPRINTF(E_DBG, L_HTTPD, "Found Range header: %s\n", param); /* Start offset */ ret = safe_atoi64(param + strlen("bytes="), &offset); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Invalid start offset, will stream whole file (%s)\n", param); offset = 0; } /* End offset, if any */ else { param_end = strchr(param, '-'); if (param_end) { ret = safe_atoi64(param_end + 1, &end_offset); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Invalid end offset, will stream to end of file (%s)\n", param); end_offset = 0; } if (end_offset < offset) { DPRINTF(E_LOG, L_HTTPD, "End offset < start offset, will stream to end of file (%" PRIi64 " < %" PRIi64 ")\n", end_offset, offset); end_offset = 0; } } } } /* Caller must have obtained a database connection from the pool */ mfi = db_file_fetch_byid(id); if (!mfi) { DPRINTF(E_LOG, L_HTTPD, "Item %d not found\n", id); return http_server_error_run(c, r, HTTP_NOT_FOUND, "Not Found"); } if (mfi->data_kind != 0) { ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Cannot stream radio station"); goto out_free_mfi; } st = (struct stream_ctx *)malloc(sizeof(struct stream_ctx)); if (!st) { DPRINTF(E_LOG, L_HTTPD, "Out of memory for struct stream_ctx\n"); ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_free_mfi; } memset(st, 0, sizeof(struct stream_ctx)); st->fd = -1; transcode = transcode_needed(req, mfi->codectype); if (transcode) { DPRINTF(E_INFO, L_HTTPD, "Preparing to transcode %s\n", mfi->path); st->xcode = transcode_setup(mfi, &st->size, 1); if (!st->xcode) { DPRINTF(E_WARN, L_HTTPD, "Transcoding setup failed, aborting streaming\n"); ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_free_st; } if (!http_response_get_header(r, "Content-Type")) http_response_add_header(r, "Content-Type", "audio/wav"); } else { /* Stream the raw file */ DPRINTF(E_INFO, L_HTTPD, "Preparing to stream %s\n", mfi->path); st->buf = (uint8_t *)malloc(STREAM_CHUNK_SIZE); if (!st->buf) { DPRINTF(E_LOG, L_HTTPD, "Out of memory for raw streaming buffer\n"); ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_free_st; } st->fd = open(mfi->path, O_RDONLY); if (st->fd < 0) { DPRINTF(E_LOG, L_HTTPD, "Could not open %s: %s\n", mfi->path, strerror(errno)); ret = http_server_error_run(c, r, HTTP_NOT_FOUND, "Not Found"); goto out_cleanup; } ret = stat(mfi->path, &sb); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Could not stat() %s: %s\n", mfi->path, strerror(errno)); ret = http_server_error_run(c, r, HTTP_NOT_FOUND, "Not Found"); goto out_cleanup; } st->size = sb.st_size; pos = lseek(st->fd, offset, SEEK_SET); if (pos == (off_t) -1) { DPRINTF(E_LOG, L_HTTPD, "Could not seek into %s: %s\n", mfi->path, strerror(errno)); ret = http_server_error_run(c, r, HTTP_BAD_REQUEST, "Bad Request"); goto out_cleanup; } st->offset = offset; st->end_offset = end_offset; /* Content-Type for video files is different than for audio files * and overrides whatever may have been set previously, like * application/x-dmap-tagged when we're speaking DAAP. */ if (mfi->has_video) { /* Front Row and others expect video/ */ ret = snprintf(buf, sizeof(buf), "video/%s", mfi->type); if ((ret < 0) || (ret >= sizeof(buf))) DPRINTF(E_LOG, L_HTTPD, "Content-Type too large for buffer, dropping\n"); else { http_response_remove_header(r, "Content-Type"); http_response_add_header(r, "Content-Type", buf); } } /* If no Content-Type has been set and we're streaming audio, add a proper * Content-Type for the file we're streaming. Remember DAAP streams audio * with application/x-dmap-tagged as the Content-Type (ugh!). */ else if (!http_response_get_header(r, "Content-Type") && mfi->type) { ret = snprintf(buf, sizeof(buf), "audio/%s", mfi->type); if ((ret < 0) || (ret >= sizeof(buf))) DPRINTF(E_LOG, L_HTTPD, "Content-Type too large for buffer, dropping\n"); else http_response_add_header(r, "Content-Type", buf); } } st->evbuf = evbuffer_new(); if (!st->evbuf) { DPRINTF(E_LOG, L_HTTPD, "Could not allocate an evbuffer for streaming\n"); goto out_error; } ret = evbuffer_expand(st->evbuf, STREAM_CHUNK_SIZE); if (ret != 0) { DPRINTF(E_LOG, L_HTTPD, "Could not expand evbuffer for streaming\n"); goto out_error; } st->id = mfi->id; st->start_offset = offset; st->stream_size = st->size; if ((offset == 0) && (end_offset == 0)) { /* If we are not decoding, send the Content-Length. We don't do * that if we are decoding because we can only guesstimate the * size in this case and the error margin is unknown and variable. */ if (!transcode) { ret = snprintf(buf, sizeof(buf), "%" PRIi64, (int64_t)st->size); if ((ret < 0) || (ret >= sizeof(buf))) DPRINTF(E_LOG, L_HTTPD, "Content-Length too large for buffer, dropping\n"); else http_response_add_header(r, "Content-Length", buf); } ret = http_response_set_status(r, HTTP_OK, "OK"); } else { if (offset > 0) st->stream_size -= offset; if (end_offset > 0) st->stream_size -= (st->size - end_offset); DPRINTF(E_DBG, L_HTTPD, "Stream request with range %" PRIi64 "-%" PRIi64 "\n", offset, end_offset); ret = snprintf(buf, sizeof(buf), "bytes %" PRIi64 "-%" PRIi64 "/%" PRIi64, offset, (end_offset) ? end_offset : (int64_t)st->size, (int64_t)st->size); if ((ret < 0) || (ret >= sizeof(buf))) DPRINTF(E_LOG, L_HTTPD, "Content-Range too large for buffer, dropping\n"); else http_response_add_header(r, "Content-Range", buf); ret = snprintf(buf, sizeof(buf), "%" PRIi64, ((end_offset) ? end_offset + 1 : (int64_t)st->size) - offset); if ((ret < 0) || (ret >= sizeof(buf))) DPRINTF(E_LOG, L_HTTPD, "Content-Length too large for buffer, dropping\n"); else http_response_add_header(r, "Content-Length", buf); ret = http_response_set_status(r, HTTP_PARTIAL_CONTENT, "Partial Content"); } /* http_response_set_status() retval */ if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Could not set status on streaming response\n"); goto out_error; } #ifdef HAVE_POSIX_FADVISE if (!transcode) { /* Hint the OS */ posix_fadvise(st->fd, st->start_offset, st->stream_size, POSIX_FADV_WILLNEED); posix_fadvise(st->fd, st->start_offset, st->stream_size, POSIX_FADV_SEQUENTIAL); posix_fadvise(st->fd, st->start_offset, st->stream_size, POSIX_FADV_NOREUSE); } #endif /* Get first chunk */ if (transcode) ret = stream_get_chunk_xcode(st); else ret = stream_get_chunk_raw(st); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Could not obtain first chunk for streaming\n"); goto out_error; } /* Empty response */ if (EVBUFFER_LENGTH(st->evbuf) == 0) { DPRINTF(E_INFO, L_HTTPD, "Empty streaming response\n"); ret = http_server_response_run(c, r); if (ret < 0) goto out_error; /* Nothing more to do */ goto out_cleanup; } /* Start streaming */ ret = http_server_response_run_chunked(c, r, st->evbuf, stream_chunk_cb, stream_chunk_free_cb, st); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Could not start chunked response for streaming\n"); goto out_error; } DPRINTF(E_INFO, L_HTTPD, "Kicking off streaming for %s\n", mfi->path); free_mfi(mfi, 0); return 0; out_error: ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); out_cleanup: if (st->evbuf) evbuffer_free(st->evbuf); if (st->xcode) transcode_cleanup(st->xcode); if (st->buf) free(st->buf); if (st->fd > 0) close(st->fd); out_free_st: free(st); out_free_mfi: free_mfi(mfi, 0); return ret; } int httpd_send_reply(struct http_connection *c, struct http_request *req, struct http_response *r, struct evbuffer *evbuf) { unsigned char outbuf[128 * 1024]; z_stream strm; struct evbuffer *gzbuf; const char *param; int flush; int zret; int ret; if (!evbuf || (EVBUFFER_LENGTH(evbuf) == 0)) { DPRINTF(E_DBG, L_HTTPD, "Not gzipping body-less reply\n"); goto no_gzip; } param = http_request_get_header(req, "Accept-Encoding"); if (!param) { DPRINTF(E_DBG, L_HTTPD, "Not gzipping; no Accept-Encoding header\n"); goto no_gzip; } else if (!strstr(param, "gzip") && !strstr(param, "*")) { DPRINTF(E_DBG, L_HTTPD, "Not gzipping; gzip not in Accept-Encoding (%s)\n", param); goto no_gzip; } gzbuf = evbuffer_new(); if (!gzbuf) { DPRINTF(E_LOG, L_HTTPD, "Could not allocate evbuffer for gzipped reply\n"); goto no_gzip; } strm.zalloc = Z_NULL; strm.zfree = Z_NULL; strm.opaque = Z_NULL; /* Set up a gzip stream (the "+ 16" in 15 + 16), instead of a zlib stream (default) */ zret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION, Z_DEFLATED, 15 + 16, 8, Z_DEFAULT_STRATEGY); if (zret != Z_OK) { DPRINTF(E_DBG, L_HTTPD, "zlib setup failed: %s\n", zError(zret)); goto out_fail_init; } strm.next_in = EVBUFFER_DATA(evbuf); strm.avail_in = EVBUFFER_LENGTH(evbuf); flush = Z_NO_FLUSH; /* 2 iterations: Z_NO_FLUSH until input is consumed, then Z_FINISH */ for (;;) { do { strm.next_out = outbuf; strm.avail_out = sizeof(outbuf); zret = deflate(&strm, flush); if (zret == Z_STREAM_ERROR) { DPRINTF(E_LOG, L_HTTPD, "Could not deflate data: %s\n", strm.msg); goto out_fail_gz; } ret = evbuffer_add(gzbuf, outbuf, sizeof(outbuf) - strm.avail_out); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Out of memory adding gzipped data to evbuffer\n"); goto out_fail_gz; } } while (strm.avail_out == 0); if (flush == Z_FINISH) break; flush = Z_FINISH; } if (zret != Z_STREAM_END) { DPRINTF(E_LOG, L_HTTPD, "Compressed data not finalized!\n"); goto out_fail_gz; } deflateEnd(&strm); ret = http_response_add_header(r, "Content-Encoding", "gzip"); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Out of memory for Content-Encoding: gzip header, not gzipping\n"); evbuffer_free(gzbuf); goto no_gzip; } http_response_set_body(r, gzbuf); evbuffer_free(evbuf); ret = http_server_response_run(c, r); if (ret < 0) return http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); return 0; out_fail_gz: deflateEnd(&strm); out_fail_init: evbuffer_free(gzbuf); no_gzip: http_response_set_body(r, evbuf); ret = http_server_response_run(c, r); if (ret < 0) return http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); return 0; } static int path_is_legal(char *path) { return strncmp(WEBFACE_ROOT, path, strlen(WEBFACE_ROOT)); } static int redirect_to_index(struct http_connection *c, struct http_response *r, char *uri) { char buf[256]; int slashed; int ret; slashed = (uri[strlen(uri) - 1] == '/'); ret = snprintf(buf, sizeof(buf), "%s%sindex.html", uri, (slashed) ? "" : "/"); if ((ret < 0) || (ret >= sizeof(buf))) { DPRINTF(E_LOG, L_HTTPD, "Redirection URL exceeds buffer length\n"); return http_server_error_run(c, r, HTTP_NOT_FOUND, "Not Found"); } ret = http_response_add_header(r, "Location", buf); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Out of memory for Location header\n"); goto out_error; } ret = http_response_set_status(r, HTTP_MOVE_TEMP, "Moved"); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Out of memory for response reason\n"); goto out_error; } ret = http_server_response_run(c, r); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Failed to run redirect response\n"); goto out_error; } return 0; out_error: return http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int serve_file(struct http_connection *c, struct http_request *req, struct http_response *r, char *uri) { char path[PATH_MAX]; char remote_host[NCONN_ADDRSTRLEN]; char *ext; char *deref; char *ctype; char *passwd; struct evbuffer *evbuf; struct stat sb; int fd; int i; int ret; /* Check authentication */ passwd = cfg_getstr(cfg_getsec(cfg, "general"), "admin_password"); if (passwd) { DPRINTF(E_DBG, L_HTTPD, "Checking web interface authentication\n"); ret = httpd_basic_auth(c, req, r, "admin", passwd, PACKAGE " web interface"); switch (ret) { case HTTP_OK: DPRINTF(E_DBG, L_HTTPD, "Authentication successful\n"); break; case -1: /* Kill connection */ return -1; default: /* HTTP_UNAUTHORIZED or HTTP_INTERNAL_ERROR on error */ return 0; } } else { remote_host[0] = '\0'; http_connection_get_remote_addr(c, remote_host); if ((strcmp(remote_host, "::1") != 0) && (strcmp(remote_host, "127.0.0.1") != 0)) { DPRINTF(E_LOG, L_HTTPD, "Remote web interface request denied; no password set\n"); return http_server_error_run(c, r, HTTP_FORBIDDEN, "Forbidden"); } } ret = snprintf(path, sizeof(path), "%s%s", WEBFACE_ROOT, uri + 1); /* skip starting '/' */ if ((ret < 0) || (ret >= sizeof(path))) { DPRINTF(E_LOG, L_HTTPD, "Request exceeds PATH_MAX: %s\n", uri); goto out_notfound; } ret = lstat(path, &sb); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Could not lstat() %s: %s\n", path, strerror(errno)); goto out_notfound; } if (S_ISDIR(sb.st_mode)) return redirect_to_index(c, r, uri); else if (S_ISLNK(sb.st_mode)) { deref = m_realpath(path); if (!deref) { DPRINTF(E_LOG, L_HTTPD, "Could not dereference %s: %s\n", path, strerror(errno)); goto out_notfound; } if (strlen(deref) + 1 > PATH_MAX) { DPRINTF(E_LOG, L_HTTPD, "Dereferenced path exceeds PATH_MAX: %s\n", path); free(deref); goto out_notfound; } strcpy(path, deref); free(deref); ret = stat(path, &sb); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Could not stat() %s: %s\n", path, strerror(errno)); goto out_notfound; } if (S_ISDIR(sb.st_mode)) return redirect_to_index(c, r, uri); } if (path_is_legal(path) != 0) return http_server_error_run(c, r, HTTP_FORBIDDEN, "Forbidden"); fd = open(path, O_RDONLY); if (fd < 0) { DPRINTF(E_LOG, L_HTTPD, "Could not open %s: %s\n", path, strerror(errno)); goto out_notfound; } evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_HTTPD, "Could not create evbuffer\n"); close(fd); goto out_unavail; } /* FIXME: this is broken, if we ever need to serve files here, * this must be fixed. */ ret = evbuffer_read(evbuf, fd, sb.st_size); close(fd); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Could not read file into evbuffer\n"); evbuffer_free(evbuf); goto out_unavail; } http_response_set_body(r, evbuf); ctype = "application/octet-stream"; ext = strrchr(path, '.'); if (ext) { for (i = 0; ext2ctype[i].ext; i++) { if (strcmp(ext, ext2ctype[i].ext) == 0) { ctype = ext2ctype[i].ctype; break; } } } ret = http_response_add_header(r, "Content-Type", ctype); if (ret < 0) goto out_unavail; ret = http_response_set_status(r, HTTP_OK, "OK"); if (ret < 0) goto out_unavail; ret = http_server_response_run(c, r); if (ret < 0) { DPRINTF(E_LOG, L_HTTPD, "Failed to serve file %s: could not run response\n", path); goto out_unavail; } return 0; out_unavail: return http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); out_notfound: return http_server_error_run(c, r, HTTP_NOT_FOUND, "Not Found"); } static void httpd_close_cb(struct http_server *srv, void *data) { if (srv == http4) { DPRINTF(E_LOG, L_HTTPD, "v4 HTTP server failure!\n"); http4 = NULL; } else { DPRINTF(E_LOG, L_HTTPD, "v6 HTTP server failure!\n"); http6 = NULL; } http_server_free(srv); } /* Queue: c->queue (read queue) */ static int httpd_cb(struct http_connection *c, struct http_request *req, struct http_response *r, void *data) { const char *req_uri; char *uri; char *ptr; int ret; req_uri = http_request_get_uri(req); if (!req_uri) return redirect_to_index(c, r, "/"); uri = strdup(req_uri); ptr = strchr(uri, '?'); if (ptr) { DPRINTF(E_DBG, L_HTTPD, "Found query string\n"); *ptr = '\0'; } http_decode_uri(uri, URI_DECODE_NORMAL); /* Dispatch protocol-specific URIs */ if (rsp_is_request(uri)) { free(uri); return rsp_request(c, req, r); } else if (daap_is_request(uri)) { free(uri); return daap_request(c, req, r); } else if (dacp_is_request(uri)) { free(uri); return dacp_request(c, req, r); } DPRINTF(E_DBG, L_HTTPD, "HTTP request: %s\n", uri); /* Serve web interface files */ ret = serve_file(c, req, r, uri); free(uri); return ret; } char * httpd_fixup_uri(struct http_request *req) { const char *ua; const char *uri; const char *u; const char *q; char *fixed; char *f; int len; uri = http_request_get_uri(req); if (!uri) return NULL; /* No query string, nothing to do */ q = strchr(uri, '?'); if (!q) return strdup(uri); ua = http_request_get_header(req, "User-Agent"); if (!ua) return strdup(uri); if ((strncmp(ua, "iTunes", strlen("iTunes")) != 0) && (strncmp(ua, "Remote", strlen("Remote")) != 0) && (strncmp(ua, "Roku", strlen("Roku")) != 0)) return strdup(uri); /* Reencode + as %2B and space as + in the query, which iTunes and Roku devices don't do */ len = strlen(uri); u = q; while (*u) { if (*u == '+') len += 2; u++; } fixed = (char *)malloc(len + 1); if (!fixed) return NULL; strncpy(fixed, uri, q - uri); f = fixed + (q - uri); while (*q) { switch (*q) { case '+': *f = '%'; f++; *f = '2'; f++; *f = 'B'; break; case ' ': *f = '+'; break; default: *f = *q; break; } q++; f++; } *f = '\0'; return fixed; } static const char *http_reply_401 = "401 UnauthorizedAuthorization required"; int httpd_basic_auth(struct http_connection *c, struct http_request *req, struct http_response *r, char *user, char *passwd, char *realm) { struct evbuffer *evbuf; char *header; const char *auth; char *authuser; char *authpwd; int len; int ret; auth = http_request_get_header(req, "Authorization"); if (!auth) { DPRINTF(E_DBG, L_HTTPD, "No Authorization header\n"); goto need_auth; } if (strncmp(auth, "Basic ", strlen("Basic ")) != 0) { DPRINTF(E_LOG, L_HTTPD, "Bad Authentication header\n"); goto need_auth; } auth += strlen("Basic "); authuser = b64_decode(auth); if (!authuser) { DPRINTF(E_LOG, L_HTTPD, "Could not decode Authentication header\n"); goto need_auth; } authpwd = strchr(authuser, ':'); if (!authpwd) { DPRINTF(E_LOG, L_HTTPD, "Malformed Authentication header\n"); free(authuser); goto need_auth; } *authpwd = '\0'; authpwd++; if (user) { if (strcmp(user, authuser) != 0) { DPRINTF(E_LOG, L_HTTPD, "Username mismatch\n"); free(authuser); goto need_auth; } } if (strcmp(passwd, authpwd) != 0) { DPRINTF(E_LOG, L_HTTPD, "Bad password\n"); free(authuser); goto need_auth; } free(authuser); return HTTP_OK; need_auth: len = strlen(realm) + strlen("Basic realm=") + 3; header = (char *)malloc(len); if (!header) goto out_error; ret = snprintf(header, len, "Basic realm=\"%s\"", realm); if ((ret < 0) || (ret >= len)) goto out_error; ret = http_response_add_header(r, "WWW-Authenticate", header); free(header); if (ret < 0) goto out_error; ret = http_response_set_status(r, HTTP_UNAUTHORIZED, "Unauthorized"); if (ret < 0) goto out_error; evbuf = evbuffer_new(); if (!evbuf) goto out_error; evbuffer_add(evbuf, http_reply_401, strlen(http_reply_401)); http_response_set_body(r, evbuf); ret = http_server_response_run(c, r); if (ret < 0) goto out_error; return HTTP_UNAUTHORIZED; out_error: ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); if (ret < 0) return -1; return HTTP_INTERNAL_ERROR; } /* Thread: main */ int httpd_init(void) { unsigned short port; int v6enabled; int ret; port = cfg_getint(cfg_getsec(cfg, "library"), "port"); v6enabled = cfg_getbool(cfg_getsec(cfg, "general"), "ipv6"); http6 = NULL; http_group = dispatch_group_create(); if (!http_group) { DPRINTF(E_FATAL, L_HTTPD, "Could not create dispatch group for HTTP servers\n"); return -1; } http4 = http_server_new(L_HTTPD, http_group, "0.0.0.0", port, httpd_cb, httpd_close_cb); if (!http4) { DPRINTF(E_FATAL, L_HTTPD, "Could not create v4 HTTP server\n"); goto http4_fail; } if (v6enabled) { http6 = http_server_new(L_HTTPD, http_group, "::", port, httpd_cb, httpd_close_cb); if (!http6) DPRINTF(E_WARN, L_HTTPD, "Could not create v6 HTTP server; that's OK\n"); } ret = rsp_init(); if (ret < 0) { DPRINTF(E_FATAL, L_HTTPD, "RSP protocol init failed\n"); goto rsp_fail; } ret = daap_init(); if (ret < 0) { DPRINTF(E_FATAL, L_HTTPD, "DAAP protocol init failed\n"); goto daap_fail; } ret = dacp_init(); if (ret < 0) { DPRINTF(E_FATAL, L_HTTPD, "DACP protocol init failed\n"); goto dacp_fail; } ret = http_server_start(http4); if (ret < 0) { DPRINTF(E_FATAL, L_HTTPD, "Failed to start v4 HTTP server\n"); goto start_fail; } if (!http6) return 0; ret = http_server_start(http6); if (ret < 0) { DPRINTF(E_WARN, L_HTTPD, "Failed to start v6 HTTP server; that's OK\n"); http_server_free(http6); http6 = NULL; } return 0; start_fail: dacp_deinit(); dacp_fail: daap_deinit(); daap_fail: rsp_deinit(); rsp_fail: if (http6) http_server_free(http6); http_server_free(http4); /* Wait for shutdown completion for both servers */ ret = dispatch_group_wait(http_group, DISPATCH_TIME_FOREVER); if (ret != 0) DPRINTF(E_LOG, L_HTTPD, "Error waiting for dispatch group\n"); http4_fail: dispatch_release(http_group); return -1; } /* Thread: main */ void httpd_deinit(void) { int ret; if (http6) http_server_free(http6); if (http4) http_server_free(http4); DPRINTF(E_INFO, L_HTTPD, "Waiting for HTTP servers to shut down...\n"); ret = dispatch_group_wait(http_group, DISPATCH_TIME_FOREVER); dispatch_release(http_group); if (ret != 0) DPRINTF(E_LOG, L_HTTPD, "Error waiting for dispatch group\n"); rsp_deinit(); dacp_deinit(); daap_deinit(); } forked-daapd-0.19gcd/src/httpd.h0000664000175000017500000000147211633141135016067 0ustar julienjulien #ifndef __HTTPD_H__ #define __HTTPD_H__ #include "evbuffer/evbuffer.h" #include "http.h" struct httpd_hdl { struct http_connection *c; struct http_request *req; struct http_response *r; struct keyval *query; }; int httpd_stream_file(struct http_connection *c, struct http_request *req, struct http_response *r, int id); int httpd_send_reply(struct http_connection *c, struct http_request *req, struct http_response *r, struct evbuffer *evbuf); int httpd_send_error(struct http_connection *c, struct http_response *r, int code, char *reason); char * httpd_fixup_uri(struct http_request *req); int httpd_basic_auth(struct http_connection *c, struct http_request *req, struct http_response *r, char *user, char *passwd, char *realm); int httpd_init(void); void httpd_deinit(void); #endif /* !__HTTPD_H__ */ forked-daapd-0.19gcd/src/httpd_daap.c0000664000175000017500000020075711633141135017056 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * Copyright (C) 2010 Kai Elwert * * Adapted from mt-daapd: * Copyright (C) 2003-2007 Ron Pedde * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "evbuffer/evbuffer.h" #include "logger.h" #include "db.h" #include "conffile.h" #include "misc.h" #include "http.h" #include "httpd.h" #include "transcode.h" #include "artwork.h" #include "httpd_daap.h" #include "daap_query.h" #include "dmap_common.h" /* Session timeout in seconds */ #define DAAP_SESSION_TIMEOUT 1800 /* Update requests refresh interval in seconds */ #define DAAP_UPDATE_REFRESH 300 struct uri_map { regex_t preg; char *regexp; int (*handler)(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri); }; struct daap_session { int id; dispatch_source_t timeout; }; struct daap_update_request { struct http_connection *c; struct http_request *req; struct http_response *r; /* Refresh tiemout */ dispatch_source_t timeout; struct daap_update_request *next; }; struct sort_ctx { struct evbuffer *headerlist; int16_t mshc; uint32_t mshi; uint32_t mshn; uint32_t misc_mshn; }; /* Default meta tags if not provided in the query */ static char *default_meta_plsongs = "dmap.itemkind,dmap.itemid,dmap.itemname,dmap.containeritemid,dmap.parentcontainerid"; static char *default_meta_pl = "dmap.itemid,dmap.itemname,dmap.persistentid,com.apple.itunes.smart-playlist"; static char *default_meta_group = "dmap.itemname,dmap.persistentid,daap.songalbumartist"; /* DAAP session tracking */ static dispatch_queue_t sessions_sq; static avl_tree_t *daap_sessions; static int next_session_id; /* Update requests */ static int current_rev; static dispatch_queue_t updates_sq; static struct daap_update_request *update_requests; /* Session handling */ static int daap_session_compare(const void *aa, const void *bb) { struct daap_session *a = (struct daap_session *)aa; struct daap_session *b = (struct daap_session *)bb; if (a->id < b->id) return -1; if (a->id > b->id) return 1; return 0; } /* Queue: sessions_sq */ static void daap_session_free(void *item) { struct daap_session *s; s = (struct daap_session *)item; dispatch_source_cancel(s->timeout); dispatch_release(s->timeout); free(s); } /* Queue: sessions_sq or HTTP read queue */ static void daap_session_kill(struct daap_session *s) { if (dispatch_get_current_queue() == sessions_sq) avl_delete(daap_sessions, s); else dispatch_sync(sessions_sq, ^{ avl_delete(daap_sessions, s); }); } /* Queue: sessions_sq */ static void daap_session_timeout_cb(void *arg) { struct daap_session *s; s = (struct daap_session *)arg; DPRINTF(E_DBG, L_DAAP, "Session %d timed out\n", s->id); daap_session_kill(s); } /* Queue: HTTP read queue */ static struct daap_session * daap_session_register(void) { struct daap_session *s; __block int b_ret; s = (struct daap_session *)malloc(sizeof(struct daap_session)); if (!s) { DPRINTF(E_LOG, L_DAAP, "Out of memory for DAAP session\n"); return NULL; } memset(s, 0, sizeof(struct daap_session)); s->timeout = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, sessions_sq); if (!s->timeout) { DPRINTF(E_LOG, L_DAAP, "Could not create dispatch source for session timeout\n"); free(s); return NULL; } dispatch_set_context(s->timeout, s); dispatch_source_set_event_handler_f(s->timeout, daap_session_timeout_cb); dispatch_source_set_timer(s->timeout, dispatch_time(DISPATCH_TIME_NOW, DAAP_SESSION_TIMEOUT * NSEC_PER_SEC), DISPATCH_TIME_FOREVER /* one-shot */, 30 * NSEC_PER_SEC); dispatch_sync(sessions_sq, ^{ avl_node_t *node; s->id = next_session_id; next_session_id++; node = avl_insert(daap_sessions, s); if (!node) { DPRINTF(E_LOG, L_DAAP, "Could not register DAAP session: %s\n", strerror(errno)); b_ret = -1; return; } dispatch_resume(s->timeout); b_ret = 0; }); if (b_ret < 0) { free(s); return NULL; } return s; } /* Queue: HTTP read queue */ int daap_session_find(struct httpd_hdl *h, struct daap_session **s) { const char *param; int id; int ret; param = keyval_get(h->query, "session-id"); if (!param) { DPRINTF(E_WARN, L_DAAP, "No session-id specified in request\n"); goto invalid; } ret = safe_atoi32(param, &id); if (ret < 0) goto invalid; dispatch_sync(sessions_sq, ^{ struct daap_session needle; avl_node_t *node; needle.id = id; node = avl_search(daap_sessions, &needle); if (!node) { DPRINTF(E_WARN, L_DAAP, "DAAP session id %d not found\n", needle.id); *s = NULL; return; } *s = (struct daap_session *)node->item; dispatch_source_set_timer((*s)->timeout, dispatch_time(DISPATCH_TIME_NOW, DAAP_SESSION_TIMEOUT * NSEC_PER_SEC), DISPATCH_TIME_FOREVER /* one-shot */, 30 * NSEC_PER_SEC); }); if (!*s) goto invalid; return 0; invalid: return http_server_error_run(h->c, h->r, HTTP_FORBIDDEN, "Forbidden"); } /* Update requests helpers */ /* Queue: updates_sq */ static void update_remove(struct daap_update_request *ur) { struct daap_update_request *p; if (ur == update_requests) update_requests = ur->next; else { for (p = update_requests; p && (p->next != ur); p = p->next) ; if (!p) { DPRINTF(E_LOG, L_DAAP, "WARNING: struct daap_update_request not found in list; BUG!\n"); return; } p->next = ur->next; } } static void update_free(struct daap_update_request *ur) { dispatch_source_cancel(ur->timeout); dispatch_release(ur->timeout); free(ur); } /* Queue: updates_sq */ static void update_refresh_cb(void *arg) { struct daap_update_request *ur; struct evbuffer *evbuf; int ret; ur = (struct daap_update_request *)arg; evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_DAAP, "Could not allocate evbuffer for DAAP update data\n"); return; } ret = evbuffer_expand(evbuf, 32); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP update data\n"); return; } /* Send back current revision */ dmap_add_container(evbuf, "mupd", 24); dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_int(evbuf, "musr", current_rev); /* 12 */ ret = http_response_set_status(ur->r, HTTP_OK, "OK"); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not set response status for DAAP update\n"); evbuffer_free(evbuf); return; } http_response_set_body(ur->r, evbuf); ret = http_server_response_thaw_and_run(ur->c, ur->r); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not thaw and run response to DAAP update request\n"); http_server_kill_connection(ur->c); } update_remove(ur); update_free(ur); } /* Queue: updates_sq */ static void update_free_cb_task(void *arg) { struct daap_update_request *ur; ur = (struct daap_update_request *)arg; update_remove(ur); update_free(ur); } static void update_free_cb(void *data) { DPRINTF(E_DBG, L_DAAP, "Update request: connection closed\n"); dispatch_sync_f(updates_sq, data, update_free_cb_task); } /* DAAP sort headers helpers */ static struct sort_ctx * daap_sort_context_new(void) { struct sort_ctx *ctx; int ret; ctx = (struct sort_ctx *)malloc(sizeof(struct sort_ctx)); if (!ctx) { DPRINTF(E_LOG, L_DAAP, "Out of memory for sorting context\n"); return NULL; } memset(ctx, 0, sizeof(struct sort_ctx)); ctx->headerlist = evbuffer_new(); if (!ctx->headerlist) { DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DAAP sort headers list\n"); free(ctx); return NULL; } ret = evbuffer_expand(ctx->headerlist, 512); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP sort headers list\n"); evbuffer_free(ctx->headerlist); free(ctx); return NULL; } ctx->mshc = -1; return ctx; } static void daap_sort_context_free(struct sort_ctx *ctx) { evbuffer_free(ctx->headerlist); free(ctx); } static int daap_sort_build(struct sort_ctx *ctx, char *str) { uint8_t *ret; size_t len; char fl; len = strlen(str); ret = u8_normalize(UNINORM_NFD, (uint8_t *)str, len, NULL, &len); if (!ret) { DPRINTF(E_LOG, L_DAAP, "Could not normalize string for sort header\n"); return -1; } fl = ret[0]; free(ret); if (isascii(fl) && isalpha(fl)) { fl = toupper(fl); /* Init */ if (ctx->mshc == -1) ctx->mshc = fl; if (fl == ctx->mshc) ctx->mshn++; else { dmap_add_container(ctx->headerlist, "mlit", 34); dmap_add_short(ctx->headerlist, "mshc", ctx->mshc); /* 10 */ dmap_add_int(ctx->headerlist, "mshi", ctx->mshi); /* 12 */ dmap_add_int(ctx->headerlist, "mshn", ctx->mshn); /* 12 */ DPRINTF(E_DBG, L_DAAP, "Added sort header: mshc = %c, mshi = %u, mshn = %u fl %c\n", ctx->mshc, ctx->mshi, ctx->mshn, fl); ctx->mshi = ctx->mshi + ctx->mshn; ctx->mshn = 1; ctx->mshc = fl; } } else { /* Non-ASCII, goes to misc category */ ctx->misc_mshn++; } return 0; } static int daap_sort_finalize(struct sort_ctx *ctx, struct evbuffer *evbuf) { int ret; /* Add current entry, if any */ if (ctx->mshc != -1) { dmap_add_container(ctx->headerlist, "mlit", 34); dmap_add_short(ctx->headerlist, "mshc", ctx->mshc); /* 10 */ dmap_add_int(ctx->headerlist, "mshi", ctx->mshi); /* 12 */ dmap_add_int(ctx->headerlist, "mshn", ctx->mshn); /* 12 */ ctx->mshi = ctx->mshi + ctx->mshn; DPRINTF(E_DBG, L_DAAP, "Added sort header: mshc = %c, mshi = %u, mshn = %u (final)\n", ctx->mshc, ctx->mshi, ctx->mshn); } /* Add misc category */ dmap_add_container(ctx->headerlist, "mlit", 34); dmap_add_short(ctx->headerlist, "mshc", '0'); /* 10 */ dmap_add_int(ctx->headerlist, "mshi", ctx->mshi); /* 12 */ dmap_add_int(ctx->headerlist, "mshn", ctx->misc_mshn); /* 12 */ dmap_add_container(evbuf, "mshl", EVBUFFER_LENGTH(ctx->headerlist)); ret = evbuffer_add_buffer(evbuf, ctx->headerlist); if (ret < 0) return -1; return 0; } static void get_query_params(struct keyval *query, int *sort_headers, struct query_params *qp) { const char *param; char *ptr; int low; int high; int ret; low = 0; high = -1; /* No limit */ param = keyval_get(query, "index"); if (param) { if (param[0] == '-') /* -n, last n entries */ DPRINTF(E_LOG, L_DAAP, "Unsupported index range: %s\n", param); else { ret = safe_atoi32(param, &low); if (ret < 0) DPRINTF(E_LOG, L_DAAP, "Could not parse index range: %s\n", param); else { ptr = strchr(param, '-'); if (!ptr) /* single item */ high = low; else { ptr++; if (*ptr != '\0') /* low-high */ { ret = safe_atoi32(ptr, &high); if (ret < 0) DPRINTF(E_LOG, L_DAAP, "Could not parse high index in range: %s\n", param); } } } } DPRINTF(E_DBG, L_DAAP, "Index range %s: low %d, high %d (offset %d, limit %d)\n", param, low, high, qp->offset, qp->limit); } if (high < low) high = -1; /* No limit */ qp->offset = low; if (high < 0) qp->limit = -1; /* No limit */ else qp->limit = (high - low) + 1; qp->idx_type = I_SUB; qp->sort = S_NONE; param = keyval_get(query, "sort"); if (param) { if (strcmp(param, "name") == 0) qp->sort = S_NAME; else if (strcmp(param, "album") == 0) qp->sort = S_ALBUM; else if (strcmp(param, "artist") == 0) qp->sort = S_ARTIST; else DPRINTF(E_DBG, L_DAAP, "Unknown sort param: %s\n", param); if (qp->sort != S_NONE) DPRINTF(E_DBG, L_DAAP, "Sorting songlist by %s\n", param); } if (sort_headers) { *sort_headers = 0; param = keyval_get(query, "include-sort-headers"); if (param) { if (strcmp(param, "1") == 0) { *sort_headers = 1; DPRINTF(E_DBG, L_DAAP, "Sort headers requested\n"); } else DPRINTF(E_DBG, L_DAAP, "Unknown include-sort-headers param: %s\n", param); } } param = keyval_get(query, "query"); if (!param) param = keyval_get(query, "filter"); if (param) { DPRINTF(E_DBG, L_DAAP, "DAAP browse query filter: %s\n", param); qp->filter = daap_query_parse_sql(param); if (!qp->filter) DPRINTF(E_LOG, L_DAAP, "Ignoring improper DAAP query\n"); } } static int parse_meta(struct httpd_hdl *h, char *tag, const char *param, const struct dmap_field ***out_meta, int *out_nmeta) { const struct dmap_field **meta; char *ptr; char *field; char *metastr; int nmeta; int i; *out_nmeta = -1; metastr = strdup(param); if (!metastr) { DPRINTF(E_LOG, L_DAAP, "Could not duplicate meta parameter; out of memory\n"); return dmap_send_error(h, tag, "Out of memory"); } nmeta = 1; ptr = metastr; while ((ptr = strchr(ptr + 1, ','))) nmeta++; DPRINTF(E_DBG, L_DAAP, "Asking for %d meta tags\n", nmeta); meta = (const struct dmap_field **)malloc(nmeta * sizeof(const struct dmap_field *)); if (!meta) { DPRINTF(E_LOG, L_DAAP, "Could not allocate meta array; out of memory\n"); free(metastr); return dmap_send_error(h, tag, "Out of memory"); } memset(meta, 0, nmeta * sizeof(struct dmap_field *)); field = strtok_r(metastr, ",", &ptr); for (i = 0; i < nmeta; i++) { meta[i] = dmap_find_field(field, strlen(field)); if (!meta[i]) { DPRINTF(E_WARN, L_DAAP, "Could not find requested meta field '%s'\n", field); i--; nmeta--; } field = strtok_r(NULL, ",", &ptr); if (!field) break; } DPRINTF(E_DBG, L_DAAP, "Found %d meta tags\n", nmeta); *out_meta = meta; *out_nmeta = nmeta; free(metastr); return 0; } static int daap_reply_server_info(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { cfg_t *lib; char *name; char *passwd; const char *clientver; int mpro; int apro; int len; int ret; lib = cfg_getsec(cfg, "library"); passwd = cfg_getstr(lib, "password"); name = cfg_getstr(lib, "name"); len = 157 + strlen(name); ret = evbuffer_expand(evbuf, len); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP server-info reply\n"); evbuffer_free(evbuf); return dmap_send_error(h, "msrv", "Out of memory"); } mpro = 2 << 16; apro = 3 << 16; clientver = http_request_get_header(h->req, "Client-DAAP-Version"); if (clientver) { if (strcmp(clientver, "1.0") == 0) { mpro = 1 << 16; apro = 1 << 16; } else if (strcmp(clientver, "2.0") == 0) { mpro = 1 << 16; apro = 2 << 16; } } dmap_add_container(evbuf, "msrv", len - 8); dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_int(evbuf, "mpro", mpro); /* 12 */ dmap_add_int(evbuf, "apro", apro); /* 12 */ dmap_add_string(evbuf, "minm", name); /* 8 + strlen(name) */ dmap_add_int(evbuf, "mstm", DAAP_SESSION_TIMEOUT); /* 12 */ dmap_add_char(evbuf, "msal", 1); /* 9 */ dmap_add_char(evbuf, "mslr", 1); /* 9 */ dmap_add_char(evbuf, "msau", (passwd) ? 2 : 0); /* 9 */ dmap_add_char(evbuf, "msex", 1); /* 9 */ dmap_add_char(evbuf, "msix", 1); /* 9 */ dmap_add_char(evbuf, "msbr", 1); /* 9 */ dmap_add_char(evbuf, "msqy", 1); /* 9 */ dmap_add_char(evbuf, "mspi", 1); /* 9 */ dmap_add_int(evbuf, "msdc", 1); /* 12 */ /* Advertise updates support even though we don't send updates */ dmap_add_char(evbuf, "msup", 1); /* 9 */ ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { evbuffer_free(evbuf); return dmap_send_error(h, "msrv", "Server Error"); } return httpd_send_reply(h->c, h->req, h->r, evbuf); } static int daap_reply_content_codes(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { const struct dmap_field *dmap_fields; int nfields; int i; int len; int ret; dmap_fields = dmap_get_fields_table(&nfields); len = 12; for (i = 0; i < nfields; i++) len += 8 + 12 + 10 + 8 + strlen(dmap_fields[i].desc); ret = evbuffer_expand(evbuf, len + 8); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP content-codes reply\n"); evbuffer_free(evbuf); return dmap_send_error(h, "mccr", "Out of memory"); } dmap_add_container(evbuf, "mccr", len); dmap_add_int(evbuf, "mstt", 200); for (i = 0; i < nfields; i++) { len = 12 + 10 + 8 + strlen(dmap_fields[i].desc); dmap_add_container(evbuf, "mdcl", len); dmap_add_string(evbuf, "mcnm", dmap_fields[i].tag); /* 12 */ dmap_add_string(evbuf, "mcna", dmap_fields[i].desc); /* 8 + strlen(desc) */ dmap_add_short(evbuf, "mcty", dmap_fields[i].type); /* 10 */ } ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { evbuffer_free(evbuf); return dmap_send_error(h, "mccr", "Server Error"); } return httpd_send_reply(h->c, h->req, h->r, evbuf); } static int daap_reply_login(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct pairing_info pi; struct daap_session *s; const char *ua; const char *guid; int ret; ret = evbuffer_expand(evbuf, 32); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP login reply\n"); evbuffer_free(evbuf); return dmap_send_error(h, "mlog", "Out of memory"); } ua = http_request_get_header(h->req, "User-Agent"); if (!ua) { DPRINTF(E_LOG, L_DAAP, "No User-Agent header, rejecting login request\n"); evbuffer_free(evbuf); return http_server_error_run(h->c, h->r, HTTP_FORBIDDEN, "Forbidden"); } if (strncmp(ua, "Remote", strlen("Remote")) == 0) { guid = keyval_get(h->query, "pairing-guid"); if (!guid) { DPRINTF(E_LOG, L_DAAP, "Login attempt with U-A: Remote and no pairing-guid\n"); evbuffer_free(evbuf); return http_server_error_run(h->c, h->r, HTTP_FORBIDDEN, "Forbidden"); } memset(&pi, 0, sizeof(struct pairing_info)); pi.guid = strdup(guid + 2); /* Skip leading 0X */ ret = db_pairing_fetch_byguid(&pi); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Login attempt with invalid pairing-guid\n"); free_pi(&pi, 1); evbuffer_free(evbuf); return http_server_error_run(h->c, h->r, HTTP_FORBIDDEN, "Forbidden"); } DPRINTF(E_INFO, L_DAAP, "Remote '%s' logging in with GUID %s\n", pi.name, pi.guid); free_pi(&pi, 1); } s = daap_session_register(); if (!s) { evbuffer_free(evbuf); return dmap_send_error(h, "mlog", "Could not start session"); } dmap_add_container(evbuf, "mlog", 24); dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_int(evbuf, "mlid", s->id); /* 12 */ ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { evbuffer_free(evbuf); return dmap_send_error(h, "mlog", "Server Error"); } return httpd_send_reply(h->c, h->req, h->r, evbuf); } static int daap_reply_logout(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int ret; evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; daap_session_kill(s); ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "Logout Successful"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int daap_reply_update(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; struct daap_update_request *ur; const char *param; int reqd_rev; int ret; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } param = keyval_get(h->query, "revision-number"); if (!param) { DPRINTF(E_LOG, L_DAAP, "Missing revision-number in update request\n"); evbuffer_free(evbuf); return dmap_send_error(h, "mupd", "Invalid request"); } ret = safe_atoi32(param, &reqd_rev); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Parameter revision-number not an integer\n"); evbuffer_free(evbuf); return dmap_send_error(h, "mupd", "Invalid request"); } if (reqd_rev == 1) /* Or revision is not valid */ { ret = evbuffer_expand(evbuf, 32); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP update reply\n"); evbuffer_free(evbuf); return dmap_send_error(h, "mupd", "Out of memory"); } /* Send back current revision */ dmap_add_container(evbuf, "mupd", 24); dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_int(evbuf, "musr", current_rev); /* 12 */ ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { evbuffer_free(evbuf); return dmap_send_error(h, "mupd", "Internal error"); } return httpd_send_reply(h->c, h->req, h->r, evbuf); } evbuffer_free(evbuf); ur = (struct daap_update_request *)malloc(sizeof(struct daap_update_request)); if (!ur) { DPRINTF(E_LOG, L_DAAP, "Out of memory for update request\n"); return dmap_send_error(h, "mupd", "Out of memory"); } memset(ur, 0, sizeof(struct daap_update_request)); ur->timeout = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, updates_sq); if (!ur->timeout) { DPRINTF(E_LOG, L_DAAP, "Could not create dispatch source for update timeout\n"); free(ur); return dmap_send_error(h, "mupd", "Could not create timer"); } dispatch_set_context(ur->timeout, ur); dispatch_source_set_event_handler_f(ur->timeout, update_refresh_cb); dispatch_source_set_timer(ur->timeout, dispatch_time(DISPATCH_TIME_NOW, DAAP_UPDATE_REFRESH * NSEC_PER_SEC), DISPATCH_TIME_FOREVER /* one-shot */, 30 * NSEC_PER_SEC); /* Freeze the request */ http_server_response_freeze(h->c, h->r, update_free_cb, ur); /* NOTE: we may need to keep reqd_rev in there too */ ur->c = h->c; ur->req = h->req; ur->r = h->r; dispatch_sync(updates_sq, ^{ ur->next = update_requests; update_requests = ur; dispatch_resume(ur->timeout); }); return 0; } static int daap_reply_activity(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { int ret; evbuffer_free(evbuf); /* That's so nice, thanks for letting us know */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); ret = http_server_response_run(h->c, h->r); if (ret < 0) return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); return 0; } static int daap_reply_dblist(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; cfg_t *lib; char *name; int namelen; int count; int ret; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } lib = cfg_getsec(cfg, "library"); name = cfg_getstr(lib, "name"); namelen = strlen(name); ret = evbuffer_expand(evbuf, 129 + namelen); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP dblist reply\n"); evbuffer_free(evbuf); return dmap_send_error(h, "avdb", "Out of memory"); } dmap_add_container(evbuf, "avdb", 121 + namelen); dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_char(evbuf, "muty", 0); /* 9 */ dmap_add_int(evbuf, "mtco", 1); /* 12 */ dmap_add_int(evbuf, "mrco", 1); /* 12 */ dmap_add_container(evbuf, "mlcl", 68 + namelen); dmap_add_container(evbuf, "mlit", 60 + namelen); dmap_add_int(evbuf, "miid", 1); /* 12 */ dmap_add_long(evbuf, "mper", 1); /* 16 */ dmap_add_string(evbuf, "minm", name); /* 8 + namelen */ count = db_files_get_count(); dmap_add_int(evbuf, "mimc", count); /* 12 */ count = db_pl_get_count(); dmap_add_int(evbuf, "mctc", count); /* 12 */ ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { evbuffer_free(evbuf); return dmap_send_error(h, "aply", "Server Error"); } return httpd_send_reply(h->c, h->req, h->r, evbuf); } static int daap_reply_songlist_generic(struct httpd_hdl *h, struct evbuffer *evbuf, int playlist) { struct query_params qp; struct db_media_file_info dbmfi; struct evbuffer *song; struct evbuffer *songlist; const struct dmap_field **meta; struct sort_ctx *sctx; const char *param; char *tag; int nmeta; int sort_headers; int nsongs; int transcode; int ret; DPRINTF(E_DBG, L_DAAP, "Fetching song list for playlist %d\n", playlist); if (playlist != -1) tag = "apso"; /* Songs in playlist */ else tag = "adbs"; /* Songs in database */ ret = evbuffer_expand(evbuf, 61); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP song list reply\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_evbuf_free; } songlist = evbuffer_new(); if (!songlist) { DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP song list\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_evbuf_free; } /* Start with a big enough evbuffer - it'll expand as needed */ ret = evbuffer_expand(songlist, 4096); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP song list\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_list_free; } song = evbuffer_new(); if (!song) { DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP song block\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_list_free; } /* The buffer will expand if needed */ ret = evbuffer_expand(song, 512); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP song block\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_song_free; } param = keyval_get(h->query, "meta"); if (!param) { DPRINTF(E_DBG, L_DAAP, "No meta parameter in query, using default\n"); if (playlist != -1) param = default_meta_plsongs; } if (param) { ret = parse_meta(h, tag, param, &meta, &nmeta); if (nmeta < 0) { DPRINTF(E_LOG, L_DAAP, "Failed to parse meta parameter in DAAP query\n"); /* retval from parse_meta() */ goto out_song_free; } } else { meta = NULL; nmeta = 0; } memset(&qp, 0, sizeof(struct query_params)); get_query_params(h->query, &sort_headers, &qp); sctx = NULL; if (sort_headers) { sctx = daap_sort_context_new(); if (!sctx) { DPRINTF(E_LOG, L_DAAP, "Could not create sort context\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_query_free; } } if (playlist != -1) { qp.type = Q_PLITEMS; qp.id = playlist; } else qp.type = Q_ITEMS; ret = db_query_start(&qp); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not start query\n"); if (sort_headers) daap_sort_context_free(sctx); ret = dmap_send_error(h, tag, "Could not start query"); goto out_query_free; } nsongs = 0; while (((ret = db_query_fetch_file(&qp, &dbmfi)) == 0) && (dbmfi.id)) { nsongs++; transcode = transcode_needed(h->req, dbmfi.codectype); ret = dmap_encode_file_metadata(songlist, song, &dbmfi, meta, nmeta, 1, transcode); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Failed to encode song metadata\n"); ret = -100; break; } if (sort_headers) { ret = daap_sort_build(sctx, dbmfi.title_sort); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add sort header to DAAP song list reply\n"); ret = -100; break; } } DPRINTF(E_DBG, L_DAAP, "Done with song\n"); } DPRINTF(E_DBG, L_DAAP, "Done with song list, %d songs\n", nsongs); if (nmeta > 0) free(meta); evbuffer_free(song); if (qp.filter) free(qp.filter); if (ret < 0) { db_query_end(&qp); if (sort_headers) daap_sort_context_free(sctx); if (ret == -100) ret = dmap_send_error(h , tag, "Out of memory"); else { DPRINTF(E_LOG, L_DAAP, "Error fetching results\n"); ret = dmap_send_error(h, tag, "Error fetching query results"); } goto out_list_free; } /* Add header to evbuf, add songlist to evbuf */ if (sort_headers) dmap_add_container(evbuf, tag, EVBUFFER_LENGTH(songlist) + EVBUFFER_LENGTH(sctx->headerlist) + 53); else dmap_add_container(evbuf, tag, EVBUFFER_LENGTH(songlist) + 53); dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_char(evbuf, "muty", 0); /* 9 */ dmap_add_int(evbuf, "mtco", qp.results); /* 12 */ dmap_add_int(evbuf, "mrco", nsongs); /* 12 */ dmap_add_container(evbuf, "mlcl", EVBUFFER_LENGTH(songlist)); db_query_end(&qp); ret = evbuffer_add_buffer(evbuf, songlist); evbuffer_free(songlist); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add song list to DAAP song list reply\n"); if (sort_headers) daap_sort_context_free(sctx); ret = dmap_send_error(h, tag, "Out of memory"); goto out_evbuf_free; } if (sort_headers) { ret = daap_sort_finalize(sctx, evbuf); daap_sort_context_free(sctx); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add sort headers to DAAP song list reply\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_evbuf_free; } } ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { ret = dmap_send_error(h, "aply", "Server Error"); goto out_evbuf_free; } return httpd_send_reply(h->c, h->req, h->r, evbuf); out_query_free: if (nmeta > 0) free(meta); if (qp.filter) free(qp.filter); out_song_free: evbuffer_free(song); out_list_free: evbuffer_free(songlist); out_evbuf_free: evbuffer_free(evbuf); return ret; } static int daap_reply_dbsonglist(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int ret; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } return daap_reply_songlist_generic(h, evbuf, -1); } static int daap_reply_plsonglist(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int playlist; int ret; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } ret = safe_atoi32(uri[3], &playlist); if (ret < 0) { evbuffer_free(evbuf); return dmap_send_error(h, "apso", "Invalid playlist ID"); } return daap_reply_songlist_generic(h, evbuf, playlist); } static int daap_reply_playlists(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct query_params qp; struct db_playlist_info dbpli; struct daap_session *s; struct evbuffer *playlistlist; struct evbuffer *playlist; const struct dmap_field_map *dfm; const struct dmap_field *df; const struct dmap_field **meta; const char *param; char **strval; int nmeta; int npls; int32_t val; int i; int ret; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } ret = evbuffer_expand(evbuf, 61); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP playlists reply\n"); ret = dmap_send_error(h, "aply", "Out of memory"); goto out_evbuf_free; } playlistlist = evbuffer_new(); if (!playlistlist) { DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP playlist list\n"); ret = dmap_send_error(h, "aply", "Out of memory"); goto out_evbuf_free; } /* Start with a big enough evbuffer - it'll expand as needed */ ret = evbuffer_expand(playlistlist, 1024); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP playlist list\n"); ret = dmap_send_error(h, "aply", "Out of memory"); goto out_list_free; } playlist = evbuffer_new(); if (!playlist) { DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP playlist block\n"); ret = dmap_send_error(h, "aply", "Out of memory"); goto out_list_free; } /* The buffer will expand if needed */ ret = evbuffer_expand(playlist, 128); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP playlist block\n"); ret = dmap_send_error(h, "aply", "Out of memory"); goto out_pl_free; } param = keyval_get(h->query, "meta"); if (!param) { DPRINTF(E_LOG, L_DAAP, "No meta parameter in query, using default\n"); param = default_meta_pl; } ret = parse_meta(h, "aply", param, &meta, &nmeta); if (nmeta < 0) { DPRINTF(E_LOG, L_DAAP, "Failed to parse meta parameter in DAAP query\n"); /* retval from parse_meta() */ goto out_pl_free; } memset(&qp, 0, sizeof(struct query_params)); get_query_params(h->query, NULL, &qp); qp.type = Q_PL; ret = db_query_start(&qp); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not start query\n"); ret = dmap_send_error(h, "aply", "Could not start query"); goto out_query_free; } npls = 0; while (((ret = db_query_fetch_pl(&qp, &dbpli)) == 0) && (dbpli.id)) { npls++; for (i = 0; i < nmeta; i++) { df = meta[i]; dfm = df->dfm; /* dmap.itemcount - always added */ if (dfm == &dfm_dmap_mimc) continue; /* com.apple.itunes.smart-playlist - type = 1 AND id != 1 */ if (dfm == &dfm_dmap_aeSP) { val = 0; ret = safe_atoi32(dbpli.type, &val); if ((ret == 0) && (val == PL_SMART)) { val = 1; ret = safe_atoi32(dbpli.id, &val); if ((ret == 0) && (val != 1)) { int32_t aePS = 0; dmap_add_char(playlist, "aeSP", 1); ret = safe_atoi32(dbpli.special_id, &aePS); if ((ret == 0) && (aePS > 0)) dmap_add_char(playlist, "aePS", aePS); } } continue; } /* Not in struct playlist_info */ if (dfm->pli_offset < 0) continue; strval = (char **) ((char *)&dbpli + dfm->pli_offset); if (!(*strval) || (**strval == '\0')) continue; dmap_add_field(playlist, df, *strval, 0); DPRINTF(E_DBG, L_DAAP, "Done with meta tag %s (%s)\n", df->desc, *strval); } /* Item count (mimc) */ val = 0; ret = safe_atoi32(dbpli.items, &val); if ((ret == 0) && (val > 0)) dmap_add_int(playlist, "mimc", val); /* Container ID (mpco) */ dmap_add_int(playlist, "mpco", 0); /* Base playlist (abpl), id = 1 */ val = 0; ret = safe_atoi32(dbpli.id, &val); if ((ret == 0) && (val == 1)) dmap_add_char(playlist, "abpl", 1); DPRINTF(E_DBG, L_DAAP, "Done with playlist\n"); dmap_add_container(playlistlist, "mlit", EVBUFFER_LENGTH(playlist)); ret = evbuffer_add_buffer(playlistlist, playlist); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add playlist to playlist list for DAAP playlists reply\n"); ret = -100; break; } } DPRINTF(E_DBG, L_DAAP, "Done with playlist list, %d playlists\n", npls); free(meta); evbuffer_free(playlist); if (qp.filter) free(qp.filter); if (ret < 0) { db_query_end(&qp); if (ret == -100) ret = dmap_send_error(h, "aply", "Out of memory"); else { DPRINTF(E_LOG, L_DAAP, "Error fetching results\n"); ret = dmap_send_error(h, "aply", "Error fetching query results"); } goto out_list_free; } /* Add header to evbuf, add playlistlist to evbuf */ dmap_add_container(evbuf, "aply", EVBUFFER_LENGTH(playlistlist) + 53); dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_char(evbuf, "muty", 0); /* 9 */ dmap_add_int(evbuf, "mtco", qp.results); /* 12 */ dmap_add_int(evbuf,"mrco", npls); /* 12 */ dmap_add_container(evbuf, "mlcl", EVBUFFER_LENGTH(playlistlist)); db_query_end(&qp); ret = evbuffer_add_buffer(evbuf, playlistlist); evbuffer_free(playlistlist); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add playlist list to DAAP playlists reply\n"); ret = dmap_send_error(h, "aply", "Out of memory"); goto out_evbuf_free; } ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { ret = dmap_send_error(h, "aply", "Server Error"); goto out_evbuf_free; } return httpd_send_reply(h->c, h->req, h->r, evbuf); out_query_free: free(meta); if (qp.filter) free(qp.filter); out_pl_free: evbuffer_free(playlist); out_list_free: evbuffer_free(playlistlist); out_evbuf_free: evbuffer_free(evbuf); return ret; } static int daap_reply_groups(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct query_params qp; struct db_group_info dbgri; struct daap_session *s; struct evbuffer *group; struct evbuffer *grouplist; const struct dmap_field_map *dfm; const struct dmap_field *df; const struct dmap_field **meta; struct sort_ctx *sctx; const char *param; char **strval; int nmeta; int sort_headers; int ngrp; int32_t val; int i; int ret; char *tag; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } /* For now we only support album groups */ tag = "agal"; ret = evbuffer_expand(evbuf, 61); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP groups reply\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_evbuf_free; } grouplist = evbuffer_new(); if (!grouplist) { DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP group list\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_evbuf_free; } /* Start with a big enough evbuffer - it'll expand as needed */ ret = evbuffer_expand(grouplist, 1024); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP group list\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_list_free; } group = evbuffer_new(); if (!group) { DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP group block\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_list_free; } /* The buffer will expand if needed */ ret = evbuffer_expand(group, 128); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP group block\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_group_free; } param = keyval_get(h->query, "meta"); if (!param) { DPRINTF(E_LOG, L_DAAP, "No meta parameter in query, using default\n"); param = default_meta_group; } ret = parse_meta(h, tag, param, &meta, &nmeta); if (nmeta < 0) { DPRINTF(E_LOG, L_DAAP, "Failed to parse meta parameter in DAAP query\n"); /* retval from parse_meta() */ goto out_group_free; } memset(&qp, 0, sizeof(struct query_params)); get_query_params(h->query, &sort_headers, &qp); qp.type = Q_GROUPS; sctx = NULL; if (sort_headers) { sctx = daap_sort_context_new(); if (!sctx) { DPRINTF(E_LOG, L_DAAP, "Could not create sort context\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_query_free; } } ret = db_query_start(&qp); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not start query\n"); if (sort_headers) daap_sort_context_free(sctx); ret = dmap_send_error(h, tag, "Could not start query"); goto out_query_free; } ngrp = 0; while ((ret = db_query_fetch_group(&qp, &dbgri)) == 0) { ngrp++; for (i = 0; i < nmeta; i++) { df = meta[i]; dfm = df->dfm; /* dmap.itemcount - always added */ if (dfm == &dfm_dmap_mimc) continue; /* Not in struct group_info */ if (dfm->gri_offset < 0) continue; strval = (char **) ((char *)&dbgri + dfm->gri_offset); if (!(*strval) || (**strval == '\0')) continue; dmap_add_field(group, df, *strval, 0); DPRINTF(E_DBG, L_DAAP, "Done with meta tag %s (%s)\n", df->desc, *strval); } if (sort_headers) { ret = daap_sort_build(sctx, dbgri.itemname); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add sort header to DAAP groups reply\n"); ret = -100; break; } } /* Item count, always added (mimc) */ val = 0; ret = safe_atoi32(dbgri.itemcount, &val); if ((ret == 0) && (val > 0)) dmap_add_int(group, "mimc", val); /* Song album artist, always added (asaa) */ dmap_add_string(group, "asaa", dbgri.songalbumartist); /* Item id (miid) */ val = 0; ret = safe_atoi32(dbgri.id, &val); if ((ret == 0) && (val > 0)) dmap_add_int(group, "miid", val); DPRINTF(E_DBG, L_DAAP, "Done with group\n"); dmap_add_container(grouplist, "mlit", EVBUFFER_LENGTH(group)); ret = evbuffer_add_buffer(grouplist, group); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add group to group list for DAAP groups reply\n"); ret = -100; break; } } DPRINTF(E_DBG, L_DAAP, "Done with group list, %d groups\n", ngrp); free(meta); evbuffer_free(group); if (qp.filter) free(qp.filter); if (ret < 0) { db_query_end(&qp); if (sort_headers) daap_sort_context_free(sctx); if (ret == -100) ret = dmap_send_error(h, tag, "Out of memory"); else { DPRINTF(E_LOG, L_DAAP, "Error fetching results\n"); ret = dmap_send_error(h, tag, "Error fetching query results"); } goto out_list_free; } /* Add header to evbuf, add grouplist to evbuf */ if (sort_headers) dmap_add_container(evbuf, tag, EVBUFFER_LENGTH(grouplist) + EVBUFFER_LENGTH(sctx->headerlist) + 53); else dmap_add_container(evbuf, tag, EVBUFFER_LENGTH(grouplist) + 53); dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_char(evbuf, "muty", 0); /* 9 */ dmap_add_int(evbuf, "mtco", qp.results); /* 12 */ dmap_add_int(evbuf,"mrco", ngrp); /* 12 */ dmap_add_container(evbuf, "mlcl", EVBUFFER_LENGTH(grouplist)); db_query_end(&qp); ret = evbuffer_add_buffer(evbuf, grouplist); evbuffer_free(grouplist); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add group list to DAAP groups reply\n"); if (sort_headers) daap_sort_context_free(sctx); ret = dmap_send_error(h, tag, "Out of memory"); goto out_evbuf_free; } if (sort_headers) { ret = daap_sort_finalize(sctx, evbuf); daap_sort_context_free(sctx); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add sort headers to DAAP browse reply\n"); ret = dmap_send_error(h, tag, "Out of memory"); goto out_evbuf_free; } } ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { ret = dmap_send_error(h, tag, "Server Error"); goto out_evbuf_free; } return httpd_send_reply(h->c, h->req, h->r, evbuf); out_query_free: free(meta); if (qp.filter) free(qp.filter); out_group_free: evbuffer_free(group); out_list_free: evbuffer_free(grouplist); out_evbuf_free: evbuffer_free(evbuf); return ret; } static int daap_reply_browse(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct query_params qp; struct daap_session *s; struct evbuffer *itemlist; struct sort_ctx *sctx; char *browse_item; char *sort_item; char *tag; int sort_headers; int nitems; int ret; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } memset(&qp, 0, sizeof(struct query_params)); if (strcmp(uri[3], "artists") == 0) { tag = "abar"; qp.type = Q_BROWSE_ARTISTS; } else if (strcmp(uri[3], "genres") == 0) { tag = "abgn"; qp.type = Q_BROWSE_GENRES; } else if (strcmp(uri[3], "albums") == 0) { tag = "abal"; qp.type = Q_BROWSE_ALBUMS; } else if (strcmp(uri[3], "composers") == 0) { tag = "abcp"; qp.type = Q_BROWSE_COMPOSERS; } else { DPRINTF(E_LOG, L_DAAP, "Invalid DAAP browse request type '%s'\n", uri[3]); evbuffer_free(evbuf); return dmap_send_error(h, "abro", "Invalid browse type"); } ret = evbuffer_expand(evbuf, 52); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DAAP browse reply\n"); evbuffer_free(evbuf); return dmap_send_error(h, "abro", "Out of memory"); } itemlist = evbuffer_new(); if (!itemlist) { DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP browse item list\n"); evbuffer_free(evbuf); return dmap_send_error(h, "abro", "Out of memory"); } /* Start with a big enough evbuffer - it'll expand as needed */ ret = evbuffer_expand(itemlist, 512); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not expand evbuffer for DMAP browse item list\n"); evbuffer_free(evbuf); evbuffer_free(itemlist); return dmap_send_error(h, "abro", "Out of memory"); } get_query_params(h->query, &sort_headers, &qp); sctx = NULL; if (sort_headers) { sctx = daap_sort_context_new(); if (!sctx) { DPRINTF(E_LOG, L_DAAP, "Could not create sort context\n"); evbuffer_free(evbuf); evbuffer_free(itemlist); if (qp.filter) free(qp.filter); return dmap_send_error(h, "abro", "Out of memory"); } } ret = db_query_start(&qp); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not start query\n"); if (sort_headers) daap_sort_context_free(sctx); evbuffer_free(evbuf); evbuffer_free(itemlist); if (qp.filter) free(qp.filter); return dmap_send_error(h, "abro", "Could not start query"); } nitems = 0; while (((ret = db_query_fetch_string_sort(&qp, &browse_item, &sort_item)) == 0) && (browse_item)) { nitems++; if (sort_headers) { ret = daap_sort_build(sctx, sort_item); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add sort header to DAAP browse reply\n"); break; } } dmap_add_string(itemlist, "mlit", browse_item); } if (qp.filter) free(qp.filter); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Error fetching/building results\n"); db_query_end(&qp); if (sort_headers) daap_sort_context_free(sctx); evbuffer_free(evbuf); evbuffer_free(itemlist); return dmap_send_error(h, "abro", "Error fetching/building query results"); } if (sort_headers) dmap_add_container(evbuf, "abro", EVBUFFER_LENGTH(itemlist) + EVBUFFER_LENGTH(sctx->headerlist) + 44); else dmap_add_container(evbuf, "abro", EVBUFFER_LENGTH(itemlist) + 44); dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_int(evbuf, "mtco", qp.results); /* 12 */ dmap_add_int(evbuf, "mrco", nitems); /* 12 */ dmap_add_container(evbuf, tag, EVBUFFER_LENGTH(itemlist)); db_query_end(&qp); ret = evbuffer_add_buffer(evbuf, itemlist); evbuffer_free(itemlist); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add item list to DAAP browse reply\n"); if (sort_headers) daap_sort_context_free(sctx); evbuffer_free(evbuf); return dmap_send_error(h, tag, "Out of memory"); } if (sort_headers) { ret = daap_sort_finalize(sctx, evbuf); daap_sort_context_free(sctx); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add sort headers to DAAP browse reply\n"); evbuffer_free(evbuf); return dmap_send_error(h, tag, "Out of memory"); } } ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { evbuffer_free(evbuf); return dmap_send_error(h, tag, "Server error"); } return httpd_send_reply(h->c, h->req, h->r, evbuf); } /* NOTE: We only handle artwork at the moment */ static int daap_reply_extra_data(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { char clen[32]; struct daap_session *s; const char *param; char *ctype; int id; int max_w; int max_h; int ret; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } ret = safe_atoi32(uri[3], &id); if (ret < 0) goto bad_request; param = keyval_get(h->query, "mw"); if (!param) { DPRINTF(E_LOG, L_DAAP, "Request for artwork without mw parameter\n"); goto bad_request; } ret = safe_atoi32(param, &max_w); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not convert mw parameter to integer\n"); goto bad_request; } param = keyval_get(h->query, "mh"); if (!param) { DPRINTF(E_LOG, L_DAAP, "Request for artwork without mh parameter\n"); goto bad_request; } ret = safe_atoi32(param, &max_h); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not convert mh parameter to integer\n"); goto bad_request; } if (strcmp(uri[2], "groups") == 0) ret = artwork_get_group(id, max_w, max_h, ART_CAN_PNG | ART_CAN_JPEG, evbuf); else if (strcmp(uri[2], "items") == 0) ret = artwork_get_item(id, max_w, max_h, ART_CAN_PNG | ART_CAN_JPEG, evbuf); switch (ret) { case ART_FMT_PNG: ctype = "image/png"; break; case ART_FMT_JPEG: ctype = "image/jpeg"; break; default: goto no_artwork; } http_response_set_body(h->r, evbuf); http_response_remove_header(h->r, "Content-Type"); ret = http_response_add_header(h->r, "Content-Type", ctype); if (ret < 0) goto out_error; snprintf(clen, sizeof(clen), "%ld", (long)EVBUFFER_LENGTH(evbuf)); ret = http_response_add_header(h->r, "Content-Length", clen); if (ret < 0) goto out_error; /* No gzip compression for artwork */ ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; no_artwork: evbuffer_free(evbuf); ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); bad_request: evbuffer_free(evbuf); return http_server_error_run(h->c, h->r, HTTP_BAD_REQUEST, "Bad Request"); } static int daap_stream(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int id; int ret; evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; ret = safe_atoi32(uri[3], &id); if (ret < 0) return http_server_error_run(h->c, h->r, HTTP_BAD_REQUEST, "Bad Request"); return httpd_stream_file(h->c, h->req, h->r, id); } static char * daap_fix_request_uri(char *uri) { char *ret; /* iTunes 9 gives us an absolute request-uri like * daap://10.1.1.20:3689/server-info */ if (strncmp(uri, "daap://", strlen("daap://")) != 0) return uri; ret = strchr(uri + strlen("daap://"), '/'); if (!ret) { DPRINTF(E_LOG, L_DAAP, "Malformed DAAP Request URI '%s'\n", uri); return NULL; } return ret; } #ifdef DMAP_TEST static const struct dmap_field dmap_TEST = { "test.container", "TEST", NULL, DMAP_TYPE_LIST }; static const struct dmap_field dmap_TST1 = { "test.ubyte", "TST1", NULL, DMAP_TYPE_UBYTE }; static const struct dmap_field dmap_TST2 = { "test.byte", "TST2", NULL, DMAP_TYPE_BYTE }; static const struct dmap_field dmap_TST3 = { "test.ushort", "TST3", NULL, DMAP_TYPE_USHORT }; static const struct dmap_field dmap_TST4 = { "test.short", "TST4", NULL, DMAP_TYPE_SHORT }; static const struct dmap_field dmap_TST5 = { "test.uint", "TST5", NULL, DMAP_TYPE_UINT }; static const struct dmap_field dmap_TST6 = { "test.int", "TST6", NULL, DMAP_TYPE_INT }; static const struct dmap_field dmap_TST7 = { "test.ulong", "TST7", NULL, DMAP_TYPE_ULONG }; static const struct dmap_field dmap_TST8 = { "test.long", "TST8", NULL, DMAP_TYPE_LONG }; static const struct dmap_field dmap_TST9 = { "test.string", "TST9", NULL, DMAP_TYPE_STRING }; static int daap_reply_dmap_test(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { char buf[64]; struct evbuffer *test; int ret; test = evbuffer_new(); if (!test) { DPRINTF(E_LOG, L_DAAP, "Could not create evbuffer for DMAP test\n"); evbuffer_free(evbuf); return dmap_send_error(h, dmap_TEST.tag, "Out of memory"); } /* UBYTE */ snprintf(buf, sizeof(buf), "%" PRIu8, UINT8_MAX); dmap_add_field(test, &dmap_TST1, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); /* BYTE */ snprintf(buf, sizeof(buf), "%" PRIi8, INT8_MIN); dmap_add_field(test, &dmap_TST2, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); snprintf(buf, sizeof(buf), "%" PRIi8, INT8_MAX); dmap_add_field(test, &dmap_TST2, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); /* USHORT */ snprintf(buf, sizeof(buf), "%" PRIu16, UINT16_MAX); dmap_add_field(test, &dmap_TST3, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); /* SHORT */ snprintf(buf, sizeof(buf), "%" PRIi16, INT16_MIN); dmap_add_field(test, &dmap_TST4, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); snprintf(buf, sizeof(buf), "%" PRIi16, INT16_MAX); dmap_add_field(test, &dmap_TST4, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); /* UINT */ snprintf(buf, sizeof(buf), "%" PRIu32, UINT32_MAX); dmap_add_field(test, &dmap_TST5, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); /* INT */ snprintf(buf, sizeof(buf), "%" PRIi32, INT32_MIN); dmap_add_field(test, &dmap_TST6, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); snprintf(buf, sizeof(buf), "%" PRIi32, INT32_MAX); dmap_add_field(test, &dmap_TST6, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); /* ULONG */ snprintf(buf, sizeof(buf), "%" PRIu64, UINT64_MAX); dmap_add_field(test, &dmap_TST7, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); /* LONG */ snprintf(buf, sizeof(buf), "%" PRIi64, INT64_MIN); dmap_add_field(test, &dmap_TST8, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); snprintf(buf, sizeof(buf), "%" PRIi64, INT64_MAX); dmap_add_field(test, &dmap_TST8, buf, 0); dmap_add_field(test, &dmap_TST9, buf, 0); dmap_add_container(evbuf, dmap_TEST.tag, EVBUFFER_LENGTH(test)); ret = evbuffer_add_buffer(evbuf, test); evbuffer_free(test); if (ret < 0) { DPRINTF(E_LOG, L_DAAP, "Could not add test results to DMAP test reply\n"); evbuffer_free(evbuf); return dmap_send_error(h, dmap_TEST.tag, "Out of memory"); } http_response_set_body(r, evbuf); ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } #endif /* DMAP_TEST */ static struct uri_map daap_handlers[] = { { .regexp = "^/server-info$", .handler = daap_reply_server_info }, { .regexp = "^/content-codes$", .handler = daap_reply_content_codes }, { .regexp = "^/login$", .handler = daap_reply_login }, { .regexp = "^/logout$", .handler = daap_reply_logout }, { .regexp = "^/update$", .handler = daap_reply_update }, { .regexp = "^/activity$", .handler = daap_reply_activity }, { .regexp = "^/databases$", .handler = daap_reply_dblist }, { .regexp = "^/databases/[[:digit:]]+/browse/[^/]+$", .handler = daap_reply_browse }, { .regexp = "^/databases/[[:digit:]]+/items$", .handler = daap_reply_dbsonglist }, { .regexp = "^/databases/[[:digit:]]+/items/[[:digit:]]+[.][^/]+$", .handler = daap_stream }, { .regexp = "^/databases/[[:digit:]]+/items/[[:digit:]]+/extra_data/artwork$", .handler = daap_reply_extra_data }, { .regexp = "^/databases/[[:digit:]]+/containers$", .handler = daap_reply_playlists }, { .regexp = "^/databases/[[:digit:]]+/containers/[[:digit:]]+/items$", .handler = daap_reply_plsonglist }, { .regexp = "^/databases/[[:digit:]]+/groups$", .handler = daap_reply_groups }, { .regexp = "^/databases/[[:digit:]]+/groups/[[:digit:]]+/extra_data/artwork$", .handler = daap_reply_extra_data }, #ifdef DMAP_TEST { .regexp = "^/dmap-test$", .handler = daap_reply_dmap_test }, #endif /* DMAP_TEST */ { .regexp = NULL, .handler = NULL } }; int daap_request(struct http_connection *c, struct http_request *req, struct http_response *r) { struct httpd_hdl hdl; struct keyval query; char *full_uri; char *uri; char *ptr; char *uri_parts[7]; struct evbuffer *evbuf; const char *ua; cfg_t *lib; char *libname; char *passwd; int handler; int ret; int i; memset(&query, 0, sizeof(struct keyval)); memset(&hdl, 0, sizeof(struct httpd_hdl)); full_uri = httpd_fixup_uri(req); if (!full_uri) return http_server_error_run(c, r, HTTP_BAD_REQUEST, "Bad Request"); ptr = daap_fix_request_uri(full_uri); if (!ptr) { free(full_uri); return http_server_error_run(c, r, HTTP_BAD_REQUEST, "Bad Request"); } if (ptr != full_uri) { uri = strdup(ptr); free(full_uri); if (!uri) return http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); full_uri = uri; } ptr = strchr(full_uri, '?'); if (ptr) *ptr = '\0'; uri = strdup(full_uri); if (!uri) { free(full_uri); return http_server_error_run(c, r, HTTP_BAD_REQUEST, "Bad Request"); } if (ptr) *ptr = '?'; http_decode_uri(uri, URI_DECODE_NORMAL); DPRINTF(E_DBG, L_DAAP, "DAAP request: %s\n", full_uri); handler = -1; for (i = 0; daap_handlers[i].handler; i++) { ret = tre_regexec(&daap_handlers[i].preg, uri, 0, NULL, 0); if (ret == 0) { handler = i; break; } } if (handler < 0) { DPRINTF(E_LOG, L_DAAP, "Unrecognized DAAP request\n"); ret = http_server_error_run(c, r, HTTP_BAD_REQUEST, "Bad Request"); goto out; } /* Check authentication */ lib = cfg_getsec(cfg, "library"); passwd = cfg_getstr(lib, "password"); /* No authentication for these URIs */ if ((strcmp(uri, "/server-info") == 0) || (strcmp(uri, "/logout") == 0) || (strncmp(uri, "/databases/1/items/", strlen("/databases/1/items/")) == 0)) passwd = NULL; /* Waive HTTP authentication for Remote * Remotes are authentified by their pairing-guid; DAAP queries require a * valid session-id that Remote can only obtain if its pairing-guid is in * our database. So HTTP authentication is waived for Remote. */ ua = http_request_get_header(req, "User-Agent"); if ((ua) && (strncmp(ua, "Remote", strlen("Remote")) == 0)) passwd = NULL; if (passwd) { libname = cfg_getstr(lib, "name"); DPRINTF(E_DBG, L_HTTPD, "Checking authentication for library '%s'\n", libname); /* We don't care about the username */ ret = httpd_basic_auth(c, req, r, NULL, passwd, libname); switch (ret) { case HTTP_OK: DPRINTF(E_DBG, L_HTTPD, "Library authentication successful\n"); break; case -1: ret = -1; goto out; default: /* HTTP_UNAUTHORIZED or HTTP_INTERNAL_ERROR on error */ ret = 0; goto out; } } memset(uri_parts, 0, sizeof(uri_parts)); uri_parts[0] = strtok_r(uri, "/", &ptr); for (i = 1; (i < sizeof(uri_parts) / sizeof(uri_parts[0])) && uri_parts[i - 1]; i++) { uri_parts[i] = strtok_r(NULL, "/", &ptr); } if (!uri_parts[0] || uri_parts[i - 1] || (i < 2)) { DPRINTF(E_LOG, L_DAAP, "DAAP URI has too many/few components (%d)\n", (uri_parts[0]) ? i : 0); ret = http_server_error_run(c, r, HTTP_BAD_REQUEST, "Bad Request"); goto out; } ret = http_parse_query_string(full_uri, &query); if (ret < 0) { ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out; } ret = http_response_add_header(r, "Accept-Ranges", "bytes"); if (ret < 0) { ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_clear_query; } ret = http_response_add_header(r, "DAAP-Server", PACKAGE "/" VERSION); if (ret < 0) { ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_clear_query; } /* Content-Type for all replies, even the actual audio streaming. Note that * video streaming will override this Content-Type with a more appropriate * video/ Content-Type as expected by clients like Front Row. */ ret = http_response_add_header(r, "Content-Type", "application/x-dmap-tagged"); if (ret < 0) { ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_clear_query; } /* Freed in the handler */ evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_DAAP, "Could not allocate evbuffer for DAAP reply\n"); ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_clear_query; } ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Could not acquire database connection\n"); evbuffer_free(evbuf); ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_clear_query; } hdl.c = c; hdl.req = req; hdl.r = r; hdl.query = &query; ret = daap_handlers[handler].handler(&hdl, evbuf, uri_parts); db_pool_release(); out_clear_query: keyval_clear(&query); out: free(uri); free(full_uri); return ret; } int daap_is_request(char *uri) { uri = daap_fix_request_uri(uri); if (!uri) return 0; if (strncmp(uri, "/databases/", strlen("/databases/")) == 0) return 1; if (strcmp(uri, "/databases") == 0) return 1; if (strcmp(uri, "/server-info") == 0) return 1; if (strcmp(uri, "/content-codes") == 0) return 1; if (strcmp(uri, "/login") == 0) return 1; if (strcmp(uri, "/update") == 0) return 1; if (strcmp(uri, "/activity") == 0) return 1; if (strcmp(uri, "/logout") == 0) return 1; #ifdef DMAP_TEST if (strcmp(uri, "/dmap-test") == 0) return 1; #endif return 0; } int daap_init(void) { char buf[64]; int i; int ret; next_session_id = 100; /* gotta start somewhere, right? */ current_rev = 2; update_requests = NULL; sessions_sq = dispatch_queue_create("org.forked-daapd.daap.sessions", NULL); if (!sessions_sq) { DPRINTF(E_FATAL, L_DAAP, "Could not create dispatch queue for DAAP sessions\n"); return -1; } updates_sq = dispatch_queue_create("org.forked-daapd.daap.updates", NULL); if (!updates_sq) { DPRINTF(E_FATAL, L_DAAP, "Could not create dispatch queue for DAAP update requests\n"); goto updates_sq_fail; } for (i = 0; daap_handlers[i].handler; i++) { ret = tre_regcomp(&daap_handlers[i].preg, daap_handlers[i].regexp, REG_EXTENDED | REG_NOSUB); if (ret != 0) { tre_regerror(ret, &daap_handlers[i].preg, buf, sizeof(buf)); DPRINTF(E_FATAL, L_DAAP, "DAAP init failed; regexp error: %s\n", buf); goto regexp_fail; } } daap_sessions = avl_alloc_tree(daap_session_compare, daap_session_free); if (!daap_sessions) { DPRINTF(E_FATAL, L_DAAP, "DAAP init could not allocate DAAP sessions AVL tree\n"); goto daap_avl_alloc_fail; } return 0; daap_avl_alloc_fail: for (i = 0; daap_handlers[i].handler; i++) tre_regfree(&daap_handlers[i].preg); regexp_fail: dispatch_release(updates_sq); updates_sq_fail: dispatch_release(sessions_sq); return -1; } void daap_deinit(void) { int i; for (i = 0; daap_handlers[i].handler; i++) tre_regfree(&daap_handlers[i].preg); avl_free_tree(daap_sessions); dispatch_release(sessions_sq); dispatch_release(updates_sq); /* Pending update requests are removed during HTTP server shutdown */ } forked-daapd-0.19gcd/src/httpd_daap.h0000664000175000017500000000042711633141135017053 0ustar julienjulien #ifndef __HTTPD_DAAP_H__ #define __HTTPD_DAAP_H__ #include "http.h" int daap_init(void); void daap_deinit(void); int daap_request(struct http_connection *c, struct http_request *req, struct http_response *r); int daap_is_request(char *uri); #endif /* !__HTTPD_DAAP_H__ */ forked-daapd-0.19gcd/src/httpd_dacp.c0000664000175000017500000013402611633141135017053 0ustar julienjulien/* * Copyright (C) 2010-2011 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include "evbuffer/evbuffer.h" #include "logger.h" #include "misc.h" #include "conffile.h" #include "artwork.h" #include "http.h" #include "httpd.h" #include "httpd_dacp.h" #include "dmap_common.h" #include "db.h" #include "player.h" /* From httpd_daap.c */ struct daap_session; int daap_session_find(struct httpd_hdl *h, struct daap_session **s); struct uri_map { regex_t preg; char *regexp; int (*handler)(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri); }; struct dacp_update_request { struct http_connection *c; struct http_request *req; struct http_response *r; struct dacp_update_request *next; }; typedef void (*dacp_propget)(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi); typedef void (*dacp_propset)(const char *value, struct keyval *query); struct dacp_prop_map { char *desc; dacp_propget propget; dacp_propset propset; }; /* Forward - properties getters */ static void dacp_propget_volume(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi); static void dacp_propget_volumecontrollable(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi); static void dacp_propget_playerstate(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi); static void dacp_propget_shufflestate(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi); static void dacp_propget_availableshufflestates(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi); static void dacp_propget_repeatstate(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi); static void dacp_propget_availablerepeatstates(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi); static void dacp_propget_nowplaying(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi); static void dacp_propget_playingtime(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi); /* Forward - properties setters */ static void dacp_propset_volume(const char *value, struct keyval *query); static void dacp_propset_playingtime(const char *value, struct keyval *query); static void dacp_propset_shufflestate(const char *value, struct keyval *query); static void dacp_propset_repeatstate(const char *value, struct keyval *query); static void dacp_propset_userrating(const char *value, struct keyval *query); /* gperf static hash, dacp_prop.gperf */ #include "dacp_prop_hash.c" /* Play status update */ static int current_rev; static dispatch_queue_t updates_sq; static dispatch_source_t updates_src; static struct dacp_update_request *update_requests; /* Seek timer */ static dispatch_queue_t seek_sq; static dispatch_source_t seek_timer; static int seek_target; /* DACP helpers */ static void dacp_nowplaying(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { char canp[16]; if ((status->status == PLAY_STOPPED) || !mfi) return; memset(canp, 0, sizeof(canp)); canp[3] = 1; /* 0-3 database ID */ canp[4] = (status->plid >> 24) & 0xff; canp[5] = (status->plid >> 16) & 0xff; canp[6] = (status->plid >> 8) & 0xff; canp[7] = status->plid & 0xff; canp[8] = (status->pos_pl >> 24) & 0xff; /* 8-11 position in playlist */ canp[9] = (status->pos_pl >> 16) & 0xff; canp[10] = (status->pos_pl >> 8) & 0xff; canp[11] = status->pos_pl & 0xff; canp[12] = (status->id >> 24) & 0xff; /* 12-15 track ID */ canp[13] = (status->id >> 16) & 0xff; canp[14] = (status->id >> 8) & 0xff; canp[15] = status->id & 0xff; dmap_add_literal(evbuf, "canp", canp, sizeof(canp)); dmap_add_string(evbuf, "cann", mfi->title); dmap_add_string(evbuf, "cana", mfi->artist); dmap_add_string(evbuf, "canl", mfi->album); dmap_add_string(evbuf, "cang", mfi->genre); dmap_add_long(evbuf, "asai", mfi->songalbumid); dmap_add_int(evbuf, "cmmk", 1); } static void dacp_playingtime(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { if ((status->status == PLAY_STOPPED) || !mfi) return; dmap_add_int(evbuf, "cant", mfi->song_length - status->pos_ms); /* Remaining time in ms */ dmap_add_int(evbuf, "cast", mfi->song_length); /* Song length in ms */ } /* Update requests helpers */ static int make_playstatusupdate(struct evbuffer *evbuf) { struct player_status status; struct media_file_info *mfi; struct evbuffer *psu; int ret; psu = evbuffer_new(); if (!psu) { DPRINTF(E_LOG, L_DACP, "Could not allocate evbuffer for playstatusupdate\n"); return -1; } player_get_status(&status); if (status.status != PLAY_STOPPED) { mfi = db_file_fetch_byid(status.id); if (!mfi) { DPRINTF(E_LOG, L_DACP, "Could not fetch file id %d\n", status.id); return -1; } } else mfi = NULL; dmap_add_int(psu, "mstt", 200); /* 12 */ dmap_add_int(psu, "cmsr", current_rev); /* 12 */ dmap_add_char(psu, "cavc", 1); /* 9 */ /* volume controllable */ dmap_add_char(psu, "caps", status.status); /* 9 */ /* play status, 2 = stopped, 3 = paused, 4 = playing */ dmap_add_char(psu, "cash", status.shuffle); /* 9 */ /* shuffle, true/false */ dmap_add_char(psu, "carp", status.repeat); /* 9 */ /* repeat, 0 = off, 1 = repeat song, 2 = repeat (playlist) */ dmap_add_int(psu, "caas", 2); /* 12 */ /* available shuffle states */ dmap_add_int(psu, "caar", 6); /* 12 */ /* available repeat states */ if (mfi) { dacp_nowplaying(psu, &status, mfi); dacp_playingtime(psu, &status, mfi); free_mfi(mfi, 0); } dmap_add_container(evbuf, "cmst", EVBUFFER_LENGTH(psu)); /* 8 + len */ ret = evbuffer_add_buffer(evbuf, psu); evbuffer_free(psu); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Could not add status data to playstatusupdate reply\n"); return -1; } return 0; } /* Queue: updates_sq */ static void playstatus_update_cb(void *arg) { struct dacp_update_request *ur; struct evbuffer *evbuf; struct evbuffer *update; int ret; if (!update_requests) { DPRINTF(E_DBG, L_DACP, "Playstatus updates: no clients\n"); return; } else DPRINTF(E_DBG, L_DACP, "Playstatus updates: sending out updates\n"); update = evbuffer_new(); if (!update) { DPRINTF(E_LOG, L_DACP, "Could not allocate evbuffer for playstatusupdate data\n"); return; } ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Could not acquire database connection; skipping playstatus update\n"); goto out_free_update; } ret = make_playstatusupdate(update); db_pool_release(); if (ret < 0) goto out_free_update; for (ur = update_requests; update_requests; ur = update_requests) { evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_DACP, "Could not allocate evbuffer for playstatusupdate reply\n"); break; } ret = evbuffer_add(evbuf, EVBUFFER_DATA(update), EVBUFFER_LENGTH(update)); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Out of memory for playstatus update\n"); evbuffer_free(evbuf); break; } ret = http_response_set_status(ur->r, HTTP_OK, "OK"); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Could not set response status for playstatus update\n"); evbuffer_free(evbuf); break; } http_response_set_body(ur->r, evbuf); ret = http_server_response_thaw_and_run(ur->c, ur->r); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Could not thaw and run response to playstatus update request\n"); http_server_kill_connection(ur->c); } update_requests = ur->next; free(ur); } current_rev++; out_free_update: evbuffer_free(update); } /* Queue: player */ static void dacp_playstatus_update_handler(void) { dispatch_source_merge_data(updates_src, 1); } /* Queue: updates_sq */ static void update_free_cb_task(void *arg) { struct dacp_update_request *ur; struct dacp_update_request *p; ur = (struct dacp_update_request *)arg; DPRINTF(E_DBG, L_DACP, "Update request: client closed connection\n"); if (ur == update_requests) update_requests = ur->next; else { for (p = update_requests; p && (p->next != ur); p = p->next) ; if (!p) { DPRINTF(E_LOG, L_DACP, "WARNING: struct dacp_update_request not found in list; BUG!\n"); return; } p->next = ur->next; } free(ur); } static void update_free_cb(void *data) { DPRINTF(E_DBG, L_DACP, "Update request: connection closed\n"); dispatch_sync_f(updates_sq, data, update_free_cb_task); } /* Properties getters */ static void dacp_propget_volume(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { dmap_add_int(evbuf, "cmvo", status->volume); } static void dacp_propget_volumecontrollable(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { dmap_add_char(evbuf, "cavc", 1); } static void dacp_propget_playerstate(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { dmap_add_char(evbuf, "caps", status->status); } static void dacp_propget_shufflestate(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { dmap_add_char(evbuf, "cash", status->shuffle); } static void dacp_propget_availableshufflestates(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { dmap_add_int(evbuf, "caas", 2); } static void dacp_propget_repeatstate(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { dmap_add_char(evbuf, "carp", status->repeat); } static void dacp_propget_availablerepeatstates(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { dmap_add_int(evbuf, "caar", 6); } static void dacp_propget_nowplaying(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { dacp_nowplaying(evbuf, status, mfi); } static void dacp_propget_playingtime(struct evbuffer *evbuf, struct player_status *status, struct media_file_info *mfi) { dacp_playingtime(evbuf, status, mfi); } /* Properties setters */ static void dacp_propset_volume(const char *value, struct keyval *query) { const char *param; uint64_t id; int volume; int ret; ret = safe_atoi32(value, &volume); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "dmcp.volume argument doesn't convert to integer: %s\n", value); return; } param = keyval_get(query, "speaker-id"); if (param) { ret = safe_atou64(param, &id); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Invalid speaker ID in dmcp.volume request\n"); return; } player_volume_setrel_speaker(id, volume); return; } param = keyval_get(query, "include-speaker-id"); if (param) { ret = safe_atou64(param, &id); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Invalid speaker ID in dmcp.volume request\n"); return; } player_volume_setabs_speaker(id, volume); return; } player_volume_set(volume); } static void seek_timer_cb(void *arg) { int ret; dispatch_source_cancel(seek_timer); dispatch_release(seek_timer); seek_timer = NULL; DPRINTF(E_DBG, L_DACP, "Seek timer expired, target %d ms\n", seek_target); ret = player_playback_seek(seek_target); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Player failed to seek to %d ms\n", seek_target); return; } ret = player_playback_start(NULL); if (ret < 0) DPRINTF(E_LOG, L_DACP, "Player returned an error for start after seek\n"); } static void dacp_propset_playingtime(const char *value, struct keyval *query) { int target; int ret; ret = safe_atoi32(value, &target); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "dacp.playingtime argument doesn't convert to integer: %s\n", value); return; } dispatch_async(seek_sq, ^{ if (!seek_timer) { seek_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, seek_sq); if (!seek_timer) { DPRINTF(E_LOG, L_DACP, "Could not create dispatch source for seek timer\n"); return; } dispatch_source_set_event_handler_f(seek_timer, seek_timer_cb); } else dispatch_suspend(seek_timer); dispatch_source_set_timer(seek_timer, dispatch_time(DISPATCH_TIME_NOW, 200 * (NSEC_PER_SEC / 1000)), DISPATCH_TIME_FOREVER /* one-shot */, 0); seek_target = target; dispatch_resume(seek_timer); }); } static void dacp_propset_shufflestate(const char *value, struct keyval *query) { int enable; int ret; ret = safe_atoi32(value, &enable); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "dacp.shufflestate argument doesn't convert to integer: %s\n", value); return; } player_shuffle_set(enable); } static void dacp_propset_repeatstate(const char *value, struct keyval *query) { int mode; int ret; ret = safe_atoi32(value, &mode); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "dacp.repeatstate argument doesn't convert to integer: %s\n", value); return; } player_repeat_set(mode); } static void dacp_propset_userrating(const char *value, struct keyval *query) { struct media_file_info *mfi; const char *param; uint32_t itemid; uint32_t rating; int ret; ret = safe_atou32(value, &rating); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "dacp.userrating argument doesn't convert to integer: %s\n", value); return; } param = keyval_get(query, "item-spec"); if (!param) { DPRINTF(E_LOG, L_DACP, "Missing item-spec parameter in dacp.userrating query\n"); return; } param = strchr(param, ':'); if (!param) { DPRINTF(E_LOG, L_DACP, "Malformed item-spec parameter in dacp.userrating query\n"); return; } param++; ret = safe_hextou32(param, &itemid); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Couldn't convert item-spec to an integer in dacp.userrating (%s)\n", param); return; } mfi = db_file_fetch_byid(itemid); if (!mfi) { DPRINTF(E_LOG, L_DACP, "Could not fetch file id %d\n", itemid); return; } mfi->rating = rating; /* We're not touching any string field in mfi, so it's safe to * skip unicode_fixup_mfi() before the update */ db_file_update(mfi); free_mfi(mfi, 0); } static int dacp_reply_ctrlint(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { int ret; dmap_add_container(evbuf, "caci", 127); /* 8 + len */ dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_char(evbuf, "muty", 0); /* 9 */ dmap_add_int(evbuf, "mtco", 1); /* 12 */ dmap_add_int(evbuf, "mrco", 1); /* 12 */ dmap_add_container(evbuf, "mlcl", 125); /* 8 + len */ dmap_add_container(evbuf, "mlit", 117); /* 8 + len */ dmap_add_int(evbuf, "miid", 1); /* 12 */ /* Database ID */ dmap_add_char(evbuf, "cmik", 1); /* 9 */ dmap_add_int(evbuf, "cmpr", (2 << 16 | 1)); /* 12 */ dmap_add_int(evbuf, "capr", (2 << 16 | 2)); /* 12 */ dmap_add_char(evbuf, "cmsp", 1); /* 9 */ dmap_add_char(evbuf, "aeFR", 0x64); /* 9 */ dmap_add_char(evbuf, "cmsv", 1); /* 9 */ dmap_add_char(evbuf, "cass", 1); /* 9 */ dmap_add_char(evbuf, "caov", 1); /* 9 */ dmap_add_char(evbuf, "casu", 1); /* 9 */ dmap_add_char(evbuf, "ceSG", 1); /* 9 */ dmap_add_char(evbuf, "cmrl", 1); /* 9 */ ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { evbuffer_free(evbuf); return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } return httpd_send_reply(h->c, h->req, h->r, evbuf); } static int dacp_reply_cue_play(struct httpd_hdl *h, struct evbuffer *evbuf) { struct player_status status; struct player_source *ps; const char *sort; const char *cuequery; const char *param; uint32_t id; int clear; int ret; /* /cue?command=play&query=...&sort=...&index=N */ param = keyval_get(h->query, "clear-first"); if (param) { ret = safe_atoi32(param, &clear); if (ret < 0) DPRINTF(E_LOG, L_DACP, "Invalid clear-first value in cue request\n"); else if (clear) { player_playback_stop(); player_queue_clear(); } } cuequery = keyval_get(h->query, "query"); if (cuequery) { sort = keyval_get(h->query, "sort"); ps = player_queue_make_daap(cuequery, sort); if (!ps) { DPRINTF(E_LOG, L_DACP, "Could not build song queue\n"); evbuffer_free(evbuf); return dmap_send_error(h, "cacr", "Could not build song queue"); } player_queue_add(ps); } else { player_get_status(&status); if (status.status != PLAY_STOPPED) player_playback_stop(); } param = keyval_get(h->query, "dacp.shufflestate"); if (param) dacp_propset_shufflestate(param, NULL); id = 0; param = keyval_get(h->query, "index"); if (param) { ret = safe_atou32(param, &id); if (ret < 0) DPRINTF(E_LOG, L_DACP, "Invalid index (%s) in cue request\n", param); } ret = player_playback_start(&id); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Could not start playback\n"); evbuffer_free(evbuf); return dmap_send_error(h, "cacr", "Playback failed to start"); } dmap_add_container(evbuf, "cacr", 24); /* 8 + len */ dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_int(evbuf, "miid", id); /* 12 */ ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); return httpd_send_reply(h->c, h->req, h->r, evbuf); } static int dacp_reply_cue_clear(struct httpd_hdl *h, struct evbuffer *evbuf) { int ret; /* /cue?command=clear */ player_playback_stop(); player_queue_clear(); dmap_add_container(evbuf, "cacr", 24); /* 8 + len */ dmap_add_int(evbuf, "mstt", 200); /* 12 */ dmap_add_int(evbuf, "miid", 0); /* 12 */ ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); return httpd_send_reply(h->c, h->req, h->r, evbuf); } static int dacp_reply_cue(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; const char *param; int ret; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } param = keyval_get(h->query, "command"); if (!param) { DPRINTF(E_DBG, L_DACP, "No command in cue request\n"); evbuffer_free(evbuf); return dmap_send_error(h, "cacr", "No command in cue request"); } if (strcmp(param, "clear") == 0) return dacp_reply_cue_clear(h, evbuf); else if (strcmp(param, "play") == 0) return dacp_reply_cue_play(h, evbuf); DPRINTF(E_LOG, L_DACP, "Unknown cue command %s\n", param); evbuffer_free(evbuf); return dmap_send_error(h, "cacr", "Unknown command in cue request"); } static int dacp_reply_playspec(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct player_status status; struct player_source *ps; struct daap_session *s; const char *param; const char *shuffle; uint32_t plid; uint32_t id; int ret; /* /ctrl-int/1/playspec?database-spec='dmap.persistentid:0x1'&container-spec='dmap.persistentid:0x5'&container-item-spec='dmap.containeritemid:0x9' * With our DAAP implementation, container-spec is the playlist ID and container-item-spec is the song ID */ evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; /* Check for shuffle */ shuffle = keyval_get(h->query, "dacp.shufflestate"); /* Playlist ID */ param = keyval_get(h->query, "container-spec"); if (!param) { DPRINTF(E_LOG, L_DACP, "No container-spec in playspec request\n"); goto out_error; } param = strchr(param, ':'); if (!param) { DPRINTF(E_LOG, L_DACP, "Malformed container-spec parameter in playspec request\n"); goto out_error; } param++; ret = safe_hextou32(param, &plid); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Couldn't convert container-spec to an integer in playspec (%s)\n", param); goto out_error; } if (!shuffle) { /* Start song ID */ param = keyval_get(h->query, "container-item-spec"); if (!param) { DPRINTF(E_LOG, L_DACP, "No container-item-spec in playspec request\n"); goto out_error; } param = strchr(param, ':'); if (!param) { DPRINTF(E_LOG, L_DACP, "Malformed container-item-spec parameter in playspec request\n"); goto out_error; } param++; ret = safe_hextou32(param, &id); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Couldn't convert container-item-spec to an integer in playspec (%s)\n", param); goto out_error; } } else id = 0; DPRINTF(E_DBG, L_DACP, "Playspec request for playlist %d, start song id %d%s\n", plid, id, (shuffle) ? ", shuffle" : ""); ps = player_queue_make_pl(plid, &id); if (!ps) { DPRINTF(E_LOG, L_DACP, "Could not build song queue from playlist %d\n", plid); goto out_error; } DPRINTF(E_DBG, L_DACP, "Playspec start song index is %d\n", id); player_get_status(&status); if (status.status != PLAY_STOPPED) player_playback_stop(); player_queue_clear(); player_queue_add(ps); player_queue_plid(plid); if (shuffle) dacp_propset_shufflestate(shuffle, NULL); ret = player_playback_start(&id); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Could not start playback\n"); goto out_error; } /* 204 No Content is the canonical reply */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int dacp_reply_pause(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int ret; evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; player_playback_pause(); /* 204 No Content is the canonical reply */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int dacp_reply_playpause(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int ret; evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; ret = player_playback_start(NULL); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Player returned an error for start after pause\n"); goto out_error; } /* 204 No Content is the canonical reply */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int dacp_reply_nextitem(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int ret; evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; ret = player_playback_next(); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Player returned an error for nextitem\n"); goto out_error; } ret = player_playback_start(NULL); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Player returned an error for start after nextitem\n"); goto out_error; } /* 204 No Content is the canonical reply */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int dacp_reply_previtem(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int ret; evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; ret = player_playback_prev(); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Player returned an error for previtem\n"); goto out_error; } ret = player_playback_start(NULL); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Player returned an error for start after previtem\n"); goto out_error; } /* 204 No Content is the canonical reply */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int dacp_reply_beginff(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int ret; evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; /* TODO */ /* 204 No Content is the canonical reply */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int dacp_reply_beginrew(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int ret; evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; /* TODO */ /* 204 No Content is the canonical reply */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int dacp_reply_playresume(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; int ret; ret = daap_session_find(h, &s); if (!s) return ret; /* TODO */ /* 204 No Content is the canonical reply */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int dacp_reply_playstatusupdate(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; struct dacp_update_request *ur; const char *param; int reqd_rev; int ret; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } param = keyval_get(h->query, "revision-number"); if (!param) { DPRINTF(E_LOG, L_DACP, "Missing revision-number in update request\n"); return dmap_send_error(h, "cmst", "Invalid request"); } ret = safe_atoi32(param, &reqd_rev); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Parameter revision-number not an integer\n"); return dmap_send_error(h, "cmst", "Invalid request"); } if (reqd_rev == 1) { ret = make_playstatusupdate(evbuf); if (ret < 0) { evbuffer_free(evbuf); return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { evbuffer_free(evbuf); return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } return httpd_send_reply(h->c, h->req, h->r, evbuf); } evbuffer_free(evbuf); ur = (struct dacp_update_request *)malloc(sizeof(struct dacp_update_request)); if (!ur) { DPRINTF(E_LOG, L_DACP, "Out of memory for update request\n"); return dmap_send_error(h, "cmst", "Out of memory"); } /* Freeze the request */ http_server_response_freeze(h->c, h->r, update_free_cb, ur); ur->c = h->c; ur->req = h->req; ur->r = h->r; dispatch_sync(updates_sq, ^{ ur->next = update_requests; update_requests = ur; }); return 0; } static int dacp_reply_nowplayingartwork(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { char clen[32]; struct daap_session *s; const char *param; char *ctype; uint32_t id; int max_w; int max_h; int ret; ret = daap_session_find(h, &s); if (!s) { evbuffer_free(evbuf); return ret; } param = keyval_get(h->query, "mw"); if (!param) { DPRINTF(E_LOG, L_DACP, "Request for artwork without mw parameter\n"); goto bad_request; } ret = safe_atoi32(param, &max_w); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Could not convert mw parameter to integer\n"); goto bad_request; } param = keyval_get(h->query, "mh"); if (!param) { DPRINTF(E_LOG, L_DACP, "Request for artwork without mh parameter\n"); goto bad_request; } ret = safe_atoi32(param, &max_h); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Could not convert mh parameter to integer\n"); goto bad_request; } ret = player_now_playing(&id); if (ret < 0) goto no_artwork; ret = artwork_get_item(id, max_w, max_h, ART_CAN_PNG | ART_CAN_JPEG, evbuf); switch (ret) { case ART_FMT_PNG: ctype = "image/png"; break; case ART_FMT_JPEG: ctype = "image/jpeg"; break; default: goto no_artwork; } http_response_set_body(h->r, evbuf); http_response_remove_header(h->r, "Content-Type"); ret = http_response_add_header(h->r, "Content-Type", ctype); if (ret < 0) goto out_error; snprintf(clen, sizeof(clen), "%ld", (long)EVBUFFER_LENGTH(evbuf)); ret = http_response_add_header(h->r, "Content-Length", clen); if (ret < 0) goto out_error; ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) goto out_error; /* No gzip compression for artwork */ ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; bad_request: evbuffer_free(evbuf); return http_server_error_run(h->c, h->r, HTTP_BAD_REQUEST, "Bad Request"); no_artwork: evbuffer_free(evbuf); return http_server_error_run(h->c, h->r, HTTP_NOT_FOUND, "Not Found"); out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int dacp_reply_getproperty(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct player_status status; struct daap_session *s; const struct dacp_prop_map *dpm; struct media_file_info *mfi; struct evbuffer *proplist; const char *param; char *ptr; char *prop; char *propstr; int ret; ret = daap_session_find(h, &s); if (!s) goto out_free_evbuf; param = keyval_get(h->query, "properties"); if (!param) { DPRINTF(E_WARN, L_DACP, "Invalid DACP getproperty request, no properties\n"); ret = dmap_send_error(h, "cmgt", "Invalid request"); goto out_free_evbuf; } propstr = strdup(param); if (!propstr) { DPRINTF(E_LOG, L_DACP, "Could not duplicate properties parameter; out of memory\n"); ret = dmap_send_error(h, "cmgt", "Out of memory"); goto out_free_evbuf; } proplist = evbuffer_new(); if (!proplist) { DPRINTF(E_LOG, L_DACP, "Could not allocate evbuffer for properties list\n"); ret = dmap_send_error(h, "cmgt", "Out of memory"); goto out_free_propstr; } player_get_status(&status); if (status.status != PLAY_STOPPED) { mfi = db_file_fetch_byid(status.id); if (!mfi) { DPRINTF(E_LOG, L_DACP, "Could not fetch file id %d\n", status.id); ret = dmap_send_error(h, "cmgt", "Server error"); goto out_free_proplist; } } else mfi = NULL; prop = strtok_r(propstr, ",", &ptr); while (prop) { dpm = dacp_find_prop(prop, strlen(prop)); if (dpm) { if (dpm->propget) dpm->propget(proplist, &status, mfi); else DPRINTF(E_WARN, L_DACP, "No getter method for DACP property %s\n", prop); } else DPRINTF(E_LOG, L_DACP, "Could not find requested property '%s'\n", prop); prop = strtok_r(NULL, ",", &ptr); } free(propstr); if (mfi) free_mfi(mfi, 0); dmap_add_container(evbuf, "cmgt", 12 + EVBUFFER_LENGTH(proplist)); /* 8 + len */ dmap_add_int(evbuf, "mstt", 200); /* 12 */ ret = evbuffer_add_buffer(evbuf, proplist); evbuffer_free(proplist); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Could not add properties to getproperty reply\n"); ret = dmap_send_error(h, "cmgt", "Out of memory"); goto out_free_evbuf; } ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { ret = dmap_send_error(h, "cmgt", "Server error"); goto out_free_evbuf; } return httpd_send_reply(h->c, h->req, h->r, evbuf); out_free_proplist: evbuffer_free(proplist); out_free_propstr: free(propstr); out_free_evbuf: evbuffer_free(evbuf); return ret; } static int dacp_reply_setproperty(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; const struct dacp_prop_map *dpm; struct onekeyval *okv; int ret; evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; /* Known properties: * dacp.shufflestate 0/1 * dacp.repeatstate 0/1/2 * dacp.playingtime seek to time in ms * dmcp.volume 0-100, float */ /* /ctrl-int/1/setproperty?dacp.shufflestate=1&session-id=100 */ for (okv = h->query->head; okv; okv = okv->next) { dpm = dacp_find_prop(okv->name, strlen(okv->name)); if (!dpm) { DPRINTF(E_SPAM, L_DACP, "Unknown DACP property %s\n", okv->name); continue; } if (dpm->propset) dpm->propset(okv->value, h->query); else DPRINTF(E_WARN, L_DACP, "No setter method for DACP property %s\n", dpm->desc); } /* 204 No Content is the canonical reply */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static void speaker_enum_cb(uint64_t id, const char *name, int relvol, struct spk_flags flags, void *arg) { struct evbuffer *evbuf; int len; evbuf = (struct evbuffer *)arg; len = 8 + strlen(name) + 28; if (flags.selected) len += 9; if (flags.has_password) len += 9; if (flags.has_video) len += 9; dmap_add_container(evbuf, "mdcl", len); /* 8 + len */ if (flags.selected) dmap_add_char(evbuf, "caia", 1); /* 9 */ if (flags.has_password) dmap_add_char(evbuf, "cahp", 1); /* 9 */ if (flags.has_video) dmap_add_char(evbuf, "caiv", 1); /* 9 */ dmap_add_string(evbuf, "minm", name); /* 8 + len */ dmap_add_long(evbuf, "msma", id); /* 16 */ dmap_add_int(evbuf, "cmvo", relvol); /* 12 */ } static int dacp_reply_getspeakers(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; struct evbuffer *spklist; int ret; ret = daap_session_find(h, &s); if (!s) goto out; spklist = evbuffer_new(); if (!spklist) { DPRINTF(E_LOG, L_DACP, "Could not create evbuffer for speaker list\n"); ret = dmap_send_error(h, "casp", "Out of memory"); goto out; } player_speaker_enumerate(speaker_enum_cb, spklist); dmap_add_container(evbuf, "casp", 12 + EVBUFFER_LENGTH(spklist)); /* 8 + len */ dmap_add_int(evbuf, "mstt", 200); /* 12 */ evbuffer_add_buffer(evbuf, spklist); evbuffer_free(spklist); ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) { ret = dmap_send_error(h, "casp", "Server error"); goto out; } return httpd_send_reply(h->c, h->req, h->r, evbuf); out: evbuffer_free(evbuf); return ret; } static int dacp_reply_setspeakers(struct httpd_hdl *h, struct evbuffer *evbuf, char **uri) { struct daap_session *s; const char *param; const char *ptr; uint64_t *ids; int nspk; int i; int ret; evbuffer_free(evbuf); ret = daap_session_find(h, &s); if (!s) return ret; param = keyval_get(h->query, "speaker-id"); if (!param) { DPRINTF(E_LOG, L_DACP, "Missing speaker-id parameter in DACP setspeakers request\n"); return http_server_error_run(h->c, h->r, HTTP_BAD_REQUEST, "Bad Request"); } if (strlen(param) == 0) { ids = NULL; goto fastpath; } nspk = 1; ptr = param; while ((ptr = strchr(ptr + 1, ','))) nspk++; ids = (uint64_t *)malloc((nspk + 1) * sizeof(uint64_t)); if (!ids) { DPRINTF(E_LOG, L_DACP, "Out of memory for speaker ids\n"); goto out_error; } param--; i = 1; do { param++; ret = safe_hextou64(param, &ids[i]); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Invalid speaker id in request: %s\n", param); nspk--; continue; } i++; } while ((param = strchr(param + 1, ','))); ids[0] = nspk; fastpath: ret = player_speaker_set(ids); if (ids) free(ids); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Speakers de/activation failed!\n"); /* Password problem */ if (ret == -2) { ret = http_response_set_status(h->r, 902, ""); if (ret < 0) goto out_error; } else goto out_error; } else { /* 204 No Content is the canonical reply */ ret = http_response_set_status(h->r, HTTP_NO_CONTENT, "No Content"); if (ret < 0) goto out_error; } ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static struct uri_map dacp_handlers[] = { { .regexp = "^/ctrl-int$", .handler = dacp_reply_ctrlint }, { .regexp = "^/ctrl-int/[[:digit:]]+/cue$", .handler = dacp_reply_cue }, { .regexp = "^/ctrl-int/[[:digit:]]+/playspec$", .handler = dacp_reply_playspec }, { .regexp = "^/ctrl-int/[[:digit:]]+/pause$", .handler = dacp_reply_pause }, { .regexp = "^/ctrl-int/[[:digit:]]+/playpause$", .handler = dacp_reply_playpause }, { .regexp = "^/ctrl-int/[[:digit:]]+/nextitem$", .handler = dacp_reply_nextitem }, { .regexp = "^/ctrl-int/[[:digit:]]+/previtem$", .handler = dacp_reply_previtem }, { .regexp = "^/ctrl-int/[[:digit:]]+/beginff$", .handler = dacp_reply_beginff }, { .regexp = "^/ctrl-int/[[:digit:]]+/beginrew$", .handler = dacp_reply_beginrew }, { .regexp = "^/ctrl-int/[[:digit:]]+/playresume$", .handler = dacp_reply_playresume }, { .regexp = "^/ctrl-int/[[:digit:]]+/playstatusupdate$", .handler = dacp_reply_playstatusupdate }, { .regexp = "^/ctrl-int/[[:digit:]]+/nowplayingartwork$", .handler = dacp_reply_nowplayingartwork }, { .regexp = "^/ctrl-int/[[:digit:]]+/getproperty$", .handler = dacp_reply_getproperty }, { .regexp = "^/ctrl-int/[[:digit:]]+/setproperty$", .handler = dacp_reply_setproperty }, { .regexp = "^/ctrl-int/[[:digit:]]+/getspeakers$", .handler = dacp_reply_getspeakers }, { .regexp = "^/ctrl-int/[[:digit:]]+/setspeakers$", .handler = dacp_reply_setspeakers }, { .regexp = NULL, .handler = NULL } }; int dacp_request(struct http_connection *c, struct http_request *req, struct http_response *r) { struct httpd_hdl hdl; struct keyval query; char *full_uri; char *uri; char *ptr; char *uri_parts[7]; struct evbuffer *evbuf; int handler; int ret; int i; memset(&query, 0, sizeof(struct keyval)); memset(&hdl, 0, sizeof(struct httpd_hdl)); full_uri = httpd_fixup_uri(req); if (!full_uri) return http_server_error_run(c, r, HTTP_BAD_REQUEST, "Bad Request"); ptr = strchr(full_uri, '?'); if (ptr) *ptr = '\0'; uri = strdup(full_uri); if (!uri) { free(full_uri); return http_server_error_run(c, r, HTTP_BAD_REQUEST, "Bad Request"); } if (ptr) *ptr = '?'; http_decode_uri(uri, URI_DECODE_NORMAL); DPRINTF(E_DBG, L_DACP, "DACP request: %s\n", full_uri); handler = -1; for (i = 0; dacp_handlers[i].handler; i++) { ret = tre_regexec(&dacp_handlers[i].preg, uri, 0, NULL, 0); if (ret == 0) { handler = i; break; } } if (handler < 0) { DPRINTF(E_LOG, L_DACP, "Unrecognized DACP request\n"); ret = http_server_error_run(c, r, HTTP_BAD_REQUEST, "Bad Request"); goto out; } /* DACP has no HTTP authentication - Remote is identified by its pairing-guid */ memset(uri_parts, 0, sizeof(uri_parts)); uri_parts[0] = strtok_r(uri, "/", &ptr); for (i = 1; (i < sizeof(uri_parts) / sizeof(uri_parts[0])) && uri_parts[i - 1]; i++) { uri_parts[i] = strtok_r(NULL, "/", &ptr); } if (!uri_parts[0] || uri_parts[i - 1] || (i < 2)) { DPRINTF(E_LOG, L_DACP, "DACP URI has too many/few components (%d)\n", (uri_parts[0]) ? i : 0); ret = http_server_error_run(c, r, HTTP_BAD_REQUEST, "Bad Request"); goto out; } ret = http_parse_query_string(full_uri, &query); if (ret < 0) { ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out; } ret = http_response_add_header(r, "DAAP-Server", PACKAGE "/" VERSION); if (ret < 0) { ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_clear_query; } /* Content-Type for all DACP replies; can be overriden as needed */ ret = http_response_add_header(r, "Content-Type", "application/x-dmap-tagged"); if (ret < 0) { ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_clear_query; } /* Freed in the handler */ evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_DACP, "Could not allocate evbuffer for DACP reply\n"); ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_clear_query; } ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_DACP, "Could not acquire database connection\n"); evbuffer_free(evbuf); ret = http_server_error_run(c, r, HTTP_INTERNAL_ERROR, "Internal Server Error"); goto out_clear_query; } hdl.c = c; hdl.req = req; hdl.r = r; hdl.query = &query; /* Freeze playstatus updates to avoid sending out updates for * transient statuses that could confuse Remote during DACP operations */ dispatch_suspend(updates_src); ret = dacp_handlers[handler].handler(&hdl, evbuf, uri_parts); /* Thaw playstatus updates */ dispatch_resume(updates_src); db_pool_release(); out_clear_query: keyval_clear(&query); out: free(uri); free(full_uri); return ret; } int dacp_is_request(char *uri) { if (strncmp(uri, "/ctrl-int/", strlen("/ctrl-int/")) == 0) return 1; if (strcmp(uri, "/ctrl-int") == 0) return 1; return 0; } int dacp_init(void) { char buf[64]; int i; int ret; seek_timer = NULL; current_rev = 2; update_requests = NULL; updates_sq = dispatch_queue_create("org.forked-daapd.dacp.updates", NULL); if (!updates_sq) { DPRINTF(E_FATAL, L_DACP, "Could not create dispatch queue for DACP update requests\n"); return -1; } seek_sq = dispatch_queue_create("org.forked-daapd.dacp.seek", NULL); if (!seek_sq) { DPRINTF(E_FATAL, L_DACP, "Could not create dispatch queue for DACP seek handling\n"); goto seek_sq_fail; } updates_src = dispatch_source_create(DISPATCH_SOURCE_TYPE_DATA_ADD, 0, 0, updates_sq); if (!updates_src) { DPRINTF(E_FATAL, L_DACP, "Could not create dispatch source for playstatus updates\n"); goto updates_src_fail; } dispatch_source_set_event_handler_f(updates_src, playstatus_update_cb); for (i = 0; dacp_handlers[i].handler; i++) { ret = tre_regcomp(&dacp_handlers[i].preg, dacp_handlers[i].regexp, REG_EXTENDED | REG_NOSUB); if (ret != 0) { tre_regerror(ret, &dacp_handlers[i].preg, buf, sizeof(buf)); DPRINTF(E_FATAL, L_DACP, "DACP init failed; regexp error: %s\n", buf); goto regexp_fail; } } player_set_update_handler(dacp_playstatus_update_handler); dispatch_resume(updates_src); return 0; regexp_fail: dispatch_resume(updates_src); dispatch_source_cancel(updates_src); dispatch_release(updates_src); updates_src_fail: dispatch_release(seek_sq); seek_sq_fail: dispatch_release(updates_sq); return -1; } void dacp_deinit(void) { int i; player_set_update_handler(NULL); for (i = 0; dacp_handlers[i].handler; i++) tre_regfree(&dacp_handlers[i].preg); dispatch_source_cancel(updates_src); dispatch_release(updates_src); dispatch_release(updates_sq); dispatch_sync(seek_sq, ^{ if (!seek_timer) return; dispatch_source_cancel(seek_timer); dispatch_release(seek_timer); }); dispatch_release(seek_sq); /* Pending update requests are removed during HTTP server shutdown */ } forked-daapd-0.19gcd/src/httpd_dacp.h0000664000175000017500000000042711633141135017055 0ustar julienjulien #ifndef __HTTPD_DACP_H__ #define __HTTPD_DACP_H__ #include "http.h" int dacp_init(void); void dacp_deinit(void); int dacp_request(struct http_connection *c, struct http_request *req, struct http_response *r); int dacp_is_request(char *uri); #endif /* !__HTTPD_DACP_H__ */ forked-daapd-0.19gcd/src/httpd_rsp.c0000664000175000017500000005632411633141135016754 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * * Adapted from mt-daapd: * Copyright (C) 2006-2007 Ron Pedde * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include "evbuffer/evbuffer.h" #include "logger.h" #include "db.h" #include "conffile.h" #include "misc.h" #include "http.h" #include "httpd.h" #include "transcode.h" #include "httpd_rsp.h" #include "rsp_query.h" #define RSP_VERSION "1.0" #define RSP_XML_ROOT "?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?" #define F_FULL (1 << 0) #define F_BROWSE (1 << 1) #define F_ID (1 << 2) #define F_DETAILED (1 << 3) #define F_ALWAYS (F_FULL | F_BROWSE | F_ID | F_DETAILED) struct field_map { char *field; size_t offset; int flags; }; struct uri_map { regex_t preg; char *regexp; int (*handler)(struct httpd_hdl *h, char **uri); }; static const struct field_map pl_fields[] = { { "id", dbpli_offsetof(id), F_ALWAYS }, { "title", dbpli_offsetof(title), F_FULL | F_BROWSE | F_DETAILED }, { "type", dbpli_offsetof(type), F_DETAILED }, { "items", dbpli_offsetof(items), F_FULL | F_BROWSE | F_DETAILED }, { "query", dbpli_offsetof(query), F_DETAILED }, { "db_timestamp", dbpli_offsetof(db_timestamp), F_DETAILED }, { "path", dbpli_offsetof(path), F_DETAILED }, { "index", dbpli_offsetof(index), F_DETAILED }, { NULL, 0, 0 } }; static const struct field_map rsp_fields[] = { { "id", dbmfi_offsetof(id), F_ALWAYS }, { "path", dbmfi_offsetof(path), F_DETAILED }, { "fname", dbmfi_offsetof(fname), F_DETAILED }, { "title", dbmfi_offsetof(title), F_ALWAYS }, { "artist", dbmfi_offsetof(artist), F_DETAILED | F_FULL | F_BROWSE }, { "album", dbmfi_offsetof(album), F_DETAILED | F_FULL | F_BROWSE }, { "genre", dbmfi_offsetof(genre), F_DETAILED | F_FULL }, { "comment", dbmfi_offsetof(comment), F_DETAILED | F_FULL }, { "type", dbmfi_offsetof(type), F_ALWAYS }, { "composer", dbmfi_offsetof(composer), F_DETAILED | F_FULL }, { "orchestra", dbmfi_offsetof(orchestra), F_DETAILED | F_FULL }, { "conductor", dbmfi_offsetof(conductor), F_DETAILED | F_FULL }, { "url", dbmfi_offsetof(url), F_DETAILED | F_FULL }, { "bitrate", dbmfi_offsetof(bitrate), F_DETAILED | F_FULL }, { "samplerate", dbmfi_offsetof(samplerate), F_DETAILED | F_FULL }, { "song_length", dbmfi_offsetof(song_length), F_DETAILED | F_FULL }, { "file_size", dbmfi_offsetof(file_size), F_DETAILED | F_FULL }, { "year", dbmfi_offsetof(year), F_DETAILED | F_FULL }, { "track", dbmfi_offsetof(track), F_DETAILED | F_FULL | F_BROWSE }, { "total_tracks", dbmfi_offsetof(total_tracks), F_DETAILED | F_FULL }, { "disc", dbmfi_offsetof(disc), F_DETAILED | F_FULL | F_BROWSE }, { "total_discs", dbmfi_offsetof(total_discs), F_DETAILED | F_FULL }, { "bpm", dbmfi_offsetof(bpm), F_DETAILED | F_FULL }, { "compilation", dbmfi_offsetof(compilation), F_DETAILED | F_FULL }, { "rating", dbmfi_offsetof(rating), F_DETAILED | F_FULL }, { "play_count", dbmfi_offsetof(play_count), F_DETAILED | F_FULL }, { "data_kind", dbmfi_offsetof(data_kind), F_DETAILED }, { "item_kind", dbmfi_offsetof(item_kind), F_DETAILED }, { "description", dbmfi_offsetof(description), F_DETAILED | F_FULL }, { "time_added", dbmfi_offsetof(time_added), F_DETAILED | F_FULL }, { "time_modified", dbmfi_offsetof(time_modified), F_DETAILED | F_FULL }, { "time_played", dbmfi_offsetof(time_played), F_DETAILED | F_FULL }, { "db_timestamp", dbmfi_offsetof(db_timestamp), F_DETAILED }, { "disabled", dbmfi_offsetof(disabled), F_ALWAYS }, { "sample_count", dbmfi_offsetof(sample_count), F_DETAILED }, { "codectype", dbmfi_offsetof(codectype), F_ALWAYS }, { "idx", dbmfi_offsetof(idx), F_DETAILED }, { "has_video", dbmfi_offsetof(has_video), F_DETAILED }, { "contentrating", dbmfi_offsetof(contentrating), F_DETAILED }, { NULL, 0, 0 } }; static struct evbuffer * mxml_to_evbuf(mxml_node_t *tree) { struct evbuffer *evbuf; char *xml; int ret; evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_RSP, "Could not create evbuffer for RSP reply\n"); return NULL; } xml = mxmlSaveAllocString(tree, MXML_NO_CALLBACK); if (!xml) { DPRINTF(E_LOG, L_RSP, "Could not finalize RSP reply\n"); evbuffer_free(evbuf); return NULL; } ret = evbuffer_add(evbuf, xml, strlen(xml)); free(xml); if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Could not load evbuffer for RSP reply\n"); evbuffer_free(evbuf); return NULL; } return evbuf; } /* Forward */ static int rsp_send_error(struct httpd_hdl *h, char *errmsg); static int get_query_params(struct httpd_hdl *h, struct query_params *qp) { const char *param; int ret; qp->offset = 0; param = keyval_get(h->query, "offset"); if (param) { ret = safe_atoi32(param, &qp->offset); if (ret < 0) return rsp_send_error(h, "Invalid offset"); } qp->limit = 0; param = keyval_get(h->query, "limit"); if (param) { ret = safe_atoi32(param, &qp->limit); if (ret < 0) return rsp_send_error(h, "Invalid limit"); } if (qp->offset || qp->limit) qp->idx_type = I_SUB; else qp->idx_type = I_NONE; qp->sort = S_NONE; param = keyval_get(h->query, "query"); if (param) { DPRINTF(E_DBG, L_RSP, "RSP browse query filter: %s\n", param); qp->filter = rsp_query_parse_sql(param); if (!qp->filter) DPRINTF(E_LOG, L_RSP, "Ignoring improper RSP query\n"); } return 1; } static int rsp_send_error(struct httpd_hdl *h, char *errmsg) { struct evbuffer *evbuf; mxml_node_t *reply; mxml_node_t *status; mxml_node_t *node; int ret; ret = http_response_add_header(h->r, "Connection", "close"); if (ret < 0) goto out_error; /* We'd use mxmlNewXML(), but then we can't put any attributes * on the root node and we need some. */ reply = mxmlNewElement(MXML_NO_PARENT, RSP_XML_ROOT); node = mxmlNewElement(reply, "response"); status = mxmlNewElement(node, "status"); /* Status block */ node = mxmlNewElement(status, "errorcode"); mxmlNewText(node, 0, "1"); node = mxmlNewElement(status, "errorstring"); mxmlNewText(node, 0, errmsg); node = mxmlNewElement(status, "records"); mxmlNewText(node, 0, "0"); node = mxmlNewElement(status, "totalrecords"); mxmlNewText(node, 0, "0"); evbuf = mxml_to_evbuf(reply); mxmlDelete(reply); if (!evbuf) goto out_error; http_response_set_body(h->r, evbuf); ret = http_response_add_header(h->r, "Content-Type", "text/xml; charset=utf-8"); if (ret < 0) goto out_error; ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) goto out_error; ret = http_server_response_run(h->c, h->r); if (ret < 0) goto out_error; return 0; out_error: return http_server_error_run(h->c, h->r, HTTP_INTERNAL_ERROR, "Internal Server Error"); } static int rsp_send_reply(struct httpd_hdl *h, mxml_node_t *reply) { struct evbuffer *evbuf; int ret; evbuf = mxml_to_evbuf(reply); mxmlDelete(reply); if (!evbuf) return rsp_send_error(h, "Could not finalize reply"); ret = http_response_add_header(h->r, "Connection", "close"); if (ret < 0) goto out_error; ret = http_response_add_header(h->r, "Content-Type", "text/xml; charset=utf-8"); if (ret < 0) goto out_error; ret = http_response_set_status(h->r, HTTP_OK, "OK"); if (ret < 0) goto out_error; return httpd_send_reply(h->c, h->req, h->r, evbuf); out_error: evbuffer_free(evbuf); return rsp_send_error(h, "Server error"); } static int rsp_reply_info(struct httpd_hdl *h, char **uri) { mxml_node_t *reply; mxml_node_t *status; mxml_node_t *info; mxml_node_t *node; cfg_t *lib; char *library; int songcount; songcount = db_files_get_count(); lib = cfg_getsec(cfg, "library"); library = cfg_getstr(lib, "name"); /* We'd use mxmlNewXML(), but then we can't put any attributes * on the root node and we need some. */ reply = mxmlNewElement(MXML_NO_PARENT, RSP_XML_ROOT); node = mxmlNewElement(reply, "response"); status = mxmlNewElement(node, "status"); info = mxmlNewElement(node, "info"); /* Status block */ node = mxmlNewElement(status, "errorcode"); mxmlNewText(node, 0, "0"); node = mxmlNewElement(status, "errorstring"); mxmlNewText(node, 0, ""); node = mxmlNewElement(status, "records"); mxmlNewText(node, 0, "0"); node = mxmlNewElement(status, "totalrecords"); mxmlNewText(node, 0, "0"); /* Info block */ node = mxmlNewElement(info, "count"); mxmlNewTextf(node, 0, "%d", songcount); node = mxmlNewElement(info, "rsp-version"); mxmlNewText(node, 0, RSP_VERSION); node = mxmlNewElement(info, "server-version"); mxmlNewText(node, 0, VERSION); node = mxmlNewElement(info, "name"); mxmlNewText(node, 0, library); return rsp_send_reply(h, reply); } static int rsp_reply_db(struct httpd_hdl *h, char **uri) { struct query_params qp; struct db_playlist_info dbpli; char **strval; mxml_node_t *reply; mxml_node_t *status; mxml_node_t *pls; mxml_node_t *pl; mxml_node_t *node; int i; int ret; memset(&qp, 0, sizeof(struct db_playlist_info)); qp.type = Q_PL; qp.idx_type = I_NONE; ret = db_query_start(&qp); if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Could not start query\n"); return rsp_send_error(h, "Could not start query"); } /* We'd use mxmlNewXML(), but then we can't put any attributes * on the root node and we need some. */ reply = mxmlNewElement(MXML_NO_PARENT, RSP_XML_ROOT); node = mxmlNewElement(reply, "response"); status = mxmlNewElement(node, "status"); pls = mxmlNewElement(node, "playlists"); /* Status block */ node = mxmlNewElement(status, "errorcode"); mxmlNewText(node, 0, "0"); node = mxmlNewElement(status, "errorstring"); mxmlNewText(node, 0, ""); node = mxmlNewElement(status, "records"); mxmlNewTextf(node, 0, "%d", qp.results); node = mxmlNewElement(status, "totalrecords"); mxmlNewTextf(node, 0, "%d", qp.results); /* Playlists block (all playlists) */ while (((ret = db_query_fetch_pl(&qp, &dbpli)) == 0) && (dbpli.id)) { /* Playlist block (one playlist) */ pl = mxmlNewElement(pls, "playlist"); for (i = 0; pl_fields[i].field; i++) { if (pl_fields[i].flags & F_FULL) { strval = (char **) ((char *)&dbpli + pl_fields[i].offset); node = mxmlNewElement(pl, pl_fields[i].field); mxmlNewText(node, 0, *strval); } } } if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Error fetching results\n"); mxmlDelete(reply); db_query_end(&qp); return rsp_send_error(h, "Error fetching query results"); } /* HACK * Add a dummy empty string to the playlists element if there is no data * to return - this prevents mxml from sending out an empty * tag that the SoundBridge does not handle. It's hackish, but it works. */ if (qp.results == 0) mxmlNewText(pls, 0, ""); db_query_end(&qp); return rsp_send_reply(h, reply); } static int rsp_reply_playlist(struct httpd_hdl *h, char **uri) { struct query_params qp; struct db_media_file_info dbmfi; const char *param; char **strval; mxml_node_t *reply; mxml_node_t *status; mxml_node_t *items; mxml_node_t *item; mxml_node_t *node; int mode; int records; int transcode; int32_t bitrate; int i; int ret; memset(&qp, 0, sizeof(struct query_params)); ret = safe_atoi32(uri[2], &qp.id); if (ret < 0) return rsp_send_error(h, "Invalid playlist ID"); if (qp.id == 0) qp.type = Q_ITEMS; else qp.type = Q_PLITEMS; mode = F_FULL; param = keyval_get(h->query, "type"); if (param) { if (strcasecmp(param, "full") == 0) mode = F_FULL; else if (strcasecmp(param, "browse") == 0) mode = F_BROWSE; else if (strcasecmp(param, "id") == 0) mode = F_ID; else if (strcasecmp(param, "detailed") == 0) mode = F_DETAILED; else DPRINTF(E_LOG, L_RSP, "Unknown browse mode %s\n", param); } ret = get_query_params(h, &qp); if (ret != 1) return ret; ret = db_query_start(&qp); if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Could not start query\n"); if (qp.filter) free(qp.filter); return rsp_send_error(h, "Could not start query"); } if (qp.offset > qp.results) records = 0; else if (qp.limit > (qp.results - qp.offset)) records = qp.results - qp.offset; else records = qp.limit; /* We'd use mxmlNewXML(), but then we can't put any attributes * on the root node and we need some. */ reply = mxmlNewElement(MXML_NO_PARENT, RSP_XML_ROOT); node = mxmlNewElement(reply, "response"); status = mxmlNewElement(node, "status"); items = mxmlNewElement(node, "items"); /* Status block */ node = mxmlNewElement(status, "errorcode"); mxmlNewText(node, 0, "0"); node = mxmlNewElement(status, "errorstring"); mxmlNewText(node, 0, ""); node = mxmlNewElement(status, "records"); mxmlNewTextf(node, 0, "%d", records); node = mxmlNewElement(status, "totalrecords"); mxmlNewTextf(node, 0, "%d", qp.results); /* Items block (all items) */ while (((ret = db_query_fetch_file(&qp, &dbmfi)) == 0) && (dbmfi.id)) { transcode = transcode_needed(h->req, dbmfi.codectype); /* Item block (one item) */ item = mxmlNewElement(items, "item"); for (i = 0; rsp_fields[i].field; i++) { if (!(rsp_fields[i].flags & mode)) continue; strval = (char **) ((char *)&dbmfi + rsp_fields[i].offset); if (!(*strval) || (strlen(*strval) == 0)) continue; node = mxmlNewElement(item, rsp_fields[i].field); if (!transcode) mxmlNewText(node, 0, *strval); else { switch (rsp_fields[i].offset) { case dbmfi_offsetof(type): mxmlNewText(node, 0, "wav"); break; case dbmfi_offsetof(bitrate): bitrate = 0; ret = safe_atoi32(dbmfi.samplerate, &bitrate); if ((ret < 0) || (bitrate == 0)) bitrate = 1411; else bitrate = (bitrate * 8) / 250; mxmlNewTextf(node, 0, "%d", bitrate); break; case dbmfi_offsetof(description): mxmlNewText(node, 0, "wav audio file"); break; case dbmfi_offsetof(codectype): mxmlNewText(node, 0, "wav"); node = mxmlNewElement(item, "original_codec"); mxmlNewText(node, 0, *strval); break; default: mxmlNewText(node, 0, *strval); break; } } } } if (qp.filter) free(qp.filter); if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Error fetching results\n"); mxmlDelete(reply); db_query_end(&qp); return rsp_send_error(h, "Error fetching query results"); } /* HACK * Add a dummy empty string to the items element if there is no data * to return - this prevents mxml from sending out an empty * tag that the SoundBridge does not handle. It's hackish, but it works. */ if (qp.results == 0) mxmlNewText(items, 0, ""); db_query_end(&qp); return rsp_send_reply(h, reply); } static int rsp_reply_browse(struct httpd_hdl *h, char **uri) { struct query_params qp; char *browse_item; mxml_node_t *reply; mxml_node_t *status; mxml_node_t *items; mxml_node_t *node; int records; int ret; memset(&qp, 0, sizeof(struct query_params)); if (strcmp(uri[3], "artist") == 0) qp.type = Q_BROWSE_ARTISTS; else if (strcmp(uri[3], "genre") == 0) qp.type = Q_BROWSE_GENRES; else if (strcmp(uri[3], "album") == 0) qp.type = Q_BROWSE_ALBUMS; else if (strcmp(uri[3], "composer") == 0) qp.type = Q_BROWSE_COMPOSERS; else { DPRINTF(E_LOG, L_RSP, "Unsupported browse type '%s'\n", uri[3]); return rsp_send_error(h, "Unsupported browse type"); } ret = safe_atoi32(uri[2], &qp.id); if (ret < 0) return rsp_send_error(h, "Invalid playlist ID"); ret = get_query_params(h, &qp); if (ret != 1) return ret; ret = db_query_start(&qp); if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Could not start query\n"); if (qp.filter) free(qp.filter); return rsp_send_error(h, "Could not start query"); } if (qp.offset > qp.results) records = 0; else if (qp.limit > (qp.results - qp.offset)) records = qp.results - qp.offset; else records = qp.limit; /* We'd use mxmlNewXML(), but then we can't put any attributes * on the root node and we need some. */ reply = mxmlNewElement(MXML_NO_PARENT, RSP_XML_ROOT); node = mxmlNewElement(reply, "response"); status = mxmlNewElement(node, "status"); items = mxmlNewElement(node, "items"); /* Status block */ node = mxmlNewElement(status, "errorcode"); mxmlNewText(node, 0, "0"); node = mxmlNewElement(status, "errorstring"); mxmlNewText(node, 0, ""); node = mxmlNewElement(status, "records"); mxmlNewTextf(node, 0, "%d", records); node = mxmlNewElement(status, "totalrecords"); mxmlNewTextf(node, 0, "%d", qp.results); /* Items block (all items) */ while (((ret = db_query_fetch_string(&qp, &browse_item)) == 0) && (browse_item)) { node = mxmlNewElement(items, "item"); mxmlNewText(node, 0, browse_item); } if (qp.filter) free(qp.filter); if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Error fetching results\n"); mxmlDelete(reply); db_query_end(&qp); return rsp_send_error(h, "Error fetching query results"); } /* HACK * Add a dummy empty string to the items element if there is no data * to return - this prevents mxml from sending out an empty * tag that the SoundBridge does not handle. It's hackish, but it works. */ if (qp.results == 0) mxmlNewText(items, 0, ""); db_query_end(&qp); return rsp_send_reply(h, reply); } static int rsp_stream(struct httpd_hdl *h, char **uri) { int id; int ret; ret = safe_atoi32(uri[2], &id); if (ret < 0) return http_server_error_run(h->c, h->r, HTTP_BAD_REQUEST, "Bad Request"); return httpd_stream_file(h->c, h->req, h->r, id); } static struct uri_map rsp_handlers[] = { { .regexp = "^/rsp/info$", .handler = rsp_reply_info }, { .regexp = "^/rsp/db$", .handler = rsp_reply_db }, { .regexp = "^/rsp/db/[[:digit:]]+$", .handler = rsp_reply_playlist }, { .regexp = "^/rsp/db/[[:digit:]]+/[^/]+$", .handler = rsp_reply_browse }, { .regexp = "^/rsp/stream/[[:digit:]]+$", .handler = rsp_stream }, { .regexp = NULL, .handler = NULL } }; int rsp_request(struct http_connection *c, struct http_request *req, struct http_response *r) { struct httpd_hdl hdl; struct keyval query; char *full_uri; char *uri; char *ptr; char *uri_parts[5]; cfg_t *lib; char *libname; char *passwd; int handler; int i; int ret; memset(&query, 0, sizeof(struct keyval)); memset(&hdl, 0, sizeof(struct httpd_hdl)); hdl.c = c; hdl.req = req; hdl.r = r; full_uri = httpd_fixup_uri(req); if (!full_uri) return rsp_send_error(&hdl, "Server error"); ptr = strchr(full_uri, '?'); if (ptr) *ptr = '\0'; uri = strdup(full_uri); if (!uri) { free(full_uri); return rsp_send_error(&hdl, "Server error"); } if (ptr) *ptr = '?'; http_decode_uri(uri, URI_DECODE_NORMAL); DPRINTF(E_DBG, L_RSP, "RSP request: %s\n", full_uri); handler = -1; for (i = 0; rsp_handlers[i].handler; i++) { ret = tre_regexec(&rsp_handlers[i].preg, uri, 0, NULL, 0); if (ret == 0) { handler = i; break; } } if (handler < 0) { DPRINTF(E_LOG, L_RSP, "Unrecognized RSP request\n"); ret = rsp_send_error(&hdl, "Bad path"); goto out; } /* Check authentication */ lib = cfg_getsec(cfg, "library"); passwd = cfg_getstr(lib, "password"); if (passwd) { libname = cfg_getstr(lib, "name"); DPRINTF(E_DBG, L_HTTPD, "Checking authentication for library '%s'\n", libname); /* We don't care about the username */ ret = httpd_basic_auth(c, req, r, NULL, passwd, libname); switch (ret) { case HTTP_OK: DPRINTF(E_DBG, L_HTTPD, "Library authentication successful\n"); break; case -1: ret = -1; goto out; default: /* HTTP_UNAUTHORIZED or HTTP_INTERNAL_ERROR on error */ ret = 0; goto out; } } memset(uri_parts, 0, sizeof(uri_parts)); uri_parts[0] = strtok_r(uri, "/", &ptr); for (i = 1; (i < sizeof(uri_parts) / sizeof(uri_parts[0])) && uri_parts[i - 1]; i++) { uri_parts[i] = strtok_r(NULL, "/", &ptr); } if (!uri_parts[0] || uri_parts[i - 1] || (i < 2)) { DPRINTF(E_LOG, L_RSP, "RSP URI has too many/few components (%d)\n", (uri_parts[0]) ? i : 0); ret = rsp_send_error(&hdl, "Bad path"); goto out; } ret = http_parse_query_string(full_uri, &query); if (ret < 0) { ret = rsp_send_error(&hdl, "Server error"); goto out; } ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Could not acquire database connection\n"); ret = rsp_send_error(&hdl, "Database error"); goto out_clear_query; } hdl.query = &query; ret = rsp_handlers[handler].handler(&hdl, uri_parts); db_pool_release(); out_clear_query: keyval_clear(&query); out: free(uri); free(full_uri); return ret; } int rsp_is_request(char *uri) { if (strncmp(uri, "/rsp/", strlen("/rsp/")) == 0) return 1; return 0; } int rsp_init(void) { char buf[64]; int i; int ret; for (i = 0; rsp_handlers[i].handler; i++) { ret = tre_regcomp(&rsp_handlers[i].preg, rsp_handlers[i].regexp, REG_EXTENDED | REG_NOSUB); if (ret != 0) { tre_regerror(ret, &rsp_handlers[i].preg, buf, sizeof(buf)); DPRINTF(E_FATAL, L_RSP, "RSP init failed; regexp error: %s\n", buf); return -1; } } return 0; } void rsp_deinit(void) { int i; for (i = 0; rsp_handlers[i].handler; i++) tre_regfree(&rsp_handlers[i].preg); } forked-daapd-0.19gcd/src/httpd_rsp.h0000664000175000017500000000042011633141135016743 0ustar julienjulien #ifndef __HTTPD_RSP_H__ #define __HTTPD_RSP_H__ #include "http.h" int rsp_init(void); void rsp_deinit(void); int rsp_request(struct http_connection *c, struct http_request *req, struct http_response *r); int rsp_is_request(char *uri); #endif /* !__HTTPD_RSP_H__ */ forked-daapd-0.19gcd/src/laudio.h0000664000175000017500000000130311633141135016212 0ustar julienjulien #ifndef __LAUDIO_H__ #define __LAUDIO_H__ #define LAUDIO_F_STARTED (1 << 15) enum laudio_state { LAUDIO_CLOSED = 0, LAUDIO_STOPPING = 1, LAUDIO_OPEN = 2, LAUDIO_STARTED = LAUDIO_F_STARTED, LAUDIO_RUNNING = LAUDIO_F_STARTED | 0x01, LAUDIO_FAILED = -1, }; typedef void (*laudio_status_cb)(enum laudio_state status); void laudio_write(uint8_t *buf, uint64_t rtptime); uint64_t laudio_get_pos(void); void laudio_set_volume(int vol); int laudio_start(uint64_t cur_pos, uint64_t next_pkt); void laudio_stop(void); int laudio_open(void); void laudio_close(void); int laudio_init(laudio_status_cb cb); void laudio_deinit(void); #endif /* !__LAUDIO_H__ */ forked-daapd-0.19gcd/src/laudio_alsa.c0000664000175000017500000003313411633141135017214 0ustar julienjulien/* * Copyright (C) 2010 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include "conffile.h" #include "logger.h" #include "player.h" #include "laudio.h" struct pcm_packet { uint8_t samples[STOB(AIRTUNES_V2_PACKET_SAMPLES)]; uint64_t rtptime; size_t offset; struct pcm_packet *next; }; static uint64_t pcm_pos; static uint64_t pcm_start_pos; static int pcm_last_error; static int pcm_recovery; static int pcm_buf_threshold; static struct pcm_packet *pcm_pkt_head; static struct pcm_packet *pcm_pkt_tail; static char *card_name; static char *mixer_name; static snd_pcm_t *hdl; static snd_mixer_t *mixer_hdl; static snd_mixer_elem_t *vol_elem; static long vol_min; static long vol_max; static enum laudio_state pcm_status; static laudio_status_cb status_cb; static void update_status(enum laudio_state status) { pcm_status = status; status_cb(status); } static int laudio_xrun_recover(int err) { int ret; if (err != 0) pcm_last_error = err; /* Buffer underrun */ if (err == -EPIPE) { pcm_last_error = 0; ret = snd_pcm_prepare(hdl); if (ret < 0) { DPRINTF(E_WARN, L_LAUDIO, "Couldn't recover from underrun: %s\n", snd_strerror(ret)); return 1; } return 0; } /* Device suspended */ else if (pcm_last_error == -ESTRPIPE) { ret = snd_pcm_resume(hdl); if (ret == -EAGAIN) { pcm_recovery++; return 2; } else if (ret < 0) { pcm_recovery = 0; ret = snd_pcm_prepare(hdl); if (ret < 0) { DPRINTF(E_WARN, L_LAUDIO, "Couldn't recover from suspend: %s\n", snd_strerror(ret)); return 1; } } pcm_recovery = 0; return 0; } return err; } static int laudio_set_start_threshold(snd_pcm_uframes_t threshold) { snd_pcm_sw_params_t *sw_params; int ret; ret = snd_pcm_sw_params_malloc(&sw_params); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not allocate sw params: %s\n", snd_strerror(ret)); goto out_fail; } ret = snd_pcm_sw_params_current(hdl, sw_params); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not retrieve current sw params: %s\n", snd_strerror(ret)); goto out_fail; } ret = snd_pcm_sw_params_set_start_threshold(hdl, sw_params, threshold); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set start threshold: %s\n", snd_strerror(ret)); goto out_fail; } ret = snd_pcm_sw_params(hdl, sw_params); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set sw params: %s\n", snd_strerror(ret)); goto out_fail; } return 0; out_fail: snd_pcm_sw_params_free(sw_params); return -1; } void laudio_write(uint8_t *buf, uint64_t rtptime) { struct pcm_packet *pkt; snd_pcm_sframes_t nsamp; int ret; pkt = (struct pcm_packet *)malloc(sizeof(struct pcm_packet)); if (!pkt) { DPRINTF(E_LOG, L_LAUDIO, "Out of memory for PCM pkt\n"); update_status(LAUDIO_FAILED); return; } memcpy(pkt->samples, buf, sizeof(pkt->samples)); pkt->rtptime = rtptime; pkt->offset = 0; pkt->next = NULL; if (pcm_pkt_tail) { pcm_pkt_tail->next = pkt; pcm_pkt_tail = pkt; } else { pcm_pkt_head = pkt; pcm_pkt_tail = pkt; } if (pcm_pos < pcm_pkt_head->rtptime) { pcm_pos += AIRTUNES_V2_PACKET_SAMPLES; return; } else if ((pcm_status != LAUDIO_RUNNING) && (pcm_pos >= pcm_start_pos)) { /* Kill threshold */ ret = laudio_set_start_threshold(0); if (ret < 0) DPRINTF(E_WARN, L_LAUDIO, "Couldn't set PCM start threshold to 0 for output start\n"); update_status(LAUDIO_RUNNING); } pkt = pcm_pkt_head; while (pkt) { if (pcm_recovery) { ret = laudio_xrun_recover(0); if ((ret == 2) && (pcm_recovery < 10)) return; else { if (ret == 2) DPRINTF(E_LOG, L_LAUDIO, "Couldn't recover PCM device after 10 tries, aborting\n"); update_status(LAUDIO_FAILED); return; } } nsamp = snd_pcm_writei(hdl, pkt->samples + pkt->offset, BTOS(sizeof(pkt->samples) - pkt->offset)); if ((nsamp == -EPIPE) || (nsamp == -ESTRPIPE)) { ret = laudio_xrun_recover(nsamp); if ((ret < 0) || (ret == 1)) { if (ret < 0) DPRINTF(E_LOG, L_LAUDIO, "PCM write error: %s\n", snd_strerror(ret)); update_status(LAUDIO_FAILED); return; } else if (ret != 0) return; continue; } else if (nsamp < 0) { DPRINTF(E_LOG, L_LAUDIO, "PCM write error: %s\n", snd_strerror(nsamp)); update_status(LAUDIO_FAILED); return; } pcm_pos += nsamp; pkt->offset += STOB(nsamp); if (pkt->offset == sizeof(pkt->samples)) { pcm_pkt_head = pkt->next; if (pkt == pcm_pkt_tail) pcm_pkt_tail = NULL; free(pkt); pkt = pcm_pkt_head; } /* Don't let ALSA fill up the buffer too much */ if (nsamp == AIRTUNES_V2_PACKET_SAMPLES) return; } } uint64_t laudio_get_pos(void) { snd_pcm_sframes_t delay; int ret; if (pcm_pos == 0) return 0; ret = snd_pcm_delay(hdl, &delay); if (ret < 0) { DPRINTF(E_WARN, L_LAUDIO, "Could not obtain PCM delay: %s\n", snd_strerror(ret)); return pcm_pos; } return pcm_pos - delay; } void laudio_set_volume(int vol) { int pcm_vol; if (!mixer_hdl || !vol_elem) return; snd_mixer_handle_events(mixer_hdl); if (!snd_mixer_selem_is_active(vol_elem)) return; switch (vol) { case 0: pcm_vol = vol_min; break; case 100: pcm_vol = vol_max; break; default: pcm_vol = vol_min + (vol * (vol_max - vol_min)) / 100; break; } DPRINTF(E_DBG, L_LAUDIO, "Setting PCM volume to %d (%d)\n", pcm_vol, vol); snd_mixer_selem_set_playback_volume_all(vol_elem, pcm_vol); } int laudio_start(uint64_t cur_pos, uint64_t next_pkt) { int ret; ret = snd_pcm_prepare(hdl); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not prepare PCM device: %s\n", snd_strerror(ret)); return -1; } DPRINTF(E_DBG, L_LAUDIO, "PCM will start after %d samples (%d packets)\n", pcm_buf_threshold, pcm_buf_threshold / AIRTUNES_V2_PACKET_SAMPLES); /* Make pcm_pos the rtptime of the packet containing cur_pos */ pcm_pos = next_pkt; while (pcm_pos > cur_pos) pcm_pos -= AIRTUNES_V2_PACKET_SAMPLES; pcm_start_pos = next_pkt + pcm_buf_threshold; /* Compensate threshold, as it's taken into account by snd_pcm_delay() */ pcm_pos += pcm_buf_threshold; DPRINTF(E_DBG, L_LAUDIO, "PCM pos %" PRIu64 ", start pos %" PRIu64 "\n", pcm_pos, pcm_start_pos); pcm_pkt_head = NULL; pcm_pkt_tail = NULL; pcm_last_error = 0; pcm_recovery = 0; ret = laudio_set_start_threshold(pcm_buf_threshold); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set PCM start threshold for local audio start\n"); return -1; } update_status(LAUDIO_STARTED); return 0; } void laudio_stop(void) { struct pcm_packet *pkt; update_status(LAUDIO_STOPPING); snd_pcm_drop(hdl); for (pkt = pcm_pkt_head; pcm_pkt_head; pkt = pcm_pkt_head) { pcm_pkt_head = pkt->next; free(pkt); } pcm_pkt_head = NULL; pcm_pkt_tail = NULL; update_status(LAUDIO_OPEN); } static int mixer_open(void) { snd_mixer_elem_t *elem; snd_mixer_elem_t *master; snd_mixer_elem_t *pcm; snd_mixer_elem_t *custom; snd_mixer_selem_id_t *sid; int ret; ret = snd_mixer_open(&mixer_hdl, 0); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Failed to open mixer: %s\n", snd_strerror(ret)); mixer_hdl = NULL; return -1; } ret = snd_mixer_attach(mixer_hdl, card_name); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Failed to attach mixer: %s\n", snd_strerror(ret)); goto out_close; } ret = snd_mixer_selem_register(mixer_hdl, NULL, NULL); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Failed to register mixer: %s\n", snd_strerror(ret)); goto out_detach; } ret = snd_mixer_load(mixer_hdl); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Failed to load mixer: %s\n", snd_strerror(ret)); goto out_detach; } /* Grab interesting elements */ snd_mixer_selem_id_alloca(&sid); pcm = NULL; master = NULL; custom = NULL; for (elem = snd_mixer_first_elem(mixer_hdl); elem; elem = snd_mixer_elem_next(elem)) { snd_mixer_selem_get_id(elem, sid); if (mixer_name && (strcmp(snd_mixer_selem_id_get_name(sid), mixer_name) == 0)) { custom = elem; break; } else if (strcmp(snd_mixer_selem_id_get_name(sid), "PCM") == 0) pcm = elem; else if (strcmp(snd_mixer_selem_id_get_name(sid), "Master") == 0) master = elem; } if (mixer_name) { if (custom) vol_elem = custom; else { DPRINTF(E_LOG, L_LAUDIO, "Failed to open configured mixer element '%s'\n", mixer_name); goto out_detach; } } else if (pcm) vol_elem = pcm; else if (master) vol_elem = master; else { DPRINTF(E_LOG, L_LAUDIO, "Failed to open PCM or Master mixer element\n"); goto out_detach; } /* Get min & max volume */ snd_mixer_selem_get_playback_volume_range(vol_elem, &vol_min, &vol_max); return 0; out_detach: snd_mixer_detach(mixer_hdl, card_name); out_close: snd_mixer_close(mixer_hdl); mixer_hdl = NULL; vol_elem = NULL; return -1; } int laudio_open(void) { snd_pcm_hw_params_t *hw_params; snd_pcm_uframes_t bufsize; int ret; hw_params = NULL; ret = snd_pcm_open(&hdl, card_name, SND_PCM_STREAM_PLAYBACK, 0); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not open playback device: %s\n", snd_strerror(ret)); return -1; } /* HW params */ ret = snd_pcm_hw_params_malloc(&hw_params); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not allocate hw params: %s\n", snd_strerror(ret)); goto out_fail; } ret = snd_pcm_hw_params_any(hdl, hw_params); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not retrieve hw params: %s\n", snd_strerror(ret)); goto out_fail; } ret = snd_pcm_hw_params_set_access(hdl, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set access method: %s\n", snd_strerror(ret)); goto out_fail; } ret = snd_pcm_hw_params_set_format(hdl, hw_params, SND_PCM_FORMAT_S16_LE); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set S16LE format: %s\n", snd_strerror(ret)); goto out_fail; } ret = snd_pcm_hw_params_set_channels(hdl, hw_params, 2); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set stereo output: %s\n", snd_strerror(ret)); goto out_fail; } ret = snd_pcm_hw_params_set_rate(hdl, hw_params, 44100, 0); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Hardware doesn't support 44.1 kHz: %s\n", snd_strerror(ret)); goto out_fail; } ret = snd_pcm_hw_params_get_buffer_size_max(hw_params, &bufsize); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not get max buffer size: %s\n", snd_strerror(ret)); goto out_fail; } DPRINTF(E_DBG, L_LAUDIO, "Max buffer size is %lu samples\n", bufsize); ret = snd_pcm_hw_params_set_buffer_size_max(hdl, hw_params, &bufsize); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set buffer size to max: %s\n", snd_strerror(ret)); goto out_fail; } DPRINTF(E_DBG, L_LAUDIO, "Buffer size is %lu samples\n", bufsize); ret = snd_pcm_hw_params(hdl, hw_params); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set hw params: %s\n", snd_strerror(ret)); goto out_fail; } snd_pcm_hw_params_free(hw_params); hw_params = NULL; pcm_pos = 0; pcm_last_error = 0; pcm_recovery = 0; pcm_buf_threshold = (bufsize / AIRTUNES_V2_PACKET_SAMPLES) * AIRTUNES_V2_PACKET_SAMPLES; ret = mixer_open(); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not open mixer\n"); goto out_fail; } update_status(LAUDIO_OPEN); return 0; out_fail: if (hw_params) snd_pcm_hw_params_free(hw_params); snd_pcm_close(hdl); hdl = NULL; return -1; } void laudio_close(void) { struct pcm_packet *pkt; snd_pcm_close(hdl); hdl = NULL; if (mixer_hdl) { snd_mixer_detach(mixer_hdl, card_name); snd_mixer_close(mixer_hdl); mixer_hdl = NULL; vol_elem = NULL; } for (pkt = pcm_pkt_head; pcm_pkt_head; pkt = pcm_pkt_head) { pcm_pkt_head = pkt->next; free(pkt); } pcm_pkt_head = NULL; pcm_pkt_tail = NULL; update_status(LAUDIO_CLOSED); } int laudio_init(laudio_status_cb cb) { snd_lib_error_set_handler(logger_alsa); status_cb = cb; card_name = cfg_getstr(cfg_getsec(cfg, "audio"), "card"); mixer_name = cfg_getstr(cfg_getsec(cfg, "audio"), "mixer"); hdl = NULL; mixer_hdl = NULL; vol_elem = NULL; return 0; } void laudio_deinit(void) { snd_lib_error_set_handler(NULL); } forked-daapd-0.19gcd/src/laudio_oss4.c0000664000175000017500000002112111633141135017155 0ustar julienjulien/* * Copyright (C) 2010 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include "conffile.h" #include "logger.h" #include "player.h" #include "laudio.h" struct pcm_packet { uint8_t samples[STOB(AIRTUNES_V2_PACKET_SAMPLES)]; uint64_t rtptime; size_t offset; struct pcm_packet *next; }; static uint64_t pcm_pos; static uint64_t pcm_start_pos; static int pcm_buf_threshold; static int pcm_retry; static struct pcm_packet *pcm_pkt_head; static struct pcm_packet *pcm_pkt_tail; static char *card_name; static int oss_fd; static enum laudio_state pcm_status; static laudio_status_cb status_cb; static void update_status(enum laudio_state status) { pcm_status = status; status_cb(status); } void laudio_write(uint8_t *buf, uint64_t rtptime) { struct pcm_packet *pkt; int scratch; int nsamp; int ret; pkt = (struct pcm_packet *)malloc(sizeof(struct pcm_packet)); if (!pkt) { DPRINTF(E_LOG, L_LAUDIO, "Out of memory for PCM pkt\n"); update_status(LAUDIO_FAILED); return; } memcpy(pkt->samples, buf, sizeof(pkt->samples)); pkt->rtptime = rtptime; pkt->offset = 0; pkt->next = NULL; if (pcm_pkt_tail) { pcm_pkt_tail->next = pkt; pcm_pkt_tail = pkt; } else { pcm_pkt_head = pkt; pcm_pkt_tail = pkt; } if (pcm_pos < pcm_pkt_head->rtptime) { pcm_pos += AIRTUNES_V2_PACKET_SAMPLES; return; } else if ((pcm_status != LAUDIO_RUNNING) && (pcm_pos >= pcm_start_pos)) { /* Start audio output */ scratch = PCM_ENABLE_OUTPUT; ret = ioctl(oss_fd, SNDCTL_DSP_SETTRIGGER, &scratch); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not enable output: %s\n", strerror(errno)); update_status(LAUDIO_FAILED); return; } update_status(LAUDIO_RUNNING); } pkt = pcm_pkt_head; while (pkt) { nsamp = write(oss_fd, pkt->samples + pkt->offset, sizeof(pkt->samples) - pkt->offset); if (nsamp < 0) { if (errno == EAGAIN) { pcm_retry++; if (pcm_retry < 10) return; } DPRINTF(E_LOG, L_LAUDIO, "Write error: %s\n", strerror(errno)); update_status(LAUDIO_FAILED); return; } pcm_retry = 0; pkt->offset += nsamp; nsamp = BTOS(nsamp); pcm_pos += nsamp; if (pkt->offset == sizeof(pkt->samples)) { pcm_pkt_head = pkt->next; if (pkt == pcm_pkt_tail) pcm_pkt_tail = NULL; free(pkt); pkt = pcm_pkt_head; } /* Don't let the buffer fill up too much */ if (nsamp == AIRTUNES_V2_PACKET_SAMPLES) break; } } uint64_t laudio_get_pos(void) { int delay; int ret; ret = ioctl(oss_fd, SNDCTL_DSP_GETODELAY, &delay); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not obtain output delay: %s\n", strerror(errno)); return pcm_pos; } return pcm_pos - BTOS(delay); } void laudio_set_volume(int vol) { int oss_vol; int ret; vol = vol & 0xff; oss_vol = vol | (vol << 8); ret = ioctl(oss_fd, SNDCTL_DSP_SETPLAYVOL, &oss_vol); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set volume: %s\n", strerror(errno)); return; } DPRINTF(E_DBG, L_LAUDIO, "Setting PCM volume to %d (real: %d)\n", vol, (oss_vol & 0xff)); } int laudio_start(uint64_t cur_pos, uint64_t next_pkt) { int scratch; int ret; DPRINTF(E_DBG, L_LAUDIO, "PCM will start after %d samples (%d packets)\n", pcm_buf_threshold, pcm_buf_threshold / AIRTUNES_V2_PACKET_SAMPLES); /* Make pcm_pos the rtptime of the packet containing cur_pos */ pcm_pos = next_pkt; while (pcm_pos > cur_pos) pcm_pos -= AIRTUNES_V2_PACKET_SAMPLES; pcm_start_pos = next_pkt + pcm_buf_threshold; /* FIXME check for OSS - Compensate threshold, as it's taken into account by snd_pcm_delay() */ pcm_pos += pcm_buf_threshold; DPRINTF(E_DBG, L_LAUDIO, "PCM pos %" PRIu64 ", start pos %" PRIu64 "\n", pcm_pos, pcm_start_pos); pcm_pkt_head = NULL; pcm_pkt_tail = NULL; pcm_retry = 0; scratch = 0; ret = ioctl(oss_fd, SNDCTL_DSP_SETTRIGGER, &scratch); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set trigger: %s\n", strerror(errno)); return -1; } update_status(LAUDIO_STARTED); return 0; } void laudio_stop(void) { struct pcm_packet *pkt; int ret; update_status(LAUDIO_STOPPING); ret = ioctl(oss_fd, SNDCTL_DSP_HALT_OUTPUT, NULL); if (ret < 0) DPRINTF(E_LOG, L_LAUDIO, "Failed to halt output: %s\n", strerror(errno)); for (pkt = pcm_pkt_head; pcm_pkt_head; pkt = pcm_pkt_head) { pcm_pkt_head = pkt->next; free(pkt); } pcm_pkt_head = NULL; pcm_pkt_tail = NULL; update_status(LAUDIO_OPEN); } int laudio_open(void) { audio_buf_info bi; int scratch; int ret; oss_fd = open(card_name, O_RDWR | O_NONBLOCK); if (oss_fd < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not open sound device: %s\n", strerror(errno)); return -1; } scratch = 0; ret = ioctl(oss_fd, SNDCTL_DSP_SETTRIGGER, &scratch); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Could not set trigger: %s\n", strerror(errno)); goto out_fail; } scratch = AFMT_S16_LE; errno = 0; ret = ioctl(oss_fd, SNDCTL_DSP_SETFMT, &scratch); if ((ret < 0) || (scratch != AFMT_S16_LE)) { if (errno) DPRINTF(E_LOG, L_LAUDIO, "Could not set sample format (S16 LE): %s\n", strerror(errno)); else DPRINTF(E_LOG, L_LAUDIO, "Sample format S16 LE not supported\n"); goto out_fail; } scratch = 2; errno = 0; ret = ioctl(oss_fd, SNDCTL_DSP_CHANNELS, &scratch); if ((ret < 0) || (scratch != 2)) { if (errno) DPRINTF(E_LOG, L_LAUDIO, "Could not set stereo: %s\n", strerror(errno)); else DPRINTF(E_LOG, L_LAUDIO, "Stereo not supported\n"); goto out_fail; } scratch = 44100; errno = 0; ret = ioctl(oss_fd, SNDCTL_DSP_SPEED, &scratch); if ((ret < 0) || (scratch != 44100)) { if (errno) DPRINTF(E_LOG, L_LAUDIO, "Could not set speed (44100): %s\n", strerror(errno)); else DPRINTF(E_LOG, L_LAUDIO, "Sample rate 44100 not supported\n"); goto out_fail; } ret = ioctl(oss_fd, SNDCTL_DSP_GETOSPACE, &bi); if (ret < 0) { DPRINTF(E_LOG, L_LAUDIO, "Couldn't get output buffer status: %s\n", strerror(errno)); goto out_fail; } pcm_buf_threshold = (BTOS(bi.bytes) / AIRTUNES_V2_PACKET_SAMPLES) * AIRTUNES_V2_PACKET_SAMPLES; update_status(LAUDIO_OPEN); return 0; out_fail: close(oss_fd); oss_fd = -1; return -1; } void laudio_close(void) { struct pcm_packet *pkt; int ret; ret = ioctl(oss_fd, SNDCTL_DSP_HALT_OUTPUT, NULL); if (ret < 0) DPRINTF(E_LOG, L_LAUDIO, "Failed to halt output: %s\n", strerror(errno)); close(oss_fd); oss_fd = -1; for (pkt = pcm_pkt_head; pcm_pkt_head; pkt = pcm_pkt_head) { pcm_pkt_head = pkt->next; free(pkt); } pcm_pkt_head = NULL; pcm_pkt_tail = NULL; update_status(LAUDIO_CLOSED); } int laudio_init(laudio_status_cb cb) { oss_sysinfo si; int ret; status_cb = cb; pcm_status = LAUDIO_CLOSED; card_name = cfg_getstr(cfg_getsec(cfg, "audio"), "card"); oss_fd = open(card_name, O_RDWR); if (oss_fd < 0) { DPRINTF(E_FATAL, L_LAUDIO, "Could not open sound device: %s\n", strerror(errno)); return -1; } ret = ioctl(oss_fd, SNDCTL_SYSINFO, &si); close(oss_fd); oss_fd = -1; if (ret < 0) { DPRINTF(E_FATAL, L_LAUDIO, "Could not check OSS version: %s\n", strerror(errno)); return -1; } if (si.versionnum < 0x040000) { DPRINTF(E_FATAL, L_LAUDIO, "Your OSS version (%s) is too old; version 4.0.0+ is required\n", si.version); return -1; } return 0; } void laudio_deinit(void) { /* EMPTY */ } forked-daapd-0.19gcd/src/logger.c0000664000175000017500000001527311633141135016222 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include "conffile.h" #include "logger.h" static dispatch_queue_t logger_sq; static int logsync; static int logdomains; static int threshold; static int console; static char *logfilename; static FILE *logfile; static char *labels[] = { "config", "daap", "db", "httpd", "main", "mdns", "misc", "rsp", "scan", "xcode", "-free-", "remote", "dacp", "ffmpeg", "artwork", "player", "raop", "laudio", "dmap", "dbperf", "http" }; static int set_logdomains(char *domains) { char *ptr; char *d; int i; logdomains = 0; while ((d = strtok_r(domains, " ,", &ptr))) { domains = NULL; for (i = 0; i < N_LOGDOMAINS; i++) { if (strcmp(d, labels[i]) == 0) { logdomains |= (1 << i); break; } } if (i == N_LOGDOMAINS) { fprintf(stderr, "Error: unknown log domain '%s'\n", d); return -1; } } return 0; } static void vlogger(int severity, int domain, const char *fmt, va_list args) { va_list ap; char *msg; time_t t; int ret; dispatch_block_t logblock; if (!((1 << domain) & logdomains) || (severity > threshold)) return; t = time(NULL); va_copy(ap, args); ret = vsnprintf(NULL, 0, fmt, ap); va_end(ap); if (ret <= 0) return; msg = (char *)malloc(ret + 1); if (!msg) return; va_copy(ap, args); ret = vsnprintf(msg, ret + 1, fmt, ap); va_end(ap); if (ret < 0) { free(msg); return; } logblock = ^{ char stamp[32]; int ret; if (!logfile && !console) { free(msg); return; } if (logfile) { ret = strftime(stamp, sizeof(stamp), "%Y-%m-%d %H:%M:%S", localtime(&t)); if (ret == 0) stamp[0] = '\0'; fprintf(logfile, "[%s] %8s: %s", stamp, labels[domain], msg); fflush(logfile); } if (console) fprintf(stderr, "%8s: %s", labels[domain], msg); free(msg); }; if (logsync) dispatch_sync(logger_sq, logblock); else dispatch_async(logger_sq, logblock); } static void vlogger_early(int severity, int domain, const char *fmt, va_list args) { va_list ap; char stamp[32]; time_t t; int ret; if (!((1 << domain) & logdomains) || (severity > threshold)) return; if (!logfile && !console) return; if (logfile) { t = time(NULL); ret = strftime(stamp, sizeof(stamp), "%Y-%m-%d %H:%M:%S", localtime(&t)); if (ret == 0) stamp[0] = '\0'; fprintf(logfile, "[%s] %8s: ", stamp, labels[domain]); va_copy(ap, args); vfprintf(logfile, fmt, ap); va_end(ap); fflush(logfile); } if (console) { fprintf(stderr, "%8s: ", labels[domain]); va_copy(ap, args); vfprintf(stderr, fmt, ap); va_end(ap); } } void DPRINTF(int severity, int domain, const char *fmt, ...) { va_list ap; va_start(ap, fmt); if (!logger_sq) vlogger_early(severity, domain, fmt, ap); else vlogger(severity, domain, fmt, ap); va_end(ap); } void logger_ffmpeg(void *ptr, int level, const char *fmt, va_list ap) { int severity; /* Can't use a switch() because some definitions have the same value */ if ((level == AV_LOG_FATAL) || (level == AV_LOG_ERROR)) severity = E_LOG; else if ((level == AV_LOG_WARNING) || (level == AV_LOG_INFO) || (level == AV_LOG_VERBOSE)) severity = E_WARN; else if (level == AV_LOG_DEBUG) severity = E_DBG; else if (level == AV_LOG_QUIET) severity = E_SPAM; else severity = E_LOG; vlogger(severity, L_FFMPEG, fmt, ap); } #ifdef LAUDIO_USE_ALSA void logger_alsa(const char *file, int line, const char *function, int err, const char *fmt, ...) { va_list ap; va_start(ap, fmt); vlogger(E_LOG, L_LAUDIO, fmt, ap); va_end(ap); } #endif /* LAUDIO_USE_ALSA */ /* Queue: logger_sq */ static void logger_reinit_task(void *arg) { FILE *fp; if (!logfile) return; fp = fopen(logfilename, "a"); if (!fp) { DPRINTF(E_LOG, L_MAIN, "Could not reopen logfile: %s\n", strerror(errno)); return; } fclose(logfile); logfile = fp; } void logger_reinit(void) { if (!logger_sq) return; dispatch_sync_f(logger_sq, NULL, logger_reinit_task); } /* The functions below are used at init time before switching to dispatch mode */ void logger_domains(void) { int i; fprintf(stdout, "%s", labels[0]); for (i = 1; i < N_LOGDOMAINS; i++) fprintf(stdout, ", %s", labels[i]); fprintf(stdout, "\n"); } void logger_detach(void) { console = 0; } int logger_start_dispatch(int sync) { logger_sq = dispatch_queue_create("org.forked-daapd.logger", NULL); if (!logger_sq) return -1; logsync = sync; return 0; } int logger_init(char *file, char *domains, int severity) { int ret; if ((sizeof(labels) / sizeof(labels[0])) != N_LOGDOMAINS) { fprintf(stderr, "WARNING: log domains do not match\n"); return -1; } logger_sq = NULL; console = 1; threshold = severity; if (domains) { ret = set_logdomains(domains); if (ret < 0) return ret; } else logdomains = ~0; if (!file) return 0; logfile = fopen(file, "a"); if (!logfile) { fprintf(stderr, "Could not open logfile %s: %s\n", file, strerror(errno)); return -1; } ret = fchown(fileno(logfile), runas_uid, 0); if (ret < 0) fprintf(stderr, "Failed to set ownership on logfile: %s\n", strerror(errno)); ret = fchmod(fileno(logfile), 0644); if (ret < 0) fprintf(stderr, "Failed to set permissions on logfile: %s\n", strerror(errno)); logfilename = file; return 0; } void logger_deinit(void) { if (logger_sq) { dispatch_sync(logger_sq, ^{ if (logfile) fclose(logfile); }); dispatch_release(logger_sq); logger_sq = NULL; } else { if (logfile) fclose(logfile); } } forked-daapd-0.19gcd/src/logger.h0000664000175000017500000000227411633141135016224 0ustar julienjulien #ifndef __LOGGER_H__ #define __LOGGER_H__ #include /* Log domains */ #define L_CONF 0 #define L_DAAP 1 #define L_DB 2 #define L_HTTPD 3 #define L_MAIN 4 #define L_MDNS 5 #define L_MISC 6 #define L_RSP 7 #define L_SCAN 8 #define L_XCODE 9 /* 10 - free */ #define L_REMOTE 11 #define L_DACP 12 #define L_FFMPEG 13 #define L_ART 14 #define L_PLAYER 15 #define L_RAOP 16 #define L_LAUDIO 17 #define L_DMAP 18 #define L_DBPERF 19 #define L_HTTP 20 #define N_LOGDOMAINS 21 /* Severities */ #define E_FATAL 0 #define E_LOG 1 #define E_WARN 2 #define E_INFO 3 #define E_DBG 4 #define E_SPAM 5 void DPRINTF(int severity, int domain, const char *fmt, ...) __attribute__((format(printf, 3, 4))); void logger_ffmpeg(void *ptr, int level, const char *fmt, va_list ap); #ifdef LAUDIO_USE_ALSA void logger_alsa(const char *file, int line, const char *function, int err, const char *fmt, ...); #endif void logger_reinit(void); void logger_domains(void); void logger_detach(void); int logger_start_dispatch(int sync); int logger_init(char *file, char *domains, int severity); void logger_deinit(void); #endif /* !__LOGGER_H__ */ forked-daapd-0.19gcd/src/main.c0000664000175000017500000004627411633141135015674 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * * Pieces from mt-daapd: * Copyright (C) 2003 Ron Pedde (ron@pedde.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include GCRY_THREAD_OPTION_PTHREAD_IMPL; #include "conffile.h" #include "db.h" #include "logger.h" #include "misc.h" #include "filescanner.h" #include "httpd.h" #include "mdns.h" #include "remote_pairing.h" #include "player.h" #if LIBAVFORMAT_VERSION_MAJOR < 53 # include "ffmpeg_url_evbuffer.h" #endif #define PIDFILE STATEDIR "/run/" PACKAGE ".pid" typedef enum { SHUTDOWN_SIG_INT = -2, SHUTDOWN_SIG_TERM = -1, SHUTDOWN_PLAN_NOMINAL = 0, SHUTDOWN_FAIL_SIGNAL, SHUTDOWN_FAIL_MDNSREG, SHUTDOWN_FAIL_REMOTE, SHUTDOWN_FAIL_HTTPD, SHUTDOWN_FAIL_PLAYER, SHUTDOWN_FAIL_FILESCANNER, SHUTDOWN_FAIL_DB, SHUTDOWN_FAIL_MDNS, SHUTDOWN_FAIL_LOGGER, SHUTDOWN_FAIL_DAEMON, SHUTDOWN_FAIL_GCRYPT, SHUTDOWN_FAIL_FFMPEG, } shutdown_plan_t; static dispatch_source_t chld_src; static dispatch_source_t term_src; static dispatch_source_t int_src; static dispatch_source_t hup_src; static char *pidfile; static int background; static void version(void) { fprintf(stdout, "Forked Media Server: Version %s\n", VERSION); fprintf(stdout, "Copyright (C) 2009-2011 Julien BLACHE \n"); fprintf(stdout, "Released under the GNU General Public License version 2 or later\n"); } static void usage(char *program) { version(); printf("\n"); printf("Usage: %s [options]\n\n", program); printf("Options:\n"); printf(" -d Log level (0-5)\n"); printf(" -D Log domains\n"); printf(" -c Use as the configfile\n"); printf(" -P Write PID to specified file\n"); printf(" -f Run in foreground\n"); printf(" -b ffid to be broadcast\n"); printf(" -v Display version information\n"); printf("\n\n"); printf("Available log domains:\n"); logger_domains(); printf("\n\n"); } static int daemonize(void) { FILE *fp; pid_t childpid; pid_t pid_ret; int fd; int ret; char *runas; if (background) { fp = fopen(pidfile, "w"); if (!fp) { DPRINTF(E_LOG, L_MAIN, "Error opening pidfile (%s): %s\n", pidfile, strerror(errno)); return -1; } fd = open("/dev/null", O_RDWR, 0); if (fd < 0) { DPRINTF(E_LOG, L_MAIN, "Error opening /dev/null: %s\n", strerror(errno)); fclose(fp); return -1; } signal(SIGTTOU, SIG_IGN); signal(SIGTTIN, SIG_IGN); signal(SIGTSTP, SIG_IGN); childpid = fork(); if (childpid > 0) exit(EXIT_SUCCESS); else if (childpid < 0) { DPRINTF(E_FATAL, L_MAIN, "Fork failed: %s\n", strerror(errno)); close(fd); fclose(fp); return -1; } pid_ret = setsid(); if (pid_ret == (pid_t) -1) { DPRINTF(E_FATAL, L_MAIN, "setsid() failed: %s\n", strerror(errno)); close(fd); fclose(fp); return -1; } logger_detach(); dup2(fd, STDIN_FILENO); dup2(fd, STDOUT_FILENO); dup2(fd, STDERR_FILENO); if (fd > 2) close(fd); ret = chdir("/"); if (ret < 0) DPRINTF(E_WARN, L_MAIN, "chdir() failed: %s\n", strerror(errno)); umask(0); fprintf(fp, "%d\n", getpid()); fclose(fp); DPRINTF(E_DBG, L_MAIN, "PID: %d\n", getpid()); } if (geteuid() == (uid_t) 0) { runas = cfg_getstr(cfg_getsec(cfg, "general"), "uid"); ret = initgroups(runas, runas_gid); if (ret != 0) { DPRINTF(E_FATAL, L_MAIN, "initgroups() failed: %s\n", strerror(errno)); return -1; } ret = setegid(runas_gid); if (ret != 0) { DPRINTF(E_FATAL, L_MAIN, "setegid() failed: %s\n", strerror(errno)); return -1; } ret = seteuid(runas_uid); if (ret != 0) { DPRINTF(E_FATAL, L_MAIN, "seteuid() failed: %s\n", strerror(errno)); return -1; } } return 0; } static int register_services(char *ffid, int no_rsp, int no_daap) { cfg_t *lib; char *libname; char *password; char *txtrecord[10]; char records[9][128]; int port; uint32_t hash; int i; int ret; srand((unsigned int)time(NULL)); lib = cfg_getsec(cfg, "library"); libname = cfg_getstr(lib, "name"); hash = djb_hash(libname, strlen(libname)); for (i = 0; i < (sizeof(records) / sizeof(records[0])); i++) { memset(records[i], 0, 128); txtrecord[i] = records[i]; } txtrecord[9] = NULL; snprintf(txtrecord[0], 128, "txtvers=1"); snprintf(txtrecord[1], 128, "Database ID=%0X", hash); snprintf(txtrecord[2], 128, "Machine ID=%0X", hash); snprintf(txtrecord[3], 128, "Machine Name=%s", libname); snprintf(txtrecord[4], 128, "mtd-version=%s", VERSION); snprintf(txtrecord[5], 128, "iTSh Version=131073"); /* iTunes 6.0.4 */ snprintf(txtrecord[6], 128, "Version=196610"); /* iTunes 6.0.4 */ password = cfg_getstr(lib, "password"); snprintf(txtrecord[7], 128, "Password=%s", (password) ? "true" : "false"); if (ffid) snprintf(txtrecord[8], 128, "ffid=%s", ffid); else snprintf(txtrecord[8], 128, "ffid=%08x", rand()); DPRINTF(E_INFO, L_MAIN, "Registering rendezvous names\n"); port = cfg_getint(lib, "port"); /* Register web server service */ ret = mdns_register(libname, "_http._tcp", port, txtrecord); if (ret < 0) return ret; /* Register RSP service */ if (!no_rsp) { ret = mdns_register(libname, "_rsp._tcp", port, txtrecord); if (ret < 0) return ret; } /* Register DAAP service */ if (!no_daap) { ret = mdns_register(libname, "_daap._tcp", port, txtrecord); if (ret < 0) return ret; } for (i = 0; i < (sizeof(records) / sizeof(records[0])); i++) { memset(records[i], 0, 128); } snprintf(txtrecord[0], 128, "txtvers=1"); snprintf(txtrecord[1], 128, "DbId=%016" PRIX64, libhash); snprintf(txtrecord[2], 128, "DvTy=iTunes"); snprintf(txtrecord[3], 128, "DvSv=2306"); /* Magic number! Yay! */ snprintf(txtrecord[4], 128, "Ver=131073"); /* iTunes 6.0.4 */ snprintf(txtrecord[5], 128, "OSsi=0x1F5"); /* Magic number! Yay! */ snprintf(txtrecord[6], 128, "CtlN=%s", libname); /* Terminator */ txtrecord[7] = NULL; /* The group name for the touch-able service advertising is a 64bit hash * but is different from the DbId in iTunes. For now we'll use a hash of * the library name for both, and we'll change that if needed. */ /* Use as scratch space for the hash */ snprintf(records[7], 128, "%016" PRIX64, libhash); /* Register touch-able service, for Remote.app */ ret = mdns_register(records[7], "_touch-able._tcp", port, txtrecord); if (ret < 0) return ret; return 0; } static int ffmpeg_lockmgr(void **mutex, enum AVLockOp op) { dispatch_semaphore_t dsem; dsem = (dispatch_semaphore_t)*mutex; switch (op) { case AV_LOCK_CREATE: dsem = dispatch_semaphore_create(1); if (!dsem) return 1; *mutex = dsem; return 0; case AV_LOCK_OBTAIN: dispatch_semaphore_wait(dsem, DISPATCH_TIME_FOREVER); return 0; case AV_LOCK_RELEASE: dispatch_semaphore_signal(dsem); return 0; case AV_LOCK_DESTROY: dispatch_release(dsem); return 0; } return 1; } static void app_startup(int logsync, int mdns_no_rsp, int mdns_no_daap, char *ffid); static void app_shutdown(shutdown_plan_t plan); int main(int argc, char **argv) { int option; char *configfile; int mdns_no_rsp; int mdns_no_daap; int loglevel; int logsync; char *logdomains; char *logfile; char *ffid; const char *gcry_version; dispatch_queue_t main_q; shutdown_plan_t shutdown_plan; int ret; struct option option_map[] = { { "ffid", 1, NULL, 'b' }, { "debug", 1, NULL, 'd' }, { "synclog", 0, NULL, 's' }, { "logdomains", 1, NULL, 'D' }, { "foreground", 0, NULL, 'f' }, { "config", 1, NULL, 'c' }, { "pidfile", 1, NULL, 'P' }, { "version", 0, NULL, 'v' }, { "mdns-no-rsp", 0, NULL, 512 }, { "mdns-no-daap", 0, NULL, 513 }, { NULL, 0, NULL, 0 } }; configfile = CONFFILE; pidfile = PIDFILE; loglevel = -1; logsync = 0; logdomains = NULL; logfile = NULL; background = 1; ffid = NULL; mdns_no_rsp = 0; mdns_no_daap = 0; int_src = NULL; term_src = NULL; hup_src = NULL; chld_src = NULL; while ((option = getopt_long(argc, argv, "D:d:sc:P:fb:v", option_map, NULL)) != -1) { switch (option) { case 512: mdns_no_rsp = 1; break; case 513: mdns_no_daap = 1; break; case 'b': ffid = optarg; break; case 'd': ret = safe_atoi32(optarg, &option); if (ret < 0) fprintf(stderr, "Error: loglevel must be an integer in '-d %s'\n", optarg); else loglevel = option; break; case 'D': logdomains = optarg; break; case 's': logsync = 1; break; case 'f': background = 0; break; case 'c': configfile = optarg; break; case 'P': pidfile = optarg; break; case 'v': version(); return EXIT_SUCCESS; break; default: usage(argv[0]); return EXIT_FAILURE; break; } } ret = logger_init(NULL, NULL, (loglevel < 0) ? E_LOG : loglevel); if (ret != 0) { fprintf(stderr, "Could not initialize log facility\n"); return EXIT_FAILURE; } ret = conffile_load(configfile); if (ret != 0) { DPRINTF(E_FATAL, L_MAIN, "Config file errors; please fix your config\n"); logger_deinit(); return EXIT_FAILURE; } logger_deinit(); /* Reinit log facility with configfile values */ if (loglevel < 0) loglevel = cfg_getint(cfg_getsec(cfg, "general"), "loglevel"); logfile = cfg_getstr(cfg_getsec(cfg, "general"), "logfile"); ret = logger_init(logfile, logdomains, loglevel); if (ret != 0) { fprintf(stderr, "Could not reinitialize log facility with config file settings\n"); conffile_unload(); return EXIT_FAILURE; } DPRINTF(E_LOG, L_MAIN, "Forked Media Server Version %s taking off\n", VERSION); /* Initialize ffmpeg */ avcodec_init(); ret = av_lockmgr_register(ffmpeg_lockmgr); if (ret < 0) { DPRINTF(E_FATAL, L_MAIN, "Could not register ffmpeg lock manager callback\n"); shutdown_plan = SHUTDOWN_FAIL_FFMPEG; goto startup_fail; } av_register_all(); av_log_set_callback(logger_ffmpeg); #if LIBAVFORMAT_VERSION_MAJOR < 53 register_ffmpeg_evbuffer_url_protocol(); #endif /* Initialize libgcrypt */ gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread); gcry_version = gcry_check_version(GCRYPT_VERSION); if (!gcry_version) { DPRINTF(E_FATAL, L_MAIN, "libgcrypt version mismatch\n"); shutdown_plan = SHUTDOWN_FAIL_GCRYPT; goto startup_fail; } /* We aren't handling anything sensitive, so give up on secure * memory, which is a scarce system resource. */ gcry_control(GCRYCTL_DISABLE_SECMEM, 0); gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0); DPRINTF(E_DBG, L_MAIN, "Initialized with gcrypt %s\n", gcry_version); /* Daemonize and drop privileges */ ret = daemonize(); if (ret < 0) { DPRINTF(E_LOG, L_MAIN, "Could not initialize server\n"); shutdown_plan = SHUTDOWN_FAIL_DAEMON; goto startup_fail; } main_q = dispatch_get_main_queue(); if (!main_q) { DPRINTF(E_FATAL, L_MAIN, "Could not get main dispatch queue\n"); shutdown_plan = SHUTDOWN_FAIL_DAEMON; goto startup_fail; } dispatch_async(main_q, ^{ app_startup(logsync, mdns_no_rsp, mdns_no_daap, ffid); }); dispatch_main(); /* NOT REACHED */ startup_fail: app_shutdown(shutdown_plan); /* NOT REACHED */ exit(EXIT_FAILURE); return 0; } static void app_startup(int logsync, int mdns_no_rsp, int mdns_no_daap, char *ffid) { dispatch_queue_t main_q; shutdown_plan_t shutdown_plan; int ret; main_q = dispatch_get_current_queue(); /* Switch logger into dispatch mode (after forking) */ ret = logger_start_dispatch(logsync); if (ret < 0) { DPRINTF(E_FATAL, L_MAIN, "Could not switch logger to dispatch mode\n"); shutdown_plan = SHUTDOWN_FAIL_LOGGER; goto startup_fail; } DPRINTF(E_DBG, L_MAIN, "Logger switched to dispatch mode\n"); DPRINTF(E_LOG, L_MAIN, "mDNS init\n"); ret = mdns_init(); if (ret != 0) { DPRINTF(E_FATAL, L_MAIN, "mDNS init failed\n"); shutdown_plan = SHUTDOWN_FAIL_MDNS; goto startup_fail; } /* Initialize the database before starting */ DPRINTF(E_INFO, L_MAIN, "Initializing database\n"); ret = db_init(); if (ret < 0) { DPRINTF(E_FATAL, L_MAIN, "Database init failed\n"); shutdown_plan = SHUTDOWN_FAIL_DB; goto startup_fail; } /* Spawn file scanner thread */ ret = filescanner_init(); if (ret != 0) { DPRINTF(E_FATAL, L_MAIN, "File scanner thread failed to start\n"); shutdown_plan = SHUTDOWN_FAIL_FILESCANNER; goto startup_fail; } /* Spawn player thread */ ret = player_init(); if (ret != 0) { DPRINTF(E_FATAL, L_MAIN, "Player thread failed to start\n"); shutdown_plan = SHUTDOWN_FAIL_PLAYER; goto startup_fail; } /* Spawn HTTPd thread */ ret = httpd_init(); if (ret != 0) { DPRINTF(E_FATAL, L_MAIN, "HTTPd thread failed to start\n"); shutdown_plan = SHUTDOWN_FAIL_HTTPD; goto startup_fail; } /* Start Remote pairing service */ ret = remote_pairing_init(); if (ret != 0) { DPRINTF(E_FATAL, L_MAIN, "Remote pairing service failed to start\n"); shutdown_plan = SHUTDOWN_FAIL_REMOTE; goto startup_fail; } /* Register mDNS services */ ret = register_services(ffid, mdns_no_rsp, mdns_no_daap); if (ret < 0) { shutdown_plan = SHUTDOWN_FAIL_MDNSREG; goto startup_fail; } /* Set up signal dispatch sources */ signal(SIGINT, SIG_IGN); int_src = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGINT, 0, main_q); if (!int_src) { DPRINTF(E_FATAL, L_MAIN, "Could not create dispatch source for SIGINT\n"); shutdown_plan = SHUTDOWN_FAIL_SIGNAL; goto startup_fail; } dispatch_source_set_event_handler(int_src, ^{ app_shutdown(SHUTDOWN_SIG_INT); }); dispatch_resume(int_src); signal(SIGTERM, SIG_IGN); term_src = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGTERM, 0, main_q); if (!term_src) { DPRINTF(E_FATAL, L_MAIN, "Could not create dispatch source for SIGTERM\n"); shutdown_plan = SHUTDOWN_FAIL_SIGNAL; goto startup_fail; } dispatch_source_set_event_handler(term_src, ^{ app_shutdown(SHUTDOWN_SIG_TERM); }); dispatch_resume(term_src); signal(SIGHUP, SIG_IGN); hup_src = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGHUP, 0, main_q); if (!hup_src) { DPRINTF(E_FATAL, L_MAIN, "Could not create dispatch source for SIGHUP\n"); shutdown_plan = SHUTDOWN_FAIL_SIGNAL; goto startup_fail; } dispatch_source_set_event_handler(hup_src, ^{ DPRINTF(E_LOG, L_MAIN, "Got SIGHUP\n"); logger_reinit(); }); dispatch_resume(hup_src); signal(SIGCHLD, SIG_IGN); chld_src = dispatch_source_create(DISPATCH_SOURCE_TYPE_SIGNAL, SIGCHLD, 0, main_q); if (!chld_src) { DPRINTF(E_FATAL, L_MAIN, "Could not create dispatch source for SIGCHLD\n"); shutdown_plan = SHUTDOWN_FAIL_SIGNAL; goto startup_fail; } dispatch_source_set_event_handler(chld_src, ^{ int status; DPRINTF(E_LOG, L_MAIN, "Got SIGCHLD, reaping children\n"); while (wait3(&status, WNOHANG, NULL) > 0) /* Nothing. */ ; }); dispatch_resume(chld_src); return; startup_fail: app_shutdown(shutdown_plan); /* NOT REACHED */ exit(EXIT_FAILURE); } static void app_shutdown(shutdown_plan_t plan) { int ret; if (int_src) dispatch_source_cancel(int_src); if (term_src) dispatch_source_cancel(term_src); if (hup_src) dispatch_source_cancel(hup_src); if (chld_src) dispatch_source_cancel(chld_src); if (int_src) dispatch_release(int_src); if (term_src) dispatch_release(term_src); if (hup_src) dispatch_release(hup_src); if (chld_src) dispatch_release(chld_src); ret = EXIT_FAILURE; switch (plan) { case SHUTDOWN_SIG_INT: case SHUTDOWN_SIG_TERM: DPRINTF(E_LOG, L_MAIN, "Got SIGTERM or SIGINT\n"); /* FALLTHROUGH */ case SHUTDOWN_PLAN_NOMINAL: DPRINTF(E_LOG, L_MAIN, "Stopping gracefully\n"); ret = EXIT_SUCCESS; /* * On a clean shutdown, bring mDNS down first to give a chance * to the clients to perform a clean shutdown on their end */ DPRINTF(E_LOG, L_MAIN, "mDNS deinit\n"); mdns_deinit(); /* FALLTHROUGH */ case SHUTDOWN_FAIL_SIGNAL: case SHUTDOWN_FAIL_MDNSREG: DPRINTF(E_LOG, L_MAIN, "Remote pairing deinit\n"); remote_pairing_deinit(); /* FALLTHROUGH */ case SHUTDOWN_FAIL_REMOTE: DPRINTF(E_LOG, L_MAIN, "HTTPd deinit\n"); httpd_deinit(); /* FALLTHROUGH */ case SHUTDOWN_FAIL_HTTPD: DPRINTF(E_LOG, L_MAIN, "Player deinit\n"); player_deinit(); /* FALLTHROUGH */ case SHUTDOWN_FAIL_PLAYER: DPRINTF(E_LOG, L_MAIN, "File scanner deinit\n"); filescanner_deinit(); /* FALLTHROUGH */ case SHUTDOWN_FAIL_FILESCANNER: DPRINTF(E_LOG, L_MAIN, "Database deinit\n"); db_deinit(); /* FALLTHROUGH */ case SHUTDOWN_FAIL_DB: if (ret == EXIT_FAILURE) { DPRINTF(E_LOG, L_MAIN, "mDNS deinit\n"); mdns_deinit(); } /* FALLTHROUGH */ case SHUTDOWN_FAIL_MDNS: case SHUTDOWN_FAIL_LOGGER: case SHUTDOWN_FAIL_DAEMON: if (background) { ret = seteuid(0); if (ret < 0) DPRINTF(E_LOG, L_MAIN, "seteuid() failed: %s\n", strerror(errno)); else { ret = unlink(pidfile); if (ret < 0) DPRINTF(E_LOG, L_MAIN, "Could not unlink PID file %s: %s\n", pidfile, strerror(errno)); } } /* FALLTHROUGH */ case SHUTDOWN_FAIL_GCRYPT: av_lockmgr_register(NULL); /* FALLTHROUGH */ case SHUTDOWN_FAIL_FFMPEG: DPRINTF(E_LOG, L_MAIN, "Exiting.\n"); conffile_unload(); logger_deinit(); break; } exit(ret); } forked-daapd-0.19gcd/src/mdns.h0000664000175000017500000000130311633141135015676 0ustar julienjulien #ifndef __MDNS_H__ #define __MDNS_H__ #include "misc.h" #define MDNS_WANT_V4 (1 << 0) #define MDNS_WANT_V4LL (1 << 1) #define MDNS_WANT_V6 (1 << 2) #define MDNS_WANT_V6LL (1 << 3) #define MDNS_WANT_DEFAULT (MDNS_WANT_V4 | MDNS_WANT_V6 | MDNS_WANT_V6LL) typedef void (* mdns_browse_cb)(const char *name, const char *type, const char *domain, const char *hostname, int family, const char *address, int port, struct keyval *txt); /* mDNS interface functions */ /* Call only from the main thread */ int mdns_init(void); void mdns_deinit(void); int mdns_register(char *name, char *type, int port, char **txt); int mdns_browse(char *type, int flags, mdns_browse_cb cb); #endif /* !__MDNS_H__ */ forked-daapd-0.19gcd/src/mdns_avahi.c0000664000175000017500000006555111633141135017060 0ustar julienjulien/* * Avahi mDNS backend, with libdispatch polling * * Copyright (C) 2009-2011 Julien BLACHE * * Pieces coming from mt-daapd: * Copyright (C) 2005 Sebastian Dröge * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "logger.h" #include "mdns.h" static dispatch_queue_t mdns_sq; static AvahiClient *mdns_client = NULL; static AvahiEntryGroup *mdns_group = NULL; struct AvahiWatch { int fd; dispatch_source_t w_read; dispatch_source_t w_write; AvahiWatchCallback cb; void *userdata; AvahiWatch *next; }; struct AvahiTimeout { dispatch_source_t timer; AvahiTimeoutCallback cb; void *userdata; AvahiTimeout *next; }; static AvahiWatch *all_w; static AvahiTimeout *all_t; /* libdispatch callbacks */ static void gcdpollcb_watch_read(void *arg) { AvahiWatch *w; w = (AvahiWatch *)arg; w->cb(w, w->fd, AVAHI_WATCH_IN, w->userdata); } static void gcdpollcb_watch_write(void *arg) { AvahiWatch *w; w = (AvahiWatch *)arg; w->cb(w, w->fd, AVAHI_WATCH_OUT, w->userdata); } /* timer cb (cancel + release) */ static void gcdpollcb_timer(void *arg) { AvahiTimeout *t; t = (AvahiTimeout *)arg; if (t->timer) { dispatch_source_cancel(t->timer); dispatch_release(t->timer); t->timer = NULL; } t->cb(t, t->userdata); } /* AvahiPoll implementation for GCD / libdispatch */ static int _gcdpoll_watch_add(AvahiWatch *w, AvahiWatchEvent a_events) { dispatch_source_t sr = NULL; dispatch_source_t sw = NULL; if ((a_events & AVAHI_WATCH_IN) && !w->w_read) { sr = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, w->fd, 0, mdns_sq); if (!sr) return -1; dispatch_set_context(sr, w); dispatch_source_set_event_handler_f(sr, gcdpollcb_watch_read); } if ((a_events & AVAHI_WATCH_OUT) && !w->w_write) { sw = dispatch_source_create(DISPATCH_SOURCE_TYPE_WRITE, w->fd, 0, mdns_sq); if (!sw) { if (sr) { dispatch_source_cancel(sr); dispatch_release(sr); } return -1; } dispatch_set_context(sw, w); dispatch_source_set_event_handler_f(sw, gcdpollcb_watch_write); } if (sr) { w->w_read = sr; dispatch_resume(sr); } if (sw) { w->w_write = sw; dispatch_resume(sw); } return 0; } static AvahiWatch * gcdpoll_watch_new(const AvahiPoll *api, int fd, AvahiWatchEvent a_events, AvahiWatchCallback cb, void *userdata) { AvahiWatch *w; int ret; w = (AvahiWatch *)malloc(sizeof(AvahiWatch)); if (!w) return NULL; memset(w, 0, sizeof(AvahiWatch)); w->fd = fd; w->cb = cb; w->userdata = userdata; ret = _gcdpoll_watch_add(w, a_events); if (ret != 0) { free(w); return NULL; } w->next = all_w; all_w = w; return w; } static void gcdpoll_watch_update(AvahiWatch *w, AvahiWatchEvent a_events) { if (w->w_read && !(a_events & AVAHI_WATCH_IN)) { dispatch_source_cancel(w->w_read); dispatch_release(w->w_read); w->w_read = NULL; } if (w->w_write && !(a_events & AVAHI_WATCH_OUT)) { dispatch_source_cancel(w->w_write); dispatch_release(w->w_write); w->w_write = NULL; } _gcdpoll_watch_add(w, a_events); } static AvahiWatchEvent gcdpoll_watch_get_events(AvahiWatch *w) { /* Not implemented, unused in the Avahi codebase */ return 0; } static void gcdpoll_watch_free(AvahiWatch *w) { AvahiWatch *prev; AvahiWatch *cur; if (w->w_read) { dispatch_source_cancel(w->w_read); dispatch_release(w->w_read); } if (w->w_write) { dispatch_source_cancel(w->w_write); dispatch_release(w->w_write); } prev = NULL; for (cur = all_w; cur; prev = cur, cur = cur->next) { if (cur != w) continue; if (prev == NULL) all_w = w->next; else prev->next = w->next; break; } free(w); } static int _gcdpoll_timeout_add(AvahiTimeout *t, const struct timeval *tv) { struct timeval e_tv; struct timeval now; int64_t nsecs; int ret; ret = gettimeofday(&now, NULL); if (ret != 0) return -1; if (!t->timer) { t->timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, mdns_sq); if (!t->timer) return -1; dispatch_set_context(t->timer, t); dispatch_source_set_event_handler_f(t->timer, gcdpollcb_timer); } else dispatch_suspend(t->timer); if ((tv->tv_sec == 0) && (tv->tv_usec == 0)) { dispatch_source_set_timer(t->timer, DISPATCH_TIME_NOW, DISPATCH_TIME_FOREVER /* one-shot */, 0); } else { timersub(tv, &now, &e_tv); nsecs = e_tv.tv_sec * NSEC_PER_SEC + e_tv.tv_usec * 1000; dispatch_source_set_timer(t->timer, dispatch_time(DISPATCH_TIME_NOW, nsecs), DISPATCH_TIME_FOREVER /* one-shot */, 0); } dispatch_resume(t->timer); return 0; } static AvahiTimeout * gcdpoll_timeout_new(const AvahiPoll *api, const struct timeval *tv, AvahiTimeoutCallback cb, void *userdata) { AvahiTimeout *t; int ret; t = (AvahiTimeout *)malloc(sizeof(AvahiTimeout)); if (!t) return NULL; memset(t, 0, sizeof(AvahiTimeout)); t->cb = cb; t->userdata = userdata; if (tv != NULL) { ret = _gcdpoll_timeout_add(t, tv); if (ret != 0) { free(t); return NULL; } } t->next = all_t; all_t = t; return t; } static void gcdpoll_timeout_update(AvahiTimeout *t, const struct timeval *tv) { if (tv) _gcdpoll_timeout_add(t, tv); else if (t->timer) { dispatch_source_cancel(t->timer); dispatch_release(t->timer); t->timer = NULL; } } static void gcdpoll_timeout_free(AvahiTimeout *t) { AvahiTimeout *prev; AvahiTimeout *cur; if (t->timer) { dispatch_source_cancel(t->timer); dispatch_release(t->timer); t->timer = NULL; } prev = NULL; for (cur = all_t; cur; prev = cur, cur = cur->next) { if (cur != t) continue; if (prev == NULL) all_t = t->next; else prev->next = t->next; break; } free(t); } static struct AvahiPoll gcdpoll_api = { .userdata = NULL, .watch_new = gcdpoll_watch_new, .watch_update = gcdpoll_watch_update, .watch_get_events = gcdpoll_watch_get_events, .watch_free = gcdpoll_watch_free, .timeout_new = gcdpoll_timeout_new, .timeout_update = gcdpoll_timeout_update, .timeout_free = gcdpoll_timeout_free }; /* Avahi client callbacks & helpers */ struct mdns_browser { char *type; mdns_browse_cb cb; int flags; struct mdns_browser *next; }; struct mdns_record_browser { struct mdns_browser *mb; char *name; char *domain; struct keyval txt_kv; unsigned short port; }; struct mdns_group_entry { char *name; char *type; int port; AvahiStringList *txt; struct mdns_group_entry *next; }; static struct mdns_browser *browser_list; static struct mdns_group_entry *group_entries; #define IPV4LL_NETWORK 0xA9FE0000 #define IPV4LL_NETMASK 0xFFFF0000 #define IPV6LL_NETWORK 0xFE80 #define IPV6LL_NETMASK 0xFFC0 static int is_v4ll(struct in_addr *addr) { return ((ntohl(addr->s_addr) & IPV4LL_NETMASK) == IPV4LL_NETWORK); } static int is_v6ll(struct in6_addr *addr) { return ((((addr->s6_addr[0] << 8) | addr->s6_addr[1]) & IPV6LL_NETMASK) == IPV6LL_NETWORK); } static void browse_record_callback_v4(AvahiRecordBrowser *b, AvahiIfIndex intf, AvahiProtocol proto, AvahiBrowserEvent event, const char *hostname, uint16_t clazz, uint16_t type, const void *rdata, size_t size, AvahiLookupResultFlags flags, void *userdata) { char address[INET_ADDRSTRLEN]; struct in_addr addr; struct mdns_record_browser *rb_data; int ll; rb_data = (struct mdns_record_browser *)userdata; switch (event) { case AVAHI_BROWSER_NEW: if (size != sizeof(addr.s_addr)) { DPRINTF(E_WARN, L_MDNS, "Got RR type A size %ld (should be %ld)\n", (long)size, (long)sizeof(addr.s_addr)); return; } memcpy(&addr.s_addr, rdata, sizeof(addr.s_addr)); ll = is_v4ll(&addr); if (ll && !(rb_data->mb->flags & MDNS_WANT_V4LL)) { DPRINTF(E_DBG, L_MDNS, "Discarding IPv4 LL, not interested (service %s)\n", rb_data->name); return; } else if (!ll && !(rb_data->mb->flags & MDNS_WANT_V4)) { DPRINTF(E_DBG, L_MDNS, "Discarding IPv4, not interested (service %s)\n", rb_data->name); return; } if (!inet_ntop(AF_INET, &addr.s_addr, address, sizeof(address))) { DPRINTF(E_LOG, L_MDNS, "Could not print IPv4 address: %s\n", strerror(errno)); return; } DPRINTF(E_DBG, L_MDNS, "Service %s, hostname %s resolved to %s\n", rb_data->name, hostname, address); /* Execute callback (mb->cb) with all the data */ rb_data->mb->cb(rb_data->name, rb_data->mb->type, rb_data->domain, hostname, AF_INET, address, rb_data->port, &rb_data->txt_kv); /* Got a suitable address, stop record browser */ break; case AVAHI_BROWSER_REMOVE: /* Not handled - record browser lifetime too short for this to happen */ return; case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: DPRINTF(E_DBG, L_MDNS, "Avahi Record Browser (%s v4): no more results (%s)\n", hostname, (event == AVAHI_BROWSER_CACHE_EXHAUSTED) ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW"); break; case AVAHI_BROWSER_FAILURE: DPRINTF(E_LOG, L_MDNS, "Avahi Record Browser (%s v4) failure: %s\n", hostname, avahi_strerror(avahi_client_errno(avahi_record_browser_get_client(b)))); break; } keyval_clear(&rb_data->txt_kv); free(rb_data->name); free(rb_data->domain); free(rb_data); avahi_record_browser_free(b); } static void browse_record_callback_v6(AvahiRecordBrowser *b, AvahiIfIndex intf, AvahiProtocol proto, AvahiBrowserEvent event, const char *hostname, uint16_t clazz, uint16_t type, const void *rdata, size_t size, AvahiLookupResultFlags flags, void *userdata) { char address[INET6_ADDRSTRLEN + IF_NAMESIZE + 1]; char ifname[IF_NAMESIZE]; struct in6_addr addr; struct mdns_record_browser *rb_data; int ll; int len; int ret; rb_data = (struct mdns_record_browser *)userdata; switch (event) { case AVAHI_BROWSER_NEW: if (size != sizeof(addr.s6_addr)) { DPRINTF(E_WARN, L_MDNS, "Got RR type AAAA size %ld (should be %ld)\n", (long)size, (long)sizeof(addr.s6_addr)); return; } memcpy(&addr.s6_addr, rdata, sizeof(addr.s6_addr)); ll = is_v6ll(&addr); if (ll && !(rb_data->mb->flags & MDNS_WANT_V6LL)) { DPRINTF(E_DBG, L_MDNS, "Discarding IPv6 LL, not interested (service %s)\n", rb_data->name); return; } else if (!ll && !(rb_data->mb->flags & MDNS_WANT_V6)) { DPRINTF(E_DBG, L_MDNS, "Discarding IPv6, not interested (service %s)\n", rb_data->name); return; } if (!inet_ntop(AF_INET6, &addr.s6_addr, address, sizeof(address))) { DPRINTF(E_LOG, L_MDNS, "Could not print IPv6 address: %s\n", strerror(errno)); return; } if (ll) { if (!if_indextoname(intf, ifname)) { DPRINTF(E_LOG, L_MDNS, "Could not map interface index %d to a name\n", intf); return; } len = strlen(address); ret = snprintf(address + len, sizeof(address) - len, "%%%s", ifname); if ((ret < 0) || (ret > sizeof(address) - len)) { DPRINTF(E_LOG, L_MDNS, "Buffer too short for scoped IPv6 LL\n"); return; } } DPRINTF(E_DBG, L_MDNS, "Service %s, hostname %s resolved to %s\n", rb_data->name, hostname, address); /* Execute callback (mb->cb) with all the data */ rb_data->mb->cb(rb_data->name, rb_data->mb->type, rb_data->domain, hostname, AF_INET6, address, rb_data->port, &rb_data->txt_kv); /* Got a suitable address, stop record browser */ break; case AVAHI_BROWSER_REMOVE: /* Not handled - record browser lifetime too short for this to happen */ return; case AVAHI_BROWSER_CACHE_EXHAUSTED: case AVAHI_BROWSER_ALL_FOR_NOW: DPRINTF(E_DBG, L_MDNS, "Avahi Record Browser (%s v6): no more results (%s)\n", hostname, (event == AVAHI_BROWSER_CACHE_EXHAUSTED) ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW"); break; case AVAHI_BROWSER_FAILURE: DPRINTF(E_LOG, L_MDNS, "Avahi Record Browser (%s v6) failure: %s\n", hostname, avahi_strerror(avahi_client_errno(avahi_record_browser_get_client(b)))); break; } /* Cleanup when done/error */ keyval_clear(&rb_data->txt_kv); free(rb_data->name); free(rb_data->domain); free(rb_data); avahi_record_browser_free(b); } static int spawn_record_browser(AvahiClient *c, AvahiIfIndex intf, AvahiProtocol proto, const char *hostname, const char *domain, uint16_t type, struct mdns_browser *mb, const char *name, uint16_t port, AvahiStringList *txt) { AvahiRecordBrowser *rb; struct mdns_record_browser *rb_data; char *key; char *value; char *ptr; size_t len; int ret; rb_data = (struct mdns_record_browser *)malloc(sizeof(struct mdns_record_browser)); if (!rb_data) { DPRINTF(E_LOG, L_MDNS, "Out of memory for record browser data\n"); return -1; } memset(rb_data, 0, sizeof(struct mdns_record_browser)); rb_data->mb = mb; rb_data->port = port; rb_data->name = strdup(name); if (!rb_data->name) { DPRINTF(E_LOG, L_MDNS, "Out of memory for service name\n"); goto out_free_rb; } rb_data->domain = strdup(domain); if (!rb_data->domain) { DPRINTF(E_LOG, L_MDNS, "Out of memory for service domain\n"); goto out_free_name; } while (txt) { len = avahi_string_list_get_size(txt); key = (char *)avahi_string_list_get_text(txt); ptr = memchr(key, '=', len); if (!ptr) { value = ""; len = 0; } else { *ptr = '\0'; value = ptr + 1; len -= strlen(key) + 1; } ret = keyval_add_size(&rb_data->txt_kv, key, value, len); if (ptr) *ptr = '='; if (ret < 0) { DPRINTF(E_LOG, L_MDNS, "Could not build TXT record keyval\n"); goto out_free_keyval; } txt = avahi_string_list_get_next(txt); } rb = NULL; switch (type) { case AVAHI_DNS_TYPE_A: rb = avahi_record_browser_new(c, intf, proto, hostname, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_A, 0, browse_record_callback_v4, rb_data); if (!rb) DPRINTF(E_LOG, L_MDNS, "Could not create v4 record browser for host %s: %s\n", hostname, avahi_strerror(avahi_client_errno(c))); break; case AVAHI_DNS_TYPE_AAAA: rb = avahi_record_browser_new(c, intf, proto, hostname, AVAHI_DNS_CLASS_IN, AVAHI_DNS_TYPE_AAAA, 0, browse_record_callback_v6, rb_data); if (!rb) DPRINTF(E_LOG, L_MDNS, "Could not create v4 record browser for host %s: %s\n", hostname, avahi_strerror(avahi_client_errno(c))); break; } if (!rb) goto out_free_keyval; return 0; out_free_keyval: keyval_clear(&rb_data->txt_kv); free(rb_data->domain); out_free_name: free(rb_data->name); out_free_rb: free(rb_data); return -1; } static void browse_resolve_callback(AvahiServiceResolver *r, AvahiIfIndex intf, AvahiProtocol proto, AvahiResolverEvent event, const char *name, const char *type, const char *domain, const char *hostname, const AvahiAddress *addr, uint16_t port, AvahiStringList *txt, AvahiLookupResultFlags flags, void *userdata) { AvahiClient *c; struct mdns_browser *mb; int ret; mb = (struct mdns_browser *)userdata; switch (event) { case AVAHI_RESOLVER_FAILURE: DPRINTF(E_LOG, L_MDNS, "Avahi Resolver failure: service '%s' type '%s': %s\n", name, type, avahi_strerror(avahi_client_errno(mdns_client))); break; case AVAHI_RESOLVER_FOUND: DPRINTF(E_DBG, L_MDNS, "Avahi Resolver: resolved service '%s' type '%s' proto %d\n", name, type, proto); c = avahi_service_resolver_get_client(r); if (mb->flags & (MDNS_WANT_V4 | MDNS_WANT_V4LL)) { ret = spawn_record_browser(c, intf, proto, hostname, domain, AVAHI_DNS_TYPE_A, mb, name, port, txt); if (ret < 0) DPRINTF(E_LOG, L_MDNS, "Failed to create record browser for type A\n"); } if (mb->flags & (MDNS_WANT_V6 | MDNS_WANT_V6LL)) { ret = spawn_record_browser(c, intf, proto, hostname, domain, AVAHI_DNS_TYPE_AAAA, mb, name, port, txt); if (ret < 0) DPRINTF(E_LOG, L_MDNS, "Failed to create record browser for type A\n"); } break; } avahi_service_resolver_free(r); return; } static void browse_callback(AvahiServiceBrowser *b, AvahiIfIndex intf, AvahiProtocol proto, AvahiBrowserEvent event, const char *name, const char *type, const char *domain, AvahiLookupResultFlags flags, void *userdata) { struct mdns_browser *mb; AvahiServiceResolver *res; int family; mb = (struct mdns_browser *)userdata; switch (event) { case AVAHI_BROWSER_FAILURE: DPRINTF(E_LOG, L_MDNS, "Avahi Browser failure: %s\n", avahi_strerror(avahi_client_errno(mdns_client))); avahi_service_browser_free(b); b = avahi_service_browser_new(mdns_client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, mb->type, NULL, 0, browse_callback, mb); if (!b) { DPRINTF(E_LOG, L_MDNS, "Failed to recreate service browser (service type %s): %s\n", mb->type, avahi_strerror(avahi_client_errno(mdns_client))); } return; case AVAHI_BROWSER_NEW: DPRINTF(E_DBG, L_MDNS, "Avahi Browser: NEW service '%s' type '%s' proto %d\n", name, type, proto); res = avahi_service_resolver_new(mdns_client, intf, proto, name, type, domain, proto, 0, browse_resolve_callback, mb); if (!res) DPRINTF(E_LOG, L_MDNS, "Failed to create service resolver: %s\n", avahi_strerror(avahi_client_errno(mdns_client))); break; case AVAHI_BROWSER_REMOVE: DPRINTF(E_DBG, L_MDNS, "Avahi Browser: REMOVE service '%s' type '%s' proto %d\n", name, type, proto); switch (proto) { case AVAHI_PROTO_INET: family = AF_INET; break; case AVAHI_PROTO_INET6: family = AF_INET6; break; default: DPRINTF(E_INFO, L_MDNS, "Avahi Browser: unknown protocol %d\n", proto); family = AF_UNSPEC; break; } if (family != AF_UNSPEC) mb->cb(name, type, domain, NULL, family, NULL, -1, NULL); break; case AVAHI_BROWSER_ALL_FOR_NOW: case AVAHI_BROWSER_CACHE_EXHAUSTED: DPRINTF(E_DBG, L_MDNS, "Avahi Browser (%s): no more results (%s)\n", mb->type, (event == AVAHI_BROWSER_CACHE_EXHAUSTED) ? "CACHE_EXHAUSTED" : "ALL_FOR_NOW"); break; } } static void entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, AVAHI_GCC_UNUSED void *userdata) { if (!g || (g != mdns_group)) return; switch (state) { case AVAHI_ENTRY_GROUP_ESTABLISHED: DPRINTF(E_DBG, L_MDNS, "Successfully added mDNS services\n"); break; case AVAHI_ENTRY_GROUP_COLLISION: DPRINTF(E_DBG, L_MDNS, "Group collision\n"); break; case AVAHI_ENTRY_GROUP_FAILURE: DPRINTF(E_DBG, L_MDNS, "Group failure\n"); break; case AVAHI_ENTRY_GROUP_UNCOMMITED: DPRINTF(E_DBG, L_MDNS, "Group uncommitted\n"); break; case AVAHI_ENTRY_GROUP_REGISTERING: DPRINTF(E_DBG, L_MDNS, "Group registering\n"); break; } } static void _create_services(void) { struct mdns_group_entry *pentry; int ret; DPRINTF(E_DBG, L_MDNS, "Creating service group\n"); if (!group_entries) { DPRINTF(E_DBG, L_MDNS, "No entries yet... skipping service create\n"); return; } if (mdns_group == NULL) { mdns_group = avahi_entry_group_new(mdns_client, entry_group_callback, NULL); if (!mdns_group) { DPRINTF(E_WARN, L_MDNS, "Could not create Avahi EntryGroup: %s\n", avahi_strerror(avahi_client_errno(mdns_client))); return; } } pentry = group_entries; while (pentry) { DPRINTF(E_DBG, L_MDNS, "Re-registering %s/%s\n", pentry->name, pentry->type); ret = avahi_entry_group_add_service_strlst(mdns_group, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, 0, pentry->name, pentry->type, NULL, NULL, pentry->port, pentry->txt); if (ret < 0) { DPRINTF(E_WARN, L_MDNS, "Could not add mDNS services: %s\n", avahi_strerror(ret)); return; } pentry = pentry->next; } ret = avahi_entry_group_commit(mdns_group); if (ret < 0) { DPRINTF(E_WARN, L_MDNS, "Could not commit mDNS services: %s\n", avahi_strerror(avahi_client_errno(mdns_client))); } } static void client_callback(AvahiClient *c, AvahiClientState state, AVAHI_GCC_UNUSED void * userdata) { struct mdns_browser *mb; AvahiServiceBrowser *b; int error; switch (state) { case AVAHI_CLIENT_S_RUNNING: DPRINTF(E_LOG, L_MDNS, "Avahi state change: Client running\n"); if (!mdns_group) _create_services(); for (mb = browser_list; mb; mb = mb->next) { b = avahi_service_browser_new(mdns_client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, mb->type, NULL, 0, browse_callback, mb); if (!b) { DPRINTF(E_LOG, L_MDNS, "Failed to recreate service browser (service type %s): %s\n", mb->type, avahi_strerror(avahi_client_errno(mdns_client))); } } break; case AVAHI_CLIENT_S_COLLISION: DPRINTF(E_LOG, L_MDNS, "Avahi state change: Client collision\n"); if(mdns_group) avahi_entry_group_reset(mdns_group); break; case AVAHI_CLIENT_FAILURE: DPRINTF(E_LOG, L_MDNS, "Avahi state change: Client failure\n"); error = avahi_client_errno(c); if (error == AVAHI_ERR_DISCONNECTED) { DPRINTF(E_LOG, L_MDNS, "Avahi Server disconnected, reconnecting\n"); avahi_client_free(mdns_client); mdns_group = NULL; mdns_client = avahi_client_new(&gcdpoll_api, AVAHI_CLIENT_NO_FAIL, client_callback, NULL, &error); if (!mdns_client) { DPRINTF(E_LOG, L_MDNS, "Failed to create new Avahi client: %s\n", avahi_strerror(error)); } } else { DPRINTF(E_LOG, L_MDNS, "Avahi client failure: %s\n", avahi_strerror(error)); } break; case AVAHI_CLIENT_S_REGISTERING: DPRINTF(E_LOG, L_MDNS, "Avahi state change: Client registering\n"); if (mdns_group) avahi_entry_group_reset(mdns_group); break; case AVAHI_CLIENT_CONNECTING: DPRINTF(E_LOG, L_MDNS, "Avahi state change: Client connecting\n"); break; } } /* mDNS interface - to be called only from the main thread */ static void mdns_init_task(void *arg) { int error; mdns_client = avahi_client_new(&gcdpoll_api, AVAHI_CLIENT_NO_FAIL, client_callback, NULL, &error); if (!mdns_client) DPRINTF(E_WARN, L_MDNS, "mdns_init: Could not create Avahi client: %s\n", avahi_strerror(avahi_client_errno(mdns_client))); } int mdns_init(void) { DPRINTF(E_DBG, L_MDNS, "Initializing Avahi mDNS\n"); all_w = NULL; all_t = NULL; group_entries = NULL; browser_list = NULL; mdns_sq = dispatch_queue_create("org.forked-daapd.mdns", NULL); if (!mdns_sq) { DPRINTF(E_FATAL, L_MDNS, "mdns_init: Could not create dispatch queue\n"); return -1; } dispatch_sync_f(mdns_sq, NULL, mdns_init_task); if (!mdns_client) goto client_fail; return 0; client_fail: dispatch_release(mdns_sq); return -1; } static void mdns_deinit_task(void *arg) { struct mdns_group_entry *ge; struct mdns_browser *mb; AvahiWatch *w; AvahiTimeout *t; if (mdns_client) avahi_client_free(mdns_client); for (t = all_t; t; t = t->next) { if (t->timer) { dispatch_source_cancel(t->timer); dispatch_release(t->timer); t->timer = NULL; } } for (w = all_w; w; w = w->next) { if (w->w_read) { dispatch_source_cancel(w->w_read); dispatch_release(w->w_read); } if (w->w_write) { dispatch_source_cancel(w->w_write); dispatch_release(w->w_write); } } for (ge = group_entries; group_entries; ge = group_entries) { group_entries = ge->next; free(ge->name); free(ge->type); avahi_string_list_free(ge->txt); free(ge); } for (mb = browser_list; browser_list; mb = browser_list) { browser_list = mb->next; free(mb->type); free(mb); } } void mdns_deinit(void) { dispatch_sync_f(mdns_sq, NULL, mdns_deinit_task); dispatch_release(mdns_sq); } static void mdns_register_task(void *arg) { struct mdns_group_entry *ge; ge = (struct mdns_group_entry *)arg; DPRINTF(E_DBG, L_MDNS, "[ASYNC] Adding mDNS service %s/%s\n", ge->name, ge->type); ge->next = group_entries; group_entries = ge; if (mdns_group) { DPRINTF(E_DBG, L_MDNS, "Resetting mDNS group\n"); avahi_entry_group_reset(mdns_group); } DPRINTF(E_DBG, L_MDNS, "Creating service group\n"); _create_services(); } int mdns_register(char *name, char *type, int port, char **txt) { struct mdns_group_entry *ge; AvahiStringList *txt_sl; int i; DPRINTF(E_DBG, L_MDNS, "Adding mDNS service %s/%s\n", name, type); ge = (struct mdns_group_entry *)malloc(sizeof(struct mdns_group_entry)); if (!ge) return -1; ge->name = strdup(name); ge->type = strdup(type); ge->port = port; txt_sl = NULL; for (i = 0; txt[i]; i++) { txt_sl = avahi_string_list_add(txt_sl, txt[i]); DPRINTF(E_DBG, L_MDNS, "Added key %s\n", txt[i]); } ge->txt = txt_sl; dispatch_async_f(mdns_sq, ge, mdns_register_task); return 0; } int mdns_browse(char *type, int flags, mdns_browse_cb cb) { struct mdns_browser *mb; __block AvahiServiceBrowser *b; DPRINTF(E_DBG, L_MDNS, "Adding service browser for type %s\n", type); mb = (struct mdns_browser *)malloc(sizeof(struct mdns_browser)); if (!mb) return -1; mb->type = strdup(type); mb->cb = cb; mb->flags = (flags) ? flags : MDNS_WANT_DEFAULT; dispatch_sync(mdns_sq, ^{ mb->next = browser_list; browser_list = mb; b = avahi_service_browser_new(mdns_client, AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC, type, NULL, 0, browse_callback, mb); if (!b) { DPRINTF(E_LOG, L_MDNS, "Failed to create service browser: %s\n", avahi_strerror(avahi_client_errno(mdns_client))); browser_list = mb->next; } }); if (!b) { free(mb->type); free(mb); return -1; } return 0; } forked-daapd-0.19gcd/src/misc.c0000664000175000017500000003240011633141135015665 0ustar julienjulien/* * Copyright (C) 2009-2010 Julien BLACHE * * Some code included below is in the public domain, check comments * in the file. * * Pieces of code adapted from mt-daapd: * Copyright (C) 2003-2007 Ron Pedde (ron@pedde.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include "logger.h" #include "misc.h" int safe_atoi32(const char *str, int32_t *val) { char *end; long intval; errno = 0; intval = strtol(str, &end, 10); if (((errno == ERANGE) && ((intval == LONG_MAX) || (intval == LONG_MIN))) || ((errno != 0) && (intval == 0))) { DPRINTF(E_DBG, L_MISC, "Invalid integer in string (%s): %s\n", str, strerror(errno)); return -1; } if (end == str) { DPRINTF(E_DBG, L_MISC, "No integer found in string (%s)\n", str); return -1; } if (intval > INT32_MAX) { DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str); return -1; } *val = (int32_t)intval; return 0; } int safe_atou32(const char *str, uint32_t *val) { char *end; unsigned long intval; errno = 0; intval = strtoul(str, &end, 10); if (((errno == ERANGE) && (intval == ULONG_MAX)) || ((errno != 0) && (intval == 0))) { DPRINTF(E_DBG, L_MISC, "Invalid integer in string (%s): %s\n", str, strerror(errno)); return -1; } if (end == str) { DPRINTF(E_DBG, L_MISC, "No integer found in string (%s)\n", str); return -1; } if (intval > UINT32_MAX) { DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str); return -1; } *val = (uint32_t)intval; return 0; } int safe_hextou32(const char *str, uint32_t *val) { char *end; unsigned long intval; errno = 0; intval = strtoul(str, &end, 16); if (((errno == ERANGE) && (intval == ULONG_MAX)) || ((errno != 0) && (intval == 0))) { DPRINTF(E_DBG, L_MISC, "Invalid integer in string (%s): %s\n", str, strerror(errno)); return -1; } if (end == str) { DPRINTF(E_DBG, L_MISC, "No integer found in string (%s)\n", str); return -1; } if (intval > UINT32_MAX) { DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str); return -1; } *val = (uint32_t)intval; return 0; } int safe_atoi64(const char *str, int64_t *val) { char *end; long long intval; errno = 0; intval = strtoll(str, &end, 10); if (((errno == ERANGE) && ((intval == LLONG_MAX) || (intval == LLONG_MIN))) || ((errno != 0) && (intval == 0))) { DPRINTF(E_DBG, L_MISC, "Invalid integer in string (%s): %s\n", str, strerror(errno)); return -1; } if (end == str) { DPRINTF(E_DBG, L_MISC, "No integer found in string (%s)\n", str); return -1; } if (intval > INT64_MAX) { DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str); return -1; } *val = (int64_t)intval; return 0; } int safe_atou64(const char *str, uint64_t *val) { char *end; unsigned long long intval; errno = 0; intval = strtoull(str, &end, 10); if (((errno == ERANGE) && (intval == ULLONG_MAX)) || ((errno != 0) && (intval == 0))) { DPRINTF(E_DBG, L_MISC, "Invalid integer in string (%s): %s\n", str, strerror(errno)); return -1; } if (end == str) { DPRINTF(E_DBG, L_MISC, "No integer found in string (%s)\n", str); return -1; } if (intval > UINT64_MAX) { DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str); return -1; } *val = (uint64_t)intval; return 0; } int safe_hextou64(const char *str, uint64_t *val) { char *end; unsigned long long intval; errno = 0; intval = strtoull(str, &end, 16); if (((errno == ERANGE) && (intval == ULLONG_MAX)) || ((errno != 0) && (intval == 0))) { DPRINTF(E_DBG, L_MISC, "Invalid integer in string (%s): %s\n", str, strerror(errno)); return -1; } if (end == str) { DPRINTF(E_DBG, L_MISC, "No integer found in string (%s)\n", str); return -1; } if (intval > UINT64_MAX) { DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str); return -1; } *val = (uint64_t)intval; return 0; } /* Key/value functions */ int keyval_add_size(struct keyval *kv, const char *name, const char *value, size_t size) { struct onekeyval *okv; const char *val; /* Check for duplicate key names */ val = keyval_get(kv, name); if (val) { /* Same value, fine */ if (strcmp(val, value) == 0) return 0; else /* Different value, bad */ return -1; } okv = (struct onekeyval *)malloc(sizeof(struct onekeyval)); if (!okv) { DPRINTF(E_LOG, L_MISC, "Out of memory for new keyval\n"); return -1; } okv->name = strdup(name); if (!okv->name) { DPRINTF(E_LOG, L_MISC, "Out of memory for new keyval name\n"); free(okv); return -1; } okv->value = (char *)malloc(size + 1); if (!okv->value) { DPRINTF(E_LOG, L_MISC, "Out of memory for new keyval value\n"); free(okv->name); free(okv); return -1; } memcpy(okv->value, value, size); okv->value[size] = '\0'; okv->next = NULL; if (!kv->head) kv->head = okv; if (kv->tail) kv->tail->next = okv; kv->tail = okv; return 0; } int keyval_add(struct keyval *kv, const char *name, const char *value) { return keyval_add_size(kv, name, value, strlen(value)); } void keyval_remove(struct keyval *kv, const char *name) { struct onekeyval *okv; struct onekeyval *pokv; for (pokv = NULL, okv = kv->head; okv; pokv = okv, okv = okv->next) { if (strcasecmp(okv->name, name) == 0) break; } if (!okv) return; if (okv == kv->head) kv->head = okv->next; if (okv == kv->tail) kv->tail = pokv; if (pokv) pokv->next = okv->next; free(okv->name); free(okv->value); free(okv); } const char * keyval_get(struct keyval *kv, const char *name) { struct onekeyval *okv; for (okv = kv->head; okv; okv = okv->next) { if (strcasecmp(okv->name, name) == 0) return okv->value; } return NULL; } void keyval_clear(struct keyval *kv) { struct onekeyval *hokv; struct onekeyval *okv; hokv = kv->head; for (okv = hokv; hokv; okv = hokv) { hokv = okv->next; free(okv->name); free(okv->value); free(okv); } kv->head = NULL; kv->tail = NULL; } char * m_realpath(const char *pathname) { char buf[PATH_MAX]; char *ret; ret = realpath(pathname, buf); if (!ret) return NULL; ret = strdup(buf); if (!ret) { DPRINTF(E_LOG, L_MISC, "Out of memory for realpath\n"); return NULL; } return ret; } char * unicode_fixup_string(char *str) { uint8_t *ret; size_t len; if (!str) return NULL; len = strlen(str); /* String is valid UTF-8 */ if (!u8_check((uint8_t *)str, len)) { if (len >= 3) { /* Check for and strip byte-order mark */ if (memcmp("\xef\xbb\xbf", str, 3) == 0) memmove(str, str + 3, len - 3 + 1); } return str; } ret = u8_conv_from_encoding("ascii", iconveh_question_mark, str, len, NULL, NULL, &len); if (!ret) { DPRINTF(E_LOG, L_MISC, "Could not convert string '%s' to UTF-8: %s\n", str, strerror(errno)); return NULL; } return (char *)ret; } uint32_t djb_hash(void *data, size_t len) { unsigned char *bytes = data; uint32_t hash = 5381; while (len--) { hash = ((hash << 5) + hash) + *bytes; bytes++; } return hash; } static unsigned char b64_decode_table[256]; char * b64_decode(const char *b64) { char *str; const unsigned char *iptr; unsigned char *optr; unsigned char c; int len; int i; if (b64_decode_table[0] == 0) { memset(b64_decode_table, 0xff, sizeof(b64_decode_table)); /* Base64 encoding: A-Za-z0-9+/ */ for (i = 0; i < 26; i++) { b64_decode_table['A' + i] = i; b64_decode_table['a' + i] = i + 26; } for (i = 0; i < 10; i++) b64_decode_table['0' + i] = i + 52; b64_decode_table['+'] = 62; b64_decode_table['/'] = 63; /* Stop on '=' */ b64_decode_table['='] = 100; /* > 63 */ } len = strlen(b64); str = (char *)malloc(len); if (!str) return NULL; memset(str, 0, len); iptr = (const unsigned char *)b64; optr = (unsigned char *)str; i = 0; while (len) { if (*iptr == '=') break; c = b64_decode_table[*iptr]; if (c > 63) { iptr++; len--; continue; } switch (i) { case 0: optr[0] = c << 2; break; case 1: optr[0] |= c >> 4; optr[1] = c << 4; break; case 2: optr[1] |= c >> 2; optr[2] = c << 6; break; case 3: optr[2] |= c; break; } i++; if (i == 4) { optr += 3; i = 0; } len--; iptr++; } return str; } static const char b64_encode_table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; static void b64_encode_block(uint8_t *in, char *out, int len) { out[0] = b64_encode_table[in[0] >> 2]; out[2] = out[3] = '='; if (len == 1) out[1] = b64_encode_table[((in[0] & 0x03) << 4)]; else { out[1] = b64_encode_table[((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4)]; if (len == 2) out[2] = b64_encode_table[((in[1] & 0x0f) << 2)]; else { out[2] = b64_encode_table[((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6)]; out[3] = b64_encode_table[in[2] & 0x3f]; } } } static void b64_encode_full_block(uint8_t *in, char *out) { out[0] = b64_encode_table[in[0] >> 2]; out[1] = b64_encode_table[((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4)]; out[2] = b64_encode_table[((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6)]; out[3] = b64_encode_table[in[2] & 0x3f]; } char * b64_encode(uint8_t *in, size_t len) { char *encoded; char *out; /* 3 in chars -> 4 out chars */ encoded = (char *)malloc(len + (len / 3) + 4 + 1); if (!encoded) return NULL; out = encoded; while (len >= 3) { b64_encode_full_block(in, out); len -= 3; in += 3; out += 4; } if (len > 0) { b64_encode_block(in, out, len); out += 4; } out[0] = '\0'; return encoded; } /* * MurmurHash2, 64-bit versions, by Austin Appleby * * Code released under the public domain, as per * * as of 2010-01-03. */ #if SIZEOF_VOID_P == 8 /* 64bit platforms */ uint64_t murmur_hash64(const void *key, int len, uint32_t seed) { const int r = 47; const uint64_t m = 0xc6a4a7935bd1e995; const uint64_t *data; const uint64_t *end; const unsigned char *data_tail; uint64_t h; uint64_t k; h = seed ^ (len * m); data = (const uint64_t *)key; end = data + (len / 8); while (data != end) { k = *data++; k *= m; k ^= k >> r; k *= m; h ^= k; h *= m; } data_tail = (const unsigned char *)data; switch (len & 7) { case 7: h ^= (uint64_t)(data_tail[6]) << 48; case 6: h ^= (uint64_t)(data_tail[5]) << 40; case 5: h ^= (uint64_t)(data_tail[4]) << 32; case 4: h ^= (uint64_t)(data_tail[3]) << 24; case 3: h ^= (uint64_t)(data_tail[2]) << 16; case 2: h ^= (uint64_t)(data_tail[1]) << 8; case 1: h ^= (uint64_t)(data_tail[0]); h *= m; } h ^= h >> r; h *= m; h ^= h >> r; return h; } #elif SIZEOF_VOID_P == 4 /* 32bit platforms */ uint64_t murmur_hash64(const void *key, int len, uint32_t seed) { const int r = 24; const uint32_t m = 0x5bd1e995; const uint32_t *data; const unsigned char *data_tail; uint32_t k1; uint32_t h1; uint32_t k2; uint32_t h2; uint64_t h; h1 = seed ^ len; h2 = 0; data = (const uint32_t *)key; while (len >= 8) { k1 = *data++; k1 *= m; k1 ^= k1 >> r; k1 *= m; h1 *= m; h1 ^= k1; k2 = *data++; k2 *= m; k2 ^= k2 >> r; k2 *= m; h2 *= m; h2 ^= k2; len -= 8; } if (len >= 4) { k1 = *data++; k1 *= m; k1 ^= k1 >> r; k1 *= m; h1 *= m; h1 ^= k1; len -= 4; } data_tail = (const unsigned char *)data; switch(len) { case 3: h2 ^= (uint32_t)(data_tail[2]) << 16; case 2: h2 ^= (uint32_t)(data_tail[1]) << 8; case 1: h2 ^= (uint32_t)(data_tail[0]); h2 *= m; }; h1 ^= h2 >> 18; h1 *= m; h2 ^= h1 >> 22; h2 *= m; h1 ^= h2 >> 17; h1 *= m; h2 ^= h1 >> 19; h2 *= m; h = h1; h = (h << 32) | h2; return h; } #else # error Platform not supported #endif forked-daapd-0.19gcd/src/misc.h0000664000175000017500000000222011633141135015667 0ustar julienjulien #ifndef __MISC_H__ #define __MISC_H__ #include struct onekeyval { char *name; char *value; struct onekeyval *next; }; struct keyval { struct onekeyval *head; struct onekeyval *tail; }; int safe_atoi32(const char *str, int32_t *val); int safe_atou32(const char *str, uint32_t *val); int safe_hextou32(const char *str, uint32_t *val); int safe_atoi64(const char *str, int64_t *val); int safe_atou64(const char *str, uint64_t *val); int safe_hextou64(const char *str, uint64_t *val); /* Key/value functions */ int keyval_add(struct keyval *kv, const char *name, const char *value); int keyval_add_size(struct keyval *kv, const char *name, const char *value, size_t size); void keyval_remove(struct keyval *kv, const char *name); const char * keyval_get(struct keyval *kv, const char *name); void keyval_clear(struct keyval *kv); char * m_realpath(const char *pathname); char * unicode_fixup_string(char *str); uint32_t djb_hash(void *data, size_t len); char * b64_decode(const char *b64); char * b64_encode(uint8_t *in, size_t len); uint64_t murmur_hash64(const void *key, int len, uint32_t seed); #endif /* !__MISC_H__ */ forked-daapd-0.19gcd/src/network.c0000664000175000017500000003642111633141135016432 0ustar julienjulien/* * Copyright (C) 2010 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include "evbuffer/evbuffer.h" #include "logger.h" #include "network.h" #if 0 # define NCONN_TRACE(args...) fprintf(stderr, ##args) #else # define NCONN_TRACE(args...) #endif enum nconn_type { NCONN_ERROR = 0, NCONN_PASSIVE, /* listen socket */ NCONN_INCOMING, /* incoming connection accept()ed from a listen socket */ NCONN_OUTGOING, }; struct nconn { enum nconn_type type; int fd; dispatch_source_t rsrc; dispatch_source_t wsrc; /* Writer queue and group */ dispatch_queue_t wq; dispatch_group_t wg; /* Write buffer, access only from the writer queue */ struct evbuffer *wbuf; union sockaddr_all sa_local; union sockaddr_all sa_remote; /* User-provided data */ int ldomain; dispatch_queue_t user_queue; dispatch_group_t user_group; void *data; nconn_write_cb write_cb; nconn_read_cb read_cb; nconn_fail_cb fail_cb; }; static struct nconn * nconn_alloc(int ldomain, dispatch_group_t user_group, dispatch_queue_t user_queue) { char qid[80]; struct nconn *n; NCONN_TRACE("*** nconn_alloc\n"); n = (struct nconn *)malloc(sizeof(struct nconn)); if (!n) { DPRINTF(E_LOG, ldomain, "Out of memory for struct nconn\n"); return NULL; } memset(n, 0, sizeof(struct nconn)); n->wbuf = evbuffer_new(); if (!n->wbuf) { DPRINTF(E_LOG, ldomain, "Out of memory for write buffer\n"); goto wbuf_fail; } snprintf(qid, sizeof(qid), "org.forked-daapd.nconn.write.%p", n); n->wq = dispatch_queue_create(qid, NULL); if (!n->wq) { DPRINTF(E_LOG, ldomain, "Could not create dispatch queue for nconn write ops\n"); goto wq_fail; } n->wg = dispatch_group_create(); if (!n->wg) { DPRINTF(E_LOG, ldomain, "Could not create dispatch group for nconn write ops\n"); goto wg_fail; } dispatch_retain(user_group); n->user_group = user_group; dispatch_retain(user_queue); n->user_queue = user_queue; n->fd = -1; return n; wg_fail: dispatch_release(n->wq); wq_fail: evbuffer_free(n->wbuf); wbuf_fail: free(n); return NULL; } void nconn_free(struct nconn *n) { NCONN_TRACE("*** nconn_free\n"); dispatch_release(n->wq); dispatch_release(n->wg); dispatch_release(n->user_queue); dispatch_release(n->user_group); evbuffer_free(n->wbuf); free(n); } void nconn_close_and_free(struct nconn *n) { NCONN_TRACE("*** nconn_close_and_free\n"); /* The connection was not started */ if (!n->rsrc) { nconn_free(n); return; } if (!dispatch_source_testcancel(n->rsrc)) dispatch_source_cancel(n->rsrc); } int nconn_running(struct nconn *n) { NCONN_TRACE("*** nconn_running\n"); if (!n) return 0; return !dispatch_source_testcancel(n->rsrc); } static void nconn_fail(struct nconn *n) { NCONN_TRACE("*** nconn_fail\n"); /* User must close connection */ n->fail_cb(n->data); } static void nconn_write_disable(struct nconn *n) { NCONN_TRACE("*** nconn_write_disable\n"); if (!n->wsrc) return; /* The write source may have been cancelled from the read queue for * a reason or another while the write source handler was running. */ if (!dispatch_source_testcancel(n->wsrc)) dispatch_source_cancel(n->wsrc); n->wsrc = NULL; } static int nconn_write_enable(struct nconn *n) { dispatch_source_t wsrc; NCONN_TRACE("*** nconn_write_enable\n"); if (n->wsrc) return 0; wsrc = dispatch_source_create(DISPATCH_SOURCE_TYPE_WRITE, n->fd, 0, n->wq); if (!wsrc) { DPRINTF(E_LOG, n->ldomain, "Could not create dispatch source (write)\n"); return -1; } n->wsrc = wsrc; dispatch_source_set_cancel_handler(wsrc, ^{ NCONN_TRACE("*** wsrc cancel handler\n"); dispatch_release(wsrc); dispatch_group_leave(n->wg); }); dispatch_source_set_event_handler(wsrc, ^{ int ret; NCONN_TRACE("**** wsrc event handler\n"); ret = evbuffer_write(n->wbuf, n->fd); if (ret < 0) { DPRINTF(E_WARN, n->ldomain, "Write error (fd %d)\n", n->fd); /* The read source will handle any error */ return; } if (EVBUFFER_LENGTH(n->wbuf) == 0) { if (n->write_cb) n->write_cb(n, n->data); NCONN_TRACE("***** returned from write_cb\n"); /* If still empty after write_cb, disable */ if (EVBUFFER_LENGTH(n->wbuf) == 0) nconn_write_disable(n); } }); dispatch_set_context(wsrc, n); /* The cancel handler leaves the group */ dispatch_group_enter(n->wg); dispatch_resume(wsrc); return 0; } static void nconn_passive_rsrc_cb(void *arg) { struct nconn *n; size_t estimated; NCONN_TRACE("*** nconn_passive_rsrc_cb\n"); n = (struct nconn *)arg; estimated = dispatch_source_get_data(n->rsrc); if (estimated == 0) goto failed; /* The failure may be specific to this one connection we tried * to accept() (eg. the other side aborted) so don't fail the * listening connection. The read source will handle errors on * the listening connection itself if there are any. */ n->read_cb(n, n->fd, 0, n->data); return; failed: DPRINTF(E_INFO, n->ldomain, "Passive connection failed (fd %d)\n", n->fd); nconn_fail(n); } static void nconn_rsrc_cb(void *arg) { struct nconn *n; size_t estimated; NCONN_TRACE("*** nconn_rsrc_cb\n"); n = (struct nconn *)arg; estimated = dispatch_source_get_data(n->rsrc); if (estimated == 0) goto failed; n->read_cb(n, n->fd, estimated, n->data); return; failed: DPRINTF(E_INFO, n->ldomain, "Connection failed (fd %d)\n", n->fd); nconn_fail(n); } int nconn_get_local_addrstr(struct nconn *n, char *buf) { const char *cret; int ret; switch (n->sa_local.ss.ss_family) { case AF_INET: cret = inet_ntop(AF_INET, &n->sa_local.sin.sin_addr.s_addr, buf, NCONN_ADDRSTRLEN); if (!cret) { DPRINTF(E_LOG, n->ldomain, "Could not print local IPv4 address: %s\n", strerror(errno)); return -1; } break; case AF_INET6: ret = getnameinfo(&n->sa_local.sa, sizeof(struct sockaddr_in6), buf, NCONN_ADDRSTRLEN, NULL, 0, NI_NUMERICHOST | NI_NUMERICSERV); if (ret != 0) { if (ret == EAI_SYSTEM) DPRINTF(E_LOG, n->ldomain, "Could not print local IPv6 address: %s\n", strerror(errno)); else DPRINTF(E_LOG, n->ldomain, "Could not print local IPv6 address: %s\n", gai_strerror(ret)); return -1; } break; } return 0; } static int nconn_get_local_addr(struct nconn *n) { socklen_t slen; int ret; NCONN_TRACE("*** nconn_get_local_addr\n"); slen = sizeof(struct sockaddr_storage); ret = getsockname(n->fd, &n->sa_local.sa, &slen); if (ret < 0) { DPRINTF(E_LOG, n->ldomain, "Could not obtain local address: %s\n", strerror(errno)); return -1; } return 0; } int nconn_get_remote_addrstr(struct nconn *n, char *buf) { const char *ret; switch (n->sa_remote.ss.ss_family) { case AF_INET: ret = inet_ntop(AF_INET, &n->sa_remote.sin.sin_addr.s_addr, buf, NCONN_ADDRSTRLEN); break; case AF_INET6: ret = inet_ntop(AF_INET6, &n->sa_remote.sin6.sin6_addr.s6_addr, buf, NCONN_ADDRSTRLEN); break; } if (!ret) { DPRINTF(E_LOG, n->ldomain, "Could not print remote address: %s\n", strerror(errno)); return -1; } return 0; } static int nconn_make_addr(struct nconn *n, struct sockaddr_storage *ss, const char *address, unsigned short port) { struct addrinfo ai_hints; struct addrinfo *ai_res; const char *errstr; char sport[8]; int ret; NCONN_TRACE("*** nconn_make_addr\n"); memset(&ai_hints, 0, sizeof(struct addrinfo)); ai_hints.ai_family = AF_UNSPEC; ai_hints.ai_socktype = SOCK_STREAM; ai_hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST | AI_NUMERICSERV; sprintf(sport, "%u", port); ret = getaddrinfo(address, sport, &ai_hints, &ai_res); if (ret != 0) { if (ret == EAI_SYSTEM) errstr = strerror(errno); else errstr = gai_strerror(ret); DPRINTF(E_LOG, n->ldomain, "getaddrinfo() error: %s\n", errstr); return -1; } memcpy(ss, ai_res->ai_addr, ai_res->ai_addrlen); freeaddrinfo(ai_res); return 0; } struct nconn * nconn_outgoing_new(int ldomain, dispatch_group_t user_group, dispatch_queue_t user_queue, const char *address, unsigned short port) { struct nconn *n; int ret; NCONN_TRACE("*** nconn_outgoing_new\n"); n = nconn_alloc(ldomain, user_group, user_queue); if (!n) return NULL; n->type = NCONN_OUTGOING; n->ldomain = ldomain; ret = nconn_make_addr(n, &n->sa_remote.ss, address, port); if (ret < 0) { nconn_free(n); return NULL; } return n; } struct nconn * nconn_listen_new(int ldomain, dispatch_group_t user_group, dispatch_queue_t user_queue, const char *address, unsigned short port) { struct nconn *n; int ret; NCONN_TRACE("*** nconn_listen_new\n"); n = nconn_alloc(ldomain, user_group, user_queue); if (!n) return NULL; n->type = NCONN_PASSIVE; n->ldomain = ldomain; ret = nconn_make_addr(n, &n->sa_local.ss, address, port); if (ret < 0) { nconn_free(n); return NULL; } return n; } struct nconn * nconn_incoming_new(struct nconn *passive, dispatch_group_t group, dispatch_queue_t queue) { struct nconn *n; socklen_t slen; NCONN_TRACE("*** nconn_incoming_new\n"); n = nconn_alloc(passive->ldomain, group, queue); if (!n) return NULL; n->type = NCONN_INCOMING; n->ldomain = passive->ldomain; slen = sizeof(struct sockaddr_storage); n->fd = accept(passive->fd, &n->sa_remote.sa, &slen); if (n->fd < 0) { DPRINTF(E_LOG, n->ldomain, "Could not accept() connection: %s\n", strerror(errno)); nconn_free(n); return NULL; } return n; } static int nconn_listen_start(struct nconn *n) { int opt; int ret; NCONN_TRACE("*** nconn_listen_start\n"); n->fd = socket(n->sa_local.ss.ss_family, SOCK_STREAM, 0); if (n->fd < 0) { DPRINTF(E_LOG, n->ldomain, "Could not create socket: %s\n", strerror(errno)); return -1; } opt = 1; ret = setsockopt(n->fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)); if (ret < 0) DPRINTF(E_WARN, n->ldomain, "Could not set SO_REUSEADDR: %s\n", strerror(errno)); if (n->sa_local.ss.ss_family == AF_INET6) { opt = 1; ret = setsockopt(n->fd, IPPROTO_IPV6, IPV6_V6ONLY, &opt, sizeof(opt)); if (ret < 0) DPRINTF(E_WARN, n->ldomain, "Could not set SO_REUSEADDR: %s\n", strerror(errno)); } ret = bind(n->fd, &n->sa_local.sa, SOCKADDR_LEN(n->sa_local)); if (ret < 0) { DPRINTF(E_LOG, n->ldomain, "Could not bind socket: %s\n", strerror(errno)); goto out_fail; } ret = listen(n->fd, 128); if (ret < 0) { DPRINTF(E_LOG, n->ldomain, "Could not listen: %s\n", strerror(errno)); goto out_fail; } return 0; out_fail: close(n->fd); return -1; } static int nconn_incoming_start(struct nconn *n) { int ret; NCONN_TRACE("*** nconn_incoming_start\n"); ret = nconn_get_local_addr(n); if (ret < 0) { close(n->fd); return -1; } return 0; } static int nconn_outgoing_start(struct nconn *n) { int ret; NCONN_TRACE("*** nconn_outgoing_start\n"); n->fd = socket(n->sa_remote.ss.ss_family, SOCK_STREAM, 0); if (n->fd < 0) { DPRINTF(E_LOG, n->ldomain, "Could not create socket: %s\n", strerror(errno)); return -1; } ret = connect(n->fd, &n->sa_remote.sa, SOCKADDR_LEN(n->sa_remote)); if (ret < 0) { DPRINTF(E_LOG, n->ldomain, "Could not connect: %s\n", strerror(errno)); goto out_fail; } ret = nconn_get_local_addr(n); if (ret < 0) goto out_fail; return 0; out_fail: close(n->fd); return -1; } int nconn_start(struct nconn *n, void *data, nconn_read_cb read_cb, nconn_write_cb write_cb, nconn_fail_cb fail_cb) { dispatch_function_t hdl; int ret; NCONN_TRACE("*** nconn_start\n"); /* The rsrc cancel handler will leave the group */ dispatch_group_enter(n->user_group); n->read_cb = read_cb; n->write_cb = write_cb; n->fail_cb = fail_cb; n->data = data; switch (n->type) { case NCONN_PASSIVE: hdl = nconn_passive_rsrc_cb; ret = nconn_listen_start(n); break; case NCONN_INCOMING: hdl = nconn_rsrc_cb; ret = nconn_incoming_start(n); break; case NCONN_OUTGOING: hdl = nconn_rsrc_cb; ret = nconn_outgoing_start(n); break; case NCONN_ERROR: DPRINTF(E_LOG, n->ldomain, "Attempt to start connection in NCONN_ERROR state!\n"); ret = -1; break; } if (ret < 0) goto start_fail; ret = fcntl(n->fd, F_SETFL, O_NONBLOCK); if (ret < 0) { DPRINTF(E_LOG, n->ldomain, "Could not switch socket to non-blocking mode: %s\n", strerror(errno)); goto nonblock_fail; } n->rsrc = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, n->fd, 0, n->user_queue); if (!n->rsrc) { DPRINTF(E_LOG, n->ldomain, "Could not create dispatch source (read)\n"); goto sources_fail; } dispatch_source_set_cancel_handler(n->rsrc, ^{ int gret; NCONN_TRACE("*** rsrc cancel handler\n"); if (n->wsrc) dispatch_source_cancel(n->wsrc); /* Wait on writer */ gret = dispatch_group_wait(n->wg, DISPATCH_TIME_FOREVER); if (gret != 0) DPRINTF(E_LOG, n->ldomain, "Error waiting for writer dispatch group\n"); dispatch_release(n->rsrc); close(n->fd); dispatch_group_leave(n->user_group); nconn_free(n); }); dispatch_source_set_event_handler_f(n->rsrc, hdl); dispatch_set_context(n->rsrc, n); dispatch_resume(n->rsrc); return 0; sources_fail: nonblock_fail: close(n->fd); start_fail: dispatch_group_leave(n->user_group); /* User must free connection */ return -1; } int nconn_write(struct nconn *n, struct evbuffer *evbuf) { __block int b_ret; dispatch_block_t do_write = ^{ int ret; NCONN_TRACE("*** nconn_write BLOCK\n"); ret = evbuffer_add_buffer(n->wbuf, evbuf); if (ret < 0) b_ret = -1; else { ret = nconn_write_enable(n); if (ret < 0) b_ret = -1; } dispatch_group_leave(n->wg); }; NCONN_TRACE("*** nconn_write\n"); dispatch_group_enter(n->wg); if (EVBUFFER_LENGTH(evbuf) == 0) { dispatch_group_leave(n->wg); return 0; } b_ret = 0; if (dispatch_get_current_queue() == n->wq) do_write(); else dispatch_sync(n->wq, do_write); /* dispatch group left in the block */ return b_ret; } forked-daapd-0.19gcd/src/network.h0000664000175000017500000000302611633141135016432 0ustar julienjulien #ifndef __NETWORK_H__ #define __NETWORK_H__ #include #include #include #include #include #include "evbuffer/evbuffer.h" union sockaddr_all { struct sockaddr_storage ss; struct sockaddr sa; struct sockaddr_in sin; struct sockaddr_in6 sin6; }; #define SOCKADDR_LEN(x) ((x.ss.ss_family == AF_INET) ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr_in6)) #define NCONN_ADDRSTRLEN (INET6_ADDRSTRLEN + IF_NAMESIZE + 2) struct nconn; typedef void (*nconn_write_cb)(struct nconn *n, void *data); typedef void (*nconn_read_cb)(struct nconn *n, int fd, size_t estimated, void *data); typedef void (*nconn_fail_cb)(void *data); void nconn_free(struct nconn *n); void nconn_close_and_free(struct nconn *n); int nconn_running(struct nconn *n); int nconn_get_local_addrstr(struct nconn *n, char *buf); int nconn_get_remote_addrstr(struct nconn *n, char *buf); struct nconn * nconn_outgoing_new(int ldomain, dispatch_group_t user_group, dispatch_queue_t user_queue, const char *address, unsigned short port); struct nconn * nconn_listen_new(int ldomain, dispatch_group_t user_group, dispatch_queue_t user_queue, const char *address, unsigned short port); struct nconn * nconn_incoming_new(struct nconn *passive, dispatch_group_t group, dispatch_queue_t queue); int nconn_start(struct nconn *n, void *data, nconn_read_cb read_cb, nconn_write_cb write_cb, nconn_fail_cb fail_cb); int nconn_write(struct nconn *n, struct evbuffer *evbuf); #endif /* !__NETWORK_H__ */ forked-daapd-0.19gcd/src/player.c0000664000175000017500000022322011633141135016230 0ustar julienjulien/* * Copyright (C) 2010-2011 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #if defined(__linux__) # include #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include # include #endif #include #include #include "evbuffer/evbuffer.h" #include "db.h" #include "daap_query.h" #include "logger.h" #include "mdns.h" #include "conffile.h" #include "misc.h" #include "rng.h" #include "transcode.h" #include "player.h" #include "raop.h" #include "laudio.h" #ifndef MIN # define MIN(a, b) ((a < b) ? a : b) #endif enum player_sync_source { PLAYER_SYNC_CLOCK, PLAYER_SYNC_LAUDIO, }; struct volume_param { int volume; uint64_t spk_id; }; struct player_command; typedef int (*cmd_func)(struct player_command *cmd); struct player_command { pthread_mutex_t lck; pthread_cond_t cond; cmd_func func; cmd_func func_bh; union { struct volume_param vol_param; void *noarg; struct player_status *status; struct player_source *ps; player_status_handler status_handler; uint32_t *id_ptr; uint64_t *raop_ids; enum repeat_mode mode; uint32_t id; int intval; } arg; int ret; int raop_pending; }; struct player_source { uint32_t id; uint64_t stream_start; uint64_t output_start; uint64_t end; struct transcode_ctx *ctx; struct player_source *pl_next; struct player_source *pl_prev; struct player_source *shuffle_next; struct player_source *shuffle_prev; struct player_source *play_next; }; /* Keep in sync with enum raop_devtype */ static const char *raop_devtype[] = { "AirPort Express 802.11g", "AirPort Express 802.11n", "AppleTV", }; /* Exported to raop.c */ dispatch_queue_t player_sq; dispatch_group_t player_grp; /* Player status */ static enum play_status player_state; static enum repeat_mode repeat; static char shuffle; /* Status updates (for DACP) */ static player_status_handler update_handler; /* Playback timer */ static int pb_timer_fd; static dispatch_source_t pb_timer_src; #if defined(__linux__) static struct timespec pb_timer_last; #endif /* Sync source */ static enum player_sync_source pb_sync_source; /* Sync values */ static struct timespec pb_pos_stamp; static uint64_t pb_pos; /* Stream position (packets) */ static uint64_t last_rtptime; /* AirTunes devices */ static int dev_autoselect; static struct raop_device *dev_list; /* Device status */ static enum laudio_state laudio_status; static int laudio_selected; static int laudio_volume; static int laudio_relvol; static int raop_sessions; /* Commands */ static int cmd_pipe[2]; static struct player_command *cur_cmd; static dispatch_source_t cmd_src; /* Last commanded volume */ static int master_volume; /* Shuffle RNG state */ struct rng_ctx shuffle_rng; /* Audio source */ static struct player_source *source_head; static struct player_source *shuffle_head; static struct player_source *cur_playing; static struct player_source *cur_streaming; static uint32_t cur_plid; static struct evbuffer *audio_buf; /* Command helpers */ static void command_async_end(struct player_command *cmd) { cur_cmd = NULL; pthread_cond_signal(&cmd->cond); pthread_mutex_unlock(&cmd->lck); /* Process commands again */ dispatch_resume(cmd_src); } static void command_init(struct player_command *cmd) { memset(cmd, 0, sizeof(struct player_command)); pthread_mutex_init(&cmd->lck, NULL); pthread_cond_init(&cmd->cond, NULL); } static void command_deinit(struct player_command *cmd) { pthread_cond_destroy(&cmd->cond); pthread_mutex_destroy(&cmd->lck); } static void status_update(enum play_status status) { player_state = status; if (update_handler) update_handler(); if (status == PLAY_PLAYING) dev_autoselect = 0; } /* Volume helpers */ static int rel_to_vol(int relvol) { float vol; if (relvol == 100) return master_volume; vol = ((float)relvol * (float)master_volume) / 100.0; return (int)vol; } static int vol_to_rel(int volume) { float rel; if (volume == master_volume) return 100; rel = ((float)volume / (float)master_volume) * 100.0; return (int)rel; } /* Master volume helpers */ static void volume_master_update(int newvol) { struct raop_device *rd; master_volume = newvol; if (laudio_selected) laudio_relvol = vol_to_rel(laudio_volume); for (rd = dev_list; rd; rd = rd->next) { if (rd->selected) rd->relvol = vol_to_rel(rd->volume); } } static void volume_master_find(void) { struct raop_device *rd; int newmaster; newmaster = -1; if (laudio_selected) newmaster = laudio_volume; for (rd = dev_list; rd; rd = rd->next) { if (rd->selected && (rd->volume > newmaster)) newmaster = rd->volume; } volume_master_update(newmaster); } /* Device select/deselect hooks */ static void speaker_select_laudio(void) { laudio_selected = 1; if (laudio_volume > master_volume) { if (player_state == PLAY_STOPPED) volume_master_update(laudio_volume); else laudio_volume = master_volume; } laudio_relvol = vol_to_rel(laudio_volume); } static void speaker_select_raop(struct raop_device *rd) { rd->selected = 1; if (rd->volume > master_volume) { if (player_state == PLAY_STOPPED) volume_master_update(rd->volume); else rd->volume = master_volume; } rd->relvol = vol_to_rel(rd->volume); } static void speaker_deselect_laudio(void) { laudio_selected = 0; if (laudio_volume == master_volume) volume_master_find(); } static void speaker_deselect_raop(struct raop_device *rd) { rd->selected = 0; if (rd->volume == master_volume) volume_master_find(); } static int player_get_current_pos_clock(uint64_t *pos, struct timespec *ts, int commit) { uint64_t delta; int ret; ret = clock_gettime(CLOCK_MONOTONIC, ts); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Couldn't get clock: %s\n", strerror(errno)); return -1; } delta = (ts->tv_sec - pb_pos_stamp.tv_sec) * 1000000 + (ts->tv_nsec - pb_pos_stamp.tv_nsec) / 1000; #ifdef DEBUG_SYNC DPRINTF(E_DBG, L_PLAYER, "Delta is %" PRIu64 " usec\n", delta); #endif delta = (delta * 44100) / 1000000; #ifdef DEBUG_SYNC DPRINTF(E_DBG, L_PLAYER, "Delta is %" PRIu64 " samples\n", delta); #endif *pos = pb_pos + delta; if (commit) { pb_pos = *pos; pb_pos_stamp.tv_sec = ts->tv_sec; pb_pos_stamp.tv_nsec = ts->tv_nsec; #ifdef DEBUG_SYNC DPRINTF(E_DBG, L_PLAYER, "Pos: %" PRIu64 " (clock)\n", *pos); #endif } return 0; } static int player_get_current_pos_laudio(uint64_t *pos, struct timespec *ts, int commit) { int ret; *pos = laudio_get_pos(); ret = clock_gettime(CLOCK_MONOTONIC, ts); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Couldn't get clock: %s\n", strerror(errno)); return -1; } if (commit) { pb_pos = *pos; pb_pos_stamp.tv_sec = ts->tv_sec; pb_pos_stamp.tv_nsec = ts->tv_nsec; #ifdef DEBUG_SYNC DPRINTF(E_DBG, L_PLAYER, "Pos: %" PRIu64 " (laudio)\n", *pos); #endif } return 0; } int player_get_current_pos(uint64_t *pos, struct timespec *ts, int commit) { switch (pb_sync_source) { case PLAYER_SYNC_CLOCK: return player_get_current_pos_clock(pos, ts, commit); case PLAYER_SYNC_LAUDIO: return player_get_current_pos_laudio(pos, ts, commit); } return -1; } /* Forward */ static void playback_abort(void); static void player_laudio_status_cb(enum laudio_state status) { struct timespec ts; uint64_t pos; switch (status) { /* Switch sync to clock sync */ case LAUDIO_STOPPING: DPRINTF(E_DBG, L_PLAYER, "Local audio stopping\n"); laudio_status = status; /* Synchronize pb_pos and pb_pos_stamp before laudio stops entirely */ player_get_current_pos_laudio(&pos, &ts, 1); pb_sync_source = PLAYER_SYNC_CLOCK; break; /* Switch sync to laudio sync */ case LAUDIO_RUNNING: DPRINTF(E_DBG, L_PLAYER, "Local audio running\n"); laudio_status = status; pb_sync_source = PLAYER_SYNC_LAUDIO; break; case LAUDIO_FAILED: DPRINTF(E_DBG, L_PLAYER, "Local audio failed\n"); pb_sync_source = PLAYER_SYNC_CLOCK; laudio_close(); if (raop_sessions == 0) playback_abort(); speaker_deselect_laudio(); break; default: laudio_status = status; break; } } /* Metadata */ static void metadata_prune(uint64_t pos) { raop_metadata_prune(pos); } static void metadata_purge(void) { raop_metadata_purge(); } static void metadata_send(struct player_source *ps, int startup) { uint64_t offset; uint64_t rtptime; offset = 0; /* Determine song boundaries, dependent on context */ /* Restart after pause/seek */ if (ps->stream_start) { offset = ps->output_start - ps->stream_start; rtptime = ps->stream_start; } else if (startup) { rtptime = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES; } /* Generic case */ else if (cur_streaming && (cur_streaming->end)) { rtptime = cur_streaming->end + 1; } else { rtptime = 0; DPRINTF(E_LOG, L_PLAYER, "PTOH! Unhandled song boundary case in metadata_send()\n"); } raop_metadata_send(ps->id, rtptime, offset, startup); } /* Audio sources */ /* Queue: HTTP read queue (DACP) */ static struct player_source * player_queue_make(struct query_params *qp, const char *sort) { struct db_media_file_info dbmfi; struct player_source *q_head; struct player_source *q_tail; struct player_source *ps; uint32_t id; int ret; qp->idx_type = I_NONE; qp->sort = S_NONE; if (sort) { if (strcmp(sort, "name") == 0) qp->sort = S_NAME; else if (strcmp(sort, "album") == 0) qp->sort = S_ALBUM; else if (strcmp(sort, "artist") == 0) qp->sort = S_ARTIST; } /* Database handle provided by DACP */ ret = db_query_start(qp); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not start query\n"); return NULL; } DPRINTF(E_DBG, L_PLAYER, "Player queue query returned %d items\n", qp->results); q_head = NULL; q_tail = NULL; while (((ret = db_query_fetch_file(qp, &dbmfi)) == 0) && (dbmfi.id)) { ret = safe_atou32(dbmfi.id, &id); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Invalid song id in query result!\n"); continue; } ps = (struct player_source *)malloc(sizeof(struct player_source)); if (!ps) { DPRINTF(E_LOG, L_PLAYER, "Out of memory for struct player_source\n"); ret = -1; break; } memset(ps, 0, sizeof(struct player_source)); ps->id = id; if (!q_head) q_head = ps; if (q_tail) { q_tail->pl_next = ps; ps->pl_prev = q_tail; q_tail->shuffle_next = ps; ps->shuffle_prev = q_tail; } q_tail = ps; DPRINTF(E_DBG, L_PLAYER, "Added song id %d (%s)\n", id, dbmfi.title); } db_query_end(qp); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Error fetching results\n"); return NULL; } if (!q_head) return NULL; q_head->pl_prev = q_tail; q_tail->pl_next = q_head; return q_head; } /* Queue: HTTP read queue (DACP) */ struct player_source * player_queue_make_daap(const char *query, const char *sort) { struct query_params qp; struct player_source *ps; memset(&qp, 0, sizeof(struct query_params)); qp.type = Q_ITEMS; qp.offset = 0; qp.limit = 0; qp.filter = daap_query_parse_sql(query); if (!qp.filter) { DPRINTF(E_LOG, L_PLAYER, "Improper DAAP query!\n"); return NULL; } ps = player_queue_make(&qp, sort); free(qp.filter); return ps; } struct player_source * player_queue_make_pl(int plid, uint32_t *id) { struct query_params qp; struct player_source *ps; struct player_source *p; uint32_t i; memset(&qp, 0, sizeof(struct query_params)); qp.id = plid; qp.type = Q_PLITEMS; qp.offset = 0; qp.limit = 0; ps = player_queue_make(&qp, NULL); /* Shortcut for shuffled playlist */ if (*id == 0) return ps; p = ps; i = 0; do { if (p->id == *id) { *id = i; break; } p = p->pl_next; i++; } while (p != ps); return ps; } static void source_free(struct player_source *ps) { if (ps->ctx) transcode_cleanup(ps->ctx); free(ps); } static void source_stop(struct player_source *ps) { struct player_source *tmp; while (ps) { if (ps->ctx) { transcode_cleanup(ps->ctx); ps->ctx = NULL; } tmp = ps; ps = ps->play_next; tmp->play_next = NULL; } } static struct player_source * source_shuffle(struct player_source *head) { struct player_source *ps; struct player_source **ps_array; int nitems; int i; if (!head) return NULL; ps = head; nitems = 0; do { nitems++; ps = ps->pl_next; } while (ps != head); ps_array = (struct player_source **)malloc(nitems * sizeof(struct player_source *)); if (!ps_array) { DPRINTF(E_LOG, L_PLAYER, "Could not allocate memory for shuffle array\n"); return NULL; } ps = head; i = 0; do { ps_array[i] = ps; ps = ps->pl_next; i++; } while (ps != head); shuffle_ptr(&shuffle_rng, (void **)ps_array, nitems); for (i = 0; i < nitems; i++) { ps = ps_array[i]; if (i > 0) ps->shuffle_prev = ps_array[i - 1]; if (i < (nitems - 1)) ps->shuffle_next = ps_array[i + 1]; } ps_array[0]->shuffle_prev = ps_array[nitems - 1]; ps_array[nitems - 1]->shuffle_next = ps_array[0]; ps = ps_array[0]; free(ps_array); return ps; } static void source_reshuffle(void) { struct player_source *ps; ps = source_shuffle(source_head); if (!ps) return; if (cur_streaming) shuffle_head = cur_streaming; else shuffle_head = ps; } /* Helper */ static int source_open(struct player_source *ps, int no_md) { struct media_file_info *mfi; int ret; ps->stream_start = 0; ps->output_start = 0; ps->end = 0; ps->play_next = NULL; ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not acquire database connection; cannot get file info\n"); return -1; } mfi = db_file_fetch_byid(ps->id); db_pool_release(); if (!mfi) { DPRINTF(E_LOG, L_PLAYER, "Couldn't fetch file id %d\n", ps->id); return -1; } if (mfi->disabled) { DPRINTF(E_DBG, L_PLAYER, "File id %d is disabled, skipping\n", ps->id); free_mfi(mfi, 0); return -1; } DPRINTF(E_DBG, L_PLAYER, "Opening %s\n", mfi->path); ps->ctx = transcode_setup(mfi, NULL, 0); free_mfi(mfi, 0); if (!ps->ctx) { DPRINTF(E_LOG, L_PLAYER, "Could not open file id %d\n", ps->id); return -1; } if (!no_md) metadata_send(ps, (player_state == PLAY_PLAYING) ? 0 : 1); return 0; } static int source_next(int force) { struct player_source *ps; struct player_source *head; struct player_source *limit; enum repeat_mode r_mode; int ret; head = (shuffle) ? shuffle_head : source_head; limit = head; r_mode = repeat; /* Force repeat mode at user request */ if (force && (r_mode == REPEAT_SONG)) r_mode = REPEAT_ALL; /* Playlist has only one file, treat REPEAT_ALL as REPEAT_SONG */ if ((r_mode == REPEAT_ALL) && (source_head == source_head->pl_next)) r_mode = REPEAT_SONG; /* Playlist has only one file, not a user action, treat as REPEAT_ALL * and source_check() will stop playback */ else if (!force && (r_mode == REPEAT_OFF) && (source_head == source_head->pl_next)) r_mode = REPEAT_SONG; if (!cur_streaming) ps = head; else ps = (shuffle) ? cur_streaming->shuffle_next : cur_streaming->pl_next; switch (r_mode) { case REPEAT_SONG: if (cur_streaming->ctx) { ret = transcode_seek(cur_streaming->ctx, 0); /* source_open() takes care of sending metadata, but we don't * call it when repeating a song as we just seek back to 0 * so we have to handle metadata ourselves here */ if (ret >= 0) metadata_send(cur_streaming, 0); } else ret = source_open(cur_streaming, force); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Failed to restart song for song repeat\n"); return -1; } return 0; case REPEAT_ALL: if (!shuffle) { limit = ps; break; } /* Reshuffle before repeating playlist */ if (cur_streaming && (ps == shuffle_head)) { source_reshuffle(); ps = shuffle_head; } limit = shuffle_head; break; case REPEAT_OFF: limit = head; if (force && (ps == limit)) { DPRINTF(E_DBG, L_PLAYER, "End of playlist reached and repeat is OFF\n"); playback_abort(); return 0; } break; } do { ret = source_open(ps, force); if (ret < 0) { if (shuffle) ps = ps->shuffle_next; else ps = ps->pl_next; continue; } break; } while (ps != limit); /* Couldn't open any of the files in our queue */ if (ret < 0) { DPRINTF(E_WARN, L_PLAYER, "Could not open any file in the queue (next)\n"); return -1; } if (!force && cur_streaming) cur_streaming->play_next = ps; cur_streaming = ps; return 0; } static int source_prev(void) { struct player_source *ps; struct player_source *head; struct player_source *limit; int ret; if (!cur_streaming) return -1; head = (shuffle) ? shuffle_head : source_head; ps = (shuffle) ? cur_streaming->shuffle_prev : cur_streaming->pl_prev; limit = ps; if ((repeat == REPEAT_OFF) && (cur_streaming == head)) { DPRINTF(E_DBG, L_PLAYER, "Start of playlist reached and repeat is OFF\n"); playback_abort(); return 0; } /* We are not reshuffling on prev calls in the shuffle case - should we? */ do { ret = source_open(ps, 1); if (ret < 0) { if (shuffle) ps = ps->shuffle_prev; else ps = ps->pl_prev; continue; } break; } while (ps != limit); /* Couldn't open any of the files in our queue */ if (ret < 0) { DPRINTF(E_WARN, L_PLAYER, "Could not open any file in the queue (prev)\n"); return -1; } cur_streaming = ps; return 0; } static int source_position(struct player_source *ps) { struct player_source *p; int ret; ret = 0; for (p = source_head; p != ps; p = p->pl_next) ret++; return ret; } static uint64_t source_check(void) { struct timespec ts; struct player_source *ps; struct player_source *head; uint64_t pos; enum repeat_mode r_mode; int i; int ret; if (!cur_streaming) return 0; ret = player_get_current_pos(&pos, &ts, 0); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Couldn't get current playback position\n"); return 0; } if (!cur_playing) { if (pos >= cur_streaming->output_start) { cur_playing = cur_streaming; status_update(PLAY_PLAYING); /* Start of streaming, no metadata to prune yet */ } return pos; } if ((cur_playing->end == 0) || (pos < cur_playing->end)) return pos; r_mode = repeat; /* Playlist has only one file, treat REPEAT_ALL as REPEAT_SONG */ if ((r_mode == REPEAT_ALL) && (source_head == source_head->pl_next)) r_mode = REPEAT_SONG; if (r_mode == REPEAT_SONG) { ps = cur_playing; /* Check that we haven't gone to the next file already * (repeat song toggled in the last 2 seconds of a song) */ if (cur_playing->play_next) { cur_playing = cur_playing->play_next; if (ps->ctx) { transcode_cleanup(ps->ctx); ps->ctx = NULL; ps->play_next = NULL; } } cur_playing->stream_start = ps->end + 1; cur_playing->output_start = cur_playing->stream_start; /* Do not use cur_playing to reset the end position, it may have changed */ ps->end = 0; status_update(PLAY_PLAYING); metadata_prune(pos); return pos; } head = (shuffle) ? shuffle_head : source_head; i = 0; while (cur_playing && (cur_playing->end != 0) && (pos > cur_playing->end)) { i++; /* Stop playback if: * - at end of playlist (NULL) * - repeat OFF and at end of playlist (wraparound) */ if (!cur_playing->play_next || ((r_mode == REPEAT_OFF) && (cur_playing->play_next == head))) { playback_abort(); return pos; } ps = cur_playing; cur_playing = cur_playing->play_next; cur_playing->stream_start = ps->end + 1; cur_playing->output_start = cur_playing->stream_start; if (ps->ctx) { transcode_cleanup(ps->ctx); ps->ctx = NULL; ps->play_next = NULL; } } if (i > 0) { DPRINTF(E_DBG, L_PLAYER, "Playback switched to next song\n"); status_update(PLAY_PLAYING); metadata_prune(pos); } return pos; } static int source_read(uint8_t *buf, int len, uint64_t rtptime) { int new; int ret; int nbytes; if (!cur_streaming) return 0; nbytes = 0; new = 0; while (nbytes < len) { if (new) { DPRINTF(E_DBG, L_PLAYER, "New file\n"); new = 0; ret = source_next(0); if (ret < 0) return -1; } if (EVBUFFER_LENGTH(audio_buf) == 0) { ret = transcode(cur_streaming->ctx, audio_buf, len - nbytes); if (ret <= 0) { /* EOF or error */ cur_streaming->end = rtptime + BTOS(nbytes) - 1; new = 1; continue; } } nbytes += evbuffer_remove(audio_buf, buf + nbytes, len - nbytes); } return nbytes; } static void playback_write(void) { uint8_t rawbuf[AIRTUNES_V2_PACKET_SAMPLES * 2 * 2]; int ret; source_check(); /* Make sure playback is still running after source_check() */ if (player_state == PLAY_STOPPED) return; last_rtptime += AIRTUNES_V2_PACKET_SAMPLES; memset(rawbuf, 0, sizeof(rawbuf)); ret = source_read(rawbuf, sizeof(rawbuf), last_rtptime); if (ret < 0) { DPRINTF(E_DBG, L_PLAYER, "Error reading from source, aborting playback\n"); playback_abort(); return; } if (laudio_status & LAUDIO_F_STARTED) laudio_write(rawbuf, last_rtptime); if (raop_sessions > 0) raop_v2_write(rawbuf, last_rtptime); } /* Queue: player_sq */ static void player_playback_cancel_cb(void *arg) { close(pb_timer_fd); pb_timer_fd = -1; dispatch_group_leave(player_grp); } #if defined(__linux__) /* Queue: player_sq */ static void player_playback_cb(void *arg) { struct itimerspec next; uint64_t ticks; int ret; /* Acknowledge timer */ read(pb_timer_fd, &ticks, sizeof(ticks)); playback_write(); /* Make sure playback is still running */ if (player_state == PLAY_STOPPED) return; pb_timer_last.tv_nsec += AIRTUNES_V2_STREAM_PERIOD; if (pb_timer_last.tv_nsec >= 1000000000) { pb_timer_last.tv_sec++; pb_timer_last.tv_nsec -= 1000000000; } next.it_interval.tv_sec = 0; next.it_interval.tv_nsec = 0; next.it_value.tv_sec = pb_timer_last.tv_sec; next.it_value.tv_nsec = pb_timer_last.tv_nsec; ret = timerfd_settime(pb_timer_fd, TFD_TIMER_ABSTIME, &next, NULL); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not set playback timer: %s\n", strerror(errno)); playback_abort(); return; } } #endif /* __linux__ */ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) /* Queue: player_sq */ static void player_playback_cb(void *arg) { struct timespec ts; struct kevent kev; int ret; ts.tv_sec = 0; ts.tv_nsec = 0; while (kevent(pb_timer_fd, NULL, 0, &kev, 1, &ts) > 0) { if (kev.filter != EVFILT_TIMER) continue; playback_write(); /* Make sure playback is still running */ if (player_state == PLAY_STOPPED) return; } } #endif /* __FreeBSD__ || __FreeBSD_kernel__ */ static void device_free(struct raop_device *dev) { free(dev->name); if (dev->v4_address) free(dev->v4_address); if (dev->v6_address) free(dev->v6_address); free(dev); } /* Helpers */ static void device_remove(struct raop_device *dev) { struct raop_device *rd; struct raop_device *prev; int ret; prev = NULL; for (rd = dev_list; rd; rd = rd->next) { if (rd == dev) break; prev = rd; } if (!rd) return; DPRINTF(E_DBG, L_PLAYER, "Removing AirTunes device %s; stopped advertising\n", dev->name); /* Make sure device isn't selected anymore */ if (dev->selected) speaker_deselect_raop(dev); /* Save device volume */ ret = db_pool_get(); if (ret == 0) { ret = db_speaker_save(dev->id, 0, dev->volume); if (ret < 0) DPRINTF(E_LOG, L_PLAYER, "Could not save state for speaker %s\n", dev->name); db_pool_release(); } else DPRINTF(E_LOG, L_PLAYER, "Could not acquire database connection; cannot save speaker state\n"); if (!prev) dev_list = dev->next; else prev->next = dev->next; device_free(dev); } static int device_check(struct raop_device *dev) { struct raop_device *rd; for (rd = dev_list; rd; rd = rd->next) { if (rd == dev) break; } return (rd) ? 0 : -1; } /* Queue: player_sq */ static void device_add(void *arg) { struct raop_device *dev; struct raop_device *rd; int selected; int ret; dev = (struct raop_device *)arg; for (rd = dev_list; rd; rd = rd->next) { if (rd->id == dev->id) break; } /* New device */ if (!rd) { rd = dev; /* Get a database connection */ ret = db_pool_get(); if (ret == 0) { ret = db_speaker_get(rd->id, &selected, &rd->volume); if (ret < 0) { selected = 0; rd->volume = (master_volume >= 0) ? master_volume : 75; } if (dev_autoselect && selected) speaker_select_raop(rd); db_pool_release(); } else rd->volume = (master_volume >= 0) ? master_volume : 75; rd->next = dev_list; dev_list = rd; } else { rd->advertised = 1; if (dev->v4_address) { if (rd->v4_address) free(rd->v4_address); rd->v4_address = dev->v4_address; rd->v4_port = dev->v4_port; /* Address is ours now */ dev->v4_address = NULL; } if (dev->v6_address) { if (rd->v6_address) free(rd->v6_address); rd->v6_address = dev->v6_address; rd->v6_port = dev->v6_port; /* Address is ours now */ dev->v6_address = NULL; } if (rd->name) free(rd->name); rd->name = dev->name; dev->name = NULL; rd->devtype = dev->devtype; rd->has_password = dev->has_password; rd->password = dev->password; device_free(dev); } } /* Queue: player_sq */ static void device_remove_family(void *arg) { struct raop_device *dev; struct raop_device *rd; dev = (struct raop_device *)arg; for (rd = dev_list; rd; rd = rd->next) { if (rd->id == dev->id) break; } if (!rd) { DPRINTF(E_WARN, L_PLAYER, "AirTunes device %s stopped advertising, but not in our list\n", dev->name); device_free(dev); return; } /* v{4,6}_port non-zero indicates the address family stopped advertising */ if (dev->v4_port && rd->v4_address) { free(rd->v4_address); rd->v4_address = NULL; rd->v4_port = 0; } if (dev->v6_port && rd->v6_address) { free(rd->v6_address); rd->v6_address = NULL; rd->v6_port = 0; } if (!rd->v4_address && !rd->v6_address) { rd->advertised = 0; if (!rd->session) device_remove(rd); } device_free(dev); } /* RAOP callbacks executed on the player queue */ static void device_streaming_cb(struct raop_device *dev, struct raop_session *rs, enum raop_session_state status) { int ret; if (status == RAOP_FAILED) { raop_sessions--; ret = device_check(dev); if (ret < 0) { DPRINTF(E_WARN, L_PLAYER, "AirTunes device disappeared during streaming!\n"); return; } DPRINTF(E_LOG, L_PLAYER, "AirTunes device %s FAILED\n", dev->name); if (player_state == PLAY_PLAYING) speaker_deselect_raop(dev); dev->session = NULL; if (!dev->advertised) device_remove(dev); /* Done with this device */ dispatch_group_leave(player_grp); } else if (status == RAOP_STOPPED) { raop_sessions--; ret = device_check(dev); if (ret < 0) { DPRINTF(E_WARN, L_PLAYER, "AirTunes device disappeared during streaming!\n"); return; } DPRINTF(E_LOG, L_PLAYER, "AirTunes device %s stopped\n", dev->name); dev->session = NULL; if (!dev->advertised) device_remove(dev); /* Done with this device */ dispatch_group_leave(player_grp); } } static void device_command_cb(struct raop_device *dev, struct raop_session *rs, enum raop_session_state status) { cur_cmd->raop_pending--; raop_set_status_cb(rs, device_streaming_cb); if (status == RAOP_FAILED) device_streaming_cb(dev, rs, status); if (cur_cmd->raop_pending == 0) { if (cur_cmd->func_bh) cur_cmd->ret = cur_cmd->func_bh(cur_cmd); else cur_cmd->ret = 0; command_async_end(cur_cmd); } } static void device_shutdown_cb(struct raop_device *dev, struct raop_session *rs, enum raop_session_state status) { int ret; cur_cmd->raop_pending--; if (raop_sessions) raop_sessions--; ret = device_check(dev); if (ret < 0) { DPRINTF(E_WARN, L_PLAYER, "AirTunes device disappeared before shutdown completion!\n"); if (cur_cmd->ret != -2) cur_cmd->ret = -1; goto out; /* Need to leave the group */ } dev->session = NULL; if (!dev->advertised) device_remove(dev); out: /* Done with this device */ dispatch_group_leave(player_grp); if (cur_cmd->raop_pending == 0) { /* cur_cmd->ret already set * - to 0 (or -2 if password issue) in speaker_set() * - to -1 above on error */ command_async_end(cur_cmd); } } static void device_lost_cb(struct raop_device *dev, struct raop_session *rs, enum raop_session_state status) { /* We lost that device during startup for some reason, not much we can do here */ if (status == RAOP_FAILED) DPRINTF(E_WARN, L_PLAYER, "Failed to stop lost device\n"); else DPRINTF(E_INFO, L_PLAYER, "Lost device stopped properly\n"); /* Done with this device */ dispatch_group_leave(player_grp); } static void device_activate_cb(struct raop_device *dev, struct raop_session *rs, enum raop_session_state status) { struct timespec ts; int ret; cur_cmd->raop_pending--; ret = device_check(dev); if (ret < 0) { DPRINTF(E_WARN, L_PLAYER, "AirTunes device disappeared during startup!\n"); /* device_lost_cb() will leave the group */ raop_set_status_cb(rs, device_lost_cb); raop_device_stop(rs); if (cur_cmd->ret != -2) cur_cmd->ret = -1; goto out; } if (status == RAOP_PASSWORD) { status = RAOP_FAILED; cur_cmd->ret = -2; } if (status == RAOP_FAILED) { speaker_deselect_raop(dev); if (!dev->advertised) device_remove(dev); /* Done with this device */ dispatch_group_leave(player_grp); if (cur_cmd->ret != -2) cur_cmd->ret = -1; goto out; } dev->session = rs; raop_sessions++; if ((player_state == PLAY_PLAYING) && (raop_sessions == 1)) { ret = clock_gettime(CLOCK_MONOTONIC, &ts); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not get current time: %s\n", strerror(errno)); #if defined(__linux__) /* Fallback to nearest timer expiration time */ ts.tv_sec = pb_timer_last.tv_sec; ts.tv_nsec = pb_timer_last.tv_nsec; #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) if (cur_cmd->ret != -2) cur_cmd->ret = -1; goto out; #endif } raop_playback_start(last_rtptime + AIRTUNES_V2_PACKET_SAMPLES, &ts); } raop_set_status_cb(rs, device_streaming_cb); out: if (cur_cmd->raop_pending == 0) { /* cur_cmd->ret already set * - to 0 in speaker_set() (default) * - to -2 above if password issue * - to -1 above on error */ command_async_end(cur_cmd); } } static void device_probe_cb(struct raop_device *dev, struct raop_session *rs, enum raop_session_state status) { int ret; cur_cmd->raop_pending--; ret = device_check(dev); if (ret < 0) { DPRINTF(E_WARN, L_PLAYER, "AirTunes device disappeared during probe!\n"); /* Done with this device */ dispatch_group_leave(player_grp); if (cur_cmd->ret != -2) cur_cmd->ret = -1; goto out; } if (status == RAOP_PASSWORD) { status = RAOP_FAILED; cur_cmd->ret = -2; } if (status == RAOP_FAILED) { speaker_deselect_raop(dev); if (!dev->advertised) device_remove(dev); /* Done with this device */ dispatch_group_leave(player_grp); if (cur_cmd->ret != -2) cur_cmd->ret = -1; goto out; } out: if (cur_cmd->raop_pending == 0) { /* cur_cmd->ret already set * - to 0 in speaker_set() (default) * - to -2 above if password issue * - to -1 above on error */ command_async_end(cur_cmd); } } static void device_restart_cb(struct raop_device *dev, struct raop_session *rs, enum raop_session_state status) { int ret; cur_cmd->raop_pending--; ret = device_check(dev); if (ret < 0) { DPRINTF(E_WARN, L_PLAYER, "AirTunes device disappeared during restart!\n"); /* device_lost_cb() will leave the group */ raop_set_status_cb(rs, device_lost_cb); raop_device_stop(rs); goto out; } if (status == RAOP_FAILED) { speaker_deselect_raop(dev); if (!dev->advertised) device_remove(dev); /* Done with this device */ dispatch_group_leave(player_grp); goto out; } dev->session = rs; raop_sessions++; raop_set_status_cb(rs, device_streaming_cb); out: if (cur_cmd->raop_pending == 0) { cur_cmd->ret = cur_cmd->func_bh(cur_cmd); command_async_end(cur_cmd); } } /* Internal abort routine */ static void playback_abort(void) { if (laudio_status != LAUDIO_CLOSED) laudio_close(); if (raop_sessions > 0) raop_playback_stop(); if (pb_timer_src) { dispatch_source_cancel(pb_timer_src); dispatch_release(pb_timer_src); pb_timer_src = NULL; } if (cur_playing) source_stop(cur_playing); else source_stop(cur_streaming); cur_playing = NULL; cur_streaming = NULL; evbuffer_drain(audio_buf, EVBUFFER_LENGTH(audio_buf)); status_update(PLAY_STOPPED); metadata_purge(); } /* Actual commands, executed in the player thread */ static int get_status(struct player_command *cmd) { struct timespec ts; struct player_source *ps; struct player_status *status; uint64_t pos; int ret; status = cmd->arg.status; status->shuffle = shuffle; status->repeat = repeat; /* No devices selected, autoselect local audio */ if (master_volume < 0) speaker_select_laudio(); status->volume = master_volume; status->plid = cur_plid; switch (player_state) { case PLAY_STOPPED: DPRINTF(E_DBG, L_PLAYER, "Player status: stopped\n"); status->status = PLAY_STOPPED; break; case PLAY_PAUSED: DPRINTF(E_DBG, L_PLAYER, "Player status: paused\n"); status->status = PLAY_PAUSED; status->id = cur_streaming->id; pos = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES - cur_streaming->stream_start; status->pos_ms = (pos * 1000) / 44100; status->pos_pl = source_position(cur_streaming); break; case PLAY_PLAYING: if (!cur_playing) { DPRINTF(E_DBG, L_PLAYER, "Player status: playing (buffering)\n"); status->status = PLAY_PAUSED; ps = cur_streaming; /* Avoid a visible 2-second jump backward for the client */ pos = ps->output_start - ps->stream_start; } else { DPRINTF(E_DBG, L_PLAYER, "Player status: playing\n"); status->status = PLAY_PLAYING; ps = cur_playing; ret = player_get_current_pos(&pos, &ts, 0); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not get current stream position for playstatus\n"); pos = 0; } if (pos < ps->stream_start) pos = 0; else pos -= ps->stream_start; } status->pos_ms = (pos * 1000) / 44100; status->id = ps->id; status->pos_pl = source_position(ps); break; } return 0; } static int now_playing(struct player_command *cmd) { uint32_t *id; id = cmd->arg.id_ptr; if (cur_playing) *id = cur_playing->id; else if (cur_streaming) *id = cur_streaming->id; else return -1; return 0; } static int playback_stop(struct player_command *cmd) { if (laudio_status != LAUDIO_CLOSED) laudio_close(); /* We may be restarting very soon, so we don't bring the devices to a * full stop just yet; this saves time when restarting, which is nicer * for the user. */ cmd->raop_pending = raop_flush(device_command_cb, last_rtptime + AIRTUNES_V2_PACKET_SAMPLES); if (pb_timer_src) { dispatch_source_cancel(pb_timer_src); dispatch_release(pb_timer_src); pb_timer_src = NULL; } if (cur_playing) source_stop(cur_playing); else source_stop(cur_streaming); cur_playing = NULL; cur_streaming = NULL; evbuffer_drain(audio_buf, EVBUFFER_LENGTH(audio_buf)); status_update(PLAY_STOPPED); metadata_purge(); /* We're async if we need to flush RAOP devices */ if (cmd->raop_pending > 0) return 1; /* async */ return 0; } /* Playback startup bottom half */ static int playback_start_bh(struct player_command *cmd) { #if defined(__linux__) struct itimerspec next; #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) struct kevent kev; #endif int ret; if ((laudio_status == LAUDIO_CLOSED) && (raop_sessions == 0)) { DPRINTF(E_LOG, L_PLAYER, "Cannot start playback: no output started\n"); goto out_fail; } /* Start laudio first as it can fail, but can be stopped easily if needed */ if (laudio_status == LAUDIO_OPEN) { laudio_set_volume(laudio_volume); ret = laudio_start(pb_pos, last_rtptime + AIRTUNES_V2_PACKET_SAMPLES); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Local audio failed to start\n"); goto out_fail; } } ret = clock_gettime(CLOCK_MONOTONIC, &pb_pos_stamp); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Couldn't get current clock: %s\n", strerror(errno)); goto out_fail; } #if defined(__linux__) pb_timer_last.tv_sec = pb_pos_stamp.tv_sec; pb_timer_last.tv_nsec = pb_pos_stamp.tv_nsec; pb_timer_fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); if (pb_timer_fd < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not create playback timer: %s\n", strerror(errno)); goto out_fail; } next.it_interval.tv_sec = 0; next.it_interval.tv_nsec = 0; next.it_value.tv_sec = pb_timer_last.tv_sec; next.it_value.tv_nsec = pb_timer_last.tv_nsec; ret = timerfd_settime(pb_timer_fd, TFD_TIMER_ABSTIME, &next, NULL); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not set playback timer: %s\n", strerror(errno)); goto out_fail; } #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) pb_timer_fd = kqueue(); if (pb_timer_fd < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not create kqueue: %s\n", strerror(errno)); goto out_fail; } memset(&kev, 0, sizeof(struct kevent)); EV_SET(&kev, 1, EVFILT_TIMER, EV_ADD | EV_ENABLE, 0, AIRTUNES_V2_STREAM_PERIOD, 0); ret = kevent(pb_timer_fd, &kev, 1, NULL, 0, NULL); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not add kevent timer: %s\n", strerror(errno)); goto out_fail; } #endif pb_timer_src = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, pb_timer_fd, 0, player_sq); if (!pb_timer_src) { DPRINTF(E_LOG, L_PLAYER, "Could not create dispatch source for playback timer\n"); goto out_fail; } /* Group left in the cancel handler */ dispatch_group_enter(player_grp); dispatch_source_set_event_handler_f(pb_timer_src, player_playback_cb); dispatch_source_set_cancel_handler_f(pb_timer_src, player_playback_cancel_cb); dispatch_resume(pb_timer_src); /* Everything OK, start RAOP */ if (raop_sessions > 0) raop_playback_start(last_rtptime + AIRTUNES_V2_PACKET_SAMPLES, &pb_pos_stamp); status_update(PLAY_PLAYING); return 0; out_fail: close(pb_timer_fd); pb_timer_fd = -1; playback_abort(); return -1; } static int playback_start(struct player_command *cmd) { struct raop_device *rd; uint32_t *idx_id; int ret; if (!source_head) { DPRINTF(E_LOG, L_PLAYER, "Nothing to play!\n"); return -1; } idx_id = cmd->arg.id_ptr; if (player_state == PLAY_PLAYING) { if (idx_id) { if (cur_playing) *idx_id = cur_playing->id; else *idx_id = cur_streaming->id; } status_update(player_state); return 0; } pb_pos = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES - 88200; if (idx_id) { if (cur_playing) source_stop(cur_playing); else if (cur_streaming) source_stop(cur_streaming); cur_playing = NULL; cur_streaming = NULL; if (shuffle) { source_reshuffle(); cur_streaming = shuffle_head; } else cur_streaming = source_head; if (*idx_id > 0) { cur_streaming = source_head; for (; *idx_id > 0; (*idx_id)--) cur_streaming = cur_streaming->pl_next; if (shuffle) shuffle_head = cur_streaming; } ret = source_open(cur_streaming, 0); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Couldn't jump to queue position %d\n", *idx_id); playback_abort(); return -1; } *idx_id = cur_streaming->id; cur_streaming->stream_start = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES; cur_streaming->output_start = cur_streaming->stream_start; } else if (!cur_streaming) { if (shuffle) source_reshuffle(); ret = source_next(0); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Couldn't find anything to play!\n"); playback_abort(); return -1; } cur_streaming->stream_start = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES; cur_streaming->output_start = cur_streaming->stream_start; } else { /* After a pause, the source is still open so source_open() doesn't get * called and we have to handle metadata ourselves. */ metadata_send(cur_streaming, 1); } /* Start local audio if needed */ if (laudio_selected && (laudio_status == LAUDIO_CLOSED)) { ret = laudio_open(); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not open local audio\n"); playback_abort(); return -1; } } /* Start RAOP sessions on selected devices if needed */ cmd->raop_pending = 0; for (rd = dev_list; rd; rd = rd->next) { if (rd->selected && !rd->session) { ret = raop_device_start(rd, device_restart_cb, last_rtptime + AIRTUNES_V2_PACKET_SAMPLES); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not start selected AirTunes device %s\n", rd->name); continue; } cmd->raop_pending++; /* Group will be left when RAOP is done deactivating the device */ dispatch_group_enter(player_grp); } } if ((laudio_status == LAUDIO_CLOSED) && (cmd->raop_pending == 0) && (raop_sessions == 0)) { DPRINTF(E_LOG, L_PLAYER, "Could not start playback: no output selected or couldn't start any output\n"); playback_abort(); return -1; } /* We're async if we need to start RAOP devices */ if (cmd->raop_pending > 0) return 1; /* async */ /* Otherwise, just run the bottom half */ return playback_start_bh(cmd); } static int playback_prev_bh(struct player_command *cmd) { int ret; if (cur_playing) source_stop(cur_playing); else source_stop(cur_streaming); ret = source_prev(); if (ret < 0) { playback_abort(); return -1; } if (player_state == PLAY_STOPPED) return -1; cur_streaming->stream_start = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES; cur_streaming->output_start = cur_streaming->stream_start; cur_playing = NULL; /* Silent status change - playback_start() sends the real status update */ player_state = PLAY_PAUSED; return 0; } static int playback_next_bh(struct player_command *cmd) { int ret; if (cur_playing) source_stop(cur_playing); else source_stop(cur_streaming); ret = source_next(1); if (ret < 0) { playback_abort(); return -1; } if (player_state == PLAY_STOPPED) return -1; cur_streaming->stream_start = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES; cur_streaming->output_start = cur_streaming->stream_start; cur_playing = NULL; /* Silent status change - playback_start() sends the real status update */ player_state = PLAY_PAUSED; return 0; } static int playback_seek_bh(struct player_command *cmd) { struct player_source *ps; int ms; int ret; ms = cmd->arg.intval; if (cur_playing) ps = cur_playing; else ps = cur_streaming; ps->end = 0; /* Seek to commanded position */ ret = transcode_seek(ps->ctx, ms); if (ret < 0) { playback_abort(); return -1; } /* Adjust start_pos for the new position */ ps->stream_start = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES - ((uint64_t)ret * 44100) / 1000; ps->output_start = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES; cur_streaming = ps; cur_playing = NULL; /* Silent status change - playback_start() sends the real status update */ player_state = PLAY_PAUSED; return 0; } static int playback_pause_bh(struct player_command *cmd) { struct player_source *ps; uint64_t pos; int ms; int ret; if (cur_playing) ps = cur_playing; else ps = cur_streaming; pos = ps->end; ps->end = 0; /* Seek back to current playback position */ pos -= ps->stream_start; ms = (int)((pos * 1000) / 44100); ret = transcode_seek(ps->ctx, ms); if (ret < 0) { playback_abort(); return -1; } /* Adjust start_pos to take into account the pause and seek back */ ps->stream_start = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES - ((uint64_t)ret * 44100) / 1000; ps->output_start = last_rtptime + AIRTUNES_V2_PACKET_SAMPLES; cur_streaming = ps; cur_playing = NULL; status_update(PLAY_PAUSED); return 0; } static int playback_pause(struct player_command *cmd) { struct player_source *ps; uint64_t pos; pos = source_check(); if (pos == 0) { DPRINTF(E_LOG, L_PLAYER, "Could not retrieve current position for pause\n"); playback_abort(); return -1; } /* Make sure playback is still running after source_check() */ if (player_state == PLAY_STOPPED) return -1; if (cur_playing) ps = cur_playing; else ps = cur_streaming; /* Store pause position */ ps->end = pos; cmd->raop_pending = raop_flush(device_command_cb, last_rtptime + AIRTUNES_V2_PACKET_SAMPLES); if (laudio_status != LAUDIO_CLOSED) laudio_stop(); if (pb_timer_src) { dispatch_source_cancel(pb_timer_src); dispatch_release(pb_timer_src); pb_timer_src = NULL; } if (ps->play_next) source_stop(ps->play_next); cur_playing = NULL; cur_streaming = ps; cur_streaming->play_next = NULL; evbuffer_drain(audio_buf, EVBUFFER_LENGTH(audio_buf)); metadata_purge(); /* We're async if we need to flush RAOP devices */ if (cmd->raop_pending > 0) return 1; /* async */ /* Otherwise, just run the bottom half */ return cmd->func_bh(cmd); } static int speaker_activate(struct raop_device *rd) { struct timespec ts; uint64_t pos; int ret; if (!rd) { /* Local */ DPRINTF(E_DBG, L_PLAYER, "Activating local audio\n"); if (laudio_status == LAUDIO_CLOSED) { ret = laudio_open(); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not open local audio\n"); return -1; } } if (player_state == PLAY_PLAYING) { laudio_set_volume(laudio_volume); ret = player_get_current_pos(&pos, &ts, 0); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not get current stream position for local audio start\n"); laudio_close(); return -1; } ret = laudio_start(pos, last_rtptime + AIRTUNES_V2_PACKET_SAMPLES); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Local playback failed to start\n"); laudio_close(); return -1; } } return 0; } else { /* RAOP */ if (player_state == PLAY_PLAYING) { DPRINTF(E_DBG, L_PLAYER, "Activating RAOP device %s\n", rd->name); ret = raop_device_start(rd, device_activate_cb, last_rtptime + AIRTUNES_V2_PACKET_SAMPLES); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not start device %s\n", rd->name); return -1; } } else { DPRINTF(E_DBG, L_PLAYER, "Probing RAOP device %s\n", rd->name); ret = raop_device_probe(rd, device_probe_cb); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not probe device %s\n", rd->name); return -1; } } /* Group will be left when RAOP is done deactivating the device */ dispatch_group_enter(player_grp); return 1; } return -1; } static int speaker_deactivate(struct raop_device *rd) { if (!rd) { /* Local */ DPRINTF(E_DBG, L_PLAYER, "Deactivating local audio\n"); if (laudio_status == LAUDIO_CLOSED) return 0; if (laudio_status & LAUDIO_F_STARTED) laudio_stop(); laudio_close(); return 0; } else { /* RAOP */ DPRINTF(E_DBG, L_PLAYER, "Deactivating RAOP device %s\n", rd->name); raop_set_status_cb(rd->session, device_shutdown_cb); raop_device_stop(rd->session); return 1; } return -1; } static int speaker_set(struct player_command *cmd) { struct raop_device *rd; uint64_t *ids; int nspk; int i; int ret; ids = cmd->arg.raop_ids; if (ids) nspk = ids[0]; else nspk = 0; DPRINTF(E_DBG, L_PLAYER, "Speaker set: %d speakers\n", nspk); cmd->raop_pending = 0; cmd->ret = 0; /* RAOP devices */ for (rd = dev_list; rd; rd = rd->next) { for (i = 1; i <= nspk; i++) { DPRINTF(E_DBG, L_PLAYER, "Set %" PRIu64 " device %" PRIu64 "\n", ids[i], rd->id); if (ids[i] == rd->id) break; } if (i <= nspk) { if (rd->has_password && !rd->password) { DPRINTF(E_INFO, L_PLAYER, "RAOP device %s is password-protected, but we don't have it\n", rd->name); cmd->ret = -2; continue; } DPRINTF(E_DBG, L_PLAYER, "RAOP device %s selected\n", rd->name); if (!rd->selected) speaker_select_raop(rd); if (!rd->session) { ret = speaker_activate(rd); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not activate RAOP device %s\n", rd->name); speaker_deselect_raop(rd); if (cmd->ret != -2) cmd->ret = -1; } /* ret = 1 if RAOP needs to take action */ cmd->raop_pending += ret; } } else { DPRINTF(E_DBG, L_PLAYER, "RAOP device %s NOT selected\n", rd->name); if (rd->selected) speaker_deselect_raop(rd); if (rd->session) { ret = speaker_deactivate(rd); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not deactivate RAOP device %s\n", rd->name); if (cmd->ret != -2) cmd->ret = -1; } /* ret = 1 if RAOP needs to take action */ cmd->raop_pending += ret; } } } /* Local audio */ for (i = 1; i <= nspk; i++) { if (ids[i] == 0) break; } if (i <= nspk) { DPRINTF(E_DBG, L_PLAYER, "Local audio selected\n"); if (!laudio_selected) speaker_select_laudio(); if (!(laudio_status & LAUDIO_F_STARTED)) { ret = speaker_activate(NULL); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not activate local audio output\n"); speaker_deselect_laudio(); if (cmd->ret != -2) cmd->ret = -1; } } } else { DPRINTF(E_DBG, L_PLAYER, "Local audio NOT selected\n"); if (laudio_selected) speaker_deselect_laudio(); if (laudio_status != LAUDIO_CLOSED) { ret = speaker_deactivate(NULL); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not deactivate local audio output\n"); if (cmd->ret != -2) cmd->ret = -1; } } } if (cmd->raop_pending > 0) return 1; /* async */ return cmd->ret; } static int volume_set(struct player_command *cmd) { struct raop_device *rd; int volume; volume = cmd->arg.intval; if (master_volume == volume) return 0; master_volume = volume; if (laudio_selected) { laudio_volume = rel_to_vol(laudio_relvol); laudio_set_volume(laudio_volume); #ifdef DEBUG_RELVOL DPRINTF(E_DBG, L_PLAYER, "*** laudio: abs %d rel %d\n", laudio_volume, laudio_relvol); #endif } cmd->raop_pending = 0; for (rd = dev_list; rd; rd = rd->next) { if (!rd->selected) continue; rd->volume = rel_to_vol(rd->relvol); #ifdef DEBUG_RELVOL DPRINTF(E_DBG, L_PLAYER, "*** %s: abs %d rel %d\n", rd->name, rd->volume, rd->relvol); #endif if (rd->session) cmd->raop_pending += raop_set_volume_one(rd->session, rd->volume, device_command_cb); } if (cmd->raop_pending > 0) return 1; /* async */ return 0; } static int volume_setrel_speaker(struct player_command *cmd) { struct raop_device *rd; uint64_t id; int relvol; id = cmd->arg.vol_param.spk_id; relvol = cmd->arg.vol_param.volume; if (id == 0) { laudio_relvol = relvol; laudio_volume = rel_to_vol(relvol); laudio_set_volume(laudio_volume); #ifdef DEBUG_RELVOL DPRINTF(E_DBG, L_PLAYER, "*** laudio: abs %d rel %d\n", laudio_volume, laudio_relvol); #endif } else { for (rd = dev_list; rd; rd = rd->next) { if (rd->id != id) continue; if (!rd->selected) return 0; rd->relvol = relvol; rd->volume = rel_to_vol(relvol); #ifdef DEBUG_RELVOL DPRINTF(E_DBG, L_PLAYER, "*** %s: abs %d rel %d\n", rd->name, rd->volume, rd->relvol); #endif if (rd->session) cmd->raop_pending = raop_set_volume_one(rd->session, rd->volume, device_command_cb); break; } } if (cmd->raop_pending > 0) return 1; /* async */ return 0; } static int volume_setabs_speaker(struct player_command *cmd) { struct raop_device *rd; uint64_t id; int volume; id = cmd->arg.vol_param.spk_id; volume = cmd->arg.vol_param.volume; master_volume = volume; if (id == 0) { laudio_relvol = 100; laudio_volume = volume; laudio_set_volume(laudio_volume); } else laudio_relvol = vol_to_rel(laudio_volume); #ifdef DEBUG_RELVOL DPRINTF(E_DBG, L_PLAYER, "*** laudio: abs %d rel %d\n", laudio_volume, laudio_relvol); #endif for (rd = dev_list; rd; rd = rd->next) { if (!rd->selected) continue; if (rd->id != id) { rd->relvol = vol_to_rel(rd->volume); #ifdef DEBUG_RELVOL DPRINTF(E_DBG, L_PLAYER, "*** %s: abs %d rel %d\n", rd->name, rd->volume, rd->relvol); #endif continue; } else { rd->relvol = 100; rd->volume = master_volume; #ifdef DEBUG_RELVOL DPRINTF(E_DBG, L_PLAYER, "*** %s: abs %d rel %d\n", rd->name, rd->volume, rd->relvol); #endif if (rd->session) cmd->raop_pending = raop_set_volume_one(rd->session, rd->volume, device_command_cb); } } if (cmd->raop_pending > 0) return 1; /* async */ return 0; } static int repeat_set(struct player_command *cmd) { switch (cmd->arg.mode) { case REPEAT_OFF: case REPEAT_SONG: case REPEAT_ALL: repeat = cmd->arg.mode; break; default: DPRINTF(E_LOG, L_PLAYER, "Invalid repeat mode: %d\n", cmd->arg.mode); return -1; } return 0; } static int shuffle_set(struct player_command *cmd) { switch (cmd->arg.intval) { case 1: if (!shuffle) source_reshuffle(); /* FALLTHROUGH*/ case 0: shuffle = cmd->arg.intval; break; default: DPRINTF(E_LOG, L_PLAYER, "Invalid shuffle mode: %d\n", cmd->arg.intval); return -1; } return 0; } static int queue_add(struct player_command *cmd) { struct player_source *ps; struct player_source *ps_shuffle; struct player_source *source_tail; struct player_source *ps_tail; ps = cmd->arg.ps; ps_shuffle = source_shuffle(ps); if (!ps_shuffle) ps_shuffle = ps; if (source_head) { /* Playlist order */ source_tail = source_head->pl_prev; ps_tail = ps->pl_prev; source_tail->pl_next = ps; ps_tail->pl_next = source_head; source_head->pl_prev = ps_tail; ps->pl_prev = source_tail; /* Shuffle */ source_tail = shuffle_head->shuffle_prev; ps_tail = ps_shuffle->shuffle_prev; source_tail->shuffle_next = ps_shuffle; ps_tail->shuffle_next = shuffle_head; shuffle_head->shuffle_prev = ps_tail; ps_shuffle->shuffle_prev = source_tail; } else { source_head = ps; shuffle_head = ps_shuffle; } if (cur_plid != 0) cur_plid = 0; return 0; } static int queue_clear(struct player_command *cmd) { struct player_source *ps; if (!source_head) return 0; shuffle_head = NULL; source_head->pl_prev->pl_next = NULL; for (ps = source_head; ps; ps = source_head) { source_head = ps->pl_next; source_free(ps); } cur_plid = 0; return 0; } static int queue_plid(struct player_command *cmd) { if (!source_head) return 0; cur_plid = cmd->arg.id; return 0; } static int set_update_handler(struct player_command *cmd) { update_handler = cmd->arg.status_handler; return 0; } /* Command processing */ /* Queue: player_sq */ static void command_cb(void *arg) { int ret; /* Shutdown in progress */ if (cur_cmd) return; ret = read(cmd_pipe[0], &cur_cmd, sizeof(cur_cmd)); if (ret != sizeof(cur_cmd)) { DPRINTF(E_LOG, L_PLAYER, "Could not read command! (read %d): %s\n", ret, (ret < 0) ? strerror(errno) : "-no error-"); return; } pthread_mutex_lock(&cur_cmd->lck); ret = cur_cmd->func(cur_cmd); if (ret <= 0) { cur_cmd->ret = ret; pthread_cond_signal(&cur_cmd->cond); pthread_mutex_unlock(&cur_cmd->lck); cur_cmd = NULL; } else { /* Command is asynchronous, we don't want to process another command * before we're done with this one. See command_async_end(). */ dispatch_suspend(cmd_src); } } /* Queue: player_sq */ static void command_cancel_cb(void *arg) { /* HTTPd & DACP stop before us, so no commands can be left in the queue */ close(cmd_pipe[0]); close(cmd_pipe[1]); cmd_pipe[0] = -1; cmd_pipe[1] = -1; dispatch_group_leave(player_grp); } /* Queue: HTTP read queue (DACP) */ static int send_command(struct player_command *cmd) { int ret; if (!cmd->func) { DPRINTF(E_LOG, L_PLAYER, "BUG: cmd->func is NULL!\n"); return -1; } ret = write(cmd_pipe[1], &cmd, sizeof(cmd)); if (ret != sizeof(cmd)) { DPRINTF(E_LOG, L_PLAYER, "Could not send command: %s\n", strerror(errno)); return -1; } return 0; } /* Queue: HTTP read queue (DACP) */ static int sync_command(struct player_command *cmd) { int ret; pthread_mutex_lock(&cmd->lck); ret = send_command(cmd); if (ret < 0) { pthread_mutex_unlock(&cmd->lck); return -1; } pthread_cond_wait(&cmd->cond, &cmd->lck); pthread_mutex_unlock(&cmd->lck); ret = cmd->ret; return ret; } /* Player API executed in the httpd (DACP) thread */ int player_get_status(struct player_status *status) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = get_status; cmd.func_bh = NULL; cmd.arg.status = status; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_now_playing(uint32_t *id) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = now_playing; cmd.func_bh = NULL; cmd.arg.id_ptr = id; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_playback_start(uint32_t *idx_id) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = playback_start; cmd.func_bh = playback_start_bh; cmd.arg.id_ptr = idx_id; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_playback_stop(void) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = playback_stop; cmd.arg.noarg = NULL; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_playback_pause(void) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = playback_pause; cmd.func_bh = playback_pause_bh; cmd.arg.noarg = NULL; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_playback_seek(int ms) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = playback_pause; cmd.func_bh = playback_seek_bh; cmd.arg.intval = ms; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_playback_next(void) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = playback_pause; cmd.func_bh = playback_next_bh; cmd.arg.noarg = NULL; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_playback_prev(void) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = playback_pause; cmd.func_bh = playback_prev_bh; cmd.arg.noarg = NULL; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } void player_speaker_enumerate(spk_enum_cb cb, void *arg) { char *laudio_name; laudio_name = cfg_getstr(cfg_getsec(cfg, "audio"), "nickname"); dispatch_sync(player_sq, ^{ struct spk_flags flags; struct raop_device *rd; /* Auto-select local audio if there are no AirTunes devices */ if (!dev_list && !laudio_selected) speaker_select_laudio(); flags.selected = laudio_selected; flags.has_password = 0; flags.has_video = 0; cb(0, laudio_name, laudio_relvol, flags, arg); #ifdef DEBUG_RELVOL DPRINTF(E_DBG, L_PLAYER, "*** master: %d\n", master_volume); DPRINTF(E_DBG, L_PLAYER, "*** laudio: abs %d rel %d\n", laudio_volume, laudio_relvol); #endif for (rd = dev_list; rd; rd = rd->next) { if (rd->advertised || rd->selected) { flags.selected = rd->selected; flags.has_password = rd->has_password; flags.has_video = (rd->devtype == RAOP_DEV_APPLETV); cb(rd->id, rd->name, rd->relvol, flags, arg); #ifdef DEBUG_RELVOL DPRINTF(E_DBG, L_PLAYER, "*** %s: abs %d rel %d\n", rd->name, rd->volume, rd->relvol); #endif } } }); } int player_speaker_set(uint64_t *ids) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = speaker_set; cmd.func_bh = NULL; cmd.arg.raop_ids = ids; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_volume_set(int vol) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = volume_set; cmd.func_bh = NULL; cmd.arg.intval = vol; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_volume_setrel_speaker(uint64_t id, int relvol) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = volume_setrel_speaker; cmd.func_bh = NULL; cmd.arg.vol_param.spk_id = id; cmd.arg.vol_param.volume = relvol; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_volume_setabs_speaker(uint64_t id, int vol) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = volume_setabs_speaker; cmd.func_bh = NULL; cmd.arg.vol_param.spk_id = id; cmd.arg.vol_param.volume = vol; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_repeat_set(enum repeat_mode mode) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = repeat_set; cmd.func_bh = NULL; cmd.arg.mode = mode; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_shuffle_set(int enable) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = shuffle_set; cmd.func_bh = NULL; cmd.arg.intval = enable; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } int player_queue_add(struct player_source *ps) { struct player_command cmd; int ret; command_init(&cmd); cmd.func = queue_add; cmd.func_bh = NULL; cmd.arg.ps = ps; ret = sync_command(&cmd); command_deinit(&cmd); return ret; } void player_queue_clear(void) { struct player_command cmd; command_init(&cmd); cmd.func = queue_clear; cmd.func_bh = NULL; cmd.arg.noarg = NULL; sync_command(&cmd); command_deinit(&cmd); } void player_queue_plid(uint32_t plid) { struct player_command cmd; command_init(&cmd); cmd.func = queue_plid; cmd.func_bh = NULL; cmd.arg.id = plid; sync_command(&cmd); command_deinit(&cmd); } void player_set_update_handler(player_status_handler handler) { struct player_command cmd; command_init(&cmd); cmd.func = set_update_handler; cmd.func_bh = NULL; cmd.arg.status_handler = handler; sync_command(&cmd); command_deinit(&cmd); } /* RAOP devices discovery - mDNS callback */ /* Queue: mdns_sq */ static void raop_device_cb(const char *name, const char *type, const char *domain, const char *hostname, int family, const char *address, int port, struct keyval *txt) { struct raop_device *rd; cfg_t *apex; const char *p; char *at_name; char *password; uint64_t id; char has_password; enum raop_devtype devtype; int ret; ret = safe_hextou64(name, &id); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not extract AirTunes device ID (%s)\n", name); return; } at_name = strchr(name, '@'); if (!at_name) { DPRINTF(E_LOG, L_PLAYER, "Could not extract AirTunes device name (%s)\n", name); return; } at_name++; DPRINTF(E_DBG, L_PLAYER, "Event for AirTunes device %" PRIx64 "/%s (%d)\n", id, at_name, port); rd = (struct raop_device *)malloc(sizeof(struct raop_device)); if (!rd) { DPRINTF(E_LOG, L_PLAYER, "Out of memory for new AirTunes device\n"); return; } memset(rd, 0, sizeof(struct raop_device)); rd->id = id; rd->name = strdup(at_name); if (port < 0) { /* Device stopped advertising */ switch (family) { case AF_INET: rd->v4_port = 1; break; case AF_INET6: rd->v6_port = 1; break; } dispatch_async_f(player_sq, rd, device_remove_family); return; } p = keyval_get(txt, "tp"); if (!p) { DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: no tp field in TXT record!\n", name); goto free_rd; } if (*p == '\0') { DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: tp has no value\n", name); goto free_rd; } if (!strstr(p, "UDP")) { DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: device does not support AirTunes v2 (tp=%s), discarding\n", name, p); goto free_rd; } password = NULL; p = keyval_get(txt, "pw"); if (!p) { DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: no pw field in TXT record!\n", name); goto free_rd; } if (*p == '\0') { DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: pw has no value\n", name); goto free_rd; } has_password = (strcmp(p, "false") != 0); if (has_password) { DPRINTF(E_LOG, L_PLAYER, "AirTunes device %s is password-protected\n", name); apex = cfg_gettsec(cfg, "apex", at_name); if (apex) password = cfg_getstr(apex, "password"); if (!password) DPRINTF(E_LOG, L_PLAYER, "No password given in config for AirTunes device %s\n", name); } devtype = RAOP_DEV_APEX_80211N; p = keyval_get(txt, "am"); if (!p) { DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: no am field in TXT record!\n", name); /* Old AirPort Express */ devtype = RAOP_DEV_APEX_80211G; goto no_am; } if (*p == '\0') { DPRINTF(E_LOG, L_PLAYER, "AirTunes %s: am has no value\n", name); goto no_am; } if (strncmp(p, "AppleTV", strlen("AppleTV")) == 0) devtype = RAOP_DEV_APPLETV; no_am: DPRINTF(E_DBG, L_PLAYER, "AirTunes device %s: password: %s, type %s\n", name, (password) ? "yes" : "no", raop_devtype[devtype]); rd->advertised = 1; switch (family) { case AF_INET: rd->v4_address = strdup(address); rd->v4_port = port; break; case AF_INET6: rd->v6_address = strdup(address); rd->v6_port = port; break; } rd->devtype = devtype; rd->has_password = has_password; rd->password = password; dispatch_async_f(player_sq, rd, device_add); return; free_rd: device_free(rd); } /* Queue: player_sq */ static void player_init_task(void *arg) { int ret; ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not acquire database connection; cannot reload saved settings\n"); return; } ret = db_speaker_get(0, &laudio_selected, &laudio_volume); if (ret < 0) laudio_volume = 75; else if (laudio_selected) speaker_select_laudio(); /* Run the select helper */ db_pool_release(); } /* Thread: main */ int player_init(void) { uint32_t rnd; int raop_v6enabled; int mdns_flags; int ret; dev_autoselect = 1; dev_list = NULL; master_volume = -1; laudio_status = LAUDIO_CLOSED; raop_sessions = 0; cur_cmd = NULL; pb_timer_fd = -1; pb_timer_src = NULL; source_head = NULL; shuffle_head = NULL; cur_playing = NULL; cur_streaming = NULL; cur_plid = 0; player_state = PLAY_STOPPED; repeat = REPEAT_OFF; shuffle = 0; update_handler = NULL; /* Initial state, init task will reload from DB */ laudio_selected = 0; /* Random RTP time start */ gcry_randomize(&rnd, sizeof(rnd), GCRY_STRONG_RANDOM); last_rtptime = ((uint64_t)1 << 32) | rnd; rng_init(&shuffle_rng); player_sq = dispatch_queue_create("org.forked-daapd.player", NULL); if (!player_sq) { DPRINTF(E_FATAL, L_PLAYER, "Could not create player dispatch queue\n"); return -1; } raop_v6enabled = cfg_getbool(cfg_getsec(cfg, "general"), "ipv6"); player_grp = dispatch_group_create(); if (!player_grp) { DPRINTF(E_FATAL, L_PLAYER, "Could not create player dispatch group\n"); goto player_grp_fail; } audio_buf = evbuffer_new(); if (!audio_buf) { DPRINTF(E_LOG, L_PLAYER, "Could not allocate evbuffer for audio buffer\n"); goto audio_buf_fail; } # if defined(__linux__) ret = pipe2(cmd_pipe, O_CLOEXEC); # else ret = pipe(cmd_pipe); # endif if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Could not create command pipe: %s\n", strerror(errno)); goto cmd_fail; } ret = laudio_init(player_laudio_status_cb); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "Local audio init failed\n"); goto laudio_fail; } ret = raop_init(&raop_v6enabled); if (ret < 0) { DPRINTF(E_LOG, L_PLAYER, "RAOP init failed\n"); goto raop_fail; } cmd_src = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, cmd_pipe[0], 0, player_sq); if (!cmd_src) { DPRINTF(E_FATAL, L_PLAYER, "Could not create dispatch source for player commands\n"); goto cmd_src_fail; } /* Group left in the cancel handler */ dispatch_group_enter(player_grp); dispatch_source_set_event_handler_f(cmd_src, command_cb); dispatch_source_set_cancel_handler_f(cmd_src, command_cancel_cb); dispatch_resume(cmd_src); if (raop_v6enabled) mdns_flags = MDNS_WANT_V4 | MDNS_WANT_V6 | MDNS_WANT_V6LL; else mdns_flags = MDNS_WANT_V4; ret = mdns_browse("_raop._tcp", mdns_flags, raop_device_cb); if (ret < 0) { DPRINTF(E_FATAL, L_PLAYER, "Could not add mDNS browser for AirTunes devices\n"); goto mdns_browse_fail; } dispatch_async_f(player_sq, NULL, player_init_task); return 0; mdns_browse_fail: dispatch_source_cancel(cmd_src); dispatch_release(cmd_src); cmd_src_fail: raop_deinit(); raop_fail: laudio_deinit(); laudio_fail: close(cmd_pipe[0]); close(cmd_pipe[1]); cmd_fail: evbuffer_free(audio_buf); audio_buf_fail: dispatch_release(player_grp); player_grp_fail: dispatch_release(player_sq); return -1; } /* Queue: player_sq */ static void player_deinit_task1(void *arg) { struct raop_device *rd; int ret; ret = db_pool_get(); if (ret < 0) DPRINTF(E_WARN, L_PLAYER, "Could not acquire database connection; cannot save selected speakers\n"); else { /* Save selected devices */ db_speaker_clear_all(); ret = db_speaker_save(0, laudio_selected, laudio_volume); if (ret < 0) DPRINTF(E_LOG, L_PLAYER, "Could not save state for local audio\n"); for (rd = dev_list; rd; rd = rd->next) { ret = db_speaker_save(rd->id, rd->selected, rd->volume); if (ret < 0) DPRINTF(E_LOG, L_PLAYER, "Could not save state for speaker %s\n", rd->name); } db_pool_release(); } if (player_state != PLAY_STOPPED) playback_abort(); if (cur_cmd) DPRINTF(E_LOG, L_PLAYER, "BUG: async command in progress during player shutdown!\n"); dispatch_source_cancel(cmd_src); dispatch_release(cmd_src); } /* Queue: player_sq */ static void player_deinit_task2(void *arg) { struct raop_device *rd; if (source_head) queue_clear(NULL); for (rd = dev_list; dev_list; rd = dev_list) { dev_list = rd->next; device_free(rd); } evbuffer_free(audio_buf); } /* Thread: main */ void player_deinit(void) { int ret; /* Stop player properly */ dispatch_sync_f(player_sq, NULL, player_deinit_task1); ret = dispatch_group_wait(player_grp, DISPATCH_TIME_FOREVER); dispatch_release(player_grp); if (ret != 0) DPRINTF(E_LOG, L_PLAYER, "Error waiting for dispatch group\n"); /* Cleanup */ dispatch_sync_f(player_sq, NULL, player_deinit_task2); dispatch_release(player_sq); laudio_deinit(); raop_deinit(); } forked-daapd-0.19gcd/src/player.h0000664000175000017500000000432011633141135016233 0ustar julienjulien #ifndef __PLAYER_H__ #define __PLAYER_H__ #include #if defined(__linux__) /* AirTunes v2 packet interval in ns */ # define AIRTUNES_V2_STREAM_PERIOD 7980000 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) /* AirTunes v2 packet interval in ms */ # define AIRTUNES_V2_STREAM_PERIOD 8 #endif /* AirTunes v2 number of samples per packet */ #define AIRTUNES_V2_PACKET_SAMPLES 352 /* Samples to bytes, bytes to samples */ #define STOB(s) ((s) * 4) #define BTOS(b) ((b) / 4) enum play_status { PLAY_STOPPED = 2, PLAY_PAUSED = 3, PLAY_PLAYING = 4, }; enum repeat_mode { REPEAT_OFF = 0, REPEAT_SONG = 1, REPEAT_ALL = 2, }; struct spk_flags { unsigned selected:1; unsigned has_password:1; unsigned has_video:1; }; struct player_status { enum play_status status; enum repeat_mode repeat; char shuffle; int volume; uint32_t plid; uint32_t id; uint32_t pos_ms; int pos_pl; }; typedef void (*spk_enum_cb)(uint64_t id, const char *name, int relvol, struct spk_flags flags, void *arg); typedef void (*player_status_handler)(void); struct player_source; int player_get_current_pos(uint64_t *pos, struct timespec *ts, int commit); int player_get_status(struct player_status *status); int player_now_playing(uint32_t *id); void player_speaker_enumerate(spk_enum_cb cb, void *arg); int player_speaker_set(uint64_t *ids); int player_playback_start(uint32_t *idx_id); int player_playback_stop(void); int player_playback_pause(void); int player_playback_seek(int ms); int player_playback_next(void); int player_playback_prev(void); int player_volume_set(int vol); int player_volume_setrel_speaker(uint64_t id, int relvol); int player_volume_setabs_speaker(uint64_t id, int vol); int player_repeat_set(enum repeat_mode mode); int player_shuffle_set(int enable); struct player_source * player_queue_make_daap(const char *query, const char *sort); struct player_source * player_queue_make_pl(int plid, uint32_t *id); int player_queue_add(struct player_source *ps); void player_queue_clear(void); void player_queue_plid(uint32_t plid); void player_set_update_handler(player_status_handler handler); int player_init(void); void player_deinit(void); #endif /* !__PLAYER_H__ */ forked-daapd-0.19gcd/src/raop.c0000664000175000017500000026036711633141135015712 0ustar julienjulien/* * Copyright (C) 2010-2011 Julien BLACHE * * RAOP AirTunes v2 * * Crypto code adapted from VideoLAN * Copyright (C) 2008 the VideoLAN team * Author: Michael Hanselmann * GPLv2+ * * ALAC encoding adapted from raop_play * Copyright (C) 2005 Shiro Ninomiya * GPLv2+ * * 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 */ /* TODO: * - Support RTSP authentication in all requests (only OPTIONS so far) */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include #if defined(__linux__) || defined(__GLIBC__) # include # include #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include #endif #include #include #include #include #include "evbuffer/evbuffer.h" #include "conffile.h" #include "logger.h" #include "misc.h" #include "player.h" #include "db.h" #include "artwork.h" #include "dmap_common.h" #include "network.h" #include "http.h" #include "raop.h" #ifndef MIN # define MIN(a, b) ((a < b) ? a : b) #endif #define AIRTUNES_V2_HDR_LEN 12 #define ALAC_HDR_LEN 3 #define AIRTUNES_V2_PKT_LEN (AIRTUNES_V2_HDR_LEN + ALAC_HDR_LEN + STOB(AIRTUNES_V2_PACKET_SAMPLES)) #define AIRTUNES_V2_PKT_TAIL_LEN (AIRTUNES_V2_PKT_LEN - AIRTUNES_V2_HDR_LEN - ((AIRTUNES_V2_PKT_LEN / 16) * 16)) #define AIRTUNES_V2_PKT_TAIL_OFF (AIRTUNES_V2_PKT_LEN - AIRTUNES_V2_PKT_TAIL_LEN) #define RETRANSMIT_BUFFER_SIZE 1000 #define RAOP_MD_DELAY_STARTUP 15360 #define RAOP_MD_DELAY_SWITCH (RAOP_MD_DELAY_STARTUP * 2) struct raop_v2_packet { uint8_t clear[AIRTUNES_V2_PKT_LEN]; uint8_t encrypted[AIRTUNES_V2_PKT_LEN]; uint16_t seqnum; struct raop_v2_packet *prev; struct raop_v2_packet *next; }; struct raop_session { struct http_connection *ctrl; enum raop_session_state state; unsigned req_has_auth:1; unsigned encrypt:1; unsigned auth_quirk_itunes:1; unsigned wants_metadata:1; int reqs_in_flight; int cseq; char *session; char session_url[128]; char *realm; char *nonce; const char *password; char *devname; char *address; int volume; uint64_t start_rtptime; /* Do not dereference - only passed to the status cb */ struct raop_device *dev; raop_status_cb status_cb; /* AirTunes v2 */ unsigned short server_port; unsigned short control_port; unsigned short timing_port; int server_fd; union sockaddr_all sa; struct raop_service *timing_svc; struct raop_service *control_svc; struct raop_session *next; }; struct raop_metadata { struct evbuffer *metadata; struct evbuffer *artwork; int artwork_fmt; /* Progress data */ uint64_t start; uint64_t end; struct raop_metadata *next; }; struct raop_service { int fd; unsigned short port; dispatch_source_t source; }; /* Truncate RTP time to lower 32bits for RAOP */ #define RAOP_RTPTIME(x) ((uint32_t)((x) & (uint64_t)0xffffffff)) /* NTP timestamp definitions */ #define FRAC 4294967296. /* 2^32 as a double */ #define NTP_EPOCH_DELTA 0x83aa7e80 /* 2208988800 - that's 1970 - 1900 in seconds */ struct ntp_stamp { uint32_t sec; uint32_t frac; }; static const uint8_t raop_rsa_pubkey[] = "\xe7\xd7\x44\xf2\xa2\xe2\x78\x8b\x6c\x1f\x55\xa0\x8e\xb7\x05\x44" "\xa8\xfa\x79\x45\xaa\x8b\xe6\xc6\x2c\xe5\xf5\x1c\xbd\xd4\xdc\x68" "\x42\xfe\x3d\x10\x83\xdd\x2e\xde\xc1\xbf\xd4\x25\x2d\xc0\x2e\x6f" "\x39\x8b\xdf\x0e\x61\x48\xea\x84\x85\x5e\x2e\x44\x2d\xa6\xd6\x26" "\x64\xf6\x74\xa1\xf3\x04\x92\x9a\xde\x4f\x68\x93\xef\x2d\xf6\xe7" "\x11\xa8\xc7\x7a\x0d\x91\xc9\xd9\x80\x82\x2e\x50\xd1\x29\x22\xaf" "\xea\x40\xea\x9f\x0e\x14\xc0\xf7\x69\x38\xc5\xf3\x88\x2f\xc0\x32" "\x3d\xd9\xfe\x55\x15\x5f\x51\xbb\x59\x21\xc2\x01\x62\x9f\xd7\x33" "\x52\xd5\xe2\xef\xaa\xbf\x9b\xa0\x48\xd7\xb8\x13\xa2\xb6\x76\x7f" "\x6c\x3c\xcf\x1e\xb4\xce\x67\x3d\x03\x7b\x0d\x2e\xa3\x0c\x5f\xff" "\xeb\x06\xf8\xd0\x8a\xdd\xe4\x09\x57\x1a\x9c\x68\x9f\xef\x10\x72" "\x88\x55\xdd\x8c\xfb\x9a\x8b\xef\x5c\x89\x43\xef\x3b\x5f\xaa\x15" "\xdd\xe6\x98\xbe\xdd\xf3\x59\x96\x03\xeb\x3e\x6f\x61\x37\x2b\xb6" "\x28\xf6\x55\x9f\x59\x9a\x78\xbf\x50\x06\x87\xaa\x7f\x49\x76\xc0" "\x56\x2d\x41\x29\x56\xf8\x98\x9e\x18\xa6\x35\x5b\xd8\x15\x97\x82" "\x5e\x0f\xc8\x75\x34\x3e\xc7\x82\x11\x76\x25\xcd\xbf\x98\x44\x7b"; static const uint8_t raop_rsa_exp[] = "\x01\x00\x01"; /* From player.c */ extern dispatch_queue_t player_sq; /* RAOP AES stream key */ static uint8_t raop_aes_key[16]; static uint8_t raop_aes_iv[16]; static gcry_cipher_hd_t raop_aes_ctx; /* Base64-encoded AES key and IV for SDP */ static char *raop_aes_key_b64; static char *raop_aes_iv_b64; /* AirTunes v2 time synchronization */ static struct raop_service timing_4svc; static struct raop_service timing_6svc; /* AirTunes v2 playback synchronization / control */ static struct raop_service control_4svc; static struct raop_service control_6svc; static int sync_counter; /* AirTunes v2 audio stream */ static uint32_t ssrc_id; static uint16_t stream_seq; /* Retransmit packet buffer */ static int pktbuf_size; static struct raop_v2_packet *pktbuf_head; static struct raop_v2_packet *pktbuf_tail; /* Metadata */ static struct raop_metadata *metadata_head; static struct raop_metadata *metadata_tail; /* FLUSH timer */ static dispatch_source_t flush_timer_src; /* Sessions */ static struct raop_session *sessions; /* ALAC bits writer - big endian * p outgoing buffer pointer * val bitfield value * blen bitfield length, max 8 bits * bpos bit position in the current byte (pointed by *p) */ static inline void alac_write_bits(uint8_t **p, uint8_t val, int blen, int *bpos) { int lb; int rb; int bd; /* Remaining bits in the current byte */ lb = 7 - *bpos + 1; /* Number of bits overflowing */ rb = lb - blen; if (rb >= 0) { bd = val << rb; if (*bpos == 0) **p = bd; else **p |= bd; /* No over- nor underflow, we're done with this byte */ if (rb == 0) { *p += 1; *bpos = 0; } else *bpos += blen; } else { /* Fill current byte */ bd = val >> -rb; **p |= bd; /* Overflow goes to the next byte */ *p += 1; **p = val << (8 + rb); *bpos = -rb; } } /* Raw data must be little endian */ static void alac_encode(uint8_t *raw, uint8_t *buf, int buflen) { uint8_t *maxraw; int bpos; bpos = 0; maxraw = raw + buflen; alac_write_bits(&buf, 1, 3, &bpos); /* channel=1, stereo */ alac_write_bits(&buf, 0, 4, &bpos); /* unknown */ alac_write_bits(&buf, 0, 8, &bpos); /* unknown */ alac_write_bits(&buf, 0, 4, &bpos); /* unknown */ alac_write_bits(&buf, 0, 1, &bpos); /* hassize */ alac_write_bits(&buf, 0, 2, &bpos); /* unused */ alac_write_bits(&buf, 1, 1, &bpos); /* is-not-compressed */ for (; raw < maxraw; raw += 4) { /* Byteswap to big endian */ alac_write_bits(&buf, *(raw + 1), 8, &bpos); alac_write_bits(&buf, *raw, 8, &bpos); alac_write_bits(&buf, *(raw + 3), 8, &bpos); alac_write_bits(&buf, *(raw + 2), 8, &bpos); } } /* AirTunes v2 time synchronization helpers */ static inline void timespec_to_ntp(struct timespec *ts, struct ntp_stamp *ns) { /* Seconds since NTP Epoch (1900-01-01) */ ns->sec = ts->tv_sec + NTP_EPOCH_DELTA; ns->frac = (uint32_t)((double)ts->tv_nsec * 1e-9 * FRAC); } static inline void ntp_to_timespec(struct ntp_stamp *ns, struct timespec *ts) { /* Seconds since Unix Epoch (1970-01-01) */ ts->tv_sec = ns->sec - NTP_EPOCH_DELTA; ts->tv_nsec = (long)((double)ns->frac / (1e-9 * FRAC)); } static inline int raop_v2_timing_get_clock_ntp(struct ntp_stamp *ns) { struct timespec ts; int ret; ret = clock_gettime(CLOCK_MONOTONIC, &ts); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't get clock: %s\n", strerror(errno)); return -1; } timespec_to_ntp(&ts, ns); return 0; } /* RAOP crypto stuff - from VLC */ /* MGF1 is specified in RFC2437, section 10.2.1. Variables are named after the * specification. */ static int raop_crypt_mgf1(uint8_t *mask, size_t l, const uint8_t *z, const size_t zlen, const int hash) { char ebuf[64]; gcry_md_hd_t md_hdl; gpg_error_t gc_err; uint8_t *md; uint32_t counter; uint8_t c[4]; size_t copylen; int len; gc_err = gcry_md_open(&md_hdl, hash, 0); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not open hash: %s\n", ebuf); return -1; } len = gcry_md_get_algo_dlen(hash); counter = 0; while (l > 0) { /* 3. For counter from 0 to \lceil{l / len}\rceil-1, do the following: * a. Convert counter to an octet string C of length 4 with the * primitive I2OSP: C = I2OSP (counter, 4) */ c[0] = (counter >> 24) & 0xff; c[1] = (counter >> 16) & 0xff; c[2] = (counter >> 8) & 0xff; c[3] = counter & 0xff; ++counter; /* b. Concatenate the hash of the seed z and c to the octet string T: * T = T || Hash (Z || C) */ gcry_md_reset(md_hdl); gcry_md_write(md_hdl, z, zlen); gcry_md_write(md_hdl, c, 4); md = gcry_md_read(md_hdl, hash); /* 4. Output the leading l octets of T as the octet string mask. */ copylen = MIN(l, len); memcpy(mask, md, copylen); mask += copylen; l -= copylen; } gcry_md_close(md_hdl); return 0; } /* EME-OAEP-ENCODE is specified in RFC2437, section 9.1.1.1. Variables are * named after the specification. */ static int raop_crypt_add_oaep_padding(uint8_t *em, const size_t emlen, const uint8_t *m, const size_t mlen, const uint8_t *p, const size_t plen) { uint8_t *seed; uint8_t *db; uint8_t *db_mask; uint8_t *seed_mask; size_t emlen_max; size_t pslen; size_t i; int hlen; int ret; /* Space for 0x00 prefix in EM. */ emlen_max = emlen - 1; hlen = gcry_md_get_algo_dlen(GCRY_MD_SHA1); /* Step 2: * If ||M|| > emLen-2hLen-1 then output "message too long" and stop. */ if (mlen > (emlen_max - (2 * hlen) - 1)) { DPRINTF(E_LOG, L_RAOP, "Could not add OAEP padding: message too long\n"); return -1; } /* Step 3: * Generate an octet string PS consisting of emLen-||M||-2hLen-1 zero * octets. The length of PS may be 0. */ pslen = emlen_max - mlen - (2 * hlen) - 1; /* * Step 5: * Concatenate pHash, PS, the message M, and other padding to form a data * block DB as: DB = pHash || PS || 01 || M */ db = calloc(1, hlen + pslen + 1 + mlen); db_mask = calloc(1, emlen_max - hlen); seed_mask = calloc(1, hlen); if (!db || !db_mask || !seed_mask) { DPRINTF(E_LOG, L_RAOP, "Could not allocate memory for OAEP padding\n"); if (db) free(db); if (db_mask) free(db_mask); if (seed_mask) free(seed_mask); return -1; } /* Step 4: * Let pHash = Hash(P), an octet string of length hLen. */ gcry_md_hash_buffer(GCRY_MD_SHA1, db, p, plen); /* Step 3: * Generate an octet string PS consisting of emLen-||M||-2hLen-1 zero * octets. The length of PS may be 0. */ memset(db + hlen, 0, pslen); /* Step 5: * Concatenate pHash, PS, the message M, and other padding to form a data * block DB as: DB = pHash || PS || 01 || M */ db[hlen + pslen] = 0x01; memcpy(db + hlen + pslen + 1, m, mlen); /* Step 6: * Generate a random octet string seed of length hLen */ seed = gcry_random_bytes(hlen, GCRY_STRONG_RANDOM); if (!seed) { DPRINTF(E_LOG, L_RAOP, "Could not allocate memory for OAEP seed\n"); ret = -1; goto out_free_alloced; } /* Step 7: * Let dbMask = MGF(seed, emLen-hLen). */ ret = raop_crypt_mgf1(db_mask, emlen_max - hlen, seed, hlen, GCRY_MD_SHA1); if (ret < 0) goto out_free_all; /* Step 8: * Let maskedDB = DB \xor dbMask. */ for (i = 0; i < (emlen_max - hlen); i++) db[i] ^= db_mask[i]; /* Step 9: * Let seedMask = MGF(maskedDB, hLen). */ ret = raop_crypt_mgf1(seed_mask, hlen, db, emlen_max - hlen, GCRY_MD_SHA1); if (ret < 0) goto out_free_all; /* Step 10: * Let maskedSeed = seed \xor seedMask. */ for (i = 0; i < hlen; i++) seed[i] ^= seed_mask[i]; /* Step 11: * Let EM = maskedSeed || maskedDB. */ em[0] = 0x00; memcpy(em + 1, seed, hlen); memcpy(em + 1 + hlen, db, hlen + pslen + 1 + mlen); /* Step 12: * Output EM. */ ret = 0; out_free_all: free(seed); out_free_alloced: free(db); free(db_mask); free(seed_mask); return ret; } static char * raop_crypt_encrypt_aes_key_base64(void) { char ebuf[64]; uint8_t padded_key[256]; gpg_error_t gc_err; gcry_sexp_t sexp_rsa_params; gcry_sexp_t sexp_input; gcry_sexp_t sexp_encrypted; gcry_sexp_t sexp_token_a; gcry_mpi_t mpi_pubkey; gcry_mpi_t mpi_exp; gcry_mpi_t mpi_input; gcry_mpi_t mpi_output; char *result; uint8_t *value; size_t value_size; int ret; result = NULL; /* Add RSA-OAES-SHA1 padding */ ret = raop_crypt_add_oaep_padding(padded_key, sizeof(padded_key), raop_aes_key, sizeof(raop_aes_key), NULL, 0); if (ret < 0) return NULL; /* Read public key */ gc_err = gcry_mpi_scan(&mpi_pubkey, GCRYMPI_FMT_USG, raop_rsa_pubkey, sizeof(raop_rsa_pubkey) - 1, NULL); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not read RAOP RSA pubkey: %s\n", ebuf); return NULL; } /* Read exponent */ gc_err = gcry_mpi_scan(&mpi_exp, GCRYMPI_FMT_USG, raop_rsa_exp, sizeof(raop_rsa_exp) - 1, NULL); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not read RAOP RSA exponent: %s\n", ebuf); goto out_free_mpi_pubkey; } /* If the input data starts with a set bit (0x80), gcrypt thinks it's a * signed integer and complains. Prefixing it with a zero byte (\0) * works, but involves more work. Converting it to an MPI in our code is * cleaner. */ gc_err = gcry_mpi_scan(&mpi_input, GCRYMPI_FMT_USG, padded_key, sizeof(padded_key), NULL); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not convert input data: %s\n", ebuf); goto out_free_mpi_exp; } /* Build S-expression with RSA parameters */ gc_err = gcry_sexp_build(&sexp_rsa_params, NULL, "(public-key(rsa(n %m)(e %m)))", mpi_pubkey, mpi_exp); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not build RSA params S-exp: %s\n", ebuf); goto out_free_mpi_input; } /* Build S-expression for data */ gc_err = gcry_sexp_build(&sexp_input, NULL, "(data(value %m))", mpi_input); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not build data S-exp: %s\n", ebuf); goto out_free_sexp_params; } /* Encrypt data */ gc_err = gcry_pk_encrypt(&sexp_encrypted, sexp_input, sexp_rsa_params); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not encrypt data: %s\n", ebuf); goto out_free_sexp_input; } /* Extract encrypted data */ sexp_token_a = gcry_sexp_find_token(sexp_encrypted, "a", 0); if (!sexp_token_a) { DPRINTF(E_LOG, L_RAOP, "Could not find token 'a' in result S-exp\n"); goto out_free_sexp_encrypted; } mpi_output = gcry_sexp_nth_mpi(sexp_token_a, 1, GCRYMPI_FMT_USG); if (!mpi_output) { DPRINTF(E_LOG, L_RAOP, "Cannot extract MPI from result\n"); goto out_free_sexp_token_a; } /* Copy encrypted data into char array */ gc_err = gcry_mpi_aprint(GCRYMPI_FMT_USG, &value, &value_size, mpi_output); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not copy encrypted data: %s\n", ebuf); goto out_free_mpi_output; } /* Encode in Base64 */ result = b64_encode(value, value_size); free(value); out_free_mpi_output: gcry_mpi_release(mpi_output); out_free_sexp_token_a: gcry_sexp_release(sexp_token_a); out_free_sexp_encrypted: gcry_sexp_release(sexp_encrypted); out_free_sexp_input: gcry_sexp_release(sexp_input); out_free_sexp_params: gcry_sexp_release(sexp_rsa_params); out_free_mpi_input: gcry_mpi_release(mpi_input); out_free_mpi_exp: gcry_mpi_release(mpi_exp); out_free_mpi_pubkey: gcry_mpi_release(mpi_pubkey); return result; } /* RAOP metadata */ static void raop_metadata_free(struct raop_metadata *rmd) { evbuffer_free(rmd->metadata); if (rmd->artwork) evbuffer_free(rmd->artwork); free(rmd); } void raop_metadata_purge(void) { struct raop_metadata *rmd; for (rmd = metadata_head; rmd; rmd = metadata_head) { metadata_head = rmd->next; raop_metadata_free(rmd); } metadata_tail = NULL; } void raop_metadata_prune(uint64_t rtptime) { struct raop_metadata *rmd; for (rmd = metadata_head; rmd; rmd = metadata_head) { if (rmd->end >= rtptime) break; if (metadata_tail == metadata_head) metadata_tail = rmd->next; metadata_head = rmd->next; raop_metadata_free(rmd); } } static struct raop_metadata * raop_metadata_prepare(int id, uint64_t rtptime) { struct query_params qp; struct db_media_file_info dbmfi; char filter[32]; struct raop_metadata *rmd; struct evbuffer *tmp; uint64_t duration; int ret; ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not acquire database connection; cannot get metadata\n"); return NULL; } rmd = (struct raop_metadata *)malloc(sizeof(struct raop_metadata)); if (!rmd) { DPRINTF(E_LOG, L_RAOP, "Out of memory for RAOP metadata\n"); goto out_db; } memset(rmd, 0, sizeof(struct raop_metadata)); /* Get dbmfi */ memset(&qp, 0, sizeof(struct query_params)); qp.type = Q_ITEMS; qp.idx_type = I_NONE; qp.sort = S_NONE; qp.filter = filter; ret = snprintf(filter, sizeof(filter), "id = %d", id); if ((ret < 0) || (ret >= sizeof(filter))) { DPRINTF(E_LOG, L_RAOP, "Could not build filter for file id %d; metadata will not be sent\n", id); goto out_rmd; } ret = db_query_start(&qp); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't start query; no metadata will be sent\n"); goto out_rmd; } ret = db_query_fetch_file(&qp, &dbmfi); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't fetch file id %d; metadata will not be sent\n", id); goto out_query; } /* Turn it into DAAP metadata */ tmp = evbuffer_new(); if (!tmp) { DPRINTF(E_LOG, L_RAOP, "Out of memory for temporary metadata evbuffer; metadata will not be sent\n"); goto out_query; } rmd->metadata = evbuffer_new(); if (!rmd->metadata) { DPRINTF(E_LOG, L_RAOP, "Out of memory for metadata evbuffer; metadata will not be sent\n"); evbuffer_free(tmp); goto out_query; } ret = dmap_encode_file_metadata(rmd->metadata, tmp, &dbmfi, NULL, 0, 0, 1); evbuffer_free(tmp); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not encode file metadata; metadata will not be sent\n"); goto out_metadata; } /* Progress */ ret = safe_atou64(dbmfi.song_length, &duration); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Failed to convert song_length to integer; no metadata will be sent\n"); goto out_metadata; } rmd->start = rtptime; rmd->end = rtptime + (duration * 44100UL) / 1000UL; /* Get artwork */ rmd->artwork = evbuffer_new(); if (!rmd->artwork) { DPRINTF(E_LOG, L_RAOP, "Out of memory for artwork evbuffer; no artwork will be sent\n"); goto skip_artwork; } ret = artwork_get_item_filename(dbmfi.path, 600, 600, ART_CAN_PNG | ART_CAN_JPEG, rmd->artwork); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Failed to retrieve artwork for '%s' (%d); no artwork will be sent\n", dbmfi.title, id); evbuffer_free(rmd->artwork); rmd->artwork = NULL; } rmd->artwork_fmt = ret; skip_artwork: db_query_end(&qp); db_pool_release(); /* Add rmd to metadata list */ if (metadata_tail) metadata_tail->next = rmd; else { metadata_head = rmd; metadata_tail = rmd; } return rmd; out_metadata: evbuffer_free(rmd->metadata); out_query: db_query_end(&qp); out_rmd: free(rmd); out_db: db_pool_release(); return NULL; } /* Helpers */ static int raop_add_auth(struct raop_session *rs, struct http_request *req, const char *method, const char *uri) { char ha1[33]; char ha2[33]; char ebuf[64]; char auth[256]; const char *hash_fmt; const char *username; uint8_t *hash_bytes; size_t hashlen; gcry_md_hd_t hd; gpg_error_t gc_err; int i; int ret; rs->req_has_auth = 0; if (!rs->nonce) return 0; if (!rs->password) { DPRINTF(E_LOG, L_RAOP, "Authentication required but no password found for device %s\n", rs->devname); return -2; } if (rs->auth_quirk_itunes) { hash_fmt = "%02X"; /* Uppercase hex */ username = "iTunes"; } else { hash_fmt = "%02x"; username = ""; /* No username */ } gc_err = gcry_md_open(&hd, GCRY_MD_MD5, 0); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not open MD5: %s\n", ebuf); return -1; } memset(ha1, 0, sizeof(ha1)); memset(ha2, 0, sizeof(ha2)); hashlen = gcry_md_get_algo_dlen(GCRY_MD_MD5); /* HA 1 */ gcry_md_write(hd, username, strlen(username)); gcry_md_write(hd, ":", 1); gcry_md_write(hd, rs->realm, strlen(rs->realm)); gcry_md_write(hd, ":", 1); gcry_md_write(hd, rs->password, strlen(rs->password)); hash_bytes = gcry_md_read(hd, GCRY_MD_MD5); if (!hash_bytes) { DPRINTF(E_LOG, L_RAOP, "Could not read MD5 hash\n"); return -1; } for (i = 0; i < hashlen; i++) sprintf(ha1 + (2 * i), hash_fmt, hash_bytes[i]); /* RESET */ gcry_md_reset(hd); /* HA 2 */ gcry_md_write(hd, method, strlen(method)); gcry_md_write(hd, ":", 1); gcry_md_write(hd, uri, strlen(uri)); hash_bytes = gcry_md_read(hd, GCRY_MD_MD5); if (!hash_bytes) { DPRINTF(E_LOG, L_RAOP, "Could not read MD5 hash\n"); return -1; } for (i = 0; i < hashlen; i++) sprintf(ha2 + (2 * i), hash_fmt, hash_bytes[i]); /* RESET */ gcry_md_reset(hd); /* Final value */ gcry_md_write(hd, ha1, 32); gcry_md_write(hd, ":", 1); gcry_md_write(hd, rs->nonce, strlen(rs->nonce)); gcry_md_write(hd, ":", 1); gcry_md_write(hd, ha2, 32); hash_bytes = gcry_md_read(hd, GCRY_MD_MD5); if (!hash_bytes) { DPRINTF(E_LOG, L_RAOP, "Could not read MD5 hash\n"); return -1; } for (i = 0; i < hashlen; i++) sprintf(ha1 + (2 * i), hash_fmt, hash_bytes[i]); gcry_md_close(hd); /* Build header */ ret = snprintf(auth, sizeof(auth), "Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", uri=\"%s\", response=\"%s\"", username, rs->realm, rs->nonce, uri, ha1); if ((ret < 0) || (ret >= sizeof(auth))) { DPRINTF(E_LOG, L_RAOP, "Authorization value header exceeds buffer size\n"); return -1; } http_request_add_header(req, "Authorization", auth); DPRINTF(E_DBG, L_RAOP, "Authorization header: %s\n", auth); rs->req_has_auth = 1; return 0; } static int raop_parse_auth(struct raop_session *rs, struct http_response *r) { const char *param; char *auth; char *token; char *ptr; if (rs->realm) { free(rs->realm); rs->realm = NULL; } if (rs->nonce) { free(rs->nonce); rs->nonce = NULL; } param = http_response_get_header(r, "WWW-Authenticate"); if (!param) { DPRINTF(E_LOG, L_RAOP, "WWW-Authenticate header not found\n"); return -1; } DPRINTF(E_DBG, L_RAOP, "WWW-Authenticate: %s\n", param); if (strncmp(param, "Digest ", strlen("Digest ")) != 0) { DPRINTF(E_LOG, L_RAOP, "Unsupported authentication method: %s\n", param); return -1; } auth = strdup(param); if (!auth) { DPRINTF(E_LOG, L_RAOP, "Out of memory for WWW-Authenticate header copy\n"); return -1; } token = strchr(auth, ' '); token++; token = strtok_r(token, " =", &ptr); while (token) { if (strcmp(token, "realm") == 0) { token = strtok_r(NULL, "=\"", &ptr); if (!token) break; rs->realm = strdup(token); } else if (strcmp(token, "nonce") == 0) { token = strtok_r(NULL, "=\"", &ptr); if (!token) break; rs->nonce = strdup(token); } token = strtok_r(NULL, " =", &ptr); } free(auth); if (!rs->realm || !rs->nonce) { DPRINTF(E_LOG, L_RAOP, "Could not find realm/nonce in WWW-Authenticate header\n"); if (rs->realm) { free(rs->realm); rs->realm = NULL; } if (rs->nonce) { free(rs->nonce); rs->nonce = NULL; } return -1; } DPRINTF(E_DBG, L_RAOP, "Found realm: [%s], nonce: [%s]\n", rs->realm, rs->nonce); return 0; } static int raop_add_headers(struct raop_session *rs, struct http_request *req, enum request_method req_method) { char buf[64]; const char *method; const char *url; int ret; method = http_method(req_method); DPRINTF(E_DBG, L_RAOP, "Building %s for %s\n", method, rs->devname); snprintf(buf, sizeof(buf), "%d", rs->cseq); http_request_add_header(req, "CSeq", buf); rs->cseq++; http_request_add_header(req, "User-Agent", "forked-daapd/" VERSION); /* Add Authorization header */ url = (req_method == RTSP_OPTIONS) ? "*" : rs->session_url; ret = raop_add_auth(rs, req, method, url); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not add Authorization header\n"); if (ret == -2) rs->state = RAOP_PASSWORD; return -1; } snprintf(buf, sizeof(buf), "%" PRIX64, libhash); http_request_add_header(req, "Client-Instance", buf); http_request_add_header(req, "DACP-ID", buf); if (rs->session) http_request_add_header(req, "Session", rs->session); /* Content-Length added automatically by gcd-http */ return 0; } static int raop_check_cseq(struct raop_session *rs, struct http_request *req, struct http_response *r) { const char *param; int reply_cseq; int request_cseq; int ret; /* Reply CSeq */ param = http_response_get_header(r, "CSeq"); if (!param) { DPRINTF(E_LOG, L_RAOP, "No CSeq in reply\n"); return -1; } ret = safe_atoi32(param, &reply_cseq); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not convert reply CSeq value to integer (%s)\n", param); return -1; } /* Request CSeq */ param = http_request_get_header(req, "CSeq"); if (!param) { DPRINTF(E_LOG, L_RAOP, "No CSeq in request\n"); return -1; } ret = safe_atoi32(param, &request_cseq); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not convert request CSeq value to integer (%s)\n", param); return -1; } if (reply_cseq == request_cseq) return 0; DPRINTF(E_LOG, L_RAOP, "Reply CSeq does not match request CSeq: got %d expected %d\n", reply_cseq, request_cseq); return -1; } static int raop_make_sdp(struct raop_session *rs, struct http_request *req, char *address, uint32_t session_id) { #define SDP_PLD_FMT \ "v=0\r\n" \ "o=iTunes %u 0 IN IP4 %s\r\n" \ "s=iTunes\r\n" \ "c=IN IP4 %s\r\n" \ "t=0 0\r\n" \ "m=audio 0 RTP/AVP 96\r\n" \ "a=rtpmap:96 AppleLossless\r\n" \ "a=fmtp:96 %d 0 16 40 10 14 2 255 0 0 44100\r\n" \ "a=rsaaeskey:%s\r\n" \ "a=aesiv:%s\r\n" struct evbuffer *evbuf; char *p; int ret; evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_RAOP, "Could not create evbuffer for SDP payload\n"); return -1; } p = strchr(rs->address, '%'); if (p) *p = '\0'; /* Add SDP payload */ ret = evbuffer_add_printf(evbuf, SDP_PLD_FMT, session_id, address, rs->address, AIRTUNES_V2_PACKET_SAMPLES, raop_aes_key_b64, raop_aes_iv_b64); if (p) *p = '%'; if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Out of memory for SDP payload\n"); evbuffer_free(evbuf); return -1; } http_request_set_body(req, evbuf); return 0; #undef SDP_PLD_FMT } /* RAOP/RTSP requests */ static int raop_send_req_teardown(struct raop_session *rs, http_cb cb) { struct http_request *req; int ret; req = http_client_request_new(RTSP_TEARDOWN, P_VER_1_0, rs->session_url, cb); if (!req) { DPRINTF(E_LOG, L_RAOP, "Could not create RTSP request for TEARDOWN\n"); return -1; } ret = raop_add_headers(rs, req, RTSP_TEARDOWN); if (ret < 0) { http_request_free(req); return -1; } ret = http_client_request_run(rs->ctrl, req); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not run TEARDOWN request\n"); http_request_free(req); return -1; } rs->reqs_in_flight++; return 0; } static int raop_send_req_flush(struct raop_session *rs, uint64_t rtptime, http_cb cb) { char buf[64]; struct http_request *req; int ret; req = http_client_request_new(RTSP_FLUSH, P_VER_1_0, rs->session_url, cb); if (!req) { DPRINTF(E_LOG, L_RAOP, "Could not create RTSP request for FLUSH\n"); return -1; } ret = raop_add_headers(rs, req, RTSP_FLUSH); if (ret < 0) { http_request_free(req); return -1; } /* Restart sequence: last sequence + 1 */ ret = snprintf(buf, sizeof(buf), "seq=%u;rtptime=%u", stream_seq + 1, RAOP_RTPTIME(rtptime)); if ((ret < 0) || (ret >= sizeof(buf))) { DPRINTF(E_LOG, L_RAOP, "RTP-Info too big for buffer in FLUSH request\n"); http_request_free(req); return -1; } http_request_add_header(req, "RTP-Info", buf); ret = http_client_request_run(rs->ctrl, req); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not run FLUSH request\n"); http_request_free(req); return -1; } rs->reqs_in_flight++; return 0; } static int raop_send_req_set_parameter(struct raop_session *rs, struct evbuffer *evbuf, char *ctype, char *rtpinfo, http_cb cb) { struct http_request *req; int ret; req = http_client_request_new(RTSP_SET_PARAMETER, P_VER_1_0, rs->session_url, cb); if (!req) { DPRINTF(E_LOG, L_RAOP, "Could not create RTSP request for SET_PARAMETER\n"); evbuffer_free(evbuf); return -1; } http_request_set_body(req, evbuf); ret = raop_add_headers(rs, req, RTSP_SET_PARAMETER); if (ret < 0) { http_request_free(req); return -1; } http_request_add_header(req, "Content-Type", ctype); if (rtpinfo) http_request_add_header(req, "RTP-Info", rtpinfo); ret = http_client_request_run(rs->ctrl, req); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not run SET_PARAMETER request\n"); http_request_free(req); return -1; } rs->reqs_in_flight++; return 0; } static int raop_send_req_record(struct raop_session *rs, http_cb cb) { char buf[64]; struct http_request *req; int ret; req = http_client_request_new(RTSP_RECORD, P_VER_1_0, rs->session_url, cb); if (!req) { DPRINTF(E_LOG, L_RAOP, "Could not create RTSP request for RECORD\n"); return -1; } ret = raop_add_headers(rs, req, RTSP_RECORD); if (ret < 0) { http_request_free(req); return -1; } http_request_add_header(req, "Range", "npt=0-"); /* Start sequence: next sequence */ ret = snprintf(buf, sizeof(buf), "seq=%u;rtptime=%u", stream_seq + 1, RAOP_RTPTIME(rs->start_rtptime)); if ((ret < 0) || (ret >= sizeof(buf))) { DPRINTF(E_LOG, L_RAOP, "RTP-Info too big for buffer in RECORD request\n"); http_request_free(req); return -1; } http_request_add_header(req, "RTP-Info", buf); ret = http_client_request_run(rs->ctrl, req); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not run RECORD request\n"); http_request_free(req); return -1; } rs->reqs_in_flight++; return 0; } static int raop_send_req_setup(struct raop_session *rs, http_cb cb) { char hdr[128]; struct http_request *req; int ret; req = http_client_request_new(RTSP_SETUP, P_VER_1_0, rs->session_url, cb); if (!req) { DPRINTF(E_LOG, L_RAOP, "Could not create RTSP request for SETUP\n"); return -1; } ret = raop_add_headers(rs, req, RTSP_SETUP); if (ret < 0) { http_request_free(req); return -1; } /* Request UDP transport, AirTunes v2 streaming */ ret = snprintf(hdr, sizeof(hdr), "RTP/AVP/UDP;unicast;interleaved=0-1;mode=record;control_port=%u;timing_port=%u", rs->control_svc->port, rs->timing_svc->port); if ((ret < 0) || (ret >= sizeof(hdr))) { DPRINTF(E_LOG, L_RAOP, "Transport header exceeds buffer length\n"); http_request_free(req); return -1; } http_request_add_header(req, "Transport", hdr); ret = http_client_request_run(rs->ctrl, req); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not run SETUP request\n"); http_request_free(req); return -1; } rs->reqs_in_flight++; return 0; } static int raop_send_req_announce(struct raop_session *rs, http_cb cb) { char address[NCONN_ADDRSTRLEN]; uint8_t challenge[16]; char *challenge_b64; char *ptr; struct http_request *req; char *intf; uint32_t session_id; int ret; /* Determine local address, needed for SDP and session URL */ ret = http_connection_get_local_addr(rs->ctrl, address); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not determine local address\n"); return -1; } intf = strchr(address, '%'); if (intf) { *intf = '\0'; intf++; } DPRINTF(E_DBG, L_RAOP, "Local address: %s (LL: %s)\n", address, (intf) ? intf : "no"); /* Session ID and session URL */ gcry_randomize(&session_id, sizeof(session_id), GCRY_STRONG_RANDOM); ret = snprintf(rs->session_url, sizeof(rs->session_url), "rtsp://%s/%u", address, session_id); if ((ret < 0) || (ret >= sizeof(rs->session_url))) { DPRINTF(E_LOG, L_RAOP, "Session URL length exceeds 127 characters\n"); return -1; } req = http_client_request_new(RTSP_ANNOUNCE, P_VER_1_0, rs->session_url, cb); if (!req) { DPRINTF(E_LOG, L_RAOP, "Could not create RTSP request for ANNOUNCE\n"); return -1; } /* SDP payload */ ret = raop_make_sdp(rs, req, address, session_id); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not generate SDP payload for ANNOUNCE\n"); goto cleanup_req; } ret = raop_add_headers(rs, req, RTSP_ANNOUNCE); if (ret < 0) goto cleanup_req; http_request_add_header(req, "Content-Type", "application/sdp"); /* Challenge */ gcry_randomize(challenge, sizeof(challenge), GCRY_STRONG_RANDOM); challenge_b64 = b64_encode(challenge, sizeof(challenge)); if (!challenge_b64) { DPRINTF(E_LOG, L_RAOP, "Couldn't encode challenge\n"); goto cleanup_req; } /* Remove base64 padding */ ptr = strchr(challenge_b64, '='); if (ptr) *ptr = '\0'; http_request_add_header(req, "Apple-Challenge", challenge_b64); free(challenge_b64); ret = http_client_request_run(rs->ctrl, req); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not run ANNOUNCE request\n"); goto cleanup_req; } rs->reqs_in_flight++; return 0; cleanup_req: http_request_free(req); return -1; } static int raop_send_req_options(struct raop_session *rs, http_cb cb) { struct http_request *req; int ret; req = http_client_request_new(RTSP_OPTIONS, P_VER_1_0, "*", cb); if (!req) { DPRINTF(E_LOG, L_RAOP, "Could not create RTSP request for OPTIONS\n"); return -1; } ret = raop_add_headers(rs, req, RTSP_OPTIONS); if (ret < 0) { http_request_free(req); return -1; } ret = http_client_request_run(rs->ctrl, req); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not make OPTIONS request\n"); http_request_free(req); return -1; } rs->reqs_in_flight++; return 0; } static void raop_session_free(struct raop_session *rs) { close(rs->server_fd); if (rs->realm) free(rs->realm); if (rs->nonce) free(rs->nonce); if (rs->session) free(rs->session); if (rs->address) free(rs->address); if (rs->devname) free(rs->devname); free(rs); } static void raop_pktbuf_free_task(void *arg) { struct raop_v2_packet *pkt; pkt = (struct raop_v2_packet *)arg; for (; pkt; pkt = pkt->next) free(pkt); } static void raop_session_cleanup(struct raop_session *rs) { struct raop_session *s; dispatch_queue_t global_q; if (rs == sessions) sessions = sessions->next; else { for (s = sessions; s && (s->next != rs); s = s->next) ; /* EMPTY */ if (!s) DPRINTF(E_WARN, L_RAOP, "WARNING: struct raop_session not found in list; BUG!\n"); else s->next = rs->next; } /* free_cb takes care of rs */ http_client_free(rs->ctrl); /* No more active sessions, free retransmit buffer */ if (!sessions) { global_q = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_async_f(global_q, pktbuf_head, raop_pktbuf_free_task); pktbuf_head = NULL; pktbuf_tail = NULL; pktbuf_size = 0; } } static void raop_session_failure(struct raop_session *rs) { /* Session failed, let our user know */ if (rs->state != RAOP_PASSWORD) rs->state = RAOP_FAILED; rs->status_cb(rs->dev, rs, rs->state); raop_session_cleanup(rs); } static void raop_rtsp_free_cb(void *data) { struct raop_session *rs; rs = (struct raop_session *)data; raop_session_free(rs); } static void raop_rtsp_fail_cb(struct http_connection *c, void *data) { struct raop_session *rs; rs = (struct raop_session *)data; DPRINTF(E_LOG, L_RAOP, "ApEx %s closed RTSP connection\n", rs->devname); rs->state = RAOP_FAILED; raop_session_failure(rs); } static struct raop_session * raop_session_make(struct raop_device *rd, int family, raop_status_cb cb) { struct raop_session *rs; char *address; char *intf; unsigned short port; int ret; switch (family) { case AF_INET: /* We always have the v4 services, so no need to check */ if (!rd->v4_address) return NULL; address = rd->v4_address; port = rd->v4_port; break; case AF_INET6: if (!rd->v6_address || (timing_6svc.fd < 0) || (control_6svc.fd < 0)) return NULL; address = rd->v6_address; port = rd->v6_port; break; default: return NULL; } rs = (struct raop_session *)malloc(sizeof(struct raop_session)); if (!rs) { DPRINTF(E_LOG, L_RAOP, "Out of memory for RAOP session\n"); return NULL; } memset(rs, 0, sizeof(struct raop_session)); rs->state = RAOP_STOPPED; rs->reqs_in_flight = 0; rs->cseq = 1; rs->dev = rd; rs->status_cb = cb; rs->server_fd = -1; rs->password = rd->password; switch (rd->devtype) { case RAOP_DEV_APEX_80211G: rs->encrypt = 1; rs->auth_quirk_itunes = 1; rs->wants_metadata = 0; break; case RAOP_DEV_APEX_80211N: rs->encrypt = 1; rs->auth_quirk_itunes = 0; rs->wants_metadata = 0; break; case RAOP_DEV_APPLETV: rs->encrypt = 0; rs->auth_quirk_itunes = 0; rs->wants_metadata = 1; break; } rs->devname = strdup(rd->name); rs->ctrl = http_client_new(L_RAOP, address, port, raop_rtsp_fail_cb, raop_rtsp_free_cb, rs); if (!rs->ctrl) { DPRINTF(E_LOG, L_RAOP, "Could not create control connection to %s\n", address); free(rs->devname); free(rs); return NULL; } rs->sa.ss.ss_family = family; switch (family) { case AF_INET: rs->timing_svc = &timing_4svc; rs->control_svc = &control_4svc; ret = inet_pton(AF_INET, address, &rs->sa.sin.sin_addr); break; case AF_INET6: rs->timing_svc = &timing_6svc; rs->control_svc = &control_6svc; intf = strchr(address, '%'); if (intf) *intf = '\0'; ret = inet_pton(AF_INET6, address, &rs->sa.sin6.sin6_addr); if (intf) { *intf = '%'; intf++; rs->sa.sin6.sin6_scope_id = if_nametoindex(intf); if (rs->sa.sin6.sin6_scope_id == 0) { DPRINTF(E_LOG, L_RAOP, "Could not find interface %s\n", intf); ret = -1; break; } } break; default: ret = -1; break; } if (ret <= 0) { DPRINTF(E_LOG, L_RAOP, "Device address not valid (%s)\n", address); /* free_cb takes care of rs */ http_client_free(rs->ctrl); return NULL; } rs->address = strdup(address); rs->volume = rd->volume; rs->next = sessions; sessions = rs; return rs; } static int raop_session_failure_cb(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { struct raop_session *rs; rs = (struct raop_session *)arg; http_request_free(req); raop_session_failure(rs); return 0; } /* Metadata handling */ static int raop_cb_metadata(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { struct raop_session *rs; const char *reason; int code; int ret; rs = (struct raop_session *)arg; rs->reqs_in_flight--; code = http_response_get_status(r, &reason); if (code != HTTP_OK) { DPRINTF(E_LOG, L_RAOP, "SET_PARAMETER request failed for metadata/artwork/progress: %d %s\n", code, reason); goto error; } ret = raop_check_cseq(rs, req, r); if (ret < 0) goto error; http_request_free(req); /* No status_cb call, user doesn't want/need to know about the status * of metadata requests unless they cause the session to fail. */ return 0; error: http_request_free(req); raop_session_failure(rs); return 0; } static int raop_metadata_send_progress(struct raop_session *rs, struct raop_metadata *rmd, uint64_t offset, uint32_t delay) { struct evbuffer *evbuf; uint32_t display; int ret; /* Here's the deal with progress values: * - first value, called display, is always start minus a delay * -> delay x1 if streaming is starting for this device (joining or not) * -> delay x2 if stream is switching to a new song * - second value, called start, is the RTP time of the first sample for this * song for this device * -> start of song * -> start of song + offset if device is joining in the middle of a song, * or getting out of a pause or seeking * - third value, called end, is the RTP time of the last sample for this song */ display = RAOP_RTPTIME(rmd->start - delay); evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_RAOP, "Could not allocate temp evbuffer for metadata processing\n"); return -1; } ret = evbuffer_add_printf(evbuf, "progress: %u/%u/%u\r\n", display, RAOP_RTPTIME(rmd->start + offset), RAOP_RTPTIME(rmd->end)); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not build progress string for sending\n"); evbuffer_free(evbuf); return -1; } /* evbuf owned by raop_send_req_set_parameter() */ ret = raop_send_req_set_parameter(rs, evbuf, "text/parameters", NULL, raop_cb_metadata); if (ret < 0) DPRINTF(E_LOG, L_RAOP, "Could not send SET_PARAMETER request for metadata\n"); return ret; } static int raop_metadata_send_artwork(struct raop_session *rs, struct raop_metadata *rmd, char *rtptime) { struct evbuffer *evbuf; char *ctype; int ret; switch (rmd->artwork_fmt) { case ART_FMT_PNG: ctype = "image/png"; break; case ART_FMT_JPEG: ctype = "image/jpeg"; break; default: DPRINTF(E_LOG, L_RAOP, "Unsupported artwork format %d\n", rmd->artwork_fmt); return -1; } evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_RAOP, "Could not allocate temp evbuffer for metadata processing\n"); return -1; } ret = evbuffer_add(evbuf, EVBUFFER_DATA(rmd->artwork), EVBUFFER_LENGTH(rmd->artwork)); if (ret != 0) { DPRINTF(E_LOG, L_RAOP, "Could not copy artwork for sending\n"); evbuffer_free(evbuf); return -1; } /* evbuf owned by raop_send_req_set_parameter() */ ret = raop_send_req_set_parameter(rs, evbuf, ctype, rtptime, raop_cb_metadata); if (ret < 0) DPRINTF(E_LOG, L_RAOP, "Could not send SET_PARAMETER request for metadata\n"); return ret; } static int raop_metadata_send_metadata(struct raop_session *rs, struct raop_metadata *rmd, char *rtptime) { struct evbuffer *evbuf; int ret; evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_RAOP, "Could not allocate temp evbuffer for metadata processing\n"); return -1; } ret = evbuffer_add(evbuf, EVBUFFER_DATA(rmd->metadata), EVBUFFER_LENGTH(rmd->metadata)); if (ret != 0) { DPRINTF(E_LOG, L_RAOP, "Could not copy metadata for sending\n"); evbuffer_free(evbuf); return -1; } /* evbuf owned by raop_send_req_set_parameter() */ ret = raop_send_req_set_parameter(rs, evbuf, "application/x-dmap-tagged", rtptime, raop_cb_metadata); if (ret < 0) DPRINTF(E_LOG, L_RAOP, "Could not send SET_PARAMETER request for metadata\n"); return ret; } static int raop_metadata_send_internal(struct raop_session *rs, struct raop_metadata *rmd, uint64_t offset, uint32_t delay) { char rtptime[32]; int ret; ret = snprintf(rtptime, sizeof(rtptime), "rtptime=%u", RAOP_RTPTIME(rmd->start)); if ((ret < 0) || (ret >= sizeof(rtptime))) { DPRINTF(E_LOG, L_RAOP, "RTP-Info too big for buffer while sending metadata\n"); return -1; } ret = raop_metadata_send_metadata(rs, rmd, rtptime); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not send metadata to %s\n", rs->devname); return -1; } if (!rmd->artwork) goto skip_artwork; ret = raop_metadata_send_artwork(rs, rmd, rtptime); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not send artwork to %s\n", rs->devname); return -1; } skip_artwork: ret = raop_metadata_send_progress(rs, rmd, offset, delay); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not send progress to %s\n", rs->devname); return -1; } return 0; } static void raop_metadata_startup_send(struct raop_session *rs) { struct raop_metadata *rmd; uint64_t offset; int sent; int ret; if (!rs->wants_metadata) return; sent = 0; for (rmd = metadata_head; rmd; rmd = rmd->next) { /* Current song */ if ((rs->start_rtptime >= rmd->start) && (rs->start_rtptime < rmd->end)) { offset = rs->start_rtptime - rmd->start; ret = raop_metadata_send_internal(rs, rmd, offset, RAOP_MD_DELAY_STARTUP); if (ret < 0) { raop_session_failure(rs); return; } sent = 1; } /* Next song(s) */ else if (sent && (rs->start_rtptime < rmd->start)) { ret = raop_metadata_send_internal(rs, rmd, 0, RAOP_MD_DELAY_SWITCH); if (ret < 0) { raop_session_failure(rs); return; } } } } void raop_metadata_send(int id, uint64_t rtptime, uint64_t offset, int startup) { struct raop_session *rs; struct raop_metadata *rmd; uint32_t delay; int ret; rmd = raop_metadata_prepare(id, rtptime); if (!rmd) return; for (rs = sessions; rs; rs = rs->next) { if (!(rs->state & RAOP_F_CONNECTED)) continue; if (!rs->wants_metadata) continue; delay = (startup) ? RAOP_MD_DELAY_STARTUP : RAOP_MD_DELAY_SWITCH; ret = raop_metadata_send_internal(rs, rmd, offset, delay); if (ret < 0) { raop_session_failure(rs); continue; } } } /* Volume handling */ static float raop_volume_convert(int volume) { float raop_volume; /* RAOP volume * -144.0 is off * 0 - -30.0 maps to 100 - 0 */ if (volume == 0) raop_volume = -144.0; else raop_volume = -30.0 + ((float)volume * 30.0) / 100.0; return raop_volume; } static int raop_set_volume_internal(struct raop_session *rs, int volume, http_cb cb) { struct evbuffer *evbuf; float raop_volume; int ret; evbuf = evbuffer_new(); if (!evbuf) { DPRINTF(E_LOG, L_RAOP, "Could not allocate evbuffer for volume payload\n"); return -1; } raop_volume = raop_volume_convert(volume); /* Don't let locales get in the way here */ ret = evbuffer_add_printf(evbuf, "volume: %d.%06d\r\n", (int)raop_volume, -(int)(1000000.0 * (raop_volume - (int)raop_volume))); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Out of memory for SET_PARAMETER payload (volume)\n"); evbuffer_free(evbuf); return -1; } /* evbuf owned by raop_send_req_set_parameter() */ ret = raop_send_req_set_parameter(rs, evbuf, "text/parameters", NULL, cb); if (ret < 0) DPRINTF(E_LOG, L_RAOP, "Could not send SET_PARAMETER request for volume\n"); return ret; } static int raop_cb_set_volume(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { raop_status_cb status_cb; struct raop_session *rs; const char *reason; int code; int ret; rs = (struct raop_session *)arg; rs->reqs_in_flight--; code = http_response_get_status(r, &reason); if (code != HTTP_OK) { DPRINTF(E_LOG, L_RAOP, "SET_PARAMETER request failed for stream volume: %d %s\n", code, reason); goto error; } ret = raop_check_cseq(rs, req, r); if (ret < 0) goto error; http_request_free(req); /* Let our user know */ status_cb = rs->status_cb; rs->status_cb = NULL; status_cb(rs->dev, rs, rs->state); return 0; error: http_request_free(req); raop_session_failure(rs); return 0; } /* Volume in [0 - 100] */ int raop_set_volume_one(struct raop_session *rs, int volume, raop_status_cb cb) { int ret; if (!(rs->state & RAOP_F_CONNECTED)) return 0; ret = raop_set_volume_internal(rs, volume, raop_cb_set_volume); if (ret < 0) { raop_session_failure(rs); return 0; } rs->status_cb = cb; return 1; } static int raop_cb_flush(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { raop_status_cb status_cb; struct raop_session *rs; const char *reason; int code; int ret; rs = (struct raop_session *)arg; rs->reqs_in_flight--; code = http_response_get_status(r, &reason); if (code != HTTP_OK) { DPRINTF(E_LOG, L_RAOP, "FLUSH request failed: %d %s\n", code, reason); goto error; } ret = raop_check_cseq(rs, req, r); if (ret < 0) goto error; http_request_free(req); rs->state = RAOP_CONNECTED; /* Let our user know */ status_cb = rs->status_cb; rs->status_cb = NULL; status_cb(rs->dev, rs, rs->state); return 0; error: http_request_free(req); raop_session_failure(rs); return 0; } static void raop_flush_timer_cb(void *arg) { struct raop_session *rs; if (!flush_timer_src) return; dispatch_source_cancel(flush_timer_src); dispatch_release(flush_timer_src); flush_timer_src = NULL; DPRINTF(E_DBG, L_RAOP, "Flush timer expired; tearing down RAOP sessions\n"); for (rs = sessions; rs; rs = rs->next) { if (!(rs->state & RAOP_F_CONNECTED)) continue; raop_device_stop(rs); } } int raop_flush(raop_status_cb cb, uint64_t rtptime) { struct raop_session *rs; int pending; int ret; pending = 0; for (rs = sessions; rs; rs = rs->next) { if (rs->state != RAOP_STREAMING) continue; ret = raop_send_req_flush(rs, rtptime, raop_cb_flush); if (ret < 0) { raop_session_failure(rs); continue; } rs->status_cb = cb; pending++; } if (pending > 0) { if (!flush_timer_src) { flush_timer_src = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, player_sq); if (!flush_timer_src) { DPRINTF(E_LOG, L_RAOP, "Could not create flush timer dispatch source\n"); return pending; } dispatch_source_set_event_handler_f(flush_timer_src, raop_flush_timer_cb); } else dispatch_suspend(flush_timer_src); dispatch_source_set_timer(flush_timer_src, dispatch_time(DISPATCH_TIME_NOW, 10 * NSEC_PER_SEC), DISPATCH_TIME_FOREVER /* one-shot */, 0); dispatch_resume(flush_timer_src); } return pending; } /* Generic service cancel handler */ static void raop_v2_svc_cancel_cb(void *arg) { struct raop_service *svc; svc = (struct raop_service *)arg; close(svc->fd); svc->fd = -1; svc->port = 0; } /* AirTunes v2 time synchronization */ static void raop_v2_timing_cb(void *arg) { char address[INET6_ADDRSTRLEN]; union sockaddr_all sa; uint8_t req[32]; uint8_t res[32]; struct ntp_stamp recv_stamp; struct ntp_stamp xmit_stamp; struct raop_session *rs; struct raop_service *svc; int len; int ret; svc = (struct raop_service *)arg; if (dispatch_source_get_data(svc->source) == 0) { DPRINTF(E_LOG, L_RAOP, "Timing service socket error\n"); dispatch_source_cancel(svc->source); return; } ret = raop_v2_timing_get_clock_ntp(&recv_stamp); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't get receive timestamp\n"); return; } len = sizeof(sa.ss); ret = recvfrom(svc->fd, req, sizeof(req), 0, &sa.sa, (socklen_t *)&len); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Error reading timing request: %s\n", strerror(errno)); return; } if (ret != 32) { DPRINTF(E_DBG, L_RAOP, "Got timing request with size %d\n", ret); return; } switch (sa.ss.ss_family) { case AF_INET: if (svc != &timing_4svc) return; for (rs = sessions; rs; rs = rs->next) { if ((rs->sa.ss.ss_family == AF_INET) && (sa.sin.sin_addr.s_addr == rs->sa.sin.sin_addr.s_addr)) break; } if (!rs) ret = (inet_ntop(AF_INET, &sa.sin.sin_addr.s_addr, address, sizeof(address)) != NULL); break; case AF_INET6: if (svc != &timing_6svc) return; for (rs = sessions; rs; rs = rs->next) { if ((rs->sa.ss.ss_family == AF_INET6) && IN6_ARE_ADDR_EQUAL(&sa.sin6.sin6_addr, &rs->sa.sin6.sin6_addr)) break; } if (!rs) ret = (inet_ntop(AF_INET6, &sa.sin6.sin6_addr.s6_addr, address, sizeof(address)) != NULL); break; default: DPRINTF(E_LOG, L_RAOP, "Time sync: Unknown address family %d\n", sa.ss.ss_family); return; } if (!rs) { if (!ret) DPRINTF(E_LOG, L_RAOP, "Time sync request from [error: %s]; not a RAOP client\n", strerror(errno)); else DPRINTF(E_LOG, L_RAOP, "Time sync request from %s; not a RAOP client\n", address); return; } if ((req[0] != 0x80) || (req[1] != 0xd2)) { DPRINTF(E_LOG, L_RAOP, "Packet header doesn't match timing request\n"); return; } memset(res, 0, sizeof(res)); /* Header */ res[0] = 0x80; res[1] = 0xd3; res[2] = req[2]; /* Copy client timestamp */ memcpy(res + 8, req + 24, 8); /* Receive timestamp */ recv_stamp.sec = htobe32(recv_stamp.sec); recv_stamp.frac = htobe32(recv_stamp.frac); memcpy(res + 16, &recv_stamp.sec, 4); memcpy(res + 20, &recv_stamp.frac, 4); /* Transmit timestamp */ ret = raop_v2_timing_get_clock_ntp(&xmit_stamp); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't get transmit timestamp, falling back to receive timestamp\n"); /* Still better than failing altogether * recv/xmit are close enough that it shouldn't matter much */ memcpy(res + 24, &recv_stamp.sec, 4); memcpy(res + 28, &recv_stamp.frac, 4); } else { xmit_stamp.sec = htobe32(xmit_stamp.sec); xmit_stamp.frac = htobe32(xmit_stamp.frac); memcpy(res + 24, &xmit_stamp.sec, 4); memcpy(res + 28, &xmit_stamp.frac, 4); } ret = sendto(svc->fd, res, sizeof(res), 0, &sa.sa, len); if (ret < 0) DPRINTF(E_LOG, L_RAOP, "Could not send timing reply: %s\n", strerror(errno)); } static int raop_v2_timing_start_one(struct raop_service *svc, int family) { union sockaddr_all sa; int on; int len; int ret; #ifdef __linux__ svc->fd = socket(family, SOCK_DGRAM | SOCK_CLOEXEC, 0); #else svc->fd = socket(family, SOCK_DGRAM, 0); #endif if (svc->fd < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't make timing socket: %s\n", strerror(errno)); return -1; } if (family == AF_INET6) { on = 1; ret = setsockopt(svc->fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not set IPV6_V6ONLY on timing socket: %s\n", strerror(errno)); goto out_fail; } } memset(&sa, 0, sizeof(union sockaddr_all)); sa.ss.ss_family = family; switch (family) { case AF_INET: sa.sin.sin_addr.s_addr = INADDR_ANY; sa.sin.sin_port = 0; len = sizeof(sa.sin); break; case AF_INET6: sa.sin6.sin6_addr = in6addr_any; sa.sin6.sin6_port = 0; len = sizeof(sa.sin6); break; } ret = bind(svc->fd, &sa.sa, len); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't bind timing socket: %s\n", strerror(errno)); goto out_fail; } len = sizeof(sa.ss); ret = getsockname(svc->fd, &sa.sa, (socklen_t *)&len); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't get timing socket name: %s\n", strerror(errno)); goto out_fail; } switch (family) { case AF_INET: svc->port = ntohs(sa.sin.sin_port); DPRINTF(E_DBG, L_RAOP, "Timing IPv4 port: %d\n", svc->port); break; case AF_INET6: svc->port = ntohs(sa.sin6.sin6_port); DPRINTF(E_DBG, L_RAOP, "Timing IPv6 port: %d\n", svc->port); break; } svc->source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, svc->fd, 0, player_sq); if (!svc->source) { DPRINTF(E_LOG, L_RAOP, "Could not create dispatch source for timing requests\n"); goto out_fail; } dispatch_set_context(svc->source, svc); dispatch_source_set_cancel_handler_f(svc->source, raop_v2_svc_cancel_cb); dispatch_source_set_event_handler_f(svc->source, raop_v2_timing_cb); dispatch_resume(svc->source); return 0; out_fail: close(svc->fd); svc->fd = -1; svc->port = 0; return -1; } static void raop_v2_timing_stop(void) { if (timing_4svc.source) { dispatch_source_cancel(timing_4svc.source); dispatch_release(timing_4svc.source); timing_4svc.source = NULL; } if (timing_6svc.source) { dispatch_source_cancel(timing_6svc.source); dispatch_release(timing_6svc.source); timing_6svc.source = NULL; } } static int raop_v2_timing_start(int v6enabled) { int ret; if (v6enabled) { ret = raop_v2_timing_start_one(&timing_6svc, AF_INET6); if (ret < 0) DPRINTF(E_WARN, L_RAOP, "Could not start timing service on IPv6\n"); } ret = raop_v2_timing_start_one(&timing_4svc, AF_INET); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not start timing service on IPv4\n"); raop_v2_timing_stop(); return -1; } return 0; } /* AirTunes v2 playback synchronization */ static void raop_v2_control_send_sync(uint64_t next_pkt, struct timespec *init) { uint8_t msg[20]; struct timespec ts; struct ntp_stamp cur_stamp; struct raop_session *rs; uint64_t cur_pos; uint32_t cur_pos32; uint32_t next_pkt32; int len; int ret; memset(msg, 0, sizeof(msg)); msg[0] = (sync_counter == 0) ? 0x90 : 0x80; msg[1] = 0xd4; msg[3] = 0x07; next_pkt32 = htobe32(RAOP_RTPTIME(next_pkt)); memcpy(msg + 16, &next_pkt32, 4); if (!init) { ret = player_get_current_pos(&cur_pos, &ts, 1); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not get current playback position and clock\n"); return; } timespec_to_ntp(&ts, &cur_stamp); } else { cur_pos = next_pkt - 88200; timespec_to_ntp(init, &cur_stamp); } cur_pos32 = htobe32(RAOP_RTPTIME(cur_pos)); cur_stamp.sec = htobe32(cur_stamp.sec); cur_stamp.frac = htobe32(cur_stamp.frac); memcpy(msg + 4, &cur_pos32, 4); memcpy(msg + 8, &cur_stamp.sec, 4); memcpy(msg + 12, &cur_stamp.frac, 4); for (rs = sessions; rs; rs = rs->next) { if (rs->state != RAOP_STREAMING) continue; switch (rs->sa.ss.ss_family) { case AF_INET: rs->sa.sin.sin_port = htons(rs->control_port); len = sizeof(rs->sa.sin); break; case AF_INET6: rs->sa.sin6.sin6_port = htons(rs->control_port); len = sizeof(rs->sa.sin6); break; default: DPRINTF(E_WARN, L_RAOP, "Unknown family %d\n", rs->sa.ss.ss_family); continue; } ret = sendto(rs->control_svc->fd, msg, sizeof(msg), 0, &rs->sa.sa, len); if (ret < 0) DPRINTF(E_LOG, L_RAOP, "Could not send playback sync to device %s: %s\n", rs->devname, strerror(errno)); } } /* Forward */ static void raop_v2_resend_range(struct raop_session *rs, uint16_t seqnum, uint16_t len); static void raop_v2_control_cb(void *arg) { char address[INET6_ADDRSTRLEN]; union sockaddr_all sa; uint8_t req[8]; struct raop_session *rs; struct raop_service *svc; uint16_t seq_start; uint16_t seq_len; int len; int ret; svc = (struct raop_service *)arg; if (dispatch_source_get_data(svc->source) == 0) { DPRINTF(E_LOG, L_RAOP, "Control service socket error\n"); dispatch_source_cancel(svc->source); return; } len = sizeof(sa.ss); ret = recvfrom(svc->fd, req, sizeof(req), 0, &sa.sa, (socklen_t *)&len); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Error reading control request: %s\n", strerror(errno)); return; } if (ret != 8) { DPRINTF(E_DBG, L_RAOP, "Got control request with size %d\n", ret); return; } switch (sa.ss.ss_family) { case AF_INET: if (svc != &control_4svc) return; for (rs = sessions; rs; rs = rs->next) { if ((rs->sa.ss.ss_family == AF_INET) && (sa.sin.sin_addr.s_addr == rs->sa.sin.sin_addr.s_addr)) break; } if (!rs) ret = (inet_ntop(AF_INET, &sa.sin.sin_addr.s_addr, address, sizeof(address)) != NULL); break; case AF_INET6: if (svc != &control_6svc) return; for (rs = sessions; rs; rs = rs->next) { if ((rs->sa.ss.ss_family == AF_INET6) && IN6_ARE_ADDR_EQUAL(&sa.sin6.sin6_addr, &rs->sa.sin6.sin6_addr)) break; } if (!rs) ret = (inet_ntop(AF_INET6, &sa.sin6.sin6_addr.s6_addr, address, sizeof(address)) != NULL); break; default: DPRINTF(E_LOG, L_RAOP, "Control svc: Unknown address family %d\n", sa.ss.ss_family); return; } if (!rs) { if (!ret) DPRINTF(E_LOG, L_RAOP, "Control request from [error: %s]; not a RAOP client\n", strerror(errno)); else DPRINTF(E_LOG, L_RAOP, "Control request from %s; not a RAOP client\n", address); return; } if ((req[0] != 0x80) || (req[1] != 0xd5)) { DPRINTF(E_LOG, L_RAOP, "Packet header doesn't match retransmit request\n"); return; } memcpy(&seq_start, req + 4, 2); memcpy(&seq_len, req + 6, 2); seq_start = be16toh(seq_start); seq_len = be16toh(seq_len); DPRINTF(E_DBG, L_RAOP, "Got retransmit request, seq_start %u len %u\n", seq_start, seq_len); raop_v2_resend_range(rs, seq_start, seq_len); } static int raop_v2_control_start_one(struct raop_service *svc, int family) { union sockaddr_all sa; int on; int len; int ret; #ifdef __linux__ svc->fd = socket(family, SOCK_DGRAM | SOCK_CLOEXEC, 0); #else svc->fd = socket(family, SOCK_DGRAM, 0); #endif if (svc->fd < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't make control socket: %s\n", strerror(errno)); return -1; } if (family == AF_INET6) { on = 1; ret = setsockopt(svc->fd, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not set IPV6_V6ONLY on control socket: %s\n", strerror(errno)); goto out_fail; } } memset(&sa, 0, sizeof(union sockaddr_all)); sa.ss.ss_family = family; switch (family) { case AF_INET: sa.sin.sin_addr.s_addr = INADDR_ANY; sa.sin.sin_port = 0; len = sizeof(sa.sin); break; case AF_INET6: sa.sin6.sin6_addr = in6addr_any; sa.sin6.sin6_port = 0; len = sizeof(sa.sin6); break; } ret = bind(svc->fd, &sa.sa, len); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't bind control socket: %s\n", strerror(errno)); goto out_fail; } len = sizeof(sa.ss); ret = getsockname(svc->fd, &sa.sa, (socklen_t *)&len); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Couldn't get control socket name: %s\n", strerror(errno)); goto out_fail; } switch (family) { case AF_INET: svc->port = ntohs(sa.sin.sin_port); DPRINTF(E_DBG, L_RAOP, "Control IPv4 port: %d\n", svc->port); break; case AF_INET6: svc->port = ntohs(sa.sin6.sin6_port); DPRINTF(E_DBG, L_RAOP, "Control IPv6 port: %d\n", svc->port); break; } svc->source = dispatch_source_create(DISPATCH_SOURCE_TYPE_READ, svc->fd, 0, player_sq); if (!svc->source) { DPRINTF(E_LOG, L_RAOP, "Could not create dispatch source for control requests\n"); goto out_fail; } dispatch_set_context(svc->source, svc); dispatch_source_set_cancel_handler_f(svc->source, raop_v2_svc_cancel_cb); dispatch_source_set_event_handler_f(svc->source, raop_v2_control_cb); dispatch_resume(svc->source); return 0; out_fail: close(svc->fd); svc->fd = -1; svc->port = 0; return -1; } static void raop_v2_control_stop(void) { if (control_4svc.source) { dispatch_source_cancel(control_4svc.source); dispatch_release(control_4svc.source); control_4svc.source = NULL; } if (control_6svc.source) { dispatch_source_cancel(control_6svc.source); dispatch_release(control_6svc.source); control_6svc.source = NULL; } } static int raop_v2_control_start(int v6enabled) { int ret; if (v6enabled) { ret = raop_v2_control_start_one(&control_6svc, AF_INET6); if (ret < 0) DPRINTF(E_WARN, L_RAOP, "Could not start control service on IPv6\n"); } ret = raop_v2_control_start_one(&control_4svc, AF_INET); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not start control service on IPv4\n"); raop_v2_control_stop(); return -1; } return 0; } /* AirTunes v2 streaming */ static struct raop_v2_packet * raop_v2_new_packet(void) { struct raop_v2_packet *pkt; if (pktbuf_size >= RETRANSMIT_BUFFER_SIZE) { pktbuf_size--; pkt = pktbuf_tail; pktbuf_tail = pktbuf_tail->prev; pktbuf_tail->next = NULL; } else { pkt = (struct raop_v2_packet *)malloc(sizeof(struct raop_v2_packet)); if (!pkt) { DPRINTF(E_LOG, L_RAOP, "Out of memory for RAOP packet\n"); return NULL; } } return pkt; } static struct raop_v2_packet * raop_v2_make_packet(uint8_t *rawbuf, uint64_t rtptime) { char ebuf[64]; struct raop_v2_packet *pkt; gpg_error_t gc_err; uint32_t rtptime32; uint16_t seq; pkt = raop_v2_new_packet(); if (!pkt) return NULL; memset(pkt, 0, sizeof(struct raop_v2_packet)); alac_encode(rawbuf, pkt->clear + AIRTUNES_V2_HDR_LEN, STOB(AIRTUNES_V2_PACKET_SAMPLES)); stream_seq++; pkt->seqnum = stream_seq; seq = htobe16(pkt->seqnum); rtptime32 = htobe32(RAOP_RTPTIME(rtptime)); pkt->clear[0] = 0x80; pkt->clear[1] = (sync_counter == 0) ? 0xe0 : 0x60; memcpy(pkt->clear + 2, &seq, 2); memcpy(pkt->clear + 4, &rtptime32, 4); /* RTP SSRC ID * Note: should htobe32() that value, but it's just a * random/unique ID so it's no big deal */ memcpy(pkt->clear + 8, &ssrc_id, 4); /* Copy AirTunes v2 header to encrypted packet */ memcpy(pkt->encrypted, pkt->clear, AIRTUNES_V2_HDR_LEN); /* Copy the tail of the audio packet that is left unencrypted */ memcpy(pkt->encrypted + AIRTUNES_V2_PKT_TAIL_OFF, pkt->clear + AIRTUNES_V2_PKT_TAIL_OFF, AIRTUNES_V2_PKT_TAIL_LEN); /* Reset cipher */ gc_err = gcry_cipher_reset(raop_aes_ctx); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not reset AES cipher: %s\n", ebuf); free(pkt); return NULL; } /* Set IV */ gc_err = gcry_cipher_setiv(raop_aes_ctx, raop_aes_iv, sizeof(raop_aes_iv)); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not set AES IV: %s\n", ebuf); free(pkt); return NULL; } /* Encrypt in blocks of 16 bytes */ gc_err = gcry_cipher_encrypt(raop_aes_ctx, pkt->encrypted + AIRTUNES_V2_HDR_LEN, ((AIRTUNES_V2_PKT_LEN - AIRTUNES_V2_HDR_LEN) / 16) * 16, pkt->clear + AIRTUNES_V2_HDR_LEN, ((AIRTUNES_V2_PKT_LEN - AIRTUNES_V2_HDR_LEN) / 16) * 16); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not encrypt payload: %s\n", ebuf); free(pkt); return NULL; } pkt->prev = NULL; pkt->next = pktbuf_head; if (pktbuf_head) pktbuf_head->prev = pkt; if (!pktbuf_tail) pktbuf_tail = pkt; pktbuf_head = pkt; pktbuf_size++; return pkt; } static int raop_v2_send_packet(struct raop_session *rs, struct raop_v2_packet *pkt) { uint8_t *data; int ret; data = (rs->encrypt) ? pkt->encrypted : pkt->clear; ret = send(rs->server_fd, data, AIRTUNES_V2_PKT_LEN, 0); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Send error for %s: %s\n", rs->devname, strerror(errno)); raop_session_failure(rs); return -1; } else if (ret != AIRTUNES_V2_PKT_LEN) { DPRINTF(E_WARN, L_RAOP, "Partial send (%d) for %s\n", ret, rs->devname); return -1; } return 0; } void raop_v2_write(uint8_t *buf, uint64_t rtptime) { struct raop_v2_packet *pkt; struct raop_session *rs; pkt = raop_v2_make_packet(buf, rtptime); if (!pkt) { raop_playback_stop(); return; } if (sync_counter == 126) { raop_v2_control_send_sync(rtptime, NULL); sync_counter = 1; } else sync_counter++; for (rs = sessions; rs; rs = rs->next) { if (rs->state != RAOP_STREAMING) continue; raop_v2_send_packet(rs, pkt); } return; } static void raop_v2_resend_range(struct raop_session *rs, uint16_t seqnum, uint16_t len) { struct raop_v2_packet *pktbuf; int ret; uint16_t distance; /* Check that seqnum is in the retransmit buffer */ if ((seqnum > pktbuf_head->seqnum) && (seqnum < pktbuf_tail->seqnum)) { DPRINTF(E_LOG, L_RAOP, "RAOP device %s asking for seqnum %u; not in buffer (h %u t %u)\n", rs->devname, seqnum, pktbuf_head->seqnum, pktbuf_tail->seqnum); return; } if (seqnum > pktbuf_head->seqnum) { distance = seqnum - pktbuf_tail->seqnum; if (distance > (RETRANSMIT_BUFFER_SIZE / 2)) pktbuf = pktbuf_head; else pktbuf = pktbuf_tail; } else { distance = pktbuf_head->seqnum - seqnum; if (distance > (RETRANSMIT_BUFFER_SIZE / 2)) pktbuf = pktbuf_tail; else pktbuf = pktbuf_head; } if (pktbuf == pktbuf_head) { while (seqnum != pktbuf->seqnum) pktbuf = pktbuf->next; } else { while (seqnum != pktbuf->seqnum) pktbuf = pktbuf->prev; } while (len && pktbuf) { ret = raop_v2_send_packet(rs, pktbuf); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Error retransmit packet, aborting retransmission\n"); return; } pktbuf = pktbuf->prev; len--; } if (len != 0) DPRINTF(E_LOG, L_RAOP, "WARNING: len non-zero at end of retransmission\n"); } static int raop_v2_stream_open(struct raop_session *rs) { int len; int ret; #ifdef __linux__ rs->server_fd = socket(rs->sa.ss.ss_family, SOCK_DGRAM | SOCK_CLOEXEC, 0); #else rs->server_fd = socket(rs->sa.ss.ss_family, SOCK_DGRAM, 0); #endif if (rs->server_fd < 0) { DPRINTF(E_LOG, L_RAOP, "Could not create socket for streaming: %s\n", strerror(errno)); return -1; } switch (rs->sa.ss.ss_family) { case AF_INET: rs->sa.sin.sin_port = htons(rs->server_port); len = sizeof(rs->sa.sin); break; case AF_INET6: rs->sa.sin6.sin6_port = htons(rs->server_port); len = sizeof(rs->sa.sin6); break; default: DPRINTF(E_WARN, L_RAOP, "Unknown family %d\n", rs->sa.ss.ss_family); goto out_fail; } ret = connect(rs->server_fd, &rs->sa.sa, len); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "connect() to [%s]:%u failed: %s\n", rs->address, rs->server_port, strerror(errno)); goto out_fail; } /* Include the device into the set of active devices if * playback is in progress. */ if (sync_counter != 0) rs->state = RAOP_STREAMING; else rs->state = RAOP_CONNECTED; return 0; out_fail: close(rs->server_fd); rs->server_fd = -1; return -1; } /* Session startup */ static void raop_startup_cancel(struct raop_session *rs) { /* Try being nice to our peer */ if (rs->session) raop_send_req_teardown(rs, raop_session_failure_cb); else raop_session_failure(rs); } static int raop_cb_startup_volume(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { raop_status_cb status_cb; struct raop_session *rs; const char *reason; int code; int ret; rs = (struct raop_session *)arg; rs->reqs_in_flight--; code = http_response_get_status(r, &reason); if (code != HTTP_OK) { DPRINTF(E_LOG, L_RAOP, "SET_PARAMETER request failed for startup volume: %d %s\n", code, reason); goto cleanup; } ret = raop_check_cseq(rs, req, r); if (ret < 0) goto cleanup; raop_metadata_startup_send(rs); ret = raop_v2_stream_open(rs); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not open streaming socket\n"); goto cleanup; } http_request_free(req); /* Session startup and setup is done, tell our user */ status_cb = rs->status_cb; rs->status_cb = NULL; status_cb(rs->dev, rs, rs->state); return 0; cleanup: http_request_free(req); raop_startup_cancel(rs); return 0; } static int raop_cb_startup_record(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { struct raop_session *rs; const char *param; const char *reason; int code; int ret; rs = (struct raop_session *)arg; rs->reqs_in_flight--; code = http_response_get_status(r, &reason); if (code != HTTP_OK) { DPRINTF(E_LOG, L_RAOP, "RECORD request failed in session startup: %d %s\n", code, reason); goto cleanup; } ret = raop_check_cseq(rs, req, r); if (ret < 0) goto cleanup; /* Audio latency */ param = http_response_get_header(r, "Audio-Latency"); if (!param) DPRINTF(E_INFO, L_RAOP, "RECORD reply from %s did not have an Audio-Latency header\n", rs->devname); else DPRINTF(E_DBG, L_RAOP, "RAOP audio latency is %s\n", param); http_request_free(req); rs->state = RAOP_RECORD; /* Set initial volume */ raop_set_volume_internal(rs, rs->volume, raop_cb_startup_volume); return 0; cleanup: http_request_free(req); raop_startup_cancel(rs); return 0; } static int raop_cb_startup_setup(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { struct raop_session *rs; const char *param; const char *reason; char *transport; char *token; char *ptr; int code; int tmp; int ret; rs = (struct raop_session *)arg; rs->reqs_in_flight--; code = http_response_get_status(r, &reason); if (code != HTTP_OK) { DPRINTF(E_LOG, L_RAOP, "SETUP request failed in session startup: %d %s\n", code, reason); goto cleanup; } ret = raop_check_cseq(rs, req, r); if (ret < 0) goto cleanup; /* Server-side session ID */ param = http_response_get_header(r, "Session"); if (!param) { DPRINTF(E_LOG, L_RAOP, "Missing Session header in SETUP reply\n"); goto cleanup; } rs->session = strdup(param); /* Check transport and get remote streaming port */ param = http_response_get_header(r, "Transport"); if (!param) { DPRINTF(E_LOG, L_RAOP, "Missing Transport header in SETUP reply\n"); goto cleanup; } /* Check transport is really UDP, AirTunes v2 streaming */ if (strncmp(param, "RTP/AVP/UDP;", strlen("RTP/AVP/UDP;")) != 0) { DPRINTF(E_LOG, L_RAOP, "ApEx replied with unsupported Transport: %s\n", param); goto cleanup; } transport = strdup(param); if (!transport) { DPRINTF(E_LOG, L_RAOP, "Out of memory for Transport header copy\n"); goto cleanup; } token = strchr(transport, ';'); token++; token = strtok_r(token, ";=", &ptr); while (token) { DPRINTF(E_DBG, L_RAOP, "token: %s\n", token); if (strcmp(token, "server_port") == 0) { token = strtok_r(NULL, ";=", &ptr); if (!token) break; ret = safe_atoi32(token, &tmp); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not read server_port\n"); break; } rs->server_port = tmp; } else if (strcmp(token, "control_port") == 0) { token = strtok_r(NULL, ";=", &ptr); if (!token) break; ret = safe_atoi32(token, &tmp); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not read control_port\n"); break; } rs->control_port = tmp; } else if (strcmp(token, "timing_port") == 0) { token = strtok_r(NULL, ";=", &ptr); if (!token) break; ret = safe_atoi32(token, &tmp); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not read timing_port\n"); break; } rs->timing_port = tmp; } token = strtok_r(NULL, ";=", &ptr); } free(transport); if ((rs->server_port == 0) || (rs->control_port == 0) || (rs->timing_port == 0)) { DPRINTF(E_LOG, L_RAOP, "Transport header lacked some port numbers in SETUP reply\n"); DPRINTF(E_LOG, L_RAOP, "Transport header was: %s\n", param); goto cleanup; } DPRINTF(E_DBG, L_RAOP, "Negotiated AirTunes v2 UDP streaming session %s; ports s=%u c=%u t=%u\n", rs->session, rs->server_port, rs->control_port, rs->timing_port); rs->state = RAOP_SETUP; /* Send RECORD */ ret = raop_send_req_record(rs, raop_cb_startup_record); if (ret < 0) goto cleanup; http_request_free(req); return 0; cleanup: http_request_free(req); raop_startup_cancel(rs); return 0; } static int raop_cb_startup_announce(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { struct raop_session *rs; const char *reason; int code; int ret; rs = (struct raop_session *)arg; rs->reqs_in_flight--; code = http_response_get_status(r, &reason); if (code != HTTP_OK) { DPRINTF(E_LOG, L_RAOP, "ANNOUNCE request failed in session startup: %d %s\n", code, reason); goto cleanup; } ret = raop_check_cseq(rs, req, r); if (ret < 0) goto cleanup; rs->state = RAOP_ANNOUNCE; /* Send SETUP */ ret = raop_send_req_setup(rs, raop_cb_startup_setup); if (ret < 0) goto cleanup; http_request_free(req); return 0; cleanup: http_request_free(req); raop_startup_cancel(rs); return 0; } static int raop_cb_startup_options(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { struct raop_session *rs; const char *reason; int code; int ret; rs = (struct raop_session *)arg; rs->reqs_in_flight--; code = http_response_get_status(r, &reason); if ((code != HTTP_OK) && (code != HTTP_UNAUTHORIZED)) { DPRINTF(E_LOG, L_RAOP, "OPTIONS request failed in session startup: %d %s\n", code, reason); goto cleanup; } ret = raop_check_cseq(rs, req, r); if (ret < 0) goto cleanup; if (code == HTTP_UNAUTHORIZED) { if (rs->req_has_auth) { DPRINTF(E_LOG, L_RAOP, "Bad password for device %s\n", rs->devname); rs->state = RAOP_PASSWORD; goto cleanup; } ret = raop_parse_auth(rs, r); if (ret < 0) goto cleanup; ret = raop_send_req_options(rs, raop_cb_startup_options); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not re-run OPTIONS request with authentication\n"); goto cleanup; } http_request_free(req); return 0; } rs->state = RAOP_OPTIONS; /* Send ANNOUNCE */ ret = raop_send_req_announce(rs, raop_cb_startup_announce); if (ret < 0) goto cleanup; http_request_free(req); return 0; cleanup: http_request_free(req); raop_startup_cancel(rs); return 0; } static int raop_cb_shutdown_teardown(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { raop_status_cb status_cb; struct raop_session *rs; const char *reason; int code; int ret; rs = (struct raop_session *)arg; rs->reqs_in_flight--; code = http_response_get_status(r, &reason); if (code != HTTP_OK) { DPRINTF(E_LOG, L_RAOP, "TEARDOWN request failed in session shutdown: %d %s\n", code, reason); goto error; } ret = raop_check_cseq(rs, req, r); if (ret < 0) goto error; http_request_free(req); rs->state = RAOP_STOPPED; /* Session shut down, tell our user */ status_cb = rs->status_cb; rs->status_cb = NULL; status_cb(rs->dev, rs, rs->state); raop_session_cleanup(rs); return 0; error: http_request_free(req); raop_session_failure(rs); return 0; } static int raop_cb_probe_options(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { raop_status_cb status_cb; struct raop_session *rs; const char *reason; int code; int ret; rs = (struct raop_session *)arg; rs->reqs_in_flight--; code = http_response_get_status(r, &reason); if ((code != HTTP_OK) && (code != HTTP_UNAUTHORIZED)) { DPRINTF(E_LOG, L_RAOP, "OPTIONS request failed in device probe: %d %s\n", code, reason); goto cleanup; } ret = raop_check_cseq(rs, req, r); if (ret < 0) goto cleanup; if (code == HTTP_UNAUTHORIZED) { if (rs->req_has_auth) { DPRINTF(E_LOG, L_RAOP, "Bad password for device %s\n", rs->devname); rs->state = RAOP_PASSWORD; goto cleanup; } ret = raop_parse_auth(rs, r); if (ret < 0) goto cleanup; ret = raop_send_req_options(rs, raop_cb_probe_options); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "Could not re-run OPTIONS request with authentication\n"); goto cleanup; } http_request_free(req); return 0; } http_request_free(req); rs->state = RAOP_OPTIONS; /* Device probed successfully, tell our user */ status_cb = rs->status_cb; rs->status_cb = NULL; status_cb(rs->dev, rs, rs->state); /* We're not going further with this session */ raop_session_cleanup(rs); return 0; cleanup: http_request_free(req); raop_session_failure(rs); return 0; } int raop_device_probe(struct raop_device *rd, raop_status_cb cb) { struct raop_session *rs; int ret; /* Send an OPTIONS request to test our ability to connect to the device, * including the need for and/or validity of the password */ rs = raop_session_make(rd, AF_INET6, cb); if (rs) { ret = raop_send_req_options(rs, raop_cb_probe_options); if (ret == 0) return 0; else { DPRINTF(E_WARN, L_RAOP, "Could not send OPTIONS request on IPv6 (probe)\n"); raop_session_cleanup(rs); } } rs = raop_session_make(rd, AF_INET, cb); if (!rs) return -1; ret = raop_send_req_options(rs, raop_cb_probe_options); if (ret < 0) { DPRINTF(E_WARN, L_RAOP, "Could not send OPTIONS request on IPv4 (probe)\n"); raop_session_cleanup(rs); return -1; } return 0; } int raop_device_start(struct raop_device *rd, raop_status_cb cb, uint64_t rtptime) { struct raop_session *rs; int ret; /* Send an OPTIONS request to establish the connection * After that, we can determine our local address and build our session URL * for all subsequent requests. */ rs = raop_session_make(rd, AF_INET6, cb); if (rs) { rs->start_rtptime = rtptime; ret = raop_send_req_options(rs, raop_cb_startup_options); if (ret == 0) return 0; else { DPRINTF(E_WARN, L_RAOP, "Could not send OPTIONS request on IPv6 (start)\n"); raop_session_cleanup(rs); } } rs = raop_session_make(rd, AF_INET, cb); if (!rs) return -1; rs->start_rtptime = rtptime; ret = raop_send_req_options(rs, raop_cb_startup_options); if (ret < 0) { DPRINTF(E_WARN, L_RAOP, "Could not send OPTIONS request on IPv4 (start)\n"); raop_session_cleanup(rs); return -1; } return 0; } void raop_device_stop(struct raop_session *rs) { if (!(rs->state & RAOP_F_CONNECTED)) raop_session_cleanup(rs); else raop_send_req_teardown(rs, raop_cb_shutdown_teardown); } void raop_playback_start(uint64_t next_pkt, struct timespec *ts) { struct raop_session *rs; if (flush_timer_src) { dispatch_source_cancel(flush_timer_src); dispatch_release(flush_timer_src); flush_timer_src = NULL; } sync_counter = 0; for (rs = sessions; rs; rs = rs->next) { if (rs->state == RAOP_CONNECTED) rs->state = RAOP_STREAMING; } /* Send initial playback sync */ raop_v2_control_send_sync(next_pkt, ts); } void raop_playback_stop(void) { struct raop_session *rs; int ret; for (rs = sessions; rs; rs = rs->next) { ret = raop_send_req_teardown(rs, raop_cb_shutdown_teardown); if (ret < 0) DPRINTF(E_LOG, L_RAOP, "shutdown: TEARDOWN request failed!\n"); } } void raop_set_status_cb(struct raop_session *rs, raop_status_cb cb) { rs->status_cb = cb; } int raop_init(int *v6enabled) { char ebuf[64]; char *ptr; char *libname; gpg_error_t gc_err; int ret; timing_4svc.fd = -1; timing_4svc.port = 0; timing_4svc.source = NULL; timing_6svc.fd = -1; timing_6svc.port = 0; timing_6svc.source = NULL; control_4svc.fd = -1; control_4svc.port = 0; control_4svc.source = NULL; control_6svc.fd = -1; control_6svc.port = 0; control_6svc.source = NULL; sessions = NULL; flush_timer_src = NULL; pktbuf_size = 0; pktbuf_head = NULL; pktbuf_tail = NULL; metadata_head = NULL; metadata_tail = NULL; /* Generate RTP SSRC ID from library name */ libname = cfg_getstr(cfg_getsec(cfg, "library"), "name"); ssrc_id = djb_hash(libname, strlen(libname)); /* Random RTP sequence start */ gcry_randomize(&stream_seq, sizeof(stream_seq), GCRY_STRONG_RANDOM); /* Generate AES key and IV */ gcry_randomize(raop_aes_key, sizeof(raop_aes_key), GCRY_STRONG_RANDOM); gcry_randomize(raop_aes_iv, sizeof(raop_aes_iv), GCRY_STRONG_RANDOM); /* Setup AES */ gc_err = gcry_cipher_open(&raop_aes_ctx, GCRY_CIPHER_AES, GCRY_CIPHER_MODE_CBC, 0); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not open AES cipher: %s\n", ebuf); return -1; } /* Set key */ gc_err = gcry_cipher_setkey(raop_aes_ctx, raop_aes_key, sizeof(raop_aes_key)); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_RAOP, "Could not set AES key: %s\n", ebuf); goto out_close_cipher; } /* Prepare Base64-encoded key & IV for SDP */ raop_aes_key_b64 = raop_crypt_encrypt_aes_key_base64(); if (!raop_aes_key_b64) { DPRINTF(E_LOG, L_RAOP, "Couldn't encrypt and encode AES session key\n"); goto out_close_cipher; } raop_aes_iv_b64 = b64_encode(raop_aes_iv, sizeof(raop_aes_iv)); if (!raop_aes_iv_b64) { DPRINTF(E_LOG, L_RAOP, "Couldn't encode AES IV\n"); goto out_free_b64_key; } /* Remove base64 padding */ ptr = strchr(raop_aes_key_b64, '='); if (ptr) *ptr = '\0'; ptr = strchr(raop_aes_iv_b64, '='); if (ptr) *ptr = '\0'; ret = raop_v2_timing_start(*v6enabled); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "AirTunes v2 time synchronization failed to start\n"); goto out_free_b64_iv; } ret = raop_v2_control_start(*v6enabled); if (ret < 0) { DPRINTF(E_LOG, L_RAOP, "AirTunes v2 playback synchronization failed to start\n"); goto out_stop_timing; } if (*v6enabled) *v6enabled = !((timing_6svc.fd < 0) || (control_6svc.fd < 0)); return 0; out_stop_timing: raop_v2_timing_stop(); out_free_b64_iv: free(raop_aes_iv_b64); out_free_b64_key: free(raop_aes_key_b64); out_close_cipher: gcry_cipher_close(raop_aes_ctx); return -1; } void raop_deinit(void) { if (sessions) DPRINTF(E_LOG, L_RAOP, "WARNING: remaining active sessions at shutdown\n"); raop_v2_timing_stop(); raop_v2_control_stop(); gcry_cipher_close(raop_aes_ctx); free(raop_aes_key_b64); free(raop_aes_iv_b64); } forked-daapd-0.19gcd/src/raop.h0000664000175000017500000000441411633141135015704 0ustar julienjulien #ifndef __RAOP_H__ #define __RAOP_H__ enum raop_devtype { RAOP_DEV_APEX_80211G, RAOP_DEV_APEX_80211N, RAOP_DEV_APPLETV, }; struct raop_session; struct raop_device { uint64_t id; char *name; char *v4_address; char *v6_address; short v4_port; short v6_port; enum raop_devtype devtype; unsigned selected:1; unsigned advertised:1; unsigned has_password:1; const char *password; int volume; int relvol; struct raop_session *session; struct raop_device *next; }; /* RAOP session state */ /* Session is starting up */ #define RAOP_F_STARTUP (1 << 15) /* Streaming is up (connection established) */ #define RAOP_F_CONNECTED (1 << 16) enum raop_session_state { RAOP_STOPPED = 0, /* Session startup */ RAOP_OPTIONS = RAOP_F_STARTUP | 0x01, RAOP_ANNOUNCE = RAOP_F_STARTUP | 0x02, RAOP_SETUP = RAOP_F_STARTUP | 0x03, RAOP_RECORD = RAOP_F_STARTUP | 0x04, /* Session established * - streaming ready (RECORD sent and acked, connection established) * - commands (SET_PARAMETER) are possible */ RAOP_CONNECTED = RAOP_F_CONNECTED, /* Audio data is being sent */ RAOP_STREAMING = RAOP_F_CONNECTED | 0x01, /* Session is failed, couldn't startup or error occurred */ RAOP_FAILED = -1, /* Password issue: unknown password or bad password */ RAOP_PASSWORD = -2, }; typedef void (*raop_status_cb)(struct raop_device *dev, struct raop_session *rs, enum raop_session_state status); void raop_metadata_purge(void); void raop_metadata_prune(uint64_t rtptime); int raop_device_probe(struct raop_device *rd, raop_status_cb cb); int raop_device_start(struct raop_device *rd, raop_status_cb cb, uint64_t rtptime); void raop_device_stop(struct raop_session *rs); void raop_playback_start(uint64_t next_pkt, struct timespec *ts); void raop_playback_stop(void); void raop_metadata_send(int id, uint64_t rtptime, uint64_t offset, int startup); int raop_set_volume_one(struct raop_session *rs, int volume, raop_status_cb cb); int raop_flush(raop_status_cb cb, uint64_t rtptime); void raop_set_status_cb(struct raop_session *rs, raop_status_cb cb); void raop_v2_write(uint8_t *buf, uint64_t rtptime); int raop_init(int *v6enabled); void raop_deinit(void); #endif /* !__RAOP_H__ */ forked-daapd-0.19gcd/src/remote_pairing.c0000664000175000017500000004510111633141135017740 0ustar julienjulien/* * Copyright (C) 2010 Julien BLACHE * * iTunes - Remote pairing hash function published by Michael Paul Bailey * * Simplified version using standard MD5 published by Jeff Sharkey * * * Pairing process based on the work by * - Michael Croes * * - Jeffrey Sharkey * * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #include #include #include #include "evbuffer/evbuffer.h" #include "logger.h" #include "conffile.h" #include "mdns.h" #include "http.h" #include "misc.h" #include "db.h" #include "remote_pairing.h" struct remote_info { struct pairing_info pi; char *paircode; char *pin; unsigned short v4_port; unsigned short v6_port; char *v4_address; char *v6_address; struct remote_info *next; }; static dispatch_queue_t pairing_sq; static struct remote_info *remote_list; /* iTunes - Remote pairing hash */ static char * itunes_pairing_hash(char *paircode, char *pin) { char hash[33]; char ebuf[64]; uint8_t *hash_bytes; size_t hashlen; gcry_md_hd_t hd; gpg_error_t gc_err; int i; if (strlen(paircode) != 16) { DPRINTF(E_LOG, L_REMOTE, "Paircode length != 16, cannot compute pairing hash\n"); return NULL; } if (strlen(pin) != 4) { DPRINTF(E_LOG, L_REMOTE, "Pin length != 4, cannot compute pairing hash\n"); return NULL; } gc_err = gcry_md_open(&hd, GCRY_MD_MD5, 0); if (gc_err != GPG_ERR_NO_ERROR) { gpg_strerror_r(gc_err, ebuf, sizeof(ebuf)); DPRINTF(E_LOG, L_REMOTE, "Could not open MD5: %s\n", ebuf); return NULL; } gcry_md_write(hd, paircode, 16); /* Add pin code characters on 16 bits - remember Mac OS X is * all UTF-16 (wchar_t). */ for (i = 0; i < 4; i++) { gcry_md_write(hd, pin + i, 1); gcry_md_write(hd, "\0", 1); } hash_bytes = gcry_md_read(hd, GCRY_MD_MD5); if (!hash_bytes) { DPRINTF(E_LOG, L_REMOTE, "Could not read MD5 hash\n"); return NULL; } hashlen = gcry_md_get_algo_dlen(GCRY_MD_MD5); for (i = 0; i < hashlen; i++) sprintf(hash + (2 * i), "%02X", hash_bytes[i]); gcry_md_close(hd); return strdup(hash); } /* Operations on the remote list must happen * with the list lock held by the caller */ static struct remote_info * add_remote(void) { struct remote_info *ri; ri = (struct remote_info *)malloc(sizeof(struct remote_info)); if (!ri) { DPRINTF(E_WARN, L_REMOTE, "Out of memory for struct remote_info\n"); return NULL; } memset(ri, 0, sizeof(struct remote_info)); ri->next = remote_list; remote_list = ri; return ri; } static void unlink_remote(struct remote_info *ri) { struct remote_info *p; if (ri == remote_list) remote_list = ri->next; else { for (p = remote_list; p && (p->next != ri); p = p->next) ; /* EMPTY */ if (!p) { DPRINTF(E_LOG, L_REMOTE, "WARNING: struct remote_info not found in list; BUG!\n"); return; } p->next = ri->next; } } static void free_remote(struct remote_info *ri) { if (ri->paircode) free(ri->paircode); if (ri->pin) free(ri->pin); if (ri->v4_address) free(ri->v4_address); if (ri->v6_address) free(ri->v6_address); free_pi(&ri->pi, 1); free(ri); } static void remove_remote(struct remote_info *ri) { unlink_remote(ri); free_remote(ri); } static void remove_remote_address_byid(const char *id, int family) { struct remote_info *ri; for (ri = remote_list; ri; ri = ri->next) { if (!ri->pi.remote_id) continue; if (strcmp(ri->pi.remote_id, id) == 0) break; } if (!ri) { DPRINTF(E_WARN, L_REMOTE, "Remote %s not found in list\n", id); return; } switch (family) { case AF_INET: if (ri->v4_address) { free(ri->v4_address); ri->v4_address = NULL; } break; case AF_INET6: if (ri->v6_address) { free(ri->v6_address); ri->v6_address = NULL; } break; } if (!ri->v4_address && !ri->v6_address) remove_remote(ri); } static int add_remote_mdns_data(const char *id, int family, const char *address, int port, char *name, char *paircode) { struct remote_info *ri; char *check_addr; int ret; for (ri = remote_list; ri; ri = ri->next) { if (!ri->pi.remote_id) continue; if (strcmp(ri->pi.remote_id, id) == 0) break; } if (!ri) { DPRINTF(E_DBG, L_REMOTE, "Remote id %s not known, adding\n", id); ri = add_remote(); if (!ri) return -1; ret = 0; } else { DPRINTF(E_DBG, L_REMOTE, "Remote id %s found\n", id); free_pi(&ri->pi, 1); switch (family) { case AF_INET: if (ri->v4_address) free(ri->v4_address); break; case AF_INET6: if (ri->v6_address) free(ri->v6_address); break; } if (ri->paircode) free(ri->paircode); ret = 1; } ri->pi.remote_id = strdup(id); switch (family) { case AF_INET: ri->v4_address = strdup(address); ri->v4_port = port; check_addr = ri->v4_address; break; case AF_INET6: ri->v6_address = strdup(address); ri->v6_port = port; check_addr = ri->v6_address; break; default: DPRINTF(E_LOG, L_REMOTE, "Unknown address family %d\n", family); check_addr = NULL; break; } if (!ri->pi.remote_id || !check_addr) { DPRINTF(E_LOG, L_REMOTE, "Out of memory for remote pairing data\n"); remove_remote(ri); return -1; } ri->pi.name = name; ri->paircode = paircode; return ret; } static int add_remote_pin_data(char *devname, char *pin) { struct remote_info *ri; for (ri = remote_list; ri; ri = ri->next) { if (strcmp(ri->pi.name, devname) == 0) break; } if (!ri) { DPRINTF(E_LOG, L_REMOTE, "Remote '%s' not known from mDNS, ignoring\n", devname); free(pin); return -1; } DPRINTF(E_DBG, L_REMOTE, "Remote '%s' found\n", devname); if (ri->pin) free(ri->pin); ri->pin = pin; return 0; } /* Queue: pairing */ static int pairing_request_cb(struct http_connection *c, struct http_request *req, struct http_response *r, void *arg) { struct remote_info *ri; struct evbuffer *body; char guid[17]; const char *reason; uint8_t *response; size_t bodylen; int code; int len; int i; int ret; ri = (struct remote_info *)arg; code = http_response_get_status(r, &reason); if (code != HTTP_OK) { DPRINTF(E_LOG, L_REMOTE, "Pairing failed with Remote %s/%s, HTTP response code %d (%s)\n", ri->pi.remote_id, ri->pi.name, code, reason); goto cleanup; } body = http_response_get_body(r); if (!body || (EVBUFFER_LENGTH(body) < 8)) { DPRINTF(E_LOG, L_REMOTE, "Remote %s/%s: pairing response too short\n", ri->pi.remote_id, ri->pi.name); goto cleanup; } bodylen = EVBUFFER_LENGTH(body); response = EVBUFFER_DATA(body); if ((response[0] != 'c') || (response[1] != 'm') || (response[2] != 'p') || (response[3] != 'a')) { DPRINTF(E_LOG, L_REMOTE, "Remote %s/%s: unknown pairing response, expected cmpa\n", ri->pi.remote_id, ri->pi.name); goto cleanup; } len = (response[4] << 24) | (response[5] << 16) | (response[6] << 8) | (response[7]); if (bodylen < 8 + len) { DPRINTF(E_LOG, L_REMOTE, "Remote %s/%s: pairing response truncated (got %d expected %d)\n", ri->pi.remote_id, ri->pi.name, (int)bodylen, len + 8); goto cleanup; } response += 8; for (; len > 0; len--, response++) { if ((response[0] != 'c') || (response[1] != 'm') || (response[2] != 'p') || (response[3] != 'g')) continue; else { len -= 8; response += 8; break; } } if (len < 8) { DPRINTF(E_LOG, L_REMOTE, "Remote %s/%s: cmpg truncated in pairing response\n", ri->pi.remote_id, ri->pi.name); goto cleanup; } for (i = 0; i < 8; i++) sprintf(guid + (2 * i), "%02X", response[i]); ri->pi.guid = strdup(guid); DPRINTF(E_INFO, L_REMOTE, "Pairing succeeded with Remote '%s' (id %s), GUID: %s\n", ri->pi.name, ri->pi.remote_id, guid); ret = db_pool_get(); if (ret < 0) { DPRINTF(E_LOG, L_REMOTE, "Could not acquire database connection; cannot register pairing with %s\n", ri->pi.name); goto cleanup; } ret = db_pairing_add(&ri->pi); db_pool_release(); if (ret < 0) { DPRINTF(E_LOG, L_REMOTE, "Failed to register pairing!\n"); goto cleanup; } cleanup: http_request_free(req); http_client_free(c); return 0; } static void pairing_free_cb(void *arg) { struct remote_info *ri; ri = (struct remote_info *)arg; free_remote(ri); } static void pairing_fail_cb(struct http_connection *c, void *arg) { struct remote_info *ri; ri = (struct remote_info *)arg; DPRINTF(E_LOG, L_REMOTE, "HTTP client failure while pairing with %s\n", ri->pi.name); /* free_cb takes care of ri */ http_client_free(c); } /* Queue: pairing */ static int send_pairing_request(struct remote_info *ri, char *req_uri, int family) { struct http_connection *c; struct http_request *req; char *address; unsigned short port; int ret; switch (family) { case AF_INET: if (!ri->v4_address) return -1; address = ri->v4_address; port = ri->v4_port; break; case AF_INET6: if (!ri->v6_address) return -1; address = ri->v6_address; port = ri->v6_port; break; default: return -1; } c = http_client_new(L_REMOTE, address, port, pairing_fail_cb, pairing_free_cb, ri); if (!c) { DPRINTF(E_LOG, L_REMOTE, "Could not create HTTP client for pairing with %s\n", ri->pi.name); return -1; } req = http_client_request_new(HTTP_GET, P_VER_1_1, req_uri, pairing_request_cb); if (!req) { DPRINTF(E_WARN, L_REMOTE, "Could not create HTTP request for pairing\n"); goto request_fail; } ret = http_request_add_header(req, "Connection", "close"); if (ret < 0) DPRINTF(E_WARN, L_REMOTE, "Could not add Connection: close header\n"); ret = http_client_request_run(c, req); if (ret < 0) { DPRINTF(E_WARN, L_REMOTE, "Could not run pairing request\n"); goto run_fail; } return 0; run_fail: http_request_free(req); request_fail: http_client_free(c); return -1; } static void do_pairing(struct remote_info *ri) { char req_uri[128]; char *pairing_hash; int ret; pairing_hash = itunes_pairing_hash(ri->paircode, ri->pin); if (!pairing_hash) { DPRINTF(E_LOG, L_REMOTE, "Could not compute pairing hash!\n"); goto hash_fail; } DPRINTF(E_DBG, L_REMOTE, "Pairing hash for %s/%s: %s\n", ri->pi.remote_id, ri->pi.name, pairing_hash); /* Prepare request URI */ /* The servicename variable is the mDNS service group name; currently it's * a hash of the library name, but in iTunes the service name and the library * ID (DbId) are different (see comment in main.c). * Remote uses the service name to perform mDNS lookups. */ ret = snprintf(req_uri, sizeof(req_uri), "/pair?pairingcode=%s&servicename=%016" PRIX64, pairing_hash, libhash); free(pairing_hash); if ((ret < 0) || (ret >= sizeof(req_uri))) { DPRINTF(E_WARN, L_REMOTE, "Request URI for pairing exceeds buffer size\n"); goto req_uri_fail; } /* Fire up the request */ if (ri->v6_address) { ret = send_pairing_request(ri, req_uri, AF_INET6); if (ret == 0) return; DPRINTF(E_WARN, L_REMOTE, "Could not send pairing request on IPv6\n"); } ret = send_pairing_request(ri, req_uri, AF_INET); if (ret < 0) { DPRINTF(E_WARN, L_REMOTE, "Could not send pairing request on IPv4\n"); goto pairing_fail; } return; pairing_fail: req_uri_fail: hash_fail: free_remote(ri); } /* Queue: pairing */ static void try_pairing(void) { struct remote_info *ri; for (ri = remote_list; ri; ri = ri->next) { /* We've got both the mDNS data and the pin */ if (ri->paircode && ri->pin) { unlink_remote(ri); do_pairing(ri); } } } /* Queue: mdns_sq */ static void touch_remote_cb(const char *name, const char *type, const char *domain, const char *hostname, int family, const char *address, int port, struct keyval *txt) { const char *p; char *bname; char *baddress; char *devname; char *paircode; bname = strdup(name); if (!bname) { DPRINTF(E_LOG, L_REMOTE, "Out of memory for name copy\n"); return; } if (port < 0) { /* If Remote stops advertising itself, the pairing either succeeded or * failed; any subsequent attempt will need a new pairing pin, so * we can just forget everything we know about the remote. */ dispatch_async(pairing_sq, ^{ remove_remote_address_byid(bname, family); free(bname); }); } else { /* Get device name (DvNm field in TXT record) */ p = keyval_get(txt, "DvNm"); if (!p) { DPRINTF(E_LOG, L_REMOTE, "Remote %s: no DvNm in TXT record!\n", name); goto out_free_bname; } if (*p == '\0') { DPRINTF(E_LOG, L_REMOTE, "Remote %s: DvNm has no value\n", name); goto out_free_bname; } devname = strdup(p); if (!devname) { DPRINTF(E_LOG, L_REMOTE, "Out of memory for device name\n"); goto out_free_bname; } /* Get pairing code (Pair field in TXT record) */ p = keyval_get(txt, "Pair"); if (!p) { DPRINTF(E_LOG, L_REMOTE, "Remote %s: no Pair in TXT record!\n", name); goto out_free_devname; } if (*p == '\0') { DPRINTF(E_LOG, L_REMOTE, "Remote %s: Pair has no value\n", name); goto out_free_devname; } paircode = strdup(p); if (!paircode) { DPRINTF(E_LOG, L_REMOTE, "Out of memory for paircode\n"); goto out_free_devname; } baddress = strdup(address); if (!baddress) { DPRINTF(E_LOG, L_REMOTE, "Out of memory for address copy\n"); free(paircode); goto out_free_devname; } /* Add the data to the list, adding the remote to the list if needed */ dispatch_async(pairing_sq, ^{ int bret; DPRINTF(E_DBG, L_REMOTE, "Discovered remote %s (id %s) at [%s]:%d, paircode %s\n", devname, bname, baddress, port, paircode); bret = add_remote_mdns_data(bname, family, baddress, port, devname, paircode); if (bret == 1) try_pairing(); else if (bret < 0) { DPRINTF(E_WARN, L_REMOTE, "Could not add Remote mDNS data, id %s\n", bname); free(devname); free(paircode); } free(bname); free(baddress); }); } return; out_free_devname: free(devname); out_free_bname: free(bname); } /* Queue: global (filescanner.c) */ void remote_pairing_read_pin(char *path) { char buf[256]; FILE *fp; char *devname; char *pin; int len; fp = fopen(path, "rb"); if (!fp) { DPRINTF(E_LOG, L_REMOTE, "Could not open Remote pairing file %s: %s\n", path, strerror(errno)); return; } devname = fgets(buf, sizeof(buf), fp); if (!devname) { DPRINTF(E_LOG, L_REMOTE, "Empty Remote pairing file %s\n", path); fclose(fp); return; } len = strlen(devname); if (buf[len - 1] != '\n') { DPRINTF(E_LOG, L_REMOTE, "Invalid Remote pairing file %s: device name too long or missing pin\n", path); fclose(fp); return; } while (len) { if ((buf[len - 1] == '\r') || (buf[len - 1] == '\n')) { buf[len - 1] = '\0'; len--; } else break; } if (!len) { DPRINTF(E_LOG, L_REMOTE, "Invalid Remote pairing file %s: empty line where device name expected\n", path); fclose(fp); return; } devname = strdup(buf); if (!devname) { DPRINTF(E_LOG, L_REMOTE, "Out of memory for device name while reading %s\n", path); fclose(fp); return; } pin = fgets(buf, sizeof(buf), fp); fclose(fp); if (!pin) { DPRINTF(E_LOG, L_REMOTE, "Invalid Remote pairing file %s: no pin\n", path); free(devname); return; } len = strlen(pin); while (len) { if ((buf[len - 1] == '\r') || (buf[len - 1] == '\n')) { buf[len - 1] = '\0'; len--; } else break; } if (len != 4) { DPRINTF(E_LOG, L_REMOTE, "Invalid pin in Remote pairing file %s: pin length should be 4, got %d\n", path, len); free(devname); return; } pin = strdup(buf); if (!pin) { DPRINTF(E_LOG, L_REMOTE, "Out of memory for device pin while reading %s\n", path); free(devname); return; } dispatch_async(pairing_sq, ^{ int bret; DPRINTF(E_DBG, L_REMOTE, "Adding Remote pin data: name '%s', pin '%s'\n", devname, pin); bret = add_remote_pin_data(devname, pin); free(devname); /* pin retained or freed in add_remote_pin_data() */ if (bret < 0) return; try_pairing(); }); } /* Thread: main */ int remote_pairing_init(void) { int ret; remote_list = NULL; pairing_sq = dispatch_queue_create("org.forked-daapd.pairing", NULL); if (!pairing_sq) { DPRINTF(E_FATAL, L_REMOTE, "Could not create dispatch queue for pairing\n"); return -1; } ret = mdns_browse("_touch-remote._tcp", MDNS_WANT_V4, touch_remote_cb); if (ret < 0) { DPRINTF(E_FATAL, L_REMOTE, "Could not browse for Remote services\n"); goto mdns_browse_fail; } return 0; mdns_browse_fail: dispatch_release(pairing_sq); return -1; } static void remote_pairing_deinit_task(void *arg) { struct remote_info *ri; for (ri = remote_list; remote_list; ri = remote_list) { remote_list = ri->next; free_remote(ri); } } /* Thread: main */ void remote_pairing_deinit(void) { dispatch_sync_f(pairing_sq, NULL, remote_pairing_deinit_task); dispatch_release(pairing_sq); } forked-daapd-0.19gcd/src/remote_pairing.h0000664000175000017500000000031511633141135017743 0ustar julienjulien #ifndef __REMOTE_PAIRING_H__ #define __REMOTE_PAIRING_H__ void remote_pairing_read_pin(char *path); int remote_pairing_init(void); void remote_pairing_deinit(void); #endif /* !__REMOTE_PAIRING_H__ */ forked-daapd-0.19gcd/src/rng.c0000664000175000017500000000604511633141135015526 0ustar julienjulien/* * Copyright (C) 2010 Julien BLACHE * * 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 #include #include #include #include #include #include #include #include "rng.h" /* Park & Miller Minimal Standard PRNG * w/ Bays-Durham shuffle * From Numerical Recipes in C, 2nd ed. */ static int32_t rng_rand_internal(int32_t *seed) { int32_t hi; int32_t lo; int32_t res; hi = *seed / 127773; lo = *seed % 127773; res = 16807 * lo - 2836 * hi; if (res < 0) res += 0x7fffffffL; /* 2147483647 */ *seed = res; return res; } void rng_init(struct rng_ctx *ctx) { int32_t val; int i; gcry_randomize(&ctx->seed, sizeof(ctx->seed), GCRY_STRONG_RANDOM); /* Load the shuffle array - first 8 iterations discarded */ for (i = sizeof(ctx->iv) / sizeof(ctx->iv[0]) + 7; i >= 0; i--) { val = rng_rand_internal(&ctx->seed); if (i < sizeof(ctx->iv) / sizeof(ctx->iv[0])) ctx->iv[i] = val; } ctx->iy = ctx->iv[0]; } int32_t rng_rand(struct rng_ctx *ctx) { int i; /* Select return value */ i = ctx->iy / (1 + (0x7fffffffL - 1) / (sizeof(ctx->iv) / sizeof(ctx->iv[0]))); ctx->iy = ctx->iv[i]; /* Refill */ ctx->iv[i] = rng_rand_internal(&ctx->seed); return ctx->iy; } /* Integer in [min, max[ */ /* Taken from GLib 2.0 v2.25.3, g_rand_int_range(), GPLv2+ */ int32_t rng_rand_range(struct rng_ctx *ctx, int32_t min, int32_t max) { int32_t res; int32_t dist; uint32_t maxvalue; uint32_t leftover; dist = max - min; if (dist <= 0) return min; /* maxvalue is set to the predecessor of the greatest * multiple of dist less or equal 2^32. */ if (dist <= 0x80000000u) /* 2^31 */ { /* maxvalue = 2^32 - 1 - (2^32 % dist) */ leftover = (0x80000000u % dist) * 2; if (leftover >= dist) leftover -= dist; maxvalue = 0xffffffffu - leftover; } else maxvalue = dist - 1; do res = rng_rand(ctx); while (res > maxvalue); res %= dist; return min + res; } /* Fisher-Yates shuffling algorithm * Durstenfeld in-place shuffling variant */ void shuffle_ptr(struct rng_ctx *ctx, void **values, int len) { int i; int32_t j; void *tmp; for (i = len - 1; i > 0; i--) { j = rng_rand_range(ctx, 0, i + 1); tmp = values[i]; values[i] = values[j]; values[j] = tmp; } } forked-daapd-0.19gcd/src/rng.h0000664000175000017500000000055611633141135015534 0ustar julienjulien #ifndef __RNG_H__ #define __RNG_H__ struct rng_ctx { int32_t iy; int32_t iv[32]; /* shuffle array */ int32_t seed; }; void rng_init(struct rng_ctx *ctx); int32_t rng_rand(struct rng_ctx *ctx); int32_t rng_rand_range(struct rng_ctx *ctx, int32_t min, int32_t max); void shuffle_ptr(struct rng_ctx *ctx, void **values, int len); #endif /* !__RNG_H__ */ forked-daapd-0.19gcd/src/rsp_query.c0000664000175000017500000000755311633141135016776 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include "logger.h" #include "misc.h" #include "rsp_query.h" #include "RSPLexer.h" #include "RSPParser.h" #include "RSP2SQL.h" char * rsp_query_parse_sql(const char *rsp_query) { /* Input RSP query, fed to the lexer */ pANTLR3_INPUT_STREAM query; /* Lexer and the resulting token stream, fed to the parser */ pRSPLexer lxr; pANTLR3_COMMON_TOKEN_STREAM tkstream; /* Parser and the resulting AST, fed to the tree parser */ pRSPParser psr; RSPParser_query_return qtree; pANTLR3_COMMON_TREE_NODE_STREAM nodes; /* Tree parser and the resulting SQL query string */ pRSP2SQL sqlconv; pANTLR3_STRING sql; char *ret = NULL; DPRINTF(E_DBG, L_RSP, "Trying RSP query -%s-\n", rsp_query); #if ANTLR3C_NEW_INPUT query = antlr3StringStreamNew ((pANTLR3_UINT8)rsp_query, ANTLR3_ENC_8BIT, (ANTLR3_UINT64)strlen(rsp_query), (pANTLR3_UINT8)"RSP query"); #else query = antlr3NewAsciiStringInPlaceStream ((pANTLR3_UINT8)rsp_query, (ANTLR3_UINT64)strlen(rsp_query), (pANTLR3_UINT8)"RSP query"); #endif if (!query) { DPRINTF(E_DBG, L_RSP, "Could not create input stream\n"); return NULL; } lxr = RSPLexerNew(query); if (!lxr) { DPRINTF(E_DBG, L_RSP, "Could not create RSP lexer\n"); goto lxr_fail; } tkstream = antlr3CommonTokenStreamSourceNew(ANTLR3_SIZE_HINT, TOKENSOURCE(lxr)); if (!tkstream) { DPRINTF(E_DBG, L_RSP, "Could not create RSP token stream\n"); goto tkstream_fail; } psr = RSPParserNew(tkstream); if (!psr) { DPRINTF(E_DBG, L_RSP, "Could not create RSP parser\n"); goto psr_fail; } qtree = psr->query(psr); /* Check for parser errors */ if (psr->pParser->rec->state->errorCount > 0) { DPRINTF(E_LOG, L_RSP, "RSP query parser terminated with %d errors\n", psr->pParser->rec->state->errorCount); goto psr_error; } DPRINTF(E_SPAM, L_RSP, "RSP query AST:\n\t%s\n", qtree.tree->toStringTree(qtree.tree)->chars); nodes = antlr3CommonTreeNodeStreamNewTree(qtree.tree, ANTLR3_SIZE_HINT); if (!nodes) { DPRINTF(E_DBG, L_RSP, "Could not create node stream\n"); goto psr_error; } sqlconv = RSP2SQLNew(nodes); if (!sqlconv) { DPRINTF(E_DBG, L_RSP, "Could not create SQL converter\n"); goto sql_fail; } sql = sqlconv->query(sqlconv); /* Check for tree parser errors */ if (sqlconv->pTreeParser->rec->state->errorCount > 0) { DPRINTF(E_LOG, L_RSP, "RSP query tree parser terminated with %d errors\n", sqlconv->pTreeParser->rec->state->errorCount); goto sql_error; } if (sql) { DPRINTF(E_DBG, L_RSP, "RSP SQL query: -%s-\n", sql->chars); ret = strdup((char *)sql->chars); } else { DPRINTF(E_LOG, L_RSP, "Invalid RSP query\n"); ret = NULL; } sql_error: sqlconv->free(sqlconv); sql_fail: nodes->free(nodes); psr_error: psr->free(psr); psr_fail: tkstream->free(tkstream); tkstream_fail: lxr->free(lxr); lxr_fail: query->close(query); return ret; } forked-daapd-0.19gcd/src/rsp_query.gperf0000664000175000017500000000344211633141135017650 0ustar julienjulien%language=ANSI-C %readonly-tables %enum %switch=1 %compare-lengths %define hash-function-name rsp_query_field_hash %define lookup-function-name rsp_query_field_lookup %define slot-name rsp_field %struct-type %omit-struct-type struct rsp_query_field_map; %% "id", RSP_TYPE_INT "path", RSP_TYPE_STRING "fname", RSP_TYPE_STRING "title", RSP_TYPE_STRING "artist", RSP_TYPE_STRING "album", RSP_TYPE_STRING "genre", RSP_TYPE_STRING "comment", RSP_TYPE_STRING "type", RSP_TYPE_STRING "composer", RSP_TYPE_STRING "orchestra", RSP_TYPE_STRING "grouping", RSP_TYPE_STRING "url", RSP_TYPE_STRING "bitrate", RSP_TYPE_INT "samplerate", RSP_TYPE_INT "song_length", RSP_TYPE_INT "file_size", RSP_TYPE_INT "year", RSP_TYPE_INT "track", RSP_TYPE_INT "total_tracks", RSP_TYPE_INT "disc", RSP_TYPE_INT "total_discs", RSP_TYPE_INT "bpm", RSP_TYPE_INT "compilation", RSP_TYPE_INT "rating", RSP_TYPE_INT "play_count", RSP_TYPE_INT "data_kind", RSP_TYPE_INT "item_kind", RSP_TYPE_INT "description", RSP_TYPE_STRING "time_added", RSP_TYPE_DATE "time_modified", RSP_TYPE_DATE "time_played", RSP_TYPE_DATE "db_timestamp", RSP_TYPE_DATE "sample_count", RSP_TYPE_INT "codectype", RSP_TYPE_STRING "idx", RSP_TYPE_INT "has_video", RSP_TYPE_INT "contentrating", RSP_TYPE_INT "bits_per_sample", RSP_TYPE_INT "album_artist", RSP_TYPE_STRING forked-daapd-0.19gcd/src/rsp_query.h0000664000175000017500000000020511633141135016766 0ustar julienjulien #ifndef __RSP_QUERY_H__ #define __RSP_QUERY_H__ char * rsp_query_parse_sql(const char *rsp_query); #endif /* !__RSP_QUERY_H__ */ forked-daapd-0.19gcd/src/scan-flac.c0000664000175000017500000002015011633141135016560 0ustar julienjulien/* * Implementation file for server side format conversion. * * Copyright (C) 2005 Timo J. Rinne (tri@iki.fi) * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #ifdef HAVE_STDINT_H #include #endif #include #include #include #ifdef HAVE_DIRENT_H # include /* why here? For osx 10.2, of course! */ #endif #include /* htons and friends */ #include #include "logger.h" #include "db.h" #include #define TRUE ((1 == 1)) #define FALSE (!TRUE) typedef struct media_file_info MP3FILE; #define GET_VORBIS_COMMENT(comment, name, len) (char*) \ (((strncasecmp(name, (char*)(comment).entry, strlen(name)) == 0) && \ ((comment).entry[strlen(name)] == '=')) ? \ ((*(len) = (comment).length - (strlen(name) + 1)), \ (&((comment).entry[strlen(name) + 1]))) : \ NULL) /** * scan a flac file for metainfo. * * @param filename file to read metainfo for * @param pmp3 MP3FILE structure to fill * @returns TRUE if file should be added to DB, FALSE otherwise */ int scan_get_flacinfo(char *filename, MP3FILE *pmp3) { FLAC__Metadata_Chain *chain; FLAC__Metadata_Iterator *iterator; FLAC__StreamMetadata *block; int found=0; unsigned int sec, ms; int i; char *val; size_t len; char tmp; chain = FLAC__metadata_chain_new(); if (! chain) { DPRINTF(E_WARN,L_SCAN,"Cannot allocate FLAC metadata chain\n"); return FALSE; } if (! FLAC__metadata_chain_read(chain, filename)) { DPRINTF(E_WARN,L_SCAN,"Cannot read FLAC metadata from %s\n", filename); FLAC__metadata_chain_delete(chain); return FALSE; } iterator = FLAC__metadata_iterator_new(); if (! iterator) { DPRINTF(E_WARN,L_SCAN,"Cannot allocate FLAC metadata iterator\n"); FLAC__metadata_chain_delete(chain); return FALSE; } FLAC__metadata_iterator_init(iterator, chain); do { block = FLAC__metadata_iterator_get_block(iterator); if (block->type == FLAC__METADATA_TYPE_STREAMINFO) { sec = (unsigned int)(block->data.stream_info.total_samples / block->data.stream_info.sample_rate); ms = (unsigned int)(((block->data.stream_info.total_samples % block->data.stream_info.sample_rate) * 1000) / block->data.stream_info.sample_rate); if ((sec == 0) && (ms == 0)) break; /* Info is crap, escape div-by-zero. */ pmp3->song_length = (sec * 1000) + ms; pmp3->bitrate = (uint32_t)((pmp3->file_size) / (((sec * 1000) + ms) / 8)); pmp3->samplerate = block->data.stream_info.sample_rate; pmp3->bits_per_sample = block->data.stream_info.bits_per_sample; pmp3->sample_count = block->data.stream_info.total_samples; found |= 1; if(found == 3) break; } if (block->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) { for (i = 0; i < (int)block->data.vorbis_comment.num_comments; i++) { if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "ARTIST", &len))) { if ((pmp3->artist = calloc(len + 1, 1)) != NULL) strncpy(pmp3->artist, val, len); } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "TITLE", &len))) { if ((pmp3->title = calloc(len + 1, 1)) != NULL) strncpy(pmp3->title, val, len); } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "ALBUMARTIST", &len))) { if ((pmp3->album_artist = calloc(len + 1, 1)) != NULL) strncpy(pmp3->album_artist, val, len); } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "ALBUM", &len))) { if ((pmp3->album = calloc(len + 1, 1)) != NULL) strncpy(pmp3->album, val, len); } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "GENRE", &len))) { if ((pmp3->genre = calloc(len + 1, 1)) != NULL) strncpy(pmp3->genre, val, len); } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "COMPOSER", &len))) { if ((pmp3->composer = calloc(len + 1, 1)) != NULL) strncpy(pmp3->composer, val, len); } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "COMMENT", &len))) { if(pmp3->comment) free(pmp3->comment); /* was description */ if ((pmp3->comment = calloc(len + 1, 1)) != NULL) strncpy(pmp3->comment, val, len); } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "DESCRIPTION", &len))) { if(!pmp3->comment) { if ((pmp3->comment = calloc(len + 1, 1)) != NULL) strncpy(pmp3->comment, val, len); } } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "TRACKNUMBER", &len))) { tmp = *(val + len); *(val + len) = '\0'; pmp3->track = atoi(val); *(val + len) = tmp; } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "DISCNUMBER", &len))) { tmp = *(val + len); *(val + len) = '\0'; pmp3->disc = atoi(val); *(val + len) = tmp; } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "YEAR", &len))) { tmp = *(val + len); *(val + len) = '\0'; pmp3->year = atoi(val); *(val + len) = tmp; } else if ((val = GET_VORBIS_COMMENT(block->data.vorbis_comment.comments[i], "DATE", &len))) { tmp = *(val + len); *(val + len) = '\0'; pmp3->year = atoi(val); *(val + len) = tmp; } } found |= 2; if(found == 3) break; } } while (FLAC__metadata_iterator_next(iterator)); if (!found) { DPRINTF(E_WARN,L_SCAN,"Cannot find FLAC metadata in %s\n", filename); } FLAC__metadata_iterator_delete(iterator); FLAC__metadata_chain_delete(chain); return TRUE; } forked-daapd-0.19gcd/src/scan-mpc.c0000664000175000017500000000730411633141135016440 0ustar julienjulien/* * Musepack tag parsing routines. * * Copyright (C) 2005 Sebastian Dröge * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #ifdef HAVE_STDINT_H #include #endif #include #include #include #include #include "logger.h" #include "db.h" #define TRUE ((1 == 1)) #define FALSE (!TRUE) typedef struct media_file_info MP3FILE; /** * scan a musepack file for metainfo. * * @param filename file to read metainfo for * @param pmp3 MP3FILE structure to fill * @returns TRUE if file should be added to DB, FALSE otherwise */ int scan_get_mpcinfo(char *filename, MP3FILE *pmp3) { TagLib_File *file; TagLib_Tag *tag; const TagLib_AudioProperties *properties; char *val; int len; unsigned int i; /* open file with taglib */ if ((file = taglib_file_new_type(filename, TagLib_File_MPC)) == NULL) { DPRINTF(E_WARN,L_SCAN,"Could not open %s with taglib\n", filename); return FALSE; } /* retrieve all tags */ if ((tag = taglib_file_tag(file)) == NULL) { DPRINTF(E_WARN,L_SCAN,"Could not retrieve tags of %s\n", filename); taglib_file_free(file); return FALSE; } /* fill the MP3FILE structure with the tags */ if ((val = taglib_tag_title(tag)) != NULL) { len = strlen(val); if ((pmp3->title = calloc(len + 1, 1)) != NULL) strncpy(pmp3->title, val, len); taglib_tag_free_strings(); } if ((val = taglib_tag_artist(tag)) != NULL) { len = strlen(val); if ((pmp3->artist = calloc(len + 1, 1)) != NULL) strncpy(pmp3->artist, val, len); taglib_tag_free_strings(); } if ((val = taglib_tag_album(tag)) != NULL) { len = strlen(val); if ((pmp3->album = calloc(len + 1, 1)) != NULL) strncpy(pmp3->album, val, len); taglib_tag_free_strings(); } if ((val = taglib_tag_comment(tag)) != NULL) { len = strlen(val); if ((pmp3->comment = calloc(len + 1, 1)) != NULL) strncpy(pmp3->comment, val, len); taglib_tag_free_strings(); } if ((val = taglib_tag_genre(tag)) != NULL) { len = strlen(val); if ((pmp3->genre = calloc(len + 1, 1)) != NULL) strncpy(pmp3->genre, val, len); taglib_tag_free_strings(); } if ((i = taglib_tag_year(tag)) != 0) pmp3->year = i; if ((i = taglib_tag_track(tag)) != 0) pmp3->track = i; /* load the properties (like bitrate) from the file */ if ((properties = taglib_file_audioproperties(file)) == NULL) { DPRINTF(E_WARN,L_SCAN,"Could not retrieve properties of %s\n", filename); return FALSE; } /* fill the properties in the MP3FILE structure */ pmp3->song_length = taglib_audioproperties_length(properties) * 1000; pmp3->bitrate = taglib_audioproperties_bitrate(properties); pmp3->samplerate = taglib_audioproperties_samplerate(properties); taglib_file_free(file); return TRUE; } forked-daapd-0.19gcd/src/scan-wma.c0000664000175000017500000011125411633141135016445 0ustar julienjulien/* * WMA metatag parsing * * Copyright (C) 2005 Ron Pedde (ron@pedde.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifdef HAVE_CONFIG_H # include #endif #include #include #ifdef HAVE_STDINT_H #include #endif #include #include #include #include #include #include #include "logger.h" #include "db.h" #define TRUE ((1 == 1)) #define FALSE (!TRUE) typedef struct media_file_info MP3FILE; typedef struct tag_wma_guidlist { char *name; char *guid; char value[16]; } WMA_GUID; WMA_GUID wma_guidlist[] = { { "ASF_Index_Object", "D6E229D3-35DA-11D1-9034-00A0C90349BE", "\xD3\x29\xE2\xD6\xDA\x35\xD1\x11\x90\x34\x00\xA0\xC9\x03\x49\xBE" }, { "ASF_Extended_Stream_Properties_Object", "14E6A5CB-C672-4332-8399-A96952065B5A", "\xCB\xA5\xE6\x14\x72\xC6\x32\x43\x83\x99\xA9\x69\x52\x06\x5B\x5A" }, { "ASF_Payload_Ext_Syst_Pixel_Aspect_Ratio", "1B1EE554-F9EA-4BC8-821A-376B74E4C4B8", "\x54\xE5\x1E\x1B\xEA\xF9\xC8\x4B\x82\x1A\x37\x6B\x74\xE4\xC4\xB8" }, { "ASF_Bandwidth_Sharing_Object", "A69609E6-517B-11D2-B6AF-00C04FD908E9", "\xE6\x09\x96\xA6\x7B\x51\xD2\x11\xB6\xAF\x00\xC0\x4F\xD9\x08\xE9" }, { "ASF_Payload_Extension_System_Timecode", "399595EC-8667-4E2D-8FDB-98814CE76C1E", "\xEC\x95\x95\x39\x67\x86\x2D\x4E\x8F\xDB\x98\x81\x4C\xE7\x6C\x1E" }, { "ASF_Marker_Object", "F487CD01-A951-11CF-8EE6-00C00C205365", "\x01\xCD\x87\xF4\x51\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65" }, { "ASF_Data_Object", "75B22636-668E-11CF-A6D9-00AA0062CE6C", "\x36\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C" }, { "ASF_Content_Description_Object", "75B22633-668E-11CF-A6D9-00AA0062CE6C", "\x33\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C" }, { "ASF_Reserved_1", "ABD3D211-A9BA-11cf-8EE6-00C00C205365", "\x11\xD2\xD3\xAB\xBA\xA9\xcf\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65" }, { "ASF_Timecode_Index_Object", "3CB73FD0-0C4A-4803-953D-EDF7B6228F0C", "\xD0\x3F\xB7\x3C\x4A\x0C\x03\x48\x95\x3D\xED\xF7\xB6\x22\x8F\x0C" }, { "ASF_Language_List_Object", "7C4346A9-EFE0-4BFC-B229-393EDE415C85", "\xA9\x46\x43\x7C\xE0\xEF\xFC\x4B\xB2\x29\x39\x3E\xDE\x41\x5C\x85" }, { "ASF_No_Error_Correction", "20FB5700-5B55-11CF-A8FD-00805F5C442B", "\x00\x57\xFB\x20\x55\x5B\xCF\x11\xA8\xFD\x00\x80\x5F\x5C\x44\x2B" }, { "ASF_Extended_Content_Description_Object", "D2D0A440-E307-11D2-97F0-00A0C95EA850", "\x40\xA4\xD0\xD2\x07\xE3\xD2\x11\x97\xF0\x00\xA0\xC9\x5E\xA8\x50" }, { "ASF_Media_Object_Index_Parameters_Obj", "6B203BAD-3F11-4E84-ACA8-D7613DE2CFA7", "\xAD\x3B\x20\x6B\x11\x3F\x84\x4E\xAC\xA8\xD7\x61\x3D\xE2\xCF\xA7" }, { "ASF_Codec_List_Object", "86D15240-311D-11D0-A3A4-00A0C90348F6", "\x40\x52\xD1\x86\x1D\x31\xD0\x11\xA3\xA4\x00\xA0\xC9\x03\x48\xF6" }, { "ASF_Stream_Bitrate_Properties_Object", "7BF875CE-468D-11D1-8D82-006097C9A2B2", "\xCE\x75\xF8\x7B\x8D\x46\xD1\x11\x8D\x82\x00\x60\x97\xC9\xA2\xB2" }, { "ASF_Script_Command_Object", "1EFB1A30-0B62-11D0-A39B-00A0C90348F6", "\x30\x1A\xFB\x1E\x62\x0B\xD0\x11\xA3\x9B\x00\xA0\xC9\x03\x48\xF6" }, { "ASF_Degradable_JPEG_Media", "35907DE0-E415-11CF-A917-00805F5C442B", "\xE0\x7D\x90\x35\x15\xE4\xCF\x11\xA9\x17\x00\x80\x5F\x5C\x44\x2B" }, { "ASF_Header_Object", "75B22630-668E-11CF-A6D9-00AA0062CE6C", "\x30\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C" }, { "ASF_Padding_Object", "1806D474-CADF-4509-A4BA-9AABCB96AAE8", "\x74\xD4\x06\x18\xDF\xCA\x09\x45\xA4\xBA\x9A\xAB\xCB\x96\xAA\xE8" }, { "ASF_JFIF_Media", "B61BE100-5B4E-11CF-A8FD-00805F5C442B", "\x00\xE1\x1B\xB6\x4E\x5B\xCF\x11\xA8\xFD\x00\x80\x5F\x5C\x44\x2B" }, { "ASF_Digital_Signature_Object", "2211B3FC-BD23-11D2-B4B7-00A0C955FC6E", "\xFC\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E" }, { "ASF_Metadata_Library_Object", "44231C94-9498-49D1-A141-1D134E457054", "\x94\x1C\x23\x44\x98\x94\xD1\x49\xA1\x41\x1D\x13\x4E\x45\x70\x54" }, { "ASF_Payload_Ext_System_File_Name", "E165EC0E-19ED-45D7-B4A7-25CBD1E28E9B", "\x0E\xEC\x65\xE1\xED\x19\xD7\x45\xB4\xA7\x25\xCB\xD1\xE2\x8E\x9B" }, { "ASF_Stream_Prioritization_Object", "D4FED15B-88D3-454F-81F0-ED5C45999E24", "\x5B\xD1\xFE\xD4\xD3\x88\x4F\x45\x81\xF0\xED\x5C\x45\x99\x9E\x24" }, { "ASF_Bandwidth_Sharing_Exclusive", "AF6060AA-5197-11D2-B6AF-00C04FD908E9", "\xAA\x60\x60\xAF\x97\x51\xD2\x11\xB6\xAF\x00\xC0\x4F\xD9\x08\xE9" }, { "ASF_Group_Mutual_Exclusion_Object", "D1465A40-5A79-4338-B71B-E36B8FD6C249", "\x40\x5A\x46\xD1\x79\x5A\x38\x43\xB7\x1B\xE3\x6B\x8F\xD6\xC2\x49" }, { "ASF_Audio_Spread", "BFC3CD50-618F-11CF-8BB2-00AA00B4E220", "\x50\xCD\xC3\xBF\x8F\x61\xCF\x11\x8B\xB2\x00\xAA\x00\xB4\xE2\x20" }, { "ASF_Advanced_Mutual_Exclusion_Object", "A08649CF-4775-4670-8A16-6E35357566CD", "\xCF\x49\x86\xA0\x75\x47\x70\x46\x8A\x16\x6E\x35\x35\x75\x66\xCD" }, { "ASF_Payload_Ext_Syst_Sample_Duration", "C6BD9450-867F-4907-83A3-C77921B733AD", "\x50\x94\xBD\xC6\x7F\x86\x07\x49\x83\xA3\xC7\x79\x21\xB7\x33\xAD" }, { "ASF_Stream_Properties_Object", "B7DC0791-A9B7-11CF-8EE6-00C00C205365", "\x91\x07\xDC\xB7\xB7\xA9\xCF\x11\x8E\xE6\x00\xC0\x0C\x20\x53\x65" }, { "ASF_Metadata_Object", "C5F8CBEA-5BAF-4877-8467-AA8C44FA4CCA", "\xEA\xCB\xF8\xC5\xAF\x5B\x77\x48\x84\x67\xAA\x8C\x44\xFA\x4C\xCA" }, { "ASF_Mutex_Unknown", "D6E22A02-35DA-11D1-9034-00A0C90349BE", "\x02\x2A\xE2\xD6\xDA\x35\xD1\x11\x90\x34\x00\xA0\xC9\x03\x49\xBE" }, { "ASF_Content_Branding_Object", "2211B3FA-BD23-11D2-B4B7-00A0C955FC6E", "\xFA\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E" }, { "ASF_Content_Encryption_Object", "2211B3FB-BD23-11D2-B4B7-00A0C955FC6E", "\xFB\xB3\x11\x22\x23\xBD\xD2\x11\xB4\xB7\x00\xA0\xC9\x55\xFC\x6E" }, { "ASF_Index_Parameters_Object", "D6E229DF-35DA-11D1-9034-00A0C90349BE", "\xDF\x29\xE2\xD6\xDA\x35\xD1\x11\x90\x34\x00\xA0\xC9\x03\x49\xBE" }, { "ASF_Payload_Ext_System_Content_Type", "D590DC20-07BC-436C-9CF7-F3BBFBF1A4DC", "\x20\xDC\x90\xD5\xBC\x07\x6C\x43\x9C\xF7\xF3\xBB\xFB\xF1\xA4\xDC" }, { "ASF_Web_Stream_Media_Subtype", "776257D4-C627-41CB-8F81-7AC7FF1C40CC", "\xD4\x57\x62\x77\x27\xC6\xCB\x41\x8F\x81\x7A\xC7\xFF\x1C\x40\xCC" }, { "ASF_Web_Stream_Format", "DA1E6B13-8359-4050-B398-388E965BF00C", "\x13\x6B\x1E\xDA\x59\x83\x50\x40\xB3\x98\x38\x8E\x96\x5B\xF0\x0C" }, { "ASF_Simple_Index_Object", "33000890-E5B1-11CF-89F4-00A0C90349CB", "\x90\x08\x00\x33\xB1\xE5\xCF\x11\x89\xF4\x00\xA0\xC9\x03\x49\xCB" }, { "ASF_Error_Correction_Object", "75B22635-668E-11CF-A6D9-00AA0062CE6C", "\x35\x26\xB2\x75\x8E\x66\xCF\x11\xA6\xD9\x00\xAA\x00\x62\xCE\x6C" }, { "ASF_Media_Object_Index_Object", "FEB103F8-12AD-4C64-840F-2A1D2F7AD48C", "\xF8\x03\xB1\xFE\xAD\x12\x64\x4C\x84\x0F\x2A\x1D\x2F\x7A\xD4\x8C" }, { "ASF_Mutex_Language", "D6E22A00-35DA-11D1-9034-00A0C90349BE", "\x00\x2A\xE2\xD6\xDA\x35\xD1\x11\x90\x34\x00\xA0\xC9\x03\x49\xBE" }, { "ASF_File_Transfer_Media", "91BD222C-F21C-497A-8B6D-5AA86BFC0185", "\x2C\x22\xBD\x91\x1C\xF2\x7A\x49\x8B\x6D\x5A\xA8\x6B\xFC\x01\x85" }, { "ASF_Reserved_3", "4B1ACBE3-100B-11D0-A39B-00A0C90348F6", "\xE3\xCB\x1A\x4B\x0B\x10\xD0\x11\xA3\x9B\x00\xA0\xC9\x03\x48\xF6" }, { "ASF_Bitrate_Mutual_Exclusion_Object", "D6E229DC-35DA-11D1-9034-00A0C90349BE", "\xDC\x29\xE2\xD6\xDA\x35\xD1\x11\x90\x34\x00\xA0\xC9\x03\x49\xBE" }, { "ASF_Bandwidth_Sharing_Partial", "AF6060AB-5197-11D2-B6AF-00C04FD908E9", "\xAB\x60\x60\xAF\x97\x51\xD2\x11\xB6\xAF\x00\xC0\x4F\xD9\x08\xE9" }, { "ASF_Command_Media", "59DACFC0-59E6-11D0-A3AC-00A0C90348F6", "\xC0\xCF\xDA\x59\xE6\x59\xD0\x11\xA3\xAC\x00\xA0\xC9\x03\x48\xF6" }, { "ASF_Audio_Media", "F8699E40-5B4D-11CF-A8FD-00805F5C442B", "\x40\x9E\x69\xF8\x4D\x5B\xCF\x11\xA8\xFD\x00\x80\x5F\x5C\x44\x2B" }, { "ASF_Reserved_2", "86D15241-311D-11D0-A3A4-00A0C90348F6", "\x41\x52\xD1\x86\x1D\x31\xD0\x11\xA3\xA4\x00\xA0\xC9\x03\x48\xF6" }, { "ASF_Binary_Media", "3AFB65E2-47EF-40F2-AC2C-70A90D71D343", "\xE2\x65\xFB\x3A\xEF\x47\xF2\x40\xAC\x2C\x70\xA9\x0D\x71\xD3\x43" }, { "ASF_Mutex_Bitrate", "D6E22A01-35DA-11D1-9034-00A0C90349BE", "\x01\x2A\xE2\xD6\xDA\x35\xD1\x11\x90\x34\x00\xA0\xC9\x03\x49\xBE" }, { "ASF_Reserved_4", "4CFEDB20-75F6-11CF-9C0F-00A0C90349CB", "\x20\xDB\xFE\x4C\xF6\x75\xCF\x11\x9C\x0F\x00\xA0\xC9\x03\x49\xCB" }, { "ASF_Alt_Extended_Content_Encryption_Obj", "FF889EF1-ADEE-40DA-9E71-98704BB928CE", "\xF1\x9E\x88\xFF\xEE\xAD\xDA\x40\x9E\x71\x98\x70\x4B\xB9\x28\xCE" }, { "ASF_Timecode_Index_Parameters_Object", "F55E496D-9797-4B5D-8C8B-604DFE9BFB24", "\x6D\x49\x5E\xF5\x97\x97\x5D\x4B\x8C\x8B\x60\x4D\xFE\x9B\xFB\x24" }, { "ASF_Header_Extension_Object", "5FBF03B5-A92E-11CF-8EE3-00C00C205365", "\xB5\x03\xBF\x5F\x2E\xA9\xCF\x11\x8E\xE3\x00\xC0\x0C\x20\x53\x65" }, { "ASF_Video_Media", "BC19EFC0-5B4D-11CF-A8FD-00805F5C442B", "\xC0\xEF\x19\xBC\x4D\x5B\xCF\x11\xA8\xFD\x00\x80\x5F\x5C\x44\x2B" }, { "ASF_Extended_Content_Encryption_Object", "298AE614-2622-4C17-B935-DAE07EE9289C", "\x14\xE6\x8A\x29\x22\x26\x17\x4C\xB9\x35\xDA\xE0\x7E\xE9\x28\x9C" }, { "ASF_File_Properties_Object", "8CABDCA1-A947-11CF-8EE4-00C00C205365", "\xA1\xDC\xAB\x8C\x47\xA9\xCF\x11\x8E\xE4\x00\xC0\x0C\x20\x53\x65" }, { NULL, NULL, "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0" } }; #define MAYBEFREE(x) { free((x)); } typedef struct tag_wma_header { unsigned char objectid[16]; unsigned long long size; unsigned int objects; char reserved1; char reserved2; } __attribute__((packed)) WMA_HEADER; typedef struct tag_wma_subheader { unsigned char objectid[16]; long long size; } __attribute__((packed)) WMA_SUBHEADER; typedef struct tag_wma_stream_properties { unsigned char stream_type[16]; unsigned char codec_type[16]; char time_offset[8]; unsigned int tsdl; unsigned int ecdl; unsigned short int flags; unsigned int reserved; } __attribute__((packed)) WMA_STREAM_PROP; typedef struct tag_wma_header_extension { unsigned char reserved_1[16]; unsigned short int reserved_2; unsigned int data_size; } __attribute__((packed)) WMA_HEADER_EXT; /* * Forwards */ WMA_GUID *wma_find_guid(unsigned char *guid); unsigned short int wma_convert_short(unsigned char *src); unsigned int wma_convert_int(unsigned char *src); unsigned long long wma_convert_ll(unsigned char *src); char *wma_utf16toutf8(unsigned char *utf16, int len); int wma_parse_content_description(int fd,int size, MP3FILE *pmp3); int wma_parse_extended_content_description(int fd,int size, MP3FILE *pmp3, int extended); int wma_parse_file_properties(int fd,int size, MP3FILE *pmp3); int wma_parse_audio_media(int fd, int size, MP3FILE *pmp3); int wma_parse_stream_properties(int fd, int size, MP3FILE *pmp3); int wma_parse_header_extension(int fd, int size, MP3FILE *pmp3); /** * read an unsigned short int from the fd */ int wma_file_read_short(int fd, unsigned short int *psi) { uint32_t len; int ret; len = sizeof(unsigned short int); ret = read(fd, psi, len); if ((ret < 0) || (ret != len)) { return 0; } *psi = wma_convert_short((unsigned char *)psi); return 1; } /** * read an unsigned int from the fd */ int wma_file_read_int(int fd, unsigned int *pi) { uint32_t len; int ret; len = sizeof(unsigned int); ret = read(fd, pi, len); if((ret < 0) || (ret != len)) { return 0; } *pi = wma_convert_int((unsigned char *)pi); return 1; } /** * read an ll from the fd */ int wma_file_read_ll(int fd, unsigned long long *pll) { uint32_t len; int ret; len = sizeof(unsigned long long); ret = read(fd, pll, len); if((ret < 0) || (ret != len)) { return 0; } *pll = wma_convert_ll((unsigned char *)pll); return 1; } /** * read a utf-16le string as a utf8 */ int wma_file_read_utf16(int fd, int len, char **utf8) { char *out; unsigned char *utf16; int ret; utf16=(unsigned char*)malloc(len); if(!utf16) return 0; ret = read(fd, utf16, len); if((ret < 0) || (ret != len)) return 0; out = wma_utf16toutf8(utf16,len); *utf8 = out; free(utf16); return 1; } int wma_file_read_bytes(int fd,int len, unsigned char **data) { int ret; *data = (unsigned char *)malloc(len); if(!*data) return 0; ret = read(fd, *data, len); if((ret < 0) || (ret != len)) return 0; return 1; } int wma_parse_header_extension(int fd, int size, MP3FILE *pmp3) { WMA_HEADER_EXT he; WMA_SUBHEADER sh; WMA_GUID *pguid; int bytes_left; /* FIXME: uint32_t? */ uint64_t current; uint32_t len; int ret; len = sizeof(he); ret = read(fd, &he, len); if((ret < 0) || (ret != len)) return FALSE; he.data_size = wma_convert_int((unsigned char *)&he.data_size); bytes_left = he.data_size; DPRINTF(E_DBG,L_SCAN,"Found header ext of %d (%d) bytes\n",he.data_size,size); while(bytes_left) { /* read in a subheader */ current = lseek(fd, 0, SEEK_CUR); len = sizeof(sh); ret = read(fd, &sh, len); if((ret < 0) || (ret != len)) return FALSE; sh.size = wma_convert_ll((unsigned char *)&sh.size); pguid = wma_find_guid(sh.objectid); if(!pguid) { DPRINTF(E_DBG,L_SCAN," Unknown ext subheader: %02hhx%02hhx" "%02hhx%02hhx-" "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-" "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx\n", sh.objectid[3],sh.objectid[2], sh.objectid[1],sh.objectid[0], sh.objectid[5],sh.objectid[4], sh.objectid[7],sh.objectid[6], sh.objectid[8],sh.objectid[9], sh.objectid[10],sh.objectid[11], sh.objectid[12],sh.objectid[13], sh.objectid[14],sh.objectid[15]); } else { DPRINTF(E_DBG,L_SCAN," Found ext subheader: %s\n", pguid->name); if(strcmp(pguid->name,"ASF_Metadata_Library_Object")==0) { if(!wma_parse_extended_content_description(fd,size,pmp3,1)) return FALSE; } } DPRINTF(E_DBG,L_SCAN," Size: %lld\n",sh.size); if(sh.size <= sizeof(sh)) return TRUE; /* guess we're done! */ bytes_left -= (long)sh.size; lseek(fd,current + (uint64_t)sh.size,SEEK_SET); } return TRUE; } /** * another try to get stream codec type * * @param fd fd of the file we are reading from -- positioned at start * @param size size of the content description block * @param pmp3 the mp3 struct we are filling with gleaned data */ int wma_parse_stream_properties(int fd, int size, MP3FILE *pmp3) { WMA_STREAM_PROP sp; WMA_GUID *pguid; uint32_t len; int ret; len = sizeof(sp); ret = read(fd, &sp, len); if((ret < 0) || (ret != len)) return FALSE; pguid = wma_find_guid(sp.stream_type); if(!pguid) return TRUE; if(strcmp(pguid->name,"ASF_Audio_Media") != 0) return TRUE; /* it is an audio stream... find codec. The Type-Specific * data should be a WAVEFORMATEX... so we'll leverage * wma_parse_audio_media */ return wma_parse_audio_media(fd,size - sizeof(WMA_STREAM_PROP),pmp3); } /** * parse the audio media section... This is essentially a * WAVFORMATEX structure. Generally we only care about the * codec type. * * @param fd fd of the file we are reading from -- positioned at start * @param size size of the content description block * @param pmp3 the mp3 struct we are filling with gleaned data */ int wma_parse_audio_media(int fd, int size, MP3FILE *pmp3) { unsigned short int codec; if(size < 18) return TRUE; /* we'll leave it wma. will work or not! */ if(!wma_file_read_short(fd,&codec)) { return FALSE; } DPRINTF(E_DBG,L_SCAN,"WMA Codec Type: %02X\n",codec); switch(codec) { case 0x0A: MAYBEFREE(pmp3->codectype); pmp3->codectype = strdup("wmav"); /* voice */ break; case 0x162: MAYBEFREE(pmp3->codectype); MAYBEFREE(pmp3->type); pmp3->codectype = strdup("wma"); /* pro */ pmp3->type = strdup("wmap"); break; case 0x163: MAYBEFREE(pmp3->codectype); pmp3->codectype = strdup("wmal"); /* lossless */ break; } /* might as well get the sample rate while we are at it */ lseek(fd,2,SEEK_CUR); if(!wma_file_read_int(fd,(unsigned int *)&pmp3->samplerate)) return FALSE; return TRUE; } /** * parse the extended content description object. this is an object that * has ad-hoc tags, basically. * * @param fd fd of the file we are reading from -- positioned at start * @param size size of the content description block * @param pmp3 the mp3 struct we are filling with gleaned data */ int wma_parse_extended_content_description(int fd,int size, MP3FILE *pmp3, int extended) { unsigned short descriptor_count; int index; unsigned short descriptor_name_len; char *descriptor_name; unsigned short descriptor_value_type; unsigned int descriptor_value_int; unsigned short descriptor_value_len; unsigned short language_list_index; unsigned short stream_number; char *descriptor_byte_value=NULL; unsigned int descriptor_int_value; /* bool and dword */ unsigned long long descriptor_ll_value; unsigned short int descriptor_short_value; int fail=0; int track, tracknumber; char numbuff[40]; char *tmp; unsigned char *ptr; track = tracknumber = 0; DPRINTF(E_DBG,L_SCAN,"Reading extended content description object\n"); if(!wma_file_read_short(fd, &descriptor_count)) return FALSE; for(index = 0; index < descriptor_count; index++) { DPRINTF(E_DBG,L_SCAN,"Reading descr %d of %d\n",index,descriptor_count); if(!extended) { if(!wma_file_read_short(fd,&descriptor_name_len)) return FALSE; if(!wma_file_read_utf16(fd,descriptor_name_len,&descriptor_name)) return FALSE; if(!wma_file_read_short(fd,&descriptor_value_type)) { free(descriptor_name); return FALSE; } if(!wma_file_read_short(fd,&descriptor_value_len)) { free(descriptor_name); return FALSE; } descriptor_value_int = descriptor_value_len; } else { if(!wma_file_read_short(fd,&language_list_index)) return FALSE; if(!wma_file_read_short(fd,&stream_number)) return FALSE; if(!wma_file_read_short(fd,&descriptor_name_len)) return FALSE; if(!wma_file_read_short(fd,&descriptor_value_type)) return FALSE; if(!wma_file_read_int(fd,&descriptor_value_int)) return FALSE; if(!wma_file_read_utf16(fd,descriptor_name_len,&descriptor_name)) return FALSE; } DPRINTF(E_DBG,L_SCAN,"Found descriptor: %s\n", descriptor_name); /* see what kind it is */ switch(descriptor_value_type) { case 0x0000: /* string */ if(!wma_file_read_utf16(fd,descriptor_value_int, &descriptor_byte_value)) { fail=1; } descriptor_int_value=atoi(descriptor_byte_value); DPRINTF(E_DBG,L_SCAN,"Type: string, value: %s\n",descriptor_byte_value); break; case 0x0001: /* byte array */ if(descriptor_value_int > 4096) { lseek(fd,(uint64_t)descriptor_value_int,SEEK_CUR); descriptor_byte_value = NULL; } else { ptr = (unsigned char *)descriptor_byte_value; if(!wma_file_read_bytes(fd,descriptor_value_int, &ptr)){ fail=1; } } DPRINTF(E_DBG,L_SCAN,"Type: bytes\n"); break; case 0x0002: /* bool - dropthru */ case 0x0003: /* dword */ if(!wma_file_read_int(fd,&descriptor_int_value)) fail=1; DPRINTF(E_DBG,L_SCAN,"Type: int, value: %d\n",descriptor_int_value); snprintf(numbuff,sizeof(numbuff)-1,"%d",descriptor_int_value); descriptor_byte_value = strdup(numbuff); break; case 0x0004: /* qword */ if(!wma_file_read_ll(fd,&descriptor_ll_value)) fail=1; DPRINTF(E_DBG,L_SCAN,"Type: ll, value: %lld\n",descriptor_ll_value); snprintf(numbuff,sizeof(numbuff)-1,"%lld",descriptor_ll_value); descriptor_byte_value = strdup(numbuff); break; case 0x0005: /* word */ if(!wma_file_read_short(fd,&descriptor_short_value)) fail=1; DPRINTF(E_DBG,L_SCAN,"type: short, value %d\n",descriptor_short_value); snprintf(numbuff,sizeof(numbuff)-1,"%d",descriptor_short_value); descriptor_byte_value = strdup(numbuff); break; case 0x0006: /* guid */ lseek(fd,16,SEEK_CUR); /* skip it */ if(descriptor_name) free(descriptor_name); descriptor_name = strdup(""); descriptor_byte_value = NULL; break; default: DPRINTF(E_LOG,L_SCAN,"Badly formatted wma file\n"); if(descriptor_name) free(descriptor_name); if(descriptor_byte_value) free(descriptor_byte_value); return FALSE; } if(fail) { DPRINTF(E_DBG,L_SCAN,"Read fail on file\n"); free(descriptor_name); return FALSE; } /* do stuff with what we found */ if(strcasecmp(descriptor_name,"wm/genre")==0) { MAYBEFREE(pmp3->genre); pmp3->genre = descriptor_byte_value; descriptor_byte_value = NULL; /* don't free it! */ } else if(strcasecmp(descriptor_name,"wm/albumtitle")==0) { MAYBEFREE(pmp3->album); pmp3->album = descriptor_byte_value; descriptor_byte_value = NULL; } else if(strcasecmp(descriptor_name,"wm/track")==0) { track = descriptor_int_value + 1; } else if(strcasecmp(descriptor_name,"wm/shareduserrating")==0) { /* what a strange rating strategy */ pmp3->rating = descriptor_int_value; if(pmp3->rating == 99) { pmp3->rating = 100; } else { if(pmp3->rating) { pmp3->rating = ((pmp3->rating / 25) + 1) * 20; } } } else if(strcasecmp(descriptor_name,"wm/tracknumber")==0) { tracknumber = descriptor_int_value; } else if(strcasecmp(descriptor_name,"wm/year")==0) { pmp3->year = atoi(descriptor_byte_value); } else if(strcasecmp(descriptor_name,"wm/composer")==0) { /* get first one only */ if(!pmp3->composer) { pmp3->composer = descriptor_byte_value; descriptor_byte_value = NULL; } else { size = (int)strlen(pmp3->composer) + 1 + (int)strlen(descriptor_byte_value) + 1; tmp = malloc(size); if(!tmp) DPRINTF(E_FATAL,L_SCAN,"malloc: wma_ext_content_descr\n"); sprintf(tmp,"%s/%s",pmp3->composer,descriptor_byte_value); free(pmp3->composer); pmp3->composer=tmp; } } else if(strcasecmp(descriptor_name,"wm/albumartist")==0) { /* get first one only */ if(!pmp3->album_artist) { pmp3->album_artist = descriptor_byte_value; descriptor_byte_value = NULL; } } else if(strcasecmp(descriptor_name,"author") == 0) { /* get first one only */ if(!pmp3->artist) { pmp3->artist = descriptor_byte_value; descriptor_byte_value = NULL; } } else if(strcasecmp(descriptor_name,"wm/contengroupdescription")==0) { MAYBEFREE(pmp3->grouping); pmp3->grouping = descriptor_byte_value; descriptor_byte_value = NULL; } else if(strcasecmp(descriptor_name,"comment")==0) { MAYBEFREE(pmp3->comment); pmp3->comment = descriptor_byte_value; descriptor_byte_value = NULL; } /* cleanup - done with this round */ if(descriptor_byte_value) { free(descriptor_byte_value); descriptor_byte_value = NULL; } free(descriptor_name); } if(tracknumber) { pmp3->track = tracknumber; } else if(track) { pmp3->track = track; } if((!pmp3->artist) && (pmp3->orchestra)) { pmp3->artist = strdup(pmp3->orchestra); } if((pmp3->artist) && (!pmp3->orchestra)) { pmp3->orchestra = strdup(pmp3->artist); } return TRUE; } /** * parse the content description object. this is an object that * contains lengths of title, author, copyright, descr, and rating * then the utf-16le strings for each. * * @param fd fd of the file we are reading from -- positioned at start * @param size size of the content description block * @param pmp3 the mp3 struct we are filling with gleaned data */ int wma_parse_content_description(int fd,int size, MP3FILE *pmp3) { unsigned short sizes[5]; int index; char *utf8; if(size < 10) /* must be at least enough room for the size block */ return FALSE; for(index=0; index < 5; index++) { if(!wma_file_read_short(fd,&sizes[index])) return FALSE; } for(index=0;index<5;index++) { if(sizes[index]) { if(!wma_file_read_utf16(fd,sizes[index],&utf8)) return FALSE; DPRINTF(E_DBG,L_SCAN,"Got item of length %d: %s\n",sizes[index],utf8); switch(index) { case 0: /* title */ if(pmp3->title) free(pmp3->title); pmp3->title = utf8; break; case 1: /* author */ if(pmp3->artist) free(pmp3->artist); pmp3->artist = utf8; break; case 2: /* copyright - dontcare */ free(utf8); break; case 3: /* description */ if(pmp3->comment) free(pmp3->comment); pmp3->comment = utf8; break; case 4: /* rating - dontcare */ free(utf8); break; default: /* can't get here */ DPRINTF(E_FATAL,L_SCAN,"This is not my beautiful wife.\n"); break; } } } return TRUE; } /** * parse the file properties object. this is an object that * contains playtime and bitrate, primarily. * * @param fd fd of the file we are reading from -- positioned at start * @param size size of the content description block * @param pmp3 the mp3 struct we are filling with gleaned data */ int wma_parse_file_properties(int fd,int size, MP3FILE *pmp3) { unsigned long long play_duration; unsigned long long send_duration; unsigned long long preroll; unsigned int max_bitrate; /* skip guid (16 bytes), filesize (8), creation time (8), * data packets (8) */ lseek(fd,40,SEEK_CUR); if(!wma_file_read_ll(fd, &play_duration)) return FALSE; if(!wma_file_read_ll(fd, &send_duration)) return FALSE; if(!wma_file_read_ll(fd, &preroll)) return FALSE; DPRINTF(E_DBG,L_SCAN,"play_duration: %lld, " "send_duration: %lld, preroll: %lld\n", play_duration, send_duration, preroll); /* I'm not entirely certain what preroll is, but it seems * to make it match up with what windows thinks is the song * length. */ pmp3->song_length = (int)((play_duration / 10000) - preroll); /* skip flags(4), * min_packet_size (4), max_packet_size(4) */ lseek(fd,12,SEEK_CUR); if(!wma_file_read_int(fd,&max_bitrate)) return FALSE; pmp3->bitrate = max_bitrate/1000; return TRUE; } /** * convert utf16 string to utf8. This is a bit naive, but... * Since utf-8 can't expand past 4 bytes per code point, and * we're converting utf-16, we can't be more than 2n+1 bytes, so * we'll just allocate that much. * * Probably it could be more efficiently calculated, but this will * always work. Besides, these are small strings, and will be freed * after the db insert. * * We assume this is utf-16LE, as it comes from windows * * @param utf16 utf-16 to convert * @param len length of utf-16 string */ char *wma_utf16toutf8(unsigned char *utf16, int len) { char *utf8; unsigned char *src=utf16; char *dst; unsigned int w1, w2; int bytes; if(!len) return NULL; utf8=(char *)malloc(len*2 + 1); if(!utf8) return NULL; memset(utf8,0x0,len*2 + 1); dst=utf8; while((src+2) <= utf16+len) { w1=src[1] << 8 | src[0]; src += 2; if((w1 & 0xFC00) == 0xD800) { /* could be surrogate pair */ if(src+2 > utf16+len) { DPRINTF(E_INFO,L_SCAN,"Invalid utf-16 in file\n"); free(utf8); return NULL; } w2 = src[3] << 8 | src[2]; if((w2 & 0xFC00) != 0xDC00) { DPRINTF(E_INFO,L_SCAN,"Invalid utf-16 in file\n"); free(utf8); return NULL; } /* get bottom 10 of each */ w1 = w1 & 0x03FF; w1 = w1 << 10; w1 = w1 | (w2 & 0x03FF); /* add back the 0x10000 */ w1 += 0x10000; } /* now encode the original code point in utf-8 */ if (w1 < 0x80) { *dst++ = w1; bytes=0; } else if (w1 < 0x800) { *dst++ = 0xC0 | (w1 >> 6); bytes=1; } else if (w1 < 0x10000) { *dst++ = 0xE0 | (w1 >> 12); bytes=2; } else { *dst++ = 0xF0 | (w1 >> 18); bytes=3; } while(bytes) { *dst++ = 0x80 | ((w1 >> (6*(bytes-1))) & 0x3f); bytes--; } } return utf8; } /** * lookup a guid by character * * @param guid 16 byte guid to look up */ WMA_GUID *wma_find_guid(unsigned char *guid) { WMA_GUID *pguid = wma_guidlist; while((pguid->name) && (memcmp(guid,pguid->value,16) != 0)) { pguid++; } if(!pguid->name) return NULL; return pguid; } /** * convert a short int in wrong-endian format to host-endian * * @param src pointer to 16-bit wrong-endian int */ unsigned short wma_convert_short(unsigned char *src) { return src[1] << 8 | src[0]; } /** * convert an int in wrong-endian format to host-endian * * @param src pointer to 32-bit wrong-endian int */ unsigned int wma_convert_int(unsigned char *src) { return src[3] << 24 | src[2] << 16 | src[1] << 8 | src[0]; } /** * convert a long long wrong-endian format to host-endian * * @param src pointer to 64-bit wrong-endian int */ unsigned long long wma_convert_ll(unsigned char *src) { unsigned int tmp_hi, tmp_lo; unsigned long long retval; tmp_hi = src[7] << 24 | src[6] << 16 | src[5] << 8 | src[4]; tmp_lo = src[3] << 24 | src[2] << 16 | src[1] << 8 | src[0]; retval = tmp_hi; retval = (retval << 32) | tmp_lo; return retval; } /** * get metainfo about a wma file * * @param filename full path to file to scan * @param pmp3 MP3FILE struct to be filled with with metainfo */ int scan_get_wmainfo(char *filename, MP3FILE *pmp3) { WMA_HEADER hdr; WMA_SUBHEADER subhdr; WMA_GUID *pguid; uint64_t offset=0; uint32_t len; int item; int res=TRUE; int encrypted = 0; int fd; int ret; fd = open(filename, O_RDONLY); if (fd < 0) { DPRINTF(E_INFO,L_SCAN,"Error opening WMA file (%s): %s\n",filename, strerror(errno)); return FALSE; } len = sizeof(hdr); ret = read(fd, &hdr, len); if((ret < 0) || (ret != len)) { DPRINTF(E_INFO,L_SCAN,"Error reading from %s: %s\n",filename, strerror(errno)); close(fd); return FALSE; } pguid = wma_find_guid(hdr.objectid); if(!pguid) { DPRINTF(E_INFO,L_SCAN,"Could not find header in %s\n",filename); close(fd); return FALSE; } hdr.objects=wma_convert_int((unsigned char *)&hdr.objects); hdr.size=wma_convert_ll((unsigned char *)&hdr.size); DPRINTF(E_DBG,L_SCAN,"Found WMA header: %s\n",pguid->name); DPRINTF(E_DBG,L_SCAN,"Header size: %lld\n",hdr.size); DPRINTF(E_DBG,L_SCAN,"Header objects: %d\n",hdr.objects); offset = sizeof(hdr); //hdr.size; /* Now we just walk through all the headers and see if we * find anything interesting */ for(item=0; item < (int) hdr.objects; item++) { if(!lseek(fd,offset,SEEK_SET)) { DPRINTF(E_INFO,L_SCAN,"Error seeking in %s\n",filename); close(fd); return FALSE; } len = sizeof(subhdr); ret = read(fd, &subhdr, len); if((ret < 0) || (ret != len)) { DPRINTF(E_INFO,L_SCAN,"Error reading from %s: %s\n",filename, strerror(errno)); close(fd); return FALSE; } subhdr.size=wma_convert_ll((unsigned char *)&subhdr.size); pguid = wma_find_guid(subhdr.objectid); if(pguid) { DPRINTF(E_DBG,L_SCAN,"%" PRIu64 ": Found subheader: %s\n", offset,pguid->name); if(strcmp(pguid->name,"ASF_Content_Description_Object")==0) { res &= wma_parse_content_description(fd,(int)subhdr.size,pmp3); } else if (strcmp(pguid->name,"ASF_Extended_Content_Description_Object")==0) { res &= wma_parse_extended_content_description(fd,(int)subhdr.size,pmp3,0); } else if (strcmp(pguid->name,"ASF_File_Properties_Object")==0) { res &= wma_parse_file_properties(fd,(int)subhdr.size,pmp3); } else if (strcmp(pguid->name,"ASF_Audio_Media")==0) { res &= wma_parse_audio_media(fd,(int)subhdr.size,pmp3); } else if (strcmp(pguid->name,"ASF_Stream_Properties_Object")==0) { res &= wma_parse_stream_properties(fd,(int)subhdr.size,pmp3); } else if(strcmp(pguid->name,"ASF_Header_Extension_Object")==0) { res &= wma_parse_header_extension(fd,(int)subhdr.size,pmp3); } else if(strstr(pguid->name,"Content_Encryption_Object")) { encrypted=1; } } else { DPRINTF(E_DBG,L_SCAN,"Unknown subheader: %02hhx%02hhx%02hhx%02hhx-" "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-" "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx\n", subhdr.objectid[3],subhdr.objectid[2], subhdr.objectid[1],subhdr.objectid[0], subhdr.objectid[5],subhdr.objectid[4], subhdr.objectid[7],subhdr.objectid[6], subhdr.objectid[8],subhdr.objectid[9], subhdr.objectid[10],subhdr.objectid[11], subhdr.objectid[12],subhdr.objectid[13], subhdr.objectid[14],subhdr.objectid[15]); } offset += (uint64_t) subhdr.size; } if(!res) { DPRINTF(E_INFO,L_SCAN,"Error reading meta info for file %s\n", filename); } else { DPRINTF(E_DBG,L_SCAN,"Successfully parsed file\n"); } close(fd); if(encrypted) { if(pmp3->codectype) free(pmp3->codectype); pmp3->codectype=strdup("wmap"); } return res; } forked-daapd-0.19gcd/src/transcode.c0000664000175000017500000003545711633141135016733 0ustar julienjulien/* * Copyright (C) 2009-2011 Julien BLACHE * * Adapted from mt-daapd: * Copyright (C) 2006-2007 Ron Pedde * * 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 */ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include #include #include #if defined(__linux__) || defined(__GLIBC__) # include # include #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) # include #endif #include #include #include "evbuffer/evbuffer.h" #include "logger.h" #include "conffile.h" #include "db.h" #include "http.h" #include "transcode.h" #define XCODE_BUFFER_SIZE ((AVCODEC_MAX_AUDIO_FRAME_SIZE * 3) / 2) struct transcode_ctx { AVFormatContext *fmtctx; /* Audio stream */ int astream; AVCodecContext *acodec; /* pCodecCtx */ AVCodec *adecoder; /* pCodec */ AVPacket apacket; AVPacket apacket2; int16_t *abuffer; /* Resampling */ int need_resample; int input_size; ReSampleContext *resample_ctx; int16_t *re_abuffer; off_t offset; uint32_t duration; uint64_t samples; /* WAV header */ int wavhdr; uint8_t header[44]; }; static char *default_codecs = "mpeg,wav"; static char *roku_codecs = "mpeg,mp4a,wma,wav"; static char *itunes_codecs = "mpeg,mp4a,mp4v,alac,wav"; static inline void add_le16(uint8_t *dst, uint16_t val) { dst[0] = val & 0xff; dst[1] = (val >> 8) & 0xff; } static inline void add_le32(uint8_t *dst, uint32_t val) { dst[0] = val & 0xff; dst[1] = (val >> 8) & 0xff; dst[2] = (val >> 16) & 0xff; dst[3] = (val >> 24) & 0xff; } static void make_wav_header(struct transcode_ctx *ctx, off_t *est_size) { uint32_t wav_len; int duration; if (ctx->duration) duration = ctx->duration; else duration = 3 * 60 * 1000; /* 3 minutes, in ms */ if (ctx->samples && !ctx->need_resample) wav_len = 2 * 2 * ctx->samples; else wav_len = 2 * 2 * 44100 * (duration / 1000); *est_size = wav_len + sizeof(ctx->header); memcpy(ctx->header, "RIFF", 4); add_le32(ctx->header + 4, 36 + wav_len); memcpy(ctx->header + 8, "WAVEfmt ", 8); add_le32(ctx->header + 16, 16); add_le16(ctx->header + 20, 1); add_le16(ctx->header + 22, 2); /* channels */ add_le32(ctx->header + 24, 44100); /* samplerate */ add_le32(ctx->header + 28, 44100 * 2 * 2); /* byte rate */ add_le16(ctx->header + 32, 2 * 2); /* block align */ add_le16(ctx->header + 34, 16); /* bits per sample */ memcpy(ctx->header + 36, "data", 4); add_le32(ctx->header + 40, wav_len); } int transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted) { int16_t *buf; int buflen; int processed; int used; int stop; int ret; #if BYTE_ORDER == BIG_ENDIAN int i; #endif processed = 0; if (ctx->wavhdr && (ctx->offset == 0)) { evbuffer_add(evbuf, ctx->header, sizeof(ctx->header)); processed += sizeof(ctx->header); ctx->offset += sizeof(ctx->header); } stop = 0; while ((processed < wanted) && !stop) { /* Decode data */ while (ctx->apacket2.size > 0) { buflen = XCODE_BUFFER_SIZE; #if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 32) /* FFmpeg 0.6 */ used = avcodec_decode_audio3(ctx->acodec, ctx->abuffer, &buflen, &ctx->apacket2); #else used = avcodec_decode_audio2(ctx->acodec, ctx->abuffer, &buflen, ctx->apacket2.data, ctx->apacket2.size); #endif if (used < 0) { /* Something happened, skip this packet */ ctx->apacket2.size = 0; break; } ctx->apacket2.data += used; ctx->apacket2.size -= used; /* No frame decoded this time around */ if (buflen == 0) continue; if (ctx->need_resample) { buflen = audio_resample(ctx->resample_ctx, ctx->re_abuffer, ctx->abuffer, buflen / ctx->input_size); if (buflen == 0) { DPRINTF(E_WARN, L_XCODE, "Resample returned no samples!\n"); continue; } buflen = buflen * 2 * 2; /* 16bit samples, 2 channels */ buf = ctx->re_abuffer; } else buf = ctx->abuffer; #if BYTE_ORDER == BIG_ENDIAN /* swap buffer, LE16 */ for (i = 0; i < (buflen / 2); i++) { buf[i] = htole16(buf[i]); } #endif ret = evbuffer_add(evbuf, buf, buflen); if (ret != 0) { DPRINTF(E_WARN, L_XCODE, "Could not copy WAV data to buffer\n"); return -1; } processed += buflen; } /* Read more data */ do { if (ctx->apacket.data) av_free_packet(&ctx->apacket); ret = av_read_frame(ctx->fmtctx, &ctx->apacket); if (ret < 0) { DPRINTF(E_WARN, L_XCODE, "Could not read more data\n"); stop = 1; break; } } while (ctx->apacket.stream_index != ctx->astream); /* Copy apacket and do not mess with it */ ctx->apacket2 = ctx->apacket; } ctx->offset += processed; return processed; } int transcode_seek(struct transcode_ctx *ctx, int ms) { int64_t start_time; int64_t target_pts; int64_t got_pts; int got_ms; int flags; int ret; start_time = ctx->fmtctx->streams[ctx->astream]->start_time; target_pts = ms; target_pts = target_pts * AV_TIME_BASE / 1000; target_pts = av_rescale_q(target_pts, AV_TIME_BASE_Q, ctx->fmtctx->streams[ctx->astream]->time_base); if ((start_time != AV_NOPTS_VALUE) && (start_time > 0)) target_pts += start_time; ret = av_seek_frame(ctx->fmtctx, ctx->astream, target_pts, AVSEEK_FLAG_BACKWARD); if (ret < 0) { DPRINTF(E_WARN, L_XCODE, "Could not seek into stream: %s\n", strerror(AVUNERROR(ret))); return -1; } avcodec_flush_buffers(ctx->acodec); #if LIBAVCODEC_VERSION_MAJOR >= 53 ctx->acodec->skip_frame = AVDISCARD_NONREF; #else ctx->acodec->hurry_up = 1; #endif flags = 0; while (1) { if (ctx->apacket.data) av_free_packet(&ctx->apacket); ret = av_read_frame(ctx->fmtctx, &ctx->apacket); if (ret < 0) { DPRINTF(E_WARN, L_XCODE, "Could not read more data while seeking\n"); flags = 1; break; } if (ctx->apacket.stream_index != ctx->astream) continue; /* Need a pts to return the real position */ if (ctx->apacket.pts == AV_NOPTS_VALUE) continue; break; } #if LIBAVCODEC_VERSION_MAJOR >= 53 ctx->acodec->skip_frame = AVDISCARD_DEFAULT; #else ctx->acodec->hurry_up = 0; #endif /* Error while reading frame above */ if (flags) return -1; /* Copy apacket and do not mess with it */ ctx->apacket2 = ctx->apacket; /* Compute position in ms from pts */ got_pts = ctx->apacket.pts; if ((start_time != AV_NOPTS_VALUE) && (start_time > 0)) got_pts -= start_time; got_pts = av_rescale_q(got_pts, ctx->fmtctx->streams[ctx->astream]->time_base, AV_TIME_BASE_Q); got_ms = got_pts / (AV_TIME_BASE / 1000); DPRINTF(E_DBG, L_XCODE, "Seek wanted %d ms, got %d ms\n", ms, got_ms); return got_ms; } struct transcode_ctx * transcode_setup(struct media_file_info *mfi, off_t *est_size, int wavhdr) { struct transcode_ctx *ctx; int i; int ret; ctx = (struct transcode_ctx *)malloc(sizeof(struct transcode_ctx)); if (!ctx) { DPRINTF(E_WARN, L_XCODE, "Could not allocate transcode context\n"); return NULL; } memset(ctx, 0, sizeof(struct transcode_ctx)); #if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVCODEC_VERSION_MINOR >= 3) ret = avformat_open_input(&ctx->fmtctx, mfi->path, NULL, NULL); #else ret = av_open_input_file(&ctx->fmtctx, mfi->path, NULL, 0, NULL); #endif if (ret != 0) { DPRINTF(E_WARN, L_XCODE, "Could not open file %s: %s\n", mfi->fname, strerror(AVUNERROR(ret))); free(ctx); return NULL; } ret = av_find_stream_info(ctx->fmtctx); if (ret < 0) { DPRINTF(E_WARN, L_XCODE, "Could not find stream info: %s\n", strerror(AVUNERROR(ret))); goto setup_fail; } ctx->astream = -1; for (i = 0; i < ctx->fmtctx->nb_streams; i++) { #if LIBAVCODEC_VERSION_MAJOR >= 53 || (LIBAVCODEC_VERSION_MAJOR == 52 && LIBAVCODEC_VERSION_MINOR >= 64) if (ctx->fmtctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) #else if (ctx->fmtctx->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) #endif { ctx->astream = i; break; } } if (ctx->astream < 0) { DPRINTF(E_WARN, L_XCODE, "No audio stream found in file %s\n", mfi->fname); goto setup_fail; } ctx->acodec = ctx->fmtctx->streams[ctx->astream]->codec; ctx->adecoder = avcodec_find_decoder(ctx->acodec->codec_id); if (!ctx->adecoder) { DPRINTF(E_WARN, L_XCODE, "No suitable decoder found for codec\n"); goto setup_fail; } if (ctx->adecoder->capabilities & CODEC_CAP_TRUNCATED) ctx->acodec->flags |= CODEC_FLAG_TRUNCATED; ret = avcodec_open(ctx->acodec, ctx->adecoder); if (ret != 0) { DPRINTF(E_WARN, L_XCODE, "Could not open codec: %s\n", strerror(AVUNERROR(ret))); goto setup_fail; } ctx->abuffer = (int16_t *)av_malloc(XCODE_BUFFER_SIZE); if (!ctx->abuffer) { DPRINTF(E_WARN, L_XCODE, "Could not allocate transcode buffer\n"); goto setup_fail_codec; } if ((ctx->acodec->sample_fmt != SAMPLE_FMT_S16) || (ctx->acodec->channels != 2) || (ctx->acodec->sample_rate != 44100)) { DPRINTF(E_DBG, L_XCODE, "Setting up resampling (%d@%d)\n", ctx->acodec->channels, ctx->acodec->sample_rate); ctx->resample_ctx = av_audio_resample_init(2, ctx->acodec->channels, 44100, ctx->acodec->sample_rate, SAMPLE_FMT_S16, ctx->acodec->sample_fmt, 16, 10, 0, 0.8); if (!ctx->resample_ctx) { DPRINTF(E_WARN, L_XCODE, "Could not init resample from %d@%d to 2@44100\n", ctx->acodec->channels, ctx->acodec->sample_rate); goto setup_fail_codec; } ctx->re_abuffer = (int16_t *)av_malloc(XCODE_BUFFER_SIZE * 2); if (!ctx->re_abuffer) { DPRINTF(E_WARN, L_XCODE, "Could not allocate resample buffer\n"); audio_resample_close(ctx->resample_ctx); goto setup_fail_codec; } ctx->need_resample = 1; #if LIBAVUTIL_VERSION_MAJOR >= 51 || (LIBAVUTIL_VERSION_MAJOR == 51 && LIBAVUTIL_VERSION_MINOR >= 4) ctx->input_size = ctx->acodec->channels * av_get_bytes_per_sample(ctx->acodec->sample_fmt); #elif LIBAVCODEC_VERSION_MAJOR >= 53 ctx->input_size = ctx->acodec->channels * av_get_bits_per_sample_fmt(ctx->acodec->sample_fmt) / 8; #else ctx->input_size = ctx->acodec->channels * av_get_bits_per_sample_format(ctx->acodec->sample_fmt) / 8; #endif } ctx->duration = mfi->song_length; ctx->samples = mfi->sample_count; ctx->wavhdr = wavhdr; if (wavhdr) make_wav_header(ctx, est_size); return ctx; setup_fail_codec: avcodec_close(ctx->acodec); setup_fail: av_close_input_file(ctx->fmtctx); free(ctx); return NULL; } void transcode_cleanup(struct transcode_ctx *ctx) { if (ctx->apacket.data) av_free_packet(&ctx->apacket); avcodec_close(ctx->acodec); av_close_input_file(ctx->fmtctx); av_free(ctx->abuffer); if (ctx->need_resample) { audio_resample_close(ctx->resample_ctx); av_free(ctx->re_abuffer); } free(ctx); } int transcode_needed(struct http_request *req, char *file_codectype) { const char *client_codecs; const char *user_agent; char *codectype; cfg_t *lib; int size; int i; DPRINTF(E_DBG, L_XCODE, "Determining transcoding status for codectype %s\n", file_codectype); lib = cfg_getsec(cfg, "library"); size = cfg_size(lib, "no_transcode"); if (size > 0) { for (i = 0; i < size; i++) { codectype = cfg_getnstr(lib, "no_transcode", i); if (strcmp(file_codectype, codectype) == 0) { DPRINTF(E_DBG, L_XCODE, "Codectype is in no_transcode\n"); return 0; } } } size = cfg_size(lib, "force_transcode"); if (size > 0) { for (i = 0; i < size; i++) { codectype = cfg_getnstr(lib, "force_transcode", i); if (strcmp(file_codectype, codectype) == 0) { DPRINTF(E_DBG, L_XCODE, "Codectype is in force_transcode\n"); return 1; } } } client_codecs = http_request_get_header(req, "Accept-Codecs"); if (!client_codecs) { user_agent = http_request_get_header(req, "User-Agent"); if (user_agent) { DPRINTF(E_DBG, L_XCODE, "User-Agent: %s\n", user_agent); if (strncmp(user_agent, "iTunes", strlen("iTunes")) == 0) { DPRINTF(E_DBG, L_XCODE, "Client is iTunes\n"); client_codecs = itunes_codecs; } else if (strncmp(user_agent, "QuickTime", strlen("QuickTime")) == 0) { DPRINTF(E_DBG, L_XCODE, "Client is QuickTime, using iTunes codecs\n"); client_codecs = itunes_codecs; } else if (strncmp(user_agent, "Front%20Row", strlen("Front%20Row")) == 0) { DPRINTF(E_DBG, L_XCODE, "Client is Front Row, using iTunes codecs\n"); client_codecs = itunes_codecs; } else if (strncmp(user_agent, "Remote", strlen("Remote")) == 0) { DPRINTF(E_DBG, L_XCODE, "Client is Remote, using iTunes codecs\n"); client_codecs = itunes_codecs; } else if (strncmp(user_agent, "Roku", strlen("Roku")) == 0) { DPRINTF(E_DBG, L_XCODE, "Client is a Roku device\n"); client_codecs = roku_codecs; } else if (strncmp(user_agent, "Hifidelio", strlen("Hifidelio")) == 0) { DPRINTF(E_DBG, L_XCODE, "Client is a Hifidelio device, allegedly cannot transcode\n"); /* Allegedly can't transcode for Hifidelio because their * HTTP implementation doesn't honour Connection: close. * At least, that's why mt-daapd didn't do it. */ return 0; } } } else DPRINTF(E_DBG, L_XCODE, "Client advertises codecs: %s\n", client_codecs); if (!client_codecs) { DPRINTF(E_DBG, L_XCODE, "Could not identify client, using default codectype set\n"); client_codecs = default_codecs; } if (strstr(client_codecs, file_codectype)) { DPRINTF(E_DBG, L_XCODE, "Codectype supported by client, no transcoding needed\n"); return 0; } DPRINTF(E_DBG, L_XCODE, "Will transcode\n"); return 1; } forked-daapd-0.19gcd/src/transcode.h0000664000175000017500000000073711633141135016731 0ustar julienjulien #ifndef __TRANSCODE_H__ #define __TRANSCODE_H__ #include "http.h" struct transcode_ctx; int transcode(struct transcode_ctx *ctx, struct evbuffer *evbuf, int wanted); int transcode_seek(struct transcode_ctx *ctx, int ms); struct transcode_ctx * transcode_setup(struct media_file_info *mfi, off_t *est_size, int wavhdr); void transcode_cleanup(struct transcode_ctx *ctx); int transcode_needed(struct http_request *req, char *file_codectype); #endif /* !__TRANSCODE_H__ */ forked-daapd-0.19gcd/src/Makefile.in0000664000175000017500000031043211633141304016635 0ustar julienjulien# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ sbin_PROGRAMS = forked-daapd$(EXEEXT) @COND_ANTLR_TRUE@am__append_1 = $(ANTLR_SOURCES) @COND_ANTLR_TRUE@am__append_2 = \ @COND_ANTLR_TRUE@ $(ANTLR_PRODUCTS) \ @COND_ANTLR_TRUE@ $(ANTLR_GRAMMARS:.g=.u) subdir = src DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/blocks.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/libunistring.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(sbindir)" PROGRAMS = $(sbin_PROGRAMS) am__forked_daapd_SOURCES_DIST = main.c db.c db.h logger.c logger.h \ conffile.c conffile.h filescanner.c filescanner.h \ filescanner_ffmpeg.c filescanner_urlfile.c filescanner_m3u.c \ filescanner_itunes.c mdns_avahi.c mdns.h network.c network.h \ remote_pairing.c remote_pairing.h ffmpeg_url_evbuffer.c \ ffmpeg_url_evbuffer.h avio_evbuffer.c avio_evbuffer.h http.c \ http.h httpd.c httpd.h httpd_rsp.c httpd_rsp.h httpd_daap.c \ httpd_daap.h httpd_dacp.c httpd_dacp.h dmap_common.c \ dmap_common.h transcode.c transcode.h artwork.c artwork.h \ misc.c misc.h rng.c rng.h rsp_query.c rsp_query.h daap_query.c \ daap_query.h player.c player.h laudio_alsa.c laudio_oss4.c \ laudio.h raop.c raop.h evbuffer/evbuffer.c evbuffer/evbuffer.h \ scan-wma.c scan-flac.c scan-mpc.c @COND_ITUNES_TRUE@am__objects_1 = \ @COND_ITUNES_TRUE@ forked_daapd-filescanner_itunes.$(OBJEXT) @COND_AVIO_FALSE@am__objects_2 = \ @COND_AVIO_FALSE@ forked_daapd-ffmpeg_url_evbuffer.$(OBJEXT) @COND_AVIO_TRUE@am__objects_3 = forked_daapd-avio_evbuffer.$(OBJEXT) @COND_ALSA_TRUE@am__objects_4 = forked_daapd-laudio_alsa.$(OBJEXT) @COND_OSS4_TRUE@am__objects_5 = forked_daapd-laudio_oss4.$(OBJEXT) @COND_FLAC_TRUE@am__objects_6 = forked_daapd-scan-flac.$(OBJEXT) @COND_MUSEPACK_TRUE@am__objects_7 = forked_daapd-scan-mpc.$(OBJEXT) am_forked_daapd_OBJECTS = forked_daapd-main.$(OBJEXT) \ forked_daapd-db.$(OBJEXT) forked_daapd-logger.$(OBJEXT) \ forked_daapd-conffile.$(OBJEXT) \ forked_daapd-filescanner.$(OBJEXT) \ forked_daapd-filescanner_ffmpeg.$(OBJEXT) \ forked_daapd-filescanner_urlfile.$(OBJEXT) \ forked_daapd-filescanner_m3u.$(OBJEXT) $(am__objects_1) \ forked_daapd-mdns_avahi.$(OBJEXT) \ forked_daapd-network.$(OBJEXT) \ forked_daapd-remote_pairing.$(OBJEXT) $(am__objects_2) \ $(am__objects_3) forked_daapd-http.$(OBJEXT) \ forked_daapd-httpd.$(OBJEXT) forked_daapd-httpd_rsp.$(OBJEXT) \ forked_daapd-httpd_daap.$(OBJEXT) \ forked_daapd-httpd_dacp.$(OBJEXT) \ forked_daapd-dmap_common.$(OBJEXT) \ forked_daapd-transcode.$(OBJEXT) \ forked_daapd-artwork.$(OBJEXT) forked_daapd-misc.$(OBJEXT) \ forked_daapd-rng.$(OBJEXT) forked_daapd-rsp_query.$(OBJEXT) \ forked_daapd-daap_query.$(OBJEXT) \ forked_daapd-player.$(OBJEXT) $(am__objects_4) \ $(am__objects_5) forked_daapd-raop.$(OBJEXT) \ forked_daapd-evbuffer.$(OBJEXT) \ forked_daapd-scan-wma.$(OBJEXT) $(am__objects_6) \ $(am__objects_7) am__objects_8 = forked_daapd-RSPLexer.$(OBJEXT) \ forked_daapd-RSPParser.$(OBJEXT) \ forked_daapd-RSP2SQL.$(OBJEXT) \ forked_daapd-DAAPLexer.$(OBJEXT) \ forked_daapd-DAAPParser.$(OBJEXT) \ forked_daapd-DAAP2SQL.$(OBJEXT) nodist_forked_daapd_OBJECTS = $(am__objects_8) forked_daapd_OBJECTS = $(am_forked_daapd_OBJECTS) \ $(nodist_forked_daapd_OBJECTS) forked_daapd_DEPENDENCIES = forked_daapd_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(forked_daapd_CFLAGS) \ $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(forked_daapd_SOURCES) $(nodist_forked_daapd_SOURCES) DIST_SOURCES = $(am__forked_daapd_SOURCES_DIST) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALSA_CFLAGS = @ALSA_CFLAGS@ ALSA_LIBS = @ALSA_LIBS@ AMTAR = @AMTAR@ ANTLR = @ANTLR@ ANTLR3C_LIBS = @ANTLR3C_LIBS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ CBLOCKS_FLAGS = @CBLOCKS_FLAGS@ CBLOCKS_LIBS = @CBLOCKS_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFUSE_CFLAGS = @CONFUSE_CFLAGS@ CONFUSE_LIBS = @CONFUSE_LIBS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FLAC_CFLAGS = @FLAC_CFLAGS@ FLAC_LIBS = @FLAC_LIBS@ GPERF = @GPERF@ GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@ GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@ GPG_ERROR_LIBS = @GPG_ERROR_LIBS@ GREP = @GREP@ HAVE_LIBUNISTRING = @HAVE_LIBUNISTRING@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBAVL_LIBS = @LIBAVL_LIBS@ LIBAV_CFLAGS = @LIBAV_CFLAGS@ LIBAV_LIBS = @LIBAV_LIBS@ LIBDISPATCH_LIBS = @LIBDISPATCH_LIBS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBPLIST_CFLAGS = @LIBPLIST_CFLAGS@ LIBPLIST_LIBS = @LIBPLIST_LIBS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBUNISTRING = @LIBUNISTRING@ LIBUNISTRING_PREFIX = @LIBUNISTRING_PREFIX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LTLIBUNISTRING = @LTLIBUNISTRING@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINIXML_CFLAGS = @MINIXML_CFLAGS@ MINIXML_LIBS = @MINIXML_LIBS@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OSS4CPPFLAGS = @OSS4CPPFLAGS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ TAGLIB_CFLAGS = @TAGLIB_CFLAGS@ TAGLIB_LIBS = @TAGLIB_LIBS@ TRE_CFLAGS = @TRE_CFLAGS@ TRE_LIBS = @TRE_LIBS@ VERSION = @VERSION@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @COND_FLAC_TRUE@FLACSRC = scan-flac.c @COND_MUSEPACK_TRUE@MUSEPACKSRC = scan-mpc.c @COND_ITUNES_TRUE@ITUNESSRC = filescanner_itunes.c @COND_ALSA_TRUE@ALSASRC = laudio_alsa.c @COND_OSS4_TRUE@OSS4SRC = laudio_oss4.c @COND_AVIO_TRUE@AVIO_SRC = avio_evbuffer.c avio_evbuffer.h @COND_AVIO_FALSE@FFURL_SRC = ffmpeg_url_evbuffer.c ffmpeg_url_evbuffer.h GPERF_FILES = \ daap_query.gperf \ rsp_query.gperf \ dacp_prop.gperf \ dmap_fields.gperf GPERF_PRODUCTS = \ daap_query_hash.c \ rsp_query_hash.c \ dacp_prop_hash.c \ dmap_fields_hash.c ANTLR_GRAMMARS = \ RSP.g RSP2SQL.g \ DAAP.g DAAP2SQL.g ANTLR_SOURCES = \ RSPLexer.c RSPLexer.h RSPParser.c RSPParser.h \ RSP2SQL.c RSP2SQL.h \ DAAPLexer.c DAAPLexer.h DAAPParser.c DAAPParser.h \ DAAP2SQL.c DAAP2SQL.h ANTLR_PRODUCTS = forked_daapd_CPPFLAGS = -D_GNU_SOURCE \ -DDATADIR="\"$(pkgdatadir)\"" -DCONFDIR="\"$(sysconfdir)\"" \ -DSTATEDIR="\"$(localstatedir)\"" -DPKGLIBDIR="\"$(pkglibdir)\"" \ @OSS4CPPFLAGS@ forked_daapd_CFLAGS = @CBLOCKS_FLAGS@ \ @ZLIB_CFLAGS@ @AVAHI_CFLAGS@ @SQLITE3_CFLAGS@ @LIBAV_CFLAGS@ \ @CONFUSE_CFLAGS@ @TAGLIB_CFLAGS@ @MINIXML_CFLAGS@ @LIBPLIST_CFLAGS@ \ @LIBGCRYPT_CFLAGS@ @GPG_ERROR_CFLAGS@ @ALSA_CFLAGS@ @TRE_CFLAGS@ forked_daapd_LDADD = -lrt \ @ZLIB_LIBS@ @AVAHI_LIBS@ @SQLITE3_LIBS@ @LIBAV_LIBS@ \ @CONFUSE_LIBS@ @FLAC_LIBS@ @TAGLIB_LIBS@ \ @LIBAVL_LIBS@ @MINIXML_LIBS@ @ANTLR3C_LIBS@ @LIBPLIST_LIBS@ \ @LIBGCRYPT_LIBS@ @GPG_ERROR_LIBS@ @ALSA_LIBS@ @LIBUNISTRING@ \ @LIBDISPATCH_LIBS@ @CBLOCKS_LIBS@ @TRE_LIBS@ forked_daapd_SOURCES = main.c \ db.c db.h \ logger.c logger.h \ conffile.c conffile.h \ filescanner.c filescanner.h \ filescanner_ffmpeg.c filescanner_urlfile.c filescanner_m3u.c $(ITUNESSRC) \ mdns_avahi.c mdns.h \ network.c network.h \ remote_pairing.c remote_pairing.h \ $(FFURL_SRC) $(AVIO_SRC) \ http.c http.h \ httpd.c httpd.h \ httpd_rsp.c httpd_rsp.h \ httpd_daap.c httpd_daap.h \ httpd_dacp.c httpd_dacp.h \ dmap_common.c dmap_common.h \ transcode.c transcode.h \ artwork.c artwork.h \ misc.c misc.h \ rng.c rng.h \ rsp_query.c rsp_query.h \ daap_query.c daap_query.h \ player.c player.h \ $(ALSASRC) $(OSS4SRC) laudio.h \ raop.c raop.h \ evbuffer/evbuffer.c evbuffer/evbuffer.h \ scan-wma.c \ $(FLACSRC) $(MUSEPACKSRC) nodist_forked_daapd_SOURCES = \ $(ANTLR_SOURCES) BUILT_SOURCES = $(GPERF_PRODUCTS) $(am__append_1) EXTRA_DIST = \ $(ANTLR_GRAMMARS) \ scan-mpc.c \ scan-flac.c CLEANFILES = $(GPERF_PRODUCTS) $(am__append_2) # Support for building the parsers when ANTLR3 is available @COND_ANTLR_TRUE@SUFFIXES = .g .u @COND_ANTLR_FALSE@DISTCLEANFILES = \ @COND_ANTLR_FALSE@ $(ANTLR_PRODUCTS) \ @COND_ANTLR_FALSE@ $(ANTLR_GRAMMARS:.g=.u) all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-am .SUFFIXES: .SUFFIXES: .g .u .c .lo .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu src/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-sbinPROGRAMS: $(sbin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(sbindir)" || $(MKDIR_P) "$(DESTDIR)$(sbindir)" @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p || test -f $$p1; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(sbindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(sbindir)$$dir" || exit $$?; \ } \ ; done uninstall-sbinPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(sbin_PROGRAMS)'; test -n "$(sbindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(sbindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(sbindir)" && rm -f $$files clean-sbinPROGRAMS: @list='$(sbin_PROGRAMS)'; test -n "$$list" || exit 0; \ echo " rm -f" $$list; \ rm -f $$list || exit $$?; \ test -n "$(EXEEXT)" || exit 0; \ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \ echo " rm -f" $$list; \ rm -f $$list forked-daapd$(EXEEXT): $(forked_daapd_OBJECTS) $(forked_daapd_DEPENDENCIES) @rm -f forked-daapd$(EXEEXT) $(forked_daapd_LINK) $(forked_daapd_OBJECTS) $(forked_daapd_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-DAAP2SQL.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-DAAPLexer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-DAAPParser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-RSP2SQL.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-RSPLexer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-RSPParser.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-artwork.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-avio_evbuffer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-conffile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-daap_query.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-db.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-dmap_common.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-evbuffer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-ffmpeg_url_evbuffer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-filescanner.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-filescanner_ffmpeg.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-filescanner_itunes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-filescanner_m3u.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-filescanner_urlfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-http.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-httpd.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-httpd_daap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-httpd_dacp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-httpd_rsp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-laudio_alsa.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-laudio_oss4.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-logger.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-mdns_avahi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-misc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-network.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-player.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-raop.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-remote_pairing.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-rng.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-rsp_query.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-scan-flac.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-scan-mpc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-scan-wma.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/forked_daapd-transcode.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .c.lo: @am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< forked_daapd-main.o: main.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-main.o -MD -MP -MF $(DEPDIR)/forked_daapd-main.Tpo -c -o forked_daapd-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-main.Tpo $(DEPDIR)/forked_daapd-main.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='forked_daapd-main.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c forked_daapd-main.obj: main.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-main.obj -MD -MP -MF $(DEPDIR)/forked_daapd-main.Tpo -c -o forked_daapd-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-main.Tpo $(DEPDIR)/forked_daapd-main.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='main.c' object='forked_daapd-main.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi` forked_daapd-db.o: db.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-db.o -MD -MP -MF $(DEPDIR)/forked_daapd-db.Tpo -c -o forked_daapd-db.o `test -f 'db.c' || echo '$(srcdir)/'`db.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-db.Tpo $(DEPDIR)/forked_daapd-db.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='db.c' object='forked_daapd-db.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-db.o `test -f 'db.c' || echo '$(srcdir)/'`db.c forked_daapd-db.obj: db.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-db.obj -MD -MP -MF $(DEPDIR)/forked_daapd-db.Tpo -c -o forked_daapd-db.obj `if test -f 'db.c'; then $(CYGPATH_W) 'db.c'; else $(CYGPATH_W) '$(srcdir)/db.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-db.Tpo $(DEPDIR)/forked_daapd-db.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='db.c' object='forked_daapd-db.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-db.obj `if test -f 'db.c'; then $(CYGPATH_W) 'db.c'; else $(CYGPATH_W) '$(srcdir)/db.c'; fi` forked_daapd-logger.o: logger.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-logger.o -MD -MP -MF $(DEPDIR)/forked_daapd-logger.Tpo -c -o forked_daapd-logger.o `test -f 'logger.c' || echo '$(srcdir)/'`logger.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-logger.Tpo $(DEPDIR)/forked_daapd-logger.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='logger.c' object='forked_daapd-logger.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-logger.o `test -f 'logger.c' || echo '$(srcdir)/'`logger.c forked_daapd-logger.obj: logger.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-logger.obj -MD -MP -MF $(DEPDIR)/forked_daapd-logger.Tpo -c -o forked_daapd-logger.obj `if test -f 'logger.c'; then $(CYGPATH_W) 'logger.c'; else $(CYGPATH_W) '$(srcdir)/logger.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-logger.Tpo $(DEPDIR)/forked_daapd-logger.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='logger.c' object='forked_daapd-logger.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-logger.obj `if test -f 'logger.c'; then $(CYGPATH_W) 'logger.c'; else $(CYGPATH_W) '$(srcdir)/logger.c'; fi` forked_daapd-conffile.o: conffile.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-conffile.o -MD -MP -MF $(DEPDIR)/forked_daapd-conffile.Tpo -c -o forked_daapd-conffile.o `test -f 'conffile.c' || echo '$(srcdir)/'`conffile.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-conffile.Tpo $(DEPDIR)/forked_daapd-conffile.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='conffile.c' object='forked_daapd-conffile.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-conffile.o `test -f 'conffile.c' || echo '$(srcdir)/'`conffile.c forked_daapd-conffile.obj: conffile.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-conffile.obj -MD -MP -MF $(DEPDIR)/forked_daapd-conffile.Tpo -c -o forked_daapd-conffile.obj `if test -f 'conffile.c'; then $(CYGPATH_W) 'conffile.c'; else $(CYGPATH_W) '$(srcdir)/conffile.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-conffile.Tpo $(DEPDIR)/forked_daapd-conffile.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='conffile.c' object='forked_daapd-conffile.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-conffile.obj `if test -f 'conffile.c'; then $(CYGPATH_W) 'conffile.c'; else $(CYGPATH_W) '$(srcdir)/conffile.c'; fi` forked_daapd-filescanner.o: filescanner.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-filescanner.o -MD -MP -MF $(DEPDIR)/forked_daapd-filescanner.Tpo -c -o forked_daapd-filescanner.o `test -f 'filescanner.c' || echo '$(srcdir)/'`filescanner.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-filescanner.Tpo $(DEPDIR)/forked_daapd-filescanner.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filescanner.c' object='forked_daapd-filescanner.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-filescanner.o `test -f 'filescanner.c' || echo '$(srcdir)/'`filescanner.c forked_daapd-filescanner.obj: filescanner.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-filescanner.obj -MD -MP -MF $(DEPDIR)/forked_daapd-filescanner.Tpo -c -o forked_daapd-filescanner.obj `if test -f 'filescanner.c'; then $(CYGPATH_W) 'filescanner.c'; else $(CYGPATH_W) '$(srcdir)/filescanner.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-filescanner.Tpo $(DEPDIR)/forked_daapd-filescanner.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filescanner.c' object='forked_daapd-filescanner.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-filescanner.obj `if test -f 'filescanner.c'; then $(CYGPATH_W) 'filescanner.c'; else $(CYGPATH_W) '$(srcdir)/filescanner.c'; fi` forked_daapd-filescanner_ffmpeg.o: filescanner_ffmpeg.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-filescanner_ffmpeg.o -MD -MP -MF $(DEPDIR)/forked_daapd-filescanner_ffmpeg.Tpo -c -o forked_daapd-filescanner_ffmpeg.o `test -f 'filescanner_ffmpeg.c' || echo '$(srcdir)/'`filescanner_ffmpeg.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-filescanner_ffmpeg.Tpo $(DEPDIR)/forked_daapd-filescanner_ffmpeg.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filescanner_ffmpeg.c' object='forked_daapd-filescanner_ffmpeg.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-filescanner_ffmpeg.o `test -f 'filescanner_ffmpeg.c' || echo '$(srcdir)/'`filescanner_ffmpeg.c forked_daapd-filescanner_ffmpeg.obj: filescanner_ffmpeg.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-filescanner_ffmpeg.obj -MD -MP -MF $(DEPDIR)/forked_daapd-filescanner_ffmpeg.Tpo -c -o forked_daapd-filescanner_ffmpeg.obj `if test -f 'filescanner_ffmpeg.c'; then $(CYGPATH_W) 'filescanner_ffmpeg.c'; else $(CYGPATH_W) '$(srcdir)/filescanner_ffmpeg.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-filescanner_ffmpeg.Tpo $(DEPDIR)/forked_daapd-filescanner_ffmpeg.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filescanner_ffmpeg.c' object='forked_daapd-filescanner_ffmpeg.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-filescanner_ffmpeg.obj `if test -f 'filescanner_ffmpeg.c'; then $(CYGPATH_W) 'filescanner_ffmpeg.c'; else $(CYGPATH_W) '$(srcdir)/filescanner_ffmpeg.c'; fi` forked_daapd-filescanner_urlfile.o: filescanner_urlfile.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-filescanner_urlfile.o -MD -MP -MF $(DEPDIR)/forked_daapd-filescanner_urlfile.Tpo -c -o forked_daapd-filescanner_urlfile.o `test -f 'filescanner_urlfile.c' || echo '$(srcdir)/'`filescanner_urlfile.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-filescanner_urlfile.Tpo $(DEPDIR)/forked_daapd-filescanner_urlfile.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filescanner_urlfile.c' object='forked_daapd-filescanner_urlfile.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-filescanner_urlfile.o `test -f 'filescanner_urlfile.c' || echo '$(srcdir)/'`filescanner_urlfile.c forked_daapd-filescanner_urlfile.obj: filescanner_urlfile.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-filescanner_urlfile.obj -MD -MP -MF $(DEPDIR)/forked_daapd-filescanner_urlfile.Tpo -c -o forked_daapd-filescanner_urlfile.obj `if test -f 'filescanner_urlfile.c'; then $(CYGPATH_W) 'filescanner_urlfile.c'; else $(CYGPATH_W) '$(srcdir)/filescanner_urlfile.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-filescanner_urlfile.Tpo $(DEPDIR)/forked_daapd-filescanner_urlfile.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filescanner_urlfile.c' object='forked_daapd-filescanner_urlfile.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-filescanner_urlfile.obj `if test -f 'filescanner_urlfile.c'; then $(CYGPATH_W) 'filescanner_urlfile.c'; else $(CYGPATH_W) '$(srcdir)/filescanner_urlfile.c'; fi` forked_daapd-filescanner_m3u.o: filescanner_m3u.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-filescanner_m3u.o -MD -MP -MF $(DEPDIR)/forked_daapd-filescanner_m3u.Tpo -c -o forked_daapd-filescanner_m3u.o `test -f 'filescanner_m3u.c' || echo '$(srcdir)/'`filescanner_m3u.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-filescanner_m3u.Tpo $(DEPDIR)/forked_daapd-filescanner_m3u.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filescanner_m3u.c' object='forked_daapd-filescanner_m3u.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-filescanner_m3u.o `test -f 'filescanner_m3u.c' || echo '$(srcdir)/'`filescanner_m3u.c forked_daapd-filescanner_m3u.obj: filescanner_m3u.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-filescanner_m3u.obj -MD -MP -MF $(DEPDIR)/forked_daapd-filescanner_m3u.Tpo -c -o forked_daapd-filescanner_m3u.obj `if test -f 'filescanner_m3u.c'; then $(CYGPATH_W) 'filescanner_m3u.c'; else $(CYGPATH_W) '$(srcdir)/filescanner_m3u.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-filescanner_m3u.Tpo $(DEPDIR)/forked_daapd-filescanner_m3u.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filescanner_m3u.c' object='forked_daapd-filescanner_m3u.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-filescanner_m3u.obj `if test -f 'filescanner_m3u.c'; then $(CYGPATH_W) 'filescanner_m3u.c'; else $(CYGPATH_W) '$(srcdir)/filescanner_m3u.c'; fi` forked_daapd-filescanner_itunes.o: filescanner_itunes.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-filescanner_itunes.o -MD -MP -MF $(DEPDIR)/forked_daapd-filescanner_itunes.Tpo -c -o forked_daapd-filescanner_itunes.o `test -f 'filescanner_itunes.c' || echo '$(srcdir)/'`filescanner_itunes.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-filescanner_itunes.Tpo $(DEPDIR)/forked_daapd-filescanner_itunes.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filescanner_itunes.c' object='forked_daapd-filescanner_itunes.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-filescanner_itunes.o `test -f 'filescanner_itunes.c' || echo '$(srcdir)/'`filescanner_itunes.c forked_daapd-filescanner_itunes.obj: filescanner_itunes.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-filescanner_itunes.obj -MD -MP -MF $(DEPDIR)/forked_daapd-filescanner_itunes.Tpo -c -o forked_daapd-filescanner_itunes.obj `if test -f 'filescanner_itunes.c'; then $(CYGPATH_W) 'filescanner_itunes.c'; else $(CYGPATH_W) '$(srcdir)/filescanner_itunes.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-filescanner_itunes.Tpo $(DEPDIR)/forked_daapd-filescanner_itunes.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='filescanner_itunes.c' object='forked_daapd-filescanner_itunes.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-filescanner_itunes.obj `if test -f 'filescanner_itunes.c'; then $(CYGPATH_W) 'filescanner_itunes.c'; else $(CYGPATH_W) '$(srcdir)/filescanner_itunes.c'; fi` forked_daapd-mdns_avahi.o: mdns_avahi.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-mdns_avahi.o -MD -MP -MF $(DEPDIR)/forked_daapd-mdns_avahi.Tpo -c -o forked_daapd-mdns_avahi.o `test -f 'mdns_avahi.c' || echo '$(srcdir)/'`mdns_avahi.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-mdns_avahi.Tpo $(DEPDIR)/forked_daapd-mdns_avahi.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mdns_avahi.c' object='forked_daapd-mdns_avahi.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-mdns_avahi.o `test -f 'mdns_avahi.c' || echo '$(srcdir)/'`mdns_avahi.c forked_daapd-mdns_avahi.obj: mdns_avahi.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-mdns_avahi.obj -MD -MP -MF $(DEPDIR)/forked_daapd-mdns_avahi.Tpo -c -o forked_daapd-mdns_avahi.obj `if test -f 'mdns_avahi.c'; then $(CYGPATH_W) 'mdns_avahi.c'; else $(CYGPATH_W) '$(srcdir)/mdns_avahi.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-mdns_avahi.Tpo $(DEPDIR)/forked_daapd-mdns_avahi.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='mdns_avahi.c' object='forked_daapd-mdns_avahi.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-mdns_avahi.obj `if test -f 'mdns_avahi.c'; then $(CYGPATH_W) 'mdns_avahi.c'; else $(CYGPATH_W) '$(srcdir)/mdns_avahi.c'; fi` forked_daapd-network.o: network.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-network.o -MD -MP -MF $(DEPDIR)/forked_daapd-network.Tpo -c -o forked_daapd-network.o `test -f 'network.c' || echo '$(srcdir)/'`network.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-network.Tpo $(DEPDIR)/forked_daapd-network.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='network.c' object='forked_daapd-network.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-network.o `test -f 'network.c' || echo '$(srcdir)/'`network.c forked_daapd-network.obj: network.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-network.obj -MD -MP -MF $(DEPDIR)/forked_daapd-network.Tpo -c -o forked_daapd-network.obj `if test -f 'network.c'; then $(CYGPATH_W) 'network.c'; else $(CYGPATH_W) '$(srcdir)/network.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-network.Tpo $(DEPDIR)/forked_daapd-network.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='network.c' object='forked_daapd-network.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-network.obj `if test -f 'network.c'; then $(CYGPATH_W) 'network.c'; else $(CYGPATH_W) '$(srcdir)/network.c'; fi` forked_daapd-remote_pairing.o: remote_pairing.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-remote_pairing.o -MD -MP -MF $(DEPDIR)/forked_daapd-remote_pairing.Tpo -c -o forked_daapd-remote_pairing.o `test -f 'remote_pairing.c' || echo '$(srcdir)/'`remote_pairing.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-remote_pairing.Tpo $(DEPDIR)/forked_daapd-remote_pairing.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='remote_pairing.c' object='forked_daapd-remote_pairing.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-remote_pairing.o `test -f 'remote_pairing.c' || echo '$(srcdir)/'`remote_pairing.c forked_daapd-remote_pairing.obj: remote_pairing.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-remote_pairing.obj -MD -MP -MF $(DEPDIR)/forked_daapd-remote_pairing.Tpo -c -o forked_daapd-remote_pairing.obj `if test -f 'remote_pairing.c'; then $(CYGPATH_W) 'remote_pairing.c'; else $(CYGPATH_W) '$(srcdir)/remote_pairing.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-remote_pairing.Tpo $(DEPDIR)/forked_daapd-remote_pairing.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='remote_pairing.c' object='forked_daapd-remote_pairing.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-remote_pairing.obj `if test -f 'remote_pairing.c'; then $(CYGPATH_W) 'remote_pairing.c'; else $(CYGPATH_W) '$(srcdir)/remote_pairing.c'; fi` forked_daapd-ffmpeg_url_evbuffer.o: ffmpeg_url_evbuffer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-ffmpeg_url_evbuffer.o -MD -MP -MF $(DEPDIR)/forked_daapd-ffmpeg_url_evbuffer.Tpo -c -o forked_daapd-ffmpeg_url_evbuffer.o `test -f 'ffmpeg_url_evbuffer.c' || echo '$(srcdir)/'`ffmpeg_url_evbuffer.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-ffmpeg_url_evbuffer.Tpo $(DEPDIR)/forked_daapd-ffmpeg_url_evbuffer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ffmpeg_url_evbuffer.c' object='forked_daapd-ffmpeg_url_evbuffer.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-ffmpeg_url_evbuffer.o `test -f 'ffmpeg_url_evbuffer.c' || echo '$(srcdir)/'`ffmpeg_url_evbuffer.c forked_daapd-ffmpeg_url_evbuffer.obj: ffmpeg_url_evbuffer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-ffmpeg_url_evbuffer.obj -MD -MP -MF $(DEPDIR)/forked_daapd-ffmpeg_url_evbuffer.Tpo -c -o forked_daapd-ffmpeg_url_evbuffer.obj `if test -f 'ffmpeg_url_evbuffer.c'; then $(CYGPATH_W) 'ffmpeg_url_evbuffer.c'; else $(CYGPATH_W) '$(srcdir)/ffmpeg_url_evbuffer.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-ffmpeg_url_evbuffer.Tpo $(DEPDIR)/forked_daapd-ffmpeg_url_evbuffer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ffmpeg_url_evbuffer.c' object='forked_daapd-ffmpeg_url_evbuffer.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-ffmpeg_url_evbuffer.obj `if test -f 'ffmpeg_url_evbuffer.c'; then $(CYGPATH_W) 'ffmpeg_url_evbuffer.c'; else $(CYGPATH_W) '$(srcdir)/ffmpeg_url_evbuffer.c'; fi` forked_daapd-avio_evbuffer.o: avio_evbuffer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-avio_evbuffer.o -MD -MP -MF $(DEPDIR)/forked_daapd-avio_evbuffer.Tpo -c -o forked_daapd-avio_evbuffer.o `test -f 'avio_evbuffer.c' || echo '$(srcdir)/'`avio_evbuffer.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-avio_evbuffer.Tpo $(DEPDIR)/forked_daapd-avio_evbuffer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='avio_evbuffer.c' object='forked_daapd-avio_evbuffer.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-avio_evbuffer.o `test -f 'avio_evbuffer.c' || echo '$(srcdir)/'`avio_evbuffer.c forked_daapd-avio_evbuffer.obj: avio_evbuffer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-avio_evbuffer.obj -MD -MP -MF $(DEPDIR)/forked_daapd-avio_evbuffer.Tpo -c -o forked_daapd-avio_evbuffer.obj `if test -f 'avio_evbuffer.c'; then $(CYGPATH_W) 'avio_evbuffer.c'; else $(CYGPATH_W) '$(srcdir)/avio_evbuffer.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-avio_evbuffer.Tpo $(DEPDIR)/forked_daapd-avio_evbuffer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='avio_evbuffer.c' object='forked_daapd-avio_evbuffer.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-avio_evbuffer.obj `if test -f 'avio_evbuffer.c'; then $(CYGPATH_W) 'avio_evbuffer.c'; else $(CYGPATH_W) '$(srcdir)/avio_evbuffer.c'; fi` forked_daapd-http.o: http.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-http.o -MD -MP -MF $(DEPDIR)/forked_daapd-http.Tpo -c -o forked_daapd-http.o `test -f 'http.c' || echo '$(srcdir)/'`http.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-http.Tpo $(DEPDIR)/forked_daapd-http.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='http.c' object='forked_daapd-http.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-http.o `test -f 'http.c' || echo '$(srcdir)/'`http.c forked_daapd-http.obj: http.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-http.obj -MD -MP -MF $(DEPDIR)/forked_daapd-http.Tpo -c -o forked_daapd-http.obj `if test -f 'http.c'; then $(CYGPATH_W) 'http.c'; else $(CYGPATH_W) '$(srcdir)/http.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-http.Tpo $(DEPDIR)/forked_daapd-http.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='http.c' object='forked_daapd-http.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-http.obj `if test -f 'http.c'; then $(CYGPATH_W) 'http.c'; else $(CYGPATH_W) '$(srcdir)/http.c'; fi` forked_daapd-httpd.o: httpd.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-httpd.o -MD -MP -MF $(DEPDIR)/forked_daapd-httpd.Tpo -c -o forked_daapd-httpd.o `test -f 'httpd.c' || echo '$(srcdir)/'`httpd.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-httpd.Tpo $(DEPDIR)/forked_daapd-httpd.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='httpd.c' object='forked_daapd-httpd.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-httpd.o `test -f 'httpd.c' || echo '$(srcdir)/'`httpd.c forked_daapd-httpd.obj: httpd.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-httpd.obj -MD -MP -MF $(DEPDIR)/forked_daapd-httpd.Tpo -c -o forked_daapd-httpd.obj `if test -f 'httpd.c'; then $(CYGPATH_W) 'httpd.c'; else $(CYGPATH_W) '$(srcdir)/httpd.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-httpd.Tpo $(DEPDIR)/forked_daapd-httpd.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='httpd.c' object='forked_daapd-httpd.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-httpd.obj `if test -f 'httpd.c'; then $(CYGPATH_W) 'httpd.c'; else $(CYGPATH_W) '$(srcdir)/httpd.c'; fi` forked_daapd-httpd_rsp.o: httpd_rsp.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-httpd_rsp.o -MD -MP -MF $(DEPDIR)/forked_daapd-httpd_rsp.Tpo -c -o forked_daapd-httpd_rsp.o `test -f 'httpd_rsp.c' || echo '$(srcdir)/'`httpd_rsp.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-httpd_rsp.Tpo $(DEPDIR)/forked_daapd-httpd_rsp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='httpd_rsp.c' object='forked_daapd-httpd_rsp.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-httpd_rsp.o `test -f 'httpd_rsp.c' || echo '$(srcdir)/'`httpd_rsp.c forked_daapd-httpd_rsp.obj: httpd_rsp.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-httpd_rsp.obj -MD -MP -MF $(DEPDIR)/forked_daapd-httpd_rsp.Tpo -c -o forked_daapd-httpd_rsp.obj `if test -f 'httpd_rsp.c'; then $(CYGPATH_W) 'httpd_rsp.c'; else $(CYGPATH_W) '$(srcdir)/httpd_rsp.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-httpd_rsp.Tpo $(DEPDIR)/forked_daapd-httpd_rsp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='httpd_rsp.c' object='forked_daapd-httpd_rsp.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-httpd_rsp.obj `if test -f 'httpd_rsp.c'; then $(CYGPATH_W) 'httpd_rsp.c'; else $(CYGPATH_W) '$(srcdir)/httpd_rsp.c'; fi` forked_daapd-httpd_daap.o: httpd_daap.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-httpd_daap.o -MD -MP -MF $(DEPDIR)/forked_daapd-httpd_daap.Tpo -c -o forked_daapd-httpd_daap.o `test -f 'httpd_daap.c' || echo '$(srcdir)/'`httpd_daap.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-httpd_daap.Tpo $(DEPDIR)/forked_daapd-httpd_daap.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='httpd_daap.c' object='forked_daapd-httpd_daap.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-httpd_daap.o `test -f 'httpd_daap.c' || echo '$(srcdir)/'`httpd_daap.c forked_daapd-httpd_daap.obj: httpd_daap.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-httpd_daap.obj -MD -MP -MF $(DEPDIR)/forked_daapd-httpd_daap.Tpo -c -o forked_daapd-httpd_daap.obj `if test -f 'httpd_daap.c'; then $(CYGPATH_W) 'httpd_daap.c'; else $(CYGPATH_W) '$(srcdir)/httpd_daap.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-httpd_daap.Tpo $(DEPDIR)/forked_daapd-httpd_daap.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='httpd_daap.c' object='forked_daapd-httpd_daap.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-httpd_daap.obj `if test -f 'httpd_daap.c'; then $(CYGPATH_W) 'httpd_daap.c'; else $(CYGPATH_W) '$(srcdir)/httpd_daap.c'; fi` forked_daapd-httpd_dacp.o: httpd_dacp.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-httpd_dacp.o -MD -MP -MF $(DEPDIR)/forked_daapd-httpd_dacp.Tpo -c -o forked_daapd-httpd_dacp.o `test -f 'httpd_dacp.c' || echo '$(srcdir)/'`httpd_dacp.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-httpd_dacp.Tpo $(DEPDIR)/forked_daapd-httpd_dacp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='httpd_dacp.c' object='forked_daapd-httpd_dacp.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-httpd_dacp.o `test -f 'httpd_dacp.c' || echo '$(srcdir)/'`httpd_dacp.c forked_daapd-httpd_dacp.obj: httpd_dacp.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-httpd_dacp.obj -MD -MP -MF $(DEPDIR)/forked_daapd-httpd_dacp.Tpo -c -o forked_daapd-httpd_dacp.obj `if test -f 'httpd_dacp.c'; then $(CYGPATH_W) 'httpd_dacp.c'; else $(CYGPATH_W) '$(srcdir)/httpd_dacp.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-httpd_dacp.Tpo $(DEPDIR)/forked_daapd-httpd_dacp.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='httpd_dacp.c' object='forked_daapd-httpd_dacp.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-httpd_dacp.obj `if test -f 'httpd_dacp.c'; then $(CYGPATH_W) 'httpd_dacp.c'; else $(CYGPATH_W) '$(srcdir)/httpd_dacp.c'; fi` forked_daapd-dmap_common.o: dmap_common.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-dmap_common.o -MD -MP -MF $(DEPDIR)/forked_daapd-dmap_common.Tpo -c -o forked_daapd-dmap_common.o `test -f 'dmap_common.c' || echo '$(srcdir)/'`dmap_common.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-dmap_common.Tpo $(DEPDIR)/forked_daapd-dmap_common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dmap_common.c' object='forked_daapd-dmap_common.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-dmap_common.o `test -f 'dmap_common.c' || echo '$(srcdir)/'`dmap_common.c forked_daapd-dmap_common.obj: dmap_common.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-dmap_common.obj -MD -MP -MF $(DEPDIR)/forked_daapd-dmap_common.Tpo -c -o forked_daapd-dmap_common.obj `if test -f 'dmap_common.c'; then $(CYGPATH_W) 'dmap_common.c'; else $(CYGPATH_W) '$(srcdir)/dmap_common.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-dmap_common.Tpo $(DEPDIR)/forked_daapd-dmap_common.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='dmap_common.c' object='forked_daapd-dmap_common.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-dmap_common.obj `if test -f 'dmap_common.c'; then $(CYGPATH_W) 'dmap_common.c'; else $(CYGPATH_W) '$(srcdir)/dmap_common.c'; fi` forked_daapd-transcode.o: transcode.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-transcode.o -MD -MP -MF $(DEPDIR)/forked_daapd-transcode.Tpo -c -o forked_daapd-transcode.o `test -f 'transcode.c' || echo '$(srcdir)/'`transcode.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-transcode.Tpo $(DEPDIR)/forked_daapd-transcode.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='transcode.c' object='forked_daapd-transcode.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-transcode.o `test -f 'transcode.c' || echo '$(srcdir)/'`transcode.c forked_daapd-transcode.obj: transcode.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-transcode.obj -MD -MP -MF $(DEPDIR)/forked_daapd-transcode.Tpo -c -o forked_daapd-transcode.obj `if test -f 'transcode.c'; then $(CYGPATH_W) 'transcode.c'; else $(CYGPATH_W) '$(srcdir)/transcode.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-transcode.Tpo $(DEPDIR)/forked_daapd-transcode.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='transcode.c' object='forked_daapd-transcode.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-transcode.obj `if test -f 'transcode.c'; then $(CYGPATH_W) 'transcode.c'; else $(CYGPATH_W) '$(srcdir)/transcode.c'; fi` forked_daapd-artwork.o: artwork.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-artwork.o -MD -MP -MF $(DEPDIR)/forked_daapd-artwork.Tpo -c -o forked_daapd-artwork.o `test -f 'artwork.c' || echo '$(srcdir)/'`artwork.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-artwork.Tpo $(DEPDIR)/forked_daapd-artwork.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='artwork.c' object='forked_daapd-artwork.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-artwork.o `test -f 'artwork.c' || echo '$(srcdir)/'`artwork.c forked_daapd-artwork.obj: artwork.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-artwork.obj -MD -MP -MF $(DEPDIR)/forked_daapd-artwork.Tpo -c -o forked_daapd-artwork.obj `if test -f 'artwork.c'; then $(CYGPATH_W) 'artwork.c'; else $(CYGPATH_W) '$(srcdir)/artwork.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-artwork.Tpo $(DEPDIR)/forked_daapd-artwork.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='artwork.c' object='forked_daapd-artwork.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-artwork.obj `if test -f 'artwork.c'; then $(CYGPATH_W) 'artwork.c'; else $(CYGPATH_W) '$(srcdir)/artwork.c'; fi` forked_daapd-misc.o: misc.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-misc.o -MD -MP -MF $(DEPDIR)/forked_daapd-misc.Tpo -c -o forked_daapd-misc.o `test -f 'misc.c' || echo '$(srcdir)/'`misc.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-misc.Tpo $(DEPDIR)/forked_daapd-misc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='forked_daapd-misc.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-misc.o `test -f 'misc.c' || echo '$(srcdir)/'`misc.c forked_daapd-misc.obj: misc.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-misc.obj -MD -MP -MF $(DEPDIR)/forked_daapd-misc.Tpo -c -o forked_daapd-misc.obj `if test -f 'misc.c'; then $(CYGPATH_W) 'misc.c'; else $(CYGPATH_W) '$(srcdir)/misc.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-misc.Tpo $(DEPDIR)/forked_daapd-misc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='misc.c' object='forked_daapd-misc.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-misc.obj `if test -f 'misc.c'; then $(CYGPATH_W) 'misc.c'; else $(CYGPATH_W) '$(srcdir)/misc.c'; fi` forked_daapd-rng.o: rng.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-rng.o -MD -MP -MF $(DEPDIR)/forked_daapd-rng.Tpo -c -o forked_daapd-rng.o `test -f 'rng.c' || echo '$(srcdir)/'`rng.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-rng.Tpo $(DEPDIR)/forked_daapd-rng.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rng.c' object='forked_daapd-rng.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-rng.o `test -f 'rng.c' || echo '$(srcdir)/'`rng.c forked_daapd-rng.obj: rng.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-rng.obj -MD -MP -MF $(DEPDIR)/forked_daapd-rng.Tpo -c -o forked_daapd-rng.obj `if test -f 'rng.c'; then $(CYGPATH_W) 'rng.c'; else $(CYGPATH_W) '$(srcdir)/rng.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-rng.Tpo $(DEPDIR)/forked_daapd-rng.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rng.c' object='forked_daapd-rng.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-rng.obj `if test -f 'rng.c'; then $(CYGPATH_W) 'rng.c'; else $(CYGPATH_W) '$(srcdir)/rng.c'; fi` forked_daapd-rsp_query.o: rsp_query.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-rsp_query.o -MD -MP -MF $(DEPDIR)/forked_daapd-rsp_query.Tpo -c -o forked_daapd-rsp_query.o `test -f 'rsp_query.c' || echo '$(srcdir)/'`rsp_query.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-rsp_query.Tpo $(DEPDIR)/forked_daapd-rsp_query.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rsp_query.c' object='forked_daapd-rsp_query.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-rsp_query.o `test -f 'rsp_query.c' || echo '$(srcdir)/'`rsp_query.c forked_daapd-rsp_query.obj: rsp_query.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-rsp_query.obj -MD -MP -MF $(DEPDIR)/forked_daapd-rsp_query.Tpo -c -o forked_daapd-rsp_query.obj `if test -f 'rsp_query.c'; then $(CYGPATH_W) 'rsp_query.c'; else $(CYGPATH_W) '$(srcdir)/rsp_query.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-rsp_query.Tpo $(DEPDIR)/forked_daapd-rsp_query.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='rsp_query.c' object='forked_daapd-rsp_query.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-rsp_query.obj `if test -f 'rsp_query.c'; then $(CYGPATH_W) 'rsp_query.c'; else $(CYGPATH_W) '$(srcdir)/rsp_query.c'; fi` forked_daapd-daap_query.o: daap_query.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-daap_query.o -MD -MP -MF $(DEPDIR)/forked_daapd-daap_query.Tpo -c -o forked_daapd-daap_query.o `test -f 'daap_query.c' || echo '$(srcdir)/'`daap_query.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-daap_query.Tpo $(DEPDIR)/forked_daapd-daap_query.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='daap_query.c' object='forked_daapd-daap_query.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-daap_query.o `test -f 'daap_query.c' || echo '$(srcdir)/'`daap_query.c forked_daapd-daap_query.obj: daap_query.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-daap_query.obj -MD -MP -MF $(DEPDIR)/forked_daapd-daap_query.Tpo -c -o forked_daapd-daap_query.obj `if test -f 'daap_query.c'; then $(CYGPATH_W) 'daap_query.c'; else $(CYGPATH_W) '$(srcdir)/daap_query.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-daap_query.Tpo $(DEPDIR)/forked_daapd-daap_query.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='daap_query.c' object='forked_daapd-daap_query.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-daap_query.obj `if test -f 'daap_query.c'; then $(CYGPATH_W) 'daap_query.c'; else $(CYGPATH_W) '$(srcdir)/daap_query.c'; fi` forked_daapd-player.o: player.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-player.o -MD -MP -MF $(DEPDIR)/forked_daapd-player.Tpo -c -o forked_daapd-player.o `test -f 'player.c' || echo '$(srcdir)/'`player.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-player.Tpo $(DEPDIR)/forked_daapd-player.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='player.c' object='forked_daapd-player.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-player.o `test -f 'player.c' || echo '$(srcdir)/'`player.c forked_daapd-player.obj: player.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-player.obj -MD -MP -MF $(DEPDIR)/forked_daapd-player.Tpo -c -o forked_daapd-player.obj `if test -f 'player.c'; then $(CYGPATH_W) 'player.c'; else $(CYGPATH_W) '$(srcdir)/player.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-player.Tpo $(DEPDIR)/forked_daapd-player.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='player.c' object='forked_daapd-player.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-player.obj `if test -f 'player.c'; then $(CYGPATH_W) 'player.c'; else $(CYGPATH_W) '$(srcdir)/player.c'; fi` forked_daapd-laudio_alsa.o: laudio_alsa.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-laudio_alsa.o -MD -MP -MF $(DEPDIR)/forked_daapd-laudio_alsa.Tpo -c -o forked_daapd-laudio_alsa.o `test -f 'laudio_alsa.c' || echo '$(srcdir)/'`laudio_alsa.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-laudio_alsa.Tpo $(DEPDIR)/forked_daapd-laudio_alsa.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='laudio_alsa.c' object='forked_daapd-laudio_alsa.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-laudio_alsa.o `test -f 'laudio_alsa.c' || echo '$(srcdir)/'`laudio_alsa.c forked_daapd-laudio_alsa.obj: laudio_alsa.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-laudio_alsa.obj -MD -MP -MF $(DEPDIR)/forked_daapd-laudio_alsa.Tpo -c -o forked_daapd-laudio_alsa.obj `if test -f 'laudio_alsa.c'; then $(CYGPATH_W) 'laudio_alsa.c'; else $(CYGPATH_W) '$(srcdir)/laudio_alsa.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-laudio_alsa.Tpo $(DEPDIR)/forked_daapd-laudio_alsa.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='laudio_alsa.c' object='forked_daapd-laudio_alsa.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-laudio_alsa.obj `if test -f 'laudio_alsa.c'; then $(CYGPATH_W) 'laudio_alsa.c'; else $(CYGPATH_W) '$(srcdir)/laudio_alsa.c'; fi` forked_daapd-laudio_oss4.o: laudio_oss4.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-laudio_oss4.o -MD -MP -MF $(DEPDIR)/forked_daapd-laudio_oss4.Tpo -c -o forked_daapd-laudio_oss4.o `test -f 'laudio_oss4.c' || echo '$(srcdir)/'`laudio_oss4.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-laudio_oss4.Tpo $(DEPDIR)/forked_daapd-laudio_oss4.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='laudio_oss4.c' object='forked_daapd-laudio_oss4.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-laudio_oss4.o `test -f 'laudio_oss4.c' || echo '$(srcdir)/'`laudio_oss4.c forked_daapd-laudio_oss4.obj: laudio_oss4.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-laudio_oss4.obj -MD -MP -MF $(DEPDIR)/forked_daapd-laudio_oss4.Tpo -c -o forked_daapd-laudio_oss4.obj `if test -f 'laudio_oss4.c'; then $(CYGPATH_W) 'laudio_oss4.c'; else $(CYGPATH_W) '$(srcdir)/laudio_oss4.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-laudio_oss4.Tpo $(DEPDIR)/forked_daapd-laudio_oss4.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='laudio_oss4.c' object='forked_daapd-laudio_oss4.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-laudio_oss4.obj `if test -f 'laudio_oss4.c'; then $(CYGPATH_W) 'laudio_oss4.c'; else $(CYGPATH_W) '$(srcdir)/laudio_oss4.c'; fi` forked_daapd-raop.o: raop.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-raop.o -MD -MP -MF $(DEPDIR)/forked_daapd-raop.Tpo -c -o forked_daapd-raop.o `test -f 'raop.c' || echo '$(srcdir)/'`raop.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-raop.Tpo $(DEPDIR)/forked_daapd-raop.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='raop.c' object='forked_daapd-raop.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-raop.o `test -f 'raop.c' || echo '$(srcdir)/'`raop.c forked_daapd-raop.obj: raop.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-raop.obj -MD -MP -MF $(DEPDIR)/forked_daapd-raop.Tpo -c -o forked_daapd-raop.obj `if test -f 'raop.c'; then $(CYGPATH_W) 'raop.c'; else $(CYGPATH_W) '$(srcdir)/raop.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-raop.Tpo $(DEPDIR)/forked_daapd-raop.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='raop.c' object='forked_daapd-raop.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-raop.obj `if test -f 'raop.c'; then $(CYGPATH_W) 'raop.c'; else $(CYGPATH_W) '$(srcdir)/raop.c'; fi` forked_daapd-evbuffer.o: evbuffer/evbuffer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-evbuffer.o -MD -MP -MF $(DEPDIR)/forked_daapd-evbuffer.Tpo -c -o forked_daapd-evbuffer.o `test -f 'evbuffer/evbuffer.c' || echo '$(srcdir)/'`evbuffer/evbuffer.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-evbuffer.Tpo $(DEPDIR)/forked_daapd-evbuffer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='evbuffer/evbuffer.c' object='forked_daapd-evbuffer.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-evbuffer.o `test -f 'evbuffer/evbuffer.c' || echo '$(srcdir)/'`evbuffer/evbuffer.c forked_daapd-evbuffer.obj: evbuffer/evbuffer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-evbuffer.obj -MD -MP -MF $(DEPDIR)/forked_daapd-evbuffer.Tpo -c -o forked_daapd-evbuffer.obj `if test -f 'evbuffer/evbuffer.c'; then $(CYGPATH_W) 'evbuffer/evbuffer.c'; else $(CYGPATH_W) '$(srcdir)/evbuffer/evbuffer.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-evbuffer.Tpo $(DEPDIR)/forked_daapd-evbuffer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='evbuffer/evbuffer.c' object='forked_daapd-evbuffer.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-evbuffer.obj `if test -f 'evbuffer/evbuffer.c'; then $(CYGPATH_W) 'evbuffer/evbuffer.c'; else $(CYGPATH_W) '$(srcdir)/evbuffer/evbuffer.c'; fi` forked_daapd-scan-wma.o: scan-wma.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-scan-wma.o -MD -MP -MF $(DEPDIR)/forked_daapd-scan-wma.Tpo -c -o forked_daapd-scan-wma.o `test -f 'scan-wma.c' || echo '$(srcdir)/'`scan-wma.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-scan-wma.Tpo $(DEPDIR)/forked_daapd-scan-wma.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan-wma.c' object='forked_daapd-scan-wma.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-scan-wma.o `test -f 'scan-wma.c' || echo '$(srcdir)/'`scan-wma.c forked_daapd-scan-wma.obj: scan-wma.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-scan-wma.obj -MD -MP -MF $(DEPDIR)/forked_daapd-scan-wma.Tpo -c -o forked_daapd-scan-wma.obj `if test -f 'scan-wma.c'; then $(CYGPATH_W) 'scan-wma.c'; else $(CYGPATH_W) '$(srcdir)/scan-wma.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-scan-wma.Tpo $(DEPDIR)/forked_daapd-scan-wma.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan-wma.c' object='forked_daapd-scan-wma.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-scan-wma.obj `if test -f 'scan-wma.c'; then $(CYGPATH_W) 'scan-wma.c'; else $(CYGPATH_W) '$(srcdir)/scan-wma.c'; fi` forked_daapd-scan-flac.o: scan-flac.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-scan-flac.o -MD -MP -MF $(DEPDIR)/forked_daapd-scan-flac.Tpo -c -o forked_daapd-scan-flac.o `test -f 'scan-flac.c' || echo '$(srcdir)/'`scan-flac.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-scan-flac.Tpo $(DEPDIR)/forked_daapd-scan-flac.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan-flac.c' object='forked_daapd-scan-flac.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-scan-flac.o `test -f 'scan-flac.c' || echo '$(srcdir)/'`scan-flac.c forked_daapd-scan-flac.obj: scan-flac.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-scan-flac.obj -MD -MP -MF $(DEPDIR)/forked_daapd-scan-flac.Tpo -c -o forked_daapd-scan-flac.obj `if test -f 'scan-flac.c'; then $(CYGPATH_W) 'scan-flac.c'; else $(CYGPATH_W) '$(srcdir)/scan-flac.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-scan-flac.Tpo $(DEPDIR)/forked_daapd-scan-flac.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan-flac.c' object='forked_daapd-scan-flac.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-scan-flac.obj `if test -f 'scan-flac.c'; then $(CYGPATH_W) 'scan-flac.c'; else $(CYGPATH_W) '$(srcdir)/scan-flac.c'; fi` forked_daapd-scan-mpc.o: scan-mpc.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-scan-mpc.o -MD -MP -MF $(DEPDIR)/forked_daapd-scan-mpc.Tpo -c -o forked_daapd-scan-mpc.o `test -f 'scan-mpc.c' || echo '$(srcdir)/'`scan-mpc.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-scan-mpc.Tpo $(DEPDIR)/forked_daapd-scan-mpc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan-mpc.c' object='forked_daapd-scan-mpc.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-scan-mpc.o `test -f 'scan-mpc.c' || echo '$(srcdir)/'`scan-mpc.c forked_daapd-scan-mpc.obj: scan-mpc.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-scan-mpc.obj -MD -MP -MF $(DEPDIR)/forked_daapd-scan-mpc.Tpo -c -o forked_daapd-scan-mpc.obj `if test -f 'scan-mpc.c'; then $(CYGPATH_W) 'scan-mpc.c'; else $(CYGPATH_W) '$(srcdir)/scan-mpc.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-scan-mpc.Tpo $(DEPDIR)/forked_daapd-scan-mpc.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='scan-mpc.c' object='forked_daapd-scan-mpc.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-scan-mpc.obj `if test -f 'scan-mpc.c'; then $(CYGPATH_W) 'scan-mpc.c'; else $(CYGPATH_W) '$(srcdir)/scan-mpc.c'; fi` forked_daapd-RSPLexer.o: RSPLexer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-RSPLexer.o -MD -MP -MF $(DEPDIR)/forked_daapd-RSPLexer.Tpo -c -o forked_daapd-RSPLexer.o `test -f 'RSPLexer.c' || echo '$(srcdir)/'`RSPLexer.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-RSPLexer.Tpo $(DEPDIR)/forked_daapd-RSPLexer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='RSPLexer.c' object='forked_daapd-RSPLexer.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-RSPLexer.o `test -f 'RSPLexer.c' || echo '$(srcdir)/'`RSPLexer.c forked_daapd-RSPLexer.obj: RSPLexer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-RSPLexer.obj -MD -MP -MF $(DEPDIR)/forked_daapd-RSPLexer.Tpo -c -o forked_daapd-RSPLexer.obj `if test -f 'RSPLexer.c'; then $(CYGPATH_W) 'RSPLexer.c'; else $(CYGPATH_W) '$(srcdir)/RSPLexer.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-RSPLexer.Tpo $(DEPDIR)/forked_daapd-RSPLexer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='RSPLexer.c' object='forked_daapd-RSPLexer.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-RSPLexer.obj `if test -f 'RSPLexer.c'; then $(CYGPATH_W) 'RSPLexer.c'; else $(CYGPATH_W) '$(srcdir)/RSPLexer.c'; fi` forked_daapd-RSPParser.o: RSPParser.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-RSPParser.o -MD -MP -MF $(DEPDIR)/forked_daapd-RSPParser.Tpo -c -o forked_daapd-RSPParser.o `test -f 'RSPParser.c' || echo '$(srcdir)/'`RSPParser.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-RSPParser.Tpo $(DEPDIR)/forked_daapd-RSPParser.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='RSPParser.c' object='forked_daapd-RSPParser.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-RSPParser.o `test -f 'RSPParser.c' || echo '$(srcdir)/'`RSPParser.c forked_daapd-RSPParser.obj: RSPParser.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-RSPParser.obj -MD -MP -MF $(DEPDIR)/forked_daapd-RSPParser.Tpo -c -o forked_daapd-RSPParser.obj `if test -f 'RSPParser.c'; then $(CYGPATH_W) 'RSPParser.c'; else $(CYGPATH_W) '$(srcdir)/RSPParser.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-RSPParser.Tpo $(DEPDIR)/forked_daapd-RSPParser.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='RSPParser.c' object='forked_daapd-RSPParser.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-RSPParser.obj `if test -f 'RSPParser.c'; then $(CYGPATH_W) 'RSPParser.c'; else $(CYGPATH_W) '$(srcdir)/RSPParser.c'; fi` forked_daapd-RSP2SQL.o: RSP2SQL.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-RSP2SQL.o -MD -MP -MF $(DEPDIR)/forked_daapd-RSP2SQL.Tpo -c -o forked_daapd-RSP2SQL.o `test -f 'RSP2SQL.c' || echo '$(srcdir)/'`RSP2SQL.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-RSP2SQL.Tpo $(DEPDIR)/forked_daapd-RSP2SQL.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='RSP2SQL.c' object='forked_daapd-RSP2SQL.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-RSP2SQL.o `test -f 'RSP2SQL.c' || echo '$(srcdir)/'`RSP2SQL.c forked_daapd-RSP2SQL.obj: RSP2SQL.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-RSP2SQL.obj -MD -MP -MF $(DEPDIR)/forked_daapd-RSP2SQL.Tpo -c -o forked_daapd-RSP2SQL.obj `if test -f 'RSP2SQL.c'; then $(CYGPATH_W) 'RSP2SQL.c'; else $(CYGPATH_W) '$(srcdir)/RSP2SQL.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-RSP2SQL.Tpo $(DEPDIR)/forked_daapd-RSP2SQL.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='RSP2SQL.c' object='forked_daapd-RSP2SQL.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-RSP2SQL.obj `if test -f 'RSP2SQL.c'; then $(CYGPATH_W) 'RSP2SQL.c'; else $(CYGPATH_W) '$(srcdir)/RSP2SQL.c'; fi` forked_daapd-DAAPLexer.o: DAAPLexer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-DAAPLexer.o -MD -MP -MF $(DEPDIR)/forked_daapd-DAAPLexer.Tpo -c -o forked_daapd-DAAPLexer.o `test -f 'DAAPLexer.c' || echo '$(srcdir)/'`DAAPLexer.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-DAAPLexer.Tpo $(DEPDIR)/forked_daapd-DAAPLexer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='DAAPLexer.c' object='forked_daapd-DAAPLexer.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-DAAPLexer.o `test -f 'DAAPLexer.c' || echo '$(srcdir)/'`DAAPLexer.c forked_daapd-DAAPLexer.obj: DAAPLexer.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-DAAPLexer.obj -MD -MP -MF $(DEPDIR)/forked_daapd-DAAPLexer.Tpo -c -o forked_daapd-DAAPLexer.obj `if test -f 'DAAPLexer.c'; then $(CYGPATH_W) 'DAAPLexer.c'; else $(CYGPATH_W) '$(srcdir)/DAAPLexer.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-DAAPLexer.Tpo $(DEPDIR)/forked_daapd-DAAPLexer.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='DAAPLexer.c' object='forked_daapd-DAAPLexer.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-DAAPLexer.obj `if test -f 'DAAPLexer.c'; then $(CYGPATH_W) 'DAAPLexer.c'; else $(CYGPATH_W) '$(srcdir)/DAAPLexer.c'; fi` forked_daapd-DAAPParser.o: DAAPParser.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-DAAPParser.o -MD -MP -MF $(DEPDIR)/forked_daapd-DAAPParser.Tpo -c -o forked_daapd-DAAPParser.o `test -f 'DAAPParser.c' || echo '$(srcdir)/'`DAAPParser.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-DAAPParser.Tpo $(DEPDIR)/forked_daapd-DAAPParser.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='DAAPParser.c' object='forked_daapd-DAAPParser.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-DAAPParser.o `test -f 'DAAPParser.c' || echo '$(srcdir)/'`DAAPParser.c forked_daapd-DAAPParser.obj: DAAPParser.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-DAAPParser.obj -MD -MP -MF $(DEPDIR)/forked_daapd-DAAPParser.Tpo -c -o forked_daapd-DAAPParser.obj `if test -f 'DAAPParser.c'; then $(CYGPATH_W) 'DAAPParser.c'; else $(CYGPATH_W) '$(srcdir)/DAAPParser.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-DAAPParser.Tpo $(DEPDIR)/forked_daapd-DAAPParser.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='DAAPParser.c' object='forked_daapd-DAAPParser.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-DAAPParser.obj `if test -f 'DAAPParser.c'; then $(CYGPATH_W) 'DAAPParser.c'; else $(CYGPATH_W) '$(srcdir)/DAAPParser.c'; fi` forked_daapd-DAAP2SQL.o: DAAP2SQL.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-DAAP2SQL.o -MD -MP -MF $(DEPDIR)/forked_daapd-DAAP2SQL.Tpo -c -o forked_daapd-DAAP2SQL.o `test -f 'DAAP2SQL.c' || echo '$(srcdir)/'`DAAP2SQL.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-DAAP2SQL.Tpo $(DEPDIR)/forked_daapd-DAAP2SQL.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='DAAP2SQL.c' object='forked_daapd-DAAP2SQL.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-DAAP2SQL.o `test -f 'DAAP2SQL.c' || echo '$(srcdir)/'`DAAP2SQL.c forked_daapd-DAAP2SQL.obj: DAAP2SQL.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -MT forked_daapd-DAAP2SQL.obj -MD -MP -MF $(DEPDIR)/forked_daapd-DAAP2SQL.Tpo -c -o forked_daapd-DAAP2SQL.obj `if test -f 'DAAP2SQL.c'; then $(CYGPATH_W) 'DAAP2SQL.c'; else $(CYGPATH_W) '$(srcdir)/DAAP2SQL.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/forked_daapd-DAAP2SQL.Tpo $(DEPDIR)/forked_daapd-DAAP2SQL.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='DAAP2SQL.c' object='forked_daapd-DAAP2SQL.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(forked_daapd_CPPFLAGS) $(CPPFLAGS) $(forked_daapd_CFLAGS) $(CFLAGS) -c -o forked_daapd-DAAP2SQL.obj `if test -f 'DAAP2SQL.c'; then $(CYGPATH_W) 'DAAP2SQL.c'; else $(CYGPATH_W) '$(srcdir)/DAAP2SQL.c'; fi` mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) check-am all-am: Makefile $(PROGRAMS) installdirs: for dir in "$(DESTDIR)$(sbindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES) clean: clean-am clean-am: clean-generic clean-libtool clean-sbinPROGRAMS \ mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-sbinPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic \ mostlyclean-libtool pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-sbinPROGRAMS .MAKE: all check install install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-libtool clean-sbinPROGRAMS ctags distclean \ distclean-compile distclean-generic distclean-libtool \ distclean-tags distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-sbinPROGRAMS install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-sbinPROGRAMS # gperf construction rules %_hash.c: %.gperf if $(GPERF) $< > $@.tmp; then \ mv $@.tmp $@; \ elif $(GPERF) --version >/dev/null 2>&1; then \ rm $@.tmp; \ exit 1; \ else \ rm $@.tmp; \ touch $@; \ fi @COND_ANTLR_TRUE@%.tokens %.c %Lexer.c %Parser.c %Lexer.h %Parser.h %.h: %.g @COND_ANTLR_TRUE@ $(ANTLR) $(ANTLR_OPTIONS) $< @COND_ANTLR_TRUE@%.u: %.g @COND_ANTLR_TRUE@ $(ANTLR) -depend $< > $@ @COND_ANTLR_TRUE@ @echo -n "ANTLR_PRODUCTS += " > $@.tmp @COND_ANTLR_TRUE@ @grep : $@ | cut -d : -f 1 | tr -d ' ' | { while read f; do test "$$f" != "$<" && echo -n "$$f "; done } >> $@.tmp @COND_ANTLR_TRUE@ @cat $@.tmp >> $@ @COND_ANTLR_TRUE@ @rm $@.tmp -include $(ANTLR_GRAMMARS:.g=.u) # 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: forked-daapd-0.19gcd/src/pregen/0000775000175000017500000000000011633141370016050 5ustar julienjulienforked-daapd-0.19gcd/src/pregen/DAAP.u0000664000175000017500000000015511633141352016744 0ustar julienjulienDAAPParser.c : DAAP.g ./DAAP.tokens : DAAP.g DAAPParser.h : DAAP.g DAAPLexer.c : DAAP.g DAAPLexer.h : DAAP.g forked-daapd-0.19gcd/src/pregen/DAAP2SQL.u0000664000175000017500000000014711633141352017407 0ustar julienjulienDAAP2SQL.g: DAAP.tokens DAAP2SQL.c : DAAP2SQL.g ./DAAP2SQL.tokens : DAAP2SQL.g DAAP2SQL.h : DAAP2SQL.g forked-daapd-0.19gcd/src/pregen/RSP.u0000664000175000017500000000014311633141353016701 0ustar julienjulienRSPParser.c : RSP.g ./RSP.tokens : RSP.g RSPParser.h : RSP.g RSPLexer.c : RSP.g RSPLexer.h : RSP.g forked-daapd-0.19gcd/src/pregen/RSP2SQL.u0000664000175000017500000000013711633141353017346 0ustar julienjulienRSP2SQL.g: RSP.tokens RSP2SQL.c : RSP2SQL.g ./RSP2SQL.tokens : RSP2SQL.g RSP2SQL.h : RSP2SQL.g forked-daapd-0.19gcd/src/pregen/DAAPParser.c0000664000175000017500000010040711633141361020100 0ustar julienjulien/** \file * This C source file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : DAAP.g * - On : 2011-09-11 16:17:21 * - for the parser : DAAPParserParser * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* ----------------------------------------- * Include the ANTLR3 generated header file. */ #include "DAAPParser.h" /* ----------------------------------------- */ /* MACROS that hide the C interface implementations from the * generated code, which makes it a little more understandable to the human eye. * I am very much against using C pre-processor macros for function calls and bits * of code as you cannot see what is happening when single stepping in debuggers * and so on. The exception (in my book at least) is for generated code, where you are * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() * hides some indirect calls, but is always referring to the input stream. This is * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig * the runtime interfaces without changing the generated code too often, without * confusing the reader of the generated output, who may not wish to know the gory * details of the interface inheritance. */ #define CTX ctx /* Aids in accessing scopes for grammar programmers */ #undef SCOPE_TYPE #undef SCOPE_STACK #undef SCOPE_TOP #define SCOPE_TYPE(scope) pDAAPParser_##scope##_SCOPE #define SCOPE_STACK(scope) pDAAPParser_##scope##Stack #define SCOPE_TOP(scope) ctx->pDAAPParser_##scope##Top #define SCOPE_SIZE(scope) ctx->pDAAPParser_##scope##Stack_limit #define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) /* Macros for accessing things in the parser */ #undef PARSER #undef RECOGNIZER #undef HAVEPARSEDRULE #undef MEMOIZE #undef INPUT #undef STRSTREAM #undef HASEXCEPTION #undef EXCEPTION #undef MATCHT #undef MATCHANYT #undef FOLLOWSTACK #undef FOLLOWPUSH #undef FOLLOWPOP #undef PRECOVER #undef PREPORTERROR #undef LA #undef LT #undef CONSTRUCTEX #undef CONSUME #undef MARK #undef REWIND #undef REWINDLAST #undef PERRORRECOVERY #undef HASFAILED #undef FAILEDFLAG #undef RECOVERFROMMISMATCHEDSET #undef RECOVERFROMMISMATCHEDELEMENT #undef INDEX #undef ADAPTOR #undef SEEK #undef RULEMEMO #undef DBG #define PARSER ctx->pParser #define RECOGNIZER PARSER->rec #define PSRSTATE RECOGNIZER->state #define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) #define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) #define INPUT PARSER->tstream #define STRSTREAM INPUT #define ISTREAM INPUT->istream #define INDEX() ISTREAM->index(INPUT->istream) #define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE) #define EXCEPTION PSRSTATE->exception #define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs) #define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER) #define FOLLOWSTACK PSRSTATE->following #define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL) #define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK) #define PRECOVER() RECOGNIZER->recover(RECOGNIZER) #define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER) #define LA(n) INPUT->istream->_LA(ISTREAM, n) #define LT(n) INPUT->_LT(INPUT, n) #define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) #define CONSUME() ISTREAM->consume(ISTREAM) #define MARK() ISTREAM->mark(ISTREAM) #define REWIND(m) ISTREAM->rewind(ISTREAM, m) #define REWINDLAST() ISTREAM->rewindLast(ISTREAM) #define SEEK(n) ISTREAM->seek(ISTREAM, n) #define PERRORRECOVERY PSRSTATE->errorRecovery #define FAILEDFLAG PSRSTATE->failed #define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE) #define BACKTRACKING PSRSTATE->backtracking #define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s) #define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s) #define ADAPTOR ctx->adaptor #define RULEMEMO PSRSTATE->ruleMemo #define DBG RECOGNIZER->debugger #define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt /* The 4 tokens defined below may well clash with your own #defines or token types. If so * then for the present you must use different names for your defines as these are hard coded * in the code generator. It would be better not to use such names internally, and maybe * we can change this in a forthcoming release. I deliberately do not #undef these * here as this will at least give you a redefined error somewhere if they clash. */ #define UP ANTLR3_TOKEN_UP #define DOWN ANTLR3_TOKEN_DOWN #define EOR ANTLR3_TOKEN_EOR #define INVALID ANTLR3_TOKEN_INVALID /* ============================================================================= * Functions to create and destroy scopes. First come the rule scopes, followed * by the global declared scopes. */ /* ============================================================================= */ /* ============================================================================= * Start of recognizer */ /** \brief Table of all token names in symbolic order, mainly used for * error reporting. */ pANTLR3_UINT8 DAAPParserTokenNames[8+4] = { (pANTLR3_UINT8) "", /* String to print to indicate an invalid token */ (pANTLR3_UINT8) "", (pANTLR3_UINT8) "", (pANTLR3_UINT8) "", (pANTLR3_UINT8) "NEWLINE", (pANTLR3_UINT8) "OPOR", (pANTLR3_UINT8) "OPAND", (pANTLR3_UINT8) "LPAR", (pANTLR3_UINT8) "RPAR", (pANTLR3_UINT8) "STR", (pANTLR3_UINT8) "QUOTE", (pANTLR3_UINT8) "ESCAPED" }; // Forward declare the locally static matching functions we have generated. // static DAAPParser_query_return query (pDAAPParser ctx); static DAAPParser_expr_return expr (pDAAPParser ctx); static DAAPParser_aexpr_return aexpr (pDAAPParser ctx); static DAAPParser_crit_return crit (pDAAPParser ctx); static void DAAPParserFree(pDAAPParser ctx); /* For use in tree output where we are accumulating rule labels via label += ruleRef * we need a function that knows how to free a return scope when the list is destroyed. * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro. */ static void ANTLR3_CDECL freeScope(void * scope) { ANTLR3_FREE(scope); } /** \brief Name of the grammar file that generated this code */ static const char fileName[] = "DAAP.g"; /** \brief Return the name of the grammar file that generated this code. */ static const char * getGrammarFileName() { return fileName; } /** \brief Create a new DAAPParser parser and return a context for it. * * \param[in] instream Pointer to an input stream interface. * * \return Pointer to new parser context upon success. */ ANTLR3_API pDAAPParser DAAPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream) { // See if we can create a new parser with the standard constructor // return DAAPParserNewSSD(instream, NULL); } /** \brief Create a new DAAPParser parser and return a context for it. * * \param[in] instream Pointer to an input stream interface. * * \return Pointer to new parser context upon success. */ ANTLR3_API pDAAPParser DAAPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) { pDAAPParser ctx; /* Context structure we will build and return */ ctx = (pDAAPParser) ANTLR3_CALLOC(1, sizeof(DAAPParser)); if (ctx == NULL) { // Failed to allocate memory for parser context // return NULL; } /* ------------------------------------------------------------------- * Memory for basic structure is allocated, now to fill in * the base ANTLR3 structures. We initialize the function pointers * for the standard ANTLR3 parser function set, but upon return * from here, the programmer may set the pointers to provide custom * implementations of each function. * * We don't use the macros defined in DAAPParser.h here, in order that you can get a sense * of what goes where. */ /* Create a base parser/recognizer, using the supplied token stream */ ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state); /* Install the implementation of our DAAPParser interface */ ctx->query = query; ctx->expr = expr; ctx->aexpr = aexpr; ctx->crit = crit; ctx->free = DAAPParserFree; ctx->getGrammarFileName = getGrammarFileName; /* Install the scope pushing methods. */ ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory); ctx->vectors = antlr3VectorFactoryNew(0); /* Install the token table */ PSRSTATE->tokenNames = DAAPParserTokenNames; /* Return the newly built parser to the caller */ return ctx; } /** Free the parser resources */ static void DAAPParserFree(pDAAPParser ctx) { /* Free any scope memory */ ctx->vectors->close(ctx->vectors); /* We created the adaptor so we must free it */ ADAPTOR->free(ADAPTOR); // Free this parser // ctx->pParser->free(ctx->pParser); ANTLR3_FREE(ctx); /* Everything is released, so we can return */ return; } /** Return token names used by this parser * * The returned pointer is used as an index into the token names table (using the token * number as the index). * * \return Pointer to first char * in the table. */ static pANTLR3_UINT8 *getTokenNames() { return DAAPParserTokenNames; } /* Declare the bitsets */ /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query42 */ static ANTLR3_BITWORD FOLLOW_expr_in_query42_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_query42 = { FOLLOW_expr_in_query42_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_NEWLINE_in_query44 */ static ANTLR3_BITWORD FOLLOW_NEWLINE_in_query44_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000) }; static ANTLR3_BITSET_LIST FOLLOW_NEWLINE_in_query44 = { FOLLOW_NEWLINE_in_query44_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_query47 */ static ANTLR3_BITWORD FOLLOW_EOF_in_query47_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_EOF_in_query47 = { FOLLOW_EOF_in_query47_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr62 */ static ANTLR3_BITWORD FOLLOW_aexpr_in_expr62_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) }; static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr62 = { FOLLOW_aexpr_in_expr62_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_OPOR_in_expr65 */ static ANTLR3_BITWORD FOLLOW_OPOR_in_expr65_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; static ANTLR3_BITSET_LIST FOLLOW_OPOR_in_expr65 = { FOLLOW_OPOR_in_expr65_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr68 */ static ANTLR3_BITWORD FOLLOW_aexpr_in_expr68_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) }; static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr68 = { FOLLOW_aexpr_in_expr68_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr80 */ static ANTLR3_BITWORD FOLLOW_crit_in_aexpr80_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) }; static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr80 = { FOLLOW_crit_in_aexpr80_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_OPAND_in_aexpr83 */ static ANTLR3_BITWORD FOLLOW_OPAND_in_aexpr83_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; static ANTLR3_BITSET_LIST FOLLOW_OPAND_in_aexpr83 = { FOLLOW_OPAND_in_aexpr83_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr86 */ static ANTLR3_BITWORD FOLLOW_crit_in_aexpr86_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) }; static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr86 = { FOLLOW_crit_in_aexpr86_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit98 */ static ANTLR3_BITWORD FOLLOW_LPAR_in_crit98_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; static ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit98 = { FOLLOW_LPAR_in_crit98_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_crit100 */ static ANTLR3_BITWORD FOLLOW_expr_in_crit100_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000100) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_crit100 = { FOLLOW_expr_in_crit100_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit102 */ static ANTLR3_BITWORD FOLLOW_RPAR_in_crit102_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit102 = { FOLLOW_RPAR_in_crit102_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_crit112 */ static ANTLR3_BITWORD FOLLOW_STR_in_crit112_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_STR_in_crit112 = { FOLLOW_STR_in_crit112_bits, 1 }; /* ============================================== * Parsing rules */ /** * $ANTLR start query * DAAP.g:27:1: query : expr ( NEWLINE )? EOF -> expr ; */ static DAAPParser_query_return query(pDAAPParser ctx) { DAAPParser_query_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN NEWLINE2; pANTLR3_COMMON_TOKEN EOF3; DAAPParser_expr_return expr1; #undef RETURN_TYPE_expr1 #define RETURN_TYPE_expr1 DAAPParser_expr_return pANTLR3_BASE_TREE NEWLINE2_tree; pANTLR3_BASE_TREE EOF3_tree; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NEWLINE; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_EOF; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr; /* Initialize rule variables */ root_0 = NULL; NEWLINE2 = NULL; EOF3 = NULL; expr1.tree = NULL; retval.start = LT(1); retval.stop = retval.start; NEWLINE2_tree = NULL; EOF3_tree = NULL; stream_NEWLINE = NULL; #define CREATE_stream_NEWLINE if (stream_NEWLINE == NULL) {stream_NEWLINE = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NEWLINE"); } stream_EOF = NULL; #define CREATE_stream_EOF if (stream_EOF == NULL) {stream_EOF = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token EOF"); } stream_expr = NULL; #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); } retval.tree = NULL; { // DAAP.g:27:7: ( expr ( NEWLINE )? EOF -> expr ) // DAAP.g:27:9: expr ( NEWLINE )? EOF { FOLLOWPUSH(FOLLOW_expr_in_query42); expr1=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulequeryEx; } CREATE_stream_expr; stream_expr->add(stream_expr, expr1.tree, NULL); // DAAP.g:27:14: ( NEWLINE )? { int alt1=2; switch ( LA(1) ) { case NEWLINE: { alt1=1; } break; } switch (alt1) { case 1: // DAAP.g:27:14: NEWLINE { NEWLINE2 = (pANTLR3_COMMON_TOKEN) MATCHT(NEWLINE, &FOLLOW_NEWLINE_in_query44); if (HASEXCEPTION()) { goto rulequeryEx; } CREATE_stream_NEWLINE; stream_NEWLINE->add(stream_NEWLINE, NEWLINE2, NULL); } break; } } EOF3 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_query47); if (HASEXCEPTION()) { goto rulequeryEx; } CREATE_stream_EOF; stream_EOF->add(stream_EOF, EOF3, NULL); /* AST REWRITE * elements : expr * token labels : * rule labels : retval * token list labels : * rule list labels : */ { pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); retval.tree = root_0; // 27:27: -> expr { ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr)); } retval.tree = root_0; // set result root if (stream_retval != NULL) stream_retval->free(stream_retval); } } } // This is where rules clean up and exit // goto rulequeryEx; /* Prevent compiler warnings */ rulequeryEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (stream_NEWLINE != NULL) stream_NEWLINE->free(stream_NEWLINE); if (stream_EOF != NULL) stream_EOF->free(stream_EOF); if (stream_expr != NULL) stream_expr->free(stream_expr); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end query */ /** * $ANTLR start expr * DAAP.g:30:1: expr : aexpr ( OPOR aexpr )* ; */ static DAAPParser_expr_return expr(pDAAPParser ctx) { DAAPParser_expr_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN OPOR5; DAAPParser_aexpr_return aexpr4; #undef RETURN_TYPE_aexpr4 #define RETURN_TYPE_aexpr4 DAAPParser_aexpr_return DAAPParser_aexpr_return aexpr6; #undef RETURN_TYPE_aexpr6 #define RETURN_TYPE_aexpr6 DAAPParser_aexpr_return pANTLR3_BASE_TREE OPOR5_tree; /* Initialize rule variables */ root_0 = NULL; OPOR5 = NULL; aexpr4.tree = NULL; aexpr6.tree = NULL; retval.start = LT(1); retval.stop = retval.start; OPOR5_tree = NULL; retval.tree = NULL; { // DAAP.g:30:6: ( aexpr ( OPOR aexpr )* ) // DAAP.g:30:8: aexpr ( OPOR aexpr )* { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); FOLLOWPUSH(FOLLOW_aexpr_in_expr62); aexpr4=aexpr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } ADAPTOR->addChild(ADAPTOR, root_0, aexpr4.tree); // DAAP.g:30:14: ( OPOR aexpr )* for (;;) { int alt2=2; switch ( LA(1) ) { case OPOR: { alt2=1; } break; } switch (alt2) { case 1: // DAAP.g:30:15: OPOR aexpr { OPOR5 = (pANTLR3_COMMON_TOKEN) MATCHT(OPOR, &FOLLOW_OPOR_in_expr65); if (HASEXCEPTION()) { goto ruleexprEx; } OPOR5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OPOR5)); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OPOR5_tree, root_0)); FOLLOWPUSH(FOLLOW_aexpr_in_expr68); aexpr6=aexpr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree); } break; default: goto loop2; /* break out of the loop */ break; } } loop2: ; /* Jump out to here if this rule does not match */ } } // This is where rules clean up and exit // goto ruleexprEx; /* Prevent compiler warnings */ ruleexprEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end expr */ /** * $ANTLR start aexpr * DAAP.g:33:1: aexpr : crit ( OPAND crit )* ; */ static DAAPParser_aexpr_return aexpr(pDAAPParser ctx) { DAAPParser_aexpr_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN OPAND8; DAAPParser_crit_return crit7; #undef RETURN_TYPE_crit7 #define RETURN_TYPE_crit7 DAAPParser_crit_return DAAPParser_crit_return crit9; #undef RETURN_TYPE_crit9 #define RETURN_TYPE_crit9 DAAPParser_crit_return pANTLR3_BASE_TREE OPAND8_tree; /* Initialize rule variables */ root_0 = NULL; OPAND8 = NULL; crit7.tree = NULL; crit9.tree = NULL; retval.start = LT(1); retval.stop = retval.start; OPAND8_tree = NULL; retval.tree = NULL; { // DAAP.g:33:7: ( crit ( OPAND crit )* ) // DAAP.g:33:9: crit ( OPAND crit )* { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); FOLLOWPUSH(FOLLOW_crit_in_aexpr80); crit7=crit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleaexprEx; } ADAPTOR->addChild(ADAPTOR, root_0, crit7.tree); // DAAP.g:33:14: ( OPAND crit )* for (;;) { int alt3=2; switch ( LA(1) ) { case OPAND: { alt3=1; } break; } switch (alt3) { case 1: // DAAP.g:33:15: OPAND crit { OPAND8 = (pANTLR3_COMMON_TOKEN) MATCHT(OPAND, &FOLLOW_OPAND_in_aexpr83); if (HASEXCEPTION()) { goto ruleaexprEx; } OPAND8_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OPAND8)); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OPAND8_tree, root_0)); FOLLOWPUSH(FOLLOW_crit_in_aexpr86); crit9=crit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleaexprEx; } ADAPTOR->addChild(ADAPTOR, root_0, crit9.tree); } break; default: goto loop3; /* break out of the loop */ break; } } loop3: ; /* Jump out to here if this rule does not match */ } } // This is where rules clean up and exit // goto ruleaexprEx; /* Prevent compiler warnings */ ruleaexprEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end aexpr */ /** * $ANTLR start crit * DAAP.g:36:1: crit : ( LPAR expr RPAR -> expr | STR ); */ static DAAPParser_crit_return crit(pDAAPParser ctx) { DAAPParser_crit_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN LPAR10; pANTLR3_COMMON_TOKEN RPAR12; pANTLR3_COMMON_TOKEN STR13; DAAPParser_expr_return expr11; #undef RETURN_TYPE_expr11 #define RETURN_TYPE_expr11 DAAPParser_expr_return pANTLR3_BASE_TREE LPAR10_tree; pANTLR3_BASE_TREE RPAR12_tree; pANTLR3_BASE_TREE STR13_tree; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr; /* Initialize rule variables */ root_0 = NULL; LPAR10 = NULL; RPAR12 = NULL; STR13 = NULL; expr11.tree = NULL; retval.start = LT(1); retval.stop = retval.start; LPAR10_tree = NULL; RPAR12_tree = NULL; STR13_tree = NULL; stream_RPAR = NULL; #define CREATE_stream_RPAR if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); } stream_LPAR = NULL; #define CREATE_stream_LPAR if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); } stream_expr = NULL; #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); } retval.tree = NULL; { { // DAAP.g:36:6: ( LPAR expr RPAR -> expr | STR ) ANTLR3_UINT32 alt4; alt4=2; switch ( LA(1) ) { case LPAR: { alt4=1; } break; case STR: { alt4=2; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 0; goto rulecritEx; } switch (alt4) { case 1: // DAAP.g:36:8: LPAR expr RPAR { LPAR10 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit98); if (HASEXCEPTION()) { goto rulecritEx; } CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR10, NULL); FOLLOWPUSH(FOLLOW_expr_in_crit100); expr11=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulecritEx; } CREATE_stream_expr; stream_expr->add(stream_expr, expr11.tree, NULL); RPAR12 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit102); if (HASEXCEPTION()) { goto rulecritEx; } CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR12, NULL); /* AST REWRITE * elements : expr * token labels : * rule labels : retval * token list labels : * rule list labels : */ { pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); retval.tree = root_0; // 36:24: -> expr { ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr)); } retval.tree = root_0; // set result root if (stream_retval != NULL) stream_retval->free(stream_retval); } } break; case 2: // DAAP.g:37:4: STR { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); STR13 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_crit112); if (HASEXCEPTION()) { goto rulecritEx; } STR13_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, STR13)); ADAPTOR->addChild(ADAPTOR, root_0, STR13_tree); } break; } } } // This is where rules clean up and exit // goto rulecritEx; /* Prevent compiler warnings */ rulecritEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR); if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR); if (stream_expr != NULL) stream_expr->free(stream_expr); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end crit */ /* End of parsing rules * ============================================== */ /* ============================================== * Syntactic predicates */ /* End of syntactic predicates * ============================================== */ /* End of code * ============================================================================= */ forked-daapd-0.19gcd/src/pregen/DAAPParser.h0000664000175000017500000002027611633141361020112 0ustar julienjulien/** \file * This C header file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : DAAP.g * - On : 2011-09-11 16:17:21 * - for the parser : DAAPParserParser * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * * The parser DAAPParser has the callable functions (rules) shown below, * which will invoke the code for the associated rule in the source grammar * assuming that the input stream is pointing to a token/text stream that could begin * this rule. * * For instance if you call the first (topmost) rule in a parser grammar, you will * get the results of a full parse, but calling a rule half way through the grammar will * allow you to pass part of a full token stream to the parser, such as for syntax checking * in editors and so on. * * The parser entry points are called indirectly (by function pointer to function) via * a parser context typedef pDAAPParser, which is returned from a call to DAAPParserNew(). * * The methods in pDAAPParser are as follows: * * - DAAPParser_query_return pDAAPParser->query(pDAAPParser) * - DAAPParser_expr_return pDAAPParser->expr(pDAAPParser) * - DAAPParser_aexpr_return pDAAPParser->aexpr(pDAAPParser) * - DAAPParser_crit_return pDAAPParser->crit(pDAAPParser) * * The return type for any particular rule is of course determined by the source * grammar file. */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _DAAPParser_H #define _DAAPParser_H /* ============================================================================= * Standard antlr3 C runtime definitions */ #include /* End of standard antlr 3 runtime definitions * ============================================================================= */ #ifdef __cplusplus extern "C" { #endif // Forward declare the context typedef so that we can use it before it is // properly defined. Delegators and delegates (from import statements) are // interdependent and their context structures contain pointers to each other // C only allows such things to be declared if you pre-declare the typedef. // typedef struct DAAPParser_Ctx_struct DAAPParser, * pDAAPParser; #ifdef ANTLR3_WINDOWS // Disable: Unreferenced parameter, - Rules with parameters that are not used // constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) // initialized but unused variable - tree rewrite variables declared but not needed // Unreferenced local variable - lexer rule declares but does not always use _type // potentially unitialized variable used - retval always returned from a rule // unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns // // These are only really displayed at warning level /W4 but that is the code ideal I am aiming at // and the codegen must generate some of these warnings by necessity, apart from 4100, which is // usually generated when a parser rule is given a parameter that it does not use. Mostly though // this is a matter of orthogonality hence I disable that one. // #pragma warning( disable : 4100 ) #pragma warning( disable : 4101 ) #pragma warning( disable : 4127 ) #pragma warning( disable : 4189 ) #pragma warning( disable : 4505 ) #pragma warning( disable : 4701 ) #endif typedef struct DAAPParser_query_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } DAAPParser_query_return; typedef struct DAAPParser_expr_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } DAAPParser_expr_return; typedef struct DAAPParser_aexpr_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } DAAPParser_aexpr_return; typedef struct DAAPParser_crit_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } DAAPParser_crit_return; /** Context tracking structure for DAAPParser */ struct DAAPParser_Ctx_struct { /** Built in ANTLR3 context tracker contains all the generic elements * required for context tracking. */ pANTLR3_PARSER pParser; DAAPParser_query_return (*query) (struct DAAPParser_Ctx_struct * ctx); DAAPParser_expr_return (*expr) (struct DAAPParser_Ctx_struct * ctx); DAAPParser_aexpr_return (*aexpr) (struct DAAPParser_Ctx_struct * ctx); DAAPParser_crit_return (*crit) (struct DAAPParser_Ctx_struct * ctx); // Delegated rules const char * (*getGrammarFileName)(); void (*free) (struct DAAPParser_Ctx_struct * ctx); /* @headerFile.members() */ pANTLR3_BASE_TREE_ADAPTOR adaptor; pANTLR3_VECTOR_FACTORY vectors; /* End @headerFile.members() */ }; // Function protoypes for the constructor functions that external translation units // such as delegators and delegates may wish to call. // ANTLR3_API pDAAPParser DAAPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream); ANTLR3_API pDAAPParser DAAPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); /** Symbolic definitions of all the tokens that the parser will work with. * \{ * * Antlr will define EOF, but we can't use that as it it is too common in * in C header files and that would be confusing. There is no way to filter this out at the moment * so we just undef it here for now. That isn't the value we get back from C recognizers * anyway. We are looking for ANTLR3_TOKEN_EOF. */ #ifdef EOF #undef EOF #endif #ifdef Tokens #undef Tokens #endif #define STR 9 #define QUOTE 10 #define NEWLINE 4 #define LPAR 7 #define OPOR 5 #define RPAR 8 #define ESCAPED 11 #define OPAND 6 #define EOF -1 #ifdef EOF #undef EOF #define EOF ANTLR3_TOKEN_EOF #endif #ifndef TOKENSOURCE #define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource #endif /* End of token definitions for DAAPParser * ============================================================================= */ /** \} */ #ifdef __cplusplus } #endif #endif /* END - Note:Keep extra line feed to satisfy UNIX systems */ forked-daapd-0.19gcd/src/pregen/DAAPLexer.c0000664000175000017500000006712211633141361017731 0ustar julienjulien/** \file * This C source file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : DAAP.g * - On : 2011-09-11 16:17:21 * - for the lexer : DAAPLexerLexer * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* ----------------------------------------- * Include the ANTLR3 generated header file. */ #include "DAAPLexer.h" /* ----------------------------------------- */ /* MACROS that hide the C interface implementations from the * generated code, which makes it a little more understandable to the human eye. * I am very much against using C pre-processor macros for function calls and bits * of code as you cannot see what is happening when single stepping in debuggers * and so on. The exception (in my book at least) is for generated code, where you are * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() * hides some indirect calls, but is always referring to the input stream. This is * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig * the runtime interfaces without changing the generated code too often, without * confusing the reader of the generated output, who may not wish to know the gory * details of the interface inheritance. */ #define CTX ctx /* Aids in accessing scopes for grammar programmers */ #undef SCOPE_TYPE #undef SCOPE_STACK #undef SCOPE_TOP #define SCOPE_TYPE(scope) pDAAPLexer_##scope##_SCOPE #define SCOPE_STACK(scope) pDAAPLexer_##scope##Stack #define SCOPE_TOP(scope) ctx->pDAAPLexer_##scope##Top #define SCOPE_SIZE(scope) ctx->pDAAPLexer_##scope##Stack_limit #define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) /* Macros for accessing things in a lexer */ #undef LEXER #undef RECOGNIZER #undef RULEMEMO #undef GETCHARINDEX #undef GETLINE #undef GETCHARPOSITIONINLINE #undef EMIT #undef EMITNEW #undef MATCHC #undef MATCHS #undef MATCHRANGE #undef LTOKEN #undef HASFAILED #undef FAILEDFLAG #undef INPUT #undef STRSTREAM #undef LA #undef HASEXCEPTION #undef EXCEPTION #undef CONSTRUCTEX #undef CONSUME #undef LRECOVER #undef MARK #undef REWIND #undef REWINDLAST #undef BACKTRACKING #undef MATCHANY #undef MEMOIZE #undef HAVEPARSEDRULE #undef GETTEXT #undef INDEX #undef SEEK #undef PUSHSTREAM #undef POPSTREAM #undef SETTEXT #undef SETTEXT8 #define LEXER ctx->pLexer #define RECOGNIZER LEXER->rec #define LEXSTATE RECOGNIZER->state #define TOKSOURCE LEXSTATE->tokSource #define GETCHARINDEX() LEXER->getCharIndex(LEXER) #define GETLINE() LEXER->getLine(LEXER) #define GETTEXT() LEXER->getText(LEXER) #define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER) #define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER) #define EMITNEW(t) LEXER->emitNew(LEXER, t) #define MATCHC(c) LEXER->matchc(LEXER, c) #define MATCHS(s) LEXER->matchs(LEXER, s) #define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2) #define MATCHANY() LEXER->matchAny(LEXER) #define LTOKEN LEXSTATE->token #define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE) #define BACKTRACKING LEXSTATE->backtracking #define FAILEDFLAG LEXSTATE->failed #define INPUT LEXER->input #define STRSTREAM INPUT #define ISTREAM INPUT->istream #define INDEX() ISTREAM->index(ISTREAM) #define SEEK(n) ISTREAM->seek(ISTREAM, n) #define EOF_TOKEN &(LEXSTATE->tokSource->eofToken) #define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE) #define EXCEPTION LEXSTATE->exception #define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) #define LRECOVER() LEXER->recover(LEXER) #define MARK() ISTREAM->mark(ISTREAM) #define REWIND(m) ISTREAM->rewind(ISTREAM, m) #define REWINDLAST() ISTREAM->rewindLast(ISTREAM) #define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) #define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) #define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str) #define POPSTREAM() LEXER->popCharStream(LEXER) #define SETTEXT(str) LEXSTATE->text = str #define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken) #define USER1 LEXSTATE->user1 #define USER2 LEXSTATE->user2 #define USER3 LEXSTATE->user3 #define CUSTOM LEXSTATE->custom #define RULEMEMO LEXSTATE->ruleMemo #define DBG RECOGNIZER->debugger /* If we have been told we can rely on the standard 8 bit or 16 bit input * stream, then we can define our macros to use the direct pointers * in the input object, which is much faster than indirect calls. This * is really only significant to lexers with a lot of fragment rules (which * do not place LA(1) in a temporary at the moment) and even then * only if there is a lot of input (order of say 1M or so). */ #if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16) # ifdef ANTLR3_INLINE_INPUT_ASCII /* 8 bit "ASCII" (actually any 8 bit character set) */ # define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar)) # define DATAP ((pANTLR3_UINT8)(INPUT->data)) # else # define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar)) # define DATAP ((pANTLR3_UINT16)(INPUT->data)) # endif # define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1))) # define CONSUME() \ { \ if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \ { \ INPUT->charPositionInLine++; \ if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \ { \ INPUT->line++; \ INPUT->charPositionInLine = 0; \ INPUT->currentLine = (void *)(NEXTCHAR + 1); \ } \ INPUT->nextChar = (void *)(NEXTCHAR + 1); \ } \ } #else // Pick up the input character by calling the input stream implementation. // #define CONSUME() INPUT->istream->consume(INPUT->istream) #define LA(n) INPUT->istream->_LA(INPUT->istream, n) #endif #define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt /* The 4 tokens defined below may well clash with your own #defines or token types. If so * then for the present you must use different names for your defines as these are hard coded * in the code generator. It would be better not to use such names internally, and maybe * we can change this in a forthcoming release. I deliberately do not #undef these * here as this will at least give you a redefined error somewhere if they clash. */ #define UP ANTLR3_TOKEN_UP #define DOWN ANTLR3_TOKEN_DOWN #define EOR ANTLR3_TOKEN_EOR #define INVALID ANTLR3_TOKEN_INVALID /* ============================================================================= * Functions to create and destroy scopes. First come the rule scopes, followed * by the global declared scopes. */ /* ============================================================================= */ /* ============================================================================= * Start of recognizer */ /* Forward declare the locally static matching functions we have generated and any predicate functions. */ static ANTLR3_INLINE void mQUOTE (pDAAPLexer ctx); static ANTLR3_INLINE void mLPAR (pDAAPLexer ctx); static ANTLR3_INLINE void mRPAR (pDAAPLexer ctx); static ANTLR3_INLINE void mOPAND (pDAAPLexer ctx); static ANTLR3_INLINE void mOPOR (pDAAPLexer ctx); static ANTLR3_INLINE void mNEWLINE (pDAAPLexer ctx); static ANTLR3_INLINE void mSTR (pDAAPLexer ctx); static ANTLR3_INLINE void mESCAPED (pDAAPLexer ctx); static ANTLR3_INLINE void mTokens (pDAAPLexer ctx); static void DAAPLexerFree(pDAAPLexer ctx); /* ========================================================================= * Lexer matching rules end. * ========================================================================= */ static void DAAPLexerFree (pDAAPLexer ctx) { LEXER->free(LEXER); ANTLR3_FREE(ctx); } /** \brief Name of the grammar file that generated this code */ static const char fileName[] = "DAAP.g"; /** \brief Return the name of the grammar file that generated this code. */ static const char * getGrammarFileName() { return fileName; } /** \brief Create a new lexer called DAAPLexer * * \param[in] instream Pointer to an initialized input stream * \return * - Success pDAAPLexer initialized for the lex start * - Fail NULL */ ANTLR3_API pDAAPLexer DAAPLexerNew (pANTLR3_INPUT_STREAM instream) { // See if we can create a new lexer with the standard constructor // return DAAPLexerNewSSD(instream, NULL); } /** \brief Create a new lexer called DAAPLexer * * \param[in] instream Pointer to an initialized input stream * \param[state] state Previously created shared recognizer stat * \return * - Success pDAAPLexer initialized for the lex start * - Fail NULL */ ANTLR3_API pDAAPLexer DAAPLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) { pDAAPLexer ctx; // Context structure we will build and return ctx = (pDAAPLexer) ANTLR3_CALLOC(1, sizeof(DAAPLexer)); if (ctx == NULL) { // Failed to allocate memory for lexer context return NULL; } /* ------------------------------------------------------------------- * Memory for basic structure is allocated, now to fill in * in base ANTLR3 structures. We initialize the function pointers * for the standard ANTLR3 lexer function set, but upon return * from here, the programmer may set the pointers to provide custom * implementations of each function. * * We don't use the macros defined in DAAPLexer.h here so you can get a sense * of what goes where. */ /* Create a base lexer, using the supplied input stream */ ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state); /* Check that we allocated the memory correctly */ if (ctx->pLexer == NULL) { ANTLR3_FREE(ctx); return NULL; } /* Install the implementation of our DAAPLexer interface */ ctx->mQUOTE = mQUOTE; ctx->mLPAR = mLPAR; ctx->mRPAR = mRPAR; ctx->mOPAND = mOPAND; ctx->mOPOR = mOPOR; ctx->mNEWLINE = mNEWLINE; ctx->mSTR = mSTR; ctx->mESCAPED = mESCAPED; ctx->mTokens = mTokens; /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE * it will call mTokens() in this generated code, and will pass it the ctx * pointer of this lexer, not the context of the base lexer, so store that now. */ ctx->pLexer->ctx = ctx; /**Install the token matching function */ ctx->pLexer->mTokens = (void (*) (void *))(mTokens); ctx->getGrammarFileName = getGrammarFileName; ctx->free = DAAPLexerFree; /* Return the newly built lexer to the caller */ return ctx; } /* ========================================================================= * Functions to match the lexer grammar defined tokens from the input stream */ // Comes from: 40:7: ( '\\'' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start QUOTE * * Looks to match the characters the constitute the token QUOTE * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mQUOTE(pDAAPLexer ctx) { ANTLR3_UINT32 _type; _type = QUOTE; // DAAP.g:40:7: ( '\\'' ) // DAAP.g:40:9: '\\'' { MATCHC('\''); if (HASEXCEPTION()) { goto ruleQUOTEEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleQUOTEEx; /* Prevent compiler warnings */ ruleQUOTEEx: ; } // $ANTLR end QUOTE // Comes from: 41:6: ( '(' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start LPAR * * Looks to match the characters the constitute the token LPAR * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mLPAR(pDAAPLexer ctx) { ANTLR3_UINT32 _type; _type = LPAR; // DAAP.g:41:6: ( '(' ) // DAAP.g:41:8: '(' { MATCHC('('); if (HASEXCEPTION()) { goto ruleLPAREx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleLPAREx; /* Prevent compiler warnings */ ruleLPAREx: ; } // $ANTLR end LPAR // Comes from: 42:6: ( ')' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start RPAR * * Looks to match the characters the constitute the token RPAR * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mRPAR(pDAAPLexer ctx) { ANTLR3_UINT32 _type; _type = RPAR; // DAAP.g:42:6: ( ')' ) // DAAP.g:42:8: ')' { MATCHC(')'); if (HASEXCEPTION()) { goto ruleRPAREx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleRPAREx; /* Prevent compiler warnings */ ruleRPAREx: ; } // $ANTLR end RPAR // Comes from: 44:7: ( '+' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start OPAND * * Looks to match the characters the constitute the token OPAND * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mOPAND(pDAAPLexer ctx) { ANTLR3_UINT32 _type; _type = OPAND; // DAAP.g:44:7: ( '+' ) // DAAP.g:44:9: '+' { MATCHC('+'); if (HASEXCEPTION()) { goto ruleOPANDEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleOPANDEx; /* Prevent compiler warnings */ ruleOPANDEx: ; } // $ANTLR end OPAND // Comes from: 45:6: ( ',' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start OPOR * * Looks to match the characters the constitute the token OPOR * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mOPOR(pDAAPLexer ctx) { ANTLR3_UINT32 _type; _type = OPOR; // DAAP.g:45:6: ( ',' ) // DAAP.g:45:8: ',' { MATCHC(','); if (HASEXCEPTION()) { goto ruleOPOREx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleOPOREx; /* Prevent compiler warnings */ ruleOPOREx: ; } // $ANTLR end OPOR // Comes from: 47:9: ( ( '\\r' )? '\\n' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start NEWLINE * * Looks to match the characters the constitute the token NEWLINE * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mNEWLINE(pDAAPLexer ctx) { ANTLR3_UINT32 _type; _type = NEWLINE; // DAAP.g:47:9: ( ( '\\r' )? '\\n' ) // DAAP.g:47:11: ( '\\r' )? '\\n' { // DAAP.g:47:11: ( '\\r' )? { int alt1=2; switch ( LA(1) ) { case '\r': { alt1=1; } break; } switch (alt1) { case 1: // DAAP.g:47:11: '\\r' { MATCHC('\r'); if (HASEXCEPTION()) { goto ruleNEWLINEEx; } } break; } } MATCHC('\n'); if (HASEXCEPTION()) { goto ruleNEWLINEEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleNEWLINEEx; /* Prevent compiler warnings */ ruleNEWLINEEx: ; } // $ANTLR end NEWLINE // Comes from: 55:2: ( QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start STR * * Looks to match the characters the constitute the token STR * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mSTR(pDAAPLexer ctx) { ANTLR3_UINT32 _type; pANTLR3_COMMON_TOKEN esc; ANTLR3_UINT32 reg; esc = NULL; _type = STR; pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory); // DAAP.g:55:2: ( QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE ) // DAAP.g:55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE { /* 55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE */ mQUOTE(ctx ); if (HASEXCEPTION()) { goto ruleSTREx; } // DAAP.g:55:10: (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ { int cnt2=0; for (;;) { int alt2=3; { /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) */ int LA2_0 = LA(1); if ( (((LA2_0 >= 0x0000) && (LA2_0 <= '&')) || ((LA2_0 >= '(') && (LA2_0 <= '[')) || ((LA2_0 >= ']') && (LA2_0 <= 0xFFFF))) ) { alt2=1; } else if ( (LA2_0 == '\\') ) { alt2=2; } } switch (alt2) { case 1: // DAAP.g:55:12: reg=~ ( '\\\\' | '\\'' ) { reg= LA(1); if ( ((LA(1) >= 0x0000) && (LA(1) <= '&')) || ((LA(1) >= '(') && (LA(1) <= '[')) || ((LA(1) >= ']') && (LA(1) <= 0xFFFF)) ) { CONSUME(); } else { CONSTRUCTEX(); EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; LRECOVER(); goto ruleSTREx; } { unesc->addc(unesc, reg); } } break; case 2: // DAAP.g:56:6: esc= ESCAPED { /* 56:6: esc= ESCAPED */ { ANTLR3_MARKER escStart114 = GETCHARINDEX(); mESCAPED(ctx ); if (HASEXCEPTION()) { goto ruleSTREx; } esc = LEXSTATE->tokFactory->newToken(LEXSTATE->tokFactory); esc->setType(esc, ANTLR3_TOKEN_INVALID); esc->setStartIndex(esc, escStart114); esc->setStopIndex(esc, GETCHARINDEX()-1); esc->input = INPUT; } { unesc->appendS(unesc, GETTEXT()); } } break; default: if ( cnt2 >= 1 ) { goto loop2; } /* mismatchedSetEx() */ CONSTRUCTEX(); EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; goto ruleSTREx; } cnt2++; } loop2: ; /* Jump to here if this rule does not match */ } /* 55:4: QUOTE (reg=~ ( '\\\\' | '\\'' ) | esc= ESCAPED )+ QUOTE */ mQUOTE(ctx ); if (HASEXCEPTION()) { goto ruleSTREx; } { SETTEXT(unesc); } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleSTREx; /* Prevent compiler warnings */ ruleSTREx: ; esc = NULL; } // $ANTLR end STR // Comes from: 59:9: ( '\\\\' ( '\\\\' | '\\'' ) ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start ESCAPED * * Looks to match the characters the constitute the token ESCAPED * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mESCAPED(pDAAPLexer ctx) { ANTLR3_UINT32 _type; // DAAP.g:59:9: ( '\\\\' ( '\\\\' | '\\'' ) ) // DAAP.g:59:11: '\\\\' ( '\\\\' | '\\'' ) { MATCHC('\\'); if (HASEXCEPTION()) { goto ruleESCAPEDEx; } // DAAP.g:60:3: ( '\\\\' | '\\'' ) { int alt3=2; switch ( LA(1) ) { case '\\': { alt3=1; } break; case '\'': { alt3=2; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 3; EXCEPTION->state = 0; goto ruleESCAPEDEx; } switch (alt3) { case 1: // DAAP.g:60:5: '\\\\' { MATCHC('\\'); if (HASEXCEPTION()) { goto ruleESCAPEDEx; } { SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\")); } } break; case 2: // DAAP.g:61:5: '\\'' { MATCHC('\''); if (HASEXCEPTION()) { goto ruleESCAPEDEx; } { SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\'")); } } break; } } } // This is where rules clean up and exit // goto ruleESCAPEDEx; /* Prevent compiler warnings */ ruleESCAPEDEx: ; } // $ANTLR end ESCAPED /** This is the entry point in to the lexer from an object that * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM */ static void mTokens(pDAAPLexer ctx) { { // DAAP.g:1:8: ( QUOTE | LPAR | RPAR | OPAND | OPOR | NEWLINE | STR ) ANTLR3_UINT32 alt4; alt4=7; switch ( LA(1) ) { case '\'': { { int LA4_1 = LA(2); if ( (((LA4_1 >= 0x0000) && (LA4_1 <= '&')) || ((LA4_1 >= '(') && (LA4_1 <= 0xFFFF))) ) { alt4=7; } else { alt4=1; } } } break; case '(': { alt4=2; } break; case ')': { alt4=3; } break; case '+': { alt4=4; } break; case ',': { alt4=5; } break; case '\n': case '\r': { alt4=6; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 0; goto ruleTokensEx; } switch (alt4) { case 1: // DAAP.g:1:10: QUOTE { /* 1:10: QUOTE */ mQUOTE(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 2: // DAAP.g:1:16: LPAR { /* 1:16: LPAR */ mLPAR(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 3: // DAAP.g:1:21: RPAR { /* 1:21: RPAR */ mRPAR(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 4: // DAAP.g:1:26: OPAND { /* 1:26: OPAND */ mOPAND(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 5: // DAAP.g:1:32: OPOR { /* 1:32: OPOR */ mOPOR(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 6: // DAAP.g:1:37: NEWLINE { /* 1:37: NEWLINE */ mNEWLINE(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 7: // DAAP.g:1:45: STR { /* 1:45: STR */ mSTR(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; } } goto ruleTokensEx; /* Prevent compiler warnings */ ruleTokensEx: ; } /* ========================================================================= * Lexer matching rules end. * ========================================================================= */ /* End of Lexer code * ================================================ * ================================================ */ /* End of code * ============================================================================= */ forked-daapd-0.19gcd/src/pregen/DAAPLexer.h0000664000175000017500000001656511633141361017743 0ustar julienjulien/** \file * This C header file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : DAAP.g * - On : 2011-09-11 16:17:21 * - for the lexer : DAAPLexerLexer * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * * The lexer DAAPLexer has the callable functions (rules) shown below, * which will invoke the code for the associated rule in the source grammar * assuming that the input stream is pointing to a token/text stream that could begin * this rule. * * For instance if you call the first (topmost) rule in a parser grammar, you will * get the results of a full parse, but calling a rule half way through the grammar will * allow you to pass part of a full token stream to the parser, such as for syntax checking * in editors and so on. * * The parser entry points are called indirectly (by function pointer to function) via * a parser context typedef pDAAPLexer, which is returned from a call to DAAPLexerNew(). * * As this is a generated lexer, it is unlikely you will call it 'manually'. However * the methods are provided anyway. * * The methods in pDAAPLexer are as follows: * * - void pDAAPLexer->QUOTE(pDAAPLexer) * - void pDAAPLexer->LPAR(pDAAPLexer) * - void pDAAPLexer->RPAR(pDAAPLexer) * - void pDAAPLexer->OPAND(pDAAPLexer) * - void pDAAPLexer->OPOR(pDAAPLexer) * - void pDAAPLexer->NEWLINE(pDAAPLexer) * - void pDAAPLexer->STR(pDAAPLexer) * - void pDAAPLexer->ESCAPED(pDAAPLexer) * - void pDAAPLexer->Tokens(pDAAPLexer) * * The return type for any particular rule is of course determined by the source * grammar file. */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _DAAPLexer_H #define _DAAPLexer_H /* ============================================================================= * Standard antlr3 C runtime definitions */ #include /* End of standard antlr 3 runtime definitions * ============================================================================= */ #ifdef __cplusplus extern "C" { #endif // Forward declare the context typedef so that we can use it before it is // properly defined. Delegators and delegates (from import statements) are // interdependent and their context structures contain pointers to each other // C only allows such things to be declared if you pre-declare the typedef. // typedef struct DAAPLexer_Ctx_struct DAAPLexer, * pDAAPLexer; #ifdef ANTLR3_WINDOWS // Disable: Unreferenced parameter, - Rules with parameters that are not used // constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) // initialized but unused variable - tree rewrite variables declared but not needed // Unreferenced local variable - lexer rule declares but does not always use _type // potentially unitialized variable used - retval always returned from a rule // unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns // // These are only really displayed at warning level /W4 but that is the code ideal I am aiming at // and the codegen must generate some of these warnings by necessity, apart from 4100, which is // usually generated when a parser rule is given a parameter that it does not use. Mostly though // this is a matter of orthogonality hence I disable that one. // #pragma warning( disable : 4100 ) #pragma warning( disable : 4101 ) #pragma warning( disable : 4127 ) #pragma warning( disable : 4189 ) #pragma warning( disable : 4505 ) #pragma warning( disable : 4701 ) #endif /** Context tracking structure for DAAPLexer */ struct DAAPLexer_Ctx_struct { /** Built in ANTLR3 context tracker contains all the generic elements * required for context tracking. */ pANTLR3_LEXER pLexer; void (*mQUOTE) (struct DAAPLexer_Ctx_struct * ctx); void (*mLPAR) (struct DAAPLexer_Ctx_struct * ctx); void (*mRPAR) (struct DAAPLexer_Ctx_struct * ctx); void (*mOPAND) (struct DAAPLexer_Ctx_struct * ctx); void (*mOPOR) (struct DAAPLexer_Ctx_struct * ctx); void (*mNEWLINE) (struct DAAPLexer_Ctx_struct * ctx); void (*mSTR) (struct DAAPLexer_Ctx_struct * ctx); void (*mESCAPED) (struct DAAPLexer_Ctx_struct * ctx); void (*mTokens) (struct DAAPLexer_Ctx_struct * ctx); const char * (*getGrammarFileName)(); void (*free) (struct DAAPLexer_Ctx_struct * ctx); }; // Function protoypes for the constructor functions that external translation units // such as delegators and delegates may wish to call. // ANTLR3_API pDAAPLexer DAAPLexerNew (pANTLR3_INPUT_STREAM instream); ANTLR3_API pDAAPLexer DAAPLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); /** Symbolic definitions of all the tokens that the lexer will work with. * \{ * * Antlr will define EOF, but we can't use that as it it is too common in * in C header files and that would be confusing. There is no way to filter this out at the moment * so we just undef it here for now. That isn't the value we get back from C recognizers * anyway. We are looking for ANTLR3_TOKEN_EOF. */ #ifdef EOF #undef EOF #endif #ifdef Tokens #undef Tokens #endif #define STR 9 #define QUOTE 10 #define NEWLINE 4 #define LPAR 7 #define OPOR 5 #define RPAR 8 #define ESCAPED 11 #define OPAND 6 #define EOF -1 #ifdef EOF #undef EOF #define EOF ANTLR3_TOKEN_EOF #endif #ifndef TOKENSOURCE #define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource #endif /* End of token definitions for DAAPLexer * ============================================================================= */ /** \} */ #ifdef __cplusplus } #endif #endif /* END - Note:Keep extra line feed to satisfy UNIX systems */ forked-daapd-0.19gcd/src/pregen/DAAP2SQL.c0000664000175000017500000007541611633141361017400 0ustar julienjulien/** \file * This C source file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : DAAP2SQL.g * - On : 2011-09-11 16:17:21 * - for the tree parser : DAAP2SQLTreeParser * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* ============================================================================= * This is what the grammar programmer asked us to put at the top of every file. */ #include #include #include #include #include #include "logger.h" #include "db.h" #include "daap_query.h" /* End of Header action. * ============================================================================= */ /* ----------------------------------------- * Include the ANTLR3 generated header file. */ #include "DAAP2SQL.h" /* ----------------------------------------- */ /* MACROS that hide the C interface implementations from the * generated code, which makes it a little more understandable to the human eye. * I am very much against using C pre-processor macros for function calls and bits * of code as you cannot see what is happening when single stepping in debuggers * and so on. The exception (in my book at least) is for generated code, where you are * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() * hides some indirect calls, but is always referring to the input stream. This is * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig * the runtime interfaces without changing the generated code too often, without * confusing the reader of the generated output, who may not wish to know the gory * details of the interface inheritance. */ #define CTX ctx /* Aids in accessing scopes for grammar programmers */ #undef SCOPE_TYPE #undef SCOPE_STACK #undef SCOPE_TOP #define SCOPE_TYPE(scope) pDAAP2SQL_##scope##_SCOPE #define SCOPE_STACK(scope) pDAAP2SQL_##scope##Stack #define SCOPE_TOP(scope) ctx->pDAAP2SQL_##scope##Top #define SCOPE_SIZE(scope) ctx->pDAAP2SQL_##scope##Stack_limit #define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) /* Macros for accessing things in the parser */ #undef PARSER #undef RECOGNIZER #undef HAVEPARSEDRULE #undef INPUT #undef STRSTREAM #undef HASEXCEPTION #undef EXCEPTION #undef MATCHT #undef MATCHANYT #undef FOLLOWSTACK #undef FOLLOWPUSH #undef FOLLOWPOP #undef PRECOVER #undef PREPORTERROR #undef LA #undef LT #undef CONSTRUCTEX #undef CONSUME #undef MARK #undef REWIND #undef REWINDLAST #undef PERRORRECOVERY #undef HASFAILED #undef FAILEDFLAG #undef RECOVERFROMMISMATCHEDSET #undef RECOVERFROMMISMATCHEDELEMENT #undef BACKTRACKING #undef ADAPTOR #undef RULEMEMO #undef SEEK #undef INDEX #undef DBG #define PARSER ctx->pTreeParser #define RECOGNIZER PARSER->rec #define PSRSTATE RECOGNIZER->state #define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) #define INPUT PARSER->ctnstream #define ISTREAM INPUT->tnstream->istream #define STRSTREAM INPUT->tnstream #define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE) #define EXCEPTION PSRSTATE->exception #define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs) #define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER) #define FOLLOWSTACK PSRSTATE->following #define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL) #define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK) #define PRECOVER() RECOGNIZER->recover(RECOGNIZER) #define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER) #define LA(n) ISTREAM->_LA(ISTREAM, n) #define LT(n) INPUT->tnstream->_LT(INPUT->tnstream, n) #define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) #define CONSUME() ISTREAM->consume(ISTREAM) #define MARK() ISTREAM->mark(ISTREAM) #define REWIND(m) ISTREAM->rewind(ISTREAM, m) #define REWINDLAST() ISTREAM->rewindLast(ISTREAM) #define PERRORRECOVERY PSRSTATE->errorRecovery #define FAILEDFLAG PSRSTATE->failed #define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE) #define BACKTRACKING PSRSTATE->backtracking #define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s) #define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s) #define ADAPTOR INPUT->adaptor #define RULEMEMO PSRSTATE->ruleMemo #define SEEK(n) ISTREAM->seek(ISTREAM, n) #define INDEX() ISTREAM->index(ISTREAM) #define DBG RECOGNIZER->debugger #define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt /* The 4 tokens defined below may well clash with your own #defines or token types. If so * then for the present you must use different names for your defines as these are hard coded * in the code generator. It would be better not to use such names internally, and maybe * we can change this in a forthcoming release. I deliberately do not #undef these * here as this will at least give you a redefined error somewhere if they clash. */ #define UP ANTLR3_TOKEN_UP #define DOWN ANTLR3_TOKEN_DOWN #define EOR ANTLR3_TOKEN_EOR #define INVALID ANTLR3_TOKEN_INVALID /* ============================================================================= * Functions to create and destroy scopes. First come the rule scopes, followed * by the global declared scopes. */ /* ============================================================================= */ /* ============================================================================= * Start of recognizer */ /** \brief Table of all token names in symbolic order, mainly used for * error reporting. */ pANTLR3_UINT8 DAAP2SQLTokenNames[8+4] = { (pANTLR3_UINT8) "", /* String to print to indicate an invalid token */ (pANTLR3_UINT8) "", (pANTLR3_UINT8) "", (pANTLR3_UINT8) "", (pANTLR3_UINT8) "NEWLINE", (pANTLR3_UINT8) "OPOR", (pANTLR3_UINT8) "OPAND", (pANTLR3_UINT8) "LPAR", (pANTLR3_UINT8) "RPAR", (pANTLR3_UINT8) "STR", (pANTLR3_UINT8) "QUOTE", (pANTLR3_UINT8) "ESCAPED" }; // Forward declare the locally static matching functions we have generated. // static pANTLR3_STRING query (pDAAP2SQL ctx); static DAAP2SQL_expr_return expr (pDAAP2SQL ctx); static void DAAP2SQLFree(pDAAP2SQL ctx); /* For use in tree output where we are accumulating rule labels via label += ruleRef * we need a function that knows how to free a return scope when the list is destroyed. * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro. */ static void ANTLR3_CDECL freeScope(void * scope) { ANTLR3_FREE(scope); } /** \brief Name of the grammar file that generated this code */ static const char fileName[] = "DAAP2SQL.g"; /** \brief Return the name of the grammar file that generated this code. */ static const char * getGrammarFileName() { return fileName; } /** \brief Create a new DAAP2SQL parser and return a context for it. * * \param[in] instream Pointer to an input stream interface. * * \return Pointer to new parser context upon success. */ ANTLR3_API pDAAP2SQL DAAP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream) { // See if we can create a new parser with the standard constructor // return DAAP2SQLNewSSD(instream, NULL); } /** \brief Create a new DAAP2SQL parser and return a context for it. * * \param[in] instream Pointer to an input stream interface. * * \return Pointer to new parser context upon success. */ ANTLR3_API pDAAP2SQL DAAP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) { pDAAP2SQL ctx; /* Context structure we will build and return */ ctx = (pDAAP2SQL) ANTLR3_CALLOC(1, sizeof(DAAP2SQL)); if (ctx == NULL) { // Failed to allocate memory for parser context // return NULL; } /* ------------------------------------------------------------------- * Memory for basic structure is allocated, now to fill in * the base ANTLR3 structures. We initialize the function pointers * for the standard ANTLR3 parser function set, but upon return * from here, the programmer may set the pointers to provide custom * implementations of each function. * * We don't use the macros defined in DAAP2SQL.h here, in order that you can get a sense * of what goes where. */ /* Create a base Tree parser/recognizer, using the supplied tree node stream */ ctx->pTreeParser = antlr3TreeParserNewStream(ANTLR3_SIZE_HINT, instream, state); /* Install the implementation of our DAAP2SQL interface */ ctx->query = query; ctx->expr = expr; ctx->free = DAAP2SQLFree; ctx->getGrammarFileName = getGrammarFileName; /* Install the scope pushing methods. */ /* Install the token table */ PSRSTATE->tokenNames = DAAP2SQLTokenNames; /* Return the newly built parser to the caller */ return ctx; } /** Free the parser resources */ static void DAAP2SQLFree(pDAAP2SQL ctx) { /* Free any scope memory */ // Free this parser // ctx->pTreeParser->free(ctx->pTreeParser); ANTLR3_FREE(ctx); /* Everything is released, so we can return */ return; } /** Return token names used by this tree parser * * The returned pointer is used as an index into the token names table (using the token * number as the index). * * \return Pointer to first char * in the table. */ static pANTLR3_UINT8 *getTokenNames() { return DAAP2SQLTokenNames; } struct dmap_query_field_map { char *dmap_field; char *db_col; int as_int; }; /* gperf static hash, daap_query.gperf */ #include "daap_query_hash.c" /* Declare the bitsets */ /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query70 */ static ANTLR3_BITWORD FOLLOW_expr_in_query70_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_query70 = { FOLLOW_expr_in_query70_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_OPAND_in_expr95 */ static ANTLR3_BITWORD FOLLOW_OPAND_in_expr95_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; static ANTLR3_BITSET_LIST FOLLOW_OPAND_in_expr95 = { FOLLOW_OPAND_in_expr95_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr101 */ static ANTLR3_BITWORD FOLLOW_expr_in_expr101_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000260) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr101 = { FOLLOW_expr_in_expr101_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr107 */ static ANTLR3_BITWORD FOLLOW_expr_in_expr107_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr107 = { FOLLOW_expr_in_expr107_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_OPOR_in_expr118 */ static ANTLR3_BITWORD FOLLOW_OPOR_in_expr118_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; static ANTLR3_BITSET_LIST FOLLOW_OPOR_in_expr118 = { FOLLOW_OPOR_in_expr118_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr124 */ static ANTLR3_BITWORD FOLLOW_expr_in_expr124_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000260) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr124 = { FOLLOW_expr_in_expr124_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr130 */ static ANTLR3_BITWORD FOLLOW_expr_in_expr130_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr130 = { FOLLOW_expr_in_expr130_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_expr140 */ static ANTLR3_BITWORD FOLLOW_STR_in_expr140_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_STR_in_expr140 = { FOLLOW_STR_in_expr140_bits, 1 }; /* ============================================== * Parsing rules */ /** * $ANTLR start query * DAAP2SQL.g:50:1: query returns [ pANTLR3_STRING result ] : e= expr ; */ static pANTLR3_STRING query(pDAAP2SQL ctx) { pANTLR3_STRING result = NULL; DAAP2SQL_expr_return e; #undef RETURN_TYPE_e #define RETURN_TYPE_e DAAP2SQL_expr_return /* Initialize rule variables */ result= NULL; { // DAAP2SQL.g:52:2: (e= expr ) // DAAP2SQL.g:52:4: e= expr { FOLLOWPUSH(FOLLOW_expr_in_query70); e=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulequeryEx; } { if (!e.valid) { result= NULL; } else { result= e.result->factory->newRaw(e.result->factory); result->append8(result, "("); result->appendS(result, e.result); result->append8(result, ")"); } } } } // This is where rules clean up and exit // goto rulequeryEx; /* Prevent compiler warnings */ rulequeryEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return result; } /* $ANTLR end query */ /** * $ANTLR start expr * DAAP2SQL.g:68:1: expr returns [ pANTLR3_STRING result, int valid ] : ( ^( OPAND a= expr b= expr ) | ^( OPOR a= expr b= expr ) | STR ); */ static DAAP2SQL_expr_return expr(pDAAP2SQL ctx) { DAAP2SQL_expr_return retval; pANTLR3_BASE_TREE STR1; DAAP2SQL_expr_return a; #undef RETURN_TYPE_a #define RETURN_TYPE_a DAAP2SQL_expr_return DAAP2SQL_expr_return b; #undef RETURN_TYPE_b #define RETURN_TYPE_b DAAP2SQL_expr_return /* Initialize rule variables */ retval.result= NULL; retval.valid= 1; STR1 = NULL; retval.start = LT(1); retval.stop = retval.start; { { // DAAP2SQL.g:70:2: ( ^( OPAND a= expr b= expr ) | ^( OPOR a= expr b= expr ) | STR ) ANTLR3_UINT32 alt1; alt1=3; switch ( LA(1) ) { case OPAND: { alt1=1; } break; case OPOR: { alt1=2; } break; case STR: { alt1=3; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 0; goto ruleexprEx; } switch (alt1) { case 1: // DAAP2SQL.g:70:4: ^( OPAND a= expr b= expr ) { MATCHT(OPAND, &FOLLOW_OPAND_in_expr95); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_DOWN, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } FOLLOWPUSH(FOLLOW_expr_in_expr101); a=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } FOLLOWPUSH(FOLLOW_expr_in_expr107); b=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_UP, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } { if (!a.valid || !b.valid) { retval.valid= 0; } else { retval.result= a.result->factory->newRaw(a.result->factory); retval.result->append8(retval.result, "("); retval.result->appendS(retval.result, a.result); retval.result->append8(retval.result, " AND "); retval.result->appendS(retval.result, b.result); retval.result->append8(retval.result, ")"); } } } break; case 2: // DAAP2SQL.g:86:4: ^( OPOR a= expr b= expr ) { MATCHT(OPOR, &FOLLOW_OPOR_in_expr118); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_DOWN, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } FOLLOWPUSH(FOLLOW_expr_in_expr124); a=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } FOLLOWPUSH(FOLLOW_expr_in_expr130); b=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_UP, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } { if (!a.valid || !b.valid) { retval.valid= 0; } else { retval.result= a.result->factory->newRaw(a.result->factory); retval.result->append8(retval.result, "("); retval.result->appendS(retval.result, a.result); retval.result->append8(retval.result, " OR "); retval.result->appendS(retval.result, b.result); retval.result->append8(retval.result, ")"); } } } break; case 3: // DAAP2SQL.g:102:4: STR { STR1 = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_expr140); if (HASEXCEPTION()) { goto ruleexprEx; } { pANTLR3_STRING str; pANTLR3_UINT8 field; pANTLR3_UINT8 val; pANTLR3_UINT8 escaped; ANTLR3_UINT8 op; int neg_op; const struct dmap_query_field_map *dqfm; char *end; long long llval; escaped = NULL; retval.result= (STR1->getText(STR1))->factory->newRaw((STR1->getText(STR1))->factory); str = (STR1->getText(STR1))->toUTF8((STR1->getText(STR1))); /* NOTE: the lexer delivers the string without quotes which may not be obvious from the grammar due to embedded code */ /* Make daap.songalbumid:0 a no-op */ if (strcmp((char *)str->chars, "daap.songalbumid:0") == 0) { retval.result->append8(retval.result, "1 = 1"); goto STR_out; } field = str->chars; val = field; while ((*val != '\0') && ((*val == '.') || ((*val >= 'a') && (*val <= 'z')) || ((*val >= 'A') && (*val <= 'Z')) || ((*val >= '0') && (*val <= '9')))) { val++; } if (*field == '\0') { DPRINTF(E_LOG, L_DAAP, "No field name found in clause '%s'\n", field); retval.valid= 0; goto STR_result_valid_0; /* ABORT */ } if (*val == '\0') { DPRINTF(E_LOG, L_DAAP, "No operator found in clause '%s'\n", field); retval.valid= 0; goto STR_result_valid_0; /* ABORT */ } op = *val; *val = '\0'; val++; if (op == '!') { if (*val == '\0') { DPRINTF(E_LOG, L_DAAP, "Negation found but operator missing in clause '%s%c'\n", field, op); retval.valid= 0; goto STR_result_valid_0; /* ABORT */ } neg_op = 1; op = *val; val++; } else neg_op = 0; /* Lookup DMAP field in the query field map */ dqfm = daap_query_field_lookup((char *)field, strlen((char *)field)); if (!dqfm) { DPRINTF(E_LOG, L_DAAP, "DMAP field '%s' is not a valid field in queries\n", field); retval.valid= 0; goto STR_result_valid_0; /* ABORT */ } /* Empty values OK for string fields, NOK for integer */ if (*val == '\0') { if (dqfm->as_int) { DPRINTF(E_LOG, L_DAAP, "No value given in clause '%s%s%c'\n", field, (neg_op) ? "!" : "", op); retval.valid= 0; goto STR_result_valid_0; /* ABORT */ } /* Need to check against NULL too */ if (op == ':') retval.result->append8(retval.result, "("); } retval.result->append8(retval.result, dqfm->db_col); /* Int field: check integer conversion */ if (dqfm->as_int) { errno = 0; llval = strtoll((const char *)val, &end, 10); if (((errno == ERANGE) && ((llval == LLONG_MAX) || (llval == LLONG_MIN))) || ((errno != 0) && (llval == 0))) { DPRINTF(E_LOG, L_DAAP, "Value '%s' in clause '%s%s%c%s' does not convert to an integer type\n", val, field, (neg_op) ? "!" : "", op, val); retval.valid= 0; goto STR_result_valid_0; /* ABORT */ } if (end == (char *)val) { DPRINTF(E_LOG, L_DAAP, "Value '%s' in clause '%s%s%c%s' does not represent an integer value\n", val, field, (neg_op) ? "!" : "", op, val); retval.valid= 0; goto STR_result_valid_0; /* ABORT */ } *end = '\0'; /* Cut out potential garbage - we're being kind */ } /* String field: escape string, check for '*' */ else { if (op != ':') { DPRINTF(E_LOG, L_DAAP, "Operation '%c' not valid for string values\n", op); retval.valid= 0; goto STR_result_valid_0; /* ABORT */ } escaped = (pANTLR3_UINT8)db_escape_string((char *)val); if (!escaped) { DPRINTF(E_LOG, L_DAAP, "Could not escape value\n"); retval.valid= 0; goto STR_result_valid_0; /* ABORT */ } val = escaped; if (val[0] == '*') { op = '%'; val[0] = '%'; } if (val[strlen((char *)val) - 1] == '*') { op = '%'; val[strlen((char *)val) - 1] = '%'; } } switch(op) { case ':': if (neg_op) retval.result->append8(retval.result, " <> "); else retval.result->append8(retval.result, " = "); break; case '+': if (neg_op) retval.result->append8(retval.result, " <= "); else retval.result->append8(retval.result, " > "); break; case '-': if (neg_op) retval.result->append8(retval.result, " >= "); else retval.result->append8(retval.result, " < "); break; case '%': retval.result->append8(retval.result, " LIKE "); break; default: if (neg_op) DPRINTF(E_LOG, L_DAAP, "Missing or unknown operator '%c' in clause '%s!%c%s'\n", op, field, op, val); else DPRINTF(E_LOG, L_DAAP, "Unknown operator '%c' in clause '%s%c%s'\n", op, field, op, val); retval.valid= 0; goto STR_result_valid_0; /* ABORT */ break; } if (!dqfm->as_int) retval.result->append8(retval.result, "'"); retval.result->append8(retval.result, (const char *)val); if (!dqfm->as_int) retval.result->append8(retval.result, "'"); /* For empty string value, we need to check against NULL too */ if ((*val == '\0') && (op == ':')) { if (neg_op) retval.result->append8(retval.result, " AND "); else retval.result->append8(retval.result, " OR "); retval.result->append8(retval.result, dqfm->db_col); if (neg_op) retval.result->append8(retval.result, " IS NOT NULL"); else retval.result->append8(retval.result, " IS NULL"); retval.result->append8(retval.result, ")"); } STR_result_valid_0: /* bail out label */ ; if (escaped) free(escaped); STR_out: /* get out of here */ ; } } break; } } } // This is where rules clean up and exit // goto ruleexprEx; /* Prevent compiler warnings */ ruleexprEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return retval; } /* $ANTLR end expr */ /* End of parsing rules * ============================================== */ /* ============================================== * Syntactic predicates */ /* End of syntactic predicates * ============================================== */ /* End of code * ============================================================================= */ forked-daapd-0.19gcd/src/pregen/DAAP2SQL.h0000664000175000017500000001575511633141361017405 0ustar julienjulien/** \file * This C header file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : DAAP2SQL.g * - On : 2011-09-11 16:17:21 * - for the tree parser : DAAP2SQLTreeParser * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * * The tree parser DAAP2SQL has the callable functions (rules) shown below, * which will invoke the code for the associated rule in the source grammar * assuming that the input stream is pointing to a token/text stream that could begin * this rule. * * For instance if you call the first (topmost) rule in a parser grammar, you will * get the results of a full parse, but calling a rule half way through the grammar will * allow you to pass part of a full token stream to the parser, such as for syntax checking * in editors and so on. * * The parser entry points are called indirectly (by function pointer to function) via * a parser context typedef pDAAP2SQL, which is returned from a call to DAAP2SQLNew(). * * The methods in pDAAP2SQL are as follows: * * - pANTLR3_STRING pDAAP2SQL->query(pDAAP2SQL) * - DAAP2SQL_expr_return pDAAP2SQL->expr(pDAAP2SQL) * * The return type for any particular rule is of course determined by the source * grammar file. */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _DAAP2SQL_H #define _DAAP2SQL_H /* ============================================================================= * Standard antlr3 C runtime definitions */ #include /* End of standard antlr 3 runtime definitions * ============================================================================= */ #ifdef __cplusplus extern "C" { #endif // Forward declare the context typedef so that we can use it before it is // properly defined. Delegators and delegates (from import statements) are // interdependent and their context structures contain pointers to each other // C only allows such things to be declared if you pre-declare the typedef. // typedef struct DAAP2SQL_Ctx_struct DAAP2SQL, * pDAAP2SQL; #include #include #include #include #include #include "logger.h" #include "db.h" #include "daap_query.h" #ifdef ANTLR3_WINDOWS // Disable: Unreferenced parameter, - Rules with parameters that are not used // constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) // initialized but unused variable - tree rewrite variables declared but not needed // Unreferenced local variable - lexer rule declares but does not always use _type // potentially unitialized variable used - retval always returned from a rule // unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns // // These are only really displayed at warning level /W4 but that is the code ideal I am aiming at // and the codegen must generate some of these warnings by necessity, apart from 4100, which is // usually generated when a parser rule is given a parameter that it does not use. Mostly though // this is a matter of orthogonality hence I disable that one. // #pragma warning( disable : 4100 ) #pragma warning( disable : 4101 ) #pragma warning( disable : 4127 ) #pragma warning( disable : 4189 ) #pragma warning( disable : 4505 ) #pragma warning( disable : 4701 ) #endif typedef struct DAAP2SQL_expr_return_struct { pANTLR3_BASE_TREE start; pANTLR3_BASE_TREE stop; pANTLR3_STRING result; int valid; } DAAP2SQL_expr_return; /** Context tracking structure for DAAP2SQL */ struct DAAP2SQL_Ctx_struct { /** Built in ANTLR3 context tracker contains all the generic elements * required for context tracking. */ pANTLR3_TREE_PARSER pTreeParser; pANTLR3_STRING (*query) (struct DAAP2SQL_Ctx_struct * ctx); DAAP2SQL_expr_return (*expr) (struct DAAP2SQL_Ctx_struct * ctx); // Delegated rules const char * (*getGrammarFileName)(); void (*free) (struct DAAP2SQL_Ctx_struct * ctx); }; // Function protoypes for the constructor functions that external translation units // such as delegators and delegates may wish to call. // ANTLR3_API pDAAP2SQL DAAP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream); ANTLR3_API pDAAP2SQL DAAP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); /** Symbolic definitions of all the tokens that the tree parser will work with. * \{ * * Antlr will define EOF, but we can't use that as it it is too common in * in C header files and that would be confusing. There is no way to filter this out at the moment * so we just undef it here for now. That isn't the value we get back from C recognizers * anyway. We are looking for ANTLR3_TOKEN_EOF. */ #ifdef EOF #undef EOF #endif #ifdef Tokens #undef Tokens #endif #define STR 9 #define QUOTE 10 #define NEWLINE 4 #define LPAR 7 #define OPOR 5 #define RPAR 8 #define ESCAPED 11 #define OPAND 6 #define EOF -1 #ifdef EOF #undef EOF #define EOF ANTLR3_TOKEN_EOF #endif #ifndef TOKENSOURCE #define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource #endif /* End of token definitions for DAAP2SQL * ============================================================================= */ /** \} */ #ifdef __cplusplus } #endif #endif /* END - Note:Keep extra line feed to satisfy UNIX systems */ forked-daapd-0.19gcd/src/pregen/RSPParser.c0000664000175000017500000026346111633141362020052 0ustar julienjulien/** \file * This C source file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : RSP.g * - On : 2011-09-11 16:17:22 * - for the parser : RSPParserParser * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* ----------------------------------------- * Include the ANTLR3 generated header file. */ #include "RSPParser.h" /* ----------------------------------------- */ /* MACROS that hide the C interface implementations from the * generated code, which makes it a little more understandable to the human eye. * I am very much against using C pre-processor macros for function calls and bits * of code as you cannot see what is happening when single stepping in debuggers * and so on. The exception (in my book at least) is for generated code, where you are * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() * hides some indirect calls, but is always referring to the input stream. This is * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig * the runtime interfaces without changing the generated code too often, without * confusing the reader of the generated output, who may not wish to know the gory * details of the interface inheritance. */ #define CTX ctx /* Aids in accessing scopes for grammar programmers */ #undef SCOPE_TYPE #undef SCOPE_STACK #undef SCOPE_TOP #define SCOPE_TYPE(scope) pRSPParser_##scope##_SCOPE #define SCOPE_STACK(scope) pRSPParser_##scope##Stack #define SCOPE_TOP(scope) ctx->pRSPParser_##scope##Top #define SCOPE_SIZE(scope) ctx->pRSPParser_##scope##Stack_limit #define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) /* Macros for accessing things in the parser */ #undef PARSER #undef RECOGNIZER #undef HAVEPARSEDRULE #undef MEMOIZE #undef INPUT #undef STRSTREAM #undef HASEXCEPTION #undef EXCEPTION #undef MATCHT #undef MATCHANYT #undef FOLLOWSTACK #undef FOLLOWPUSH #undef FOLLOWPOP #undef PRECOVER #undef PREPORTERROR #undef LA #undef LT #undef CONSTRUCTEX #undef CONSUME #undef MARK #undef REWIND #undef REWINDLAST #undef PERRORRECOVERY #undef HASFAILED #undef FAILEDFLAG #undef RECOVERFROMMISMATCHEDSET #undef RECOVERFROMMISMATCHEDELEMENT #undef INDEX #undef ADAPTOR #undef SEEK #undef RULEMEMO #undef DBG #define PARSER ctx->pParser #define RECOGNIZER PARSER->rec #define PSRSTATE RECOGNIZER->state #define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) #define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) #define INPUT PARSER->tstream #define STRSTREAM INPUT #define ISTREAM INPUT->istream #define INDEX() ISTREAM->index(INPUT->istream) #define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE) #define EXCEPTION PSRSTATE->exception #define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs) #define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER) #define FOLLOWSTACK PSRSTATE->following #define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL) #define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK) #define PRECOVER() RECOGNIZER->recover(RECOGNIZER) #define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER) #define LA(n) INPUT->istream->_LA(ISTREAM, n) #define LT(n) INPUT->_LT(INPUT, n) #define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) #define CONSUME() ISTREAM->consume(ISTREAM) #define MARK() ISTREAM->mark(ISTREAM) #define REWIND(m) ISTREAM->rewind(ISTREAM, m) #define REWINDLAST() ISTREAM->rewindLast(ISTREAM) #define SEEK(n) ISTREAM->seek(ISTREAM, n) #define PERRORRECOVERY PSRSTATE->errorRecovery #define FAILEDFLAG PSRSTATE->failed #define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE) #define BACKTRACKING PSRSTATE->backtracking #define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s) #define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s) #define ADAPTOR ctx->adaptor #define RULEMEMO PSRSTATE->ruleMemo #define DBG RECOGNIZER->debugger #define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt /* The 4 tokens defined below may well clash with your own #defines or token types. If so * then for the present you must use different names for your defines as these are hard coded * in the code generator. It would be better not to use such names internally, and maybe * we can change this in a forthcoming release. I deliberately do not #undef these * here as this will at least give you a redefined error somewhere if they clash. */ #define UP ANTLR3_TOKEN_UP #define DOWN ANTLR3_TOKEN_DOWN #define EOR ANTLR3_TOKEN_EOR #define INVALID ANTLR3_TOKEN_INVALID /* ============================================================================= * Functions to create and destroy scopes. First come the rule scopes, followed * by the global declared scopes. */ /* ============================================================================= */ /* ============================================================================= * Start of recognizer */ /** \brief Table of all token names in symbolic order, mainly used for * error reporting. */ pANTLR3_UINT8 RSPParserTokenNames[30+4] = { (pANTLR3_UINT8) "", /* String to print to indicate an invalid token */ (pANTLR3_UINT8) "", (pANTLR3_UINT8) "", (pANTLR3_UINT8) "", (pANTLR3_UINT8) "NEWLINE", (pANTLR3_UINT8) "OR", (pANTLR3_UINT8) "AND", (pANTLR3_UINT8) "LPAR", (pANTLR3_UINT8) "RPAR", (pANTLR3_UINT8) "FIELD", (pANTLR3_UINT8) "STR", (pANTLR3_UINT8) "NOT", (pANTLR3_UINT8) "EQUAL", (pANTLR3_UINT8) "INCLUDES", (pANTLR3_UINT8) "STARTSW", (pANTLR3_UINT8) "ENDSW", (pANTLR3_UINT8) "INT", (pANTLR3_UINT8) "LESS", (pANTLR3_UINT8) "GREATER", (pANTLR3_UINT8) "LTE", (pANTLR3_UINT8) "GTE", (pANTLR3_UINT8) "BEFORE", (pANTLR3_UINT8) "AFTER", (pANTLR3_UINT8) "DATE", (pANTLR3_UINT8) "TODAY", (pANTLR3_UINT8) "DAY", (pANTLR3_UINT8) "WEEK", (pANTLR3_UINT8) "MONTH", (pANTLR3_UINT8) "YEAR", (pANTLR3_UINT8) "QUOTE", (pANTLR3_UINT8) "WS", (pANTLR3_UINT8) "DIGIT19", (pANTLR3_UINT8) "DIGIT09", (pANTLR3_UINT8) "ESCAPED" }; // Forward declare the locally static matching functions we have generated. // static RSPParser_query_return query (pRSPParser ctx); static RSPParser_expr_return expr (pRSPParser ctx); static RSPParser_aexpr_return aexpr (pRSPParser ctx); static RSPParser_crit_return crit (pRSPParser ctx); static RSPParser_strcrit_return strcrit (pRSPParser ctx); static RSPParser_strop_return strop (pRSPParser ctx); static RSPParser_intcrit_return intcrit (pRSPParser ctx); static RSPParser_intop_return intop (pRSPParser ctx); static RSPParser_datecrit_return datecrit (pRSPParser ctx); static RSPParser_dateop_return dateop (pRSPParser ctx); static RSPParser_datespec_return datespec (pRSPParser ctx); static RSPParser_dateref_return dateref (pRSPParser ctx); static RSPParser_dateintval_return dateintval (pRSPParser ctx); static void RSPParserFree(pRSPParser ctx); /* For use in tree output where we are accumulating rule labels via label += ruleRef * we need a function that knows how to free a return scope when the list is destroyed. * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro. */ static void ANTLR3_CDECL freeScope(void * scope) { ANTLR3_FREE(scope); } /** \brief Name of the grammar file that generated this code */ static const char fileName[] = "RSP.g"; /** \brief Return the name of the grammar file that generated this code. */ static const char * getGrammarFileName() { return fileName; } /** \brief Create a new RSPParser parser and return a context for it. * * \param[in] instream Pointer to an input stream interface. * * \return Pointer to new parser context upon success. */ ANTLR3_API pRSPParser RSPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream) { // See if we can create a new parser with the standard constructor // return RSPParserNewSSD(instream, NULL); } /** \brief Create a new RSPParser parser and return a context for it. * * \param[in] instream Pointer to an input stream interface. * * \return Pointer to new parser context upon success. */ ANTLR3_API pRSPParser RSPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) { pRSPParser ctx; /* Context structure we will build and return */ ctx = (pRSPParser) ANTLR3_CALLOC(1, sizeof(RSPParser)); if (ctx == NULL) { // Failed to allocate memory for parser context // return NULL; } /* ------------------------------------------------------------------- * Memory for basic structure is allocated, now to fill in * the base ANTLR3 structures. We initialize the function pointers * for the standard ANTLR3 parser function set, but upon return * from here, the programmer may set the pointers to provide custom * implementations of each function. * * We don't use the macros defined in RSPParser.h here, in order that you can get a sense * of what goes where. */ /* Create a base parser/recognizer, using the supplied token stream */ ctx->pParser = antlr3ParserNewStream(ANTLR3_SIZE_HINT, instream->tstream, state); /* Install the implementation of our RSPParser interface */ ctx->query = query; ctx->expr = expr; ctx->aexpr = aexpr; ctx->crit = crit; ctx->strcrit = strcrit; ctx->strop = strop; ctx->intcrit = intcrit; ctx->intop = intop; ctx->datecrit = datecrit; ctx->dateop = dateop; ctx->datespec = datespec; ctx->dateref = dateref; ctx->dateintval = dateintval; ctx->free = RSPParserFree; ctx->getGrammarFileName = getGrammarFileName; /* Install the scope pushing methods. */ ADAPTOR = ANTLR3_TREE_ADAPTORNew(instream->tstream->tokenSource->strFactory); ctx->vectors = antlr3VectorFactoryNew(0); /* Install the token table */ PSRSTATE->tokenNames = RSPParserTokenNames; /* Return the newly built parser to the caller */ return ctx; } /** Free the parser resources */ static void RSPParserFree(pRSPParser ctx) { /* Free any scope memory */ ctx->vectors->close(ctx->vectors); /* We created the adaptor so we must free it */ ADAPTOR->free(ADAPTOR); // Free this parser // ctx->pParser->free(ctx->pParser); ANTLR3_FREE(ctx); /* Everything is released, so we can return */ return; } /** Return token names used by this parser * * The returned pointer is used as an index into the token names table (using the token * number as the index). * * \return Pointer to first char * in the table. */ static pANTLR3_UINT8 *getTokenNames() { return RSPParserTokenNames; } /* Declare the bitsets */ /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query42 */ static ANTLR3_BITWORD FOLLOW_expr_in_query42_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000010) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_query42 = { FOLLOW_expr_in_query42_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_NEWLINE_in_query44 */ static ANTLR3_BITWORD FOLLOW_NEWLINE_in_query44_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000000) }; static ANTLR3_BITSET_LIST FOLLOW_NEWLINE_in_query44 = { FOLLOW_NEWLINE_in_query44_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_EOF_in_query47 */ static ANTLR3_BITWORD FOLLOW_EOF_in_query47_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_EOF_in_query47 = { FOLLOW_EOF_in_query47_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr63 */ static ANTLR3_BITWORD FOLLOW_aexpr_in_expr63_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) }; static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr63 = { FOLLOW_aexpr_in_expr63_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expr66 */ static ANTLR3_BITWORD FOLLOW_OR_in_expr66_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; static ANTLR3_BITSET_LIST FOLLOW_OR_in_expr66 = { FOLLOW_OR_in_expr66_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_aexpr_in_expr69 */ static ANTLR3_BITWORD FOLLOW_aexpr_in_expr69_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000022) }; static ANTLR3_BITSET_LIST FOLLOW_aexpr_in_expr69 = { FOLLOW_aexpr_in_expr69_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr81 */ static ANTLR3_BITWORD FOLLOW_crit_in_aexpr81_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) }; static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr81 = { FOLLOW_crit_in_aexpr81_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_aexpr84 */ static ANTLR3_BITWORD FOLLOW_AND_in_aexpr84_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; static ANTLR3_BITSET_LIST FOLLOW_AND_in_aexpr84 = { FOLLOW_AND_in_aexpr84_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_crit_in_aexpr87 */ static ANTLR3_BITWORD FOLLOW_crit_in_aexpr87_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000042) }; static ANTLR3_BITSET_LIST FOLLOW_crit_in_aexpr87 = { FOLLOW_crit_in_aexpr87_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_LPAR_in_crit99 */ static ANTLR3_BITWORD FOLLOW_LPAR_in_crit99_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000280) }; static ANTLR3_BITSET_LIST FOLLOW_LPAR_in_crit99 = { FOLLOW_LPAR_in_crit99_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_crit101 */ static ANTLR3_BITWORD FOLLOW_expr_in_crit101_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000100) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_crit101 = { FOLLOW_expr_in_crit101_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_RPAR_in_crit103 */ static ANTLR3_BITWORD FOLLOW_RPAR_in_crit103_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_RPAR_in_crit103 = { FOLLOW_RPAR_in_crit103_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_crit114 */ static ANTLR3_BITWORD FOLLOW_strcrit_in_crit114_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_crit114 = { FOLLOW_strcrit_in_crit114_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_crit119 */ static ANTLR3_BITWORD FOLLOW_intcrit_in_crit119_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_crit119 = { FOLLOW_intcrit_in_crit119_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_datecrit_in_crit124 */ static ANTLR3_BITWORD FOLLOW_datecrit_in_crit124_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_datecrit_in_crit124 = { FOLLOW_datecrit_in_crit124_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit134 */ static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit134_bits[] = { ANTLR3_UINT64_LIT(0x000000000000F000) }; static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit134 = { FOLLOW_FIELD_in_strcrit134_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit136 */ static ANTLR3_BITWORD FOLLOW_strop_in_strcrit136_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) }; static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit136 = { FOLLOW_strop_in_strcrit136_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit138 */ static ANTLR3_BITWORD FOLLOW_STR_in_strcrit138_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit138 = { FOLLOW_STR_in_strcrit138_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit155 */ static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit155_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000800) }; static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit155 = { FOLLOW_FIELD_in_strcrit155_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_strcrit157 */ static ANTLR3_BITWORD FOLLOW_NOT_in_strcrit157_bits[] = { ANTLR3_UINT64_LIT(0x000000000000F000) }; static ANTLR3_BITSET_LIST FOLLOW_NOT_in_strcrit157 = { FOLLOW_NOT_in_strcrit157_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit159 */ static ANTLR3_BITWORD FOLLOW_strop_in_strcrit159_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) }; static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit159 = { FOLLOW_strop_in_strcrit159_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit161 */ static ANTLR3_BITWORD FOLLOW_STR_in_strcrit161_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit161 = { FOLLOW_STR_in_strcrit161_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_strop0 */ static ANTLR3_BITWORD FOLLOW_set_in_strop0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_set_in_strop0 = { FOLLOW_set_in_strop0_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit211 */ static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit211_bits[] = { ANTLR3_UINT64_LIT(0x00000000001E1000) }; static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit211 = { FOLLOW_FIELD_in_intcrit211_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit213 */ static ANTLR3_BITWORD FOLLOW_intop_in_intcrit213_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit213 = { FOLLOW_intop_in_intcrit213_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit215 */ static ANTLR3_BITWORD FOLLOW_INT_in_intcrit215_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit215 = { FOLLOW_INT_in_intcrit215_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit232 */ static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit232_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000800) }; static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit232 = { FOLLOW_FIELD_in_intcrit232_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_intcrit234 */ static ANTLR3_BITWORD FOLLOW_NOT_in_intcrit234_bits[] = { ANTLR3_UINT64_LIT(0x00000000001E1000) }; static ANTLR3_BITSET_LIST FOLLOW_NOT_in_intcrit234 = { FOLLOW_NOT_in_intcrit234_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit236 */ static ANTLR3_BITWORD FOLLOW_intop_in_intcrit236_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit236 = { FOLLOW_intop_in_intcrit236_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit238 */ static ANTLR3_BITWORD FOLLOW_INT_in_intcrit238_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit238 = { FOLLOW_INT_in_intcrit238_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_intop0 */ static ANTLR3_BITWORD FOLLOW_set_in_intop0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_set_in_intop0 = { FOLLOW_set_in_intop0_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_datecrit292 */ static ANTLR3_BITWORD FOLLOW_FIELD_in_datecrit292_bits[] = { ANTLR3_UINT64_LIT(0x0000000000600000) }; static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_datecrit292 = { FOLLOW_FIELD_in_datecrit292_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datecrit294 */ static ANTLR3_BITWORD FOLLOW_dateop_in_datecrit294_bits[] = { ANTLR3_UINT64_LIT(0x0000000001810000) }; static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datecrit294 = { FOLLOW_dateop_in_datecrit294_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_datespec_in_datecrit296 */ static ANTLR3_BITWORD FOLLOW_datespec_in_datecrit296_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_datespec_in_datecrit296 = { FOLLOW_datespec_in_datecrit296_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateop0 */ static ANTLR3_BITWORD FOLLOW_set_in_dateop0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_set_in_dateop0 = { FOLLOW_set_in_dateop0_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec331 */ static ANTLR3_BITWORD FOLLOW_dateref_in_datespec331_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec331 = { FOLLOW_dateref_in_datespec331_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_datespec336 */ static ANTLR3_BITWORD FOLLOW_INT_in_datespec336_bits[] = { ANTLR3_UINT64_LIT(0x000000001E000000) }; static ANTLR3_BITSET_LIST FOLLOW_INT_in_datespec336 = { FOLLOW_INT_in_datespec336_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_dateintval_in_datespec338 */ static ANTLR3_BITWORD FOLLOW_dateintval_in_datespec338_bits[] = { ANTLR3_UINT64_LIT(0x0000000000600000) }; static ANTLR3_BITSET_LIST FOLLOW_dateintval_in_datespec338 = { FOLLOW_dateintval_in_datespec338_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datespec340 */ static ANTLR3_BITWORD FOLLOW_dateop_in_datespec340_bits[] = { ANTLR3_UINT64_LIT(0x0000000001800000) }; static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datespec340 = { FOLLOW_dateop_in_datespec340_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec342 */ static ANTLR3_BITWORD FOLLOW_dateref_in_datespec342_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec342 = { FOLLOW_dateref_in_datespec342_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateref0 */ static ANTLR3_BITWORD FOLLOW_set_in_dateref0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_set_in_dateref0 = { FOLLOW_set_in_dateref0_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_set_in_dateintval0 */ static ANTLR3_BITWORD FOLLOW_set_in_dateintval0_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_set_in_dateintval0 = { FOLLOW_set_in_dateintval0_bits, 1 }; /* ============================================== * Parsing rules */ /** * $ANTLR start query * RSP.g:27:1: query : expr ( NEWLINE )? EOF -> expr ; */ static RSPParser_query_return query(pRSPParser ctx) { RSPParser_query_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN NEWLINE2; pANTLR3_COMMON_TOKEN EOF3; RSPParser_expr_return expr1; #undef RETURN_TYPE_expr1 #define RETURN_TYPE_expr1 RSPParser_expr_return pANTLR3_BASE_TREE NEWLINE2_tree; pANTLR3_BASE_TREE EOF3_tree; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NEWLINE; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_EOF; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr; /* Initialize rule variables */ root_0 = NULL; NEWLINE2 = NULL; EOF3 = NULL; expr1.tree = NULL; retval.start = LT(1); retval.stop = retval.start; NEWLINE2_tree = NULL; EOF3_tree = NULL; stream_NEWLINE = NULL; #define CREATE_stream_NEWLINE if (stream_NEWLINE == NULL) {stream_NEWLINE = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NEWLINE"); } stream_EOF = NULL; #define CREATE_stream_EOF if (stream_EOF == NULL) {stream_EOF = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token EOF"); } stream_expr = NULL; #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); } retval.tree = NULL; { // RSP.g:27:7: ( expr ( NEWLINE )? EOF -> expr ) // RSP.g:27:9: expr ( NEWLINE )? EOF { FOLLOWPUSH(FOLLOW_expr_in_query42); expr1=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulequeryEx; } CREATE_stream_expr; stream_expr->add(stream_expr, expr1.tree, NULL); // RSP.g:27:14: ( NEWLINE )? { int alt1=2; switch ( LA(1) ) { case NEWLINE: { alt1=1; } break; } switch (alt1) { case 1: // RSP.g:27:14: NEWLINE { NEWLINE2 = (pANTLR3_COMMON_TOKEN) MATCHT(NEWLINE, &FOLLOW_NEWLINE_in_query44); if (HASEXCEPTION()) { goto rulequeryEx; } CREATE_stream_NEWLINE; stream_NEWLINE->add(stream_NEWLINE, NEWLINE2, NULL); } break; } } EOF3 = (pANTLR3_COMMON_TOKEN) MATCHT(EOF, &FOLLOW_EOF_in_query47); if (HASEXCEPTION()) { goto rulequeryEx; } CREATE_stream_EOF; stream_EOF->add(stream_EOF, EOF3, NULL); /* AST REWRITE * elements : expr * token labels : * rule labels : retval * token list labels : * rule list labels : */ { pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); retval.tree = root_0; // 27:28: -> expr { ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr)); } retval.tree = root_0; // set result root if (stream_retval != NULL) stream_retval->free(stream_retval); } } } // This is where rules clean up and exit // goto rulequeryEx; /* Prevent compiler warnings */ rulequeryEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (stream_NEWLINE != NULL) stream_NEWLINE->free(stream_NEWLINE); if (stream_EOF != NULL) stream_EOF->free(stream_EOF); if (stream_expr != NULL) stream_expr->free(stream_expr); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end query */ /** * $ANTLR start expr * RSP.g:30:1: expr : aexpr ( OR aexpr )* ; */ static RSPParser_expr_return expr(pRSPParser ctx) { RSPParser_expr_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN OR5; RSPParser_aexpr_return aexpr4; #undef RETURN_TYPE_aexpr4 #define RETURN_TYPE_aexpr4 RSPParser_aexpr_return RSPParser_aexpr_return aexpr6; #undef RETURN_TYPE_aexpr6 #define RETURN_TYPE_aexpr6 RSPParser_aexpr_return pANTLR3_BASE_TREE OR5_tree; /* Initialize rule variables */ root_0 = NULL; OR5 = NULL; aexpr4.tree = NULL; aexpr6.tree = NULL; retval.start = LT(1); retval.stop = retval.start; OR5_tree = NULL; retval.tree = NULL; { // RSP.g:30:6: ( aexpr ( OR aexpr )* ) // RSP.g:30:8: aexpr ( OR aexpr )* { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); FOLLOWPUSH(FOLLOW_aexpr_in_expr63); aexpr4=aexpr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } ADAPTOR->addChild(ADAPTOR, root_0, aexpr4.tree); // RSP.g:30:14: ( OR aexpr )* for (;;) { int alt2=2; switch ( LA(1) ) { case OR: { alt2=1; } break; } switch (alt2) { case 1: // RSP.g:30:15: OR aexpr { OR5 = (pANTLR3_COMMON_TOKEN) MATCHT(OR, &FOLLOW_OR_in_expr66); if (HASEXCEPTION()) { goto ruleexprEx; } OR5_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, OR5)); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, OR5_tree, root_0)); FOLLOWPUSH(FOLLOW_aexpr_in_expr69); aexpr6=aexpr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } ADAPTOR->addChild(ADAPTOR, root_0, aexpr6.tree); } break; default: goto loop2; /* break out of the loop */ break; } } loop2: ; /* Jump out to here if this rule does not match */ } } // This is where rules clean up and exit // goto ruleexprEx; /* Prevent compiler warnings */ ruleexprEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end expr */ /** * $ANTLR start aexpr * RSP.g:33:1: aexpr : crit ( AND crit )* ; */ static RSPParser_aexpr_return aexpr(pRSPParser ctx) { RSPParser_aexpr_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN AND8; RSPParser_crit_return crit7; #undef RETURN_TYPE_crit7 #define RETURN_TYPE_crit7 RSPParser_crit_return RSPParser_crit_return crit9; #undef RETURN_TYPE_crit9 #define RETURN_TYPE_crit9 RSPParser_crit_return pANTLR3_BASE_TREE AND8_tree; /* Initialize rule variables */ root_0 = NULL; AND8 = NULL; crit7.tree = NULL; crit9.tree = NULL; retval.start = LT(1); retval.stop = retval.start; AND8_tree = NULL; retval.tree = NULL; { // RSP.g:33:7: ( crit ( AND crit )* ) // RSP.g:33:9: crit ( AND crit )* { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); FOLLOWPUSH(FOLLOW_crit_in_aexpr81); crit7=crit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleaexprEx; } ADAPTOR->addChild(ADAPTOR, root_0, crit7.tree); // RSP.g:33:14: ( AND crit )* for (;;) { int alt3=2; switch ( LA(1) ) { case AND: { alt3=1; } break; } switch (alt3) { case 1: // RSP.g:33:15: AND crit { AND8 = (pANTLR3_COMMON_TOKEN) MATCHT(AND, &FOLLOW_AND_in_aexpr84); if (HASEXCEPTION()) { goto ruleaexprEx; } AND8_tree = (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, AND8)); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, AND8_tree, root_0)); FOLLOWPUSH(FOLLOW_crit_in_aexpr87); crit9=crit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleaexprEx; } ADAPTOR->addChild(ADAPTOR, root_0, crit9.tree); } break; default: goto loop3; /* break out of the loop */ break; } } loop3: ; /* Jump out to here if this rule does not match */ } } // This is where rules clean up and exit // goto ruleaexprEx; /* Prevent compiler warnings */ ruleaexprEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end aexpr */ /** * $ANTLR start crit * RSP.g:36:1: crit : ( LPAR expr RPAR -> expr | strcrit | intcrit | datecrit ); */ static RSPParser_crit_return crit(pRSPParser ctx) { RSPParser_crit_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN LPAR10; pANTLR3_COMMON_TOKEN RPAR12; RSPParser_expr_return expr11; #undef RETURN_TYPE_expr11 #define RETURN_TYPE_expr11 RSPParser_expr_return RSPParser_strcrit_return strcrit13; #undef RETURN_TYPE_strcrit13 #define RETURN_TYPE_strcrit13 RSPParser_strcrit_return RSPParser_intcrit_return intcrit14; #undef RETURN_TYPE_intcrit14 #define RETURN_TYPE_intcrit14 RSPParser_intcrit_return RSPParser_datecrit_return datecrit15; #undef RETURN_TYPE_datecrit15 #define RETURN_TYPE_datecrit15 RSPParser_datecrit_return pANTLR3_BASE_TREE LPAR10_tree; pANTLR3_BASE_TREE RPAR12_tree; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_RPAR; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_LPAR; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_expr; /* Initialize rule variables */ root_0 = NULL; LPAR10 = NULL; RPAR12 = NULL; expr11.tree = NULL; strcrit13.tree = NULL; intcrit14.tree = NULL; datecrit15.tree = NULL; retval.start = LT(1); retval.stop = retval.start; LPAR10_tree = NULL; RPAR12_tree = NULL; stream_RPAR = NULL; #define CREATE_stream_RPAR if (stream_RPAR == NULL) {stream_RPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token RPAR"); } stream_LPAR = NULL; #define CREATE_stream_LPAR if (stream_LPAR == NULL) {stream_LPAR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token LPAR"); } stream_expr = NULL; #define CREATE_stream_expr if (stream_expr == NULL) {stream_expr = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule expr"); } retval.tree = NULL; { { // RSP.g:36:6: ( LPAR expr RPAR -> expr | strcrit | intcrit | datecrit ) ANTLR3_UINT32 alt4; alt4=4; switch ( LA(1) ) { case LPAR: { alt4=1; } break; case FIELD: { switch ( LA(2) ) { case NOT: { switch ( LA(3) ) { case EQUAL: { switch ( LA(4) ) { case STR: { alt4=2; } break; case INT: { alt4=3; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 8; goto rulecritEx; } } break; case INCLUDES: case STARTSW: case ENDSW: { alt4=2; } break; case LESS: case GREATER: case LTE: case GTE: { alt4=3; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 3; goto rulecritEx; } } break; case EQUAL: { switch ( LA(3) ) { case INT: { alt4=3; } break; case STR: { alt4=2; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 4; goto rulecritEx; } } break; case BEFORE: case AFTER: { alt4=4; } break; case LESS: case GREATER: case LTE: case GTE: { alt4=3; } break; case INCLUDES: case STARTSW: case ENDSW: { alt4=2; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 2; goto rulecritEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 0; goto rulecritEx; } switch (alt4) { case 1: // RSP.g:36:8: LPAR expr RPAR { LPAR10 = (pANTLR3_COMMON_TOKEN) MATCHT(LPAR, &FOLLOW_LPAR_in_crit99); if (HASEXCEPTION()) { goto rulecritEx; } CREATE_stream_LPAR; stream_LPAR->add(stream_LPAR, LPAR10, NULL); FOLLOWPUSH(FOLLOW_expr_in_crit101); expr11=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulecritEx; } CREATE_stream_expr; stream_expr->add(stream_expr, expr11.tree, NULL); RPAR12 = (pANTLR3_COMMON_TOKEN) MATCHT(RPAR, &FOLLOW_RPAR_in_crit103); if (HASEXCEPTION()) { goto rulecritEx; } CREATE_stream_RPAR; stream_RPAR->add(stream_RPAR, RPAR12, NULL); /* AST REWRITE * elements : expr * token labels : * rule labels : retval * token list labels : * rule list labels : */ { pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); retval.tree = root_0; // 36:25: -> expr { ADAPTOR->addChild(ADAPTOR, root_0, stream_expr == NULL ? NULL : stream_expr->nextTree(stream_expr)); } retval.tree = root_0; // set result root if (stream_retval != NULL) stream_retval->free(stream_retval); } } break; case 2: // RSP.g:37:4: strcrit { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); FOLLOWPUSH(FOLLOW_strcrit_in_crit114); strcrit13=strcrit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulecritEx; } ADAPTOR->addChild(ADAPTOR, root_0, strcrit13.tree); } break; case 3: // RSP.g:38:4: intcrit { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); FOLLOWPUSH(FOLLOW_intcrit_in_crit119); intcrit14=intcrit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulecritEx; } ADAPTOR->addChild(ADAPTOR, root_0, intcrit14.tree); } break; case 4: // RSP.g:39:4: datecrit { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); FOLLOWPUSH(FOLLOW_datecrit_in_crit124); datecrit15=datecrit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulecritEx; } ADAPTOR->addChild(ADAPTOR, root_0, datecrit15.tree); } break; } } } // This is where rules clean up and exit // goto rulecritEx; /* Prevent compiler warnings */ rulecritEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (stream_RPAR != NULL) stream_RPAR->free(stream_RPAR); if (stream_LPAR != NULL) stream_LPAR->free(stream_LPAR); if (stream_expr != NULL) stream_expr->free(stream_expr); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end crit */ /** * $ANTLR start strcrit * RSP.g:42:1: strcrit : ( FIELD strop STR -> ^( strop FIELD STR ) | FIELD NOT strop STR -> ^( NOT ^( strop FIELD STR ) ) ); */ static RSPParser_strcrit_return strcrit(pRSPParser ctx) { RSPParser_strcrit_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN FIELD16; pANTLR3_COMMON_TOKEN STR18; pANTLR3_COMMON_TOKEN FIELD19; pANTLR3_COMMON_TOKEN NOT20; pANTLR3_COMMON_TOKEN STR22; RSPParser_strop_return strop17; #undef RETURN_TYPE_strop17 #define RETURN_TYPE_strop17 RSPParser_strop_return RSPParser_strop_return strop21; #undef RETURN_TYPE_strop21 #define RETURN_TYPE_strop21 RSPParser_strop_return pANTLR3_BASE_TREE FIELD16_tree; pANTLR3_BASE_TREE STR18_tree; pANTLR3_BASE_TREE FIELD19_tree; pANTLR3_BASE_TREE NOT20_tree; pANTLR3_BASE_TREE STR22_tree; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_STR; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NOT; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_strop; /* Initialize rule variables */ root_0 = NULL; FIELD16 = NULL; STR18 = NULL; FIELD19 = NULL; NOT20 = NULL; STR22 = NULL; strop17.tree = NULL; strop21.tree = NULL; retval.start = LT(1); retval.stop = retval.start; FIELD16_tree = NULL; STR18_tree = NULL; FIELD19_tree = NULL; NOT20_tree = NULL; STR22_tree = NULL; stream_STR = NULL; #define CREATE_stream_STR if (stream_STR == NULL) {stream_STR = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token STR"); } stream_FIELD = NULL; #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); } stream_NOT = NULL; #define CREATE_stream_NOT if (stream_NOT == NULL) {stream_NOT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NOT"); } stream_strop = NULL; #define CREATE_stream_strop if (stream_strop == NULL) {stream_strop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule strop"); } retval.tree = NULL; { { // RSP.g:42:9: ( FIELD strop STR -> ^( strop FIELD STR ) | FIELD NOT strop STR -> ^( NOT ^( strop FIELD STR ) ) ) ANTLR3_UINT32 alt5; alt5=2; switch ( LA(1) ) { case FIELD: { switch ( LA(2) ) { case NOT: { alt5=2; } break; case EQUAL: case INCLUDES: case STARTSW: case ENDSW: { alt5=1; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 5; EXCEPTION->state = 1; goto rulestrcritEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 5; EXCEPTION->state = 0; goto rulestrcritEx; } switch (alt5) { case 1: // RSP.g:42:11: FIELD strop STR { FIELD16 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit134); if (HASEXCEPTION()) { goto rulestrcritEx; } CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD16, NULL); FOLLOWPUSH(FOLLOW_strop_in_strcrit136); strop17=strop(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulestrcritEx; } CREATE_stream_strop; stream_strop->add(stream_strop, strop17.tree, NULL); STR18 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_strcrit138); if (HASEXCEPTION()) { goto rulestrcritEx; } CREATE_stream_STR; stream_STR->add(stream_STR, STR18, NULL); /* AST REWRITE * elements : strop, FIELD, STR * token labels : * rule labels : retval * token list labels : * rule list labels : */ { pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); retval.tree = root_0; // 42:29: -> ^( strop FIELD STR ) { // RSP.g:42:32: ^( strop FIELD STR ) { pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_strop == NULL ? NULL : stream_strop->nextNode(stream_strop), root_1)); ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD)); ADAPTOR->addChild(ADAPTOR, root_1, stream_STR == NULL ? NULL : stream_STR->nextNode(stream_STR)); ADAPTOR->addChild(ADAPTOR, root_0, root_1); } } retval.tree = root_0; // set result root if (stream_retval != NULL) stream_retval->free(stream_retval); } } break; case 2: // RSP.g:43:4: FIELD NOT strop STR { FIELD19 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit155); if (HASEXCEPTION()) { goto rulestrcritEx; } CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD19, NULL); NOT20 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_strcrit157); if (HASEXCEPTION()) { goto rulestrcritEx; } CREATE_stream_NOT; stream_NOT->add(stream_NOT, NOT20, NULL); FOLLOWPUSH(FOLLOW_strop_in_strcrit159); strop21=strop(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulestrcritEx; } CREATE_stream_strop; stream_strop->add(stream_strop, strop21.tree, NULL); STR22 = (pANTLR3_COMMON_TOKEN) MATCHT(STR, &FOLLOW_STR_in_strcrit161); if (HASEXCEPTION()) { goto rulestrcritEx; } CREATE_stream_STR; stream_STR->add(stream_STR, STR22, NULL); /* AST REWRITE * elements : STR, FIELD, NOT, strop * token labels : * rule labels : retval * token list labels : * rule list labels : */ { pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); retval.tree = root_0; // 43:25: -> ^( NOT ^( strop FIELD STR ) ) { // RSP.g:43:28: ^( NOT ^( strop FIELD STR ) ) { pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_NOT == NULL ? NULL : stream_NOT->nextNode(stream_NOT), root_1)); // RSP.g:43:34: ^( strop FIELD STR ) { pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_strop == NULL ? NULL : stream_strop->nextNode(stream_strop), root_2)); ADAPTOR->addChild(ADAPTOR, root_2, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD)); ADAPTOR->addChild(ADAPTOR, root_2, stream_STR == NULL ? NULL : stream_STR->nextNode(stream_STR)); ADAPTOR->addChild(ADAPTOR, root_1, root_2); } ADAPTOR->addChild(ADAPTOR, root_0, root_1); } } retval.tree = root_0; // set result root if (stream_retval != NULL) stream_retval->free(stream_retval); } } break; } } } // This is where rules clean up and exit // goto rulestrcritEx; /* Prevent compiler warnings */ rulestrcritEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (stream_STR != NULL) stream_STR->free(stream_STR); if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD); if (stream_NOT != NULL) stream_NOT->free(stream_NOT); if (stream_strop != NULL) stream_strop->free(stream_strop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end strcrit */ /** * $ANTLR start strop * RSP.g:46:1: strop : ( EQUAL | INCLUDES | STARTSW | ENDSW ); */ static RSPParser_strop_return strop(pRSPParser ctx) { RSPParser_strop_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN set23; pANTLR3_BASE_TREE set23_tree; /* Initialize rule variables */ root_0 = NULL; set23 = NULL; retval.start = LT(1); retval.stop = retval.start; set23_tree = NULL; retval.tree = NULL; { // RSP.g:46:7: ( EQUAL | INCLUDES | STARTSW | ENDSW ) // RSP.g: { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); set23=(pANTLR3_COMMON_TOKEN)LT(1); if ( ((LA(1) >= EQUAL) && (LA(1) <= ENDSW)) ) { CONSUME(); ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set23))); PERRORRECOVERY=ANTLR3_FALSE; } else { CONSTRUCTEX(); EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; EXCEPTION->expectingSet = &FOLLOW_set_in_strop0; RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_strop0); goto rulestropEx; } } } // This is where rules clean up and exit // goto rulestropEx; /* Prevent compiler warnings */ rulestropEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end strop */ /** * $ANTLR start intcrit * RSP.g:52:1: intcrit : ( FIELD intop INT -> ^( intop FIELD INT ) | FIELD NOT intop INT -> ^( NOT ^( intop FIELD INT ) ) ); */ static RSPParser_intcrit_return intcrit(pRSPParser ctx) { RSPParser_intcrit_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN FIELD24; pANTLR3_COMMON_TOKEN INT26; pANTLR3_COMMON_TOKEN FIELD27; pANTLR3_COMMON_TOKEN NOT28; pANTLR3_COMMON_TOKEN INT30; RSPParser_intop_return intop25; #undef RETURN_TYPE_intop25 #define RETURN_TYPE_intop25 RSPParser_intop_return RSPParser_intop_return intop29; #undef RETURN_TYPE_intop29 #define RETURN_TYPE_intop29 RSPParser_intop_return pANTLR3_BASE_TREE FIELD24_tree; pANTLR3_BASE_TREE INT26_tree; pANTLR3_BASE_TREE FIELD27_tree; pANTLR3_BASE_TREE NOT28_tree; pANTLR3_BASE_TREE INT30_tree; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_INT; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_NOT; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_intop; /* Initialize rule variables */ root_0 = NULL; FIELD24 = NULL; INT26 = NULL; FIELD27 = NULL; NOT28 = NULL; INT30 = NULL; intop25.tree = NULL; intop29.tree = NULL; retval.start = LT(1); retval.stop = retval.start; FIELD24_tree = NULL; INT26_tree = NULL; FIELD27_tree = NULL; NOT28_tree = NULL; INT30_tree = NULL; stream_FIELD = NULL; #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); } stream_INT = NULL; #define CREATE_stream_INT if (stream_INT == NULL) {stream_INT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token INT"); } stream_NOT = NULL; #define CREATE_stream_NOT if (stream_NOT == NULL) {stream_NOT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token NOT"); } stream_intop = NULL; #define CREATE_stream_intop if (stream_intop == NULL) {stream_intop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule intop"); } retval.tree = NULL; { { // RSP.g:52:9: ( FIELD intop INT -> ^( intop FIELD INT ) | FIELD NOT intop INT -> ^( NOT ^( intop FIELD INT ) ) ) ANTLR3_UINT32 alt6; alt6=2; switch ( LA(1) ) { case FIELD: { switch ( LA(2) ) { case NOT: { alt6=2; } break; case EQUAL: case LESS: case GREATER: case LTE: case GTE: { alt6=1; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 6; EXCEPTION->state = 1; goto ruleintcritEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 6; EXCEPTION->state = 0; goto ruleintcritEx; } switch (alt6) { case 1: // RSP.g:52:11: FIELD intop INT { FIELD24 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit211); if (HASEXCEPTION()) { goto ruleintcritEx; } CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD24, NULL); FOLLOWPUSH(FOLLOW_intop_in_intcrit213); intop25=intop(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleintcritEx; } CREATE_stream_intop; stream_intop->add(stream_intop, intop25.tree, NULL); INT26 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_intcrit215); if (HASEXCEPTION()) { goto ruleintcritEx; } CREATE_stream_INT; stream_INT->add(stream_INT, INT26, NULL); /* AST REWRITE * elements : intop, INT, FIELD * token labels : * rule labels : retval * token list labels : * rule list labels : */ { pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); retval.tree = root_0; // 52:29: -> ^( intop FIELD INT ) { // RSP.g:52:32: ^( intop FIELD INT ) { pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_intop == NULL ? NULL : stream_intop->nextNode(stream_intop), root_1)); ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD)); ADAPTOR->addChild(ADAPTOR, root_1, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT)); ADAPTOR->addChild(ADAPTOR, root_0, root_1); } } retval.tree = root_0; // set result root if (stream_retval != NULL) stream_retval->free(stream_retval); } } break; case 2: // RSP.g:53:4: FIELD NOT intop INT { FIELD27 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit232); if (HASEXCEPTION()) { goto ruleintcritEx; } CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD27, NULL); NOT28 = (pANTLR3_COMMON_TOKEN) MATCHT(NOT, &FOLLOW_NOT_in_intcrit234); if (HASEXCEPTION()) { goto ruleintcritEx; } CREATE_stream_NOT; stream_NOT->add(stream_NOT, NOT28, NULL); FOLLOWPUSH(FOLLOW_intop_in_intcrit236); intop29=intop(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleintcritEx; } CREATE_stream_intop; stream_intop->add(stream_intop, intop29.tree, NULL); INT30 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_intcrit238); if (HASEXCEPTION()) { goto ruleintcritEx; } CREATE_stream_INT; stream_INT->add(stream_INT, INT30, NULL); /* AST REWRITE * elements : intop, NOT, INT, FIELD * token labels : * rule labels : retval * token list labels : * rule list labels : */ { pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); retval.tree = root_0; // 53:25: -> ^( NOT ^( intop FIELD INT ) ) { // RSP.g:53:28: ^( NOT ^( intop FIELD INT ) ) { pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_NOT == NULL ? NULL : stream_NOT->nextNode(stream_NOT), root_1)); // RSP.g:53:34: ^( intop FIELD INT ) { pANTLR3_BASE_TREE root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); root_2 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_intop == NULL ? NULL : stream_intop->nextNode(stream_intop), root_2)); ADAPTOR->addChild(ADAPTOR, root_2, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD)); ADAPTOR->addChild(ADAPTOR, root_2, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT)); ADAPTOR->addChild(ADAPTOR, root_1, root_2); } ADAPTOR->addChild(ADAPTOR, root_0, root_1); } } retval.tree = root_0; // set result root if (stream_retval != NULL) stream_retval->free(stream_retval); } } break; } } } // This is where rules clean up and exit // goto ruleintcritEx; /* Prevent compiler warnings */ ruleintcritEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD); if (stream_INT != NULL) stream_INT->free(stream_INT); if (stream_NOT != NULL) stream_NOT->free(stream_NOT); if (stream_intop != NULL) stream_intop->free(stream_intop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end intcrit */ /** * $ANTLR start intop * RSP.g:56:1: intop : ( EQUAL | LESS | GREATER | LTE | GTE ); */ static RSPParser_intop_return intop(pRSPParser ctx) { RSPParser_intop_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN set31; pANTLR3_BASE_TREE set31_tree; /* Initialize rule variables */ root_0 = NULL; set31 = NULL; retval.start = LT(1); retval.stop = retval.start; set31_tree = NULL; retval.tree = NULL; { // RSP.g:56:7: ( EQUAL | LESS | GREATER | LTE | GTE ) // RSP.g: { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); set31=(pANTLR3_COMMON_TOKEN)LT(1); if ( LA(1) == EQUAL || ((LA(1) >= LESS) && (LA(1) <= GTE)) ) { CONSUME(); ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set31))); PERRORRECOVERY=ANTLR3_FALSE; } else { CONSTRUCTEX(); EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; EXCEPTION->expectingSet = &FOLLOW_set_in_intop0; RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_intop0); goto ruleintopEx; } } } // This is where rules clean up and exit // goto ruleintopEx; /* Prevent compiler warnings */ ruleintopEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end intop */ /** * $ANTLR start datecrit * RSP.g:63:1: datecrit : FIELD dateop datespec -> ^( dateop FIELD datespec ) ; */ static RSPParser_datecrit_return datecrit(pRSPParser ctx) { RSPParser_datecrit_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN FIELD32; RSPParser_dateop_return dateop33; #undef RETURN_TYPE_dateop33 #define RETURN_TYPE_dateop33 RSPParser_dateop_return RSPParser_datespec_return datespec34; #undef RETURN_TYPE_datespec34 #define RETURN_TYPE_datespec34 RSPParser_datespec_return pANTLR3_BASE_TREE FIELD32_tree; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_FIELD; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_datespec; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateop; /* Initialize rule variables */ root_0 = NULL; FIELD32 = NULL; dateop33.tree = NULL; datespec34.tree = NULL; retval.start = LT(1); retval.stop = retval.start; FIELD32_tree = NULL; stream_FIELD = NULL; #define CREATE_stream_FIELD if (stream_FIELD == NULL) {stream_FIELD = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token FIELD"); } stream_datespec = NULL; #define CREATE_stream_datespec if (stream_datespec == NULL) {stream_datespec = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule datespec"); } stream_dateop = NULL; #define CREATE_stream_dateop if (stream_dateop == NULL) {stream_dateop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateop"); } retval.tree = NULL; { // RSP.g:63:9: ( FIELD dateop datespec -> ^( dateop FIELD datespec ) ) // RSP.g:63:11: FIELD dateop datespec { FIELD32 = (pANTLR3_COMMON_TOKEN) MATCHT(FIELD, &FOLLOW_FIELD_in_datecrit292); if (HASEXCEPTION()) { goto ruledatecritEx; } CREATE_stream_FIELD; stream_FIELD->add(stream_FIELD, FIELD32, NULL); FOLLOWPUSH(FOLLOW_dateop_in_datecrit294); dateop33=dateop(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatecritEx; } CREATE_stream_dateop; stream_dateop->add(stream_dateop, dateop33.tree, NULL); FOLLOWPUSH(FOLLOW_datespec_in_datecrit296); datespec34=datespec(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatecritEx; } CREATE_stream_datespec; stream_datespec->add(stream_datespec, datespec34.tree, NULL); /* AST REWRITE * elements : FIELD, datespec, dateop * token labels : * rule labels : retval * token list labels : * rule list labels : */ { pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); retval.tree = root_0; // 63:34: -> ^( dateop FIELD datespec ) { // RSP.g:63:37: ^( dateop FIELD datespec ) { pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_dateop == NULL ? NULL : stream_dateop->nextNode(stream_dateop), root_1)); ADAPTOR->addChild(ADAPTOR, root_1, stream_FIELD == NULL ? NULL : stream_FIELD->nextNode(stream_FIELD)); ADAPTOR->addChild(ADAPTOR, root_1, stream_datespec == NULL ? NULL : stream_datespec->nextTree(stream_datespec)); ADAPTOR->addChild(ADAPTOR, root_0, root_1); } } retval.tree = root_0; // set result root if (stream_retval != NULL) stream_retval->free(stream_retval); } } } // This is where rules clean up and exit // goto ruledatecritEx; /* Prevent compiler warnings */ ruledatecritEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (stream_FIELD != NULL) stream_FIELD->free(stream_FIELD); if (stream_datespec != NULL) stream_datespec->free(stream_datespec); if (stream_dateop != NULL) stream_dateop->free(stream_dateop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end datecrit */ /** * $ANTLR start dateop * RSP.g:66:1: dateop : ( BEFORE | AFTER ); */ static RSPParser_dateop_return dateop(pRSPParser ctx) { RSPParser_dateop_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN set35; pANTLR3_BASE_TREE set35_tree; /* Initialize rule variables */ root_0 = NULL; set35 = NULL; retval.start = LT(1); retval.stop = retval.start; set35_tree = NULL; retval.tree = NULL; { // RSP.g:66:8: ( BEFORE | AFTER ) // RSP.g: { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); set35=(pANTLR3_COMMON_TOKEN)LT(1); if ( ((LA(1) >= BEFORE) && (LA(1) <= AFTER)) ) { CONSUME(); ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set35))); PERRORRECOVERY=ANTLR3_FALSE; } else { CONSTRUCTEX(); EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; EXCEPTION->expectingSet = &FOLLOW_set_in_dateop0; RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateop0); goto ruledateopEx; } } } // This is where rules clean up and exit // goto ruledateopEx; /* Prevent compiler warnings */ ruledateopEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end dateop */ /** * $ANTLR start datespec * RSP.g:70:1: datespec : ( dateref | INT dateintval dateop dateref -> ^( dateop dateref INT dateintval ) ); */ static RSPParser_datespec_return datespec(pRSPParser ctx) { RSPParser_datespec_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN INT37; RSPParser_dateref_return dateref36; #undef RETURN_TYPE_dateref36 #define RETURN_TYPE_dateref36 RSPParser_dateref_return RSPParser_dateintval_return dateintval38; #undef RETURN_TYPE_dateintval38 #define RETURN_TYPE_dateintval38 RSPParser_dateintval_return RSPParser_dateop_return dateop39; #undef RETURN_TYPE_dateop39 #define RETURN_TYPE_dateop39 RSPParser_dateop_return RSPParser_dateref_return dateref40; #undef RETURN_TYPE_dateref40 #define RETURN_TYPE_dateref40 RSPParser_dateref_return pANTLR3_BASE_TREE INT37_tree; pANTLR3_REWRITE_RULE_TOKEN_STREAM stream_INT; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateintval; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateref; pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_dateop; /* Initialize rule variables */ root_0 = NULL; INT37 = NULL; dateref36.tree = NULL; dateintval38.tree = NULL; dateop39.tree = NULL; dateref40.tree = NULL; retval.start = LT(1); retval.stop = retval.start; INT37_tree = NULL; stream_INT = NULL; #define CREATE_stream_INT if (stream_INT == NULL) {stream_INT = antlr3RewriteRuleTOKENStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token INT"); } stream_dateintval = NULL; #define CREATE_stream_dateintval if (stream_dateintval == NULL) {stream_dateintval = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateintval"); } stream_dateref = NULL; #define CREATE_stream_dateref if (stream_dateref == NULL) {stream_dateref = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateref"); } stream_dateop = NULL; #define CREATE_stream_dateop if (stream_dateop == NULL) {stream_dateop = antlr3RewriteRuleSubtreeStreamNewAE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"rule dateop"); } retval.tree = NULL; { { // RSP.g:70:9: ( dateref | INT dateintval dateop dateref -> ^( dateop dateref INT dateintval ) ) ANTLR3_UINT32 alt7; alt7=2; switch ( LA(1) ) { case DATE: case TODAY: { alt7=1; } break; case INT: { alt7=2; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 7; EXCEPTION->state = 0; goto ruledatespecEx; } switch (alt7) { case 1: // RSP.g:70:11: dateref { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); FOLLOWPUSH(FOLLOW_dateref_in_datespec331); dateref36=dateref(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatespecEx; } ADAPTOR->addChild(ADAPTOR, root_0, dateref36.tree); } break; case 2: // RSP.g:71:4: INT dateintval dateop dateref { INT37 = (pANTLR3_COMMON_TOKEN) MATCHT(INT, &FOLLOW_INT_in_datespec336); if (HASEXCEPTION()) { goto ruledatespecEx; } CREATE_stream_INT; stream_INT->add(stream_INT, INT37, NULL); FOLLOWPUSH(FOLLOW_dateintval_in_datespec338); dateintval38=dateintval(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatespecEx; } CREATE_stream_dateintval; stream_dateintval->add(stream_dateintval, dateintval38.tree, NULL); FOLLOWPUSH(FOLLOW_dateop_in_datespec340); dateop39=dateop(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatespecEx; } CREATE_stream_dateop; stream_dateop->add(stream_dateop, dateop39.tree, NULL); FOLLOWPUSH(FOLLOW_dateref_in_datespec342); dateref40=dateref(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatespecEx; } CREATE_stream_dateref; stream_dateref->add(stream_dateref, dateref40.tree, NULL); /* AST REWRITE * elements : dateintval, dateref, dateop, INT * token labels : * rule labels : retval * token list labels : * rule list labels : */ { pANTLR3_REWRITE_RULE_SUBTREE_STREAM stream_retval; stream_retval=antlr3RewriteRuleSubtreeStreamNewAEE(ADAPTOR, RECOGNIZER, (pANTLR3_UINT8)"token retval", retval.tree != NULL ? retval.tree : NULL); root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); retval.tree = root_0; // 71:34: -> ^( dateop dateref INT dateintval ) { // RSP.g:71:37: ^( dateop dateref INT dateintval ) { pANTLR3_BASE_TREE root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); root_1 = (pANTLR3_BASE_TREE)(ADAPTOR->becomeRoot(ADAPTOR, stream_dateop == NULL ? NULL : stream_dateop->nextNode(stream_dateop), root_1)); ADAPTOR->addChild(ADAPTOR, root_1, stream_dateref == NULL ? NULL : stream_dateref->nextTree(stream_dateref)); ADAPTOR->addChild(ADAPTOR, root_1, stream_INT == NULL ? NULL : stream_INT->nextNode(stream_INT)); ADAPTOR->addChild(ADAPTOR, root_1, stream_dateintval == NULL ? NULL : stream_dateintval->nextTree(stream_dateintval)); ADAPTOR->addChild(ADAPTOR, root_0, root_1); } } retval.tree = root_0; // set result root if (stream_retval != NULL) stream_retval->free(stream_retval); } } break; } } } // This is where rules clean up and exit // goto ruledatespecEx; /* Prevent compiler warnings */ ruledatespecEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (stream_INT != NULL) stream_INT->free(stream_INT); if (stream_dateintval != NULL) stream_dateintval->free(stream_dateintval); if (stream_dateref != NULL) stream_dateref->free(stream_dateref); if (stream_dateop != NULL) stream_dateop->free(stream_dateop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end datespec */ /** * $ANTLR start dateref * RSP.g:74:1: dateref : ( DATE | TODAY ); */ static RSPParser_dateref_return dateref(pRSPParser ctx) { RSPParser_dateref_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN set41; pANTLR3_BASE_TREE set41_tree; /* Initialize rule variables */ root_0 = NULL; set41 = NULL; retval.start = LT(1); retval.stop = retval.start; set41_tree = NULL; retval.tree = NULL; { // RSP.g:74:9: ( DATE | TODAY ) // RSP.g: { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); set41=(pANTLR3_COMMON_TOKEN)LT(1); if ( ((LA(1) >= DATE) && (LA(1) <= TODAY)) ) { CONSUME(); ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set41))); PERRORRECOVERY=ANTLR3_FALSE; } else { CONSTRUCTEX(); EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; EXCEPTION->expectingSet = &FOLLOW_set_in_dateref0; RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateref0); goto ruledaterefEx; } } } // This is where rules clean up and exit // goto ruledaterefEx; /* Prevent compiler warnings */ ruledaterefEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end dateref */ /** * $ANTLR start dateintval * RSP.g:78:1: dateintval : ( DAY | WEEK | MONTH | YEAR ); */ static RSPParser_dateintval_return dateintval(pRSPParser ctx) { RSPParser_dateintval_return retval; pANTLR3_BASE_TREE root_0; pANTLR3_COMMON_TOKEN set42; pANTLR3_BASE_TREE set42_tree; /* Initialize rule variables */ root_0 = NULL; set42 = NULL; retval.start = LT(1); retval.stop = retval.start; set42_tree = NULL; retval.tree = NULL; { // RSP.g:79:2: ( DAY | WEEK | MONTH | YEAR ) // RSP.g: { root_0 = (pANTLR3_BASE_TREE)(ADAPTOR->nilNode(ADAPTOR)); set42=(pANTLR3_COMMON_TOKEN)LT(1); if ( ((LA(1) >= DAY) && (LA(1) <= YEAR)) ) { CONSUME(); ADAPTOR->addChild(ADAPTOR, root_0, (pANTLR3_BASE_TREE)(ADAPTOR->create(ADAPTOR, set42))); PERRORRECOVERY=ANTLR3_FALSE; } else { CONSTRUCTEX(); EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; EXCEPTION->expectingSet = &FOLLOW_set_in_dateintval0; RECOVERFROMMISMATCHEDSET(&FOLLOW_set_in_dateintval0); goto ruledateintvalEx; } } } // This is where rules clean up and exit // goto ruledateintvalEx; /* Prevent compiler warnings */ ruledateintvalEx: ; retval.stop = LT(-1); retval.stop = LT(-1); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->rulePostProcessing(ADAPTOR, root_0)); ADAPTOR->setTokenBoundaries(ADAPTOR, retval.tree, retval.start, retval.stop); if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); retval.tree = (pANTLR3_BASE_TREE)(ADAPTOR->errorNode(ADAPTOR, INPUT, retval.start, LT(-1), EXCEPTION)); } return retval; } /* $ANTLR end dateintval */ /* End of parsing rules * ============================================== */ /* ============================================== * Syntactic predicates */ /* End of syntactic predicates * ============================================== */ /* End of code * ============================================================================= */ forked-daapd-0.19gcd/src/pregen/RSPParser.h0000664000175000017500000003065411633141362020053 0ustar julienjulien/** \file * This C header file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : RSP.g * - On : 2011-09-11 16:17:22 * - for the parser : RSPParserParser * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * * The parser RSPParser has the callable functions (rules) shown below, * which will invoke the code for the associated rule in the source grammar * assuming that the input stream is pointing to a token/text stream that could begin * this rule. * * For instance if you call the first (topmost) rule in a parser grammar, you will * get the results of a full parse, but calling a rule half way through the grammar will * allow you to pass part of a full token stream to the parser, such as for syntax checking * in editors and so on. * * The parser entry points are called indirectly (by function pointer to function) via * a parser context typedef pRSPParser, which is returned from a call to RSPParserNew(). * * The methods in pRSPParser are as follows: * * - RSPParser_query_return pRSPParser->query(pRSPParser) * - RSPParser_expr_return pRSPParser->expr(pRSPParser) * - RSPParser_aexpr_return pRSPParser->aexpr(pRSPParser) * - RSPParser_crit_return pRSPParser->crit(pRSPParser) * - RSPParser_strcrit_return pRSPParser->strcrit(pRSPParser) * - RSPParser_strop_return pRSPParser->strop(pRSPParser) * - RSPParser_intcrit_return pRSPParser->intcrit(pRSPParser) * - RSPParser_intop_return pRSPParser->intop(pRSPParser) * - RSPParser_datecrit_return pRSPParser->datecrit(pRSPParser) * - RSPParser_dateop_return pRSPParser->dateop(pRSPParser) * - RSPParser_datespec_return pRSPParser->datespec(pRSPParser) * - RSPParser_dateref_return pRSPParser->dateref(pRSPParser) * - RSPParser_dateintval_return pRSPParser->dateintval(pRSPParser) * * The return type for any particular rule is of course determined by the source * grammar file. */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _RSPParser_H #define _RSPParser_H /* ============================================================================= * Standard antlr3 C runtime definitions */ #include /* End of standard antlr 3 runtime definitions * ============================================================================= */ #ifdef __cplusplus extern "C" { #endif // Forward declare the context typedef so that we can use it before it is // properly defined. Delegators and delegates (from import statements) are // interdependent and their context structures contain pointers to each other // C only allows such things to be declared if you pre-declare the typedef. // typedef struct RSPParser_Ctx_struct RSPParser, * pRSPParser; #ifdef ANTLR3_WINDOWS // Disable: Unreferenced parameter, - Rules with parameters that are not used // constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) // initialized but unused variable - tree rewrite variables declared but not needed // Unreferenced local variable - lexer rule declares but does not always use _type // potentially unitialized variable used - retval always returned from a rule // unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns // // These are only really displayed at warning level /W4 but that is the code ideal I am aiming at // and the codegen must generate some of these warnings by necessity, apart from 4100, which is // usually generated when a parser rule is given a parameter that it does not use. Mostly though // this is a matter of orthogonality hence I disable that one. // #pragma warning( disable : 4100 ) #pragma warning( disable : 4101 ) #pragma warning( disable : 4127 ) #pragma warning( disable : 4189 ) #pragma warning( disable : 4505 ) #pragma warning( disable : 4701 ) #endif typedef struct RSPParser_query_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_query_return; typedef struct RSPParser_expr_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_expr_return; typedef struct RSPParser_aexpr_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_aexpr_return; typedef struct RSPParser_crit_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_crit_return; typedef struct RSPParser_strcrit_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_strcrit_return; typedef struct RSPParser_strop_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_strop_return; typedef struct RSPParser_intcrit_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_intcrit_return; typedef struct RSPParser_intop_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_intop_return; typedef struct RSPParser_datecrit_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_datecrit_return; typedef struct RSPParser_dateop_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_dateop_return; typedef struct RSPParser_datespec_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_datespec_return; typedef struct RSPParser_dateref_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_dateref_return; typedef struct RSPParser_dateintval_return_struct { /** Generic return elements for ANTLR3 rules that are not in tree parsers or returning trees */ pANTLR3_COMMON_TOKEN start; pANTLR3_COMMON_TOKEN stop; pANTLR3_BASE_TREE tree; } RSPParser_dateintval_return; /** Context tracking structure for RSPParser */ struct RSPParser_Ctx_struct { /** Built in ANTLR3 context tracker contains all the generic elements * required for context tracking. */ pANTLR3_PARSER pParser; RSPParser_query_return (*query) (struct RSPParser_Ctx_struct * ctx); RSPParser_expr_return (*expr) (struct RSPParser_Ctx_struct * ctx); RSPParser_aexpr_return (*aexpr) (struct RSPParser_Ctx_struct * ctx); RSPParser_crit_return (*crit) (struct RSPParser_Ctx_struct * ctx); RSPParser_strcrit_return (*strcrit) (struct RSPParser_Ctx_struct * ctx); RSPParser_strop_return (*strop) (struct RSPParser_Ctx_struct * ctx); RSPParser_intcrit_return (*intcrit) (struct RSPParser_Ctx_struct * ctx); RSPParser_intop_return (*intop) (struct RSPParser_Ctx_struct * ctx); RSPParser_datecrit_return (*datecrit) (struct RSPParser_Ctx_struct * ctx); RSPParser_dateop_return (*dateop) (struct RSPParser_Ctx_struct * ctx); RSPParser_datespec_return (*datespec) (struct RSPParser_Ctx_struct * ctx); RSPParser_dateref_return (*dateref) (struct RSPParser_Ctx_struct * ctx); RSPParser_dateintval_return (*dateintval) (struct RSPParser_Ctx_struct * ctx); // Delegated rules const char * (*getGrammarFileName)(); void (*free) (struct RSPParser_Ctx_struct * ctx); /* @headerFile.members() */ pANTLR3_BASE_TREE_ADAPTOR adaptor; pANTLR3_VECTOR_FACTORY vectors; /* End @headerFile.members() */ }; // Function protoypes for the constructor functions that external translation units // such as delegators and delegates may wish to call. // ANTLR3_API pRSPParser RSPParserNew (pANTLR3_COMMON_TOKEN_STREAM instream); ANTLR3_API pRSPParser RSPParserNewSSD (pANTLR3_COMMON_TOKEN_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); /** Symbolic definitions of all the tokens that the parser will work with. * \{ * * Antlr will define EOF, but we can't use that as it it is too common in * in C header files and that would be confusing. There is no way to filter this out at the moment * so we just undef it here for now. That isn't the value we get back from C recognizers * anyway. We are looking for ANTLR3_TOKEN_EOF. */ #ifdef EOF #undef EOF #endif #ifdef Tokens #undef Tokens #endif #define STARTSW 14 #define WEEK 26 #define TODAY 24 #define YEAR 28 #define ENDSW 15 #define GTE 20 #define BEFORE 21 #define DAY 25 #define INT 16 #define NOT 11 #define AFTER 22 #define AND 6 #define EOF -1 #define LTE 19 #define MONTH 27 #define DIGIT19 31 #define INCLUDES 13 #define STR 10 #define QUOTE 29 #define WS 30 #define GREATER 18 #define LPAR 7 #define NEWLINE 4 #define EQUAL 12 #define OR 5 #define LESS 17 #define RPAR 8 #define FIELD 9 #define ESCAPED 33 #define DATE 23 #define DIGIT09 32 #ifdef EOF #undef EOF #define EOF ANTLR3_TOKEN_EOF #endif #ifndef TOKENSOURCE #define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource #endif /* End of token definitions for RSPParser * ============================================================================= */ /** \} */ #ifdef __cplusplus } #endif #endif /* END - Note:Keep extra line feed to satisfy UNIX systems */ forked-daapd-0.19gcd/src/pregen/RSPLexer.c0000664000175000017500000032665511633141362017702 0ustar julienjulien/** \file * This C source file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : RSP.g * - On : 2011-09-11 16:17:22 * - for the lexer : RSPLexerLexer * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* ----------------------------------------- * Include the ANTLR3 generated header file. */ #include "RSPLexer.h" /* ----------------------------------------- */ /** String literals used by RSPLexer that we must do things like MATCHS() with. * C will normally just lay down 8 bit characters, and you can use L"xxx" to * get wchar_t, but wchar_t is 16 bits on Windows, which is not UTF32 and so * we perform this little trick of defining the literals as arrays of UINT32 * and passing in the address of these. */ static ANTLR3_UCHAR lit_1[] = { 0x61, 0x6E, 0x64, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_2[] = { 0x6F, 0x72, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_3[] = { 0x69, 0x6E, 0x63, 0x6C, 0x75, 0x64, 0x65, 0x73, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_4[] = { 0x73, 0x74, 0x61, 0x72, 0x74, 0x73, 0x77, 0x69, 0x74, 0x68, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_5[] = { 0x65, 0x6E, 0x64, 0x73, 0x77, 0x69, 0x74, 0x68, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_6[] = { 0x3E, 0x3D, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_7[] = { 0x3C, 0x3D, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_8[] = { 0x62, 0x65, 0x66, 0x6F, 0x72, 0x65, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_9[] = { 0x61, 0x66, 0x74, 0x65, 0x72, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_10[] = { 0x64, 0x61, 0x79, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_11[] = { 0x64, 0x61, 0x79, 0x73, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_12[] = { 0x77, 0x65, 0x65, 0x6B, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_13[] = { 0x77, 0x65, 0x65, 0x6B, 0x73, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_14[] = { 0x6D, 0x6F, 0x6E, 0x74, 0x68, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_15[] = { 0x6D, 0x6F, 0x6E, 0x74, 0x68, 0x73, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_16[] = { 0x79, 0x65, 0x61, 0x72, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_17[] = { 0x79, 0x65, 0x61, 0x72, 0x73, ANTLR3_STRING_TERMINATOR}; static ANTLR3_UCHAR lit_18[] = { 0x74, 0x6F, 0x64, 0x61, 0x79, ANTLR3_STRING_TERMINATOR}; /* MACROS that hide the C interface implementations from the * generated code, which makes it a little more understandable to the human eye. * I am very much against using C pre-processor macros for function calls and bits * of code as you cannot see what is happening when single stepping in debuggers * and so on. The exception (in my book at least) is for generated code, where you are * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() * hides some indirect calls, but is always referring to the input stream. This is * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig * the runtime interfaces without changing the generated code too often, without * confusing the reader of the generated output, who may not wish to know the gory * details of the interface inheritance. */ #define CTX ctx /* Aids in accessing scopes for grammar programmers */ #undef SCOPE_TYPE #undef SCOPE_STACK #undef SCOPE_TOP #define SCOPE_TYPE(scope) pRSPLexer_##scope##_SCOPE #define SCOPE_STACK(scope) pRSPLexer_##scope##Stack #define SCOPE_TOP(scope) ctx->pRSPLexer_##scope##Top #define SCOPE_SIZE(scope) ctx->pRSPLexer_##scope##Stack_limit #define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) /* Macros for accessing things in a lexer */ #undef LEXER #undef RECOGNIZER #undef RULEMEMO #undef GETCHARINDEX #undef GETLINE #undef GETCHARPOSITIONINLINE #undef EMIT #undef EMITNEW #undef MATCHC #undef MATCHS #undef MATCHRANGE #undef LTOKEN #undef HASFAILED #undef FAILEDFLAG #undef INPUT #undef STRSTREAM #undef LA #undef HASEXCEPTION #undef EXCEPTION #undef CONSTRUCTEX #undef CONSUME #undef LRECOVER #undef MARK #undef REWIND #undef REWINDLAST #undef BACKTRACKING #undef MATCHANY #undef MEMOIZE #undef HAVEPARSEDRULE #undef GETTEXT #undef INDEX #undef SEEK #undef PUSHSTREAM #undef POPSTREAM #undef SETTEXT #undef SETTEXT8 #define LEXER ctx->pLexer #define RECOGNIZER LEXER->rec #define LEXSTATE RECOGNIZER->state #define TOKSOURCE LEXSTATE->tokSource #define GETCHARINDEX() LEXER->getCharIndex(LEXER) #define GETLINE() LEXER->getLine(LEXER) #define GETTEXT() LEXER->getText(LEXER) #define GETCHARPOSITIONINLINE() LEXER->getCharPositionInLine(LEXER) #define EMIT() LEXSTATE->type = _type; LEXER->emit(LEXER) #define EMITNEW(t) LEXER->emitNew(LEXER, t) #define MATCHC(c) LEXER->matchc(LEXER, c) #define MATCHS(s) LEXER->matchs(LEXER, s) #define MATCHRANGE(c1,c2) LEXER->matchRange(LEXER, c1, c2) #define MATCHANY() LEXER->matchAny(LEXER) #define LTOKEN LEXSTATE->token #define HASFAILED() (LEXSTATE->failed == ANTLR3_TRUE) #define BACKTRACKING LEXSTATE->backtracking #define FAILEDFLAG LEXSTATE->failed #define INPUT LEXER->input #define STRSTREAM INPUT #define ISTREAM INPUT->istream #define INDEX() ISTREAM->index(ISTREAM) #define SEEK(n) ISTREAM->seek(ISTREAM, n) #define EOF_TOKEN &(LEXSTATE->tokSource->eofToken) #define HASEXCEPTION() (LEXSTATE->error == ANTLR3_TRUE) #define EXCEPTION LEXSTATE->exception #define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) #define LRECOVER() LEXER->recover(LEXER) #define MARK() ISTREAM->mark(ISTREAM) #define REWIND(m) ISTREAM->rewind(ISTREAM, m) #define REWINDLAST() ISTREAM->rewindLast(ISTREAM) #define MEMOIZE(ri,si) RECOGNIZER->memoize(RECOGNIZER, ri, si) #define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) #define PUSHSTREAM(str) LEXER->pushCharStream(LEXER, str) #define POPSTREAM() LEXER->popCharStream(LEXER) #define SETTEXT(str) LEXSTATE->text = str #define SKIP() LEXSTATE->token = &(TOKSOURCE->skipToken) #define USER1 LEXSTATE->user1 #define USER2 LEXSTATE->user2 #define USER3 LEXSTATE->user3 #define CUSTOM LEXSTATE->custom #define RULEMEMO LEXSTATE->ruleMemo #define DBG RECOGNIZER->debugger /* If we have been told we can rely on the standard 8 bit or 16 bit input * stream, then we can define our macros to use the direct pointers * in the input object, which is much faster than indirect calls. This * is really only significant to lexers with a lot of fragment rules (which * do not place LA(1) in a temporary at the moment) and even then * only if there is a lot of input (order of say 1M or so). */ #if defined(ANTLR3_INLINE_INPUT_ASCII) || defined(ANTLR3_INLINE_INPUT_UTF16) # ifdef ANTLR3_INLINE_INPUT_ASCII /* 8 bit "ASCII" (actually any 8 bit character set) */ # define NEXTCHAR ((pANTLR3_UINT8)(INPUT->nextChar)) # define DATAP ((pANTLR3_UINT8)(INPUT->data)) # else # define NEXTCHAR ((pANTLR3_UINT16)(INPUT->nextChar)) # define DATAP ((pANTLR3_UINT16)(INPUT->data)) # endif # define LA(n) ((NEXTCHAR + n) > (DATAP + INPUT->sizeBuf) ? ANTLR3_CHARSTREAM_EOF : (ANTLR3_UCHAR)(*(NEXTCHAR + n - 1))) # define CONSUME() \ { \ if (NEXTCHAR < (DATAP + INPUT->sizeBuf)) \ { \ INPUT->charPositionInLine++; \ if ((ANTLR3_UCHAR)(*NEXTCHAR) == INPUT->newlineChar) \ { \ INPUT->line++; \ INPUT->charPositionInLine = 0; \ INPUT->currentLine = (void *)(NEXTCHAR + 1); \ } \ INPUT->nextChar = (void *)(NEXTCHAR + 1); \ } \ } #else // Pick up the input character by calling the input stream implementation. // #define CONSUME() INPUT->istream->consume(INPUT->istream) #define LA(n) INPUT->istream->_LA(INPUT->istream, n) #endif #define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt /* The 4 tokens defined below may well clash with your own #defines or token types. If so * then for the present you must use different names for your defines as these are hard coded * in the code generator. It would be better not to use such names internally, and maybe * we can change this in a forthcoming release. I deliberately do not #undef these * here as this will at least give you a redefined error somewhere if they clash. */ #define UP ANTLR3_TOKEN_UP #define DOWN ANTLR3_TOKEN_DOWN #define EOR ANTLR3_TOKEN_EOR #define INVALID ANTLR3_TOKEN_INVALID /* ============================================================================= * Functions to create and destroy scopes. First come the rule scopes, followed * by the global declared scopes. */ /* ============================================================================= */ /* ============================================================================= * Start of recognizer */ /* Forward declare the locally static matching functions we have generated and any predicate functions. */ static ANTLR3_INLINE void mQUOTE (pRSPLexer ctx); static ANTLR3_INLINE void mLPAR (pRSPLexer ctx); static ANTLR3_INLINE void mRPAR (pRSPLexer ctx); static ANTLR3_INLINE void mAND (pRSPLexer ctx); static ANTLR3_INLINE void mOR (pRSPLexer ctx); static ANTLR3_INLINE void mNOT (pRSPLexer ctx); static ANTLR3_INLINE void mEQUAL (pRSPLexer ctx); static ANTLR3_INLINE void mINCLUDES (pRSPLexer ctx); static ANTLR3_INLINE void mSTARTSW (pRSPLexer ctx); static ANTLR3_INLINE void mENDSW (pRSPLexer ctx); static ANTLR3_INLINE void mGREATER (pRSPLexer ctx); static ANTLR3_INLINE void mLESS (pRSPLexer ctx); static ANTLR3_INLINE void mGTE (pRSPLexer ctx); static ANTLR3_INLINE void mLTE (pRSPLexer ctx); static ANTLR3_INLINE void mBEFORE (pRSPLexer ctx); static ANTLR3_INLINE void mAFTER (pRSPLexer ctx); static ANTLR3_INLINE void mDAY (pRSPLexer ctx); static ANTLR3_INLINE void mWEEK (pRSPLexer ctx); static ANTLR3_INLINE void mMONTH (pRSPLexer ctx); static ANTLR3_INLINE void mYEAR (pRSPLexer ctx); static ANTLR3_INLINE void mTODAY (pRSPLexer ctx); static ANTLR3_INLINE void mNEWLINE (pRSPLexer ctx); static ANTLR3_INLINE void mWS (pRSPLexer ctx); static ANTLR3_INLINE void mFIELD (pRSPLexer ctx); static ANTLR3_INLINE void mINT (pRSPLexer ctx); static ANTLR3_INLINE void mDATE (pRSPLexer ctx); static ANTLR3_INLINE void mSTR (pRSPLexer ctx); static ANTLR3_INLINE void mESCAPED (pRSPLexer ctx); static ANTLR3_INLINE void mDIGIT09 (pRSPLexer ctx); static ANTLR3_INLINE void mDIGIT19 (pRSPLexer ctx); static ANTLR3_INLINE void mTokens (pRSPLexer ctx); static void RSPLexerFree(pRSPLexer ctx); /* ========================================================================= * Lexer matching rules end. * ========================================================================= */ static void RSPLexerFree (pRSPLexer ctx) { LEXER->free(LEXER); ANTLR3_FREE(ctx); } /** \brief Name of the grammar file that generated this code */ static const char fileName[] = "RSP.g"; /** \brief Return the name of the grammar file that generated this code. */ static const char * getGrammarFileName() { return fileName; } /** \brief Create a new lexer called RSPLexer * * \param[in] instream Pointer to an initialized input stream * \return * - Success pRSPLexer initialized for the lex start * - Fail NULL */ ANTLR3_API pRSPLexer RSPLexerNew (pANTLR3_INPUT_STREAM instream) { // See if we can create a new lexer with the standard constructor // return RSPLexerNewSSD(instream, NULL); } /** \brief Create a new lexer called RSPLexer * * \param[in] instream Pointer to an initialized input stream * \param[state] state Previously created shared recognizer stat * \return * - Success pRSPLexer initialized for the lex start * - Fail NULL */ ANTLR3_API pRSPLexer RSPLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) { pRSPLexer ctx; // Context structure we will build and return ctx = (pRSPLexer) ANTLR3_CALLOC(1, sizeof(RSPLexer)); if (ctx == NULL) { // Failed to allocate memory for lexer context return NULL; } /* ------------------------------------------------------------------- * Memory for basic structure is allocated, now to fill in * in base ANTLR3 structures. We initialize the function pointers * for the standard ANTLR3 lexer function set, but upon return * from here, the programmer may set the pointers to provide custom * implementations of each function. * * We don't use the macros defined in RSPLexer.h here so you can get a sense * of what goes where. */ /* Create a base lexer, using the supplied input stream */ ctx->pLexer = antlr3LexerNewStream(ANTLR3_SIZE_HINT, instream, state); /* Check that we allocated the memory correctly */ if (ctx->pLexer == NULL) { ANTLR3_FREE(ctx); return NULL; } /* Install the implementation of our RSPLexer interface */ ctx->mQUOTE = mQUOTE; ctx->mLPAR = mLPAR; ctx->mRPAR = mRPAR; ctx->mAND = mAND; ctx->mOR = mOR; ctx->mNOT = mNOT; ctx->mEQUAL = mEQUAL; ctx->mINCLUDES = mINCLUDES; ctx->mSTARTSW = mSTARTSW; ctx->mENDSW = mENDSW; ctx->mGREATER = mGREATER; ctx->mLESS = mLESS; ctx->mGTE = mGTE; ctx->mLTE = mLTE; ctx->mBEFORE = mBEFORE; ctx->mAFTER = mAFTER; ctx->mDAY = mDAY; ctx->mWEEK = mWEEK; ctx->mMONTH = mMONTH; ctx->mYEAR = mYEAR; ctx->mTODAY = mTODAY; ctx->mNEWLINE = mNEWLINE; ctx->mWS = mWS; ctx->mFIELD = mFIELD; ctx->mINT = mINT; ctx->mDATE = mDATE; ctx->mSTR = mSTR; ctx->mESCAPED = mESCAPED; ctx->mDIGIT09 = mDIGIT09; ctx->mDIGIT19 = mDIGIT19; ctx->mTokens = mTokens; /** When the nextToken() call is made to this lexer's pANTLR3_TOKEN_SOURCE * it will call mTokens() in this generated code, and will pass it the ctx * pointer of this lexer, not the context of the base lexer, so store that now. */ ctx->pLexer->ctx = ctx; /**Install the token matching function */ ctx->pLexer->mTokens = (void (*) (void *))(mTokens); ctx->getGrammarFileName = getGrammarFileName; ctx->free = RSPLexerFree; /* Return the newly built lexer to the caller */ return ctx; } /* ========================================================================= * Functions to match the lexer grammar defined tokens from the input stream */ // Comes from: 85:7: ( '\"' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start QUOTE * * Looks to match the characters the constitute the token QUOTE * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mQUOTE(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = QUOTE; // RSP.g:85:7: ( '\"' ) // RSP.g:85:9: '\"' { MATCHC('"'); if (HASEXCEPTION()) { goto ruleQUOTEEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleQUOTEEx; /* Prevent compiler warnings */ ruleQUOTEEx: ; } // $ANTLR end QUOTE // Comes from: 86:6: ( '(' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start LPAR * * Looks to match the characters the constitute the token LPAR * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mLPAR(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = LPAR; // RSP.g:86:6: ( '(' ) // RSP.g:86:8: '(' { MATCHC('('); if (HASEXCEPTION()) { goto ruleLPAREx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleLPAREx; /* Prevent compiler warnings */ ruleLPAREx: ; } // $ANTLR end LPAR // Comes from: 87:6: ( ')' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start RPAR * * Looks to match the characters the constitute the token RPAR * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mRPAR(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = RPAR; // RSP.g:87:6: ( ')' ) // RSP.g:87:8: ')' { MATCHC(')'); if (HASEXCEPTION()) { goto ruleRPAREx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleRPAREx; /* Prevent compiler warnings */ ruleRPAREx: ; } // $ANTLR end RPAR // Comes from: 89:5: ( 'and' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start AND * * Looks to match the characters the constitute the token AND * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mAND(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = AND; // RSP.g:89:5: ( 'and' ) // RSP.g:89:7: 'and' { MATCHS(lit_1); if (HASEXCEPTION()) { goto ruleANDEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleANDEx; /* Prevent compiler warnings */ ruleANDEx: ; } // $ANTLR end AND // Comes from: 90:4: ( 'or' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start OR * * Looks to match the characters the constitute the token OR * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mOR(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = OR; // RSP.g:90:4: ( 'or' ) // RSP.g:90:6: 'or' { MATCHS(lit_2); if (HASEXCEPTION()) { goto ruleOREx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleOREx; /* Prevent compiler warnings */ ruleOREx: ; } // $ANTLR end OR // Comes from: 91:5: ( '!' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start NOT * * Looks to match the characters the constitute the token NOT * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mNOT(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = NOT; // RSP.g:91:5: ( '!' ) // RSP.g:91:7: '!' { MATCHC('!'); if (HASEXCEPTION()) { goto ruleNOTEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleNOTEx; /* Prevent compiler warnings */ ruleNOTEx: ; } // $ANTLR end NOT // Comes from: 94:7: ( '=' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start EQUAL * * Looks to match the characters the constitute the token EQUAL * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mEQUAL(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = EQUAL; // RSP.g:94:7: ( '=' ) // RSP.g:94:9: '=' { MATCHC('='); if (HASEXCEPTION()) { goto ruleEQUALEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleEQUALEx; /* Prevent compiler warnings */ ruleEQUALEx: ; } // $ANTLR end EQUAL // Comes from: 97:9: ( 'includes' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start INCLUDES * * Looks to match the characters the constitute the token INCLUDES * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mINCLUDES(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = INCLUDES; // RSP.g:97:9: ( 'includes' ) // RSP.g:97:11: 'includes' { MATCHS(lit_3); if (HASEXCEPTION()) { goto ruleINCLUDESEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleINCLUDESEx; /* Prevent compiler warnings */ ruleINCLUDESEx: ; } // $ANTLR end INCLUDES // Comes from: 98:9: ( 'startswith' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start STARTSW * * Looks to match the characters the constitute the token STARTSW * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mSTARTSW(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = STARTSW; // RSP.g:98:9: ( 'startswith' ) // RSP.g:98:11: 'startswith' { MATCHS(lit_4); if (HASEXCEPTION()) { goto ruleSTARTSWEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleSTARTSWEx; /* Prevent compiler warnings */ ruleSTARTSWEx: ; } // $ANTLR end STARTSW // Comes from: 99:7: ( 'endswith' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start ENDSW * * Looks to match the characters the constitute the token ENDSW * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mENDSW(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = ENDSW; // RSP.g:99:7: ( 'endswith' ) // RSP.g:99:9: 'endswith' { MATCHS(lit_5); if (HASEXCEPTION()) { goto ruleENDSWEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleENDSWEx; /* Prevent compiler warnings */ ruleENDSWEx: ; } // $ANTLR end ENDSW // Comes from: 102:9: ( '>' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start GREATER * * Looks to match the characters the constitute the token GREATER * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mGREATER(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = GREATER; // RSP.g:102:9: ( '>' ) // RSP.g:102:11: '>' { MATCHC('>'); if (HASEXCEPTION()) { goto ruleGREATEREx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleGREATEREx; /* Prevent compiler warnings */ ruleGREATEREx: ; } // $ANTLR end GREATER // Comes from: 103:6: ( '<' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start LESS * * Looks to match the characters the constitute the token LESS * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mLESS(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = LESS; // RSP.g:103:6: ( '<' ) // RSP.g:103:8: '<' { MATCHC('<'); if (HASEXCEPTION()) { goto ruleLESSEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleLESSEx; /* Prevent compiler warnings */ ruleLESSEx: ; } // $ANTLR end LESS // Comes from: 104:5: ( '>=' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start GTE * * Looks to match the characters the constitute the token GTE * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mGTE(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = GTE; // RSP.g:104:5: ( '>=' ) // RSP.g:104:7: '>=' { MATCHS(lit_6); if (HASEXCEPTION()) { goto ruleGTEEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleGTEEx; /* Prevent compiler warnings */ ruleGTEEx: ; } // $ANTLR end GTE // Comes from: 105:5: ( '<=' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start LTE * * Looks to match the characters the constitute the token LTE * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mLTE(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = LTE; // RSP.g:105:5: ( '<=' ) // RSP.g:105:7: '<=' { MATCHS(lit_7); if (HASEXCEPTION()) { goto ruleLTEEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleLTEEx; /* Prevent compiler warnings */ ruleLTEEx: ; } // $ANTLR end LTE // Comes from: 108:8: ( 'before' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start BEFORE * * Looks to match the characters the constitute the token BEFORE * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mBEFORE(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = BEFORE; // RSP.g:108:8: ( 'before' ) // RSP.g:108:10: 'before' { MATCHS(lit_8); if (HASEXCEPTION()) { goto ruleBEFOREEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleBEFOREEx; /* Prevent compiler warnings */ ruleBEFOREEx: ; } // $ANTLR end BEFORE // Comes from: 109:7: ( 'after' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start AFTER * * Looks to match the characters the constitute the token AFTER * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mAFTER(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = AFTER; // RSP.g:109:7: ( 'after' ) // RSP.g:109:9: 'after' { MATCHS(lit_9); if (HASEXCEPTION()) { goto ruleAFTEREx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleAFTEREx; /* Prevent compiler warnings */ ruleAFTEREx: ; } // $ANTLR end AFTER // Comes from: 110:5: ( 'day' | 'days' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start DAY * * Looks to match the characters the constitute the token DAY * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mDAY(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = DAY; { // RSP.g:110:5: ( 'day' | 'days' ) ANTLR3_UINT32 alt1; alt1=2; switch ( LA(1) ) { case 'd': { switch ( LA(2) ) { case 'a': { switch ( LA(3) ) { case 'y': { switch ( LA(4) ) { case 's': { alt1=2; } break; default: alt1=1;} } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 2; goto ruleDAYEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 1; goto ruleDAYEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 0; goto ruleDAYEx; } switch (alt1) { case 1: // RSP.g:110:7: 'day' { MATCHS(lit_10); if (HASEXCEPTION()) { goto ruleDAYEx; } } break; case 2: // RSP.g:110:15: 'days' { MATCHS(lit_11); if (HASEXCEPTION()) { goto ruleDAYEx; } } break; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleDAYEx; /* Prevent compiler warnings */ ruleDAYEx: ; } // $ANTLR end DAY // Comes from: 111:6: ( 'week' | 'weeks' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start WEEK * * Looks to match the characters the constitute the token WEEK * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mWEEK(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = WEEK; { // RSP.g:111:6: ( 'week' | 'weeks' ) ANTLR3_UINT32 alt2; alt2=2; switch ( LA(1) ) { case 'w': { switch ( LA(2) ) { case 'e': { switch ( LA(3) ) { case 'e': { switch ( LA(4) ) { case 'k': { switch ( LA(5) ) { case 's': { alt2=2; } break; default: alt2=1;} } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 2; EXCEPTION->state = 3; goto ruleWEEKEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 2; EXCEPTION->state = 2; goto ruleWEEKEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 2; EXCEPTION->state = 1; goto ruleWEEKEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 2; EXCEPTION->state = 0; goto ruleWEEKEx; } switch (alt2) { case 1: // RSP.g:111:8: 'week' { MATCHS(lit_12); if (HASEXCEPTION()) { goto ruleWEEKEx; } } break; case 2: // RSP.g:111:17: 'weeks' { MATCHS(lit_13); if (HASEXCEPTION()) { goto ruleWEEKEx; } } break; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleWEEKEx; /* Prevent compiler warnings */ ruleWEEKEx: ; } // $ANTLR end WEEK // Comes from: 112:7: ( 'month' | 'months' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start MONTH * * Looks to match the characters the constitute the token MONTH * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mMONTH(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = MONTH; { // RSP.g:112:7: ( 'month' | 'months' ) ANTLR3_UINT32 alt3; alt3=2; switch ( LA(1) ) { case 'm': { switch ( LA(2) ) { case 'o': { switch ( LA(3) ) { case 'n': { switch ( LA(4) ) { case 't': { switch ( LA(5) ) { case 'h': { switch ( LA(6) ) { case 's': { alt3=2; } break; default: alt3=1;} } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 3; EXCEPTION->state = 4; goto ruleMONTHEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 3; EXCEPTION->state = 3; goto ruleMONTHEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 3; EXCEPTION->state = 2; goto ruleMONTHEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 3; EXCEPTION->state = 1; goto ruleMONTHEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 3; EXCEPTION->state = 0; goto ruleMONTHEx; } switch (alt3) { case 1: // RSP.g:112:9: 'month' { MATCHS(lit_14); if (HASEXCEPTION()) { goto ruleMONTHEx; } } break; case 2: // RSP.g:112:19: 'months' { MATCHS(lit_15); if (HASEXCEPTION()) { goto ruleMONTHEx; } } break; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleMONTHEx; /* Prevent compiler warnings */ ruleMONTHEx: ; } // $ANTLR end MONTH // Comes from: 113:6: ( 'year' | 'years' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start YEAR * * Looks to match the characters the constitute the token YEAR * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mYEAR(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = YEAR; { // RSP.g:113:6: ( 'year' | 'years' ) ANTLR3_UINT32 alt4; alt4=2; switch ( LA(1) ) { case 'y': { switch ( LA(2) ) { case 'e': { switch ( LA(3) ) { case 'a': { switch ( LA(4) ) { case 'r': { switch ( LA(5) ) { case 's': { alt4=2; } break; default: alt4=1;} } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 3; goto ruleYEAREx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 2; goto ruleYEAREx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 1; goto ruleYEAREx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 0; goto ruleYEAREx; } switch (alt4) { case 1: // RSP.g:113:8: 'year' { MATCHS(lit_16); if (HASEXCEPTION()) { goto ruleYEAREx; } } break; case 2: // RSP.g:113:17: 'years' { MATCHS(lit_17); if (HASEXCEPTION()) { goto ruleYEAREx; } } break; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleYEAREx; /* Prevent compiler warnings */ ruleYEAREx: ; } // $ANTLR end YEAR // Comes from: 114:7: ( 'today' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start TODAY * * Looks to match the characters the constitute the token TODAY * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mTODAY(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = TODAY; // RSP.g:114:7: ( 'today' ) // RSP.g:114:9: 'today' { MATCHS(lit_18); if (HASEXCEPTION()) { goto ruleTODAYEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleTODAYEx; /* Prevent compiler warnings */ ruleTODAYEx: ; } // $ANTLR end TODAY // Comes from: 116:9: ( ( '\\r' )? '\\n' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start NEWLINE * * Looks to match the characters the constitute the token NEWLINE * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mNEWLINE(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = NEWLINE; // RSP.g:116:9: ( ( '\\r' )? '\\n' ) // RSP.g:116:11: ( '\\r' )? '\\n' { // RSP.g:116:11: ( '\\r' )? { int alt5=2; switch ( LA(1) ) { case '\r': { alt5=1; } break; } switch (alt5) { case 1: // RSP.g:116:11: '\\r' { MATCHC('\r'); if (HASEXCEPTION()) { goto ruleNEWLINEEx; } } break; } } MATCHC('\n'); if (HASEXCEPTION()) { goto ruleNEWLINEEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleNEWLINEEx; /* Prevent compiler warnings */ ruleNEWLINEEx: ; } // $ANTLR end NEWLINE // Comes from: 118:4: ( ( ' ' | '\\t' ) ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start WS * * Looks to match the characters the constitute the token WS * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mWS(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = WS; // RSP.g:118:4: ( ( ' ' | '\\t' ) ) // RSP.g:118:6: ( ' ' | '\\t' ) { if ( LA(1) == '\t' || LA(1) == ' ' ) { CONSUME(); } else { CONSTRUCTEX(); EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; LRECOVER(); goto ruleWSEx; } { LEXSTATE->channel = HIDDEN; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleWSEx; /* Prevent compiler warnings */ ruleWSEx: ; } // $ANTLR end WS // Comes from: 120:7: ( 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start FIELD * * Looks to match the characters the constitute the token FIELD * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mFIELD(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = FIELD; // RSP.g:120:7: ( 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z' ) // RSP.g:120:9: 'a' .. 'z' ( 'a' .. 'z' | '_' )* 'a' .. 'z' { MATCHRANGE('a', 'z'); if (HASEXCEPTION()) { goto ruleFIELDEx; } // RSP.g:120:18: ( 'a' .. 'z' | '_' )* for (;;) { int alt6=2; switch ( LA(1) ) { case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { switch ( LA(2) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt6=1; } break; } } break; case '_': { alt6=1; } break; } switch (alt6) { case 1: // RSP.g: { if ( LA(1) == '_' || ((LA(1) >= 'a') && (LA(1) <= 'z')) ) { CONSUME(); } else { CONSTRUCTEX(); EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; LRECOVER(); goto ruleFIELDEx; } } break; default: goto loop6; /* break out of the loop */ break; } } loop6: ; /* Jump out to here if this rule does not match */ MATCHRANGE('a', 'z'); if (HASEXCEPTION()) { goto ruleFIELDEx; } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleFIELDEx; /* Prevent compiler warnings */ ruleFIELDEx: ; } // $ANTLR end FIELD // Comes from: 122:5: ( DIGIT19 ( DIGIT09 )* ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start INT * * Looks to match the characters the constitute the token INT * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mINT(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = INT; // RSP.g:122:5: ( DIGIT19 ( DIGIT09 )* ) // RSP.g:122:7: DIGIT19 ( DIGIT09 )* { /* 122:7: DIGIT19 ( DIGIT09 )* */ mDIGIT19(ctx ); if (HASEXCEPTION()) { goto ruleINTEx; } // RSP.g:122:15: ( DIGIT09 )* for (;;) { int alt7=2; switch ( LA(1) ) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { alt7=1; } break; } switch (alt7) { case 1: // RSP.g:122:15: DIGIT09 { /* 122:15: DIGIT09 */ mDIGIT09(ctx ); if (HASEXCEPTION()) { goto ruleINTEx; } } break; default: goto loop7; /* break out of the loop */ break; } } loop7: ; /* Jump out to here if this rule does not match */ } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleINTEx; /* Prevent compiler warnings */ ruleINTEx: ; } // $ANTLR end INT // Comes from: 125:6: ( DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start DATE * * Looks to match the characters the constitute the token DATE * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mDATE(pRSPLexer ctx) { ANTLR3_UINT32 _type; _type = DATE; // RSP.g:125:6: ( DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) ) // RSP.g:125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) { /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */ mDIGIT19(ctx ); if (HASEXCEPTION()) { goto ruleDATEEx; } /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */ mDIGIT09(ctx ); if (HASEXCEPTION()) { goto ruleDATEEx; } /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */ mDIGIT09(ctx ); if (HASEXCEPTION()) { goto ruleDATEEx; } /* 125:8: DIGIT19 DIGIT09 DIGIT09 DIGIT09 '-' ( '0' DIGIT19 | '1' '0' .. '2' ) '-' ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) */ mDIGIT09(ctx ); if (HASEXCEPTION()) { goto ruleDATEEx; } MATCHC('-'); if (HASEXCEPTION()) { goto ruleDATEEx; } // RSP.g:125:44: ( '0' DIGIT19 | '1' '0' .. '2' ) { int alt8=2; switch ( LA(1) ) { case '0': { alt8=1; } break; case '1': { alt8=2; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 8; EXCEPTION->state = 0; goto ruleDATEEx; } switch (alt8) { case 1: // RSP.g:125:45: '0' DIGIT19 { MATCHC('0'); if (HASEXCEPTION()) { goto ruleDATEEx; } /* 125:45: '0' DIGIT19 */ mDIGIT19(ctx ); if (HASEXCEPTION()) { goto ruleDATEEx; } } break; case 2: // RSP.g:125:59: '1' '0' .. '2' { MATCHC('1'); if (HASEXCEPTION()) { goto ruleDATEEx; } MATCHRANGE('0', '2'); if (HASEXCEPTION()) { goto ruleDATEEx; } } break; } } MATCHC('-'); if (HASEXCEPTION()) { goto ruleDATEEx; } // RSP.g:125:77: ( '0' DIGIT19 | '1' .. '2' DIGIT09 | '3' '0' .. '1' ) { int alt9=3; switch ( LA(1) ) { case '0': { alt9=1; } break; case '1': case '2': { alt9=2; } break; case '3': { alt9=3; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 9; EXCEPTION->state = 0; goto ruleDATEEx; } switch (alt9) { case 1: // RSP.g:125:78: '0' DIGIT19 { MATCHC('0'); if (HASEXCEPTION()) { goto ruleDATEEx; } /* 125:78: '0' DIGIT19 */ mDIGIT19(ctx ); if (HASEXCEPTION()) { goto ruleDATEEx; } } break; case 2: // RSP.g:125:92: '1' .. '2' DIGIT09 { MATCHRANGE('1', '2'); if (HASEXCEPTION()) { goto ruleDATEEx; } /* 125:92: '1' .. '2' DIGIT09 */ mDIGIT09(ctx ); if (HASEXCEPTION()) { goto ruleDATEEx; } } break; case 3: // RSP.g:125:111: '3' '0' .. '1' { MATCHC('3'); if (HASEXCEPTION()) { goto ruleDATEEx; } MATCHRANGE('0', '1'); if (HASEXCEPTION()) { goto ruleDATEEx; } } break; } } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleDATEEx; /* Prevent compiler warnings */ ruleDATEEx: ; } // $ANTLR end DATE // Comes from: 133:2: ( QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start STR * * Looks to match the characters the constitute the token STR * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mSTR(pRSPLexer ctx) { ANTLR3_UINT32 _type; pANTLR3_COMMON_TOKEN esc; ANTLR3_UINT32 reg; esc = NULL; _type = STR; pANTLR3_STRING unesc = GETTEXT()->factory->newRaw(GETTEXT()->factory); // RSP.g:133:2: ( QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE ) // RSP.g:133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE { /* 133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE */ mQUOTE(ctx ); if (HASEXCEPTION()) { goto ruleSTREx; } // RSP.g:133:10: (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ { int cnt10=0; for (;;) { int alt10=3; { /* dfaLoopbackState(k,edges,eotPredictsAlt,description,stateNumber,semPredState) */ int LA10_0 = LA(1); if ( (((LA10_0 >= 0x0000) && (LA10_0 <= '!')) || ((LA10_0 >= '#') && (LA10_0 <= '[')) || ((LA10_0 >= ']') && (LA10_0 <= 0xFFFF))) ) { alt10=1; } else if ( (LA10_0 == '\\') ) { alt10=2; } } switch (alt10) { case 1: // RSP.g:133:12: reg=~ ( '\\\\' | '\"' ) { reg= LA(1); if ( ((LA(1) >= 0x0000) && (LA(1) <= '!')) || ((LA(1) >= '#') && (LA(1) <= '[')) || ((LA(1) >= ']') && (LA(1) <= 0xFFFF)) ) { CONSUME(); } else { CONSTRUCTEX(); EXCEPTION->type = ANTLR3_MISMATCHED_SET_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_MISMATCHED_SET_NAME; LRECOVER(); goto ruleSTREx; } { unesc->addc(unesc, reg); } } break; case 2: // RSP.g:134:6: esc= ESCAPED { /* 134:6: esc= ESCAPED */ { ANTLR3_MARKER escStart381 = GETCHARINDEX(); mESCAPED(ctx ); if (HASEXCEPTION()) { goto ruleSTREx; } esc = LEXSTATE->tokFactory->newToken(LEXSTATE->tokFactory); esc->setType(esc, ANTLR3_TOKEN_INVALID); esc->setStartIndex(esc, escStart381); esc->setStopIndex(esc, GETCHARINDEX()-1); esc->input = INPUT; } { unesc->appendS(unesc, GETTEXT()); } } break; default: if ( cnt10 >= 1 ) { goto loop10; } /* mismatchedSetEx() */ CONSTRUCTEX(); EXCEPTION->type = ANTLR3_EARLY_EXIT_EXCEPTION; EXCEPTION->name = (void *)ANTLR3_EARLY_EXIT_NAME; goto ruleSTREx; } cnt10++; } loop10: ; /* Jump to here if this rule does not match */ } /* 133:4: QUOTE (reg=~ ( '\\\\' | '\"' ) | esc= ESCAPED )+ QUOTE */ mQUOTE(ctx ); if (HASEXCEPTION()) { goto ruleSTREx; } { SETTEXT(unesc); } } LEXSTATE->type = _type; // This is where rules clean up and exit // goto ruleSTREx; /* Prevent compiler warnings */ ruleSTREx: ; esc = NULL; } // $ANTLR end STR // Comes from: 138:9: ( '\\\\' ( '\\\\' | '\"' ) ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start ESCAPED * * Looks to match the characters the constitute the token ESCAPED * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mESCAPED(pRSPLexer ctx) { ANTLR3_UINT32 _type; // RSP.g:138:9: ( '\\\\' ( '\\\\' | '\"' ) ) // RSP.g:138:11: '\\\\' ( '\\\\' | '\"' ) { MATCHC('\\'); if (HASEXCEPTION()) { goto ruleESCAPEDEx; } // RSP.g:139:3: ( '\\\\' | '\"' ) { int alt11=2; switch ( LA(1) ) { case '\\': { alt11=1; } break; case '"': { alt11=2; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 11; EXCEPTION->state = 0; goto ruleESCAPEDEx; } switch (alt11) { case 1: // RSP.g:139:5: '\\\\' { MATCHC('\\'); if (HASEXCEPTION()) { goto ruleESCAPEDEx; } { SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\\")); } } break; case 2: // RSP.g:140:5: '\"' { MATCHC('"'); if (HASEXCEPTION()) { goto ruleESCAPEDEx; } { SETTEXT(GETTEXT()->factory->newStr8(GETTEXT()->factory, (pANTLR3_UINT8)"\"")); } } break; } } } // This is where rules clean up and exit // goto ruleESCAPEDEx; /* Prevent compiler warnings */ ruleESCAPEDEx: ; } // $ANTLR end ESCAPED // Comes from: 145:9: ( '0' .. '9' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start DIGIT09 * * Looks to match the characters the constitute the token DIGIT09 * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mDIGIT09(pRSPLexer ctx) { ANTLR3_UINT32 _type; // RSP.g:145:9: ( '0' .. '9' ) // RSP.g:145:11: '0' .. '9' { MATCHRANGE('0', '9'); if (HASEXCEPTION()) { goto ruleDIGIT09Ex; } } // This is where rules clean up and exit // goto ruleDIGIT09Ex; /* Prevent compiler warnings */ ruleDIGIT09Ex: ; } // $ANTLR end DIGIT09 // Comes from: 148:9: ( '1' .. '9' ) /** \brief Lexer rule generated by ANTLR3 * * $ANTLR start DIGIT19 * * Looks to match the characters the constitute the token DIGIT19 * from the attached input stream. * * * \remark * - lexer->error == ANTLR3_TRUE if an exception was thrown. */ static ANTLR3_INLINE void mDIGIT19(pRSPLexer ctx) { ANTLR3_UINT32 _type; // RSP.g:148:9: ( '1' .. '9' ) // RSP.g:148:11: '1' .. '9' { MATCHRANGE('1', '9'); if (HASEXCEPTION()) { goto ruleDIGIT19Ex; } } // This is where rules clean up and exit // goto ruleDIGIT19Ex; /* Prevent compiler warnings */ ruleDIGIT19Ex: ; } // $ANTLR end DIGIT19 /** This is the entry point in to the lexer from an object that * wants to generate the next token, such as a pCOMMON_TOKEN_STREAM */ static void mTokens(pRSPLexer ctx) { { // RSP.g:1:8: ( QUOTE | LPAR | RPAR | AND | OR | NOT | EQUAL | INCLUDES | STARTSW | ENDSW | GREATER | LESS | GTE | LTE | BEFORE | AFTER | DAY | WEEK | MONTH | YEAR | TODAY | NEWLINE | WS | FIELD | INT | DATE | STR ) ANTLR3_UINT32 alt12; alt12=27; switch ( LA(1) ) { case '"': { { int LA12_1 = LA(2); if ( (((LA12_1 >= 0x0000) && (LA12_1 <= '!')) || ((LA12_1 >= '#') && (LA12_1 <= 0xFFFF))) ) { alt12=27; } else { alt12=1; } } } break; case '(': { alt12=2; } break; case ')': { alt12=3; } break; case 'a': { switch ( LA(2) ) { case 'n': { switch ( LA(3) ) { case 'd': { switch ( LA(4) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=4;} } break; default: alt12=24;} } break; case 'f': { switch ( LA(3) ) { case 't': { switch ( LA(4) ) { case 'e': { switch ( LA(5) ) { case 'r': { switch ( LA(6) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=16;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 4; goto ruleTokensEx; } } break; case 'o': { switch ( LA(2) ) { case 'r': { switch ( LA(3) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=5;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 5; goto ruleTokensEx; } } break; case '!': { alt12=6; } break; case '=': { alt12=7; } break; case 'i': { switch ( LA(2) ) { case 'n': { switch ( LA(3) ) { case 'c': { switch ( LA(4) ) { case 'l': { switch ( LA(5) ) { case 'u': { switch ( LA(6) ) { case 'd': { switch ( LA(7) ) { case 'e': { switch ( LA(8) ) { case 's': { switch ( LA(9) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=8;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 8; goto ruleTokensEx; } } break; case 's': { switch ( LA(2) ) { case 't': { switch ( LA(3) ) { case 'a': { switch ( LA(4) ) { case 'r': { switch ( LA(5) ) { case 't': { switch ( LA(6) ) { case 's': { switch ( LA(7) ) { case 'w': { switch ( LA(8) ) { case 'i': { switch ( LA(9) ) { case 't': { switch ( LA(10) ) { case 'h': { switch ( LA(11) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=9;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 9; goto ruleTokensEx; } } break; case 'e': { switch ( LA(2) ) { case 'n': { switch ( LA(3) ) { case 'd': { switch ( LA(4) ) { case 's': { switch ( LA(5) ) { case 'w': { switch ( LA(6) ) { case 'i': { switch ( LA(7) ) { case 't': { switch ( LA(8) ) { case 'h': { switch ( LA(9) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=10;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 10; goto ruleTokensEx; } } break; case '>': { switch ( LA(2) ) { case '=': { alt12=13; } break; default: alt12=11;} } break; case '<': { switch ( LA(2) ) { case '=': { alt12=14; } break; default: alt12=12;} } break; case 'b': { switch ( LA(2) ) { case 'e': { switch ( LA(3) ) { case 'f': { switch ( LA(4) ) { case 'o': { switch ( LA(5) ) { case 'r': { switch ( LA(6) ) { case 'e': { switch ( LA(7) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=15;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 13; goto ruleTokensEx; } } break; case 'd': { switch ( LA(2) ) { case 'a': { switch ( LA(3) ) { case 'y': { switch ( LA(4) ) { case 's': { switch ( LA(5) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=17;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=17;} } break; default: alt12=24;} } break; case '_': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 14; goto ruleTokensEx; } } break; case 'w': { switch ( LA(2) ) { case 'e': { switch ( LA(3) ) { case 'e': { switch ( LA(4) ) { case 'k': { switch ( LA(5) ) { case 's': { switch ( LA(6) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=18;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=18;} } break; default: alt12=24;} } break; default: alt12=24;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 15; goto ruleTokensEx; } } break; case 'm': { switch ( LA(2) ) { case 'o': { switch ( LA(3) ) { case 'n': { switch ( LA(4) ) { case 't': { switch ( LA(5) ) { case 'h': { switch ( LA(6) ) { case 's': { switch ( LA(7) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=19;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=19;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 16; goto ruleTokensEx; } } break; case 'y': { switch ( LA(2) ) { case 'e': { switch ( LA(3) ) { case 'a': { switch ( LA(4) ) { case 'r': { switch ( LA(5) ) { case 's': { switch ( LA(6) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=20;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=20;} } break; default: alt12=24;} } break; default: alt12=24;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 17; goto ruleTokensEx; } } break; case 't': { switch ( LA(2) ) { case 'o': { switch ( LA(3) ) { case 'd': { switch ( LA(4) ) { case 'a': { switch ( LA(5) ) { case 'y': { switch ( LA(6) ) { case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'o': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: alt12=21;} } break; default: alt12=24;} } break; default: alt12=24;} } break; default: alt12=24;} } break; case '_': case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': case 'g': case 'h': case 'i': case 'j': case 'k': case 'l': case 'm': case 'n': case 'p': case 'q': case 'r': case 's': case 't': case 'u': case 'v': case 'w': case 'x': case 'y': case 'z': { alt12=24; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 18; goto ruleTokensEx; } } break; case '\n': case '\r': { alt12=22; } break; case '\t': case ' ': { alt12=23; } break; case 'c': case 'f': case 'g': case 'h': case 'j': case 'k': case 'l': case 'n': case 'p': case 'q': case 'r': case 'u': case 'v': case 'x': case 'z': { alt12=24; } break; case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { switch ( LA(2) ) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { switch ( LA(3) ) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { switch ( LA(4) ) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': { switch ( LA(5) ) { case '-': { alt12=26; } break; default: alt12=25;} } break; default: alt12=25;} } break; default: alt12=25;} } break; default: alt12=25;} } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 12; EXCEPTION->state = 0; goto ruleTokensEx; } switch (alt12) { case 1: // RSP.g:1:10: QUOTE { /* 1:10: QUOTE */ mQUOTE(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 2: // RSP.g:1:16: LPAR { /* 1:16: LPAR */ mLPAR(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 3: // RSP.g:1:21: RPAR { /* 1:21: RPAR */ mRPAR(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 4: // RSP.g:1:26: AND { /* 1:26: AND */ mAND(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 5: // RSP.g:1:30: OR { /* 1:30: OR */ mOR(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 6: // RSP.g:1:33: NOT { /* 1:33: NOT */ mNOT(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 7: // RSP.g:1:37: EQUAL { /* 1:37: EQUAL */ mEQUAL(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 8: // RSP.g:1:43: INCLUDES { /* 1:43: INCLUDES */ mINCLUDES(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 9: // RSP.g:1:52: STARTSW { /* 1:52: STARTSW */ mSTARTSW(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 10: // RSP.g:1:60: ENDSW { /* 1:60: ENDSW */ mENDSW(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 11: // RSP.g:1:66: GREATER { /* 1:66: GREATER */ mGREATER(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 12: // RSP.g:1:74: LESS { /* 1:74: LESS */ mLESS(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 13: // RSP.g:1:79: GTE { /* 1:79: GTE */ mGTE(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 14: // RSP.g:1:83: LTE { /* 1:83: LTE */ mLTE(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 15: // RSP.g:1:87: BEFORE { /* 1:87: BEFORE */ mBEFORE(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 16: // RSP.g:1:94: AFTER { /* 1:94: AFTER */ mAFTER(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 17: // RSP.g:1:100: DAY { /* 1:100: DAY */ mDAY(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 18: // RSP.g:1:104: WEEK { /* 1:104: WEEK */ mWEEK(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 19: // RSP.g:1:109: MONTH { /* 1:109: MONTH */ mMONTH(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 20: // RSP.g:1:115: YEAR { /* 1:115: YEAR */ mYEAR(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 21: // RSP.g:1:120: TODAY { /* 1:120: TODAY */ mTODAY(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 22: // RSP.g:1:126: NEWLINE { /* 1:126: NEWLINE */ mNEWLINE(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 23: // RSP.g:1:134: WS { /* 1:134: WS */ mWS(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 24: // RSP.g:1:137: FIELD { /* 1:137: FIELD */ mFIELD(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 25: // RSP.g:1:143: INT { /* 1:143: INT */ mINT(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 26: // RSP.g:1:147: DATE { /* 1:147: DATE */ mDATE(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; case 27: // RSP.g:1:152: STR { /* 1:152: STR */ mSTR(ctx ); if (HASEXCEPTION()) { goto ruleTokensEx; } } break; } } goto ruleTokensEx; /* Prevent compiler warnings */ ruleTokensEx: ; } /* ========================================================================= * Lexer matching rules end. * ========================================================================= */ /* End of Lexer code * ================================================ * ================================================ */ /* End of code * ============================================================================= */ forked-daapd-0.19gcd/src/pregen/RSPLexer.h0000664000175000017500000002367611633141362017704 0ustar julienjulien/** \file * This C header file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : RSP.g * - On : 2011-09-11 16:17:22 * - for the lexer : RSPLexerLexer * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * * The lexer RSPLexer has the callable functions (rules) shown below, * which will invoke the code for the associated rule in the source grammar * assuming that the input stream is pointing to a token/text stream that could begin * this rule. * * For instance if you call the first (topmost) rule in a parser grammar, you will * get the results of a full parse, but calling a rule half way through the grammar will * allow you to pass part of a full token stream to the parser, such as for syntax checking * in editors and so on. * * The parser entry points are called indirectly (by function pointer to function) via * a parser context typedef pRSPLexer, which is returned from a call to RSPLexerNew(). * * As this is a generated lexer, it is unlikely you will call it 'manually'. However * the methods are provided anyway. * * The methods in pRSPLexer are as follows: * * - void pRSPLexer->QUOTE(pRSPLexer) * - void pRSPLexer->LPAR(pRSPLexer) * - void pRSPLexer->RPAR(pRSPLexer) * - void pRSPLexer->AND(pRSPLexer) * - void pRSPLexer->OR(pRSPLexer) * - void pRSPLexer->NOT(pRSPLexer) * - void pRSPLexer->EQUAL(pRSPLexer) * - void pRSPLexer->INCLUDES(pRSPLexer) * - void pRSPLexer->STARTSW(pRSPLexer) * - void pRSPLexer->ENDSW(pRSPLexer) * - void pRSPLexer->GREATER(pRSPLexer) * - void pRSPLexer->LESS(pRSPLexer) * - void pRSPLexer->GTE(pRSPLexer) * - void pRSPLexer->LTE(pRSPLexer) * - void pRSPLexer->BEFORE(pRSPLexer) * - void pRSPLexer->AFTER(pRSPLexer) * - void pRSPLexer->DAY(pRSPLexer) * - void pRSPLexer->WEEK(pRSPLexer) * - void pRSPLexer->MONTH(pRSPLexer) * - void pRSPLexer->YEAR(pRSPLexer) * - void pRSPLexer->TODAY(pRSPLexer) * - void pRSPLexer->NEWLINE(pRSPLexer) * - void pRSPLexer->WS(pRSPLexer) * - void pRSPLexer->FIELD(pRSPLexer) * - void pRSPLexer->INT(pRSPLexer) * - void pRSPLexer->DATE(pRSPLexer) * - void pRSPLexer->STR(pRSPLexer) * - void pRSPLexer->ESCAPED(pRSPLexer) * - void pRSPLexer->DIGIT09(pRSPLexer) * - void pRSPLexer->DIGIT19(pRSPLexer) * - void pRSPLexer->Tokens(pRSPLexer) * * The return type for any particular rule is of course determined by the source * grammar file. */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _RSPLexer_H #define _RSPLexer_H /* ============================================================================= * Standard antlr3 C runtime definitions */ #include /* End of standard antlr 3 runtime definitions * ============================================================================= */ #ifdef __cplusplus extern "C" { #endif // Forward declare the context typedef so that we can use it before it is // properly defined. Delegators and delegates (from import statements) are // interdependent and their context structures contain pointers to each other // C only allows such things to be declared if you pre-declare the typedef. // typedef struct RSPLexer_Ctx_struct RSPLexer, * pRSPLexer; #ifdef ANTLR3_WINDOWS // Disable: Unreferenced parameter, - Rules with parameters that are not used // constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) // initialized but unused variable - tree rewrite variables declared but not needed // Unreferenced local variable - lexer rule declares but does not always use _type // potentially unitialized variable used - retval always returned from a rule // unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns // // These are only really displayed at warning level /W4 but that is the code ideal I am aiming at // and the codegen must generate some of these warnings by necessity, apart from 4100, which is // usually generated when a parser rule is given a parameter that it does not use. Mostly though // this is a matter of orthogonality hence I disable that one. // #pragma warning( disable : 4100 ) #pragma warning( disable : 4101 ) #pragma warning( disable : 4127 ) #pragma warning( disable : 4189 ) #pragma warning( disable : 4505 ) #pragma warning( disable : 4701 ) #endif /** Context tracking structure for RSPLexer */ struct RSPLexer_Ctx_struct { /** Built in ANTLR3 context tracker contains all the generic elements * required for context tracking. */ pANTLR3_LEXER pLexer; void (*mQUOTE) (struct RSPLexer_Ctx_struct * ctx); void (*mLPAR) (struct RSPLexer_Ctx_struct * ctx); void (*mRPAR) (struct RSPLexer_Ctx_struct * ctx); void (*mAND) (struct RSPLexer_Ctx_struct * ctx); void (*mOR) (struct RSPLexer_Ctx_struct * ctx); void (*mNOT) (struct RSPLexer_Ctx_struct * ctx); void (*mEQUAL) (struct RSPLexer_Ctx_struct * ctx); void (*mINCLUDES) (struct RSPLexer_Ctx_struct * ctx); void (*mSTARTSW) (struct RSPLexer_Ctx_struct * ctx); void (*mENDSW) (struct RSPLexer_Ctx_struct * ctx); void (*mGREATER) (struct RSPLexer_Ctx_struct * ctx); void (*mLESS) (struct RSPLexer_Ctx_struct * ctx); void (*mGTE) (struct RSPLexer_Ctx_struct * ctx); void (*mLTE) (struct RSPLexer_Ctx_struct * ctx); void (*mBEFORE) (struct RSPLexer_Ctx_struct * ctx); void (*mAFTER) (struct RSPLexer_Ctx_struct * ctx); void (*mDAY) (struct RSPLexer_Ctx_struct * ctx); void (*mWEEK) (struct RSPLexer_Ctx_struct * ctx); void (*mMONTH) (struct RSPLexer_Ctx_struct * ctx); void (*mYEAR) (struct RSPLexer_Ctx_struct * ctx); void (*mTODAY) (struct RSPLexer_Ctx_struct * ctx); void (*mNEWLINE) (struct RSPLexer_Ctx_struct * ctx); void (*mWS) (struct RSPLexer_Ctx_struct * ctx); void (*mFIELD) (struct RSPLexer_Ctx_struct * ctx); void (*mINT) (struct RSPLexer_Ctx_struct * ctx); void (*mDATE) (struct RSPLexer_Ctx_struct * ctx); void (*mSTR) (struct RSPLexer_Ctx_struct * ctx); void (*mESCAPED) (struct RSPLexer_Ctx_struct * ctx); void (*mDIGIT09) (struct RSPLexer_Ctx_struct * ctx); void (*mDIGIT19) (struct RSPLexer_Ctx_struct * ctx); void (*mTokens) (struct RSPLexer_Ctx_struct * ctx); const char * (*getGrammarFileName)(); void (*free) (struct RSPLexer_Ctx_struct * ctx); }; // Function protoypes for the constructor functions that external translation units // such as delegators and delegates may wish to call. // ANTLR3_API pRSPLexer RSPLexerNew (pANTLR3_INPUT_STREAM instream); ANTLR3_API pRSPLexer RSPLexerNewSSD (pANTLR3_INPUT_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); /** Symbolic definitions of all the tokens that the lexer will work with. * \{ * * Antlr will define EOF, but we can't use that as it it is too common in * in C header files and that would be confusing. There is no way to filter this out at the moment * so we just undef it here for now. That isn't the value we get back from C recognizers * anyway. We are looking for ANTLR3_TOKEN_EOF. */ #ifdef EOF #undef EOF #endif #ifdef Tokens #undef Tokens #endif #define STARTSW 14 #define WEEK 26 #define TODAY 24 #define YEAR 28 #define ENDSW 15 #define GTE 20 #define BEFORE 21 #define DAY 25 #define INT 16 #define NOT 11 #define AFTER 22 #define AND 6 #define EOF -1 #define LTE 19 #define MONTH 27 #define DIGIT19 31 #define INCLUDES 13 #define STR 10 #define QUOTE 29 #define GREATER 18 #define WS 30 #define NEWLINE 4 #define LPAR 7 #define EQUAL 12 #define OR 5 #define LESS 17 #define FIELD 9 #define RPAR 8 #define ESCAPED 33 #define DATE 23 #define DIGIT09 32 #ifdef EOF #undef EOF #define EOF ANTLR3_TOKEN_EOF #endif #ifndef TOKENSOURCE #define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource #endif /* End of token definitions for RSPLexer * ============================================================================= */ /** \} */ #ifdef __cplusplus } #endif #endif /* END - Note:Keep extra line feed to satisfy UNIX systems */ forked-daapd-0.19gcd/src/pregen/RSP2SQL.c0000664000175000017500000022706211633141363017335 0ustar julienjulien/** \file * This C source file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : RSP2SQL.g * - On : 2011-09-11 16:17:23 * - for the tree parser : RSP2SQLTreeParser * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* ============================================================================= * This is what the grammar programmer asked us to put at the top of every file. */ /* Needs #define _GNU_SOURCE for strptime() */ #include #include #include #include #include "logger.h" #include "db.h" #include "misc.h" #include "rsp_query.h" /* End of Header action. * ============================================================================= */ /* ----------------------------------------- * Include the ANTLR3 generated header file. */ #include "RSP2SQL.h" /* ----------------------------------------- */ /* MACROS that hide the C interface implementations from the * generated code, which makes it a little more understandable to the human eye. * I am very much against using C pre-processor macros for function calls and bits * of code as you cannot see what is happening when single stepping in debuggers * and so on. The exception (in my book at least) is for generated code, where you are * not maintaining it, but may wish to read and understand it. If you single step it, you know that input() * hides some indirect calls, but is always referring to the input stream. This is * probably more readable than ctx->input->istream->input(snarfle0->blarg) and allows me to rejig * the runtime interfaces without changing the generated code too often, without * confusing the reader of the generated output, who may not wish to know the gory * details of the interface inheritance. */ #define CTX ctx /* Aids in accessing scopes for grammar programmers */ #undef SCOPE_TYPE #undef SCOPE_STACK #undef SCOPE_TOP #define SCOPE_TYPE(scope) pRSP2SQL_##scope##_SCOPE #define SCOPE_STACK(scope) pRSP2SQL_##scope##Stack #define SCOPE_TOP(scope) ctx->pRSP2SQL_##scope##Top #define SCOPE_SIZE(scope) ctx->pRSP2SQL_##scope##Stack_limit #define SCOPE_INSTANCE(scope, i) (ctx->SCOPE_STACK(scope)->get(ctx->SCOPE_STACK(scope),i)) /* Macros for accessing things in the parser */ #undef PARSER #undef RECOGNIZER #undef HAVEPARSEDRULE #undef INPUT #undef STRSTREAM #undef HASEXCEPTION #undef EXCEPTION #undef MATCHT #undef MATCHANYT #undef FOLLOWSTACK #undef FOLLOWPUSH #undef FOLLOWPOP #undef PRECOVER #undef PREPORTERROR #undef LA #undef LT #undef CONSTRUCTEX #undef CONSUME #undef MARK #undef REWIND #undef REWINDLAST #undef PERRORRECOVERY #undef HASFAILED #undef FAILEDFLAG #undef RECOVERFROMMISMATCHEDSET #undef RECOVERFROMMISMATCHEDELEMENT #undef BACKTRACKING #undef ADAPTOR #undef RULEMEMO #undef SEEK #undef INDEX #undef DBG #define PARSER ctx->pTreeParser #define RECOGNIZER PARSER->rec #define PSRSTATE RECOGNIZER->state #define HAVEPARSEDRULE(r) RECOGNIZER->alreadyParsedRule(RECOGNIZER, r) #define INPUT PARSER->ctnstream #define ISTREAM INPUT->tnstream->istream #define STRSTREAM INPUT->tnstream #define HASEXCEPTION() (PSRSTATE->error == ANTLR3_TRUE) #define EXCEPTION PSRSTATE->exception #define MATCHT(t, fs) RECOGNIZER->match(RECOGNIZER, t, fs) #define MATCHANYT() RECOGNIZER->matchAny(RECOGNIZER) #define FOLLOWSTACK PSRSTATE->following #define FOLLOWPUSH(x) FOLLOWSTACK->push(FOLLOWSTACK, ((void *)(&(x))), NULL) #define FOLLOWPOP() FOLLOWSTACK->pop(FOLLOWSTACK) #define PRECOVER() RECOGNIZER->recover(RECOGNIZER) #define PREPORTERROR() RECOGNIZER->reportError(RECOGNIZER) #define LA(n) ISTREAM->_LA(ISTREAM, n) #define LT(n) INPUT->tnstream->_LT(INPUT->tnstream, n) #define CONSTRUCTEX() RECOGNIZER->exConstruct(RECOGNIZER) #define CONSUME() ISTREAM->consume(ISTREAM) #define MARK() ISTREAM->mark(ISTREAM) #define REWIND(m) ISTREAM->rewind(ISTREAM, m) #define REWINDLAST() ISTREAM->rewindLast(ISTREAM) #define PERRORRECOVERY PSRSTATE->errorRecovery #define FAILEDFLAG PSRSTATE->failed #define HASFAILED() (FAILEDFLAG == ANTLR3_TRUE) #define BACKTRACKING PSRSTATE->backtracking #define RECOVERFROMMISMATCHEDSET(s) RECOGNIZER->recoverFromMismatchedSet(RECOGNIZER, s) #define RECOVERFROMMISMATCHEDELEMENT(e) RECOGNIZER->recoverFromMismatchedElement(RECOGNIZER, s) #define ADAPTOR INPUT->adaptor #define RULEMEMO PSRSTATE->ruleMemo #define SEEK(n) ISTREAM->seek(ISTREAM, n) #define INDEX() ISTREAM->index(ISTREAM) #define DBG RECOGNIZER->debugger #define TOKTEXT(tok, txt) tok, (pANTLR3_UINT8)txt /* The 4 tokens defined below may well clash with your own #defines or token types. If so * then for the present you must use different names for your defines as these are hard coded * in the code generator. It would be better not to use such names internally, and maybe * we can change this in a forthcoming release. I deliberately do not #undef these * here as this will at least give you a redefined error somewhere if they clash. */ #define UP ANTLR3_TOKEN_UP #define DOWN ANTLR3_TOKEN_DOWN #define EOR ANTLR3_TOKEN_EOR #define INVALID ANTLR3_TOKEN_INVALID /* ============================================================================= * Functions to create and destroy scopes. First come the rule scopes, followed * by the global declared scopes. */ /* ============================================================================= */ /* ============================================================================= * Start of recognizer */ /** \brief Table of all token names in symbolic order, mainly used for * error reporting. */ pANTLR3_UINT8 RSP2SQLTokenNames[30+4] = { (pANTLR3_UINT8) "", /* String to print to indicate an invalid token */ (pANTLR3_UINT8) "", (pANTLR3_UINT8) "", (pANTLR3_UINT8) "", (pANTLR3_UINT8) "NEWLINE", (pANTLR3_UINT8) "OR", (pANTLR3_UINT8) "AND", (pANTLR3_UINT8) "LPAR", (pANTLR3_UINT8) "RPAR", (pANTLR3_UINT8) "FIELD", (pANTLR3_UINT8) "STR", (pANTLR3_UINT8) "NOT", (pANTLR3_UINT8) "EQUAL", (pANTLR3_UINT8) "INCLUDES", (pANTLR3_UINT8) "STARTSW", (pANTLR3_UINT8) "ENDSW", (pANTLR3_UINT8) "INT", (pANTLR3_UINT8) "LESS", (pANTLR3_UINT8) "GREATER", (pANTLR3_UINT8) "LTE", (pANTLR3_UINT8) "GTE", (pANTLR3_UINT8) "BEFORE", (pANTLR3_UINT8) "AFTER", (pANTLR3_UINT8) "DATE", (pANTLR3_UINT8) "TODAY", (pANTLR3_UINT8) "DAY", (pANTLR3_UINT8) "WEEK", (pANTLR3_UINT8) "MONTH", (pANTLR3_UINT8) "YEAR", (pANTLR3_UINT8) "QUOTE", (pANTLR3_UINT8) "WS", (pANTLR3_UINT8) "DIGIT19", (pANTLR3_UINT8) "DIGIT09", (pANTLR3_UINT8) "ESCAPED" }; // Forward declare the locally static matching functions we have generated. // static pANTLR3_STRING query (pRSP2SQL ctx); static RSP2SQL_expr_return expr (pRSP2SQL ctx); static RSP2SQL_strcrit_return strcrit (pRSP2SQL ctx); static pANTLR3_COMMON_TOKEN strop (pRSP2SQL ctx); static RSP2SQL_intcrit_return intcrit (pRSP2SQL ctx); static pANTLR3_COMMON_TOKEN intop (pRSP2SQL ctx); static RSP2SQL_datecrit_return datecrit (pRSP2SQL ctx); static pANTLR3_COMMON_TOKEN dateop (pRSP2SQL ctx); static RSP2SQL_datespec_return datespec (pRSP2SQL ctx); static RSP2SQL_dateref_return dateref (pRSP2SQL ctx); static RSP2SQL_dateintval_return dateintval (pRSP2SQL ctx); static void RSP2SQLFree(pRSP2SQL ctx); /* For use in tree output where we are accumulating rule labels via label += ruleRef * we need a function that knows how to free a return scope when the list is destroyed. * We cannot just use ANTLR3_FREE because in debug tracking mode, this is a macro. */ static void ANTLR3_CDECL freeScope(void * scope) { ANTLR3_FREE(scope); } /** \brief Name of the grammar file that generated this code */ static const char fileName[] = "RSP2SQL.g"; /** \brief Return the name of the grammar file that generated this code. */ static const char * getGrammarFileName() { return fileName; } /** \brief Create a new RSP2SQL parser and return a context for it. * * \param[in] instream Pointer to an input stream interface. * * \return Pointer to new parser context upon success. */ ANTLR3_API pRSP2SQL RSP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream) { // See if we can create a new parser with the standard constructor // return RSP2SQLNewSSD(instream, NULL); } /** \brief Create a new RSP2SQL parser and return a context for it. * * \param[in] instream Pointer to an input stream interface. * * \return Pointer to new parser context upon success. */ ANTLR3_API pRSP2SQL RSP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state) { pRSP2SQL ctx; /* Context structure we will build and return */ ctx = (pRSP2SQL) ANTLR3_CALLOC(1, sizeof(RSP2SQL)); if (ctx == NULL) { // Failed to allocate memory for parser context // return NULL; } /* ------------------------------------------------------------------- * Memory for basic structure is allocated, now to fill in * the base ANTLR3 structures. We initialize the function pointers * for the standard ANTLR3 parser function set, but upon return * from here, the programmer may set the pointers to provide custom * implementations of each function. * * We don't use the macros defined in RSP2SQL.h here, in order that you can get a sense * of what goes where. */ /* Create a base Tree parser/recognizer, using the supplied tree node stream */ ctx->pTreeParser = antlr3TreeParserNewStream(ANTLR3_SIZE_HINT, instream, state); /* Install the implementation of our RSP2SQL interface */ ctx->query = query; ctx->expr = expr; ctx->strcrit = strcrit; ctx->strop = strop; ctx->intcrit = intcrit; ctx->intop = intop; ctx->datecrit = datecrit; ctx->dateop = dateop; ctx->datespec = datespec; ctx->dateref = dateref; ctx->dateintval = dateintval; ctx->free = RSP2SQLFree; ctx->getGrammarFileName = getGrammarFileName; /* Install the scope pushing methods. */ /* Install the token table */ PSRSTATE->tokenNames = RSP2SQLTokenNames; /* Return the newly built parser to the caller */ return ctx; } /** Free the parser resources */ static void RSP2SQLFree(pRSP2SQL ctx) { /* Free any scope memory */ // Free this parser // ctx->pTreeParser->free(ctx->pTreeParser); ANTLR3_FREE(ctx); /* Everything is released, so we can return */ return; } /** Return token names used by this tree parser * * The returned pointer is used as an index into the token names table (using the token * number as the index). * * \return Pointer to first char * in the table. */ static pANTLR3_UINT8 *getTokenNames() { return RSP2SQLTokenNames; } #define RSP_TYPE_STRING 0 #define RSP_TYPE_INT 1 #define RSP_TYPE_DATE 2 struct rsp_query_field_map { char *rsp_field; int field_type; /* RSP fields are named after the DB columns - or vice versa */ }; /* gperf static hash, rsp_query.gperf */ #include "rsp_query_hash.c" /* Declare the bitsets */ /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_query70 */ static ANTLR3_BITWORD FOLLOW_expr_in_query70_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_query70 = { FOLLOW_expr_in_query70_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_AND_in_expr95 */ static ANTLR3_BITWORD FOLLOW_AND_in_expr95_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; static ANTLR3_BITSET_LIST FOLLOW_AND_in_expr95 = { FOLLOW_AND_in_expr95_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr101 */ static ANTLR3_BITWORD FOLLOW_expr_in_expr101_bits[] = { ANTLR3_UINT64_LIT(0x00000000007EF860) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr101 = { FOLLOW_expr_in_expr101_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr107 */ static ANTLR3_BITWORD FOLLOW_expr_in_expr107_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr107 = { FOLLOW_expr_in_expr107_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_OR_in_expr118 */ static ANTLR3_BITWORD FOLLOW_OR_in_expr118_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; static ANTLR3_BITSET_LIST FOLLOW_OR_in_expr118 = { FOLLOW_OR_in_expr118_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr124 */ static ANTLR3_BITWORD FOLLOW_expr_in_expr124_bits[] = { ANTLR3_UINT64_LIT(0x00000000007EF860) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr124 = { FOLLOW_expr_in_expr124_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_expr_in_expr130 */ static ANTLR3_BITWORD FOLLOW_expr_in_expr130_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; static ANTLR3_BITSET_LIST FOLLOW_expr_in_expr130 = { FOLLOW_expr_in_expr130_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_expr144 */ static ANTLR3_BITWORD FOLLOW_strcrit_in_expr144_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_expr144 = { FOLLOW_strcrit_in_expr144_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_expr154 */ static ANTLR3_BITWORD FOLLOW_NOT_in_expr154_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; static ANTLR3_BITSET_LIST FOLLOW_NOT_in_expr154 = { FOLLOW_NOT_in_expr154_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_strcrit_in_expr160 */ static ANTLR3_BITWORD FOLLOW_strcrit_in_expr160_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; static ANTLR3_BITSET_LIST FOLLOW_strcrit_in_expr160 = { FOLLOW_strcrit_in_expr160_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_expr174 */ static ANTLR3_BITWORD FOLLOW_intcrit_in_expr174_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_expr174 = { FOLLOW_intcrit_in_expr174_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_NOT_in_expr184 */ static ANTLR3_BITWORD FOLLOW_NOT_in_expr184_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; static ANTLR3_BITSET_LIST FOLLOW_NOT_in_expr184 = { FOLLOW_NOT_in_expr184_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_intcrit_in_expr190 */ static ANTLR3_BITWORD FOLLOW_intcrit_in_expr190_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; static ANTLR3_BITSET_LIST FOLLOW_intcrit_in_expr190 = { FOLLOW_intcrit_in_expr190_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_datecrit_in_expr204 */ static ANTLR3_BITWORD FOLLOW_datecrit_in_expr204_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_datecrit_in_expr204 = { FOLLOW_datecrit_in_expr204_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_strop_in_strcrit233 */ static ANTLR3_BITWORD FOLLOW_strop_in_strcrit233_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; static ANTLR3_BITSET_LIST FOLLOW_strop_in_strcrit233 = { FOLLOW_strop_in_strcrit233_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_strcrit239 */ static ANTLR3_BITWORD FOLLOW_FIELD_in_strcrit239_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000400) }; static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_strcrit239 = { FOLLOW_FIELD_in_strcrit239_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_STR_in_strcrit245 */ static ANTLR3_BITWORD FOLLOW_STR_in_strcrit245_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; static ANTLR3_BITSET_LIST FOLLOW_STR_in_strcrit245 = { FOLLOW_STR_in_strcrit245_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_EQUAL_in_strop274 */ static ANTLR3_BITWORD FOLLOW_EQUAL_in_strop274_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_EQUAL_in_strop274 = { FOLLOW_EQUAL_in_strop274_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_INCLUDES_in_strop287 */ static ANTLR3_BITWORD FOLLOW_INCLUDES_in_strop287_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_INCLUDES_in_strop287 = { FOLLOW_INCLUDES_in_strop287_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_STARTSW_in_strop300 */ static ANTLR3_BITWORD FOLLOW_STARTSW_in_strop300_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_STARTSW_in_strop300 = { FOLLOW_STARTSW_in_strop300_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_ENDSW_in_strop313 */ static ANTLR3_BITWORD FOLLOW_ENDSW_in_strop313_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_ENDSW_in_strop313 = { FOLLOW_ENDSW_in_strop313_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_intop_in_intcrit342 */ static ANTLR3_BITWORD FOLLOW_intop_in_intcrit342_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; static ANTLR3_BITSET_LIST FOLLOW_intop_in_intcrit342 = { FOLLOW_intop_in_intcrit342_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_intcrit348 */ static ANTLR3_BITWORD FOLLOW_FIELD_in_intcrit348_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_intcrit348 = { FOLLOW_FIELD_in_intcrit348_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_intcrit354 */ static ANTLR3_BITWORD FOLLOW_INT_in_intcrit354_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; static ANTLR3_BITSET_LIST FOLLOW_INT_in_intcrit354 = { FOLLOW_INT_in_intcrit354_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_EQUAL_in_intop383 */ static ANTLR3_BITWORD FOLLOW_EQUAL_in_intop383_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_EQUAL_in_intop383 = { FOLLOW_EQUAL_in_intop383_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_LESS_in_intop396 */ static ANTLR3_BITWORD FOLLOW_LESS_in_intop396_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_LESS_in_intop396 = { FOLLOW_LESS_in_intop396_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_GREATER_in_intop409 */ static ANTLR3_BITWORD FOLLOW_GREATER_in_intop409_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_GREATER_in_intop409 = { FOLLOW_GREATER_in_intop409_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_LTE_in_intop422 */ static ANTLR3_BITWORD FOLLOW_LTE_in_intop422_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_LTE_in_intop422 = { FOLLOW_LTE_in_intop422_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_GTE_in_intop435 */ static ANTLR3_BITWORD FOLLOW_GTE_in_intop435_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_GTE_in_intop435 = { FOLLOW_GTE_in_intop435_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datecrit464 */ static ANTLR3_BITWORD FOLLOW_dateop_in_datecrit464_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datecrit464 = { FOLLOW_dateop_in_datecrit464_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_FIELD_in_datecrit470 */ static ANTLR3_BITWORD FOLLOW_FIELD_in_datecrit470_bits[] = { ANTLR3_UINT64_LIT(0x0000000001FEF860) }; static ANTLR3_BITSET_LIST FOLLOW_FIELD_in_datecrit470 = { FOLLOW_FIELD_in_datecrit470_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_datespec_in_datecrit476 */ static ANTLR3_BITWORD FOLLOW_datespec_in_datecrit476_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; static ANTLR3_BITSET_LIST FOLLOW_datespec_in_datecrit476 = { FOLLOW_datespec_in_datecrit476_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_BEFORE_in_dateop505 */ static ANTLR3_BITWORD FOLLOW_BEFORE_in_dateop505_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_BEFORE_in_dateop505 = { FOLLOW_BEFORE_in_dateop505_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_AFTER_in_dateop518 */ static ANTLR3_BITWORD FOLLOW_AFTER_in_dateop518_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_AFTER_in_dateop518 = { FOLLOW_AFTER_in_dateop518_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec546 */ static ANTLR3_BITWORD FOLLOW_dateref_in_datespec546_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec546 = { FOLLOW_dateref_in_datespec546_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_dateop_in_datespec560 */ static ANTLR3_BITWORD FOLLOW_dateop_in_datespec560_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000004) }; static ANTLR3_BITSET_LIST FOLLOW_dateop_in_datespec560 = { FOLLOW_dateop_in_datespec560_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_dateref_in_datespec566 */ static ANTLR3_BITWORD FOLLOW_dateref_in_datespec566_bits[] = { ANTLR3_UINT64_LIT(0x0000000000010000) }; static ANTLR3_BITSET_LIST FOLLOW_dateref_in_datespec566 = { FOLLOW_dateref_in_datespec566_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_INT_in_datespec572 */ static ANTLR3_BITWORD FOLLOW_INT_in_datespec572_bits[] = { ANTLR3_UINT64_LIT(0x000000001E000000) }; static ANTLR3_BITSET_LIST FOLLOW_INT_in_datespec572 = { FOLLOW_INT_in_datespec572_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_dateintval_in_datespec578 */ static ANTLR3_BITWORD FOLLOW_dateintval_in_datespec578_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000008) }; static ANTLR3_BITSET_LIST FOLLOW_dateintval_in_datespec578 = { FOLLOW_dateintval_in_datespec578_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_DATE_in_dateref607 */ static ANTLR3_BITWORD FOLLOW_DATE_in_dateref607_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_DATE_in_dateref607 = { FOLLOW_DATE_in_dateref607_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_TODAY_in_dateref616 */ static ANTLR3_BITWORD FOLLOW_TODAY_in_dateref616_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_TODAY_in_dateref616 = { FOLLOW_TODAY_in_dateref616_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_DAY_in_dateintval640 */ static ANTLR3_BITWORD FOLLOW_DAY_in_dateintval640_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_DAY_in_dateintval640 = { FOLLOW_DAY_in_dateintval640_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_WEEK_in_dateintval649 */ static ANTLR3_BITWORD FOLLOW_WEEK_in_dateintval649_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_WEEK_in_dateintval649 = { FOLLOW_WEEK_in_dateintval649_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_MONTH_in_dateintval658 */ static ANTLR3_BITWORD FOLLOW_MONTH_in_dateintval658_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_MONTH_in_dateintval658 = { FOLLOW_MONTH_in_dateintval658_bits, 1 }; /** Bitset defining follow set for error recovery in rule state: FOLLOW_YEAR_in_dateintval667 */ static ANTLR3_BITWORD FOLLOW_YEAR_in_dateintval667_bits[] = { ANTLR3_UINT64_LIT(0x0000000000000002) }; static ANTLR3_BITSET_LIST FOLLOW_YEAR_in_dateintval667 = { FOLLOW_YEAR_in_dateintval667_bits, 1 }; /* ============================================== * Parsing rules */ /** * $ANTLR start query * RSP2SQL.g:56:1: query returns [ pANTLR3_STRING result ] : e= expr ; */ static pANTLR3_STRING query(pRSP2SQL ctx) { pANTLR3_STRING result = NULL; RSP2SQL_expr_return e; #undef RETURN_TYPE_e #define RETURN_TYPE_e RSP2SQL_expr_return /* Initialize rule variables */ result= NULL; { // RSP2SQL.g:58:2: (e= expr ) // RSP2SQL.g:58:4: e= expr { FOLLOWPUSH(FOLLOW_expr_in_query70); e=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulequeryEx; } { if (!e.valid) { result= NULL; } else { result= e.result->factory->newRaw(e.result->factory); result->append8(result, "("); result->appendS(result, e.result); result->append8(result, ")"); } } } } // This is where rules clean up and exit // goto rulequeryEx; /* Prevent compiler warnings */ rulequeryEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return result; } /* $ANTLR end query */ /** * $ANTLR start expr * RSP2SQL.g:74:1: expr returns [ pANTLR3_STRING result, int valid ] : ( ^( AND a= expr b= expr ) | ^( OR a= expr b= expr ) | c= strcrit | ^( NOT c= strcrit ) | i= intcrit | ^( NOT i= intcrit ) | d= datecrit ); */ static RSP2SQL_expr_return expr(pRSP2SQL ctx) { RSP2SQL_expr_return retval; RSP2SQL_expr_return a; #undef RETURN_TYPE_a #define RETURN_TYPE_a RSP2SQL_expr_return RSP2SQL_expr_return b; #undef RETURN_TYPE_b #define RETURN_TYPE_b RSP2SQL_expr_return RSP2SQL_strcrit_return c; #undef RETURN_TYPE_c #define RETURN_TYPE_c RSP2SQL_strcrit_return RSP2SQL_intcrit_return i; #undef RETURN_TYPE_i #define RETURN_TYPE_i RSP2SQL_intcrit_return RSP2SQL_datecrit_return d; #undef RETURN_TYPE_d #define RETURN_TYPE_d RSP2SQL_datecrit_return /* Initialize rule variables */ retval.result= NULL; retval.valid= 1; retval.start = LT(1); retval.stop = retval.start; { { // RSP2SQL.g:76:2: ( ^( AND a= expr b= expr ) | ^( OR a= expr b= expr ) | c= strcrit | ^( NOT c= strcrit ) | i= intcrit | ^( NOT i= intcrit ) | d= datecrit ) ANTLR3_UINT32 alt1; alt1=7; switch ( LA(1) ) { case AND: { alt1=1; } break; case OR: { alt1=2; } break; case EQUAL: { switch ( LA(2) ) { case DOWN: { switch ( LA(3) ) { case FIELD: { switch ( LA(4) ) { case INT: { alt1=5; } break; case STR: { alt1=3; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 10; goto ruleexprEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 8; goto ruleexprEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 3; goto ruleexprEx; } } break; case INCLUDES: case STARTSW: case ENDSW: { alt1=3; } break; case NOT: { switch ( LA(2) ) { case DOWN: { switch ( LA(3) ) { case EQUAL: { switch ( LA(4) ) { case DOWN: { switch ( LA(5) ) { case FIELD: { switch ( LA(6) ) { case STR: { alt1=4; } break; case INT: { alt1=6; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 15; goto ruleexprEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 14; goto ruleexprEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 11; goto ruleexprEx; } } break; case LESS: case GREATER: case LTE: case GTE: { alt1=6; } break; case INCLUDES: case STARTSW: case ENDSW: { alt1=4; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 9; goto ruleexprEx; } } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 5; goto ruleexprEx; } } break; case LESS: case GREATER: case LTE: case GTE: { alt1=5; } break; case BEFORE: case AFTER: { alt1=7; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 1; EXCEPTION->state = 0; goto ruleexprEx; } switch (alt1) { case 1: // RSP2SQL.g:76:4: ^( AND a= expr b= expr ) { MATCHT(AND, &FOLLOW_AND_in_expr95); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_DOWN, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } FOLLOWPUSH(FOLLOW_expr_in_expr101); a=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } FOLLOWPUSH(FOLLOW_expr_in_expr107); b=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_UP, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } { if (!a.valid || !b.valid) { retval.valid= 0; } else { retval.result= a.result->factory->newRaw(a.result->factory); retval.result->append8(retval.result, "("); retval.result->appendS(retval.result, a.result); retval.result->append8(retval.result, " AND "); retval.result->appendS(retval.result, b.result); retval.result->append8(retval.result, ")"); } } } break; case 2: // RSP2SQL.g:92:4: ^( OR a= expr b= expr ) { MATCHT(OR, &FOLLOW_OR_in_expr118); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_DOWN, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } FOLLOWPUSH(FOLLOW_expr_in_expr124); a=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } FOLLOWPUSH(FOLLOW_expr_in_expr130); b=expr(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_UP, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } { if (!a.valid || !b.valid) { retval.valid= 0; } else { retval.result= a.result->factory->newRaw(a.result->factory); retval.result->append8(retval.result, "("); retval.result->appendS(retval.result, a.result); retval.result->append8(retval.result, " OR "); retval.result->appendS(retval.result, b.result); retval.result->append8(retval.result, ")"); } } } break; case 3: // RSP2SQL.g:108:4: c= strcrit { FOLLOWPUSH(FOLLOW_strcrit_in_expr144); c=strcrit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } { retval.valid= c.valid; retval.result= c.result; } } break; case 4: // RSP2SQL.g:113:4: ^( NOT c= strcrit ) { MATCHT(NOT, &FOLLOW_NOT_in_expr154); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_DOWN, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } FOLLOWPUSH(FOLLOW_strcrit_in_expr160); c=strcrit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_UP, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } { if (!c.valid) { retval.valid= 0; } else { retval.result= c.result->factory->newRaw(c.result->factory); retval.result->append8(retval.result, "(NOT "); retval.result->appendS(retval.result, c.result); retval.result->append8(retval.result, ")"); } } } break; case 5: // RSP2SQL.g:127:4: i= intcrit { FOLLOWPUSH(FOLLOW_intcrit_in_expr174); i=intcrit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } { retval.valid= i.valid; retval.result= i.result; } } break; case 6: // RSP2SQL.g:132:4: ^( NOT i= intcrit ) { MATCHT(NOT, &FOLLOW_NOT_in_expr184); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_DOWN, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } FOLLOWPUSH(FOLLOW_intcrit_in_expr190); i=intcrit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } MATCHT(ANTLR3_TOKEN_UP, NULL); if (HASEXCEPTION()) { goto ruleexprEx; } { if (!i.valid) { retval.valid= 0; } else { retval.result= i.result->factory->newRaw(i.result->factory); retval.result->append8(retval.result, "(NOT "); retval.result->appendS(retval.result, i.result); retval.result->append8(retval.result, ")"); } } } break; case 7: // RSP2SQL.g:146:4: d= datecrit { FOLLOWPUSH(FOLLOW_datecrit_in_expr204); d=datecrit(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleexprEx; } { retval.valid= d.valid; retval.result= d.result; } } break; } } } // This is where rules clean up and exit // goto ruleexprEx; /* Prevent compiler warnings */ ruleexprEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return retval; } /* $ANTLR end expr */ /** * $ANTLR start strcrit * RSP2SQL.g:153:1: strcrit returns [ pANTLR3_STRING result, int valid ] : ^(o= strop f= FIELD s= STR ) ; */ static RSP2SQL_strcrit_return strcrit(pRSP2SQL ctx) { RSP2SQL_strcrit_return retval; pANTLR3_BASE_TREE f; pANTLR3_BASE_TREE s; pANTLR3_COMMON_TOKEN o; #undef RETURN_TYPE_o #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN /* Initialize rule variables */ retval.result= NULL; retval.valid= 1; f = NULL; s = NULL; o = NULL; retval.start = LT(1); retval.stop = retval.start; { // RSP2SQL.g:155:2: ( ^(o= strop f= FIELD s= STR ) ) // RSP2SQL.g:155:4: ^(o= strop f= FIELD s= STR ) { FOLLOWPUSH(FOLLOW_strop_in_strcrit233); o=strop(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto rulestrcritEx; } MATCHT(ANTLR3_TOKEN_DOWN, NULL); if (HASEXCEPTION()) { goto rulestrcritEx; } f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_strcrit239); if (HASEXCEPTION()) { goto rulestrcritEx; } s = (pANTLR3_BASE_TREE) MATCHT(STR, &FOLLOW_STR_in_strcrit245); if (HASEXCEPTION()) { goto rulestrcritEx; } MATCHT(ANTLR3_TOKEN_UP, NULL); if (HASEXCEPTION()) { goto rulestrcritEx; } { char *op; const struct rsp_query_field_map *rqfp; pANTLR3_STRING field; char *escaped; ANTLR3_UINT32 optok; escaped = NULL; op = NULL; optok = o->getType(o); switch (optok) { case EQUAL: op = " = "; break; case INCLUDES: case STARTSW: case ENDSW: op = " LIKE "; break; } field = f->getText(f); /* Field lookup */ rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars)); if (!rqfp) { DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars); retval.valid= 0; goto strcrit_valid_0; /* ABORT */ } /* Check field type */ if (rqfp->field_type != RSP_TYPE_STRING) { DPRINTF(E_LOG, L_RSP, "Field '%s' is not a string field\n", field->chars); retval.valid= 0; goto strcrit_valid_0; /* ABORT */ } escaped = db_escape_string((char *)s->getText(s)->chars); if (!escaped) { DPRINTF(E_LOG, L_RSP, "Could not escape value\n"); retval.valid= 0; goto strcrit_valid_0; /* ABORT */ } retval.result= field->factory->newRaw(field->factory); retval.result->append8(retval.result, "f."); retval.result->appendS(retval.result, field); retval.result->append8(retval.result, op); retval.result->append8(retval.result, "'"); if ((optok == INCLUDES) || (optok == STARTSW)) retval.result->append8(retval.result, "%"); retval.result->append8(retval.result, escaped); if ((optok == INCLUDES) || (optok == ENDSW)) retval.result->append8(retval.result, "%"); retval.result->append8(retval.result, "'"); strcrit_valid_0: ; if (escaped) free(escaped); } } } // This is where rules clean up and exit // goto rulestrcritEx; /* Prevent compiler warnings */ rulestrcritEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return retval; } /* $ANTLR end strcrit */ /** * $ANTLR start strop * RSP2SQL.g:229:1: strop returns [ pANTLR3_COMMON_TOKEN op ] : (n= EQUAL | n= INCLUDES | n= STARTSW | n= ENDSW ); */ static pANTLR3_COMMON_TOKEN strop(pRSP2SQL ctx) { pANTLR3_COMMON_TOKEN op = NULL; pANTLR3_BASE_TREE n; /* Initialize rule variables */ op= NULL; n = NULL; { { // RSP2SQL.g:231:2: (n= EQUAL | n= INCLUDES | n= STARTSW | n= ENDSW ) ANTLR3_UINT32 alt2; alt2=4; switch ( LA(1) ) { case EQUAL: { alt2=1; } break; case INCLUDES: { alt2=2; } break; case STARTSW: { alt2=3; } break; case ENDSW: { alt2=4; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 2; EXCEPTION->state = 0; goto rulestropEx; } switch (alt2) { case 1: // RSP2SQL.g:231:4: n= EQUAL { n = (pANTLR3_BASE_TREE) MATCHT(EQUAL, &FOLLOW_EQUAL_in_strop274); if (HASEXCEPTION()) { goto rulestropEx; } { op= n->getToken(n); } } break; case 2: // RSP2SQL.g:233:4: n= INCLUDES { n = (pANTLR3_BASE_TREE) MATCHT(INCLUDES, &FOLLOW_INCLUDES_in_strop287); if (HASEXCEPTION()) { goto rulestropEx; } { op= n->getToken(n); } } break; case 3: // RSP2SQL.g:235:4: n= STARTSW { n = (pANTLR3_BASE_TREE) MATCHT(STARTSW, &FOLLOW_STARTSW_in_strop300); if (HASEXCEPTION()) { goto rulestropEx; } { op= n->getToken(n); } } break; case 4: // RSP2SQL.g:237:4: n= ENDSW { n = (pANTLR3_BASE_TREE) MATCHT(ENDSW, &FOLLOW_ENDSW_in_strop313); if (HASEXCEPTION()) { goto rulestropEx; } { op= n->getToken(n); } } break; } } } // This is where rules clean up and exit // goto rulestropEx; /* Prevent compiler warnings */ rulestropEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return op; } /* $ANTLR end strop */ /** * $ANTLR start intcrit * RSP2SQL.g:241:1: intcrit returns [ pANTLR3_STRING result, int valid ] : ^(o= intop f= FIELD i= INT ) ; */ static RSP2SQL_intcrit_return intcrit(pRSP2SQL ctx) { RSP2SQL_intcrit_return retval; pANTLR3_BASE_TREE f; pANTLR3_BASE_TREE i; pANTLR3_COMMON_TOKEN o; #undef RETURN_TYPE_o #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN /* Initialize rule variables */ retval.result= NULL; retval.valid= 1; f = NULL; i = NULL; o = NULL; retval.start = LT(1); retval.stop = retval.start; { // RSP2SQL.g:243:2: ( ^(o= intop f= FIELD i= INT ) ) // RSP2SQL.g:243:4: ^(o= intop f= FIELD i= INT ) { FOLLOWPUSH(FOLLOW_intop_in_intcrit342); o=intop(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruleintcritEx; } MATCHT(ANTLR3_TOKEN_DOWN, NULL); if (HASEXCEPTION()) { goto ruleintcritEx; } f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_intcrit348); if (HASEXCEPTION()) { goto ruleintcritEx; } i = (pANTLR3_BASE_TREE) MATCHT(INT, &FOLLOW_INT_in_intcrit354); if (HASEXCEPTION()) { goto ruleintcritEx; } MATCHT(ANTLR3_TOKEN_UP, NULL); if (HASEXCEPTION()) { goto ruleintcritEx; } { char *op; const struct rsp_query_field_map *rqfp; pANTLR3_STRING field; op = NULL; switch (o->getType(o)) { case EQUAL: op = " = "; break; case LESS: op = " < "; break; case GREATER: op = " > "; break; case LTE: op = " <= "; break; case GTE: op = " >= "; break; } field = f->getText(f); /* Field lookup */ rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars)); if (!rqfp) { DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars); retval.valid= 0; goto intcrit_valid_0; /* ABORT */ } /* Check field type */ if (rqfp->field_type != RSP_TYPE_INT) { DPRINTF(E_LOG, L_RSP, "Field '%s' is not an integer field\n", field->chars); retval.valid= 0; goto intcrit_valid_0; /* ABORT */ } retval.result= field->factory->newRaw(field->factory); retval.result->append8(retval.result, "f."); retval.result->appendS(retval.result, field); retval.result->append8(retval.result, op); retval.result->appendS(retval.result, i->getText(i)); intcrit_valid_0: ; } } } // This is where rules clean up and exit // goto ruleintcritEx; /* Prevent compiler warnings */ ruleintcritEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return retval; } /* $ANTLR end intcrit */ /** * $ANTLR start intop * RSP2SQL.g:303:1: intop returns [ pANTLR3_COMMON_TOKEN op ] : (n= EQUAL | n= LESS | n= GREATER | n= LTE | n= GTE ); */ static pANTLR3_COMMON_TOKEN intop(pRSP2SQL ctx) { pANTLR3_COMMON_TOKEN op = NULL; pANTLR3_BASE_TREE n; /* Initialize rule variables */ op= NULL; n = NULL; { { // RSP2SQL.g:305:2: (n= EQUAL | n= LESS | n= GREATER | n= LTE | n= GTE ) ANTLR3_UINT32 alt3; alt3=5; switch ( LA(1) ) { case EQUAL: { alt3=1; } break; case LESS: { alt3=2; } break; case GREATER: { alt3=3; } break; case LTE: { alt3=4; } break; case GTE: { alt3=5; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 3; EXCEPTION->state = 0; goto ruleintopEx; } switch (alt3) { case 1: // RSP2SQL.g:305:4: n= EQUAL { n = (pANTLR3_BASE_TREE) MATCHT(EQUAL, &FOLLOW_EQUAL_in_intop383); if (HASEXCEPTION()) { goto ruleintopEx; } { op= n->getToken(n); } } break; case 2: // RSP2SQL.g:307:4: n= LESS { n = (pANTLR3_BASE_TREE) MATCHT(LESS, &FOLLOW_LESS_in_intop396); if (HASEXCEPTION()) { goto ruleintopEx; } { op= n->getToken(n); } } break; case 3: // RSP2SQL.g:309:4: n= GREATER { n = (pANTLR3_BASE_TREE) MATCHT(GREATER, &FOLLOW_GREATER_in_intop409); if (HASEXCEPTION()) { goto ruleintopEx; } { op= n->getToken(n); } } break; case 4: // RSP2SQL.g:311:4: n= LTE { n = (pANTLR3_BASE_TREE) MATCHT(LTE, &FOLLOW_LTE_in_intop422); if (HASEXCEPTION()) { goto ruleintopEx; } { op= n->getToken(n); } } break; case 5: // RSP2SQL.g:313:4: n= GTE { n = (pANTLR3_BASE_TREE) MATCHT(GTE, &FOLLOW_GTE_in_intop435); if (HASEXCEPTION()) { goto ruleintopEx; } { op= n->getToken(n); } } break; } } } // This is where rules clean up and exit // goto ruleintopEx; /* Prevent compiler warnings */ ruleintopEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return op; } /* $ANTLR end intop */ /** * $ANTLR start datecrit * RSP2SQL.g:317:1: datecrit returns [ pANTLR3_STRING result, int valid ] : ^(o= dateop f= FIELD d= datespec ) ; */ static RSP2SQL_datecrit_return datecrit(pRSP2SQL ctx) { RSP2SQL_datecrit_return retval; pANTLR3_BASE_TREE f; pANTLR3_COMMON_TOKEN o; #undef RETURN_TYPE_o #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN RSP2SQL_datespec_return d; #undef RETURN_TYPE_d #define RETURN_TYPE_d RSP2SQL_datespec_return /* Initialize rule variables */ retval.result= NULL; retval.valid= 1; f = NULL; o = NULL; retval.start = LT(1); retval.stop = retval.start; { // RSP2SQL.g:319:2: ( ^(o= dateop f= FIELD d= datespec ) ) // RSP2SQL.g:319:4: ^(o= dateop f= FIELD d= datespec ) { FOLLOWPUSH(FOLLOW_dateop_in_datecrit464); o=dateop(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatecritEx; } MATCHT(ANTLR3_TOKEN_DOWN, NULL); if (HASEXCEPTION()) { goto ruledatecritEx; } f = (pANTLR3_BASE_TREE) MATCHT(FIELD, &FOLLOW_FIELD_in_datecrit470); if (HASEXCEPTION()) { goto ruledatecritEx; } FOLLOWPUSH(FOLLOW_datespec_in_datecrit476); d=datespec(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatecritEx; } MATCHT(ANTLR3_TOKEN_UP, NULL); if (HASEXCEPTION()) { goto ruledatecritEx; } { char *op; const struct rsp_query_field_map *rqfp; pANTLR3_STRING field; char buf[32]; int ret; op = NULL; switch (o->getType(o)) { case BEFORE: op = " < "; break; case AFTER: op = " > "; break; } field = f->getText(f); /* Field lookup */ rqfp = rsp_query_field_lookup((char *)field->chars, strlen((char *)field->chars)); if (!rqfp) { DPRINTF(E_LOG, L_RSP, "Field '%s' is not a valid field in queries\n", field->chars); retval.valid= 0; goto datecrit_valid_0; /* ABORT */ } /* Check field type */ if (rqfp->field_type != RSP_TYPE_DATE) { DPRINTF(E_LOG, L_RSP, "Field '%s' is not a date field\n", field->chars); retval.valid= 0; goto datecrit_valid_0; /* ABORT */ } ret = snprintf(buf, sizeof(buf), "%ld", d.date); if ((ret < 0) || (ret >= sizeof(buf))) { DPRINTF(E_LOG, L_RSP, "Date %ld too large for buffer, oops!\n", d.date); retval.valid= 0; goto datecrit_valid_0; /* ABORT */ } retval.result= field->factory->newRaw(field->factory); retval.result->append8(retval.result, "f."); retval.result->appendS(retval.result, field); retval.result->append8(retval.result, op); retval.result->append8(retval.result, buf); datecrit_valid_0: ; } } } // This is where rules clean up and exit // goto ruledatecritEx; /* Prevent compiler warnings */ ruledatecritEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return retval; } /* $ANTLR end datecrit */ /** * $ANTLR start dateop * RSP2SQL.g:377:1: dateop returns [ pANTLR3_COMMON_TOKEN op ] : (n= BEFORE | n= AFTER ); */ static pANTLR3_COMMON_TOKEN dateop(pRSP2SQL ctx) { pANTLR3_COMMON_TOKEN op = NULL; pANTLR3_BASE_TREE n; /* Initialize rule variables */ op= NULL; n = NULL; { { // RSP2SQL.g:379:2: (n= BEFORE | n= AFTER ) ANTLR3_UINT32 alt4; alt4=2; switch ( LA(1) ) { case BEFORE: { alt4=1; } break; case AFTER: { alt4=2; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 4; EXCEPTION->state = 0; goto ruledateopEx; } switch (alt4) { case 1: // RSP2SQL.g:379:4: n= BEFORE { n = (pANTLR3_BASE_TREE) MATCHT(BEFORE, &FOLLOW_BEFORE_in_dateop505); if (HASEXCEPTION()) { goto ruledateopEx; } { op= n->getToken(n); } } break; case 2: // RSP2SQL.g:381:4: n= AFTER { n = (pANTLR3_BASE_TREE) MATCHT(AFTER, &FOLLOW_AFTER_in_dateop518); if (HASEXCEPTION()) { goto ruledateopEx; } { op= n->getToken(n); } } break; } } } // This is where rules clean up and exit // goto ruledateopEx; /* Prevent compiler warnings */ ruledateopEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return op; } /* $ANTLR end dateop */ /** * $ANTLR start datespec * RSP2SQL.g:385:1: datespec returns [ time_t date, int valid ] : (r= dateref | ^(o= dateop r= dateref m= INT i= dateintval ) ); */ static RSP2SQL_datespec_return datespec(pRSP2SQL ctx) { RSP2SQL_datespec_return retval; pANTLR3_BASE_TREE m; RSP2SQL_dateref_return r; #undef RETURN_TYPE_r #define RETURN_TYPE_r RSP2SQL_dateref_return pANTLR3_COMMON_TOKEN o; #undef RETURN_TYPE_o #define RETURN_TYPE_o pANTLR3_COMMON_TOKEN RSP2SQL_dateintval_return i; #undef RETURN_TYPE_i #define RETURN_TYPE_i RSP2SQL_dateintval_return /* Initialize rule variables */ retval.date= 0; retval.valid= 1; m = NULL; o = NULL; retval.start = LT(1); retval.stop = retval.start; { { // RSP2SQL.g:387:2: (r= dateref | ^(o= dateop r= dateref m= INT i= dateintval ) ) ANTLR3_UINT32 alt5; alt5=2; switch ( LA(1) ) { case DATE: case TODAY: { alt5=1; } break; case BEFORE: case AFTER: { alt5=2; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 5; EXCEPTION->state = 0; goto ruledatespecEx; } switch (alt5) { case 1: // RSP2SQL.g:387:4: r= dateref { FOLLOWPUSH(FOLLOW_dateref_in_datespec546); r=dateref(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatespecEx; } { if (!r.valid) retval.valid= 0; else retval.date= r.date; } } break; case 2: // RSP2SQL.g:394:4: ^(o= dateop r= dateref m= INT i= dateintval ) { FOLLOWPUSH(FOLLOW_dateop_in_datespec560); o=dateop(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatespecEx; } MATCHT(ANTLR3_TOKEN_DOWN, NULL); if (HASEXCEPTION()) { goto ruledatespecEx; } FOLLOWPUSH(FOLLOW_dateref_in_datespec566); r=dateref(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatespecEx; } m = (pANTLR3_BASE_TREE) MATCHT(INT, &FOLLOW_INT_in_datespec572); if (HASEXCEPTION()) { goto ruledatespecEx; } FOLLOWPUSH(FOLLOW_dateintval_in_datespec578); i=dateintval(ctx); FOLLOWPOP(); if (HASEXCEPTION()) { goto ruledatespecEx; } MATCHT(ANTLR3_TOKEN_UP, NULL); if (HASEXCEPTION()) { goto ruledatespecEx; } { int32_t val; int ret; if (!r.valid || !i.valid) { retval.valid= 0; goto datespec_valid_0; /* ABORT */ } ret = safe_atoi32((char *)m->getText(m)->chars, &val); if (ret < 0) { DPRINTF(E_LOG, L_RSP, "Could not convert '%s' to integer\n", (char *)m->getText(m)); retval.valid= 0; goto datespec_valid_0; /* ABORT */ } switch (o->getType(o)) { case BEFORE: retval.date= r.date - (val * i.period); break; case AFTER: retval.date= r.date + (val * i.period); break; } datespec_valid_0: ; } } break; } } } // This is where rules clean up and exit // goto ruledatespecEx; /* Prevent compiler warnings */ ruledatespecEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return retval; } /* $ANTLR end datespec */ /** * $ANTLR start dateref * RSP2SQL.g:429:1: dateref returns [ time_t date, int valid ] : (n= DATE | TODAY ); */ static RSP2SQL_dateref_return dateref(pRSP2SQL ctx) { RSP2SQL_dateref_return retval; pANTLR3_BASE_TREE n; /* Initialize rule variables */ retval.date= 0; retval.valid= 1; n = NULL; retval.start = LT(1); retval.stop = retval.start; { { // RSP2SQL.g:431:2: (n= DATE | TODAY ) ANTLR3_UINT32 alt6; alt6=2; switch ( LA(1) ) { case DATE: { alt6=1; } break; case TODAY: { alt6=2; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 6; EXCEPTION->state = 0; goto ruledaterefEx; } switch (alt6) { case 1: // RSP2SQL.g:431:4: n= DATE { n = (pANTLR3_BASE_TREE) MATCHT(DATE, &FOLLOW_DATE_in_dateref607); if (HASEXCEPTION()) { goto ruledaterefEx; } { struct tm tm; char *ret; ret = strptime((char *)n->getText(n), "%Y-%m-%d", &tm); if (!ret) { DPRINTF(E_LOG, L_RSP, "Date '%s' could not be interpreted\n", (char *)n->getText(n)); retval.valid= 0; goto dateref_valid_0; /* ABORT */ } else { if (*ret != '\0') DPRINTF(E_LOG, L_RSP, "Garbage at end of date '%s' ?!\n", (char *)n->getText(n)); retval.date= mktime(&tm); if (retval.date == (time_t) -1) { DPRINTF(E_LOG, L_RSP, "Date '%s' could not be converted to an epoch\n", (char *)n->getText(n)); retval.valid= 0; goto dateref_valid_0; /* ABORT */ } } dateref_valid_0: ; } } break; case 2: // RSP2SQL.g:460:4: TODAY { MATCHT(TODAY, &FOLLOW_TODAY_in_dateref616); if (HASEXCEPTION()) { goto ruledaterefEx; } { retval.date= time(NULL); } } break; } } } // This is where rules clean up and exit // goto ruledaterefEx; /* Prevent compiler warnings */ ruledaterefEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return retval; } /* $ANTLR end dateref */ /** * $ANTLR start dateintval * RSP2SQL.g:464:1: dateintval returns [ time_t period, int valid ] : ( DAY | WEEK | MONTH | YEAR ); */ static RSP2SQL_dateintval_return dateintval(pRSP2SQL ctx) { RSP2SQL_dateintval_return retval; /* Initialize rule variables */ retval.period= 0; retval.valid= 1; retval.start = LT(1); retval.stop = retval.start; { { // RSP2SQL.g:466:2: ( DAY | WEEK | MONTH | YEAR ) ANTLR3_UINT32 alt7; alt7=4; switch ( LA(1) ) { case DAY: { alt7=1; } break; case WEEK: { alt7=2; } break; case MONTH: { alt7=3; } break; case YEAR: { alt7=4; } break; default: CONSTRUCTEX(); EXCEPTION->type = ANTLR3_NO_VIABLE_ALT_EXCEPTION; EXCEPTION->message = (void *)""; EXCEPTION->decisionNum = 7; EXCEPTION->state = 0; goto ruledateintvalEx; } switch (alt7) { case 1: // RSP2SQL.g:466:4: DAY { MATCHT(DAY, &FOLLOW_DAY_in_dateintval640); if (HASEXCEPTION()) { goto ruledateintvalEx; } { retval.period= 24 * 60 * 60; } } break; case 2: // RSP2SQL.g:468:4: WEEK { MATCHT(WEEK, &FOLLOW_WEEK_in_dateintval649); if (HASEXCEPTION()) { goto ruledateintvalEx; } { retval.period= 7 * 24 * 60 * 60; } } break; case 3: // RSP2SQL.g:470:4: MONTH { MATCHT(MONTH, &FOLLOW_MONTH_in_dateintval658); if (HASEXCEPTION()) { goto ruledateintvalEx; } { retval.period= 30 * 24 * 60 * 60; } } break; case 4: // RSP2SQL.g:472:4: YEAR { MATCHT(YEAR, &FOLLOW_YEAR_in_dateintval667); if (HASEXCEPTION()) { goto ruledateintvalEx; } { retval.period= 365 * 24 * 60 * 60; } } break; } } } // This is where rules clean up and exit // goto ruledateintvalEx; /* Prevent compiler warnings */ ruledateintvalEx: ; if (HASEXCEPTION()) { PREPORTERROR(); PRECOVER(); } return retval; } /* $ANTLR end dateintval */ /* End of parsing rules * ============================================== */ /* ============================================== * Syntactic predicates */ /* End of syntactic predicates * ============================================== */ /* End of code * ============================================================================= */ forked-daapd-0.19gcd/src/pregen/RSP2SQL.h0000664000175000017500000002341411633141363017335 0ustar julienjulien/** \file * This C header file was generated by $ANTLR version 3.2 debian-5 * * - From the grammar source file : RSP2SQL.g * - On : 2011-09-11 16:17:23 * - for the tree parser : RSP2SQLTreeParser * * Editing it, at least manually, is not wise. * * C language generator and runtime by Jim Idle, jimi|hereisanat|idle|dotgoeshere|ws. * * * The tree parser RSP2SQL has the callable functions (rules) shown below, * which will invoke the code for the associated rule in the source grammar * assuming that the input stream is pointing to a token/text stream that could begin * this rule. * * For instance if you call the first (topmost) rule in a parser grammar, you will * get the results of a full parse, but calling a rule half way through the grammar will * allow you to pass part of a full token stream to the parser, such as for syntax checking * in editors and so on. * * The parser entry points are called indirectly (by function pointer to function) via * a parser context typedef pRSP2SQL, which is returned from a call to RSP2SQLNew(). * * The methods in pRSP2SQL are as follows: * * - pANTLR3_STRING pRSP2SQL->query(pRSP2SQL) * - RSP2SQL_expr_return pRSP2SQL->expr(pRSP2SQL) * - RSP2SQL_strcrit_return pRSP2SQL->strcrit(pRSP2SQL) * - pANTLR3_COMMON_TOKEN pRSP2SQL->strop(pRSP2SQL) * - RSP2SQL_intcrit_return pRSP2SQL->intcrit(pRSP2SQL) * - pANTLR3_COMMON_TOKEN pRSP2SQL->intop(pRSP2SQL) * - RSP2SQL_datecrit_return pRSP2SQL->datecrit(pRSP2SQL) * - pANTLR3_COMMON_TOKEN pRSP2SQL->dateop(pRSP2SQL) * - RSP2SQL_datespec_return pRSP2SQL->datespec(pRSP2SQL) * - RSP2SQL_dateref_return pRSP2SQL->dateref(pRSP2SQL) * - RSP2SQL_dateintval_return pRSP2SQL->dateintval(pRSP2SQL) * * The return type for any particular rule is of course determined by the source * grammar file. */ // [The "BSD licence"] // Copyright (c) 2005-2009 Jim Idle, Temporal Wave LLC // http://www.temporal-wave.com // http://www.linkedin.com/in/jimidle // // All rights reserved. // // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions // are met: // 1. Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // 2. Redistributions in binary form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // 3. The name of the author may not be used to endorse or promote products // derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT // NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef _RSP2SQL_H #define _RSP2SQL_H /* ============================================================================= * Standard antlr3 C runtime definitions */ #include /* End of standard antlr 3 runtime definitions * ============================================================================= */ #ifdef __cplusplus extern "C" { #endif // Forward declare the context typedef so that we can use it before it is // properly defined. Delegators and delegates (from import statements) are // interdependent and their context structures contain pointers to each other // C only allows such things to be declared if you pre-declare the typedef. // typedef struct RSP2SQL_Ctx_struct RSP2SQL, * pRSP2SQL; /* Needs #define _GNU_SOURCE for strptime() */ #include #include #include #include #include "logger.h" #include "db.h" #include "misc.h" #include "rsp_query.h" #ifdef ANTLR3_WINDOWS // Disable: Unreferenced parameter, - Rules with parameters that are not used // constant conditional, - ANTLR realizes that a prediction is always true (synpred usually) // initialized but unused variable - tree rewrite variables declared but not needed // Unreferenced local variable - lexer rule declares but does not always use _type // potentially unitialized variable used - retval always returned from a rule // unreferenced local function has been removed - susually getTokenNames or freeScope, they can go without warnigns // // These are only really displayed at warning level /W4 but that is the code ideal I am aiming at // and the codegen must generate some of these warnings by necessity, apart from 4100, which is // usually generated when a parser rule is given a parameter that it does not use. Mostly though // this is a matter of orthogonality hence I disable that one. // #pragma warning( disable : 4100 ) #pragma warning( disable : 4101 ) #pragma warning( disable : 4127 ) #pragma warning( disable : 4189 ) #pragma warning( disable : 4505 ) #pragma warning( disable : 4701 ) #endif typedef struct RSP2SQL_expr_return_struct { pANTLR3_BASE_TREE start; pANTLR3_BASE_TREE stop; pANTLR3_STRING result; int valid; } RSP2SQL_expr_return; typedef struct RSP2SQL_strcrit_return_struct { pANTLR3_BASE_TREE start; pANTLR3_BASE_TREE stop; pANTLR3_STRING result; int valid; } RSP2SQL_strcrit_return; typedef struct RSP2SQL_intcrit_return_struct { pANTLR3_BASE_TREE start; pANTLR3_BASE_TREE stop; pANTLR3_STRING result; int valid; } RSP2SQL_intcrit_return; typedef struct RSP2SQL_datecrit_return_struct { pANTLR3_BASE_TREE start; pANTLR3_BASE_TREE stop; pANTLR3_STRING result; int valid; } RSP2SQL_datecrit_return; typedef struct RSP2SQL_datespec_return_struct { pANTLR3_BASE_TREE start; pANTLR3_BASE_TREE stop; time_t date; int valid; } RSP2SQL_datespec_return; typedef struct RSP2SQL_dateref_return_struct { pANTLR3_BASE_TREE start; pANTLR3_BASE_TREE stop; time_t date; int valid; } RSP2SQL_dateref_return; typedef struct RSP2SQL_dateintval_return_struct { pANTLR3_BASE_TREE start; pANTLR3_BASE_TREE stop; time_t period; int valid; } RSP2SQL_dateintval_return; /** Context tracking structure for RSP2SQL */ struct RSP2SQL_Ctx_struct { /** Built in ANTLR3 context tracker contains all the generic elements * required for context tracking. */ pANTLR3_TREE_PARSER pTreeParser; pANTLR3_STRING (*query) (struct RSP2SQL_Ctx_struct * ctx); RSP2SQL_expr_return (*expr) (struct RSP2SQL_Ctx_struct * ctx); RSP2SQL_strcrit_return (*strcrit) (struct RSP2SQL_Ctx_struct * ctx); pANTLR3_COMMON_TOKEN (*strop) (struct RSP2SQL_Ctx_struct * ctx); RSP2SQL_intcrit_return (*intcrit) (struct RSP2SQL_Ctx_struct * ctx); pANTLR3_COMMON_TOKEN (*intop) (struct RSP2SQL_Ctx_struct * ctx); RSP2SQL_datecrit_return (*datecrit) (struct RSP2SQL_Ctx_struct * ctx); pANTLR3_COMMON_TOKEN (*dateop) (struct RSP2SQL_Ctx_struct * ctx); RSP2SQL_datespec_return (*datespec) (struct RSP2SQL_Ctx_struct * ctx); RSP2SQL_dateref_return (*dateref) (struct RSP2SQL_Ctx_struct * ctx); RSP2SQL_dateintval_return (*dateintval) (struct RSP2SQL_Ctx_struct * ctx); // Delegated rules const char * (*getGrammarFileName)(); void (*free) (struct RSP2SQL_Ctx_struct * ctx); }; // Function protoypes for the constructor functions that external translation units // such as delegators and delegates may wish to call. // ANTLR3_API pRSP2SQL RSP2SQLNew (pANTLR3_COMMON_TREE_NODE_STREAM instream); ANTLR3_API pRSP2SQL RSP2SQLNewSSD (pANTLR3_COMMON_TREE_NODE_STREAM instream, pANTLR3_RECOGNIZER_SHARED_STATE state); /** Symbolic definitions of all the tokens that the tree parser will work with. * \{ * * Antlr will define EOF, but we can't use that as it it is too common in * in C header files and that would be confusing. There is no way to filter this out at the moment * so we just undef it here for now. That isn't the value we get back from C recognizers * anyway. We are looking for ANTLR3_TOKEN_EOF. */ #ifdef EOF #undef EOF #endif #ifdef Tokens #undef Tokens #endif #define STARTSW 14 #define WEEK 26 #define TODAY 24 #define YEAR 28 #define ENDSW 15 #define GTE 20 #define BEFORE 21 #define DAY 25 #define INT 16 #define NOT 11 #define AFTER 22 #define AND 6 #define EOF -1 #define LTE 19 #define MONTH 27 #define DIGIT19 31 #define INCLUDES 13 #define STR 10 #define QUOTE 29 #define GREATER 18 #define WS 30 #define NEWLINE 4 #define LPAR 7 #define EQUAL 12 #define OR 5 #define LESS 17 #define FIELD 9 #define RPAR 8 #define ESCAPED 33 #define DATE 23 #define DIGIT09 32 #ifdef EOF #undef EOF #define EOF ANTLR3_TOKEN_EOF #endif #ifndef TOKENSOURCE #define TOKENSOURCE(lxr) lxr->pLexer->rec->state->tokSource #endif /* End of token definitions for RSP2SQL * ============================================================================= */ /** \} */ #ifdef __cplusplus } #endif #endif /* END - Note:Keep extra line feed to satisfy UNIX systems */ forked-daapd-0.19gcd/ltmain.sh0000755000175000017500000105051111633141277015633 0ustar julienjulien # libtool (GNU libtool) 2.4 # Written by Gordon Matzigkeit , 1996 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, # 2007, 2008, 2009, 2010 Free Software Foundation, Inc. # This is free software; see the source for copying conditions. There is NO # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, # or obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Usage: $progname [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 # --mode=MODE use operation mode MODE # --preserve-dup-deps don't remove duplicate dependency libraries # --quiet, --silent don't print informational messages # --no-quiet, --no-silent # print informational messages (default) # --tag=TAG use configuration variables from tag TAG # -v, --verbose print more informational messages than default # --no-verbose don't print the extra informational messages # --version print version information # -h, --help, --help-all print short, long, or detailed help message # # 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. When passed as first option, # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. # Try `$progname --help --mode=MODE' for a more detailed description of MODE. # # When reporting a bug, please describe a test case to reproduce it and # include the following information: # # host-triplet: $host # shell: $SHELL # compiler: $LTCC # compiler flags: $LTCFLAGS # linker: $LD (gnu? $with_gnu_ld) # $progname: (GNU libtool) 2.4 Debian-2.4-4 # automake: $automake_version # autoconf: $autoconf_version # # Report bugs to . # GNU libtool home page: . # General help using GNU software: . PROGRAM=libtool PACKAGE=libtool VERSION="2.4 Debian-2.4-4" TIMESTAMP="" package_revision=1.3293 # Be Bourne compatible if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } # NLS nuisances: We save the old values to restore during execute mode. lt_user_locale= lt_safe_locale= for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${$lt_var+set}\" = set; then save_$lt_var=\$$lt_var $lt_var=C export $lt_var lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" fi" done LC_ALL=C LANGUAGE=C export LANGUAGE LC_ALL $lt_unset CDPATH # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh # is ksh but when the shell is invoked as "sh" and the current value of # the _XPG environment variable is not equal to 1 (one), the special # positional parameter $0, within a function call, is the name of the # function. progpath="$0" : ${CP="cp -f"} test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} : ${EGREP="/bin/grep -E"} : ${FGREP="/bin/grep -F"} : ${GREP="/bin/grep"} : ${LN_S="ln -s"} : ${MAKE="make"} : ${MKDIR="mkdir"} : ${MV="mv -f"} : ${RM="rm -f"} : ${SED="/bin/sed"} : ${SHELL="${CONFIG_SHELL-/bin/sh}"} : ${Xsed="$SED -e 1s/^X//"} # Global variables: EXIT_SUCCESS=0 EXIT_FAILURE=1 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. exit_status=$EXIT_SUCCESS # Make sure IFS has a sensible default lt_nl=' ' IFS=" $lt_nl" dirname="s,/[^/]*$,," basename="s,^.*/,," # func_dirname file append nondir_replacement # Compute the dirname of FILE. If nonempty, add APPEND to the result, # otherwise set result to NONDIR_REPLACEMENT. func_dirname () { func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi } # func_dirname may be replaced by extended shell implementation # func_basename file func_basename () { func_basename_result=`$ECHO "${1}" | $SED "$basename"` } # func_basename may be replaced by extended shell implementation # func_dirname_and_basename file append nondir_replacement # perform func_basename and func_dirname in a single function # call: # dirname: Compute the dirname of FILE. If nonempty, # add APPEND to the result, otherwise set result # to NONDIR_REPLACEMENT. # value returned in "$func_dirname_result" # basename: Compute filename of FILE. # value retuned in "$func_basename_result" # Implementation must be kept synchronized with func_dirname # and func_basename. For efficiency, we do not delegate to # those functions but instead duplicate the functionality here. func_dirname_and_basename () { # Extract subdirectory from the argument. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` if test "X$func_dirname_result" = "X${1}"; then func_dirname_result="${3}" else func_dirname_result="$func_dirname_result${2}" fi func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` } # func_dirname_and_basename may be replaced by extended shell implementation # func_stripname prefix suffix name # strip PREFIX and SUFFIX off of NAME. # PREFIX and SUFFIX must not contain globbing or regex special # characters, hashes, percent signs, but SUFFIX may contain a leading # dot (in which case that matches only a dot). # func_strip_suffix prefix name func_stripname () { case ${2} in .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; esac } # func_stripname may be replaced by extended shell implementation # These SED scripts presuppose an absolute path with a trailing slash. pathcar='s,^/\([^/]*\).*$,\1,' pathcdr='s,^/[^/]*,,' removedotparts=':dotsl s@/\./@/@g t dotsl s,/\.$,/,' collapseslashes='s@/\{1,\}@/@g' finalslash='s,/*$,/,' # func_normal_abspath PATH # Remove doubled-up and trailing slashes, "." path components, # and cancel out any ".." path components in PATH after making # it an absolute path. # value returned in "$func_normal_abspath_result" func_normal_abspath () { # Start from root dir and reassemble the path. func_normal_abspath_result= func_normal_abspath_tpath=$1 func_normal_abspath_altnamespace= case $func_normal_abspath_tpath in "") # Empty path, that just means $cwd. func_stripname '' '/' "`pwd`" func_normal_abspath_result=$func_stripname_result return ;; # The next three entries are used to spot a run of precisely # two leading slashes without using negated character classes; # we take advantage of case's first-match behaviour. ///*) # Unusual form of absolute path, do nothing. ;; //*) # Not necessarily an ordinary path; POSIX reserves leading '//' # and for example Cygwin uses it to access remote file shares # over CIFS/SMB, so we conserve a leading double slash if found. func_normal_abspath_altnamespace=/ ;; /*) # Absolute path, do nothing. ;; *) # Relative path, prepend $cwd. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath ;; esac # Cancel out all the simple stuff to save iterations. We also want # the path to end with a slash for ease of parsing, so make sure # there is one (and only one) here. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` while :; do # Processed it all yet? if test "$func_normal_abspath_tpath" = / ; then # If we ascended to the root using ".." the result may be empty now. if test -z "$func_normal_abspath_result" ; then func_normal_abspath_result=/ fi break fi func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcar"` func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ -e "$pathcdr"` # Figure out what to do with it case $func_normal_abspath_tcomponent in "") # Trailing empty path component, ignore it. ;; ..) # Parent dir; strip last assembled component from result. func_dirname "$func_normal_abspath_result" func_normal_abspath_result=$func_dirname_result ;; *) # Actual path component, append it. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent ;; esac done # Restore leading double-slash if one was found on entry. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result } # func_relative_path SRCDIR DSTDIR # generates a relative path from SRCDIR to DSTDIR, with a trailing # slash if non-empty, suitable for immediately appending a filename # without needing to append a separator. # value returned in "$func_relative_path_result" func_relative_path () { func_relative_path_result= func_normal_abspath "$1" func_relative_path_tlibdir=$func_normal_abspath_result func_normal_abspath "$2" func_relative_path_tbindir=$func_normal_abspath_result # Ascend the tree starting from libdir while :; do # check if we have found a prefix of bindir case $func_relative_path_tbindir in $func_relative_path_tlibdir) # found an exact match func_relative_path_tcancelled= break ;; $func_relative_path_tlibdir*) # found a matching prefix func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" func_relative_path_tcancelled=$func_stripname_result if test -z "$func_relative_path_result"; then func_relative_path_result=. fi break ;; *) func_dirname $func_relative_path_tlibdir func_relative_path_tlibdir=${func_dirname_result} if test "x$func_relative_path_tlibdir" = x ; then # Have to descend all the way to the root! func_relative_path_result=../$func_relative_path_result func_relative_path_tcancelled=$func_relative_path_tbindir break fi func_relative_path_result=../$func_relative_path_result ;; esac done # Now calculate path; take care to avoid doubling-up slashes. func_stripname '' '/' "$func_relative_path_result" func_relative_path_result=$func_stripname_result func_stripname '/' '/' "$func_relative_path_tcancelled" if test "x$func_stripname_result" != x ; then func_relative_path_result=${func_relative_path_result}/${func_stripname_result} fi # Normalisation. If bindir is libdir, return empty string, # else relative path ending with a slash; either way, target # file name can be directly appended. if test ! -z "$func_relative_path_result"; then func_stripname './' '' "$func_relative_path_result/" func_relative_path_result=$func_stripname_result fi } # The name of this program: func_dirname_and_basename "$progpath" progname=$func_basename_result # Make sure we have an absolute path for reexecution: case $progpath in [\\/]*|[A-Za-z]:\\*) ;; *[\\/]*) progdir=$func_dirname_result progdir=`cd "$progdir" && pwd` progpath="$progdir/$progname" ;; *) save_IFS="$IFS" IFS=: for progdir in $PATH; do IFS="$save_IFS" test -x "$progdir/$progname" && break done IFS="$save_IFS" test -n "$progdir" || progdir=`pwd` progpath="$progdir/$progname" ;; esac # 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='s/\([`"$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution that turns a string into a regex matching for the # string literally. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g' # Sed substitution that converts a w32 file name or path # which contains forward slashes, into one that contains # (escaped) backslashes. A very naive implementation. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' # Re-`\' parameter expansions in output of double_quote_subst that were # `\'-ed in input to the same. If an odd number of `\' preceded a '$' # in input to double_quote_subst, that '$' was protected from expansion. # Since each input `\' is now two `\'s, look for any number of runs of # four `\'s followed by two `\'s and then a '$'. `\' that '$'. bs='\\' bs2='\\\\' bs4='\\\\\\\\' dollar='\$' sed_double_backslash="\ s/$bs4/&\\ /g s/^$bs2$dollar/$bs&/ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g s/\n//g" # Standard options: opt_dry_run=false opt_help=false opt_quiet=false opt_verbose=false opt_warning=: # func_echo arg... # Echo program name prefixed message, along with the current mode # name if it has been set yet. func_echo () { $ECHO "$progname: ${opt_mode+$opt_mode: }$*" } # func_verbose arg... # Echo program name prefixed message in verbose mode only. func_verbose () { $opt_verbose && func_echo ${1+"$@"} # A bug in bash halts the script if the last line of a function # fails when set -e is in force, so we need another command to # work around that: : } # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "$*" } # func_error arg... # Echo program name prefixed message to standard error. func_error () { $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 } # func_warning arg... # Echo program name prefixed warning message to standard error. func_warning () { $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 # bash bug again: : } # func_fatal_error arg... # Echo program name prefixed message to standard error, and exit. func_fatal_error () { func_error ${1+"$@"} exit $EXIT_FAILURE } # func_fatal_help arg... # Echo program name prefixed message to standard error, followed by # a help hint, and exit. func_fatal_help () { func_error ${1+"$@"} func_fatal_error "$help" } help="Try \`$progname --help' for more information." ## default # func_grep expression filename # Check whether EXPRESSION matches any line of FILENAME, without output. func_grep () { $GREP "$1" "$2" >/dev/null 2>&1 } # func_mkdir_p directory-path # Make sure the entire path to DIRECTORY-PATH is available. func_mkdir_p () { my_directory_path="$1" my_dir_list= if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then # Protect directory names starting with `-' case $my_directory_path in -*) my_directory_path="./$my_directory_path" ;; esac # While some portion of DIR does not yet exist... while test ! -d "$my_directory_path"; do # ...make a list in topmost first order. Use a colon delimited # list incase some portion of path contains whitespace. my_dir_list="$my_directory_path:$my_dir_list" # If the last portion added has no slash in it, the list is done case $my_directory_path in */*) ;; *) break ;; esac # ...otherwise throw away the child directory and loop my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` done my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` save_mkdir_p_IFS="$IFS"; IFS=':' for my_dir in $my_dir_list; do IFS="$save_mkdir_p_IFS" # mkdir can fail with a `File exist' error if two processes # try to create one of the directories concurrently. Don't # stop in that case! $MKDIR "$my_dir" 2>/dev/null || : done IFS="$save_mkdir_p_IFS" # Bail out if we (or some other process) failed to create a directory. test -d "$my_directory_path" || \ func_fatal_error "Failed to create \`$1'" fi } # func_mktempdir [string] # Make a temporary directory that won't clash with other running # libtool processes, and avoids race conditions if possible. If # given, STRING is the basename for that directory. func_mktempdir () { my_template="${TMPDIR-/tmp}/${1-$progname}" if test "$opt_dry_run" = ":"; then # Return a directory name, but don't create it in dry-run mode my_tmpdir="${my_template}-$$" else # If mktemp works, use that first and foremost my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` if test ! -d "$my_tmpdir"; then # Failing that, at least try and use $RANDOM to avoid a race my_tmpdir="${my_template}-${RANDOM-0}$$" save_mktempdir_umask=`umask` umask 0077 $MKDIR "$my_tmpdir" umask $save_mktempdir_umask fi # If we're not in dry-run mode, bomb out on failure test -d "$my_tmpdir" || \ func_fatal_error "cannot create temporary directory \`$my_tmpdir'" fi $ECHO "$my_tmpdir" } # func_quote_for_eval arg # Aesthetically quote ARG to be evaled later. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT # is double-quoted, suitable for a subsequent eval, whereas # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters # which are still active within double quotes backslashified. func_quote_for_eval () { case $1 in *[\\\`\"\$]*) func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; *) func_quote_for_eval_unquoted_result="$1" ;; esac case $func_quote_for_eval_unquoted_result in # Double-quote args containing shell metacharacters to delay # word splitting, command substitution and and variable # expansion for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" ;; *) func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" esac } # func_quote_for_expand arg # Aesthetically quote ARG to be evaled later; same as above, # but do not quote variable references. func_quote_for_expand () { case $1 in *[\\\`\"]*) my_arg=`$ECHO "$1" | $SED \ -e "$double_quote_subst" -e "$sed_double_backslash"` ;; *) my_arg="$1" ;; esac case $my_arg in # Double-quote args containing shell metacharacters to delay # word splitting and command substitution for a subsequent eval. # Many Bourne shells cannot handle close brackets correctly # in scan sets, so we specify it separately. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") my_arg="\"$my_arg\"" ;; esac func_quote_for_expand_result="$my_arg" } # func_show_eval cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. func_show_eval () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$my_cmd" my_status=$? if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_show_eval_locale cmd [fail_exp] # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP # is given, then evaluate it. Use the saved locale for evaluation. func_show_eval_locale () { my_cmd="$1" my_fail_exp="${2-:}" ${opt_silent-false} || { func_quote_for_expand "$my_cmd" eval "func_echo $func_quote_for_expand_result" } if ${opt_dry_run-false}; then :; else eval "$lt_user_locale $my_cmd" my_status=$? eval "$lt_safe_locale" if test "$my_status" -eq 0; then :; else eval "(exit $my_status); $my_fail_exp" fi fi } # func_tr_sh # Turn $1 into a string suitable for a shell variable name. # Result is stored in $func_tr_sh_result. All characters # not in the set a-zA-Z0-9_ are replaced with '_'. Further, # if $1 begins with a digit, a '_' is prepended as well. func_tr_sh () { case $1 in [0-9]* | *[!a-zA-Z0-9_]*) func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` ;; * ) func_tr_sh_result=$1 ;; esac } # func_version # Echo version message to standard output and exit. func_version () { $opt_debug $SED -n '/(C)/!b go :more /\./!{ N s/\n# / / b more } :go /^# '$PROGRAM' (GNU /,/# warranty; / { s/^# // s/^# *$// s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ p }' < "$progpath" exit $? } # func_usage # Echo short help message to standard output and exit. func_usage () { $opt_debug $SED -n '/^# Usage:/,/^# *.*--help/ { s/^# // s/^# *$// s/\$progname/'$progname'/ p }' < "$progpath" echo $ECHO "run \`$progname --help | more' for full usage" exit $? } # func_help [NOEXIT] # Echo long help message to standard output and exit, # unless 'noexit' is passed as argument. func_help () { $opt_debug $SED -n '/^# Usage:/,/# Report bugs to/ { :print s/^# // s/^# *$// s*\$progname*'$progname'* s*\$host*'"$host"'* s*\$SHELL*'"$SHELL"'* s*\$LTCC*'"$LTCC"'* s*\$LTCFLAGS*'"$LTCFLAGS"'* s*\$LD*'"$LD"'* s/\$with_gnu_ld/'"$with_gnu_ld"'/ s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ p d } /^# .* home page:/b print /^# General help using/b print ' < "$progpath" ret=$? if test -z "$1"; then exit $ret fi } # func_missing_arg argname # Echo program name prefixed message to standard error and set global # exit_cmd. func_missing_arg () { $opt_debug func_error "missing argument for $1." exit_cmd=exit } # func_split_short_opt shortopt # Set func_split_short_opt_name and func_split_short_opt_arg shell # variables after splitting SHORTOPT after the 2nd character. func_split_short_opt () { my_sed_short_opt='1s/^\(..\).*$/\1/;q' my_sed_short_rest='1s/^..\(.*\)$/\1/;q' func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` } # func_split_short_opt may be replaced by extended shell implementation # func_split_long_opt longopt # Set func_split_long_opt_name and func_split_long_opt_arg shell # variables after splitting LONGOPT at the `=' sign. func_split_long_opt () { my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' my_sed_long_arg='1s/^--[^=]*=//' func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` } # func_split_long_opt may be replaced by extended shell implementation exit_cmd=: magic="%%%MAGIC variable%%%" magic_exe="%%%MAGIC EXE variable%%%" # Global variables. nonopt= preserve_args= lo2o="s/\\.lo\$/.${objext}/" o2lo="s/\\.${objext}\$/.lo/" extracted_archives= extracted_serial=0 # If this variable is set in any of the actions, the command in it # will be execed at the end. This prevents here-documents from being # left over by shells. exec_cmd= # func_append var value # Append VALUE to the end of shell variable VAR. func_append () { eval "${1}=\$${1}\${2}" } # func_append may be replaced by extended shell implementation # func_append_quoted var value # Quote VALUE and append to the end of shell variable VAR, separated # by a space. func_append_quoted () { func_quote_for_eval "${2}" eval "${1}=\$${1}\\ \$func_quote_for_eval_result" } # func_append_quoted may be replaced by extended shell implementation # func_arith arithmetic-term... func_arith () { func_arith_result=`expr "${@}"` } # func_arith may be replaced by extended shell implementation # func_len string # STRING may not start with a hyphen. func_len () { func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` } # func_len may be replaced by extended shell implementation # func_lo2o object func_lo2o () { func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` } # func_lo2o may be replaced by extended shell implementation # func_xform libobj-or-source func_xform () { func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` } # func_xform may be replaced by extended shell implementation # func_fatal_configuration arg... # Echo program name prefixed message to standard error, followed by # a configuration failure hint, and exit. func_fatal_configuration () { func_error ${1+"$@"} func_error "See the $PACKAGE documentation for more information." func_fatal_error "Fatal configuration error." } # func_config # Display the configuration for all the tags in this script. func_config () { re_begincf='^# ### BEGIN LIBTOOL' re_endcf='^# ### END LIBTOOL' # Default configuration. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" # Now print the configurations for the tags. for tagname in $taglist; do $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" done exit $? } # func_features # Display the features supported by this script. func_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 $? } # func_enable_tag tagname # Verify that TAGNAME is valid, and either flag an error and exit, or # enable the TAGNAME tag. We also add TAGNAME to the global $taglist # variable here. func_enable_tag () { # Global variable: tagname="$1" re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" sed_extractcf="/$re_begincf/,/$re_endcf/p" # Validate tagname. case $tagname in *[!-_A-Za-z0-9,/]*) func_fatal_error "invalid tag name: $tagname" ;; esac # Don't test for the "default" C tag, as we know it's # there but not specially marked. case $tagname in CC) ;; *) if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then taglist="$taglist $tagname" # Evaluate the configuration. Be careful to quote the path # and the sed script, to avoid splitting on whitespace, but # also don't use non-portable quotes within backquotes within # quotes we have to do it in 2 steps: extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` eval "$extractedcf" else func_error "ignoring unknown tag $tagname" fi ;; esac } # func_check_version_match # Ensure that we are using m4 macros, and libtool script from the same # release of libtool. func_check_version_match () { if test "$package_revision" != "$macro_revision"; then if test "$VERSION" != "$macro_version"; then if test -z "$macro_version"; then cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from an older release. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, but the $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION $progname: and run autoconf again. _LT_EOF fi else cat >&2 <<_LT_EOF $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, $progname: but the definition of this LT_INIT comes from revision $macro_revision. $progname: You should recreate aclocal.m4 with macros from revision $package_revision $progname: of $PACKAGE $VERSION and run autoconf again. _LT_EOF fi exit $EXIT_MISMATCH fi } # Shorthand for --mode=foo, only valid as the first argument case $1 in clean|clea|cle|cl) shift; set dummy --mode clean ${1+"$@"}; shift ;; compile|compil|compi|comp|com|co|c) shift; set dummy --mode compile ${1+"$@"}; shift ;; execute|execut|execu|exec|exe|ex|e) shift; set dummy --mode execute ${1+"$@"}; shift ;; finish|finis|fini|fin|fi|f) shift; set dummy --mode finish ${1+"$@"}; shift ;; install|instal|insta|inst|ins|in|i) shift; set dummy --mode install ${1+"$@"}; shift ;; link|lin|li|l) shift; set dummy --mode link ${1+"$@"}; shift ;; uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) shift; set dummy --mode uninstall ${1+"$@"}; shift ;; esac # Option defaults: opt_debug=: opt_dry_run=false opt_config=false opt_preserve_dup_deps=false opt_features=false opt_finish=false opt_help=false opt_help_all=false opt_silent=: opt_verbose=: opt_silent=false opt_verbose=false # Parse options once, thoroughly. This comes as soon as possible in the # script to make things like `--version' happen as quickly as we can. { # this just eases exit handling while test $# -gt 0; do opt="$1" shift case $opt in --debug|-x) opt_debug='set -x' func_echo "enabling shell trace mode" $opt_debug ;; --dry-run|--dryrun|-n) opt_dry_run=: ;; --config) opt_config=: func_config ;; --dlopen|-dlopen) optarg="$1" opt_dlopen="${opt_dlopen+$opt_dlopen }$optarg" shift ;; --preserve-dup-deps) opt_preserve_dup_deps=: ;; --features) opt_features=: func_features ;; --finish) opt_finish=: set dummy --mode finish ${1+"$@"}; shift ;; --help) opt_help=: ;; --help-all) opt_help_all=: opt_help=': help-all' ;; --mode) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_mode="$optarg" case $optarg in # Valid mode arguments: clean|compile|execute|finish|install|link|relink|uninstall) ;; # Catch anything else as an error *) func_error "invalid argument for $opt" exit_cmd=exit break ;; esac shift ;; --no-silent|--no-quiet) opt_silent=false func_append preserve_args " $opt" ;; --no-verbose) opt_verbose=false func_append preserve_args " $opt" ;; --silent|--quiet) opt_silent=: func_append preserve_args " $opt" opt_verbose=false ;; --verbose|-v) opt_verbose=: func_append preserve_args " $opt" opt_silent=false ;; --tag) test $# = 0 && func_missing_arg $opt && break optarg="$1" opt_tag="$optarg" func_append preserve_args " $opt $optarg" func_enable_tag "$optarg" shift ;; -\?|-h) func_usage ;; --help) func_help ;; --version) func_version ;; # Separate optargs to long options: --*=*) func_split_long_opt "$opt" set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} shift ;; # Separate non-argument short options: -\?*|-h*|-n*|-v*) func_split_short_opt "$opt" set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} shift ;; --) break ;; -*) func_fatal_help "unrecognized option \`$opt'" ;; *) set dummy "$opt" ${1+"$@"}; shift; break ;; esac done # Validate options: # save first non-option argument if test "$#" -gt 0; then nonopt="$opt" shift fi # preserve --debug test "$opt_debug" = : || func_append preserve_args " --debug" case $host in *cygwin* | *mingw* | *pw32* | *cegcc*) # don't eliminate duplications in $postdeps and $predeps opt_duplicate_compiler_generated_deps=: ;; *) opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps ;; esac $opt_help || { # Sanity checks first: func_check_version_match if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then func_fatal_configuration "not configured to build any kind of library" fi # Darwin sucks eval std_shrext=\"$shrext_cmds\" # Only execute mode is allowed to have -dlopen flags. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then func_error "unrecognized option \`-dlopen'" $ECHO "$help" 1>&2 exit $EXIT_FAILURE fi # Change the help message to a mode-specific one. generic_help="$help" help="Try \`$progname --help --mode=$opt_mode' for more information." } # Bail if the options were screwed $exit_cmd $EXIT_FAILURE } ## ----------- ## ## Main. ## ## ----------- ## # func_lalib_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_lalib_p () { test -f "$1" && $SED -e 4q "$1" 2>/dev/null \ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 } # func_lalib_unsafe_p file # True iff FILE is a libtool `.la' library or `.lo' object file. # This function implements the same check as func_lalib_p without # resorting to external programs. To this end, it redirects stdin and # closes it afterwards, without saving the original file descriptor. # As a safety measure, use it only where a negative result would be # fatal anyway. Works if `file' does not exist. func_lalib_unsafe_p () { lalib_p=no if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then for lalib_p_l in 1 2 3 4 do read lalib_p_line case "$lalib_p_line" in \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; esac done exec 0<&5 5<&- fi test "$lalib_p" = yes } # func_ltwrapper_script_p file # True iff FILE is a libtool wrapper script # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_script_p () { func_lalib_p "$1" } # func_ltwrapper_executable_p file # True iff FILE is a libtool wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_executable_p () { func_ltwrapper_exec_suffix= case $1 in *.exe) ;; *) func_ltwrapper_exec_suffix=.exe ;; esac $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 } # func_ltwrapper_scriptname file # Assumes file is an ltwrapper_executable # uses $file to determine the appropriate filename for a # temporary ltwrapper_script. func_ltwrapper_scriptname () { func_dirname_and_basename "$1" "" "." func_stripname '' '.exe' "$func_basename_result" func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" } # func_ltwrapper_p file # True iff FILE is a libtool wrapper script or wrapper executable # This function is only a basic sanity check; it will hardly flush out # determined imposters. func_ltwrapper_p () { func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" } # func_execute_cmds commands fail_cmd # Execute tilde-delimited COMMANDS. # If FAIL_CMD is given, eval that upon failure. # FAIL_CMD may read-access the current command in variable CMD! func_execute_cmds () { $opt_debug save_ifs=$IFS; IFS='~' for cmd in $1; do IFS=$save_ifs eval cmd=\"$cmd\" func_show_eval "$cmd" "${2-:}" done IFS=$save_ifs } # func_source file # Source FILE, adding directory component if necessary. # Note that it is not necessary on cygwin/mingw to append a dot to # FILE even if both FILE and FILE.exe exist: automatic-append-.exe # behavior happens only for exec(3), not for open(2)! Also, sourcing # `FILE.' does not work on cygwin managed mounts. func_source () { $opt_debug case $1 in */* | *\\*) . "$1" ;; *) . "./$1" ;; esac } # func_resolve_sysroot PATH # Replace a leading = in PATH with a sysroot. Store the result into # func_resolve_sysroot_result func_resolve_sysroot () { func_resolve_sysroot_result=$1 case $func_resolve_sysroot_result in =*) func_stripname '=' '' "$func_resolve_sysroot_result" func_resolve_sysroot_result=$lt_sysroot$func_stripname_result ;; esac } # func_replace_sysroot PATH # If PATH begins with the sysroot, replace it with = and # store the result into func_replace_sysroot_result. func_replace_sysroot () { case "$lt_sysroot:$1" in ?*:"$lt_sysroot"*) func_stripname "$lt_sysroot" '' "$1" func_replace_sysroot_result="=$func_stripname_result" ;; *) # Including no sysroot. func_replace_sysroot_result=$1 ;; esac } # func_infer_tag arg # Infer tagged configuration to use if any are available and # if one wasn't chosen via the "--tag" command line option. # Only attempt this if the compiler in the base compile # command doesn't match the default compiler. # arg is usually of the form 'gcc ...' func_infer_tag () { $opt_debug if test -n "$available_tags" && test -z "$tagname"; then CC_quoted= for arg in $CC; do func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case $@ in # Blanks in the command may have been stripped by the calling shell, # but not from the CC environment variable when configure was run. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; # Blanks at the start of $base_compile will cause this to fail # if we don't check for them as well. *) for z in $available_tags; do if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then # Evaluate the configuration. eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" CC_quoted= for arg in $CC; do # Double-quote args containing other shell metacharacters. func_append_quoted CC_quoted "$arg" done CC_expanded=`func_echo_all $CC` CC_quoted_expanded=`func_echo_all $CC_quoted` case "$@ " in " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) # The compiler in the base compile command matches # the one in the tagged configuration. # Assume this is the tagged configuration we want. tagname=$z break ;; esac fi done # If $tagname still isn't set, then no tagged configuration # was found and let the user know that the "--tag" command # line option must be used. if test -z "$tagname"; then func_echo "unable to infer tagged configuration" func_fatal_error "specify a tag with \`--tag'" # else # func_verbose "using $tagname tagged configuration" fi ;; esac fi } # func_write_libtool_object output_name pic_name nonpic_name # Create a libtool object file (analogous to a ".la" file), # but don't create it if we're doing a dry run. func_write_libtool_object () { write_libobj=${1} if test "$build_libtool_libs" = yes; then write_lobj=\'${2}\' else write_lobj=none fi if test "$build_old_libs" = yes; then write_oldobj=\'${3}\' else write_oldobj=none fi $opt_dry_run || { cat >${write_libobj}T </dev/null` if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | $SED -e "$lt_sed_naive_backslashify"` else func_convert_core_file_wine_to_w32_result= fi fi } # end: func_convert_core_file_wine_to_w32 # func_convert_core_path_wine_to_w32 ARG # Helper function used by path conversion functions when $build is *nix, and # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly # configured wine environment available, with the winepath program in $build's # $PATH. Assumes ARG has no leading or trailing path separator characters. # # ARG is path to be converted from $build format to win32. # Result is available in $func_convert_core_path_wine_to_w32_result. # Unconvertible file (directory) names in ARG are skipped; if no directory names # are convertible, then the result may be empty. func_convert_core_path_wine_to_w32 () { $opt_debug # unfortunately, winepath doesn't convert paths, only file names func_convert_core_path_wine_to_w32_result="" if test -n "$1"; then oldIFS=$IFS IFS=: for func_convert_core_path_wine_to_w32_f in $1; do IFS=$oldIFS func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" if test -n "$func_convert_core_file_wine_to_w32_result" ; then if test -z "$func_convert_core_path_wine_to_w32_result"; then func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" else func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" fi fi done IFS=$oldIFS fi } # end: func_convert_core_path_wine_to_w32 # func_cygpath ARGS... # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or # (2), returns the Cygwin file name or path in func_cygpath_result (input # file name or path is assumed to be in w32 format, as previously converted # from $build's *nix or MSYS format). In case (3), returns the w32 file name # or path in func_cygpath_result (input file name or path is assumed to be in # Cygwin format). Returns an empty string on error. # # ARGS are passed to cygpath, with the last one being the file name or path to # be converted. # # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH # environment variable; do not put it in $PATH. func_cygpath () { $opt_debug if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` if test "$?" -ne 0; then # on failure, ensure result is empty func_cygpath_result= fi else func_cygpath_result= func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" fi } #end: func_cygpath # func_convert_core_msys_to_w32 ARG # Convert file name or path ARG from MSYS format to w32 format. Return # result in func_convert_core_msys_to_w32_result. func_convert_core_msys_to_w32 () { $opt_debug # awkward: cmd appends spaces to result func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` } #end: func_convert_core_msys_to_w32 # func_convert_file_check ARG1 ARG2 # Verify that ARG1 (a file name in $build format) was converted to $host # format in ARG2. Otherwise, emit an error message, but continue (resetting # func_to_host_file_result to ARG1). func_convert_file_check () { $opt_debug if test -z "$2" && test -n "$1" ; then func_error "Could not determine host file name corresponding to" func_error " \`$1'" func_error "Continuing, but uninstalled executables may not work." # Fallback: func_to_host_file_result="$1" fi } # end func_convert_file_check # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH # Verify that FROM_PATH (a path in $build format) was converted to $host # format in TO_PATH. Otherwise, emit an error message, but continue, resetting # func_to_host_file_result to a simplistic fallback value (see below). func_convert_path_check () { $opt_debug if test -z "$4" && test -n "$3"; then func_error "Could not determine the host path corresponding to" func_error " \`$3'" func_error "Continuing, but uninstalled executables may not work." # Fallback. This is a deliberately simplistic "conversion" and # should not be "improved". See libtool.info. if test "x$1" != "x$2"; then lt_replace_pathsep_chars="s|$1|$2|g" func_to_host_path_result=`echo "$3" | $SED -e "$lt_replace_pathsep_chars"` else func_to_host_path_result="$3" fi fi } # end func_convert_path_check # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT # and appending REPL if ORIG matches BACKPAT. func_convert_path_front_back_pathsep () { $opt_debug case $4 in $1 ) func_to_host_path_result="$3$func_to_host_path_result" ;; esac case $4 in $2 ) func_append func_to_host_path_result "$3" ;; esac } # end func_convert_path_front_back_pathsep ################################################## # $build to $host FILE NAME CONVERSION FUNCTIONS # ################################################## # invoked via `$to_host_file_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # Result will be available in $func_to_host_file_result. # func_to_host_file ARG # Converts the file name ARG from $build format to $host format. Return result # in func_to_host_file_result. func_to_host_file () { $opt_debug $to_host_file_cmd "$1" } # end func_to_host_file # func_to_tool_file ARG LAZY # converts the file name ARG from $build format to toolchain format. Return # result in func_to_tool_file_result. If the conversion in use is listed # in (the comma separated) LAZY, no conversion takes place. func_to_tool_file () { $opt_debug case ,$2, in *,"$to_tool_file_cmd",*) func_to_tool_file_result=$1 ;; *) $to_tool_file_cmd "$1" func_to_tool_file_result=$func_to_host_file_result ;; esac } # end func_to_tool_file # func_convert_file_noop ARG # Copy ARG to func_to_host_file_result. func_convert_file_noop () { func_to_host_file_result="$1" } # end func_convert_file_noop # func_convert_file_msys_to_w32 ARG # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_file_result. func_convert_file_msys_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_to_host_file_result="$func_convert_core_msys_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_w32 # func_convert_file_cygwin_to_w32 ARG # Convert file name ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_file_cygwin_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # because $build is cygwin, we call "the" cygpath in $PATH; no need to use # LT_CYGPATH in this case. func_to_host_file_result=`cygpath -m "$1"` fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_cygwin_to_w32 # func_convert_file_nix_to_w32 ARG # Convert file name ARG from *nix to w32 format. Requires a wine environment # and a working winepath. Returns result in func_to_host_file_result. func_convert_file_nix_to_w32 () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_file_wine_to_w32 "$1" func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_w32 # func_convert_file_msys_to_cygwin ARG # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_file_msys_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then func_convert_core_msys_to_w32 "$1" func_cygpath -u "$func_convert_core_msys_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_msys_to_cygwin # func_convert_file_nix_to_cygwin ARG # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed # in a wine environment, working winepath, and LT_CYGPATH set. Returns result # in func_to_host_file_result. func_convert_file_nix_to_cygwin () { $opt_debug func_to_host_file_result="$1" if test -n "$1"; then # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. func_convert_core_file_wine_to_w32 "$1" func_cygpath -u "$func_convert_core_file_wine_to_w32_result" func_to_host_file_result="$func_cygpath_result" fi func_convert_file_check "$1" "$func_to_host_file_result" } # end func_convert_file_nix_to_cygwin ############################################# # $build to $host PATH CONVERSION FUNCTIONS # ############################################# # invoked via `$to_host_path_cmd ARG' # # In each case, ARG is the path to be converted from $build to $host format. # The result will be available in $func_to_host_path_result. # # Path separators are also converted from $build format to $host format. If # ARG begins or ends with a path separator character, it is preserved (but # converted to $host format) on output. # # All path conversion functions are named using the following convention: # file name conversion function : func_convert_file_X_to_Y () # path conversion function : func_convert_path_X_to_Y () # where, for any given $build/$host combination the 'X_to_Y' value is the # same. If conversion functions are added for new $build/$host combinations, # the two new functions must follow this pattern, or func_init_to_host_path_cmd # will break. # func_init_to_host_path_cmd # Ensures that function "pointer" variable $to_host_path_cmd is set to the # appropriate value, based on the value of $to_host_file_cmd. to_host_path_cmd= func_init_to_host_path_cmd () { $opt_debug if test -z "$to_host_path_cmd"; then func_stripname 'func_convert_file_' '' "$to_host_file_cmd" to_host_path_cmd="func_convert_path_${func_stripname_result}" fi } # func_to_host_path ARG # Converts the path ARG from $build format to $host format. Return result # in func_to_host_path_result. func_to_host_path () { $opt_debug func_init_to_host_path_cmd $to_host_path_cmd "$1" } # end func_to_host_path # func_convert_path_noop ARG # Copy ARG to func_to_host_path_result. func_convert_path_noop () { func_to_host_path_result="$1" } # end func_convert_path_noop # func_convert_path_msys_to_w32 ARG # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic # conversion to w32 is not available inside the cwrapper. Returns result in # func_to_host_path_result. func_convert_path_msys_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from ARG. MSYS # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; # and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_msys_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_msys_to_w32 # func_convert_path_cygwin_to_w32 ARG # Convert path ARG from Cygwin to w32 format. Returns result in # func_to_host_file_result. func_convert_path_cygwin_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_cygwin_to_w32 # func_convert_path_nix_to_w32 ARG # Convert path ARG from *nix to w32 format. Requires a wine environment and # a working winepath. Returns result in func_to_host_file_result. func_convert_path_nix_to_w32 () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" func_convert_path_check : ";" \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" fi } # end func_convert_path_nix_to_w32 # func_convert_path_msys_to_cygwin ARG # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. # Returns result in func_to_host_file_result. func_convert_path_msys_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # See func_convert_path_msys_to_w32: func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_msys_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_msys_to_cygwin # func_convert_path_nix_to_cygwin ARG # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a # a wine environment, working winepath, and LT_CYGPATH set. Returns result in # func_to_host_file_result. func_convert_path_nix_to_cygwin () { $opt_debug func_to_host_path_result="$1" if test -n "$1"; then # Remove leading and trailing path separator characters from # ARG. msys behavior is inconsistent here, cygpath turns them # into '.;' and ';.', and winepath ignores them completely. func_stripname : : "$1" func_to_host_path_tmp1=$func_stripname_result func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" func_to_host_path_result="$func_cygpath_result" func_convert_path_check : : \ "$func_to_host_path_tmp1" "$func_to_host_path_result" func_convert_path_front_back_pathsep ":*" "*:" : "$1" fi } # end func_convert_path_nix_to_cygwin # func_mode_compile arg... func_mode_compile () { $opt_debug # Get the compilation command and the source file. base_compile= srcfile="$nonopt" # always keep a non-empty value in "srcfile" suppress_opt=yes suppress_output= arg_mode=normal libobj= later= pie_flag= for arg do case $arg_mode in arg ) # do not "continue". Instead, add this to base_compile lastarg="$arg" arg_mode=normal ;; target ) libobj="$arg" arg_mode=normal continue ;; normal ) # Accept any command-line options. case $arg in -o) test -n "$libobj" && \ func_fatal_error "you cannot specify \`-o' more than once" arg_mode=target continue ;; -pie | -fpie | -fPIE) func_append pie_flag " $arg" continue ;; -shared | -static | -prefer-pic | -prefer-non-pic) func_append later " $arg" continue ;; -no-suppress) suppress_opt=no continue ;; -Xcompiler) arg_mode=arg # the next one goes into the "base_compile" arg list continue # The current "srcfile" will either be retained or ;; # replaced later. I would guess that would be a bug. -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result lastarg= save_ifs="$IFS"; IFS=',' for arg in $args; do IFS="$save_ifs" func_append_quoted lastarg "$arg" done IFS="$save_ifs" func_stripname ' ' '' "$lastarg" lastarg=$func_stripname_result # Add the arguments to base_compile. func_append base_compile " $lastarg" continue ;; *) # Accept the current argument as the source file. # The previous "srcfile" becomes the current argument. # lastarg="$srcfile" srcfile="$arg" ;; esac # case $arg ;; esac # case $arg_mode # Aesthetically quote the previous argument. func_append_quoted base_compile "$lastarg" done # for arg case $arg_mode in arg) func_fatal_error "you must specify an argument for -Xcompile" ;; target) func_fatal_error "you must specify a target with \`-o'" ;; *) # Get the name of the library object. test -z "$libobj" && { func_basename "$srcfile" libobj="$func_basename_result" } ;; esac # Recognize several different file suffixes. # If the user specifies -o file.o, it is replaced with file.lo case $libobj in *.[cCFSifmso] | \ *.ada | *.adb | *.ads | *.asm | \ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) func_xform "$libobj" libobj=$func_xform_result ;; esac case $libobj in *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; *) func_fatal_error "cannot determine name of library object from \`$libobj'" ;; esac func_infer_tag $base_compile for arg in $later; do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no continue ;; -static) build_libtool_libs=no build_old_libs=yes continue ;; -prefer-pic) pic_mode=yes continue ;; -prefer-non-pic) pic_mode=no continue ;; esac done func_quote_for_eval "$libobj" test "X$libobj" != "X$func_quote_for_eval_result" \ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ && func_warning "libobj name \`$libobj' may not contain shell special characters." func_dirname_and_basename "$obj" "/" "" objname="$func_basename_result" xdir="$func_dirname_result" lobj=${xdir}$objdir/$objname test -z "$base_compile" && \ func_fatal_help "you must specify a compilation command" # Delete any leftover library objects. if test "$build_old_libs" = yes; then removelist="$obj $lobj $libobj ${libobj}T" else removelist="$lobj $libobj ${libobj}T" fi # On Cygwin there's no "real" PIC flag so we must build both object types case $host_os in cygwin* | mingw* | pw32* | os2* | cegcc*) pic_mode=default ;; esac if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then # non-PIC code in shared libraries is not supported pic_mode=default fi # Calculate the filename of the output object if compiler does # not support -o with -c if test "$compiler_c_o" = no; then output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} lockfile="$output_obj.lock" else output_obj= 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 $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "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." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi func_append removelist " $output_obj" $ECHO "$srcfile" > "$lockfile" fi $opt_dry_run || $RM $removelist func_append removelist " $lockfile" trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 srcfile=$func_to_tool_file_result func_quote_for_eval "$srcfile" qsrcfile=$func_quote_for_eval_result # 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 command="$base_compile $qsrcfile $pic_flag" else # Don't build PIC code command="$base_compile $qsrcfile" fi func_mkdir_p "$xdir$objdir" if test -z "$output_obj"; then # Place PIC objects in $objdir func_append command " -o $lobj" fi func_show_eval_locale "$command" \ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 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." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed, then go on to compile the next one if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then func_show_eval '$MV "$output_obj" "$lobj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi # Allow error messages only from the first compilation. if test "$suppress_opt" = yes; then suppress_output=' >/dev/null 2>&1' fi 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 $qsrcfile$pie_flag" else command="$base_compile $qsrcfile $pic_flag" fi if test "$compiler_c_o" = yes; then func_append command " -o $obj" fi # Suppress compiler output if we already did a PIC compilation. func_append command "$suppress_output" func_show_eval_locale "$command" \ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 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." $opt_dry_run || $RM $removelist exit $EXIT_FAILURE fi # Just move the object if needed if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then func_show_eval '$MV "$output_obj" "$obj"' \ 'error=$?; $opt_dry_run || $RM $removelist; exit $error' fi fi $opt_dry_run || { func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" # Unlock the critical section if it was locked if test "$need_locks" != no; then removelist=$lockfile $RM "$lockfile" fi } exit $EXIT_SUCCESS } $opt_help || { test "$opt_mode" = compile && func_mode_compile ${1+"$@"} } func_mode_help () { # We need to display help for each of the modes. case $opt_mode in "") # Generic help is extracted from the usage comments # at the start of this file. func_help ;; clean) $ECHO \ "Usage: $progname [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: $progname [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 -no-suppress do not suppress compiler output for multiple passes -prefer-pic try to build PIC objects only -prefer-non-pic try to build non-PIC objects only -shared do not build a \`.o' file suitable for static linking -static only build a \`.o' file suitable for static linking -Wc,FLAG pass FLAG directly to the compiler 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: $progname [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: $progname [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: $progname [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 following components of INSTALL-COMMAND are treated specially: -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation The rest of the components are interpreted as arguments to that command (only BSD-compatible install options are recognized)." ;; link) $ECHO \ "Usage: $progname [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 -bindir BINDIR specify path to binaries directory (for systems where libraries must be found in the PATH setting at runtime) -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) -export-symbols SYMFILE try to export only the symbols listed in SYMFILE -export-symbols-regex REGEX try to export only the symbols matching REGEX -LLIBDIR search LIBDIR for required installed libraries -lNAME OUTPUT-FILE requires the installed library libNAME -module build a library that can dlopened -no-fast-install disable the fast-install mode -no-install link a not-installable executable -no-undefined declare that a library does not refer to external symbols -o OUTPUT-FILE create OUTPUT-FILE from the specified objects -objectlist FILE Use a list of object files found in FILE to specify objects -precious-files-regex REGEX don't remove output files matching REGEX -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 -shared only do dynamic linking of libtool libraries -shrext SUFFIX override the standard shared library file extension -static do not do any dynamic linking of uninstalled libtool libraries -static-libtool-libs do not do any dynamic linking of libtool libraries -version-info CURRENT[:REVISION[:AGE]] specify library version info [each variable defaults to 0] -weak LIBNAME declare that the target provides the LIBNAME interface -Wc,FLAG -Xcompiler FLAG pass linker-specific FLAG directly to the compiler -Wl,FLAG -Xlinker FLAG pass linker-specific FLAG directly to the linker -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 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: $progname [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." ;; *) func_fatal_help "invalid operation mode \`$opt_mode'" ;; esac echo $ECHO "Try \`$progname --help' for more information about other modes." } # Now that we've collected a possible --mode arg, show help if necessary if $opt_help; then if test "$opt_help" = :; then func_mode_help else { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do func_mode_help done } | sed -n '1p; 2,$s/^Usage:/ or: /p' { func_help noexit for opt_mode in compile link execute install finish uninstall clean; do echo func_mode_help done } | sed '1d /^When reporting/,/^Report/{ H d } $x /information about other modes/d /more detailed .*MODE/d s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' fi exit $? fi # func_mode_execute arg... func_mode_execute () { $opt_debug # The first argument is the command name. cmd="$nonopt" test -z "$cmd" && \ func_fatal_help "you must specify a COMMAND" # Handle -dlopen flags immediately. for file in $opt_dlopen; do test -f "$file" \ || func_fatal_help "\`$file' is not a file" dir= case $file in *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$lib' is not a valid libtool archive" # Read the libtool library. dlname= library_names= func_source "$file" # Skip this library if it cannot be dlopened. if test -z "$dlname"; then # Warn if it was a shared library. test -n "$library_names" && \ func_warning "\`$file' was not linked with \`-export-dynamic'" continue fi func_dirname "$file" "" "." dir="$func_dirname_result" if test -f "$dir/$objdir/$dlname"; then func_append dir "/$objdir" else if test ! -f "$dir/$dlname"; then func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" fi fi ;; *.lo) # Just add the directory containing the .lo file. func_dirname "$file" "" "." dir="$func_dirname_result" ;; *) func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 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 -* | *.la | *.lo ) ;; *) # Do a test to see if this is really a libtool program. if func_ltwrapper_script_p "$file"; then func_source "$file" # Transform arg to wrapped name. file="$progdir/$program" elif func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" func_source "$func_ltwrapper_scriptname_result" # Transform arg to wrapped name. file="$progdir/$program" fi ;; esac # Quote arguments (to preserve shell metacharacters). func_append_quoted args "$file" done if test "X$opt_dry_run" = Xfalse; then if test -n "$shlibpath_var"; then # Export the shlibpath_var. eval "export $shlibpath_var" fi # Restore saved environment variables for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES do eval "if test \"\${save_$lt_var+set}\" = set; then $lt_var=\$save_$lt_var; export $lt_var else $lt_unset $lt_var fi" done # Now prepare to actually exec the command. exec_cmd="\$cmd$args" else # Display what would be done. if test -n "$shlibpath_var"; then eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" echo "export $shlibpath_var" fi $ECHO "$cmd$args" exit $EXIT_SUCCESS fi } test "$opt_mode" = execute && func_mode_execute ${1+"$@"} # func_mode_finish arg... func_mode_finish () { $opt_debug libs= libdirs= admincmds= for opt in "$nonopt" ${1+"$@"} do if test -d "$opt"; then func_append libdirs " $opt" elif test -f "$opt"; then if func_lalib_unsafe_p "$opt"; then func_append libs " $opt" else func_warning "\`$opt' is not a valid libtool archive" fi else func_fatal_error "invalid argument \`$opt'" fi done if test -n "$libs"; then if test -n "$lt_sysroot"; then sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" else sysroot_cmd= fi # Remove sysroot references if $opt_dry_run; then for lib in $libs; do echo "removing references to $lt_sysroot and \`=' prefixes from $lib" done else tmpdir=`func_mktempdir` for lib in $libs; do sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ > $tmpdir/tmp-la mv -f $tmpdir/tmp-la $lib done ${RM}r "$tmpdir" fi fi if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then for libdir in $libdirs; do if test -n "$finish_cmds"; then # Do each command in the finish commands. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds '"$cmd"'"' fi if test -n "$finish_eval"; then # Do the single finish_eval. eval cmds=\"$finish_eval\" $opt_dry_run || eval "$cmds" || func_append admincmds " $cmds" fi done fi # Exit here if they wanted silent mode. $opt_silent && exit $EXIT_SUCCESS if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then echo "----------------------------------------------------------------------" echo "Libraries have been installed in:" for libdir in $libdirs; do $ECHO " $libdir" done echo echo "If you ever happen to want to link against installed libraries" echo "in a given directory, LIBDIR, you must either use libtool, and" echo "specify the full pathname of the library, or use the \`-LLIBDIR'" echo "flag during linking and do at least one of the following:" if test -n "$shlibpath_var"; then echo " - add LIBDIR to the \`$shlibpath_var' environment variable" echo " during execution" fi if test -n "$runpath_var"; then echo " - add LIBDIR to the \`$runpath_var' environment variable" echo " during linking" fi if test -n "$hardcode_libdir_flag_spec"; then libdir=LIBDIR eval flag=\"$hardcode_libdir_flag_spec\" $ECHO " - use the \`$flag' linker flag" fi if test -n "$admincmds"; then $ECHO " - have your system administrator run these commands:$admincmds" fi if test -f /etc/ld.so.conf; then echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" fi echo echo "See any operating system documentation about shared libraries for" case $host in solaris2.[6789]|solaris2.1[0-9]) echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" echo "pages." ;; *) echo "more information, such as the ld(1) and ld.so(8) manual pages." ;; esac echo "----------------------------------------------------------------------" fi exit $EXIT_SUCCESS } test "$opt_mode" = finish && func_mode_finish ${1+"$@"} # func_mode_install arg... func_mode_install () { $opt_debug # There may be an optional sh(1) argument at the beginning of # install_prog (especially on Windows NT). if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || # Allow the use of GNU shtool's install command. case $nonopt in *shtool*) :;; *) false;; esac; then # Aesthetically quote it. func_quote_for_eval "$nonopt" install_prog="$func_quote_for_eval_result " arg=$1 shift else install_prog= arg=$nonopt fi # The real first argument should be the name of the installation program. # Aesthetically quote it. func_quote_for_eval "$arg" func_append install_prog "$func_quote_for_eval_result" install_shared_prog=$install_prog case " $install_prog " in *[\\\ /]cp\ *) install_cp=: ;; *) install_cp=false ;; esac # We need to accept at least all the BSD install flags. dest= files= opts= prev= install_type= isdir=no stripme= no_mode=: for arg do arg2= if test -n "$dest"; then func_append files " $dest" dest=$arg continue fi case $arg in -d) isdir=yes ;; -f) if $install_cp; then :; else prev=$arg fi ;; -g | -m | -o) prev=$arg ;; -s) stripme=" -s" continue ;; -*) ;; *) # If the previous option needed an argument, then skip it. if test -n "$prev"; then if test "x$prev" = x-m && test -n "$install_override_mode"; then arg2=$install_override_mode no_mode=false fi prev= else dest=$arg continue fi ;; esac # Aesthetically quote the argument. func_quote_for_eval "$arg" func_append install_prog " $func_quote_for_eval_result" if test -n "$arg2"; then func_quote_for_eval "$arg2" fi func_append install_shared_prog " $func_quote_for_eval_result" done test -z "$install_prog" && \ func_fatal_help "you must specify an install program" test -n "$prev" && \ func_fatal_help "the \`$prev' option requires an argument" if test -n "$install_override_mode" && $no_mode; then if $install_cp; then :; else func_quote_for_eval "$install_override_mode" func_append install_shared_prog " -m $func_quote_for_eval_result" fi fi if test -z "$files"; then if test -z "$dest"; then func_fatal_help "no file or destination specified" else func_fatal_help "you must specify a destination" fi fi # Strip any trailing slash from the destination. func_stripname '' '/' "$dest" dest=$func_stripname_result # Check to see that the destination is a directory. test -d "$dest" && isdir=yes if test "$isdir" = yes; then destdir="$dest" destname= else func_dirname_and_basename "$dest" "" "." destdir="$func_dirname_result" destname="$func_basename_result" # Not a directory, so check to see that there is only one file specified. set dummy $files; shift test "$#" -gt 1 && \ func_fatal_help "\`$dest' is not a directory" fi case $destdir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) for file in $files; do case $file in *.lo) ;; *) func_fatal_help "\`$destdir' must be an absolute directory name" ;; esac done ;; esac # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" staticlibs= future_libdirs= current_libdirs= for file in $files; do # Do each installation. case $file in *.$libext) # Do the static libraries later. func_append staticlibs " $file" ;; *.la) func_resolve_sysroot "$file" file=$func_resolve_sysroot_result # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$file" \ || func_fatal_help "\`$file' is not a valid libtool archive" library_names= old_library= relink_command= func_source "$file" # Add the libdir to current_libdirs if it is the destination. if test "X$destdir" = "X$libdir"; then case "$current_libdirs " in *" $libdir "*) ;; *) func_append current_libdirs " $libdir" ;; esac else # Note the libdir as a future libdir. case "$future_libdirs " in *" $libdir "*) ;; *) func_append future_libdirs " $libdir" ;; esac fi func_dirname "$file" "/" "" dir="$func_dirname_result" func_append dir "$objdir" if test -n "$relink_command"; then # Determine the prefix the user has applied to our future dir. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` # Don't allow the user to place us outside of our expected # location b/c this prevents finding dependent libraries that # are installed to the same prefix. # At present, this check doesn't affect windows .dll's that # are installed into $libdir/../bin (currently, that works fine) # but it's something to keep an eye on. test "$inst_prefix_dir" = "$destdir" && \ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" if test -n "$inst_prefix_dir"; then # Stick the inst_prefix_dir data into the link command. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` else relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` fi func_warning "relinking \`$file'" func_show_eval "$relink_command" \ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' fi # See the names of the shared library. set dummy $library_names; shift if test -n "$1"; then realname="$1" shift srcname="$realname" test -n "$relink_command" && srcname="$realname"T # Install the shared library and build the symlinks. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 'exit $?' tstripme="$stripme" case $host_os in cygwin* | mingw* | pw32* | cegcc*) case $realname in *.dll.a) tstripme="" ;; esac ;; esac if test -n "$tstripme" && test -n "$striplib"; then func_show_eval "$striplib $destdir/$realname" 'exit $?' fi if test "$#" -gt 0; then # Delete the old symlinks, and create new ones. # Try `ln -sf' first, because the `ln' binary might depend on # the symlink we replace! Solaris /bin/ln does not understand -f, # so we also need to try rm && ln -s. for linkname do test "$linkname" != "$realname" \ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" done fi # Do each command in the postinstall commands. lib="$destdir/$realname" func_execute_cmds "$postinstall_cmds" 'exit $?' fi # Install the pseudo-library for information purposes. func_basename "$file" name="$func_basename_result" instname="$dir/$name"i func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' # Maybe install the static library, too. test -n "$old_library" && func_append 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 func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # Deduce the name of the destination old-style object file. case $destfile in *.lo) func_lo2o "$destfile" staticdest=$func_lo2o_result ;; *.$objext) staticdest="$destfile" destfile= ;; *) func_fatal_help "cannot copy a libtool object to \`$destfile'" ;; esac # Install the libtool object if requested. test -n "$destfile" && \ func_show_eval "$install_prog $file $destfile" 'exit $?' # Install the old object if enabled. if test "$build_old_libs" = yes; then # Deduce the name of the old-style object file. func_lo2o "$file" staticobj=$func_lo2o_result func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' fi exit $EXIT_SUCCESS ;; *) # Figure out destination file name, if it wasn't already specified. if test -n "$destname"; then destfile="$destdir/$destname" else func_basename "$file" destfile="$func_basename_result" destfile="$destdir/$destfile" fi # If the file is missing, and there is a .exe on the end, strip it # because it is most likely a libtool script we actually want to # install stripped_ext="" case $file in *.exe) if test ! -f "$file"; then func_stripname '' '.exe' "$file" file=$func_stripname_result stripped_ext=".exe" fi ;; esac # Do a test to see if this is really a libtool program. case $host in *cygwin* | *mingw*) if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" wrapper=$func_ltwrapper_scriptname_result else func_stripname '' '.exe' "$file" wrapper=$func_stripname_result fi ;; *) wrapper=$file ;; esac if func_ltwrapper_script_p "$wrapper"; then notinst_deplibs= relink_command= func_source "$wrapper" # Check the variables that should have been set. test -z "$generated_by_libtool_version" && \ func_fatal_error "invalid libtool wrapper script \`$wrapper'" finalize=yes for lib in $notinst_deplibs; do # Check to see that each library is installed. libdir= if test -f "$lib"; then func_source "$lib" fi libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test if test -n "$libdir" && test ! -f "$libfile"; then func_warning "\`$lib' has not been installed in \`$libdir'" finalize=no fi done relink_command= func_source "$wrapper" outputname= if test "$fast_install" = no && test -n "$relink_command"; then $opt_dry_run || { if test "$finalize" = yes; then tmpdir=`func_mktempdir` func_basename "$file$stripped_ext" file="$func_basename_result" outputname="$tmpdir/$file" # Replace the output file specification. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` $opt_silent || { func_quote_for_expand "$relink_command" eval "func_echo $func_quote_for_expand_result" } if eval "$relink_command"; then : else func_error "error: relink \`$file' with the above command before installing it" $opt_dry_run || ${RM}r "$tmpdir" continue fi file="$outputname" else func_warning "cannot relink \`$file'" fi } else # Install the binary that we compiled earlier. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` fi fi # remove .exe since cygwin /usr/bin/install will append another # one anyway case $install_prog,$host in */usr/bin/install*,*cygwin*) case $file:$destfile in *.exe:*.exe) # this is ok ;; *.exe:*) destfile=$destfile.exe ;; *:*.exe) func_stripname '' '.exe' "$destfile" destfile=$func_stripname_result ;; esac ;; esac func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' $opt_dry_run || if test -n "$outputname"; then ${RM}r "$tmpdir" fi ;; esac done for file in $staticlibs; do func_basename "$file" name="$func_basename_result" # Set up the ranlib parameters. oldlib="$destdir/$name" func_show_eval "$install_prog \$file \$oldlib" 'exit $?' if test -n "$stripme" && test -n "$old_striplib"; then func_show_eval "$old_striplib $oldlib" 'exit $?' fi # Do each command in the postinstall commands. func_execute_cmds "$old_postinstall_cmds" 'exit $?' done test -n "$future_libdirs" && \ func_warning "remember to run \`$progname --finish$future_libdirs'" if test -n "$current_libdirs"; then # Maybe just do a dry run. $opt_dry_run && current_libdirs=" -n$current_libdirs" exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' else exit $EXIT_SUCCESS fi } test "$opt_mode" = install && func_mode_install ${1+"$@"} # func_generate_dlsyms outputname originator pic_p # Extract symbols from dlprefiles and create ${outputname}S.o with # a dlpreopen symbol table. func_generate_dlsyms () { $opt_debug my_outputname="$1" my_originator="$2" my_pic_p="${3-no}" my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` my_dlsyms= if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then if test -n "$NM" && test -n "$global_symbol_pipe"; then my_dlsyms="${my_outputname}S.c" else func_error "not configured to extract global symbols from dlpreopened files" fi fi if test -n "$my_dlsyms"; then case $my_dlsyms in "") ;; *.c) # Discover the nlist of each of the dlfiles. nlist="$output_objdir/${my_outputname}.nm" func_show_eval "$RM $nlist ${nlist}S ${nlist}T" # Parse the name list into a source file. func_verbose "creating $output_objdir/$my_dlsyms" $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ #ifdef __cplusplus extern \"C\" { #endif #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" #endif /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif /* External symbol declarations for the compiler. */\ " if test "$dlself" = yes; then func_verbose "generating symbol list for \`$output'" $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" # Add our own program objects to the symbol list. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` for progfile in $progfiles; do func_to_tool_file "$progfile" func_convert_file_msys_to_w32 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" done if test -n "$exclude_expsyms"; then $opt_dry_run || { eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi if test -n "$export_symbols_regex"; then $opt_dry_run || { eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' } fi # Prepare the list of exported symbols if test -z "$export_symbols"; then export_symbols="$output_objdir/$outputname.exp" $opt_dry_run || { $RM $export_symbols eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' ;; esac } else $opt_dry_run || { eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' eval '$MV "$nlist"T "$nlist"' case $host in *cygwin* | *mingw* | *cegcc* ) eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' ;; esac } fi fi for dlprefile in $dlprefiles; do func_verbose "extracting global C symbols from \`$dlprefile'" func_basename "$dlprefile" name="$func_basename_result" case $host in *cygwin* | *mingw* | *cegcc* ) # if an import library, we need to obtain dlname if func_win32_import_lib_p "$dlprefile"; then func_tr_sh "$dlprefile" eval "curr_lafile=\$libfile_$func_tr_sh_result" dlprefile_dlbasename="" if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then # Use subshell, to avoid clobbering current variable values dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` if test -n "$dlprefile_dlname" ; then func_basename "$dlprefile_dlname" dlprefile_dlbasename="$func_basename_result" else # no lafile. user explicitly requested -dlpreopen . $sharedlib_from_linklib_cmd "$dlprefile" dlprefile_dlbasename=$sharedlib_from_linklib_result fi fi $opt_dry_run || { if test -n "$dlprefile_dlbasename" ; then eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' else func_warning "Could not compute DLL name from $name" eval '$ECHO ": $name " >> "$nlist"' fi func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" } else # not an import lib $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } fi ;; *) $opt_dry_run || { eval '$ECHO ": $name " >> "$nlist"' func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" } ;; esac done $opt_dry_run || { # Make sure we have at least an empty file. test -f "$nlist" || : > "$nlist" if test -n "$exclude_expsyms"; then $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T $MV "$nlist"T "$nlist" fi # Try sorting and uniquifying the output. if $GREP -v "^: " < "$nlist" | if sort -k 3 /dev/null 2>&1; then sort -k 3 else sort +2 fi | uniq > "$nlist"S; then : else $GREP -v "^: " < "$nlist" > "$nlist"S fi if test -f "$nlist"S; then eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' else echo '/* NONE */' >> "$output_objdir/$my_dlsyms" fi echo >> "$output_objdir/$my_dlsyms" "\ /* The mapping between symbol names and symbols. */ typedef struct { const char *name; void *address; } lt_dlsymlist; extern LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[]; LT_DLSYM_CONST lt_dlsymlist lt_${my_prefix}_LTX_preloaded_symbols[] = {\ { \"$my_originator\", (void *) 0 }," case $need_lib_prefix in no) eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; *) eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" ;; esac echo >> "$output_objdir/$my_dlsyms" "\ {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt_${my_prefix}_LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif\ " } # !$opt_dry_run pic_flag_for_symtable= case "$compile_command " in *" -static "*) ;; *) 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*) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; *-*-hpux*) pic_flag_for_symtable=" $pic_flag" ;; *) if test "X$my_pic_p" != Xno; then pic_flag_for_symtable=" $pic_flag" fi ;; esac ;; esac symtab_cflags= for arg in $LTCFLAGS; do case $arg in -pie | -fpie | -fPIE) ;; *) func_append symtab_cflags " $arg" ;; esac done # Now compile the dynamic symbol file. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' # Clean up the generated files. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' # Transform the symbol file into the correct name. symfileobj="$output_objdir/${my_outputname}S.$objext" case $host in *cygwin* | *mingw* | *cegcc* ) if test -f "$output_objdir/$my_outputname.def"; then compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` else compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` fi ;; *) compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` ;; esac ;; *) func_fatal_error "unknown suffix for \`$my_dlsyms'" ;; 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 "$compile_command" | $SED "s% @SYMFILE@%%"` finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` fi } # func_win32_libid arg # return the library type of file 'arg' # # Need a lot of goo to handle *both* DLLs and import libs # Has to be a shell function in order to 'eat' the argument # that is supplied when $file_magic_command is called. # Despite the name, also deal with 64 bit binaries. func_win32_libid () { $opt_debug win32_libid_type="unknown" win32_fileres=`file -L $1 2>/dev/null` case $win32_fileres in *ar\ archive\ import\ library*) # definitely import win32_libid_type="x86 archive import" ;; *ar\ archive*) # could be an import, or static # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then func_to_tool_file "$1" func_convert_file_msys_to_w32 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | $SED -n -e ' 1,100{ / I /{ s,.*,import, p q } }'` case $win32_nmres in import*) win32_libid_type="x86 archive import";; *) win32_libid_type="x86 archive static";; esac fi ;; *DLL*) win32_libid_type="x86 DLL" ;; *executable*) # but shell scripts are "executable" too... case $win32_fileres in *MS\ Windows\ PE\ Intel*) win32_libid_type="x86 DLL" ;; esac ;; esac $ECHO "$win32_libid_type" } # func_cygming_dll_for_implib ARG # # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib () { $opt_debug sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` } # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs # # The is the core of a fallback implementation of a # platform-specific function to extract the name of the # DLL associated with the specified import library LIBNAME. # # SECTION_NAME is either .idata$6 or .idata$7, depending # on the platform and compiler that created the implib. # # Echos the name of the DLL associated with the # specified import library. func_cygming_dll_for_implib_fallback_core () { $opt_debug match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` $OBJDUMP -s --section "$1" "$2" 2>/dev/null | $SED '/^Contents of section '"$match_literal"':/{ # Place marker at beginning of archive member dllname section s/.*/====MARK====/ p d } # These lines can sometimes be longer than 43 characters, but # are always uninteresting /:[ ]*file format pe[i]\{,1\}-/d /^In archive [^:]*:/d # Ensure marker is printed /^====MARK====/p # Remove all lines with less than 43 characters /^.\{43\}/!d # From remaining lines, remove first 43 characters s/^.\{43\}//' | $SED -n ' # Join marker and all lines until next marker into a single line /^====MARK====/ b para H $ b para b :para x s/\n//g # Remove the marker s/^====MARK====// # Remove trailing dots and whitespace s/[\. \t]*$// # Print /./p' | # we now have a list, one entry per line, of the stringified # contents of the appropriate section of all members of the # archive which possess that section. Heuristic: eliminate # all those which have a first or second character that is # a '.' (that is, objdump's representation of an unprintable # character.) This should work for all archives with less than # 0x302f exports -- but will fail for DLLs whose name actually # begins with a literal '.' or a single character followed by # a '.'. # # Of those that remain, print the first one. $SED -e '/^\./d;/^.\./d;q' } # func_cygming_gnu_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is a GNU/binutils-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_gnu_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` test -n "$func_cygming_gnu_implib_tmp" } # func_cygming_ms_implib_p ARG # This predicate returns with zero status (TRUE) if # ARG is an MS-style import library. Returns # with nonzero status (FALSE) otherwise. func_cygming_ms_implib_p () { $opt_debug func_to_tool_file "$1" func_convert_file_msys_to_w32 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` test -n "$func_cygming_ms_implib_tmp" } # func_cygming_dll_for_implib_fallback ARG # Platform-specific function to extract the # name of the DLL associated with the specified # import library ARG. # # This fallback implementation is for use when $DLLTOOL # does not support the --identify-strict option. # Invoked by eval'ing the libtool variable # $sharedlib_from_linklib_cmd # Result is available in the variable # $sharedlib_from_linklib_result func_cygming_dll_for_implib_fallback () { $opt_debug if func_cygming_gnu_implib_p "$1" ; then # binutils import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` elif func_cygming_ms_implib_p "$1" ; then # ms-generated import library sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` else # unknown sharedlib_from_linklib_result="" fi } # func_extract_an_archive dir oldlib func_extract_an_archive () { $opt_debug f_ex_an_ar_dir="$1"; shift f_ex_an_ar_oldlib="$1" if test "$lock_old_archive_extraction" = yes; then lockfile=$f_ex_an_ar_oldlib.lock until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do func_echo "Waiting for $lockfile to be removed" sleep 2 done fi func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 'stat=$?; rm -f "$lockfile"; exit $stat' if test "$lock_old_archive_extraction" = yes; then $opt_dry_run || rm -f "$lockfile" fi if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then : else func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" fi } # func_extract_archives gentop oldlib ... func_extract_archives () { $opt_debug my_gentop="$1"; shift my_oldlibs=${1+"$@"} my_oldobjs="" my_xlib="" my_xabs="" my_xdir="" for my_xlib in $my_oldlibs; do # Extract the objects. case $my_xlib in [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; *) my_xabs=`pwd`"/$my_xlib" ;; esac func_basename "$my_xlib" my_xlib="$func_basename_result" my_xlib_u=$my_xlib while :; do case " $extracted_archives " in *" $my_xlib_u "*) func_arith $extracted_serial + 1 extracted_serial=$func_arith_result my_xlib_u=lt$extracted_serial-$my_xlib ;; *) break ;; esac done extracted_archives="$extracted_archives $my_xlib_u" my_xdir="$my_gentop/$my_xlib_u" func_mkdir_p "$my_xdir" case $host in *-darwin*) func_verbose "Extracting $my_xabs" # Do not bother doing anything if just a dry run $opt_dry_run || { darwin_orig_dir=`pwd` cd $my_xdir || exit $? darwin_archive=$my_xabs darwin_curdir=`pwd` darwin_base_archive=`basename "$darwin_archive"` darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` if test -n "$darwin_arches"; then darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` darwin_arch= func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" for darwin_arch in $darwin_arches ; do func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" func_extract_an_archive "`pwd`" "${darwin_base_archive}" cd "$darwin_curdir" $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" done # $darwin_arches ## Okay now we've a bunch of thin objects, gotta fatten them up :) darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` darwin_file= darwin_files= for darwin_file in $darwin_filelist; do darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` $LIPO -create -output "$darwin_file" $darwin_files done # $darwin_filelist $RM -rf unfat-$$ cd "$darwin_orig_dir" else cd $darwin_orig_dir func_extract_an_archive "$my_xdir" "$my_xabs" fi # $darwin_arches } # !$opt_dry_run ;; *) func_extract_an_archive "$my_xdir" "$my_xabs" ;; esac my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` done func_extract_archives_result="$my_oldobjs" } # func_emit_wrapper [arg=no] # # Emit a libtool wrapper script on stdout. # Don't directly open a file because we may want to # incorporate the script contents within a cygwin/mingw # wrapper executable. Must ONLY be called from within # func_mode_link because it depends on a number of variables # set therein. # # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR # variable will take. If 'yes', then the emitted script # will assume that the directory in which it is stored is # the $objdir directory. This is a cygwin/mingw-specific # behavior. func_emit_wrapper () { func_emit_wrapper_arg1=${1-no} $ECHO "\ #! $SHELL # $output - temporary wrapper script for $objdir/$outputname # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # 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. sed_quote_subst='$sed_quote_subst' # Be Bourne compatible if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac fi BIN_SH=xpg4; export BIN_SH # for Tru64 DUALCASE=1; export DUALCASE # for MKS sh # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH relink_command=\"$relink_command\" # This environment variable determines our operation mode. if test \"\$libtool_install_magic\" = \"$magic\"; then # install mode needs the following variables: generated_by_libtool_version='$macro_version' notinst_deplibs='$notinst_deplibs' else # When we are sourced in execute mode, \$file and \$ECHO are already set. if test \"\$libtool_execute_magic\" != \"$magic\"; then file=\"\$0\"" qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` $ECHO "\ # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } ECHO=\"$qECHO\" fi # Very basic option parsing. These options are (a) specific to # the libtool wrapper, (b) are identical between the wrapper # /script/ and the wrapper /executable/ which is used only on # windows platforms, and (c) all begin with the string "--lt-" # (application programs are unlikely to have options which match # this pattern). # # There are only two supported options: --lt-debug and # --lt-dump-script. There is, deliberately, no --lt-help. # # The first argument to this parsing function should be the # script's $0 value, followed by "$@". lt_option_debug= func_parse_lt_options () { lt_script_arg0=\$0 shift for lt_opt do case \"\$lt_opt\" in --lt-debug) lt_option_debug=1 ;; --lt-dump-script) lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` cat \"\$lt_dump_D/\$lt_dump_F\" exit 0 ;; --lt-*) \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 exit 1 ;; esac done # Print the debug banner immediately: if test -n \"\$lt_option_debug\"; then echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 fi } # Used when --lt-debug. Prints its arguments to stdout # (redirection is the responsibility of the caller) func_lt_dump_args () { lt_dump_args_N=1; for lt_arg do \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` done } # Core function for launching the target application func_exec_program_core () { " case $host in # Backslashes separate directories on plain windows *-*-mingw | *-*-os2* | *-cegcc*) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} " ;; *) $ECHO "\ if test -n \"\$lt_option_debug\"; then \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 func_lt_dump_args \${1+\"\$@\"} 1>&2 fi exec \"\$progdir/\$program\" \${1+\"\$@\"} " ;; esac $ECHO "\ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 exit 1 } # A function to encapsulate launching the target application # Strips options in the --lt-* namespace from \$@ and # launches target application with the remaining arguments. func_exec_program () { for lt_wr_arg do case \$lt_wr_arg in --lt-*) ;; *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; esac shift done func_exec_program_core \${1+\"\$@\"} } # Parse options func_parse_lt_options \"\$0\" \${1+\"\$@\"} # Find the directory that this script lives in. thisdir=\`\$ECHO \"\$file\" | $SED '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 \"\$file\" | $SED '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 \"\$file\" | $SED 's%^.*/%%'\` file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` done # Usually 'no', except on cygwin/mingw when embedded into # the cwrapper. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then # special case for '.' if test \"\$thisdir\" = \".\"; then thisdir=\`pwd\` fi # remove .libs from thisdir case \"\$thisdir\" in *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; $objdir ) thisdir=. ;; esac fi # Try to get the absolute directory name. absdir=\`cd \"\$thisdir\" && pwd\` test -n \"\$absdir\" && thisdir=\"\$absdir\" " if test "$fast_install" = yes; then $ECHO "\ program=lt-'$outputname'$exeext progdir=\"\$thisdir/$objdir\" if test ! -f \"\$progdir/\$program\" || { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ test \"X\$file\" != \"X\$progdir/\$program\"; }; then file=\"\$\$-\$program\" if test ! -d \"\$progdir\"; then $MKDIR \"\$progdir\" else $RM \"\$progdir/\$file\" fi" $ECHO "\ # relink executable if necessary if test -n \"\$relink_command\"; then if relink_command_output=\`eval \$relink_command 2>&1\`; then : else $ECHO \"\$relink_command_output\" >&2 $RM \"\$progdir/\$file\" exit 1 fi fi $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || { $RM \"\$progdir/\$program\"; $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } $RM \"\$progdir/\$file\" fi" else $ECHO "\ program='$outputname' progdir=\"\$thisdir/$objdir\" " fi $ECHO "\ if test -f \"\$progdir/\$program\"; then" # fixup the dll searchpath if we need to. # # Fix the DLL searchpath if we need to. Do this before prepending # to shlibpath, because on Windows, both are PATH and uninstalled # libraries must come first. if test -n "$dllsearchpath"; then $ECHO "\ # Add the dll search path components to the executable PATH PATH=$dllsearchpath:\$PATH " fi # Export our shlibpath_var if we have one. if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then $ECHO "\ # 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 \"\$$shlibpath_var\" | $SED 's/::*\$//'\` export $shlibpath_var " fi $ECHO "\ if test \"\$libtool_execute_magic\" != \"$magic\"; then # Run the actual program with our arguments. func_exec_program \${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\ " } # func_emit_cwrapperexe_src # emit the source code for a wrapper executable on stdout # Must ONLY be called from within func_mode_link because # it depends on a number of variable set therein. func_emit_cwrapperexe_src () { cat < #include #ifdef _MSC_VER # include # include # include #else # include # include # ifdef __CYGWIN__ # include # endif #endif #include #include #include #include #include #include #include #include /* declarations of non-ANSI functions */ #if defined(__MINGW32__) # ifdef __STRICT_ANSI__ int _putenv (const char *); # endif #elif defined(__CYGWIN__) # ifdef __STRICT_ANSI__ char *realpath (const char *, char *); int putenv (char *); int setenv (const char *, const char *, int); # endif /* #elif defined (other platforms) ... */ #endif /* portability defines, excluding path handling macros */ #if defined(_MSC_VER) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv # define S_IXUSR _S_IEXEC # ifndef _INTPTR_T_DEFINED # define _INTPTR_T_DEFINED # define intptr_t int # endif #elif defined(__MINGW32__) # define setmode _setmode # define stat _stat # define chmod _chmod # define getcwd _getcwd # define putenv _putenv #elif defined(__CYGWIN__) # define HAVE_SETENV # define FOPEN_WB "wb" /* #elif defined (other platforms) ... */ #endif #if defined(PATH_MAX) # define LT_PATHMAX PATH_MAX #elif defined(MAXPATHLEN) # define LT_PATHMAX MAXPATHLEN #else # define LT_PATHMAX 1024 #endif #ifndef S_IXOTH # define S_IXOTH 0 #endif #ifndef S_IXGRP # define S_IXGRP 0 #endif /* path handling portability macros */ #ifndef DIR_SEPARATOR # define DIR_SEPARATOR '/' # define PATH_SEPARATOR ':' #endif #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ defined (__OS2__) # define HAVE_DOS_BASED_FILE_SYSTEM # define FOPEN_WB "wb" # ifndef DIR_SEPARATOR_2 # define DIR_SEPARATOR_2 '\\' # endif # ifndef PATH_SEPARATOR_2 # define PATH_SEPARATOR_2 ';' # endif #endif #ifndef DIR_SEPARATOR_2 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) #else /* DIR_SEPARATOR_2 */ # define IS_DIR_SEPARATOR(ch) \ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) #endif /* DIR_SEPARATOR_2 */ #ifndef PATH_SEPARATOR_2 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) #else /* PATH_SEPARATOR_2 */ # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) #endif /* PATH_SEPARATOR_2 */ #ifndef FOPEN_WB # define FOPEN_WB "w" #endif #ifndef _O_BINARY # define _O_BINARY 0 #endif #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) #define XFREE(stale) do { \ if (stale) { free ((void *) stale); stale = 0; } \ } while (0) #if defined(LT_DEBUGWRAPPER) static int lt_debug = 1; #else static int lt_debug = 0; #endif const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ void *xmalloc (size_t num); char *xstrdup (const char *string); const char *base_name (const char *name); char *find_executable (const char *wrapper); char *chase_symlinks (const char *pathspec); int make_executable (const char *path); int check_executable (const char *path); char *strendzap (char *str, const char *pat); void lt_debugprintf (const char *file, int line, const char *fmt, ...); void lt_fatal (const char *file, int line, const char *message, ...); static const char *nonnull (const char *s); static const char *nonempty (const char *s); void lt_setenv (const char *name, const char *value); char *lt_extend_str (const char *orig_value, const char *add, int to_end); void lt_update_exe_path (const char *name, const char *value); void lt_update_lib_path (const char *name, const char *value); char **prepare_spawn (char **argv); void lt_dump_script (FILE *f); EOF cat <= 0) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) return 1; else return 0; } int make_executable (const char *path) { int rval = 0; struct stat st; lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", nonempty (path)); if ((!path) || (!*path)) return 0; if (stat (path, &st) >= 0) { rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); } return rval; } /* Searches for the full path of the wrapper. Returns newly allocated full path name if found, NULL otherwise Does not chase symlinks, even on platforms that support them. */ char * find_executable (const char *wrapper) { int has_slash = 0; const char *p; const char *p_next; /* static buffer for getcwd */ char tmp[LT_PATHMAX + 1]; int tmp_len; char *concat_name; lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", nonempty (wrapper)); if ((wrapper == NULL) || (*wrapper == '\0')) return NULL; /* Absolute path? */ #if defined (HAVE_DOS_BASED_FILE_SYSTEM) if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } else { #endif if (IS_DIR_SEPARATOR (wrapper[0])) { concat_name = xstrdup (wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } #if defined (HAVE_DOS_BASED_FILE_SYSTEM) } #endif for (p = wrapper; *p; p++) if (*p == '/') { has_slash = 1; break; } if (!has_slash) { /* no slashes; search PATH */ const char *path = getenv ("PATH"); if (path != NULL) { for (p = path; *p; p = p_next) { const char *q; size_t p_len; for (q = p; *q; q++) if (IS_PATH_SEPARATOR (*q)) break; p_len = q - p; p_next = (*q == '\0' ? q : q + 1); if (p_len == 0) { /* empty path: current directory */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); } else { concat_name = XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, p, p_len); concat_name[p_len] = '/'; strcpy (concat_name + p_len + 1, wrapper); } if (check_executable (concat_name)) return concat_name; XFREE (concat_name); } } /* not found in PATH; assume curdir */ } /* Relative path | not found in path: prepend cwd */ if (getcwd (tmp, LT_PATHMAX) == NULL) lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", nonnull (strerror (errno))); tmp_len = strlen (tmp); concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); memcpy (concat_name, tmp, tmp_len); concat_name[tmp_len] = '/'; strcpy (concat_name + tmp_len + 1, wrapper); if (check_executable (concat_name)) return concat_name; XFREE (concat_name); return NULL; } char * chase_symlinks (const char *pathspec) { #ifndef S_ISLNK return xstrdup (pathspec); #else char buf[LT_PATHMAX]; struct stat s; char *tmp_pathspec = xstrdup (pathspec); char *p; int has_symlinks = 0; while (strlen (tmp_pathspec) && !has_symlinks) { lt_debugprintf (__FILE__, __LINE__, "checking path component for symlinks: %s\n", tmp_pathspec); if (lstat (tmp_pathspec, &s) == 0) { if (S_ISLNK (s.st_mode) != 0) { has_symlinks = 1; break; } /* search backwards for last DIR_SEPARATOR */ p = tmp_pathspec + strlen (tmp_pathspec) - 1; while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) p--; if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) { /* no more DIR_SEPARATORS left */ break; } *p = '\0'; } else { lt_fatal (__FILE__, __LINE__, "error accessing file \"%s\": %s", tmp_pathspec, nonnull (strerror (errno))); } } XFREE (tmp_pathspec); if (!has_symlinks) { return xstrdup (pathspec); } tmp_pathspec = realpath (pathspec, buf); if (tmp_pathspec == 0) { lt_fatal (__FILE__, __LINE__, "could not follow symlinks for %s", pathspec); } return xstrdup (tmp_pathspec); #endif } char * strendzap (char *str, const char *pat) { size_t len, patlen; assert (str != NULL); assert (pat != NULL); len = strlen (str); patlen = strlen (pat); if (patlen <= len) { str += len - patlen; if (strcmp (str, pat) == 0) *str = '\0'; } return str; } void lt_debugprintf (const char *file, int line, const char *fmt, ...) { va_list args; if (lt_debug) { (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); va_start (args, fmt); (void) vfprintf (stderr, fmt, args); va_end (args); } } static void lt_error_core (int exit_status, const char *file, int line, const char *mode, const char *message, va_list ap) { fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); vfprintf (stderr, message, ap); fprintf (stderr, ".\n"); if (exit_status >= 0) exit (exit_status); } void lt_fatal (const char *file, int line, const char *message, ...) { va_list ap; va_start (ap, message); lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); va_end (ap); } static const char * nonnull (const char *s) { return s ? s : "(null)"; } static const char * nonempty (const char *s) { return (s && !*s) ? "(empty)" : nonnull (s); } void lt_setenv (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_setenv) setting '%s' to '%s'\n", nonnull (name), nonnull (value)); { #ifdef HAVE_SETENV /* always make a copy, for consistency with !HAVE_SETENV */ char *str = xstrdup (value); setenv (name, str, 1); #else int len = strlen (name) + 1 + strlen (value) + 1; char *str = XMALLOC (char, len); sprintf (str, "%s=%s", name, value); if (putenv (str) != EXIT_SUCCESS) { XFREE (str); } #endif } } char * lt_extend_str (const char *orig_value, const char *add, int to_end) { char *new_value; if (orig_value && *orig_value) { int orig_value_len = strlen (orig_value); int add_len = strlen (add); new_value = XMALLOC (char, add_len + orig_value_len + 1); if (to_end) { strcpy (new_value, orig_value); strcpy (new_value + orig_value_len, add); } else { strcpy (new_value, add); strcpy (new_value + add_len, orig_value); } } else { new_value = xstrdup (add); } return new_value; } void lt_update_exe_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); /* some systems can't cope with a ':'-terminated path #' */ int len = strlen (new_value); while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) { new_value[len-1] = '\0'; } lt_setenv (name, new_value); XFREE (new_value); } } void lt_update_lib_path (const char *name, const char *value) { lt_debugprintf (__FILE__, __LINE__, "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", nonnull (name), nonnull (value)); if (name && *name && value && *value) { char *new_value = lt_extend_str (getenv (name), value, 0); lt_setenv (name, new_value); XFREE (new_value); } } EOF case $host_os in mingw*) cat <<"EOF" /* Prepares an argument vector before calling spawn(). Note that spawn() does not by itself call the command interpreter (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&v); v.dwPlatformId == VER_PLATFORM_WIN32_NT; }) ? "cmd.exe" : "command.com"). Instead it simply concatenates the arguments, separated by ' ', and calls CreateProcess(). We must quote the arguments since Win32 CreateProcess() interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a special way: - Space and tab are interpreted as delimiters. They are not treated as delimiters if they are surrounded by double quotes: "...". - Unescaped double quotes are removed from the input. Their only effect is that within double quotes, space and tab are treated like normal characters. - Backslashes not followed by double quotes are not special. - But 2*n+1 backslashes followed by a double quote become n backslashes followed by a double quote (n >= 0): \" -> " \\\" -> \" \\\\\" -> \\" */ #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" char ** prepare_spawn (char **argv) { size_t argc; char **new_argv; size_t i; /* Count number of arguments. */ for (argc = 0; argv[argc] != NULL; argc++) ; /* Allocate new argument vector. */ new_argv = XMALLOC (char *, argc + 1); /* Put quoted arguments into the new argument vector. */ for (i = 0; i < argc; i++) { const char *string = argv[i]; if (string[0] == '\0') new_argv[i] = xstrdup ("\"\""); else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) { int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); size_t length; unsigned int backslashes; const char *s; char *quoted_string; char *p; length = 0; backslashes = 0; if (quote_around) length++; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') length += backslashes + 1; length++; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) length += backslashes + 1; quoted_string = XMALLOC (char, length + 1); p = quoted_string; backslashes = 0; if (quote_around) *p++ = '"'; for (s = string; *s != '\0'; s++) { char c = *s; if (c == '"') { unsigned int j; for (j = backslashes + 1; j > 0; j--) *p++ = '\\'; } *p++ = c; if (c == '\\') backslashes++; else backslashes = 0; } if (quote_around) { unsigned int j; for (j = backslashes; j > 0; j--) *p++ = '\\'; *p++ = '"'; } *p = '\0'; new_argv[i] = quoted_string; } else new_argv[i] = (char *) string; } new_argv[argc] = NULL; return new_argv; } EOF ;; esac cat <<"EOF" void lt_dump_script (FILE* f) { EOF func_emit_wrapper yes | $SED -e 's/\([\\"]\)/\\\1/g' \ -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' cat <<"EOF" } EOF } # end: func_emit_cwrapperexe_src # func_win32_import_lib_p ARG # True if ARG is an import lib, as indicated by $file_magic_cmd func_win32_import_lib_p () { $opt_debug case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in *import*) : ;; *) false ;; esac } # func_mode_link arg... func_mode_link () { $opt_debug case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) # 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 invocation. # 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 base_compile="$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` inst_prefix_dir= new_inherited_linker_flags= avoid_version=no bindir= dlfiles= dlprefiles= dlself=no export_dynamic=no export_symbols= export_symbols_regex= generated= libobjs= ltlibs= module=no no_install=no objs= non_pic_objects= precious_files_regex= prefer_static_libs=no preload=no prev= prevarg= release= rpath= xrpath= perm_rpath= temp_rpath= thread_safe=no vinfo= vinfo_number=no weak_libs= single_module="${wl}-single_module" func_infer_tag $base_compile # We need to know -static, to get the right output filenames. for arg do case $arg in -shared) test "$build_libtool_libs" != yes && \ func_fatal_configuration "can not build a shared library" build_old_libs=no break ;; -all-static | -static | -static-libtool-libs) case $arg in -all-static) if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then func_warning "complete static linking is impossible in this configuration" fi if test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; -static) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=built ;; -static-libtool-libs) if test -z "$pic_flag" && test -n "$link_static_flag"; then dlopen_self=$dlopen_self_static fi prefer_static_libs=yes ;; esac build_libtool_libs=no build_old_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 func_quote_for_eval "$arg" qarg=$func_quote_for_eval_unquoted_result func_append libtool_args " $func_quote_for_eval_result" # If the previous option needs an argument, assign it. if test -n "$prev"; then case $prev in output) func_append compile_command " @OUTPUT@" func_append finalize_command " @OUTPUT@" ;; esac case $prev in bindir) bindir="$arg" prev= continue ;; dlfiles|dlprefiles) if test "$preload" = no; then # Add the symbol object into the linking commands. func_append compile_command " @SYMFILE@" func_append 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 func_append dlfiles " $arg" else func_append dlprefiles " $arg" fi prev= continue ;; esac ;; expsyms) export_symbols="$arg" test -f "$arg" \ || func_fatal_error "symbol file \`$arg' does not exist" prev= continue ;; expsyms_regex) export_symbols_regex="$arg" prev= continue ;; framework) case $host in *-*-darwin*) case "$deplibs " in *" $qarg.ltframework "*) ;; *) func_append deplibs " $qarg.ltframework" # this is fixed later ;; esac ;; esac prev= continue ;; inst_prefix) inst_prefix_dir="$arg" prev= continue ;; objectlist) if test -f "$arg"; then save_arg=$arg moreargs= for fil in `cat "$save_arg"` do # func_append moreargs " $fil" arg=$fil # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi done else func_fatal_error "link input file \`$arg' does not exist" fi arg=$save_arg prev= continue ;; precious_regex) precious_files_regex="$arg" prev= continue ;; release) release="-$arg" prev= continue ;; rpath | xrpath) # We need an absolute path. case $arg in [\\/]* | [A-Za-z]:[\\/]*) ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac if test "$prev" = rpath; then case "$rpath " in *" $arg "*) ;; *) func_append rpath " $arg" ;; esac else case "$xrpath " in *" $arg "*) ;; *) func_append xrpath " $arg" ;; esac fi prev= continue ;; shrext) shrext_cmds="$arg" prev= continue ;; weak) func_append weak_libs " $arg" prev= continue ;; xcclinker) func_append linker_flags " $qarg" func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xcompiler) func_append compiler_flags " $qarg" prev= func_append compile_command " $qarg" func_append finalize_command " $qarg" continue ;; xlinker) func_append linker_flags " $qarg" func_append compiler_flags " $wl$qarg" prev= func_append compile_command " $wl$qarg" func_append finalize_command " $wl$qarg" continue ;; *) eval "$prev=\"\$arg\"" prev= continue ;; esac fi # test -n "$prev" prevarg="$arg" case $arg in -all-static) if test -n "$link_static_flag"; then # See comment for -static flag below, for more details. func_append compile_command " $link_static_flag" func_append finalize_command " $link_static_flag" fi continue ;; -allow-undefined) # FIXME: remove this flag sometime in the future. func_fatal_error "\`-allow-undefined' must not be used because it is the default" ;; -avoid-version) avoid_version=yes continue ;; -bindir) prev=bindir 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 func_fatal_error "more than one -exported-symbols argument is not allowed" fi if test "X$arg" = "X-export-symbols"; then prev=expsyms else prev=expsyms_regex fi continue ;; -framework) prev=framework continue ;; -inst-prefix-dir) prev=inst_prefix continue ;; # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* # so, if we see these flags be careful not to treat them like -L -L[A-Z][A-Z]*:*) case $with_gcc/$host in no/*-*-irix* | /*-*-irix*) func_append compile_command " $arg" func_append finalize_command " $arg" ;; esac continue ;; -L*) func_stripname "-L" '' "$arg" if test -z "$func_stripname_result"; then if test "$#" -gt 0; then func_fatal_error "require no space between \`-L' and \`$1'" else func_fatal_error "need path for \`-L' option" fi fi func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; *) absdir=`cd "$dir" && pwd` test -z "$absdir" && \ func_fatal_error "cannot determine absolute directory name of \`$dir'" dir="$absdir" ;; esac case "$deplibs " in *" -L$dir "* | *" $arg "*) # Will only happen for absolute or sysroot arguments ;; *) # Preserve sysroot, but never include relative directories case $dir in [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; *) func_append deplibs " -L$dir" ;; esac func_append lib_search_path " $dir" ;; esac case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` case :$dllsearchpath: in *":$dir:"*) ;; ::) dllsearchpath=$dir;; *) func_append dllsearchpath ":$dir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; esac ;; esac continue ;; -l*) if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) # These systems don't actually have a C or math library (as such) continue ;; *-*-os2*) # These systems don't actually have a C library (as such) test "X$arg" = "X-lc" && continue ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. test "X$arg" = "X-lc" && continue ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C and math libraries are in the System framework func_append deplibs " System.ltframework" continue ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype test "X$arg" = "X-lc" && continue ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work test "X$arg" = "X-lc" && continue ;; esac elif test "X$arg" = "X-lc_r"; then case $host in *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc_r directly, use -pthread flag. continue ;; esac fi func_append deplibs " $arg" continue ;; -module) module=yes continue ;; # Tru64 UNIX uses -model [arg] to determine the layout of C++ # classes, name mangling, and exception handling. # Darwin uses the -arch flag to determine output architecture. -model|-arch|-isysroot|--sysroot) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" prev=xcompiler continue ;; -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) func_append compiler_flags " $arg" func_append compile_command " $arg" func_append finalize_command " $arg" case "$new_inherited_linker_flags " in *" $arg "*) ;; * ) func_append new_inherited_linker_flags " $arg" ;; esac continue ;; -multi_module) single_module="${wl}-multi_module" continue ;; -no-fast-install) fast_install=no continue ;; -no-install) case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) # The PATH hackery in wrapper scripts is required on Windows # and Darwin in order for the loader to find any dlls it needs. func_warning "\`-no-install' is ignored for $host" func_warning "assuming \`-no-fast-install' instead" fast_install=no ;; *) no_install=yes ;; esac continue ;; -no-undefined) allow_undefined=no continue ;; -objectlist) prev=objectlist continue ;; -o) prev=output ;; -precious-files-regex) prev=precious_regex continue ;; -release) prev=release continue ;; -rpath) prev=rpath continue ;; -R) prev=xrpath continue ;; -R*) func_stripname '-R' '' "$arg" dir=$func_stripname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) ;; =*) func_stripname '=' '' "$dir" dir=$lt_sysroot$func_stripname_result ;; *) func_fatal_error "only absolute run-paths are allowed" ;; esac case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac continue ;; -shared) # The effects of -shared are defined in a previous loop. continue ;; -shrext) prev=shrext continue ;; -static | -static-libtool-libs) # The effects of -static are defined in a previous loop. # We used to do the same as -all-static on platforms that # didn't have a PIC flag, but the assumption that the effects # would be equivalent was wrong. It would break on at least # Digital Unix and AIX. continue ;; -thread-safe) thread_safe=yes continue ;; -version-info) prev=vinfo continue ;; -version-number) prev=vinfo vinfo_number=yes continue ;; -weak) prev=weak continue ;; -Wc,*) func_stripname '-Wc,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $func_quote_for_eval_result" func_append compiler_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Wl,*) func_stripname '-Wl,' '' "$arg" args=$func_stripname_result arg= save_ifs="$IFS"; IFS=',' for flag in $args; do IFS="$save_ifs" func_quote_for_eval "$flag" func_append arg " $wl$func_quote_for_eval_result" func_append compiler_flags " $wl$func_quote_for_eval_result" func_append linker_flags " $func_quote_for_eval_result" done IFS="$save_ifs" func_stripname ' ' '' "$arg" arg=$func_stripname_result ;; -Xcompiler) prev=xcompiler continue ;; -Xlinker) prev=xlinker continue ;; -XCClinker) prev=xcclinker continue ;; # -msg_* for osf cc -msg_*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; # Flags to be passed through unchanged, with rationale: # -64, -mips[0-9] enable 64-bit mode for the SGI compiler # -r[0-9][0-9]* specify processor for the SGI compiler # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler # +DA*, +DD* enable 64-bit mode for the HP compiler # -q* compiler args for the IBM compiler # -m*, -t[45]*, -txscale* architecture-specific flags for GCC # -F/path path to uninstalled frameworks, gcc on darwin # -p, -pg, --coverage, -fprofile-* profiling flags for GCC # @file GCC response files # -tp=* Portland pgcc target processor selection # --sysroot=* for sysroot support # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -O*|-flto*|-fwhopr*|-fuse-linker-plugin) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" func_append compile_command " $arg" func_append finalize_command " $arg" func_append compiler_flags " $arg" continue ;; # Some other compiler flag. -* | +*) func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; *.$objext) # A standard object. func_append objs " $arg" ;; *.lo) # A libtool-controlled object. # Check to see that this really is a libtool object. if func_lalib_unsafe_p "$arg"; then pic_object= non_pic_object= # Read the .lo file func_source "$arg" if test -z "$pic_object" || test -z "$non_pic_object" || test "$pic_object" = none && test "$non_pic_object" = none; then func_fatal_error "cannot find name of object for \`$arg'" fi # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" if test "$pic_object" != none; then # Prepend the subdirectory the object is found in. pic_object="$xdir$pic_object" if test "$prev" = dlfiles; then if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then func_append dlfiles " $pic_object" prev= continue else # If libtool objects are unsupported, then we need to preload. prev=dlprefiles fi fi # CHECK ME: I think I busted this. -Ossama if test "$prev" = dlprefiles; then # Preload the old-style object. func_append dlprefiles " $pic_object" prev= fi # A PIC object. func_append libobjs " $pic_object" arg="$pic_object" fi # Non-PIC object. if test "$non_pic_object" != none; then # Prepend the subdirectory the object is found in. non_pic_object="$xdir$non_pic_object" # A standard non-PIC object func_append non_pic_objects " $non_pic_object" if test -z "$pic_object" || test "$pic_object" = none ; then arg="$non_pic_object" fi else # If the PIC object exists, use it instead. # $xdir was prepended to $pic_object above. non_pic_object="$pic_object" func_append non_pic_objects " $non_pic_object" fi else # Only an error if not doing a dry-run. if $opt_dry_run; then # Extract subdirectory from the argument. func_dirname "$arg" "/" "" xdir="$func_dirname_result" func_lo2o "$arg" pic_object=$xdir$objdir/$func_lo2o_result non_pic_object=$xdir$func_lo2o_result func_append libobjs " $pic_object" func_append non_pic_objects " $non_pic_object" else func_fatal_error "\`$arg' is not a valid libtool object" fi fi ;; *.$libext) # An archive. func_append deplibs " $arg" func_append old_deplibs " $arg" continue ;; *.la) # A libtool-controlled library. func_resolve_sysroot "$arg" if test "$prev" = dlfiles; then # This library was specified with -dlopen. func_append dlfiles " $func_resolve_sysroot_result" prev= elif test "$prev" = dlprefiles; then # The library was specified with -dlpreopen. func_append dlprefiles " $func_resolve_sysroot_result" prev= else func_append deplibs " $func_resolve_sysroot_result" fi continue ;; # Some other compiler argument. *) # Unknown arguments in both finalize_command and compile_command need # to be aesthetically quoted because they are evaled later. func_quote_for_eval "$arg" arg="$func_quote_for_eval_result" ;; esac # arg # Now actually substitute the argument into the commands. if test -n "$arg"; then func_append compile_command " $arg" func_append finalize_command " $arg" fi done # argument parsing loop test -n "$prev" && \ func_fatal_help "the \`$prevarg' option requires an argument" if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then eval arg=\"$export_dynamic_flag_spec\" func_append compile_command " $arg" func_append finalize_command " $arg" fi oldlibs= # calculate the name of the file, without its directory func_basename "$output" outputname="$func_basename_result" libobjs_save="$libobjs" if test -n "$shlibpath_var"; then # get the directories listed in $shlibpath_var eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'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\" func_dirname "$output" "/" "" output_objdir="$func_dirname_result$objdir" func_to_tool_file "$output_objdir/" tool_output_objdir=$func_to_tool_file_result # Create the object directory. func_mkdir_p "$output_objdir" # Determine the type of output case $output in "") func_fatal_help "you must specify an output file" ;; *.$libext) linkmode=oldlib ;; *.lo | *.$objext) linkmode=obj ;; *.la) linkmode=lib ;; *) linkmode=prog ;; # Anything else should be a program. esac specialdeplibs= libs= # Find all interdependent deplibs by searching for libraries # that are linked more than once (e.g. -la -lb -la) for deplib in $deplibs; do if $opt_preserve_dup_deps ; then case "$libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append libs " $deplib" done if test "$linkmode" = lib; then libs="$predeps $libs $compiler_lib_search_path $postdeps" # Compute libraries that are listed more than once in $predeps # $postdeps and mark them as special (i.e., whose duplicates are # not to be eliminated). pre_post_deps= if $opt_duplicate_compiler_generated_deps; then for pre_post_dep in $predeps $postdeps; do case "$pre_post_deps " in *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; esac func_append pre_post_deps " $pre_post_dep" done fi pre_post_deps= fi deplibs= newdependency_libs= newlib_search_path= need_relink=no # whether we're linking any uninstalled libtool libraries notinst_deplibs= # not-installed libtool libraries notinst_path= # paths that contain not-installed libtool libraries case $linkmode in lib) passes="conv dlpreopen link" for file in $dlfiles $dlprefiles; do case $file in *.la) ;; *) func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" ;; esac done ;; prog) compile_deplibs= finalize_deplibs= alldeplibs=no newdlfiles= newdlprefiles= passes="conv scan dlopen dlpreopen link" ;; *) passes="conv" ;; esac for pass in $passes; do # The preopen pass in lib mode reverses $deplibs; put it back here # so that -L comes before libs that need it for instance... if test "$linkmode,$pass" = "lib,link"; then ## FIXME: Find the place where the list is rebuilt in the wrong ## order, and fix it there properly tmp_deplibs= for deplib in $deplibs; do tmp_deplibs="$deplib $tmp_deplibs" done deplibs="$tmp_deplibs" fi if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan"; then libs="$deplibs" deplibs= fi if test "$linkmode" = prog; then case $pass in dlopen) libs="$dlfiles" ;; dlpreopen) libs="$dlprefiles" ;; link) libs="$deplibs %DEPLIBS%" test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" ;; esac fi if test "$linkmode,$pass" = "lib,dlpreopen"; then # Collect and forward deplibs of preopened libtool libs for lib in $dlprefiles; do # Ignore non-libtool-libs dependency_libs= func_resolve_sysroot "$lib" case $lib in *.la) func_source "$func_resolve_sysroot_result" ;; esac # Collect preopened libtool deplibs, except any this library # has declared as weak libs for deplib in $dependency_libs; do func_basename "$deplib" deplib_base=$func_basename_result case " $weak_libs " in *" $deplib_base "*) ;; *) func_append deplibs " $deplib" ;; esac done done libs="$dlprefiles" fi if test "$pass" = dlopen; then # Collect dlpreopened libraries save_deplibs="$deplibs" deplibs= fi for deplib in $libs; do lib= found=no case $deplib in -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append compiler_flags " $deplib" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -l*) if test "$linkmode" != lib && test "$linkmode" != prog; then func_warning "\`-l' is ignored for archives/objects" continue fi func_stripname '-l' '' "$deplib" name=$func_stripname_result if test "$linkmode" = lib; then searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" else searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" fi for searchdir in $searchdirs; do for search_ext in .la $std_shrext .so .a; do # Search the libtool library lib="$searchdir/lib${name}${search_ext}" if test -f "$lib"; then if test "$search_ext" = ".la"; then found=yes else found=no fi break 2 fi done done if test "$found" != yes; then # deplib doesn't seem to be a libtool library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue else # deplib is a libtool library # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, # We need to do some special things here, and not later. if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $deplib "*) if func_lalib_p "$lib"; then library_names= old_library= func_source "$lib" for l in $old_library $library_names; do ll="$l" done if test "X$ll" = "X$old_library" ; then # only static version available found=no func_dirname "$lib" "" "." ladir="$func_dirname_result" lib=$ladir/$old_library if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" fi continue fi fi ;; *) ;; esac fi fi ;; # -l *.ltframework) if test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else deplibs="$deplib $deplibs" if test "$linkmode" = lib ; then case "$new_inherited_linker_flags " in *" $deplib "*) ;; * ) func_append new_inherited_linker_flags " $deplib" ;; esac fi fi continue ;; -L*) case $linkmode in lib) deplibs="$deplib $deplibs" test "$pass" = conv && continue newdependency_libs="$deplib $newdependency_libs" func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; prog) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi if test "$pass" = scan; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; *) func_warning "\`-L' is ignored for archives/objects" ;; esac # linkmode continue ;; # -L -R*) if test "$pass" = link; then func_stripname '-R' '' "$deplib" func_resolve_sysroot "$func_stripname_result" dir=$func_resolve_sysroot_result # Make sure the xrpath contains only unique directories. case "$xrpath " in *" $dir "*) ;; *) func_append xrpath " $dir" ;; esac fi deplibs="$deplib $deplibs" continue ;; *.la) func_resolve_sysroot "$deplib" lib=$func_resolve_sysroot_result ;; *.$libext) if test "$pass" = conv; then deplibs="$deplib $deplibs" continue fi case $linkmode in lib) # Linking convenience modules into shared libraries is allowed, # but linking other static libraries is non-portable. case " $dlpreconveniencelibs " in *" $deplib "*) ;; *) valid_a_lib=no case $deplibs_check_method in match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | $EGREP "$match_pattern_regex" > /dev/null; then valid_a_lib=yes fi ;; pass_all) valid_a_lib=yes ;; esac if test "$valid_a_lib" != yes; then echo $ECHO "*** Warning: Trying to link with static lib archive $deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because the file extensions .$libext of this argument makes me believe" echo "*** that it is just a static archive that I should not use here." else echo $ECHO "*** Warning: Linking the shared library $output against the" $ECHO "*** static library $deplib is not portable!" deplibs="$deplib $deplibs" fi ;; esac continue ;; prog) if test "$pass" != link; then deplibs="$deplib $deplibs" else compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" fi continue ;; esac # linkmode ;; # *.$libext *.lo | *.$objext) if test "$pass" = conv; then deplibs="$deplib $deplibs" elif test "$linkmode" = prog; then if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlopen support or we're linking statically, # we need to preload. func_append newdlprefiles " $deplib" compile_deplibs="$deplib $compile_deplibs" finalize_deplibs="$deplib $finalize_deplibs" else func_append newdlfiles " $deplib" fi fi continue ;; %DEPLIBS%) alldeplibs=yes continue ;; esac # case $deplib if test "$found" = yes || test -f "$lib"; then : else func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" fi # Check to see that this really is a libtool archive. func_lalib_unsafe_p "$lib" \ || func_fatal_error "\`$lib' is not a valid libtool archive" func_dirname "$lib" "" "." ladir="$func_dirname_result" dlname= dlopen= dlpreopen= libdir= library_names= old_library= inherited_linker_flags= # If the library was installed with an old release of libtool, # it will not redefine variables installed, or shouldnotlink installed=yes shouldnotlink=no avoidtemprpath= # Read the .la file func_source "$lib" # Convert "-framework foo" to "foo.ltframework" if test -n "$inherited_linker_flags"; then tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do case " $new_inherited_linker_flags " in *" $tmp_inherited_linker_flag "*) ;; *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; esac done fi dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` if test "$linkmode,$pass" = "lib,link" || test "$linkmode,$pass" = "prog,scan" || { test "$linkmode" != prog && test "$linkmode" != lib; }; then test -n "$dlopen" && func_append dlfiles " $dlopen" test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" fi if test "$pass" = conv; then # Only check for convenience libraries deplibs="$lib $deplibs" if test -z "$libdir"; then if test -z "$old_library"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # It is a libtool convenience library, so add in its objects. func_append convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library" tmp_libs= for deplib in $dependency_libs; do deplibs="$deplib $deplibs" if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done elif test "$linkmode" != prog && test "$linkmode" != lib; then func_fatal_error "\`$lib' is not a convenience library" fi continue fi # $pass = conv # Get the name of the library we link against. linklib= if test -n "$old_library" && { test "$prefer_static_libs" = yes || test "$prefer_static_libs,$installed" = "built,no"; }; then linklib=$old_library else for l in $old_library $library_names; do linklib="$l" done fi if test -z "$linklib"; then func_fatal_error "cannot find name of link library for \`$lib'" fi # This library was specified with -dlopen. if test "$pass" = dlopen; then if test -z "$libdir"; then func_fatal_error "cannot -dlopen a convenience library: \`$lib'" fi if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then # If there is no dlname, no dlopen support or we're linking # statically, we need to preload. We also need to preload any # dependent libraries so libltdl's deplib preloader doesn't # bomb out in the load deplibs phase. func_append dlprefiles " $lib $dependency_libs" else func_append newdlfiles " $lib" fi continue fi # $pass = dlopen # We need an absolute path. case $ladir in [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; *) abs_ladir=`cd "$ladir" && pwd` if test -z "$abs_ladir"; then func_warning "cannot determine absolute directory name of \`$ladir'" func_warning "passing it literally to the linker, although it might fail" abs_ladir="$ladir" fi ;; esac func_basename "$lib" laname="$func_basename_result" # Find the relevant object directory and library name. if test "X$installed" = Xyes; then if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then func_warning "library \`$lib' was moved." dir="$ladir" absdir="$abs_ladir" libdir="$abs_ladir" else dir="$lt_sysroot$libdir" absdir="$lt_sysroot$libdir" fi test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes else if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then dir="$ladir" absdir="$abs_ladir" # Remove this search path later func_append notinst_path " $abs_ladir" else dir="$ladir/$objdir" absdir="$abs_ladir/$objdir" # Remove this search path later func_append notinst_path " $abs_ladir" fi fi # $installed = yes func_stripname 'lib' '.la' "$laname" name=$func_stripname_result # This library was specified with -dlpreopen. if test "$pass" = dlpreopen; then if test -z "$libdir" && test "$linkmode" = prog; then func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" fi case "$host" in # special handling for platforms with PE-DLLs. *cygwin* | *mingw* | *cegcc* ) # Linker will automatically link against shared library if both # static and shared are present. Therefore, ensure we extract # symbols from the import library if a shared library is present # (otherwise, the dlopen module name will be incorrect). We do # this by putting the import library name into $newdlprefiles. # We recover the dlopen module name by 'saving' the la file # name in a special purpose variable, and (later) extracting the # dlname from the la file. if test -n "$dlname"; then func_tr_sh "$dir/$linklib" eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" func_append newdlprefiles " $dir/$linklib" else func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" fi ;; * ) # Prefer using a static library (so that no silly _DYNAMIC symbols # are required to link). if test -n "$old_library"; then func_append newdlprefiles " $dir/$old_library" # Keep a list of preopened convenience libraries to check # that they are being used correctly in the link pass. test -z "$libdir" && \ func_append dlpreconveniencelibs " $dir/$old_library" # Otherwise, use the dlname, so that lt_dlopen finds it. elif test -n "$dlname"; then func_append newdlprefiles " $dir/$dlname" else func_append newdlprefiles " $dir/$linklib" fi ;; esac fi # $pass = dlpreopen if test -z "$libdir"; then # Link the convenience library if test "$linkmode" = lib; then deplibs="$dir/$old_library $deplibs" elif test "$linkmode,$pass" = "prog,link"; then compile_deplibs="$dir/$old_library $compile_deplibs" finalize_deplibs="$dir/$old_library $finalize_deplibs" else deplibs="$lib $deplibs" # used for prog,scan pass fi continue fi if test "$linkmode" = prog && test "$pass" != link; then func_append newlib_search_path " $ladir" deplibs="$lib $deplibs" linkalldeplibs=no if test "$link_all_deplibs" != no || test -z "$library_names" || test "$build_libtool_libs" = no; then linkalldeplibs=yes fi tmp_libs= for deplib in $dependency_libs; do case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result" func_append newlib_search_path " $func_resolve_sysroot_result" ;; esac # Need to link against all dependency_libs? if test "$linkalldeplibs" = yes; then deplibs="$deplib $deplibs" else # Need to hardcode shared library paths # or/and link against static libraries newdependency_libs="$deplib $newdependency_libs" fi if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $deplib "*) func_append specialdeplibs " $deplib" ;; esac fi func_append tmp_libs " $deplib" done # for deplib continue fi # $linkmode = prog... if test "$linkmode,$pass" = "prog,link"; then if test -n "$library_names" && { { test "$prefer_static_libs" = no || test "$prefer_static_libs,$installed" = "built,yes"; } || test -z "$old_library"; }; then # We need to hardcode the library path if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then # Make sure the rpath contains only unique directories. case "$temp_rpath:" in *"$absdir:"*) ;; *) func_append temp_rpath "$absdir:" ;; 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 "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi # $linkmode,$pass = prog,link... if test "$alldeplibs" = yes && { test "$deplibs_check_method" = pass_all || { test "$build_libtool_libs" = yes && test -n "$library_names"; }; }; then # We only need to search for static libraries continue fi fi link_static=no # Whether the deplib will be linked statically use_static_libs=$prefer_static_libs if test "$use_static_libs" = built && test "$installed" = yes; then use_static_libs=no fi if test -n "$library_names" && { test "$use_static_libs" = no || test -z "$old_library"; }; then case $host in *cygwin* | *mingw* | *cegcc*) # No point in relinking DLLs because paths are not encoded func_append notinst_deplibs " $lib" need_relink=no ;; *) if test "$installed" = no; then func_append notinst_deplibs " $lib" need_relink=yes fi ;; esac # This is a shared library # Warn about portability, can't link against -module's on some # systems (darwin). Don't bleat about dlopened modules though! dlopenmodule="" for dlpremoduletest in $dlprefiles; do if test "X$dlpremoduletest" = "X$lib"; then dlopenmodule="$dlpremoduletest" break fi done if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then echo if test "$linkmode" = prog; then $ECHO "*** Warning: Linking the executable $output against the loadable module" else $ECHO "*** Warning: Linking the shared library $output against the loadable module" fi $ECHO "*** $linklib is not portable!" fi if test "$linkmode" = lib && test "$hardcode_into_libs" = yes; then # Hardcode the library path. # Skip directories that are in the system default run-time # search path. case " $sys_lib_dlsearch_path " in *" $absdir "*) ;; *) case "$compile_rpath " in *" $absdir "*) ;; *) func_append compile_rpath " $absdir" ;; esac ;; esac case " $sys_lib_dlsearch_path " in *" $libdir "*) ;; *) case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac ;; esac fi if test -n "$old_archive_from_expsyms_cmds"; then # figure out the soname set dummy $library_names shift realname="$1" shift libname=`eval "\\$ECHO \"$libname_spec\""` # use dlname if we got it. it's perfectly good, no? if test -n "$dlname"; then soname="$dlname" elif test -n "$soname_spec"; then # bleh windows case $host in *cygwin* | mingw* | *cegcc*) func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; esac eval soname=\"$soname_spec\" else soname="$realname" fi # Make a new name for the extract_expsyms_cmds to use soroot="$soname" func_basename "$soroot" soname="$func_basename_result" func_stripname 'lib' '.dll' "$soname" newlib=libimp-$func_stripname_result.a # If the library has no export list, then create one now if test -f "$output_objdir/$soname-def"; then : else func_verbose "extracting exported symbol list from \`$soname'" func_execute_cmds "$extract_expsyms_cmds" 'exit $?' fi # Create $newlib if test -f "$output_objdir/$newlib"; then :; else func_verbose "generating import library for \`$soname'" func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' fi # make sure the library variables are pointing to the new library dir=$output_objdir linklib=$newlib fi # test -n "$old_archive_from_expsyms_cmds" if test "$linkmode" = prog || test "$opt_mode" != relink; then add_shlibpath= add_dir= add= lib_linked=yes case $hardcode_action in immediate | unsupported) if test "$hardcode_direct" = no; then add="$dir/$linklib" case $host in *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; *-*-sysv4*uw2*) add_dir="-L$dir" ;; *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ *-*-unixware7*) add_dir="-L$dir" ;; *-*-darwin* ) # if the lib is a (non-dlopened) module then we can not # link against it, someone is ignoring the earlier warnings if /usr/bin/file -L $add 2> /dev/null | $GREP ": [^:]* bundle" >/dev/null ; then if test "X$dlopenmodule" != "X$lib"; then $ECHO "*** Warning: lib $linklib is a module, not a shared library" if test -z "$old_library" ; then echo echo "*** And there doesn't seem to be a static archive available" echo "*** The link will probably fail, sorry" else add="$dir/$old_library" fi elif test -n "$old_library"; then add="$dir/$old_library" fi fi esac elif test "$hardcode_minus_L" = no; then case $host in *-*-sunos*) add_shlibpath="$dir" ;; esac add_dir="-L$dir" add="-l$name" elif test "$hardcode_shlibpath_var" = no; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; relink) if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$dir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$dir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then add_shlibpath="$dir" add="-l$name" else lib_linked=no fi ;; *) lib_linked=no ;; esac if test "$lib_linked" != yes; then func_fatal_configuration "unsupported hardcode properties" fi if test -n "$add_shlibpath"; then case :$compile_shlibpath: in *":$add_shlibpath:"*) ;; *) func_append compile_shlibpath "$add_shlibpath:" ;; esac fi if test "$linkmode" = prog; then test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" test -n "$add" && compile_deplibs="$add $compile_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" if test "$hardcode_direct" != yes && test "$hardcode_minus_L" != yes && test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac fi fi fi if test "$linkmode" = prog || test "$opt_mode" = relink; then add_shlibpath= add_dir= add= # Finalize command for both is simple: just hardcode it. if test "$hardcode_direct" = yes && test "$hardcode_direct_absolute" = no; then add="$libdir/$linklib" elif test "$hardcode_minus_L" = yes; then add_dir="-L$libdir" add="-l$name" elif test "$hardcode_shlibpath_var" = yes; then case :$finalize_shlibpath: in *":$libdir:"*) ;; *) func_append finalize_shlibpath "$libdir:" ;; esac add="-l$name" elif test "$hardcode_automatic" = yes; then if test -n "$inst_prefix_dir" && test -f "$inst_prefix_dir$libdir/$linklib" ; then add="$inst_prefix_dir$libdir/$linklib" else add="$libdir/$linklib" fi else # We cannot seem to hardcode it, guess we'll fake it. add_dir="-L$libdir" # Try looking first in the location we're being installed to. if test -n "$inst_prefix_dir"; then case $libdir in [\\/]*) func_append add_dir " -L$inst_prefix_dir$libdir" ;; esac fi add="-l$name" fi if test "$linkmode" = prog; then test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" test -n "$add" && finalize_deplibs="$add $finalize_deplibs" else test -n "$add_dir" && deplibs="$add_dir $deplibs" test -n "$add" && deplibs="$add $deplibs" fi fi elif test "$linkmode" = prog; then # Here we assume that one of hardcode_direct or hardcode_minus_L # is not unsupported. This is valid on all known static and # shared platforms. if test "$hardcode_direct" != unsupported; then test -n "$old_library" && linklib="$old_library" compile_deplibs="$dir/$linklib $compile_deplibs" finalize_deplibs="$dir/$linklib $finalize_deplibs" else compile_deplibs="-l$name -L$dir $compile_deplibs" finalize_deplibs="-l$name -L$dir $finalize_deplibs" fi elif test "$build_libtool_libs" = yes; then # Not a shared library if test "$deplibs_check_method" != pass_all; then # We're trying link a shared library against a static one # but the system doesn't support it. # Just print a warning and add the library to dependency_libs so # that the program can be linked against the static library. echo $ECHO "*** Warning: This system can not link to static lib archive $lib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have." if test "$module" = yes; then echo "*** But as you try to build a module library, libtool will still create " echo "*** a static module, that should work as long as the dlopening application" echo "*** is linked with the -dlopen flag to resolve symbols at runtime." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi else deplibs="$dir/$old_library $deplibs" link_static=yes fi fi # link shared/static library? if test "$linkmode" = lib; then if test -n "$dependency_libs" && { test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes || test "$link_static" = yes; }; then # Extract -R from dependency_libs temp_deplibs= for libdir in $dependency_libs; do case $libdir in -R*) func_stripname '-R' '' "$libdir" temp_xrpath=$func_stripname_result case " $xrpath " in *" $temp_xrpath "*) ;; *) func_append xrpath " $temp_xrpath";; esac;; *) func_append temp_deplibs " $libdir";; esac done dependency_libs="$temp_deplibs" fi func_append newlib_search_path " $absdir" # Link against this library test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" # ... and its dependency_libs tmp_libs= for deplib in $dependency_libs; do newdependency_libs="$deplib $newdependency_libs" case $deplib in -L*) func_stripname '-L' '' "$deplib" func_resolve_sysroot "$func_stripname_result";; *) func_resolve_sysroot "$deplib" ;; esac if $opt_preserve_dup_deps ; then case "$tmp_libs " in *" $func_resolve_sysroot_result "*) func_append specialdeplibs " $func_resolve_sysroot_result" ;; esac fi func_append tmp_libs " $func_resolve_sysroot_result" done if test "$link_all_deplibs" != no; then # Add the search paths of all dependency libraries for deplib in $dependency_libs; do path= case $deplib in -L*) path="$deplib" ;; *.la) func_resolve_sysroot "$deplib" deplib=$func_resolve_sysroot_result func_dirname "$deplib" "" "." dir=$func_dirname_result # We need an absolute path. case $dir in [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; *) absdir=`cd "$dir" && pwd` if test -z "$absdir"; then func_warning "cannot determine absolute directory name of \`$dir'" absdir="$dir" fi ;; esac if $GREP "^installed=no" $deplib > /dev/null; then case $host in *-*-darwin*) depdepl= eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` if test -n "$deplibrary_names" ; then for tmp in $deplibrary_names ; do depdepl=$tmp done if test -f "$absdir/$objdir/$depdepl" ; then depdepl="$absdir/$objdir/$depdepl" darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` if test -z "$darwin_install_name"; then darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` fi func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" path= fi fi ;; *) path="-L$absdir/$objdir" ;; esac else eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" test "$absdir" != "$libdir" && \ func_warning "\`$deplib' seems to be moved" path="-L$absdir" fi ;; esac case " $deplibs " in *" $path "*) ;; *) deplibs="$path $deplibs" ;; esac done fi # link_all_deplibs != no fi # linkmode = lib done # for deplib in $libs if test "$pass" = link; then if test "$linkmode" = "prog"; then compile_deplibs="$new_inherited_linker_flags $compile_deplibs" finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" else compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` fi fi dependency_libs="$newdependency_libs" if test "$pass" = dlpreopen; then # Link the dlpreopened libraries before other libraries for deplib in $save_deplibs; do deplibs="$deplib $deplibs" done fi if test "$pass" != dlopen; then if test "$pass" != conv; then # Make sure lib_search_path contains only unique directories. lib_search_path= for dir in $newlib_search_path; do case "$lib_search_path " in *" $dir "*) ;; *) func_append lib_search_path " $dir" ;; esac done newlib_search_path= fi if test "$linkmode,$pass" != "prog,link"; then vars="deplibs" else vars="compile_deplibs finalize_deplibs" fi for var in $vars dependency_libs; do # Add libraries to $var in reverse order eval tmp_libs=\"\$$var\" new_libs= for deplib in $tmp_libs; do # FIXME: Pedantically, this is the right thing to do, so # that some nasty dependency loop isn't accidentally # broken: #new_libs="$deplib $new_libs" # Pragmatically, this seems to cause very few problems in # practice: case $deplib in -L*) new_libs="$deplib $new_libs" ;; -R*) ;; *) # And here is the reason: when a library appears more # than once as an explicit dependence of a library, or # is implicitly linked in more than once by the # compiler, it is considered special, and multiple # occurrences thereof are not removed. Compare this # with having the same library being listed as a # dependency of multiple other libraries: in this case, # we know (pedantically, we assume) the library does not # need to be listed more than once, so we keep only the # last copy. This is not always right, but it is rare # enough that we require users that really mean to play # such unportable linking tricks to link the library # using -Wl,-lname, so that libtool does not consider it # for duplicate removal. case " $specialdeplibs " in *" $deplib "*) new_libs="$deplib $new_libs" ;; *) case " $new_libs " in *" $deplib "*) ;; *) new_libs="$deplib $new_libs" ;; esac ;; esac ;; esac done tmp_libs= for deplib in $new_libs; do case $deplib in -L*) case " $tmp_libs " in *" $deplib "*) ;; *) func_append tmp_libs " $deplib" ;; esac ;; *) func_append tmp_libs " $deplib" ;; esac done eval $var=\"$tmp_libs\" done # for var fi # Last step: remove runtime libs from dependency_libs # (they stay in deplibs) tmp_libs= for i in $dependency_libs ; do case " $predeps $postdeps $compiler_lib_search_path " in *" $i "*) i="" ;; esac if test -n "$i" ; then func_append tmp_libs " $i" fi done dependency_libs=$tmp_libs done # for pass if test "$linkmode" = prog; then dlfiles="$newdlfiles" fi if test "$linkmode" = prog || test "$linkmode" = lib; then dlprefiles="$newdlprefiles" fi case $linkmode in oldlib) if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for archives" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for archives" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for archives" test -n "$xrpath" && \ func_warning "\`-R' is ignored for archives" test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for archives" test -n "$release" && \ func_warning "\`-release' is ignored for archives" test -n "$export_symbols$export_symbols_regex" && \ func_warning "\`-export-symbols' is ignored for archives" # Now set the variables for building old libraries. build_libtool_libs=no oldlibs="$output" func_append objs "$old_deplibs" ;; lib) # Make sure we only generate libraries of the form `libNAME.la'. case $outputname in lib*) func_stripname 'lib' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" ;; *) test "$module" = no && \ func_fatal_help "libtool library \`$output' must begin with \`lib'" if test "$need_lib_prefix" != no; then # Add the "lib" prefix for modules if required func_stripname '' '.la' "$outputname" name=$func_stripname_result eval shared_ext=\"$shrext_cmds\" eval libname=\"$libname_spec\" else func_stripname '' '.la' "$outputname" libname=$func_stripname_result fi ;; esac if test -n "$objs"; then if test "$deplibs_check_method" != pass_all; then func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" else echo $ECHO "*** Warning: Linking the shared library $output against the non-libtool" $ECHO "*** objects $objs is not portable!" func_append libobjs " $objs" fi fi test "$dlself" != no && \ func_warning "\`-dlopen self' is ignored for libtool libraries" set dummy $rpath shift test "$#" -gt 1 && \ func_warning "ignoring multiple \`-rpath's for a libtool library" install_libdir="$1" oldlibs= if test -z "$rpath"; then if test "$build_libtool_libs" = yes; then # Building a libtool convenience library. # Some compilers have problems with a `.al' extension so # convenience libraries should have the same extension an # archive normally would. oldlibs="$output_objdir/$libname.$libext $oldlibs" build_libtool_libs=convenience build_old_libs=yes fi test -n "$vinfo" && \ func_warning "\`-version-info/-version-number' is ignored for convenience libraries" test -n "$release" && \ func_warning "\`-release' is ignored for convenience libraries" else # Parse the version information argument. save_ifs="$IFS"; IFS=':' set dummy $vinfo 0 0 0 shift IFS="$save_ifs" test -n "$7" && \ func_fatal_help "too many parameters to \`-version-info'" # convert absolute version numbers to libtool ages # this retains compatibility with .la files and attempts # to make the code below a bit more comprehensible case $vinfo_number in yes) number_major="$1" number_minor="$2" number_revision="$3" # # There are really only two kinds -- those that # use the current revision as the major version # and those that subtract age and use age as # a minor version. But, then there is irix # which has an extra 1 added just for fun # case $version_type in darwin|linux|osf|windows|none) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_revision" ;; freebsd-aout|freebsd-elf|qnx|sunos) current="$number_major" revision="$number_minor" age="0" ;; irix|nonstopux) func_arith $number_major + $number_minor current=$func_arith_result age="$number_minor" revision="$number_minor" lt_irix_increment=no ;; *) func_fatal_configuration "$modename: unknown library version type \`$version_type'" ;; esac ;; no) current="$1" revision="$2" age="$3" ;; esac # Check that each of the things are valid numbers. case $current in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "CURRENT \`$current' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $revision in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "REVISION \`$revision' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac case $age in 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;; *) func_error "AGE \`$age' must be a nonnegative integer" func_fatal_error "\`$vinfo' is not valid version information" ;; esac if test "$age" -gt "$current"; then func_error "AGE \`$age' is greater than the current interface number \`$current'" func_fatal_error "\`$vinfo' is not valid version information" fi # Calculate the version variables. major= versuffix= verstring= case $version_type in none) ;; darwin) # Like Linux, but with the current version available in # verstring for coding it into the library header func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" # Darwin ld doesn't like 0 for these options... func_arith $current + 1 minor_current=$func_arith_result xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" ;; freebsd-aout) major=".$current" versuffix=".$current.$revision"; ;; freebsd-elf) major=".$current" versuffix=".$current" ;; irix | nonstopux) if test "X$lt_irix_increment" = "Xno"; then func_arith $current - $age else func_arith $current - $age + 1 fi major=$func_arith_result case $version_type in nonstopux) verstring_prefix=nonstopux ;; *) verstring_prefix=sgi ;; esac verstring="$verstring_prefix$major.$revision" # Add in all the interfaces that we are compatible with. loop=$revision while test "$loop" -ne 0; do func_arith $revision - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring_prefix$major.$iface:$verstring" done # Before this point, $major must not contain `.'. major=.$major versuffix="$major.$revision" ;; linux) func_arith $current - $age major=.$func_arith_result versuffix="$major.$age.$revision" ;; osf) func_arith $current - $age major=.$func_arith_result versuffix=".$current.$age.$revision" verstring="$current.$age.$revision" # Add in all the interfaces that we are compatible with. loop=$age while test "$loop" -ne 0; do func_arith $current - $loop iface=$func_arith_result func_arith $loop - 1 loop=$func_arith_result verstring="$verstring:${iface}.0" done # Make executables depend on our current version. func_append verstring ":${current}.0" ;; qnx) major=".$current" versuffix=".$current" ;; sunos) major=".$current" versuffix=".$current.$revision" ;; windows) # Use '-' rather than '.', since we only want one # extension on DOS 8.3 filesystems. func_arith $current - $age major=$func_arith_result versuffix="-$major" ;; *) func_fatal_configuration "unknown library version type \`$version_type'" ;; esac # Clear the version info if we defaulted, and they specified a release. if test -z "$vinfo" && test -n "$release"; then major= case $version_type in darwin) # we can't check for "0.0" in archive_cmds due to quoting # problems, so we reset it completely verstring= ;; *) verstring="0.0" ;; esac if test "$need_version" = no; then versuffix= else versuffix=".0.0" fi fi # Remove version info from name if versioning should be avoided if test "$avoid_version" = yes && test "$need_version" = no; then major= versuffix= verstring="" fi # Check to see if the archive will have undefined symbols. if test "$allow_undefined" = yes; then if test "$allow_undefined_flag" = unsupported; then func_warning "undefined symbols not allowed in $host shared libraries" build_libtool_libs=no build_old_libs=yes fi else # Don't allow undefined symbols. allow_undefined_flag="$no_undefined_flag" fi fi func_generate_dlsyms "$libname" "$libname" "yes" func_append libobjs " $symfileobj" test "X$libobjs" = "X " && libobjs= if test "$opt_mode" != relink; then # Remove our outputs, but don't remove object files since they # may have been created when compiling PIC objects. removelist= tempremovelist=`$ECHO "$output_objdir/*"` for p in $tempremovelist; do case $p in *.$objext | *.gcno) ;; $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) if test "X$precious_files_regex" != "X"; then if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 then continue fi fi func_append removelist " $p" ;; *) ;; esac done test -n "$removelist" && \ func_show_eval "${RM}r \$removelist" fi # Now set the variables for building old libraries. if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then func_append oldlibs " $output_objdir/$libname.$libext" # Transform .lo files to .o files. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` fi # Eliminate all temporary directories. #for path in $notinst_path; do # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` # dependency_libs=`$ECHO "$dependency_libs " | $SED "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 func_replace_sysroot "$libdir" func_append temp_xrpath " -R$func_replace_sysroot_result" case "$finalize_rpath " in *" $libdir "*) ;; *) func_append finalize_rpath " $libdir" ;; esac done if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then dependency_libs="$temp_xrpath $dependency_libs" fi fi # Make sure dlfiles contains only unique files that won't be dlpreopened old_dlfiles="$dlfiles" dlfiles= for lib in $old_dlfiles; do case " $dlprefiles $dlfiles " in *" $lib "*) ;; *) func_append dlfiles " $lib" ;; esac done # Make sure dlprefiles contains only unique files old_dlprefiles="$dlprefiles" dlprefiles= for lib in $old_dlprefiles; do case "$dlprefiles " in *" $lib "*) ;; *) func_append dlprefiles " $lib" ;; esac done if test "$build_libtool_libs" = yes; then if test -n "$rpath"; then case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) # these systems don't actually have a c library (as such)! ;; *-*-rhapsody* | *-*-darwin1.[012]) # Rhapsody C library is in the System framework func_append deplibs " System.ltframework" ;; *-*-netbsd*) # Don't link with libc until the a.out ld.so is fixed. ;; *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) # Do not include libc due to us having libc/libc_r. ;; *-*-sco3.2v5* | *-*-sco5v6*) # Causes problems with __ctype ;; *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) # Compiler inserts libc in the correct place for threads to work ;; *) # Add libc to deplibs on all other systems if necessary. if test "$build_libtool_need_lc" = "yes"; then func_append deplibs " -lc" fi ;; esac fi # Transform deplibs into only deplibs that can be linked in shared. name_save=$name libname_save=$libname release_save=$release versuffix_save=$versuffix major_save=$major # I'm not sure if I'm treating the release correctly. I think # release should show up in the -l (ie -lgmp5) so we don't want to # add it in twice. Is that correct? release="" versuffix="" major="" newdeplibs= droppeddeps=no case $deplibs_check_method in pass_all) # Don't check for shared/static. Everything works. # This might be a little naive. We might want to check # whether the library exists or not. But this is on # osf3 & osf4 and I'm not really sure... Just # implementing what was already the behavior. 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. $opt_dry_run || $RM conftest.c cat > conftest.c </dev/null` $nocaseglob else potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` fi 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 "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; esac done if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | $SED -e 10q | $EGREP "$file_magic_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for file magic test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a file magic. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; match_pattern*) set dummy $deplibs_check_method; shift match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` for a_deplib in $deplibs; do case $a_deplib in -l*) func_stripname -l '' "$a_deplib" name=$func_stripname_result if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then case " $predeps $postdeps " in *" $a_deplib "*) func_append newdeplibs " $a_deplib" a_deplib="" ;; esac fi if test -n "$a_deplib" ; then libname=`eval "\\$ECHO \"$libname_spec\""` for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do potential_libs=`ls $i/$libname[.-]* 2>/dev/null` for potent_lib in $potential_libs; do potlib="$potent_lib" # see symlink-check above in file_magic test if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ $EGREP "$match_pattern_regex" > /dev/null; then func_append newdeplibs " $a_deplib" a_deplib="" break 2 fi done done fi if test -n "$a_deplib" ; then droppeddeps=yes echo $ECHO "*** Warning: linker path does not have real file for library $a_deplib." echo "*** I have the capability to make that library automatically link in when" echo "*** you link to this library. But I can only do this if you have a" echo "*** shared version of the library, which you do not appear to have" echo "*** because I did check the linker path looking for a file starting" if test -z "$potlib" ; then $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" else $ECHO "*** with $libname and none of the candidates passed a file format test" $ECHO "*** using a regex pattern. Last file checked: $potlib" fi fi ;; *) # Add a -L argument. func_append newdeplibs " $a_deplib" ;; esac done # Gone through all deplibs. ;; none | unknown | *) newdeplibs="" tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then for i in $predeps $postdeps ; do # can't use Xsed below, because $i might contain '/' tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` done fi case $tmp_deplibs in *[!\ \ ]*) 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 ;; esac ;; esac versuffix=$versuffix_save major=$major_save release=$release_save libname=$libname_save name=$name_save case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library with the System framework newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac if test "$droppeddeps" = yes; then if test "$module" = yes; then echo echo "*** Warning: libtool could not satisfy all declared inter-library" $ECHO "*** dependencies of module $libname. Therefore, libtool will create" echo "*** a static module, that should work as long as the dlopening" echo "*** application is linked with the -dlopen flag." if test -z "$global_symbol_pipe"; then echo echo "*** However, this would only work if libtool was able to extract symbol" echo "*** lists from a program, using \`nm' or equivalent, but libtool could" echo "*** not find such a program. So, this module is probably useless." echo "*** \`nm' from GNU binutils and a full rebuild may help." fi if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi else echo "*** The inter-library dependencies that have been dropped here will be" echo "*** automatically added whenever a program is linked with this library" echo "*** or is declared to -dlopen it." if test "$allow_undefined" = no; then echo echo "*** Since this library must not contain undefined symbols," echo "*** because either the platform does not support them or" echo "*** it was explicitly requested with -no-undefined," echo "*** libtool will only create a static version of it." if test "$build_old_libs" = no; then oldlibs="$output_objdir/$libname.$libext" build_libtool_libs=module build_old_libs=yes else build_libtool_libs=no fi fi fi fi # Done checking deplibs! deplibs=$newdeplibs fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" case $host in *-*-darwin*) newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done deplibs="$new_libs" # 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 "$opt_mode" != relink && rpath="$compile_rpath$rpath" for libdir in $rpath; do if test -n "$hardcode_libdir_flag_spec"; then if test -n "$hardcode_libdir_separator"; then func_replace_sysroot "$libdir" libdir=$func_replace_sysroot_result 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"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append dep_rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_apped 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" if test -n "$hardcode_libdir_flag_spec_ld"; then eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" else eval dep_rpath=\"$hardcode_libdir_flag_spec\" fi fi if test -n "$runpath_var" && test -n "$perm_rpath"; then # We should set the runpath_var. rpath= for dir in $perm_rpath; do func_append 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 "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" if test -n "$shlibpath"; then eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" fi # Get the real and link names of the library. eval shared_ext=\"$shrext_cmds\" eval library_names=\"$library_names_spec\" set dummy $library_names shift realname="$1" shift if test -n "$soname_spec"; then eval soname=\"$soname_spec\" else soname="$realname" fi if test -z "$dlname"; then dlname=$soname fi lib="$output_objdir/$realname" linknames= for link do func_append linknames " $link" done # Use standard objects if they are pic test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` test "X$libobjs" = "X " && libobjs= delfiles= if test -n "$export_symbols" && test -n "$include_expsyms"; then $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" export_symbols="$output_objdir/$libname.uexp" func_append delfiles " $export_symbols" fi orig_export_symbols= case $host_os in cygwin* | mingw* | cegcc*) if test -n "$export_symbols" && test -z "$export_symbols_regex"; then # exporting using user supplied symfile if test "x`$SED 1q $export_symbols`" != xEXPORTS; then # and it's NOT already a .def file. Must figure out # which of the given symbols are data symbols and tag # them as such. So, trigger use of export_symbols_cmds. # export_symbols gets reassigned inside the "prepare # the list of exported symbols" if statement, so the # include_expsyms logic still works. orig_export_symbols="$export_symbols" export_symbols= always_export_symbols=yes fi fi ;; esac # Prepare the list of exported symbols if test -z "$export_symbols"; then if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols cmds=$export_symbols_cmds save_ifs="$IFS"; IFS='~' for cmd1 in $cmds; do IFS="$save_ifs" # Take the normal branch if the nm_file_list_spec branch # doesn't work or if tool conversion is not needed. case $nm_file_list_spec~$to_tool_file_cmd in *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) try_normal_branch=yes eval cmd=\"$cmd1\" func_len " $cmd" len=$func_len_result ;; *) try_normal_branch=no ;; esac if test "$try_normal_branch" = yes \ && { test "$len" -lt "$max_cmd_len" \ || test "$max_cmd_len" -le -1; } then func_show_eval "$cmd" 'exit $?' skipped_export=false elif test -n "$nm_file_list_spec"; then func_basename "$output" output_la=$func_basename_result save_libobjs=$libobjs save_output=$output output=${output_objdir}/${output_la}.nm func_to_tool_file "$output" libobjs=$nm_file_list_spec$func_to_tool_file_result func_append delfiles " $output" func_verbose "creating $NM input file list: $output" for obj in $save_libobjs; do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > "$output" eval cmd=\"$cmd1\" func_show_eval "$cmd" 'exit $?' output=$save_output libobjs=$save_libobjs skipped_export=false else # The command line is too long to execute in one step. func_verbose "using reloadable object file for export list..." skipped_export=: # Break out early, otherwise skipped_export may be # set to false by a later but shorter cmd. break fi done IFS="$save_ifs" if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi fi if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi tmp_deplibs= for test_deplib in $deplibs; do case " $convenience " in *" $test_deplib "*) ;; *) func_append tmp_deplibs " $test_deplib" ;; esac done deplibs="$tmp_deplibs" if test -n "$convenience"; then if test -n "$whole_archive_flag_spec" && test "$compiler_needs_object" = yes && test -z "$libobjs"; then # extract the archives, so we have objects to list. # TODO: could optimize this to just extract one archive. whole_archive_flag_spec= fi if test -n "$whole_archive_flag_spec"; then save_libobjs=$libobjs eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= else gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $convenience func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi fi if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then eval flag=\"$thread_safe_flag_spec\" func_append linker_flags " $flag" fi # Make a backup of the uninstalled library when relinking if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? fi # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then eval test_cmds=\"$module_expsym_cmds\" cmds=$module_expsym_cmds else eval test_cmds=\"$module_cmds\" cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then eval test_cmds=\"$archive_expsym_cmds\" cmds=$archive_expsym_cmds else eval test_cmds=\"$archive_cmds\" cmds=$archive_cmds fi fi if test "X$skipped_export" != "X:" && func_len " $test_cmds" && len=$func_len_result && test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then : else # The command line is too long to link in one step, link piecewise # or, if using GNU ld and skipped_export is not :, use a linker # script. # Save the value of $output and $libobjs because we want to # use them later. If we have whole_archive_flag_spec, we # want to use save_libobjs as it was before # whole_archive_flag_spec was expanded, because we can't # assume the linker understands whole_archive_flag_spec. # This may have to be revisited, in case too many # convenience libraries get linked in and end up exceeding # the spec. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then save_libobjs=$libobjs fi save_output=$output func_basename "$output" output_la=$func_basename_result # Clear the reloadable object creation command queue and # initialize k to one. test_cmds= concat_cmds= objlist= last_robj= k=1 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then output=${output_objdir}/${output_la}.lnkscript func_verbose "creating GNU ld script: $output" echo 'INPUT (' > $output for obj in $save_libobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done echo ')' >> $output func_append delfiles " $output" func_to_tool_file "$output" output=$func_to_tool_file_result elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then output=${output_objdir}/${output_la}.lnk func_verbose "creating linker input file list: $output" : > $output set x $save_libobjs shift firstobj= if test "$compiler_needs_object" = yes; then firstobj="$1 " shift fi for obj do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" >> $output done func_append delfiles " $output" func_to_tool_file "$output" output=$firstobj\"$file_list_spec$func_to_tool_file_result\" else if test -n "$save_libobjs"; then func_verbose "creating reloadable object files..." output=$output_objdir/$output_la-${k}.$objext eval test_cmds=\"$reload_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 # Loop over the list of objects to be linked. for obj in $save_libobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result if test "X$objlist" = X || test "$len" -lt "$max_cmd_len"; then func_append objlist " $obj" else # The command $test_cmds is almost too long, add a # command to the queue. if test "$k" -eq 1 ; then # The first file doesn't have a previous command to add. reload_objs=$objlist eval concat_cmds=\"$reload_cmds\" else # All subsequent reloadable object files will link in # the last one created. reload_objs="$objlist $last_robj" eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" fi last_robj=$output_objdir/$output_la-${k}.$objext func_arith $k + 1 k=$func_arith_result output=$output_objdir/$output_la-${k}.$objext objlist=" $obj" func_len " $last_robj" func_arith $len0 + $func_len_result len=$func_arith_result fi done # Handle the remaining objects by creating one last # reloadable object file. All subsequent reloadable object # files will link in the last one created. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ reload_objs="$objlist $last_robj" eval concat_cmds=\"\${concat_cmds}$reload_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" fi func_append delfiles " $output" else output= fi if ${skipped_export-false}; then func_verbose "generating symbol list for \`$libname.la'" export_symbols="$output_objdir/$libname.exp" $opt_dry_run || $RM $export_symbols libobjs=$output # Append the command to create the export file. test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" if test -n "$last_robj"; then eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" fi fi test -n "$save_libobjs" && func_verbose "creating a temporary reloadable object file: $output" # Loop through the commands generated above and execute them. save_ifs="$IFS"; IFS='~' for cmd in $concat_cmds; do IFS="$save_ifs" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" if test -n "$export_symbols_regex" && ${skipped_export-false}; then func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' func_show_eval '$MV "${export_symbols}T" "$export_symbols"' fi fi if ${skipped_export-false}; then if test -n "$export_symbols" && test -n "$include_expsyms"; then tmp_export_symbols="$export_symbols" test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' fi if test -n "$orig_export_symbols"; then # The given exports_symbols file has to be filtered, so filter it. func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" # FIXME: $output_objdir/$libname.filter potentially contains lots of # 's' commands which not all seds can handle. GNU sed should be fine # though. Also, the filter scales superlinearly with the number of # global variables. join(1) would be nice here, but unfortunately # isn't a blessed tool. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter func_append delfiles " $export_symbols $output_objdir/$libname.filter" export_symbols=$output_objdir/$libname.def $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols fi fi libobjs=$output # Restore the value of output. output=$save_output if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then eval libobjs=\"\$libobjs $whole_archive_flag_spec\" test "X$libobjs" = "X " && libobjs= fi # Expand the library linking commands again to reset the # value of $libobjs for piecewise linking. # Do each of the archive commands. if test "$module" = yes && test -n "$module_cmds" ; then if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then cmds=$module_expsym_cmds else cmds=$module_cmds fi else if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then cmds=$archive_expsym_cmds else cmds=$archive_cmds fi fi fi if test -n "$delfiles"; then # Append the command to remove temporary files to $cmds. eval cmds=\"\$cmds~\$RM $delfiles\" fi # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append libobjs " $func_extract_archives_result" test "X$libobjs" = "X " && libobjs= fi save_ifs="$IFS"; IFS='~' for cmd in $cmds; do IFS="$save_ifs" eval cmd=\"$cmd\" $opt_silent || { func_quote_for_expand "$cmd" eval "func_echo $func_quote_for_expand_result" } $opt_dry_run || eval "$cmd" || { lt_exit=$? # Restore the uninstalled library and exit if test "$opt_mode" = relink; then ( cd "$output_objdir" && \ $RM "${realname}T" && \ $MV "${realname}U" "$realname" ) fi exit $lt_exit } done IFS="$save_ifs" # Restore the uninstalled library and exit if test "$opt_mode" = relink; then $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? if test -n "$convenience"; then if test -z "$whole_archive_flag_spec"; then func_show_eval '${RM}r "$gentop"' fi fi exit $EXIT_SUCCESS fi # Create links to the real library. for linkname in $linknames; do if test "$realname" != "$linkname"; then func_show_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 "$dlfiles$dlprefiles" || test "$dlself" != no; then func_warning "\`-dlopen' is ignored for objects" fi case " $deplibs" in *\ -l* | *\ -L*) func_warning "\`-l' and \`-L' are ignored for objects" ;; esac test -n "$rpath" && \ func_warning "\`-rpath' is ignored for objects" test -n "$xrpath" && \ func_warning "\`-R' is ignored for objects" test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for objects" test -n "$release" && \ func_warning "\`-release' is ignored for objects" case $output in *.lo) test -n "$objs$old_deplibs" && \ func_fatal_error "cannot build library object \`$output' from non-libtool objects" libobj=$output func_lo2o "$libobj" obj=$func_lo2o_result ;; *) libobj= obj="$output" ;; esac # Delete the old objects. $opt_dry_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 and hope we can get by with # turning comma into space.. wl= if test -n "$convenience"; then if test -n "$whole_archive_flag_spec"; then eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` else gentop="$output_objdir/${obj}x" func_append generated " $gentop" func_extract_archives $gentop $convenience reload_conv_objs="$reload_objs $func_extract_archives_result" fi fi # If we're not building shared, we need to use non_pic_objs test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" # Create the old-style object. reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test output="$obj" func_execute_cmds "$reload_cmds" 'exit $?' # Exit if we aren't doing a library object file. if test -z "$libobj"; then if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS fi if test "$build_libtool_libs" != yes; then if test -n "$gentop"; then func_show_eval '${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" # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? exit $EXIT_SUCCESS 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" func_execute_cmds "$reload_cmds" 'exit $?' fi if test -n "$gentop"; then func_show_eval '${RM}r "$gentop"' fi exit $EXIT_SUCCESS ;; prog) case $host in *cygwin*) func_stripname '' '.exe' "$output" output=$func_stripname_result.exe;; esac test -n "$vinfo" && \ func_warning "\`-version-info' is ignored for programs" test -n "$release" && \ func_warning "\`-release' is ignored for programs" test "$preload" = yes \ && test "$dlopen_support" = unknown \ && test "$dlopen_self" = unknown \ && test "$dlopen_self_static" = unknown && \ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." case $host in *-*-rhapsody* | *-*-darwin1.[012]) # On Rhapsody replace the C library is the System framework compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` ;; esac case $host in *-*-darwin*) # Don't allow lazy linking, it breaks C++ global constructors # But is supposedly fixed on 10.4 or later (yay!). if test "$tagname" = CXX ; then case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10.[0123]) func_append compile_command " ${wl}-bind_at_load" func_append finalize_command " ${wl}-bind_at_load" ;; esac fi # Time to change all our "foo.ltframework" stuff back to "-framework foo" compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` ;; esac # move library search paths that coincide with paths to not yet # installed libraries to the beginning of the library search list new_libs= for path in $notinst_path; do case " $new_libs " in *" -L$path/$objdir "*) ;; *) case " $compile_deplibs " in *" -L$path/$objdir "*) func_append new_libs " -L$path/$objdir" ;; esac ;; esac done for deplib in $compile_deplibs; do case $deplib in -L*) case " $new_libs " in *" $deplib "*) ;; *) func_append new_libs " $deplib" ;; esac ;; *) func_append new_libs " $deplib" ;; esac done compile_deplibs="$new_libs" func_append compile_command " $compile_deplibs" func_append finalize_command " $finalize_deplibs" if test -n "$rpath$xrpath"; then # If the user specified any rpath flags, then add them. for libdir in $rpath $xrpath; do # This is the magic to use -rpath. case "$finalize_rpath " in *" $libdir "*) ;; *) func_append 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"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$perm_rpath " in *" $libdir "*) ;; *) func_append perm_rpath " $libdir" ;; esac fi case $host in *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` case :$dllsearchpath: in *":$libdir:"*) ;; ::) dllsearchpath=$libdir;; *) func_append dllsearchpath ":$libdir";; esac case :$dllsearchpath: in *":$testbindir:"*) ;; ::) dllsearchpath=$testbindir;; *) func_append dllsearchpath ":$testbindir";; 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"*) ;; *) func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" ;; esac fi else eval flag=\"$hardcode_libdir_flag_spec\" func_append rpath " $flag" fi elif test -n "$runpath_var"; then case "$finalize_perm_rpath " in *" $libdir "*) ;; *) func_append 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 "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` fi func_generate_dlsyms "$outputname" "@PROGRAM@" "no" # template prelinking step if test -n "$prelink_cmds"; then func_execute_cmds "$prelink_cmds" 'exit $?' fi wrappers_required=yes case $host in *cegcc* | *mingw32ce*) # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. wrappers_required=no ;; *cygwin* | *mingw* ) if test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; *) if test "$need_relink" = no || test "$build_libtool_libs" != yes; then wrappers_required=no fi ;; esac if test "$wrappers_required" = no; then # Replace the output file specification. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` link_command="$compile_command$compile_rpath" # We have no uninstalled library dependencies, so finalize right now. exit_status=0 func_show_eval "$link_command" 'exit_status=$?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Delete the generated files. if test -f "$output_objdir/${outputname}S.${objext}"; then func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' fi exit $exit_status 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 func_append 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 func_append rpath "$dir:" done finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " fi fi if test "$no_install" = yes; then # We don't need to create a wrapper script. link_command="$compile_var$compile_command$compile_rpath" # Replace the output file specification. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` # Delete the old output file. $opt_dry_run || $RM $output # Link the executable and exit func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi exit $EXIT_SUCCESS fi if test "$hardcode_action" = relink; then # Fast installation is not supported link_command="$compile_var$compile_command$compile_rpath" relink_command="$finalize_var$finalize_command$finalize_rpath" func_warning "this platform does not like uninstalled shared libraries" func_warning "\`$output' will be relinked during installation" else if test "$fast_install" != no; then link_command="$finalize_var$compile_command$finalize_rpath" if test "$fast_install" = yes; then relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED '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 "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` # Delete the old output files. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname func_show_eval "$link_command" 'exit $?' if test -n "$postlink_cmds"; then func_to_tool_file "$output_objdir/$outputname" postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` func_execute_cmds "$postlink_cmds" 'exit $?' fi # Now create the wrapper script. func_verbose "creating $output" # Quote the relink command for shipping. if test -n "$relink_command"; then # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done relink_command="(cd `pwd`; $relink_command)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` fi # Only actually do things if not in dry run mode. $opt_dry_run || { # win32 will think the script is a binary if it has # a .exe suffix, so we strip it off here. case $output in *.exe) func_stripname '' '.exe' "$output" output=$func_stripname_result ;; esac # test for cygwin because mv fails w/o .exe extensions case $host in *cygwin*) exeext=.exe func_stripname '' '.exe' "$outputname" outputname=$func_stripname_result ;; *) exeext= ;; esac case $host in *cygwin* | *mingw* ) func_dirname_and_basename "$output" "" "." output_name=$func_basename_result output_path=$func_dirname_result cwrappersource="$output_path/$objdir/lt-$output_name.c" cwrapper="$output_path/$output_name.exe" $RM $cwrappersource $cwrapper trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 func_emit_cwrapperexe_src > $cwrappersource # The wrapper executable is built using the $host compiler, # because it contains $host paths and files. If cross- # compiling, it, like the target executable, must be # executed on the $host or under an emulation environment. $opt_dry_run || { $LTCC $LTCFLAGS -o $cwrapper $cwrappersource $STRIP $cwrapper } # Now, create the wrapper script for func_source use: func_ltwrapper_scriptname $cwrapper $RM $func_ltwrapper_scriptname_result trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 $opt_dry_run || { # note: this script will not be executed, so do not chmod. if test "x$build" = "x$host" ; then $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result else func_emit_wrapper no > $func_ltwrapper_scriptname_result fi } ;; * ) $RM $output trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 func_emit_wrapper no > $output chmod +x $output ;; esac } exit $EXIT_SUCCESS ;; 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 $symfileobj" addlibs="$convenience" build_libtool_libs=no else if test "$build_libtool_libs" = module; then oldobjs="$libobjs_save" build_libtool_libs=no else oldobjs="$old_deplibs $non_pic_objects" if test "$preload" = yes && test -f "$symfileobj"; then func_append oldobjs " $symfileobj" fi fi addlibs="$old_convenience" fi if test -n "$addlibs"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $addlibs func_append oldobjs " $func_extract_archives_result" fi # Do each command in the archive commands. if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then cmds=$old_archive_from_new_cmds else # Add any objects from preloaded convenience libraries if test -n "$dlprefiles"; then gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_extract_archives $gentop $dlprefiles func_append oldobjs " $func_extract_archives_result" fi # POSIX demands no paths to be encoded in archives. We have # to avoid creating archives with duplicate basenames if we # might have to extract them afterwards, e.g., when creating a # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). if (for obj in $oldobjs do func_basename "$obj" $ECHO "$func_basename_result" done | sort | sort -uc >/dev/null 2>&1); then : else echo "copying selected object files to avoid basename conflicts..." gentop="$output_objdir/${outputname}x" func_append generated " $gentop" func_mkdir_p "$gentop" save_oldobjs=$oldobjs oldobjs= counter=1 for obj in $save_oldobjs do func_basename "$obj" objbase="$func_basename_result" case " $oldobjs " in " ") oldobjs=$obj ;; *[\ /]"$objbase "*) while :; do # Make sure we don't pick an alternate name that also # overlaps. newobj=lt$counter-$objbase func_arith $counter + 1 counter=$func_arith_result case " $oldobjs " in *[\ /]"$newobj "*) ;; *) if test ! -f "$gentop/$newobj"; then break; fi ;; esac done func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" func_append oldobjs " $gentop/$newobj" ;; *) func_append oldobjs " $obj" ;; esac done fi eval cmds=\"$old_archive_cmds\" func_len " $cmds" len=$func_len_result if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then cmds=$old_archive_cmds elif test -n "$archiver_list_spec"; then func_verbose "using command file archive linking..." for obj in $oldobjs do func_to_tool_file "$obj" $ECHO "$func_to_tool_file_result" done > $output_objdir/$libname.libcmd func_to_tool_file "$output_objdir/$libname.libcmd" oldobjs=" $archiver_list_spec$func_to_tool_file_result" cmds=$old_archive_cmds else # the command line is too long to link in one step, link in parts func_verbose "using piecewise archive linking..." save_RANLIB=$RANLIB RANLIB=: objlist= concat_cmds= save_oldobjs=$oldobjs oldobjs= # Is there a better way of finding the last object in the list? for obj in $save_oldobjs do last_oldobj=$obj done eval test_cmds=\"$old_archive_cmds\" func_len " $test_cmds" len0=$func_len_result len=$len0 for obj in $save_oldobjs do func_len " $obj" func_arith $len + $func_len_result len=$func_arith_result func_append objlist " $obj" if test "$len" -lt "$max_cmd_len"; then : else # the above command should be used before it gets too long oldobjs=$objlist if test "$obj" = "$last_oldobj" ; then RANLIB=$save_RANLIB fi test -z "$concat_cmds" || concat_cmds=$concat_cmds~ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" objlist= len=$len0 fi done RANLIB=$save_RANLIB oldobjs=$objlist if test "X$oldobjs" = "X" ; then eval cmds=\"\$concat_cmds\" else eval cmds=\"\$concat_cmds~\$old_archive_cmds\" fi fi fi func_execute_cmds "$cmds" 'exit $?' done test -n "$generated" && \ func_show_eval "${RM}r$generated" # Now create the libtool archive. case $output in *.la) old_library= test "$build_old_libs" = yes && old_library="$libname.$libext" func_verbose "creating $output" # Preserve any variables that may affect compiler behavior for var in $variables_saved_for_relink; do if eval test -z \"\${$var+set}\"; then relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" elif eval var_value=\$$var; test -z "$var_value"; then relink_command="$var=; export $var; $relink_command" else func_quote_for_eval "$var_value" relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" fi done # Quote the link command for shipping. relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` if test "$hardcode_automatic" = yes ; then relink_command= fi # Only create the output if not a dry run. $opt_dry_run || { 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) func_basename "$deplib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` test -z "$libdir" && \ func_fatal_error "\`$deplib' is not a valid libtool archive" func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" ;; -L*) func_stripname -L '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -L$func_replace_sysroot_result" ;; -R*) func_stripname -R '' "$deplib" func_replace_sysroot "$func_stripname_result" func_append newdependency_libs " -R$func_replace_sysroot_result" ;; *) func_append newdependency_libs " $deplib" ;; esac done dependency_libs="$newdependency_libs" newdlfiles= for lib in $dlfiles; do case $lib in *.la) func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" ;; *) func_append newdlfiles " $lib" ;; esac done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in *.la) # Only pass preopened files to the pseudo-archive (for # eventual linking with the app. that links it) if we # didn't already link the preopened objects directly into # the library: func_basename "$lib" name="$func_basename_result" eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` test -z "$libdir" && \ func_fatal_error "\`$lib' is not a valid libtool archive" func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" ;; esac done dlprefiles="$newdlprefiles" else newdlfiles= for lib in $dlfiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlfiles " $abs" done dlfiles="$newdlfiles" newdlprefiles= for lib in $dlprefiles; do case $lib in [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; *) abs=`pwd`"/$lib" ;; esac func_append newdlprefiles " $abs" done dlprefiles="$newdlprefiles" fi $RM $output # place dlname in correct position for cygwin # In fact, it would be nice if we could use this code for all target # systems that can't hard-code library paths into their executables # and that have no shared library path variable independent of PATH, # but it turns out we can't easily determine that from inspecting # libtool variables, so we have to hard-code the OSs to which it # applies here; at the moment, that means platforms that use the PE # object format with DLL files. See the long comment at the top of # tests/bindir.at for full details. tdlname=$dlname case $host,$output,$installed,$module,$dlname in *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) # If a -bindir argument was supplied, place the dll there. if test "x$bindir" != x ; then func_relative_path "$install_libdir" "$bindir" tdlname=$func_relative_path_result$dlname else # Otherwise fall back on heuristic. tdlname=../bin/$dlname fi ;; esac $ECHO > $output "\ # $outputname - a libtool library file # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION # # Please DO NOT delete this file! # It is necessary for linking the library. # The name that we can dlopen(3). dlname='$tdlname' # Names of this library. library_names='$library_names' # The name of the static archive. old_library='$old_library' # Linker flags that can not go in dependency_libs. inherited_linker_flags='$new_inherited_linker_flags' # Libraries that this one depends upon. dependency_libs='$dependency_libs' # Names of additional weak libraries provided by this library weak_library_names='$weak_libs' # Version information for $libname. current=$current age=$age revision=$revision # Is this an already installed library? installed=$installed # Should we warn about portability when linking against -modules? shouldnotlink=$module # Files to dlopen/dlpreopen dlopen='$dlfiles' dlpreopen='$dlprefiles' # Directory that this library needs to be installed in: libdir='$install_libdir'" if test "$installed" = no && test "$need_relink" = yes; then $ECHO >> $output "\ relink_command=\"$relink_command\"" fi done } # Do a symbolic link so that the libtool archive can be found in # LD_LIBRARY_PATH before the program is installed. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' ;; esac exit $EXIT_SUCCESS } { test "$opt_mode" = link || test "$opt_mode" = relink; } && func_mode_link ${1+"$@"} # func_mode_uninstall arg... func_mode_uninstall () { $opt_debug RM="$nonopt" files= rmforce= exit_status=0 # This variable tells wrapper scripts just to set variables rather # than running their programs. libtool_install_magic="$magic" for arg do case $arg in -f) func_append RM " $arg"; rmforce=yes ;; -*) func_append RM " $arg" ;; *) func_append files " $arg" ;; esac done test -z "$RM" && \ func_fatal_help "you must specify an RM program" rmdirs= for file in $files; do func_dirname "$file" "" "." dir="$func_dirname_result" if test "X$dir" = X.; then odir="$objdir" else odir="$dir/$objdir" fi func_basename "$file" name="$func_basename_result" test "$opt_mode" = uninstall && odir="$dir" # Remember odir for removal later, being careful to avoid duplicates if test "$opt_mode" = clean; then case " $rmdirs " in *" $odir "*) ;; *) func_append rmdirs " $odir" ;; esac fi # Don't error if the file doesn't exist and rm -f was used. if { test -L "$file"; } >/dev/null 2>&1 || { test -h "$file"; } >/dev/null 2>&1 || test -f "$file"; then : elif test -d "$file"; then exit_status=1 continue elif test "$rmforce" = yes; then continue fi rmfiles="$file" case $name in *.la) # Possibly a libtool archive, so verify it. if func_lalib_p "$file"; then func_source $dir/$name # Delete the libtool libraries and symlinks. for n in $library_names; do func_append rmfiles " $odir/$n" done test -n "$old_library" && func_append rmfiles " $odir/$old_library" case "$opt_mode" in clean) case " $library_names " in *" $dlname "*) ;; *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; esac test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" ;; uninstall) if test -n "$library_names"; then # Do each command in the postuninstall commands. func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi if test -n "$old_library"; then # Do each command in the old_postuninstall commands. func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' fi # FIXME: should reinstall the best remaining shared library. ;; esac fi ;; *.lo) # Possibly a libtool object, so verify it. if func_lalib_p "$file"; then # Read the .lo file func_source $dir/$name # Add PIC object to the list of files to remove. if test -n "$pic_object" && test "$pic_object" != none; then func_append rmfiles " $dir/$pic_object" fi # Add non-PIC object to the list of files to remove. if test -n "$non_pic_object" && test "$non_pic_object" != none; then func_append rmfiles " $dir/$non_pic_object" fi fi ;; *) if test "$opt_mode" = clean ; then noexename=$name case $file in *.exe) func_stripname '' '.exe' "$file" file=$func_stripname_result func_stripname '' '.exe' "$name" noexename=$func_stripname_result # $file with .exe has already been added to rmfiles, # add $file without .exe func_append rmfiles " $file" ;; esac # Do a test to see if this is a libtool program. if func_ltwrapper_p "$file"; then if func_ltwrapper_executable_p "$file"; then func_ltwrapper_scriptname "$file" relink_command= func_source $func_ltwrapper_scriptname_result func_append rmfiles " $func_ltwrapper_scriptname_result" else relink_command= func_source $dir/$noexename fi # note $name still contains .exe if it was in $file originally # as does the version of $file that was added into $rmfiles func_append rmfiles " $odir/$name $odir/${name}S.${objext}" if test "$fast_install" = yes && test -n "$relink_command"; then func_append rmfiles " $odir/lt-$name" fi if test "X$noexename" != "X$name" ; then func_append rmfiles " $odir/lt-${noexename}.c" fi fi fi ;; esac func_show_eval "$RM $rmfiles" 'exit_status=1' done # Try to remove the ${objdir}s in the directories where we deleted files for dir in $rmdirs; do if test -d "$dir"; then func_show_eval "rmdir $dir >/dev/null 2>&1" fi done exit $exit_status } { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && func_mode_uninstall ${1+"$@"} test -z "$opt_mode" && { help="$generic_help" func_fatal_help "you must specify a MODE" } test -z "$exec_cmd" && \ func_fatal_help "invalid operation mode \`$opt_mode'" if test -n "$exec_cmd"; then eval exec "$exec_cmd" exit $EXIT_FAILURE fi exit $exit_status # The TAGs below are defined such that we never get into a situation # in which we disable both kinds of libraries. Given conflicting # choices, we go for a static library, that is the most portable, # since we can't tell whether shared libraries were disabled because # the user asked for that or because the platform doesn't support # them. This is particularly important on AIX, because we don't # support having both static and shared libraries enabled at the same # time on that platform, so we default to a shared-only configuration. # If a disable-shared tag is given, we'll fallback to a static-only # configuration. But we'll never go from static-only to shared-only. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared build_libtool_libs=no build_old_libs=yes # ### END LIBTOOL TAG CONFIG: disable-shared # ### BEGIN LIBTOOL TAG CONFIG: disable-static build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` # ### END LIBTOOL TAG CONFIG: disable-static # Local Variables: # mode:shell-script # sh-indentation:2 # End: # vi:sw=2 forked-daapd-0.19gcd/aclocal.m40000664000175000017500000030570011633141302015641 0ustar julienjulien# generated automatically by aclocal 1.11.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, [m4_warning([this file was generated for autoconf 2.68. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) # gpg-error.m4 - autoconf macro to detect libgpg-error. # Copyright (C) 2002, 2003, 2004 g10 Code GmbH # # This file is free software; as a special exception the author gives # unlimited permission to copy and/or distribute it, with or without # modifications, as long as this notice is preserved. # # This file 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. dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS dnl AC_DEFUN([AM_PATH_GPG_ERROR], [ AC_ARG_WITH(gpg-error-prefix, AC_HELP_STRING([--with-gpg-error-prefix=PFX], [prefix where GPG Error is installed (optional)]), gpg_error_config_prefix="$withval", gpg_error_config_prefix="") if test x$gpg_error_config_prefix != x ; then if test x${GPG_ERROR_CONFIG+set} != xset ; then GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config fi fi AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no) min_gpg_error_version=ifelse([$1], ,0.0,$1) AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version) ok=no if test "$GPG_ERROR_CONFIG" != "no" ; then req_major=`echo $min_gpg_error_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` req_minor=`echo $min_gpg_error_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version` major=`echo $gpg_error_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` minor=`echo $gpg_error_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` if test "$major" -gt "$req_major"; then ok=yes else if test "$major" -eq "$req_major"; then if test "$minor" -ge "$req_minor"; then ok=yes fi fi fi fi if test $ok = yes; then GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags` GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs` AC_MSG_RESULT([yes ($gpg_error_config_version)]) ifelse([$2], , :, [$2]) else GPG_ERROR_CFLAGS="" GPG_ERROR_LIBS="" AC_MSG_RESULT(no) ifelse([$3], , :, [$3]) fi AC_SUBST(GPG_ERROR_CFLAGS) AC_SUBST(GPG_ERROR_LIBS) ]) # iconv.m4 serial 11 (gettext-0.18.1) dnl Copyright (C) 2000-2002, 2007-2010 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 From Bruno Haible. AC_DEFUN([AM_ICONV_LINKFLAGS_BODY], [ dnl Prerequisites of AC_LIB_LINKFLAGS_BODY. AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_LIB_LINKFLAGS_BODY([iconv]) ]) AC_DEFUN([AM_ICONV_LINK], [ dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and dnl those with the standalone portable GNU libiconv installed). AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV dnl accordingly. AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY]) dnl Add $INCICONV to CPPFLAGS before performing the following checks, dnl because if the user has installed libiconv and not disabled its use dnl via --without-libiconv-prefix, he wants to use it. The first dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed. am_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV]) AC_CACHE_CHECK([for iconv], [am_cv_func_iconv], [ am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no AC_TRY_LINK([#include #include ], [iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);], [am_cv_func_iconv=yes]) if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" AC_TRY_LINK([#include #include ], [iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd);], [am_cv_lib_iconv=yes] [am_cv_func_iconv=yes]) LIBS="$am_save_LIBS" fi ]) if test "$am_cv_func_iconv" = yes; then AC_CACHE_CHECK([for working iconv], [am_cv_func_iconv_works], [ dnl This tests against bugs in AIX 5.1, HP-UX 11.11, Solaris 10. am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi AC_TRY_RUN([ #include #include int main () { /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { static const char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; const char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) return 1; } } /* Test against Solaris 10 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); if (cd_ascii_to_88591 != (iconv_t)(-1)) { static const char input[] = "\263"; char buf[10]; const char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_ascii_to_88591, (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) return 1; } } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; const char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) return 1; } } #endif /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is provided. */ if (/* Try standardized names. */ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) /* Try IRIX, OSF/1 names. */ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) /* Try AIX names. */ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try HP-UX names. */ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) return 1; return 0; }], [am_cv_func_iconv_works=yes], [am_cv_func_iconv_works=no], [case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac]) LIBS="$am_save_LIBS" ]) case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; *) am_func_iconv=yes ;; esac else am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then AC_DEFINE([HAVE_ICONV], [1], [Define if you have the iconv() function and it works.]) fi if test "$am_cv_lib_iconv" = yes; then AC_MSG_CHECKING([how to link with libiconv]) AC_MSG_RESULT([$LIBICONV]) else dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV dnl either. CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi AC_SUBST([LIBICONV]) AC_SUBST([LTLIBICONV]) ]) dnl Define AM_ICONV using AC_DEFUN_ONCE for Autoconf >= 2.64, in order to dnl avoid warnings like dnl "warning: AC_REQUIRE: `AM_ICONV' was expanded before it was required". dnl This is tricky because of the way 'aclocal' is implemented: dnl - It requires defining an auxiliary macro whose name ends in AC_DEFUN. dnl Otherwise aclocal's initial scan pass would miss the macro definition. dnl - It requires a line break inside the AC_DEFUN_ONCE and AC_DEFUN expansions. dnl Otherwise aclocal would emit many "Use of uninitialized value $1" dnl warnings. m4_define([gl_iconv_AC_DEFUN], m4_version_prereq([2.64], [[AC_DEFUN_ONCE( [$1], [$2])]], [[AC_DEFUN( [$1], [$2])]])) gl_iconv_AC_DEFUN([AM_ICONV], [ AM_ICONV_LINK if test "$am_cv_func_iconv" = yes; then AC_MSG_CHECKING([for iconv declaration]) AC_CACHE_VAL([am_cv_proto_iconv], [ AC_TRY_COMPILE([ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif ], [], [am_cv_proto_iconv_arg1=""], [am_cv_proto_iconv_arg1="const"]) am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"]) am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` AC_MSG_RESULT([ $am_cv_proto_iconv]) AC_DEFINE_UNQUOTED([ICONV_CONST], [$am_cv_proto_iconv_arg1], [Define as const if the declaration of iconv() needs const.]) fi ]) # lib-ld.m4 serial 4 (gettext-0.18) dnl Copyright (C) 1996-2003, 2009-2010 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 Subroutines of libtool.m4, dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision dnl with libtool.m4. dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no. AC_DEFUN([AC_LIB_PROG_LD_GNU], [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], [acl_cv_prog_gnu_ld], [# I'd rather use --version here, but apparently some GNU ld's only accept -v. case `$LD -v 2>&1 conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. AC_MSG_CHECKING([for ld used by GCC]) case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [[\\/]* | [A-Za-z]:[\\/]*)] [re_direlt='/[^/][^/]*/\.\./'] # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then AC_MSG_CHECKING([for GNU ld]) else AC_MSG_CHECKING([for non-GNU ld]) fi AC_CACHE_VAL([acl_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 acl_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. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi]) LD="$acl_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_LIB_PROG_LD_GNU ]) # lib-link.m4 serial 21 (gettext-0.18) dnl Copyright (C) 2001-2010 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 From Bruno Haible. AC_PREREQ([2.54]) dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and dnl augments the CPPFLAGS variable. dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) pushdef([Name],[translit([$1],[./-], [___])]) pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [ AC_LIB_LINKFLAGS_BODY([$1], [$2]) ac_cv_lib[]Name[]_libs="$LIB[]NAME" ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" ac_cv_lib[]Name[]_cppflags="$INC[]NAME" ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX" ]) LIB[]NAME="$ac_cv_lib[]Name[]_libs" LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" INC[]NAME="$ac_cv_lib[]Name[]_cppflags" LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) AC_SUBST([LIB]NAME[_PREFIX]) dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the dnl results of this search when this library appears as a dependency. HAVE_LIB[]NAME=yes popdef([NAME]) popdef([Name]) ]) dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message]) dnl searches for libname and the libraries corresponding to explicit and dnl implicit dependencies, together with the specified include files and dnl the ability to compile and link the specified testcode. The missing-message dnl defaults to 'no' and may contain additional hints for the user. dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], [ AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) AC_REQUIRE([AC_LIB_RPATH]) pushdef([Name],[translit([$1],[./-], [___])]) pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME dnl accordingly. AC_LIB_LINKFLAGS_BODY([$1], [$2]) dnl Add $INC[]NAME to CPPFLAGS before performing the following checks, dnl because if the user has installed lib[]Name and not disabled its use dnl via --without-lib[]Name-prefix, he wants to use it. ac_save_CPPFLAGS="$CPPFLAGS" AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [ ac_save_LIBS="$LIBS" dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS, dnl because these -l options might require -L options that are present in dnl LIBS. -l options benefit only from the -L options listed before it. dnl Otherwise, add it to the front of LIBS, because it may be a static dnl library that depends on another static library that is present in LIBS. dnl Static libraries benefit only from the static libraries listed after dnl it. case " $LIB[]NAME" in *" -l"*) LIBS="$LIBS $LIB[]NAME" ;; *) LIBS="$LIB[]NAME $LIBS" ;; esac AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])']) LIBS="$ac_save_LIBS" ]) if test "$ac_cv_lib[]Name" = yes; then HAVE_LIB[]NAME=yes AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.]) AC_MSG_CHECKING([how to link with lib[]$1]) AC_MSG_RESULT([$LIB[]NAME]) else HAVE_LIB[]NAME=no dnl If $LIB[]NAME didn't lead to a usable library, we don't need dnl $INC[]NAME either. CPPFLAGS="$ac_save_CPPFLAGS" LIB[]NAME= LTLIB[]NAME= LIB[]NAME[]_PREFIX= fi AC_SUBST([HAVE_LIB]NAME) AC_SUBST([LIB]NAME) AC_SUBST([LTLIB]NAME) AC_SUBST([LIB]NAME[_PREFIX]) popdef([NAME]) popdef([Name]) ]) dnl Determine the platform dependent parameters needed to use rpath: dnl acl_libext, dnl acl_shlibext, dnl acl_hardcode_libdir_flag_spec, dnl acl_hardcode_libdir_separator, dnl acl_hardcode_direct, dnl acl_hardcode_minus_L. AC_DEFUN([AC_LIB_RPATH], [ dnl Tell automake >= 1.10 to complain if config.rpath is missing. m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done ]) wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" dnl Determine whether the user wants rpath handling at all. AC_ARG_ENABLE([rpath], [ --disable-rpath do not hardcode runtime library paths], :, enable_rpath=yes) ]) dnl AC_LIB_FROMPACKAGE(name, package) dnl declares that libname comes from the given package. The configure file dnl will then not have a --with-libname-prefix option but a dnl --with-package-prefix option. Several libraries can come from the same dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar dnl macro call that searches for libname. AC_DEFUN([AC_LIB_FROMPACKAGE], [ pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) define([acl_frompackage_]NAME, [$2]) popdef([NAME]) pushdef([PACK],[$2]) pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) define([acl_libsinpackage_]PACKUP, m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1]) popdef([PACKUP]) popdef([PACK]) ]) dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and dnl the libraries corresponding to explicit and implicit dependencies. dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. AC_DEFUN([AC_LIB_LINKFLAGS_BODY], [ AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])]) pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-], [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])]) dnl Autoconf >= 2.61 supports dots in --with options. pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_ARG_WITH(P_A_C_K[-prefix], [[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib --without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi ]) dnl Search the library and its dependencies in $additional_libdir and dnl $LDFLAGS. Using breadth-first-seach. LIB[]NAME= LTLIB[]NAME= INC[]NAME= LIB[]NAME[]_PREFIX= dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been dnl computed. So it has to be reset here. HAVE_LIB[]NAME= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='$1 $2' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" dnl See if it was already located by an earlier AC_LIB_LINKFLAGS dnl or AC_LIB_HAVE_LINKFLAGS call. uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value" else dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined dnl that this library doesn't exist. So just drop it. : fi else dnl Search the library lib$name in $additional_libdir and $LDFLAGS dnl and the already constructed $LIBNAME/$LTLIBNAME. found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" dnl The same code as in the loop below: dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` dnl First look for a shared library. if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi dnl Then look for a static library. if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then dnl Found the library. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then dnl Linking with a shared library. We attempt to hardcode its dnl directory into the executable's runpath, unless it's the dnl standard /usr/lib. if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then dnl No hardcoding is needed. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl Use an explicit option to hardcode DIR into the resulting dnl binary. dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi dnl The hardcoding into $LIBNAME is system dependent. if test "$acl_hardcode_direct" = yes; then dnl Using DIR/libNAME.so during linking hardcodes DIR into the dnl resulting binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode DIR into the resulting dnl binary. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else dnl Rely on "-L$found_dir". dnl But don't add it if it's already contained in the LDFLAGS dnl or the already constructed $LIBNAME haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" else dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH dnl here, because this doesn't fit in flags passed to the dnl compiler. So give up. No hardcoding. This affects only dnl very old systems. dnl FIXME: Not sure whether we should use dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" dnl here. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then dnl Linking with a static library. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a" else dnl We shouldn't come here, but anyway it's good to have a dnl fallback. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name" fi fi dnl Assume the include files are nearby. additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = '$1'; then LIB[]NAME[]_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = '$1'; then LIB[]NAME[]_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then dnl Potentially add $additional_includedir to $INCNAME. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's /usr/local/include and we are using GCC on Linux, dnl 3. if it's already present in $CPPFLAGS or the already dnl constructed $INCNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INC[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $INCNAME. INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir" fi fi fi fi fi dnl Look for dependencies. if test -n "$found_la"; then dnl Read the .la file. It defines the variables dnl dlname, library_names, old_library, dependency_libs, current, dnl age, revision, installed, dlopen, dlpreopen, libdir. save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" dnl We use only dependency_libs. for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's /usr/local/lib and we are using GCC on Linux, dnl 3. if it's already present in $LDFLAGS or the already dnl constructed $LIBNAME, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LIBNAME. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIB[]NAME; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LTLIBNAME. LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then dnl Potentially add DIR to rpathdirs. dnl The rpathdirs will be appended to $LIBNAME at the end. haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi dnl Potentially add DIR to ltrpathdirs. dnl The ltrpathdirs will be appended to $LTLIBNAME at the end. haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) dnl Handle this in the next round. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) dnl Handle this in the next round. Throw away the .la's dnl directory; it is already contained in a preceding -L dnl option. names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) dnl Most likely an immediate library name. LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep" ;; esac done fi else dnl Didn't find the library; assume it is in the system directories dnl known to the linker and runtime loader. (All the system dnl directories known to the linker should also be known to the dnl runtime loader, otherwise the system is severely misconfigured.) LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name" LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user must dnl pass all path elements in one option. We can arrange that for a dnl single library, but not when more than one $LIBNAMEs are used. alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" else dnl The -rpath options are cumulative. for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then dnl When using libtool, the option that works for both libraries and dnl executables is -R. The -R options are cumulative. for found_dir in $ltrpathdirs; do LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir" done fi popdef([P_A_C_K]) popdef([PACKLIBS]) popdef([PACKUP]) popdef([PACK]) popdef([NAME]) ]) dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR, dnl unless already present in VAR. dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes dnl contains two or three consecutive elements that belong together. AC_DEFUN([AC_LIB_APPENDTOVAR], [ for element in [$2]; do haveit= for x in $[$1]; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then [$1]="${[$1]}${[$1]:+ }$element" fi done ]) dnl For those cases where a variable contains several -L and -l options dnl referring to unknown libraries and directories, this macro determines the dnl necessary additional linker options for the runtime path. dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) dnl sets LDADDVAR to linker options needed together with LIBSVALUE. dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, dnl otherwise linking without libtool is assumed. AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], [ AC_REQUIRE([AC_LIB_RPATH]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) $1= if test "$enable_rpath" != no; then if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then dnl Use an explicit option to hardcode directories into the resulting dnl binary. rpathdirs= next= for opt in $2; do if test -n "$next"; then dir="$next" dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem" \ && test "X$dir" != "X/usr/$acl_libdirstem2"; then rpathdirs="$rpathdirs $dir" fi next= else case $opt in -L) next=yes ;; -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` dnl No need to hardcode the standard /usr/lib. if test "X$dir" != "X/usr/$acl_libdirstem" \ && test "X$dir" != "X/usr/$acl_libdirstem2"; then rpathdirs="$rpathdirs $dir" fi next= ;; *) next= ;; esac fi done if test "X$rpathdirs" != "X"; then if test -n ""$3""; then dnl libtool is used for linking. Use -R options. for dir in $rpathdirs; do $1="${$1}${$1:+ }-R$dir" done else dnl The linker is used for linking directly. if test -n "$acl_hardcode_libdir_separator"; then dnl Weird platform: only the last -rpath option counts, the user dnl must pass all path elements in one option. alldirs= for dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="$flag" else dnl The -rpath options are cumulative. for dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" $1="${$1}${$1:+ }$flag" done fi fi fi fi fi AC_SUBST([$1]) ]) # lib-prefix.m4 serial 7 (gettext-0.18) dnl Copyright (C) 2001-2005, 2008-2010 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 From Bruno Haible. dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't dnl require excessive bracketing. ifdef([AC_HELP_STRING], [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])], [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])]) dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed dnl to access previously installed libraries. The basic assumption is that dnl a user will want packages to use other packages he previously installed dnl with the same --prefix option. dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate dnl libraries, but is otherwise very convenient. AC_DEFUN([AC_LIB_PREFIX], [ AC_BEFORE([$0], [AC_LIB_LINKFLAGS]) AC_REQUIRE([AC_PROG_CC]) AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) dnl By default, look in $includedir and $libdir. use_additional=yes AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) AC_LIB_ARG_WITH([lib-prefix], [ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib --without-lib-prefix don't search for libraries in includedir and libdir], [ if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then AC_LIB_WITH_FINAL_PREFIX([ eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" ]) else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" fi fi ]) if test $use_additional = yes; then dnl Potentially add $additional_includedir to $CPPFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/include, dnl 2. if it's already present in $CPPFLAGS, dnl 3. if it's /usr/local/include and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_includedir" != "X/usr/include"; then haveit= for x in $CPPFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_includedir"; then dnl Really add $additional_includedir to $CPPFLAGS. CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir" fi fi fi fi dnl Potentially add $additional_libdir to $LDFLAGS. dnl But don't add it dnl 1. if it's the standard /usr/lib, dnl 2. if it's already present in $LDFLAGS, dnl 3. if it's /usr/local/lib and we are using GCC on Linux, dnl 4. if it doesn't exist as a directory. if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then haveit= for x in $LDFLAGS; do AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"]) if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then if test -n "$GCC"; then case $host_os in linux*) haveit=yes;; esac fi fi if test -z "$haveit"; then if test -d "$additional_libdir"; then dnl Really add $additional_libdir to $LDFLAGS. LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir" fi fi fi fi fi ]) dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix, dnl acl_final_exec_prefix, containing the values to which $prefix and dnl $exec_prefix will expand at the end of the configure script. AC_DEFUN([AC_LIB_PREPARE_PREFIX], [ dnl Unfortunately, prefix and exec_prefix get only finally determined dnl at the end of configure. if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" ]) dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the dnl variables prefix and exec_prefix bound to the values they will have dnl at the end of the configure script. AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX], [ acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" $1 exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" ]) dnl AC_LIB_PREPARE_MULTILIB creates dnl - a variable acl_libdirstem, containing the basename of the libdir, either dnl "lib" or "lib64" or "lib/64", dnl - a variable acl_libdirstem2, as a secondary possible value for dnl acl_libdirstem, either the same as acl_libdirstem or "lib/sparcv9" or dnl "lib/amd64". AC_DEFUN([AC_LIB_PREPARE_MULTILIB], [ dnl There is no formal standard regarding lib and lib64. dnl On glibc systems, the current practice is that on a system supporting dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under dnl $prefix/lib64 and 32-bit libraries go under $prefix/lib. We determine dnl the compiler's default mode by looking at the compiler's library search dnl path. If at least one of its elements ends in /lib64 or points to a dnl directory whose absolute pathname ends in /lib64, we assume a 64-bit ABI. dnl Otherwise we use the default, namely "lib". dnl On Solaris systems, the current practice is that on a system supporting dnl 32-bit and 64-bit instruction sets or ABIs, 64-bit libraries go under dnl $prefix/lib/64 (which is a symlink to either $prefix/lib/sparcv9 or dnl $prefix/lib/amd64) and 32-bit libraries go under $prefix/lib. AC_REQUIRE([AC_CANONICAL_HOST]) acl_libdirstem=lib acl_libdirstem2= case "$host_os" in solaris*) dnl See Solaris 10 Software Developer Collection > Solaris 64-bit Developer's Guide > The Development Environment dnl . dnl "Portable Makefiles should refer to any library directories using the 64 symbolic link." dnl But we want to recognize the sparcv9 or amd64 subdirectory also if the dnl symlink is missing, so we set acl_libdirstem2 too. AC_CACHE_CHECK([for 64-bit host], [gl_cv_solaris_64bit], [AC_EGREP_CPP([sixtyfour bits], [ #ifdef _LP64 sixtyfour bits #endif ], [gl_cv_solaris_64bit=yes], [gl_cv_solaris_64bit=no]) ]) if test $gl_cv_solaris_64bit = yes; then acl_libdirstem=lib/64 case "$host_cpu" in sparc*) acl_libdirstem2=lib/sparcv9 ;; i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; esac fi ;; *) searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; */../ | */.. ) # Better ignore directories of this form. They are misleading. ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ;; esac test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" ]) dnl Autoconf macros for libgcrypt dnl Copyright (C) 2002, 2004 Free Software Foundation, Inc. dnl dnl This file is free software; as a special exception the author gives dnl unlimited permission to copy and/or distribute it, with or without dnl modifications, as long as this notice is preserved. dnl dnl This file is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]]) dnl Test for libgcrypt and define LIBGCRYPT_CFLAGS and LIBGCRYPT_LIBS. dnl MINIMUN-VERSION is a string with the version number optionalliy prefixed dnl with the API version to also check the API compatibility. Example: dnl a MINIMUN-VERSION of 1:1.2.5 won't pass the test unless the installed dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1. Using dnl this features allows to prevent build against newer versions of libgcrypt dnl with a changed API. dnl AC_DEFUN([AM_PATH_LIBGCRYPT], [ AC_ARG_WITH(libgcrypt-prefix, AC_HELP_STRING([--with-libgcrypt-prefix=PFX], [prefix where LIBGCRYPT is installed (optional)]), libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="") if test x$libgcrypt_config_prefix != x ; then if test x${LIBGCRYPT_CONFIG+set} != xset ; then LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config fi fi AC_PATH_TOOL(LIBGCRYPT_CONFIG, libgcrypt-config, no) tmp=ifelse([$1], ,1:1.2.0,$1) if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` else req_libgcrypt_api=0 min_libgcrypt_version="$tmp" fi AC_MSG_CHECKING(for LIBGCRYPT - version >= $min_libgcrypt_version) ok=no if test "$LIBGCRYPT_CONFIG" != "no" ; then req_major=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\1/'` req_minor=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\2/'` req_micro=`echo $min_libgcrypt_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\)/\3/'` libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` major=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\1/'` minor=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\2/'` micro=`echo $libgcrypt_config_version | \ sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/\3/'` if test "$major" -gt "$req_major"; then ok=yes else if test "$major" -eq "$req_major"; then if test "$minor" -gt "$req_minor"; then ok=yes else if test "$minor" -eq "$req_minor"; then if test "$micro" -ge "$req_micro"; then ok=yes fi fi fi fi fi fi if test $ok = yes; then AC_MSG_RESULT([yes ($libgcrypt_config_version)]) else AC_MSG_RESULT(no) fi if test $ok = yes; then # If we have a recent libgcrypt, we should also check that the # API is compatible if test "$req_libgcrypt_api" -gt 0 ; then tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` if test "$tmp" -gt 0 ; then AC_MSG_CHECKING([LIBGCRYPT API version]) if test "$req_libgcrypt_api" -eq "$tmp" ; then AC_MSG_RESULT([okay]) else ok=no AC_MSG_RESULT([does not match. want=$req_libgcrypt_api got=$tmp]) fi fi fi fi if test $ok = yes; then LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` ifelse([$2], , :, [$2]) if test x"$host" != x ; then libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none` if test x"$libgcrypt_config_host" != xnone ; then if test x"$libgcrypt_config_host" != x"$host" ; then AC_MSG_WARN([[ *** *** The config script $LIBGCRYPT_CONFIG was *** built for $libgcrypt_config_host and thus may not match the *** used host $host. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script. ***]]) fi fi fi else LIBGCRYPT_CFLAGS="" LIBGCRYPT_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(LIBGCRYPT_CFLAGS) AC_SUBST(LIBGCRYPT_LIBS) ]) # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- # serial 1 (pkg-config-0.24) # # Copyright © 2004 Scott James Remnant . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # PKG_PROG_PKG_CONFIG([MIN-VERSION]) # ---------------------------------- AC_DEFUN([PKG_PROG_PKG_CONFIG], [m4_pattern_forbid([^_?PKG_[A-Z_]+$]) m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) fi if test -n "$PKG_CONFIG"; then _pkg_min_version=m4_default([$1], [0.9.0]) AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) PKG_CONFIG="" fi fi[]dnl ])# PKG_PROG_PKG_CONFIG # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # # Check to see whether a particular set of modules exists. Similar # to PKG_CHECK_MODULES(), but does not set variables or print errors. # # Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) # only at the first occurence in configure.ac, so if the first place # it's called might be skipped (such as if it is within an "if", you # have to call PKG_CHECK_EXISTS manually # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_EXISTS], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl if test -n "$PKG_CONFIG" && \ AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then m4_default([$2], [:]) m4_ifvaln([$3], [else $3])dnl fi]) # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) # --------------------------------------------- m4_define([_PKG_CONFIG], [if test -n "$$1"; then pkg_cv_[]$1="$$1" elif test -n "$PKG_CONFIG"; then PKG_CHECK_EXISTS([$3], [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes ], [pkg_failed=yes]) else pkg_failed=untried fi[]dnl ])# _PKG_CONFIG # _PKG_SHORT_ERRORS_SUPPORTED # ----------------------------- AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], [AC_REQUIRE([PKG_PROG_PKG_CONFIG]) if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi[]dnl ])# _PKG_SHORT_ERRORS_SUPPORTED # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], # [ACTION-IF-NOT-FOUND]) # # # Note that if there is a possibility the first call to # PKG_CHECK_MODULES might not happen, you should be sure to include an # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac # # # -------------------------------------------------------------- AC_DEFUN([PKG_CHECK_MODULES], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl pkg_failed=no AC_MSG_CHECKING([for $1]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2]) m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS and $1[]_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details.]) if test $pkg_failed = yes; then AC_MSG_RESULT([no]) _PKG_SHORT_ERRORS_SUPPORTED if test $_pkg_short_errors_supported = yes; then $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` else $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD m4_default([$4], [AC_MSG_ERROR( [Package requirements ($2) were not met: $$1_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. _PKG_TEXT])[]dnl ]) elif test $pkg_failed = untried; then AC_MSG_RESULT([no]) m4_default([$4], [AC_MSG_FAILURE( [The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. _PKG_TEXT To get pkg-config, see .])[]dnl ]) else $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS AC_MSG_RESULT([yes]) $3 fi[]dnl ])# PKG_CHECK_MODULES # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.11' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.11.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.11.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 9 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 10 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], UPC, [depcc="$UPC" am_compiler_list=], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 5 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 16 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.62])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES(OBJC)], [define([AC_PROG_OBJC], defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl ]) _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl dnl The `parallel-tests' driver may need to know about EXEEXT, so add the dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl ]) dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_PROG_CC_C_O # -------------- # Like AC_PROG_CC_C_O, but changed for automake. AC_DEFUN([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC_C_O])dnl AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi dnl Make sure AC_PROG_CC is never called again, or it will override our dnl setting of CC. m4_define([AC_PROG_CC], [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 6 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_MKDIR_P # --------------- # Check for `mkdir -p'. AC_DEFUN([AM_PROG_MKDIR_P], [AC_PREREQ([2.60])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, dnl while keeping a definition of mkdir_p for backward compatibility. dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of dnl Makefile.ins that do not define MKDIR_P, so we do our own dnl adjustment using top_builddir (which is defined more often than dnl MKDIR_P). AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl case $mkdir_p in [[\\/$]]* | ?:[[\\/]]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 5 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR m4_include([m4/blocks.m4]) m4_include([m4/libtool.m4]) m4_include([m4/libunistring.m4]) m4_include([m4/ltoptions.m4]) m4_include([m4/ltsugar.m4]) m4_include([m4/ltversion.m4]) m4_include([m4/lt~obsolete.m4]) forked-daapd-0.19gcd/configure0000775000175000017500000213407611633141303015721 0ustar julienjulien#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.68. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software # Foundation, Inc. # # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which # is contrary to our usage. Disable this feature. alias -g '\${1+\"\$@\"}'='\"\$@\"' setopt NO_GLOB_SUBST else case \`(set -o) 2>/dev/null\` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi " as_required="as_fn_return () { (exit \$1); } as_fn_success () { as_fn_return 0; } as_fn_failure () { as_fn_return 1; } as_fn_ret_success () { return 0; } as_fn_ret_failure () { return 1; } exitcode=0 as_fn_success || { exitcode=1; echo as_fn_success failed.; } as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi test x\$exitcode = x0 || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || ( ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO PATH=/empty FPATH=/empty; export PATH FPATH test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1 test \$(( 1 + 1 )) = 2 || exit 1" if (eval "$as_required") 2>/dev/null; then : as_have_required=yes else as_have_required=no fi if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR as_found=false for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. as_found=: case $as_dir in #( /*) for as_base in sh bash ksh sh5; do # Try only shells that exist, to save several forks. as_shell=$as_dir/$as_base if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : CONFIG_SHELL=$as_shell as_have_required=yes if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : break 2 fi fi done;; esac as_found=false done $as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : CONFIG_SHELL=$SHELL as_have_required=yes fi; } IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : # We cannot yet assume a decent shell, so we have to provide a # neutralization value for shells without unset; and this also # works around shells that cannot unset nonexistent variables. # Preserve -v and -x to the replacement shell. BASH_ENV=/dev/null ENV=/dev/null (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV export CONFIG_SHELL case $- in # (((( *v*x* | *x*v* ) as_opts=-vx ;; *v* ) as_opts=-v ;; *x* ) as_opts=-x ;; * ) as_opts= ;; esac exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} fi if test x$as_have_required = xno; then : $as_echo "$0: This script requires a shell more modern than all" $as_echo "$0: the shells that I found on your system." if test x${ZSH_VERSION+set} = xset ; then $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, $0: including any error possibly output before this $0: message. Then install a modern shell, or manually run $0: the script under such a shell if you do have one." fi exit 1 fi fi fi SHELL=${CONFIG_SHELL-/bin/sh} export SHELL # Unset more variables known to interfere with behavior of common tools. CLICOLOR_FORCE= GREP_OPTIONS= unset CLICOLOR_FORCE GREP_OPTIONS ## --------------------- ## ## M4sh Shell Functions. ## ## --------------------- ## # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits as_lineno_1=$LINENO as_lineno_1a=$LINENO as_lineno_2=$LINENO as_lineno_2a=$LINENO eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" SHELL=${CONFIG_SHELL-/bin/sh} test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= PACKAGE_URL= ac_unique_file="config.h.in" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='am__EXEEXT_FALSE am__EXEEXT_TRUE LTLIBOBJS LIBOBJS CBLOCKS_LIBS CBLOCKS_FLAGS HAVE_CBLOCKS_FALSE HAVE_CBLOCKS_TRUE LIBDISPATCH_LIBS OSS4CPPFLAGS COND_OSS4_FALSE COND_OSS4_TRUE COND_ALSA_FALSE COND_ALSA_TRUE ALSA_LIBS ALSA_CFLAGS LIBPLIST_LIBS LIBPLIST_CFLAGS TAGLIB_LIBS TAGLIB_CFLAGS FLAC_LIBS FLAC_CFLAGS GPG_ERROR_LIBS GPG_ERROR_CFLAGS GPG_ERROR_CONFIG LIBGCRYPT_LIBS LIBGCRYPT_CFLAGS LIBGCRYPT_CONFIG ANTLR3C_LIBS LIBAVL_LIBS MINIXML_LIBS MINIXML_CFLAGS COND_AVIO_FALSE COND_AVIO_TRUE LIBAV_LIBS LIBAV_CFLAGS SQLITE3_LIBS SQLITE3_CFLAGS AVAHI_LIBS AVAHI_CFLAGS CONFUSE_LIBS CONFUSE_CFLAGS TRE_LIBS TRE_CFLAGS ZLIB_LIBS ZLIB_CFLAGS PKG_CONFIG_LIBDIR PKG_CONFIG_PATH PKG_CONFIG LTLIBICONV LIBICONV LIBUNISTRING_PREFIX LTLIBUNISTRING LIBUNISTRING HAVE_LIBUNISTRING COND_ITUNES_FALSE COND_ITUNES_TRUE COND_MUSEPACK_FALSE COND_MUSEPACK_TRUE COND_FLAC_FALSE COND_FLAC_TRUE COND_ANTLR_FALSE COND_ANTLR_TRUE ANTLR GPERF CPP OTOOL64 OTOOL LIPO NMEDIT DSYMUTIL MANIFEST_TOOL RANLIB ac_ct_AR AR DLLTOOL OBJDUMP LN_S NM ac_ct_DUMPBIN DUMPBIN LD FGREP EGREP GREP SED host_os host_vendor host_cpu host build_os build_vendor build_cpu build LIBTOOL am__fastdepCC_FALSE am__fastdepCC_TRUE CCDEPMODE AMDEPBACKSLASH AMDEP_FALSE AMDEP_TRUE am__quote am__include DEPDIR OBJEXT EXEEXT ac_ct_CC CPPFLAGS LDFLAGS CFLAGS CC am__untar am__tar AMTAR am__leading_dot SET_MAKE AWK mkdir_p MKDIR_P INSTALL_STRIP_PROGRAM STRIP install_sh MAKEINFO AUTOHEADER AUTOMAKE AUTOCONF ACLOCAL VERSION PACKAGE CYGPATH_W am__isrc INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM target_alias host_alias build_alias LIBS ECHO_T ECHO_N ECHO_C DEFS mandir localedir libdir psdir pdfdir dvidir htmldir infodir docdir oldincludedir includedir localstatedir sharedstatedir sysconfdir datadir datarootdir libexecdir sbindir bindir program_transform_name prefix exec_prefix PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION PACKAGE_TARNAME PACKAGE_NAME PATH_SEPARATOR SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking enable_dependency_tracking enable_static enable_shared with_pic enable_fast_install with_gnu_ld with_sysroot enable_libtool_lock enable_largefile enable_flac enable_musepack enable_itunes with_oss4 enable_rpath with_libunistring_prefix with_libiconv_prefix with_libgcrypt_prefix with_gpg_error_prefix with_blocks_runtime ' ac_precious_vars='build_alias host_alias target_alias CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP PKG_CONFIG PKG_CONFIG_PATH PKG_CONFIG_LIBDIR ZLIB_CFLAGS ZLIB_LIBS TRE_CFLAGS TRE_LIBS CONFUSE_CFLAGS CONFUSE_LIBS AVAHI_CFLAGS AVAHI_LIBS SQLITE3_CFLAGS SQLITE3_LIBS LIBAV_CFLAGS LIBAV_LIBS MINIXML_CFLAGS MINIXML_LIBS FLAC_CFLAGS FLAC_LIBS TAGLIB_CFLAGS TAGLIB_LIBS LIBPLIST_CFLAGS LIBPLIST_LIBS ALSA_CFLAGS ALSA_LIBS' # Initialize some variables set by options. ac_init_help= ac_init_version=false ac_unrecognized_opts= ac_unrecognized_sep= # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *=) ac_optarg= ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "enable_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval enable_$ac_useropt=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=\$ac_optarg ;; -without-* | --without-*) ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in *" "with_$ac_useropt" "*) ;; *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" ac_unrecognized_sep=', ';; esac eval with_$ac_useropt=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) as_fn_error $? "unrecognized option: \`$ac_option' Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi # Check all directory arguments for consistency. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. case $ac_val in */ ) ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` eval $ac_var=\$ac_val;; esac # Be sure to have absolute directory names. case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$as_myself" || $as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_myself" : 'X\(//\)[^/]' \| \ X"$as_myself" : 'X\(//\)$' \| \ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_myself" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-static[=PKGS] build static libraries [default=no] --enable-shared[=PKGS] build shared libraries [default=yes] --enable-fast-install[=PKGS] optimize for fast installation [default=yes] --disable-libtool-lock avoid locking (might break parallel builds) --disable-largefile omit support for large files --enable-flac Enable FLAC support --enable-musepack Enable Musepack support --enable-itunes Enable iTunes library support --disable-rpath do not hardcode runtime library paths Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-pic try to use only PIC/non-PIC objects [default=use both] --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-sysroot=DIR Search for dependent libraries within DIR (or the compiler's sysroot if not specified). --with-oss4=includedir Use OSS4 with soundcard.h in includedir (default /usr/lib/oss/include/sys) --with-gnu-ld assume the C compiler uses GNU ld default=no --with-libunistring-prefix[=DIR] search for libunistring in DIR/include and DIR/lib --without-libunistring-prefix don't search for libunistring in includedir and libdir --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib --without-libiconv-prefix don't search for libiconv in includedir and libdir --with-libgcrypt-prefix=PFX prefix where LIBGCRYPT is installed (optional) --with-gpg-error-prefix=PFX prefix where GPG Error is installed (optional) --with-blocks-runtime Specify path to the blocks runtime Some influential environment variables: CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor PKG_CONFIG path to pkg-config utility PKG_CONFIG_PATH directories to add to pkg-config's search path PKG_CONFIG_LIBDIR path overriding pkg-config's built-in search path ZLIB_CFLAGS C compiler flags for ZLIB, overriding pkg-config ZLIB_LIBS linker flags for ZLIB, overriding pkg-config TRE_CFLAGS C compiler flags for TRE, overriding pkg-config TRE_LIBS linker flags for TRE, overriding pkg-config CONFUSE_CFLAGS C compiler flags for CONFUSE, overriding pkg-config CONFUSE_LIBS linker flags for CONFUSE, overriding pkg-config AVAHI_CFLAGS C compiler flags for AVAHI, overriding pkg-config AVAHI_LIBS linker flags for AVAHI, overriding pkg-config SQLITE3_CFLAGS C compiler flags for SQLITE3, overriding pkg-config SQLITE3_LIBS linker flags for SQLITE3, overriding pkg-config LIBAV_CFLAGS C compiler flags for LIBAV, overriding pkg-config LIBAV_LIBS linker flags for LIBAV, overriding pkg-config MINIXML_CFLAGS C compiler flags for MINIXML, overriding pkg-config MINIXML_LIBS linker flags for MINIXML, overriding pkg-config FLAC_CFLAGS C compiler flags for FLAC, overriding pkg-config FLAC_LIBS linker flags for FLAC, overriding pkg-config TAGLIB_CFLAGS C compiler flags for TAGLIB, overriding pkg-config TAGLIB_LIBS linker flags for TAGLIB, overriding pkg-config LIBPLIST_CFLAGS C compiler flags for LIBPLIST, overriding pkg-config LIBPLIST_LIBS linker flags for LIBPLIST, overriding pkg-config ALSA_CFLAGS C compiler flags for ALSA, overriding pkg-config ALSA_LIBS linker flags for ALSA, overriding pkg-config Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. Report bugs to the package provider. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure generated by GNU Autoconf 2.68 Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi ## ------------------------ ## ## Autoconf initialization. ## ## ------------------------ ## # ac_fn_c_try_compile LINENO # -------------------------- # Try to compile conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_compile # ac_fn_c_try_link LINENO # ----------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_link () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack rm -f conftest.$ac_objext conftest$ac_exeext if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_test_x conftest$ac_exeext }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_link # ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists and can be compiled using the include files in # INCLUDES, setting the cache variable VAR accordingly. ac_fn_c_check_header_compile () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. ac_fn_c_try_cpp () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err ac_status=$? if test -s conftest.err; then grep -v '^ *+' conftest.err >conftest.er1 cat conftest.er1 >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : ac_retval=0 else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_cpp # ac_fn_c_try_run LINENO # ---------------------- # Try to link conftest.$ac_ext, and return whether this succeeded. Assumes # that executables *can* be run. ac_fn_c_try_run () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then : ac_retval=0 else $as_echo "$as_me: program exited with status $ac_status" >&5 $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno as_fn_set_status $ac_retval } # ac_fn_c_try_run # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly ac_fn_c_check_func () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Define $2 to an innocuous variant, in case declares $2. For example, HP-UX 11i declares gettimeofday. */ #define $2 innocuous_$2 /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $2 (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $2 /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $2 (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$2 || defined __stub___$2 choke me #endif int main () { return $2 (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : eval "$3=yes" else eval "$3=no" fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func # ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES # ------------------------------------------------------- # Tests whether HEADER exists, giving a warning if it cannot be compiled using # the include files in INCLUDES and setting the cache variable VAR # accordingly. ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } else # Is the header compilable? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 $as_echo_n "checking $2 usability... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 #include <$2> _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_header_compiler=yes else ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 $as_echo "$ac_header_compiler" >&6; } # Is the header present? { $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 $as_echo_n "checking $2 presence... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <$2> _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : ac_header_preproc=yes else ac_header_preproc=no fi rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( yes:no: ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 $as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; no:yes:* ) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 $as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 $as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel # ac_fn_c_check_type LINENO TYPE VAR INCLUDES # ------------------------------------------- # Tests whether TYPE exists after having included INCLUDES, setting cache # variable VAR accordingly. ac_fn_c_check_type () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof ($2)) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { if (sizeof (($2))) return 0; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else eval "$3=yes" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type # ac_fn_c_compute_int LINENO EXPR VAR INCLUDES # -------------------------------------------- # Tries to find the compile-time value of EXPR in a program that includes # INCLUDES, setting VAR accordingly. Returns whether the value could be # computed ac_fn_c_compute_int () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack if test "$cross_compiling" = yes; then # Depending upon the size, compute the lo and hi bounds. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= 0)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=0 ac_mid=0 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid; break else as_fn_arith $ac_mid + 1 && ac_lo=$as_val if test $ac_lo -le $ac_mid; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) < 0)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=-1 ac_mid=-1 while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_lo=$ac_mid; break else as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val if test $ac_mid -le $ac_hi; then ac_lo= ac_hi= break fi as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done else ac_lo= ac_hi= fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Binary search between lo and hi bounds. while test "x$ac_lo" != "x$ac_hi"; do as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; test_array [0] = 0 ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_hi=$ac_mid else as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done case $ac_lo in #(( ?*) eval "$3=\$ac_lo"; ac_retval=0 ;; '') ac_retval=1 ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $4 static long int longval () { return $2; } static unsigned long int ulongval () { return $2; } #include #include int main () { FILE *f = fopen ("conftest.val", "w"); if (! f) return 1; if (($2) < 0) { long int i = longval (); if (i != ($2)) return 1; fprintf (f, "%ld", i); } else { unsigned long int i = ulongval (); if (i != ($2)) return 1; fprintf (f, "%lu", i); } /* Do not output a trailing newline, as this causes \r\n confusion on some platforms. */ return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : echo >>conftest.val; read $3 config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.68. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. $as_echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done { ac_configure_args0=; unset ac_configure_args0;} { ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo $as_echo "## ---------------- ## ## Cache variables. ## ## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo $as_echo "## ----------------- ## ## Output variables. ## ## ----------------- ##" echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then $as_echo "## ------------------- ## ## File substitutions. ## ## ------------------- ##" echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac $as_echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then $as_echo "## ----------- ## ## confdefs.h. ## ## ----------- ##" echo cat confdefs.h echo fi test "$ac_signal" != 0 && $as_echo "$as_me: caught signal $ac_signal" $as_echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h $as_echo "/* confdefs.h */" > confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_URL "$PACKAGE_URL" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then # We do not want a PATH search for config.site. case $CONFIG_SITE in #(( -*) ac_site_file1=./$CONFIG_SITE;; */*) ac_site_file1=$CONFIG_SITE;; *) ac_site_file1=./$CONFIG_SITE;; esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site else ac_site_file1=$ac_default_prefix/share/config.site ac_site_file2=$ac_default_prefix/etc/config.site fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" \ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "failed to load site script $ac_site_file See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special files # actually), so we avoid doing that. DJGPP emulates it as a regular file. if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then # differences in whitespace do not lead to failure. ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## ## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers config.h" am__api_version='1.11' ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in #(( ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else rm -rf conftest.one conftest.two conftest.dir echo one > conftest.one echo two > conftest.two mkdir conftest.dir if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && test -s conftest.one && test -s conftest.two && test -s conftest.dir/conftest.one && test -s conftest.dir/conftest.two then ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi fi done done ;; esac done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; esac # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file ) then # Ok. : else as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. # By default was `s,x,x', remove it if useless. ac_script='s/[\\$]/&&/g;s/;s,x,x,$//' program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"` # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5 $as_echo_n "checking for a thread-safe mkdir -p... " >&6; } if test -z "$MKDIR_P"; then if ${ac_cv_path_mkdir+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ 'mkdir (fileutils) '4.1*) ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext break 3;; esac done done done IFS=$as_save_IFS fi test -d ./--version && rmdir ./--version if test "${ac_cv_path_mkdir+set}" = set; then MKDIR_P="$ac_cv_path_mkdir -p" else # As a last resort, use the slow shell script. Don't cache a # value for MKDIR_P within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. MKDIR_P="$ac_install_sh -d" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5 $as_echo "$MKDIR_P" >&6; } mkdir_p="$MKDIR_P" case $mkdir_p in [\\/$]* | ?:[\\/]*) ;; */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; esac for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AWK" && break done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE=forked-daapd VERSION=0.19gcd cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then for ac_prog in clang llvm-gcc do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in clang llvm-gcc do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "no acceptable C compiler found in \$PATH See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 for ac_option in --version -v -V -qversion; do { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? if test -s conftest.err; then sed '10a\ ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 fi rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 $as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi if test -z "$ac_file"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "C compiler cannot create executables See \`config.log' for more details" "$LINENO" 5; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 $as_echo_n "checking for C compiler default output file name... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 $as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of executables: cannot compile and link See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { FILE *f = fopen ("conftest.out", "w"); return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files="$ac_clean_files conftest.out" # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 $as_echo_n "checking whether we are cross compiling... " >&6; } if test "$cross_compiling" != yes; then { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if { ac_try='./conftest$ac_cv_exeext' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details" "$LINENO" 5; } fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 $as_echo "$cross_compiling" >&6; } rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "cannot compute suffix of object files: cannot compile See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes else GCC= fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else CFLAGS="" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : else ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac if test "x$ac_cv_prog_cc_c89" != xno; then : fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from `make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi depcc="$CC" am_compiler_list= { $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi am__universal=false case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvisualcpp | msvcmsys) # This compiler won't grok `-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi if test "x$CC" != xcc; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5 $as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5 $as_echo_n "checking whether cc understands -c and -o together... " >&6; } fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` if eval \${ac_cv_prog_cc_${ac_cc}_c_o+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF # Make sure it works both with $CC and with simple cc. # We do the test twice because some compilers refuse to overwrite an # existing .o file with -o, though they will create one. ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then eval ac_cv_prog_cc_${ac_cc}_c_o=yes if test "x$CC" != xcc; then # Test first that cc exists at all. if { ac_try='cc -c conftest.$ac_ext >&5' { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; }; then ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5' rm -f conftest2.* if { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -f conftest2.$ac_objext && { { case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" $as_echo "$ac_try_echo"; } >&5 (eval "$ac_try") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # cc works too. : else # cc exists but doesn't like -o. eval ac_cv_prog_cc_${ac_cc}_c_o=no fi fi fi else eval ac_cv_prog_cc_${ac_cc}_c_o=no fi rm -f core conftest* fi if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } $as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h fi # FIXME: we rely on the cache variable name because # there is no other way. set dummy $CC am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o if test "$am_t" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi case `pwd` in *\ * | *\ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5 $as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;; esac macro_version='2.4' macro_revision='1.3293' ltmain="$ac_aux_dir/ltmain.sh" # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } if ${ac_cv_build+:} false; then : $as_echo_n "(cached) " >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5 $as_echo_n "checking host system type... " >&6; } if ${ac_cv_host+:} false; then : $as_echo_n "(cached) " >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5 $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # Backslashify metacharacters that are still active within # double-quoted strings. sed_quote_subst='s/\(["`$\\]\)/\\\1/g' # Same as above, but do not quote variable references. double_quote_subst='s/\(["`\\]\)/\\\1/g' # Sed substitution to delay expansion of an escaped shell variable in a # double_quote_subst'ed string. delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' # Sed substitution to delay expansion of an escaped single quote. delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' # Sed substitution to avoid accidental globbing in evaled expressions no_glob_subst='s/\*/\\\*/g' ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5 $as_echo_n "checking how to print strings... " >&6; } # Test print first, because it will be a builtin if present. if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='print -r --' elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then ECHO='printf %s\n' else # Use this function as a fallback that always works. func_fallback_echo () { eval 'cat <<_LTECHO_EOF $1 _LTECHO_EOF' } ECHO='func_fallback_echo' fi # func_echo_all arg... # Invoke $ECHO with all args, space-separated. func_echo_all () { $ECHO "" } case "$ECHO" in printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5 $as_echo "printf" >&6; } ;; print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5 $as_echo "print -r" >&6; } ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5 $as_echo "cat" >&6; } ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5 $as_echo_n "checking for a sed that does not truncate output... " >&6; } if ${ac_cv_path_SED+:} false; then : $as_echo_n "(cached) " >&6 else ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ for ac_i in 1 2 3 4 5 6 7; do ac_script="$ac_script$as_nl$ac_script" done echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed { ac_script=; unset ac_script;} if test -z "$SED"; then ac_path_SED_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in *GNU*) ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo '' >> "conftest.nl" "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_SED_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_SED="$ac_path_SED" ac_path_SED_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_SED_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_SED"; then as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5 fi else ac_cv_path_SED=$SED fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5 $as_echo "$ac_cv_path_SED" >&6; } SED="$ac_cv_path_SED" rm -f conftest.sed test -z "$SED" && SED=sed Xsed="$SED -e 1s/^X//" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else if test -z "$EGREP"; then ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5 $as_echo_n "checking for fgrep... " >&6; } if ${ac_cv_path_FGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1 then ac_cv_path_FGREP="$GREP -F" else if test -z "$FGREP"; then ac_path_FGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in *GNU*) ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;; *) ac_count=0 $as_echo_n 0123456789 >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" $as_echo 'FGREP' >> "conftest.nl" "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_FGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_FGREP_found && break 3 done done done IFS=$as_save_IFS if test -z "$ac_cv_path_FGREP"; then as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_FGREP=$FGREP fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5 $as_echo "$ac_cv_path_FGREP" >&6; } FGREP="$ac_cv_path_FGREP" test -z "$GREP" && GREP=grep # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5 $as_echo_n "checking for ld used by $CC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | ?:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the pathname of ld ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${lt_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$LD"; then lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then lt_cv_path_LD="$ac_dir/$ac_prog" # Check to see if the program is GNU ld. I'd rather use --version, # but apparently some variants of GNU ld only accept -v. # Break only if it was the GNU/non-GNU ld that we prefer. case `"$lt_cv_path_LD" -v 2>&1 &5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${lt_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU lds only accept -v. case `$LD -v 2>&1 &5 $as_echo "$lt_cv_prog_gnu_ld" >&6; } with_gnu_ld=$lt_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5 $as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; } if ${lt_cv_path_NM+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NM"; then # Let the user override the test. lt_cv_path_NM="$NM" else lt_nm_to_check="${ac_tool_prefix}nm" if test -n "$ac_tool_prefix" && test "$build" = "$host"; then lt_nm_to_check="$lt_nm_to_check nm" fi for lt_tmp_nm in $lt_nm_to_check; do lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. tmp_nm="$ac_dir/$lt_tmp_nm" if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then # Check to see if the nm accepts a BSD-compat flag. # Adding the `sed 1q' prevents false positives on HP-UX, which says: # nm: unknown option "B" ignored # Tru64's nm complains that /dev/null is an invalid object file case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in */dev/null* | *'Invalid file or object type'*) lt_cv_path_NM="$tmp_nm -B" break ;; *) case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in */dev/null*) lt_cv_path_NM="$tmp_nm -p" break ;; *) lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but continue # so that we can try to find one that supports BSD flags ;; esac ;; esac fi done IFS="$lt_save_ifs" done : ${lt_cv_path_NM=no} fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5 $as_echo "$lt_cv_path_NM" >&6; } if test "$lt_cv_path_NM" != "no"; then NM="$lt_cv_path_NM" else # Didn't find any BSD compatible name lister, look for dumpbin. if test -n "$DUMPBIN"; then : # Let the user override the test. else if test -n "$ac_tool_prefix"; then for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DUMPBIN"; then ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DUMPBIN=$ac_cv_prog_DUMPBIN if test -n "$DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5 $as_echo "$DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$DUMPBIN" && break done fi if test -z "$DUMPBIN"; then ac_ct_DUMPBIN=$DUMPBIN for ac_prog in dumpbin "link -dump" do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DUMPBIN"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN if test -n "$ac_ct_DUMPBIN"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5 $as_echo "$ac_ct_DUMPBIN" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_DUMPBIN" && break done if test "x$ac_ct_DUMPBIN" = x; then DUMPBIN=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DUMPBIN=$ac_ct_DUMPBIN fi fi case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in *COFF*) DUMPBIN="$DUMPBIN -symbols" ;; *) DUMPBIN=: ;; esac fi if test "$DUMPBIN" != ":"; then NM="$DUMPBIN" fi fi test -z "$NM" && NM=nm { $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5 $as_echo_n "checking the name lister ($NM) interface... " >&6; } if ${lt_cv_nm_interface+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 (eval echo "\"\$as_me:$LINENO: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5 $as_echo "$lt_cv_nm_interface" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5 $as_echo_n "checking whether ln -s works... " >&6; } LN_S=$as_ln_s if test "$LN_S" = "ln -s"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5 $as_echo "no, using $LN_S" >&6; } fi # find the maximum length of command line arguments { $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5 $as_echo_n "checking the maximum length of command line arguments... " >&6; } if ${lt_cv_sys_max_cmd_len+:} false; then : $as_echo_n "(cached) " >&6 else i=0 teststring="ABCD" case $build_os in msdosdjgpp*) # On DJGPP, this test can blow up pretty badly due to problems in libc # (any single argument exceeding 2000 bytes causes a buffer overrun # during glob expansion). Even if it were fixed, the result of this # check would be larger than it should be. lt_cv_sys_max_cmd_len=12288; # 12K is about right ;; gnu*) # Under GNU Hurd, this test is not required because there is # no limit to the length of command line arguments. # Libtool will interpret -1 as no limit whatsoever lt_cv_sys_max_cmd_len=-1; ;; cygwin* | mingw* | cegcc*) # On Win9x/ME, this test blows up -- it succeeds, but takes # about 5 minutes as the teststring grows exponentially. # Worse, since 9x/ME are not pre-emptively multitasking, # you end up with a "frozen" computer, even though with patience # the test eventually succeeds (with a max line length of 256k). # Instead, let's just punt: use the minimum linelength reported by # all of the supported platforms: 8192 (on NT/2K/XP). lt_cv_sys_max_cmd_len=8192; ;; mint*) # On MiNT this can take a long time and run out of memory. lt_cv_sys_max_cmd_len=8192; ;; amigaos*) # On AmigaOS with pdksh, this test takes hours, literally. # So we just punt and use a minimum line length of 8192. lt_cv_sys_max_cmd_len=8192; ;; netbsd* | freebsd* | openbsd* | darwin* | dragonfly*) # This has been around since 386BSD, at least. Likely further. if test -x /sbin/sysctl; then lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` elif test -x /usr/sbin/sysctl; then lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` else lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs fi # And add a safety zone lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` ;; interix*) # We know the value 262144 and hardcode it with a safety zone (like BSD) lt_cv_sys_max_cmd_len=196608 ;; osf*) # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not # nice to cause kernel panics so lets avoid the loop below. # First set a reasonable default. lt_cv_sys_max_cmd_len=16384 # if test -x /sbin/sysconfig; then case `/sbin/sysconfig -q proc exec_disable_arg_limit` in *1*) lt_cv_sys_max_cmd_len=-1 ;; esac fi ;; sco3.2v5*) lt_cv_sys_max_cmd_len=102400 ;; sysv5* | sco5v6* | sysv4.2uw2*) kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` if test -n "$kargmax"; then lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'` else lt_cv_sys_max_cmd_len=32768 fi ;; *) lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` if test -n "$lt_cv_sys_max_cmd_len"; then lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` else # Make teststring a little bigger before we do anything with it. # a 1K string should be a reasonable start. for i in 1 2 3 4 5 6 7 8 ; do teststring=$teststring$teststring done SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} # If test is not a shell built-in, we'll probably end up computing a # maximum length that is only half of the actual maximum length, but # we can't tell. while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \ = "X$teststring$teststring"; } >/dev/null 2>&1 && test $i != 17 # 1/2 MB should be enough do i=`expr $i + 1` teststring=$teststring$teststring done # Only check the string length outside the loop. lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` teststring= # Add a significant safety factor because C++ compilers can tack on # massive amounts of additional arguments before passing them to the # linker. It appears as though 1/2 is a usable value. lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` fi ;; esac fi if test -n $lt_cv_sys_max_cmd_len ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5 $as_echo "$lt_cv_sys_max_cmd_len" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5 $as_echo "none" >&6; } fi max_cmd_len=$lt_cv_sys_max_cmd_len : ${CP="cp -f"} : ${MV="mv -f"} : ${RM="rm -f"} { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5 $as_echo_n "checking whether the shell understands some XSI constructs... " >&6; } # Try some XSI features xsi_shell=no ( _lt_dummy="a/b/c" test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \ = c,a/b,b/c, \ && eval 'test $(( 1 + 1 )) -eq 2 \ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \ && xsi_shell=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5 $as_echo "$xsi_shell" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5 $as_echo_n "checking whether the shell understands \"+=\"... " >&6; } lt_shell_append=no ( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \ >/dev/null 2>&1 \ && lt_shell_append=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5 $as_echo "$lt_shell_append" >&6; } if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then lt_unset=unset else lt_unset=false fi # test EBCDIC or ASCII case `echo X|tr X '\101'` in A) # ASCII based system # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr lt_SP2NL='tr \040 \012' lt_NL2SP='tr \015\012 \040\040' ;; *) # EBCDIC based system lt_SP2NL='tr \100 \n' lt_NL2SP='tr \r\n \100\100' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5 $as_echo_n "checking how to convert $build file names to $host format... " >&6; } if ${lt_cv_to_host_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 ;; esac ;; *-*-cygwin* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin ;; *-*-cygwin* ) lt_cv_to_host_file_cmd=func_convert_file_noop ;; * ) # otherwise, assume *nix lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin ;; esac ;; * ) # unhandled hosts (and "normal" native builds) lt_cv_to_host_file_cmd=func_convert_file_noop ;; esac fi to_host_file_cmd=$lt_cv_to_host_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5 $as_echo "$lt_cv_to_host_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5 $as_echo_n "checking how to convert $build file names to toolchain format... " >&6; } if ${lt_cv_to_tool_file_cmd+:} false; then : $as_echo_n "(cached) " >&6 else #assume ordinary cross tools, or native build. lt_cv_to_tool_file_cmd=func_convert_file_noop case $host in *-*-mingw* ) case $build in *-*-mingw* ) # actually msys lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 ;; esac ;; esac fi to_tool_file_cmd=$lt_cv_to_tool_file_cmd { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5 $as_echo "$lt_cv_to_tool_file_cmd" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5 $as_echo_n "checking for $LD option to reload object files... " >&6; } if ${lt_cv_ld_reload_flag+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_reload_flag='-r' fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5 $as_echo "$lt_cv_ld_reload_flag" >&6; } reload_flag=$lt_cv_ld_reload_flag case $reload_flag in "" | " "*) ;; *) reload_flag=" $reload_flag" ;; esac reload_cmds='$LD$reload_flag -o $output$reload_objs' case $host_os in cygwin* | mingw* | pw32* | cegcc*) if test "$GCC" != yes; then reload_cmds=false fi ;; darwin*) if test "$GCC" = yes; then reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs' else reload_cmds='$LD$reload_flag -o $output$reload_objs' fi ;; esac if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. set dummy ${ac_tool_prefix}objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OBJDUMP"; then ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OBJDUMP=$ac_cv_prog_OBJDUMP if test -n "$OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5 $as_echo "$OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OBJDUMP"; then ac_ct_OBJDUMP=$OBJDUMP # Extract the first word of "objdump", so it can be a program name with args. set dummy objdump; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OBJDUMP"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP if test -n "$ac_ct_OBJDUMP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5 $as_echo "$ac_ct_OBJDUMP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OBJDUMP" = x; then OBJDUMP="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OBJDUMP=$ac_ct_OBJDUMP fi else OBJDUMP="$ac_cv_prog_OBJDUMP" fi test -z "$OBJDUMP" && OBJDUMP=objdump { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5 $as_echo_n "checking how to recognize dependent libraries... " >&6; } if ${lt_cv_deplibs_check_method+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_file_magic_cmd='$MAGIC_CMD' lt_cv_file_magic_test_file= lt_cv_deplibs_check_method='unknown' # Need to set the preceding variable on all platforms that support # interlibrary dependencies. # 'none' -- dependencies not supported. # `unknown' -- same as none, but documents that we really don't know. # 'pass_all' -- all dependencies passed with no checks. # 'test_compile' -- check by making test program. # 'file_magic [[regex]]' -- check by looking for files in library path # which responds to the $file_magic_cmd with a given extended regex. # If you have `file' or equivalent on your system and you're not sure # whether `pass_all' will *always* work, you probably want this one. case $host_os in aix[4-9]*) lt_cv_deplibs_check_method=pass_all ;; beos*) lt_cv_deplibs_check_method=pass_all ;; bsdi[45]*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_file_magic_cmd='/usr/bin/file -L' lt_cv_file_magic_test_file=/shlib/libc.so ;; cygwin*) # func_win32_libid is a shell function defined in ltmain.sh lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' ;; mingw* | pw32*) # Base MSYS/MinGW do not provide the 'file' command needed by # func_win32_libid shell function, so use a weaker test based on 'objdump', # unless we find 'file', for example because we are cross-compiling. # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin. if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' lt_cv_file_magic_cmd='func_win32_libid' else # Keep this pattern in sync with the one in func_win32_libid. lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' lt_cv_file_magic_cmd='$OBJDUMP -f' fi ;; cegcc*) # use the weaker test based on 'objdump'. See mingw*. lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' lt_cv_file_magic_cmd='$OBJDUMP -f' ;; darwin* | rhapsody*) lt_cv_deplibs_check_method=pass_all ;; freebsd* | dragonfly*) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then case $host_cpu in i*86 ) # Not sure whether the presence of OpenBSD here was a mistake. # Let's accept both of them until this is cleared up. lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` ;; esac else lt_cv_deplibs_check_method=pass_all fi ;; gnu*) lt_cv_deplibs_check_method=pass_all ;; haiku*) lt_cv_deplibs_check_method=pass_all ;; hpux10.20* | hpux11*) lt_cv_file_magic_cmd=/usr/bin/file case $host_cpu in ia64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so ;; hppa*64*) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]' lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl ;; *) lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library' lt_cv_file_magic_test_file=/usr/lib/libc.sl ;; esac ;; interix[3-9]*) # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$' ;; irix5* | irix6* | nonstopux*) case $LD in *-32|*"-32 ") libmagic=32-bit;; *-n32|*"-n32 ") libmagic=N32;; *-64|*"-64 ") libmagic=64-bit;; *) libmagic=never-match;; esac lt_cv_deplibs_check_method=pass_all ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) lt_cv_deplibs_check_method=pass_all ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$' fi ;; newos6*) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_file_magic_cmd=/usr/bin/file lt_cv_file_magic_test_file=/usr/lib/libnls.so ;; *nto* | *qnx*) lt_cv_deplibs_check_method=pass_all ;; openbsd*) if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$' else lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' fi ;; osf3* | osf4* | osf5*) lt_cv_deplibs_check_method=pass_all ;; rdos*) lt_cv_deplibs_check_method=pass_all ;; solaris*) lt_cv_deplibs_check_method=pass_all ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) lt_cv_deplibs_check_method=pass_all ;; sysv4 | sysv4.3*) case $host_vendor in motorola) lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]' lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` ;; ncr) lt_cv_deplibs_check_method=pass_all ;; sequent) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )' ;; sni) lt_cv_file_magic_cmd='/bin/file' lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib" lt_cv_file_magic_test_file=/lib/libc.so ;; siemens) lt_cv_deplibs_check_method=pass_all ;; pc) lt_cv_deplibs_check_method=pass_all ;; esac ;; tpf*) lt_cv_deplibs_check_method=pass_all ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5 $as_echo "$lt_cv_deplibs_check_method" >&6; } file_magic_glob= want_nocaseglob=no if test "$build" = "$host"; then case $host_os in mingw* | pw32*) if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then want_nocaseglob=yes else file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"` fi ;; esac fi file_magic_cmd=$lt_cv_file_magic_cmd deplibs_check_method=$lt_cv_deplibs_check_method test -z "$deplibs_check_method" && deplibs_check_method=unknown if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. set dummy ${ac_tool_prefix}dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DLLTOOL"; then ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DLLTOOL=$ac_cv_prog_DLLTOOL if test -n "$DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5 $as_echo "$DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DLLTOOL"; then ac_ct_DLLTOOL=$DLLTOOL # Extract the first word of "dlltool", so it can be a program name with args. set dummy dlltool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DLLTOOL"; then ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL if test -n "$ac_ct_DLLTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5 $as_echo "$ac_ct_DLLTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DLLTOOL" = x; then DLLTOOL="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DLLTOOL=$ac_ct_DLLTOOL fi else DLLTOOL="$ac_cv_prog_DLLTOOL" fi test -z "$DLLTOOL" && DLLTOOL=dlltool { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5 $as_echo_n "checking how to associate runtime and link libraries... " >&6; } if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_sharedlib_from_linklib_cmd='unknown' case $host_os in cygwin* | mingw* | pw32* | cegcc*) # two different shell functions defined in ltmain.sh # decide which to use based on capabilities of $DLLTOOL case `$DLLTOOL --help 2>&1` in *--identify-strict*) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib ;; *) lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback ;; esac ;; *) # fallback: assume linklib IS sharedlib lt_cv_sharedlib_from_linklib_cmd="$ECHO" ;; esac fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5 $as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; } sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO if test -n "$ac_tool_prefix"; then for ac_prog in ar do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AR"; then ac_cv_prog_AR="$AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AR=$ac_cv_prog_AR if test -n "$AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5 $as_echo "$AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$AR" && break done fi if test -z "$AR"; then ac_ct_AR=$AR for ac_prog in ar do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_AR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_AR"; then ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_AR=$ac_cv_prog_ac_ct_AR if test -n "$ac_ct_AR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5 $as_echo "$ac_ct_AR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -n "$ac_ct_AR" && break done if test "x$ac_ct_AR" = x; then AR="false" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac AR=$ac_ct_AR fi fi : ${AR=ar} : ${AR_FLAGS=cru} { $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5 $as_echo_n "checking for archiver @FILE support... " >&6; } if ${lt_cv_ar_at_file+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ar_at_file=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : echo conftest.$ac_objext > conftest.lst lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5' { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -eq 0; then # Ensure the archiver fails upon bogus file names. rm -f conftest.$ac_objext libconftest.a { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5 (eval $lt_ar_try) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } if test "$ac_status" -ne 0; then lt_cv_ar_at_file=@ fi fi rm -f conftest.* libconftest.a fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5 $as_echo "$lt_cv_ar_at_file" >&6; } if test "x$lt_cv_ar_at_file" = xno; then archiver_list_spec= else archiver_list_spec=$lt_cv_ar_at_file fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi test -z "$STRIP" && STRIP=: if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 $as_echo "$RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 $as_echo "$ac_ct_RANLIB" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi test -z "$RANLIB" && RANLIB=: # Determine commands to create old-style static archives. old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' old_postinstall_cmds='chmod 644 $oldlib' old_postuninstall_cmds= if test -n "$RANLIB"; then case $host_os in openbsd*) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib" ;; *) old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib" ;; esac old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib" fi case $host_os in darwin*) lock_old_archive_extraction=yes ;; *) lock_old_archive_extraction=no ;; esac # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Check for command to grab the raw symbol name followed by C symbol from nm. { $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5 $as_echo_n "checking command to parse $NM output from $compiler object... " >&6; } if ${lt_cv_sys_global_symbol_pipe+:} false; then : $as_echo_n "(cached) " >&6 else # These are sane defaults that work on at least a few old systems. # [They come from Ultrix. What could be older than Ultrix?!! ;)] # Character class describing NM global symbol codes. symcode='[BCDEGRST]' # Regexp to match symbols that can be accessed directly from C. sympat='\([_A-Za-z][_A-Za-z0-9]*\)' # Define system-specific variables. case $host_os in aix*) symcode='[BCDT]' ;; cygwin* | mingw* | pw32* | cegcc*) symcode='[ABCDGISTW]' ;; hpux*) if test "$host_cpu" = ia64; then symcode='[ABCDEGRST]' fi ;; irix* | nonstopux*) symcode='[BCDEGRST]' ;; osf*) symcode='[BCDEGQRST]' ;; solaris*) symcode='[BDRT]' ;; sco3.2v5*) symcode='[DT]' ;; sysv4.2uw2*) symcode='[DT]' ;; sysv5* | sco5v6* | unixware* | OpenUNIX*) symcode='[ABDT]' ;; sysv4) symcode='[DFNSTU]' ;; esac # If we're using GNU nm, then use its standard symbol codes. case `$NM -V 2>&1` in *GNU* | *'with BFD'*) symcode='[ABCDGIRSTW]' ;; esac # Transform an extracted symbol line into a proper C declaration. # Some systems (esp. on ia64) link data and code symbols differently, # so use this general approach. lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'" # Transform an extracted symbol line into symbol name and symbol address lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'" lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'" # Handle CRLF in mingw tool chain opt_cr= case $build_os in mingw*) opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp ;; esac # Try without a prefix underscore, then with it. for ac_symprfx in "" "_"; do # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. symxfrm="\\1 $ac_symprfx\\2 \\2" # Write the raw and C identifiers. if test "$lt_cv_nm_interface" = "MS dumpbin"; then # Fake it for dumpbin and say T for any non-static function # and D for any global variable. # Also find C++ and __fastcall symbols from MSVC++, # which start with @ or ?. lt_cv_sys_global_symbol_pipe="$AWK '"\ " {last_section=section; section=\$ 3};"\ " /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ " \$ 0!~/External *\|/{next};"\ " / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ " {if(hide[section]) next};"\ " {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\ " {split(\$ 0, a, /\||\r/); split(a[2], s)};"\ " s[1]~/^[@?]/{print s[1], s[1]; next};"\ " s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\ " ' prfx=^$ac_symprfx" else lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" fi lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" # Check to see that the pipe works correctly. pipe_works=no rm -f conftest* cat > conftest.$ac_ext <<_LT_EOF #ifdef __cplusplus extern "C" { #endif char nm_test_var; void nm_test_func(void); void nm_test_func(void){} #ifdef __cplusplus } #endif int main(){nm_test_var='a';nm_test_func();return(0);} _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then # Now try to grab the symbols. nlist=conftest.nm if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5 (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s "$nlist"; then # Try sorting and uniquifying the output. if sort "$nlist" | uniq > "$nlist"T; then mv -f "$nlist"T "$nlist" else rm -f "$nlist"T fi # Make sure that we snagged all the symbols we need. if $GREP ' nm_test_var$' "$nlist" >/dev/null; then if $GREP ' nm_test_func$' "$nlist" >/dev/null; then cat <<_LT_EOF > conftest.$ac_ext /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) /* DATA imports from DLLs on WIN32 con't be const, because runtime relocations are performed -- see ld's documentation on pseudo-relocs. */ # define LT_DLSYM_CONST #elif defined(__osf__) /* This system does not cope well with relocations in const data. */ # define LT_DLSYM_CONST #else # define LT_DLSYM_CONST const #endif #ifdef __cplusplus extern "C" { #endif _LT_EOF # Now generate the symbol file. eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' cat <<_LT_EOF >> conftest.$ac_ext /* The mapping between symbol names and symbols. */ LT_DLSYM_CONST struct { const char *name; void *address; } lt__PROGRAM__LTX_preloaded_symbols[] = { { "@PROGRAM@", (void *) 0 }, _LT_EOF $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext cat <<\_LT_EOF >> conftest.$ac_ext {0, (void *) 0} }; /* This works around a problem in FreeBSD linker */ #ifdef FREEBSD_WORKAROUND static const void *lt_preloaded_setup() { return lt__PROGRAM__LTX_preloaded_symbols; } #endif #ifdef __cplusplus } #endif _LT_EOF # Now try linking the two files. mv conftest.$ac_objext conftstm.$ac_objext lt_globsym_save_LIBS=$LIBS lt_globsym_save_CFLAGS=$CFLAGS LIBS="conftstm.$ac_objext" CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag" if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext}; then pipe_works=yes fi LIBS=$lt_globsym_save_LIBS CFLAGS=$lt_globsym_save_CFLAGS else echo "cannot find nm_test_func in $nlist" >&5 fi else echo "cannot find nm_test_var in $nlist" >&5 fi else echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5 fi else echo "$progname: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -rf conftest* conftst* # Do not use the global_symbol_pipe unless it works. if test "$pipe_works" = yes; then break else lt_cv_sys_global_symbol_pipe= fi done fi if test -z "$lt_cv_sys_global_symbol_pipe"; then lt_cv_sys_global_symbol_to_cdecl= fi if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5 $as_echo "failed" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } fi # Response file support. if test "$lt_cv_nm_interface" = "MS dumpbin"; then nm_file_list_spec='@' elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then nm_file_list_spec='@' fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5 $as_echo_n "checking for sysroot... " >&6; } # Check whether --with-sysroot was given. if test "${with_sysroot+set}" = set; then : withval=$with_sysroot; else with_sysroot=no fi lt_sysroot= case ${with_sysroot} in #( yes) if test "$GCC" = yes; then lt_sysroot=`$CC --print-sysroot 2>/dev/null` fi ;; #( /*) lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` ;; #( no|'') ;; #( *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5 $as_echo "${with_sysroot}" >&6; } as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5 $as_echo "${lt_sysroot:-no}" >&6; } # Check whether --enable-libtool-lock was given. if test "${enable_libtool_lock+set}" = set; then : enableval=$enable_libtool_lock; fi test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes # Some flags need to be propagated to the compiler or linker for good # libtool support. case $host in ia64-*-hpux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.$ac_objext` in *ELF-32*) HPUX_IA64_MODE="32" ;; *ELF-64*) HPUX_IA64_MODE="64" ;; esac fi rm -rf conftest* ;; *-*-irix6*) # Find out which ABI we are using. echo '#line '$LINENO' "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then if test "$lt_cv_prog_gnu_ld" = yes; then case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -melf32bsmip" ;; *N32*) LD="${LD-ld} -melf32bmipn32" ;; *64-bit*) LD="${LD-ld} -melf64bmip" ;; esac else case `/usr/bin/file conftest.$ac_objext` in *32-bit*) LD="${LD-ld} -32" ;; *N32*) LD="${LD-ld} -n32" ;; *64-bit*) LD="${LD-ld} -64" ;; esac fi fi rm -rf conftest* ;; x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \ s390*-*linux*|s390*-*tpf*|sparc*-*linux*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *32-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_i386_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_i386" ;; ppc64-*linux*|powerpc64-*linux*) LD="${LD-ld} -m elf32ppclinux" ;; s390x-*linux*) LD="${LD-ld} -m elf_s390" ;; sparc64-*linux*) LD="${LD-ld} -m elf32_sparc" ;; esac ;; *64-bit*) case $host in x86_64-*kfreebsd*-gnu) LD="${LD-ld} -m elf_x86_64_fbsd" ;; x86_64-*linux*) LD="${LD-ld} -m elf_x86_64" ;; ppc*-*linux*|powerpc*-*linux*) LD="${LD-ld} -m elf64ppc" ;; s390*-*linux*|s390*-*tpf*) LD="${LD-ld} -m elf64_s390" ;; sparc*-*linux*) LD="${LD-ld} -m elf64_sparc" ;; esac ;; esac fi rm -rf conftest* ;; *-*-sco3.2v5*) # On SCO OpenServer 5, we need -belf to get full-featured binaries. SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5 $as_echo_n "checking whether the C compiler needs -belf... " >&6; } if ${lt_cv_cc_needs_belf+:} false; then : $as_echo_n "(cached) " >&6 else ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_cc_needs_belf=yes else lt_cv_cc_needs_belf=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5 $as_echo "$lt_cv_cc_needs_belf" >&6; } if test x"$lt_cv_cc_needs_belf" != x"yes"; then # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf CFLAGS="$SAVE_CFLAGS" fi ;; sparc*-*solaris*) # Find out which ABI we are using. echo 'int i;' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then case `/usr/bin/file conftest.o` in *64-bit*) case $lt_cv_prog_gnu_ld in yes*) LD="${LD-ld} -m elf64_sparc" ;; *) if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then LD="${LD-ld} -64" fi ;; esac ;; esac fi rm -rf conftest* ;; esac need_locks="$enable_libtool_lock" if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args. set dummy ${ac_tool_prefix}mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$MANIFEST_TOOL"; then ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL if test -n "$MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5 $as_echo "$MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_MANIFEST_TOOL"; then ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL # Extract the first word of "mt", so it can be a program name with args. set dummy mt; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_MANIFEST_TOOL"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL if test -n "$ac_ct_MANIFEST_TOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5 $as_echo "$ac_ct_MANIFEST_TOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_MANIFEST_TOOL" = x; then MANIFEST_TOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL fi else MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL" fi test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5 $as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; } if ${lt_cv_path_mainfest_tool+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_path_mainfest_tool=no echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5 $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out cat conftest.err >&5 if $GREP 'Manifest Tool' conftest.out > /dev/null; then lt_cv_path_mainfest_tool=yes fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5 $as_echo "$lt_cv_path_mainfest_tool" >&6; } if test "x$lt_cv_path_mainfest_tool" != xyes; then MANIFEST_TOOL=: fi case $host_os in rhapsody* | darwin*) if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args. set dummy ${ac_tool_prefix}dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$DSYMUTIL"; then ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi DSYMUTIL=$ac_cv_prog_DSYMUTIL if test -n "$DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5 $as_echo "$DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_DSYMUTIL"; then ac_ct_DSYMUTIL=$DSYMUTIL # Extract the first word of "dsymutil", so it can be a program name with args. set dummy dsymutil; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_DSYMUTIL"; then ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL if test -n "$ac_ct_DSYMUTIL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5 $as_echo "$ac_ct_DSYMUTIL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_DSYMUTIL" = x; then DSYMUTIL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac DSYMUTIL=$ac_ct_DSYMUTIL fi else DSYMUTIL="$ac_cv_prog_DSYMUTIL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args. set dummy ${ac_tool_prefix}nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$NMEDIT"; then ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi NMEDIT=$ac_cv_prog_NMEDIT if test -n "$NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5 $as_echo "$NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_NMEDIT"; then ac_ct_NMEDIT=$NMEDIT # Extract the first word of "nmedit", so it can be a program name with args. set dummy nmedit; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_NMEDIT"; then ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT if test -n "$ac_ct_NMEDIT"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5 $as_echo "$ac_ct_NMEDIT" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_NMEDIT" = x; then NMEDIT=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac NMEDIT=$ac_ct_NMEDIT fi else NMEDIT="$ac_cv_prog_NMEDIT" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args. set dummy ${ac_tool_prefix}lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$LIPO"; then ac_cv_prog_LIPO="$LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi LIPO=$ac_cv_prog_LIPO if test -n "$LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5 $as_echo "$LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_LIPO"; then ac_ct_LIPO=$LIPO # Extract the first word of "lipo", so it can be a program name with args. set dummy lipo; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_LIPO+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_LIPO"; then ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO if test -n "$ac_ct_LIPO"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5 $as_echo "$ac_ct_LIPO" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_LIPO" = x; then LIPO=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIPO=$ac_ct_LIPO fi else LIPO="$ac_cv_prog_LIPO" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args. set dummy ${ac_tool_prefix}otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL"; then ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL=$ac_cv_prog_OTOOL if test -n "$OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5 $as_echo "$OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL"; then ac_ct_OTOOL=$OTOOL # Extract the first word of "otool", so it can be a program name with args. set dummy otool; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL"; then ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL if test -n "$ac_ct_OTOOL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5 $as_echo "$ac_ct_OTOOL" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL" = x; then OTOOL=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL=$ac_ct_OTOOL fi else OTOOL="$ac_cv_prog_OTOOL" fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args. set dummy ${ac_tool_prefix}otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$OTOOL64"; then ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi OTOOL64=$ac_cv_prog_OTOOL64 if test -n "$OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5 $as_echo "$OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_prog_OTOOL64"; then ac_ct_OTOOL64=$OTOOL64 # Extract the first word of "otool64", so it can be a program name with args. set dummy otool64; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_OTOOL64"; then ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64 if test -n "$ac_ct_OTOOL64"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5 $as_echo "$ac_ct_OTOOL64" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_ct_OTOOL64" = x; then OTOOL64=":" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac OTOOL64=$ac_ct_OTOOL64 fi else OTOOL64="$ac_cv_prog_OTOOL64" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5 $as_echo_n "checking for -single_module linker flag... " >&6; } if ${lt_cv_apple_cc_single_mod+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_apple_cc_single_mod=no if test -z "${LT_MULTI_MODULE}"; then # By default we will add the -single_module flag. You can override # by either setting the environment variable LT_MULTI_MODULE # non-empty at configure time, or by adding -multi_module to the # link flags. rm -rf libconftest.dylib* echo "int foo(void){return 1;}" > conftest.c echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c" >&5 $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err _lt_result=$? if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then lt_cv_apple_cc_single_mod=yes else cat conftest.err >&5 fi rm -rf libconftest.dylib* rm -f conftest.* fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5 $as_echo "$lt_cv_apple_cc_single_mod" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5 $as_echo_n "checking for -exported_symbols_list linker flag... " >&6; } if ${lt_cv_ld_exported_symbols_list+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_exported_symbols_list=no save_LDFLAGS=$LDFLAGS echo "_main" > conftest.sym LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_ld_exported_symbols_list=yes else lt_cv_ld_exported_symbols_list=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5 $as_echo "$lt_cv_ld_exported_symbols_list" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5 $as_echo_n "checking for -force_load linker flag... " >&6; } if ${lt_cv_ld_force_load+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_ld_force_load=no cat > conftest.c << _LT_EOF int forced_loaded() { return 2;} _LT_EOF echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 echo "$AR cru libconftest.a conftest.o" >&5 $AR cru libconftest.a conftest.o 2>&5 echo "$RANLIB libconftest.a" >&5 $RANLIB libconftest.a 2>&5 cat > conftest.c << _LT_EOF int main() { return 0;} _LT_EOF echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5 $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err _lt_result=$? if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then lt_cv_ld_force_load=yes else cat conftest.err >&5 fi rm -f conftest.err libconftest.a conftest conftest.c rm -rf conftest.dSYM fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5 $as_echo "$lt_cv_ld_force_load" >&6; } case $host_os in rhapsody* | darwin1.[012]) _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;; darwin1.*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; darwin*) # darwin 5.x on # if running on 10.5 or later, the deployment target defaults # to the OS version, if on x86, and 10.4, the deployment # target defaults to 10.4. Don't you love it? case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; 10.[012]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; esac ;; esac if test "$lt_cv_apple_cc_single_mod" = "yes"; then _lt_dar_single_mod='$single_module' fi if test "$lt_cv_ld_exported_symbols_list" = "yes"; then _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym' else _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}' fi if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then _lt_dsymutil='~$DSYMUTIL $lib || :' else _lt_dsymutil= fi ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : else # Broken: fails on valid input. continue fi rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in dlfcn.h do : ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default " if test "x$ac_cv_header_dlfcn_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DLFCN_H 1 _ACEOF fi done # Set options # Check whether --enable-static was given. if test "${enable_static+set}" = set; then : enableval=$enable_static; p=${PACKAGE-default} case $enableval in yes) enable_static=yes ;; no) enable_static=no ;; *) enable_static=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_static=yes fi done IFS="$lt_save_ifs" ;; esac else enable_static=no fi enable_dlopen=no enable_win32_dll=no # Check whether --enable-shared was given. if test "${enable_shared+set}" = set; then : enableval=$enable_shared; p=${PACKAGE-default} case $enableval in yes) enable_shared=yes ;; no) enable_shared=no ;; *) enable_shared=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_shared=yes fi done IFS="$lt_save_ifs" ;; esac else enable_shared=yes fi # Check whether --with-pic was given. if test "${with_pic+set}" = set; then : withval=$with_pic; pic_mode="$withval" else pic_mode=default fi test -z "$pic_mode" && pic_mode=default # Check whether --enable-fast-install was given. if test "${enable_fast_install+set}" = set; then : enableval=$enable_fast_install; p=${PACKAGE-default} case $enableval in yes) enable_fast_install=yes ;; no) enable_fast_install=no ;; *) enable_fast_install=no # Look at the argument we got. We use all the common list separators. lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR," for pkg in $enableval; do IFS="$lt_save_ifs" if test "X$pkg" = "X$p"; then enable_fast_install=yes fi done IFS="$lt_save_ifs" ;; esac else enable_fast_install=yes fi # This can be used to rebuild libtool when needed LIBTOOL_DEPS="$ltmain" # Always use our own libtool. LIBTOOL='$(SHELL) $(top_builddir)/libtool' test -z "$LN_S" && LN_S="ln -s" if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5 $as_echo_n "checking for objdir... " >&6; } if ${lt_cv_objdir+:} false; then : $as_echo_n "(cached) " >&6 else rm -f .libs 2>/dev/null mkdir .libs 2>/dev/null if test -d .libs; then lt_cv_objdir=.libs else # MS-DOS does not allow filenames that begin with a dot. lt_cv_objdir=_libs fi rmdir .libs 2>/dev/null fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5 $as_echo "$lt_cv_objdir" >&6; } objdir=$lt_cv_objdir cat >>confdefs.h <<_ACEOF #define LT_OBJDIR "$lt_cv_objdir/" _ACEOF case $host_os in aix3*) # AIX sometimes has problems with the GCC collect2 program. For some # reason, if we set the COLLECT_NAMES environment variable, the problems # vanish in a puff of smoke. if test "X${COLLECT_NAMES+set}" != Xset; then COLLECT_NAMES= export COLLECT_NAMES fi ;; esac # Global variables: ofile=libtool can_build_shared=yes # All known linkers require a `.a' archive for static linking (except MSVC, # which needs '.lib'). libext=a with_gnu_ld="$lt_cv_prog_gnu_ld" old_CC="$CC" old_CFLAGS="$CFLAGS" # Set sane defaults for various variables test -z "$CC" && CC=cc test -z "$LTCC" && LTCC=$CC test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS test -z "$LD" && LD=ld test -z "$ac_objext" && ac_objext=o for cc_temp in $compiler""; do case $cc_temp in compile | *[\\/]compile | ccache | *[\\/]ccache ) ;; distcc | *[\\/]distcc | purify | *[\\/]purify ) ;; \-*) ;; *) break;; esac done cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` # Only perform the check for file, if the check method requires it test -z "$MAGIC_CMD" && MAGIC_CMD=file case $deplibs_check_method in file_magic*) if test "$file_magic_cmd" = '$MAGIC_CMD'; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5 $as_echo_n "checking for ${ac_tool_prefix}file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/${ac_tool_prefix}file; then lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test -z "$lt_cv_path_MAGIC_CMD"; then if test -n "$ac_tool_prefix"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5 $as_echo_n "checking for file... " >&6; } if ${lt_cv_path_MAGIC_CMD+:} false; then : $as_echo_n "(cached) " >&6 else case $MAGIC_CMD in [\\/*] | ?:[\\/]*) lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path. ;; *) lt_save_MAGIC_CMD="$MAGIC_CMD" lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR ac_dummy="/usr/bin$PATH_SEPARATOR$PATH" for ac_dir in $ac_dummy; do IFS="$lt_save_ifs" test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/file; then lt_cv_path_MAGIC_CMD="$ac_dir/file" if test -n "$file_magic_test_file"; then case $deplibs_check_method in "file_magic "*) file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | $EGREP "$file_magic_regex" > /dev/null; then : else cat <<_LT_EOF 1>&2 *** Warning: the command libtool uses to detect shared libraries, *** $file_magic_cmd, produces output that libtool cannot recognize. *** The result is that libtool may fail to recognize shared libraries *** as such. This will affect the creation of libtool libraries that *** depend on shared libraries, but programs linked with such libtool *** libraries will work regardless of this problem. Nevertheless, you *** may want to report the problem to your system manager and/or to *** bug-libtool@gnu.org _LT_EOF fi ;; esac fi break fi done IFS="$lt_save_ifs" MAGIC_CMD="$lt_save_MAGIC_CMD" ;; esac fi MAGIC_CMD="$lt_cv_path_MAGIC_CMD" if test -n "$MAGIC_CMD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5 $as_echo "$MAGIC_CMD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi else MAGIC_CMD=: fi fi fi ;; esac # Use C for the default configuration in the libtool script lt_save_CC="$CC" ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu # Source file extension for C test sources. ac_ext=c # Object file extension for compiled C test sources. objext=o objext=$objext # Code to be used in simple compile tests lt_simple_compile_test_code="int some_variable = 0;" # Code to be used in simple link tests lt_simple_link_test_code='int main(){return(0);}' # If no C compiler was specified, use CC. LTCC=${LTCC-"$CC"} # If no C compiler flags were specified, use CFLAGS. LTCFLAGS=${LTCFLAGS-"$CFLAGS"} # Allow CC to be a program name with arguments. compiler=$CC # Save the default compiler, since it gets overwritten when the other # tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. compiler_DEFAULT=$CC # save warnings/boilerplate of simple test code ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" >conftest.$ac_ext eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_compiler_boilerplate=`cat conftest.err` $RM conftest* ac_outfile=conftest.$ac_objext echo "$lt_simple_link_test_code" >conftest.$ac_ext eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err _lt_linker_boilerplate=`cat conftest.err` $RM -r conftest* ## CAVEAT EMPTOR: ## There is no encapsulation within the following macros, do not change ## the running order or otherwise move them around unless you know exactly ## what you are doing... if test -n "$compiler"; then lt_prog_compiler_no_builtin_flag= if test "$GCC" = yes; then case $cc_basename in nvcc*) lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;; *) lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5 $as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; } if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_rtti_exceptions=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-fno-rtti -fno-exceptions" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_rtti_exceptions=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5 $as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; } if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions" else : fi fi lt_prog_compiler_wl= lt_prog_compiler_pic= lt_prog_compiler_static= if test "$GCC" = yes; then lt_prog_compiler_wl='-Wl,' lt_prog_compiler_static='-static' case $host_os in aix*) # All AIX code is PIC. if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support lt_prog_compiler_pic='-fPIC' ;; m68k) # FIXME: we need at least 68020 code to build shared libraries, but # adding the `-m68020' flag to GCC prevents building anything better, # like `-m68040'. lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4' ;; esac ;; beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) # PIC is the default for these OSes. ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # 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). # Although the cygwin gcc ignores -fPIC, still need this for old-style # (--disable-auto-import) libraries lt_prog_compiler_pic='-DDLL_EXPORT' ;; darwin* | rhapsody*) # PIC is the default on this platform # Common symbols not allowed in MH_DYLIB files lt_prog_compiler_pic='-fno-common' ;; haiku*) # PIC is the default for Haiku. # The "-static" flag exists, but is broken. lt_prog_compiler_static= ;; hpux*) # PIC is the default for 64-bit PA HP-UX, but not for 32-bit # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag # sets the default TLS model and affects inlining. case $host_cpu in hppa*64*) # +Z the default ;; *) lt_prog_compiler_pic='-fPIC' ;; esac ;; interix[3-9]*) # Interix 3.x gcc -fpic/-fPIC options generate broken code. # Instead, we relocate shared libraries at runtime. ;; msdosdjgpp*) # Just because we use GCC doesn't mean we suddenly get shared libraries # on systems that don't support them. lt_prog_compiler_can_build_shared=no enable_shared=no ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; sysv4*MP*) if test -d /usr/nec; then lt_prog_compiler_pic=-Kconform_pic fi ;; *) lt_prog_compiler_pic='-fPIC' ;; esac case $cc_basename in nvcc*) # Cuda Compiler Driver 2.2 lt_prog_compiler_wl='-Xlinker ' lt_prog_compiler_pic='-Xcompiler -fPIC' ;; esac else # PORTME Check for flag to pass linker flags through the system compiler. case $host_os in aix*) lt_prog_compiler_wl='-Wl,' if test "$host_cpu" = ia64; then # AIX 5 now supports IA64 processor lt_prog_compiler_static='-Bstatic' else lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp' fi ;; mingw* | cygwin* | pw32* | os2* | cegcc*) # This hack is so that the source file can tell whether it is being # built for inclusion in a dll (and should export symbols for example). lt_prog_compiler_pic='-DDLL_EXPORT' ;; hpux9* | hpux10* | hpux11*) lt_prog_compiler_wl='-Wl,' # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but # not for PA HP-UX. case $host_cpu in hppa*64*|ia64*) # +Z the default ;; *) lt_prog_compiler_pic='+Z' ;; esac # Is there a better lt_prog_compiler_static that works with the bundled CC? lt_prog_compiler_static='${wl}-a ${wl}archive' ;; irix5* | irix6* | nonstopux*) lt_prog_compiler_wl='-Wl,' # PIC (with -KPIC) is the default. lt_prog_compiler_static='-non_shared' ;; linux* | k*bsd*-gnu | kopensolaris*-gnu) case $cc_basename in # old Intel for x86_64 which still supported -KPIC. ecc*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-static' ;; # icc used to be incompatible with GCC. # ICC 10 doesn't accept -KPIC any more. icc* | ifort*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fPIC' lt_prog_compiler_static='-static' ;; # Lahey Fortran 8.1. lf95*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='--shared' lt_prog_compiler_static='--static' ;; nagfor*) # NAG Fortran compiler lt_prog_compiler_wl='-Wl,-Wl,,' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group compilers (*not* the Pentium gcc compiler, # which looks to be a dead project) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-fpic' lt_prog_compiler_static='-Bstatic' ;; ccc*) lt_prog_compiler_wl='-Wl,' # All Alpha code is PIC. lt_prog_compiler_static='-non_shared' ;; xl* | bgxl* | bgf* | mpixl*) # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-qpic' lt_prog_compiler_static='-qstaticlink' ;; *) case `$CC -V 2>&1 | sed 5q` in *Sun\ F* | *Sun*Fortran*) # Sun Fortran 8.3 passes all unrecognized flags to the linker lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='' ;; *Sun\ C*) # Sun C 5.9 lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' lt_prog_compiler_wl='-Wl,' ;; esac ;; esac ;; newsos6) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; *nto* | *qnx*) # QNX uses GNU C++, but need to define -shared option too, otherwise # it will coredump. lt_prog_compiler_pic='-fPIC -shared' ;; osf3* | osf4* | osf5*) lt_prog_compiler_wl='-Wl,' # All OSF/1 code is PIC. lt_prog_compiler_static='-non_shared' ;; rdos*) lt_prog_compiler_static='-non_shared' ;; solaris*) lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' case $cc_basename in f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) lt_prog_compiler_wl='-Qoption ld ';; *) lt_prog_compiler_wl='-Wl,';; esac ;; sunos4*) lt_prog_compiler_wl='-Qoption ld ' lt_prog_compiler_pic='-PIC' lt_prog_compiler_static='-Bstatic' ;; sysv4 | sysv4.2uw2* | sysv4.3*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; sysv4*MP*) if test -d /usr/nec ;then lt_prog_compiler_pic='-Kconform_pic' lt_prog_compiler_static='-Bstatic' fi ;; sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_pic='-KPIC' lt_prog_compiler_static='-Bstatic' ;; unicos*) lt_prog_compiler_wl='-Wl,' lt_prog_compiler_can_build_shared=no ;; uts4*) lt_prog_compiler_pic='-pic' lt_prog_compiler_static='-Bstatic' ;; *) lt_prog_compiler_can_build_shared=no ;; esac fi case $host_os in # For platforms which do not support PIC, -DPIC is meaningless: *djgpp*) lt_prog_compiler_pic= ;; *) lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC" ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5 $as_echo_n "checking for $compiler option to produce PIC... " >&6; } if ${lt_cv_prog_compiler_pic+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic=$lt_prog_compiler_pic fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5 $as_echo "$lt_cv_prog_compiler_pic" >&6; } lt_prog_compiler_pic=$lt_cv_prog_compiler_pic # # Check to make sure the PIC flag actually works. # if test -n "$lt_prog_compiler_pic"; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5 $as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; } if ${lt_cv_prog_compiler_pic_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_pic_works=no ac_outfile=conftest.$ac_objext echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="$lt_prog_compiler_pic -DPIC" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. # The option is referenced via a variable to avoid confusing sed. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_pic_works=yes fi fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5 $as_echo "$lt_cv_prog_compiler_pic_works" >&6; } if test x"$lt_cv_prog_compiler_pic_works" = xyes; then case $lt_prog_compiler_pic in "" | " "*) ;; *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;; esac else lt_prog_compiler_pic= lt_prog_compiler_can_build_shared=no fi fi # # Check to make sure the static flag actually works. # wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5 $as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; } if ${lt_cv_prog_compiler_static_works+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_static_works=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS $lt_tmp_static_flag" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler_static_works=yes fi else lt_cv_prog_compiler_static_works=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5 $as_echo "$lt_cv_prog_compiler_static_works" >&6; } if test x"$lt_cv_prog_compiler_static_works" = xyes; then : else lt_prog_compiler_static= fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5 $as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; } if ${lt_cv_prog_compiler_c_o+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler_c_o=no $RM -r conftest 2>/dev/null mkdir conftest cd conftest mkdir out echo "$lt_simple_compile_test_code" > conftest.$ac_ext lt_compiler_flag="-o out/conftest2.$ac_objext" # Insert the option either (1) after the last *FLAGS variable, or # (2) before a word containing "conftest.", or (3) at the end. # Note that $ac_compile itself does not contain backslashes and begins # with a dollar sign (not a hyphen), so the echo should work correctly. lt_compile=`echo "$ac_compile" | $SED \ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then lt_cv_prog_compiler_c_o=yes fi fi chmod u+w . 2>&5 $RM conftest* # SGI C++ compiler will create directory out/ii_files/ for # template instantiation test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files $RM out/* && rmdir out cd .. $RM -r conftest $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5 $as_echo "$lt_cv_prog_compiler_c_o" >&6; } hard_links="nottested" if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then # do not overwrite the value of need_locks provided by the user { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5 $as_echo_n "checking if we can lock with hard links... " >&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 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5 $as_echo "$hard_links" >&6; } if test "$hard_links" = no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5 $as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;} need_locks=warn fi else need_locks=no fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5 $as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; } runpath_var= allow_undefined_flag= always_export_symbols=no archive_cmds= archive_expsym_cmds= compiler_needs_object=no enable_shared_with_static_runtimes=no export_dynamic_flag_spec= export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' hardcode_automatic=no hardcode_direct=no hardcode_direct_absolute=no hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld= hardcode_libdir_separator= hardcode_minus_L=no hardcode_shlibpath_var=unsupported inherit_rpath=no link_all_deplibs=unknown module_cmds= module_expsym_cmds= old_archive_from_new_cmds= old_archive_from_expsyms_cmds= thread_safe_flag_spec= whole_archive_flag_spec= # 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 extended regexp 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_|_GLOBAL__F[ID]_.*' # 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. # Exclude shared library initialization/finalization symbols. extract_expsyms_cmds= case $host_os in cygwin* | mingw* | pw32* | cegcc*) # FIXME: the MSVC++ port hasn't been tested in a loooong time # When not using gcc, we currently assume that we are using # Microsoft Visual C++. if test "$GCC" != yes; then with_gnu_ld=no fi ;; interix*) # we just hope/assume this is gcc and not c89 (= MSVC++) with_gnu_ld=yes ;; openbsd*) with_gnu_ld=no ;; linux* | k*bsd*-gnu | gnu*) link_all_deplibs=no ;; esac ld_shlibs=yes # On some targets, GNU ld is compatible enough with the native linker # that we're better off using the native interface for both. lt_use_gnu_ld_interface=no if test "$with_gnu_ld" = yes; then case $host_os in aix*) # The AIX port of GNU ld has always aspired to compatibility # with the native linker. However, as the warning in the GNU ld # block says, versions before 2.19.5* couldn't really create working # shared libraries, regardless of the interface used. case `$LD -v 2>&1` in *\ \(GNU\ Binutils\)\ 2.19.5*) ;; *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;; *\ \(GNU\ Binutils\)\ [3-9]*) ;; *) lt_use_gnu_ld_interface=yes ;; esac ;; *) lt_use_gnu_ld_interface=yes ;; esac fi if test "$lt_use_gnu_ld_interface" = yes; then # If archive_cmds runs LD, not CC, wlarc should be empty wlarc='${wl}' # Set some defaults for GNU ld with shared library support. These # are reset later if shared libraries are not supported. Putting them # here allows them to be overridden if necessary. runpath_var=LD_RUN_PATH hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' export_dynamic_flag_spec='${wl}--export-dynamic' # ancient GNU ld didn't support --whole-archive et. al. if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive' else whole_archive_flag_spec= fi supports_anon_versioning=no case `$LD -v 2>&1` in *GNU\ gold*) supports_anon_versioning=yes ;; *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... *\ 2.11.*) ;; # other 2.11 versions *) supports_anon_versioning=yes ;; esac # See if GNU ld supports shared libraries. case $host_os in aix[3-9]*) # On AIX/PPC, the GNU linker is very broken if test "$host_cpu" != ia64; then ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: the GNU linker, at least up to release 2.19, 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 install binutils *** 2.20 or above, or modify your PATH so that a non-GNU linker is found. *** You will then need to restart the configuration process. _LT_EOF fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; beos*) if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then allow_undefined_flag=unsupported # Joseph Beckenbach says some releases of gcc # support --undefined. This deserves some investigation. FIXME archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' else ld_shlibs=no fi ;; cygwin* | mingw* | pw32* | cegcc*) # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless, # as there is no search path for DLLs. hardcode_libdir_flag_spec='-L$libdir' export_dynamic_flag_spec='${wl}--export-all-symbols' allow_undefined_flag=unsupported always_export_symbols=no enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols' exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname' if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' # If the export-symbols file already is a .def file (1st line # is EXPORTS), use it as is; otherwise, prepend... archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then cp $export_symbols $output_objdir/$soname.def; else echo EXPORTS > $output_objdir/$soname.def; cat $export_symbols >> $output_objdir/$soname.def; fi~ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' else ld_shlibs=no fi ;; haiku*) archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' link_all_deplibs=yes ;; interix[3-9]*) hardcode_direct=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. # Instead, shared libraries are loaded at an image base (0x10000000 by # default) and relocated if they conflict, which is a slow very memory # consuming and fragmenting process. To avoid this, we pick a random, # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # time. Moving up from 0x10000000 also allows more sbrk(2) space. archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' ;; gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) tmp_diet=no if test "$host_os" = linux-dietlibc; then case $cc_basename in diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) esac fi if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag' ;; pgf77* | pgf90* | pgf95* | pgfortran*) # Portland Group f77 and f90 compilers whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' tmp_addflag=' $pic_flag -Mnomain' ;; ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 tmp_addflag=' -i_dynamic' ;; efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 tmp_addflag=' -i_dynamic -nofor_main' ;; ifc* | ifort*) # Intel Fortran compiler tmp_addflag=' -nofor_main' ;; lf95*) # Lahey Fortran 8.1 whole_archive_flag_spec= tmp_sharedflag='--shared' ;; xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below) tmp_sharedflag='-qmkshrobj' tmp_addflag= ;; nvcc*) # Cuda Compiler Driver 2.2 whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes ;; esac case `$CC -V 2>&1 | sed 5q` in *Sun\ C*) # Sun C 5.9 whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive' compiler_needs_object=yes tmp_sharedflag='-G' ;; *Sun\ F*) # Sun Fortran 8.3 tmp_sharedflag='-G' ;; esac archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib' fi case $cc_basename in xlf* | bgf* | bgxlf* | mpixlf*) # IBM XL Fortran 10.1 on PPC cannot create shared libs itself whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive' hardcode_libdir_flag_spec= hardcode_libdir_flag_spec_ld='-rpath $libdir' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' if test "x$supports_anon_versioning" = xyes; then archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' fi ;; esac else ld_shlibs=no fi ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' wlarc= else archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' fi ;; solaris*) if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then ld_shlibs=no cat <<_LT_EOF 1>&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. _LT_EOF elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib' else ld_shlibs=no fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) case `$LD -v 2>&1` in *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*) ld_shlibs=no cat <<_LT_EOF 1>&2 *** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not *** reliably create shared libraries on SCO systems. Therefore, libtool *** is disabling shared libraries support. We urge you to upgrade GNU *** binutils to release 2.16.91.0.3 or newer. Another option is to modify *** your PATH or compiler configuration so that the native linker is *** used, and then restart. _LT_EOF ;; *) # For security reasons, it is highly recommended that you always # use absolute paths for naming shared libraries, and exclude the # DT_RUNPATH tag from executables and libraries. But doing so # requires that you compile everything twice, which is a pain. if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' 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 ;; 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 | $GREP ': supported targets:.* elf' > /dev/null; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $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" = no; then runpath_var= hardcode_libdir_flag_spec= export_dynamic_flag_spec= whole_archive_flag_spec= fi else # PORTME fill in a description of your system's linker (not GNU ld) case $host_os in aix3*) allow_undefined_flag=unsupported always_export_symbols=yes archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' # Note: this linker hardcodes the directories in LIBPATH if there # are no directories specified by -L. hardcode_minus_L=yes if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then # Neither direct hardcoding nor static linking is supported with a # broken collect2. hardcode_direct=unsupported fi ;; aix[4-9]*) if test "$host_cpu" = ia64; then # On IA64, the linker does run time linking by default, so we don't # have to do anything special. aix_use_runtimelinking=no exp_sym_flag='-Bexport' no_entry_flag="" else # If we're using GNU nm, then we don't want the "-C" option. # -C means demangle to AIX nm, but means don't demangle with GNU nm # Also, AIX nm treats weak defined symbols like other global # defined symbols, whereas GNU nm marks them as "W". if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' else export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols' fi aix_use_runtimelinking=no # Test if we are trying to use run time linking or normal # AIX style linking. If -brtl is somewhere in LDFLAGS, we # need to do runtime linking. case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*) for ld_flag in $LDFLAGS; do if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then aix_use_runtimelinking=yes break fi done ;; esac exp_sym_flag='-bexport' no_entry_flag='-bnoentry' fi # When large executables or shared objects are built, AIX ld can # have problems creating the table of contents. If linking a library # or program results in "error TOC overflow" add -mminimal-toc to # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. archive_cmds='' hardcode_direct=yes hardcode_direct_absolute=yes hardcode_libdir_separator=':' link_all_deplibs=yes file_list_spec='${wl}-f,' if test "$GCC" = yes; then case $host_os in aix4.[012]|aix4.[012].*) # We only want to do this on AIX 4.2 and lower, the check # below for broken collect2 doesn't work under 4.3+ collect2name=`${CC} -print-prog-name=collect2` if test -f "$collect2name" && strings "$collect2name" | $GREP resolve_lib_name >/dev/null then # We have reworked collect2 : else # We have old collect2 hardcode_direct=unsupported # It fails to find uninstalled libraries when the uninstalled # path is not listed in the libpath. Setting hardcode_minus_L # to unsupported forces relinking hardcode_minus_L=yes hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_separator= fi ;; esac shared_flag='-shared' if test "$aix_use_runtimelinking" = yes; then shared_flag="$shared_flag "'${wl}-G' fi link_all_deplibs=no else # not using gcc if test "$host_cpu" = ia64; then # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release # chokes on -Wl,-G. The following line is correct: shared_flag='-G' else if test "$aix_use_runtimelinking" = yes; then shared_flag='${wl}-G' else shared_flag='${wl}-bM:SRE' fi fi fi export_dynamic_flag_spec='${wl}-bexpall' # It seems that -bexpall does not export symbols beginning with # underscore (_), so it is better to generate a list of symbols to export. always_export_symbols=yes if test "$aix_use_runtimelinking" = yes; then # Warning - without using the other runtime loading flags (-brtl), # -berok will link without error, but may produce a broken library. allow_undefined_flag='-berok' # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag" else if test "$host_cpu" = ia64; then hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib' allow_undefined_flag="-z nodefs" archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols" else # Determine the default libpath from the value encoded in an # empty executable. if test "${lt_cv_aix_libpath+set}" = set; then aix_libpath=$lt_cv_aix_libpath else if ${lt_cv_aix_libpath_+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_aix_libpath_sed=' /Import File Strings/,/^$/ { /^0/ { s/^0 *\([^ ]*\) *$/\1/ p } }' lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` # Check for a 64-bit object if we didn't find anything. if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test -z "$lt_cv_aix_libpath_"; then lt_cv_aix_libpath_="/usr/lib:/lib" fi fi aix_libpath=$lt_cv_aix_libpath_ fi hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath" # Warning - without using the other run time loading flags, # -berok will link without error, but may produce a broken library. no_undefined_flag=' ${wl}-bernotok' allow_undefined_flag=' ${wl}-berok' if test "$with_gnu_ld" = yes; then # We only use this code for GNU lds that support --whole-archive. whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive' else # Exported symbols can be pulled into shared objects from archives whole_archive_flag_spec='$convenience' fi archive_cmds_need_lc=yes # This is similar to how AIX traditionally builds its shared libraries. archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname' fi fi ;; amigaos*) case $host_cpu in powerpc) # see comment about AmigaOS4 .so support archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib' archive_expsym_cmds='' ;; m68k) archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes ;; esac ;; bsdi[45]*) export_dynamic_flag_spec=-rdynamic ;; cygwin* | mingw* | pw32* | cegcc*) # 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. case $cc_basename in cl*) # Native MSVC hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported always_export_symbols=yes file_list_spec='@' # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames=' archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp; else sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp; fi~ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ linknames=' # The linker will not automatically build a static lib if we build a DLL. # _LT_TAGVAR(old_archive_from_new_cmds, )='true' enable_shared_with_static_runtimes=yes export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols' # Don't use ranlib old_postinstall_cmds='chmod 644 $oldlib' postlink_cmds='lt_outputfile="@OUTPUT@"~ lt_tool_outputfile="@TOOL_OUTPUT@"~ case $lt_outputfile in *.exe|*.EXE) ;; *) lt_outputfile="$lt_outputfile.exe" lt_tool_outputfile="$lt_tool_outputfile.exe" ;; esac~ if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; $RM "$lt_outputfile.manifest"; fi' ;; *) # Assume MSVC wrapper hardcode_libdir_flag_spec=' ' allow_undefined_flag=unsupported # Tell ltmain to make .lib files, not .a files. libext=lib # Tell ltmain to make .dll files, not .so files. shrext_cmds=".dll" # FIXME: Setting linknames here is a bad hack. archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' # The linker will automatically build a .lib file if we build a DLL. old_archive_from_new_cmds='true' # FIXME: Should let the user specify the lib program. old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs' enable_shared_with_static_runtimes=yes ;; esac ;; darwin* | rhapsody*) archive_cmds_need_lc=no hardcode_direct=no hardcode_automatic=yes hardcode_shlibpath_var=unsupported if test "$lt_cv_ld_force_load" = "yes"; then whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' else whole_archive_flag_spec='' fi link_all_deplibs=yes allow_undefined_flag="$_lt_dar_allow_undefined" case $cc_basename in ifort*) _lt_dar_can_shared=yes ;; *) _lt_dar_can_shared=$GCC ;; esac if test "$_lt_dar_can_shared" = "yes"; then output_verbose_link_cmd=func_echo_all archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}" archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}" module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}" else ld_shlibs=no fi ;; dgux*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; 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* | dragonfly*) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; hpux9*) if test "$GCC" = yes; then archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' else archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib' fi hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: hardcode_direct=yes # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes export_dynamic_flag_spec='${wl}-E' ;; hpux10*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_flag_spec_ld='+b $libdir' hardcode_libdir_separator=: hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes fi ;; hpux11*) if test "$GCC" = yes && test "$with_gnu_ld" = no; then case $host_cpu in hppa*64*) archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' ;; esac else case $host_cpu in hppa*64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' ;; ia64*) archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' ;; *) # Older versions of the 11.00 compiler do not understand -b yet # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5 $as_echo_n "checking if $CC understands -b... " >&6; } if ${lt_cv_prog_compiler__b+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_prog_compiler__b=no save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -b" echo "$lt_simple_link_test_code" > conftest.$ac_ext if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then # The linker can only warn and ignore the option if not recognized # So say no if there are warnings if test -s conftest.err; then # Append any errors to the config.log. cat conftest.err 1>&5 $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 if diff conftest.exp conftest.er2 >/dev/null; then lt_cv_prog_compiler__b=yes fi else lt_cv_prog_compiler__b=yes fi fi $RM -r conftest* LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5 $as_echo "$lt_cv_prog_compiler__b" >&6; } if test x"$lt_cv_prog_compiler__b" = xyes; then archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' fi ;; esac fi if test "$with_gnu_ld" = no; then hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_libdir_separator=: case $host_cpu in hppa*64*|ia64*) hardcode_direct=no hardcode_shlibpath_var=no ;; *) hardcode_direct=yes hardcode_direct_absolute=yes export_dynamic_flag_spec='${wl}-E' # hardcode_minus_L: Not really in the search PATH, # but as the default location of the library. hardcode_minus_L=yes ;; esac fi ;; irix5* | irix6* | nonstopux*) if test "$GCC" = yes; then archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' # Try to use the -exported_symbol ld option, if it does not # work, assume that -exports_file does not work either and # implicitly export all symbols. # This should be the same for all languages, so no per-tag cache variable. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5 $as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; } if ${lt_cv_irix_exported_symbol+:} false; then : $as_echo_n "(cached) " >&6 else save_LDFLAGS="$LDFLAGS" LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int foo (void) { return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : lt_cv_irix_exported_symbol=yes else lt_cv_irix_exported_symbol=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS="$save_LDFLAGS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5 $as_echo "$lt_cv_irix_exported_symbol" >&6; } if test "$lt_cv_irix_exported_symbol" = yes; then archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib' fi else archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: inherit_rpath=yes link_all_deplibs=yes ;; netbsd* | netbsdelf*-gnu) if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out else archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF fi hardcode_libdir_flag_spec='-R$libdir' hardcode_direct=yes hardcode_shlibpath_var=no ;; newsos6) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: hardcode_shlibpath_var=no ;; *nto* | *qnx*) ;; openbsd*) if test -f /usr/libexec/ld.so; then hardcode_direct=yes hardcode_shlibpath_var=no hardcode_direct_absolute=yes if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' export_dynamic_flag_spec='${wl}-E' else case $host_os in openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*) archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-R$libdir' ;; *) archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' hardcode_libdir_flag_spec='${wl}-rpath,$libdir' ;; esac fi else ld_shlibs=no fi ;; os2*) hardcode_libdir_flag_spec='-L$libdir' hardcode_minus_L=yes allow_undefined_flag=unsupported archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def' old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def' ;; osf3*) if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' fi archive_cmds_need_lc='no' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_separator=: ;; osf4* | osf5*) # as osf3* with the addition of -msym flag if test "$GCC" = yes; then allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*' archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' else allow_undefined_flag=' -expect_unresolved \*' archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib' archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp' # Both c and cxx compiler support -rpath directly hardcode_libdir_flag_spec='-rpath $libdir' fi archive_cmds_need_lc='no' hardcode_libdir_separator=: ;; solaris*) no_undefined_flag=' -z defs' if test "$GCC" = yes; then wlarc='${wl}' archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' else case `$CC -V 2>&1` in *"Compilers 5.0"*) wlarc='' 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' ;; *) wlarc='${wl}' archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' ;; esac fi hardcode_libdir_flag_spec='-R$libdir' hardcode_shlibpath_var=no case $host_os in solaris2.[0-5] | solaris2.[0-5].*) ;; *) # The compiler driver will combine and reorder linker options, # but understands `-z linker_flag'. GCC discards it without `$wl', # but is careful enough not to reorder. # Supported since Solaris 2.6 (maybe 2.5.1?) if test "$GCC" = yes; then whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract' else whole_archive_flag_spec='-z allextract$convenience -z defaultextract' fi ;; esac link_all_deplibs=yes ;; sunos4*) if test "x$host_vendor" = xsequent; then # Use $CC to link under sequent, because it throws in some extra .o # files that make .init and .fini sections work. archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' fi hardcode_libdir_flag_spec='-L$libdir' hardcode_direct=yes hardcode_minus_L=yes hardcode_shlibpath_var=no ;; sysv4) case $host_vendor in sni) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=yes # is this really true??? ;; siemens) ## LD is ld it makes a PLAMLIB ## CC just makes a GrossModule. archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags' reload_cmds='$CC -r -o $output$reload_objs' hardcode_direct=no ;; motorola) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_direct=no #Motorola manual says yes, but my tests say they lie ;; esac runpath_var='LD_RUN_PATH' hardcode_shlibpath_var=no ;; sysv4.3*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no export_dynamic_flag_spec='-Bexport' ;; sysv4*MP*) if test -d /usr/nec; then archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_shlibpath_var=no runpath_var=LD_RUN_PATH hardcode_runpath_var=yes ld_shlibs=yes fi ;; sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*) no_undefined_flag='${wl}-z,text' archive_cmds_need_lc=no hardcode_shlibpath_var=no runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; sysv5* | sco3.2v5* | sco5v6*) # Note: We can NOT use -z defs as we might desire, because we do not # link with -lc, and that would cause any symbols used from libc to # always be unresolved, which means just about no library would # ever link correctly. If we're not using GNU ld we use -z text # though, which does catch some bad symbols but isn't as heavy-handed # as -z defs. no_undefined_flag='${wl}-z,text' allow_undefined_flag='${wl}-z,nodefs' archive_cmds_need_lc=no hardcode_shlibpath_var=no hardcode_libdir_flag_spec='${wl}-R,$libdir' hardcode_libdir_separator=':' link_all_deplibs=yes export_dynamic_flag_spec='${wl}-Bexport' runpath_var='LD_RUN_PATH' if test "$GCC" = yes; then archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' else archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags' fi ;; uts4*) archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' hardcode_libdir_flag_spec='-L$libdir' hardcode_shlibpath_var=no ;; *) ld_shlibs=no ;; esac if test x$host_vendor = xsni; then case $host in sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) export_dynamic_flag_spec='${wl}-Blargedynsym' ;; esac fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5 $as_echo "$ld_shlibs" >&6; } test "$ld_shlibs" = no && can_build_shared=no with_gnu_ld=$with_gnu_ld # # Do we need to explicitly link libc? # case "x$archive_cmds_need_lc" in x|xyes) # Assume -lc should be added archive_cmds_need_lc=yes if test "$enable_shared" = yes && test "$GCC" = yes; then case $archive_cmds in *'~'*) # FIXME: we may have to deal with multi-command sequences. ;; '$CC '*) # Test whether the compiler implicitly links with -lc since on some # systems, -lgcc has to come before -lc. If gcc already passes -lc # to ld, don't add -lc before -lgcc. { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5 $as_echo_n "checking whether -lc should be explicitly linked in... " >&6; } if ${lt_cv_archive_cmds_need_lc+:} false; then : $as_echo_n "(cached) " >&6 else $RM conftest* echo "$lt_simple_compile_test_code" > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } 2>conftest.err; then soname=conftest lib=conftest libobjs=conftest.$ac_objext deplibs= wl=$lt_prog_compiler_wl pic_flag=$lt_prog_compiler_pic compiler_flags=-v linker_flags=-v verstring= output_objdir=. libname=conftest lt_save_allow_undefined_flag=$allow_undefined_flag allow_undefined_flag= if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5 (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } then lt_cv_archive_cmds_need_lc=no else lt_cv_archive_cmds_need_lc=yes fi allow_undefined_flag=$lt_save_allow_undefined_flag else cat conftest.err 1>&5 fi $RM conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5 $as_echo "$lt_cv_archive_cmds_need_lc" >&6; } archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc ;; esac fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5 $as_echo_n "checking dynamic linker characteristics... " >&6; } if test "$GCC" = yes; then case $host_os in darwin*) lt_awk_arg="/^libraries:/,/LR/" ;; *) lt_awk_arg="/^libraries:/" ;; esac case $host_os in mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;; *) lt_sed_strip_eq="s,=/,/,g" ;; esac lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` case $lt_search_path_spec in *\;*) # if the path contains ";" then we assume it to be the separator # otherwise default to the standard path separator (i.e. ":") - it is # assumed that no part of a normal pathname contains ";" but that should # okay in the real world where ";" in dirpaths is itself problematic. lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` ;; *) lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` ;; esac # Ok, now we have the path, separated by spaces, we can step through it # and add multilib dir if necessary. lt_tmp_lt_search_path_spec= lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` for lt_sys_path in $lt_search_path_spec; do if test -d "$lt_sys_path/$lt_multi_os_dir"; then lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir" else test -d "$lt_sys_path" && \ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" fi done lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' BEGIN {RS=" "; FS="/|\n";} { lt_foo=""; lt_count=0; for (lt_i = NF; lt_i > 0; lt_i--) { if ($lt_i != "" && $lt_i != ".") { if ($lt_i == "..") { lt_count++; } else { if (lt_count == 0) { lt_foo="/" $lt_i lt_foo; } else { lt_count--; } } } } if (lt_foo != "") { lt_freq[lt_foo]++; } if (lt_freq[lt_foo] == 1) { print lt_foo; } }'` # AWK program above erroneously prepends '/' to C:/dos/paths # for these hosts. case $host_os in mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ $SED 's,/\([A-Za-z]:\),\1,g'` ;; esac sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` else sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" fi library_names_spec= libname_spec='lib$name' soname_spec= shrext_cmds=".so" 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" need_lib_prefix=unknown hardcode_into_libs=no # when you set need_version to no, make sure it does not cause -set_version # flags to be left without arguments need_version=unknown case $host_os in aix3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a' shlibpath_var=LIBPATH # AIX 3 has no versioning support, so we append a major version to the name. soname_spec='${libname}${release}${shared_ext}$major' ;; aix[4-9]*) version_type=linux need_lib_prefix=no need_version=no hardcode_into_libs=yes if test "$host_cpu" = ia64; then # AIX 5 supports IA64 library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH else # With GCC up to 2.95.x, collect2 would create an import file # for dependence libraries. The import file would start with # the line `#! .'. This would cause the generated library to # depend on `.', always an invalid library. This was fixed in # development snapshots of GCC prior to 3.0. case $host_os in aix4 | aix4.[01] | aix4.[01].*) if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' echo ' yes ' echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then : else can_build_shared=no fi ;; esac # AIX (on Power*) has no versioning support, so currently we can not hardcode correct # soname into executable. Probably we can add versioning support to # collect2, so additional links can be useful in future. if test "$aix_use_runtimelinking" = yes; then # If using run time linking (on AIX 4.2 or later) use lib.so # instead of lib.a to let people know that these are not # typical AIX shared libraries. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' else # We preserve .a as extension for shared libraries through AIX4.2 # and later when we are not doing run time linking. library_names_spec='${libname}${release}.a $libname.a' soname_spec='${libname}${release}${shared_ext}$major' fi shlibpath_var=LIBPATH fi ;; amigaos*) case $host_cpu in powerpc) # Since July 2007 AmigaOS4 officially supports .so libraries. # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' ;; m68k) 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=`func_echo_all "$lib" | $SED '\''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' ;; esac ;; beos*) library_names_spec='${libname}${shared_ext}' dynamic_linker="$host_os ld.so" shlibpath_var=LIBRARY_PATH ;; bsdi[45]*) version_type=linux need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" # the default ld.so.conf also contains /usr/contrib/lib and # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow # libtool to hard-code these into programs ;; cygwin* | mingw* | pw32* | cegcc*) version_type=windows shrext_cmds=".dll" need_version=no need_lib_prefix=no case $GCC,$cc_basename in yes,*) # gcc library_names_spec='$libname.dll.a' # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname~ chmod a+x \$dldir/$dlname~ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; fi' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes case $host_os in cygwin*) # Cygwin DLLs use 'cyg' prefix rather than 'lib' soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" ;; mingw* | cegcc*) # MinGW DLLs use traditional 'lib' prefix soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; pw32*) # pw32 DLLs use 'pw' prefix rather than 'lib' library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' ;; esac dynamic_linker='Win32 ld.exe' ;; *,cl*) # Native MSVC libname_spec='$name' soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}' library_names_spec='${libname}.dll.lib' case $build_os in mingw*) sys_lib_search_path_spec= lt_save_ifs=$IFS IFS=';' for lt_path in $LIB do IFS=$lt_save_ifs # Let DOS variable expansion print the short 8.3 style file name. lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" done IFS=$lt_save_ifs # Convert to MSYS style. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` ;; cygwin*) # Convert to unix form, then to dos form, then back to unix form # but this time dos style (no spaces!) so that the unix form looks # like /cygdrive/c/PROGRA~1:/cygdr... sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` ;; *) sys_lib_search_path_spec="$LIB" if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then # It is most probably a Windows format PATH. sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` else sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` fi # FIXME: find the short name or the path components, as spaces are # common. (e.g. "Program Files" -> "PROGRA~1") ;; esac # DLL is installed to $(libdir)/../bin by postinstall_cmds postinstall_cmds='base_file=`basename \${file}`~ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~ dldir=$destdir/`dirname \$dlpath`~ test -d \$dldir || mkdir -p \$dldir~ $install_prog $dir/$dlname \$dldir/$dlname' postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ dlpath=$dir/\$dldll~ $RM \$dlpath' shlibpath_overrides_runpath=yes dynamic_linker='Win32 link.exe' ;; *) # Assume MSVC wrapper library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib' dynamic_linker='Win32 ld.exe' ;; esac # FIXME: first we should search . and the directory the executable is in shlibpath_var=PATH ;; darwin* | rhapsody*) dynamic_linker="$host_os dyld" version_type=darwin need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext' soname_spec='${libname}${release}${major}$shared_ext' shlibpath_overrides_runpath=yes shlibpath_var=DYLD_LIBRARY_PATH shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib" sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' ;; dgux*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; freebsd1*) dynamic_linker=no ;; freebsd* | dragonfly*) # DragonFly does not have aout. When/if they implement a new # versioning mechanism, adjust this. if test -x /usr/bin/objformat; then objformat=`/usr/bin/objformat` else case $host_os in freebsd[123]*) objformat=aout ;; *) objformat=elf ;; esac fi version_type=freebsd-$objformat case $version_type in freebsd-elf*) library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' need_version=no need_lib_prefix=no ;; freebsd-*) library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$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 ;; freebsd3.[2-9]* | freebsdelf3.[2-9]* | \ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1) shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; *) # from 4.6 on, and DragonFly shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; esac ;; gnu*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; haiku*) version_type=linux need_lib_prefix=no need_version=no dynamic_linker="$host_os runtime_loader" library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LIBRARY_PATH shlibpath_overrides_runpath=yes sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' hardcode_into_libs=yes ;; hpux9* | hpux10* | hpux11*) # Give a soname corresponding to the major version so that dld.sl refuses to # link against other versions. version_type=sunos need_lib_prefix=no need_version=no case $host_cpu in ia64*) shrext_cmds='.so' hardcode_into_libs=yes dynamic_linker="$host_os dld.so" shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' if test "X$HPUX_IA64_MODE" = X32; then sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" else sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" fi sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; hppa*64*) shrext_cmds='.sl' hardcode_into_libs=yes dynamic_linker="$host_os dld.sl" shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec ;; *) shrext_cmds='.sl' dynamic_linker="$host_os dld.sl" shlibpath_var=SHLIB_PATH shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' ;; esac # HP-UX runs *really* slowly unless shared libraries are mode 555, ... postinstall_cmds='chmod 555 $lib' # or fails outright, so override atomically: install_override_mode=555 ;; interix[3-9]*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; irix5* | irix6* | nonstopux*) case $host_os in nonstopux*) version_type=nonstopux ;; *) if test "$lt_cv_prog_gnu_ld" = yes; then version_type=linux else version_type=irix fi ;; esac need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}' case $host_os in irix5* | nonstopux*) libsuff= shlibsuff= ;; *) case $LD in # libtool.m4 will add one of these switches to LD *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= libmagic=32-bit;; *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 libmagic=N32;; *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 libmagic=64-bit;; *) libsuff= shlibsuff= libmagic=never-match;; esac ;; esac shlibpath_var=LD_LIBRARY${shlibsuff}_PATH shlibpath_overrides_runpath=no sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}" sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}" hardcode_into_libs=yes ;; # No shared lib support for Linux oldld, aout, or coff. linux*oldld* | linux*aout* | linux*coff*) dynamic_linker=no ;; # This must be Linux ELF. linux* | k*bsd*-gnu | kopensolaris*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no # Some binutils ld are patched to set DT_RUNPATH if ${lt_cv_shlibpath_overrides_runpath+:} false; then : $as_echo_n "(cached) " >&6 else lt_cv_shlibpath_overrides_runpath=no save_LDFLAGS=$LDFLAGS save_libdir=$libdir eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\"" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then : lt_cv_shlibpath_overrides_runpath=yes fi fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LDFLAGS=$save_LDFLAGS libdir=$save_libdir fi shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath # This implies no fast_install, which is unacceptable. # Some rework will be needed to allow for fast_install # before this can be enabled. hardcode_into_libs=yes # Append ld.so.conf contents to the search path if test -f /etc/ld.so.conf; then lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" fi # We used to test for /lib/ld.so.1 and disable shared libraries on # powerpc, because MkLinux only supported shared libraries with the # GNU dynamic linker. Since this was broken with cross compilers, # most powerpc-linux boxes support dynamic linking these days and # people can always --disable-shared, the test was removed, and we # assume the GNU/Linux dynamic linker is in use. dynamic_linker='GNU/Linux ld.so' ;; netbsdelf*-gnu) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='NetBSD ld.elf_so' ;; netbsd*) version_type=sunos need_lib_prefix=no need_version=no if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' dynamic_linker='NetBSD (a.out) ld.so' else library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' dynamic_linker='NetBSD ld.elf_so' fi shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes ;; newsos6) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes ;; *nto* | *qnx*) version_type=qnx need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes dynamic_linker='ldqnx.so' ;; openbsd*) version_type=sunos sys_lib_dlsearch_path_spec="/usr/lib" need_lib_prefix=no # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs. case $host_os in openbsd3.3 | openbsd3.3.*) need_version=yes ;; *) need_version=no ;; esac library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix' finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' shlibpath_var=LD_LIBRARY_PATH if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then case $host_os in openbsd2.[89] | openbsd2.[89].*) shlibpath_overrides_runpath=no ;; *) shlibpath_overrides_runpath=yes ;; esac else shlibpath_overrides_runpath=yes fi ;; os2*) libname_spec='$name' shrext_cmds=".dll" need_lib_prefix=no library_names_spec='$libname${shared_ext} $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH ;; osf3* | osf4* | osf5*) version_type=osf need_lib_prefix=no need_version=no soname_spec='${libname}${release}${shared_ext}$major' library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec" ;; rdos*) dynamic_linker=no ;; solaris*) version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes # ldd complains unless libraries are executable postinstall_cmds='chmod +x $lib' ;; sunos4*) version_type=sunos library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$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.3*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH case $host_vendor in sni) shlibpath_overrides_runpath=no need_lib_prefix=no runpath_var=LD_RUN_PATH ;; siemens) need_lib_prefix=no ;; motorola) need_lib_prefix=no need_version=no shlibpath_overrides_runpath=no sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' ;; esac ;; sysv4*MP*) if test -d /usr/nec ;then version_type=linux library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}' soname_spec='$libname${shared_ext}.$major' shlibpath_var=LD_LIBRARY_PATH fi ;; sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) version_type=freebsd-elf need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=yes hardcode_into_libs=yes if test "$with_gnu_ld" = yes; then sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' else sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' case $host_os in sco3.2v5*) sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" ;; esac fi sys_lib_dlsearch_path_spec='/usr/lib' ;; tpf*) # TPF is a cross-target only. Preferred cross-host = GNU/Linux. version_type=linux need_lib_prefix=no need_version=no library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' shlibpath_var=LD_LIBRARY_PATH shlibpath_overrides_runpath=no hardcode_into_libs=yes ;; uts4*) version_type=linux library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}' soname_spec='${libname}${release}${shared_ext}$major' shlibpath_var=LD_LIBRARY_PATH ;; *) dynamic_linker=no ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5 $as_echo "$dynamic_linker" >&6; } test "$dynamic_linker" = no && can_build_shared=no variables_saved_for_relink="PATH $shlibpath_var $runpath_var" if test "$GCC" = yes; then variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" fi if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec" fi if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5 $as_echo_n "checking how to hardcode library paths into programs... " >&6; } hardcode_action= if test -n "$hardcode_libdir_flag_spec" || test -n "$runpath_var" || test "X$hardcode_automatic" = "Xyes" ; then # We can hardcode non-existent 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 "$_LT_TAGVAR(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 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5 $as_echo "$hardcode_action" >&6; } if test "$hardcode_action" = relink || test "$inherit_rpath" = 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 if test "x$enable_dlopen" != xyes; then enable_dlopen=unknown enable_dlopen_self=unknown enable_dlopen_self_static=unknown else lt_cv_dlopen=no lt_cv_dlopen_libs= case $host_os in beos*) lt_cv_dlopen="load_add_on" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes ;; mingw* | pw32* | cegcc*) lt_cv_dlopen="LoadLibrary" lt_cv_dlopen_libs= ;; cygwin*) lt_cv_dlopen="dlopen" lt_cv_dlopen_libs= ;; darwin*) # if libdl is installed we need to link against it { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else lt_cv_dlopen="dyld" lt_cv_dlopen_libs= lt_cv_dlopen_self=yes fi ;; *) ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load" if test "x$ac_cv_func_shl_load" = xyes; then : lt_cv_dlopen="shl_load" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5 $as_echo_n "checking for shl_load in -ldld... " >&6; } if ${ac_cv_lib_dld_shl_load+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shl_load (); int main () { return shl_load (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_shl_load=yes else ac_cv_lib_dld_shl_load=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5 $as_echo "$ac_cv_lib_dld_shl_load" >&6; } if test "x$ac_cv_lib_dld_shl_load" = xyes; then : lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld" else ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen" if test "x$ac_cv_func_dlopen" = xyes; then : lt_cv_dlopen="dlopen" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5 $as_echo_n "checking for dlopen in -ldl... " >&6; } if ${ac_cv_lib_dl_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dl_dlopen=yes else ac_cv_lib_dl_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5 $as_echo "$ac_cv_lib_dl_dlopen" >&6; } if test "x$ac_cv_lib_dl_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5 $as_echo_n "checking for dlopen in -lsvld... " >&6; } if ${ac_cv_lib_svld_dlopen+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsvld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dlopen (); int main () { return dlopen (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_svld_dlopen=yes else ac_cv_lib_svld_dlopen=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5 $as_echo "$ac_cv_lib_svld_dlopen" >&6; } if test "x$ac_cv_lib_svld_dlopen" = xyes; then : lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld" else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5 $as_echo_n "checking for dld_link in -ldld... " >&6; } if ${ac_cv_lib_dld_dld_link+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldld $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dld_link (); int main () { return dld_link (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dld_dld_link=yes else ac_cv_lib_dld_dld_link=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5 $as_echo "$ac_cv_lib_dld_dld_link" >&6; } if test "x$ac_cv_lib_dld_dld_link" = xyes; then : lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld" fi fi fi fi fi fi ;; esac if test "x$lt_cv_dlopen" != xno; then enable_dlopen=yes else enable_dlopen=no fi case $lt_cv_dlopen in dlopen) save_CPPFLAGS="$CPPFLAGS" test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" save_LDFLAGS="$LDFLAGS" wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" save_LIBS="$LIBS" LIBS="$lt_cv_dlopen_libs $LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5 $as_echo_n "checking whether a program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;; esac else : # compilation failed lt_cv_dlopen_self=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5 $as_echo "$lt_cv_dlopen_self" >&6; } if test "x$lt_cv_dlopen_self" = xyes; then wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5 $as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; } if ${lt_cv_dlopen_self_static+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : lt_cv_dlopen_self_static=cross else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF #line $LINENO "configure" #include "confdefs.h" #if HAVE_DLFCN_H #include #endif #include #ifdef RTLD_GLOBAL # define LT_DLGLOBAL RTLD_GLOBAL #else # ifdef DL_GLOBAL # define LT_DLGLOBAL DL_GLOBAL # else # define LT_DLGLOBAL 0 # endif #endif /* We may have to define LT_DLLAZY_OR_NOW in the command line if we find out it does not work in some platform. */ #ifndef LT_DLLAZY_OR_NOW # ifdef RTLD_LAZY # define LT_DLLAZY_OR_NOW RTLD_LAZY # else # ifdef DL_LAZY # define LT_DLLAZY_OR_NOW DL_LAZY # else # ifdef RTLD_NOW # define LT_DLLAZY_OR_NOW RTLD_NOW # else # ifdef DL_NOW # define LT_DLLAZY_OR_NOW DL_NOW # else # define LT_DLLAZY_OR_NOW 0 # endif # endif # endif # endif #endif /* When -fvisbility=hidden is used, assume the code has been annotated correspondingly for the symbols needed. */ #if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) int fnord () __attribute__((visibility("default"))); #endif int fnord () { return 42; } int main () { void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); int status = $lt_dlunknown; if (self) { if (dlsym (self,"fnord")) status = $lt_dlno_uscore; else { if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; else puts (dlerror ()); } /* dlclose (self); */ } else puts (dlerror ()); return status; } _LT_EOF if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5 (eval $ac_link) 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then (./conftest; exit; ) >&5 2>/dev/null lt_status=$? case x$lt_status in x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;; x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;; esac else : # compilation failed lt_cv_dlopen_self_static=no fi fi rm -fr conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5 $as_echo "$lt_cv_dlopen_self_static" >&6; } fi CPPFLAGS="$save_CPPFLAGS" LDFLAGS="$save_LDFLAGS" LIBS="$save_LIBS" ;; esac case $lt_cv_dlopen_self in yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; *) enable_dlopen_self=unknown ;; esac case $lt_cv_dlopen_self_static in yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; *) enable_dlopen_self_static=unknown ;; esac fi striplib= old_striplib= { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 $as_echo_n "checking whether stripping libraries is possible... " >&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" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else # FIXME - insert some real tests, host_os isn't really good enough case $host_os in darwin*) if test -n "$STRIP" ; then striplib="$STRIP -x" old_striplib="$STRIP -S" { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi ;; *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } ;; esac fi # Report which library types will actually be built { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5 $as_echo_n "checking if libtool supports shared libraries... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5 $as_echo "$can_build_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5 $as_echo_n "checking whether to build shared libraries... " >&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 ;; aix[4-9]*) if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then test "$enable_shared" = yes && enable_static=no fi ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5 $as_echo "$enable_shared" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5 $as_echo_n "checking whether to build static libraries... " >&6; } # Make sure either enable_shared or enable_static is yes. test "$enable_shared" = yes || enable_static=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5 $as_echo "$enable_static" >&6; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu CC="$lt_save_CC" ac_config_commands="$ac_config_commands libtool" # Only expand once: # Extract the first word of "gperf", so it can be a program name with args. set dummy gperf; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_GPERF+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$GPERF"; then ac_cv_prog_GPERF="$GPERF" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_GPERF="gperf" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi GPERF=$ac_cv_prog_GPERF if test -n "$GPERF"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GPERF" >&5 $as_echo "$GPERF" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$GPERF" = x; then as_fn_error $? "GNU gperf not found, please install it" "$LINENO" 5 fi # Extract the first word of "antlr3", so it can be a program name with args. set dummy antlr3; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_prog_ANTLR+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ANTLR"; then ac_cv_prog_ANTLR="$ANTLR" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ANTLR="antlr3" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ANTLR=$ac_cv_prog_ANTLR if test -n "$ANTLR"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ANTLR" >&5 $as_echo "$ANTLR" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ANTLR" = x; then if test -d $srcdir/src/pregen; then for f in $srcdir/src/pregen/*; do bf=`basename $f` ln -sf pregen/$bf $srcdir/src/$bf done { $as_echo "$as_me:${as_lineno-$LINENO}: antlr3 wrapper not found, using pre-generated files" >&5 $as_echo "$as_me: antlr3 wrapper not found, using pre-generated files" >&6;} else as_fn_error $? "antlr3 wrapper not found and pre-generated files not available" "$LINENO" 5 fi fi if test "x$ANTLR" != x; then COND_ANTLR_TRUE= COND_ANTLR_FALSE='#' else COND_ANTLR_TRUE='#' COND_ANTLR_FALSE= fi CFLAGS="$CFLAGS -Wall -D_LARGEFILE_SOURCE" for ac_header in sys/wait.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/wait.h" "ac_cv_header_sys_wait_h" "$ac_includes_default" if test "x$ac_cv_header_sys_wait_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_WAIT_H 1 _ACEOF fi done for ac_header in sys/param.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default" if test "x$ac_cv_header_sys_param_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_PARAM_H 1 _ACEOF fi done for ac_header in sys/select.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/select.h" "ac_cv_header_sys_select_h" "$ac_includes_default" if test "x$ac_cv_header_sys_select_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_SELECT_H 1 _ACEOF fi done for ac_header in dirent.h do : ac_fn_c_check_header_mongrel "$LINENO" "dirent.h" "ac_cv_header_dirent_h" "$ac_includes_default" if test "x$ac_cv_header_dirent_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_DIRENT_H 1 _ACEOF fi done for ac_func in posix_fadvise do : ac_fn_c_check_func "$LINENO" "posix_fadvise" "ac_cv_func_posix_fadvise" if test "x$ac_cv_func_posix_fadvise" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_POSIX_FADVISE 1 _ACEOF fi done for ac_func in strptime do : ac_fn_c_check_func "$LINENO" "strptime" "ac_cv_func_strptime" if test "x$ac_cv_func_strptime" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRPTIME 1 _ACEOF fi done for ac_func in strtok_r do : ac_fn_c_check_func "$LINENO" "strtok_r" "ac_cv_func_strtok_r" if test "x$ac_cv_func_strtok_r" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRTOK_R 1 _ACEOF fi done for ac_func in timegm do : ac_fn_c_check_func "$LINENO" "timegm" "ac_cv_func_timegm" if test "x$ac_cv_func_timegm" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_TIMEGM 1 _ACEOF fi done # Check whether --enable-largefile was given. if test "${enable_largefile+set}" = set; then : enableval=$enable_largefile; fi if test "$enable_largefile" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 $as_echo_n "checking for special C compiler options needed for large files... " >&6; } if ${ac_cv_sys_largefile_CC+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then ac_save_CC=$CC while :; do # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : break fi rm -f core conftest.err conftest.$ac_objext CC="$CC -n32" if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_largefile_CC=' -n32'; break fi rm -f core conftest.err conftest.$ac_objext break done CC=$ac_save_CC rm -f conftest.$ac_ext fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 $as_echo "$ac_cv_sys_largefile_CC" >&6; } if test "$ac_cv_sys_largefile_CC" != no; then CC=$CC$ac_cv_sys_largefile_CC fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 $as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } if ${ac_cv_sys_file_offset_bits+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _FILE_OFFSET_BITS 64 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_file_offset_bits=64; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_file_offset_bits=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 $as_echo "$ac_cv_sys_file_offset_bits" >&6; } case $ac_cv_sys_file_offset_bits in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits _ACEOF ;; esac rm -rf conftest* if test $ac_cv_sys_file_offset_bits = unknown; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 $as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } if ${ac_cv_sys_large_files+:} false; then : $as_echo_n "(cached) " >&6 else while :; do cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=no; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #define _LARGE_FILES 1 #include /* Check that off_t can represent 2**63 - 1 correctly. We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ #define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_sys_large_files=1; break fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_sys_large_files=unknown break done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 $as_echo "$ac_cv_sys_large_files" >&6; } case $ac_cv_sys_large_files in #( no | unknown) ;; *) cat >>confdefs.h <<_ACEOF #define _LARGE_FILES $ac_cv_sys_large_files _ACEOF ;; esac rm -rf conftest* fi fi ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" if test "x$ac_cv_type_off_t" = xyes; then : else cat >>confdefs.h <<_ACEOF #define off_t long int _ACEOF fi # Check whether --enable-flac was given. if test "${enable_flac+set}" = set; then : enableval=$enable_flac; use_flac=true; CPPFLAGS="${CPPFLAGS} -DFLAC" fi # Check whether --enable-musepack was given. if test "${enable_musepack+set}" = set; then : enableval=$enable_musepack; use_musepack=true; CPPFLAGS="${CPPFLAGS} -DMUSEPACK" fi # Check whether --enable-itunes was given. if test "${enable_itunes+set}" = set; then : enableval=$enable_itunes; use_itunes=true; CPPFLAGS="${CPPFLAGS} -DITUNES" fi if test x$use_flac = xtrue; then COND_FLAC_TRUE= COND_FLAC_FALSE='#' else COND_FLAC_TRUE='#' COND_FLAC_FALSE= fi if test x$use_musepack = xtrue; then COND_MUSEPACK_TRUE= COND_MUSEPACK_FALSE='#' else COND_MUSEPACK_TRUE='#' COND_MUSEPACK_FALSE= fi if test x$use_itunes = xtrue; then COND_ITUNES_TRUE= COND_ITUNES_FALSE='#' else COND_ITUNES_TRUE='#' COND_ITUNES_FALSE= fi # Check whether --with-oss4 was given. if test "${with_oss4+set}" = set; then : withval=$with_oss4; case "$withval" in no) case "$host" in *-*-linux-*) use_oss4=false ;; *-*-kfreebsd*-*|*-*-freebsd-*) as_fn_error $? "OSS4 must be enabled on FreeBSD systems" "$LINENO" 5 ;; esac ;; yes) use_oss4=true oss4_includedir=/usr/lib/oss/include/sys ;; [\\/$]* | ?:[\\/]* ) use_oss4=true oss4_includedir="$withval" ;; *) as_fn_error $? "expected an absolute directory name for --with-oss4: $withval" "$LINENO" 5 ;; esac else case "$host" in *-*-linux-*) use_oss4=false ;; *-*-kfreebsd*-*|*-*-freebsd-*) use_oss4=true oss4_includedir=/usr/lib/oss/include/sys ;; esac fi if test "X$prefix" = "XNONE"; then acl_final_prefix="$ac_default_prefix" else acl_final_prefix="$prefix" fi if test "X$exec_prefix" = "XNONE"; then acl_final_exec_prefix='${prefix}' else acl_final_exec_prefix="$exec_prefix" fi acl_save_prefix="$prefix" prefix="$acl_final_prefix" eval acl_final_exec_prefix=\"$acl_final_exec_prefix\" prefix="$acl_save_prefix" # Check whether --with-gnu-ld was given. if test "${with_gnu_ld+set}" = set; then : withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes else with_gnu_ld=no fi # Prepare PATH_SEPARATOR. # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi ac_prog=ld if test "$GCC" = yes; then # Check if gcc -print-prog-name=ld gives a path. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5 $as_echo_n "checking for ld used by GCC... " >&6; } case $host in *-*-mingw*) # gcc leaves a trailing carriage return which upsets mingw ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; *) ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; esac case $ac_prog in # Accept absolute paths. [\\/]* | [A-Za-z]:[\\/]*) re_direlt='/[^/][^/]*/\.\./' # Canonicalize the path of ld ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` done test -z "$LD" && LD="$ac_prog" ;; "") # If it fails, then pretend we aren't using GCC. ac_prog=ld ;; *) # If it is relative, then search for the first ld in PATH. with_gnu_ld=unknown ;; esac elif test "$with_gnu_ld" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5 $as_echo_n "checking for GNU ld... " >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5 $as_echo_n "checking for non-GNU ld... " >&6; } fi if ${acl_cv_path_LD+:} false; then : $as_echo_n "(cached) " >&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 acl_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. case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in *GNU* | *'with BFD'*) test "$with_gnu_ld" != no && break ;; *) test "$with_gnu_ld" != yes && break ;; esac fi done IFS="$ac_save_ifs" else acl_cv_path_LD="$LD" # Let the user override the test with a path. fi fi LD="$acl_cv_path_LD" if test -n "$LD"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5 $as_echo "$LD" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5 $as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; } if ${acl_cv_prog_gnu_ld+:} false; then : $as_echo_n "(cached) " >&6 else # I'd rather use --version here, but apparently some GNU ld's only accept -v. case `$LD -v 2>&1 &5 $as_echo "$acl_cv_prog_gnu_ld" >&6; } with_gnu_ld=$acl_cv_prog_gnu_ld { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5 $as_echo_n "checking for shared library run path origin... " >&6; } if ${acl_cv_rpath+:} false; then : $as_echo_n "(cached) " >&6 else CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh . ./conftest.sh rm -f ./conftest.sh acl_cv_rpath=done fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5 $as_echo "$acl_cv_rpath" >&6; } wl="$acl_cv_wl" acl_libext="$acl_cv_libext" acl_shlibext="$acl_cv_shlibext" acl_libname_spec="$acl_cv_libname_spec" acl_library_names_spec="$acl_cv_library_names_spec" acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" acl_hardcode_direct="$acl_cv_hardcode_direct" acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" # Check whether --enable-rpath was given. if test "${enable_rpath+set}" = set; then : enableval=$enable_rpath; : else enable_rpath=yes fi acl_libdirstem=lib acl_libdirstem2= case "$host_os" in solaris*) { $as_echo "$as_me:${as_lineno-$LINENO}: checking for 64-bit host" >&5 $as_echo_n "checking for 64-bit host... " >&6; } if ${gl_cv_solaris_64bit+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef _LP64 sixtyfour bits #endif _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "sixtyfour bits" >/dev/null 2>&1; then : gl_cv_solaris_64bit=yes else gl_cv_solaris_64bit=no fi rm -f conftest* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gl_cv_solaris_64bit" >&5 $as_echo "$gl_cv_solaris_64bit" >&6; } if test $gl_cv_solaris_64bit = yes; then acl_libdirstem=lib/64 case "$host_cpu" in sparc*) acl_libdirstem2=lib/sparcv9 ;; i*86 | x86_64) acl_libdirstem2=lib/amd64 ;; esac fi ;; *) searchpath=`(LC_ALL=C $CC -print-search-dirs) 2>/dev/null | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'` if test -n "$searchpath"; then acl_save_IFS="${IFS= }"; IFS=":" for searchdir in $searchpath; do if test -d "$searchdir"; then case "$searchdir" in */lib64/ | */lib64 ) acl_libdirstem=lib64 ;; */../ | */.. ) # Better ignore directories of this form. They are misleading. ;; *) searchdir=`cd "$searchdir" && pwd` case "$searchdir" in */lib64 ) acl_libdirstem=lib64 ;; esac ;; esac fi done IFS="$acl_save_IFS" fi ;; esac test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem" use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-libiconv-prefix was given. if test "${with_libiconv_prefix+set}" = set; then : withval=$with_libiconv_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi fi LIBICONV= LTLIBICONV= INCICONV= LIBICONV_PREFIX= HAVE_LIBICONV= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='iconv ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value" else : fi else found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else haveit= for x in $LDFLAGS $LIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so" else LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a" else LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = 'iconv'; then LIBICONV_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = 'iconv'; then LIBICONV_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INCICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir" fi fi fi fi fi if test -n "$found_la"; then save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LIBICONV="${LIBICONV}${LIBICONV:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIBICONV; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) LIBICONV="${LIBICONV}${LIBICONV:+ }$dep" LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep" ;; esac done fi else LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name" LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBICONV="${LIBICONV}${LIBICONV:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir" done fi am_save_CPPFLAGS="$CPPFLAGS" for element in $INCICONV; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5 $as_echo_n "checking for iconv... " >&6; } if ${am_cv_func_iconv+:} false; then : $as_echo_n "(cached) " >&6 else am_cv_func_iconv="no, consider installing GNU libiconv" am_cv_lib_iconv=no cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext if test "$am_cv_func_iconv" != yes; then am_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { iconv_t cd = iconv_open("",""); iconv(cd,NULL,NULL,NULL,NULL); iconv_close(cd); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : am_cv_lib_iconv=yes am_cv_func_iconv=yes fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$am_save_LIBS" fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5 $as_echo "$am_cv_func_iconv" >&6; } if test "$am_cv_func_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5 $as_echo_n "checking for working iconv... " >&6; } if ${am_cv_func_iconv_works+:} false; then : $as_echo_n "(cached) " >&6 else am_save_LIBS="$LIBS" if test $am_cv_lib_iconv = yes; then LIBS="$LIBS $LIBICONV" fi if test "$cross_compiling" = yes; then : case "$host_os" in aix* | hpux*) am_cv_func_iconv_works="guessing no" ;; *) am_cv_func_iconv_works="guessing yes" ;; esac else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include int main () { /* Test against AIX 5.1 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8"); if (cd_utf8_to_88591 != (iconv_t)(-1)) { static const char input[] = "\342\202\254"; /* EURO SIGN */ char buf[10]; const char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_utf8_to_88591, (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) return 1; } } /* Test against Solaris 10 bug: Failures are not distinguishable from successful returns. */ { iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646"); if (cd_ascii_to_88591 != (iconv_t)(-1)) { static const char input[] = "\263"; char buf[10]; const char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_ascii_to_88591, (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if (res == 0) return 1; } } #if 0 /* This bug could be worked around by the caller. */ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */ { iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591"); if (cd_88591_to_utf8 != (iconv_t)(-1)) { static const char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337"; char buf[50]; const char *inptr = input; size_t inbytesleft = strlen (input); char *outptr = buf; size_t outbytesleft = sizeof (buf); size_t res = iconv (cd_88591_to_utf8, (char **) &inptr, &inbytesleft, &outptr, &outbytesleft); if ((int)res > 0) return 1; } } #endif /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is provided. */ if (/* Try standardized names. */ iconv_open ("UTF-8", "EUC-JP") == (iconv_t)(-1) /* Try IRIX, OSF/1 names. */ && iconv_open ("UTF-8", "eucJP") == (iconv_t)(-1) /* Try AIX names. */ && iconv_open ("UTF-8", "IBM-eucJP") == (iconv_t)(-1) /* Try HP-UX names. */ && iconv_open ("utf8", "eucJP") == (iconv_t)(-1)) return 1; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : am_cv_func_iconv_works=yes else am_cv_func_iconv_works=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi LIBS="$am_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5 $as_echo "$am_cv_func_iconv_works" >&6; } case "$am_cv_func_iconv_works" in *no) am_func_iconv=no am_cv_lib_iconv=no ;; *) am_func_iconv=yes ;; esac else am_func_iconv=no am_cv_lib_iconv=no fi if test "$am_func_iconv" = yes; then $as_echo "#define HAVE_ICONV 1" >>confdefs.h fi if test "$am_cv_lib_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5 $as_echo_n "checking how to link with libiconv... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5 $as_echo "$LIBICONV" >&6; } else CPPFLAGS="$am_save_CPPFLAGS" LIBICONV= LTLIBICONV= fi if test "$am_cv_func_iconv" = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv declaration" >&5 $as_echo_n "checking for iconv declaration... " >&6; } if ${am_cv_proto_iconv+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include extern #ifdef __cplusplus "C" #endif #if defined(__STDC__) || defined(__cplusplus) size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft); #else size_t iconv(); #endif int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : am_cv_proto_iconv_arg1="" else am_cv_proto_iconv_arg1="const" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);" fi am_cv_proto_iconv=`echo "$am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'` { $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_proto_iconv" >&5 $as_echo " $am_cv_proto_iconv" >&6; } cat >>confdefs.h <<_ACEOF #define ICONV_CONST $am_cv_proto_iconv_arg1 _ACEOF fi use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-libunistring-prefix was given. if test "${with_libunistring_prefix+set}" = set; then : withval=$with_libunistring_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi fi LIBUNISTRING= LTLIBUNISTRING= INCUNISTRING= LIBUNISTRING_PREFIX= HAVE_LIBUNISTRING= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='unistring ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }$value" else : fi else found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBUNISTRING; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$found_so" else haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else haveit= for x in $LDFLAGS $LIBUNISTRING; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$found_so" else LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$found_a" else LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = 'unistring'; then LIBUNISTRING_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = 'unistring'; then LIBUNISTRING_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INCUNISTRING; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then INCUNISTRING="${INCUNISTRING}${INCUNISTRING:+ }-I$additional_includedir" fi fi fi fi fi if test -n "$found_la"; then save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIBUNISTRING; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIBUNISTRING; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$dep" LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }$dep" ;; esac done fi else LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }-l$name" LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }-R$found_dir" done fi ac_save_CPPFLAGS="$CPPFLAGS" for element in $INCUNISTRING; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libunistring" >&5 $as_echo_n "checking for libunistring... " >&6; } if ${ac_cv_libunistring+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_LIBS="$LIBS" case " $LIBUNISTRING" in *" -l"*) LIBS="$LIBS $LIBUNISTRING" ;; *) LIBS="$LIBUNISTRING $LIBS" ;; esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { u8_strconv_from_locale((char*)0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_libunistring=yes else ac_cv_libunistring='no, consider installing GNU libunistring' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$ac_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libunistring" >&5 $as_echo "$ac_cv_libunistring" >&6; } if test "$ac_cv_libunistring" = yes; then HAVE_LIBUNISTRING=yes $as_echo "#define HAVE_LIBUNISTRING 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libunistring" >&5 $as_echo_n "checking how to link with libunistring... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBUNISTRING" >&5 $as_echo "$LIBUNISTRING" >&6; } else HAVE_LIBUNISTRING=no CPPFLAGS="$ac_save_CPPFLAGS" LIBUNISTRING= LTLIBUNISTRING= LIBUNISTRING_PREFIX= fi if test "$ac_cv_libunistring" != yes; then if test -n "$LIBICONV"; then unset ac_cv_libunistring glus_save_LIBS="$LIBS" LIBS="$LIBS $LIBICONV" use_additional=yes acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" # Check whether --with-libunistring-prefix was given. if test "${with_libunistring_prefix+set}" = set; then : withval=$with_libunistring_prefix; if test "X$withval" = "Xno"; then use_additional=no else if test "X$withval" = "X"; then acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval additional_includedir=\"$includedir\" eval additional_libdir=\"$libdir\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" else additional_includedir="$withval/include" additional_libdir="$withval/$acl_libdirstem" if test "$acl_libdirstem2" != "$acl_libdirstem" \ && ! test -d "$withval/$acl_libdirstem"; then additional_libdir="$withval/$acl_libdirstem2" fi fi fi fi LIBUNISTRING= LTLIBUNISTRING= INCUNISTRING= LIBUNISTRING_PREFIX= HAVE_LIBUNISTRING= rpathdirs= ltrpathdirs= names_already_handled= names_next_round='unistring ' while test -n "$names_next_round"; do names_this_round="$names_next_round" names_next_round= for name in $names_this_round; do already_handled= for n in $names_already_handled; do if test "$n" = "$name"; then already_handled=yes break fi done if test -z "$already_handled"; then names_already_handled="$names_already_handled $name" uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'` eval value=\"\$HAVE_LIB$uppername\" if test -n "$value"; then if test "$value" = yes; then eval value=\"\$LIB$uppername\" test -z "$value" || LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$value" eval value=\"\$LTLIB$uppername\" test -z "$value" || LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }$value" else : fi else found_dir= found_la= found_so= found_a= eval libname=\"$acl_libname_spec\" # typically: libname=lib$name if test -n "$acl_shlibext"; then shrext=".$acl_shlibext" # typically: shrext=.so else shrext= fi if test $use_additional = yes; then dir="$additional_libdir" if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi fi if test "X$found_dir" = "X"; then for x in $LDFLAGS $LTLIBUNISTRING; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" case "$x" in -L*) dir=`echo "X$x" | sed -e 's/^X-L//'` if test -n "$acl_shlibext"; then if test -f "$dir/$libname$shrext"; then found_dir="$dir" found_so="$dir/$libname$shrext" else if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then ver=`(cd "$dir" && \ for f in "$libname$shrext".*; do echo "$f"; done \ | sed -e "s,^$libname$shrext\\\\.,," \ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | sed 1q ) 2>/dev/null` if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then found_dir="$dir" found_so="$dir/$libname$shrext.$ver" fi else eval library_names=\"$acl_library_names_spec\" for f in $library_names; do if test -f "$dir/$f"; then found_dir="$dir" found_so="$dir/$f" break fi done fi fi fi if test "X$found_dir" = "X"; then if test -f "$dir/$libname.$acl_libext"; then found_dir="$dir" found_a="$dir/$libname.$acl_libext" fi fi if test "X$found_dir" != "X"; then if test -f "$dir/$libname.la"; then found_la="$dir/$libname.la" fi fi ;; esac if test "X$found_dir" != "X"; then break fi done fi if test "X$found_dir" != "X"; then LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }-L$found_dir -l$name" if test "X$found_so" != "X"; then if test "$enable_rpath" = no \ || test "X$found_dir" = "X/usr/$acl_libdirstem" \ || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$found_so" else haveit= for x in $ltrpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $found_dir" fi if test "$acl_hardcode_direct" = yes; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$found_so" else if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$found_so" haveit= for x in $rpathdirs; do if test "X$x" = "X$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $found_dir" fi else haveit= for x in $LDFLAGS $LIBUNISTRING; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$found_dir"; then haveit=yes break fi done if test -z "$haveit"; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }-L$found_dir" fi if test "$acl_hardcode_minus_L" != no; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$found_so" else LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }-l$name" fi fi fi fi else if test "X$found_a" != "X"; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$found_a" else LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }-L$found_dir -l$name" fi fi additional_includedir= case "$found_dir" in */$acl_libdirstem | */$acl_libdirstem/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` if test "$name" = 'unistring'; then LIBUNISTRING_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; */$acl_libdirstem2 | */$acl_libdirstem2/) basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'` if test "$name" = 'unistring'; then LIBUNISTRING_PREFIX="$basedir" fi additional_includedir="$basedir/include" ;; esac if test "X$additional_includedir" != "X"; then if test "X$additional_includedir" != "X/usr/include"; then haveit= if test "X$additional_includedir" = "X/usr/local/include"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then for x in $CPPFLAGS $INCUNISTRING; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-I$additional_includedir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_includedir"; then INCUNISTRING="${INCUNISTRING}${INCUNISTRING:+ }-I$additional_includedir" fi fi fi fi fi if test -n "$found_la"; then save_libdir="$libdir" case "$found_la" in */* | *\\*) . "$found_la" ;; *) . "./$found_la" ;; esac libdir="$save_libdir" for dep in $dependency_libs; do case "$dep" in -L*) additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'` if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \ && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then haveit= if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \ || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then if test -n "$GCC"; then case $host_os in linux* | gnu* | k*bsd*-gnu) haveit=yes;; esac fi fi if test -z "$haveit"; then haveit= for x in $LDFLAGS $LIBUNISTRING; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }-L$additional_libdir" fi fi haveit= for x in $LDFLAGS $LTLIBUNISTRING; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X-L$additional_libdir"; then haveit=yes break fi done if test -z "$haveit"; then if test -d "$additional_libdir"; then LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }-L$additional_libdir" fi fi fi fi ;; -R*) dir=`echo "X$dep" | sed -e 's/^X-R//'` if test "$enable_rpath" != no; then haveit= for x in $rpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then rpathdirs="$rpathdirs $dir" fi haveit= for x in $ltrpathdirs; do if test "X$x" = "X$dir"; then haveit=yes break fi done if test -z "$haveit"; then ltrpathdirs="$ltrpathdirs $dir" fi fi ;; -l*) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'` ;; *.la) names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'` ;; *) LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$dep" LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }$dep" ;; esac done fi else LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }-l$name" LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }-l$name" fi fi fi done done if test "X$rpathdirs" != "X"; then if test -n "$acl_hardcode_libdir_separator"; then alldirs= for found_dir in $rpathdirs; do alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" done acl_save_libdir="$libdir" libdir="$alldirs" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$flag" else for found_dir in $rpathdirs; do acl_save_libdir="$libdir" libdir="$found_dir" eval flag=\"$acl_hardcode_libdir_flag_spec\" libdir="$acl_save_libdir" LIBUNISTRING="${LIBUNISTRING}${LIBUNISTRING:+ }$flag" done fi fi if test "X$ltrpathdirs" != "X"; then for found_dir in $ltrpathdirs; do LTLIBUNISTRING="${LTLIBUNISTRING}${LTLIBUNISTRING:+ }-R$found_dir" done fi ac_save_CPPFLAGS="$CPPFLAGS" for element in $INCUNISTRING; do haveit= for x in $CPPFLAGS; do acl_save_prefix="$prefix" prefix="$acl_final_prefix" acl_save_exec_prefix="$exec_prefix" exec_prefix="$acl_final_exec_prefix" eval x=\"$x\" exec_prefix="$acl_save_exec_prefix" prefix="$acl_save_prefix" if test "X$x" = "X$element"; then haveit=yes break fi done if test -z "$haveit"; then CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element" fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libunistring" >&5 $as_echo_n "checking for libunistring... " >&6; } if ${ac_cv_libunistring+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_LIBS="$LIBS" case " $LIBUNISTRING" in *" -l"*) LIBS="$LIBS $LIBUNISTRING" ;; *) LIBS="$LIBUNISTRING $LIBS" ;; esac cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { u8_strconv_from_locale((char*)0); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_libunistring=yes else ac_cv_libunistring='no, consider installing GNU libunistring' fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS="$ac_save_LIBS" fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libunistring" >&5 $as_echo "$ac_cv_libunistring" >&6; } if test "$ac_cv_libunistring" = yes; then HAVE_LIBUNISTRING=yes $as_echo "#define HAVE_LIBUNISTRING 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libunistring" >&5 $as_echo_n "checking how to link with libunistring... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBUNISTRING" >&5 $as_echo "$LIBUNISTRING" >&6; } else HAVE_LIBUNISTRING=no CPPFLAGS="$ac_save_CPPFLAGS" LIBUNISTRING= LTLIBUNISTRING= LIBUNISTRING_PREFIX= fi if test -n "$LIBUNISTRING"; then LIBUNISTRING="$LIBUNISTRING $LIBICONV" LTLIBUNISTRING="$LTLIBUNISTRING $LTLIBICONV" fi LIBS="$glus_save_LIBS" fi fi if test x$HAVE_LIBUNISTRING != xyes; then as_fn_error $? "GNU libunistring is required" "$LINENO" 5 fi if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. set dummy ${ac_tool_prefix}pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi PKG_CONFIG=$ac_cv_path_PKG_CONFIG if test -n "$PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5 $as_echo "$PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_PKG_CONFIG"; then ac_pt_PKG_CONFIG=$PKG_CONFIG # Extract the first word of "pkg-config", so it can be a program name with args. set dummy pkg-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_PKG_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_PKG_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG if test -n "$ac_pt_PKG_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5 $as_echo "$ac_pt_PKG_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_PKG_CONFIG" = x; then PKG_CONFIG="" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac PKG_CONFIG=$ac_pt_PKG_CONFIG fi else PKG_CONFIG="$ac_cv_path_PKG_CONFIG" fi fi if test -n "$PKG_CONFIG"; then _pkg_min_version=0.9.0 { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5 $as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; } if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } PKG_CONFIG="" fi fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ZLIB" >&5 $as_echo_n "checking for ZLIB... " >&6; } if test -n "$ZLIB_CFLAGS"; then pkg_cv_ZLIB_CFLAGS="$ZLIB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" zlib \""; } >&5 ($PKG_CONFIG --exists --print-errors " zlib ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_ZLIB_CFLAGS=`$PKG_CONFIG --cflags " zlib " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$ZLIB_LIBS"; then pkg_cv_ZLIB_LIBS="$ZLIB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" zlib \""; } >&5 ($PKG_CONFIG --exists --print-errors " zlib ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_ZLIB_LIBS=`$PKG_CONFIG --libs " zlib " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then ZLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " zlib " 2>&1` else ZLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " zlib " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$ZLIB_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( zlib ) were not met: $ZLIB_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables ZLIB_CFLAGS and ZLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables ZLIB_CFLAGS and ZLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else ZLIB_CFLAGS=$pkg_cv_ZLIB_CFLAGS ZLIB_LIBS=$pkg_cv_ZLIB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TRE" >&5 $as_echo_n "checking for TRE... " >&6; } if test -n "$TRE_CFLAGS"; then pkg_cv_TRE_CFLAGS="$TRE_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" tre \""; } >&5 ($PKG_CONFIG --exists --print-errors " tre ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TRE_CFLAGS=`$PKG_CONFIG --cflags " tre " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$TRE_LIBS"; then pkg_cv_TRE_LIBS="$TRE_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" tre \""; } >&5 ($PKG_CONFIG --exists --print-errors " tre ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TRE_LIBS=`$PKG_CONFIG --libs " tre " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then TRE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " tre " 2>&1` else TRE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " tre " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$TRE_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( tre ) were not met: $TRE_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables TRE_CFLAGS and TRE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables TRE_CFLAGS and TRE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else TRE_CFLAGS=$pkg_cv_TRE_CFLAGS TRE_LIBS=$pkg_cv_TRE_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CONFUSE" >&5 $as_echo_n "checking for CONFUSE... " >&6; } if test -n "$CONFUSE_CFLAGS"; then pkg_cv_CONFUSE_CFLAGS="$CONFUSE_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libconfuse \""; } >&5 ($PKG_CONFIG --exists --print-errors " libconfuse ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_CONFUSE_CFLAGS=`$PKG_CONFIG --cflags " libconfuse " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$CONFUSE_LIBS"; then pkg_cv_CONFUSE_LIBS="$CONFUSE_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libconfuse \""; } >&5 ($PKG_CONFIG --exists --print-errors " libconfuse ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_CONFUSE_LIBS=`$PKG_CONFIG --libs " libconfuse " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then CONFUSE_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " libconfuse " 2>&1` else CONFUSE_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " libconfuse " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$CONFUSE_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( libconfuse ) were not met: $CONFUSE_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables CONFUSE_CFLAGS and CONFUSE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables CONFUSE_CFLAGS and CONFUSE_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else CONFUSE_CFLAGS=$pkg_cv_CONFUSE_CFLAGS CONFUSE_LIBS=$pkg_cv_CONFUSE_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for AVAHI" >&5 $as_echo_n "checking for AVAHI... " >&6; } if test -n "$AVAHI_CFLAGS"; then pkg_cv_AVAHI_CFLAGS="$AVAHI_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" avahi-client >= 0.6.24 \""; } >&5 ($PKG_CONFIG --exists --print-errors " avahi-client >= 0.6.24 ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_AVAHI_CFLAGS=`$PKG_CONFIG --cflags " avahi-client >= 0.6.24 " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$AVAHI_LIBS"; then pkg_cv_AVAHI_LIBS="$AVAHI_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" avahi-client >= 0.6.24 \""; } >&5 ($PKG_CONFIG --exists --print-errors " avahi-client >= 0.6.24 ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_AVAHI_LIBS=`$PKG_CONFIG --libs " avahi-client >= 0.6.24 " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then AVAHI_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " avahi-client >= 0.6.24 " 2>&1` else AVAHI_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " avahi-client >= 0.6.24 " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$AVAHI_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( avahi-client >= 0.6.24 ) were not met: $AVAHI_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables AVAHI_CFLAGS and AVAHI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables AVAHI_CFLAGS and AVAHI_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else AVAHI_CFLAGS=$pkg_cv_AVAHI_CFLAGS AVAHI_LIBS=$pkg_cv_AVAHI_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SQLITE3" >&5 $as_echo_n "checking for SQLITE3... " >&6; } if test -n "$SQLITE3_CFLAGS"; then pkg_cv_SQLITE3_CFLAGS="$SQLITE3_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" sqlite3 >= 3.5.0 \""; } >&5 ($PKG_CONFIG --exists --print-errors " sqlite3 >= 3.5.0 ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SQLITE3_CFLAGS=`$PKG_CONFIG --cflags " sqlite3 >= 3.5.0 " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$SQLITE3_LIBS"; then pkg_cv_SQLITE3_LIBS="$SQLITE3_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" sqlite3 >= 3.5.0 \""; } >&5 ($PKG_CONFIG --exists --print-errors " sqlite3 >= 3.5.0 ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_SQLITE3_LIBS=`$PKG_CONFIG --libs " sqlite3 >= 3.5.0 " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then SQLITE3_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " sqlite3 >= 3.5.0 " 2>&1` else SQLITE3_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " sqlite3 >= 3.5.0 " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$SQLITE3_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( sqlite3 >= 3.5.0 ) were not met: $SQLITE3_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables SQLITE3_CFLAGS and SQLITE3_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables SQLITE3_CFLAGS and SQLITE3_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else SQLITE3_CFLAGS=$pkg_cv_SQLITE3_CFLAGS SQLITE3_LIBS=$pkg_cv_SQLITE3_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi save_LIBS="$LIBS" LIBS="$SQLITE3_LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sqlite3_unlock_notify in -lsqlite3" >&5 $as_echo_n "checking for sqlite3_unlock_notify in -lsqlite3... " >&6; } if ${ac_cv_lib_sqlite3_sqlite3_unlock_notify+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsqlite3 $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char sqlite3_unlock_notify (); int main () { return sqlite3_unlock_notify (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_sqlite3_sqlite3_unlock_notify=yes else ac_cv_lib_sqlite3_sqlite3_unlock_notify=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_sqlite3_sqlite3_unlock_notify" >&5 $as_echo "$ac_cv_lib_sqlite3_sqlite3_unlock_notify" >&6; } if test "x$ac_cv_lib_sqlite3_sqlite3_unlock_notify" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBSQLITE3 1 _ACEOF LIBS="-lsqlite3 $LIBS" else as_fn_error $? "SQLite3 was built without unlock notify support" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking if SQLite3 was built with threadsafe operations support" >&5 $as_echo_n "checking if SQLite3 was built with threadsafe operations support... " >&6; } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test "$cross_compiling" = yes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: runtime will tell" >&5 $as_echo "runtime will tell" >&6; } else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include int main () { int ret = sqlite3_config(SQLITE_CONFIG_MULTITHREAD); if (ret != SQLITE_OK) return 1; return 0; ; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else as_fn_error $? "SQLite3 was not built with threadsafe operations support" "$LINENO" 5 fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu LIBS="$save_LIBS" pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBAV" >&5 $as_echo_n "checking for LIBAV... " >&6; } if test -n "$LIBAV_CFLAGS"; then pkg_cv_LIBAV_CFLAGS="$LIBAV_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libavcodec libavformat libswscale libavutil \""; } >&5 ($PKG_CONFIG --exists --print-errors " libavcodec libavformat libswscale libavutil ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBAV_CFLAGS=`$PKG_CONFIG --cflags " libavcodec libavformat libswscale libavutil " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBAV_LIBS"; then pkg_cv_LIBAV_LIBS="$LIBAV_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libavcodec libavformat libswscale libavutil \""; } >&5 ($PKG_CONFIG --exists --print-errors " libavcodec libavformat libswscale libavutil ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBAV_LIBS=`$PKG_CONFIG --libs " libavcodec libavformat libswscale libavutil " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LIBAV_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " libavcodec libavformat libswscale libavutil " 2>&1` else LIBAV_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " libavcodec libavformat libswscale libavutil " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBAV_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( libavcodec libavformat libswscale libavutil ) were not met: $LIBAV_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBAV_CFLAGS and LIBAV_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables LIBAV_CFLAGS and LIBAV_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else LIBAV_CFLAGS=$pkg_cv_LIBAV_CFLAGS LIBAV_LIBS=$pkg_cv_LIBAV_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi save_LIBS="$LIBS" { $as_echo "$as_me:${as_lineno-$LINENO}: checking for av_lockmgr_register in -lavcodec" >&5 $as_echo_n "checking for av_lockmgr_register in -lavcodec... " >&6; } if ${ac_cv_lib_avcodec_av_lockmgr_register+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lavcodec $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char av_lockmgr_register (); int main () { return av_lockmgr_register (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_avcodec_av_lockmgr_register=yes else ac_cv_lib_avcodec_av_lockmgr_register=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avcodec_av_lockmgr_register" >&5 $as_echo "$ac_cv_lib_avcodec_av_lockmgr_register" >&6; } if test "x$ac_cv_lib_avcodec_av_lockmgr_register" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_LIBAVCODEC 1 _ACEOF LIBS="-lavcodec $LIBS" else as_fn_error $? "libav (ffmpeg) >= 0.5.1 required" "$LINENO" 5 fi LIBS="$save_LIBS" # Check for libavformat >= 53; url -> avio switch if test -n "$libavformat_VERSION"; then pkg_cv_libavformat_VERSION="$libavformat_VERSION" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libavformat\""; } >&5 ($PKG_CONFIG --exists --print-errors "libavformat") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_libavformat_VERSION=`$PKG_CONFIG --atleast-version=53 "libavformat" 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then if false; then COND_AVIO_TRUE= COND_AVIO_FALSE='#' else COND_AVIO_TRUE='#' COND_AVIO_FALSE= fi else if true; then COND_AVIO_TRUE= COND_AVIO_FALSE='#' else COND_AVIO_TRUE='#' COND_AVIO_FALSE= fi fi pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for MINIXML" >&5 $as_echo_n "checking for MINIXML... " >&6; } if test -n "$MINIXML_CFLAGS"; then pkg_cv_MINIXML_CFLAGS="$MINIXML_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" mxml \""; } >&5 ($PKG_CONFIG --exists --print-errors " mxml ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_MINIXML_CFLAGS=`$PKG_CONFIG --cflags " mxml " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$MINIXML_LIBS"; then pkg_cv_MINIXML_LIBS="$MINIXML_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" mxml \""; } >&5 ($PKG_CONFIG --exists --print-errors " mxml ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_MINIXML_LIBS=`$PKG_CONFIG --libs " mxml " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then MINIXML_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " mxml " 2>&1` else MINIXML_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " mxml " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$MINIXML_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( mxml ) were not met: $MINIXML_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables MINIXML_CFLAGS and MINIXML_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables MINIXML_CFLAGS and MINIXML_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else MINIXML_CFLAGS=$pkg_cv_MINIXML_CFLAGS MINIXML_LIBS=$pkg_cv_MINIXML_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi ac_fn_c_check_header_mongrel "$LINENO" "avl.h" "ac_cv_header_avl_h" "$ac_includes_default" if test "x$ac_cv_header_avl_h" = xyes; then : else as_fn_error $? "avl.h not found" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for avl_alloc_tree in -lavl" >&5 $as_echo_n "checking for avl_alloc_tree in -lavl... " >&6; } if ${ac_cv_lib_avl_avl_alloc_tree+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lavl $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char avl_alloc_tree (); int main () { return avl_alloc_tree (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_avl_avl_alloc_tree=yes else ac_cv_lib_avl_avl_alloc_tree=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_avl_avl_alloc_tree" >&5 $as_echo "$ac_cv_lib_avl_avl_alloc_tree" >&6; } if test "x$ac_cv_lib_avl_avl_alloc_tree" = xyes; then : LIBAVL_LIBS="-lavl" else as_fn_error $? "libavl not found" "$LINENO" 5 fi ac_fn_c_check_header_mongrel "$LINENO" "antlr3.h" "ac_cv_header_antlr3_h" "$ac_includes_default" if test "x$ac_cv_header_antlr3_h" = xyes; then : else as_fn_error $? "antlr3.h not found" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for antlr3BaseRecognizerNew in -lantlr3c" >&5 $as_echo_n "checking for antlr3BaseRecognizerNew in -lantlr3c... " >&6; } if ${ac_cv_lib_antlr3c_antlr3BaseRecognizerNew+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lantlr3c $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char antlr3BaseRecognizerNew (); int main () { return antlr3BaseRecognizerNew (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_antlr3c_antlr3BaseRecognizerNew=yes else ac_cv_lib_antlr3c_antlr3BaseRecognizerNew=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_antlr3c_antlr3BaseRecognizerNew" >&5 $as_echo "$ac_cv_lib_antlr3c_antlr3BaseRecognizerNew" >&6; } if test "x$ac_cv_lib_antlr3c_antlr3BaseRecognizerNew" = xyes; then : ANTLR3C_LIBS="-lantlr3c" else as_fn_error $? "ANTLR3 C runtime (libantlr3c) not found" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for antlr3NewAsciiStringInPlaceStream in -lantlr3c" >&5 $as_echo_n "checking for antlr3NewAsciiStringInPlaceStream in -lantlr3c... " >&6; } if ${ac_cv_lib_antlr3c_antlr3NewAsciiStringInPlaceStream+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lantlr3c $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char antlr3NewAsciiStringInPlaceStream (); int main () { return antlr3NewAsciiStringInPlaceStream (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_antlr3c_antlr3NewAsciiStringInPlaceStream=yes else ac_cv_lib_antlr3c_antlr3NewAsciiStringInPlaceStream=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_antlr3c_antlr3NewAsciiStringInPlaceStream" >&5 $as_echo "$ac_cv_lib_antlr3c_antlr3NewAsciiStringInPlaceStream" >&6; } if test "x$ac_cv_lib_antlr3c_antlr3NewAsciiStringInPlaceStream" = xyes; then : $as_echo "#define ANTLR3C_NEW_INPUT 0" >>confdefs.h else $as_echo "#define ANTLR3C_NEW_INPUT 1" >>confdefs.h fi # Check whether --with-libgcrypt-prefix was given. if test "${with_libgcrypt_prefix+set}" = set; then : withval=$with_libgcrypt_prefix; libgcrypt_config_prefix="$withval" else libgcrypt_config_prefix="" fi if test x$libgcrypt_config_prefix != x ; then if test x${LIBGCRYPT_CONFIG+set} != xset ; then LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config fi fi if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}libgcrypt-config", so it can be a program name with args. set dummy ${ac_tool_prefix}libgcrypt-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_LIBGCRYPT_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $LIBGCRYPT_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_LIBGCRYPT_CONFIG="$LIBGCRYPT_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_LIBGCRYPT_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi LIBGCRYPT_CONFIG=$ac_cv_path_LIBGCRYPT_CONFIG if test -n "$LIBGCRYPT_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBGCRYPT_CONFIG" >&5 $as_echo "$LIBGCRYPT_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi fi if test -z "$ac_cv_path_LIBGCRYPT_CONFIG"; then ac_pt_LIBGCRYPT_CONFIG=$LIBGCRYPT_CONFIG # Extract the first word of "libgcrypt-config", so it can be a program name with args. set dummy libgcrypt-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_ac_pt_LIBGCRYPT_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $ac_pt_LIBGCRYPT_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_ac_pt_LIBGCRYPT_CONFIG="$ac_pt_LIBGCRYPT_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_ac_pt_LIBGCRYPT_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS ;; esac fi ac_pt_LIBGCRYPT_CONFIG=$ac_cv_path_ac_pt_LIBGCRYPT_CONFIG if test -n "$ac_pt_LIBGCRYPT_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_LIBGCRYPT_CONFIG" >&5 $as_echo "$ac_pt_LIBGCRYPT_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test "x$ac_pt_LIBGCRYPT_CONFIG" = x; then LIBGCRYPT_CONFIG="no" else case $cross_compiling:$ac_tool_warned in yes:) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac LIBGCRYPT_CONFIG=$ac_pt_LIBGCRYPT_CONFIG fi else LIBGCRYPT_CONFIG="$ac_cv_path_LIBGCRYPT_CONFIG" fi tmp=1:1.2.0 if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then req_libgcrypt_api=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\1/'` min_libgcrypt_version=`echo "$tmp" | sed 's/\(.*\):\(.*\)/\2/'` else req_libgcrypt_api=0 min_libgcrypt_version="$tmp" fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBGCRYPT - version >= $min_libgcrypt_version" >&5 $as_echo_n "checking for LIBGCRYPT - version >= $min_libgcrypt_version... " >&6; } ok=no if test "$LIBGCRYPT_CONFIG" != "no" ; then req_major=`echo $min_libgcrypt_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\1/'` req_minor=`echo $min_libgcrypt_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\2/'` req_micro=`echo $min_libgcrypt_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)/\3/'` libgcrypt_config_version=`$LIBGCRYPT_CONFIG --version` major=`echo $libgcrypt_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/'` minor=`echo $libgcrypt_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/'` micro=`echo $libgcrypt_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/'` if test "$major" -gt "$req_major"; then ok=yes else if test "$major" -eq "$req_major"; then if test "$minor" -gt "$req_minor"; then ok=yes else if test "$minor" -eq "$req_minor"; then if test "$micro" -ge "$req_micro"; then ok=yes fi fi fi fi fi fi if test $ok = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($libgcrypt_config_version)" >&5 $as_echo "yes ($libgcrypt_config_version)" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi if test $ok = yes; then # If we have a recent libgcrypt, we should also check that the # API is compatible if test "$req_libgcrypt_api" -gt 0 ; then tmp=`$LIBGCRYPT_CONFIG --api-version 2>/dev/null || echo 0` if test "$tmp" -gt 0 ; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking LIBGCRYPT API version" >&5 $as_echo_n "checking LIBGCRYPT API version... " >&6; } if test "$req_libgcrypt_api" -eq "$tmp" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: okay" >&5 $as_echo "okay" >&6; } else ok=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: does not match. want=$req_libgcrypt_api got=$tmp" >&5 $as_echo "does not match. want=$req_libgcrypt_api got=$tmp" >&6; } fi fi fi fi if test $ok = yes; then LIBGCRYPT_CFLAGS=`$LIBGCRYPT_CONFIG --cflags` LIBGCRYPT_LIBS=`$LIBGCRYPT_CONFIG --libs` : if test x"$host" != x ; then libgcrypt_config_host=`$LIBGCRYPT_CONFIG --host 2>/dev/null || echo none` if test x"$libgcrypt_config_host" != xnone ; then if test x"$libgcrypt_config_host" != x"$host" ; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** *** The config script $LIBGCRYPT_CONFIG was *** built for $libgcrypt_config_host and thus may not match the *** used host $host. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script. ***" >&5 $as_echo "$as_me: WARNING: *** *** The config script $LIBGCRYPT_CONFIG was *** built for $libgcrypt_config_host and thus may not match the *** used host $host. *** You may want to use the configure option --with-libgcrypt-prefix *** to specify a matching config script. ***" >&2;} fi fi fi else LIBGCRYPT_CFLAGS="" LIBGCRYPT_LIBS="" as_fn_error $? "libgcrypt not found" "$LINENO" 5 fi # Check whether --with-gpg-error-prefix was given. if test "${with_gpg_error_prefix+set}" = set; then : withval=$with_gpg_error_prefix; gpg_error_config_prefix="$withval" else gpg_error_config_prefix="" fi if test x$gpg_error_config_prefix != x ; then if test x${GPG_ERROR_CONFIG+set} != xset ; then GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config fi fi # Extract the first word of "gpg-error-config", so it can be a program name with args. set dummy gpg-error-config; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } if ${ac_cv_path_GPG_ERROR_CONFIG+:} false; then : $as_echo_n "(cached) " >&6 else case $GPG_ERROR_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_GPG_ERROR_CONFIG="$GPG_ERROR_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_GPG_ERROR_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_GPG_ERROR_CONFIG" && ac_cv_path_GPG_ERROR_CONFIG="no" ;; esac fi GPG_ERROR_CONFIG=$ac_cv_path_GPG_ERROR_CONFIG if test -n "$GPG_ERROR_CONFIG"; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GPG_ERROR_CONFIG" >&5 $as_echo "$GPG_ERROR_CONFIG" >&6; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi min_gpg_error_version=1.6 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GPG Error - version >= $min_gpg_error_version" >&5 $as_echo_n "checking for GPG Error - version >= $min_gpg_error_version... " >&6; } ok=no if test "$GPG_ERROR_CONFIG" != "no" ; then req_major=`echo $min_gpg_error_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)/\1/'` req_minor=`echo $min_gpg_error_version | \ sed 's/\([0-9]*\)\.\([0-9]*\)/\2/'` gpg_error_config_version=`$GPG_ERROR_CONFIG $gpg_error_config_args --version` major=`echo $gpg_error_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\).*/\1/'` minor=`echo $gpg_error_config_version | \ sed 's/\([0-9]*\)\.\([0-9]*\).*/\2/'` if test "$major" -gt "$req_major"; then ok=yes else if test "$major" -eq "$req_major"; then if test "$minor" -ge "$req_minor"; then ok=yes fi fi fi fi if test $ok = yes; then GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags` GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs` { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($gpg_error_config_version)" >&5 $as_echo "yes ($gpg_error_config_version)" >&6; } : else GPG_ERROR_CFLAGS="" GPG_ERROR_LIBS="" { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } as_fn_error $? "libgpg-error not found" "$LINENO" 5 fi if test x$use_flac = xtrue; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FLAC" >&5 $as_echo_n "checking for FLAC... " >&6; } if test -n "$FLAC_CFLAGS"; then pkg_cv_FLAC_CFLAGS="$FLAC_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" flac \""; } >&5 ($PKG_CONFIG --exists --print-errors " flac ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_FLAC_CFLAGS=`$PKG_CONFIG --cflags " flac " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$FLAC_LIBS"; then pkg_cv_FLAC_LIBS="$FLAC_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" flac \""; } >&5 ($PKG_CONFIG --exists --print-errors " flac ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_FLAC_LIBS=`$PKG_CONFIG --libs " flac " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then FLAC_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " flac " 2>&1` else FLAC_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " flac " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$FLAC_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( flac ) were not met: $FLAC_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables FLAC_CFLAGS and FLAC_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables FLAC_CFLAGS and FLAC_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else FLAC_CFLAGS=$pkg_cv_FLAC_CFLAGS FLAC_LIBS=$pkg_cv_FLAC_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi fi if test x$use_musepack = xtrue; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for TAGLIB" >&5 $as_echo_n "checking for TAGLIB... " >&6; } if test -n "$TAGLIB_CFLAGS"; then pkg_cv_TAGLIB_CFLAGS="$TAGLIB_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" taglib_c \""; } >&5 ($PKG_CONFIG --exists --print-errors " taglib_c ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TAGLIB_CFLAGS=`$PKG_CONFIG --cflags " taglib_c " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$TAGLIB_LIBS"; then pkg_cv_TAGLIB_LIBS="$TAGLIB_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" taglib_c \""; } >&5 ($PKG_CONFIG --exists --print-errors " taglib_c ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_TAGLIB_LIBS=`$PKG_CONFIG --libs " taglib_c " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then TAGLIB_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " taglib_c " 2>&1` else TAGLIB_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " taglib_c " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$TAGLIB_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( taglib_c ) were not met: $TAGLIB_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables TAGLIB_CFLAGS and TAGLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables TAGLIB_CFLAGS and TAGLIB_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else TAGLIB_CFLAGS=$pkg_cv_TAGLIB_CFLAGS TAGLIB_LIBS=$pkg_cv_TAGLIB_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi fi if test x$use_itunes = xtrue; then pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBPLIST" >&5 $as_echo_n "checking for LIBPLIST... " >&6; } if test -n "$LIBPLIST_CFLAGS"; then pkg_cv_LIBPLIST_CFLAGS="$LIBPLIST_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libplist >= 0.16 \""; } >&5 ($PKG_CONFIG --exists --print-errors " libplist >= 0.16 ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBPLIST_CFLAGS=`$PKG_CONFIG --cflags " libplist >= 0.16 " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$LIBPLIST_LIBS"; then pkg_cv_LIBPLIST_LIBS="$LIBPLIST_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" libplist >= 0.16 \""; } >&5 ($PKG_CONFIG --exists --print-errors " libplist >= 0.16 ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_LIBPLIST_LIBS=`$PKG_CONFIG --libs " libplist >= 0.16 " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then LIBPLIST_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " libplist >= 0.16 " 2>&1` else LIBPLIST_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " libplist >= 0.16 " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$LIBPLIST_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( libplist >= 0.16 ) were not met: $LIBPLIST_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables LIBPLIST_CFLAGS and LIBPLIST_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables LIBPLIST_CFLAGS and LIBPLIST_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else LIBPLIST_CFLAGS=$pkg_cv_LIBPLIST_CFLAGS LIBPLIST_LIBS=$pkg_cv_LIBPLIST_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi fi case "$host" in *-*-linux-*) if test x$use_oss4 != xtrue; then use_alsa=true pkg_failed=no { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ALSA" >&5 $as_echo_n "checking for ALSA... " >&6; } if test -n "$ALSA_CFLAGS"; then pkg_cv_ALSA_CFLAGS="$ALSA_CFLAGS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" alsa \""; } >&5 ($PKG_CONFIG --exists --print-errors " alsa ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_ALSA_CFLAGS=`$PKG_CONFIG --cflags " alsa " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test -n "$ALSA_LIBS"; then pkg_cv_ALSA_LIBS="$ALSA_LIBS" elif test -n "$PKG_CONFIG"; then if test -n "$PKG_CONFIG" && \ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \" alsa \""; } >&5 ($PKG_CONFIG --exists --print-errors " alsa ") 2>&5 ac_status=$? $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; }; then pkg_cv_ALSA_LIBS=`$PKG_CONFIG --libs " alsa " 2>/dev/null` test "x$?" != "x0" && pkg_failed=yes else pkg_failed=yes fi else pkg_failed=untried fi if test $pkg_failed = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then _pkg_short_errors_supported=yes else _pkg_short_errors_supported=no fi if test $_pkg_short_errors_supported = yes; then ALSA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs " alsa " 2>&1` else ALSA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs " alsa " 2>&1` fi # Put the nasty error message in config.log where it belongs echo "$ALSA_PKG_ERRORS" >&5 as_fn_error $? "Package requirements ( alsa ) were not met: $ALSA_PKG_ERRORS Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix. Alternatively, you may set the environment variables ALSA_CFLAGS and ALSA_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details." "$LINENO" 5 elif test $pkg_failed = untried; then { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it is in your PATH or set the PKG_CONFIG environment variable to the full path to pkg-config. Alternatively, you may set the environment variables ALSA_CFLAGS and ALSA_LIBS to avoid the need to call pkg-config. See the pkg-config man page for more details. To get pkg-config, see . See \`config.log' for more details" "$LINENO" 5; } else ALSA_CFLAGS=$pkg_cv_ALSA_CFLAGS ALSA_LIBS=$pkg_cv_ALSA_LIBS { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } fi $as_echo "#define LAUDIO_USE_ALSA 1" >>confdefs.h fi for ac_header in sys/eventfd.h do : ac_fn_c_check_header_mongrel "$LINENO" "sys/eventfd.h" "ac_cv_header_sys_eventfd_h" "$ac_includes_default" if test "x$ac_cv_header_sys_eventfd_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_SYS_EVENTFD_H 1 _ACEOF fi done for ac_func in eventfd do : ac_fn_c_check_func "$LINENO" "eventfd" "ac_cv_func_eventfd" if test "x$ac_cv_func_eventfd" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_EVENTFD 1 _ACEOF fi done ac_fn_c_check_header_mongrel "$LINENO" "sys/timerfd.h" "ac_cv_header_sys_timerfd_h" "$ac_includes_default" if test "x$ac_cv_header_sys_timerfd_h" = xyes; then : else as_fn_error $? "timerfd required; glibc 2.8+ recommended" "$LINENO" 5 fi ac_fn_c_check_func "$LINENO" "timerfd_create" "ac_cv_func_timerfd_create" if test "x$ac_cv_func_timerfd_create" = xyes; then : else as_fn_error $? "timerfd required; glibc 2.8+ recommended" "$LINENO" 5 fi ;; esac if test x$use_oss4 = xtrue; then OSS4CPPFLAGS="-I$oss4_includedir" save_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$OSS4CPPFLAGS" ac_fn_c_check_header_mongrel "$LINENO" "soundcard.h" "ac_cv_header_soundcard_h" "$ac_includes_default" if test "x$ac_cv_header_soundcard_h" = xyes; then : else as_fn_error $? "soundcard.h not found in $oss4_includedir" "$LINENO" 5 fi CPPFLAGS="$save_CPPFLAGS" fi if test x$use_alsa = xtrue; then COND_ALSA_TRUE= COND_ALSA_FALSE='#' else COND_ALSA_TRUE='#' COND_ALSA_FALSE= fi if test x$use_oss4 = xtrue; then COND_OSS4_TRUE= COND_OSS4_FALSE='#' else COND_OSS4_TRUE='#' COND_OSS4_FALSE= fi # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. # This bug is HP SR number 8606223364. { $as_echo "$as_me:${as_lineno-$LINENO}: checking size of void *" >&5 $as_echo_n "checking size of void *... " >&6; } if ${ac_cv_sizeof_void_p+:} false; then : $as_echo_n "(cached) " >&6 else if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (void *))" "ac_cv_sizeof_void_p" "$ac_includes_default"; then : else if test "$ac_cv_type_void_p" = yes; then { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error 77 "cannot compute sizeof (void *) See \`config.log' for more details" "$LINENO" 5; } else ac_cv_sizeof_void_p=0 fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_void_p" >&5 $as_echo "$ac_cv_sizeof_void_p" >&6; } cat >>confdefs.h <<_ACEOF #define SIZEOF_VOID_P $ac_cv_sizeof_void_p _ACEOF for ac_header in getopt.h do : ac_fn_c_check_header_mongrel "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default" if test "x$ac_cv_header_getopt_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_GETOPT_H 1 _ACEOF fi done for ac_header in stdint.h do : ac_fn_c_check_header_mongrel "$LINENO" "stdint.h" "ac_cv_header_stdint_h" "$ac_includes_default" if test "x$ac_cv_header_stdint_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STDINT_H 1 _ACEOF fi done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : : else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : else ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ conftest.$ac_objext conftest.beam conftest.$ac_ext fi fi fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then $as_echo "#define STDC_HEADERS 1" >>confdefs.h fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } if ${ac_cv_header_sys_wait_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include #ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8) #endif #ifndef WIFEXITED # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) #endif int main () { int s; wait (&s); s = WIFEXITED (s) ? WEXITSTATUS (s) : 1; ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_sys_wait_h=yes else ac_cv_header_sys_wait_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_sys_wait_h" >&5 $as_echo "$ac_cv_header_sys_wait_h" >&6; } if test $ac_cv_header_sys_wait_h = yes; then $as_echo "#define HAVE_SYS_WAIT_H 1" >>confdefs.h fi ac_fn_c_check_header_mongrel "$LINENO" "dispatch/dispatch.h" "ac_cv_header_dispatch_dispatch_h" "$ac_includes_default" if test "x$ac_cv_header_dispatch_dispatch_h" = xyes; then : else as_fn_error $? "dispatch/dispatch.h not found" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dispatch_main in -ldispatch" >&5 $as_echo_n "checking for dispatch_main in -ldispatch... " >&6; } if ${ac_cv_lib_dispatch_dispatch_main+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldispatch $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dispatch_main (); int main () { return dispatch_main (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dispatch_dispatch_main=yes else ac_cv_lib_dispatch_dispatch_main=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dispatch_dispatch_main" >&5 $as_echo "$ac_cv_lib_dispatch_dispatch_main" >&6; } if test "x$ac_cv_lib_dispatch_dispatch_main" = xyes; then : LIBDISPATCH_LIBS="-ldispatch" else as_fn_error $? "libdispatch not found" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dispatch_after in -ldispatch" >&5 $as_echo_n "checking for dispatch_after in -ldispatch... " >&6; } if ${ac_cv_lib_dispatch_dispatch_after+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldispatch $LIBS" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dispatch_after (); int main () { return dispatch_after (); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : ac_cv_lib_dispatch_dispatch_after=yes else ac_cv_lib_dispatch_dispatch_after=no fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dispatch_dispatch_after" >&5 $as_echo "$ac_cv_lib_dispatch_dispatch_after" >&6; } if test "x$ac_cv_lib_dispatch_dispatch_after" = xyes; then : LIBDISPATCH_LIBS="-ldispatch" else as_fn_error $? "libdispatch built without Blocks support" "$LINENO" 5 fi save_LIBS="$LIBS" # # Allow configure to be passed a path to the directory where it should look # for the Blocks runtime library, if any. # # Check whether --with-blocks-runtime was given. if test "${with_blocks_runtime+set}" = set; then : withval=$with_blocks_runtime; blocks_runtime=${withval} LIBS="$LIBS -L$blocks_runtime" fi # # Detect compiler support for Blocks; perhaps someday -fblocks won't be # required, in which case we'll need to change this. # { $as_echo "$as_me:${as_lineno-$LINENO}: checking for C Blocks support" >&5 $as_echo_n "checking for C Blocks support... " >&6; } if ${dispatch_cv_cblocks+:} false; then : $as_echo_n "(cached) " >&6 else saveCFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fblocks" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { (void)^{int i; i = 0; }(); ; return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : CFLAGS="$saveCFLAGS" dispatch_cv_cblocks="-fblocks" else CFLAGS="$saveCFLAGS" dispatch_cv_cblocks="no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $dispatch_cv_cblocks" >&5 $as_echo "$dispatch_cv_cblocks" >&6; } if test "x$dispatch_cv_cblocks" != "xno"; then : CBLOCKS_FLAGS="$dispatch_cv_cblocks" # # It may be necessary to directly link the Blocks runtime on some # systems, so give it a try if we can't link a C program that uses # Blocks. We will want to remove this at somepoint, as really -fblocks # should force that linkage already. # saveCFLAGS="$CFLAGS" CFLAGS="$CFLAGS -fblocks -O0" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether additional libraries are required for the Blocks runtime" >&5 $as_echo_n "checking whether additional libraries are required for the Blocks runtime... " >&6; } cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ^{ int j; j=0; }(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; }; else saveLIBS="$LIBS" LIBS="$LIBS -lBlocksRuntime" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { ^{ int k; k=0; }(); ; return 0; } _ACEOF if ac_fn_c_try_link "$LINENO"; then : { $as_echo "$as_me:${as_lineno-$LINENO}: result: -lBlocksRuntime" >&5 $as_echo "-lBlocksRuntime" >&6; } else as_fn_error $? "can't find Blocks runtime" "$LINENO" 5 fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext CFLAGS="$saveCFLAGS" have_cblocks=true else CBLOCKS_FLAGS="" have_cblocks=false fi if $have_cblocks; then HAVE_CBLOCKS_TRUE= HAVE_CBLOCKS_FALSE='#' else HAVE_CBLOCKS_TRUE='#' HAVE_CBLOCKS_FALSE= fi if test "x$have_cblocks" != xtrue; then as_fn_error $? "C compiler doesn't support C Blocks extension" "$LINENO" 5 fi CBLOCKS_LIBS="$LIBS" LIBS="$save_LIBS" ac_config_files="$ac_config_files src/Makefile sqlext/Makefile Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes: double-quote # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} if test ! -f "$cache_file" || test -h "$cache_file"; then cat confcache >"$cache_file" else case $cache_file in #( */* | ?:*) mv -f confcache "$cache_file"$$ && mv -f "$cache_file"$$ "$cache_file" ;; #( *) mv -f confcache "$cache_file" ;; esac fi fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -n "$EXEEXT"; then am__EXEEXT_TRUE= am__EXEEXT_FALSE='#' else am__EXEEXT_TRUE='#' am__EXEEXT_FALSE= fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${COND_ANTLR_TRUE}" && test -z "${COND_ANTLR_FALSE}"; then as_fn_error $? "conditional \"COND_ANTLR\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${COND_FLAC_TRUE}" && test -z "${COND_FLAC_FALSE}"; then as_fn_error $? "conditional \"COND_FLAC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${COND_MUSEPACK_TRUE}" && test -z "${COND_MUSEPACK_FALSE}"; then as_fn_error $? "conditional \"COND_MUSEPACK\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${COND_ITUNES_TRUE}" && test -z "${COND_ITUNES_FALSE}"; then as_fn_error $? "conditional \"COND_ITUNES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${COND_AVIO_TRUE}" && test -z "${COND_AVIO_FALSE}"; then as_fn_error $? "conditional \"COND_AVIO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${COND_AVIO_TRUE}" && test -z "${COND_AVIO_FALSE}"; then as_fn_error $? "conditional \"COND_AVIO\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${COND_ALSA_TRUE}" && test -z "${COND_ALSA_FALSE}"; then as_fn_error $? "conditional \"COND_ALSA\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${COND_OSS4_TRUE}" && test -z "${COND_OSS4_FALSE}"; then as_fn_error $? "conditional \"COND_OSS4\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${HAVE_CBLOCKS_TRUE}" && test -z "${HAVE_CBLOCKS_FALSE}"; then as_fn_error $? "conditional \"HAVE_CBLOCKS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} as_write_fail=0 cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} export SHELL _ASEOF cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 ## -------------------- ## ## M4sh Initialization. ## ## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in #( *posix*) : set -o posix ;; #( *) : ;; esac fi as_nl=' ' export as_nl # Printing a long string crashes Solaris 7 /usr/bin/printf. as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo # Prefer a ksh shell builtin over an external printf program on Solaris, # but without wasting forks for bash or zsh. if test -z "$BASH_VERSION$ZSH_VERSION" \ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='print -r --' as_echo_n='print -rn --' elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' as_echo_n='/usr/ucb/echo -n' else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; esac; expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" ' export as_echo_n_body as_echo_n='sh -c $as_echo_n_body as_echo' fi export as_echo_body as_echo='sh -c $as_echo_body as_echo' fi # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then PATH_SEPARATOR=: (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || PATH_SEPARATOR=';' } fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 exit 1 fi # Unset variables that we do not need and which cause bugs (e.g. in # pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" # suppresses any "Segmentation fault" message there. '((' could # trigger a bug in pdksh 5.2.14. for as_var in BASH_ENV ENV MAIL MAILPATH do eval test x\${$as_var+set} = xset \ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. LC_ALL=C export LC_ALL LANGUAGE=C export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH # as_fn_error STATUS ERROR [LINENO LOG_FD] # ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the # script with STATUS, using 1 if that was 0. as_fn_error () { as_status=$1; test $as_status -eq 0 && as_status=1 if test "$4"; then as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error # as_fn_set_status STATUS # ----------------------- # Set $? to STATUS, without forking. as_fn_set_status () { return $1 } # as_fn_set_status # as_fn_exit STATUS # ----------------- # Exit the shell with STATUS, even in a "trap 0" or "set -e" context. as_fn_exit () { set +e as_fn_set_status $1 exit $1 } # as_fn_exit # as_fn_unset VAR # --------------- # Portably unset VAR. as_fn_unset () { { eval $1=; unset $1;} } as_unset=as_fn_unset # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take # advantage of any shell optimizations that allow amortized linear growth over # repeated appends, instead of the typical quadratic growth present in naive # implementations. if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : eval 'as_fn_append () { eval $1+=\$2 }' else as_fn_append () { eval $1=\$$1\$2 } fi # as_fn_append # as_fn_arith ARG... # ------------------ # Perform arithmetic evaluation on the ARGs, and store the result in the # global $as_val. Take advantage of shells that can avoid forks. The arguments # must be portable across $(()) and expr. if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : eval 'as_fn_arith () { as_val=$(( $* )) }' else as_fn_arith () { as_val=`expr "$@" || test $? -eq 1` } fi # as_fn_arith if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || $as_echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in #((((( -n*) case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. xy) ECHO_C='\c';; *) echo `echo ksh88 bug on AIX 6.1` > /dev/null ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir 2>/dev/null fi if (echo >conf$$.file) 2>/dev/null; then if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null # as_fn_mkdir_p # ------------- # Create "$as_dir" as a directory, including parents if necessary. as_fn_mkdir_p () { case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || eval $as_mkdir_p || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in #( -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 ## ----------------------------------- ## ## Main body of $CONFIG_STATUS script. ## ## ----------------------------------- ## _ASEOF test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was generated by GNU Autoconf 2.68. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac case $ac_config_headers in *" "*) set x $ac_config_headers; shift; ac_config_headers=$*;; esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ \`$as_me' instantiates files and other configuration actions from templates according to the current configuration. Unless the files and actions are specified as TAGs, all are instantiated by default. Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to the package provider." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.68, with options \\"\$ac_cs_config\\" Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' MKDIR_P='$MKDIR_P' AWK='$AWK' test -n "\$AWK" || AWK=awk _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # The default lists apply if the user does not specify any file. ac_need_defaults=: while test $# != 0 do case $1 in --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; --*=) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg= ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; --config | --confi | --conf | --con | --co | --c ) $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' export CONFIG_SHELL exec "\$@" fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX $as_echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" # The HP-UX ksh and POSIX shell print the target directory to stdout # if CDPATH is set. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH sed_quote_subst='$sed_quote_subst' double_quote_subst='$double_quote_subst' delay_variable_subst='$delay_variable_subst' macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`' macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`' enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`' enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`' pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`' enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`' SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`' ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`' host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`' host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`' host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`' build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`' build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`' build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`' SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`' Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`' GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`' EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`' FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`' LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`' NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`' LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`' max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`' ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`' exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`' lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`' lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`' lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`' lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`' want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`' old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`' old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`' old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`' lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`' CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`' CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`' compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`' GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`' lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`' nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`' lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`' objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`' MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`' lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`' lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`' need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`' MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`' DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`' NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`' LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`' OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`' OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`' libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`' shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`' extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`' enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`' export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`' whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`' compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`' old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`' old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`' archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`' archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`' module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`' module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`' with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`' allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`' no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`' hardcode_libdir_flag_spec_ld='`$ECHO "$hardcode_libdir_flag_spec_ld" | $SED "$delay_single_quote_subst"`' hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`' hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`' hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`' hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`' hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`' hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`' inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`' link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`' always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`' export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`' exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`' include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`' prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`' postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`' file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`' variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`' need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`' need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`' version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`' runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`' shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`' libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`' library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`' soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`' install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`' postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`' postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`' finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`' finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`' hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`' sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`' sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`' hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`' enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`' enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`' enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`' old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`' striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`' LTCC='$LTCC' LTCFLAGS='$LTCFLAGS' compiler='$compiler_DEFAULT' # A function that is used when there is no print builtin or printf. func_fallback_echo () { eval 'cat <<_LTECHO_EOF \$1 _LTECHO_EOF' } # Quote evaled strings. for var in SHELL \ ECHO \ SED \ GREP \ EGREP \ FGREP \ LD \ NM \ LN_S \ lt_SP2NL \ lt_NL2SP \ reload_flag \ OBJDUMP \ deplibs_check_method \ file_magic_cmd \ file_magic_glob \ want_nocaseglob \ DLLTOOL \ sharedlib_from_linklib_cmd \ AR \ AR_FLAGS \ archiver_list_spec \ STRIP \ RANLIB \ CC \ CFLAGS \ compiler \ lt_cv_sys_global_symbol_pipe \ lt_cv_sys_global_symbol_to_cdecl \ lt_cv_sys_global_symbol_to_c_name_address \ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \ nm_file_list_spec \ lt_prog_compiler_no_builtin_flag \ lt_prog_compiler_pic \ lt_prog_compiler_wl \ lt_prog_compiler_static \ lt_cv_prog_compiler_c_o \ need_locks \ MANIFEST_TOOL \ DSYMUTIL \ NMEDIT \ LIPO \ OTOOL \ OTOOL64 \ shrext_cmds \ export_dynamic_flag_spec \ whole_archive_flag_spec \ compiler_needs_object \ with_gnu_ld \ allow_undefined_flag \ no_undefined_flag \ hardcode_libdir_flag_spec \ hardcode_libdir_flag_spec_ld \ hardcode_libdir_separator \ exclude_expsyms \ include_expsyms \ file_list_spec \ variables_saved_for_relink \ libname_spec \ library_names_spec \ soname_spec \ install_override_mode \ finish_eval \ old_striplib \ striplib; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done # Double-quote double-evaled strings. for var in reload_cmds \ old_postinstall_cmds \ old_postuninstall_cmds \ old_archive_cmds \ extract_expsyms_cmds \ old_archive_from_new_cmds \ old_archive_from_expsyms_cmds \ archive_cmds \ archive_expsym_cmds \ module_cmds \ module_expsym_cmds \ export_symbols_cmds \ prelink_cmds \ postlink_cmds \ postinstall_cmds \ postuninstall_cmds \ finish_cmds \ sys_lib_search_path_spec \ sys_lib_dlsearch_path_spec; do case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in *[\\\\\\\`\\"\\\$]*) eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ;; *) eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" ;; esac done ac_aux_dir='$ac_aux_dir' xsi_shell='$xsi_shell' lt_shell_append='$lt_shell_append' # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes INIT. if test -n "\${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi PACKAGE='$PACKAGE' VERSION='$VERSION' TIMESTAMP='$TIMESTAMP' RM='$RM' ofile='$ofile' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; "sqlext/Makefile") CONFIG_FILES="$CONFIG_FILES sqlext/Makefile" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= ac_tmp= trap 'exit_status=$? : "${ac_tmp:=$tmp}" { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. # This happens for instance with `./config.status config.h'. if test -n "$CONFIG_FILES"; then ac_cr=`echo X | tr X '\015'` # On cygwin, bash can eat \r inside `` if the user requested igncr. # But we know of no other shell where ac_cr would be empty at this # point, so we can use a bashism as a fallback. if test "x$ac_cr" = x; then eval ac_cr=\$\'\\r\' fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF { echo "cat >conf$$subs.awk <<_ACEOF" && echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h s/^/S["/; s/!.*/"]=/ p g s/^[^!]*!// :repl t repl s/'"$ac_delim"'$// t delim :nl h s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p n b repl :more1 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t nl :delim h s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p b :more2 s/["\\]/\\&/g; s/^/"/; s/$/"\\/ p g s/.\{148\}// t delim ' >$CONFIG_STATUS || ac_write_fail=1 rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" } { line = $ 0 nfields = split(line, field, "@") substed = 0 len = length(field[1]) for (i = 2; i < nfields; i++) { key = field[i] keylen = length(key) if (S_is_set[key]) { value = S[key] line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) len += length(value) + length(field[++i]) substed = 1 } else len += 1 + keylen } print line } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF # VPATH may cause trouble with some makes, so we remove sole $(srcdir), # ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ h s/// s/^/:/ s/[ ]*$/:/ s/:\$(srcdir):/:/g s/:\${srcdir}:/:/g s/:@srcdir@:/:/g s/^:*// s/:*$// x s/\(=[ ]*\).*/\1/ G s/\n// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" # Set up the scripts for CONFIG_HEADERS section. # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF # Transform confdefs.h into an awk script `defines.awk', embedded as # here-document in config.status, that substitutes the proper values into # config.h.in to produce config.h. # Create a delimiter string that does not exist in confdefs.h, to ease # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do ac_tt=`sed -n "/$ac_delim/p" confdefs.h` if test -z "$ac_tt"; then break elif $ac_last_try; then as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done # For the awk script, D is an array of macro values keyed by name, # likewise P contains macro parameters if any. Preserve backslash # newline sequences. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* sed -n ' s/.\{148\}/&'"$ac_delim"'/g t rset :rset s/^[ ]*#[ ]*define[ ][ ]*/ / t def d :def s/\\$// t bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3"/p s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p d :bsnl s/["\\]/\\&/g s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ D["\1"]=" \3\\\\\\n"\\/p t cont s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p t cont d :cont n s/.\{148\}/&'"$ac_delim"'/g t clear :clear s/\\$// t bsnlc s/["\\]/\\&/g; s/^/"/; s/$/"/p d :bsnlc s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p b cont ' >$CONFIG_STATUS || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 for (key in D) D_is_set[key] = 1 FS = "" } /^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { line = \$ 0 split(line, arg, " ") if (arg[1] == "#") { defundef = arg[2] mac1 = arg[3] } else { defundef = substr(arg[1], 2) mac1 = arg[2] } split(mac1, mac2, "(") #) macro = mac2[1] prefix = substr(line, 1, index(line, defundef) - 1) if (D_is_set[macro]) { # Preserve the white space surrounding the "#". print prefix "define", macro P[macro] D[macro] next } else { # Replace #undef with comments. This is necessary, for example, # in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. if (defundef == "undef") { print "/*", prefix defundef, macro, "*/" next } } } { print } _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS" shift for ac_tag do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input='Generated from '` $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. case $configure_input in #( *\&* | *\|* | *\\* ) ac_sed_conf_input=`$as_echo "$configure_input" | sed 's/[\\\\&|]/\\\\&/g'`;; #( *) ac_sed_conf_input=$configure_input;; esac case $ac_tag in *:-:* | *:-) cat >"$ac_tmp/stdin" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac ac_MKDIR_P=$MKDIR_P case $MKDIR_P in [\\/$]* | ?:[\\/]* ) ;; */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= ac_sed_dataroot=' /datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_sed_extra="$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s|@configure_input@|$ac_sed_conf_input|;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@top_build_prefix@&$ac_top_build_prefix&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t s&@MKDIR_P@&$ac_MKDIR_P&;t t $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$ac_tmp/stdin" case $ac_file in -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # # CONFIG_HEADER # if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" } >"$ac_tmp/config.h" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$ac_tmp/config.h" "$ac_file" \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || $as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$_am_arg" : 'X\(//\)[^/]' \| \ X"$_am_arg" : 'X\(//\)$' \| \ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$_am_arg" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || { # Autoconf 2.62 quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || $as_echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ;; "libtool":C) # See if we are running on zsh, and set the options which allow our # commands through without removal of \ escapes. if test -n "${ZSH_VERSION+set}" ; then setopt NO_GLOB_SUBST fi cfgfile="${ofile}T" trap "$RM \"$cfgfile\"; exit 1" 1 2 15 $RM "$cfgfile" cat <<_LT_EOF >> "$cfgfile" #! $SHELL # `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services. # Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION # Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010 Free Software Foundation, # Inc. # Written by Gordon Matzigkeit, 1996 # # This file is part of GNU Libtool. # # GNU Libtool 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. # # As a special exception to the GNU General Public License, # if you distribute this file as part of a program or library that # is built using GNU Libtool, you may include this file under the # same distribution terms that you use for the rest of that program. # # GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy # can be downloaded from http://www.gnu.org/licenses/gpl.html, or # obtained by writing to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # The names of the tagged configurations supported by this script. available_tags="" # ### BEGIN LIBTOOL CONFIG # Which release of libtool.m4 was used? macro_version=$macro_version macro_revision=$macro_revision # Whether or not to build static libraries. build_old_libs=$enable_static # Whether or not to build shared libraries. build_libtool_libs=$enable_shared # What type of objects to build. pic_mode=$pic_mode # Whether or not to optimize for fast installation. fast_install=$enable_fast_install # Shell to use when invoking shell scripts. SHELL=$lt_SHELL # An echo program that protects backslashes. ECHO=$lt_ECHO # The host system. host_alias=$host_alias host=$host host_os=$host_os # The build system. build_alias=$build_alias build=$build build_os=$build_os # A sed program that does not truncate output. SED=$lt_SED # Sed that helps us avoid accidentally triggering echo(1) options like -n. Xsed="\$SED -e 1s/^X//" # A grep program that handles long lines. GREP=$lt_GREP # An ERE matcher. EGREP=$lt_EGREP # A literal string matcher. FGREP=$lt_FGREP # A BSD- or MS-compatible name lister. NM=$lt_NM # Whether we need soft or hard links. LN_S=$lt_LN_S # What is the maximum length of a command? max_cmd_len=$max_cmd_len # Object file suffix (normally "o"). objext=$ac_objext # Executable file suffix (normally ""). exeext=$exeext # whether the shell understands "unset". lt_unset=$lt_unset # turn spaces into newlines. SP2NL=$lt_lt_SP2NL # turn newlines into spaces. NL2SP=$lt_lt_NL2SP # convert \$build file names to \$host format. to_host_file_cmd=$lt_cv_to_host_file_cmd # convert \$build files to toolchain format. to_tool_file_cmd=$lt_cv_to_tool_file_cmd # An object symbol dumper. OBJDUMP=$lt_OBJDUMP # Method to check whether dependent libraries are shared objects. deplibs_check_method=$lt_deplibs_check_method # Command to use when deplibs_check_method = "file_magic". file_magic_cmd=$lt_file_magic_cmd # How to find potential files when deplibs_check_method = "file_magic". file_magic_glob=$lt_file_magic_glob # Find potential files using nocaseglob when deplibs_check_method = "file_magic". want_nocaseglob=$lt_want_nocaseglob # DLL creation program. DLLTOOL=$lt_DLLTOOL # Command to associate shared and link libraries. sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd # The archiver. AR=$lt_AR # Flags to create an archive. AR_FLAGS=$lt_AR_FLAGS # How to feed a file listing to the archiver. archiver_list_spec=$lt_archiver_list_spec # A symbol stripping program. STRIP=$lt_STRIP # Commands used to install an old-style archive. RANLIB=$lt_RANLIB old_postinstall_cmds=$lt_old_postinstall_cmds old_postuninstall_cmds=$lt_old_postuninstall_cmds # Whether to use a lock for old archive extraction. lock_old_archive_extraction=$lock_old_archive_extraction # A C compiler. LTCC=$lt_CC # LTCC compiler flags. LTCFLAGS=$lt_CFLAGS # Take the output of nm and produce a listing of raw symbols and C names. global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe # Transform the output of nm in a proper C declaration. global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl # Transform the output of nm in a C name address pair. global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address # Transform the output of nm in a C name address pair when lib prefix is needed. global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix # Specify filename containing input files for \$NM. nm_file_list_spec=$lt_nm_file_list_spec # The root where to search for dependent libraries,and in which our libraries should be installed. lt_sysroot=$lt_sysroot # The name of the directory that contains temporary libtool files. objdir=$objdir # Used to examine libraries when file_magic_cmd begins with "file". MAGIC_CMD=$MAGIC_CMD # Must we lock files when doing compilation? need_locks=$lt_need_locks # Manifest tool. MANIFEST_TOOL=$lt_MANIFEST_TOOL # Tool to manipulate archived DWARF debug symbol files on Mac OS X. DSYMUTIL=$lt_DSYMUTIL # Tool to change global to local symbols on Mac OS X. NMEDIT=$lt_NMEDIT # Tool to manipulate fat objects and archives on Mac OS X. LIPO=$lt_LIPO # ldd/readelf like tool for Mach-O binaries on Mac OS X. OTOOL=$lt_OTOOL # ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4. OTOOL64=$lt_OTOOL64 # Old archive suffix (normally "a"). libext=$libext # Shared library suffix (normally ".so"). shrext_cmds=$lt_shrext_cmds # The commands to extract the exported symbol list from a shared archive. extract_expsyms_cmds=$lt_extract_expsyms_cmds # Variables whose values should be saved in libtool wrapper scripts and # restored at link time. variables_saved_for_relink=$lt_variables_saved_for_relink # 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 # Library versioning type. version_type=$version_type # Shared library runtime path variable. runpath_var=$runpath_var # Shared library path variable. shlibpath_var=$shlibpath_var # Is shlibpath searched before the hard-coded library search path? shlibpath_overrides_runpath=$shlibpath_overrides_runpath # Format of library name prefix. libname_spec=$lt_libname_spec # List of archive names. First name is the real one, the rest are links. # The last name is the one that the linker finds with -lNAME library_names_spec=$lt_library_names_spec # The coded name of the library, if different from the real name. soname_spec=$lt_soname_spec # Permission mode override for installation of shared libraries. install_override_mode=$lt_install_override_mode # Command to use after installation of a shared archive. postinstall_cmds=$lt_postinstall_cmds # Command to use after uninstallation of a shared archive. postuninstall_cmds=$lt_postuninstall_cmds # Commands used to finish a libtool library installation in a directory. finish_cmds=$lt_finish_cmds # As "finish_cmds", except a single script fragment to be evaled but # not shown. finish_eval=$lt_finish_eval # Whether we should hardcode library paths into libraries. hardcode_into_libs=$hardcode_into_libs # Compile-time system search path for libraries. sys_lib_search_path_spec=$lt_sys_lib_search_path_spec # Run-time system search path for libraries. sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec # Whether dlopen is supported. dlopen_support=$enable_dlopen # Whether dlopen of programs is supported. dlopen_self=$enable_dlopen_self # Whether dlopen of statically linked programs is supported. dlopen_self_static=$enable_dlopen_self_static # Commands to strip libraries. old_striplib=$lt_old_striplib striplib=$lt_striplib # The linker used to build libraries. LD=$lt_LD # How to create reloadable object files. reload_flag=$lt_reload_flag reload_cmds=$lt_reload_cmds # Commands used to build an old-style archive. old_archive_cmds=$lt_old_archive_cmds # A language specific compiler. CC=$lt_compiler # Is the compiler the GNU compiler? with_gcc=$GCC # Compiler flag to turn off builtin functions. no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag # Additional compiler flags for building library objects. pic_flag=$lt_lt_prog_compiler_pic # How to pass a linker flag through the compiler. wl=$lt_lt_prog_compiler_wl # Compiler flag to prevent dynamic linking. link_static_flag=$lt_lt_prog_compiler_static # Does compiler simultaneously support -c and -o options? compiler_c_o=$lt_lt_cv_prog_compiler_c_o # Whether or not to add -lc for building shared libraries. build_libtool_need_lc=$archive_cmds_need_lc # Whether or not to disallow shared libs when runtime libs are static. allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes # Compiler flag to allow reflexive dlopens. export_dynamic_flag_spec=$lt_export_dynamic_flag_spec # Compiler flag to generate shared objects directly from archives. whole_archive_flag_spec=$lt_whole_archive_flag_spec # Whether the compiler copes with passing no objects directly. compiler_needs_object=$lt_compiler_needs_object # Create an old-style archive from a shared archive. old_archive_from_new_cmds=$lt_old_archive_from_new_cmds # Create a temporary old-style archive to link instead of a shared archive. old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds # Commands used to build a shared archive. archive_cmds=$lt_archive_cmds archive_expsym_cmds=$lt_archive_expsym_cmds # Commands used to build a loadable module if different from building # a shared archive. module_cmds=$lt_module_cmds module_expsym_cmds=$lt_module_expsym_cmds # Whether we are building with GNU ld or not. with_gnu_ld=$lt_with_gnu_ld # Flag that allows shared libraries with undefined symbols to be built. allow_undefined_flag=$lt_allow_undefined_flag # Flag that enforces no undefined symbols. no_undefined_flag=$lt_no_undefined_flag # Flag to hardcode \$libdir into a binary during linking. # This must work even if \$libdir does not exist hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec # If ld is used when linking, flag to hardcode \$libdir into a binary # during linking. This must work even if \$libdir does not exist. hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld # Whether we need a single "-rpath" flag with a separated argument. hardcode_libdir_separator=$lt_hardcode_libdir_separator # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary. hardcode_direct=$hardcode_direct # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes # DIR into the resulting binary and the resulting library dependency is # "absolute",i.e impossible to change by setting \${shlibpath_var} if the # library is relocated. hardcode_direct_absolute=$hardcode_direct_absolute # 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 # Set to "yes" if building a shared library automatically hardcodes DIR # into the library and all subsequent libraries and executables linked # against it. hardcode_automatic=$hardcode_automatic # Set to yes if linker adds runtime paths of dependent libraries # to runtime path list. inherit_rpath=$inherit_rpath # Whether libtool must link a program against all its dependency libraries. link_all_deplibs=$link_all_deplibs # Set to "yes" if exported symbols are required. always_export_symbols=$always_export_symbols # The commands to list exported symbols. export_symbols_cmds=$lt_export_symbols_cmds # Symbols that should not be listed in the preloaded symbols. exclude_expsyms=$lt_exclude_expsyms # Symbols that must always be exported. include_expsyms=$lt_include_expsyms # Commands necessary for linking programs (against libraries) with templates. prelink_cmds=$lt_prelink_cmds # Commands necessary for finishing linking programs. postlink_cmds=$lt_postlink_cmds # Specify filename containing input files. file_list_spec=$lt_file_list_spec # How to hardcode a shared library path into an executable. hardcode_action=$hardcode_action # ### END LIBTOOL CONFIG _LT_EOF case $host_os in aix3*) cat <<\_LT_EOF >> "$cfgfile" # 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 _LT_EOF ;; esac ltmain="$ac_aux_dir/ltmain.sh" # 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? sed '$q' "$ltmain" >> "$cfgfile" \ || (rm -f "$cfgfile"; exit 1) if test x"$xsi_shell" = xyes; then sed -e '/^func_dirname ()$/,/^} # func_dirname /c\ func_dirname ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ } # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_basename ()$/,/^} # func_basename /c\ func_basename ()\ {\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\ func_dirname_and_basename ()\ {\ \ case ${1} in\ \ */*) func_dirname_result="${1%/*}${2}" ;;\ \ * ) func_dirname_result="${3}" ;;\ \ esac\ \ func_basename_result="${1##*/}"\ } # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_stripname ()$/,/^} # func_stripname /c\ func_stripname ()\ {\ \ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\ \ # positional parameters, so assign one to ordinary parameter first.\ \ func_stripname_result=${3}\ \ func_stripname_result=${func_stripname_result#"${1}"}\ \ func_stripname_result=${func_stripname_result%"${2}"}\ } # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\ func_split_long_opt ()\ {\ \ func_split_long_opt_name=${1%%=*}\ \ func_split_long_opt_arg=${1#*=}\ } # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\ func_split_short_opt ()\ {\ \ func_split_short_opt_arg=${1#??}\ \ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\ } # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\ func_lo2o ()\ {\ \ case ${1} in\ \ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\ \ *) func_lo2o_result=${1} ;;\ \ esac\ } # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_xform ()$/,/^} # func_xform /c\ func_xform ()\ {\ func_xform_result=${1%.*}.lo\ } # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_arith ()$/,/^} # func_arith /c\ func_arith ()\ {\ func_arith_result=$(( $* ))\ } # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_len ()$/,/^} # func_len /c\ func_len ()\ {\ func_len_result=${#1}\ } # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$lt_shell_append" = xyes; then sed -e '/^func_append ()$/,/^} # func_append /c\ func_append ()\ {\ eval "${1}+=\\${2}"\ } # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\ func_append_quoted ()\ {\ \ func_quote_for_eval "${2}"\ \ eval "${1}+=\\\\ \\$func_quote_for_eval_result"\ } # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: # Save a `func_append' function call where possible by direct use of '+=' sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: else # Save a `func_append' function call even when '+=' is not available sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \ && mv -f "$cfgfile.tmp" "$cfgfile" \ || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp") test 0 -eq $? || _lt_function_replace_fail=: fi if test x"$_lt_function_replace_fail" = x":"; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5 $as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;} fi mv -f "$cfgfile" "$ofile" || (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") chmod +x "$ofile" ;; esac done # for ac_tag as_fn_exit 0 _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi forked-daapd-0.19gcd/config.h.in0000664000175000017500000000667011633141303016031 0ustar julienjulien/* config.h.in. Generated from configure.in by autoheader. */ /* define if antlr3 C runtime uses new input routines */ #undef ANTLR3C_NEW_INPUT /* Define to 1 if you have the header file. */ #undef HAVE_DIRENT_H /* Define to 1 if you have the header file. */ #undef HAVE_DLFCN_H /* Define to 1 if you have the `eventfd' function. */ #undef HAVE_EVENTFD /* Define to 1 if you have the header file. */ #undef HAVE_GETOPT_H /* Define if you have the iconv() function and it works. */ #undef HAVE_ICONV /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `avcodec' library (-lavcodec). */ #undef HAVE_LIBAVCODEC /* Define to 1 if you have the `sqlite3' library (-lsqlite3). */ #undef HAVE_LIBSQLITE3 /* Define if you have the libunistring library. */ #undef HAVE_LIBUNISTRING /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `posix_fadvise' function. */ #undef HAVE_POSIX_FADVISE /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strptime' function. */ #undef HAVE_STRPTIME /* Define to 1 if you have the `strtok_r' function. */ #undef HAVE_STRTOK_R /* Define to 1 if you have the header file. */ #undef HAVE_SYS_EVENTFD_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_SELECT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H /* Define to 1 if you have the `timegm' function. */ #undef HAVE_TIMEGM /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define as const if the declaration of iconv() needs const. */ #undef ICONV_CONST /* define if local audio output uses ALSA */ #undef LAUDIO_USE_ALSA /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* The size of `void *', as computed by sizeof. */ #undef SIZEOF_VOID_P /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Version number of package */ #undef VERSION /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* Define to `long int' if does not define. */ #undef off_t forked-daapd-0.19gcd/compile0000755000175000017500000000727111633141304015361 0ustar julienjulien#! /bin/sh # Wrapper for compilers which do not understand `-c -o'. scriptversion=2009-10-06.20; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009 Free Software # Foundation, Inc. # Written by Tom Tromey . # # 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand `-c -o'. Remove `-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file `INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; esac ofile= cfile= eat= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as `compile cc -o foo foo.c'. # So we strip `-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no `-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # `.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use `[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: forked-daapd-0.19gcd/config.guess0000755000175000017500000012673011633141304016325 0ustar julienjulien#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011 Free Software Foundation, Inc. timestamp='2011-05-11' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner. Please send patches (context # diff format) to and include a ChangeLog # entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; sh5el) machine=sh5le-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit ;; *:OpenBSD:*:*) UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} exit ;; *:ekkoBSD:*:*) echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} exit ;; *:SolidBSD:*:*) echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd${UNAME_RELEASE} exit ;; *:MirBSD:*:*) echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` ;; *5.*) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` # Reset EXIT trap before exiting to avoid spurious non-zero exit code. exitcode=$? trap '' 0 exit $exitcode ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit ;; *:OS/390:*:*) echo i370-ibm-openedition exit ;; *:z/VM:*:*) echo s390-ibm-zvmoe exit ;; *:OS400:*:*) echo powerpc-ibm-os400 exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit ;; arm:riscos:*:*|arm:RISCOS:*:*) echo arm-unknown-riscos exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; s390x:SunOS:*:*) echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) echo i386-pc-auroraux${UNAME_RELEASE} exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) eval $set_cc_for_build SUN_ARCH="i386" # If there is a compiler, see if it is configured for 64-bit objects. # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. # This test works for both compilers. if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then SUN_ARCH="x86_64" fi fi echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit ;; m68k:machten:*:*) echo m68k-apple-machten${UNAME_RELEASE} exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && SYSTEM_NAME=`$dummy $dummyarg` && { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` then echo "$SYSTEM_NAME" else echo rs6000-ibm-aix3.2.5 fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit ;; *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit ;; *:AIX:*:*) echo rs6000-ibm-aix exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then eval $set_cc_for_build # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler # generating 64-bit code. GNU and HP use different nomenclature: # # $ CC_FOR_BUILD=cc ./config.guess # => hppa2.0w-hp-hpux11.23 # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | grep -q __LP64__ then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; *:UNICOS/mp:*:*) echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; 5000:UNIX_System_V:4.*:*) FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit ;; *:FreeBSD:*:*) case ${UNAME_MACHINE} in pc98) echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; amd64) echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; *) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; esac exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit ;; *:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit ;; i*:windows32*:*) # uname -m includes "-pc" on this system. echo ${UNAME_MACHINE}-mingw32 exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) echo ia64-unknown-interix${UNAME_RELEASE} exit ;; esac ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; 8664:Windows_NT:*) echo x86_64-pc-mks exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) echo x86_64-unknown-cygwin exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; *:GNU:*:*) # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit ;; *:GNU/*:*:*) # other systems with GNU libc and userland echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep -q ld.so.1 if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then echo ${UNAME_MACHINE}-unknown-linux-gnu else if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_PCS_VFP then echo ${UNAME_MACHINE}-unknown-linux-gnueabi else echo ${UNAME_MACHINE}-unknown-linux-gnueabihf fi fi exit ;; avr32*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit ;; crisv32:Linux:*:*) echo crisv32-axis-linux-gnu exit ;; frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; i*86:Linux:*:*) LIBC=gnu eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __dietlibc__ LIBC=dietlibc #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` echo "${UNAME_MACHINE}-pc-linux-${LIBC}" exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m32r*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef ${UNAME_MACHINE} #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; padre:Linux:*:*) echo sparc-unknown-linux-gnu exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; tile*:Linux:*:*) echo ${UNAME_MACHINE}-tilera-linux-gnu exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit ;; xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit ;; i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i586. # Note: whatever this is, it MUST be the same as what config.sub # prints for the "djgpp" host, or else GDB configury will decide that # this is a cross-build. echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit ;; paragon:*:*:*) echo i860-intel-osf1 exit ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit ;; M68*:*:R3V[5678]*:*) test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit ;; i*86:VOS:*:*) # From Paul.Green@stratus.com. echo ${UNAME_MACHINE}-stratus-vos exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; BePC:Haiku:*:*) # Haiku running on Intel PC compatible. echo i586-pc-haiku exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit ;; SX-7:SUPER-UX:*:*) echo sx7-nec-superux${UNAME_RELEASE} exit ;; SX-8:SUPER-UX:*:*) echo sx8-nec-superux${UNAME_RELEASE} exit ;; SX-8R:SUPER-UX:*:*) echo sx8r-nec-superux${UNAME_RELEASE} exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit ;; *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in i386) eval $set_cc_for_build if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ grep IS_64BIT_ARCH >/dev/null then UNAME_PROCESSOR="x86_64" fi fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit ;; *:QNX:*:4*) echo i386-pc-qnx exit ;; NEO-?:NONSTOP_KERNEL:*:*) echo neo-tandem-nsk${UNAME_RELEASE} exit ;; NSE-?:NONSTOP_KERNEL:*:*) echo nse-tandem-nsk${UNAME_RELEASE} exit ;; NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit ;; *:ITS:*:*) echo pdp10-unknown-its exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit ;; *:DragonFly:*:*) echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit ;; *:*VMS:*:*) UNAME_MACHINE=`(uname -p) 2>/dev/null` case "${UNAME_MACHINE}" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; V*) echo vax-dec-vms ; exit ;; esac ;; *:XENIX:*:SysV) echo i386-pc-xenix exit ;; i*86:skyos:*:*) echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' exit ;; i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; i*86:AROS:*:*) echo ${UNAME_MACHINE}-pc-aros exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit ;; c34*) echo c34-convex-bsd exit ;; c38*) echo c38-convex-bsd exit ;; c4*) echo c4-convex-bsd exit ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: forked-daapd-0.19gcd/config.sub0000755000175000017500000010460611633141304015766 0ustar julienjulien#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, # 2011 Free Software Foundation, Inc. timestamp='2011-03-23' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA # 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: # http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit ;; --version | -v ) echo "$version" ; exit ;; --help | --h* | -h ) echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit ;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; -bluegene*) os=-cnk ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco6) os=-sco5v6 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco5v6*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fido | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ | mips64r5900 | mips64r5900el \ | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64r2 | mipsisa64r2el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | moxie \ | mt \ | msp430 \ | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | open8 \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle \ | pyramid \ | rx \ | score \ | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu \ | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ | x86 | xc16x | xstormy16 | xtensa \ | z8k | z80) basic_machine=$basic_machine-unknown ;; c54x) basic_machine=tic54x-unknown ;; c55x) basic_machine=tic55x-unknown ;; c6x) basic_machine=tic6x-unknown ;; m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; ms1) basic_machine=mt-unknown ;; strongarm | thumb | xscale) basic_machine=arm-unknown ;; xscaleeb) basic_machine=armeb-unknown ;; xscaleel) basic_machine=armel-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ | mips64r5900-* | mips64r5900el-* \ | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64r2-* | mipsisa64r2el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | mmix-* \ | mt-* \ | msp430-* \ | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | open8-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ | pyramid-* \ | romp-* | rs6000-* | rx-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \ | tahoe-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tile-* | tilegx-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) basic_machine=$basic_machine-unknown ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; abacus) basic_machine=abacus-unknown ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amd64-*) basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aros) basic_machine=i386-pc os=-aros ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; blackfin) basic_machine=bfin-unknown os=-linux ;; blackfin-*) basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; bluegene*) basic_machine=powerpc-ibm os=-cnk ;; c54x-*) basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c55x-*) basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c6x-*) basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` ;; c90) basic_machine=c90-cray os=-unicos ;; cegcc) basic_machine=arm-unknown os=-cegcc ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; craynv) basic_machine=craynv-cray os=-unicosmp ;; cr16 | cr16-*) basic_machine=cr16-unknown os=-elf ;; crds | unos) basic_machine=m68k-crds ;; crisv32 | crisv32-* | etraxfs*) basic_machine=crisv32-axis ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; crx) basic_machine=crx-unknown os=-elf ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dicos) basic_machine=i686-pc os=-dicos ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m68knommu) basic_machine=m68k-unknown os=-linux ;; m68knommu-*) basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; microblaze) basic_machine=microblaze-xilinx ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; mingw32ce) basic_machine=arm-unknown os=-mingw32ce ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; ms1-*) basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; neo-tandem) basic_machine=neo-tandem ;; nse-tandem) basic_machine=nse-tandem ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; openrisc | openrisc-*) basic_machine=or32-unknown ;; os400) basic_machine=powerpc-ibm os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; parisc) basic_machine=hppa-unknown os=-linux ;; parisc-*) basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pc98) basic_machine=i386-pc ;; pc98-*) basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2 | pentiumiii | pentium3) basic_machine=i686-pc ;; pentium4) basic_machine=i786-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentium4-*) basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc | ppcbe) basic_machine=powerpc-unknown ;; ppc-* | ppcbe-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rdos) basic_machine=i386-pc os=-rdos ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sde) basic_machine=mipsisa32-sde os=-elf ;; sei) basic_machine=mips-sei os=-seiux ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sh5el) basic_machine=sh5le-unknown ;; sh64) basic_machine=sh64-unknown ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; strongarm-* | thumb-*) basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; # This must be matched before tile*. tilegx*) basic_machine=tilegx-unknown os=-linux-gnu ;; tile*) basic_machine=tile-unknown os=-linux-gnu ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; tpf) basic_machine=s390x-ibm os=-tpf ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xbox) basic_machine=i686-pc os=-mingw32 ;; xps | xps100) basic_machine=xps100-honeywell ;; xscale-* | xscalee[bl]-*) basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; z80-*-coff) basic_machine=z80-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; mmix) basic_machine=mmix-knuth ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -auroraux) os=-auroraux ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ | -openbsd* | -solidbsd* \ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -linux-android* \ | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux-dietlibc) os=-linux-dietlibc ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -os400*) os=-os400 ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -syllable*) os=-syllable ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -tpf*) os=-tpf ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -zvmoe) os=-zvmoe ;; -dicos*) os=-dicos ;; -nacl*) ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in score-*) os=-elf ;; spu-*) os=-elf ;; *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; c4x-* | tic4x-*) os=-coff ;; tic54x-*) os=-coff ;; tic55x-*) os=-coff ;; tic6x-*) os=-coff ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mep-*) os=-elf ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-haiku) os=-haiku ;; *-ibm) os=-aix ;; *-knuth) os=-mmixware ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -cnk*|-aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -os400*) vendor=ibm ;; -ptx*) vendor=sequent ;; -tpf*) vendor=ibm ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: forked-daapd-0.19gcd/install-sh0000755000175000017500000003253711633141304016012 0ustar julienjulien#!/bin/sh # install - install a program, script, or datafile scriptversion=2009-04-28.21; # UTC # This originates from X11R5 (mit/util/scripts/install.sh), which was # later released in X11R6 (xc/config/util/install.sh) with the # following copyright and license. # # Copyright (C) 1994 X Consortium # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # # Except as contained in this notice, the name of the X Consortium shall not # be used in advertising or otherwise to promote the sale, use or other deal- # ings in this Software without prior written authorization from the X Consor- # tium. # # # FSF changes to this file are in the public domain. # # 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. nl=' ' IFS=" "" $nl" # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit=${DOITPROG-} if test -z "$doit"; then doit_exec=exec else doit_exec=$doit fi # Put in absolute file names if you don't have them in your path; # or use environment vars. chgrpprog=${CHGRPPROG-chgrp} chmodprog=${CHMODPROG-chmod} chownprog=${CHOWNPROG-chown} cmpprog=${CMPPROG-cmp} cpprog=${CPPROG-cp} mkdirprog=${MKDIRPROG-mkdir} mvprog=${MVPROG-mv} rmprog=${RMPROG-rm} stripprog=${STRIPPROG-strip} posix_glob='?' initialize_posix_glob=' test "$posix_glob" != "?" || { if (set -f) 2>/dev/null; then posix_glob= else posix_glob=: fi } ' posix_mkdir= # Desired mode of installed file. mode=0755 chgrpcmd= chmodcmd=$chmodprog chowncmd= mvcmd=$mvprog rmcmd="$rmprog -f" stripcmd= src= dst= dir_arg= dst_arg= copy_on_change=false no_target_directory= usage="\ Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE or: $0 [OPTION]... SRCFILES... DIRECTORY or: $0 [OPTION]... -t DIRECTORY SRCFILES... or: $0 [OPTION]... -d DIRECTORIES... In the 1st form, copy SRCFILE to DSTFILE. In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. In the 4th, create DIRECTORIES. Options: --help display this help and exit. --version display version info and exit. -c (ignored) -C install only if different (preserve the last data modification time) -d create directories instead of installing files. -g GROUP $chgrpprog installed files to GROUP. -m MODE $chmodprog installed files to MODE. -o USER $chownprog installed files to USER. -s $stripprog installed files. -t DIRECTORY install into DIRECTORY. -T report an error if DSTFILE is a directory. Environment variables override the default commands: CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG " while test $# -ne 0; do case $1 in -c) ;; -C) copy_on_change=true;; -d) dir_arg=true;; -g) chgrpcmd="$chgrpprog $2" shift;; --help) echo "$usage"; exit $?;; -m) mode=$2 case $mode in *' '* | *' '* | *' '* | *'*'* | *'?'* | *'['*) echo "$0: invalid mode: $mode" >&2 exit 1;; esac shift;; -o) chowncmd="$chownprog $2" shift;; -s) stripcmd=$stripprog;; -t) dst_arg=$2 shift;; -T) no_target_directory=true;; --version) echo "$0 $scriptversion"; exit $?;; --) shift break;; -*) echo "$0: invalid option: $1" >&2 exit 1;; *) break;; esac shift done if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then # When -d is used, all remaining arguments are directories to create. # When -t is used, the destination is already specified. # Otherwise, the last argument is the destination. Remove it from $@. for arg do if test -n "$dst_arg"; then # $@ is not empty: it contains at least $arg. set fnord "$@" "$dst_arg" shift # fnord fi shift # arg dst_arg=$arg done fi if test $# -eq 0; then if test -z "$dir_arg"; then echo "$0: no input file specified." >&2 exit 1 fi # It's OK to call `install-sh -d' without argument. # This can happen when creating conditional directories. exit 0 fi if test -z "$dir_arg"; then trap '(exit $?); exit' 1 2 13 15 # Set umask so as not to create temps with too-generous modes. # However, 'strip' requires both read and write access to temps. case $mode in # Optimize common cases. *644) cp_umask=133;; *755) cp_umask=22;; *[0-7]) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw='% 200' fi cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; *) if test -z "$stripcmd"; then u_plus_rw= else u_plus_rw=,u+rw fi cp_umask=$mode$u_plus_rw;; esac fi for src do # Protect names starting with `-'. case $src in -*) src=./$src;; esac if test -n "$dir_arg"; then dst=$src dstdir=$dst test -d "$dstdir" dstdir_status=$? else # Waiting for this to be detected by the "$cpprog $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if test ! -f "$src" && test ! -d "$src"; then echo "$0: $src does not exist." >&2 exit 1 fi if test -z "$dst_arg"; then echo "$0: no destination specified." >&2 exit 1 fi dst=$dst_arg # Protect names starting with `-'. case $dst in -*) dst=./$dst;; esac # If destination is a directory, append the input filename; won't work # if double slashes aren't ignored. if test -d "$dst"; then if test -n "$no_target_directory"; then echo "$0: $dst_arg: Is a directory" >&2 exit 1 fi dstdir=$dst dst=$dstdir/`basename "$src"` dstdir_status=0 else # Prefer dirname, but fall back on a substitute if dirname fails. dstdir=` (dirname "$dst") 2>/dev/null || expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$dst" : 'X\(//\)[^/]' \| \ X"$dst" : 'X\(//\)$' \| \ X"$dst" : 'X\(/\)' \| . 2>/dev/null || echo X"$dst" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q' ` test -d "$dstdir" dstdir_status=$? fi fi obsolete_mkdir_used=false if test $dstdir_status != 0; then case $posix_mkdir in '') # Create intermediate dirs using mode 755 as modified by the umask. # This is like FreeBSD 'install' as of 1997-10-28. umask=`umask` case $stripcmd.$umask in # Optimize common cases. *[2367][2367]) mkdir_umask=$umask;; .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; *[0-7]) mkdir_umask=`expr $umask + 22 \ - $umask % 100 % 40 + $umask % 20 \ - $umask % 10 % 4 + $umask % 2 `;; *) mkdir_umask=$umask,go-w;; esac # With -d, create the new directory with the user-specified mode. # Otherwise, rely on $mkdir_umask. if test -n "$dir_arg"; then mkdir_mode=-m$mode else mkdir_mode= fi posix_mkdir=false case $umask in *[123567][0-7][0-7]) # POSIX mkdir -p sets u+wx bits regardless of umask, which # is incompatible with FreeBSD 'install' when (umask & 300) != 0. ;; *) tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 if (umask $mkdir_umask && exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 then if test -z "$dir_arg" || { # Check for POSIX incompatibilities with -m. # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or # other-writeable bit of parent directory when it shouldn't. # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. ls_ld_tmpdir=`ls -ld "$tmpdir"` case $ls_ld_tmpdir in d????-?r-*) different_mode=700;; d????-?--*) different_mode=755;; *) false;; esac && $mkdirprog -m$different_mode -p -- "$tmpdir" && { ls_ld_tmpdir_1=`ls -ld "$tmpdir"` test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" } } then posix_mkdir=: fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations. rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null fi trap '' 0;; esac;; esac if $posix_mkdir && ( umask $mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" ) then : else # The umask is ridiculous, or mkdir does not conform to POSIX, # or it failed possibly due to a race condition. Create the # directory the slow way, step by step, checking for races as we go. case $dstdir in /*) prefix='/';; -*) prefix='./';; *) prefix='';; esac eval "$initialize_posix_glob" oIFS=$IFS IFS=/ $posix_glob set -f set fnord $dstdir shift $posix_glob set +f IFS=$oIFS prefixes= for d do test -z "$d" && continue prefix=$prefix$d if test -d "$prefix"; then prefixes= else if $posix_mkdir; then (umask=$mkdir_umask && $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break # Don't fail if two instances are running concurrently. test -d "$prefix" || exit 1 else case $prefix in *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; *) qprefix=$prefix;; esac prefixes="$prefixes '$qprefix'" fi fi prefix=$prefix/ done if test -n "$prefixes"; then # Don't fail if two instances are running concurrently. (umask $mkdir_umask && eval "\$doit_exec \$mkdirprog $prefixes") || test -d "$dstdir" || exit 1 obsolete_mkdir_used=true fi fi fi if test -n "$dir_arg"; then { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 else # Make a couple of temp file names in the proper directory. dsttmp=$dstdir/_inst.$$_ rmtmp=$dstdir/_rm.$$_ # Trap to clean up those temp files at exit. trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $cpprog $src $dsttmp" command. # { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && # If -C, don't bother to copy if it wouldn't change the file. if $copy_on_change && old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && eval "$initialize_posix_glob" && $posix_glob set -f && set X $old && old=:$2:$4:$5:$6 && set X $new && new=:$2:$4:$5:$6 && $posix_glob set +f && test "$old" = "$new" && $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 then rm -f "$dsttmp" else # Rename the file to the real destination. $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || # The rename failed, perhaps because mv can't rename something else # to itself, or perhaps because mv is so ancient that it does not # support -f. { # Now remove or move aside any old file at destination location. # We try this two ways since rm can't unlink itself on some # systems and the destination file might be busy for other # reasons. In this case, the final cleanup might fail but the new # file should still install successfully. { test ! -f "$dst" || $doit $rmcmd -f "$dst" 2>/dev/null || { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } } || { echo "$0: cannot unlink or rename $dst" >&2 (exit 1); exit 1 } } && # Now rename the file to the real destination. $doit $mvcmd "$dsttmp" "$dst" } fi || exit 1 trap '' 0 fi done # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: forked-daapd-0.19gcd/missing0000755000175000017500000002623311633141304015401 0ustar julienjulien#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2009-04-28.21; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; tar*) if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then exit 1 fi ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG="\${$#}" case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; tar*) shift # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar "$@" && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar "$@" && exit 0 fi firstarg="$1" if shift; then case $firstarg in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" "$@" && exit 0 ;; esac case $firstarg in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" "$@" && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: forked-daapd-0.19gcd/depcomp0000755000175000017500000004426711633141304015366 0ustar julienjulien#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2009-04-28.21; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009 Free # Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputing dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u="sed s,\\\\\\\\,/,g" depmode=msvisualcpp fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: forked-daapd-0.19gcd/Makefile.in0000664000175000017500000006777511633141304016071 0ustar julienjulien# Makefile.in generated by automake 1.11.1 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, # Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ compile config.guess config.rpath config.sub depcomp \ install-sh ltmain.sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/m4/blocks.m4 \ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/libunistring.m4 \ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno config.status.lineno mkinstalldirs = $(install_sh) -d CONFIG_HEADER = config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ install-html-recursive install-info-recursive \ install-pdf-recursive install-ps-recursive install-recursive \ installcheck-recursive installdirs-recursive pdf-recursive \ ps-recursive uninstall-recursive am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' man8dir = $(mandir)/man8 am__installdirs = "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(sysconfdir)" NROFF = nroff MANS = $(man_MANS) DATA = $(sysconf_DATA) RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ distclean-recursive maintainer-clean-recursive AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ distdir dist dist-all distcheck ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d "$(distdir)" \ || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr "$(distdir)"; }; } am__relativize = \ dir0=`pwd`; \ sed_first='s,^\([^/]*\)/.*$$,\1,'; \ sed_rest='s,^[^/]*/*,,'; \ sed_last='s,^.*/\([^/]*\)$$,\1,'; \ sed_butlast='s,/*[^/]*$$,,'; \ while test -n "$$dir1"; do \ first=`echo "$$dir1" | sed -e "$$sed_first"`; \ if test "$$first" != "."; then \ if test "$$first" = ".."; then \ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ else \ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ if test "$$first2" = "$$first"; then \ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ else \ dir2="../$$dir2"; \ fi; \ dir0="$$dir0"/"$$first"; \ fi; \ fi; \ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ done; \ reldir="$$dir2" DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ ALSA_CFLAGS = @ALSA_CFLAGS@ ALSA_LIBS = @ALSA_LIBS@ AMTAR = @AMTAR@ ANTLR = @ANTLR@ ANTLR3C_LIBS = @ANTLR3C_LIBS@ AR = @AR@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AVAHI_CFLAGS = @AVAHI_CFLAGS@ AVAHI_LIBS = @AVAHI_LIBS@ AWK = @AWK@ CBLOCKS_FLAGS = @CBLOCKS_FLAGS@ CBLOCKS_LIBS = @CBLOCKS_LIBS@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFUSE_CFLAGS = @CONFUSE_CFLAGS@ CONFUSE_LIBS = @CONFUSE_LIBS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ DLLTOOL = @DLLTOOL@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ FLAC_CFLAGS = @FLAC_CFLAGS@ FLAC_LIBS = @FLAC_LIBS@ GPERF = @GPERF@ GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@ GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@ GPG_ERROR_LIBS = @GPG_ERROR_LIBS@ GREP = @GREP@ HAVE_LIBUNISTRING = @HAVE_LIBUNISTRING@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBAVL_LIBS = @LIBAVL_LIBS@ LIBAV_CFLAGS = @LIBAV_CFLAGS@ LIBAV_LIBS = @LIBAV_LIBS@ LIBDISPATCH_LIBS = @LIBDISPATCH_LIBS@ LIBGCRYPT_CFLAGS = @LIBGCRYPT_CFLAGS@ LIBGCRYPT_CONFIG = @LIBGCRYPT_CONFIG@ LIBGCRYPT_LIBS = @LIBGCRYPT_LIBS@ LIBICONV = @LIBICONV@ LIBOBJS = @LIBOBJS@ LIBPLIST_CFLAGS = @LIBPLIST_CFLAGS@ LIBPLIST_LIBS = @LIBPLIST_LIBS@ LIBS = @LIBS@ LIBTOOL = @LIBTOOL@ LIBUNISTRING = @LIBUNISTRING@ LIBUNISTRING_PREFIX = @LIBUNISTRING_PREFIX@ LIPO = @LIPO@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBOBJS = @LTLIBOBJS@ LTLIBUNISTRING = @LTLIBUNISTRING@ MAKEINFO = @MAKEINFO@ MANIFEST_TOOL = @MANIFEST_TOOL@ MINIXML_CFLAGS = @MINIXML_CFLAGS@ MINIXML_LIBS = @MINIXML_LIBS@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OSS4CPPFLAGS = @OSS4CPPFLAGS@ OTOOL = @OTOOL@ OTOOL64 = @OTOOL64@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ RANLIB = @RANLIB@ SED = @SED@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ SQLITE3_CFLAGS = @SQLITE3_CFLAGS@ SQLITE3_LIBS = @SQLITE3_LIBS@ STRIP = @STRIP@ TAGLIB_CFLAGS = @TAGLIB_CFLAGS@ TAGLIB_LIBS = @TAGLIB_LIBS@ TRE_CFLAGS = @TRE_CFLAGS@ TRE_LIBS = @TRE_LIBS@ VERSION = @VERSION@ ZLIB_CFLAGS = @ZLIB_CFLAGS@ ZLIB_LIBS = @ZLIB_LIBS@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_AR = @ac_ct_AR@ ac_ct_CC = @ac_ct_CC@ ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ ACLOCAL_AMFLAGS = -I m4 sysconf_DATA = forked-daapd.conf EXTRA_DIST = configure SUBDIRS = sqlext src man_MANS = forked-daapd.8 all: config.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) $(am__cd) $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) $(am__aclocal_m4_deps): config.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status config.h $(srcdir)/config.h.in: $(am__configure_deps) ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f config.h stamp-h1 mostlyclean-libtool: -rm -f *.lo clean-libtool: -rm -rf .libs _libs distclean-libtool: -rm -f libtool config.lt install-man8: $(man_MANS) @$(NORMAL_INSTALL) test -z "$(man8dir)" || $(MKDIR_P) "$(DESTDIR)$(man8dir)" @list=''; test -n "$(man8dir)" || exit 0; \ { for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.8[a-z]*$$/p'; \ } | while read p; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; echo "$$p"; \ done | \ sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ sed 'N;N;s,\n, ,g' | { \ list=; while read file base inst; do \ if test "$$base" = "$$inst"; then list="$$list $$file"; else \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man8dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man8dir)/$$inst" || exit $$?; \ fi; \ done; \ for i in $$list; do echo "$$i"; done | $(am__base_list) | \ while read files; do \ test -z "$$files" || { \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man8dir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(man8dir)" || exit $$?; }; \ done; } uninstall-man8: @$(NORMAL_UNINSTALL) @list=''; test -n "$(man8dir)" || exit 0; \ files=`{ for i in $$list; do echo "$$i"; done; \ l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ sed -n '/\.8[a-z]*$$/p'; \ } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^8][0-9a-z]*$$,8,;x' \ -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ test -z "$$files" || { \ echo " ( cd '$(DESTDIR)$(man8dir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(man8dir)" && rm -f $$files; } install-sysconfDATA: $(sysconf_DATA) @$(NORMAL_INSTALL) test -z "$(sysconfdir)" || $(MKDIR_P) "$(DESTDIR)$(sysconfdir)" @list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(sysconfdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(sysconfdir)" || exit $$?; \ done uninstall-sysconfDATA: @$(NORMAL_UNINSTALL) @list='$(sysconf_DATA)'; test -n "$(sysconfdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ test -n "$$files" || exit 0; \ echo " ( cd '$(DESTDIR)$(sysconfdir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(sysconfdir)" && rm -f $$files # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ 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; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" $(RECURSIVE_CLEAN_TARGETS): @fail= failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @list='$(MANS)'; if test -n "$$list"; then \ list=`for p in $$list; do \ if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ if test -n "$$list" && \ grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ echo " typically \`make maintainer-clean' will remove them" >&2; \ exit 1; \ else :; fi; \ else :; fi $(am__remove_distdir) test -d "$(distdir)" || mkdir "$(distdir)" @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(MKDIR_P) "$(distdir)/$$subdir" \ || exit 1; \ fi; \ done @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ $(am__relativize); \ new_distdir=$$reldir; \ dir1=$$subdir; dir2="$(top_distdir)"; \ $(am__relativize); \ new_top_distdir=$$reldir; \ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ ($(am__cd) $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$new_top_distdir" \ distdir="$$new_distdir" \ am__remove_distdir=: \ am__skip_length_check=: \ am__skip_mode_fix=: \ distdir) \ || exit 1; \ fi; \ done -test -n "$(am__skip_mode_fix)" \ || find "$(distdir)" -type d ! -perm -755 \ -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r "$(distdir)" dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-lzma: distdir tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma $(am__remove_distdir) dist-xz: distdir tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.lzma*) \ lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ *.tar.xz*) \ xz -dc $(distdir).tar.xz | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) test -d $(distdir)/_build || exit 0; \ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && am__cwd=`pwd` \ && $(am__cd) $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ && cd "$$am__cwd" \ || exit 1 $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' distuninstallcheck: @$(am__cd) '$(distuninstallcheck_dir)' \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(MANS) $(DATA) config.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(man8dir)" "$(DESTDIR)$(sysconfdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-generic clean-libtool mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -f Makefile distclean-am: clean-am distclean-generic distclean-hdr \ distclean-libtool distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive html-am: info: info-recursive info-am: install-data-am: install-man @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-dvi: install-dvi-recursive install-dvi-am: install-exec-am: install-sysconfDATA install-html: install-html-recursive install-html-am: install-info: install-info-recursive install-info-am: install-man: install-man8 install-pdf: install-pdf-recursive install-pdf-am: install-ps: install-ps-recursive install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-generic mostlyclean-libtool pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-man uninstall-sysconfDATA uninstall-man: uninstall-man8 .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ ctags-recursive install-am install-data-am install-strip \ tags-recursive .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--refresh check check-am clean clean-generic \ clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \ dist-gzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ distcheck distclean distclean-generic distclean-hdr \ distclean-libtool distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am \ install-data-hook install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-man8 install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ install-sysconfDATA installcheck installcheck-am installdirs \ installdirs-am maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \ ps ps-am tags tags-recursive uninstall uninstall-am \ uninstall-man uninstall-man8 uninstall-sysconfDATA install-data-hook: $(MKDIR_P) $(DESTDIR)$(localstatedir)/cache/forked-daapd # 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: